akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<algorithm>
#include<cmath>
#include<vector>
#include<map>
#include<set>
#include<string>

#define fast_io ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);

using namespace std;

//inline int read(){int t = 0;int neg=1;char c;while((c=getchar_unlocked())!='\n'&&c!=' '&&c!=EOF){if(c=='-'){neg=-1;continue;}t=t*10+c-48;}return neg*t;}
//inline int readl(){long long t = 0;long long neg=1ll;char c;while((c=getchar_unlocked())!='\n'&&c!=' '&&c!=EOF){if(c=='-'){neg=-1ll;continue;}t=t*10+c-48;}return neg*t;}

#define debug(x) cout<<(#x)<<"="<<(x)<<", ";
#define debug1(x) debug(x) cout<<'\n';
#define debug2(x1, x2) debug(x1) debug(x2) cout<<'\n';
#define debug3(x1, x2, x3) debug(x1) debug(x2) debug(x3) cout<<'\n';
#define debug4(x1, x2, x3, x4) debug(x1) debug(x2) debug(x3) debug(x4) cout<<'\n';
#define debug5(x1, x2, x3, x4, x5) debug(x1) debug(x2) debug(x3) debug(x4) debug(x5) cout<<'\n';

typedef long long int lli;
typedef unsigned long long int ulli;
typedef pair<int,int> pi;
typedef pair<lli,lli> plli;
typedef vector<int> vi;
typedef vector<lli> vlli;
typedef vector<pi> vpi;
typedef vector<plli> vplli;
const lli M=1000000007ll;

