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


public class Main {


//	final int MOD = 1000000007;


	public static void main(String[] args) {

		int ans = 0;
		Scanner sc = new Scanner(System.in);
		boolean f = false;

		int n = sc.nextInt();

		TreeMap< String, Integer> map = new TreeMap<String, Integer>();
		int[] a = new int[n];
		for (int i = 0; i < n; i++) {
			map.put(sc.next(), i);
		}

		//-------------------------------------------------------------------------------------

		ans = map.size();

		//-------------------------------------------------------------------------------------

//		for(int i = 0; i < n; i++) {
//			System.out.println(ans[i]);
//		}

//		if(f) {
//			System.out.println("Yes");
//		} else {
//			System.out.println("No");
//		}

		System.out.println(ans);

		sc.close();
	}
}

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

int main(){
    int N, A; cin >> N >> A;
    vector<int> X(N);
    for(int i = 0; i < N; i++){
        cin >> X[i];
        X[i] -= A;
    }

    ll ans = 0;
    unordered_map<ll, ll> MP1, MP2, MP3, MP4;

    for(int i = 0; i < 1 << (N/3); i++){
        ll sum = 0;
        for(int j = 0; j < (N/3); j++){
            if(i >> j & 1){
                sum += X[j];
            }
        }
        MP1[sum]++;
    }
    /* for(auto e: MP1){
        cout << e.first << " " << e.second << endl;
    } */

    for(int i = 0; i < 1 << N*2/3 - (N/3); i++){
        ll sum = 0;
        for(int j = N/3; j < N*2/3; j++){
            if(i >> (j - N / 3) & 1){
                sum += X[j];
            }
        }
        MP2[sum]++;
    }

    for(int i = 0; i < 1 << N - (N*2/3); i++){
        ll sum = 0;
        for(int j = N*2/3; j < N; j++){
            if(i >> (j - N * 2 / 3) & 1){
                sum += X[j];
            }
        }
        MP3[sum]++;
    }

    /* for(auto e: MP2){
        cout << e.first << " " << e.second << endl;
    } */

    /* for(auto e: MP3){
        cout << e.first << " " << e.second << endl;
    } */

    for(auto e: MP1){
        for(auto p: MP2){
            MP4[e.first + p.first] += e.second * p.second;
        }
    }

    /* for(auto e: MP4){
        cout << e.first << " " << e.second << endl;
    } */

    for(auto e: MP3){
        ans += e.second * MP4[-e.first];
    }
    cout <<  ans - 1 << endl;

}

Measured memory_bytes: 256
#include<stdio.h>

int main(void)
{
    int r=0 ,c=0 ;
    int i=0 ,j=0 ;
    int list[100][100] = {0} ;
    int mem=0 ,total=0 ;

    scanf("%d%d",&r ,&c);

    for (i=0 ;i<r ;i++){
        for (j=0 ;j<c ;j++){
            scanf("%d",&mem);
            list[i][j]=mem;
        }
    }

    for (i=0 ;i<r ;i++){

        mem=0;
        for (j=0 ;j<c ;j++){
            printf("%d ",list[i][j]);
            mem=mem+list[i][j];
        }
        printf("%d\n",mem);

    }

    for (j=0 ;j<c ;j++){
        mem=0;

        for (i=0 ;i<r ;i++){
            mem=mem+list[i][j];
        }
        printf("%d ",mem);
    }

    for (i=0 ;i<r ;i++){
        for (j=0 ;j<c ;j++){

            total=total+list[i][j];

        }
    }
    printf("%d\n",total);

    return 0;
}

Measured memory_bytes: 648
#pragma GCC optimize("O3")
#include <stdio.h>
#define INF 2300000000000000000LL
long long dist[1000][1000];
int main(){
	int V,E,i,j;long long k;
	int f=rand()%2;
	scanf("%d%d",&V,&E);
	for(i=0;i<V;i++){
		for(j=0;j<i;j++)dist[i][j]=INF;
		dist[i][j++]=0;
		for(;j<V;j++)dist[i][j]=INF;
	}
	for(;E--;)scanf("%d%d%lld",&i,&j,&k),dist[i-1][j-1]=-k;
	for(k=0;k<V;k++)for(i=0;i<V;i++)for(j=0;j<V;j++)
		if(dist[i][k]!=INF && dist[k][j]!=INF && dist[i][j]>dist[i][k]+dist[k][j])
			dist[i][j]=dist[i][k]+dist[k][j];
	for(i=0;i<V;i++)if(dist[0][i]!=INF&&dist[i][V-1]!=INF&&dist[i][i]<0){puts("inf");return 0;}
	printf("%lld\n",-dist[0][V-1]);
	return 0;
}

Measured memory_bytes: 8064
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define SZ(x) ((int)(x).size())
using namespace std;
using ll = long long;

int main() {
    int n, k;
    cin >> n >> k;
    vector<bool> v(10, true);
    rep(i, k) {
        int a;
        cin >> a;
        v[a] = false;
    }
    while(1) {
        int ans = n;
        while(ans > 0) {
            if (!v[ans % 10]) {
                break;
            }
            ans /= 10;
        }
        if (ans == 0) break;
        n++;
    }
    cout << n << "\n";
}

Measured memory_bytes: 3632
#include <iostream>
#include <cmath>
#include <string>
#include <map>
#include <queue>
using namespace std;

#define N 3
#define N2 9

struct Puzzle{
  int f[N2];
  int space;
  string path;

  bool operator < (const Puzzle &p) const{
    for(int i = 0;i < N2;i++){
      if(f[i] == p.f[i]) continue;
      return f[i] > p.f[i];
    }
    return false;
  }
};

static const int dx[4] = {-1,0,1,0};
static const int dy[4] = {0,-1,0,1};
static const char dir[4] = {'u','l','d','r'};

bool isTarget(Puzzle p){
  for(int i = 0;i < N2;i++){
    if(p.f[i] != (i + 1))return false;
  }
  return true;
}

string bfs(Puzzle s){
  queue<Puzzle> Q;
  map<Puzzle, bool> V;
  Puzzle u,v;
  s.path = "";
  Q.push(s);
  V[s] = true;

  while(!Q.empty()){
    u = Q.front();Q.pop();
    if(isTarget(u)) return u.path;
    int sx = u.space / N;
    int sy = u.space % N;
    for(int r = 0;r < 4;r++){
      int tx = sx + dx[r];
      int ty = sy + dy[r];
      if(tx < 0 || ty < 0 || tx >= N || ty >= N) continue;
      v = u;
      swap(v.f[u.space],v.f[tx * N + ty]);
      v.space = tx * N + ty;
      if(!V[v]){
        V[v] = true;
        v.path += dir[r];
        Q.push(v);
      }
    }
  }

  return "unsolvable";
}

int main(){
  Puzzle in;

  for(int i = 0;i < N2;i++){
    cin >> in.f[i];
    if(in.f[i] == 0){
      in.f[i] = N2;
      in.space = i;
    }
  }
  string ans = bfs(in);
  cout << ans.size() << endl;

  return 0;
}



