akhauriyash/Code-Regression huggingface dataset:
#include <stdlib.h>     /* srand, rand */
#include <time.h>       /* time */
#include <bits/stdc++.h>
#include <cmath>
#include <iomanip>
#include <iterator> 
using namespace std;

#define f first
#define s second

#define pb push_back
#define pp pop_back
#define mp make_pair

#define sz(x) (int)x.size()
#define sqr(x) ((x) * 1ll * (x))
#define all(x) x.begin(), x.end()
#define clr(a,v) memset(a, v, sizeof(a))

#define rep(i, l, r) for (int i = (l); i <= (r); i++)
#define per(i, l, r) for (int i = (l); i >= (r); i--)
#define reflex ios_base::sync_with_stdio(false)

#define nl '\n'
#define ioi exit(0);


#define PI 3.14159265

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;

typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
//~ const int N= (int)2e5 + 7;
const int inf = (int)1e9 + 7;
const int mod = (int)1e9 + 7;
//const int mod = 1000000007;
const ll linf = (ll)1e18 + 7;

const int dx[] = {-1, 0, 1, 0, 1, -1, -1, 1};
const int dy[] = {0, 1, 0, -1, 1, -1, 1, -1};
const int kx[] = {-1,1,2,2,1,-1,-2,-2};
const int ky[] = {2,2,1,-1,-2,-2,-1,1};
int cnt = 1;
int a[100], b[100], c[100];
int d[100];
int n, m, q;
vector<int> v;

int compute() {
	int sum = 0;	
	for (int k = 1; k <= q; k++) {
		if(v[b[k]-1] - v[a[k]-1] == c[k]) {
			sum += d[k];
		}
	}
	return sum;
}
int solve(int id){
	if ((int)v.size() == n) {
		return compute();
	}
	int maxi = 0;
	for(int nxt = id; nxt <= m; nxt++) {
		v.push_back(nxt);
		int a = solve(nxt);
		v.pop_back();
		maxi = max(maxi,a);
	}
	return maxi;
}
int main() { 
	cin>> n >> m >> q;
	for (int i = 1; i <= q; i++) {
		cin>> a[i] >> b[i] >> c[i] >> d[i]; 
	}
	cout<<solve(1);

	return 0;
} 




Measured memory_bytes: 3608
#include<iostream>

using namespace std;

int main(){

  int N,res=0;
  cin >> N;
  if(N>=10) res+=9;
  else{
    res+=N;
    cout << res << endl;
    return 0;
  }
  
  if(N>=1000) res+= 899+1;
  else{
    int temp = N-100+1;
    res += max(temp, 0);
    cout << res << endl;
    return 0;
  }
  // 100000以下
  if(N == 100000) res+= 89999+1;
  else{
    int temp = N-10000+1;
    res+= max(temp, 0);
  }
  
  cout << res << endl;
}


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

using namespace std;
using   ll=long long;

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

#define pb          	push_back
#define mp          	make_pair
#define F           	first
#define S           	second
#define pll				pair<int , int>
#define int             long long int
#define endl            "\n"

#define ALL(v)      	v.begin(),v.end()
#define ALLR(v)     	v.rbegin(),v.rend()
#define pii         	3.14159265358979323
#define inf     		LLONG_MAX
#define ones(x)     	__builtin_popcount(x)
#define fill(a,b)   	memset(a,b,sizeof(a))
#define mod 			998244353

ll mod_pow(ll a,ll b,ll m)
{
    ll res = 1;
    while(b)
    {
        if(b&1)
        {
        	res=(res*a) % m;
        }
        a=(a*a) % m;
        b>>=1;
    }
    return res;
}

ll mod_inverse(int a , int m)
{
	return mod_pow(a , m - 2 , m);
}

const int maxn = 3e5 + 5;
 
int a[maxn];
 
int tree[6*maxn];
 
int query(int v ,int l ,int r ,int lq ,int rq) {
	if(lq <= l && r <= rq) {
		return tree[v];
	}
	
	if(l > rq or lq > r) {
		return 0;
	}
	
	int mid = (l+r)/2;
	
	int t1 = query(2*v + 1 , l , mid , lq , rq);
	int t2 = query(2*v + 2 , mid + 1 , r , lq , rq);
	
	return max(t1 , t2);
}
 
void update(int v , int pos , int l , int r , int val)
{
	if(l == r) {
		tree[v] = val;
		return;
	}
	
	int mid = (l+r)/2;
	
	if(pos <= mid) {
		update(2*v + 1, pos , l , mid , val);
	}
	else {
		update(2*v + 2, pos , mid+1 , r , val);
	}
	
	tree[v] = max(tree[2*v + 1] , tree[2*v + 2]);
}

signed main() {
	fast;
  
  	int n , k;
	
	cin >> n >> k;
	
	for(int i = 1; i <= n; ++i) {
		cin >> a[i];
	}
	
	int mx = 1;
	
	for(int i = 1; i <= n; ++i) {
		int t1 = query(1 , 1 , 3e5 , max(1LL , a[i] - k) , min((ll)3e5 , a[i] + k));
		int t2 = query(1 , 1 , 3e5 , a[i] , a[i]);
		
		
		if(t2 < t1+1) {
			update(1 , a[i] , 1 , 3e5 , t1 + 1);
			mx = max(mx , t1 + 1);
		}
	}
	
	cout << mx;


  
  
    return 0;
}

Measured memory_bytes: 14236
#include <iostream>

using namespace std;

int main() {
    int N, Y;
    cin >> N >> Y;
    for (int x = N; 0 <= x; --x) {
        for (int y = N - x; 0 <= y; --y) {
            int rest = N - (x + y);
            if (0 <= rest && (10000 * x + 5000 * y + 1000 * rest) == Y) {
                cout << x << " " << y << " " << rest << endl;
                return 0;
            }
        }
    }
    cout << "-1 -1 -1" << endl;
    return 0;
}


Measured memory_bytes: 256
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<iostream>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<sstream>
#include<unordered_map>
#include<unordered_set>
#include<vector>
using uint = unsigned int;
using ll = long long;
enum : int { M = (int)1e9 + 7 };
enum : ll { MLL = (ll)1e18L + 9 };
using namespace std;
#ifdef LOCAL
#include"rprint2.hpp"
#else
#define FUNC(name) template <ostream& out = cout, class... T> void name(T&&...){ }
FUNC(prints) FUNC(printe) FUNC(printw) FUNC(printew) FUNC(printb) FUNC(printd) FUNC(printde);
#endif

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n; cin >> n;
    int ans = pow(3, n), odd = 1;
    for(int i = 0; i < n; i++){
        int a; cin >> a;
        if(a % 2 == 0){
            odd *= 2;
        }
    }
    cout << ans - odd << '\n';
}


