akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

using namespace std;

int add(int a, int b){
	return max(a,b);
}

int mul(int a, int b){
	return min(a,b);
}

int sub(int a){
	return 2-a;
}

bool is_digit(char c){
	return c >= '0' && c <= '9';
}

string calc(string s, int p, int q, int r){
	string ret;
	replace(s.begin(),s.end(),'P',char(p + '0'));
	replace(s.begin(),s.end(),'Q',char(q + '0'));
	replace(s.begin(),s.end(),'R',char(r + '0'));
	//cout << s << endl;
	for(int i=0;i < s.size();i++){
		if(i < s.size()-2){
			if(s[i] == '(' && s[i+2] == ')'){
				ret += s[i+1];
				i+=2;
				continue;
			}
			if(s[i+1] == '+' && is_digit(s[i]) && is_digit(s[i+2])){
				ret += to_string(add(int(s[i] - '0'),int(s[i+2] - '0')));
				i+=2;
				continue;
			}
			if(s[i+1] == '*' && is_digit(s[i]) && is_digit(s[i+2])){
				ret += to_string(mul(int(s[i] - '0'),int(s[i+2] - '0')));
				i+=2;
				continue;
			}
		}
		if(i < s.size()-1){
			if(s[i] == '-' && s[i+1] == '-'){
				i++;
				continue;
			}
			if(s[i] == '-' && is_digit(s[i+1])){
				ret += to_string(sub(int(s[i+1] - '0')));
				i++;
				continue;
			}
		}
		ret += s[i];
	}
	//cout << ret << endl;
	if(ret.size() > 1){
		return calc(ret, p, q, r);
	} else {
		return ret;
	}
}

int main(){
	string s;
	while(cin >> s, s != "."){
		int ans = 0;
		for(int p=0;p<3;p++){
			for(int q=0;q<3;q++){
				for(int r=0;r<3;r++){
					int x = stoi(calc(s, p, q, r));
					if(x == 2){
						ans ++;
					}
				}
			}
		}
		cout << ans << endl;
	}
}


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

int a[200001];
long long s1[200001],s2[200001],s3[200001],s4[200001];
int main(){
	int n,L;
	scanf("%d%d",&L,&n);
	for(int i=1;i<=n;i++)
		scanf("%d",&a[i]);
	a[n+1]=L;
	long long ans=0;
	for(int kk=0;kk<2;kk++){
		for(int i=1;i<=n;i++){
			s1[i]=a[i];
			s2[i]=L-a[n-i+1];
			s3[i]=s3[i-1]+1ll*(a[i]-a[i-1])*i;
			s4[i]=s4[i-1]+1ll*(a[n-i+2]-a[n-i+1])*i;
		}
		for(int i=1;i<=n;i++){
			int w=n+i+1>>1;
			long long o=s2[n-w+1]*(2*(n-w+1))-s4[n-w+1]*2+
				s1[i]*(2*(w-i)+1)+(s1[w]-s1[i])*(2*w+1)-(s3[w]-s3[i])*2;
			if((n+i)%2)o+=-s1[w]+s2[n-w+1];
			ans=max(ans,o);
		}
		for(int i=1;i<=n-i+1;i++){
			swap(a[i],a[n-i+1]);
			a[i]=L-a[i];
			if(i!=n-i+1)a[n-i+1]=L-a[n-i+1];
		}
	}
	printf("%lld\n",ans);
}

Measured memory_bytes: 8748
#include<iostream>
using namespace std;
int i, j;
int dp[1000][1000];
char cp[1000][1000];

int min(int a,int b){
  int mp;
  if(a<b)mp=a;
  else mp=b;

  return mp; 
}





int main(void){
  
  int n, i, j, a, b;
  //int dp[1000][1000];
  int sq=0;
  
  while(1){
    
    cin >> n;
    sq=0;
  
  if(n==0){break;}
  
  else{
    for(i=0; i<n; i++){
      for(j=0; j<n; j++){
	
	cin >> cp[i][j];
	
	//ã[,¶[Ì
	if((i==0 || j==0)&& cp[i][j]=='.'){
	  dp[i][j]=1;
	}
	if(cp[i][j]=='*'){
	  dp[i][j]=0;
	}
	
	

	//
	else if(i-1>=0 && j -1>=0){
	dp[i][j]=min(dp[i-1][j], min(dp[i-1][j-1], dp[i][j-1]))+1;
	}

	//êÔ½«¢³û`ðÛ¶
	if(dp[i][j]>sq)sq=dp[i][j];
      }
      
    }            
  }
  
  printf("%d\n", sq);
  
  }
 
  return 0;
 
}

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

int GetMaxPoint(int a[][3], int n)
{
    for(int i=1; i<n; ++i)
    {
        a[i][0] += max(a[i-1][1], a[i-1][2]);
        a[i][1] += max(a[i-1][0], a[i-1][2]);
        a[i][2] += max(a[i-1][0], a[i-1][1]);
    }
    
    return max(max(a[n-1][0], a[n-1][1]), a[n-1][2]);
}

int main() {
	
	int n;
	
	cin >> n;
	int a[n][3];
	
	for(int i=0; i<n; ++i)
	{
	    for(int j=0; j<3; ++j)
	    {
	        cin >> a[i][j];
	    }
	}
	
	
	cout << GetMaxPoint(a, n) << "\n";
	
	return 0;
}


Measured memory_bytes: 1408
#include <iostream>
#include <stack>
#include <queue>

using ll = long long;
using namespace std;
using P = pair<int, int>;

int move(int A,int B, int C){
    if(!A&&!B) return 0;
    if(C&1)return move(A>>1,B>>1, C>>1);
    if(B&1)return move(C>>1,B>>1, A>>1)+move((A|B|C )>>1, 0, 0) + 1;
    if(A&1)return move(A>>1,B>>1, C>>1)+ 2*move((A|B|C)>>1, 0,0)+ 2;
}

int main() {
    int n, m;
    while(cin>>n>>m, n || m){
        int cup[3] = {};
        for (int &i : cup) {
            int t;
            cin >> t;
            for (int j = 0; j < t; ++j) {
                int a;
                cin >> a;
                i += 1<<(a-1);
            }
        }
        int a = min(move(cup[0],cup[1], cup[2]),move(cup[2], cup[1], cup[0]));
        cout << (a<=m ? a : -1) << "\n";
    }
    return 0;
}



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

#ifdef LOCAL 
string to_string(char a) { return string(1,a); }
string to_string(bool a) { return a ? "1" : "0"; }
string to_string(const char* a) { return (string)a; }
string to_string(string a) { return a; }
string to_string(vector<bool> v) {
	string s = "["; for(unsigned i=0;i<v.size();i++){ s += ((i>0)?" ":"");
    s += char('0'+v[i]); } 	s += "]"; return s; }