Measured memory_bytes: 30616
#include<bits/stdc++.h>
using namespace std;
int main(){
  long long N,K;
  cin >> N >> K;
  vector<long long> A(N);
  long long loop,loop2;
  long long inner=0,outer=0;
  long long ans;
  for(loop=0;loop<N;loop++){
    cin >> A[loop];
  }
  for(loop=0;loop<N;loop++){
    for(loop2=0;loop2<N;loop2++){
      if(A[loop]>A[loop2]){
        if(loop<loop2)
          inner++;
        outer++;
      }
    }
  }
  ans=((inner*K)%1000000007+outer*((K*(K-1)/2)%1000000007))%1000000007;
  cout << ans << endl;
  return 0;
}

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

using namespace std;

#define _CRT_SECURE_NO_WARNINGS
#define rep(i, n) for(int i=0; i<(n); i++)
#define FOR(i, m, n) for(int i=(m);i<(n);i++)
#define SZ(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
#define SORT(x) sort((x).begin(),(x).end())
#define REVE(x) reverse((x).begin(),(x).end())
#define mp make_pair
#define pb push_back
#define F first
#define S second

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

int main() {
	int m, n;
	cin >> m >> n;
	vector<VI> a(30, VI(30));
	rep(i, m) {
		rep(j, n) {
			cin >> a[i][j];
		}
	}
	int ans = 0;
	rep(i, m) {
		int sum = accumulate(all(a[i]), 0);
		if (ans < sum)ans = sum;
	}
	cout << ans << endl;
}


Measured memory_bytes: 3164
#include <bits/stdc++.h>
#define SORT(a) sort(a.begin(), a.end())
#define RSORT(a) sort(a.rbegin(), a.rend())
#define REP(i, n) for (int i = 0; i < n; i++)
#define FOR(i, start, end) for (int i = start; i < end; i++)
#define ALL(a) a.begin(), a.end()
#define MOD(a) a %= 1'000'000'007
using ll = long long;
using namespace std;
const int INF32       = 1'050'000'000;
const long long INF64 = 4'000'000'000'000'000'000;
const int MOD7        = 1'000'000'007;
const int MOD9        = 1'000'000'009;
template <class T> inline bool chmin(T &a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template <class T> inline bool chmax(T &a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}

template <class T> vector<T> divisor(T N) {
    vector<T> ans;
    if (N == 1) {
        ans.emplace_back(1);
        return ans;
    }
    for (long long i = 1; i * i <= N; i++) {
        if (N % i == 0) {
            ans.emplace_back(i);
            if (i != 1 && i * i != N) {
                ans.emplace_back(N / i);
            }
        }
    }
    ans.emplace_back(N);
    return ans;
}

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

    int M;
    cin >> M;
    vector<int> b(M);
    for (auto &&i : b) {
        cin >> i;
    }
    vector<int> cnt(M);
    vector<int> ans(M);
    for (int i = M; i >= 1; i--) {
        if (b[i - 1] != cnt[i - 1]) {
            auto div = divisor(i);
            ans[i - 1]++;
            for (auto &&j : div) {
                cnt[j - 1] ^= 1;
            }
        }
    }
    vector<int> out;
    REP(i, M) {
        if (ans[i] == 1)
            out.emplace_back(i + 1);
    }
    std::cout << out.size() << '\n';
    for (auto &&i : out) {
        cout << i << " ";
    }
    std::cout << '\n';

    return 0;
}

Measured memory_bytes: 3832
#include<bits/stdc++.h>
using namespace std;
int main() {
    string s;
    cin>>s;
    int n=0;
    int a[9];
    for(int i=0;i<s.size()-2;i++){
        n=(s[i]-48)*100+(s[i+1]-48)*10+s[i+2]-48;
        a[i]=abs(753-n);
    }
    int m=a[0];
    for(int k=1;k<s.size()-2;k++){
        m=min(m,a[k]);
    }
    cout<<m<<endl;
}
//114　514(いいよ来いよ回だー）


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

using namespace std;
typedef long long ll;
#define INF 1999999999
#define MODA 1000000007 
#define rep(i,n) for (long long i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()

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

  vector<ll> Aibin(100001, 0);
  vector<ll> Aihist;
  ll Ai = X;
  Aibin[Ai]++;
  Aihist.push_back(Ai);
  ll i = 0;
  while (i < N) {
    Ai = (Ai*Ai)%M;
    if (Aibin[Ai] == 0) {
      Aibin[Ai]++;
      Aihist.push_back(Ai);
    }
    else {
      break;
    }
    i++;
  }
  ll itr = 0;
  // cerr << Ai << endl;
  while(true) {
    // cerr << Aihist[itr] <<" "<< itr << endl;
    if (Aihist[itr] != Ai) itr++;
    else break;
  }
  // cerr << Aihist.size() << endl;
  ll numitr = Aihist.size() - itr;
  ll numloop = (N - Aihist.size()) / numitr;
  ll rest = (N - Aihist.size()) % numitr;
  cerr << numitr <<" "<< numloop <<" "<< rest << endl;
  for(ll i = itr; i < Aihist.size(); ++i) {
    Aibin[Aihist[i]] += numloop;
  }
  for(ll i = itr; i < itr + rest; ++i) {
    Aibin[Aihist[i]] += 1;
  }
  ll ans = 0;
  for(ll i = 1; i < Aibin.size(); i++) {
    // if(Aibin[i] != 0) cerr << i <<" "<< Aibin[i] << endl;
    ans += i * Aibin[i];
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 4672
/*input
2 5
10 12 1 2 14
*/
#include <bits/stdc++.h>
#pragma GCC optimize("unroll-loops,no-stack-protector")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<double,double> pdd;
#define IOS ios_base::sync_with_stdio(0); cin.tie(0)
#define ALL(a) a.begin(),a.end()
#define SZ(a) ((int)a.size())
#define F first
#define S second
#define REP(i,n) for(int i=0;i<((int)n);i++)
#define pb push_back
#define MP(a,b) make_pair(a,b)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
template<typename T1,typename T2>
ostream& operator<<(ostream& out,pair<T1,T2> P){
	out<<'('<<P.F<<','<<P.S<<')';
	return out;
}

//}}}
const ll maxn=300005;
const ll maxlg=__lg(maxn)+2;
const ll INF64=8000000000000000000LL;
const int INF=0x3f3f3f3f;
const ll MOD=ll(1e9+7);
const double PI=acos(-1);
//const ll p=880301;
//const ll P=31;

ll mypow(ll a,ll b){
	ll res=1LL;
	while(b){
		if(b&1) res=res*a%MOD;
		a=a*a%MOD;
		
		b>>=1;
	}
	return res;
}
vector<ll> v;
ll a[maxn];
int main()
{
	IOS;
	int n,m;
	cin>>m>>n;
	m--;
	REP(i,n) cin>>a[i];
	sort(a,a+n);
	ll ans=a[n-1]-a[0];

	REP(i,n-1) v.pb(a[i+1]-a[i]);

	sort(ALL(v));
	while(SZ(v)&&m){
		ans-=v.back();
		v.pop_back();
		m--;
	}
	cout<<ans<<'\n';
	return 0;
}


Measured memory_bytes: 2168
#include<bits/stdc++.h>
using namespace std;
#define _rep(n, a, b) for (ll n = (a); n <= (b); ++n)
#define _rev(n, a, b) for (ll n = (a); n >= (b); --n)
#define _for(n, a, b) for (ll n = (a); n < (b); ++n)
#define _rof(n, a, b) for (ll n = (a); n > (b); --n)
#define oo 0x3f3f3f3f3f3f
#define ll long long
#define db double
#define eps 1e-3
#define bin(x) cout << bitset<10>(x) << endl;
#define what_is(x) cerr << #x << " is " << x << endl
#define met(a, b) memset(a, b, sizeof(a))
#define all(x) x.begin(), x.end()
#define pii pair<ll, ll>
#define pdd pair<db, db>
const ll mod = 1e9 + 9;
const db pi = acos(-1.0);
const ll maxn = 5e5+10;
map<int, int> cc;
signed main(){
    int n;
    cin >> n;
    ll res = 0;
    _rep(i, 1, n){
        int x;
        cin >> x;
        cc[x]++;
        res += x;
    }
    int m;
    cin >> m;
    _rep(i, 1, m){
        int a, b;
        cin >> a >> b;
        int dif = b - a;
        res = res  + cc[a]*dif;
        cc[b] += cc[a];
        cc[a] = 0;
        cout << res << endl;
    }
}

Measured memory_bytes: 7892
#include <iostream>
#include <stdio.h>
#include <vector>
#include <cmath>
#include <algorithm>
#include <string>
#include <queue>
#include <stack>
#include <functional>
#include <list>
#include <utility>
#include <map>
#include <vector>
using namespace std;

typedef long long ll;
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,x) for(int i=1;i<=x;i++)
#define rrep(i,x) for(int i=x-1;i>=0;i--)
#define rrep1(i,x) for(int i=x;i>0;i--)
#define sor(v) sort(v.begin(),v.end())
#define rev(s) reverse(s.begin(),s.end())
#define lb(vec,a) lower_bound(vec.begin(),vec.end(),a)
#define ub(vec,a) upper_bound(vec.begin(),vec.end(),a)
#define mp1(a,b,c) P1(a,P(b,c))
#define get_arsize(a) (sizeof(a)/sizeof(a[0]))
const ll mod = 1000000007;
const double eps = 1e-10;
const int MAX = 200000;

