akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
//#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#include <vector>
#include <numeric>
#include <map>
#include <cmath>
#include <iomanip>
#include <queue>
using ll =long long;
#define PI 3.14159265358979
#define rep(i,init,n) for(ll i=init;i<=n;++i)
using P = pair<string , int>;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector<vi>;
using vs = vector<string>;

int main(){
    ll a, b,c,k;
    cin >> a >>b >>c >>k;
    if(k <= a) cout << k << endl;
    else if (k>a && k <= a+b) cout << a << endl;
    else {
        cout << a-(k-(a+b)) << endl;
    }


    return 0;
}

Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int>pii;
typedef pair<ll,pair<ll,ll>>plll;
#define sf(a) scanf("%I64d",&a)
#define pf(a) printf("%I64d\n",a)
#define mem(a,b)     memset(a,b,sizeof(a))
#define vll(v) v.begin(),v.end()
#define all(x) x.rbegin(),x.rend()
#define F first
#define S second
#define minheap int,vector<int>,greater<int>
//#define mp make_pair
#define pb push_back
#define pp pop_back
#define BOUNDARY(i, j) ((i >= 0 && i < row) && (j >= 0 && j < column))
#define ischar(x)  (('a' <= x && x <= 'z') || ('A' <= x && x <= 'Z'))
#define isvowel(ch) ((ch=='a'||ch=='e'||ch=='i'||ch=='o'||ch=='u')||(ch=='A'|| ch=='E' || ch=='I'|| ch=='O'|| ch=='U'))
#define fastread() (ios_base:: sync_with_stdio(false),cin.tie(NULL));
#define in  freopen("input.txt", "r", stdin)
#define out  freopen("output.txt", "w", stdout)
const int Max_node = 7e6 + 10;
const int Mod = 1e9 + 7;
bool compare(const pair<int,int> &a, const pair<int,int> &b)
{
    return (a.first > b.first);
}
ll lcm(ll a,ll b)
{
    if(a==0 || b==0)
        return 0;

    return a/__gcd(a,b)*b;
}
//___________________________________________________________________________________________________________________
//                              CODE STARTS FROM HERE
//                               MU_Codefighter2018
//-------------------------------------------------------------------------------------------------------------------



ll cnt[Max_node][3];


void Insert(ll x)
{

    int now=0,i;

       for(i=63; i>=0; i--)
       {
           ll bit=(x>>i)&1ll;



          cnt[i][bit]++;


       }
}



ll Set(ll num, ll pos) {
        return num | (1LL << pos);
}


ll MAX(ll target)
{

    ll i,temp=0,sum=0;

        for(i=60; i>=0; i--)
       {




         if(cnt[i][0]<=cnt[i][1])
         {
             continue;
         }
         else
         {
             temp=sum;

           temp= Set(temp,i);



           if(temp<=target)
            sum=temp;




         }


       }

       return sum;
}

int main()
{
    fastread();



   ll i,j,n,m,p,a,sum=0,k,t,b,c,d,cnt=0,q,l,r,ans=0;

      bool flag=false;

      string str;


      cin>>n>>k;


      ll ara[n+2];

      for(i=0; i<n; i++)
      {
          cin>>ara[i];

          Insert(ara[i]);
      }

      ll mx=MAX(k);

     // cout<<mx<<endl;


      for(i=0; i<n; i++)
      {
          sum+=(ara[i]^mx);
      }

      cout<<sum<<endl;









}


Measured memory_bytes: 4412
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Main main = new Main();
        main.solve();
    }
    public void solve() {
        Scanner scan = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
        int N = scan.nextInt();
        List<Long> l = new ArrayList<>();
        for (int i = 0; i < N; i++) {
            l.add(scan.nextLong());
        }
        l.sort(Comparator.naturalOrder());
        long ans = 0;
        for (int i = 0; i < N; i++) {
            long l_i = l.get(i);
            for (int j = i+1; j < N; j++) {
                long l_j = l.get(j);
                long seek = l_i + l_j;
                int key = ~Collections.binarySearch(l, seek, new LowerBoundComparator<>());
                ans += Math.max(0, key - 1 - j);
            }
        }
        System.out.println(ans);
    }
    class LowerBoundComparator<T extends Comparable<? super T>> implements Comparator<T> {
        public int compare(T x, T y) {
            return (x.compareTo(y) >= 0) ? 1 : -1;
        }
    }
}


Measured memory_bytes: 43752
import sys

def input():
    return sys.stdin.readline().strip()

def main():
    X = int(input())
    for A in range(-118,120):
        for B in range(-119,119):
            if A**5 - B**5 == X:
                print(A,B)
                exit()

if __name__ == "__main__":
    main()

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

using namespace std;

bool isprime(int n) {
    if(n < 2) return false;
    for(int i = 2; i*i <= n; i++) {
        if(n % i == 0) return false;
    }
    return true;
} 

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

    int x;
    cin >> x;
    for(int i = x;; i++) {
        if(isprime(i)) {
            cout << i << '\n';
            break;
        }
    }

    return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define pb push_back
#define F first
#define S second
//#define biGinf 9e+18
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define inpv(v) for(auto &x:v) cin>>x
#define otpv(v) for(auto &x:v) cout<<x<<nwl
#define otpv2(v) for(auto &x:v) cout<<x<<" "
#define CASES int tt;cin>>tt; while(tt--)
#define for0(i,n) for(int i=0; i<n; i++)
#define for1(i,n) for(int i=1; i<=n; i++)
#define sz(v) (int)(v).size()
#define vec(x) vector < x >
using vi = vector < int >;
using vvi = vector < vi >;
using pii = pair < int , int >;
using vpii = vector < pii >;
using int64 = long long;
//const int64 biGinf = 9e+18;
//const string yo = "YES", no = "NO";
const int inf = 2e9 + 7;
const char nwl = '\n';

int main() {
// #ifndef ONLINE_JUDGE
// 	if (fopen("input.txt", "r")) {
// 		freopen("input.txt", "r", stdin);
// 		freopen("output.txt", "w", stdout);
// 	}
// #endif
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	//ur code
	int n;
	cin >> n;
	vi v(n);
	inpv(v);
	int x = 0;
	for (int y : v) {
		x ^= y;
	}
	for (int y : v) {
		x ^= y;
		cout << x << " ";
		x ^= y;
	}


	return 0;
}

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

#define M 1046527
#define NIL (-1)
#define L 14

char H[M][L];

int getChar(char ch){
    if(ch=='A')return 1;
    else if(ch=='C')return 2;
    else if(ch=='G')return 3;
    else if(ch=='T')return 4;
    else return 0;
}

long long getKey(char str[]){
    long long sum=0,p=1,i;
    for(i=0;i<strlen(str);i++){
        sum+=p*(getChar(str[i]));
        p*=5;
    }
    return sum;
}