template<class A, class B> string to_string(pair<A,B> p);
template<class T> string to_string(T v) {
	bool b = 1; string s = "["; for (const auto& x: v) {
		if (!b) {s += ", ";} b = 0; s += to_string(x); } s += "]"; return s; }
template<class A, class B> string to_string(pair<A,B> p) {
	return "("+to_string(p.first)+", "+to_string(p.second)+")"; }
void dbgf() { cerr << endl; }
template<class H, class... T> void dbgf(H h, T... t) {
	cerr << to_string(h); if (sizeof...(t)) cerr << ", ";
	dbgf(t...); }
#define dbg(...) cerr << #__VA_ARGS__ << " = ", dbgf(__VA_ARGS__)
#else
#define dbg(...) 0
#endif
#define boolout(x) cout<<(x?"YES":"NO")<<endl;
typedef long long ll;

const int mod = 1e9+7;

void add_self(int &a, int b){
    a+=b;
    if (a>=mod) {
        a-=mod;
    }
}

void solve()
{
    int n;
    string s;
    cin >> n >> s;

    vector<vector<int>> dp(n+1, vector<int>(n+1, 0));
    dp[1][1] = 1;
    for (int i = 2; i <= n; ++i) {
        vector<int> pref(i+1, 0);
        for (int j = 1; j < i; ++j) {
            pref[j] = (pref[j-1] + dp[i-1][j])%mod; 
        }
        for (int b = 1; b <= i; ++b) {
            int l, r;
            if (s[i-2]=='<') {
                l=1; r=b-1; 
            } else {
                l=b; r=i-1;
            }
            add_self(dp[i][b], (pref[r]-pref[l-1]+mod)%mod);
            /* for (int a = 0; a < b-1; ++a) { */
            /*     int real_a = a; */
            /*     if (b>=a) { */
            /*         real_a = a+1; */
            /*     } */
            /*     assert(real_a!=b); */
            /*     if ((real_a < b) != (s[i-2]=='<')) { */
            /*        continue; */
            /*     } */
            /*     add_self(dp[i][b], dp[i-1][a]); */
            /* } */
        }
    }
    dbg(dp);
    int res = 0;
    for (int i = 1; i < n+1; ++i) {
        add_self(res, dp[n][i]); 
    }
    cout << res << endl;
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int t=1;
    //cin >> t; // read t. cin knows that t is an int, so it reads it as such.
    for (int i = 1; i <= t; ++i) {
        solve();
    }
    return 0;
}



Measured memory_bytes: 38956
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 c = scan.nextInt();
		int d = Math.abs(a-b);
		int e = Math.abs(b-c);
		int f = Math.abs(c-a);
		int g = d+e;
		int h = e+f;
		int i = f+d;
		int min = Math.min(g, h);
		min = Math.min(min, i);
		System.out.println(min);
	}
}


Measured memory_bytes: 21844
x = int(input())


def is_prime(num):
    limit = int(num ** 0.5) + 1
    for i in range(2, limit):
        if num % i == 0:
            return False
    return True


for num in range(x, 10**7):
    if is_prime(num):
        print(num)
        exit()

Measured memory_bytes: 3060
#include <iostream>

using namespace std;

int main() {
    int X = 0, t = 0;
    int result = 0;

    cin >> X >> t;

    
    result = X - t;
    if(result > 0) {
        cout << result << endl;
    } else {
        result = 0;
        cout << result << endl;
    }
}


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

struct node{
  int key;
  struct node *pa;
  struct node *le;
  struct node *ri;
};
typedef struct node* TREE;
TREE root;

void insert(int);
void print();
void inorder(TREE);
void preorder(TREE);

int main(){
  int i,m,num;
  char com[7];

  scanf("%d",&m);
  if(m>500000) exit(2);
  root = NULL;
  for(i=0;i<m;i++){
    scanf("%s",com);
    if(com[0] == 'i'){
      scanf("%d",&num);
      insert(num);
    }
    else print();
  }
  
  return 0;
}

void insert(int key){
  TREE node_root=root,newnode,p,oya=NULL;

  newnode = (TREE)malloc(sizeof(struct node));
  newnode->le = newnode->ri = NULL;
  newnode->key = key;
  p=node_root;
  while(p!=NULL){
    oya=p;
    if(p->key > key) p=p->le;
    else p=p->ri;
  }
  newnode->pa = oya;
  if(oya == NULL){
    root = newnode;
  }else{
    if(oya->key > newnode->key) oya->le = newnode;
    else oya->ri = newnode;
  }
}

void print(){
  inorder(root);
  printf("\n");
  preorder(root);
  printf("\n");
}

void inorder(TREE out){
  if(out == NULL) return;
  inorder(out->le);
  printf(" %d",out->key);
  inorder(out->ri);
}

void preorder(TREE out){
  if(out == NULL) return;
  printf(" %d",out->key);
  preorder(out->le);
  preorder(out->ri);
}



Measured memory_bytes: 25228
#include <iostream>
#include <vector>

using namespace std;