int main(){
	fast_io
	string s;cin>>s>>s;
	cout<<"A"<<s[0]<<"C"; 
	
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define rgi register int
#define rgl register ll
#define maxn 100005
#define mod 998244353
#define inf 1000000007
namespace lib
{
	using namespace std;
	class fastio
	{
		private:
			#define _NUMLEN 111
			char _num[_NUMLEN],_ch;
			int _f,_head;
		public:
			inline void gc(char & _c) {_c=getchar();}
			template<typename _T> inline fastio & operator - (_T & _x)
			{
				_x=0;
				while(!isdigit(_ch)) _f|=_ch=='-',gc(_ch);
				while(isdigit(_ch)) _x=(_x<<1)+(_x<<3)+(_ch^48),gc(_ch);
				_f&&(_x=-_x,_f=0);
				return *this; 
			}
			inline void pc(char _c) {putchar(_c);}
			template<typename _T> inline fastio & operator + (_T _x)
			{
				_T _k;
				if(_x==0) {pc('0'),pc(' ');return *this;}
				if(_x<0) pc('-'),_x=-_x;
				while(_x>0) _k=_x/10,++_head,_num[_head]=(_x-(_k<<1)-(_k<<3))^48,_x=_k;
				while(_head>0) pc(_num[_head]),--_head;
				pc(' ');
				return *this; 
			}
			#define endl pc('\n')
		fastio() {_f=0,_head=0,_ch=' ';}
	}io;
}using namespace lib;

signed main()
{
//	freopen("ttin.in","r",stdin);
//	freopen("ttout.out","w",stdout);
	ios::sync_with_stdio(false);
	cin.tie(0),cout.tie(0);
	string s;
	cin>>s;
	int len=s.length(),ans=0;
	for(rgi i=0;i<len>>1;++i)
		if(s[i]!=s[len-1-i])++ans;
	cout<<ans;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <bitset>
#include <string>
#include <cstring>
#include <cmath>
#include <iomanip>
#include <sstream>

#define DEBUG 0
#define fi first
#define se second
#define pb push_back
#define fore(i, a, b) for (int i = (a), _b = (b); i < (_b); ++i)
#define fort(i, a, b) for (int i = (a), _b = (b); i <= (_b); ++i)
#define ford(i, a, b) for (int i = (a), _b = (b); i >= (_b); --i)

using namespace std;

typedef long long LL;
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ii> vii;
typedef vector<vii> vvii;

const int INF = 1e9 + 3;
const int MOD = 1e9 + 7;

int main() {
    if (DEBUG) {
        freopen("CP.inp", "r", stdin);
        //freopen("CP.out", "w", stdout);
    }
    ios_base::sync_with_stdio(false); cin.tie(0);
    int n, d; cin >> n >> d;
    cout << (n + d * 2) / (d * 2 + 1) << '\n';
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <random>
#include <ctime>
#include <map>
#include <queue>

using namespace std; using ll=long long; using P=pair<ll,ll>; const int INF=1e9; const ll LNF=1e18;

int main(){
  int n; cin>>n;
  P x[n]; for(int i=0;i<n;i++) {
    cin>>x[i].first; x[i].second=i;
  }
  sort(x,x+n);
  int an[n];
  for(int i=0;i<n;i++) {
    if (i < n/2) {
      an[x[i].second] = x[n/2].first;
    } else {
      an[x[i].second] = x[n/2-1].first;
    }
  }
  for(int i=0;i<n;i++) {
    cout<<an[i]<<endl;
  }
}

Measured memory_bytes: 6144
import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		char[] s = sc.next().toCharArray();
		int k = sc.nextInt();
		sc.close();

		int n = s.length;
		int[][] dp0 = new int[n + 1][k + 1];
		int[][] dp1 = new int[n + 1][k + 1];
		dp0[0][0] = 1;
		for (int i = 0; i < n; i++) {
			dp1[i + 1][0] = 1;
			if (s[i] == '0') {
				for (int j = 1; j <= k; j++) {
					dp0[i + 1][j] = dp0[i][j];
					dp1[i + 1][j] = dp1[i][j - 1] * 9 + dp1[i][j];
				}
			} else {
				int d = s[i] - '0' - 1;
				for (int j = 0; j < k; j++) {
					dp0[i + 1][j + 1] = dp0[i][j];
					dp1[i + 1][j + 1] = dp0[i][j] * d + dp0[i][j + 1]
							+ dp1[i][j] * 9 + dp1[i][j + 1];
				}
			}
		}
		System.out.println(dp0[n][k] + dp1[n][k]);
	}
}


Measured memory_bytes: 23764
n, m = (int(x) for x in input().split())
par = [-1]*(n+1)
def find(x):
    if par[x] < 0:
        return x
    else:
        par[x] = find(par[x]) #経路圧縮
        return par[x]
def same(x,y):
    return find(x) == find(y)
def unite(x,y):
    x = find(x)
    y = find(y)
    if x == y:
        return 0
    else:
        if par[x] > par[y]:
            x,y = y,x
        par[x] += par[y]
        par[y] = x
def size(x):
    return -par[find(x)]
g = [[] for _ in range(n+1)]
for _ in range(m):
    s,t = map(int,input().split())
    unite(s,t)
    g[s].append(t)
    g[t].append(s)
ma = 0
for i in range(1,n+1):
    ans = size(i)
    if ma<ans:
        ma = ans
print(ma)


Measured memory_bytes: 105916
using System;

class Program
{
    static void Main()
    {
            int i, j, x;
            int[] h = new int[2000];
            int[] w = new int[2000];
            for (i = 0; i < 2000; i++)
            {
                string inp = Console.ReadLine();
                string[] data = inp.Split();
                h[i] = int.Parse(data[0]);
                w[i] = int.Parse(data[1]);
                if (h[i] == 0 && w[i] == 0)
                {
                    break;
                }
            }
            for (x = 0; x < 2000; x++)
            {
                if (h[x] == 0 && w[x] == 0)
                {
                    break;
                }
                for (i = 0; i < h[x]; i++)
                {
                    for (j = 0; j < w[x]; j++)
                    {
                        if ((i+j) % 2 == 0)
                        {
                            Console.Write("#");
                        }else
                        {
                            Console.Write(".");
                        }
                    }
                    Console.Write("\n");
                }
                Console.Write("\n");
            }
    }
}


Measured memory_bytes: 8852
#include <iostream>
#include <vector>
using namespace std;
int main(void)
{
	bool flag;
	int n,a,k=0,b;
	cin >> n;
	vector<int> v(n);
	for(int i=0;i<n;i++) cin >> v[i];
	for(int i=0;i<n;i++){
		b=i;
		flag=false;
		for(int j=i;j<n;j++){
			if(v[j]<v[b]){
				b=j;
				flag=true;
			}
		}
		if(flag==true) k+=1;
		a=v[i];
		v[i]=v[b];
		v[b]=a;
	}
	cout << v[0];
	for(int i=1;i<n;i++) cout << " " << v[i];
	cout << endl << k << endl;
	return 0;
}

Measured memory_bytes: 1200
n = int(input())
a = list(map(int, input().split()))
ans = [[] for i in range(n)]
for i in range(n):
    ans[i] = [a[i], i+1]
#print(ans)
ans.sort()
#print(ans)
for i in range(n):
    print(ans[i][1], end=" ")

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

int main() { 
  int X;
  cin >> X;
  
  if( 400 <= X && X<600) cout << 8 << endl;
  else if( 600 <= X && X<800) cout << 7 << endl;
  else if( 800 <= X && X<1000) cout << 6 << endl;
  else if( 1000 <= X && X<1200) cout << 5 << endl;
  else if( 1200 <= X && X<1400) cout << 4 << endl;
  else if( 1400 <= X && X<1600) cout << 3 << endl;
  else if( 1600 <= X && X<1800) cout << 2 << endl;
  else cout << 1 << endl;
}

Measured memory_bytes: 3632
use std::io::{self, Read};

fn gcd(x: i64, y: i64) -> i64 {
	let mut a = x;
	let mut b = y;
	while (b != 0) {
		let t = b;
		b = a % b;
		a = t;
	}
	return a;
}

fn main() {
	let mut input = String::new();
	let _ = io::stdin().read_to_string(&mut input);
	let lines: Vec<&str> = input.split("\n").collect();	
	let (A, B) = {
		let numbers: Vec<i64> = lines[0].split(" ").map(|x| x.parse::<i64>().unwrap_or(0)).collect();
		(numbers[0], numbers[1])
	};
	println!("{}", A * B / gcd(A, B));
}



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

using namespace std;
#define X first
#define Y second
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;

#define debug(x) cerr << #x << " = " << (x) << endl;
template<typename T>
ostream& operator<<(ostream& o, vector<T>& v) {
    for (auto& x : v) o << x << ' ';
    return o;
}


int main(){
    std::ios_base::sync_with_stdio(false); cin.tie(0);
    ll i, j; cin >> i >> j;
    if (abs(i - j) <= 1) cout << "Brown" << endl;
    else cout << "Alice" << endl;


}


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

typedef long long ll;
const int inf = 1e9;

int n, m, u, res;
string s, t;

int main(){
	cin>>s>>t;
	res = inf;
	n = s.size();
	m = t.size();
	for(int i = 0; i < n - m + 1; ++i){
		string x = s.substr(i, m);
		u = 0;
		for(int j = 0; j < m; ++j){
			if(x[j] != t[j])u++;
		}
		res = min(res, u);
	}
	cout<<res<<endl;
	return 0;
}


Measured memory_bytes: 3604
#include <iostream>

#include <stack>
#include <queue>
#include <deque>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>

#include <cassert>
#include <cmath>
#include <algorithm>
#include <cstdint>
#include <ctime>

#include <fstream>

#include <cassert>

/*
ADD_CUSTOM_COMMAND(TARGET trainings
        POST_BUILD
        COMMAND trainings
        WORKING_DIRECTORY /Users/Roman/ClionProjects/trainings)
 */

using namespace std;

#define M_PI 3.14159265358979323846264338327950288
using LL = long long;
const int INF = 1e9;

const long double kek = 1.0;
const float eps = 1e-9;
#define DB(x) cerr << #x << " " << x << endl;


vector < int > colors;
vector < int > num_colors;
void dfs(int v, int c, const vector < set < int > > &g) {
    if (colors[v] == -1) {
        colors[v] = c;
        num_colors[c]++;
    } else {
        return;
    }
    for (auto to: g[v]) {
        dfs(to, c, g);
    }
}

//long double D = 100.0;

vector < int > calc (vector < set < int > > g) {
    int n = g.size();
    colors.clear();
    num_colors.clear();
    colors.resize(n, -1);
    num_colors.resize(n, 0);
    for (int i = 0; i < n; ++i) {
        dfs(i, i, g);
    }
    vector < int > res(n);
    for (int i = 0; i < n; ++i) {
        res[i] = num_colors[colors[i]];
        //cout << num_colors[colors[i]] << " ";
    }
    //cout << endl;
    return colors;
}

int main()
{
    //gen(1001);
    //freopen("input.txt", "r", stdin);
    //cin.tie(nullptr);
    //ios_base::sync_with_stdio(false);
    cerr.setf(ios_base::fixed);
    string s;
    int m, n, k;
    cin >> n;
    cin >> m >> k;
    vector < set < int >  > g(n);
    for (int i = 0; i < m; ++i) {
        int a, b;
        cin >> a >> b;
        a--;
        b--;
        g[a].insert(b);
        g[b].insert(a);
    }
    /*cout << 179 << endl;*/
    auto res = calc(g);
    m = k;
    vector < set < int >  > g1(n);
    for (int i = 0; i < m; ++i) {
        int a, b;
        cin >> a >> b;
        a--;
        b--;
        g1[a].insert(b);
        g1[b].insert(a);
    }

    auto res1 = calc(g1);
    map < pair < int, int > , int > cnt;
    for (int i = 0; i < n; ++i) {
        cnt[{res[i],res1[i]}]++;
    }
    for (int i = 0; i < n; ++i) {
        cout <<  cnt[{res[i],res1[i]}] << " ";
    }

    return 0;
}






Measured memory_bytes: 59356
n = gets.to_i
arr = []
n.times{arr << gets.to_i}
result = []
for i in 0...n
    for j in 0...n
        next if i == j
        result << ((arr[i].to_s + arr[j].to_s).to_i)
    end
    result.sort!
    result = result[0..2]
end
puts result.last


Measured memory_bytes: 122532
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main()
{
    ll N,W;
    cin >> N >> W;
    int weights[N],values[N];
    for(int i = 0; i < N; i++)
    {
        cin >> weights[i] >> values[i];
    }
    ll dp[N+1][W+1];
    for(int i =0; i <= N; i++)
    {
        for(int j = 0; j <= W; j++)
        {
            if(i == 0 || j == 0)
            {
                dp[i][j] = 0;
            }else{
                if(j >= weights[i-1])
                {
                    dp[i][j] = max(dp[i-1][j], values[i-1] + dp[i-1][j - weights[i-1]]);
                }
                else{
                    dp[i][j] = dp[i-1][j];
                }
            }
        }
    }
    cout<<dp[N][W];
}

Measured memory_bytes: 79104
import java.util.*;
import java.io.*;

public class Main {
    static void answer(LinkedList<Long> list){
        int i=0;
        for(long e:list){
            System.out.print(e);
            i++;
            if(i<list.size()) System.out.print(" ");
            else System.out.println();
        }
        System.exit(0);
    }
    static LinkedList<Long> simulate(LinkedList<Long> initial, long[] A, int startIndex){
        Set<Long> set = new HashSet<>();
        for(long e:initial) set.add(e);
        for(int n=startIndex; n<A.length; n++){
            if(!set.contains(A[n])){
                initial.addLast(A[n]);
                set.add(A[n]);
            }
            else{
                while(initial.getLast()!=A[n]){
                    set.remove(initial.getLast());
                    initial.removeLast();
                }
                set.remove(A[n]);
                initial.removeLast();
            }
        }
        return initial;
    }

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        long K = sc.nextLong();
        long[] A = new long[N];
        for(int n=0; n<N; n++) A[n] = sc.nextLong();

        Map<Long, Long> jump = new HashMap<>();
        {
            Map<Long, Long> lastAppear = new HashMap<>();
            for(int n=0; n<N*2; n++){
                if(lastAppear.containsKey(A[n%N])){
                    jump.putIfAbsent(lastAppear.get(A[n%N]), (long)n);
                }
                lastAppear.put(A[n%N], (long)(n%N));
            }
        }

        for(long a=N-1; a>=0; a--){
            if(jump.containsKey(a) && jump.get(a)<N-1){
                jump.put(a, jump.get(jump.get(a)+1));
            }
        }

        long current = 0;
        Map<Long, Long> visited = new HashMap<>();
        visited.put(0L,0L);
        while(current < N*K){
            long curIndex = current%N;
            if(current >= N * (K-1)){
                answer(simulate(new LinkedList<>(), A, (int)curIndex));
            }
            long next = current - curIndex + jump.get(curIndex) + 1;
            if(next >= N*K) {
                answer(simulate(new LinkedList<>(), A, (int)curIndex));
                break;
            }
            if(visited.containsKey(next%N)){
                long period = next - visited.get(next%N);
                long circ = (N*K-next)/period;
                next += period * circ;
            }
            current = next;
        }
    }
}