Measured memory_bytes: 888
#include <bits/stdc++.h>
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)
#define pll pair<ll,ll>
#define pint pll
using ll = long long;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;

int main(){
  int n;
  cin >> n;
  ll a[n],b[n];
  rep(i,n)cin >> a[i] >> b[i];
  if(n%2){
    sort(a,a+n);
    sort(b,b+n);
    cout << -a[n/2]+b[n/2]+1 << endl;
  }else{
    sort(a,a+n);
    sort(b,b+n);
    cout << -a[n/2]-a[n/2-1]+b[n/2]+b[n/2-1]+1 << endl;
  }
return 0;}

Measured memory_bytes: 6764
#include<bits/stdc++.h> 
using namespace std; 
#define ll long long int
#define fi first
#define se second
#define pb push_back
#define mod 1000000007
#define FIO ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
ll power(ll x, ll y, ll p)  
{  
    ll res = 1;
    x = x % p;
    if (x == 0)
    return 0; // In case x is divisible by p; 
    while (y > 0)  
    {  
        if (y & 1)  
            res = (res*x) % p;  
        y = y>>1; // y = y/2  
        x = (x*x) % p;  
    }  
    return res;  
}
bool sortinrev(const pair<vector<int>,int>&a,const pair<vector<int>,int>&b)
{
    if(a.fi==b.fi)
    return b.se>a.se;
    return a.fi>b.fi;
}
// make adjustment;
// void BFS()
// {
//     level[1]=1;
//     q.push(1);vis[1]=true;
//     while(!q.empty())
//     {
//         int p = q.front();
//         q.pop();
//         for(int i=0;i<adj[p].size();i++)
//         {
//             if(vis[adj[p][i]]==false)
//             {
//                 level[adj[p][i]] = level[p]+1;
//                 q.push(adj[p][i]);
//                 vis[adj[p][i]]=true;
//             }
//         }
//     }
// }
void DFS(vector<int>adj[],vector<bool>&visited,int u,int n,vector<int>&vi)
{
    visited[u]=true;
    vi.pb(u);
    for(int i=0;i<adj[u].size();i++)
    {
        if(visited[adj[u][i]]==false)
        {
            (DFS(adj,visited,adj[u][i],n,vi));
        }
    }
}
void run(vector<int>v)
{
    for(int i=0;i<v.size();i++)
    cout<<v[i]<<" ";
    cout<<endl;
}
ll fact(ll n)
{
    ll f=1;
    for(int i=1;i<=n;i++)
    {
        f*=i;
    }
    return f;
}
int main() 
{ 
    FIO;
    int n;
    cin>>n;
    unordered_map<string,int>mp;
    for(int i=0;i<n;i++)
    {
        string s;
        cin>>s;
        mp[s]++;
    }
    cout<<mp.size();
   return 0; 
} 

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

using namespace std;

int main(){
    long long int N,ans=2;
    bool flag = true;
    cin >> N;
    vector<int> A(N/2 +1,0);

    for(int i=0;i<N;i++){
        int a;
        cin >> a;
        if(N%2==0){
            if(a%2==0){
                flag = false;
            }
        }else{
            if(a%2==1){
                flag = false;
            }
        }

        A[a/2]++;
    }

    if(N%2==1){
        for(int i=1;i<N/2+1;i++){
            if(A[0]!=1 || A[i] != 2){
                flag = false;
            }
        }
    }else{
        for(int i=0;i<N/2;i++){
            if(A[i] != 2){
                flag = false;
            }
        }
    }

    for(int i=0;i<N/2-1;i++){
        ans *= 2;
        ans %= 1000000007;
    }

    if(flag && N==1){
        cout << "1" << endl;
    }else if(flag){
        cout << ans << endl;
    }else{
        cout << "0" << endl;
    }
}

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

const int MAX_N = 200000;
int N, M;
std::vector<int> ab[MAX_N];
bool visit[MAX_N];

bool dfs(int x, int y, int count){
   if(x==y) return true;
   if(count>1) return false;
   if(visit[x]) return false;
   ++count;
   visit[x] = true;

   for(int i=0; i<ab[x].size(); ++i){
      if(dfs(ab[x][i],y,count)) return true;
   }
   return false;
}

int main(){
   std::cin >> N >> M;
   int a, b;
   for(int i=0; i<M; ++i){
      std::cin >> a >> b;
      --a; --b;
      ab[a].push_back(b);
      ab[b].push_back(a);
   }

   if(dfs(0,N-1,0)) std::cout << "POSSIBLE" << std::endl;
   else std::cout << "IMPOSSIBLE" << std::endl;

   return 0;

}


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

template<typename T, typename U>
using pv=vector<pair<T,U>>;
template<typename T>
using matrix=vector<vector<T>>;
template<typename T>
using pque=priority_queue<T>;
template<typename T>
using lpque=priority_queue<T,vector<T>,greater<T>>;

using ll=long long;
using intpair=pair<int,int>;
using llpair=pair<ll,ll>;
using ilpair=pair<int,ll>;
using lipair=pair<ll,int>;
using intvec=vector<int>;
using llvec=vector<ll>;
using intq=queue<int>;
using llq=queue<ll>;
using intmat=vector<intvec>;
using llmat=vector<llvec>;

#define PI 3.141592653589793
#define INTINF 1<<30
#define LLINF 1LL<<60
#define MPRIME 1000000007
#define MPRIME9 998244353
#define MMPRIME (1ll<<61)-1

#define len length()
#define pushb push_back
#define fi first
#define se second

#define setpr fixed<<setprecision(15)
#define all(name) name.begin(),name.end()
#define rall(name) name.rbegin(),name.rend()
#define gsort(vbeg,vend) sort(vbeg,vend,greater<>())

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

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

template<class T>
inline void outmat(T& a, int y, int x) {
	for(int i=0; i<y; i++) {
		for(int j=0; j<x; j++) cout<<a[i][j]<<" ";
		cout<<endl;
	}
}

template<class T>
inline void init(T& v) {
	for(auto &a: v) cin>>a;
}
template<class T, class U>
inline void init(vector<pair<T,U>>& v) {
	for(auto &a: v) cin>>a.first>>a.second;
}
template<class T, class N>
inline void init(T& v, N n) {
	v.resize(n);
	for(auto &a: v) cin>>a;
}
template<class T, class U, class N>
inline void init(vector<pair<T,U>>& v, N n) {
	v.resize(n);
	for(auto &a: v) cin>>a.first>>a.second;
}

template<class N>
void resiz(N n) {
	//empty
}
template<class N, class T, class... U>
void resiz(N n, T&& hd, U&&... tl) {
	hd.resize(n);
	resiz(n,forward<U>(tl)...);
}

