akhauriyash/Code-Regression huggingface dataset:
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include<bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define pii pair<int,int>
#define pp pair<pair<ll, ll>,pair<ll, ll>>
#define pll pair<ll,ll>
#define pdd pair<double,double>
#define vii vector<int>
#define vll vector<ll>
#define mat vector<vector<ll>>
#define lb lower_bound
#define ub upper_bound
#define pb push_back
#define eb emplace_back
#define fi first
#define sc second
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep2(i,a,b) for(ll i=a;i<b;i++)
#define repr(i,n) for(ll i=n-1;i>=0;i--)
#define all(x) x.begin(),x.end()
#define sz(x) (ll) (x).size()
#define pq priority_queue<ll>
#define pqg priority_queue<ll,vector<ll>,greater<ll>>
#define LB(v,x) (lower_bound(v.begin(),v.end(),x)-v.begin())
#define UB(v,x) (upper_bound(v.begin(),v.end(),x)-v.begin())
#define ERASE(v) sort(v.begin(),v.end());v.erase(unique(v.begin(),v.end()),v.end())
#define int ll
// #define ll int
using namespace std;
const ll INF = (1 << 30 ) - 1;
const ll LLINF = (1LL << 60LL);
const ll MOD = 1000000007;
const ll mod = 998244353;
const ll MAX = 1100000;
const double pi = acos(-1);
const double eps = 1e-10;
ll dx[4] ={1,0,-1,0} , dy[4] ={0,1,0,-1};

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

struct Timer{
    chrono::system_clock::time_point start, end;
    Timer(){ start = chrono::system_clock::now(); }
    ~Timer(){
        end = chrono::system_clock::now();
        auto msec = chrono::duration_cast<chrono::milliseconds>(end - start).count();
        cerr<<"time : "<<msec<<" ms"<<endl;
    }
};

ll sumofdigits(ll n){
    int sum =0;
    while(n>0){
        sum += n%10;
        n /=10;
    }
    return sum;
}

void solve(){
    ll n;
    cin>>n;
    ll l[10010];
    l[0]=2;
    l[1]=1;
    rep2(i,2,1010){
        l[i]=l[i-1]+l[i-2];
    }
    cout<<l[n]<<endl;


}


signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    // Timer TM;
    
    solve();

    return 0;
}


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

s = list(S)

dict1 = {'A':1, 'B':2, 'C':3, 'D':4, 'E':5, 'F':6, 'G':7, 'H':8, 'I':9, 'J':10, 'K':11, 'L':12, 'M':13, 'N':14, 'O':15, 'P':16, 'Q':17, 'R':18, 'S':19, 'T':20, 'U':21, 'V':22, 'W':23, 'X':24, 'Y':25, 'Z':26}
dict2 = {1:'A', 2:'B', 3:'C', 4:'D', 5:'E', 6:'F', 7:'G', 8:'H', 9:'I', 10:'J', 11:'K', 12:'L', 13:'M', 14:'N', 15:'O', 16:'P', 17:'Q', 18:'R', 19:'S', 20:'T', 21:'U', 22:'V', 23:'W', 24:'X', 25:'Y', 26:'Z'}

result = ''
for i in s:
    num = dict1[i] + N
    if num > 26:
        num -= 26
    key = dict2[num]
    result += key

print(result)

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

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

template< typename T > inline void read(T &x)
{
    static char _c;
    static bool _f;

    x = 0;
    _f = 0;
    _c = getchar();

    while(_c < '0' || '9' < _c) {if(_c == '-') _f = true; _c = getchar();}
    while('0' <= _c && _c <= '9') {x = (x << 1) + (x << 3) + (_c & 15); _c = getchar();}
    if(_f) x = -x;
}

template < typename T > inline void Min(T &x, T y) {if(y < x) x = y;}
template < typename T > inline void Max(T &x, T y) {if(x < y) x = y;}


#define lowbit(x) ((x) & -(x))
#define lson l,mid,id<<1
#define rson mid+1,r,id<<1|1
#define ls id<<1
#define rs id<<1|1
#define MID(l,r) ((l)+(((r)-(l))>>1))
#define fi first
#define se second
#define mk make_pair
#define pb push_back

const int MOD = (int) 1e9 + 7;
const int inf = (int) 1e9;
const int maxn = (int) 2e5 + 20;
const int maxm = (int) 5e5 + 20;

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

    int sum = accumulate(a.begin(), a.end(), 0);

    int inf = 1e9;

    int t = 0;
    for(int i = 0; i <= n; i++)
    {
        Min(inf, abs(sum - 2 * t));
        t += a[i];
    }

    cout <<inf <<endl;
}

int main()
{
#ifdef yukihana0416
freopen("in.txt", "r", stdin);
//freopen("out.txt", "w", stdout);
#endif // yukihana0416
    int tc = 1;
//    cin >>tc;
    for(int ca = 1; ca <= tc; ca++)
    {
//        printf("Case #%d: ", ca);
        work();
    }
    return 0;
}


Measured memory_bytes: 256
import math

N = int(input())

ans = 0

for i in range(int((math.sqrt(N)))+1):
    if N % (i+1) == 0:
        if  ( N / (i+1) ) -1 > (i+1):
            ans = ans + ( N / (i+1) ) -1
        else:
            break
            #break
        #print( N / (i+1)-1)
        #ans = ans + ( N / (i+1) ) -1
        
        
print(int(ans))

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

int main() {
	string in;
	int n = 0;
	while (cin >> in) {
		n = 0;
		in += '\0';
		for (int i = 0; i < in.size(); i++) {
			if (in[i] == 'M')
				n += 1000;
			if (in[i] == 'D')
				n += 500;
			if (in[i] == 'L')
				n += 50;
			if (in[i] == 'V')
				n += 5;
			if (in[i] == 'C') {
				if (in[i+1] == 'M' || in[i+1] == 'D')
					n -= 100;
				else
					n += 100;
			}
			if (in[i] == 'X') {
				if (in[i+1] == 'C' || in[i+1] == 'L')
					n -= 10;
				else
					n += 10;
			}
			if (in[i] == 'I') {
				if (in[i+1] == 'X' || in[i+1] == 'V')
					n -= 1;
				else
					n += 1;
			}
		}
		cout << n << endl;
	}
}


Measured memory_bytes: 3216
#include<cstdio>
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<queue>
#include<stack>
#include<map>
#include <iomanip>

#define rep0(i,N) for(int i=0;i<N;i++)
#define rep1(i,a,N) for(int i=0+a;i<N;i++)
#define lint long long int
#define SIZE 100005

using namespace std;

int main(){
	string str;
	cin>>str;
	lint ans=0;
	int cc;
	if(str[0]=='B')cc=0;
	else cc=1;
	rep1(i,1,str.size()){
		if(str[i]=='B'){
			if(cc==1) ans++;
			cc=0;
		}
		else{
			if(cc==0) ans++;
			cc=1;
		}
	}
	cout<<ans;

return 0;
}

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

