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

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int a = Integer.parseInt(sc.next());
        int b = Integer.parseInt(sc.next());
        int[] c = {1,2,3};
        boolean isOdd = false;
        for (int eachC : c) {
            if ((a * b * eachC) % 2 == 1) {
                isOdd = true;
            }
        }
        if (isOdd) {
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }
    }
}


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

int main() {
  int N, W;
  cin >> N >> W;
  
  vector<ll> w(N), v(N);
  for (int i = 0; i < N; i++) {
    cin >> w.at(i) >> v.at(i);
  }
  
  vector<ll> dp(W + 1, -1);
  dp.at(0) = 0;
  for (int i = 0; i < N; i++) {
    for (int j = W; j >= 0; j--) {
      if (j - w.at(i) >= 0) {
        dp.at(j) = max(dp.at(j), dp.at(j - w.at(i)) + v.at(i));
      }
    }
  }
  
  ll ans = 0;
  for (int i = 0; i <= W; i++) {
    if (dp.at(i) > ans) ans = dp.at(i);
  }
  
  cout << ans << endl;
  
  return 0;
}

Measured memory_bytes: 1024
#include<cstdio>

using namespace std;

int pazzle[16][16];
bool check[16][16];

int main(void){
	int n;
	while(scanf("%d", &n) != EOF){
		while(n-- > 0){
			
			//ツ渉可甘コツ可サ
			for(int i = 0; i < 9; i++){
				for(int j = 0; j < 9; j++){
					check[i][j] = false;
				}
			}
			
			//ツパツズツδ仰づ個禿偲ヲ
			for(int i = 0; i < 9; i++){
				for(int j = 0; j < 9; j++){
					scanf("%d", &pazzle[i][j]);
				}
			}
			
			//ツ可。ツ板サツ津ィ
			for(int i = 0; i < 9; i++){
				for(int j= 0; j < 9; j++){
					for(int k = j+1; k < 9; k++){
						if(pazzle[i][j] == pazzle[i][k]){
							check[i][j] = true;
							check[i][k] = true;
						}
					}
				}
			}
			
			//ツ縦ツ板サツ津ィ
			for(int i = 0; i < 9; i++){
				for(int j= 0; j < 9; j++){
					for(int k = j+1; k < 9; k++){
						if(pazzle[j][i] == pazzle[k][i]){
							check[j][i] = true;
							check[k][i] = true;
						}
					}
				}
			}
			
			//3*3ツ板サツ津ィ
			for(int i = 0; i < 9; i++){
				for(int j = 0; j < 9; j++){
					for(int k = j+1; k < 9; k++){
						int ax=3*(i/3)+j/3,ay=3*(i%3)+j%3;
						int bx=3*(i/3)+k/3,by=3*(i%3)+k%3;
//						printf("[%d][%d] | [%d][%d]\n",ax,ay,bx,by);
						if(pazzle[ax][ay] == pazzle[bx][by]){
							check[ax][ay] = true;
							check[bx][by] = true;
						}
					}
				}
			}
							
			
			for(int i = 0; i < 9; i++){
				for(int j = 0; j < 9; j++){
					printf("%c%d", check[i][j]?'*':' ',pazzle[i][j]);
				}puts("");
			}
			if(n>0)puts("");
		}
	}
	
	return 0;
}

Measured memory_bytes: 0
int main(){
    int a,b,ans[100],n=0;
    char c;
    while(1){
        scanf("%d %c %d",&a,&c,&b);
        if(c=='?'){
            break;
        }else{
            switch(c){
                case '+':
                    ans[n]=a+b;
                    break;
                case '-':
                    ans[n]=a-b;
                    break;
                case '*':
                    ans[n]=a*b;
                    break;
                case '/':
                    ans[n]=a/b;
                    break;
                default:
                    break;
            }
            n++;
        }
    }
    for(int i=0;i<n;i++){
        printf("%d\n",ans[i]);
    }
}



Measured memory_bytes: 2064
#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<bits/stdc++.h>
#define ld long double
#define ll long long int
#define ull unsigned long long intS
#define rep(i,n) for(int i=0;i<n;i++)
#define fin(ans) cout<<(ans)<<endl
#define in(n) cin>>n>>
#define INF INT_MAX
#define vi vector<int>
#define vc vector<char>
#define vs vector<string>
#define vpii vector<pair<int,int> >
#define vvi vector<vector<int> >
#define vvc vector<vector<char> >
#define vvs vector<vector<string> >
#define P 1000000007
using namespace std;
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 long long LLINF=1LL<<60;
//set<int>::iterator it;


int main(void){ios::sync_with_stdio(false);cin.tie(0);
//////////////////////////////////////////////////////
    
    
    int x,a;
    
    cin >> x>>a;
    
    
    if(x<a){
    
    cout << '0' << endl;
    }else{
    
    cout << "10" << endl;
    
    }
    
    

return 0;}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
using ld=long double;
using pll=pair<ll,ll>;
using plll=pair<ll,pll>;
using graph=vector<vector<int>>;
using wgraph=vector<vector<pll>>;

const ll MOD=1000000007;
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};

ll abs1(ll a){
  if(a>=0)return a;
  else return -a;
}

ll pow1(ll a,ll b,ll p=LLONG_MAX){
  ll ret=1;
  while(b!=0){
    if((b&1)==1){
      ret*=a;
    }
    a*=a;
    if(a>=p)a%=p;
    b=b>>1;
  }
  return ret;
}

int digit(ll a,ll b){
  int i=0;
  while(a!=0){
    a/=b;
    i++;
  }
  return i;
}

ll gcd1(ll a,ll b){
  if(a==0 && b==0)return 0;
  ll n;
  while(a%b!=0){
    n=a%b;
    a=b;
    b=n;
  }
  return b;
}

ll solveLinear(ll n,ll m,ll c){
  if(n==0 && m==0)return 0;
  ll a[100],b[100];
  a[0]=n;b[0]=m;
  int i=1;
  while(b[i-1]!=0){
    a[i]=b[i-1];
    b[i]=a[i-1]%b[i-1];
    i++;
  }
  n=i;
  if(c%a[n-1]!=0){
    return 0;
  }
  ll x=c/a[n-1],y=0;
  for(i=1;i<n;i++){
    ll cnt=x;
    x=y;
    y=cnt-(a[n-i-1]/b[n-i-1])*y;
  }
  return x;
}

ll modRev(ll a,ll p=MOD){
  a%=p;
  ll n=solveLinear(a,p,1);
  n%=p;
  if(n<0)return n+p;
  return n;
}

