akhauriyash/Code-Regression huggingface dataset:
import java.util.Scanner;

public class Main {
	
	static int n;
	static int a[];
	static int count=0;
	static int m;
	static int g[];
	
	static void insertionSort(int a[],int n,int g) {
		for(int i=g;i<n;i++) {
			int v = a[i];
			int j = i-g;
			while(j>=0 && a[j]>v) {
				a[j+g] = a[j];
				j -= g;
				count++;
			}
			a[j+g] = v;
		}
	}
	
	static void shellSort(int a[],int n) {
		m = 0;
		int t = 1;
		while(t<=n) {
			m++;
			t = 3*t+1;
		}
		g = new int[m];
		g[0] = 1;
		for(int i=1;i<m;i++) {
			g[i] = 3*g[i-1]+1;
		}
		for(int i=0;i<m/2;i++) {
			int temp = g[i];
			g[i] = g[m-1-i];
			g[m-1-i] = temp;
		}
		for(int i=0;i<m;i++) {
			insertionSort(a,n,g[i]);
		}
	}
	
	 public static void main(String[] args) {
		 Scanner sc = new Scanner(System.in);
		 n = sc.nextInt();
		 a = new int[n];
		 for(int i=0;i<n;i++) {
			 a[i] = sc.nextInt();
		 }
		 shellSort(a,n);
		 System.out.println(m);
		 System.out.print(g[0]);
		 for(int i=1;i<m;i++) {
			 System.out.printf( " %d",g[i]);
		 }
		 System.out.println();
		 System.out.println(count);
		 for(int i=0;i<n;i++) {
			 System.out.println(a[i]);
		 }
	 }	  
}


Measured memory_bytes: 323260
n=int(input())
if n<10: #1-9
  print(n)
elif 10<=n<100: #10-99
  print(9)
elif 100<=n<1000: #100-999
  print(n-90)
elif 1000<=n<10000: #1000-9999
  print(909)
elif 10000<=n<100000: #10000-99999
  print(n-9090)
elif n==100000:
  print(90909)

Measured memory_bytes: 3060
/*
	*#*#*#* Author GaryMr *#*#*#*
########################################################################
	是否可以简化问题：
	抓住数据范围哪里小
	dfs or bfs
	是否可以化具体为抽象
	字符串问题是否可以用数学模拟递归过程（取c[i]或不取来算结果）
	二分？左闭右开？
	long long？
	逆向思维？
	dp？
	贪心？
	树的直径:随便找一点再走到它最远的点A，再从A最远的点走到最远B的点。AB就是树的直径
	匹配括号 左减右>=0
	字符串赋值字符加单引号
	double> printf("%lf")输出小数点6位，%.16lf输出后十六位
	多组数据清空？
	dp优化用g？
	线段树：大小为n的8倍
	线段树：左闭右开！
	线段树：find： if(l>=b||r<=a) return 0x3f3f3f3f; if(r<=b&&l>=a) return tree[k];
	线段树：满二叉树 
	循环跳出条件 
	代数设出每个值寻找关系？
	优先队列：priority_queue<类型> q;   
	priority_queue<类,vector<类>, less<类> > pq1; 　　　 // 使用递减	
	priority_queue<类，vector<类>, greater<类> > pq2; 　　// 使用递增
	判断括号，判断是否长度为偶数
	1<<ceil(log2(double(n)))
*/
#include<bits/stdc++.h>
#define rb(a,b,c) for(int a=b;a<=c;a++)
#define rl(a,b,c) for(int a=b;a>=c;a--)
#define niv vector<int>
#define LL long long
#define IT iterator
#define FIR first
#define SEC second
using namespace std;
const int MAX=0x3f3f3f3f;
const int MOD=1e9+7;
typedef pair<int,int> mp;
typedef pair<mp,mp> superpair;
LL h,w,a[1001][1001],dp[1001][1001];
int main(){
	dp[1][1]=1;
	scanf("%lld %lld",&h,&w);getchar();
	rb(i,1,h)
	rb(j,1,w){
		char tmp;
		tmp=getchar();
		if(j==w) getchar();
		a[i][j]=bool(tmp=='.');
		dp[i][j]+=dp[i-1][j]*a[i-1][j]+dp[i][j-1]*a[i][j-1];
		dp[i][j]%=MOD;
	}
	printf("%lld\n",dp[h][w]);
	return 0;
}

Measured memory_bytes: 15872
import java.io.IOException;
import java.io.InputStream;
import java.util.NoSuchElementException;
 
public class Main {
	private static FastScanner sc = new FastScanner();
	
	public static void main(String[] args) {
		int N = sc.nextInt();
		int M = sc.nextInt();
		int K = sc.nextInt();
		
		for(int i=0; i<=N; i++) {
			for(int j=0; j<=M; j++) {
				int temp = j*(N-i) + i*(M-j);
				if(temp == K) {
					System.out.println("Yes");
					return;
				}
			}
		}
		System.out.println("No");
	}
	
	static class FastScanner {
        private final InputStream in = System.in;
        private final byte[] buffer = new byte[1024];
        private int ptr = 0;
        private int buflen = 0;
        private boolean hasNextByte() {
            if(ptr < buflen) {
                return true;
            } else {
                ptr = 0;
                try {
                    buflen = in.read(buffer);
                } catch(IOException e) {
                    e.printStackTrace();
                }
                if(buflen <= 0) {
                    return false;
                }
            }
            return true;
        }
        private int readByte() { if (hasNextByte()) return buffer[ptr++]; else return -1;}
        private static boolean isPrintableChar(int c) { return 33 <= c && c <= 126;}
        private void skipUnprintable() { while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++;}
        public boolean hasNext() { skipUnprintable(); return hasNextByte();}
        public String next() {
            if (!hasNext()) throw new NoSuchElementException();
            StringBuilder sb = new StringBuilder();
            int b = readByte();
            while(isPrintableChar(b)) {
                sb.appendCodePoint(b);
                b = readByte();
            }
            return sb.toString();
        }
        public long nextLong() {
            return Long.parseLong(next());
        }
        public int nextInt(){
            return Integer.parseInt(next());
        }
        public double nextDouble(){
            return Double.parseDouble(next());
        }
    }
}


Measured memory_bytes: 22996
N = int(input())
a = list(map(int, input().split()))
c = 0
bool = True

while (bool):
    for i in range(N):
        if a[i] % 2 == 0:
            a[i] = a[i] // 2
        else:
            bool = False
            print(c)
            break    
    else:
        c += 1

Measured memory_bytes: 3060
#include <cstdio>
#include <algorithm>
#include <vector>
using namespace std;

int n,dp[100005],a[100005]; 
int main(){
	scanf("%d",&n);
	for (int i=1;i<=n;i++){
		scanf("%d",&a[i]);
	}
	for (int i=2;i<=n;i++){
		dp[i]=dp[i-1]+abs(a[i]-a[i-1]);
		if (i > 2)
		dp[i]=min(dp[i],dp[i-2]+abs(a[i]-a[i-2]));
	}
	printf("%d\n",dp[n]);
	return 0;
} 

Measured memory_bytes: 896
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
typedef long double ld;
const int INF = 1e9; 

int n;
vector<int> a, dp, ans;
vector<pair<int, int>> st;