ll binpow(ll a, ll ex, ll p) {
	ll result=1;
	while(ex>0) {
		if(ex&1) result=result*a%p;
		ex>>=1;
		a=a*a%p;
	}
	return result;
}


int D;
intvec C(26);
intmat S;
intvec last(26,-1);
ll score;

void input() {
	cin>>D;
	init(C);
	S.resize(D);
	for(int i=0; i<D; i++) init(S[i],26);
}

ll calc(int d, int c, intvec &lst) {
	ll res=S[d][c];
	for(int i=0; i<26; i++) {
		res-=C[c]*(d-lst[c]);
	}
	return res;
}

void solve() {
	srand(time(NULL));
	for(int d=0; d<D; d++) {
		ll temps=-LLINF;
		int c=rand()%26,oldc,oldd;
		while(c<26) {
			oldd=last[c];
			last[c]=d;
			chmax(temps,calc(d,c,last));
			last[c]=oldd;
			oldc=c;
			c=rand()%30;
		}
		score+=temps;
		last[oldc]=d;
		cout<<oldc+1<<endl;
	}
}

int main() {
	int t=1;
	while(t) {
		input();
		solve();
		t--;
	}
}


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

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

    for(int i =b; i < c+1; i++){
        if (i % a == 0){
        cout << "OK" << endl;
        return 0;
        }
    }
 cout << "NG" << endl;
 return 0;
}

Measured memory_bytes: 3600
#include <iostream>
#include <sstream>
#include <algorithm>
#include <functional>
#include <iterator>
#include <bitset>
#include <string>
#include <list>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cmath>

typedef   signed long long int slli;
typedef unsigned long long int ulli;
const slli MAX_SLLI = 0x7FFFFFFFFFFFFFFF;
const slli MIN_SLLI = 0x8000000000000000;
const ulli MAX_ULLI = 0xFFFFFFFFFFFFFFFF;
const ulli MIN_ULLI = 0x0000000000000000;

#define N_TIMES(i, n)     for (ulli i = 0;     i <  n; ++i)
#define N_TIMES_REV(i, n) for (slli i = n - 1; i >= 0; --i)

#ifdef __DEBUG__
template<typename T>
std::ostream& operator<<(std::ostream &os, const std::list<T> &list)
{
  const std::string delim = ", ";
  typename std::list<T>::const_iterator itr = list.begin();
  while (itr != list.end()) {
    os << *itr;
    ++itr;
    if(itr != list.end()) os << delim;
  }
  return os;
}

template<typename T>
std::ostream& operator<<(std::ostream &os, const std::vector<T> &v)
{
  const std::string delim = ", ";
  for (unsigned n = 0; n < v.size(); ++n) {
    os << v[n];
    if((n + 1) < v.size()) os << delim;
  }
  return os;
}
#endif /* __DEBUG__ */

int main()
{
  ulli N;
  std::cin >> N;

  unsigned n = ::floor(::sqrt(N));
  std::cout << (n * n) << std::endl;

  return 0;
}

Measured memory_bytes: 256
use std::io;

fn procon_read<T: std::str::FromStr>() ->  Vec<T> {
	let mut buf = String::new();
	io::stdin().read_line(&mut buf).expect("");
	let iter = buf.split_whitespace();
	let mut v: Vec<T> = Vec::new();
	for i in iter {
		v.push(i.parse().ok().unwrap());
	}
	v
}

fn main() {
	let mut v:Vec<i32> = procon_read();
	v.sort();
	println!("{}", (v[1] - v[0]) + (v[2] - v[1]));
}

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

#define ll long long
#define pb push_back
#define speed ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0)
#define fr freopen("input.txt", "r", stdin);freopen("output.txt", "w", stdout);
#define mp make_pair
#define F first
#define S second

using namespace std;

const int N = 5e5 + 2;
const int mod = 1e9 + 7;

int n,k;
int a[N];
int main ()
{
	#define int long long
	cin>>n>>k;
	for (int i=0;i<n;i++){
		cin>>a[i];
	}
	sort(a,a+n);
	for (int i=n-1;k>0 && i>=0;i--){
		a[i]=0;
		--k;
	}
	int ans=0;
	for (int i=0;i<n;i++){
		ans+=a[i];
	}
	cout<<ans;
}



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