int main() {
  // three patterns
  char c;
  // 今回見ていたあまりが*10されて、次の1桁目がくっついて、13で割ったあまりの場合の数になる。
  // "非決定性有限オートマトンの場合は、ノードの長さだけの配列を用意しておいて、各配列の要素がそのターンにその配列を踏む場合の数"
  // 2次元配列が使える(高々数MB)
  int dp[100013][13] = {};
  // 読み取り0文字目のとき、0とみなす。
  // 13で割ったあまりが0となる場合の数が1で、他は0。
  dp[0][0] = 1;
  int i = 0;
  while (true) {
    c = cin.get();
    if (c == '\n') {
      cout << dp[i][5] << endl;
      return 0;
    }
    if (c =='?') { // 現在のkの状態、0~12が考えられる状態から、j(0〜9)が入ってきたときの遷移をする。
      for (int j = 0; j < 10; j++) {
        for (int k = 0; k < 13; k++) {
          dp[i + 1][(k * 10 + j) % 13] += dp[i][k];
          dp[i + 1][(k * 10 + j) % 13] %= mod;
        }
      }
    } else { // 現在のkの状態、0~12が考えられる状態から、numが入ってきたときの遷移をする。
      int num = c - '0';
      for (int k = 0; k < 13; k++) {
        dp[i + 1][(k * 10 + num) % 13] += dp[i][k];
        dp[i + 1][(k * 10 + num) % 13] %= mod;
      }
    }
    i++;
  }
  return 0;
}

Measured memory_bytes: 5376
//#include <stdio.h>
#include <math.h>
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
#include <queue>
#include <map>
#include <utility>
#include <iomanip>

using namespace std;

#define ll long long
vector<vector<ll>> dp;
vector<ll> w, v;
ll N, W;

ll res(ll i, ll j)
{
    if (i >= N)
    {
        return 0;
    }

    if (dp.at(i).at(j) != -1)
    {
        return dp.at(i).at(j);
    }
    ll ret;
    if (w.at(i) > j)
    {
        ret = res(i + 1, j);
    }
    else
    {
        ret = max(res(i + 1, j), res(i + 1, j - w.at(i)) + v.at(i));
    }

    return dp.at(i).at(j) = ret;
}

void solve()
{
    cin >> N >> W;
    dp = vector<vector<ll>>(N, vector<ll>(100001, -1));
    w = vector<ll>(N);
    v = vector<ll>(N);
    for (ll i = 0; i < N; i++)
    {
        cin >> w.at(i) >> v.at(i);
    }

    cout << res(0, W) << endl;

    return;
}

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


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

int main(){
  int n, k, count = 0;
  
  cin >> n >> k;
  
  vector<int> h(n);
  
  for(int i = 0; i < n; i++){
   cin >> h.at(i);
  }
  
  for(int i = 0; i < n; i++){
   if(h.at(i) >= k){
    count++;
   }
  }
  
  cout << count << endl;
  return 0;
}

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

#define ll long long
#define F(i,m,n) for(ll i=m;i<n;i++)
#define Fr(j,n,m) for(ll j=n;i>=m;i--)
#define vll vector<ll>
#define pll pair<ll,ll>
#define ff first
#define ss second
#define vpll vector< pll >
/*-------------------------------------*---------------------------------------*/

#define godspeed ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define deb(x) cout << #x << "=" << x << endl
#define cout_array(a) for(auto x: a){ cout<<x<<" ";}cout<<endl

ll gcd(ll a,ll b){
    if(b==0)return a;
    return gcd(b,a%b);
}
string dec_bin(ll x){
    string result;
    while(x>0){
        result.push_back(x%2 + 48);
        x = (x-(x%2))/2;
    }
    reverse(result.begin(),result.end());
    return result;
}
const ll MAX_PRIME = 1e9+7;
const ll INF = 1e18;

ll pow_2(ll factor){
    ll count = 0;
    while(factor%2==0){
        count+=1;
        factor/=2;
    }
    if(factor==1)return count;
    else return -1;
}

/*I NEED YOU TO WORK FOR TWO HOURS ON THIS NO MATTER WHAT....THE RESULT DOESN'T MATTER.....ITS ALL ABOUT YOUR EFFORTS.
---------------------------------------------------------------------------------------------------------------------*/

int main(){
    godspeed
    ll k;
    cin>>k;
    string string1;
    cin>>string1;
    ll count = 0;
    F(i,0,k){
        if(string1[i]  == 'W')count++;
    }
    ll count2 = 0;
    F(i,k-count,k){
        if(string1[i] == 'W')count2++;
    }
    cout<<count-count2<<endl;

    return 0;
}


Measured memory_bytes: 3740
//2020.1.16
//s1270188 xxxmk2
//alds1_05d

#include<stdio.h>
#include<limits.h>
#define N 200000

//prototype
long marge(int,int,int);
long m_sort(int,int);

//global
int data[N], num;