int main(){
    string s;
    cin >> s;
    vector<string> d = {"SUN", "MON", "TUE", "WED", "THU", "FRI", "SAT"};
    rep(i,7){
        if(s == d[i]){
            cout << 7-i << endl;
            return 0;
        }
    }

}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long int llint;
typedef long int lint;
typedef long long ll;
typedef vector<char> vchar;
typedef vector<int> vint;
typedef vector<long long> vll;
typedef vector<vector<long long>> vvll;
typedef vector<vector<int>> vvint;
typedef vector<vector<char>> vvchar;
#define vsort(v) sort((v).begin(), (v).end())
#define vrsort(v) sort((v).rbegin(), (v).rend())
#define vreverse(v) reverse((v).begin(), (v).end())
#define pb(a) push_back(a)
#define INF 2000000009
#define MOD 1000000007
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  //input
  ll n,a,b;cin>>n>>a>>b;
  //caricurate
  if(n==1){
    if(a==b){cout<<1<<endl;return 0;}
    else{cout<<0<<endl;return 0;}
  }
  if(a>b){cout<<0<<endl;return 0;}
  ll ans;ans=(b-a)*(n-2);
  //output
  cout<<ans+1<<endl;
}

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

int compare_int(const void *a, const void *b)
{
    return *(int*)b - *(int*)a;
}

int main(void)
{
	//変数の宣言
	int xgoal,ygoal;
	char s[8010];
	int move[8010];
	int movelen,xlen,ylen;
	int x[4010];
	int y[4010];
	int xdp[8000];
	int ydp[8000];
	int xsum,ysum;
	
	//よく使う変数
	int i,j,k,l;
	int flag=0;
	int ans=0;
	int count=0;
	int temp,temp1,temp2;
	int min;
	int len;
	//データの読み込み
	scanf("%s",&s);
	scanf("%d %d",&xgoal,&ygoal);
	
	/*for(i=0;i<n;i++){
		for(j=0;j<n;j++){
			scanf("%d",&a[i][j]);
		}
	}*/
	
	for(i=0;i<8010;i++){
		xdp[i]=0;
		ydp[i]=0;
	}
//	printf("nは%dです\n", n);
//	printf("データの読み込み終了\n");
	//実際の処理
	len=strlen(s);
	
	j=0;
	temp=0;
	for(i=0;i<len;i++){
		if(s[i]=='F'){
			temp++;
		}else{
			move[j]=temp;
			temp=0;
			j++;
		}
	}
	if(temp!=0){
		move[j]=temp;
		temp=0;
		j++;
	}
	movelen=j;
	xlen=(j+1)/2;
	ylen=j/2;
	xsum=0;
	ysum=0;
	for(i=0;i<movelen;i++){
		if(i%2==0){
			x[i/2]=move[i];
			xsum=xsum+move[i];
		}else{
			y[i/2]=move[i];
			ysum=ysum+move[i];
		}
	}
	
/*	printf("x[i]\n");
	for(i=0;i<xlen;i++){
		printf("%d ",x[i]);
	}
	printf("\n");
	printf("y[i]\n");
	for(i=0;i<ylen;i++){
		printf("%d ",y[i]);
	}
	printf("\n");
*/	
	
	
	if((xsum+xgoal)%2==1||(ysum+ygoal)%2==1){
		printf("No");
		return 0;
	}
	
	xgoal=(xsum+xgoal)/2;
	ygoal=(ysum+ygoal)/2;
	xdp[x[0]]=1;
	x[0]=0;
	
	qsort(x, xlen, sizeof(int), compare_int);
	qsort(y, ylen, sizeof(int), compare_int);
	
/*	printf("x[i]\n");
	for(i=0;i<xlen;i++){
		printf("%d ",x[i]);
	}
	printf("\n");
	printf("y[i]\n");
	for(i=0;i<ylen;i++){
		printf("%d ",y[i]);
	}
	printf("\n");
*/	
	
	for(i=0;i<xlen;i++){
		for(j=xgoal-1;j>=0;j--){
			if(xdp[j]==1){
				xdp[j+x[i]]=1;
			}
		}
		if(xdp[xgoal]==1){
			flag=1;
		}
	}
	
//	for(j=0;j<=xgoal;j++){
//		printf("%d ",xdp[j]);
//	}
//	printf("\n");
	
	if(flag==0){
		printf("No");
		return 0;
	}
	flag=0;
	
	if(ylen==0&&ygoal==0){
		printf("Yes");
		return 0;
	}
	
	ydp[0]=1;
	for(i=0;i<ylen;i++){
		for(j=ygoal-1;j>=0;j--){
			if(ydp[j]==1){
				ydp[j+y[i]]=1;
			}
		}
		if(ydp[ygoal]==1){
			flag=1;
		}
//		printf("tag5 i=%d y[%d]=%d\n",i,i,y[i]);
//		for(k=0;k<=ygoal;k++){
//		printf("%d ",ydp[k]);
//		}
//		printf("\n");
	}
	
//	for(j=0;j<=ygoal;j++){
//		printf("%d ",ydp[j]);
//	}
//	printf("\n");
	
	if(flag==0){
		printf("No");
	}else{
		printf("Yes");
	}
	
//	printf("計算部分終了\n");
	//出力
	
	//printf("%d",ans);
	
//	printf("結果の出力終了\n");
	
	return 0;
	
}



Measured memory_bytes: 256
#![allow(unused)]

fn solve<R: std::io::BufRead>(mut sc: Scanner<R>) {
    let x: i64 = sc.get();

    let mut m = 100;
    for y in 1.. {
        m = ((m as f64) * 1.01) as i64;
        if m >= x {
            println!("{}", y);
            break;
        }
    }
}

macro_rules! debug {
    ($($a:expr),*) => {
        eprintln!(concat!($(stringify!($a), " = {:?}, "),*), $($a),*);
    }
}

//
// Based on EbTech's Scanner https://stackoverflow.com/q/56449027
//
struct Scanner<'a, R: std::io::BufRead> {
    reader: R,
    buf: String,
    iter: std::str::SplitWhitespace<'a>,
}

impl<'a, R: std::io::BufRead> Scanner<'a, R> {
    fn new(reader: R) -> Self {
        Self { reader, buf: String::new(), iter: "".split_whitespace() }
    }

    fn get<T: std::str::FromStr>(&mut self) -> T {
        if let Some(t) = self.iter.next() {
            return t.parse().ok().expect("Parse error")
        }
        self.buf.clear();
        self.reader.read_line(&mut self.buf).expect("I/O error");
        self.iter = unsafe { std::mem::transmute(self.buf.split_whitespace()) };
        self.get()
    }