int main(){

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

    sort(a, a+n);

    int dis = a[n-1]/2;
    int index = -1;
    for(int i=0; i<n-1; i++){
        if(abs(a[i] - a[n-1]/2) <= dis){
            dis = abs(a[i] - a[n-1]/2);
            index = i;
        }
    }


    cout << a[n-1] << " " << a[index] << endl;
    return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
//for(int i = 0; i < n; i++)
 
int main() {
  int n, a = 0;
  string s;
  cin >> n >> s;
  //vector<int> v(n), c(n);
  if(n % 2 == 1) {
    cout << "No" << endl;
    return 0;
  }
  for(int i = 0; i < n / 2; i++){
    if(s.at(i) == s.at(i + n / 2)) a++;
  }
  if(a == n / 2) cout << "Yes" << endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
using namespace std;
 
int main() {
while(1){
int a;
cin >> a;
if(a == 0){break;}
char *b = new char [a];
char *c = new char [a];
for(int i = 0;i < a;i++){
cin >> b[i] >> c[i];
}
int m;
cin >> m;
for(int i = 1;i <= m;i++){
char p;
cin >> p;
int ii = 0;
while(ii < a){
if(p == b[ii]){
p = c[ii];
break;
}
ii++;
}
if(i == m){cout << p << endl;}
else{cout << p;}
}
 
 
}
	return 0;
}

Measured memory_bytes: 1184
/*Whose woods these are I think I know.
His house is in the village though;
He will not see me stopping here
To watch his woods fill up with snow.

My little horse must think it queer
To stop without a farmhouse near
Between the woods and frozen lake
The darkest evening of the year.

He gives his harness bells a shake
To ask if there is some mistake.
The only other sound’s the sweep
Of easy wind and downy flake.

The woods are lovely, dark and deep,
But I have promises to keep,
And miles to go before I sleep,
And miles to go before I sleep.*/

#include<bits/stdc++.h>
using namespace std;
#define lli long long int
#define pb push_back
#define fi first
#define se second
#define MOD 1000000007
const int maxn= 100010;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n=0,k=0;
    cin>>n>>k;
    vector<int> v[n];
    while(k--)
    {
        int d;
        cin>>d;
        for(int i=0;i<d;++i)
        {
            int x;
            cin>>x;
            --x;
            v[x].pb(d);
        }
    }
    int ct=0;
    for(int i=0;i<n;++i)
    {
        if(v[i].empty())
            ++ct;
    }
    cout<<ct<<endl;
}

Measured memory_bytes: 3720
import java.util.*;

public class Main 
{
    public static void main(String[] args)
    {
        Scanner sc = new Scanner(System.in);
        logic(sc);
    }
    
    public static void logic(Scanner sc)
    {
        int ans = 0;
        
        int m = sc.nextInt();
        ans = gcd(sc.nextInt(),sc.nextInt());
        for(int i=1;i<=m-2;i++)
        {
            ans = gcd(ans,sc.nextInt());
        }
        
        sc.close();
        System.out.print(ans);
    }

    private static int gcd(int a, int b) 
    { 
        if (b == 0) 
            return a; 
        return gcd(b, a % b);  
    } 
}


Measured memory_bytes: 48008
n,a,b = map(int,input().split())
lis = [int(input()) for i in range(n)]
more = a-b

def tansaku(x):
  cou = 0
  normal = b * x
  for hp in lis:
    r = hp -normal
    if r <= 0:continue
    cou += r // more
    
    if r % more != 0:
      cou += 1
  return cou <= x

left = 1
right = max(lis)
while right - left > 1:
  mid = (right + left)//2
  if tansaku(mid):
    right = mid
  else:
    left = mid
print(right)

Measured memory_bytes: 7072
/**
  @file a.cpp
  @title A - 和風いろはちゃんイージー / Iroha and Haiku (ABC Edition)
  @url https://atcoder.jp/contests/abc042/tasks/abc042_a
**/

#include <bits/stdc++.h>
using namespace std;

typedef long long LL;
#define ALL(obj) (obj).begin(), (obj).end()
#define REP(i, N) for (int i = 0; i < (N); ++i)

int main() {
  int A, B, C;
  cin >> A >> B >> C;

  int query = 100 * A + 10 * B + C;

  if (query == 755 || query == 575 || query == 557) {
    cout << "YES" << endl;
  } else {
    cout << "NO" << endl;
  }

  return 0;
}


Measured memory_bytes: 256
N, M = map(int, input().split())
B = [list(input()) for _ in range(N)]
list = [['#']*M] * N

MOVE = [(0, 1),(0, -1),(1, 0),(-1, 0),(1, 1),(1, -1),(-1, 1),(-1, -1)]

for h in range(N):
    for w in range(M):
        count = 0

        for x, y in MOVE:
            next_h = h + y
            next_w = w + x
            if not 0 <= next_h < N or not 0 <= next_w < M:
                continue
            if B[next_h][next_w] == '#':
                count += 1

        list[h][w] = str(count)
        if B[h][w] == '#':
            list[h][w] = '#'

    print(''.join(list[h]))


Measured memory_bytes: 3064
#include<iostream>
using namespace std;
string S;
bool a[26];
int main(){
    cin>>S;
    if(S=="zyxwvutsrqponmlkjihgfedcba"){cout<<-1<<endl;return 0;}
    for(int i=0;i<S.size();i++)a[S[i]-'a']=true;

    if(S.size()!=26)for(int i=0;i<26;i++)if(a[i]==false){cout<<S+char('a'+i)<<endl;return 0;}
    for(int i=0;i<S.size();i++){
        for(int c=S[S.size()-1-i]-'a';c<26;c++){
            if(a[c]==false){
                S[S.size()-1-i]=char('a'+c);
                cout<<S.substr(0,S.size()-i)<<endl;
                return 0;
            }
        }
        a[S[S.size()-1-i]-'a']=false;
    }
    return 0;
}

Measured memory_bytes: 256
#define IN(x,s,g) ((x) >= (s) && (x) < (g))
#define ISIN(x,y,w,h) (IN((x),0,(w)) && IN((y),0,(h)))

#include <queue>
#include <algorithm>
#include <cstring>
#include <cstdlib>
#define REP(i,n) for(int i=0; i<(int)(n); i++)

#include <cstdio>
inline int getInt(){ int s; scanf("%d", &s); return s; }

#include <set>
using namespace std;

const int _dx[] = {0,1,0,-1};
const int _dy[] = {-1,0,1,0};


char g[128][128];
int d[128][128];

int memo[1 << 5][100][100];
int m[100][100];

int main(){
  const int w = getInt();
  const int h = getInt();

  REP(i,h) scanf("%s", g[i]);

  REP(i,h) REP(j,w) d[i][j] = 1;
  REP(i,h) REP(j,w) if(g[i][j] == '#'){
    REP(ii,5) REP(jj, 5){
      const int y = i + (ii - 2);
      const int x = j + (jj - 2);
      d[y][x] = max(d[y][x], 4 - max(abs(y - i), abs(x - j)));
    }
  }

  memset(memo, -1, sizeof(memo));

  typedef pair<int, pair<int, pair<int, int> > > data;

  priority_queue<data, vector<data>, greater<data> > pq;
  REP(i,h) REP(j,w) if(g[i][j] == 'S')
    pq.push(make_pair(0, make_pair(0, make_pair(j, i))));

  int cnt = 0;
  REP(i,h) REP(j,w) if(g[i][j] == 'M'){
    m[i][j] = cnt++;
  }

  while(pq.size()){
    const data dt = pq.top(); pq.pop();
    const int cost = dt.first;
    const int maki = dt.second.first;

    const int x = dt.second.second.first;
    const int y = dt.second.second.second;
    const int cc = cost + d[y][x];

    if(maki == (1 << cnt) - 1 && g[y][x] == 'G'){
      printf("%d\n", cost);
      break;
    }
    if(memo[maki][y][x] != -1) continue;
    memo[maki][y][x] = cost;

    REP(i,4){
      const int xx = x + _dx[i];
      const int yy = y + _dy[i];

      if(ISIN(xx, yy, w, h) && g[yy][xx] != '#'){
	int mm = maki;
	if(g[yy][xx] == 'M'){
	  mm |= (1 << m[yy][xx]);
	}
	if(memo[mm][yy][xx] == -1){
	  pq.push(make_pair(cc, make_pair(mm, make_pair(xx, yy))));
	}
      }
    }
  }

  return 0;
}

Measured memory_bytes: 2508
X = int(input())
a = []
for i in range(4000):
  a.append(i**5)
for i in range(4000):
  if X + a[i] in a:
    A = int((X + a[i])**0.2)
    B = i
  elif X - a[i] in a:
    A = int((X - a[i])**0.2)
    B = -i
print(A,B)

Measured memory_bytes: 9340
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  while(cin>>n,n){
    int k;
    int chk=0,cnt=0;
    for(int i=0;i<n;++i){
      cin>>k;
      if(k>=2) chk=1;
      if(k>=1) cnt++;
    }
    if(!chk) cout<<"NA\n";
    else if(n==1) cout<<2<<endl;
    else cout<<cnt+1<<endl;
  }
    return 0;
  }
  