int h1(int key){return key%M;}
int h2(int key){return 1+(key%(M-1));}
int find(char str[]){
    long long key,i,h;
    key=getKey(str);
    for(i=0;;i++){
        h=(h1(key)+i*h2(key))%M;
        if(strcmp(H[h],str)==0)return 1;
        else if(strlen(H[h])==0)return 0;
    }
    return 0;
}
int insert(char str[]){
    long long key,i,h;
    key=getKey(str);
    for(int i=0;;i++){
        h=(h1(key)+i*h2(key))%M;
        if(strcmp(H[h],str)==0)return 1;
        else if(strlen(H[h])==0){
            strcpy(H[h],str);
            return 0;
        }
    }
    return 0;
}
int main(){
    int i,n,h;
    char str[L],com[9];
    for(i=0;i<M;i++)H[i][0]='\0';
    cin>>n;
    for(i=0;i<n;i++){
        cin>>com>>str;
        if(com[0]=='i'){
            insert(str);
        }else{
            if(find(str)){
                cout<<"yes"<<endl;
            }else{
                cout<<"no"<<endl;
            }
        }
    }
    return 0;
}


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


int main() {
  int A, B;
  cin >> A >> B;
  string S;
  cin >> S;
  
  if(S[A] != '-') {
    cout << "No" <<endl;
    return 0;
  }
  
  rep(i, A+B+1) {
    if(S[i] == '-' && i != A) {
      cout << "No" <<endl;
      return 0;
    }
  }
  cout << "Yes" <<endl;
  
}


Measured memory_bytes: 256
// 2013/11/15 Tazoe

#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
 
int main()
{
	vector<int> T;		// 正四面体数
	for(int n=1; ; n++){
		int t = n*(n+1)*(n+2)/6;

		if(t>=1000000)
			break;

		T.push_back(t);
	}

	int DP1[1000000];	// 正四面体数の個数
	int DP2[1000000];	// 奇数の正四面体数の個数
	DP1[0] = DP2[0] = 0;
	for(int i=1; i<1000000; i++){
		DP1[i] = DP2[i] = 1000000;
	}

	for(int i=0; i<T.size(); i++){
		for(int j=T[i]; j<1000000; j++){
			DP1[j] = min(DP1[j], DP1[j-T[i]]+1);
		}

		if(T[i]%2==1){
			for(int j=T[i]; j<1000000; j++){
				DP2[j] = min(DP2[j], DP2[j-T[i]]+1);
			}
		}
	}

	while(true){
		int m;
		cin >> m;

		if(m==0)
			break;

		cout << DP1[m] << ' ' << DP2[m] << endl;
	}

	return 0;
}

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

using ll = long long;
using ull = unsigned long long;
#define countof(a) (sizeof(a)/sizeof((a)[0]))
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i < (n); i++)
#define bzero(p, n) memset(p, 0, n)
#define all(a) begin(a),end(a)
template<class T> istream& operator >> (istream& s, vector<T>& v)
{ for (T& x: v) { s >> x; } return s;}

int main()
{
    cin.tie(0); ios::sync_with_stdio(false);
    //cout<<std::fixed<<std::setprecision(10);

    string X; cin >>X;

    int ans = X.size();
    int s_count = 0;
    rep(i, X.size()) {
        if (X[i] == 'S') {
            s_count++;
        } else {
            if (s_count > 0) {
                ans -= 2;
                s_count--;
            }
        }
    }

    cout << ans << endl;
}


Measured memory_bytes: 720
#include<stdio.h>
#include<math.h>
#define SIZE 10000
int main(){
    int N;
    int M;
    int A[SIZE];
    int sum=0;
    scanf("%d %d",&N,&M);
    for(int i=0 ; i<M; i++){
        scanf("%d",&A[i]);
        sum += A[i];
    }
    if(N>=sum){
        int b;
        b= N-sum;
        printf("%d",b);
        return 0;
    }
    printf("%d",-1);
    return 0;
}

Measured memory_bytes: 1768
import pprint
n = int(input())
dp = [{} for i in range(n + 1)]
s = "AGCT"
M = 10 ** 9 + 7

for j in range(n + 1):
  for c1 in s:
    for c2 in s:
      for c3 in s:
        dp[j][c1 + c2 + c3] = 0

dp[0]["TTT"] = 1

for l in range(n):
  for c1 in s:
    for c2 in s:
      for c3 in s:
        for p in s:
          if c2 == "A" and c3 == "G" and p == "C":
            continue
          if c1 == "A" and c3 == "G" and p == "C":
            continue
          if c1 == "A" and c2 == "G" and p == "C":
            continue
          if c2 == "G" and c3 == "A" and p == "C":
            continue
          if c2 == "A" and c3 == "C" and p == "G":
            continue
          dp[l + 1][c2 + c3 + p] += dp[l][c1 + c2 + c3]
          dp[l + 1][c2 + c3 + p] = dp[l + 1][c2 + c3 + p] % M

ans = 0
for c1 in s:
  for c2 in s:
    for c3 in s:
      ans += dp[n][c1 + c2 + c3]
      ans = ans % M
print(ans)


Measured memory_bytes: 4468
# coding: utf-8
# Here your code !

q = int(raw_input())
for i in range(q):
    xp0, yp0, xp1, yp1, xp2, yp2, xp3, yp3 = map(float,raw_input().split())
    if xp1 - xp0 == 0:
        if xp3 - xp2 == 0:
            print 2
        elif yp3 - yp2 == 0:
            print 1
        else:
            print 0
    elif xp3 - xp2 == 0:
        if xp1 - xp0 == 0:
            print 2
        elif yp1 - yp0 == 0:
            print 1
        else:
            print 0
    
    else:
        s1 = (yp1 - yp0, xp1 - xp0)
        s2 = (yp3 - yp2, xp3 - xp2)
        if s1[0]/s1[1] == s2[0]/s2[1]:
            print 2
        elif s1[0]*s2[0] + s1[1]*s2[1] == 0:
            print 1
        else:
            print 0