ll fact(ll n,ll p=MOD){
  if(n<0)return 0;
  int i;
  ll ret=1;
  for(i=0;i<n;i++){
    ret=ret*(i+1);
    if(ret>=p)ret%=p;
  }
  return ret;
}

ll perm(ll n,ll k,ll p=MOD){
  if(n<0 || k<0 || n<k)return 0;
  int i;
  ll ret=1;
  for(i=0;i<k;i++){
    ret=ret*(n-i);
    if(ret>=p)ret%=p;
  }
  return ret;
}

ll binom(ll n,ll k,ll p=MOD){
  if(n<0 || k<0 || n<k)return 0;
  int i;
  ll ret=1,fact=1;
  for(i=0;i<k;i++){
    ret=ret*(n-i);
    fact*=i+1;
    if(ret>=p)ret%=p;
    if(fact>=p)fact%=p;
  }
  return (ret*modRev(fact))%p;
}

void pushHeap(vector<ll>& h,int n){
  int i=h.size();
  h.push_back(n);
  while(i!=0 && h[(i-1)/2]<h[i]){
    swap(h[i],h[(i-1)/2]);
    i=(i-1)/2;
  }
  h[i]=n;
}

ll popHeap(vector<ll>& h){
  int n=h.size()-1;
  if(n==-1)return 0;
  ll i,ret=h[0];
  swap(h[0],h[n]);
  h.pop_back();
  for(i=0;i<n;){
    int j=2*i+1;
    if(j>=n)break;
    if(j!=n-1 && h[j]<h[j+1])j++;
    if(h[i]<h[j]){
      swap(h[i],h[j]);
    }
    i=j;
  }
  return ret;
}

int bis(vector<int> v,int key){
  int left=-1,right=v.size();
  while(abs1(right-left)>1){
    int mid=left+(right-left)/2;
    if(v[mid]<=key)left=mid;
    else right=mid;
  }
  return left;
}

vector<int> aoki,taka;
void dfsa(const graph &g,int v,int p,int d){
  aoki[v]=d;
  for(auto i:g[v]){
    if(i==p)continue;
    dfsa(g,i,v,d+1);
  }
}

void dfst(const graph &g,int v,int p,int d){
  taka[v]=1;
  for(auto i:g[v]){
    if(i==p)continue;
    if(aoki[i]<=d+1){
      continue;
    }
    dfst(g,i,v,d+1);
  }
}

int main(){
  int i,j,k,cnt=0;
  int n,u,v;
  cin>>n>>u>>v;
  graph g(n);
  for(i=0;i<n-1;i++){
    int a,b;
    cin>>a>>b;
    a--;b--;
    g[a].push_back(b);
    g[b].push_back(a);
  }
  aoki.assign(n,0);
  taka.assign(n,0);
  dfsa(g,v-1,-1,0);
  dfst(g,u-1,-1,0);
  int ans=0;
  for(i=0;i<n;i++){
    if(taka[i]!=0)ans=max(ans,aoki[i]-1);
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 11648
import numpy as np

N = int(input())
A = np.array(list(map(int, input().split())))
B = np.array(list(map(int, input().split())))
C = -np.array(list(map(int, input().split())))

A.sort()
B.sort()
C.sort()

a = np.searchsorted(A, B, side='left')
c = np.searchsorted(C, -B, side='left')

print((a * c).sum())

Measured memory_bytes: 25472
#include <iostream>
#include <iomanip>
#include <string>
#include <algorithm>
#include <functional>
#include <set>
#include <map>
#include <unordered_map>
#include <queue>
#include <deque>
#include <cmath>
#include <cstdio>

using namespace std;

typedef long long ll;

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) for (int i = 0; i < (n); ++i)

int main(int argc, char **argv)
{
    int s;
    cin >> s;

    set<int> a;
    a.insert(s);
    int prev = s;
    int itr = 1;
    while (true) {
        itr++;
        int next;
        if (prev % 2 == 0) {
            next = prev / 2;
        }
        else {
            next = 3 * prev + 1;
        }
        if (a.find(next) != a.end()) {
            break;
        }
        else {
            a.insert(next);
            prev = next;
        }
    }
    cout << itr << endl;

    return 0;
}


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

int main()
{
    int n,c=0;
    cin>>n;
    int p[n];
    for(int i=0;i<n;i++)
        cin>>p[i];
    for(int i=0;i<n;i++)
    {
        if(p[i]!=i+1)
            c++;
    }
    if(c==0||c==2)
        cout<<"YES";
    else
        cout<<"NO";
    return 0;
}

//YES You can sort p in ascending order by swapping p 1 and p5


Measured memory_bytes: 3624
#include <bits/stdc++.h>
#define REP(i,a,b) for(int i=(a);i<(b);i++)
#define RREP(i,a,b) for(int i=(a);i>=(b);i--)
#define pq priority_queue
#define P pair<int,int>
#define P2 pair<int,P>
#define P3 pair<int,P2>
typedef long long ll; typedef long double ld;
using namespace std;
const int INF=1e9, MOD=1e9+7, around[]={0,1,1,-1,-1,0,-1,1,0,0};
const ll LINF=1e18;
const ld PI=abs(acos(-1));
int li[30];
string s;

int main(){
	cin >> s;
	REP(i,0,s.size()) li[s[i]-'a']++;
	
	ll c=1;
	REP(i,0,s.size()){
		li[s[i]-'a']--;
		REP(j,0,30) if(s[i]-'a'!=j) c+=li[j];
	}
	
	cout << c << endl;
	return 0;
}



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

using namespace std;

typedef long long ll;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef vector<int> vi;

// Common memset settings
//memset(memo, -1, sizeof memo); // dp memoization with -1
//memset(arr, 0, sizeof arr); //clear array of integers




int main(){
	//ios::sync_with_stdio(0);
	//cin.tie(0);
	
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);

	int n;

	cin >> n;

	string s;

	cin >> s;


	if(n&1){
		cout << "No";
	}else{
		int mid = n/2;

		bool flag = true;
		for(int i =0;i<mid;i++){

			if(s[i] != s[i+mid]){
				flag = false;
				break;
			}
		}

		if(flag){
			cout << "Yes";
		}else{
			cout << "No";
		}
	}
	

	return 0;
}





Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main()
{
	int a=0 , b=0 , c= 0 , x=0 , y=0 ;
	cin >> a >> b >> c ;
	if (a>b)
	{
		x=a ;
		y=b ;
		a=y ;
		b=x ;
	}
	if (b>c)
	{
		x=b ;
		y=c ;
		b=y ;
		c=x ;
	}
	if (a>b)
	{
		x=a ;
		y=b ;
		a=y ;
		b=x ;
	}
	cout << a << " " << b << " " << c << endl ;
	return 0 ;
}


