akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
 
using namespace std;
 
#define ll long long
#define ull unsigned long long
#define ar array
 
const int N = 1e6 + 5;
int cnt[N];
 
int main() {
    ios::sync_with_stdio(0); cin.tie(0);
 
    int n;
    cin >> n;
    vector<int> a(n);
    memset(cnt, 0, sizeof(cnt));
    for (int i = 0; i < n; i++) {
        cin >> a[i];
        cnt[a[i]]++;
    }
    if (n == 1 || cnt[1] == 1) {
        cout << 1 << '\n';
        return 0;
    }
    if (cnt[1] > 1) {
        cout << 0 << '\n';
        return 0;
    }
    int ans = 0;
    for (int i = 0; i < n; i++) {
        bool ok = true;
        if (cnt[a[i]] > 1) ok = false;
        else {
            for (int j = 2; j * j <= a[i]; j++) {
                if (a[i] % j == 0 && (cnt[j] != 0 || cnt[a[i] / j] != 0)) {
                    ok = false;
                    break;
                }
            }
        }
        ans += ok;
    }
    cout << ans << '\n';
}

Measured memory_bytes: 7936
#include <bits/stdc++.h>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstring>
#include <chrono>
#include <complex>
#define endl "\n"
#define ll long long int
#define vi vector<int>
#define vll vector<ll>
#define vvi vector < vi >
#define unm unordered_map
#define pii pair<int,int>
#define pll pair<long long, long long>
#define mod 1000000007
#define inf 1000000000000000001;
#define all(c) c.begin(),c.end()
#define mp(x,y) make_pair(x,y)
#define mem(a,val) memset(a,val,sizeof(a))
#define eb emplace_back
#define f first
using namespace std;


int main()
{
	std::ios::sync_with_stdio(false);
	cin.tie(NULL); cout.tie(NULL);
	ll a, b;
	cin >> a >> b;
	cout << a*b;
	return 0;
}



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

int main(){
	int a, b;
	while(1){
		cin >> a >> b;
		if(a == b && a == 0)
			break;
		for(int i = 0; i < a; i++){
			for(int j = 0; j < b; j++)
				cout << "#";
			cout << endl;
		}
		cout << endl;
	}
}


Measured memory_bytes: 3064
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

long long int GCD(long long int a, long long int b) {
    if(a<b) swap(a, b);
    
    if(b==0) {
        return a;
    }
    
    return GCD(b, a%b);
}

int main() {
    int N;
    cin >> N;
    vector<long long int> x(N+1);
    cin >> x[N];
    
    long long int mnx=1e9;
    for(int n=0; n<N; n++) {
        cin >> x[n];
        mnx = min(mnx, x[n]);
    }
    
    sort(x.begin(), x.end());
    
    long long int ans=x[1]-x[0];
    for(int n=1; n<N; n++) {
        ans = GCD(ans, x[n+1]-x[n]);
    }
    
    cout << ans << endl;


    return 0;
    
}

Measured memory_bytes: 1024
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define REPS(I, a, b) for (int i = (a); i < (b); ++i)
using namespace std;
using ll = long long;

int main() {
  int n,k;
  cin >> n >> k;
  vector<int> h(n);
  
  REP(i,n) cin >> h[i];
  
  sort(h.begin(), h.end());
  
  ll ans = 0;
  
  REP(i,n-k){
    ans += h[i];
  }
  
  
  cout << ans << endl;
  
}


Measured memory_bytes: 4080
a = int(input())
b = int(input())
c = int(input())
x = int(input())
cnt = 0
for i in range(a+1):
    for j in range(b+1):
        for k in range(c+1):
            if x == i*500 + j*100 + k*50:
                cnt += 1
print(cnt)


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

int main()
{
    int A, B, K;
    cin >> A >> B >> K;
    int count = 0;
    for(int i=min(A,B);i>=1;i--)
    {
        if(A % i == 0 && B % i == 0)
        {
            count++;
            if(count == K)
            {
                cout << i << endl;
                return 0;
            }
        }

    }
}

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

int W, H;
char b[20][20];
int ans;
int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};

void dfs(int x, int y) {
	ans++;
	b[y][x] = '#';
	for (int i = 0; i < 4; i++) {
		int nx = x + dx[i], ny = y + dy[i];
		if (0 <= nx && nx < W && 0 <= ny && ny < H && b[ny][nx] == '.') {
			dfs(nx, ny);
		}
	}
}

int main() {
	while (cin >> W >> H , W) {
		for (int y = 0; y < H; y++) {
			for (int x = 0; x < W; x++) {
				cin >> b[y][x];
			}
		}

		for (int y = 0; y < H; y++) {
			for (int x = 0; x < W; x++) {
				if (b[y][x] == '@') {
					ans = 0;
					dfs(x, y);
				}
			}
		}

		cout << ans << endl;
	}
}

Measured memory_bytes: 1168
#include <bits/stdc++.h>
#include <string>
#include <algorithm>
#include <string.h>
#include <ctype.h>
#include <math.h>
#include <float.h>
#include <iomanip>
#include <iostream>
using namespace std;

int digitsSum(int x){
    int ans=0;
    while(1){
        ans+=x%10;
        x/=10;
        if(x<1){
            break;
        }
    }
    return ans;
}

int main(){

    int N,M;

    cin >>N>>M;

    cout << N*(N-1)/2 + M*(M-1)/2 <<endl;


    return 0;
}


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

int main()
{
    int a, b, c;
    cin >> a >> b >> c;
    if ((a == 7 && b == 5 && c == 5) || (a == 5 && b == 7 && c == 5) || (a == 5 && b == 5 && c == 7)) {
        cout << "YES" << endl;
    } else {
        cout << "NO" << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define EPS (1e-7)
#define INF (1e9)
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) x.begin(),x.end()
const double PI = acos(-1);
const ll MOD = 1000000007;
template<class T>
inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}
 
template<class T>
inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
}
///////////////////////////////////////////////////////////////

int main() {
    ios::sync_with_stdio(false); cin.tie(nullptr);
    int N,K; cin >> N >> K;
    vector<int> A(N);
    rep(i,N) cin >> A[i];
    vector<bool> dp(K+1,false);
    rep(i,A[0]) dp[i] = false;

    rep(i,K+1) {
        bool flag = false;
        rep(j,N) {
            if (i < A[j]) continue;
            if (!dp[i-A[j]]) flag = true;
        }
        if (flag) dp[i] = true;
    }

    cout << (dp[K] ? "First" : "Second") << endl; 
}


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