Measured memory_bytes: 4272
#include<bits/stdc++.h>
using namespace std;
int n, m, i, j, k, l, cnt[128], n1, n2, n3;
char e[105][105];
int main() {
	scanf("%d%d", &n, &m);
	if(n + m == 2) {
		printf("Yes\n");
		return 0;
	}
	for(i = 1; i <= n; i++) scanf("%s", e[i]);
	for(i = 1; i <= n; i++) for(j = 0; j < m; j++) ++cnt[(int) e[i][j]];
	if(n % 2 && m % 2) {
		for(i = 97; i < 123; i++) if(cnt[i] % 4 == 3) ++n3;
		if(n3 > 1) {
			printf("No\n");
			return 0;
		}
		for(i = 97; i < 123; i++) if(cnt[i] % 4 == 1) ++n1;
		for(i = 97; i < 123; i++) if(cnt[i] % 4 == 2) ++n2;
		if(n1 + n3 > 1 || n2 > n / 2 + m / 2) printf("No\n");
		else printf("Yes\n");
		return 0;
	}
	if(!(n % 2 + m % 2)) {
		for(i = 97; i < 123; i++) if(cnt[i] % 4 > 0) {
			printf("No\n");
			return 0;
		}
		printf("Yes\n");
		 return 0;
	}
	if(n % 2 == 0 && m % 2 == 1) {
		for(i = 97; i < 123; i++) if(cnt[i] % 4 == 2) ++n2;
		for(i = 97; i < 123; i++) if((cnt[i] % 4) % 2 != 0) {
			printf("No\n");
			return 0;
		}
		if(n2 > n / 2) printf("No\n");
		else printf("Yes\n");
		return 0;
	}
	if(n % 2 == 1 && m % 2 == 0) {
		for(i = 97; i < 123; i++) if(cnt[i] % 4 == 2) ++n2;
		for(i = 97; i < 123; i++) if((cnt[i] % 4) % 2 != 0) {
			printf("No\n");
			return 0;
		}
		if(n2 > m / 2) printf("No\n");
		else printf("Yes\n");
		return 0;
	}
}

Measured memory_bytes: 256
# coding: utf-8
import sys

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

# 桁DP, Lを超えないものと保留のもの
MOD = 10 ** 9 + 7
L = sr()
dp_dec = 1 # decide
dp_res = 2 # reserve
length = len(L)
for i in range(1, length):
    x, y = dp_dec, dp_res
    if L[i] == '1':
        dp_dec = x * 3 + y
        dp_res = y * 2
    else:
        dp_dec = x * 3
        dp_res = y
    dp_dec %= MOD
    dp_res %= MOD

answer = dp_dec + dp_res
print(answer % MOD)


Measured memory_bytes: 3188
#include <stdio.h>

int main(){
  int x,y,tre,r;
  
    scanf("%d%d",&x,&y);
  if(y>x){
    tre=y;
    y=x;
    x=tre;
  }

  while(y>0){
    r=x%y;
    x=y;
    y=r;
  }
  printf("%d",x);
  printf("\n");

  return 0;
}

Measured memory_bytes: 596
def main():
    def f(a, b):
        return max(len(str(a)), len(str(b)))
    def make_divisors(n):
        divisors = []
        for i in range(1, int(n**0.5)+1):
            if n % i == 0:
                divisors.append(i)
                if i != n // i:
                    divisors.append(n//i)
        return divisors
    n = int(input())
    divisors = make_divisors(n)
    ans = float('inf')
    for a in divisors:
        b = n // a
        ans = min(ans, f(a, b))
    print(ans)


if __name__ == '__main__':
    main()


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

int main()
{
  int n;
  cin >> n;
  
  string s[n+1];
  for(int i = 0; i < n; i++){
    cin >> s[i];
  }
  
  sort(s,s+n);
  int ans = 1,maxans = 0;
  for(int i = 0; i < n; i++){
    if(s[i] == s[i+1]){
      ans++;
      continue;
    }
    if(ans > maxans){
      maxans = ans;
    }
    ans = 1;
  }
  
  ans = 1;
  for(int i = 0; i < n; i++){
    if(s[i] == s[i+1]){
      ans++;
      continue;
    }
    if(ans == maxans){
      cout << s[i] << endl;
    }
    ans = 1;
  }
      
}

Measured memory_bytes: 9844
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int mod4 = 0;
		int mod2 = 0;
		int N = scan.nextInt();
		int needMod4 = N / 2;
		int[] a = new int[N];
		for(int i = 0; i < N; i++) {
			a[i] = scan.nextInt();
			if(a[i] % 4 == 0) {
				mod4++;
			}
			if(a[i] % 2 == 0 && a[i] % 4 != 0) {
				mod2++;
			}
		}
		
		if(mod4 == 0 && N == mod2) {
			System.out.println("Yes");
		} else if(needMod4 <= mod4 + (mod2 / 2)) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}
		scan.close();

	}

}


Measured memory_bytes: 49664
import java.util.Scanner;

class Main{

	static char[][] map;
	static int H;
	static int W;

	public static void main(String[] args) {



		Scanner sc = new Scanner(System.in);			//文字の入力
		String string = sc.next();
		if(string.charAt(0) != 'A'){
			System.out.println("WA");
			return;

		}
		int c = 0;
		for(int i= 2;i < string.length()-1;i++){
			if(string.charAt(i) == 'C'){
				c++;
			}
		}
		for(int i = 1;i < string.length()-1;i++){
			if(Character.isUpperCase( string.charAt(i)) && string.charAt(i) != 'C'){
				System.out.println("WA");
				return;

			}
		}


		if(c != 1){
			System.out.println("WA");
			return;

		}

		if(Character.isUpperCase( string.charAt(string.length()-1) )){

			System.out.println("WA");
			return;

		}
		System.out.println("AC");


	}
}





Measured memory_bytes: 23124
#if 1
  #include <bits/stdc++.h>
#else
  #include "../../bits/stdc++.h"
#endif

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

using namespace std;

//typedef pair<int, int> P;
#define pb push_back
#define mp make_pair
#define ft first
#define sd second

int N, M, P;
int x[102];

bool input(){
  cin>>N>>M>>P;
  REP(i, N)cin>>x[i];
  return N|M|P;
}

void solve(){
  int s=0;
  REP(i, N)s+=x[i];
  int res=s*(100-P);
  if(x[M-1]==0) {
    cout<<0<<endl;
    return ;
  }
  res /= x[M-1];
  cout<<res<<endl;
}

int main(){
  cin.tie(0);
  
  while (input()){
      solve();
  }
  
  return 0;
}

Measured memory_bytes: 3008
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
#include <stdio.h>
#include <queue>
#include <deque>
#include <cstdio>
using namespace std;
int main() {
	int n;
	cin >> n;
	int a[200010];
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	sort(a, a + n);
	for (int j = 0; j < n - 1; j++) {
		if (a[j] == a[j + 1]) {
			cout << "NO" << endl;
			return 0;
		}
	}
	cout << "YES" << endl;
	return 0;
}






Measured memory_bytes: 1024
#include "bits/stdc++.h"
using namespace std;
int main(){
    int N;
    cin >> N;

    int V[20];
    int i = 0;
    while(i < N){
        cin >> V[i];
        i++;
    }

    int C[20];
    i = 0;
    while(i < N){
        cin >> C[i];
        i++;
    }

    int answer = 0;
    i = 0;
    while(i < N){
        if(V[i] > C[i]){
            answer = answer + V[i] - C[i];
        }
        i++;
    }
    cout << answer << endl;
}

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