Measured memory_bytes: 3068
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (int)n; i++)
#define ALL(a) (a).begin(), (a).end()
const ll mod = 1e9 + 7;

int main()
{
    int n;
    cin >> n;
    vector<ll> a(3 * n);
    rep(i, 3 * n) cin >> a[i];
    sort(ALL(a));
    ll sum = 0;
    rep(i, n)
    {
        sum += a[3 * n - 2 - 2 * i];
    }
    cout << sum << endl;
    return 0;
}

Measured memory_bytes: 2560
#include <iostream>
#include <vector>
#include <utility>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <iomanip>

using namespace std;

typedef long long ll;

int main(void)
{
	string a, b;
	cin >> a >> b;
	string c = b + a;

	cout << c << endl;

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
  int n; cin>>n; vector<int> v(n);
  for(int i=0;i<n;i++) cin>>v[i];
  int mintill_now=v[0]; int ans=1;
  for(int i=1;i<n;i++){
    if(v[i]<mintill_now){ ans++; mintill_now=v[i];}
  }
  cout<<ans;
  return 0;
}

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


int main()
{
	vector<int> v;
	int q;
	int query;
	cin >> q;
	while (q--) {
		cin >> query;
		switch (query)
		{
		case 0:
		{
			int x;
			cin >> x;
			v.push_back(x);
		}
			break;
		case 1:
		{
			int p;
			cin >> p;
			cout << v[p] << endl;
		}
			break;
		case 2:
			v.pop_back();
			break;
		default:
			break;
		}
	}
    return 0;
}


Measured memory_bytes: 3848
#include <iostream>
#include <climits>
#include <stdio.h>

using namespace std;

int main (int argc, char *args[])
{
  int n;
  cin >> n;

  int total = 0;
  int min_dec = INT_MAX;
  for( int i = 0;i < n;++i )
  {
    int s;
    cin >> s;
    total += s;
    if( s % 10 != 0 && s < min_dec )
    {
      min_dec = s;
    }
  }

  if( total % 10 != 0 )
    cout << total;
  else if( min_dec != INT_MAX )
    cout << (total - min_dec);
  else
    cout << 0;
  return 0;
}  

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(v) v.begin(),v.end()
#define len(x) (ll)(x).length()
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
const int INF=1e9;
const int di[] = {-1,0,1,0};
const int dj[] = {0,-1,0,1};

int main(){
  string s;
  cin>>s;
  int ans=1;
  for(int i=1;i<len(s);i++){
    if(s[i]==s[i-1]&&i==len(s)-1){
      continue;
    }
    if(s[i]==s[i-1]&&i==len(s)-2){
      ans++;
      break;
    }
    if(s[i]==s[i-1]&&i!=len(s)-1){
      i+=2;
      ans+=2;
      continue;
    }
    ans++;
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 3732
from bisect import bisect

n = int(input())
a = sorted(map(int, input().split()))
b = sorted(map(int, input().split()))
c = sorted(map(int, input().split()))

ans = 0
bb = [n-bisect(c, b[i])  for i in range(n)]
bbb = []
tmp = 0
for i in range(n)[::-1]:
    tmp += bb[i]
    bbb.append(tmp)
bbb = bbb[::-1]
j = 0
while i < n:
    j = bisect(b, a[i], j,n-1)
    if b[j] <= a[i]:
        break
    ans += bbb[j]
    i += 1

print(ans)


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

		public static void main(String [] args) {
				
			Scanner in = new Scanner(System.in);
			
				
			int n = in.nextInt();
			String [] arr = new String [n];
			String [] arr2 = new String [n];
			
				
			for(int i = 0; i < n; i++) {
					String s = in.next();
					arr[i] = s;
					arr2[i] = s;
				}
			
			
			for(int j = 0; j < n - 1; j++) {
				
				
				for(int h = n - 1; h > j ; h--) {
					int cardVal = Integer.parseInt(arr[h].replaceAll("\\D", ""));
					int cardVal2 = Integer.parseInt(arr[h - 1].replaceAll("\\D", ""));
					if(cardVal < cardVal2) {
						String temp = arr[h];
						arr[h] = arr[h - 1];
						arr[h - 1] = temp;
						
					}
				}
			}
			
			for(int k = 0; k < n; k++) {
				System.out.print(arr[k]);
				
				if(k != n - 1) {
					System.out.print(" ");
				}
			}
			
			System.out.println("\nStable");
			
			
			String stable = "Stable";
			for(int j = 0; j < n; j++) {
				
				int minIndex = j;
				int jCardVal = Integer.parseInt(arr2[j].replaceAll("\\D", ""));
				boolean existsEqual = false;
				int equalIndex = Integer.MAX_VALUE;
				
				
				for(int h = j + 1; h < n; h++) {
					int cardVal = Integer.parseInt(arr2[h].replaceAll("\\D", ""));
					int minCardVal = Integer.parseInt(arr2[minIndex].replaceAll("\\D", ""));
					
					
					if(cardVal == jCardVal) {
						existsEqual = true;
						equalIndex = h;
					}
					if(cardVal < jCardVal && cardVal < minCardVal) {
						minIndex = h;
						
					}
					
					
				}
				
				if(j != minIndex) {
					String temp = arr2[j];
					arr2[j] = arr2[minIndex];
					arr2[minIndex] = temp;
					if(existsEqual && minIndex > equalIndex) {
						stable = "Not stable";
					}
				}
			}
			for(int k = 0; k < n; k++) {
				System.out.print(arr2[k]);
				
				if(k != n - 1) {
					System.out.print(" ");
				}
			}
			
			System.out.println("\n" + stable);
			
		}
	}





Measured memory_bytes: 31136
I = [-1,0,1]
J = [-1,0,1]

H, W = map(int,input().split(' '))
S = [input() for i in range(H)]

for i in range(len(S)):
    new_line = ''
    for j in range(len(S[i])):
        if S[i][j]=='.':
            count = 0
            for x in I:
                for y in J:
                    if 0 <= x+i < len(S) and 0 <= y+j < len(S[i]):
                        if S[x+i][y+j] == '#':
                            count = count + 1
            new_line = new_line + str(count)
        else:
            new_line = new_line + '#'

    print(new_line)


Measured memory_bytes: 3064
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <bits/stdc++.h>

using namespace std;
using ll = long long;
ll gcd(ll a, ll b);
int main(){
cin.tie(0);
char a;
 cin >>a;
 if(isupper(a))cout<<"A";
 else cout << "a";
  

return 0;
}






ll gcd(ll a, ll b){

   if (a%b == 0)
   {
       return(b);
   }
   else
   {
       return(gcd(b, a%b));
   }

}


Measured memory_bytes: 3620
#include<bits/stdc++.h>
using namespace std;
long long int t(long long int a,long long int b)
{
        long long int p=b-a+1;
        return (a+b)*p/2;
}
int main()
{
        long long int n,k;
        long long int s=0;
        long long mod=1000000007;
        cin>>n>>k;
        {
            for(long long int i=k-1; i<=n; i++)
            {
                s+=t(n-i,n)-t(0,i)+1;
            }
        }
        cout<<s%mod;
    }


Measured memory_bytes: 3632
#include <iostream>
#include <vector>
#include <queue>

using namespace std;

int main()
{
  int nnode, nedge;
  cin >> nnode >> nedge;
  vector<vector<int>> graph(3*nnode);
  for (int i = 0; i < nedge; i++) {
    int dst, src;
    cin >> src >> dst;
    src--;
    dst--;
    graph.at(3*src+0).push_back(3*dst+1);
    graph.at(3*src+1).push_back(3*dst+2);
    graph.at(3*src+2).push_back(3*dst+0);
  }
  int start, goal;
  cin >> start >> goal;
  start--;
  goal--;
  vector<int> score(3*nnode, -3);
  queue<int> q;
  score.at(3*start) = 0;
  q.push(3*start);
  while (!q.empty()) {
    int index = q.front();
    q.pop();
    if (index == 3*goal) {
      break;
    }
    for (int x : graph.at(index)) {
      if (score.at(x) == -3) {
        score.at(x) = score.at(index)+1;
        q.push(x);
      }
    }
  }
  cout << score.at(3*goal)/3 << '\n';
  return 0;
}


Measured memory_bytes: 17792
from collections import deque


H, W = map(int, input().split())
Ch, Cw = map(lambda x:int(x) - 1, input().split())
Dh, Dw = map(lambda x:int(x) - 1, input().split())
S = [list(input()) for _ in range(H)]


dh = [0, 0, 1, -1]
dw = [1, -1, 0, 0]
INF = float('inf')


def main():
    dist = [[INF] * W for i in range(H)]
    que = deque()
    dist[Ch][Cw] = 0
    que.append([Ch, Cw])

    # 01-BFS
    while que:
        h, w = que.popleft()
        d = dist[h][w]
        for i in range(4):
            nh = h + dh[i]
            nw = w + dw[i]
            if nh < 0 or nw < 0 or nh >= H or nw >= W:
                continue
            if S[nh][nw] == '#':
                continue
            if dist[nh][nw] <= d:
                continue
            dist[nh][nw] = d
            que.appendleft([nh, nw])
        
        # 魔法
        for mh in range(-2, 3):
            for mw in range(-2, 3):
                nh = h + mh
                nw = w + mw
                if nh < 0 or nw < 0 or nh >= H or nw >= W:
                    continue
                if S[nh][nw] == '#':
                    continue
                if dist[nh][nw] <= d + 1:
                    continue
                dist[nh][nw] = d + 1
                que.append([nh, nw])
    
    ans = dist[Dh][Dw]
    if ans == INF:
        ans = -1
    print(ans)


if __name__ == "__main__":
    main()



Measured memory_bytes: 168232
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < n; i++)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pi;
typedef pair<ll, ll> pl;
const double EPS = 1e-9;
const ll MOD = 1000000007;
const int inf = 1 << 30;
const ll linf = 1LL << 60;
const double PI = 3.14159265358979323846;