int main(){
  long i;

  //input
  scanf("%d",&num);
  for(i=0;i<num;i++) scanf("%d",&data[i]);

  //marge sort
  i=m_sort(0,num);

  //output
  printf("%ld\n",i);
  
  return 0;
}

long merge(int left,int mid,int right){
  int n1, n2, L[N/2+2], R[N/2+2];
  int i, j, k;
  long cnt=0;

  n1=mid-left;
  n2=right-mid;
  
  for(i=0;i<n1;i++) L[i]=data[left+i];
  for(i=0;i<n2;i++) R[i]=data[mid+i];

  L[n1]=R[n2]=INT_MAX;

  i=j=0;
  for(k=left;k<right;k++){
    if(L[i]<R[j]) data[k]=L[i++];
    else{
      data[k]=R[j++];
      cnt+=n1-i;
    }
  }
  return cnt;
}


long m_sort(int left,int right){
  int mid;
  long cnt=0;
  
  if(left+1<right){
    mid=(left+right)/2;
    cnt+=m_sort(left,mid);
    cnt+=m_sort(mid,right);
    cnt+=merge(left,mid,right);

    return cnt;
  }
  else return 0;
}



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

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;

#define fi first
#define se second
#define repl(i,a,b) for(ll i=(ll)(a);i<(ll)(b);i++)
#define rep(i,n) repl(i,0,n)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define mmax(x,y) (x>y?x:y)
#define mmin(x,y) (x<y?x:y)
#define maxch(x,y) x=mmax(x,y)
#define minch(x,y) x=mmin(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt __builtin_popcountll

#define INF 1e16
#define mod 1000000007

ll a,b;

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

  cin>>a>>b;
  cout<<max({a+b,a-b,a*b})<<endl;

  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int n,p,a[110],odd;