int main() {
  string n;
  cin>>n;
  int sum=0;
  for(int i=0;i<n.size();i++){
    int d=n.at(i)-'0';
    sum+=d;
  }
  if(stoi(n)%sum==0){cout<<"Yes"<<endl;}
  else{cout<<"No"<<endl;}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (ll i=0; i<(n); ++i)
#define rep1(i,n) for (ll i=1; i<=(n); ++i)
typedef long long ll;
bool debug=false;
string yes = "Yes";
string no = "No";

int main(){
  ll n; cin >> n;
  string ans;
  if(abs(n)==0) {
    cout << 0;
    return 0;
  }
  while(n!=1){
    if(n>0){
      ans.append(to_string(n%2));
      n=-1*(n/2);
    }else{
      if(abs(n)%2==0){
        ans.append("0");
        n=abs(n)/2;
      }else{
        ans.append("1");
        n=(1+abs(n))/2;
      }
    }
  }
  ans.append("1");
  reverse(ans.begin(),ans.end());
  cout << ans;
  return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <climits>
#include <cmath>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <unordered_map>
#include <vector>

const int mod = 1e9 + 7;
const int kmax = 510000;

long long fact[kmax], fact_inv[kmax], inv[kmax];

void init_comb()
{
    fact[0] = fact[1] = 1;
    fact_inv[0] = fact_inv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < kmax; i++) {
        fact[i] = fact[i - 1] * i % mod;
        inv[i] = mod - inv[mod % i] * (mod / i) % mod;
        fact_inv[i] = fact_inv[i - 1] * inv[i] % mod;
    }
}

long long comb(int n, int r)
{
    if (n < r) {
        return 0;
    }

    if (n < 0 || r < 0) {
        return 0;
    }

    return fact[n] * (fact_inv[r] * fact_inv[n - r] % mod) % mod;
}

template <typename T, T N>
class UnionFind {
    T parent_[N];
    T rank_[N];
    T size_[N];

public:
    UnionFind();
    T Root(T idx);
    bool IsSame(T x, T y);
    void Unite(T x, T y);
    T GetSize(T idx);
};

template <typename T, T N>
UnionFind<T, N>::UnionFind()
{
    for (T i = 0; i < N; i++) {
        parent_[i] = i;
        rank_[i] = 0;
        size_[i] = 1;
    }
}

template <typename T, T N>
T UnionFind<T, N>::Root(T idx)
{
    return parent_[idx] == idx ? idx : parent_[idx] = Root(parent_[idx]);
}

template <typename T, T N>
bool UnionFind<T, N>::IsSame(T x, T y)
{
    return Root(x) == Root(y);
}

template <typename T, T N>
void UnionFind<T, N>::Unite(T x, T y)
{
    x = Root(x);
    y = Root(y);
    if (x == y) {
        return;
    }

    if (rank_[x] < rank_[y]) {
        parent_[x] = y;
        size_[y] += size_[x];
    } else {
        parent_[y] = x;
        size_[x] += size_[y];
        if (rank_[x] == rank_[y]) {
            rank_[x]++;
        }
    }
}

template <typename T, T N>
T UnionFind<T, N>::GetSize(T idx)
{
    return size_[Root(idx)];
}

long long pow_mod(long long n, long long p, long long m)
{
    if (p == 0) {
        return 1;
    }

    if (p % 2 == 0) {
        long long t = pow_mod(n, p / 2, m);
        return t * t % m;
    }
    return n * pow_mod(n, p - 1, m) % mod;
}

long long nCr_mod(long long n, long long r)
{
    long long x = 1;
    for (long long i = n - r + 1; i <= n; i++) {
        x *= i;
        x %= mod;
    }

    long long a = 1;
    for (long long i = 1; i <= r; i++) {
        a *= i;
        a %= mod;
    }

    long long y = pow_mod(a, mod - 2, mod) % mod;

    return x * y % mod;
}

bool is_prime(long long n)
{
    if (n == 1) {
        return false;
    }

    for (long long i = 2; i * i <= n; i++) {
        if (n % i == 0) {
            return false;
        }
    }

    return true;
}

int main()
{
    long long a, b, c;
    std::cin >> a >> b >> c;

    std::cout << (a + b + c >= 22 ? "bust" : "win") << std::endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
//#define fr(i,j,k) for(int i=j;i<k;i++)
//#define f(n) fr(i,0,n)
//#define f1(n) fr(i,1,n+1)
#define pb push_back
#define F first
#define S second
#define all(x) x.begin(), x.end()
const ll mod = 1e9 + 7;
const int maxn = 2e5+5;
#include<atcoder/all>
using namespace atcoder;
void solve() {
    string s;
    cin >> s;
    vector<int>sa = suffix_array(s);
    vector<int>lcp = lcp_array(s,sa);
    ll sum = 1LL * s.size() * (s.size() + 1) / 2;
    for (auto &i : lcp) {
        sum -= i;
    }
    cout << sum << '\n';
}
int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int c = 0;
    int t;
    if (!c) {
        t = 1;
    }
    else {
        cin >> t;
    }
    while (t--) {
        solve();
    }
    
}


Measured memory_bytes: 15560
N = int(input())

C = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 12, 14, 15, 16, 18, 20, 21, 24, 25, 27, 28, 30, 32, 35, 36, 40, 42, 45, 48, 49, 54, 56, 63, 64, 72, 81]

if N in C:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 3060
#pragma warning(disable:4996)


#include<iostream>
#include<algorithm>
//#include<unordered_map>
#include<fstream>
#include<iomanip>
#include<string>
#include<cmath>
#include<cstring>
#include<vector>
#include<map>
#include<set>
#include<list>
#include<queue>
#include<stack>
#include<sstream>
#include<cstdio>
#include<ctime>
#include<cstdlib>
#define INF 0x3f3f3f3f
#define inf 0x7FFFFFFF
#define MOD 1000000007
#define pii pair<ll,ll>
#define eps 1e-8
#define equals(a,b) (fabs(a-b)<eps)
#define bug puts("bug")
#define re  register
#define fi first
#define se second
const int maxn = 1e6+ 5;
const double Inf = 10000.0;
const double PI = acos(-1.0);
typedef  long long ll;
using namespace std;

string a, b;

int main() {
	int res = 0;
	cin >> a >> b;
	for (int i = 0; i < a.length(); i++) {
		if (a[i] != b[i]) res++;
	}
	cout << res;
}

Measured memory_bytes: 3888
#include <iostream>

using namespace std;

int main()	{
  int n, k;
  cin >> n >> k;
  if (n == 1)	{
    cout << k << endl;
    return 0;
  }
  int ways = 0;
  ways = k;
  for (int i = 0; i < n - 1; i++)	{
    ways *= (k - 1);
  }
  cout << ways << endl;
  return 0;
}

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