    fn gets<T: std::iter::FromIterator<char>>(&mut self) -> T {
        use std::io::Read;
        assert_eq!(self.iter.next(), None);
        self.reader
            .by_ref()
            .bytes()
            .map(|b| b.unwrap() as char)
            .skip_while(|&c| c.is_whitespace())
            .take_while(|&c| !c.is_whitespace())
            .collect()
    }
}

fn main() {
    let stdin = std::io::stdin();
    solve(Scanner::new(stdin.lock()));
}



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


public class Main {

	private static Scanner sc;
	private static Printer pr;

	private static void solve() {
		int n = sc.nextInt();

		int[] t = new int[n];
		int sum = 0;
		for (int i = 0; i < n; i++) {
			t[i] = sc.nextInt();
			sum += t[i];
		}

		int m = sc.nextInt();
		int[] p = new int[m];
		int[] x = new int[m];
		for (int i = 0; i < m; i++) {
			p[i] = sc.nextInt() - 1;
			x[i] = sc.nextInt();
		}

		for (int i = 0; i < m; i++) {
			pr.println(sum - t[p[i]] + x[i]);
		}
	}

	// ---------------------------------------------------
	public static void main(String[] args) {
		sc = new Scanner(System.in);
		pr = new Printer(System.out);

		solve();

		pr.close();
		sc.close();
	}

	private static class Printer extends PrintWriter {
		Printer(PrintStream out) {
			super(out);
		}
	}
}


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

#define mod 998244353
ll ebob(ll a, ll b){
	if(a == 0) return b;
	return ebob(b%a, a);
}
ll ekok(ll a, ll b){
	return (a*b)/ebob(a,b);
}
int main(){
	char c2 = '.';
	while(1){
		char c; scanf("%c", &c);
		if(c2 == c){
			cout<<"Bad";
			return 0;
		}
		if(c == '\n') break;
		c2 = c;
	}
	cout<<"Good";
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long n,x;
    cin>>n>>x;
    vector<pair<long long,long long>>v(n);
    for(long long i=0;i<n;i++)
    {
        cin>>v[i].first;
        cin>>v[i].second;
    }
    long long dp[n+1][x+1];
    for(long long i=0;i<=n;i++)
        {for(long long j=0;j<=x;j++)
           {
               if(i==0||j==0)
                    dp[i][j]=0;
               else if(v[i-1].first<=j)
                    dp[i][j]=max(dp[i-1][j],(dp[i-1][j-v[i-1].first]+v[i-1].second));
               else
                    dp[i][j]=dp[i-1][j];
                //cout<<" "<<dp[i-1][j-v[i-1].first]+v[i-1].second;
           }
           //cout<<endl;
        }
    /*for(long long i=0;i<=n;i++)
        {for(long long j=0;j<=x;j++)
           {
               cout<<dp[i][j]<<" ";
           }
           cout<<endl;}*/
    cout<<dp[n][x];
    return 0;
}


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

#ifndef ONLINE_JUDGE
#  define LOG(x) (cerr <<">>>>>>"<< #x << " = " << (x) << endl)
#else
#  define LOG(x) ((void)0)
#endif

int main()
{
	
int n,an=1;
cin>>n;
while(an*2<=n)an<<=1;
cout<<an<<endl;

}



Measured memory_bytes: 3556
#include<iostream>

using namespace std;

int main(){

  int n, a, b;
  int c[100010]={};

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

  int ans=0;
  for(int j=2;j<=100001;j++) if(j-1<=c[j]) ans=j-1;

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



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

#define ln '\n'
#define REP(i, n) for(int i = 0; i < (int)(n); ++i)
#define FOR(i, a, b) for(int i = (a); i <= (int)(b); ++i)
#define FORR(i, a, b) for(int i = (a); i >= (int)(b); --i)
#define ALL(c) (c).begin(), (c).end()

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;
typedef vector<P> VP;
typedef vector<PL> VPL;
typedef vector<string> VS;


int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, m;
    cin >> n >> m;
    VI a_hash(m, 0);
    REP(i, n) {
        int k;
        cin >> k;
        REP(j, k) {
            int a;
            cin >> a;
            a--;
            a_hash[a]++;
        }
    }
    int ans = 0;
    REP(i, m)if(a_hash[i] == n)ans++;
    cout << ans << ln;
    return 0;
}


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

int n,T,i,j,a,b;
int f[2020];

int main(){
	scanf("%d%d",&n,&T);
	memset(f,0x3f3f33f,sizeof(f));
	f[0]=0;
	for (i=1;i<=n;i++){
		scanf("%d%d",&a,&b);
		for (j=T-b;j>=0;j--)
			if (f[j]+a<f[j+b])	f[j+b]=f[j]+a;
	}
	f[0]=0x3f3f3f3f;
	for (i=1;i<=T;i++)
	if (f[i]<f[0])	f[0]=f[i];
	if (f[0]!=0x3f3f3f3f)
	cout<<f[0]<<endl;	else cout<<"TLE";
	return 0;
}

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

#define fi first
#define se second
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

using namespace std;

typedef long long ll;
typedef vector<ll> vll;
typedef pair<ll, ll> pll;
typedef long double ld;

const ll mod = (ll)1e9 + 7;
const ll mxN = 200200;



void solve(){
	string s;ll k;
	cin>>s>>k;
	int i;
	for(i=0;i<s.length() && s[i]=='1';i++);
	if(k<=i) cout<<1<<"\n";
	else cout<<s[i];
}

int main() {
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.precision(20);
	cout << fixed;

	//ll t;cin>>t;while(t--)
	solve();

}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
	//freopen(".in","r",stdin);
	//freopen(".out","w",stdout);
	int x,y,z;
	cin>>x>>y>>z;
	cout<<z<<' '<<x<<' '<<y<<endl; 
	return 0;
}


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

typedef long long ll;
const ll INF = 1e9, MOD = 1e9 + 7;
const double EPS = 1e-9, PI = 3.141592653589793;
#define REP(i,a,b) for(ll i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)
#define REPR(i,a,b) for(ll i=b;i>=a;i--)
#define repr(i,n) REPR(i,0,n)
#define all(v) (v).begin(), (v).end()
#define pb push_back
#define fi first
#define se second
#define P pair<ll,ll>
#define m_p make_pair

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

    ll n,m,amount,ans=0;
    cin >> n >> m;
    vector<ll> a(n),b(n);
    map<ll,ll> mp;
    rep(i,n){
        cin >> a[i] >> b[i];
        mp[a[i]] += b[i];
    }
    for(auto x : mp){
        amount = min(m,x.se);
        ans += x.fi * amount;
        m -= amount;
        if(m==0) break;
    }
    cout << ans << "\n";
    return 0;
}

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