Measured memory_bytes: 150476
#include <iostream>
using namespace std;
int main(void){
    int n,Q=0,i=2;
    cin >> n;
    int x[n];
    for(int h=0;h<n;h=h+1){
        cin >> x[h];
    }
    for(int h=0;h<n;h=h+1){
        for(;i*i<=x[h];i=i+1){
            if(x[h]%i==0){
                i=i+200000000;
            }
                
  //          cout << i << " "<<x[h] << endl;
            
        }
        if(i<200000000&&x[h]!=1){
            Q=Q+1;
        
 //           cout << i << " "<<x[h] <<" " <<Q<< endl;
        }
        i=2;
    
//        cout << i << " "<<x[h] <<" " <<Q<< endl;
    }
    
    cout << Q << endl;
    
}




Measured memory_bytes: 3116
/**
 *     author: qodjf
 *     created: 04.11.2020 20:40:54
 */
#include <bits/stdc++.h>
using namespace std;

string to_string(string s) { return '"' + s + '"'; }

string to_string(const char* s) { return to_string((string)s); }

string to_string(bool b) { return (b ? "true" : "false"); }

template <typename A, typename B>
string to_string(pair<A, B> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}

template <typename A>
string to_string(A v) {
  bool first = true;
  string res = "{";
  for (const auto& x : v) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(x);
  }
  res += "}";
  return res;
}

void debug_out() { cerr << endl; }

template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}

#ifndef ONLINE_JUDGE
#define dbg(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define dbg(...) 42
#endif

#define mst(x, a) memset(x, a, sizeof(x))

using ll = long long;
using P = pair<int, int>;
using T = tuple<int, int, int>;
const int INF = 0x3f3f3f3f;
const ll LLINF = 0x3f3f3f3f3f3f3f3f;
const ll MOD = 1e9 + 7;

int dx[4] = {-1, 1, 0, 0};
int dy[4] = {0, 0, -1, 1};
ll mul(ll a, ll b) { return a * b % MOD; }

ll add(ll a, ll b) { return (a + b) % MOD; }

ll sub(ll a, ll b) { return (a - b + MOD) % MOD; }

ll my_pow(ll a, ll b) {
  ll r = 1;
  while (b) {
    if (b & 1) r = mul(r, a);
    a = mul(a, a);
    b >>= 1;
  }
  return r;
}

ll my_inv(ll a) { return my_pow(a, MOD - 2); }