#define INF 1050000000
#define MOD 1000000007

using namespace std;


int main() {
	int n, k; cin >> n >> k;
	int d[20];
	for (int i = 0; i < k; i++) {
		cin >> d[i];
	}

	while (1) {
		bool flag = true;
		string x = to_string(n);
		for (int i = 0; i < k; i++) {
			string s = to_string(d[i]);
			if (x.find(s) != -1) {
				flag = false;
			}
		}
		if (flag) {
			break;
		}
		n++;
	}

	cout << n << endl;





}

Measured memory_bytes: 256
N = int(input())
S = input()

cnt = left = 0
for s in S:
    if s == "(":
        cnt += 1
    else:
        cnt -= 1

        if cnt < 0:
            left = max(left, -cnt)

S = "(" * left + S

right = 0
for s in S:
    if s == "(":
        right += 1
    else:
        right -= 1

S = S + ")" * right

print(S)

Measured memory_bytes: 3060
from sys import exit

s = input()

n = len(s)
for i in range(n):
  if i+1 < n and s[i] == s[i+1]:
    print(i+1, i+2)
    exit()
  if i+2 < n and s[i] == s[i+2]:
    print(i+1, i+3)
    exit()
    
print(-1, -1)

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

int main(){
#ifdef _DEBUG
	freopen("in" , "r", stdin );
	freopen("out", "w", stdout);
#endif
	ios::sync_with_stdio(0); cin.tie(0);
	string s; char c;
	while(cin >> c){
		if(c == 'B' && s.size()) s.erase(prev(s.end()));
		if(c != 'B') s += c;
	}
	cout << s << '\n';
}


Measured memory_bytes: 3632
a, b, c, d, e, k = int(input()), int(input()), int(input()), int(input()), int(
    input()), int(input())

ABC = [a, b, c, d, e]

for i in range(5):
    for j in range(5):
        if abs(ABC[i] - ABC[j]) > k:
            print(':(')
            exit()
print('Yay!')


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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(a) (a).begin(), (a).end()
#define INF (int)1e8
#define EPS 1e-9

using vi = vector<int>;
using vvi = vector<vi>;
using vs = vector<string>;

int main() {
  int N, L;
  cin >> N >> L;
  vs s(N);
  rep(i, N) cin >> s[i];

  string res = "";
  sort(all(s));
  rep(i, N) res += s[i];

  cout << res << endl;
}

Measured memory_bytes: 256
import std.stdio, std.conv, std.string, std.array, std.math, std.regex, std.range, std.ascii, std.numeric, std.random;
import std.typecons, std.functional, std.traits,std.concurrency;
import std.algorithm, std.container;
import core.bitop, core.time, core.memory;
import std.bitmanip;
import std.regex;

enum INF = long.max/3;
enum MOD = 10L^^9+7;

//辞書順順列はiota(1,N),nextPermituionを使う


void end(T)(T v)
if(isIntegral!T||isSomeString!T||isSomeChar!T)
{
    import core.stdc.stdlib;
    writeln(v);
    exit(0);
}

T[] scanArray(T = long)()
{
    static char[] scanBuf;
    readln(scanBuf);
    return scanBuf.split.to!(T[]);
}

dchar scanChar()
{
    int c = ' ';
    while (isWhite(c) && c != -1)
    {
        c = getchar;
    }
    return cast(dchar)c;
}

T scanElem(T = long)()
{
    import core.stdc.stdlib;
    static auto scanBuf = appender!(char[])([]);

    scanBuf.clear;

    int c = ' ';
    while (isWhite(c) && c != -1)
    {
        c = getchar;
    }
    while (!isWhite(c) && c != -1)
    {
        scanBuf ~= cast(char) c;
        c = getchar;
    }
    return scanBuf.data.to!T;
}

dchar[] scanString(){
    return scanElem!(dchar[]);
}


void main()
{
  auto l = [scanElem,scanElem,scanElem].sort();
  if(l[0..2].sum==l[2])end("Yes");end("No");
}


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

    int main(){
        int h,n;
        cin >> h >> n;
        int sum = 0;
        for (int i = 0; i < n; i++){
            int l;
            cin >> l;
            sum += l;
        }
        if (h-sum <= 0){
            cout << "Yes";
        }
        else {
            cout << "No";
        }

}

Measured memory_bytes: 384
#include<iostream>
#include<cmath>
using namespace std;
int main()
{
	int n,m;
	cin>>n>>m;
	int a[n],b[n],c[m],d[m];
	for(int i=0;i<n;i++)
	{
		cin>>a[i]>>b[i];
	}
	for(int i=0;i<m;i++)
	{
		cin>>c[i]>>d[i];
	}
	int e[n];
	for(int i=0;i<n;i++)
	{
		int mix=-1,p;
		for(int j=0;j<m;j++)
		{
			if(abs(a[i]-c[j])+abs(b[i]-d[j])<mix||mix==-1)
			{
				mix=abs(a[i]-c[j])+abs(b[i]-d[j]);
				p=j;
			}
		}
		e[i]=p+1;
	}
	for(int i=0;i<n;i++)
	{
		if(i==n-1)
		{
			cout<<e[i];
		}
		else
		{
			cout<<e[i]<<endl;
		}
	}
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args){
        Scanner scan = new Scanner(System.in);
        int r = scan.nextInt();
        int c = scan.nextInt();

        int[][] sheet = new int[r+1][c+1];

        for(int l = 0; l < (c+1); l++){
            sheet[r][l] = 0;
        }

        for(int row = 0; row < r; row++){
            sheet[row][c] = 0;
        }

        for(int f = 0; f < r; f++){
            for(int i = 0; i < c; i++){
                sheet[f][i] = scan.nextInt();

                sheet[f][c] = sheet[f][c] + sheet[f][i];
                sheet[r][i] = sheet[r][i] + sheet[f][i];
            }
            sheet[r][c] = sheet[r][c] + sheet[f][c];
        }


        for(int f = 0; f < (r+1); f++){
            for(int i = 0; i < (c+1); i++){
                System.out.print(sheet[f][i]);
                if(i != c){
                    System.out.print(" ");
                }
            }
            System.out.println();
        }



    }
}



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

using namespace std;

void solve() {
    int N;
    cin >> N;
    
    vector<int> X(N), X2;
    for (int i = 0; i < N; i++)
    {
        cin >> X[i];
    }
    X2 = X;
    sort(X.begin(), X.end());
    int med_min, med_max;
    med_min = X[N/2-1];
    med_max = X[N/2];

    for (int i = 0; i < N; i++)
    {
        if (X2[i] <= med_min)
        {
            cout << med_max << endl;
        }
        else
        {
            cout << med_min << endl;
        }
    }
}