int main(){
	int a, n;
	while(cin >> n){
	a = 0;
	for(int i = 0;i < 10;i++){
		for(int j = 0;j < 10;j++){
			for(int k = 0;k < 10;k++){
				for(int t = 0;t < 10;t++){
					if(i + j + k + t == n)a++;
				}
			}
		}
	}
	cout << a << endl;
	}
	return 0;
}

Measured memory_bytes: 3068
N,M = map(int,input().split())
li = [[int(i) for i in input().split()] for j in range(M)]
li.sort()
a = b = C = 0
for d in li:
    if a < d[0]:
      if b <= d[0]:
        C += 1
        a = d[0]
        b = d[1]
      else:
        b = min(b,d[1])
print(C)

Measured memory_bytes: 21652
N,M = map(int,input().split())
h = [list(map(int, input().split()))for i in range(M)]
for i in range(M):
    h[i].append(i)
h = sorted(h,key=lambda h:(h[0],h[1]))
k = 0
p = h[0][0]
for i in range(M):
    if h[i][0] == p:
        h[i].append(str(p).zfill(6)+str(k+1).zfill(6))
        k+=1
    else:
        p = h[i][0]
        k = 0
        h[i].append(str(p).zfill(6) + str(k + 1).zfill(6))
        k += 1
# print(h)
h = sorted(h,key=lambda h:h[2])
# print(h)
for i in range(M):
    print(h[i][3])

Measured memory_bytes: 39572
#include<iostream>
#include<string>
using namespace std;
int main(){
  int k=0;
  string a;
  cin>>a;
  if(a[0]=='1') k++;
  if(a[1]=='1') k++;
  if(a[2]=='1') k++;
  
  cout<<k<<endl;
  return 0;
}


Measured memory_bytes: 3192
#include<bits/stdc++.h>
using namespace std;
signed main(){
  long long n,a,b;
  cin>>n;
  while(true){
    a = sqrt(n);
    if(a*a==n){
	cout<<n<<"\n";
      return(0);
    }else{
      n--;
    }
  }
  return(0);
}
  

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n;
    cin>>n;
    int a[n-1],b[n-1],c[n-1];
    vector<vector<pair<int,int>>>pas(n);
    for(int i=0;i<n-1;i++){
        cin>>a[i]>>b[i]>>c[i];
        pas[a[i]-1].push_back({b[i]-1,c[i]});
        pas[b[i]-1].push_back({a[i]-1,c[i]});
    }
    int q,k;
    cin>>q>>k;
    k--;
    long long dist[n];
    int check[n]={};
    dist[k]=0;
    check[k]=1;
    queue<int>que;
    que.push(k);
    while(que.size()){
        int f=que.front();
        que.pop();
        for(int i=0;i<pas[f].size();i++){
            if(check[pas[f][i].first]==0){
                check[pas[f][i].first]=1;
                que.push(pas[f][i].first);
                dist[pas[f][i].first]=dist[f]+pas[f][i].second;
            }
        }
    }
    int x[q],y[q];
    for(int i=0;i<q;i++)cin>>x[i]>>y[i];
    for(int i=0;i<q;i++)cout<<dist[x[i]-1]+dist[y[i]-1]<<endl;
    return 0;
}

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

// MEMO
//
//

// THE BEGINNING OF THE LIBRARY

template< typename T,typename L=T >
struct LazySegmentTree {
	using F=function< T(T,T) >;
	using G=function< T(T,L) >;
	using H=function< L(L,L) >;
	using P=function< L(L,int) >;

	int sz;
	vector<T> node;
	vector<L> lazy;
	const F f;
	const G g;
	const H h;
	const P p;
	const T NODE_INIT;
	const L LAZY_INIT;

	LazySegmentTree(int n,const F f,const G g,const H h,const P p,
					const T &NODE_INIT,const L &LAZY_INIT):
		f(f),g(g),h(h),p(p),NODE_INIT(NODE_INIT),LAZY_INIT(LAZY_INIT) {
		sz=1;
		while(sz<n) sz<<=1;
		node.assign(2*sz-1,NODE_INIT);
		lazy.assign(2*sz-1,LAZY_INIT);
	}

	void set(int k,const T &x) {
		node[k+sz-1]=x;
	}

	void build() {
		for(int i=sz-2;i>=0;i--) {
			node[i]=f(node[i*2+1],node[i*2+2]);
		}
	}

	void eval(int k,int len) {
		if(lazy[k]!=LAZY_INIT) {
			if(k<sz-1) {
				lazy[2*k+1]=h(lazy[2*k+1],lazy[k]);
				lazy[2*k+2]=h(lazy[2*k+2],lazy[k]);
			}
			node[k]=g(node[k],p(lazy[k],len));
			lazy[k]=LAZY_INIT;
		}
	}

	T update(int a,int b,const T &x,int k,int l,int r) {
		eval(k,r-l);
		if(r<=a||b<=l) return node[k];
		else if(a<=l&&r<=b) {
			lazy[k]=h(lazy[k],x);
			eval(k,r-l);
			return node[k];
		}
		else {
			node[k]=f(update(a,b,x,2*k+1,l,(l+r)/2),update(a,b,x,2*k+2,(l+r)/2,r));
			return node[k];
		}
	}

	T update(int a,int b,const T &x) {
		return update(a,b,x,0,0,sz);
	}

	T query(int a,int b,int k,int l,int r) {
		eval(k,r-l);
		if(r<=a||b<=l) return NODE_INIT;
		else if(a<=l&&r<=b) return node[k];
		else return f(query(a,b,2*k+1,l,(l+r)/2),query(a,b,2*k+2,(l+r)/2,r));
	}

	T query(int a,int b) {
		return query(a,b,0,0,sz);
	}

	void show() {
		for(int i=0;i<sz*2-1;i++) cout<<node[i]<<' ';
		cout<<endl;
	}
};

// THE ENDING OF THE LIBRARY
// THE FOLLOWING IS AN EXAMPLE

typedef long long TYPE;

int main() {

	auto add=[](TYPE a,TYPE b){ return a+b; };
	auto multipy=[](TYPE a,TYPE b){ return a*b; };

	int n,q;
	cin>>n>>q;

	LazySegmentTree<TYPE> tree(n,add,add,add,multipy,0,0);

	while(q--) {
		int type,s,t;TYPE x;
		cin>>type>>s>>t;
		s--,t--;
		if(type==0) {
			cin>>x;
			tree.update(s,t+1,x);
		}
		else {
			cout<<tree.query(s,t+1)<<endl;
		}
	}

	return 0;
}



Measured memory_bytes: 7100
import sys
input = sys.stdin.readline

def main():
    K, S = [int(x) for x in input().split()]
    ans = 0
    for x in range(K + 1):
        for y in range(K + 1):
            z = S - x - y
            if z < 0 or z > K:
                continue
            else:
                ans += 1

    print(ans)