namespace Comb {
const int MAXK = 2e5 + 5;
int fac[MAXK], inv_fac[MAXK];

void init() {
  fac[0] = inv_fac[0] = 1;
  for (int i = 1; i < MAXK; ++i) {
    fac[i] = mul(fac[i - 1], i);
    inv_fac[i] = my_inv(fac[i]);
  }
}

int C(int a, int b) {
  if (a < 0 || b < 0 || b > a) {
    return 0;
  }
  return mul(fac[a], mul(inv_fac[b], inv_fac[a - b]));
}

}  // namespace Comb

int f(int a, int b) { return Comb::C(a + b, b); }

int main() {
  int H, W, N;
  scanf("%d%d%d", &H, &W, &N);
  vector<P> in(N);
  for (int i = 0; i < N; i++) {
    scanf("%d%d", &in[i].first, &in[i].second);
  }
  in.emplace_back(H, W);
  sort(in.begin(), in.end());

  Comb::init();

  // dp[i] - the number of paths to vertex in[i] such that it's the first
  // forbidden vertex
  vector<int> dp(N + 1);
  for (int i = 0; i <= N; i++) {
    int h = in[i].first, w = in[i].second;
    int tmp = f(h - 1, w - 1);
    for (int j = 0; j < i; j++) {
      if (in[j].second <= w) {
        tmp = sub(tmp, mul(dp[j], f(h - in[j].first, w - in[j].second)));
      }
    }
    dp[i] = tmp;
  }

  printf("%d\n", dp[N]);
}


Measured memory_bytes: 1920
#include<stdio.h>
#include<iostream>
#include<string>

int main(void){

    int X,Y,Z,TEMP;
    std:: cin >> X >> Y >> Z;

    // SWAP 1
    TEMP = Y;
    Y = X;
    X = TEMP;

    //SWAP2
    TEMP = Z;
    Z = X;
    X = TEMP;
    
    std:: cout << X << ' ' << Y << ' ' << Z;

    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;
public class Main {

public static void main(String[] args){
		
		Scanner scan = new Scanner(System.in);
		
		
		int a = scan.nextInt();
		int b = scan.nextInt();
		
		int area = a * b;
		int perimeter = (2*a) + (2*b);
		System.out.println(area + " " + perimeter);
}
}



Measured memory_bytes: 26100
/**
 *     author: qodjf
 *     created: 05.04.2020 16:03:50
 */
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#include <unordered_set>
using namespace std;

#define mst(x, a) memset(x, a, sizeof(x))
#define all(a) begin(a), end(a)
#define rep(i, begin, end)                            \
  for (__typeof(end) i = (begin) - ((begin) > (end)); \
       i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))

using ll = long long;
using P = pair<int, int>;
using T = tuple<int, int, int>;
constexpr int INF = 0x3f3f3f3f;
constexpr ll LLINF = 0x3f3f3f3f3f3f3f3f;
constexpr ll MOD = 1e9 + 7;

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

  int N;
  cin >> N;
  vector<int> a(N);
  rep(i, 0, N) {
    cin >> a[i];
  }

  ll ans = 0;
  map<int, ll> cnt;
  rep(i, 0, N) {
    ans += cnt[i - a[i]];
    cnt[i + a[i]]++;
  }
  cout << ans << endl;
}


Measured memory_bytes: 26348
use proconio::input;
use proconio::marker::Chars;
use std::cmp::min;

fn main() {
    input! {
        t:usize
    }

    'outer: for _ in 0..t {
        input! {
            n:usize,
            a:[i64; n],
            s:Chars,
        }
        let mut v: Vec<i64> = Vec::new();
        for i in 0..n {
            let mut now = a[n - i - 1];
            for u in &v {
                now = min(now, now ^ u);
            }
            if now > 0 {
                if s[n - i - 1] == '0' {
                    v.push(now);
                } else {
                    println!("1");
                    continue 'outer;
                }
            }
        }
        println!("0");
    }
}


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

int sx, sy, tx, ty;

signed main() {
	cin >> sx >> sy >> tx >> ty;
	tx -= sx;
	ty -= sy;
	sx = 0;
	sy = 0;
	rep(i,tx)
	{
		cout << "R";
	}
	rep(i,ty)
	{
		cout << "U";
	}

	rep(i,tx)
	{
		cout << "L";
	}
	rep(i,ty)
	{
		cout << "D";
	}

	cout << "D";
	rep(i,tx)
	{
		cout << "R";
	}
	cout << "R";
	rep(i,ty)
	{
		cout << "U";
	}
	cout << "U";
	cout << "L";
	cout << "U";
	rep(i,tx)
	{
		cout << "L";
	}
	cout << "L";
	rep(i,ty)
	{
		cout << "D";
	}
	cout << "D";
	cout << "R";
	cout << endl;
}


Measured memory_bytes: 256
N=int(input())
A=input()
B=input()
C=input()
count=N*2
d=0
for i in range(N):
    if A[i]==B[i]==C[i]:
        count += -1
        
    if A[i]==B[i] or A[i]==C[i] or B[i]==C[i]:
        count += -1
        

print(count)

Measured memory_bytes: 61816
#include <algorithm>
#include <array>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <tuple>
#include <utility>
#include <vector>
#include <cassert>

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

using namespace std;

int main() {
    int R, G, B, N;
    cin  >> R >> G >> B >> N;

    int ret = 0;
    for(int i=0; i<=N; ++i) {
        for(int j=0; j<=N; j++) {
            int rem = N - i*R - j*G;
            if(rem < 0)
                continue;
            if(rem % B == 0) {
                ++ret;
            }
        }
    }
    cout << ret << endl;
    return 0;
}



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

using namespace std;

#define REP(var, n)  for (int var = 0; var < (n); var++)
#define RREP(var, n)  for (auto var = n - 1; var != static_cast<int>(-1); var--)
#define FOR(var, a, b)  for (auto var = (a); var < (b); var++)
#define RFOR(var, a, b)  for (auto var = b - 1; var != a; var--)

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef pair<int, int> pii;

#define all(c) begin(c),end(c)

#define D(x) do { std::cerr << x << " "; } while (0)
#define D2(x) do { std::cerr << #x << ": " << x << std::endl; } while (0)


template<typename T>
std::ostream &operator<<(std::ostream &out, const std::vector<T> &v) {
    if (!v.empty()) {
        out << '[';
        std::copy(v.begin(), v.end(), std::ostream_iterator<T>(out, ", "));
        out << "\b\b]";
    }
    return out;
}


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


template<class T>
bool chmax(T &a, const T &b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}

template<class T>
bool chmin(T &a, const T &b) {
    if (b < a) {
        a = b;
        return true;
    }
    return false;
}