int main(){
    int a, b;
    while(cin >> a >> b){
        vector<int> cnt(5, 0);
        cnt[a]++; cnt[b]++;
        for(int i=0;i<2;i++){
            cin >> a >> b;
            cnt[a]++;
            cnt[b]++;
        }
        int c = 0;
        for(int i=1;i<=4;i++) if(cnt[i]%2 == 1) c++;
        cout << (c == 2 ? "YES" : "NO") << endl;
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cstdlib>
#include <vector>
#include <algorithm>
#include <map>
using namespace std;
int main(){
    int N;cin >> N;
    map<int,int> mp;
    for(int a = 0;a < N;a++){
        int x;cin >> x;
        auto itr = mp.find(x);
        if(itr == mp.end()){
            mp[x] = 1;
        }else{
            mp[x]++;
        }
    }
    int ans  = 0;
    for(auto n:mp){
        ans += n.second%2;
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 4992
#include<iostream>
using namespace std;
int main(){
    int a,b,c;
    cin>>a>>b>>c;
    if((a==b&&b==c)||(a!=b&&b!=c&&a!=c)){
        cout<<"No"<<endl;
    }else{
        cout<<"Yes"<<endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#define MAX 100
#define INFTY 10000001

int main(){
  int i, j, n;
  int M[MAX][MAX];
  int k, c, u, v;
  int minv;
  int d[MAX];
  int vis[MAX];

  scanf("%d", &n);
  
  for (i = 0; i< n; i++){
    for ( j = 0; j < n; j++ ){
      M[i][j] = INFTY;
    }
  }

  for ( i = 0; i < n; i++ ){
    scanf("%d %d", &u, &k);
    for ( j = 0; j < k; j++ ){
      scanf("%d %d", &v, &c);
      M[u][v] = c;
    }
  }

  for ( i = 0; i < n; i++ ) {
    d[i] = INFTY;
    vis[i] = 0;
  }

  d[0] = 0;

  while(1){
    minv = INFTY;
    u = -1;
    for ( i = 0; i < n; i++ ){
      if ( minv > d[i] && !vis[i] ){
        u = i;
        minv = d[i];
      }
    }
    if ( u == -1 ) break;
    vis[u] = 1;
    for ( v = 0; v < n; v++ ){
      if ( !vis[v] && M[u][v] != INFTY ){
        if ( d[v] > d[u] + M[u][v] ){
          d[v] = d[u] + M[u][v];
        }
      }
    }
  }

  for ( i = 0; i < n; i++ ){
    printf("%d %d\n", i, (d[i]==INFTY?-1:d[i]));
  }

  return 0;
}



Measured memory_bytes: 2108
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <climits>
#include <bitset>
#include <utility>
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<pair<int,int>> vpii;
typedef vector<vector<int>> vvi;
typedef vector<vector<char>> vvc;
typedef vector<vector<string>> vvs;
#define rep(i,n) for(int i=0;i<n;i++)
#define repll(i,n) for(long long int i=0;i<n;i++)
#define fin(ans) cout<<(ans)<<endl
#define P 1000000007
#define STI(s) atoi(s.c_str())//string to int
#define mp(p,q) make_pair(p,q)
#define Sort(a) sort(a.begin(),a.end())
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;}
const int INF = INT_MAX;
const long long LLINF = 1LL<<60;
template <typename T_char>
char ToUpper (char cX) { return toupper(cX); }
//g++ -std=c++1z temp.cpp
//./a.exe
int digit(int a){
    int count = 0;
    for (int i = 0; i < a; i++)
    {   if (a == 0)
        {
            break;
        }else
        {
            a = a/10;
            count++;
        }     
    }
    return count;
}
//pow(x,n) == x^n
ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a;}
ll lcm(ll a, ll b) { return a / gcd(a,   b) * b;}

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

int n;
cin >> n;
cout << n*n << endl;






//////////////////////////////////////////////////////
return 0;}

Measured memory_bytes: 256
#a,bの最大公約数
def gcd(a, b):
    while b:
        a, b = b, a % b
    return a

#a,bの最小公倍数
def lcm(a, b):
    return a * b // gcd (a, b)
  

if __name__ == '__main__':
  A, B = map(int, input().split())
  print(lcm(A, B))

Measured memory_bytes: 2940
#include <cstdio>
double a,b;
inline char nc()
{
    static char buf[100000],*p1=buf,*p2=buf;
    return p1==p2&&(p2=(p1=buf)+fread(buf,1,100000,stdin),p1==p2)?EOF:*p1++;
}
inline double read()
{
    char ch=nc();
    double sum=0;
    while(!(ch>='0'&&ch<='9')) ch=nc();
    while(ch>='0'&&ch<='9') sum=sum*10+ch-48,ch=nc();
    return sum;
}
int main()
{
	a=read(),b=read();
	std::printf("%.6lf",a*b/(a+b));
	return 0;
}

Measured memory_bytes: 128
#include<string>
#include<iostream>

using namespace std;

int main() {
	int a, b, n,otori;
	bool www = true;
	
	int ans = 0;
	cin >> n >> a >> b;
	for (int i = 1; i < n+1; i++) {
		otori = i;
		int wa = 0;
		while (otori > 0) {
			wa = wa + otori % 10;
			otori = otori / 10;
		}
		if (wa<=b && wa>=a) {
			ans = ans + i;
		}
    }
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(ll i=0;i<(n);++i)
#define sayyes cout<<"Yes"<<endl;
#define sayno cout<<"No"<<endl;
using namespace std;
typedef long long ll;
const double PI=acos(-1);
typedef pair<int,int>P;
const int mod =1e9+7;

int main()
{
    int a;
    cin>>a;
    cout<<a+a*a+a*a*a;
    
}

Measured memory_bytes: 3616
import java.util.Scanner;

public class Main{
  public static void main(String args[])
  {
    Scanner scanner = new Scanner(System.in);
    int a = scanner.nextInt();
    int b = scanner.nextInt();

    if(a > b){
      System.out.println("a > b");
    }
    else if(a < b){
      System.out.println("a < b");
    }
    else{
      System.out.println("a == b");
    }
  }
}



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

int main() {
  int a, b, c;
  cin >> a >> b >> c;
  bool tf = false;
  rep(i,100010) {
    if ((a * i) % b == c) {
      tf = true;
      break;
    }
  }
  if (tf) cout << "YES" << endl;
  else cout << "NO" << endl;
}

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

public class Main {
    public static void main(String[] args) {
        MyScanner sc = new MyScanner();
        PrintWriter out = new PrintWriter(new BufferedOutputStream(System.out));
        int n = sc.nextInt();
        String s = sc.next();
        int ans = Integer.MAX_VALUE;
        int prefR = 0; int prefW = 0; int sufR = 0; int sufW = 0;
        for (int i = 0; i < n; i++) if (s.charAt(i) == 'R') sufR++; else sufW++;
        for (int i = 0; i < n; i++) {
            int got = Math.min(prefW, sufR);
            ans = Math.min(ans, got + Math.max(i - (prefR + got), (n - i) - (sufW + got)));
            if (s.charAt(i) == 'R') {
                prefR++;
                sufR--;
            } else {
                prefW++;
                sufW--;
            }
        }
        int got = Math.min(prefW, sufR);
        ans = Math.min(ans, got + Math.max(n - (prefR + got), (n - n) - (sufW + got)));
        out.println(ans);
        out.close();
    }


    //-----------MyScanner class for faster input----------
    public static class MyScanner {
        BufferedReader br;
        StringTokenizer st;

        public MyScanner() {
            br = new BufferedReader(new InputStreamReader(System.in));
        }

        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        long nextLong() {
            return Long.parseLong(next());
        }

        double nextDouble() {
            return Double.parseDouble(next());
        }

        String nextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }


    }

}

Measured memory_bytes: 36436
#![allow(unused_imports)]
use std::cmp::*;
use std::collections::*;
use std::io::Write;
use std::ops::Bound::*;

#[allow(unused_macros)]
macro_rules! debug {
    ($($e:expr),*) => {
        #[cfg(debug_assertions)]
        $({
            let (e, mut err) = (stringify!($e), std::io::stderr());
            writeln!(err, "{} = {:?}", e, $e).unwrap()
        })*
    };
}

fn main() {
    let mut l = read::<usize>() - 1;
    let cands = (0..20).map(|x| (1 << x) - 1).collect::<Vec<_>>();

    let mut members = vec![];
    for (i, &cand) in cands.iter().enumerate().rev() {
        if members.is_empty() {
            if cand <= l {
                l -= cand;
                members.push(i);
            }
        } else {
            if cand + 1 <= l {
                l -= cand + 1;
                members.push(i);
            }
        }
    }
    debug!(members, l);

    let mut edges = vec![];
    let mut added = 0;
    for i in 1..members[0] + 1 {
        edges.push((i - 1, i, 0));
        edges.push((i - 1, i, 1 << (i - 1)));
        added += 1 << (i - 1);
    }

    for &mem in members.iter().skip(1) {
        edges.push((mem, members[0], added + 1));
        added += cands[mem] + 1;
    }
    debug!(edges);

    println!("{} {}", members[0] + 1, edges.len());
    for (l, r, c) in edges {
        println!("{} {} {}", l + 1, r + 1, c);
    }
}

fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}


Measured memory_bytes: 2132
import java.util.*;
 
public class Main {
 
  public static void main(String[] args) {
 
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int ans = 1;
    for (int i = 0; i < N; i++) {
      if ((sc.nextInt() % 2) == 0) {
        ans *= 2;
      }
    }
    System.out.println((int)Math.pow(3, N) - ans);
  }
}

Measured memory_bytes: 35684
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
const ll MOD = 1e9 + 7;
const ll INF = 1LL << 60;
const double PI = 3.141592653589793238;
const double EPS = 1e-10;
vector<int> solve(int n, int A, int B) {
	if (n == 1) {
		vector<int> ret;
		ret.push_back(A);
		ret.push_back(B);
		return ret;
	}
	int k = 0;
	while (k < n) {
		if ((A^B)&(1 << k)) break;
		k++;
	}
	int nxtA = 0, nxtB = 0;
	for (int i = n - 1; i >= 0; i--) {
		if (i == k) continue;
		nxtA <<= 1;
		if (A&(1 << i)) nxtA |= 1;
		nxtB <<= 1;
		if (B&(1 << i)) nxtB |= 1;
	}
	int C = nxtA ^ 1;
	vector<int> v1 = solve(n - 1, nxtA, C);
	vector<int> v2 = solve(n - 1, C, nxtB);
	vector<int> ret;
	for (int i = 0; i < v1.size(); i++) {
		int x = 0;
		for (int j = 0; j < n; j++) {
			if (j == k) {
				if (A&(1 << k)) x |= (1 << j);
			}
			else {
				if (v1[i] & 1) x |= (1 << j);
				v1[i] >>= 1;
			}
		}
		ret.push_back(x);
	}
	for (int i = 0; i < v2.size(); i++) {
		int x = 0;
		for (int j = 0; j < n; j++) {
			if (j == k) {
				if (B&(1 << k)) x |= (1 << j);
			}
			else {
				if (v2[i] & 1) x |= (1 << j);
				v2[i] >>= 1;
			}
		}
		ret.push_back(x);
	}
	return ret;
}
int pop_count(int n) {
	int ret = 0;
	for (int i = 0; i < 17; i++) {
		if (n&(1 << i)) ret++;
	}
	return ret;
}
int main() {
	int N, A, B;
	cin >> N >> A >> B;
	if (pop_count(A) % 2 == pop_count(B) % 2) {
		cout << "NO" << endl;
		return 0;
	}
	cout << "YES" << endl;
	vector<int> ret = solve(N, A, B);
	for (int i = 0; i < ret.size(); i++) {
		cout << ret[i] << " ";
	}
	cout << endl;
}


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

vector<long long> V, WTF;
int n;

int main() {
    scanf("%d", &n);
    for(int i = 0; i < n; i++) {
        int x; scanf("%d", &x);
        V.emplace_back(x);
    }
    sort(begin(V), end(V));
    for(int j, i = 0; i < (int)V.size(); i++) {
        j = i;
        while(j < (int)V.size() - 1 && V[j] == V[j + 1]) {
            j++;
        }
        if(i != j) for(int k = 0; k < (j - i + 1) / 2; k ++ )
            WTF.emplace_back(V[i]);
        i = j;
    }
    if(WTF.size() < 2) puts("0");
    else printf("%lld\n", WTF[WTF.size() - 1] * WTF[WTF.size() - 2]);
    return 0;
}


Measured memory_bytes: 1908
#include<bits/stdc++.h> 
//#define <- プログラムの文字列を置換する
//typedef <- 新しい型に名前を付けるためのキーワード

using namespace std;

#define MAX_N 1

typedef long long ll;

const double PI = 3.141592653589793;
const long long MOD = 1e9 + 7;
const long long INF = 1e15;


int main(){
    int N;
    cin >> N;
    vector<int> h(N);
    int mini = 1e9 + 1;
    int mini_num = -1;
    for(int i = 0; i < N ;i++){
        cin >> h[i];
        if(mini > h[i]){
            mini = h[i];
            mini_num = i;
        }
    }
    int count = N;
    while(1){
        for(int i = 0; i < N; i++){
            if(i == mini_num || h[i] <= 0) continue;
            int temp = h[i] / mini;
            h[i] -= temp * mini;
            if(h[i] >= 1 && mini > h[i]){
                mini = h[i];
                mini_num = i;
            }
            if(h[i] <= 0 ) count--;
        }
        if(count == 1) break;
    }
    cout << mini << endl;
    return 0;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
#define F first
#define S second
#define INF (1<<30)
#define LINF (1LL<<60)
using namespace std;
typedef pair<long long,long long> P;
long long b,c,d;
long long a[100005];
string s,s2,s3;
long long  sum=0,ans=0,pos=0;
long long n,m,h,w;
main(){
  cin>>n;
  for(int i=0;i<n;i++){
    cin>>a[i];
  }
  sort(a,a+n);
  vector<P> a2;
  a2.push_back(P(a[0],1));
  pos=0;
  for(int i=1;i<n;i++){
    if(a[i]==a2[pos].F){
      a2[pos].S++;
    }
    else{
      a2.push_back(P(a[i],1));
      pos++;
    }
  }
  ans=0;
  int f=0;
  while(1){
    f=0;
    for(int i=0;i<a2.size()&&f==0;i++){
      if(a2[i].S>=3){
	a2[i].S-=2;
	f=1;
      }
      else if(a2[i].S==2){
	int p2=-1;
	for(int j=a2.size()-1;j>i;j--){
	  if(a2[j].S>=2){
	    a2[j].S--;
	    a2[i].S--;
	    f=1;
	    break;
	  }
	  else if(a2[j].S==1){
	    p2=j;
	  }
	}
	if(f==0){
	  if(p2==-1){
	    for(int j=i-1;j>=0;j--){
	      if(a2[j].S>=1){
		a2[j].S--;
		a2[i].S--;
		f=1;
	      }
	    }
	  }
	  else{
	    a2[p2].S--;
	    a2[i].S--;
	    f=1;
	  }
	}
      }
    }
    if(f==0){
      break;
    }
    ans+=2;
  }
  cout<<n-ans<<endl;
}

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

int abs(int num1){
  if(num1 <0){
    return num1*(-1);
  }else{
    return num1;
  }
}

int main() {
  int n,x,y;
  cin >> n >> x >> y;

  vector<int> num2(n-1);
  for(int i=1;i<=n;i++){
    for(int j=i+1;j<=n;j++){
      int ind;
      ind = min(j-i,abs(x-i)+abs(j-y)+1);
      num2[ind-1]++;
      // cout << ind << endl;
    }
  }
  for(int i=0;i<n-1;i++){
    cout << num2[i] << endl;
  }
}


Measured memory_bytes: 256
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;
import java.io.BufferedReader;
import java.io.FileReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        EActiveInfants solver = new EActiveInfants();
        solver.solve(1, in, out);
        out.close();
    }

    static class EActiveInfants {
        pair[] arr;
        int n;
        long[][] memo;

        public void solve(int testNumber, Scanner sc, PrintWriter pw) {
            n = sc.nextInt();
            arr = new pair[n];
            for (int i = 0; i < n; i++)
                arr[i] = new pair(sc.nextInt(), i);
            Arrays.sort(arr, (a, b) -> b.val - a.val);
            memo = new long[n][n];
            for (long[] x : memo)
                Arrays.fill(x, -1);
            pw.println(dp(0, n - 1));
        }

        private long dp(int l, int r) {
            if (l > r)
                return 0;
            if (memo[l][r] != -1)
                return memo[l][r];
            long takeL = 1l * arr[l + n - 1 - r].val * Math.abs(arr[l + n - 1 - r].idx - l) + dp(l + 1, r);
            long takeR = 1l * arr[l + n - 1 - r].val * Math.abs(arr[l + n - 1 - r].idx - r) + dp(l, r - 1);
            return memo[l][r] = Math.max(takeL, takeR);
        }

        class pair {
            int val;
            int idx;

            public pair(int val, int idx) {
                this.val = val;
                this.idx = idx;
            }

            public String toString() {
                return val + " " + idx;
            }

        }

    }

    static class Scanner {
        StringTokenizer st;
        BufferedReader br;

        public Scanner(FileReader r) {
            br = new BufferedReader(r);
        }

        public Scanner(InputStream s) {
            br = new BufferedReader(new InputStreamReader(s));
        }

        public String next() {
            while (st == null || !st.hasMoreTokens()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return st.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

    }
}



Measured memory_bytes: 83640
#include <algorithm>
#include <bitset>
#include <climits>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <string>
#include <unordered_map>
#include <vector>

#define MOD 1000000007
//#define PI 3.14159265358979

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

using namespace std;

template < typename T >
ostream &operator<<(ostream &os, const vector< T > &A) {
	for (int i = 0; i < A.size(); i++)
		os << A[i] << " ";
	os << endl;
	return os;
}
template <>
ostream &operator<<(ostream &os, const vector< vector< int > > &A) {
	int N = A.size();
	int M;
	if (N > 0)
		M = A[0].size();
	for (int i = 0; i < N; i++) {
		for (int j = 0; j < M; j++)
			os << A[i][j] << " ";
		os << endl;
	}
	return os;
}

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

struct edge {
	int from, to, d, c;
	edge(int _from = 0, int _to = 0, int _d = 0, int _c = 0) {
		from = _from;
		to = _to;
		d = _d;
		c = _c;
	}
	bool operator<(const edge &rhs) const {
		return (d == rhs.d) ? (c < rhs.c) : (d < rhs.d);
	}
};

typedef vector< edge > edges;
typedef vector< edges > graph;
struct flow {
	int to, cap, rev, cost;
	flow(int to = 0, int cap = 0, int rev = 0, int cost = 0) : to(to), cap(cap), rev(rev), cost(cost) {}
};
typedef vector< vector< flow > > flows;

const int di[4] = {0, -1, 0, 1};
const int dj[4] = {-1, 0, 1, 0};
const int ci[5] = {0, 0, -1, 0, 1};
const int cj[5] = {0, -1, 0, 1, 0};
const ll LINF = LLONG_MAX / 2;
const int INF = INT_MAX / 2;
const double PI = acos(-1);

template < typename T, typename U >
bool chmin(T &x, const U &y) {
	if (x > y) {
		x = y;
		return true;
	}
	return false;
}
template < typename T, typename U >
bool chmax(T &x, const U &y) {
	if (x < y) {
		x = y;
		return true;
	}
	return false;
}

struct initializer {
	initializer() {
		cout << fixed << setprecision(11);
	}
};
initializer _____;

int N, M, K, T, Q;
int main() {
	cin >> N;
	vector< int > A(N);
	rep(i, N) cin >> A[i];
	int z, maxabs = 0;
	rep(i, N) if (abs(A[i]) > maxabs) {
		maxabs = abs(A[i]);
		z = i;
	}
	cout << 2 * N << endl;
	if (A[z] > 0) {
		int x = z, y = 0;
		for (y = 0; y < N; y++) {
			cout << x + 1 << " " << y + 1 << endl;
			cout << x + 1 << " " << y + 1 << endl;
			x = y;
		}
	} else {
		int x = z,
			y = N - 1;
		for (y = N - 1; y >= 0; y--) {
			cout << x + 1 << " " << y + 1 << endl;
			cout << x + 1 << " " << y + 1 << endl;
			x = y;
		}
	}
	return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
#define fio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define all(V) (V).begin(), (V).end() 
#define x first
#define y second
using namespace std;
typedef long long ll;
typedef pair <ll, ll> pll;
int cnt = 0;
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...);
}
#ifdef KEK
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

ll intersection(pll a, pll b) {
    return max(min(a.y, b.y) - max(a.x, b.x) + 1, 0LL);
}
ll best(pll st, pll en, vector <pll> &ranges) {
    if(st.y > en.x) {
        swap(st, en);
    }
    if(st == en) {
        if(count(all(ranges), st) == 1) {
            return 0;
        }
    }
    pll lef = st;
    pll rig = en;
    vector <pll> yo;
    for(auto u : ranges) {
        yo.push_back({intersection(u, lef), intersection(u, rig)});
    }
    ll ans = 0;
    sort(all(yo));
    set <ll> mn;
    mn.insert(intersection(rig, rig));
    for(int i = 0; i < yo.size(); i++) {
        ans = max(ans, *mn.begin() + yo[i].first);
        mn.insert(yo[i].second);
    }
    return ans;
}
int main() {fio;
    ll N;
    cin >> N;
    vector <pll> ranges(N);
    ll ans = 0;
    int id = -1;
    for(int i = 0; i < N; i++) {
        cin >> ranges[i].x >> ranges[i].y;
        ans = max(ans, ranges[i].y - ranges[i].x + 1);
        if(ranges[i].y - ranges[i].x + 1 == ans) {
            id = i;
        }
    }
    ll l = -1e13, r = 1e14;
    for(int i = 0; i < N; i++) {
        if(i != id) {
            l = max(l, ranges[i].x);
            r = min(r, ranges[i].y);
        }
    }
    ans += max(0ll, r - l + 1);
    vector <pll> crits;
    sort(all(ranges), [&](pll a, pll b) {
        return a.y < b.y;
    });
    crits.push_back(ranges[0]);
    sort(all(ranges), [&](pll a, pll b) {
        return a.x < b.x;
    });
    crits.push_back(ranges[N - 1]);
    ans = max(ans, best(crits[0], crits[1], ranges));
    cout << ans;
    return 0;
}

Measured memory_bytes: 8048
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
#define For(i, a, b) for (i = a; i <= b; i++)
using namespace std;
inline int read() {
	int res = 0; bool bo = 0; char c;
	while (((c = getchar()) < '0' || c > '9') && c != '-');
	if (c == '-') bo = 1; else res = c - 48;
	while ((c = getchar()) >= '0' && c <= '9')
		res = (res << 3) + (res << 1) + (c - 48);
	return bo ? ~res + 1 : res;
}
const int N = 5e6 + 5, PYZ = 998244353;
int n, K, fac[N], inv[N], ans;
int C(int n, int m) {return n < m ? 0 : 1ll * fac[n] * inv[m] % PYZ * inv[n - m] % PYZ;}
int main() {
	int i; n = read(); K = read(); fac[0] = inv[0] = inv[1] = 1; For (i, 1, 5000000)
		fac[i] = 1ll * fac[i - 1] * i % PYZ;
	For (i, 2, 5000000) inv[i] = 1ll * (PYZ - PYZ / i) * inv[PYZ % i] % PYZ;
	For (i, 2, 5000000) inv[i] = 1ll * inv[i] * inv[i - 1] % PYZ; For (i, n, K) {
		int res = (C(K, i) - C(K, (i << 1) - n + 1) + PYZ) % PYZ;
		ans = (ans + res) % PYZ;
	}
	cout << ans << endl; return 0;
}

Measured memory_bytes: 39424
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <queue>
#include <utility>
#include <cstdlib>
#define maxn 10005
using namespace std;
typedef long long ll;
inline int getint(){
  char c; int res = 0, sig = 1;
  for(c = getchar();c < '0' || c > '9';c = getchar()) if(c == '-') sig = -1;
  for(;c >= '0' && c <= '9';c = getchar()) res = res * 10 + (c - '0');
  return res * sig;
}
int n,a[maxn],b[maxn];
int pri[1235],k;
bool notp[maxn];
int gcd(int x,int y){
  return y ? gcd(y,x % y) : x;
}
bool ok(int p){
  //b: tmp
  for(int i = n;i >= 0;i--) b[i] = a[i];
  for(int i = n;i >= p;i--){
    (b[i - p + 1] += b[i]) %= p;
    b[i] = 0;
  }
  for(int i = min(n,p - 1);i >= 0;i--){
    if(b[i] % p) return false;
  }
  return true;
}
int main(){
  n = getint();
  notp[1] = true;
  for(int i = 2;i <= n;i++){
    if(!notp[i]) pri[++k] = i;
    for(int j = 1;j <= k && pri[j] * i <= n;j++){
      notp[pri[j] * i] = true;
      if(i % pri[j] == 0) break;
    }
  }
  for(int i = n;i >= 0;i--){
    a[i] = getint();
  }
  vector <int> ans;
  for(int i = 1;i <= k;i++) if(ok(pri[i])) ans.push_back(pri[i]);
  int tmp = 0;
  for(int i = n;i >= 0;i--) tmp = gcd(tmp,abs(a[i]));
  for(int i = 2;(ll)i * i <= (ll)tmp;i++){
    if(tmp % i == 0){
      if(i > n) ans.push_back(i);
      while(tmp % i == 0) tmp /= i;
    }
  }
  if(tmp > 1){
    if(ok(tmp) && tmp > n) ans.push_back(tmp);
  }
  sort(ans.begin(),ans.end());
  for(int i = 0;i < (int)ans.size();i++){
    printf("%d\n",ans[i]);
  }
  return 0;
}


Measured memory_bytes: 512
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

using namespace std;
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}

int main(){
  string s;
  cin >> s;
  for(int i = 0; i < s.size(); i+=2) cout << s[i];
  cout << endl;
  return 0;
}


Measured memory_bytes: 512
#include <iostream>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <string>
#include <math.h>
#define ll long long
#define vl vector<ll>
#define vvl vector<vector<ll> >
#define vvvl vector<vector<vector<ll> > >
#define vd vector<double>
#define vvd vector<vector<double> >
#define vvvd vector<vector<vector<double> > >
#define rep(i,a) for(ll i = 0;i<a;++i)
#define mod 1000000007
#define inf 11451419198
using namespace std;

struct node{
	vl next;
	ll cand = -1;
	ll group = -1;
};

void dfs(vector<node> &tree, vector<bool> &visit, vl &hist, ll now, ll *count){
	if (visit[now]) return;
	if (tree[now].cand != -1) return;
	(*count)++;
	visit[now] = true;
	hist.push_back(now);
	for (ll nex : tree[now].next) dfs(tree, visit, hist, nex, count);
}

ll g = 0;

int main(){
	ll n, m, k; cin >> n >> m >> k;
	vector<node> loveTree(n);
	vvl cd(k,vl(2,0));
	rep(i, m){
		ll a, b; cin >> a >> b;
		a--; b--;
		loveTree[a].next.push_back(b);
		loveTree[b].next.push_back(a);
	}
	rep(i, k){
		ll c, d; cin >> c >> d;
		c--; d--;
		cd[i][0] = c;
		cd[i][1] = d;
	}
	rep(i, n){
		vl hist;
		vector<bool> visit(n, 0);
		ll count = 0;
		dfs(loveTree, visit, hist, i, &count);
		rep(j, hist.size()){
			loveTree[hist[j]].cand = count;
			loveTree[hist[j]].group = g;
		}if (count > 0) g++;
	}
	vl dame(n, 0);
	rep(i, k){
		if (loveTree[cd[i][0]].group == loveTree[cd[i][1]].group){
			dame[cd[i][0]]++;
			dame[cd[i][1]]++;
		}
	}
	rep(i, n){
		cout << loveTree[i].cand - loveTree[i].next.size() - dame[i] - 1 << " ";
	}

	return 0;
}

Measured memory_bytes: 16520
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ABC122_A_Double_Helix
{
	class Program
	{
		static void Main(string[] args)
		{
			Dictionary<char, char> valuePairs = new Dictionary<char, char>()
			{
				{'A', 'T' },
				{'T', 'A' },
				{'C', 'G' },
				{'G', 'C' }
			};

			char input = char.Parse(Console.ReadLine());
			Console.WriteLine(valuePairs[input]);
		}
	}
}


Measured memory_bytes: 11104
ar = gets.chomp.split(" ").map{|i|i = i.to_i}
$n = ar[0]
$a = ar[1]
$b = ar[2]
$c = ar[3]
$l_ar = []
$n.times do|i|
    $l_ar << gets.chomp.to_i
end
$l_ar.sort!

def eda(pos, a, b, c)
    #puts "now pos=#{pos}, a=#{a}, b=#{b}, c=#{c}"
    if pos >= $n then
        if [a,b,c].min <= 0 then
            return 10**9 
        else
            return (a-$a).abs + (b-$b).abs + (c-$c).abs - 30
        end
    end

    ret0 = eda(pos + 1, a, b, c)
    ret1 = eda(pos + 1, a + $l_ar[pos], b, c) + 10
    ret2 = eda(pos + 1, a, b + $l_ar[pos], c) + 10
    ret3 = eda(pos + 1, a, b, c + $l_ar[pos]) + 10
    #puts "now [ret0,ret1,ret2,ret3].min = #{[ret0,ret1,ret2,ret3].min}"
    return [ret0,ret1,ret2,ret3].min

end

puts eda(0, 0, 0, 0)



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

int main(){
	int a,b,k;
	
	cin >> a >> b >> k;
	for(int i = a;i < a+k&&i<=b;i++) cout << i << endl;
	for(int i = max(b-k+1,a+k);i<=b;i++) cout << i << endl;
}

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

int main() {
  int n,m;
  cin >> n >> m;
  for(int i=0; i<m; i++) {
    int a; cin >> a;
    n -= a;
  }
  if(n < 0) cout << -1 << endl;
  else cout << n << endl;
}

Measured memory_bytes: 3632
#include "bits/stdc++.h"

// clang-format off
template <typename T> T gcd(T a, T b) { return b == 0 ? a : gcd(b, a % b); }
template <typename T> T lcm(T a, T b) { return a * b / gcd(a, b); }
template <typename T> T clamp(T val, T min, T max) { return val < min ? min : (max < val ? max : val); }
char capitalize(char c) { return static_cast<char>(std::toupper(static_cast<unsigned char>(c))); }
// template <typename T> size_t max_index(T begin, T end) { return distance(begin, max_element(begin, end)); }
// template <typename T> size_t min_index(T begin, T end) { return distance(begin, min_element(begin, end)); }
// clang-format on

// #define int long long
#define YES "YES"
#define NO  "NO"

using namespace std;

signed main(void) {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);

  int num = 0;
  // num = numeric_limits<int>::max();
  // num = numeric_limits<int>::min();
  bool flag = false;
  // flag = true;

  string s; cin >> s;
  deque<char> q;
  for (auto it = s.begin(); it != s.end(); ++it) {
    if (*it == '0') q.push_back('0');
    if (*it == '1') q.push_back('1');
    if (*it == 'B') if (!q.empty()) q.pop_back();
  }

  for (auto it = q.begin(); it != q.end(); ++it) cout << *it;
  cout << endl;
  
  // cout << num << endl;
  // cout << (flag ? YES : NO) << endl;
  
  return 0;
}