if __name__ == '__main__':
    main()




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

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

  vector<int> A(N);
  for (int i = 0; i < N; i++) cin >> A.at(i);

  vector<int> B(N);
  for (int i = 0; i < N - 1; i++) {
    B.at(i) = A.at(i + 1) - A.at(i);
  }
  B.at(N - 1) = ((K - A.at(N - 1)) + A.at(0));

  int ans = 100100100;
  for (int i = 0; i < N; i++) {
    ans = min(ans, K - B.at(i));
  }

  cout << ans << endl;
}

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

typedef long long ll;
typedef long double ld; 
typedef double db; 
typedef string str; 

typedef pair<int, int> pi;
typedef pair<ll,ll> pl; 
typedef pair<ld,ld> pd; 

typedef vector<int> vi; 
typedef vector<ll> vl;
typedef vector<ld> vd; 
typedef vector<str> vs; 
typedef vector<pi> vpi;
typedef vector<pl> vpl; 

#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define F0R(i,a) FOR(i,0,a)
#define ROF(i,a,b) for (int i = (b)-1; i >= (a); --i)
#define R0F(i,a) ROF(i,0,a)
#define trav(a,x) for (auto& a: x)

#define sz(x) (int)x.size()
#define all(x) begin(x), end(x)
#define rall(x) rbegin(x), rend(x)

#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound 
#define ub upper_bound 

const int MOD = 1e9 + 7;
const ll INF = 1e18;
const int MX = 1000001;

namespace Modop {
    ll modAdd(ll a, ll b) {
        return (a + b) % MOD;
    }
    
    ll modSub(ll a, ll b) {
        return (((a - b) % MOD) + MOD) % MOD;
    }
    
    ll modMul(ll a, ll b) {
        return ((a % MOD) * (b % MOD)) % MOD;
    }

    ll modExp(ll base, ll power) {
        if (power == 0) {
            return 1;
        } else {
            ll cur = modExp(base, power / 2); cur = cur * cur; cur = cur % MOD;
            if (power % 2 == 1) cur = cur * base;
            cur = cur % MOD;
            return cur;
        }
    }
    
    ll modInv(ll a) {
        return modExp(a, MOD - 2);
    }
    
    ll modDiv(ll a, ll b) {
        return modMul(a, modInv(b));
    }
}

using namespace Modop;

int N;
ll ans;

int main() {
	cin.sync_with_stdio(0); cin.tie(0);
    // int total[5] = {0};
    // FOR(i, 1, (1 << 2)) {
        // int cnt = 0;
        // F0R(j, 2) {
            // if ((1 << j) & i) total[j] += ++cnt;
        // }
    // }
    // trav(i, total) cout << i << " ";
    cin >> N;
    vl a(N); 
    F0R(i, N) {
        cin >> a[i];
    }
    sort(all(a), greater<ll>());
    vl mul;    
    if (N == 1) mul.pb(1);
    else mul.pb(modDiv(modExp(2, N), 2));
    ll toAdd = modDiv(mul[0], 2);
    F0R(i, N) {
        // ll toAdd = 0;
        // F0R(j, sz(mul)) {
            // toAdd += modMul(j + 1, modMul(mul[j], a[i]));
        // }
        
        // cout << "ToAdd: " << toAdd << "\n";
        // ans = modAdd(ans, toAdd);
        ans = modAdd(ans, mul[0] * a[i]);

        // Ignore
        // trav(j, mul) cout << j << " ";
        // cout << ans << "\n";
        // R0F(j, sz(mul) - 1) {
            // mul[j + 1] = (mul[j] + mul[j + 1]) / 2;
        // }
        // mul[0] /= 2;
        // mul.pb(mul[0]);
        mul[0] = modAdd(mul[0], toAdd);
    }
 
    ans = modMul(ans, modExp(2, N));
    cout << ans;
    return 0;
    // You should actually read the stuff at the bottom
}

/* Stuff to Look For
 * -----------------
 * Int overflow, array bounds
 * Initializing all variables, avoid weird behavior
 * Edge cases(n = 0, n = 1)
 * Just return 0 after result
 */


Measured memory_bytes: 1792
//file_name:ABC92_A.cpp
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define snuke srand((unsigned)clock()+(unsigned)time(NULL));
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
inline int in() { int x; scanf("%d",&x); return x;}
template<typename T>inline istream& operator>>(istream&i,v(T)&v)
{rep(j,sz(v))i>>v[j];return i;}
template<typename T>string join(const v(T)&v)
{stringstream s;rep(i,sz(v))s<<' '<<v[i];return s.str().substr(1);}
template<typename T>inline ostream& operator<<(ostream&o,const v(T)&v)
{if(sz(v))o<<join(v);return o;}
template<typename T1,typename T2>inline istream& operator>>(istream&i,pair<T1,T2>&v)
{return i>>v.fi>>v.se;}
template<typename T1,typename T2>inline ostream& operator<<(ostream&o,const pair<T1,T2>&v)
{return o<<v.fi<<","<<v.se;}
template<typename T>inline ll suma(const v(T)& a) { ll res(0); for (auto&& x : a) res += x; return res;}
const double eps = 1e-10;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
#define dame { puts("-1"); return 0;}
#define yn {puts("Yes");}else{puts("No");}
const int MX = 200005;

    // int scan
    /*
    int x;
    scanf("%d",&x);
    int y;
    scanf("%d",&y);
    int z;
    scanf("%d",&z);

    // matrix scan
    /*
    ll a[n] = {};
    rep(i,n){
        scanf("%lld",&a[i]);
    }
    */

    // string scan
    /*
    string s;
    cin >> s;
    */


int main() {
    int n;
    scanf("%d",&n);
    int x;
    scanf("%d",&x);
    int y;
    scanf("%d",&y);
    int z;
    scanf("%d",&z);


    int ans = mins(n,x)+mins(y,z);

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



Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
#include <functional>
using namespace __gnu_pbds;  
using namespace std;



typedef tree<long long, null_type, less<long long>, rb_tree_tag, 
             tree_order_statistics_node_update> 
    new_data_set; 
    
    
    
//defines
typedef long long ll;
typedef long double ld;
ll a,b,c,n,m,k,t=1;

void solve()
{
    cin>>n;
    vector<ll>v(n);
    for(ll i=0;i<n;i++)cin>>v[i];
    sort(v.begin(),v.end());
    
    m=v[n-1];
    c=1LL;
    
    for(ll i=n-2;i>=0;i--)
    {
        if(c<n-1LL)
        {
        m+=v[i];c++;
        if(c<n-1)
        m+=v[i],c++;
        else break;}
        else break;
    }
    
    cout<<m<<"\n";
 
}

int32_t main()
{
#ifdef ONPC
    freopen("input.txt", "r", stdin);
#endif
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);

  //cin>>t;
    while(t--)
    {
        solve();
    }
  //cout<<sum;
        
    return 0;
}