int main()
{
	cin>>n>>p;
	for (int i=1;i<=n;i++){
		cin>>a[i];
		if (a[i]&1) odd=1;
	}
	if ((p&1)&&!odd) return puts("0"),0;
	printf("%lld\n",1ll<<(n-odd));
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <cstdlib>
#include <cstdio>
#include <string>
#include <cstring>
#include <cassert>
#include <utility>
#include <iomanip>
#include <chrono>
#include <random>
#include <bitset>

using namespace std;

#define sz(x) (int) x.size()
#define unique(x) x.erase(unique(x.begin(), x.end()), x.end())
#define all(a) a.begin(), a.end()
#define sqr(x) ((x) * (x)) 
#define y1 aksjdaskdjksjfksdjf
#define left kdnvldvoiwejifejg
#define right lkdsjflksdjfdjfk
#define prev asdasfsadjkjsdfjs
#define tm aklsjdasjdasjdkdjjf
#define lcm hddalkwjeidjjhasda
#define random_shuffle asdasdd

long long n, a, b, c, d, e;

int main() { 

  cin >> n >> a >> b >> c >> d >> e;

  long long mn = min({a, b, c, d, e});
  long long tm = (n + mn - 1) / mn;

  cout << tm + 4 << endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (ll i = 0; i < (n); ++i)
#define All(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()   //reverse
#define strall(v) (v).cbegin(),(v).cend() //const_itterator
#define IN(a, b, x) (a<=x&&x<b)
using namespace std;
using ll = long long;
using P = pair<int,int>;
using Graph = vector<vector<ll>>;
template<typename T> using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;
template<typename t, typename u, typename Comp=less<>>
bool chmax(t& xmax, const u& x, Comp comp={}) { if(comp(xmax, x)) { xmax = x; return true; } return false;}
template<typename t, typename u, typename Comp=less<>>
bool chmin(t& xmin, const u& x, Comp comp={}) { if(comp(x, xmin)) { xmin = x; return true;} return false;}
const int INF = 1e9;
const ll infl = ll(1e18)+5;

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


int main() {
  set<string> st;
  string str;
  int k;
  cin >> str >> k;
  for(int i=0;i<str.size();i++){
    for(int j=1;j<=k;j++){
      st.insert(str.substr(i,j));
    }
  }
  int cnt = 1;
  string ans;
  for(auto s:st){
    if(k == cnt) ans = s;
    cnt++;
  }
  cout << ans << endl;
}

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

H, W = list(map(int, input().split()))

mtrx = []

for i in range(H):
    inputstr = input()
    if '#' in inputstr:
        mtrx.append(list(inputstr))

trv_mtrx = list(map(list, zip(*mtrx)))

new_mtrx = []

for line in trv_mtrx:
    if '#' in line:
        new_mtrx.append(line)

for l in list(map(list,zip(*new_mtrx))):
    print(''.join(l))

Measured memory_bytes: 3316
#include <iostream>

using namespace std;

int main()
{
    int n;
    cin >> n;
    int *v =new int[n];
    for (int i=0;i<n;i++){
    	cin>>v[i];
    }
    int *c =new int[n];
    for (int i=0;i<n;i++){
    	cin>>c[i];
    }
    int r=0;
    int k=0;
    for (int i=0;i<n;i++){
    	k=v[i]-c[i];
        if(k>0){
        	r+=k;
        }
    }
    cout << r << endl;
}

Measured memory_bytes: 256
use std::io::stdin;
use std::str::FromStr;

fn read_line<T>() -> Vec<T>
where
    T: FromStr,
    <T as std::str::FromStr>::Err: std::fmt::Debug,
{
    let mut s = String::new();
    stdin().read_line(&mut s).ok();
    s.trim()
        .split_whitespace()
        .map(|x| x.parse().unwrap())
        .collect()
}

fn main() {
    let x: i64 = read_line()[0];

    let mut res_a: i64 = 0;
    let mut res_b: i64 = 0;
    for a in 0..120{
        for b in -120..120{
            if a < b {
                break;
            }
            if i64::pow(a, 5) - i64::pow(b, 5) == x {
                res_a = a;
                res_b = b;
            }
        }
    }

    println!("{} {}", res_a, res_b);
}


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

bool dp[4001][16001];
int x,y,tx,ty,ax[4001],ay[4001];

void dfsx(int t,int n){
	if(dp[t][n+8000]) return;
	if(t<tx){
		dfsx(t+1,n+ax[t]);
		dfsx(t+1,n-ax[t]);
	}
	dp[t][n+8000]=1;
}

void dfsy(int t,int n){
	if(dp[t][n+8000]) return;
	if(t<ty){
		dfsy(t+1,n+ay[t]);
		dfsy(t+1,n-ay[t]);
	}
	dp[t][n+8000]=1;
}

int main()
{
	string s;
	cin>>s>>x>>y;
	bool fx=1;
	for(int i=0;i<s.length();i++){
		if(s[i]=='F'){
			if(fx) ax[tx]++;
			else ay[ty]++;
		}
		else{
			if(fx) fx=0,tx++;
			else fx=1,ty++;
		}
	}
	if(s[s.length()-1]=='F'){
		if(fx) tx++;
		else ty++;
	}
	dfsx(1,ax[0]);
	bool xx=dp[tx][8000+x]==1?1:0;
	memset(dp,0,sizeof(dp));
	dfsy(0,0);
	bool yy=dp[ty][8000+y]==1?1:0;
	if(xx&&yy) cout<<"Yes";
	else cout<<"No";
}

Measured memory_bytes: 62976
// Running Offline
// g++ tester.cpp
// ./a.out
//#include "/Users/manasgupta/Desktop/stdc++.h"

 #include<bits/stdc++.h>
using namespace std;
#define int long long int 
#define pi pair<int,int>
#define pb push_back
#define fi first
#define se second
// #define mp make_pair
#define inf 1e9
#define EPS 1e-6
#define endl '\n'
#define IOS ios::sync_with_stdio(0), cin.tie(0), cout.tie(0)
#define FILEIO(name1, name2) \
    freopen(name1".txt","r",stdin); \
    freopen(name2".txt","w",stdout);

const int N=10005;
const int mod = 1000000007;

int power(int a, int b, int c)
{
	int res=1;
	while (b)
	{
		if (b&1) res=(res*a)%c;
		a=(a*a)%c;
		b=b>>1;
	}
	return res;
}

int dp[1005][1005];
int h, w;
vector<string> v;

signed main()
{
	IOS;
	cin>>h>>w;
	for (int i=0; i<h; i++)
	{
		string x;
		cin>>x;
		v.pb(x);
	}
	// cout<<v[0]<<endl;
	for (int i=0; i<h; i++)
	{
		for (int j=0; j<w; j++)
		{
			dp[i][j]=0;
			if (i==0 and j==0)
			{
				if (v[i][j]=='.') dp[i][j]=1;
			}
			else if (i==0)
			{
				if (v[i][j]=='.') dp[i][j]=dp[i][j-1];
			}
			else if (j==0)
			{
				if (v[i][j]=='.') dp[i][j]=dp[i-1][j];
			}
			else
			{
				if (v[i][j]=='.')
				{
					dp[i][j]=(dp[i-1][j]+dp[i][j-1])%mod;
				}
			}
		}
	}
	cout<<dp[h-1][w-1]<<endl;
    return 0;
}





Measured memory_bytes: 9216
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pll = pair<ll,ll>;
using vl = vector<ll>;
using vvl = vector<vl>;
using vb = vector<bool>;
using vd = vector<double>;
const ll oo = 0x3f3f3f3f3f3f3f3fLL;
const double eps = 1e-9;
#define sz(c) ll((c).size())
#define all(c) begin(c),end(c)
#define mp make_pair
#define pb push_back
#define xx first
#define yy second
#define FOR(i,a,b) for (ll i=(a); i<(b); i++)
#define FORD(i,a,b) for (ll i=ll(b)-1; i>=(a); i--)

void self_min(ll &a, ll b) {
	a = min (a,b);
}
template <class T>
void self_max(T &a, T b) {
	a = max(a,b);
}
void add(ll &a, ll b) {
	a = (a+b)% 1000000007;
}

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

	ll n,k; cin >> n >> k;
	vl a(n);

	FOR(i,0,n) {
		cin >> a[i];
	}
	sort(all(a));

	vb dp(k+1, false);
	FOR(stones,1,k+1) {
		FOR(i,0,n) {
			ll curr = stones - a[i];
			if (curr < 0) {
				break;
			}
			if (dp[curr] == false) {
				dp[stones] = true;
				break;
			}
		}
	}

	if (dp[k]) {
		cout << "First" << endl;
	} else {
		cout << "Second" << endl;
	}

	return 0;
}


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

void ap_dfs(int at, int from, int &cnt, const vector<vector<int>> &graph, vector<bool> &used, vector<int> &par, vector<int> &num, vector<int> &low)
{
    num[at] = cnt;
    low[at] = cnt;
    used[at] = true;
    for (int ne : graph[at]) {
        if (used[ne]) low[at] = min(low[at], num[ne]);
        else {
            par[ne] = at;
            cnt++;
            ap_dfs(ne, at, cnt, graph, used, par, num, low);
            low[at] = min(low[at], low[ne]);
        }
    }
}

vector<int> articulation_points(const vector<vector<int>> &graph)
{
    const int SIZE = graph.size();

    vector<int> par(SIZE), num(SIZE), low(SIZE);
    vector<bool> used(SIZE);
    int cnt = 0;
    ap_dfs(0, -1, cnt, graph, used, par, num, low);

    vector<bool> is_ap(SIZE);
    int scnt = 0;
    for (int ne : graph[0]) {
        if (num[par[ne]] == 0) scnt++;
    }
    if (scnt >= 2) is_ap[0] = true;
    for (int i = 1; i < SIZE; i++) {
        if (num[par[i]] != 0 && num[par[i]] <= low[i]) is_ap[par[i]] = true;
    }

    vector<int> ret;
    for (int i = 0; i < SIZE; i++) {
        if (is_ap[i]) ret.push_back(i);
    }
    return ret;
}

#include <iostream>

int main()
{
    int V, E;
    cin >> V >> E;
    vector<vector<int>> graph(V);
    int s, t;
    for (int i = 0; i < E; i++) {
        cin >> s >> t;
        graph[s].push_back(t);
        graph[t].push_back(s);
    }

    auto res = articulation_points(graph);
    for (int v : res) {
        cout << v << endl;
    }
}

Measured memory_bytes: 4896
n = int(input())
s = input()
ans = []
target = ["A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z"]
for i in s:
  ans.append(target[(target.index(i)+n) % 26])
print(*ans,sep="")



Measured memory_bytes: 4724
#include<bits/stdc++.h>
const int N = 1e5 + 5;
using namespace std;

int n, a[N];
bool t;

int main(){
    cin >> n;
    for (int i = 1; i <= n; i++) cin >> a[i];
    while (true){
        bool sum = 0;
        for (int i = 1; i <= n; i++) sum ^= ((a[i]-1)&1);
        if (sum){
            if (!t) cout << "First";
            else cout << "Second";
            return 0;
        }
        int cnt = 0, cnt1 = 0, gcd = 0;
        for (int i = 1; i <= n; i++) cnt += a[i]&1, cnt1 += a[i] == 1;
        if (cnt == 1 && !cnt1){
            for (int i = 1; i <= n; i++){
                if (a[i]&1) a[i]--;
                gcd = __gcd(gcd, a[i]);
            }
            for (int i = 1; i <= n; i++) a[i] /= gcd;
        }
        else{
            t ^= 1;
            if (!t) cout << "First";
            else cout << "Second";
            return 0;
        }
        t ^= 1;
    }
}


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

int main(){
  int a,b;
  cin >> a >> b;
  if(a+ b == 15){
    cout << "+" << endl;
  }else if(a*b == 15){
    cout << "*" << endl;
  }else{
    cout << "x" << endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
	int a,b,c,d;
	cin>>a>>b>>c>>d;
	while (a>0&&c>0) {
		c-=b;
		if (c<=0) {
			cout<<"Yes"<<endl;
			return 0;
		}
		a-=d;
		if (a<=0) {
			cout<<"No"<<endl;
			return 0;
		}
	}
	return 0;
}

Measured memory_bytes: 3640
#include<bits/stdc++.h>
#define N 100
#define D 100001
#define INF (1e9)
using namespace std;
typedef pair<int,int> P;

int n,hp[N],m,mp[N],damage[N],ans,cnt;
int dpAll[D],dpSin[D];
string name,target[N];
vector<P> v;
vector<int> minv;

int bynary_search(int x){
  int L=0,R=v.size();
  while(L<R){
    int M=(L+R)/2;
    if(v[M].first>=x)R=M;
    else L=M+1;
  }
  return L;
}

int main(){
  while(1){
    cin>>n;
    if(!n)break;
    for(int i=0;i<n;i++)cin>>hp[i];
    cin>>m;
    for(int i=0;i<m;i++)
      cin>>name>>mp[i]>>target[i]>>damage[i];
    for(int i=0;i<D;i++)dpAll[i]=dpSin[i]=INF;
    dpAll[0]=dpSin[0]=0;
    for(int i=0;i<D;i++){
      if(dpAll[i]==INF)continue;
      for(int j=0;j<m;j++){
	if(target[j]!="All")continue;
	if(i+damage[j]<D)
	  dpAll[i+damage[j]]=min(dpAll[i+damage[j]],dpAll[i]+mp[j]);
	else
	  dpAll[D-1]=min(dpAll[D-1],dpAll[i]+mp[j]);
      }
    }
    for(int i=0;i<D;i++){
      if(dpSin[i]==INF)continue;
      for(int j=0;j<m;j++){
	if(target[j]!="Single")continue;
	if(i+damage[j]<D)
	  dpSin[i+damage[j]]=min(dpSin[i+damage[j]],dpSin[i]+mp[j]);
	else
	  dpSin[D-1]=min(dpSin[D-1],dpSin[i]+mp[j]);
      }
    }
    for(int i=0;i<D;i++)
      if(dpSin[i]!=INF)v.push_back(P(i,dpSin[i])),minv.push_back(0);
    int a=INF;
    for(int i=(int)v.size()-1;i>=0;i--){
      a=min(a,v[i].second);
      minv[i]=a;
    }
    ans=INF;
    for(int i=0;i<D;i++){
      if(dpAll[i]==INF)continue;
      cnt=dpAll[i];
      for(int j=0;j<n;j++){
	int k=hp[j]-i;
	cnt+=minv[bynary_search(k)];
      }
      ans=min(ans,cnt);
    }
    cout<<ans<<endl;
    v.clear();
    minv.clear();
  }
  return 0;
}

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

template<typename T> struct LiChaoTree {
    struct Line {
        T a, b;
        Line(T a, T b) : a(a), b(b) {}
        // f(x) = ax + b
        inline T f(T x) const { return a * x + b; }
        inline bool cmp(const Line &o, const T &x) const {
            return f(x) < o.f(x);
        }
    };
    vector<T> xs;
    vector<Line> seg;
    int sz; T INF;
    LiChaoTree(T MAX_INT, T INF) : INF(INF) {
        for (T i = 0; i <= MAX_INT; i++) xs.emplace_back(i);
        build();
    }
    LiChaoTree(const vector<T> &x, T INF) : xs(x), INF(INF) { build(); }
    void build() {
        sz = 1;
        while (sz < xs.size()) sz <<= 1;
        while (xs.size() < sz) xs.emplace_back(xs.back()+1);
        seg.assign(2*sz-1, Line(0, INF));
    }
    void update(Line &x, int k, int l, int r) {
        int m = (l + r) / 2;
        bool lef = x.cmp(seg[k], xs[l]), mid = x.cmp(seg[k], xs[m]);
        if (mid) swap(seg[k], x);
        if (r - l <= 1) return;
        else if (lef != mid) update(x, 2*k+1, l, m);
        else update(x, 2*k+2, m, r); 
    }
    void add_line(T a, T b) {
        Line l(a, b);
        update(l, 0, 0, sz);
    }
    // query : get min_value of f(xs[k])
    T query(int k) {
        const T x = xs[k];
        k += sz - 1;
        T ret = seg[k].f(x);
        while (k) {
            k = (k - 1) / 2; ret = min(ret, seg[k].f(x));
        }
        return ret;
    }
};

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n; cin >> n;
	long long c; cin >> c;
    vector<long long> h(n+1);
	for (int i = 0; i < n; i++) cin >> h[i+1];
	LiChaoTree<long long> lct(1e6, 1e18);
	vector<long long> dp(n+1, 0);
	for (int i = n; i > 0; i--) {
		lct.add_line(-2*h[i], dp[i]+h[i]*h[i]+c);
		dp[i-1] = lct.query(h[i-1]) + h[i-1] * h[i-1];
	}
	cout << dp[1] << endl;
	return 0;
}

Measured memory_bytes: 44392
#include <bits/stdc++.h>
using namespace std;
int main(){
    int N, Ali=0, Bob=0;
    cin >> N;
    vector<int> vec(N);
    for (int i=0; i<N; i++){
        cin >> vec.at(i);
    }
    for (int i=0; i<N; i++){
        sort(vec.begin(), vec.end());
        reverse(vec.begin(), vec.end());
        if (i%2 == 0) Ali += vec.at(i);
        else Bob += vec.at(i);
    }
    cout << Ali - Bob << endl;
    return 0;
}

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

using namespace std;

#define ar array
#define ll long long

const int MAX_N = 1e5 + 1;
const int MOD = 1e9 + 7;
const int INF = 1e9;
const ll LINF = 1e18;



void solve() {
    int n; cin >> n;
    ll ans = 0;
    for (int i = 1; i < n; i++) {
        for (int j = 1; j * j <= i; j++) {
            if (i % j == 0) {
                ans++;
                if (j * j != i) ans++;
            }
        }
    }
    cout << ans;
}

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

    int tc; tc = 1;
    for (int t = 1; t <= tc; t++) {
        // cout << "Case #" << t  << ": ";
        solve();
    }
}