Measured memory_bytes: 256
def test():

	# Define the output array
	output = [0] * 50
	num_student = 0

	#A:0
	#B:1
	#C:2
	#D:3
	#F:4
	#NaN:5

	while True:

		# Input stream
		inputs = list(map(int,input().split()))
		
		# exit condition
		if inputs[0] == -1 and inputs[1] == -1 and inputs[2] == -1:
			output[num_student] = 5
			break

		# First condition - F
		if inputs[0] == -1 or inputs[1] == -1:
			output[num_student] = 4
			num_student += 1
			continue
		# Second condition - A
		elif (inputs[0] + inputs[1]) >= 80:
			output[num_student] = 0
			num_student += 1
			continue
		# Third condtion - B
		elif (inputs[0] + inputs[1]) >= 65:
			output[num_student] = 1
			num_student += 1
			continue
		# Fourth condtion - C
		elif (inputs[0] + inputs[1]) >= 50:
			output[num_student] = 2
			num_student += 1
			continue
		# Fifth condition - D or C
		elif (inputs[0] + inputs[1]) >= 30:
			output[num_student] = 3
			if inputs[2] >= 50:
				output[num_student] = 2
			num_student += 1
			continue
		# Sixth condition - F
		else:
			output[num_student] = 4
			num_student += 1
			continue

	for i in range(num_student):
		if output[i] == 0:
			print("A")
		elif output[i] == 1:
			print("B")
		elif output[i] == 2:
			print("C")
		elif output[i] == 3:
			print("D")
		elif output[i] == 4:
			print("F")