void dfs(vector<vector<int>> &G, int v, int pre)
{
  auto itr = lower_bound(ALL(dp), a[v]);
  st.emplace_back(itr - dp.begin(), *itr);
  *itr = a[v];
  ans[v] = int(lower_bound(ALL(dp), INF) - dp.begin()) - 1;

  for(auto nv: G[v]){
    if(nv==pre) continue;
    dfs(G, nv, v);
  }

  pair<int, int> p = st.back();
  st.pop_back();
  dp[p.first] = p.second;
}

int main()
{
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  cin >> n;
  a.resize(n);
  REP(i,n) cin >> a[i];
  vector<vector<int>> G(n);
  REP(i,n-1){
    int u,v;
    cin >> u >> v;
    u--,v--;
    G[u].push_back(v);
    G[v].push_back(u);
  }

  dp.assign(n+1, INF);
  dp[0] = -INF;
  ans.resize(n);
  dfs(G, 0, -1);
  REP(i,n) cout << ans[i] << '\n';
  return 0;
}


Measured memory_bytes: 32248
#include "bits/stdc++.h"
using namespace std;
using ll = long long;

int main(){
    ll n;
    ll ans = -1;
    cin >> n;
    vector<pair<ll, ll> > v(n);
    for(int i = 0; i < n; i++){
        int a;
        cin >> a;
        v[i] = make_pair(a, i);
    }
    sort(v.rbegin(), v.rend());
    ll dp[n+1][n+1];
    dp[0][0] = 0;
    for(ll i = 0; i < n; i++){
        dp[i+1][0] = dp[i][0] + v[i].first * abs(v[i].second - i);
        dp[0][i+1] = dp[0][i] + v[i].first * abs(n-1-i - v[i].second);
    }
    for(ll i = 1; i < n; i++){
        for(ll j = 1; j < n; j++){
            if(i + j > n) continue;
            dp[i][j] = max(dp[i-1][j] + v[i+j-1].first * abs(v[i+j-1].second - i + 1), dp[i][j-1] + v[i+j-1].first * abs(n-1-j+1-v[i+j-1].second));

        }
    }
    for(int i = 0; i <= n; i++){
        ans = max(ans, dp[i][n-i]);
    }
    cout << ans << endl;
}

Measured memory_bytes: 26328
#include "bits/stdc++.h"
using namespace std;
bool is_prime[100000];
int main() {
	memset(is_prime,-1,sizeof(is_prime));
	for(int i=2;i*i<100000;i++) {
		if(!is_prime[i]) continue;
		for(int j=i*2;j<100000;j+=i) {
			is_prime[j]=0;
		}
	}
	int m,a,b;
	while(scanf("%d %d %d",&m,&a,&b),m) {
		int ans=0;
		int P,Q;
		for(int p=2;p*p<=m;p++) {
			if(!is_prime[p]) continue;
			for(int q=p;p*q<=m;q++) {
				if(!is_prime[q]) continue;
				if(b*p-a*q>=0) {
					if(ans<p*q) {
						ans=p*q;
						P=p,Q=q;
					}
				}
			}
		}
		printf("%d %d\n",P,Q);
	}
}

Measured memory_bytes: 3204
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <numeric>
#include <string>
#include <cstdio>
#include <cstring>
#include <queue>
#include <stack>
#include <set>
#include <cmath>
#include <bitset>
#include <iomanip> 

using ll = long long;
using ull = unsigned long long;
using namespace std;

#define FALSE printf("false\n");
#define TRUE printf("true\n");
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int i = 0;(i) < ((int)(n));++(i))
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() )
#define test(a) cout<<"line:"<<__LINE__<<"["<<(#a)<<": "<<(a)<<"]"<<endl

const int INF = 1e9+7;
const ll INFL = 9*1e18;

// const int dx[4] = { 1, 0, -1, 0 };
// const int dy[4] = { 0, 1, 0, -1 };

const int dx[8] = {1, 1, 0,-1,-1,-1, 0, 1};
const int dy[8] = {0, 1, 1, 1, 0,-1,-1,-1};

ll inline digit(ll num){int tmp = 0;while(num){tmp++;num/=10;}return tmp;} // 桁数
template<typename T>inline void print(T&& x){cout<<x<<endl;}// 改行付き出力
template<typename T>inline T SUM(vector<T> vec){return accumulate(all(vec),(T)0);} // vectorの中身を全部足す
template<typename T>inline T digitSum(T num){T sum = 0;while(num){sum+=num%10;num/=10;}return sum;} // 各桁の和
template<typename T>inline T gcd(T a,T b){if(b == 0)return a;return gcd(b,a%b);} // 最大公約数
template<typename T>inline T lcm(T a, T b){T g = gcd(a,b);return a/g*b;} // 最小公倍数
template<typename T>inline T power(T a,T b){T tmp=1;rep(i,b){tmp*=a;}return tmp;} // 累乗
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
int ctoi(char c){return c-'0';}


// TODO: write
int main() {
  int n,x;cin>>n>>x;
  vector<int> a(n);rep(i,n)cin>>a[i];
  ll ans = 0;
  rep(i,n){
    ans += max(0,a[i] - x);
    chmin(a[i],x);
  }
  rep(i,n-1){
    int dif = a[i] + a[i+1] - x;
    if(dif > 0){
      int minus = min(a[i+1],dif);
      a[i+1] -= minus;
      dif -= minus;
      ans += minus;
      if(dif > 0){
        minus = dif;
        a[i] -= minus;
        ans += minus;
      }
    }
  }
  print(ans);
  return 0;
}

Measured memory_bytes: 3796
D = gets.to_i
if D % 9 != 0
    puts 0
    exit
end

def rec(index, arr, diff)
    if index == arr.length-1
        if arr[-1] == 0
            if diff == 0
                return (index == 0 ? 9 : 10)
            else
                return 0
            end
        else
            if diff % arr[-1] == 0
                d = 10 - diff.abs/arr[-1]
                d -= 1 if index == 0 && diff >= 0
                return d > 0 ? d : 0
            else
                return 0
            end
        end
    end
    ret = 0
    n0 = diff/arr[index]
    [n0, n0+1].each do |n|
        d = 10 - n.abs
        d -= 1 if index == 0 && n >= 0
        next unless d >= 0
        ret += d * rec(index+1, arr, diff - n*arr[index])
    end
    ret
end

ans = 0
(2..18).each do |digit|
    arr = []
    ((digit+1)/2).times do |i|
        arr[i] = 10**(digit-i-1) - 10**i
    end
    ans += rec(0, arr, D)
end
p ans

Measured memory_bytes: 3836
import java.util.*;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
public class Main {

	public static void main(String[] args) {
		Scanner cin=new Scanner(System.in);
		Stack<Integer>stk=new Stack<>();
		
		while(cin.hasNext()) {
			String obj=cin.next();
			
			Pattern p=Pattern.compile("^[0-9]*$");
			Matcher m=p.matcher(obj);
			if(m.find()) {
				stk.push(Integer.valueOf(obj));
			}
			else {
				if(obj.equals("+")) {
					int sum=0;
					for(int i=0;i<2;i++) {
						sum+=stk.peek();
						stk.pop();
					}
					stk.push(sum);
				}
				else if(obj.equals("-")) {
					int sum=stk.peek();stk.pop();
					sum=stk.peek()-sum;stk.pop();
					stk.push(sum);
				}
				else if(obj.equals("*")) {
					int sum=1;
					for(int i=0;i<2;i++) {
						sum*=stk.peek();
						stk.pop();
					}
					stk.push(sum);
				}
			}
			
		}
		System.out.println(stk.peek());
		
	}

}