Measured memory_bytes: 4760
#include <queue>
#include <cstdio>
#include <iostream>
#include <math.h>
#include <set>
#include <map>
#include <string>
#include <vector>
#include <sstream>
#include <algorithm>
#include <iomanip>
using namespace std;
typedef long long int ll;

#define EPS (1e-9)
#define INF (1e9)
#define PI (acos(-1))
#define REP(i,n) for(int i=0;i<n;i++)

/*
int gcd(int a, int b) {
	if (b == 0) return a;
	return gcd(b, a % b);
}
*/

int N;
int D[200010];
int M;
int T[200010];

int main()
{
	cin >> N;
	REP(i, N) cin >> D[i];
	sort(D, D + N);
	cin >> M;
	REP(i, M) cin >> T[i];
	sort(T, T + M);
	if (N < M) {
		cout << "NO" << endl;
		return 0;
	}
	int j = 0;
	REP(i, N) {
		if (D[i] == T[j]) {
			if (j == M - 1) {
				cout << "YES" << endl;
				return 0;
			}
			else j++;
		}
	}
	cout << "NO" << endl;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
#define FLASH cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(false);
#define pb push_back
#define int long long
#define fr(i,a,b) for(int i=a;i<b;i++)
#define mod 1000000007
#define FILEIO freopen("/home/aman/Desktop/Kachda/input.txt", "r", stdin); freopen("/home/aman/Desktop/Kachda/output.txt", "w", stdout);

using namespace std;

int n, a, b, c, d;
string s;

signed main()
{
 	FLASH

 	cin>>n>>a>>b>>c>>d;
 	a--;
 	b--;
 	c--;
 	d--;
 	cin>>s;

 	bool ok = 1;
 	fr(i, a + 1, c){
 		if(s[i] == '#' and s[i - 1] == '#') ok = 0;
 	}

 	fr(i, b + 1, d){
 		if(s[i] == '#' and s[i - 1] == '#') ok = 0;
 	}

 	if(d < c){
 		bool ok1 = 0;
 		fr(i, b + 1, d){
 			if(s[i - 1] == '.' and s[i] == '.' and s[i + 1] == '.') ok1 = 1;
 		}
 		if(d < n - 1 and s[d - 1] == '.' and s[d + 1] == '.' and s[d] == '.') ok1 = 1;
 		if(b > 0 and s[b - 1] == '.' and s[b + 1] == '.' and s[b] == '.') ok1 = 1; 
 		ok &= ok1;
 	}

 	if(ok) cout<<"Yes";
 	else cout<<"No";
 	
}

Measured memory_bytes: 592
#include <stdio.h>
#include <string.h>
#include <stdbool.h>
#include <math.h>
 
int main(void) {
    int N;
    int numR = 0;
    int numW = 0;
    int numD = 0;
    char str[200000];
 
    scanf("%d\n", &N );
    
    for(int i = 0; i < N; i++) {
        scanf("%c", &str[i] );
        if( str[i] == 'R' ) {
            numR++;
        }
    }
 
    for(int i = 0; i < numR; i++) {
        if( str[i] == 'W' ) {
            numD++;
        }
    }
 
    printf("%d\n", numD);
 
    return 0;
}


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

int main(){
	int n,samu=0;
  	cin >> n;
	int t[n];
	for (int i=0;i<n;i++){
      	cin >>t[i];
      	samu+=t[i];
    }
  	int m;
  	cin >> m;
  	int ph[m],re[m];
  	for (int i=0;i<m;i++){
      	cin >> ph[i] >> re[i];
    }
  	for (int i=0;i<m;i++){
    	cout << samu - t[ph[i]-1]+re[i]<<endl;
    }
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-

import sys
from collections import Counter

def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def list4d(a, b, c, d, e): return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(N=None): return list(MAP()) if N is None else [INT() for i in range(N)]
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
INF = 10 ** 18
MOD = 10 ** 9 + 7

N = INT()
A = LIST()

C = Counter(A)
ans = 0
# 大きい数から見ていく
for i in range(30, 0, -1):
    x = 2 ** i
    for k in C.keys():
        if x-k in C:
            # 同値ペアは別処理
            if k == x-k:
                p = C[k] // 2
                C[k] -= p * 2
                ans += p
            else:
                # 少ない方に合わせてペア作成
                p = min(C[k], C[x-k])
                C[k] -= p
                C[x-k] -= p
                ans += p
print(ans)


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

using namespace std;

void solve() {
  int n;
  cin >> n;
  unordered_set<int> s;
  bool no_dup = true;
  for (int i = 0; i < n; ++i) {
    int a;
    cin >> a;
    if (!s.emplace(a).second) {
      no_dup = false;
    }
  }
  cout << (no_dup ? "YES" : "NO") << endl;
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  solve();
}



Measured memory_bytes: 8520
#include<stdio.h>

int main(void){
  int n,m,i;
  int a[200000] = {};
  scanf("%d", &n);
  for(i=0;i<n-1;i++){
    scanf("%d", &m);
    a[m-1] += 1;
  }
  for(i=0;i<n;i++)
    printf("%d\n", a[i]);
  return 0;
}

Measured memory_bytes: 2512
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#define MOD 1000000007
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;

typedef pair<int, int> P;
typedef pair<long long, long long> LLP;

int main() {

    int N;
    string S, T;

    cin >> N >> S >> T;
    rep(i, N) {
        cout << S[i] << T[i];
    }

    cout << endl;
    
    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>

using namespace std;

int v[100010];

int main()
{
    //freopen("file.in", "r", stdin);
    //freopen("file.out", "w", stdout);
    int n,sol=0;
    scanf("%d",&n);
    for(int i=1;i<=n;i++) scanf("%d",&v[i]);
    for(int i=1;i<n;i++)
        if(v[i]==i) {swap(v[i],v[i+1]);sol++;}
    if(v[n]==n) sol++;
    printf("%d",sol);
    return 0;
}


Measured memory_bytes: 512
//Daniel Grzegorzewski
#include <bits/stdc++.h>
#pragma GCC optimize("O3")

#define MP make_pair
#define PB push_back
#define ST first
#define ND second

using namespace std;

typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<PII> VII;
typedef long long LL;

void init_ios() {
     ios_base::sync_with_stdio(0);
     cin.tie(0);
}

const int N = (int)1e5 + 6;
const int MOD = (int)1e9 + 7;

int n, k, a[105], dp[105][N], pref[N];

int main() {
  init_ios();
  cin >> n >> k;
  for (int i = 1; i <= n; ++i)
    cin >> a[i];
  dp[0][0] = 1;
  for (int i = 0; i <= k; ++i)
    pref[i] = 1;
  for (int i = 1; i <= n; ++i) {
    for (int j = 0; j <= k; ++j) {
      dp[i][j] = pref[j];
      if (j > a[i])
        dp[i][j] -= pref[j-a[i]-1];
      dp[i][j] %= MOD;
      if (dp[i][j] < 0)
        dp[i][j] += MOD;
    }
    pref[0] = dp[i][0];
    for (int j = 1; j <= k; ++j)
      pref[j] = (pref[j-1]+dp[i][j])%MOD;
  }
  cout<<dp[n][k]<<"\n";
}

Measured memory_bytes: 40832
#include "bits/stdc++.h"
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int h, w;
    cin >> h >> w;
    rep(j,w+2) cout << "#";
    cout << endl;
    char c;
    rep(i,h){
        cout << "#";
        rep(j,w){
            cin >> c;
            cout << c;
        }
        cout << "#" << endl;
    }
    rep(j,w+2) cout << "#";
    cout << endl;
	return 0;
}

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

int main(){
    // 制約見て！！！デカかったらlong longにすること！
    ll n;
    int k;
    cin >>n>>k;
    int i = 0;
    while(n/k>0){
        n /= k;
        i++;
    }
    if(n!=0){
        i++;
    }
    cout<< i<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <queue>
#include <algorithm>
#include <vector>
#include <string>
#define rep(i, n)   for(int i = 0; i < (n); i++)
using namespace std;
typedef long long int ll; 

int main(){
    int n,m;	cin >> n >> m;
    vector<int>a(n);
    rep(i, n)	cin >> a[i];
    //solve
    priority_queue<int>que;
    rep(i, n)	que.push(a[i]);
    rep(i, m){
	int tmp = que.top()/2;	que.pop();
	que.push(tmp);
    }
    ll ans = 0;
    while(!que.empty()){
	ans += que.top();   que.pop();
    }
    cout << ans << endl;
}


Measured memory_bytes: 1276
#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<utility>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<functional>
#include<math.h>
#include<random>
#include <bitset>
using namespace std;
#define N (1000000000+7)
//#define N 998244353
#define INF 1e16
typedef long long ll;
typedef pair<ll,ll> P;
typedef pair<int,P> Q;

int main() {
    ll X,K,D;
    cin>>X>>K>>D;
    if(X==0){
        if(K%2==0)cout<<0<<endl;
        else cout<<D<<endl;
        return 0;
    }
    if(X<0)X*=-1;
    if(X<=D){
        if(K%2==1){
            cout<<D-X<<endl;
        }
        else cout<<X<<endl;
    }
    else{
        ll Y = X/D;
        ll R = X%D;
        if(Y>=K){
            cout<<X-K*D<<endl;
        }
        else{
            K-=Y;
            X = R;
            if(K%2==0)cout<<X<<endl;
            else cout<<D-X<<endl;
        }
    }
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
#define repr(i,a,b) for( i=a;i<b;i++)
#define rep(i,n) for(ll i=0;i<n;i++)
#define invrepr(i,a,b) for(int i=b-1;i>=a;i--)
#define invrep(i,n) invrepr(i,0,n)
#define repitr(itr,a) for(auto itr=a.begin();itr!=a.end();++itr)
const ll MOD=1e9+7;



int main() {
    ios_base::sync_with_stdio(false);

    int n;
    cin >> n;
    vector<string> s(n);
    rep(i,n) cin >> s[i];
    vector<int> alp(26,100);
    rep(i,n) {
        vector<int> talp(26);
        rep(j,s[i].size()) {
            ++talp[s[i][j]-'a'];
        }
        rep(j,26) alp[j]=min(alp[j],talp[j]);
    }
    rep(i,26) {
        rep(j,alp[i]) cout << char(i+'a');
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
// rep(i, 1, 4) --> {1,2,3,4}
// rep(i, 4, 1) --> {4,3,2,1}
// rep(it, end(v), begin(v)) --> *it

using namespace std;

int main()
{
    int n;
    cin >> n;
    cout << (n+1)/2;
    return 0;
}

Measured memory_bytes: 256
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define pp pair<int,int>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define ld long double
#define al(a) (a).begin(),(a).end()
#define mk make_pair
#define check cout<<"?"<<endl;

ll MOD=1000000007;
ll mod=998244353;
int inf=1000001000;
ll INF=1e18+5;

int main(){
    int h,w,k,cnt=1; cin>>h>>w>>k;
    vector<string> data(h);
    vector<vector<int>> ans(h,vector<int>(w,0));
    rep(i,h) cin>>data[i];
    for(int i=0;i<h;i++)for(int j=0;j<w;j++){
        if(j==0){
            if(data[i][j]=='#'){
                ans[i][j]=cnt;
                cnt++;
            }
        }
        else{
            if(data[i][j]=='#'){
                ans[i][j]=cnt;
                cnt++;
            }
            else if(ans[i][j-1]!=0 && ans[i][j]==0){
                ans[i][j]=ans[i][j-1];
            }
        }
    }
    for(int i=0;i<h;i++)for(int j=w-1;j>=0;j--){
        if(j==w-1){
            continue;
        } 
        if(ans[i][j+1]!=0 && ans[i][j]==0)
        ans[i][j]=ans[i][j+1];
    }
    for(int i=0;i<w;i++)for(int j=0;j<h;j++){
        if(j==0) continue;
        if(ans[j-1][i]!=0 && ans[j][i]==0)
        ans[j][i]=ans[j-1][i];
    }
    for(int i=0;i<w;i++)for(int j=h-1;j>=0;j--){
        if(j==h-1) continue;
        if(ans[j+1][i]!=0 && ans[j][i]==0)
        ans[j][i]=ans[j+1][i];
    }
    rep(i,h)rep(j,w){
        if(j!=w-1) cout<<ans[i][j]<<" ";
        else cout<<ans[i][j]<<endl;
    }
}


Measured memory_bytes: 1280
n = gets.to_i
s = n.times.map{gets.chomp}

cnt = {}
max_v = 0
s.each do |x|
  if cnt[x].nil?
    cnt[x] = 1
  else
    cnt[x] += 1
  end

  max_v = [max_v, cnt[x]].max
end

cnt.sort{|x, y| x[0] <=> y[0]}.each do |key, value|
  if value == max_v
    puts key
  end
end

Measured memory_bytes: 59464
#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>
#include<algorithm>//next_permutation
#define rep(i,n) for (int i = 0;i < (n);i++)
#define all(v) v.begin(),v.end()
#define dec(n) cout << fixed << setprecision(n);
#define large "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
#define small "abcdefghijklmnopqrstuvwxyz"
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
using vl = vector<ll>;
using vvl = vector<vl>;

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

const ll MOD = 998244353;
const ll MAX = 2000001;

ll mod(ll a){
  if(a % MOD < 0) return MOD + (a % MOD);
  return a % MOD;
}

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


int main(){
  ll n,k; cin >> n >> k;
  
  vl dp(3*n,0LL); vl imos(3*n);
  dp[0] = 1;
  
  vvl table(k,vl(2));
  
  rep(i,k){
    cin >> table[i][0] >> table[i][1];
  }
  
  ll now = 0;
  for(ll i=0; i < n; i++){
    
    if(i != 0){
      now += mod(imos[i]);
      dp[i] = mod(now);
      dp[i] = mod(dp[i]);
    }
    
    now = mod(now);
    
    rep(j,k){
      imos[i+table[j][0]] += dp[i];
      imos[i+table[j][1]+1] -= dp[i];
      imos[i+table[j][0]] = mod(imos[i+table[j][0]]);
      imos[i+table[j][1]+1] = mod(imos[i+table[j][1]+1]);
    }
    
  }
  
  cout << mod(dp[n-1]) << endl;
  
  //for(ll x : dp) cout << x ;
  
  
}

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

#define rep(i, j) for (int i = 0; i < j; i++)
#define all(obj) (obj).begin(), (obj).end()
#define rall(obj) (obj).rbegin(), (obj).rend()
typedef long long int ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef vector<pii> vpii;

int n;
map<int, vector<int>> m;

int rec(int root) {
    vector<int> ds;
    for (auto c: m[root]) {
        ds.push_back(rec(c));
    }
    sort(rall(ds));
    int d = 0;
    rep(i, ds.size()) {
        d = max(d, ds[i] + i);
    }
    return d + 1;
}

int main() {

    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.precision(10);
    cout << fixed;

    cin>>n;
    rep(i, n - 1) {
        int a;
        cin>>a;
        m[a].push_back(i + 2);
    }

    cout << rec(1) - 1 << endl;

    return 0;
}


Measured memory_bytes: 22144
A, B, C, X, Y = map(int, input().split())

# ans = float('inf')

# for i in range(10 ** 5 + 1):
#     ans = min(ans, A * max(X - i, 0) + B * max(Y - i, 0) + 2 * C * i)
# print(ans)

min_xy = min(X, Y)
max_xy = max(X, Y)
ans1 = 2 * C * min_xy + A * (X - min_xy) + B * (Y - min_xy)
ans2 = A * X + B * Y
ans3 = 2 * C * max_xy
print(min(ans1, ans2, ans3))

Measured memory_bytes: 3060
import java.util.Scanner;

public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int r = Integer.parseInt(sc.next());
        int D = Integer.parseInt(sc.next());
        int x_2000 = Integer.parseInt(sc.next());
        sc.close();

        int ans = x_2000;
        for (int i = 1 ;i <= 10 ;i++ ) {
            ans = r * ans - D;
            System.out.println(ans);
        }
    }
}


Measured memory_bytes: 21844
# 

from sys import stdin
input = lambda: stdin.readline().rstrip()

N = int(input())
A = list(map(int, input().split()))

if 0 in A:
    print(0)
    exit()

answer = 1
limit = 10**18
for i in A:
    answer = answer * i
    if answer > limit:
        print(-1)
        exit()

print(answer)

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


int dp[10001];
int N, M;
int digit_to_match[] = {-1, 2, 5, 5, 4, 5, 6, 3, 7, 6};

int main(){
    cin >> N >> M;
    vector<int> A(M);
    for(int i = 0; i < M; i++){
        cin >> A[i];
    }
    sort(A.rbegin(), A.rend());
    for(int i = 1; i <= 10000; i++){
        dp[i] = -1;
    }
    for(int i = 2; i <= 10000; i++){
        for(int j = 0; j < M; j++){
            if(i - digit_to_match[A[j]] >= 0 && dp[i - digit_to_match[A[j]]] >= 0){
                dp[i] = max(dp[i], dp[i - digit_to_match[A[j]]] + 1);
            }
        }
    }

    int n_now = N;
    for(int i = dp[N]; i > 0; i--){
        for(auto it = A.begin(); it != A.end(); it++){
            if(n_now >= digit_to_match[*it] && dp[n_now - digit_to_match[*it]] + 1 == dp[n_now]){
                cout << *it;
                n_now -= digit_to_match[*it];
                break;
            }
        }
    }

    cout <<endl;
//    cout << dp[N] << endl;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {

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

        int catCount = x - a;
        if (catCount >= 0 && catCount <= b) {
            System.out.println("YES");
        } else {
            System.out.println("NO");
        }
    }
}


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

int main() {
  int N;
  cin >> N;
  
  if (N / 1000 == N % 1000 / 100 && N % 1000 / 100 == N % 100 / 10){
      cout << "Yes" << endl;
  }else  if (N % 1000 / 100 == N % 100 / 10 && N % 100 / 10 == N % 10){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
}


Measured memory_bytes: 256
import sys
input = sys.stdin.readline

def f(x):
    return B//x-(A-1)//x

def gcd(a, b):
    while b:
        a, b = b, a%b
    return a

def lcm(a, b):
    return a*b//gcd(a, b)

A, B, C, D = map(int, input().split())
print(B-A+1-f(C)-f(D)+f(lcm(C, D)))

Measured memory_bytes: 38384
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int a = sc.nextInt();
    int b = sc.nextInt();
    int c = sc.nextInt();
    if(a + b + c>=22){
      System.out.println("bust");
    }else{
      System.out.println("win");
    }
  }
}


Measured memory_bytes: 21844
n = int(input())
a = list(map(int, input().split()))

a.sort()
if a[0] >= 0:
    m = sum(a[1:]) - a[0]
    print(m)
    tmp = a[0]
    for i in range(1, n-1):
        print(tmp, a[i])
        tmp -= a[i]
    print(a[n-1], tmp)
elif a[-1] <= 0:
    m = -sum(a[:-1]) + a[-1]
    print(m)
    tmp = a[n-1]
    for i in range(n-1):
        print(tmp, a[i])
        tmp -= a[i]
else:
    m = 0
    pos = []
    neg = []
    for ai in a:
        m += abs(ai)
        if ai >= 0:
            pos.append(ai)
        else:
            neg.append(ai)
    print(m)
    tmp = 0
    ni = 0
    pi = 0

    if len(pos) > 1:
        print(neg[ni], pos[pi])
        tmp = neg[ni] - pos[pi]
        ni += 1
        pi += 1

        while pi < len(pos) - 1:
            print(tmp, pos[pi])
            tmp = tmp - pos[pi]
            pi += 1
        print(pos[pi], tmp)
        tmp = pos[pi] - tmp
        while ni < len(neg):
            print(tmp, neg[ni])
            tmp -= neg[ni]
            ni += 1
    else:
        print(pos[pi], neg[ni])
        tmp = pos[pi] - neg[ni]
        ni += 1
        while ni < len(neg):
            print(tmp, neg[ni])
            tmp -= neg[ni]
            ni += 1


Measured memory_bytes: 60556