if __name__ == "__main__":
	test()


Measured memory_bytes: 5608
#include<iostream>   
#include<string>
#include<vector>
using namespace std; 
 
int main()
{
	int a, b; 
	char op; 
	cin >> a >> op >> b; 
	if (op=='+')
	{
		cout << a + b << "\n";
	} 
	else
	{
		cout << a - b << "\n";
	}
	

}

Measured memory_bytes: 256
import java.util.*

fun main(args: Array<String>) {
  val sc = Scanner(System.`in`)
  val a = sc.nextInt()
  val b = sc.nextInt()
  val k = sc.nextInt()

  val ans = mutableSetOf<Int>()
  for (i in a until a + k) {
    if (i > b) break
    ans.add(i)
  }
  for (j in b downTo b - k + 1) {
    if (j <= a) break
    ans.add(j)
  }

  println(ans.toIntArray().sorted().joinToString("\n"))
}


Measured memory_bytes: 35960
import sys
import re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

A, B, M = MAP()
A_L = LIST()
B_L = LIST()

M_L = []
for i in range(M):
    tmp = LIST()
    M_L.append(tmp)

A_L_min = min(A_L)
B_L_min = min(B_L)
A_B_min_sum = A_L_min + B_L_min

ans = A_B_min_sum
for m in M_L:
    tmp = A_L[m[0]-1] + B_L[m[1]-1] - m[2]
    if tmp < ans:
        ans = tmp