Measured memory_bytes: 27156
from bisect import bisect_left

n = int(input())
l = list( map(int, input().split())) 
ans = 0
l.sort()

for i in range(n-2):
    shortest = l[i]
    for j in range(i+1, n-1):
        second = l[j]
        # このスライスしたやつと地味にTLEになる...
        # k = bisect_left(l[j], shortest + second)
        # ans += k

        k = bisect_left(l, shortest + second)
        ans += k - j - 1

print(ans)

Measured memory_bytes: 3188
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <map>
#include <list>
#include <cmath>

typedef unsigned long long ull;
typedef long long ll;

using namespace std;

int main(void) {

    ll X;
    cin >> X;

    vector<ll> beki;
    beki.push_back(1);

    ll ans = 1;
    for(int i = 2; i < ceil(sqrt(X)); ++i) {
        ll x = i * i;
        while(x * i <= X) {
            x *= i;
        }

        ans = max(ans, x);
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cmath>
using namespace std;

double getDistance( int x, int y )
{
    double X = x * x, Y = y * y;
    return sqrt( X + Y );
}

int main( void )
{
    int n;
    cin >> n;

    for ( int i = 0; i < n; i++ )
    {
        int x = 0, y = 0;
        int dx, dy;
        int ax = 0, ay = 0;
        double maxd = 0.0;
        while ( cin >> dx >> dy && ( dx != 0 || dy != 0 ) ) {
            x += dx;
            y += dy;
            double d = getDistance( x, y );
            if ( d > maxd ) {
                ax = x;
                ay = y;
                maxd = d;
            } else if ( fabs( d - maxd ) < 1e-9 && x > ax ) {
                ax = x;
                ay = y;
            }
        }
        cout << ax << " " << ay << endl;
    }

    return 0;
}

Measured memory_bytes: 0
#include<iostream>
using namespace std;
int a, b, c, d;
bool k;

int main()
{
	cin >> a >> b >> c >> d;
	while(1)
	{
		if(k == 1)
		{
			a -= d;
			if(a <= 0)
				break;
		}
		if(k == 0)
		{
			c -= b;
			if (c <= 0)
				break;
		}
		if(k == 1)
        	k = 0;
      	else
          	k = 1;
	}
	if(k == 1)
	{
		cout << "No";
		return 0;
	}
	cout << "Yes";
	return 0;
}


Measured memory_bytes: 3672
#include<bits/stdc++.h>
using namespace std;

#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 
  
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> 
 
#define FS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ll long long int
#define ld long double
#define pb push_back
#define bp __builtin_popcount
#define sz size()
#define ff first
#define ss second
#define vll vector<ll>
#define vbool vector<bool>
#define vpll vector<pair<ll,ll>>
#define pll pair<ll,ll>
#define vllv vector<vector<ll>>
#define setpri(x) cout<<setprecision(x)<<fixed;
#define all(v) v.begin(),v.end()
#define allr(v) v.rbegin(),v.rend()
#define yesr {cout<<"YES"<<endl;return;}
#define nor {cout<<"NO"<<endl;return;}
// getline (std::cin,name);
ll MOD=1e9+7;
ll ceil1(ll n,ll x){if(n%x==0)return n/x; else return (n/x)+1;}
ll gcd(ll a,ll b){return __gcd(a,b);}
ll lcm(ll a,ll b){return (max(a,b)/gcd(a,b))*min(a,b);}
ll pow1(ll n,ll k,ll mm){
    if(k==0)return 1;
    if(k%2==0)return (pow1((n%mm)*(n%mm),k/2,mm))%mm;
    	return ((n%mm)*(pow1((n%mm)*(n%mm),k/2,mm)%mm))%mm;
}
ll pow2(ll n,ll k){ll ans=1;
    while(k>0){
        if(k%2==1)ans=ans*n;n=n*n;k/=2;
    }return ans;
}
ll modinv(ll n,ll mod){
    return pow1(n,mod-2,mod);
}
bool func(pair<ll,ll> &a,pair<ll,ll> &b ){
    if(a.ff != b.ff)return a.ff < b.ff;
    return a.ss > b.ss;
}
ll store;
void dfs(vllv &v,vbool &vis,vll &level,ll k,ll l){
	vis[k]=true;
	level[k]=l;
	for(auto x:v[k]){
		if(!vis[x]){
			dfs(v,vis,level,x,l+1);
		}
		else store=x;
	}
}
void solve(){
	
    ll i,j,k,l,n,m,x,y,z,r;
	
	cin>>n>>k;
	vllv v(n+11);
	for(i=1;i<=n;i++){
		cin>>x;
		v[i].pb(x);
		// v[x].pb(i);
	}
	vll level(n+11);
	vbool vis(n+11);
	store=0;
	dfs(v,vis,level,1,0);
	m=1;
	for(i=1;i<=n;i++){
		m=max(m,level[i]+1);
		// cout<<level[i]<<" ";
	}
	if(store){
		if(k<=level[store]){
			for(i=1;i<=n;i++){
				if(level[i]==k){
					cout<<i<<endl;
					return;
				}
			}
		}
		
		ll tt=k-level[store];
		tt%=(m-level[store]);
		tt+=level[store];
		// cout<<tt<<endl;
		for(i=1;i<=n;i++){
				if(level[i]==tt){
					cout<<i<<endl;
					return;
				}
			}
		return;
	}
	
	level[1]=m;
	k%=m;
	// cout<<m<<endl;
	// cout<<k<<endl;
	if(k==0)k=m;
	// cout<<k<<endl;
	for(i=1;i<=n;i++){
		// cout<<level[i]<<" ";
		if(level[i]==k){
			// cout<<"kkk";
			cout<<i<<endl;
			return;
		}
	}
	
}
int main(){
    FS;
    ll i,j,k,n,m,x,y,z,q;
    q=1;
    // cin>>q;
    while(q--){
        solve();
    }
    return 0;
}

Measured memory_bytes: 28000
import sys
sys.setrecursionlimit(10**7)


def rootedTree(node,parent,root,num):
    A.append([node,parent,root,num])
    for root_num,num in root:
            rootedTree(root_num,node,tree[root_num],num)


n=int(input())
AB=[list(map(int,input().split()))+[i+1] for i in range(n-1)]
A=[]
tree=[[] for i in range(n+1)]
for a,b,c in AB:
    tree[a] +=[[b,c]]

rootedTree(1,0,tree[1],0)
ans=[0]*n
for node,parent,root,num in A:
    flag=0
    for i,j in enumerate(root):
        if ans[num]==i+1:flag=1
        ans[j[1]]=i+1+flag

print(max(ans))
for i in range(1,n):print(ans[i])

Measured memory_bytes: 86748
#include<stdio.h>

int main(){
  int o,n,k,i,j;
  int key;
  int A[110];
  scanf("%d",&n);
  for(i=1;i<=n;i++)scanf("%d",&A[i]);

  /*for(o=1;o<=n;o++)
    {
      if(o == n){printf("%d\n",A[o]);}
      else printf("%d ",A[o]);
    }
  */
  for(j=1;j<=n;j++)
    {   
	      key = A[j];		
	      i = j-1;
	      while(i>0 && A[i]>key)
		{
		  A[i+1]=A[i];  
		  i = i-1;
		}
	      A[i+1] = key;
	      for(k=1;k<=n;k++){
		if(k == n)printf("%d\n",A[k]);
		else printf("%d ",A[k]);
	      }
    }
  
  return 0;
}



Measured memory_bytes: 2048
#include <iostream>
#include <string>
#include <math.h>
#include <algorithm>
#include <vector>
#include <set>
using namespace std;

typedef long long ll;
#define rep(i, n) for(int i = 0; i < n; i++)

int main(){
    int N;
    ll x;
    cin >> N >> x;
    ll a[N];
    ll a_sum = 0;
    rep(i, N){
        cin >> a[i];
        a_sum += a[i];
    }
    if(a_sum == x){
        cout << N << endl;
        return 0;
    }

    sort(a, a + N);
    ll rest = x;
    int count = 0; //満足してくれた人数
    rep(i, N-1){
        rest -= a[i];
        if(rest >= 0){
            count++;
        }else{
            break;
        }
    }

    cout << count << endl;

    return 0;
}

Measured memory_bytes: 256
import math
for _ in range(int(input())):
    x1, y1, x2, y2, x3, y3 = map(float, input().split())
    p = ((y1-y3)*(y1**2 -y2**2 +x1**2 -x2**2) -(y1-y2)*(y1**2 -y3**2 +x1**2 -x3**2)) / 2/ ((y1-y3)*(x1-x2)-(y1-y2)*(x1-x3))
    q = ((x1-x3)*(x1**2 -x2**2 +y1**2 -y2**2) -(x1-x2)*(x1**2 -x3**2 +y1**2 -y3**2)) / 2/ ((x1-x3)*(y1-y2)-(x1-x2)*(y1-y3))
    r = math.sqrt((x1 - p) ** 2 + (y1 - q) ** 2)
    print("{:.3f} {:.3f} {:.3f}".format(p, q, r))



Measured memory_bytes: 5684
#include <iostream>    
  using namespace std;    
      
  int main()    
  {    
          int a, b;    
          cin >> a >> b;    
          int c = a * b;    
          if(c % 2 == 0){    
                  cout << "Even" << endl;    
          }    
          else{    
                  cout << "Odd" << endl;    
          }    
  }    


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main()
{
    int n;
    cin>>n;
    
    long int arr[n];
    
    for(int i=0;i<n;i++)
    {
        cin>>arr[i];
    }
    
    //start from last and compare
    
     long int cnt=0,max=0;
    for(int i=1;i<n;i++)
    {
        if(arr[i]<=arr[i-1])
        cnt+=1;
        
        if(cnt>max)
        max=cnt;
        
        if(arr[i]>arr[i-1])
        cnt=0;
    }
    
    
    cout<<max<<endl;
    
    return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <string>
#include <vector>
#include <math.h>
#include <algorithm>
#include <stdint.h>
#include <queue>
#include <bitset>
#include <iomanip>
#define PI (3.14159265358979323846)
#define INF (1e+9)
#define DIV_NUM (1000000007)

using namespace std;

int main()
{

	/*--------------------------------*/
		/* 数字宣言と入力*/
	int n, tmpX;

	cin >> n;


	tmpX = n / 2 + n % 2;

	/*---------------------------------*/
		/* 出力 */
	cout << tmpX << endl;


	/*----------------------------------*/
	return 0;
}


Measured memory_bytes: 256
/*..............................................*\
Author:Kishor Kumar Paroi
Dept:CSE-1703053
RUET,BANGLADESH
\*---------------------------*/
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cctype>
#include <cmath>
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <string>
#include <fstream>
#include <sstream>
#include <map>
#include <vector>
#include <stack>
#include <queue>
#include<bits/stdc++.h>
#include<iostream>
#include<iterator>

#define max(a,b) ((a>b)?a:b)                        //finding max
#define min(a,b) ((a<b)?a:b)                        //finding min
#define Max(a,b,c) max(a,max(b,c))                  //finding max between 3 numbers
#define Min(a,b,c) min(a,min(b,c))                  //finding min between 3 numbers
#define Pi acos(-1.0)                               //defining Pi for mathematical uses
#define Clear(a) memset(a,0,sizeof(a))              //clearing memory of an array
#define setfalse(a) memset(a,false,sizeof(a))       //setting the array into false
#define settrue(a) memset(a,true,sizeof(a))         //setting the array into true
#define clrstr(a) memset(a,'\0',sizeof(a))          //setting string array to null
#define open freopen("input.txt","r",stdin)         //opening input file
#define close freopen ("output.txt","w",stdout)     //opening output file
#define Case(a) printf("Case %d: ",a)               //printing case number
#define caseh(a) printf("Case #%d: ",a)             //printing case number having '#'
#define getcase(a) scanf("%d",&a)                   //scanning case number
#define caseloop(a,b) for(a=1;a<=b;a++)             //making case loop
#define EPS 1e-9                                    //small value for avoiding preccesion error
#define LL long long                                //long long short form
#define fori(i,n) for(int i=1;i<=n;++i)
#define forn(i,n) for(int i=0;i<n;++i)
#define sz(x) int(x.size())
#define error(x) cout<<#x<<" "<<x<<endl
#define IOS  ios::sync_with_stdio(0);cin.tie(0);cout.tie(0)

//const int N=100*1000;
//const int mod=1e9+7;

//# define int min3(int a,int b,int c){return min(a,min(b,c));}
//#define int max3(int a,int b,int c){return max(a,max(b,c));}
//#define int min4(int a,int b,int c,int d){return min(min(a,b),min(c,d));}
//#define int max4(int a,int b,int c,int d){return max(max(a,b),max(c,d));}

using namespace std;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int max=0,n,h=0,cnt=0;
    cin>>n;
    for(int i=0;i<n;i++)
    {
        cin>>h;
        if(h>=max)
        {
            max=h;
            cnt++;
        }
    }
    cout<<cnt <<endl;
    return 0;
}



Measured memory_bytes: 256
from sys import stdin
n = int(stdin.readline().rstrip())
t, a = [int(x) for x in stdin.readline().rstrip().split()]
hs = [int(x) for x in stdin.readline().rstrip().split()]

answers=[t-h*0.006 for h in hs]

answers=[abs(an-a) for an in answers]

print(answers.index(min(answers))+1)

Measured memory_bytes: 3060
#!usr/bin/env python3
from collections import defaultdict, deque
from heapq import heappush, heappop
from itertools import permutations, accumulate
import sys
import math
import bisect
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS():return [list(x) for x in sys.stdin.readline().split()]
def S():
    res = list(sys.stdin.readline())
    if res[-1] == "\n":
        return res[:-1]
    return res
def IR(n):
    return [I() for i in range(n)]
def LIR(n):
    return [LI() for i in range(n)]
def SR(n):
    return [S() for i in range(n)]
def LSR(n):
    return [LS() for i in range(n)]

sys.setrecursionlimit(1000000)
mod = 1000000007

def solve():
    n = I()
    if n == 2:
        print(2)
        print(0)
        print(11)
    elif n == 1:
        print(1)
        print(0)
    else:
        print(n-1)
        for i in range(n-1):
            print("0"+"1"*i+"0")
    return

#Solve
if __name__ == "__main__":
    solve()



Measured memory_bytes: 6084
#include <bits/stdc++.h>
#define REP(i, a, n) for (long long i = (a); i < (long long)(n); ++i)
#define REPC(i, a, n) for (long long i = (a); i <= (long long)(n); ++i)
#define ALL(t) t.begin(), t.end()
#define RALL(t) t.rbegin(), t.rend()
#define MATINIT(type, row, col, init)                                          \
  vector<vector<type>>(row, vector<type>(col, init));
#define Yes(cond) cout << (cond ? "Yes" : "No") << endl;
#define YES(cond) cout << (cond ? "YES" : "NO") << endl;
using namespace std;
using LL = long long;
using ULL = unsigned long long;
template <class T> using VEC = std::vector<T>;
template <class T> using MAT = std::vector<std::vector<T>>;
void DUMP() { cerr << endl; }
template <class Head, class... Tail> void DUMP(Head &&head, Tail &&... tail) {
  cerr << head << ", ";
  DUMP(std::move(tail)...);
}
template <typename T> ostream &operator<<(ostream &os, vector<T> &vec) {
  os << "{";
  for (auto v : vec)
    os << v << ",";
  os << "}";
  return os;
}
template <typename T> ostream &operator<<(ostream &os, set<T> &s) {
  os << "{";
  for (auto p : s)
    os << p << ",";
  os << "}";
  return os;
}
template <typename T1, typename T2>
ostream &operator<<(ostream &os, map<T1, T2> &m) {
  os << "{";
  for (auto p : m)
    os << p << ",";
  os << "}";
  return os;
}
template <typename T1, typename T2>
ostream &operator<<(ostream &os, pair<T1, T2> p) {
  os << "[" << p.first << " " << p.second << "]";
  return os;
}

int main() {
  int A,B;
  cin>>A>>B;
  int ans = 0;
  if(B==1){
    cout<<0<<endl;
    return 0;
  }
  REP(i,1,50){
    // int n = A +(A-1)*(i-1);
    int n = A*i-(i-1);
    // assert(n==m);
    if(n>=B){
      ans=i;
      break;
    }
  }
  cout<<ans<<endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define rep(i, n) FOR(i, 0, n)
#define whole(x) (x).begin(),(x).end()
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())
using P = pair<int, int>;
#define debug(var) cerr << "[" << #var << "] " << var << endl
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
const ll mod = 1000000007;
const int dx[] = {-1,0,1,0};
const int dy[] = {0,-1,0,1};
 
int main()
{
  string s;
  cin >> s;
  for (char& c: s) {
    if (c=='1') c='9';
    else if (c=='9') c = '1';
  }
  cout << s << endl;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int MAXN = 3e5 + 5;
const int n = 31;
typedef long long ll;
template <typename T> void chkmax(T &x, T y) {x = max(x, y); }
template <typename T> void chkmin(T &x, T y) {x = min(x, y); } 
template <typename T> void read(T &x) {
	x = 0; int f = 1;
	char c = getchar();
	for (; !isdigit(c); c = getchar()) if (c == '-') f = -f;
	for (; isdigit(c); c = getchar()) x = x * 10 + c - '0';
	x *= f;
}
struct info {
	char opt;
	int i, j, k;
};
vector <info> ans; int v[MAXN];
int a, b, res, p, q, two[MAXN], zero, cnt;
void check() {
	read(v[0]), read(v[1]);
	for (auto x : ans) {
		if (x.opt == '<') v[x.i] = v[x.j] < v[x.k];
		else v[x.i] = v[x.j] + v[x.k];
	}
	cerr << v[2] << endl;
}
int cmp(int x, int y) {
	ans.push_back((info) {'<', ++cnt, x, y});
	return cnt;
}
int add(int x, int y) {
	ans.push_back((info) {'+', ++cnt, x, y});
	return cnt;
}
int power(int x, int y) {
	if (y == 0) return x;
	else {
		int res = power(x, y - 1);
		return add(res, res);
	}
}
void update(int x, int y, int z) {
	int cur = cmp(two[0], add(x, y));
	cur = power(cur, z);
	ans.push_back((info) {'+', res, res, cur});
}
int getone() {
	int x = cnt + 1;
	ans.push_back((info) {'+', ++cnt, a, b});
	ans.push_back((info) {'<', ++cnt, zero, x});
	return cnt;
}
void work(int flg, int x, int b) {
	int q = ++cnt;
	for (int i = n; i >= 0; i--) {
		int glg = cmp(add(q, two[i]), b);
		update(flg, glg, x + i), q = add(q, power(glg, i));
	}
	int glg = cmp(q, b);
	update(flg, glg, x);
}
int main() {
	a = 0, b = 1, res = 2, zero = cnt = 3;
	two[0] = getone();
	for (int i = 1; i <= n * 2; i++)
		two[i] = add(two[i - 1], two[i - 1]);
	int p = ++cnt;
	for (int i = n; i >= 0; i--) {
		int flg = cmp(add(p, two[i]), a);
		work(flg, i, b), p = add(p, power(flg, i));
	}
	int flg = cmp(p, a);
	work(flg, 0, b);
	cout << ans.size() << endl;
	for (auto x : ans) printf("%c %d %d %d\n", x.opt, x.j, x.k, x.i);
	//check();
	return 0;
}


Measured memory_bytes: 4036
#include <bits/stdc++.h>
//#include <boost/multiprecision/cpp_int.hpp>
//#include <boost/math/common_factor_rt.hpp>
#define USE_MATH_DEFINES
#define rep(i, n) for (int i = 0; i < (n); i++)

using namespace std;
// namespace mp = boost::multiprecision;
// namespace mt = boost::math
// using Bint = mp::cpp_int;

int main() {
    int n, q, c = 0;
    cin >> n;
    int s[n];
    rep(i, n) cin >> s[i];
    cin >> q;
    int t[q];

    rep(i, q) {
        cin >> t[i];
        if (binary_search(&s[0], &s[n], t[i]))
            c++;
    }
    printf("%d\n", c);
}


Measured memory_bytes: 3816
#include <iostream>
#include <algorithm>
using namespace std;
int main(void){
    long long N,K,i,j,n,a;
    cin>>N>>K;
    long long A[N],B[N+1];
    B[0]=0;
    for(i=0;i<N;i++){
        cin>>A[i];
        B[i+1]=(B[i]+A[i]-1)%K;
    }
    if(N>K-1){
        long long p[K];
        for(i=0;i<K;i++){
            p[i]=0;
        }
        a=0;
        for(i=0;i<N+1;i++){
            a+=p[B[i]];
            p[B[i]]++;
            if(i>K-2){
                p[B[i-K+1]]--;
            }
        }
        cout<<a<<endl;
        return 0;
    }
    sort(B,B+N+1);
    a=0;n=1;
    for(i=1;i<N+1;i++){
        if(B[i]==B[i-1]){
            n++;
        }else{
            a+=(n*(n-1))/2;
            n=1;
        }
    }
    a+=(n*(n-1))/2;
    cout<<a<<endl;
}


Measured memory_bytes: 3328
#include <iostream>
using namespace std;
#define ll long long
int mod=1000000007;
 ll arr[1000]={0};
int main()
{
    ll n;
    cin>>n;
    ll x;
   
    for(int i=2;i<=n;i++)
    {
        x=i;
        for(int j=2;j<=x;j++)
        {
            while(x%j==0)
            {
                arr[j]++;
                arr[j]=arr[j]%mod;
                x=x/j;
            }
        }
        if(x!=1)
            arr[x]++;
    }
    ll count1=1;
    for(int i=1;i<=n;i++)
    {
        if(arr[i])
        {
            count1=(count1*((arr[i]+1)%mod))%mod;
        }
    }
    cout<<count1;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <array>
#include <deque>
#include <stack>
#include <queue>
#include <list>
#include <map>
#include <set>
#include <algorithm>
#include <numeric>
#include <utility>
#include <cmath>

using namespace std;
using ll=long long int;

int main() {
    int t, x;
    cin >> t >> x;

    cout << (double)t / x << endl;

    return 0;
}


Measured memory_bytes: 256
N = int(input())
Vanswer = 0
Canswer = 0
V = input().split()
V = [int(x) for x in V]
C = input().split()
C = [int(x) for x in C]
#print(V)
for i in range(N):
  if V[i] > C[i]:
    Vanswer = Vanswer + V[i]
    Canswer = Canswer + C[i]
print(Vanswer - Canswer)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; i++)
using namespace std;

typedef long long ll;

int main() {
    int N;
    ll K;
    cin >> N >> K;
    vector<int> A(N);
    rep(i, N) {
        cin >> A[i];
        A[i]--;
    }
    vector<vector<int>> B(N, vector<int>(60));
    rep(i, N) {
        B[i][0] = A[i];
    }
    rep(i, 59) {
        rep(j, N) {
            B[j][i + 1] = B[B[j][i]][i];
        }
    }
    int ans = 0;
    rep(i, 60) {
        if ((K >> i) & 1) {
                ans = B[ans][i];
        }
    }
    cout << ans + 1 << "\n";
}

Measured memory_bytes: 58700
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep2(i, x, n) for(int i = x; i <= n; i++)
#define rep3(i, x, n) for(int i = x; i >= n; i--)
#define elif else if
typedef long long ll;
typedef pair<ll, ll> P;
const ll MOD = 1e9+7;
const ll MOD2 = 998244353;
const ll INF = 1e18;
string alpha = "abcdefghijklmnopqrstuvwxyz";

int main(){
    int N;
    cin >> N;
    string S[N];
    rep(i, N) cin >> S[i];
    int cnt = 0;
    rep(i, N){
        bool able = true;
        rep(j, N)rep(k, N){
            int p = (j+i)%N, q = (k+i)%N;
            if(S[p][k] != S[q][j]) able = false;
        }
        if(able) cnt++;
    }
    cout << cnt*N << endl;
}


Measured memory_bytes: 384
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int x1 = sc.nextInt();
    int y1 = sc.nextInt();
    int x2 = sc.nextInt();
    int y2 = sc.nextInt();
    int vx = x2 - x1;
    int vy = y2 - y1;

    int vx1 = (-1) * vy;
    int vy1 = vx;
    int vx2 = (-1) * vy1;
    int vy2 = vx1;

    int x3 = x2 + vx1;
    int y3 = y2 + vy1;
    int x4 = x3 + vx2;
    int y4 = y3 + vy2;
    System.out.print(x3);
    System.out.print(" ");
    System.out.print(y3);
    System.out.print(" ");
    System.out.print(x4);
    System.out.print(" ");
    System.out.print(y4);
  }
}

Measured memory_bytes: 23380
#include <stdio.h>

#define N 500
#define M 200000
#define Q 100000

int main() {
	static int ll[M], rr[M], pp[Q], qq[Q], kk[N][N], dp[N][N];
	int n, m, q, i, j, k;

	scanf("%d%d%d", &n, &m, &q);
	for (i = 0; i < m; i++)
		scanf("%d%d", &ll[i], &rr[i]), ll[i]--, rr[i]--, kk[ll[i]][rr[i]]++;
	for (i = 0; i < q; i++)
		scanf("%d%d", &pp[i], &qq[i]), pp[i]--, qq[i]--;
	for (i = 0; i < n; i++) {
		dp[i][i] = kk[i][i];
		for (j = i + 1; j < n; j++) {
			dp[i][j] = dp[i][j - 1];
			for (k = i; k <= j; k++)
				dp[i][j] += kk[k][j];
		}
	}
	for (i = 0; i < q; i++)
		printf("%d\n", dp[pp[i]][qq[i]]);
	return 0;
}


Measured memory_bytes: 5120
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

#define sf scanf
#define pf printf
#define pb push_back
#define mp make_pair
#define PI ( acos(-1.0) )
#define IN freopen("nocross.in","r",stdin)
#define OUT freopen("nocross.out","w",stdout)
#define FOR(i,a,b) for(i=a ; i<=b ; i++)
#define DBG pf("Hi\n")
#define i64 long long int
#define eps (1e-8)
#define xx first
#define yy second
#define LOG 19
#define off 2

#define mod 1000000007LL

using namespace __gnu_pbds;
using namespace std ;

typedef tree< i64, null_type, less< i64 >, rb_tree_tag, tree_order_statistics_node_update> ordered_set;

#define INF 1000000000000000000LL
#define maxn 1000005
#define log 20

vector < pair<int,int> > vp ;
int st[maxn] ;
int Left[maxn] , Right[maxn] ;

int dp[maxn] , sum[maxn] ;

int main()
{
    int n ;

    scanf("%d",&n) ;

    for(int i=1; i<=n ; i++)
    {
        int x , v ;
        scanf("%d %d",&x,&v) ;
        vp.pb( mp(x,v) ) ;
    }

    sort( vp.begin() , vp.end() ) ;

    for(int i=0 ; i<vp.size() ; i++) vp[i].xx = i+1 ;
    for(int i=0 ; i<vp.size() ; i++) swap(vp[i].xx,vp[i].yy) ;

    sort(vp.begin(),vp.end()) ;

    for(int i=0 ; i<vp.size() ; i++) vp[i].xx = i+1 ;
//    for(int i=0 ; i<vp.size() ; i++) swap(vp[i].xx,vp[i].yy) ;


    int mx = 0 ;

    for(int i=0 ; i<vp.size() ; i++)
    {
        mx = max( mx , vp[i].yy ) ;
        Right[ vp[i].yy ] = mx ;
    }

    int mn = n+1 ;

    for(int i=(int)vp.size() - 1 ; i>=0 ; i--)
    {
        mn = min( mn , vp[i].yy ) ;
        Left[ vp[i].yy ] = mn ;
    }

  //  for(int i=1 ; i<=n ; i++) printf("%d %d\n",Left[i],Right[i]) ;

    for(int i=1; i<=n ; i++) st[i] = 0 ;

    for(int i=1; i<=n ; i++)
    {
        st[ Right[i] ] = max( st[Right[i]] , Left[i] ) ;
    }

    mx = 0 ;
    dp[0] = 1 ; sum[0] = 1 ;

    for(int i=1 ; i<=n ; i++)
    {
 //       mx = max( st[i] , mx ) ;
        dp[i] = sum[i-1] ;
        if( mx > 0 ) dp[i] -= sum[mx-1] ;
        dp[i] = (dp[i]%mod + mod)%mod ;
        sum[i] = (sum[i-1]+dp[i])%mod ;
        mx = max(st[i],mx) ;
    }

    int ans = 0 ;
    for(int i=n ; i>=mx ; i--) ans = (ans+dp[i])%mod ;

    printf("%d\n",ans) ;

    return 0 ;
}


Measured memory_bytes: 19056
#include <iostream>
using namespace std;

int main()
{
  int high;
  int temp1,temp2;
  int first=0,second=0,third=0;
  
  for(int i=0;i<10;i++){
    cin>>high;
    if(high>first){
      temp1=first;
      first=high;
      temp2=second;
      second=temp1;
      third=temp2;
    } else if (first>=high && high>second){
      temp2=second;
      second=high;
      third=temp2;
    } else if (second>=high && high>third){
      third=high;
    }
  }

  cout<<first<<endl;
  cout<<second<<endl;
  cout<<third<<endl;
  
  return 0;
}


Measured memory_bytes: 3092
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <map>
#include <queue>
#include <iomanip>
#include <set>
#include <tuple>
#define mkp make_pair
#define mkt make_tuple
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
const ll MOD=1e9+7;
template<class T> void chmin(T &a,const T &b){if(a>b) a=b;}
template<class T> void chmax(T &a,const T &b){if(a<b) a=b;}

#include <functional>

template< typename T, typename S >
struct LazySegmentTree{
    int n;
    vector<T> data;
    vector<S> lazy;
    T te;
    S se;

    inline void merge_functions(S& lazy,S& val){
        lazy+=val;
        //lazy=val;
    }
    inline void operate(T& data,S& val,int len){
        //data+=val*len;
        data+=val;
        //data=val;
    }
    inline T merge_values(T& x,T& y){
        //return x+y;
        return min(x,y);
        //return max(x,y);
    }

    LazySegmentTree(){}
    LazySegmentTree(int sz,T te,S se):te(te),se(se){
        n=1;
        while(n<sz) n*=2;
        data.resize(2*n-1,te);
        lazy.resize(2*n-1,se);
    }

    void build(vector<T> &A){
        for(int k=0;k<int(A.size());k++) data[k+n-1]=A[k];
        for(int k=n-2;k>=0;k--) data[k]=merge_values(data[2*k+1],data[2*k+2]);
    }

    void eval(int k,int l,int r){
        if(lazy[k]==se) return;
        operate(data[k],lazy[k],r-l);
        if(r-l>1){
            merge_functions(lazy[2*k+1],lazy[k]);
            merge_functions(lazy[2*k+2],lazy[k]);
        }
        lazy[k]=se;
    }

    void update(int a,int b,S val,int k=0,int l=0,int r=-1){
        if(r<0) r=n;
        eval(k,l,r);
        if(b<=l||r<=a) return;
        if(a<=l&&r<=b){
            merge_functions(lazy[k],val);
            eval(k,l,r);
        }else{
            update(a,b,val,2*k+1,l,(l+r)/2);
            update(a,b,val,2*k+2,(l+r)/2,r);
            data[k]=merge_values(data[2*k+1],data[2*k+2]);
        }
    }

    T query(int a,int b,int k=0,int l=0,int r=-1){
        if(r<0) r=n;
        eval(k,l,r);
        if(b<=l||r<=a) return te;
        if(a<=l&&r<=b) return data[k];

        T vl=query(a,b,2*k+1,l,(l+r)/2);
        T vr=query(a,b,2*k+2,(l+r)/2,r);
        return merge_values(vl,vr);
    }
};

const ll INF=1e18;

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);

  int N,Q;
  cin>>N>>Q;

  LazySegmentTree<ll,ll> seg(N,INF,0);

  vector<ll> init(N,0);
  seg.build(init);

  for(int q=0;q<Q;q++){
      int t;cin>>t;
      if(t==0){
          int a,b;
          ll x;
          cin>>a>>b>>x;
          seg.update(a,b+1,x);
      }else{
          int a,b;
          cin>>a>>b;
          cout<<seg.query(a,b+1)<<"\n";
      }
  }

  return 0;
}