auto solve() {
    int N;
    cin>>N;
    double sum = 0;
    REP(i,N) {
        double v; cin>>v;
        string s;cin>>s;
        if(s == "BTC") v*= 380000.0;
        sum+=v;
    }

    return sum;
}


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

//    cout << (solve() ? "Heisei" : "TBD") << endl;
//    cout << (solve() ? "YES" : "NO") << endl;
    cout << solve() << endl;
//    solve();

    return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii =  pair<int, int>;
using pll =  pair<long long, long long>;
constexpr char ln =  '\n';
constexpr long long MOD = 1000000007LL;
constexpr long long INF = 1000000009LL;
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define fo(i,j,n) for (int i=(j); i < (n); i++)
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 main() {
    int n, k; cin >> n >> k;
    vector<bool> fg(n, false);
    rep(i, k){
        int d; cin >> d;
        rep(i, d){
            int a; cin >> a; a--;
            fg[a] = true;
        }
    }
    int cnt = 0;
    rep(i, n) if(!fg[i]) cnt++;
    cout << cnt << ln;
}

Measured memory_bytes: 3636
import math 
import bisect
from collections import deque
a,b = map(int, input().split())
def pf(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a
a_s = pf(a)
a_s = list(set(a_s))
b_s = pf(b)
count = 0

for i in range(len(a_s)):
    if a_s[i] in b_s: count += 1 

print(count + 1) # 1


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

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0); 
	
	string s;
	cin >> s;
	int a = 0, b = 0, c = 0;
	for(int i = 0; i < s.size(); i++) {
		if(s[i] == 'a') a++;
		if(s[i] == 'b') b++;
		if(s[i] == 'c') c++;
	}
	int mi = min({a, b, c});
	if(a - mi <= 1 && b - mi <= 1 && c - mi <= 1) {
		cout << "YES" << endl;
	} else {
		cout << "NO" << endl;
	}
	return 0;
}



Measured memory_bytes: 512
#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
#define E "\n"

using namespace std;
const long long MOD = (long long)1e9 + 7;

int x;

int main()
{
	ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	cin >> x;
	int ans = 9;
	if (400 <= x) ans--;
	if (600 <= x) ans--;
	if (800 <= x) ans--;
	if (1000 <= x) ans--;
	if (1200 <= x) ans--;
	if (1400 <= x) ans--;
	if (1600 <= x) ans--;
	if (1800 <= x) ans--;
	cout << ans << E;
	//system("pause");
	return 0;
}

Measured memory_bytes: 3648
#include<bits/stdc++.h>
#define ll long long int
#define M 1000000007
using namespace std;

ll power(ll x,ll n)
{
    if(n==0){return 1;}
    if(n==1){return x%M;}
    ll ans;
    if(n%2==0)
    {
        ll y=power(x,n/2);
        ans=(y*y)%M;
    }
    else
    {
        ans=power(x,n-1);
        ans=(ans*x)%M;
    }
    return ans;
}

ll f(ll a,ll d,ll n)
{
    ll ans=0;
    ans=((2*a)%M+((n-1)*d)%M);
    ans=(ans*(n))%M;
    ans=(ans*power(2,M-2))%M;
    return ans;
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);

    ll n,k;
    cin>>n>>k;
    ll ar[n];
    ll bh[n]={0};
    ll ch[n]={0};
    for(ll i=0;i<n;++i){cin>>ar[i];}
    for(ll i=0;i<n;++i)
    {
        for(ll j=0;j<i;++j)
        {
            if(ar[j]>ar[i]){++ch[i];}
        }
        for(ll j=0;j<n;++j)
        {
            if(ar[j]>ar[i]){++bh[i];}
        }
        bh[i]+=ch[i];
    }
    ll ans=0;
    for(ll i=0;i<n;++i)
    {
        ans=(ans+ch[i])%M;
    }
    if(k==1){cout<<ans<<endl;return(0);}
    for(ll i=0;i<n;++i)
    {
        ans=(ans+f(bh[i],bh[i]-ch[i],k-1))%M;
    }
    cout<<ans<<endl;

    return (0);
}


Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>

using namespace std;

int main() {
	int a,b,c,d;
	int time;
	cin >> a >> b >> c >> d;
	time = a + b + c + d;
	cout << time / 60 << endl;
	cout << time % 60 << endl;

	return 0;
}

Measured memory_bytes: 1164
from collections import Counter,defaultdict,deque
from heapq import heappop,heappush,heapify
import sys,bisect,math,itertools
sys.setrecursionlimit(10**8)
mod = 10**9+7
mod2 = 998244353
INF = float('inf')
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpln(n): return list(int(sys.stdin.readline()) for i in range(n))

s = sys.stdin.readline()
n = len(s)-1
now = [0] * 13
now[0] = 1
for i in range(n)[::-1]:
    prev = now[::]
    now = [0] * 13
    c = n - i - 1#桁
    m = pow(10,c,13)
    if s[i] == '?':
        for k in range(10):
            l = (m*k) % 13
            for j in range(13):
                now[(j+l)%13] += prev[j]
                now[(j+l)%13] = now[(j+l)%13] % mod
    else:
        k = int(s[i])
        l = (m*k) % 13
        for j in range(13):
            now[(j+l)%13] = prev[j]
    # print(now)
print(now[5])


Measured memory_bytes: 43756
X = list(map(int, input().split()))
N = int(X[0])
K = int(X[1])
#print(N,K)
S = 0

for i in range(K,N+2):
  Min = (i-1)*i/2
  Max = (N-i+N+1)*i/2
#  print(Min,Max)
  S+=(Max-Min+1)
  
print(int(S%(pow(10,9)+7)))

Measured memory_bytes: 9132
import java.util.Scanner;

public class Main {


    static int[] a = new int[31];

    public static void main(String[] args){

        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int m = sc.nextInt();
        int[] aa = {0,2,5,5,4,5,6,3,7,6};
        int a[] = new int[m];
        for(int i=0; i<m; i++) {
            a[i] = sc.nextInt();
        }
        Num[] memo = new Num[n+1];

        for(int i=0; i<m; i++) {
            int ni = aa[a[i]];
            if(ni>n) continue;
            if(memo[ni] == null ) {
                memo[ni] = new Num(a[i]);
            } else {
                if(new Num(a[i]).compareTo(memo[ni]) > 0) {
                    memo[ni] = new Num(a[i]);
                }
            }
        }
        for(int j=1; j<n; j++) {
            if(memo[j] == null) continue;
            for(int i=0; i<m; i++) {
                int ni = j + aa[a[i]];
                if(ni>n) continue;
                if(memo[ni] == null) {
                    memo[ni] = new Num(0);
                }
                Num num;
                num = new Num(memo[j].s + a[i]);
                if(num.compareTo(memo[ni]) > 0) {
                    memo[ni] = num;
                }
                num = new Num(a[i] + memo[j].s);
                if(num.compareTo(memo[ni]) > 0) {
                    memo[ni] = num;
                }
                num = new Num(memo[j].s.substring(0,1) + a[i] + memo[j].s.substring(1));
                if(num.compareTo(memo[ni]) > 0) {
                    memo[ni] = num;
                }
            }
        }

        System.out.println(memo[n].s);
    }