print(ans)


Measured memory_bytes: 40588
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <list>
#include <stdio.h>
#include <stdlib.h>
#include <cmath>
using namespace std;

int N, M, ans = 0;
vector<int> a(30);
vector<int> b(30);
vector<int> c(9,1);
int m[9][9] = {0};

void graph(int d){
  bool flag1 = false;
  if(d == N-1){
    // for(int i = 0; i < N; i++)
    //   cout << c[i] << " ";
    //   cout << endl;
    for(int i = 0; i < N-1; i++){
      if(m[c[i]][c[i+1]]==0)
        flag1 = true;
    }
    if(!flag1)
      ++ans;
  }
  else{
    
    for(int i = 2; i <= N; i++){
      bool flag2 = true;
      for(int j = 1; j <= d; j++){
        if(c[j]==i)
          flag2 = false;
      }
      if(flag2){
        c[d+1] = i;
        graph(d+1);
      }
    }
  }
}

int main(){
  cin >> N >> M;

  for(int i = 0; i < M; i++){
    cin >> a[i] >> b[i];
    m[a[i]][b[i]]=1;
    m[b[i]][a[i]]=1;
  }

  graph(0);

  cout <<ans << endl;
  return 0;
}



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

#define MAXN 105
#define F first
#define S second
#define MP make_pair
#define PB push_back
#define INF 2147483647
#define EPS 1e-9
#define PI 3.141592653589793238462
#define MOD 1000000007
#define REP(i,a,b) for (int i = a; i <= b; i++)
typedef long long LL;
typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<VI > VVI;
typedef vector<PII > VPII;
typedef vector<VPII > VVPII;
typedef map<int,int> MII;