using namespace std;
int main(){
    string s;cin>>s;
    int l = s.length()-1;
    if(s[l]=='3'){
        cout << "bon"<< endl;
    }else if(s[l] =='2'||s[l] =='4'||s[l] =='5'||s[l] =='7'||s[l] =='9'){
        cout << "hon" << endl;
    }else{
        cout << "pon" << endl;
    }

    return 0;
}

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

#define MOD_1000000007 (1000000007LL)
#define rep(i, n)   for (long long i = 0; i <  (long long)(n); i++)
#define rep1(i, n)  for (long long i = 1; i <  (long long)(n); i++)
#define rep0c(i, n) for (long long i = 0; i <= (long long)(n); i++)
#define rep1c(i, n) for (long long i = 1; i <= (long long)(n); i++)
#define rep2c(i, n) for (long long i = 2; i <= (long long)(n); i++)
#define repc0(n, i) for (long long i = (long long)(n); i >= 0; i--)
#define repc1(n, i) for (long long i = (long long)(n); i >= 1; i--)

using std::cerr;
using std::cout;
using std::endl;
using std::map;
using std::set;
using std::string;
using std::vector;
typedef long long ll;

string S;
vector<int> base_mods {1,10,9,12,3,4};
ll memo[2][13];

void solve() {
  int n = (int)S.size();
  std::reverse(S.begin(), S.end());
  memo[0][0] = 1;
  rep(i, n) {
    vector<int> digits;
    if(S[i]=='?') rep0c(j, 9) digits.push_back(j);
    else digits.push_back(S[i]-'0');
    int before = i%2, after = (i+1)%2;
    int base_mod = base_mods[i%6];
    rep(j, 13) memo[after][j] = 0;
    for(const int& digit : digits) {
      int mod = (digit * base_mod) % 13;
      rep(j, 13) memo[after][(j+mod)%13] = (memo[after][(j+mod)%13] + memo[before][j]) % MOD_1000000007;
    }
  }
  printf("%lld\n", memo[n%2][5]);
  return;
}

int main() {
  std::cin >> S;
  solve();
  return 0;
}

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

int main(){
  int N,T;
  cin>>N>>T;
  int c,t;
  int ans=1e9;
  for(int i=0;i<N;i++){
    cin>>c>>t;
    if(t<=T)ans=min(ans,c);
  }
  if(ans>1e6)cout<<"TLE"<<endl;
  else cout<<ans<<endl;
}


Measured memory_bytes: 256
S=input()
x=int(S[:2])
y=int(S[2:])
if x==0:
    if 0<y<=12:
        print("YYMM")
    else:
        print("NA")
elif 0<x<=12:
    if 0<y<=12:
        print("AMBIGUOUS")
    else:
        print("MMYY")
elif x>=13:
    if 0<y<=12:
        print("YYMM")
    else:
        print("NA")

Measured memory_bytes: 9108
#![allow(unused_imports)]
use proconio::{input, fastout};
use proconio::marker::*;

#[fastout]
fn main() {
    input! {
    x: usize
    }
    let ans = if x <= 599 {
        8
    } else if x <= 799 {
        7
    } else if x <= 999 {
        6
    } else if x <= 1199 {
        5
    } else if x <= 1399 {
        4
    } else if x <= 1599 {
        3
    } else if x <= 1799 {
        2
    } else {
        1
    };
    println!("{}", ans);
}


Measured memory_bytes: 2132
import java.util.Arrays;
import java.util.HashSet;
import java.util.Scanner;
import java.util.Vector;

public class Main {

	public static void main(String args[]) {
		Scanner in = new Scanner(System.in);
		String string = in.next();
		int max = 0;
		int submax = 0;
		for (int i = 0; i < string.length(); i++) {
			if (string.charAt(i)=='R') {
				submax++;
			}else {
				if (max<submax) {
					max = submax;
					submax = 0;
				}
			}
		}
		if (max<submax) {
			System.out.println(submax);
		}else {
			System.out.println(max);
		}
		
	}

}

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


int main() {
    int N, K;
    cin >> N >> K;
    vector<int> h(N);
    vector<int> t;

    for(int i = 0; i < N; i++) cin >> h[i];

    sort(h.begin(), h.end());

    for (int i = 0; i < N-1; i++) t.push_back(h[i+1] - h[i]);
    
    long ans = 10000000000;
    for (int i = 0; i < N-(K-1); i++) {
        long dif = h[i+K-1] - h[i];
        if (dif < ans) ans = dif;
    }
    
    cout << ans << endl;
}