    static class Num implements Comparable<Num>{
        String s;
        public Num(String s) {
            this.s = s;
        }
        public Num(int n) {
            this.s = Integer.toString(n);
        }

        @Override public int compareTo(Num o) {
            if(s.length() != o.s.length()) {
                return s.length() - o.s.length();
            }
            return s.compareTo(o.s);
        }
    }


}


Measured memory_bytes: 396228
#include <bits/stdc++.h>
using namespace std;
#define int long long   // aaaaaaaaaaaaaaaaaa
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n;i>=a;i--)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define allr(x) (x).rbegin(),(x).rend()
#define in(s,x) s.find(x) != s.end()
#define fi first
#define se second
#define SZ(x) ((int)(x).size())
#define SIZE(buff) (sizeof(buff)/sizeof(buff[0]))
typedef vector<int> VI;
typedef vector<vector<int> > VVI;
typedef long long ll;
typedef pair<int,int> PII;
typedef vector<pair<int,int>> VPII;
const ll mod=1000000007;
const ll INF= 1LL<<60-1;
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}
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; }
template <class T>ostream &operator<<(ostream &o,const vector<T>&v)
{o<<"{";for(int i=0;i<(int)v.size();i++)o<<(i>0?", ":"")<<v[i];o<<"}";return o;}
template<typename T, typename U>ostream& operator << (ostream& os, pair<T, U>& pair_var)
{os << "(" << pair_var.first << ", " << pair_var.second << ")";return os;}

// head


int m,n,k,res,tmp,tmp2,tmp3,h,x,y;
VI a;
deque<PII> que;
string s;
//VI b;
vector<PII> g[2100600];
int b[2100000];
int c[210000] = {};
int rui[210000];
set<int> ch;

std::vector<int> enum_div(int n)
{
	std::vector<int> ret;
	for(int i=1 ; i*i<=n ; ++i)
	{
		if(n%i == 0)
		{
			ret.push_back(i);
			if(i*i!=n)
			{
				ret.push_back(n/i);
			}
		}
	}
	return ret;
}

signed main() {
	cin.tie(0);
  ios::sync_with_stdio(false);
  cin>>n>>k;
  rep(i,0,n){cin>>b[i];x+=b[i];}
  VI aa = enum_div(x);
  sort(allr(aa));
  for(auto i :aa){
    x = 0;
    rep(j,0,n){
      a.pb(b[j]%i);
      x += b[j]%i; 
    }
    if(x%i==0){sort(all(a));
      rep(j,0,n){
          rui[j+1] = rui[j] + a[j]; 
      }
      y = 0;
      per(j,0,n-1){
        if (y == rui[j+1])break;
        y += i-a[j];
      }
      if(y<=k){cout<<i<<endl;exit(0);}
    }
  a.clear();
  }
}