int main() {
    solve();
    return 0;
}

Measured memory_bytes: 4772
# include<stdio.h>

int main(){


int W,H,x,y,r;

//x = 0;
//y = 0;
//z = 0;
scanf("%d %d %d %d %d",&W,&H,&x,&y,&r);

if (x-r >=0 && x+r<=W && y-r>=0 && y+r<=H){
 printf("Yes\n");
}



else{
  printf("No\n");
}


return(0);


}

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

using namespace std;
using ll = long long;
using ld = long double;

//#define int long long
//signed main(){
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int h,w,k;
    cin >> h >> w >> k;
    vector<bool> s(h*w,false);
    for(int i = 0; i < h; i++) {
        string tmp;
        cin >> tmp;
        for(int j = 0; j < w; j++) if(tmp[j]=='#') s[i*w+j]=true;
    }

    vector<int> cnt(h);
    for(int i = 0; i < h; i++) {
        for(int j = 0; j < w; j++) if(s[i*w+j]) cnt[i]++;
    }
    vector<int> acnt(h);
    acnt[0]=cnt[0];

    for(int i = 1; i < h; i++) acnt[i]=acnt[i-1]+cnt[i];

    vector<int> ans(h*w+w,-1);
    int idx=1;
    int lr=0;
    for(int i = 0; i < h; i++) {
        if(cnt[i]==0) continue;
        for(int j = 0; j < w; j++) {
            ans[i*w+j]=idx;
            if(s[i*w+j]) idx++;
            if(idx==acnt[i]+1) idx--;
        }
        idx++;
        lr=i;
    }

    for(int j = 0; j < w; j++) ans[h*w+j]=ans[lr*w+j];

    for(int j = 0; j < w; j++) {
        for(int i = 0; i < h; i++) {
            int k=h-1-i;
            if(ans[k*w+j]==-1) ans[k*w+j]=ans[(k+1)*w+j];
        }
    }

    for(int i = 0; i < h; i++) {
        for(int j = 0; j < w; j++) {
            cout << ans[i*w+j] << " ";
        }
        cout << "\n";
    }


    return 0;
}

Measured memory_bytes: 3732
import sys
import numpy as np
import numba
from numba import jit

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

@jit
def main(n, d):
  d_sort = np.sort(d)
  num = len(d_sort)//2
  return d_sort[num]-d_sort[num-1]


n = int(readline())
d = np.array(readline().split(), np.int64)


print(main(n, d))

Measured memory_bytes: 121632
#include <iostream>
#include <sstream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <map>
#include <stdio.h>

using namespace std;

//typedefリスト
typedef vector<long long int> vint;
typedef vector<string> vstr;
typedef long long int llint;