Measured memory_bytes: 7836
#include <bits/stdc++.h>
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <utility>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define _GLIBCXX_DEBUG
using namespace std;
typedef long long ll;

int main(){
    ll a;
    cin >> a;
    if(a%2) cout << a * 2 << endl;
    else cout << a << endl;
}
   

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <math.h>
using namespace std;

int main() {
    int h,w;
    string s;
    int v[52][52];
    cin >> h >> w;
    for(int i=0;i<h;i++){
        cin >> s;
        for(int j=0;j<w;j++){
            if(s[j]=='#')v[i][j]=1;
            else v[i][j]=0;
        }
    }
    bool flag = false;
    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
            if(v[i][j]==1) {
                if (i - 1 >= 0) {
                    if (v[i - 1][j] == 1)flag = true;
                }
                if (j - 1 >= 0) {
                    if (v[i][j - 1] == 1)flag = true;
                }
                if (i + 1 < h) {
                    if (v[i + 1][j] == 1)flag = true;
                }
                if (j + 1 < w) {
                    if (v[i][j + 1] == 1)flag = true;
                }
                if(!flag){
                    cout << "No" << endl;
                    return 0;
                }
                flag = false;
            }
        }
    }
    cout << "Yes" << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;

int main(){
    long long N,K;
    cin >>N>>K;
    if(K == 1){
        cout <<"0"<<endl;
        return 0;
    }
    else{
        long long x = N % K;
        cout <<min(x,abs(K-x))<<endl;
    }
}