Measured memory_bytes: 3080
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		
		List<Integer> list = new ArrayList<>();
		
		while (a > 0) {
			list.add(a%10);
			a /= 10;
		}
		
		int result = 0;
		for (int l : list) {
			if (l == 1) {
				result += l;
			}
		}
		
		System.out.println(result);
		
	}
}

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

int main()
{
    int K, N;
    cin >> K >> N;
    vector<int> A(N),B(N);
    for (int i = 0; i < N; i++)
        cin >> A.at(i);
    for (int i = 0; i < N-1; i++) {
        B.at(i) = A.at(i+1) - A.at(i);
    }
    B.at(N-1) = A.at(0) + K - A.at(N-1);
    
    sort(B.begin(), B.end());
    
    int max = 0;
    int sum = 0;
    for (int i = 0; i < N; i++) {
        sum += B.at(i);
        if (max < B.at(i)) max = B.at(i);
    }
    cout << sum - max << endl;
}


Measured memory_bytes: 1792
#include <iostream>

#define lli long long int

using namespace std;

lli max(lli a,lli b){
	return a>=b ? a :b;
}

lli min(lli a,lli b){
	return a<=b ? a : b;
}

void calculateSpace(lli *sMax,lli *sMin,lli h,lli w){
	lli tmp = (h/2)*w;
	lli tmp2 = (h-(h/2))*w;

	*sMax = max(tmp,tmp2);
	*sMin = min(tmp,tmp2);
}

int main(){

	lli h,w;
	cin>>h>>w;

	lli sMax=0;
	lli sMin=100000000;

	lli ans=100000000;

	for(lli i=1;i<w;i++){
		lli s1 = i*h;
		calculateSpace(&sMax,&sMin,h,w-i);
		ans = min(ans,max(sMax,s1)-min(sMin,s1));

		calculateSpace(&sMax,&sMin,w-i,h);
		ans = min(ans,max(sMax,s1)-min(sMin,s1));


	}
		
	for(lli i=1;i<h;i++){
		lli s1 = i*w;
		calculateSpace(&sMax,&sMin,h-i,w);
		ans = min(ans,max(sMax,s1)-min(sMin,s1));
		calculateSpace(&sMax,&sMin,w,h-i);
		ans = min(ans,max(sMax,s1)-min(sMin,s1));
	}

	cout<<ans<<endl;

	return 0;

}

Measured memory_bytes: 256
N,M=map(int,input().split())
K=[list(map(int,input().split()))[1:] for i in range(N)]
X=[0 for i in range(M)]
for i in range(N):
    for j in K[i]:
        X[j-1]+=1
ans=0
for i in range(M):
    if X[i]==N:
        ans+=1
print(ans)


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

#define lli long long int
#define REP(i,s,n) for(int i=s;i<n;i++)
#define MOD 1000000007
#define NUM 2520
#define INF (1LL<<50)
#define DEBUG 0
#define mp(a,b) make_pair(a,b)
#define SORT(V) sort(V.begin(),V.end())
#define PI (3.141592653589794)
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

//dp[i][j],i前の日にしたもの,j:index
lli dp[3100][3100];

int main(){

	string s,t;
	cin>>s>>t;

	REP(i,0,s.size()){
		REP(j,0,t.size()){
			if(s[i]==t[j])chmax(dp[i+1][j+1],dp[i][j]+1);
			else chmax(dp[i+1][j+1],max(dp[i+1][j],dp[i][j+1]));
		}
	}

	lli x=s.size(),y=t.size();

	string u;
	while(x>0&&y>0){
		if(dp[x][y]==dp[x-1][y])x--;
		else if(dp[x][y]==dp[x][y-1])y--;
		else{
			u.push_back(s[x-1]);
			x--,y--;
		}
	}
	reverse(u.begin(),u.end());

	cout<<u<<endl;
    return 0;
}


Measured memory_bytes: 73984
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include <unordered_map>
#include <queue>
#define lol long long
using namespace std;


int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    lol a,b,c;
    cin >> a >> b >> c;
    lol q1=min(a,min(b,c)),q3=max(a,max(b,c)),q2=a+b+c-q1-q3;
    cout << q3-q1;
    return 0;
}

Measured memory_bytes: 256
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author Harshad
 */

#include <bits/stdc++.h>

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define int long long

using namespace __gnu_pbds;
using namespace std;

template <typename T>
using ordered_set =
    tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

const int N = 1e5+1;
int dp[N][3], a[N], b[N], c[N];

class CVacation {
public:
    int n;
    int rec(int i, int prev) {
        if(i == n) return 0;
        if(dp[i][prev] != -1) return dp[i][prev];
        int res = INT_MIN;
        if(prev != 0) res = max(res, a[i] + rec(i+1, 0));
        if(prev != 1) res = max(res, b[i] + rec(i+1, 1));
        if(prev != 2) res = max(res, c[i] + rec(i+1, 2));
        return dp[i][prev] = res;
    }
	void solve(std::istream& in, std::ostream& out) {
        in >> n;
        for(int i = 0; i < n; ++i) in >> a[i] >> b[i] >> c[i];
        memset(dp, -1, sizeof dp);
        int res = 0;
        for(int i = 0; i < 3; ++i) res = max(res, rec(0, i));
        out << res;
	}
};