int n, k;

int main() {
    cin >> n >> k;
    cout << n-k+1 << endl;
}

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

int main(){
  int n;
  int sum=0;
  cin >> n;
  vector<int> l(n);
  for(int i=0;i<n;i++){
    cin >> l[i];
  }
  sort(l.begin(),l.end());
  for(int i=0;i<n-1;i++){
    sum += l[i];
  }
  if(sum>l[n-1]){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
n=int(input())
l=list(map(int,input().split()))
d={}
ans=0
for i in l:
    if i not in d:
        d[i]=1
    else:
        d[i]+=1
for i in d.keys():
    x=d[i]*(d[i]-1)//2
    ans+=x
for i in l:
    if d[i]>2:
        print(ans-(d[i]*(d[i]-1)//2)+((d[i]-1)*(d[i]-2)//2))
    elif d[i]==2:
        print(ans-1)
    else:
        print(ans)
    


Measured memory_bytes: 26268
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i,n) for(ll i=0;i<n;++i)
#define P pair<ll,ll>
#define Graph vector<vector<P>>
#define fi first
#define se second
constexpr ll mod=1000000007;
constexpr ll INF=(1ll<<60);
constexpr double pi=3.14159265358979323846;
template<typename T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;} return 0;}
template<typename T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;} return 0;}

int main(){
    ll a,b,k;cin>>a>>b>>k;
    if(a<k){
        k-=a;
        cout<<0<<" "<<max(0ll,b-k)<<endl;
    }else{
        cout<<a-k<<" "<<b<<endl;
    }
    return 0;
}

Measured memory_bytes: 3608
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#include <math.h>

int main()
{
  char str[1003];
  scanf("%s", str);
  int n = strlen(str);
  if(str[n-1] == 's'){
    str[n] = 'e';
    str[n+1] = 's';
    str[n+2] = '\0';
  }else{
    str[n] = 's';
    str[n+1] = '\0';
  }


  printf("%s\n", str);
  return 0;
}

Measured memory_bytes: 1664
K = gets.chomp.to_i

a = %w|0 1 2 3 4 5 6 7 8 9|

lun_s = '0'
digit = 1





(0...10**5).each do |i|

  if a[i][0].to_i-1 >= 0
    a << (a[i][0].to_i-1).to_s + a[i]
  end

  if a[i][0].to_i >= 0
    a << (a[i][0].to_i).to_s + a[i]
  end

  if a[i][0].to_i+1 < 10
    a << (a[i][0].to_i+1).to_s + a[i]
  end

  break if i == K

end

puts (a.map(&:to_i).uniq.sort)[K]



Measured memory_bytes: 45564
#include<iostream>
#include<string>
#include<sstream>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<cmath>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<numeric>
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
using ll = long long;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;
int dx[4] = {1,0,-1,0}, dy[4] = {0,1,0,-1};