Measured memory_bytes: 1404
#include<bits/stdc++.h>
using namespace std;
int main() {
	int N,K;
	cin>>N>>K;
	int x[100000];
	int negative=0,zero=0,positive=0;
	for(int i=0;i<N;i++){
		cin>>x[i];
		if(x[i]<0){negative++;}
		else if(x[i]==0){zero++;}
		else{positive++;}
	}
	int left;
	if(negative+zero>=K){
		left=negative+zero-K;
	}else{
		left=0;
	}
	
	int ans=1000000000;
	int add=1;
	if(zero==0){
    	add=0;
    }
	while(left+K<=N&&left<=negative+add){
		ans=min({ans,abs(x[left])+abs(x[left]-x[left+K-1]),abs(x[left+K-1])+abs(x[left]-x[left+K-1])});
		left++;
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 640
#pragma GCC optimize(3)
#include<bits/stdc++.h>
#define MAXN 3005
#define INF 1000000000
#define MOD 1000000007
#define INV 500000004
#define F first
#define S second
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
void add(int &a,int b) {a+=b; if(a>=MOD) a-=MOD;}
int n,q,a[MAXN],pos[MAXN];
int dp[MAXN][MAXN];
int cnt[MAXN][MAXN];
P query[MAXN];
int p2[MAXN];
int main()
{
    p2[0]=1;
    for(int i=1;i<=3000;i++) p2[i]=2LL*p2[i-1]%MOD;
    scanf("%d%d",&n,&q);
    vector<int> v;
    for(int i=1;i<=n;i++) scanf("%d",&a[i]);
    for(int i=0;i<q;i++) scanf("%d%d",&query[i].F,&query[i].S);
    memset(dp,0,sizeof(dp));
    for(int i=1;i<=n;i++)
        for(int j=i+1;j<=n;j++)
        {
           if(a[i]>a[j]) dp[i][j]=1;
           else if(a[j]>a[i]) dp[j][i]=1;
        }
    
    for(int i=0;i<q;i++)
    {
        int u=query[i].F,v=query[i].S;
        if(u>v) swap(u,v);
        int s=dp[u][v]+dp[v][u];
        if(s>=MOD) s-=MOD;
        dp[u][v]=dp[v][u]=1LL*s*INV%MOD;
        for(int j=1;j<=n;j++)
        {
            if(j==u||j==v) continue;
            int s=dp[u][j]+dp[v][j];
            if(s>=MOD) s-=MOD;
            dp[u][j]=dp[v][j]=1LL*s*INV%MOD;
            s=dp[j][u]+dp[j][v];
            if(s>=MOD) s-=MOD;
            dp[j][u]=dp[j][v]=1LL*s*INV%MOD;
        }
    }
    int ans=0;
    for(int i=1;i<=n;i++)
        for(int j=i+1;j<=n;j++)
            add(ans,1LL*dp[i][j]*p2[q]%MOD);
    printf("%d\n",ans);
    return 0;
}



Measured memory_bytes: 36096
#include<bits/stdc++.h>
#define ll long long int
#define ul unsigned long long int
#define mp make_pair
#define endl "\n"
#define fio ios_base::sync_with_stdio(false);cin.tie(NULL);
#define lb lower_bound
#define forn(i,n) for(ll i=0 ; i<n ; i++)
#define arr(a,n) for(ll i=0;i<n;i++){ cin>>a[i]; }
#define ub upper_bound
#define pb push_back
#define pi pair<int,int>
#define mod 1000000007
#define vectormax *max_element
#define vectormin *min_element
#define arraysize 1000000
#define setbit __builtin_popcountll
#define bs binary_search
using namespace std;

ll ipow(ll x, ll n)
{
    ll result = 1;
    while (n) {
        if (n & 1)
            result = result * x ;
        n = n / 2;
        x = x * x;
    }
    return result;
}
// binary search using recursion.

bool solve(int x,int y,int d){
    double temp=sqrt((ll)((ll)x*x+(ll)y*y));

  // cout<<ceil(temp)<<endl;
    if(ceil(temp)<=d)
        return true;
    else
        return false;
    //if(x>=-1*d and x<=d and y)
}
int main(){
    fio
int n;
int d;
cin>>n>>d;
int count=0;
while(n--){
    int x,y;
    cin>>x>>y;
    if(solve(abs(x),abs(y),d))
        count++;
}
cout<<count<<endl;
}


Measured memory_bytes: 3672
#include <iostream>
#include <math.h>
#include <algorithm>
using namespace std;
typedef long long int ll;

int main(){

    ios::sync_with_stdio(false);
    cin.tie(0);

    int N;
    cin >> N;

    int A[N];
    ll total = 0;
    for(int i=0; i<N; i++){
        int Ai;
        cin >> Ai;
        Ai = Ai-i-1;
        A[i] = Ai;
        total += Ai;
    }

    sort(A, A+N);
    int middle = A[N/2];
    ll ans = 0;
    for(int i=0; i<N; i++){
        ans += abs(A[i] - middle);
    }

    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)   FOR(i,0,n)
#define ALL(obj)   (obj).begin(),(obj).end()

#define debug(var)  do{std::cout << __LINE__ << "> " << #var << ": ";view(var);}while(0)
template<typename T> void view(T e){std::cout << e << std::endl;}
template<typename T> void view(const std::vector<T>& v){for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void view(const std::vector<std::vector<T> >& vv){ for(const auto& v : vv){ view(v); } }

using namespace std;
using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector<vector<int>>;
using vvl = vector<vector<ll>>;

void Main() {
	ll a, b, c; cin >> a >> b >> c;
	vvl vec;
	vec.push_back({a, b, c});
	vec.push_back({a, c, b});
	vec.push_back({b, c, a});
	ll res = numeric_limits<ll>::max();
	for (auto v : vec) {
		if (v[2] % 2 == 0) {
			cout << 0 << endl;
			return;
		}
		res = min(res, v[0] * v[1]);
	}
	cout << res << endl;
}

int main() {
    cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	Main();
}


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

using namespace std;

#define dump(x)  cerr << #x << " = " << (x) << endl;
#define PB push_back
#define MP make_pair
#define ll long long

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

int main(){
    std::ios::sync_with_stdio(false);
    int a, b;
    cin >> a >> b;

    if(a+b == 15)
    {
        cout << "+" << endl;
    }
    else if(a*b == 15)
    {
        cout << "*" << endl;
    }
    else
    {
        cout << "x" << endl;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define  rep(i, n) for(int i = 0; i < n; i++) 
#define  all(x) (x).begin(),(x).end()     // 昇順ソート
#define  rall(v) (v).rbegin(), (v).rend() // 降順ソート
#define  INF 1000000000
#define  pow(x) pow(10,(x)) 
typedef long long int LL;
const int MOD = 1000000007;
//sort(all(x))とするとソートできるよ

int main(){
    LL A,B;cin >> A >> B;
    if(A == B){
        cout << 0 << endl;
    }
    else{
        if((A+B) % 2 == 0){
            cout << (A+B)/2 << endl;
        }
        else{
            cout << "IMPOSSIBLE" << endl;
        }
    }
    
}

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

// a+b   = x
// 2a+4b = y
// ----------
// 2b = y-2x   ->    x-2y harus genap non negatif
// 2a = y-2(y-2x)
// 2a = y-2y+4x = 4x-y

int x, y;

int main () {
	cin >> x >> y;
	if ((y-2*x)%2==0 && (y-2*x>=0) && (4*x-y)%2==0 && (4*x-y>=0))
		cout << "Yes" << endl;
	else
		cout << "No" << endl;
}


Measured memory_bytes: 3636
import java.text.DecimalFormat;
import java.util.stream.LongStream;
import java.util.stream.IntStream;
import java.io.*;
import java.util.*;

public class Main {

    public static void main(String[] args) {
        FastScanner sc = new FastScanner();
        PrintWriter out = new PrintWriter(System.out);

        AtCoder problem = new AtCoder(sc);
        problem.solve(out);

        out.flush();
    }

}

class AtCoder {

    int A, B, C, K;

    AtCoder(FastScanner sc) {
        A = sc.nextInt();
        B = sc.nextInt();
        C = sc.nextInt();
        K = sc.nextInt();
    }

    void solve(PrintWriter out) {
        long max = nMax(A, B, C);
        out.println(A + B + C - max + max * (1 << K));
    }

    long nMax(long... numbers) {
        Arrays.sort(numbers);
        return numbers[numbers.length - 1];
    }
}

class FastScanner {

    private final InputStream in = System.in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;

    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        } else {
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }

    private int readByte() {
        if (hasNextByte()) {
            return buffer[ptr++];
        } else {
            return -1;
        }
    }

    private static boolean isPrintableChar(int c) {
        return 33 <= c && c <= 126;
    }

    public boolean hasNext() {
        while (hasNextByte() && !isPrintableChar(buffer[ptr])) {
            ptr++;
        }
        return hasNextByte();
    }

    public String next() {
        if (!hasNext()) {
            throw new NoSuchElementException();
        }
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while (isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }

    public long nextLong() {
        if (!hasNext()) {
            throw new NoSuchElementException();
        }
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while (true) {
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            } else if (b == -1 || !isPrintableChar(b)) {
                return minus ? -n : n;
            } else {
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }

    public int nextInt() {
        long nl = nextLong();
        if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) {
            throw new NumberFormatException();
        }
        return (int) nl;
    }

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


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

int main() {
  ll n; cin >> n;
  vector<P> p(n);
  rep(i, n){
    cin >> p[i].first; 
    p[i].second = i+1;
  }
  
  sort(p.begin(), p.end());
  
  rep(i, n){
    cout << p[i].second;
    if(i < n-1)  cout << " ";
    else  cout << endl;
  }
}

Measured memory_bytes: 4844
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef unsigned int uint;
typedef unsigned char uchar;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
 
#define REP(i,x) for(int i=0;i<(int)(x);i++)
#define REPS(i,x) for(int i=1;i<=(int)(x);i++)
#define RREP(i,x) for(int i=((int)(x)-1);i>=0;i--)
#define RREPS(i,x) for(int i=((int)(x));i>0;i--)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();i++)
#define RFOR(i,c) for(__typeof((c).rbegin())i=(c).rbegin();i!=(c).rend();i++)
#define ALL(container) (container).begin(), (container).end()
#define RALL(container) (container).rbegin(), (container).rend()
#define SZ(container) ((int)container.size())
#define mp(a,b) make_pair(a, b)
#define pb push_back
#define eb emplace_back
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
#define __builtin_popcount __builtin_popcountll
 
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 (a>b) { a=b; return 1; } return 0; }
template<class T> ostream& operator<<(ostream &os, const vector<T> &t) {
    os<<"["; FOR(it,t) {if(it!=t.begin()) os<<","; os<<*it;} os<<"]"; return os;
}
template<class T> ostream& operator<<(ostream &os, const set<T> &t) {
    os<<"{"; FOR(it,t) {if(it!=t.begin()) os<<","; os<<*it;} os<<"}"; return os;
}
template<class S, class T> ostream& operator<<(ostream &os, const map<S, T> &t) {
    os<<"{"; FOR(it,t) {if(it!=t.begin()) os<<","; os<<*it;} os<<"}"; return os;
}
template<class S, class T> ostream& operator<<(ostream &os, const pair<S,T> &t) { return os<<"("<<t.first<<","<<t.second<<")";}
template<class S, class T> pair<S,T> operator+(const pair<S,T> &s, const pair<S,T> &t){ return pair<S,T>(s.first+t.first, s.second+t.second);}
template<class S, class T> pair<S,T> operator-(const pair<S,T> &s, const pair<S,T> &t){ return pair<S,T>(s.first-t.first, s.second-t.second);}
 
const int INF = 1<<28;
const double EPS = 1e-8;
const int MOD = 1000000007;
 
 
int T, n, m;
int comp(string s, string t) {
    REP(i, min(s.size(), t.size())) {
        if (s[i] != t[i]) return i;
    }
    return min(s.size(), t.size());
 
}
int main(int argc, char *argv[]){
    ios::sync_with_stdio(false);
    string s;
    while(cin >> s ){
        string t = s;
        reverse(ALL(t));
        cout << (comp(s, "keyence") + comp(t, "ecneyek") >= 7 ? "YES" : "NO") << endl;
    }
    return 0;
}

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

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

typedef long long ll;
typedef array<int, 3> tri;
typedef long double ld;

template <class T> istream& operator>>(istream& I, vector<T>& v) {for (T &e: v) I >> e; return I;}
template <class T> ostream& operator<<(ostream &O, const vector<T>& v) {for (const T &e: v) O << e << ' '; return O;}



void _main() {
        ll a, b, c, d; cin >> a >> b >> c >> d;
        ll ans = LLONG_MIN;
        for (auto x: {a, b}) {
                for (auto y: {c, d}) {
                        ans = max(ans, x * y);
                }
        }

        cout << ans;
}



signed main() {
        ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
//        freopen("input.txt", "r", stdin);
        int _t = 1;
//        cin >> _t;
        while (_t--) _main();
        return 0;
}

Measured memory_bytes: 3644
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = Integer.parseInt(sc.next());
		int b = Integer.parseInt(sc.next());
		int k = Integer.parseInt(sc.next());
		for (int i = a; i < Math.min(a + k, b + 1); i++)
			System.out.println(i);
		for (int i = Math.max(a + k, b - k + 1); i <= b; i++)
			System.out.println(i);
	}
}

Measured memory_bytes: 21844
#include <iostream>
#include <iomanip>
#include <cmath>
#include <string>
#include <algorithm>

using namespace std;

int main()
{
    int w, n;
    
    cin >> w >> n;
    
    int *arr = new int(w + 1);
    
    for (int i = 0; i <= w; i++)
    {
        arr[i] = i;
    }
    
    for (int i = 0; i < n; i++)
    {
        int a, b;
        scanf("%d,%d", &a, &b);
        
        swap(arr[a], arr[b]);
    }
    for (int i = 1; i <= w; i++)
    {
        cout << arr[i] << endl;
    }
    
    return 0;
}



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

int main(){
    int H,W;
    while(1){
        cin >> H >> W;
        if((H==0)&&(W==0))break;
        for(int i = 0;i<H;i++){
            for(int j = 0;j<W;j++){
                cout << "#";
            }
            cout << endl;
        }
        cout <<endl;
    }
    return 0;
}


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

void chmin(int& a, int b){
    a = min(a, b);
}

int main(){
    int N, P[4], T[4];
    cin >> N;
    for(int i=0; i<4; i++) cin >> P[i];
    for(int i=0; i<4; i++) cin >> T[i];

    vector<int> dp(200, 1e9);
    dp[0] = 0;
    for(int i=0; i<N; i++) for(int k=0; k<4; k++) chmin(dp[i+T[k]], dp[i] + P[k]);
    int ans = 1e9;
    for(int i=N; i<200; i++) chmin(ans, dp[i]);
    cout << ans << endl; 
    return 0;
}



Measured memory_bytes: 3104
package main

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

func newScanner() *bufio.Scanner {
	scanner := bufio.NewScanner(os.Stdin)
	scanner.Split(bufio.ScanWords)
	return scanner
}

var sc = newScanner()

func scanInt() int {
	sc.Scan()
	v, _ := strconv.Atoi(sc.Text())
	return v
}

func scanInts(n int) []int {
	a := make([]int, n)
	for i := 0; i < n; i++ {
		a[i] = scanInt()
	}
	return a
}

func scanString() string {
	if sc.Scan() {
		return sc.Text()
	}
	panic(sc.Err())
}

func main() {
	n, q := scanInt(), scanInt()
	weightedUnionFindTrees(n, q)
}

func debug(a ...interface{}) {
	// fmt.Println(a...)
}

func weightedUnionFindTrees(n, q int) {
	par := make([]int, n)
	for i := 0; i < n; i++ {
		par[i] = i
	}
	rank := make([]int, n)
	weight := make([]int, n)
	for i := 0; i < q; i++ {
		executeQuery(par, rank, weight)
	}
}

func executeQuery(par, rank, weight []int) {
	cmd := scanInt()
	switch cmd {
	case 0: // relate
		x, y, z := scanInt(), scanInt(), scanInt()
		setWeight(x, y, z, weight, par)
	case 1: // diff
		x, y := scanInt(), scanInt()
		diff(x, y, weight, par)
	}
}

func setWeight(small, large, greaterBy int, weight, par []int) {
	debug("setWeight", small, large, greaterBy)
	if getRoot(small, par, weight) != getRoot(large, par, weight) {
		smallRoot := getRoot(small, par, weight)
		weight[smallRoot] = weight[smallRoot] - weight[small] - greaterBy
		par[smallRoot] = large
	} else {
		weight[small] = weight[large] - greaterBy
	}
	debug(weight)
}

func diff(x, y int, weight, par []int) {
	debug("diff", x, y)
	if getRoot(x, par, weight) == getRoot(y, par, weight) {
		fmt.Println(weight[y] - weight[x])
	} else {
		fmt.Println("?")
	}

	debug(weight)
}

func getRoot(x int, par, weight []int) int {
	debug("getRoot [START]", x, par, weight)
	if par[x] == x {
		debug("getRoot [END]", x, par, weight)
		return x
	}
	root := getRoot(par[x], par, weight)
	weight[x] += weight[par[x]]
	par[x] = root
	debug("getRoot [END]", x, par, weight)
	return root
}



Measured memory_bytes: 55296
#pragma GCC target ("avx2")
#pragma GCC optimize ("unroll-loops")
#pragma GCC optimize ("O3")
#include "bits/stdc++.h"
#include <unordered_set>
#include <unordered_map>
#include <random>
using namespace std;
typedef long long ll;
const ll MOD = /*1'000'000'007LL;*/ 998'244'353LL;
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for(int (i)=0; (i)<(n); (i)++)
const int dx[4]={ 1,0,-1,0 };
const int dy[4]={ 0,1,0,-1 };

template<typename T>
vector<T> divisor_enumeration(T n){
    vector<T> ret1, ret2;
    for(T i=1; i*i<=n; i++){
        if(n%i == 0){
            ret1.push_back(i);
            if(i*i != n) ret2.push_back(n/i);
        }
    }
    reverse(ret2.begin(), ret2.end());
    ret1.insert(ret1.end(), ret2.begin(), ret2.end());
    return ret1;
}

template<typename T>
T extgcd(T a, T b, T &x, T &y){
    T ret = a;
    if(b != 0){
        ret = extgcd(b, a%b, y, x);
        y -= (a / b) * x;
    }
    else{
        x = 1;
        y = 0;
    }
    return ret;
}

ll N, k;

signed main(){
    cin >> N;
    if(N == 1){
        cout << 1 << endl;
        return 0;
    }
    if(N%2) k = N-1;
    else k = 2*N-1;

    vector<ll> v = divisor_enumeration(N);
    rep(i, v.size()){
        ll A = v[i];
        ll B = N / A;
        ll x, y;
        ll g = extgcd(2*A, -B, x, y);
        if(g != 1) continue;
        if(y <= 0){
            y += 2*A/g;
            x += B/g;
        }
        ll tmp = min((y-1)/(2*A/g), (x-1)/(B/g));
        y -= tmp * 2*A/g;
        x -= tmp * B/g;
        //cout << x << " " << 2*A << " " << y << " " << -B << endl;
        k = min(k, y*B);
    }
    rep(i, v.size()){
        ll A = v[i];
        ll B = N / A;
        ll x, y;
        ll g = extgcd(A, -2*B, x, y);
        if(g != 1) continue;
        if(y <= 0){
            y += A/g;
            x += 2*B/g;
        }
        ll tmp = min((y-1)/(A/g), (x-1)/(2*B/g));
        y -= tmp * A/g;
        x -= tmp * 2*B/g;
        //cout << x << " " << A << " " << y << " " << -2*B << endl;
        k = min(k, y*2*B);
    }
    cout << k << endl;
}

Measured memory_bytes: 3844
#include <iostream>
using namespace std;
int main() {
 int x,k,range;
 cin >> k >> x;
 
 range =(k*2)-1;
 x=x-k+1;
 for (int i=0;i<range;++i){
   cout << x << " ";
   x+=1;
    }
  
return 0;}

Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <cstdlib>
#include <iomanip>
#include <cmath>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdlib>
#include <limits>
#include <numeric>
#include <set>

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;


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

	system("pause");
	return 0;
}

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

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

  for (int i = 0; i < m; i++) {
    cin >> c[i] >> d[i];
  }

  for (int i = 0; i < n; i++) {
    int max = abs(a[i] - c[0]) + abs(b[i] - d[0]);
    int maxp = 0;
    for (int j = 1; j < m; j++) {
      int res = abs(a[i] - c[j]) + abs(b[i] - d[j]);
      if (res < max) {
	max = res;
	maxp = j;
      }
    }
    cout << maxp + 1 << endl;
  }

  return 0;
}


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

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


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

using ll = long long;
using Vi = vector<int>;
using Vl = vector<ll>;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;

constexpr int I_INF = numeric_limits<int>::max();
constexpr ll L_INF = numeric_limits<ll>::max();

//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

void solve() {
    ll X, N;
    cin >> X >> N;
    vector<bool> used(102);
    for (ll i = 0; i < N; i++) {
        ll a;
        cin >> a;
        used[a] = true;
    }

    ll b = 1e9, c = 1e9;
    for (ll i = X; i <= 101; i++) {
        if (!used[i]) {
            b = i;
            break;
        }
    }
    for (ll i = X; i >= 0; i--) {
        if (!used[i]) {
            c = i;
            break;
        }
    }

    ll ans;
    if (abs(X - b) < abs(X - c)) {
        ans = b;
    }
    else {
        ans = c;
    }

    cout << ans << "\n";
}

//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

int main() {
#ifdef FASTIO
    cin.tie(0), cout.tie(0);
    ios::sync_with_stdio(false);
#endif
#ifdef FILEINPUT
    ifstream ifs("./in_out/input.txt");
    cin.rdbuf(ifs.rdbuf());
#endif
#ifdef FILEOUTPUT
    ofstream ofs("./in_out/output.txt");
    cout.rdbuf(ofs.rdbuf());
#endif
    solve();
    cout << flush;
    return 0;
}

Measured memory_bytes: 3612
function main(arg) {
  var inputs = arg.trim().split(' ').map(v => parseInt(v));
  var N = inputs[0];
  var Y = inputs[1];

  for (var i = 0; i <= N; i++) {
    if (10000 * i > Y) continue;
    for (var j = 0; j <= N - i; j++) {
      if (10000 * i + 5000 * j > Y) continue;
      var total = 10000 * i + 5000 * j + 1000 * (N - i - j);
      if (total === Y) {
        console.log(i + ' ' + j + ' ' + (N - i - j));
        return;
      }
    }
  }
  console.log('-1 -1 -1');
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));