int32_t main() {
	CVacation solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 9600
#include<stdio.h>
int main(){
  	long long int i,n,sum=0;
  	scanf("%lld",&n);
  	for(i=1;i*(i+1)<n;i++){
    	if(n%i==0) sum=sum+n/i-1;
    }
	printf("%lld",sum);
	return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <string>
#include <math.h>
#include <iomanip>
using namespace std;

#define PI 3.14159265358979323846264338327950L

long long res;

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

    int N;
    bool flag = true;
    //long long *array = new long long [N];
    long long array[100010];
    cin >> N;
    for (int i = 0; i < N; i++)
    {
        cin >> array[i];
        if (array[i] == 0)
        {
            flag = false;
        }
    }

    res = 1;
    if (flag == false)
    {
        res = 0;
    }
    else
    {
        for (int i = 0; i < N; i++)
        {

            if (array[i] <= 1000000000000000000 / res)

            {
                res *= array[i];
            }
            else
            {
                res = -1;
                break;
            }
        }
    }

    cout << res << endl;
    return 0;
}

Measured memory_bytes: 4432
import numpy as np
A, B, C, D = [int(i) for i in input().split()]

large = np.max([C, D])
small = np.min([C, D])

g = large
while small != 0:
    large, small = small, large % small

g = large

l = C * D // g

num_B_1 = B // C
num_B_2 = B // D
num_B_3 = B // l
num_B = B - (num_B_1 + num_B_2 - num_B_3)

num_A_1 = (A - 1) // C
num_A_2 = (A - 1) // D
num_A_3 = (A - 1) // l
num_A = (A - 1) - (num_A_1 + num_A_2 - num_A_3)

print(num_B - num_A)


Measured memory_bytes: 12544
#include<bits/stdc++.h>
#define fast ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define int long long int
#define M 1000000007
#define pie 3.141592653589793238
using namespace std;



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

Measured memory_bytes: 5016
#include <bits/stdc++.h>
#include <sstream> 
#define FAST_IO ios_base::sync_with_stdio(false); cin.tie(NULL);cout.tie(NULL)
#define endl "\n"
#define pi 2*acos(0.0)
#define rep(i,a,b) for(ll i=a;i<b;++i)
#define repe(i,a,b) for(ll i=a;i<=b;++i)
#define CPrint(c)  for(auto i:(c)) { cout<<i<<" "; } nl 
#define eb   emplace_back
#define ef   emplace_front
#define pb   push_back
#define pf   push_front
#define popb pop_back
#define popf pop_front
#define mp   make_pair
typedef long long ll;
using namespace std;
typedef vector<int> vi;
typedef vector< vi > vvi;
typedef pair<ll,ll> pll;
const int INF = 1e5+5;
string convertInt(int number){stringstream ss;ss << number;return ss.str();}
int convertString(string s){int num;stringstream sstr(s);sstr>>num;return num;}
int main()
{
	ll n,w;
	cin >> n >> w;
	vector<ll>weight(n);
	vector<ll>v(n);
	vector<ll> dp(w+1);
 
	rep(i,0,n)
	{
		cin >> weight[i] >> v[i];
		for(int j=w - weight[i];j>=0;j--)
		{
			dp[j+weight[i]] = max(dp[j+weight[i]],dp[j]+v[i]);
		}
	}
	cout << *max_element(dp.begin(),dp.end())<<endl;
}

Measured memory_bytes: 4040
#include <bits/stdc++.h>
#define all(x) begin(x), end(x)
#define dbg(x) cerr << #x << " = " << x << endl
#define _ << ' ' <<
using namespace std;
using ll = long long;
using vi = vector<int>;

vector<pair<int, int>> adj[100000];
int color[100000];

void dfs(int x, int p, int m)
{
    color[x] = (m == 0);
    for (auto q : adj[x])
    {
        int y, w;
        tie(y, w) = q;
        if (y == p) continue;
        dfs(y, x, (m + w) % 2);
    }
}

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    for (int i = 0; i < n - 1; ++i)
    {
        int u, v, w;
        cin >> u >> v >> w;
        u--; v--;
        adj[u].emplace_back(v, w);
        adj[v].emplace_back(u, w);
    }
    dfs(0, -1, 0);
    for (int i = 0; i < n; ++i)
        cout << color[i] << '\n';
}


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

int main() {
  char c;
  cin >>  c;

 
  if (c == 'a' || c == 'e' || c == 'i' || c == 'o' || c == 'u'){
    cout << "vowel" << endl;
  }
  else{
    cout << "consonant" << endl;
  }

}


Measured memory_bytes: 256
# 入力が10**5とかになったときに100ms程度早い
import sys
read = sys.stdin.readline


def read_ints():
    return list(map(int, read().split()))


def read_a_int():
    return int(read())


def read_matrix(H):
    '''
    H is number of rows
    '''
    return [list(map(int, read().split())) for _ in range(H)]


def read_map(H):
    '''
    H is number of rows
    文字列で与えられた盤面を読み取る用
    '''
    return [read()[:-1] for _ in range(H)]


def read_col(H, n_cols):
    '''
    H is number of rows
    n_cols is number of cols

    A列、B列が与えられるようなとき
    '''
    ret = [[] for _ in range(n_cols)]
    for _ in range(H):
        tmp = list(map(int, read().split()))
        for col in range(n_cols):
            ret[col].append(tmp[col])

    return ret


N = read_a_int()
S = input()

s_pre = 'unko'
cnt = 0
for s in S:
    if s != s_pre:
        cnt += 1
        s_pre = s

print(cnt)


Measured memory_bytes: 3316
r,c = [int(i) for i in input().split()]
a = [[int(i) for i in input().split()] for j in range(r)]
b = [sum(a[i]) for i in range(r)]
[a[i].append(b[i]) for i in range(r)]
d = [0 for i in range(c + 1)]
for i in range(r):
    for j in range(c + 1):
        d[j] += a[i][j]
a.append(d)
for i in range(r + 1):
    print(' '.join(map(str,a[i])))

Measured memory_bytes: 7736
#include <stdio.h>

int main() {
  int ans = 0;
  int a, b, c;
  
  scanf("%d %d %d", &a, &b, &c);
  ans++;
  if(a != b) ans++;
  if(a != c && b != c) ans++;
  
  printf("%d\n", ans);
  
  return 0;
}

Measured memory_bytes: 128
import core.bitop, std.algorithm, std.ascii, std.bigint, std.conv,
    std.functional, std.math, std.numeric, std.range, std.stdio, std.string,
    std.random, std.typecons, std.container;

ulong MAX = 1_000_100, MOD = 1_000_000_007, INF = 1_000_000_000_000;
alias sread = () => readln.chomp();
alias lread(T = long) = () => readln.chomp.to!(T);
alias aryread(T = long) = () => readln.split.to!(T[]);
alias Pair = Tuple!(long, "l    ", long, "r");
alias PQueue(T, alias less = "a<b") = BinaryHeap!(Array!T, less);

void main()
{
    long d, n;
    scan(d, n);
    if(n < 100)
        writeln(n * 100 ^^ d);
    else
        writeln(100 ^^ d + 100 ^^ (d + 1));
}

void scan(TList...)(ref TList Args)
{
    auto line = readln.split();
    foreach (i, T; TList)
    {
        T val = line[i].to!(T);
        Args[i] = val;
    }
}


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

int main(){
  long long n, q; cin >> n >> q;
  vector<vector<long long>> e(n);
  for(int i = 0; i < n - 1; i++){
    long long a, b; cin >> a >> b;
    a--; b--;
    e.at(a).push_back(b);
    e.at(b).push_back(a);
  }
  vector<long long> count(n, 0);
  for(int i = 0; i < q; i++){
    long long p, x; cin >> p >> x;
    p--;
    count.at(p) += x;
  }
  vector<long long> out(n, -1);
  queue<long long> que;
  que.push(0);
  long long val = 0;
  while(!que.empty()){
    long long u = que.front();
    que.pop();
    for(int i : e.at(u)){
      if(out.at(i) != -1){
        val = out.at(i);
        continue;
      }
      que.push(i);
    }
    out.at(u) = val + count.at(u);

  }
  for(int i = 0; i < n; i++){
    cout << out.at(i) << " ";
  }
}