int main()
{

    ll N;
    cin >> N;
    map<string,ll> s;
    ll t[N+1];
    string title;
    ll time;
    t[0] = 0;
    for (ll i=1; i<N+1; ++i)
    {
        cin >> title >> time;
        s.insert(make_pair(title, i));
        t[i] = t[i-1] + time;
    }
    string X;
    cin >> X;

    ll idx = s[X];
    ll ans = t[N] - t[idx];
    cout << ans << endl;
    return 0;
}

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


int main() {
    int sx,sy,tx,ty;
    cin>>sx>>sy>>tx>>ty;
    
    for(int i = 1; i <= ty-sy;i++){
        cout<<'U';
    }
    for(int i = 1 ; i <= tx-sx;i++){
        cout<<'R';
    }
    for(int i = 1; i <= ty-sy;i++){
        cout<<'D';
    }
    for(int i = 1 ; i <= tx-sx;i++){
        cout<<'L';
    }
    cout<<'L';
    for(int i = 1 ; i <= ty-sy;i++){
        cout<<'U';
    }
    cout<<'U';
    cout<<'R';
    for(int i = 1 ; i <= tx-sx;i++){
        cout<<'R';
    }
    cout<<'D';
    cout<<'R';
    for(int i = 1; i <= ty-sy;i++){
        cout<<'D';
    }
    cout<<'D';
    cout<<'L';
    for(int i = 1 ; i <= tx-sx;i++){
        cout<<'L';
    }
    cout<<'U';
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int a, b;

int main(){
	scanf("%d", &a);
	for(int i=1; a%10!=0; i++){
		a=a-1;
		b=i;
	}
	if(b==3)printf("bon");
	else if ((b==0) || (b==1) || (b==6) || (b==8)) printf("pon");
	else printf("hon");
	return 0;
}

Measured memory_bytes: 1728
using System;
using System.Linq;
using System.Collections.Generic;

namespace AtCoder.Contests.ABC166
{
    /// <summary>
    /// 
    /// </summary>
    static class A
    {
        static void Main(string[] args)
        {
            var s = Next();
            Console.WriteLine(s == "ABC" ? "ARC" : "ABC");
        }

        #region Console
        static int _index = 0;
        static string[] _buffer;

        static string Next()
        {
            if (_buffer == null || _index >= _buffer.Length)
            {
                _buffer = Console.ReadLine().Split();
                _index = 0;
            }

            return _buffer[_index++];
        }
        static int NextInt()
        {
            return int.Parse(Next());
        }
        static long NextLong()
        {
            return long.Parse(Next());
        }
        static int ReadInt()
        {
            return int.Parse(Console.ReadLine());
        }
        static long ReadLong()
        {
            return long.Parse(Console.ReadLine());
        }
        static int[] ReadIntArray()
        {
            return Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
        }
        static int[] ReadIntArray(int n)
        {
            var a = new int[n];
            for (int i = 0; i < n; i++)
            {
                a[i] = ReadInt();
            }
            return a;
        }
        static long[] ReadLongArray()
        {
            return Console.ReadLine().Split(' ').Select(long.Parse).ToArray();
        }
        static long[] ReadLongArray(int n)
        {
            var a = new long[n];
            for (int i = 0; i < n; i++)
            {
                a[i] = ReadLong();
            }
            return a;
        }
        static List<T> ReadObjects<T>(int n, Func<int[], T> creator)
        {
            var l = new List<T>(n);

            for (int i = 0; i < n; i++)
            {
                var a = ReadIntArray();
                l.Add(creator(a));
            }

            return l;
        }

        static int[,] ReadMatrix(int n, int m)
        {
            var r = new int[n, m];
            for (int i = 0; i < n; i++)
            {
                var a = ReadIntArray();
                for (int j = 0; j < m; j++)
                {
                    r[i, j] = a[j];
                }
            }
            return r;
        }
        #endregion
    }
}


Measured memory_bytes: 25736
#include <iostream>
#include <vector>
using namespace std;
int main(){
	int n;
    cin>>n;
    vector<int> p;
    for(int i=0;i<n;i++){
        int temp;
        cin >> temp;
        p.push_back(temp);
    }

    int ans = 0;
    for(int i=1;i<n-1;i++){
        if((p.at(i-1)<p.at(i) && p.at(i)<=p.at(i+1)) || (p.at(i+1)<p.at(i) && p.at(i)<=p.at(i-1))){
            ans++;
        }
    }
    cout << ans <<"\n";
    return 0;
}

Measured memory_bytes: 256
def resolve():
    '''
    code here
    '''
    import math

    dishes = [int(input()) for _ in range(5)]
    dev_dis = [item % 10 for item in dishes if item % 10 != 0]
    dev_dis.sort()

    res = sum(dishes)
    if dev_dis:
        for item in dev_dis[1:]:
            if item != 0:
                res += 10 -item

    print(res)

if __name__ == "__main__":
    resolve()


Measured memory_bytes: 9108
#include <bits/stdc++.h>
#define r(i,n) for(int i=0;i<n;i++)
#define int long long
using namespace std;
typedef pair<int,int>P;
#define fi first
#define se second
main(){
	int a,b,c,x,y;
	int SUM=1e17;
	cin>>a>>b>>c>>y>>x;
	for(int i=0;i<=max(x,y)*2;i++)if(i%2==0){
		int sum=0;
		int ny=i/2;
		int nx=i/2;
		if(0){
			ny++;
			sum+=c*i;
			if(ny<y)sum+=(y-ny)*a;
			if(nx<x)sum+=(x-nx)*b;
			SUM=min(sum,SUM);
			ny--;

			sum=c*i;
			nx++;
			if(ny<y)sum+=(y-ny)*a;
			if(nx<x)sum+=(x-nx)*b;
			SUM=min(sum,SUM);
		}
		else{
			sum+=c*i;
			if(ny<y)sum+=(y-ny)*a;
			if(nx<x)sum+=(x-nx)*b;
			SUM=min(sum,SUM);
			//cout<<y<<' '<<ny<<endl;
			//cout<<sum<<endl;
		}
		//cout<<i<<' '<<SUM<<endl;
	}
	cout<<SUM<<endl;
}

Measured memory_bytes: 256
#pragma GCC optimize(2)
#pragma GCC optimize(3)
#include <bits/stdc++.h>
#define ios ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define debug  freopen("in.txt","r",stdin),freopen("out.txt","w",stdout);
#define pb push_back
#define all(x) x.begin(),x.end()
#define fs first
#define sc second
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
const int maxn = 1e6+10;
const int maxM = 1e6+10;
const int inf = 0x3f3f3f3f;
const ll inf2 = 0x3f3f3f3f3f3f3f3f;

template<class T>void read(T &x){
    T s=0,w=1;
    char ch=getchar();
    while(ch<'0'||ch>'9'){if(ch=='-')w=-1;ch=getchar();}
    while(ch>='0'&&ch<='9') s=s*10+ch-'0',ch=getchar();
    x = s*w;
}
template<class H, class... T> void read(H& h, T&... t) {
    read(h);
    read(t...);
}
string s;
void solve(){
	
}	
int main(){
	// debug;
	
	cin>>s;
	if(s[s.size()-1] == 's') {
		cout<<s<<"es";
	}else{
		cout<<s<<"s";
	}

	
	return 0;
}


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

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

int main(){
  int n,m;
  cin >> n >> m;

  vector<ll> a(n);
  rep(i,n) cin >> a.at(i);

  vector<pair<ll, ll>> sousa;
  rep(i,m){
    ll b,c;
    cin >> b >> c;
    sousa.push_back(make_pair(c,b));
  }

  sort(sousa.rbegin(), sousa.rend());
  sort(a.begin(), a.end());

  int count=0;
  int i=0;
  while(i<n){
    if(count>=m) break;   
    
    ll b,c;
    b = sousa.at(count).second;
    c = sousa.at(count).first;
    int change=0;
    
    while(i<n&&a.at(i)<c&&change<b){
      a.at(i) = c;
      i++;
      change++;
    }

    if(!change) break;
    count++;
  }

  ll ans=0;
  rep(i,n) ans+=a.at(i);
  cout << ans;
  //rep(i,n) cout << a.at(i) << " ";  
  
}

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

public class Main {

	void submit() {
		int num = nextInt();
		int len = nextInt();
		if (num % 2 == 0) {
			out.print(num / 2 + " ");
			for (int i = 0; i < len - 1; i++) {
				out.print(num + " ");
			}
			out.println();
			return;
		}

		if (num == 1) {
			int outp = (len + 1) / 2;
			for (int i = 0; i < outp; i++) {
				out.print("1 ");
			}
			out.println();
			return;
		}

		int[] a = new int[len];
		Arrays.fill(a, (num + 1) / 2);

		int nowLen = len;

		int decr = len / 2;

		while (decr > 0) {
			if (nowLen == len) {
				if (a[len - 1] - 1 >= decr) {
					a[len - 1] -= decr;
					break;
				}
				nowLen -= 1;
				decr -= a[len - 1];
			} else {
				decr--;
				if (a[nowLen - 1] == 1) {
					nowLen--;
				} else {
					a[nowLen - 1]--;
					for (int j = nowLen; j < len; j++) {
						a[j] = num;
					}
					nowLen = len;
				}
			}
		}

		for (int i = 0; i < nowLen; i++) {
			out.print(a[i] + " ");
		}
		out.println();

	}

	void preCalc() {

	}

	void stress() {

	}

	void test() {

	}

	Main() throws IOException {
		br = new BufferedReader(new InputStreamReader(System.in));
		out = new PrintWriter(System.out);
		preCalc();
		submit();
		// stress();
		// test();
		out.close();
	}

	static final Random rng = new Random();

	static int rand(int l, int r) {
		return l + rng.nextInt(r - l + 1);
	}

	public static void main(String[] args) throws IOException {
		new Main();
	}

	BufferedReader br;
	PrintWriter out;
	StringTokenizer st;

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

	String nextString() {
		try {
			return br.readLine();
		} catch (IOException e) {
			throw new RuntimeException(e);
		}
	}

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

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

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


Measured memory_bytes: 44880
import sys

input = sys.stdin.readline

def main():
    ans = 0
    A = int(input())
    B = int(input())
    C = int(input())
    X = int(input())
    for i in range(A+1):
        f = i*500
        if f == X:
            ans += 1
            break
        elif f > X:
            break
        for j in range(B+1):
            h = j*100
            if f + h == X:
                ans += 1
                break
            elif f + h > X:
                break
            for k in range(C+1):
                if f + h + k*50 == X:
                    ans += 1
                    break
    print(ans)

if __name__ == '__main__':
    main()

Measured memory_bytes: 3064
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
using P   = pair<ll, ll>;
using mat = vector<vector<ll>>;
typedef string::const_iterator State;
class ParseError {};

void IOS() { ios::sync_with_stdio(false), cin.tie(0); }

constexpr ll INF = 1e16;
constexpr ll INM = 114514;
constexpr ll MOD = 1e9 + 7;
constexpr ld EPS = 1e-12;

template <typename T>
void dump(T x) { cout << x << endl; }
void dumpf(ld x, int t) { cout << setprecision(t) << fixed << x << endl; }
template <typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val) {
	fill((T *)array, (T *)(array + N), val);
}
inline ll mod(ll a, ll b) {
	if (a > 0) return a % b;
	if (a % b == 0) return 0;
	ll x = -a / b + 1;
	a += x * b;
	return a % b;
}
ll powm(ll a, ll b, ll c) {
	if (b == 0)
		return 1;
	else if (b % 2 == 0) {
		ll d = powm(a, b / 2, c);
		return (d * d) % c;
	} else
		return (a * powm(a, b - 1, c)) % c;
}
ll gcd(ll a, ll b) {
	if (b == 0) return a;
	return gcd(b, a % b);
}
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
ll dx[4] = {1, 0, -1, 0};
ll dy[4] = {0, 1, 0, -1};

int main() {
	IOS();
	bool ok = true;
	string s;
	cin >> s;
	for (int i = 0; i < s.size(); i++) {
		if (i % 2 == 0 && s[i] == 'L') ok = false;
		if (i % 2 == 1 && s[i] == 'R') ok = false;
	}
	dump(ok ? "Yes" : "No");
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int N = 2005;
int n,k; vector<int>G[N];
int dp[N][N],ans;
inline void upd(int &x,int v){ v > x ? x = v : 0; }
int fa[N],siz[N],tmp[N];
inline void work(int x,int y){
	int i,j;
	for (i = 0; i <= k && i <= siz[x]+siz[y]; ++i) tmp[i] = dp[x][i];
	for (i = 0; i <= siz[x] && i <= k; ++i) if (dp[x][i])
	for (j = 0; j <= siz[y] && j <= k; ++j) if (dp[y][j] && i + j + 1 <= k)
		upd(tmp[max(i,j+1)],dp[x][i]+dp[y][j]);
	siz[x] += siz[y]; for (i = 0; i <= k && i <= siz[x]; ++i) dp[x][i] = tmp[i];
	for (i = 1; i <= k && i <= siz[x]; ++i) upd(dp[x][i],dp[x][i-1]);
}
inline void dfs(int x){
	int i,j,y;
	siz[x] = 1;
	for (i = 0; i <= k; ++i) dp[x][i] = 1; 
	for (i = 0; i < G[x].size(); ++i) if ((y=G[x][i])^fa[x]) fa[y] = x,dfs(y),work(x,y);
	for (i = 0; i <= k; ++i) upd(ans,dp[x][i]);
}
int main(){
	int i,x,y;
	cin >> n >> k;
	if (k >= n-1){ cout << 0 << '\n'; return 0; }
	for (i = 1; i < n; ++i) cin >> x >> y,G[x].push_back(y),G[y].push_back(x);
	int rt = -1;
	for (i = 1; i <= n; ++i) if (G[i].size() > 1) rt = i;
	ans = min(n,k+1);
	dfs(rt);
	ans = n - ans;
	cout << ans << '\n';
	return 0;
}

Measured memory_bytes: 16164
import sys

input = sys.stdin.readline

def search(x, y):
    while root[x] != x: x = root[x]
    while root[y] != y: y = root[y]
    return x, y

def rebuild(x, y, r):
    while root[x] != r: x, root[x] = root[x], r
    while root[y] != r: y, root[y] = root[y], r
        
N, M = map(int, input().split())

root = {i:i for i in range(1, N+1)}
size = {i:1 for i in range(1, N+1)}
ans = 0

for i in range(M):
    x, y, z = map(int, input().split())
    
    x_r, y_r = search(x, y)

    if x_r == y_r: continue
    
    root[y_r] = x_r
    size[x_r] += size[y_r]
    if size[x_r] > 10: rebuild(x, y, x_r)
    ans += 1

print(N-ans)

Measured memory_bytes: 27368
import sys
from functools import reduce
import copy
import math
from pprint import pprint
import collections
import bisect


sys.setrecursionlimit(4100000)


def inputs(num_of_input):
    ins = [input() for i in range(num_of_input)]
    return ins


def int_inputs(num_of_input):
    ins = [int(input()) for i in range(num_of_input)]
    return ins


def solve(inputs):
    S = inputs[0]
    counter = collections.Counter(list(S))
    max_n = counter.most_common(1)[0][1]
    if max_n >= 2:
        return 'no'
    return 'yes'


def string_to_int(string):
    return list(map(int, string.split()))


if __name__ == "__main__":
    ret = solve(inputs(1))
    print(ret)


Measured memory_bytes: 3812
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;

bool visited[26], g[26][26];
int in[26], out[26];

void dfs(int v) {
    visited[v] = true;
    for (int u = 0; u < 26; u++) {
        if (visited[u]) continue;
        if (!g[v][u]) continue;
        dfs(u);
    }
}

int main() {
    int n;
    while (cin >> n && n) {
        for (int i = 0; i < 26; i++) {
            visited[i] = false;
            in[i] = out[i] = 0;
            for (int j = 0; j < 26; j++) {
                g[i][j] = false;
            }
        }
        for (int i = 0; i < n; i++) {
            string s;
            cin >> s;
            in[s.back() - 'a']++;
            out[s.front() - 'a']++;
            g[s.front() - 'a'][s.back() - 'a'] = true;
        }
        for (int i = 0; i < 26; i++) {
            if (in[i] == 0 && out[i] == 0) continue;
            dfs(i);
            break;
        }
        bool flag = true;
        for (int i = 0; i < 26; i++) {
            if (in[i] == 0 && out[i] == 0) continue;
            if (!visited[i]) flag = false;
        }
        for (int i = 0; i < 26; i++) {
            if (in[i] != out[i]) flag = false;
        }
        if (flag) cout << "OK" << endl;
        else cout << "NG" << endl;
    }
}


Measured memory_bytes: 3188
#include<iostream>
#include<vector>
#include<algorithm>
#include<math.h>
#include<ctime>
#include<cmath>
#include<utility>
#include<cstdlib>
#include<bitset>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<iomanip>
using namespace std;                       

#define ll long long
#define pb push_back
#define mp make_pair
#define pii pair<int, int>
#define pll pair<ll, ll>
#define fi first
#define sc second


#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)

const ll M = 1e9 + 7;

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

ll mul(ll a, ll b){
    (a *= b)%=M;
    (a += M)%=M;
    return a;
}

ll fastpo(ll a, ll x){
    if(x == 0) return 1ll;
    if(x == 1) return a;
    ll y = fastpo(a, x/2);
    if(x%2 == 0){
        return y*y;
    }
    return y*y*a;
}

ll inv(ll a, ll M){
    return fastpo(a, M-2);
}

ll gcdExtended(ll a, ll b, ll *x, ll *y) 
{ 
    if (a == 0) 
    { 
        *x = 0, *y = 1; 
        return b; 
    } 
  
    ll x1, y1; 
    ll gcd = gcdExtended(b%a, a, &x1, &y1); 
  
    *x = y1 - (b/a) * x1; 
    *y = x1; 
  
    return gcd; 
}

ll modInverse(ll a, ll m) 
{ 
    ll x, y; 
    ll g = gcdExtended(a, m, &x, &y); 
    if (g != 1) 
        return -1; 
    else
    { 
        ll res = (x%m + m) % m; 
        return res;
    } 
}


ll gcd(ll a, ll b){
    if(a == 0){
        return b;
    }
    return gcd(b%a, a);
}

ll lcm(ll a, ll b){
    return (a*b)/gcd(a, b);
}

void print(vector<int> &a){
    int n = a.size();
    for(int i=0; i<n; i++){
        cout<<a[i]<<" ";
    }
    cout<<endl;
}


int main(){
//    clock_t time_req;
//     time_req = clock();
    fastio;
    ll x, k, d;
    cin>>x>>k>>d;
    x = abs(x);
    ll r1 = x%d, r2 = r1 - d;
    ll t1 = x/d, t2 = t1 + 1;
    if(t1 >= k){
        cout<<(x-k*d)<<endl;
        return 0;
    }
    if(t1%2 == 1){
        swap(r1, r2);
    }
    if(k%2 == 0){
        cout<<abs(r1)<<endl;
    }
    else{
        cout<<abs(r2)<<endl;
    }

    // time_req = clock()-time_req;
    // cout<<"Time taken: "<<(float)time_req/CLOCKS_PER_SEC<<"s"<<endl;
    return 0;
}

Measured memory_bytes: 3652
#include "bits/stdc++.h"
#define in std::cin
#define out std::cout
#define rep(i,N) for(LL i=0;i<N;++i)
typedef long long int LL;

int main()
{
	LL N, M;
	in >> N >> M;
	std::vector<LL>k(M), p(M);
	std::vector<std::vector<LL>>s(M);
	rep(i, M)
	{
		in >> k[i];
		s[i].resize(k[i]);
		rep(j, k[i]) in >> s[i][j];
	}
	rep(i, M) in >> p[i];

	LL ans = 0;
	rep(bit, (1LL << N))
	{
		bool flag = true;
		rep(i, M)
		{
			LL cnt = 0;
			rep(j, k[i])
			{
				if (bit & (1LL << (s[i][j] - 1))) ++cnt;
			}
			if (cnt % 2 != p[i])
			{
				flag = false;
				break;
			}
		}
		if (flag) ++ans;
	}

	out << ans << std::endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define fi first
#define se second
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repp(i, a, b) for (int i = a; i <= (b); ++i)
#define repr(i, a, b) for (int i = a; i >= (b); --i)
typedef long long ll;
const int INF = 1001001001;
const ll LINF = 1001001001001001001ll;
const int MOD = 1e9 + 7;

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

  vector<ll> A(N);
  rep(i, N) cin >> A[i];

  typedef pair<ll, ll> P;
  vector<P> CB(M);
  rep(i, M) { cin >> CB[i].second >> CB[i].first; }
  sort(all(CB), greater<P>());

  int cnt = 0;
  vector<ll> C;

  rep(i, M) {
    rep(j, CB[i].se) {
      C.pb(CB[i].fi);
      cnt++;
      if (cnt > N) break;
    }
    if (cnt > N) break;
  }
  rep(i, N - cnt) C.pb(0);

  sort(all(A));

  ll sum = 0;
  rep(i, N) { sum += max(A[i], C[i]); }
  cout << sum << endl;
}

Measured memory_bytes: 3832
#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>
#include <queue>
using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);

//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))

//debug
#define dump(x)  cerr << #x << '=' << (x) << endl;
#define debug(x) cerr << #x << '=' << (x) << '('<<'L' << __LINE__ << ')' << ' ' << __FILE__ << endl;

#define yes cout<<"Yes"<<endl;
#define no cout<<"No"<<endl;

int main(){
 
    int a,b;
    cin>>a>>b;
    cout<<2*b-a<<endl;




}


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

//var 
bool dp[100001];
int n,k,a[101];

int main(){
	cin >> n >> k;
	for(int i = 1; i<=n; i++)cin >> a[i];
	for(int i = 1; i<=k; i++){
		for(int j = 1; j<=n; j++){
			if(i-a[j]<0)continue;
			if(i-a[j]==0){
				dp[i] = 1;
				break;
			}
			if(!dp[i-a[j]])dp[i] |= 1;
		}
	}cout << (dp[k]?"First":"Second") << endl;
}

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

using namespace std;

int h,w,a,b;
int ans[1005][1005];

void solve(){
	for(int i=0; i<h; i++){
		for(int j=0; j<w; j++){
			if(i < b){
				if(j < a) ans[i][j] = 0;
				else ans[i][j] = 1;
			}
			else{
				if(j < a) ans[i][j] = 1;
				else ans[i][j] = 0;
			}
		}
	}
}


int main(){
	cin >> h >> w >> a >> b;
	solve();
	for(int i=0; i<h; i++){
		for(int j=0; j<w; j++){
			cout << ans[i][j];
		}
		cout << endl;
	}
	return 0;
}

Measured memory_bytes: 5120
x, y = map(int, input().split())

# a = [1,3,5,7,8,10,12]
# b = [4,6,9,11]
# c = [2]

# if (x in a and  y in a) or (x in b and y in b) or (x in c and y in c):
#   print('Yes')
# else:
#   print('No')

a = [0,1,3,1,2,1,2,1,1,2,1,2,1]
if a[x] == a[y]:
  print('Yes')
else:
  print('No')

Measured memory_bytes: 3068
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func init() {
	const maxWord = (1 << 30)
	buf := []byte{}
	sc.Buffer(buf, maxWord)
	sc.Split(bufio.ScanWords)
}

func input() string {
	sc.Scan()
	return sc.Text()
}

func main() {
	n, _ := strconv.Atoi(input())
	a := make([]int, n)
	for i := 0; i < n; i++ {
		a[i], _ = strconv.Atoi(input())
	}

	cnt := map[int]int{}
	for i := 0; i < n; i++ {
		cnt[a[i]]++
	}

	numEven := 0
	for key := range cnt {
		if cnt[key]%2 == 0 {
			numEven++
			cnt[key] = 2
		} else {
			cnt[key] = 1
		}
	}

	ans := len(cnt)
	if numEven%2 == 1 {
		ans--
	}
	fmt.Println(ans)
}


Measured memory_bytes: 7168
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=int(a);i<int(b);++i)
using namespace std;
typedef long long ll;
typedef pair<ll, int> P;
int INF = (1LL << 30) - 1;
int MOD = 1e9+7;
ll gcd (ll a,ll b){
    return b ? gcd(b,a%b) : a;
}
vector<int> factor(ll x){
    vector<int> vec;
    map<ll, int> mp;
    for(ll i = 2;i * i <= x;i++){
        while(x % i == 0){
            mp[i]++;
            x /= i;
        }
    }
    if(x != 1)mp[x]++;
    vector<P> prime;
    for(auto p:mp){
        prime.emplace_back(p);
    }
    /*
    stack<P> st;
    st.push(P(1, 0));
    while(!st.empty()){
        
        auto p = st.top();
        st.pop();
        ll num = p.first, index = p.second;
        //cout << num << " " << index << endl;
        if(index == prime.size()){
            vec.push_back(num);
            continue;
        }
        st.push(P(num, index+1));
        rep(i,0,prime[index].second){
            num *= prime[index].first;
            st.push(P(num, index+1));
        }
        
    }
    sort(vec.begin(), vec.end());
    return vec;
    */
    vector<int> ans(1);
    ans[0] = mp.size() + 1;
    return ans;
}
main(){
    ll A,B;
    cin >> A >> B;
    /*
    auto v1 = factor(A);
    for(auto i:v1)cout << i << " ";cout << endl;
    auto v2 = factor(B);
    for(auto i:v2)cout << i << " ";cout << endl;
    auto v3 = factor(gcd(A, B));
    for(auto i:v3)cout << i << " ";cout << endl;
    */
    auto ans = factor(gcd(A, B));
    cout << ans[0] << endl;
}

Measured memory_bytes: 256
import sys

def main():
    data = list(input())

    for i in range(len(data)):
        if data[i] == 'A':
            left = i
            break

    for i in range(len(data))[::-1]:
        if data[i] == 'Z':
            right = i
            break

    print(right - left + 1)


if __name__ == '__main__':
    main()


Measured memory_bytes: 61552