Measured memory_bytes: 3632
package main

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

func main() {
	r := bufio.NewReader(os.Stdin)
	var n, m int
	fmt.Fscan(r, &n)
	fmt.Fscan(r, &m)

	homeworkDays := 0
	var a int
	for i := 0; i < m; i++ {
		fmt.Fscan(r, &a)
		homeworkDays += a
	}

	fmt.Println(max(-1, n-homeworkDays))
}

// Union-Find
type unionFind struct {
	d []int
}

func newUnionFind(n int) *unionFind {
	uf := new(unionFind)
	uf.d = make([]int, n)
	for i := 0; i < n; i++ {
		uf.d[i] = -1
	}
	return uf
}

func (uf *unionFind) find(x int) int {
	if uf.d[x] < 0 {
		return x
	}
	uf.d[x] = uf.find(uf.d[x])
	return uf.d[x]
}

func (uf *unionFind) unite(x, y int) bool {
	rootX := uf.find(x)
	rootY := uf.find(y)
	if rootX == rootY {
		return false
	}

	if uf.d[rootX] < uf.d[rootY] {
		uf.d[rootX] += uf.d[rootY]
		uf.d[rootY] = rootX
	} else {
		uf.d[rootY] += uf.d[rootX]
		uf.d[rootX] = rootY
	}

	return true
}

func (uf *unionFind) same(x, y int) bool {
	return uf.find(x) == uf.find(y)
}