Measured memory_bytes: 19440
#include<cstdio>
#include<algorithm>
using namespace std;
long long b, e, w[101000];
int K;
int main() {
	int i;
	scanf("%d", &K);
	for (i = 1; i <= K; i++)scanf("%lld", &w[i]);
	b = e = 2;
	for (i = K; i >= 1; i--) {
		long long t1 = (b + w[i] - 1) / w[i], t2 = e / w[i];
		if (t1 > t2) {
			printf("-1\n");
			return 0;
		}
		b = t1*w[i], e = (t2 + 1)*w[i] - 1;
	}
	printf("%lld %lld\n", b, e);
}

Measured memory_bytes: 896
#include <bits/stdc++.h>
using namespace std;
int main()
{
	int n, m;
	cin>>n>>m;
	int cnt = 0;
	vector<pair<int,int> > arr;
	for(int i =0;i<m;i++)
	{
		int a, b;
		cin>>a>>b;
		arr.push_back(make_pair(a,b));
	}
	int f = 0, e = n;
	for(int i =0;i<arr.size();i++)
	{
		int l = arr[i].first, r = arr[i].second;
		f = max(l,f);
		e = min(e, r);
	}
	if(f > e)
		cout<<0<<endl;
	else
	cout<<e - f +1<<endl;
	return 0;
} 	

Measured memory_bytes: 1400
#include <iostream>
#include <cstring>
using namespace std;
int main()
{
	int n;
	cin>>n;
	int x;
	int a[n+1],b[n+1];
	memset(a,0,sizeof(a));
	memset(b,0,sizeof(b));
	for(int i=1;i<=n;i++)
	{
		cin>>x;
		a[i]=a[i-1]+x;
	}
	for(int i=1;i<=n;i++)
	{
		cin>>x;
		b[i]=b[i-1]+x;
	}
	int maxv=-1;
	for(int i=1;i<=n;i++)
	{
		int sum=a[i]-a[0]+b[n]-b[i-1];
		if(sum>maxv)
			maxv=sum;
	}
	cout<<maxv<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, a, n) for (int i = a; i < n; i++)
#define repr(i, a, n) for (int i = n - 1; i >= a; i--)
using namespace std;
using ll = long long;
using P = pair<int, int>;
template <typename T> void chmin(T &a, T b) { a = min(a, b); }
template <typename T> void chmax(T &a, T b) { a = max(a, b); }

constexpr int mod = 1000000007;
struct mint {
  long long x;
  constexpr mint(long long x = 0) : x((x % mod + mod) % mod) {}
  constexpr mint operator-() const { return mint(-x); }
  constexpr mint &operator+=(const mint &a) {
    if ((x += a.x) >= mod)
      x -= mod;
    return *this;
  }
  constexpr mint &operator-=(const mint &a) {
    if ((x += mod - a.x) >= mod)
      x -= mod;
    return *this;
  }
  constexpr mint &operator*=(const mint &a) {
    (x *= a.x) %= mod;
    return *this;
  }
  constexpr mint operator+(const mint &a) const {
    mint res(*this);
    return res += a;
  }
  constexpr mint operator-(const mint &a) const {
    mint res(*this);
    return res -= a;
  }
  constexpr mint operator*(const mint &a) const {
    mint res(*this);
    return res *= a;
  }
  constexpr mint pow(long long t) const {
    if (!t)
      return 1;
    mint a = pow(t >> 1);
    a *= a;
    if (t & 1)
      a *= *this;
    return a;
  }

  constexpr mint inv() const { return pow(mod - 2); }
  constexpr mint &operator/=(const mint &a) { return (*this) *= a.inv(); }
  constexpr mint operator/(const mint &a) const {
    mint res(*this);
    return res /= a;
  }
};
ostream &operator<<(ostream &os, const mint &m) {
  os << m.x;
  return os;
}

struct combination {
  vector<mint> fact, ifact;
  combination(int n) : fact(n + 1), ifact(n + 1) {
    assert(n < mod);
    fact[0] = 1;
    for (int i = 1; i <= n; ++i)
      fact[i] = fact[i - 1] * i;
    ifact[n] = fact[n].inv();
    for (int i = n; i >= 1; --i)
      ifact[i - 1] = ifact[i] * i;
  }
  mint operator()(int n, int k) {
    if (k < 0 || k > n)
      return 0;
    return fact[n] * ifact[k] * ifact[n - k];
  }
};

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

  ll x, y;
  cin >> x >> y;

  if ((x + y) % 3 != 0) {
    cout << 0 << endl;
    return 0;
  }

  int c = (x + y) / 3;
  int xx = x - c, yy = y - c;

  combination comb(xx + yy);
  mint ans = comb(xx + yy, xx);

  cout << ans.x << endl;
}


Measured memory_bytes: 13716
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
#include <cstring>
#include <utility>
#include <numeric>

using namespace std;

const long long INF = (1LL << 60);

int main(){

    vector<int> a(4);
    cin >> a[0] >> a[1] >> a[2] >> a[3];

    long long ans = -INF;
    if(a[0] <= 0 && 0 <= a[1]){
        ans = 0;
    }
    if(a[2] <= 0 && 0 <= a[3]){
        ans = 0;
    }
    
    for(int i = 0; i <= 1; i++){
        for(int j = 2; j <= 3; j++){
            ans = max(ans, (long long)a[i] * a[j]);
        }
    }

    cout << ans << endl;

    return 0;
}

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

#include <cstdlib>  // abs() for integer 絶対値求めやつ

#include <cmath>    // abs() for float, and fabs()

#include <algorithm>
#include <vector>
#define rep(i,n) for(int i = 0; i< (n);i++)

#define sort(a) sort((a).begin(),(a).end());

#define che(a,string) cout<<string<<":"<<(a)<<endl;

#define ch(a,string) cout<<string<<":"<<(a)<<" ";

using namespace std;

typedef pair<int,int> p;

int main(){
	int a,b,c;
	cin>>a>>b>>c;
	int ans = 0;
	ans =a;
	if(ans == b){
		ans = c;
	  }
	  else{//a!=b 
		  ans = b;
		  if(ans == c){//a!= b katu b == c
			  ans =a;
			}
		}
		cout<<ans<<endl;
}