Measured memory_bytes: 7372
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
const int INF = 1 << 29;
const int MOD = 1000000007;

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

    // 0段目からn段目のどこが壊れていないか(0段目とn段目は壊れてない)
    vector<bool> not_broken(n + 1, true);
    long long a;
    rep(i, m) {
        cin >> a;
        not_broken.at(a) = false;
    }

    // dp[i] = i段目まで登るときの場合の数としたときdp[i] = dp[i-1] + dp[i-2]となる
    // dp[i]が壊れているとき0を代入(何もしない)
    vector<long long> dp(n + 1, 0);
    // 0段目にあるという意味で1通り
    dp.at(0) = 1;
    // 1段目だけ別判定する  壊れてないとき1通り
    if (not_broken.at(0) == true) dp.at(1) = 1;

    for (int i = 2; i <= n; i++) {
        // i番目が壊れているとき何もしない(0のまま)
        if (not_broken.at(i) == false) continue;

        // i番目が壊れていないとき
        if (not_broken.at(i - 2) == true) dp.at(i) += dp.at(i - 2);
        if (not_broken.at(i - 1) == true) dp.at(i) += dp.at(i - 1);

        // MODを取る
        dp.at(i) %= MOD;
    }
    // 途中が全て壊れているときも大丈夫
    cout << dp.at(n) << endl;
}


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