func (uf *unionFind) size(x int) int {
	return -uf.d[uf.find(x)]
}

// mod combination
func modpow(a, n, mod int) int {
	res := 1
	for n > 0 {
		if n%2 != 0 {
			res = res * a % mod
		}
		a = a * a % mod
		n = n / 2
	}
	return res
}

func modcomb(n, a, mod int) int {
	x := 1
	y := 1
	for i := 0; i < a; i++ {
		x = x * (n - i)
		x %= mod
		y = y * (i + 1)
		y %= mod
	}
	return x * modpow(y, mod-2, mod) % mod
}

func modfactorial(n, mod int) int {
	result := 1
	for i := 1; i <= n; i++ {
		result = (result * i) % mod
	}
	return result
}

// Utility

func min(x, y int) int {
	if x < y {
		return x
	}
	return y
}

func max(x, y int) int {
	if x > y {
		return x
	}
	return y
}

func abs(x int) int {
	if x < 0 {
		return -x
	}
	return x
}

func primeFactor(x int) map[int]int {
	res := make(map[int]int)
	for i := 2; i*i <= x; i++ {
		for x%i == 0 {
			res[i]++
			x = x / i
		}
	}
	if x != 1 {
		res[x] = 1
	}
	return res
}

func divisor(x int) []int {
	res := make([]int, 0)
	for i := 1; i*i <= x; i++ {
		if x%i == 0 {
			res = append(res, i)
			if i != x/i {
				res = append(res, x/i)
			}
		}
	}
	return res
}

func gcd(x, y int) int {
	if y == 0 {
		return x
	}
	return gcd(y, x%y)
}

func lcm(x, y int) int {
	return x / gcd(x, y) * y
}

func reverseString(s string) string {
	r := []rune(s)
	for i, j := 0, len(r)-1; i < len(r)/2; i, j = i+1, j-1 {
		r[i], r[j] = r[j], r[i]
	}
	return string(r)
}

// Queue ...
type Queue []int

// pop ...
func (q *Queue) empty() bool {
	return len(*q) == 0
}

// push ...
func (q *Queue) push(i int) {
	*q = append(*q, i)
}

// pop ...
func (q *Queue) pop() (int, bool) {
	if q.empty() {
		return 0, false
	} else {
		res := (*q)[0]
		*q = (*q)[1:]
		return res, true
	}
}

// Stack ...
type Stack []int

// pop ...
func (s *Stack) empty() bool {
	return len(*s) == 0
}

// push ...
func (s *Stack) push(i int) {
	*s = append(*s, i)
}

// pop ...
func (s *Stack) pop() (int, bool) {
	if s.empty() {
		return 0, false
	} else {
		index := len(*s) - 1
		res := (*s)[index]
		*s = (*s)[:index]
		return res, true
	}
}


Measured memory_bytes: 1860
#include<bits/stdc++.h>
using namespace std;
typedef long long lld;
typedef pair<lld,lld> pr;
lld const mod = 1e9+7;

int main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  string s,s1,s2,temp;
  cin>>s;
  lld n= s.length();

  // cout<<n<<'\n';

  temp=s;
  lld f=0;
  reverse(temp.begin(),temp.end());
  if(s==temp)
  {
    s1 = s.substr(0,(n-1)/2 );
    temp = s1;
    reverse(temp.begin(),temp.end());

    // cout<<s1<<' '<<temp<<'\n';

    if(temp==s1)
    {
      s2 = s.substr((n+3)/2 -1,n);
      temp=s2;
      reverse(temp.begin(),temp.end());

      // cout<<s2<<' '<<temp<<'\n';

      if(temp==s2)
      {
        f=1;
      }
    }
  }
  if(f)
  {
    cout<<"Yes\n";
  }
  else
  {
    cout<<"No\n";
  }
}


Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cstring>
#include <string>
#include <vector>
#include <queue>
#include <numeric>
#include <functional>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <memory>
#include <thread>
#include <tuple>
#include <limits>
 
using namespace std;

int main()
{
	int arr[] = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
	int n; scanf("%d", &n);
	printf("%d", arr[--n]);
}

Measured memory_bytes: 128
#include <iostream>

int main() {
  int N;

  std::cin >> N;

  if (N == 1)
    std::cout << "Hello World" << std::endl;
  else {
    int A, B;
    std::cin >> A >> B;
    std::cout << (A + B) << std::endl;
  }

  return 0;
}


Measured memory_bytes: 256
from queue import Queue

n = int(input())
if n <= 10:
    print(n)
    exit()
n -= 9
que = Queue()
for i in range(1, 10):
    que.put(i)

while True:
    i = str(que.get())
    last = int(i[-1])
    if last != 0:
        if n == 1:
            print(int(i+str(last-1)))
            break
        que.put(int(i+str(last-1)))
        n -= 1
    if n == 1:
        print(int(i+str(last)))
        break
    que.put(int(i+str(last)))
    n -= 1
    if last != 9:
        if n == 1:
            print(int(i+str(last+1)))
            break
        que.put(int(i+str(last+1)))
        n -= 1


    
    
        
         

Measured memory_bytes: 12004
import java.io.PrintWriter
import java.util.*

fun next() = readLine()!!
fun nextInt() = next().toInt()
fun nextLong() = next().toLong()
fun nextDouble() = next().toDouble()
fun nextList() = next().split(" ")
fun nextIntList() = nextList().map(String::toInt)
fun nextLongList() = nextList().map(String::toLong)
fun nextDoubleList() = nextList().map(String::toDouble)

val pw = PrintWriter(System.out)
fun print(s: Any = "") = pw.print(s)
fun println(s: Any = "") = pw.println(s)

fun <T> Iterable<T>.join(separator: CharSequence = ", ", prefix: CharSequence = "", postfix: CharSequence = "") = joinToString(separator, prefix, postfix)

fun main(args: Array<String>) {
    main()
    pw.flush()
}

fun main() {
    val Q = nextInt()
    val sieve = Sieve(10000000000L)
    val answers = sieve.primes.filter { sieve.isPrime((it + 1) / 2) }
    val sums = IntArray(100001)
    for (i in 1..100000) {
        sums[i] = sums[i - 1]
        if (answers.contains(i)) sums[i]++
    }
    repeat(Q) {
        val (l, r) = nextIntList()
        println(sums[r] - sums[l - 1])
    }
}

class Sieve(max: Long) {
    private val N = Math.sqrt(max.toDouble()).toInt()
    val primes: Array<Int>

    init {
        val que = ArrayDeque<Int>()
        val sieve = BooleanArray(N + 1) { true }
        sieve[0] = false
        sieve[1] = false
        for (i in 2..N) {
            if (!sieve[i]) continue
            que.push(i)
            for (j in (i * 2)..N step i) {
                sieve[j] = false
            }
        }
        primes = que.toTypedArray()
    }

    fun isPrime(v: Int) = primes.contains(v)
}

Measured memory_bytes: 57168
#include<bits/stdc++.h>
#include<stdio.h>
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
using namespace std;