Measured memory_bytes: 256
#include<cstdio>
#include<queue>
#include<algorithm>
#include<string.h>
#include<math.h>
#include<set>
using namespace std;
long long fun(long long x){
	if(x==1)
	return 1;
	return 2*fun(x/2)+1;
}
int main(){
	long long n;
	scanf("%lld",&n);
	printf("%lld\n",fun(n));
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define ll long long int
#define mp make_pair
#define S second
#define F first
ll mod=1e9+7 ;
#define fastIO ios_base::sync_with_stdio(false); cin.tie(NULL);
#define input_from_file  freopen("input.txt", "r", stdin);
using namespace std::chrono; 

int main()
{
  // input_from_file 
  // ll q;cin>>q;while(q--){
    ll n,d,ctr=0;cin>>n>>d;
    for(int i=0;i<n;i++){
      ll x,y;cin>>x>>y;if(x*x+y*y<=d*d) ctr++;
    }
    cout<<ctr;
  // }
  return 0;
}


Measured memory_bytes: 3636
import std.stdio, std.string, std.conv;
import std.range, std.algorithm, std.array, std.math;

import std.typecons;
alias Seg = Tuple!(int, "l", int, "r", int, "len");

void main() {
    int n, m;
    scan(n, m);

    auto p = new Seg[](n);

    foreach (i ; 0 .. n) {
        int li, ri;
        scan(li, ri);
        p[i] = Seg(li, ri, ri - li + 1);
    }

    p.sort!"a.len < b.len"();

    writeln(n);

    //auto ft = FenwickTree(m + 2);
    auto sd = SqrtDecomp(m + 2);

    foreach (d ; 2 .. m + 1) {
        while (!p.empty && p.front.len < d) {
            //ft.add(p.front.l, 1);
            //ft.add(p.front.r + 1, -1);
            sd.add(p.front.l, 1);
            sd.add(p.front.r + 1, -1);
            p.popFront();
            n--;
        }

        int ans = n;

        for (int i = 0; i <= m; i += d) {
            ans += sd.sum(0, i + 1);
        }

        writeln(ans);
    }
}

struct SqrtDecomp {
    private {
        enum rt = 512;
        int N, K;
        int[] buck;
        int[] data;
    }

    this(int n) {
        N = n;
        K = (N + rt - 1) / rt;
        buck = new int[](K);
        data = new int[](K * rt);
    }

    void add(int i, int x) {
        data[i] += x;
        buck[i / rt] += x;
    }

    int sum(int l, int r) {
        int res;

        foreach (k ; 0 .. K) {
            int bl = k * rt, br = (k + 1) * rt;
            if (r <= bl || br <= l) continue;
            if (l <= bl && br <= r) {
                res += buck[k];
            }
            else {
                foreach (j ; max(l, bl) .. min(r, br)) {
                    res += data[j];
                }
            }
        }

        return res;
    }
}


struct FenwickTree {
    private {
        int N;
        int[] data;
    }

    this(int n) {
        N = n;
        data = new int[](N + 1);
    }

    void add(int i, int x) {
        i++;
        while (i <= N) {
            data[i] += x;
            i += i & (-i);
        }
    }

    int sum(int r) {
        int res;
        while (r > 0) {
            res += data[r];
            r -= r & (-r);
        }
        return res;
    }
}


void scan(T...)(ref T args) {
    import std.stdio : readln;
    import std.algorithm : splitter;
    import std.conv : to;
    import std.range.primitives;

    auto line = readln().splitter();
    foreach (ref arg; args) {
        arg = line.front.to!(typeof(arg));
        line.popFront();
    }
    assert(line.empty);
}



void fillAll(R, T)(ref R arr, T value) {
    static if (is(typeof(arr[] = value))) {
        arr[] = value;
    }
    else {
        foreach (ref e; arr) {
            fillAll(e, value);
        }
    }
}


Measured memory_bytes: 7036
n=int(input())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
lack=0
ob=[0]
ans=0
for i in range(n):
	if a[i]>b[i]:
		ob.append(a[i]-b[i])
	elif a[i]<b[i]:
		lack+=(b[i]-a[i])
		ans+=1
ob.sort()
ob.reverse()
for i in range(len(ob)-1):
	if lack<=0:
		break
	lack-=ob[i]
	ans+=1
	
if lack>0:
	print(-1)
else:
	print(ans)


Measured memory_bytes: 18292
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<algorithm>
#include<bitset>
#include<vector>
#include<deque>
#include<queue>
#include<map>
#include<set>
#include<stack>
#include<cmath>
#include<iomanip>
#include <functional>
using namespace std;
typedef long long ll;
const int mod = 1000000007;
const double EPS = 1e-10;
const int INF = 2147483647;
//cout << fixed << std::setprecision(9)
//memset(a, 0, sizeof(a));
//--------------------------

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

	if (a == b) {
		cout << c << endl;
	}
	if (a == c) {
		cout << b << endl;
	}
	if (c == b) {
		cout << a << endl;
	}

	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <utility>
#include <cstdlib>
#include <cstdio>
#include <vector>
#include <queue>
#include <cmath>
#include <map>
#include <set>
using namespace std;
int mark[100001],A[100001]; 
int main()
{
	int n,i,j,k,x,y,z,c=0;
	cin>>n;
	for(i=1;i<=n;i++)
	cin>>A[i];
	x=1;
	c=0;
	mark[1]=1;
	while(x!=2)
	{
		c++;
		x=A[x];
		if(mark[x])
		break;
		mark[x]=1;
	}
	if(x==2)
	cout<<c<<endl;
	else
	cout<<-1<<endl;
return 0;
}



Measured memory_bytes: 1152
import bisect


def solve(k, aaa):
    aaa = aaa[:bisect.bisect_left(aaa, k)]

    dp = [False] * k
    dp[0] = True
    curr_max = 0
    ans = len(aaa)
    for i, a in reversed(list(enumerate(aaa))):
        if curr_max + a >= k:
            ans = i
        f = True
        for j in range(min(curr_max, k - a - 1), -1, -1):
            if dp[j]:
                dp[j + a] = True
                if f:
                    curr_max = max(curr_max, j + a)
                    f = False
    return ans


n, k = map(int, input().split())
aaa = list(map(int, input().split()))
aaa.sort()

print(solve(k, aaa))


Measured memory_bytes: 3828
#include <cstdio>
#include <algorithm>
#include <iostream>
#include <string>
#include <cstring>
using namespace std;
int main(){
    int n,m,x,y;
    int a[200],b[200];
    
    cin>>n>>m>>x>>y;
    for(int i=0;i<n;i++) cin>>a[i];
    for(int i=0;i<m;i++) cin>>b[i];
    
    sort(a,a+n);
    sort(b,b+m);
    bool flag = false;
    for(int i=x+1;i<=y;i++){
        if(i>a[n-1] && i<=b[0]){
            flag = true;
            //cout<<i;
            break;
        }
    }
    if(flag) cout<<"No War"<<endl;
    else cout<<"War"<<endl;
    return 0;
}



Measured memory_bytes: 256