using namespace std;

typedef long long LL;
typedef pair<int , int> P2;
typedef pair<pair<int , int> , int> P3;
typedef pair<pair<int , int> , pair<int , int> > P4;
#define PB(a) push_back(a)
#define MP(a , b) make_pair((a) , (b))
#define M3P(a , b , c) make_pair(make_pair((a) , (b)) , (c))
#define M4P(a , b , c , d) make_pair(make_pair((a) , (b)) , make_pair((c) , (d)))
#define repp(i,a,b) for(int i = (int)(a) ; i < (int)(b) ; ++i)
#define repm(i,a,b) for(int i = (int)(a) ; i > (int)(b) ; --i)

vector<LL> ans;

LL S(LL x){
	LL ret = 0;
	for(; x ; x /= 10) ret += x%10;
	return ret;
}

void check(LL x){
	LL y = S(x);
	while(ans.size()){
		LL p = *ans.rbegin();
		if(p*y > x*S(p)) ans.pop_back();
		else break;
	}
	ans.push_back(x);
}

int main(){
	int K; cin >> K;
	repp(i,1,100) check(i);
	LL a = 0 , b = 1;
	while(a < 1e12){
		repp(i,100,1000) check(i*b+a);
		a = a*10+9;
		b *= 10;
	}
	repp(i,0,K) cout << ans[i] << endl;
	return 0;
}


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