int main(void) {
	llint N, H, W, ans1, ans2;
	cin >> N >> H >> W;
	ans1 = (N - H) + 1;
	
	ans2 = (N - W) + 1;
	
	cout << ans1*ans2 << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
using namespace std;
ll max1[1 << 19];
ll s1[1 << 19];
ll max2[1 << 19];
ll s2[1 << 19];
ll dp[1 << 19];
ll a[1 << 19];
int main()
{
	ll n;
	scanf("%lld", &n);
	for(ll i = 0; i < (1 << n); ++ i)
		scanf("%lld", &a[i]);
	memset(max1, 128, sizeof(max1));
	memset(max2, 128, sizeof(max2));
	for(ll i = 0; i < (1 << n); ++ i)
	{
		if(max1[i] <= a[i])
		{
			max2[i] = max1[i], max1[i] = a[i];
			s2[i] = s1[i], s1[i] = i;
		}
		else
			if(max2[i] <= a[i])
			{
				max2[i] = a[i];
				s2[i] = i;
			}
		for(ll j = 0; j < n; ++ j)
		{
			ll s = i | (1 << j);
			if(s == i)
				continue;
			if(max1[s] <= a[i])
			{
				max2[s] = max1[s], max1[s] = a[i];
				s2[s] = s1[s], s1[s] = i;
			}
			else
				if(max2[s] <= a[i])
				{
					max2[s] = a[i];
					s2[s] = i;
				}
		}
	}
	for(ll i = 0; i <= n; ++ i)
	{
		for(ll j = 0; j < (1 << n); ++ j)
		{
			for(ll k = 0; k < n; ++ k)
			{
				ll s = j | (1 << k);
				if(max1[s] <= max1[j] && s1[s] != s1[j] && s2[s] != s1[j])
				{
					max2[s] = max1[s], max1[s] = max1[j];
					s2[s] = s1[s], s1[s] = s1[j];
				}
				if(max2[s] <= max1[j] && s2[s] != s1[j] && s1[j] != s1[s])
				{
					max2[s] = max1[j];
					s2[s] = s1[j];
				}
				else
					if(max2[s] <= max2[j] && s2[s] != s2[j] && s2[j] != s1[s])
					{
						max2[s] = max2[j];
						s2[s] = s2[j];
					}
			}
		}
	}
	for(ll i = 0; i < (1 << n); ++ i)
		dp[i] = max1[i] + max2[i];
	for(ll i = 0; i < (1 << n); ++ i)
		dp[i] = max(dp[i], dp[i - 1]);
	for(ll i = 1; i < (1 << n); ++ i)
		printf("%lld\n", dp[i]);
	return 0;
}

Measured memory_bytes: 27648
#include <bits/stdc++.h>
using namespace std;
int main() {
  map<string, int> mp;
  int n;
  cin >> n;
  for (int i = 0; i < n; ++i) {
    string s;
    cin >> s;
    mp[s]++;
  }
  int m;
  cin >> m;
  for (int i = 0; i < m; ++i) {
    string t;
    cin >> t;
    mp[t]--;
  }
  int ans = 0;
  for (auto i = mp.begin(); i != mp.end(); ++i) {
    ans = max(ans, (int)i->second);
  }
  cout << ans << endl;
}

Measured memory_bytes: 3632
/*************************************************************************
	> File Name: 2.cpp
	> Author: Knowledge_llz
	> Mail: 925538513@qq.com 
	> Blog: https://blog.csdn.net/Pig_cfbsl 
	> Created Time: 2020/7/13 15:49:53
 ************************************************************************/

#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<cstring>
#include<algorithm>
#define For(i,a,b) for(register int i=(a);i<=(b);++i)
#define LL long long
using namespace std;
int read(){
	char x=getchar(); int u=0,fg=0;
	while(!isdigit(x)){ if(x=='-') fg=1; x=getchar(); }
	while(isdigit(x)){ u=(u<<3)+(u<<1)+(x^48); x=getchar(); }
	return fg?-u:u;
}
const int oo=1e9+7;
int n,m,l,mp[300][300],dis[300][300],to[300][300];
int main()
{
#ifndef ONLINE_JUDGE
	freopen("input.in", "r", stdin);
	freopen("output.out", "w", stdout);
#endif 
	int u,v,c;
	n=read(); m=read(); l=read(); 
	For(i,1,n) For(j,1,n) dis[i][j]=to[i][j]=oo;
	For(i,1,m){
		u=read(); v=read(); c=read();
		dis[u][v]=dis[v][u]=c;
	}
	For(k,1,n)
		For(i,1,n)
			For(j,1,n)
				if(dis[i][k]+dis[k][j]<dis[i][j])
					dis[i][j]=dis[i][k]+dis[k][j];

	For(i,1,n) For(j,1,n)
		if(dis[i][j]<=l) to[i][j]=0;
	For(k,1,n)
		For(i,1,n)
			For(j,1,n){
				if(to[i][k]+to[k][j]+1<to[i][j])
					to[i][j]=to[i][k]+to[k][j]+1;
			}
	int q=read();
	while(q--){
		u=read(); v=read();
		if(to[u][v]==oo) printf("-1\n");
		else printf("%d\n",to[u][v]);
	}
	return 0;
}


Measured memory_bytes: 4456
import sys

while True:
    h,w = map(int,raw_input().split())
    if h == 0 and w == 0:
	    break

    for i in range(h):
        for j in range(w):
    	    if (i + j) % 2 == 0:
    		    sys.stdout.write('#')
    	    else:
    		    sys.stdout.write('.')
        print''
    print

Measured memory_bytes: 6368
mod = 10**9+7
X,Y = map(int,input().split())

if (2*X-Y)%3 != 0 or (2*Y-X)%3 != 0 or 2*X-Y<0 or 2*Y-X<0:
    print(0)
    exit()

x = (2*Y-X)//3
y = (2*X-Y)//3

def factorial_mod(n,mod):
    factorial = 1
    for i in range(1,n+1):
        factorial *= i
        factorial %= mod
    return factorial

def pow_mod(x,n):
    if n==0:
        return 1
    
    K = 1
    while n>1:
        if n%2 != 0:
            K *= x
            K %= mod
        x *= x
        x %= mod
        n //= 2

    return K*x

def n_C_k(n,k,mod):
    factorial_n = factorial_mod(n,mod)
    factorial_k = factorial_mod(k,mod)
    factorial_nk = factorial_mod(n-k,mod)
    conbi=factorial_n*pow_mod(factorial_nk,mod-2)*pow_mod(factorial_k,mod-2)
    return conbi%mod

print(n_C_k(x+y,x,mod))

Measured memory_bytes: 38512
s = sorted(list(input()))
t = sorted(list(input()), reverse=True)
if s == t:
    print('No')
    exit()
sd = ''.join(s)
td = ''.join(t)
l = [sd, td]
ls = sorted(l)
if l == ls:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 3064
def main():
    n, k = map(int, input().split())
    p_lst = list(map(int, input().split()))
    lst = []

    for i in range(n):
        lst.append((p_lst[i] + 1) / 2)

    tmp_sum = sum(lst[:k])
    maximum = tmp_sum
    for i in range(n - k):
        tmp_sum -= lst[i]
        tmp_sum += lst[i + k]
        maximum = max(maximum, tmp_sum)

    print(maximum)


if __name__ == '__main__':
    main()

Measured memory_bytes: 32140
#include<iostream>
using namespace std;
int main(){
	int r,c,i,j,s,p[101][101],sum=0,w=0,t=0,m,n;
	cin>>r>>c;
	for(i=0;i<r;i++){
		for(j=0;j<c;j++){
			cin>>p[i][j];
		}
	}
	for(i=0;i<r;i++){
		for(j=1;j<=c;j++){
			cout<<p[i][j-1]<<" ";
			sum+=p[i][j-1];
			w+=p[i][j-1];
			if(j==c){
				cout<<w<<endl;
				w=0;
			}
		}
	}
	for(m=1;m<=c;m++){
		for(n=0;n<r;n++){
			t+=p[n][m-1];
		}
		cout<<t<<" ";
		t=0;
		if(m==c)
			cout<<sum<<endl;
	}
	return 0;
}

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

namespace atcoder174
{
    class Program
    {
        static void Main(string[] args)
        {
            var x = int.Parse(Console.ReadLine());
            var ans = "No";
            if (x >= 30)
            {
                ans = "Yes";
            }
            Console.WriteLine(ans);
        }
    }
}


Measured memory_bytes: 27516
/* Author : Aaryan Srivastava ^__^ */ 
#include <bits/stdc++.h>
#include <random>
#include <chrono>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp> 
#define pb push_back
#define popb pop_back
#define mt make_tuple 
#define eb emplace_back
#define mp make_pair
#define ff first
#define ss second 
#define ull unsigned long long  
#define pii pair<int, int>
#define piii pair<int,pii>
#define beg begin
#define rep(i,n) for(int (i) = 0 ; i < (n) ; i++)
#define repA(i,x,y) for(int i = (x) ; i <= (y) ; i++)
#define repD(i,x,y) for(int i = (x) ; i >= (y) ; i--)
#define all(c) (c).begin(),(c).end()
#define fill(a,val) memset(a,val,sizeof(a))
#define Randomize mt19937 rng(chrono::steady_clock::now().time_since_epoch().count())
#define int ll
using ll = long long;
const int N = 3*1e5 +5 ;
const int mod = 1e9 + 7 ;
const int inf = 1e18 ;
const int SZ = 101 ;
const double eps = 1e-9 ;
using namespace __gnu_pbds;
using namespace std;
using ordered_set =  tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> ;

#ifdef AaryanS
#define mycout cout
#define mycerr cerr 
#endif

#ifndef AaryanS
#define mycout if(false) cout
#define mycerr if(false) cerr
#endif


void solve()
{
    char c;
    cin >> c ;
    cout << (char) (c + 1) ;
}   

     
int32_t main(int32_t argc, char *argv[])
{
    double t1 = clock() ;
    ios::sync_with_stdio(0);    
    cin.tie(0); cout.tie(0);
    int TC = 1, t = 0;
    //cin >> TC ;
    while(t++ < TC)
    {
        //cout << "Case #" << t << ": " ;
        solve();
        //cout << endl ;
    }
    mycerr << "Time : " << 1000 *(clock() - t1)/CLOCKS_PER_SEC << " ms\n" ;
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);

        int N = sc.nextInt();
        int i ,j ,count = 0 ,a;
        int array[] = new int[N];

        for(i = 0;i < N;i++){
            array[i] = sc.nextInt();
        }

        for(i = N - 1;i > 0;i--){
            for(j = N - 1;j >= N - i;j--){
                if(array[j] < array[j-1]){
                    a = array[j];
                    array[j] = array[j-1];
                    array[j-1] = a;
                    count++;
                }
            }
        }

        for(i = 0;i < N;i++){
            if(i <= N-2){
                System.out.printf("%d ",array[i]);
            }else{
                System.out.printf("%d\n",array[i]);
            }
        }

        System.out.printf("%d\n",count);

    }
}