#define ll                  long long
#define scl(n)              scanf("%lld",&n)
#define scll(n, m)              scanf("%lld%lld",&n, &m)
#define scc(c)	            scanf("%c",&c)
#define fr(i,n)             for (ll i=0;i<n;i++)
#define fr1(i,n)            for(ll i=1;i<=n;i++)
#define pfl(x)              printf("%lld\n",x)
#define pb                  push_back
#define debug               cout<<"I am here"<<endl;
#define pno                 cout<<"NO"<<endl
#define pys                 cout<<"YES"<<endl
#define tcas(i,t)           for(ll i=1;i<=t;i++)


#define N 100006

ll dp[N][3],task[3][N], vis[N][3] , n;

ll solve(ll pos , ll last )
{
    if(pos == n+1 )return 0;

    if(vis[pos ][last] )return dp[pos ][last];
    vis[pos][last]=1;

    ll best=0;
    fr(i, 3)
    {
        if( i != last)
        {
            best=max(best , task[i][pos]+ solve(pos+1 , i) );
        }
    }

    return dp[pos ][last]=best;
}

int main()
{
    ll m,b,c,d,i,j,k,x,y,z,l,q,r;

    ll cnt=0,cn=0,ans=0,sum=0 ;
    cin>>n;

    fr1(i, n)scll(task[0][i] ,task[1][i]) , scl(task[2][i] ) ;


    ans=max({ solve(1, 0)  , solve(1, 1) , solve(1, 2 )} );
    cout<<ans;
return 0;
}

///***************Before submit*****************

///    ****Please check all base case output***
///    *check for integer overflow,array bounds
///    *check for n=1




Measured memory_bytes: 14464
N=int(input())
A=list(map(int,input().split()))
count=0
for i in range(N-1):
    minj=i
    for j in range(i+1,N):
        if A[minj]>A[j]:
            minj=j
    if i<minj:
        A[minj],A[i]=A[i],A[minj]
        count+=1
for i in range(N):
    if i<N-1:
        print(A[i],end=' ')
    else:
        print(A[i])
print(count)


Measured memory_bytes: 5612
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i, n) for(int i=0;i<(int)n;i++)
struct edge{int from, to;};

int main(){
    ll a,b;
    cin >> a >> b;
    ll ans;
    for(ll i=a;i<=a*b;i+=a){
        if(i%b==0){
            ans=i;
            break;
        }
    }
    cout << ans << endl;
    return 0;
}

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

#define inRange(x,a,b) (a <= x && x < b)

int dx[13] = {1,0,0,1,1,0,-1,-1, 0,1,-1, 1, 1};
int dy[13] = {0,1,0,1,0,1, 1, 0,-1,1, 1,-1, 1};
int dz[13] = {0,0,1,0,1,1, 0, 1, 1,1, 1, 1,-1};

int main(){
    int n, m, p;
    while(cin >> n >> m >> p, n+m+p){
        int peg[n][n][n];
        memset(peg, -1, sizeof(peg));

        int x[p], y[p];
        for(int i = 0; i < p; i++)  cin >> x[i] >> y[i], x[i]--, y[i]--;

        string ans = "Draw";
        int turn = -1;
        
        for(int i = 0; i < p; i++){
            int z;
            for(z = 0;;z++) if(peg[x[i]][y[i]][z] == -1)    break;
            peg[x[i]][y[i]][z] = i%2;

            for(int k = 0; k < 13; k++){
                int cont = 1;
                
                int zx = x[i]+dx[k], zy = y[i]+dy[k], zz = z+dz[k];
                while(inRange(zx, 0, n) && inRange(zy, 0, n) && inRange(zz, 0, n) && peg[zx][zy][zz] == peg[x[i]][y[i]][z]){
                    cont++;
                    zx += dx[k], zy += dy[k], zz += dz[k];
                }
                
                zx = x[i]-dx[k], zy = y[i]-dy[k], zz = z-dz[k];
                while(inRange(zx, 0, n) && inRange(zy, 0, n) && inRange(zz, 0, n) && peg[zx][zy][zz] == peg[x[i]][y[i]][z]){
                    cont++;
                    zx -= dx[k], zy -= dy[k], zz -= dz[k];
                }

                if(cont >= m){
                    if(i % 2 == 0)  ans = "Black";
                    else            ans = "White";
                    turn = i+1;
                    break;
                }
            }

            if(ans != "Draw")   break;
        }

        if(ans != "Draw")   cout << ans << " " << turn << endl;
        else                cout << ans << endl;
    }
    return 0;
}


Measured memory_bytes: 3188
from math import*
x,n=map(int,input().split())
arr=list(map(int,input().split()))
if len(arr)==0:
	print(x)
else:
	arr.sort()
	i=arr[0]-1
	dif=[]
	abdif=[]
	while i<arr[-1]+2:
		if i not in arr:
			dif.append(x-i)
			abdif.append(int(fabs(x-i)))
		i+=1
	#print(dif)
	#print(abdif)
	ans=[]
	for i in range(len(abdif)):
		if abdif[i]==min(abdif):	
			if dif[i]>=0:
				ans.append(x-dif[i])
			else:
				ans.append(x-dif[i])
	#print(ans)
	print(min(ans))


Measured memory_bytes: 62996
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;

#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define For(i, a) for (int i=0; i<(a); i++)
#define FORR(i,a,b) for (int i = (b)-1; i >= a; i--)
#define Forr(i,a) for (int i = (a)-1; i >= 0; i--)

#define deb(...) cerr << "[" << #__VA_ARGS__ << "] : [", DBG(__VA_ARGS__) 
void DBG() { cerr << "]\n";}
template<typename T, typename ...Args> void DBG(T first, Args... args){
cerr << first; if(sizeof...(args))cerr<<", "; DBG(args...); }

#define int ll
#define pb(x) push_back(x)
#define INF (int)1e17
#define PI 3.14159265358979323846
 
int del_x[4] = {-1, 1, 0, 0};
int del_y[4] = {0, 0, 1, -1};
int XX[8] = {-1, -1, -1, 0, 1, 1, 1, 0};
int YY[8] = {-1, 0, 1, 1, 1, 0, -1, -1};


void solve(){
	int x,k,d; cin >> x >> k >> d;
	if(x>=0){
		int n = x/d;
		if(n>k)n=k;
		int rem = k-n;
		int final = x-n*d;
		if(n+1<=k && abs(final-d)<final){
			final = abs(x-n*d-d);
			rem--;
		}
		if(rem&1){
			cout << min(abs(final-d),abs(final+d))<<"\n";
		}
		else{
			cout << final <<"\n";
		}
	}
	else{
		int n = abs(x)/d;
		if(n>k)n=k;
		int rem = k-n;
		int final = x+n*d;
		if(n+1<=k && abs(final+d)<abs(final)){
			final = abs(x+n*d+d);
			rem--;
		}
		if(rem&1){
			cout << min(abs(final-d),abs(final+d))<<"\n";
		}
		else{
			cout << abs(final) <<"\n";
		}
	}
}

int32_t main(){ 
	ios_base:: sync_with_stdio(false); 
	cin.tie(0); 
	int t=1;
	//cin >> t;
	for(int tt=1;tt<=t;tt++){
		//cout << "Case #"<<tt<<": ";
		solve();
	}
}

Measured memory_bytes: 3572