int N, K, a, ans;

int main()
{
    cin >> N >> K;
    REP(i,1,N) {
        cin >> a;
        ans += min(abs(a - 0), abs(K - a)) * 2;
    }
    cout << ans;
    return 0;
}


Measured memory_bytes: 256
N,K=list(map(int, input().split()))
A=list(map(int, input().split()))

MOD=10**9+7

def count(A,N):
    arr=[0]*N
    for i, ai in enumerate(A[:-1]):
        cnt=0
        for aj in A[i+1:]:
            if ai > aj:
                cnt+=1
        arr[i]=cnt
    return arr

s1=sum(count(A,N))
s2=sum(count(sorted(A,reverse=True),N))
v=K*(K-1)//2
print((s1*K+v*s2)%MOD)

Measured memory_bytes: 3188
n=int(input())
A=list(map(int,input().split()))
B=list(map(int,input().split()))
ans=0
c=0
for i in range(n):
    if A[i]-(B[i]+c) >= 0:
        ans += B[i]+c
        c=0
    else:
        ans += A[i]
        c = B[i] - max(A[i] - c,0)
ans += min(A[-1],c)
print(ans)

Measured memory_bytes: 18624
# coding: utf-8
H, W = list(map(int, input().split()))

if (W == 1) | (H == 1):
    print(1)