Measured memory_bytes: 256
($D,$G)=glob<>;
$min=1000;
for(0..$D-1){
    ($p,$c)=glob<>;
    $num{$_}->{p}=$p;
    $num{$_}->{c}=$c;
}

for$i(0..2**$D-1){
    @T=split//,(sprintf("%0".$D."b",$i));
    $nos=0;
    $sco=0;
    for(0..$D-1){
        if($T[$_]){
            $nos+=$num{$_}->{p};
            $sco+=$num{$_}->{p}*($_+1)*100+$num{$_}->{c};
        }else{
            $ns=$_+1;
        }
    }
    if($sco<$G){
        if($G-$sco <= $ns*100*($num{$ns-1}->{p}-1)){
            $t=int(($G-$sco-1)/($ns*100)+1);
            $nos+=$t;
            $sco+=$t*100;
        }else{
            next;
        }
    }
    $min = $min<$nos?$min:$nos;
}   
print$min

Measured memory_bytes: 768
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

const int MAXN = 1e5+5;
const ll p = 1e9+7;
const ll inf = (1<<30);

string s;
ll v[MAXN], dp[MAXN][3], part[MAXN][3][3], r[MAXN][3], n;
vector<int> pos[3];

int main() {
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	cin >> s;
	n = s.length();
	v[0] = 0;
	for (int i = 1; i <= n; ++i)
		v[i] = (v[i-1] + 1 + (s[i-1] == 'b'))%3;
	n++;
	for (int i = 0; i < n; ++i)
		pos[v[i]].push_back(i);

	for (int i = n-1; i >= 0; --i) {
		for (int j = 0; j < 3; ++j) {
			if (v[i] == j)
				r[i][j] = i;
			else
				r[i][j] = max(i+1LL, r[i+1][j]);
		}
	}

	dp[0][0] = 1;
	for (int i = 1; i < n; ++i) {
		for (int j = 0; j < 3; ++j)
			for (int k = 0; k < 3; ++k) {
				if (v[i] != k && v[i-1] == j)
					part[i][j][k] = (part[i-1][j][k] + dp[i-1][j])%p;
				else
					part[i][j][k] = part[i-1][j][k];
			}
		for (int j = 0; j < 3; ++j) {
			if (v[i] == j)
				continue;
			//find the range of j that "project" onto i
			int k = 3-v[i]-j;
			//j -> k -> v[i]
			int lo = 0, hi = pos[j].size();
			//find first guy who is >= i;
			if (pos[j].size() == 0)
				continue;
			while (lo != hi) {
				int mid = (lo+hi)/2;
				int x = pos[j][mid];
				if (r[x][k] >= i) {
					hi = mid;
					continue;
				}
				if (r[r[x][k]][v[i]] >= i)
					hi = mid;
				else
					lo = mid+1;
			}
			if (lo == pos[j].size())
				continue;
			int val1 = pos[j][lo];
			lo = -1, hi = pos[j].size()-1;
			//find last guy who is <= i
			while (lo != hi) {
				int mid = (lo+hi+1)/2;
				int x = pos[j][mid];
				if (r[x][k] > i) {
					hi = mid-1;
					continue;
				}
				if (r[r[x][k]][v[i]] > i)
					hi = mid-1;
				else
					lo = mid;
			}
			if (lo == -1)
				continue;
			int val2 = pos[j][lo];
			if (val1 > val2)
				continue;
			dp[i][v[i]] = (dp[i][v[i]] + part[val2+1][j][v[i]] + p - part[val1][j][v[i]])%p;
		}
		dp[i][v[i]] = (dp[i][v[i]] + dp[i-1][v[i-1]])%p;
	}

	ll ans = 0;
	int g = -1;
	for (int i = n-3; i >= 0; --i)
		if (v[i] + v[n-1] + v[n-2] == 3) {
			g = i;
			break;
		}
	if (g == -1) {
		cout << 1 << endl;
		return 0;
	}
	for (int i = 0; i < n-1; ++i)
		if (v[i] != v[n-1])
			ans = (ans + dp[i][v[i]])%p;
	cout << ans << endl;
}