Measured memory_bytes: 26588
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <stack>
#include <set>
#include <queue>
#include <iomanip>
#include <math.h>
#include <fstream>

using namespace std;

long long mod = 1000000007;

void dfs(int p, int prev, vector<int> &a, vector<int> &dp, int dpl, vector<vector<int>> &v, vector<int> &res)
{
    int l = -1, r = dpl, mid;
    while (r - l > 1)
    {
        mid = (l + r) / 2;
        if (dp[mid] >= a[p])
        {
            r = mid;
        }
        else
        {
            l = mid;
        }
    }
    int temp = dp[r];
    dp[r] = a[p];
    if (temp == -1)
    {
        dpl++;
    }
    res[p] = dpl;
    for (int i = 0; i < v[p].size(); i++)
    {
        if (v[p][i] == prev)
        {
            continue;
        }
        dfs(v[p][i], p, a, dp, dpl, v, res);
    }
    dp[r] = temp;
}

int main()
{
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(12);
    cin.tie();
    cout.tie();
    // ifstream cin("in.txt");
    // ofstream cout("out.txt");
    
    
    // int t;
    // cin >> t;
    // for (int qwe = 0; qwe < t; qwe++)
    // {
    //     cout << "Case #" << qwe + 1 << ": ";
    // }


    int n;
    cin >> n;
    long long k;
    cin >> k;
    vector<int> a(n + 1);
    for (int i = 1; i <= n; i++)
    {
        cin >> a[i];
    }
    int cycle = 0;
    int curr = 1;
    vector<bool> visited(n + 1, false);
    while (!visited[curr])
    {
        visited[curr] = true;
        curr = a[curr];
    }
    int start = curr;
    while (true)
    {
        curr = a[curr];
        cycle++;
        if (curr == start)
        {
            break;
        }
    }
    curr = 1;
    while (k > 0)
    {
        if (curr == start && k >= cycle)
        {
            k %= cycle;
            continue;
        }
        curr = a[curr];
        k--;
    }
    cout << curr << '\n';


    return 0;
}


Measured memory_bytes: 3680
#!/usr/bin/env python3
import sys


def solve(L: int):
    a,b,c=L/3,L/3,L/3
    print(a*b*c)
    return


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    L = int(next(tokens))  # type: int
    solve(L)

if __name__ == '__main__':
    main()


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

#define vi vector<int>
#define pb push_back

int main()
{
    int n, tmp, i0 = 0, i1 = 0, i2 = 0;
    cin >> n;
    rep(i, n)
    {
        cin >> tmp;
        int m2 = 0;
        for (m2; tmp % 2 == 0; m2++)
            tmp /= 2;
        if (m2 == 0)
            i0++;
        else if (m2 == 1)
            i1++;
        else
            i2++;
    }
    string ans = "Yes";
    if (i0 == 0)
        ;
    else if (i1 == 0 && i0 - 1 <= i2)
        ;
    else if (i1 != 0 && i0 <= i2)
        ;
    else
        ans = "No";

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

Measured memory_bytes: 256
a=input().split()
N=int(a[0])
K=int(a[1])
list1=[]
for i in range(K) :
  c=int(input())
  d=input().split()
  for item in d :
    list1.append(int(item))

m=len(list(set(list1)))
print(N-m)

Measured memory_bytes: 67728
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"
#include "numeric"
#include "cassert"

using namespace std;

const long long int MOD = 1000000007;
//const int MOD = 1000000007;
//const int MOD = 998244353;

long long int N, M, K, H, W, L, R;
//int N, M, K, H, W, L, R;

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

	string s, t;
	while(cin>>s){
	    cin>>t;
	vector<vector<int>>dp(s.size() + 1, vector<int>(t.size() + 1));
	for (int i = s.size() - 1; i >= 0; i--) {
		for (int j = t.size() - 1; j >= 0; j--) {
			if (s[i] == t[j])dp[i][j] = dp[i + 1][j + 1] + 1;
		}
	}
	int ans = 0;
	for (auto i : dp)for (auto j : i)ans = max(ans, j);
	cout << ans << endl;
	}
	return 0;
}



Measured memory_bytes: 65620
N,M = map(int,input().split())
LRlist = [tuple(map(int,input().split())) for _ in range(M)]

min_n = 0
max_n = N
for l,r in LRlist:
    min_n = l if l>min_n else min_n
    max_n = r if r<max_n else max_n

if max_n-min_n >= 0:
    print(max_n-min_n+1)
else:
    print(0)

Measured memory_bytes: 16608
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; ++i)
#define ALL(v) v.begin(), v.end()
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1000000007;

int Par[51],Rank[51];
void init(int n)
{
   rep(i,n)Par[i]=i,Rank[i]=0;
}

int find(int x)
{
   if(Par[x]==x){
      return x;
   }
   else
   {
      return Par[x] = find(Par[x]);
   }
}

void unite(int x,int y)
{
   x = find(x);
   y = find(y);
   if(x==y)return;
   if(Rank[x]<Rank[y])
   {
      Par[x] = y;
   }
   else
   {
      Par[y] = x;
      if(Rank[x]==Rank[y])Rank[x] ++;
   }
}

bool same(int x, int y)
{
   return find(x) == find(y);
}

int main()
{
   int n,m;
   cin >> n >> m;
   vector<pair<int,int>> mp(m);
   rep(i,m)
   {
      int a,b;
      cin >> a >> b;
      a--; b--;
      mp[i] = make_pair(a,b);
   }

   int ans = 0;
   rep(i,m)
   {
      init(n);
      rep(j,m)
      {
         if(j==i)continue;
         unite(mp[j].first,mp[j].second);
      }
      rep(i,n)
      {
         if(!same(0,i))
         {
            ans++;
            break;
         }
      }
   }
   cout<<ans<<endl;
   return 0;
}

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

int main(){
	int D[123],k,check;
	
	for(int i=0;i<5;i++)
		cin>>D[i];
	
	cin>>k;
	
	for(int i=1;i<5;i++){
		if(D[i]-D[0]>k){
			check=1;
			continue;
		}
		else
			check=0;
	}
		
	if(check==1)
		cout<<":(";
	else
		cout<<"Yay!";
	
	return 0;
}

Measured memory_bytes: 256
n,k=map(int,input().split(" "))

if(n==k or n%k==0):
    print(0)
elif(n<k):
    print(min(n,abs(n-k)))
else:
    q=n//k
    ma=n%k

    aa = n-q*k
    print(min(aa,abs(aa-k)))

Measured memory_bytes: 3060