else:
    if H % 2 == 1:
        h1 = H // 2 + 1
        h2 = H // 2
        if W % 2 == 1:
            print((h1+h2)*(W//2) + h1)
        else:
            print((h1+h2)*(W//2))
    else:
        print(H // 2 * W)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define ALL(v) v.begin(), v.end()
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rep1(i, n) for(int i = 1; i <= (int)(n); i++)
using namespace std;
typedef long long ll;

int main() {
ll n;
 cin>>n;
  ll num[n];
  ll sumn=0; 
  rep(i, n){
    cin>>num[i];
  sumn+=num[i];}
  
  ll dis[n];
  rep(i, n-1){
    dis[i]=num[i+1]-num[i];}
  dis[n-1]=num[0]-num[n-1];
  
  if(sumn%((n+1)*n/2)!=0){
    cout<<"NO"<<endl;
    return 0;}
  
  ll cnt=sumn/((n+1)*n/2);
  
  rep(i, n){
    if(num[i]<cnt){
      cout<<"NO"<<endl;
      return 0;}
  }
  
  ll ccnt=0;
  
  rep(i, n){
    if((cnt-dis[i])%n!=0){
      cout<<"NO"<<endl;
      return 0;}
    ccnt+=(cnt-dis[i])/n;
  }
  
  if(ccnt==cnt){
    cout<<"YES"<<endl;}
  else{
    cout<<"NO"<<endl;}
  
  return 0;

  
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
typedef long long ll;
#define REP(i,n) for(int i=0;i<n;i++)
#define ALL(x) (x).begin(),(x).end()
using namespace std;

//素因数分解
vector<pair<ll,int>> factorize(ll n){
    vector<pair<ll,int>>res;
    for(ll i=2;i*i<=n;i++){
        if(n%i)continue;
        res.emplace_back(i,0);
        while (n%i == 0)
        {
        n /= i;
        res.back().second++;
        }
        
    }
    if(n != 1) res.emplace_back(n,1);
    return res;
}

void trace(int A[],int N){
    REP(i,N){
        if(i>0)printf(" ");
        printf("%d",A[i]);
    }
    printf("\n");
}


int main(){
    int A,B,h;
    cin >> A >> B >> h;
    int ans = ((A+B)*h)/2;
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,l,r) for((i)=(l);(i)<(r);(i)++)
#define MOD 1000000007
#define ll long long
using namespace std;
int main(){
    int n,m;
    cin>>n>>m;
    int s[m][n+1],p[m],k[m],i,j;
    rep(i,0,m){
        cin>>k[i];
        rep(j,0,k[i]){
            cin>>s[i][j];
            s[i][j]--;
        }
    }
    rep(i,0,m)cin>>p[i];

    int ans=0,bit;
    rep(bit,0,1<<n){
        int ok=1;
        rep(i,0,m){
            int swi=0;
            rep(j,0,k[i]) if(bit&(1<<s[i][j]))swi++;
            if(swi%2!=p[i])ok=0;
        }
        if(ok)ans++;
    }

    cout<<ans<<endl;
}

Measured memory_bytes: 256
#include<string>
#include<iostream>

using namespace std;

bool isvalid(string s)
{
	if(s.length()%2==1)	return false;
	for(int i=0;i<s.length();i+=2){
		int c=s[i]-'0'-1,r=s[i+1]-'0'-1;
		if(!(0<=c && c<=5 && 0<=r && r<=4))	return false;
	}
	return true;
}

int main()
{
	char code[]="abcdefghijklmnopqrstuvwxyz.?! ";
	string s;
	while(cin>>s){
		if(isvalid(s)){
			for(int i=0;i<s.length();i+=2)
				cout<<code[(s[i]-'0'-1)*5+(s[i+1]-'0'-1)];
			cout<<endl;
		}
		else	cout<<"NA"<<endl;
	}

	return 0;
}

Measured memory_bytes: 0