int main() {
  int N, L;
  std::cin >> N >> L;
  std::vector<std::string> data(N);
  for (int i=0; i<N; i++) {
    std::cin >> data.at(i);
  }
  std::sort(data.begin(), data.end());
  for (int i=0; i<N; i++) {
    std::cout << data.at(i);
  }
  std::cout << std::endl;
}
  


Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <complex>
#include <string>
#include <sstream>
#include <limits>
#include <numeric>
#include <algorithm>
#include <functional>

#include <map>
#include <set>
#include <vector>

using namespace std;

vector<bool> sieve;

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

	int N;
	cin >> N;

	map<int, int> a_cnt;
	set<int> a_set;
	int max_a = 0;

	for (int i = 0; i < N; i++)
	{
		int a;
		cin >> a;

		a_cnt[a]++;
		a_set.insert(a);
		max_a = max(max_a, a);
	}

	sieve.assign(max_a + 1, true);

	for (pair<int, int> e : a_cnt)
	{
		if (e.second > 1)
		{
			sieve[e.first] = false;
		}
	}

	for (int e : a_set)
	{
		for (int ne = e * 2; ne <= max_a; ne += e)
		{
			sieve[ne] = false;
		}
	}

	int result = 0;
	for (int e : a_set)
	{
		if (sieve[e])
		{
			result++;
		}
	}

	cout << result;

	return 0;
}


Measured memory_bytes: 22188
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#define int long long