Measured memory_bytes: 13564
a, b, c = map(int, raw_input().split())
ans = 0
used = {(a, b, c)}
while a%2+b%2+c%2 == 0:
    a, b, c = b/2+c/2, c/2+a/2, a/2+b/2
    ans += 1
    if (a, b, c) in used:
        print -1
        break
    used.add((a, b, c))
else:
    print ans


Measured memory_bytes: 2568
#include<bits/stdc++.h>

using namespace std;

#define int long long

inline int read(){
	int x=0,f=1;
	char p=getchar();
	while(!isdigit(p)){
		if(p=='-') f=-1;
		p=getchar();
	}
	while(isdigit(p)) x=(x<<3)+(x<<1)+(p^48),p=getchar();
	return x*f;
}

const int maxn=405,mod=998244353;

int f[2][maxn][maxn],a[maxn],b[maxn],sa,sb,n,cur,las,ans;

inline int power(int a,int b){
	int ans=1;
	while(b){
		if(b&1) ans=ans*a%mod;
		a=a*a%mod;
		b>>=1;
	}
	return ans;
}

signed main(){
	n=read();
	for(int i=1;i<=n;i++) a[i]=read(),b[i]=read(),sa+=a[i],sb+=b[i];f[0][0][0]=mod-1;
	for(int i=1;i<=n;i++){
		cur=i&1,las=cur^1;
		memcpy(f[cur],f[las],sizeof(f[cur]));
		for(int p=1,l=0;l<b[i];l++,p=p*power(l,mod-2)%mod*a[i]%mod) 
		for(int j=a[i];j<=sa;j++)
		for(int k=l;k<sb;k++) 
		f[cur][j][k]=(f[cur][j][k]- p*f[las][j-a[i]][k-l] %mod +mod ) %mod; 
	}
	for(int i=1;i<=sa;i++){
		int inv=power(i,mod-2),p=1,q=sa*inv%mod;
		for(int j=0;j<sb;j++,p=p*j%mod*inv%mod) ans=(ans+q*p%mod*f[cur][i][j]%mod)%mod;
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 2816
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>

#include <algorithm>
#include <bitset>
#include <complex>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>

#include <cassert>
#include <functional>

typedef long long ll;
using namespace std;

#ifndef LOCAL
#define debug(x) ;
#else
#define debug(x) cerr << __LINE__ << " : " << #x << " = " << (x) << endl;

template<typename T1, typename T2>
ostream &operator<<(ostream &out, const pair<T1, T2> &p) {
  out << "{" << p.first << ", " << p.second << "}";
  return out;
}

template<typename T>
ostream &operator<<(ostream &out, const vector<T> &v) {
  out << '{';
  for (const T &item : v) out << item << ", ";
  out << "\b\b}";
  return out;
}
#endif

#define mod 1000000007 //1e9+7(prime number)
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define SIZE 200010


int main() {
  int N, K, a[SIZE];

  cin >> N >> K;
  for (int i = 0; i < N; i++) cin >> a[i];
  sort(a, a + N);

  int sum = 0;
  for (int i = 0; i < K; i++) sum += a[i];

  cout << sum << endl;

  return 0;
}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
using ll = int64_t;
#define rep(i, n) for (int i = 0; i < ((int)(n)); i++) // 0-indexed昇順

int main()
{
  int N, A;
  cin >> N >> A;
  cout << N * N - A << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;

int main(){
    int h,w;
    scanf("%d %d", &h,&w);

    long long int s1,s2,s3,mini=LLONG_MAX;
    for(long long int i=1;i<=w/2;++i){
        s1 = h * i;
        long long int j = (w-i) / 2;
        s2 = h * j;
        s3 = h * (w-i-j);
        long long int s = max(s1,max(s2,s3)) - min(s1,min(s2,s3));
        if(s < mini)mini = s;
        j = h/2;
        s2 = j * (w-i);
        s3 = (h-j) * (w-i);
        s = max(s1,max(s2,s3)) - min(s1,min(s2,s3));
        if(s < mini)mini = s;

    }
    for(long long int i=1;i<=h/2;++i){
        s1 = w * i;
        long long int j = (h-i) / 2;
        s2 = w * j;
        s3 = w * (h-i-j);
        long long int s = max(s1,max(s2,s3)) - min(s1,min(s2,s3));
        if(s < mini)mini = s;

        j = w / 2;
        s2 = j * (h-i);
        s3 = (h-i) * (w-j);
        s = max(s1,max(s2,s3)) - min(s1,min(s2,s3));
        if(s < mini)mini = s;
    }
    printf("%lld\n",mini);

    return 0;
}


Measured memory_bytes: 256
S = list(input())
cou_0s = 0
cou_1s = 0
i = -1

for s in S:
    i += 1
    if i % 2 == 0 and s == "0":
        cou_1s += 1
    elif i % 2 == 0:
        cou_0s += 1
    elif s == "1":
        cou_1s += 1
    else:
        cou_0s += 1

print(min(cou_0s, cou_1s))


Measured memory_bytes: 4004