Measured memory_bytes: 52864
#include <bits/stdc++.h>
using namespace std;
int main() {
    int n;
    cin>>n;

    vector<int>a(n);
    for (int i=0;i<n;i++) {
        cin>>a[i];
    }

    int count=0,min=10e9;

    for (int i=0;i<n;i++) {
        if(a[i]%2==0){
            while(a[i]%2==0){
                a[i]/=2;
                count++;
            }
        }
        if(count<min){
            min=count;
        }
        count=0;
    }

    cout<<min<<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <sstream>
#include <iomanip>
#include <vector>
#include <deque>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define rep(i,n) for (int i=0;i<(n);i++)
#define all(a) (a).begin(),(a).end()
#define reunique(v) v.erase(unique(v.begin(),v.end()),v.end())
#define RET(p,x) return p<<x<<endl,0;
#define Debug(...) __debug_assistant(#__VA_ARGS__,__VA_ARGS__)
template<typename T>void __debug_assistant(const char* name,T&& t){cout<<name<<" = "<<t<<endl;}
template<typename T1,typename... T>void __debug_assistant(const char* names,T1&& t1,T&&... t){
	const char* comma=strchr(names+1,',');
	cout.write(names,comma-names)<<" = "<<t1<<", ";__debug_assistant(comma+1,t...);
}
const int inf=1e9;
const ll h1=239017;
const ll h2=731604233;
const ll mod=1000000007;
const ll mod2=1000000009;
const int dx[]={1,0,-1,0,1,0,-1,0};
const int dy[]={0,1,0,-1,1,0,-1,0};
long long n;
signed main()
{
	ios_base::sync_with_stdio();cin.tie();cout.tie();cout<<setprecision(15);
	cin>>n;
	int ct=0;
	ll nn=n;
	while (nn)
	{
		ct++;
		nn/=10;
	}
	ll ans=(ct-1)*9;
	ans+=n/((ll)pow(10,ct-1));
	n%=((ll)pow(10,ct-1));
	if ((n+1)%((ll)pow(10,ct-1))) ans--;
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <queue>
#include <map>
#include <unordered_map>
#include <set>
#include <functional>
#include <bitset>
#include <numeric>
#include <complex>
#include <cassert>
#include <random>


int main() {
    int n; std::cin >> n;
    std::vector<int> a(n);
    for (int i = 0; i < n; i++) std::cin >> a[i];
    std::vector<int> id(n);
    std::iota(id.begin(), id.end(), 0);
    std::sort(id.begin(), id.end(), [&](int i, int j) {
        return a[i] > a[j];
    });
    std::multiset<int> s;
    s.insert(-1); s.insert(-1);
    s.insert(n); s.insert(n);
    long long ans = 0;
    for (int i : id) {
        auto itr = s.lower_bound(i);
        long long r0 = *itr;
        itr++;
        long long r1 = *itr;
        itr--;
        itr--;
        long long l0 = *itr;
        itr--;
        long long l1 = *itr;
        ans += a[i]*(r1 - r0)*(i - l0);
        ans += a[i] * (l0 - l1)*(r0 - i);
        s.insert(i);
    }
    std::cout << ans << std::endl;
    return 0;
}


Measured memory_bytes: 5760
r, D, X = map(int, input().split())


def calcWeight(r, D, X, stepper):
    if stepper == 10:
        return X
    weight = r*X-D
    stepper += 1
    print(weight)
    return calcWeight(r, D, weight, stepper)


calcWeight(r, D, X, 0)


Measured memory_bytes: 38384
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;

int main(){
    int n;
    cin>>n;
    long a=1;
    for (int i = 1; i < n+1; i++){
      a=a*i;  
      a=a%(1000000007);
    }
    cout<<a;
    return 0;
}

Measured memory_bytes: 256
// clang-format off
#include <bits/stdc++.h>
#define int long long
#define main signed main()
// #define main int main()
#define loop(i, a, n) for (int i = (a); i < (n); i++)
#define rep(i, n) loop(i, 0, n)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define prec(n) fixed << setprecision(n)
#define stlice(from, to) substr(from, (to) - (from) + 1)
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
using namespace std;
using pii = pair<int, int>;
using vi = vector<int>;
using vd = vector<double>;
using vc = vector<char>;
using vb = vector<bool>;
using vs = vector<string>;
using vpii = vector<pii>;
using vvi = vector<vi>;
using vvb = vector<vb>;
using vvpii = vector<vpii>;
template<typename A> using fn = function<A>;
constexpr int INF = sizeof(int) == sizeof(long long) ? 1000000000000000000LL : 1000000000;
constexpr int MOD = 1000000007;
constexpr double PI = acos(-1);
template<typename A, typename B> bool cmin(A &a, const B &b) { return a > b ? (a = b, true) : false; }
template<typename A, typename B> bool cmax(A &a, const B &b) { return a < b ? (a = b, true) : false; }
constexpr bool odd(const int &n) { return n & 1; }
constexpr bool even(const int &n) { return !odd(n); }
void solve();
main { solve(); return 0; }
// clang-format on

constexpr bool isPrime(const int &n) {
  if (n == 1) return false;
  for (int i = 2; i * i <= n; i++) {
    if (n % i == 0) return false;
  }
  return true;
}

void solve() {
  int n;
  while (cin >> n) {
    vi a(n);
    iota(all(a), 1);
    vi b = a;
    reverse(all(b));
    int c = 0;
    rep(i, n) c += isPrime(a[i]) && isPrime(b[i]);
    cout << c << endl;
  }
}

Measured memory_bytes: 3120
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

class Main {

    public static void main(String[] args) throws Exception {

        try {

            BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

            int peopleCount = Integer.parseInt(br.readLine());
            int groupCount = 0;
            while (peopleCount >= 3) {
                peopleCount -= 3;
                groupCount += 1;
            }

            System.out.println(groupCount);
        } catch (IOException | NumberFormatException e) {
            e.printStackTrace();
            System.exit(0);
        } catch (final Exception e) {
            e.printStackTrace();
            System.exit(0);
        }
    }
}

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

int main(){
  int n;
  cin >> n;
  int a[n];
  for (int i=0; i<n; ++i) cin >> a[i];
  for (int i=0; i<n-1; ++i) cout << a[n-1-i] << " ";
  cout << a[0] << endl;
  return 0;
}

Measured memory_bytes: 3080
while True:
    n, x = map(int, raw_input().split())
    if (n, x) == (0, 0):
        break
    ans = 0
    for a in xrange(1, n+1):
        for b in xrange(a+1, n+1):
            for c in xrange(b+1, n+1):
                if a + b + c == x:
                    ans += 1
    print ans

Measured memory_bytes: 4216
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
const int dx[2]={-1,0},dy[2]={0,-1};
char ch[2101];
int ans,t1,t2,t3,t4,i,j,k,n,m,tq,a[2101][2101],sv[2101][2101],se[2101][2101],ts[2101][2101],now;
int sl[2101][2101],su[2101][2101];
int solve(int x1,int y1,int x2,int y2){
	int tv,te;
	now++;
	tv=sv[x2][y2]-sv[x1-1][y2]-sv[x2][y1-1]+sv[x1-1][y1-1];
	te=se[x2][y2]-se[x1-1][y2]-se[x2][y1-1]+se[x1-1][y1-1];
	te-=(su[x1][y2]-su[x1][y1-1])+(sl[x2][y1]-sl[x1-1][y1]);
	return tv-te;
}
int main(){
	scanf("%d%d%d",&n,&m,&tq);memset(a,0,sizeof(a));memset(sv,0,sizeof(sv));memset(se,0,sizeof(se));
	memset(ts,0,sizeof(ts));now=0;memset(su,0,sizeof(su));memset(sl,0,sizeof(sl));
	for (i=1;i<=n;i++){
		scanf("%s",ch);
		for (j=0;j<m;j++) a[i][j+1]=ch[j]-'0';
	}
	for (i=1;i<=n;i++)
	 for (j=1;j<=m;j++){
	 	sv[i][j]=sv[i-1][j]+sv[i][j-1]-sv[i-1][j-1]+a[i][j];
	 	se[i][j]=se[i-1][j]+se[i][j-1]-se[i-1][j-1];
		sl[i][j]=sl[i-1][j];su[i][j]=su[i][j-1];
	 	if (!a[i][j]) continue;
	 	for (k=0;k<2;k++){
	 		t1=i+dx[k];t2=j+dy[k];
	 		if (a[t1][t2]){
	 			se[i][j]++;
	 			if (!k) su[i][j]++;else sl[i][j]++;
			}
		 }
	 }
	for (i=1;i<=tq;i++){
		scanf("%d%d%d%d",&t1,&t2,&t3,&t4);
		ans=solve(t1,t2,t3,t4);
		printf("%d\n",ans);
	}
	return 0;
}

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

int main(){
	char c1, c2, c3, c4; cin >> c1 >> c2 >> c3 >> c4;
	int s1 = (c1 - '0') * 10 + (c2 - '0');
	int s2 = (c3 - '0') * 10 + (c4 - '0');
	//cout << s1 << endl << s2 << endl;
	string res;
	if(1 <= s1 && s1 <= 12){
		if(1 <= s2 && s2 <= 12){
			res = "AMBIGUOUS";
		}else{
			res = "MMYY";
		}
	}else{
		if(1 <= s2 && s2 <= 12){
			res = "YYMM";
		}else{
			res = "NA";
		}
	}

	cout << res << endl;
}


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

// 積が奇数ならばtrueを返す関数
bool OddOrEven(int, int);

int main()
{
  int a, b;
  cin>>a>>b;

  if(OddOrEven(a, b))
    cout<<"Odd"<<endl;
  else
    cout<<"Even"<<endl;

  return 0;
}

bool OddOrEven(int a, int b)
{
  if(a%2!=0 && b%2!=0)
    return true;
  else
    return false;
}


Measured memory_bytes: 256
using System;
using System.Linq;
using System.Collections.Generic;
class Program
{
    static void Main(string[] args)
    {
        string[] s = Console.ReadLine().Split(' ');
        int D = int.Parse(s[0]);
        int N = int.Parse(s[1]);

        int num = 1;
        for (int i = 0; i < D; i++)
            num *= 100;
        Console.WriteLine(N == 100 ? num * (N + 1) : num * N);
    }
}


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

int main()
{
    ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);

    long long a,b,c,d,i,j,k,t,m,n,x,y,z,s,f=0,p,r,w,v,q,e;

     cin>>x;
     cin>>y>>z;
    for(i=y;i<=z;i++)
    {
        if((i%x)==0)
        {
            f=1;
            break;
        }
    }
     if(f==1)
     {
         cout<<"OK"<<endl;
     }
     else
     {
         cout<<"NG"<<endl;
     }

     return 0;
}




Measured memory_bytes: 3652
#include "bits/stdc++.h"
using namespace std;

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP0(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define REP1(i, n) for (int i = 1, i##_len = (n); i <= i##_len; ++i)

typedef long long LL;
typedef pair<int, int> pii;

const int INTINF = int(1e9) + 1;
const LL LLINF   = LL(1e18) + 1;
#define pow10(n) int(1e##n + n)

void solve()
{
    int N;
    cin >> N;
    vector<int> X(N);
    double mu = 0;
    REP0 (i, N)
    {
        cin >> X[i];
        mu += X[i];
    }
    mu /= N;
    int nn = round(mu);

    LL ans = 0;
    REP0 (i, N)
    {
        ans += (X[i] - nn) * (X[i] - nn);
    }

    cout << ans << endl;
}

int main(int argc, char const *argv[])
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    std::cout << std::fixed << std::setprecision(10);
    solve();
    return 0;
}


Measured memory_bytes: 384
#include <stdio.h>

int main(){
  int H,N;
  int sum = 0;
  
  scanf("%d %d",&H ,&N);
  
  int A;
  
  for(int i=0;i<N;i++){
    scanf("%d",&A);
    sum += A;
  }
  
  if(sum >= H) printf("Yes\n");
  else printf("No\n");
  
  return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
main(){char* s[]={"light fly","fly","bantam","feather","light","light welter","welter","light middle","middle","light heavy","heavy"};float f[]={48.0,51.0,54.0,57.0,60.0,64.0,69.0,75.0,81.0,91.0,1e9};float a;while(std::cin>>a)for(int i=0;;i++)if(a<=f[i]){printf("%s\n",s[i]);break;}}

Measured memory_bytes: 1184
using System;
using System.Collections.Generic;
    class Program
    {
        static void Main(string[] args)
        {
            var input1 = Console.ReadLine();
            string[] strinputArray = input1.Split(' ');
            int[] input1Array = Array.ConvertAll<string, int>(strinputArray, delegate (string value) { return int.Parse(value); });

            if (input1Array[0] <= input1Array[2] && input1Array[1] >= input1Array[2])
            {
                Console.WriteLine("Yes");
            }
            else if (input1Array[0] >= input1Array[2] && input1Array[1] <= input1Array[2])
            {
                Console.WriteLine("Yes");
            }
            else
            {
                Console.WriteLine("No");
            }

        }
    }

Measured memory_bytes: 13140
#include <stdio.h>
#define M 10001
#define NIL M+1

int main(void){
  int i,x[M],limit,left,right,parent;
  for(i=0;i<=M;i++){
    x[i]= NIL;
  }
  
  scanf("%d",&limit);
  for(i=1;i<=limit;i++){
    scanf("%d",&x[i]);
  }
  for(i=1;i<=limit;i++){
    printf("node %d: ",i);
    printf("key = %d, ",x[i]);
    parent = x[i/2];
    left = x[2 * i];
    right = x[2*i +1];
    if(parent != NIL){
      printf("parent key = %d, ",parent);
    }
    if(left != NIL){
      printf("left key = %d, ",left);
    }
    if(right != NIL){
      printf("right key = %d, ",right);
    }
    printf("\n");
  }
  return 0;
}



Measured memory_bytes: 2108
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System;
using System.IO;

public class Playground
{
    public static void Main(string[] args)
    {
        Input();
        System.Console.ReadLine();
    }

    private static void Input()
    {
        var dic = new HashSet<string>();
        int num = int.Parse(Console.ReadLine());
        for (int i = 0; i < num; i++)
        {
            var ope = (Console.ReadLine().Split(' '));
            if (ope[0].Equals("insert"))
            {
                dic.Add(ope[1]);
            }
            else
            {
                if (dic.Contains(ope[1]))
                {
                    Console.WriteLine("yes");
                }
                else
                {
                    Console.WriteLine("no");
                }
            }
        }
    }
}

Measured memory_bytes: 39940
#C
n,m = map(int,input().split())
h = list(map(int,input().split()))
r = []
for _ in range(m):
    a,b = map(int,input().split())
    r.append([a,b])
    
flg = [True for _ in range(n)]

for i in range(m):
    if h[r[i][0] - 1] > h[r[i][1] - 1]:
        flg[r[i][1] - 1] = False
    elif h[r[i][0] - 1] < h[r[i][1] - 1]:
        flg[r[i][0] - 1] = False
    else:
        flg[r[i][1] - 1] = False
        flg[r[i][0] - 1] = False

print(flg.count(True))

Measured memory_bytes: 28960
#include<cstdio>
#include<algorithm>
#include<utility>
using namespace std;
int main(){
    long w,h,a,b,p,ans=0;
    pair<long,int> c[200000];
    scanf("%ld %ld",&w,&h);
    for(long i=0;i<w;i++){
        scanf("%ld",&p);
        c[i]=make_pair(p,0);
    }
    for(long i=0;i<h;i++){
        scanf("%ld",&p);
        c[i+w]=make_pair(p,1);
    }
    sort(c,c+w+h);
    a=w+1;
    b=h+1;
    for(int i=0;i<w+h;i++){
        if(c[i].second){
            ans+=a*c[i].first;
            b--;
        }
        else{
            ans+=b*c[i].first;
            a--;
        }
    }
    printf("%ld\n",ans);
}

Measured memory_bytes: 3328