signed main()
{
	std::ios::sync_with_stdio(false);
	std::cin.tie(NULL);

	int n;
	std::cin >> n;
	std::vector<int> h;
	for (int j = 0; j < n; j++)
	{
		int m;
		std::cin >> m;
		h.push_back(m);
	}
	std::vector<int> dp;
	dp.push_back(0);
	dp.push_back(std::abs(h[1]-h[0]));
	for (int j = 2; j < n; j++)
	{
		dp.push_back(std::min((std::abs(h[j - 2] - h[j]) + dp[j - 2]), std::abs(h[j] - h[j - 1]) + dp[j - 1]));
	}
	std::cout << dp[n - 1];
	return 0;
}

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

#define ll long long
#define vec vector<ll>
#define sortv(a); sort(a.begin(), a.end());
#define rev(a); reverse(a.begin(), a.end());
#define FOR(i,a,b) for (ll i = (ll)(a); i < (b); i++)
#define ROF(i,a,b) for (ll i = (ll)(b)-1; i >= (a); i--)

ll MOD = 1000000007;
ll INF = 1LL << 60;

int main() {
	ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	
	string s;cin>>s;
	if (s[2]==s[3]&&s[4]==s[5]) {
		cout<<"Yes";
	}else{
		cout<<"No";
	}
}

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

int main() {
  int N;
  cin >> N;
  vector<int> a(N);
  for(int i = 0; i < N; i++)
    cin >> a.at(i);
  sort(a.begin(), a.end());
  reverse(a.begin(), a.end());
  int as = 0;
  int bs = 0;
  for(int i = 0; i < N; i++) {
    if( i%2 == 1 )
      as += a.at(i);
    else
      bs += a.at(i);
  }
  cout << abs(as -bs) << endl;
}

Measured memory_bytes: 256
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools

sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**13
mod = 10**9+7
dd = [(-1,0),(0,1),(1,0),(0,-1)]
ddn = [(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)

class UnionFind:
    def __init__(self, size):
        self.table = [-1 for _ in range(size)]

    def find(self, x):
        if self.table[x] < 0:
            return x
        else:
            self.table[x] = self.find(self.table[x])
            return self.table[x]

    def union(self, x, y):
        s1 = self.find(x)
        s2 = self.find(y)
        if s1 != s2:
            if self.table[s1] <= self.table[s2]:
                self.table[s1] += self.table[s2]
                self.table[s2] = s1
            else:
                self.table[s2] += self.table[s1]
                self.table[s1] = s2
            return True
        return False

    def subsetall(self):
        a = []
        for i in range(len(self.table)):
            if self.table[i] < 0:
                a.append((i, -self.table[i]))
        return a

def main():
    rr = []

    def f(n,m):
        a = sorted([LI()[::-1] for _ in range(m)])
        uf = UnionFind(n+1)
        b = 0
        for c,t,s in a:
            if uf.union(s,t):
                b += 1
                if b > (n-1) // 2:
                    return c
        return -1

    while True:
        n,m = LI()
        if n == 0:
            break
        rr.append(f(n,m))

    return '\n'.join(map(str,rr))


print(main())



Measured memory_bytes: 10776
import fractions as math
n,x = map(int,input().split())
list1 = list(map(int,input().split()))
ans = max(abs(x-list1[0]),abs(list1[-1]-x))
for i in range(n):
	gcd = math.gcd(ans,abs(x-list1[i]))
	ans = min(ans, gcd)

print(ans)

Measured memory_bytes: 16240
import java.util.*;

public class Main {

    public static void main(String[] args) {
        // write your code here
        Scanner sc = new Scanner(System.in);

        int n = sc.nextInt();
        int m = sc.nextInt();

        for (int i = 0; i < m; i++) {
            n -= sc.nextInt();
        }

        System.out.println(Math.max(n, - 1));
    }
}

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

int main(){ 
    int n;
    cin >> n;
    if((n%10) == ((n/10/10%10))) puts("Yes");
    else puts("No");
}   

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <complex>
#include <cmath>
using namespace std;
typedef complex<double> P;
 
const double eps = 1e-8;
 
bool equals(double a, double b) {
  return abs(a-b) < eps;
}
 
double dot(P a, P b) {
  return a.real()*b.real() + a.imag()*b.imag();
}
 
double cross(P a, P b) {
  return a.real()*b.imag() - a.imag()*b.real();
}
 
int ccw(P p, P a, P b) {
  a -= p;
  b -= p;
  if(cross(a, b) > eps) return 1;
  if(cross(a, b) < -eps) return -1;
  if(dot(a,b) < -eps) return 2;
  if(norm(b)-norm(a) > eps) return -2;
  return 0;
}
 
bool isIntersect(P a1, P a2, P b1, P b2) {
  return ( ccw(a1, a2, b1) * ccw(a1, a2, b2) <= 0 &&
           ccw(b1, b2, a1) * ccw(b1, b2, a2) <= 0 );
}
 
P getCrossP(P a1, P a2, P b1, P b2) {
  P a = a2 - a1;
  P b = b2 - b1;
  return a1 + a * cross(b, b1 - a1)/cross(b, a);
}
 
P A, B;
int N;
vector<P> S, T;
vector<int> Own, Pos;
 
int main() {
  int Tc;
  cin >> Tc;
  while(Tc--) {
    cin >> A.real() >> A.imag() >> B.real() >> B.imag();
    cin >> N;
    S.resize(N);
    T.resize(N);
    Own.resize(N);
    Pos.resize(N);
    for(int i = 0; i < N; ++i) {
      cin >> S[i].real() >> S[i].imag() >> T[i].real() >> T[i].imag()
          >> Own[i] >> Pos[i];
    }
 
    vector<pair<double, int> > v;
    for(int i = 0; i < N; ++i) {
      if(isIntersect(A,B,S[i],T[i])) {
        P p = getCrossP(A,B,S[i],T[i]);
        v.push_back(make_pair(norm(p-A), i));
      }
    }
    int cnt = 0;
    if(v.size()) {
      sort(v.begin(), v.end());
      int pos = (Pos[v[0].second] ^ ~Own[v[0].second]);
       
      for(int i = 1; i < v.size(); ++i) {
        int npos = Pos[v[i].second] ^ ~Own[v[i].second];
        if(npos != pos) ++cnt;
        pos = npos;
      }
    }
    cout << cnt << endl;
  }
  return 0;
}

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

using namespace std;

static constexpr int MAX_S = 3;

string a = {}, b = {}, c = {};

void input()
{
  cin >> a;
  cin >> b;
  cin >> c;
}

void solve()
{
  cout << a[0] << b[0] << c[0];
}

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

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long 
// memo  fixed  setprecision(20);
using vvll = vector<vector<ll>>;
ll mod =1e9+7;
/*"itob" int to "N"base */           template<typename TypeInt> string itob(const TypeInt v, int base){static const char table[] = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ";string ret;static numeric_limits<TypeInt> t;TypeInt n = v;if (t.is_signed) {if (v < 0) n *= -1;}while (n >= base) {ret += table[n%base];n /= base;}ret += table[n];if (t.is_signed) {if (v < 0 && base == 10) ret += '-';}reverse(ret.begin(), ret.end());return ret;}
/*"chmin" a = MAX*/                  template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
/*"chmax" a = MIN*/                  template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
/*"ctoi"  char to int*/              int ctoi(char c) {return c-'0';}
/*"gcd"   MAX Euclidean */           ll gcd(ll a,ll b){if(b==0)return a; return gcd(b,a%b);}
/*"lcm"   MIN*/                      ll lcm(ll a,ll b){ll g = gcd(a,b);return a/g*b;}
/*"primecheck"If prime,return true.*/bool primecheck(ll n){if(n < 2) return false;else{for(int i = 2; i * i <= n; i++){if(n % i == 0) return false;}return true;}}
string  reverserange(string s,ll a,ll b){reverse(s.begin()+a-1,s.begin()+b); return s;}
int main(){
   int n;
   cin >> n;
   vector<int>ans(n,0);
   for(int i=0;i<n-1;i++){
      int z;
      cin >> z;
      z--;
      ans.at(z)++;
   }
   for(int i=0;i<n;i++){
      cout << ans.at(i)<<endl;
   }
}
    



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

typedef long long ll;

const int Maxn = 52;
const int Inf = 1000000000;

int dp[Maxn][Maxn];
int n;
int a[Maxn], b[Maxn];
bool has[Maxn][Maxn];
ll res;

int main()
{
	for (int j = 0; j < Maxn; j++) {
		for (int i = 0; i < j; i++)
			dp[i][j] = Inf;
		dp[j][j] = 0;
		for (int i = j + 1; i < Maxn; i++) {
			int my = 1;
			while (my <= i && dp[i % my][j] >= my) my++;
			dp[i][j] = my <= i? my: Inf;
		}
	}
	scanf("%d", &n);
	for (int i = 0; i < n; i++) {
		scanf("%d", &a[i]);
		has[i][a[i]] = true;
	}
	for (int i = 0; i < n; i++)
		scanf("%d", &b[i]);
	while (true) {
		int mx = 0;
		for (int i = 0; i < n; i++) {
			int mn = Inf;
			for (int j = 0; j < Maxn; j++)
				if (has[i][j]) mn = min(mn, dp[j][b[i]]);
			mx = max(mx, mn);
		}
		if (mx >= Inf) { printf("-1\n"); return 0; }
		if (mx == 0) break;
		for (int i = 0; i < n; i++)
			for (int j = 0; j < Maxn; j++) if (has[i][j])
				has[i][j % mx] = true;
		res |= 1ll << ll(mx);
	}
	cout << res << endl;
	return 0;
}

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

#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define FORD(i,b,a) for (int i = (int)(b) - 1; i >= a; --i)
#define REP(i,N) FOR(i,0,N)
#define st first
#define nd second
#define pb push_back

typedef pair<int, int> PII;
typedef long long LL;

char M[1000][1000];
int D[1000][1000];
int D2[1000][1000];

const int INF = 1e9;

int main() {
  int H, W, K;
  scanf("%d%d%d", &H, &W, &K);
  REP(i,H) scanf("%s", M[i]);
  PII starting;
  REP(i,H)REP(j,W) {
    if (M[i][j] == 'S') {
      M[i][j] = '.';
      starting = {i,j};
    }

    D[i][j] = D2[i][j] = INF;
  }

  queue<PII> Q;
  REP(i,H) D[i][0] = D[i][W-1] = 0;
  REP(j,W) D[0][j] = D[H-1][j] = 0;
  REP(i,H)REP(j,W) if (D[i][j] == 0) Q.push({i,j});

  while (!Q.empty()) {
    PII p = Q.front();
    int d = D[p.st][p.nd];
    Q.pop();
    if (p.st > 0 && D[p.st-1][p.nd] > d + 1) {
      D[p.st-1][p.nd] = d + 1;
      Q.push({p.st - 1, p.nd});
    }
    if (p.st < H - 1 && D[p.st+1][p.nd] > d + 1) {
      D[p.st+1][p.nd] = d + 1;
      Q.push({p.st + 1, p.nd});
    }
    if (p.nd > 0 && D[p.st][p.nd - 1] > d + 1) {
      D[p.st][p.nd - 1] = d + 1;
      Q.push({p.st, p.nd - 1});
    }
    if (p.nd < W - 1 && D[p.st][p.nd + 1] > d + 1) {
      D[p.st][p.nd + 1] = d + 1;
      Q.push({p.st, p.nd + 1});
    }
  }

  D2[starting.st][starting.nd] = 0;
  Q.push(starting);
  while (!Q.empty()) {
    PII p = Q.front();
    int d = D2[p.st][p.nd];
    Q.pop();
    if (M[p.st][p.nd] == '#') continue;

    if (p.st > 0 && D2[p.st-1][p.nd] > d + 1) {
      D2[p.st-1][p.nd] = d + 1;
      Q.push({p.st - 1, p.nd});
    }
    if (p.st < H - 1 && D2[p.st+1][p.nd] > d + 1) {
      D2[p.st+1][p.nd] = d + 1;
      Q.push({p.st + 1, p.nd});
    }
    if (p.nd > 0 && D2[p.st][p.nd - 1] > d + 1) {
      D2[p.st][p.nd - 1] = d + 1;
      Q.push({p.st, p.nd - 1});
    }
    if (p.nd < W - 1 && D2[p.st][p.nd + 1] > d + 1) {
      D2[p.st][p.nd + 1] = d + 1;
      Q.push({p.st, p.nd + 1});
    }
  }

  int result = INF;
  REP(i,H)REP(j,W) {
    if (M[i][j] == '#' || D2[i][j] > K) continue;
    result = min(result, 1 + (D[i][j] + K-1) / K);
  }
  printf("%d\n", result);
}


Measured memory_bytes: 8832