akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef signed long long ll;

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------


int N,S;
const ll mo=998244353;
ll dp[3030][3030];

void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>N>>S;
	dp[0][0]=1;
	FOR(i,N) {
		cin>>x;
		FOR(j,S+1) {
			// not
			(dp[i+1][j]+=dp[i][j]*2)%=mo;
			if(j+x<=S) (dp[i+1][j+x]+=dp[i][j])%=mo;
		}
	}
	cout<<dp[N][S]<<endl;
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	cout.tie(0); solve(); return 0;
}


Measured memory_bytes: 74636
# じょえチャンネルおもしろいよ～～～
# https://www.youtube.com/channel/UCRXsI3FL_kvaVL9zoolBfbQ

n=int(input())
s=[input()for _ in range(n)]
print("AC x",s.count("AC"))
print("WA x",s.count("WA"))
print("TLE x",s.count("TLE"))
print("RE x",s.count("RE"))

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

struct WeightedUnionFind{
  vector< pair<int, long long> > data;
  WeightedUnionFind(int n) : data(n, pair<int,long long>(-1,0LL)) {}
  bool unite(int x, int y, long long w){//weight(y)-weight(x) = w;
    int x_ = find(x), y_ = find(y);
    if(x_ == y_) return true;
    if(data[y_].first < data[x_].first){
      swap(x_,y_);
      swap(x,y);
      w *= -1LL;
    }
    data[x_].first += data[y_].first;//高さを更新
    data[y_].first = x_;//親を更新
    data[y_].second += w + rel_weight(x) - rel_weight(y);
    return true;
  }
  bool same(int x, int y){ return find(x) == find(y); }
  int find(int x){
    if(data[x].first < 0) return x;
    int p = find(data[x].first);
    data[x].second += data[data[x].first].second;
    data[x].first = p;
    return data[x].first;
  }
  long long rel_weight(int x){
    return data[x].second;
  }
};

int main(){
  int n, q;
  cin >> n >> q;
  WeightedUnionFind wuf(n);
  while(q--){
    int t, x, y, z;
    cin >> t >> x >> y;
    if(t){
      if(wuf.same(x,y)) cout << wuf.rel_weight(y) - wuf.rel_weight(x) << endl;
      else cout << "?" << endl;
      continue;
    }
    cin >> z;
    wuf.unite(x,y,z);
  }
}



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

using namespace std;
#define ll long long
const int N=1e5+5;
const int mod=1e9+7;
ll qpow(ll a,ll b)
{
    ll res=1;
    while(b)
    {
        if(b&1)
            res=res*a%mod;
        b>>=1;
        a=a*a%mod;
    }
    return res;
}
int main()
{
    ios::sync_with_stdio(false);
    int n;
    while(cin>>n)
    {
        int a[N];
        for(int i=1;i<=n;i++)
            cin>>a[i];
        int b[N];
        for(int i=0;i<=n;i++)
            b[i]=0;
        for(int i=1;i<=n;i++)
        {
            b[a[i]]++;
        }
        int cnt=0;
        for(int i=0;i<=n;i++)
        {
            if(b[i]&1)
                cnt++;
        }
        if((n%2&&cnt==1&&b[0]==1)||(n%2==0&&cnt==0))
        {
            cout<<qpow(2,n/2)%mod<<endl;
        }
        else
            cout<<0<<endl;
    }
    return 0;
}
//1 2 4 8 16 30 60 96


Measured memory_bytes: 1024
#include <iostream>
#include <string>

using namespace std;
int main(int argc, char* argv[])
{
	string S;
	cin>>S;
	int i;
	for (i=0;i<S.length();i++){
		if (S[i]==','){
			S[i]=' ';
		}
	}
	cout<<S.c_str()<<endl;
	return 0;
}

Measured memory_bytes: 764
#include <stdio.h>

void Transfer(int& A, int& B, int& C)
{
    A -= B;

    C -= A;

    if (C < 0) printf("%d\n", 0);
    else { printf("%d\n", C); }
}


int main()
{
    int A;
    int B;
    int C;

    scanf("%d", &A);
    scanf("%d", &B);
    scanf("%d", &C);

    Transfer(A, B, C);

    return 0;
}

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

using namespace std;

#define roop(a,b) for(int a=0;a<b;++a)

int main(){
	int n,k,res = 0,h;
	cin >> n >> k;
	roop(i,n){
		cin >> h;
		if(h >= k)res++;
	}
	cout << res << endl;
}

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

ll gcd(ll a,ll b){
  ll r;
  while ((r=a%b)){a=b;b=r;}
  return b;
}

int main(){

  cout << fixed << setprecision(10);

  double a,b,x; cin >> a >> b >> x;
  double ans;
  if (x <= a*a*b/2) {ans = atan(a*b*b/(2*x))*180/3.14159265358979323846;}
  else {ans = atan((2*b-(2*x)/(a*a))/a)*180/3.14159265358979323846;}
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 512
import java.io.*;
import java.util.Scanner;
import java.util.ArrayList;
import java.util.Arrays;

public class Main {

  public static void main(String[] args) {

    try {

      // 標準入力受け取り
      Scanner scan = new Scanner(System.in);
      ArrayList<Integer> strs = new ArrayList<Integer>();

      while (scan.hasNext()) {
        strs.add(scan.nextInt());
      }

      // 変数へ代入
      int[][] bingo = new int[3][3]; // ビンゴ表

      String jadge = "No"; // 判定

      for (int x = 0; x < 9; x++) {
        for (int y = 10; y < strs.size(); y++) {
          bingo[x / 3][x % 3] = 0;
          // 穴が開いた場合
          if (strs.get(x) == strs.get(y)) {
            bingo[x / 3][x % 3] = 1;
            break;
          }
        }
      }

      int[] verticalSum = new int[3]; // 縦のチェック値
      int sideSum = 0; // 横のチェック値
      int upperRight = 0; // 斜め(左下から右上)のチェック値
      int lowerRight = 0; // 斜め(左上から右下)のチェック値

      // ビンゴ有無チェック
      for (int i = 0; i < 3; i++) {
        for (int j = 0; j < 3; j++) {

          verticalSum[j] += bingo[i][j];
          sideSum += bingo[i][j];
          // 縦・横のビンゴチェック
          if (sideSum == 3 || verticalSum[j] == 3) {

            jadge = "Yes";
            System.out.println(jadge);
            return;
          }
        }

        upperRight += bingo[i][i];
        lowerRight += bingo[i][2 - i];
        // 斜めのビンゴチェック
        if (upperRight == 3 || lowerRight == 3) {

          jadge = "Yes";
          System.out.println(jadge);
          return;
        }
        // 横のチェック値をリセット
        sideSum = 0;
      }

      System.out.println(jadge);
    } catch (Exception e) {

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

Measured memory_bytes: 21972
#include<stdio.h>
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<string.h>
using namespace std;

typedef long long LL;
typedef vector<int> VI;

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define EACH(i,c) for(__typeof((c).begin()) i=(c).begin(),i##_end=(c).end();i!=i##_end;++i)
#define eprintf(...) fprintf(stderr, __VA_ARGS__)

template<class T> inline void amin(T &x, const T &y) { if (y<x) x=y; }
template<class T> inline void amax(T &x, const T &y) { if (x<y) x=y; }
template<class Iter> void rprintf(const char *fmt, Iter begin, Iter end) {
    for (bool sp=0; begin!=end; ++begin) { if (sp) putchar(' '); else sp = true; printf(fmt, *begin); }
    putchar('\n');
}

int N;
int A[200011];

void MAIN() {
    scanf("%d", &N);
    REP (i, N) scanf("%d", A+i);

    LL ans = 0;
    int x = 0;
    int left = 0;
    REP (i, N) {
	while (left < i && (x & A[i])) {
	    x ^= A[left];
	    left++;
	}

	x ^= A[i];
	ans += i-left+1;
    }

//    int ans = 0;
//    REP (i, N) {
//	int x = 0, s = 0, o = 0;
//	for (int j=i; j<N; j++) {
//	    x ^= A[j];
//	    s += A[j];
//	    if (o & A[j]) break;
//	    o |= A[j];
//	    if (x == s) {
//		ans++;
//		eprintf("%d %d, %d %d %d\n", i, j, x, s, o);
//	    }
//	}
//    }
//
    printf("%lld\n", ans);
}


int main() {
    int TC = 1;
//    scanf("%d", &TC);
    REP (tc, TC) MAIN();
    return 0;
}



Measured memory_bytes: 1024
#include <iostream>
#include <iomanip>
#include <cmath>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#include <set>
using namespace std;

int main(){
    int Q;
    cin >> Q;
    long long B = 0;
    long long cnt = 0;
    long long sm0 = 0;
    long long sm1 = 0;

    priority_queue<long long> pq0;
    priority_queue<long long, vector<long long>, greater<long long>> pq1;

    for(int i=0; i<Q; i++){
        int kind;
        cin >> kind;
        if(kind == 1){
            long long a, b;
            cin >> a >> b;
            B += b;

            if(i == 0){
                pq0.push(a);
                sm0 += a;
                continue;
            }

            long long tp0 = pq0.top();

            if(a <= tp0){
                pq0.push(a);
                sm0 += a;
            }else{
                pq1.push(a);
                sm1 += a;
            }
            if(pq0.size() >= pq1.size() + 2){
                long long a0 = pq0.top();
                pq0.pop();
                pq1.push(a0);
                sm0 -= a0;
                sm1 += a0;
            }else if(pq0.size() < pq1.size()){
                long long a0 = pq1.top();
                pq1.pop();
                pq0.push(a0);
                sm0 += a0;
                sm1 -= a0;
            }
        }else{
            long long med = pq0.top();
            long long ans = med * (pq0.size() - pq1.size()) + B;
            ans += sm1 - sm0;
            cout << med << " " << ans << endl;
        }
    }

    return 0;
}

Measured memory_bytes: 3828
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n;
    cin >> n;
    string s;
    int p;
    pair<pair<string,int>,int> pr[200];
    for( int i=0; i<n; i++){
        cin >> s >> p;
        pr[i] = make_pair(make_pair(s,-p),i); // negative for top to down order
    }
    sort(pr,pr+n);
    for( int i=0; i<n; i++){
        cout << pr[i].second+1 << endl;
    }
}




Measured memory_bytes: 256
#include<stdio.h>

int main(){
  int n;
  int a[200000];
  int array[400000];

  scanf("%d", &n);
  for(int i=0; i<n; ++i){
     scanf("%d", &a[i]);
  }
  int f = 200000;
  int b = f+1;
  for(int i=0; i<n; ++i){
    if(i%2 == (n-1)%2){
      array[f--]=a[i];
    }else{
      array[b++]=a[i];
    }
  }

  for(int i=f+1; i<b; ++i){
    printf("%d ", array[i]);
  }
  return 0;
}


Measured memory_bytes: 3712
#include <bits/stdc++.h>
using namespace std;
int main(){
	int n;
	string s;
	cin >> n >> s;
	int count=0;
	int ans=0;
	for(int i=0;i<n;i++){
		if(s[i]=='I'){
			count++;
		}else{
			count--;
		}
		if(count>ans){
			ans=count;
		}
	}
	cout << ans << endl;
}


Measured memory_bytes: 256
/* 
	Author: ankrypt
*/


#include <bits/stdc++.h>

using namespace std;

#define MOD 1000000007
#define ll long long int
#define u64 unsigned long long int

ll N1, N2, N3, N4;
ll mp[15];

int main() {
	scanf("%lld %lld %lld %lld", &N1, &N2, &N3, &N4);
	mp[N1]++;
	mp[N2]++;
	mp[N3]++;
	mp[N4]++;
	if(mp[1] && mp[9] && mp[7] && mp[4]) {
		printf("YES\n");
	}
	else {
		printf("NO\n");
	}
	return 0;
}
/*
	Powered by Buggy Plugin
*/


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

int main() {
	
	int n;
	string s;
	cin >> n >> s;
	for(int i = 0; i < s.size(); i++){
		s[i] += n;
		if(s[i] > 'Z') s[i] -= 'Z' - 'A' + 1;
	}
	cout << s << endl;
	return 0;
}

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

int main() {
  int N;
  
  cin >> N;
  
  vector<int> moto(N);
  vector<int> ato(N);
  
  for(int i = 0; i < N; i++){
    cin >> moto.at(i);
    ato.at(moto.at(i)-1) = i;
  }
  
  for(int i = 0; i < N; i++){
    if(i==(N-1)){
      cout<<ato.at(i)+1;
      break;
    }      
    cout<< ato.at(i) +1 << " ";
  } 
}

Measured memory_bytes: 1536
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i,m,n) for(ll i = (m); i < (n); i++)
#define all(v) v.begin(), v.end()
#define print(x) cout << (x) << endl

int main() {
    ll X,cnt=0;
    cin >> X;
    for(ll i = 100; i<X; i += i/100){
        cnt++;
    }
    
    cout << cnt << endl;
    return 0;
}


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

typedef long long ll;
#define pii pair<int , int>
#define _FastIO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define MAXX 1005

int a , b , c;
string s;

int main()
{
    _FastIO;
    cin >> a >> b >> c;
    int n = a / c;
    int m = b / c;
    if(a % c == 0)
        n--;
    cout << m - n << endl;
    return 0;
}


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

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll n;
	cin>>n;
	vector<ll>v(n+1);
	v[0]=0;
	for(ll i=1;i<n+1;i++) v[i]=1000000;
	for(ll i=0;i<n;i++){
		for(ll j=0;j<8;j++){
			if(i+pow(9,j)<=n){
				v[i+pow(9,j)]=min(v[i]+1,v[i+pow(9,j)]);
			}
			if(i+pow(6,j)<=n){
				v[i+pow(6,j)]=min(v[i]+1,v[i+pow(6,j)]);
			}
		}
		v[i+1]=min(v[i]+1,v[i+1]);
	}
	cout<<v[n]<<endl;
	return 0;
}


Measured memory_bytes: 1024
from bisect import bisect_left
from itertools import accumulate
N,M,*A = map(int, open(0).read().split())
A.sort()
B = list(accumulate(A[::-1]))
l = -1
r = 10**9
while l+1<r:
  s = (l+r)//2
  cnt = 0
  for c in A:
    i = bisect_left(A,s-c)
    cnt += N-i
  if cnt>=M:
    l = s
  else:
    r = s
ans = 0
for c in A:
  i = bisect_left(A,r-c)
  M -= N-i
  if i<N:
    ans += B[N-1-i]+c*(N-i)
ans += M*l
print(ans)

Measured memory_bytes: 14620
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define repl(i,l,r) for(ll i=(l);i<(r);i++)
#define per(i,n) for(ll i=n-1;i>=0;i--)
#define lper(i,r,l) for(ll i=r-1;i>=l;i--)
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define ins insert
#define all(x) (x).begin(),(x).end()
#define CST(x) cout<<fixed<<setprecision(x)
using ll=long long;
using vl=vector<ll>;
using vvl=vector<vector<ll>>;
using pl=pair<ll,ll>;
const ll MOD=1000000007;
const ll MOD9=998244353;
const int inf=1e9+10;
const ll INF=4e18;
const ll dy[4]={1,0,-1,0};
const ll dx[4]={0,-1,0,1};
ll modfac(ll a){
    ll ans=1;
    while(a>1){
        ans*=a;
        ans%=1000000007;
        a--;
    }
    return ans;
}
ll modinv(ll a,ll m) {
    ll b = m, u = 1, v = 0;
    while (b) {
        ll t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m; 
    if (u < 0) u += m;
    return u;
}
struct UnionFind {
    vector<int> par;
    
    UnionFind(int n) : par(n, -1) {}

    int root(int x) {
        if (par[x] < 0) return x;
        else return par[x] = root(par[x]);
    }
    
    bool same(int x, int y) {
        return root(x) == root(y);
    }
    
    bool merge(int x, int y) {
        x = root(x); y = root(y);
        if (x == y) return false;
        if (par[x] > par[y]) swap(x, y);
        par[x] += par[y];
        par[y] = x;
        return true;
    }
    
    int size(int x) {
        return -par[root(x)];
    }
};
ll modpow(ll a, ll n, ll mod) {
    ll res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
int main(){
    ll n;cin >> n;
    vector<vector<pair<ll,ll>>> g(n);
    rep(i,n-1){
        ll a,b,c;cin >> a >> b >>c;
        a--;b--;
        g[a].pb(mp(b,c));
        g[b].pb(mp(a,c));
    }
    vl dist(n,-1);
    queue<ll> que;
    ll q,s;cin >> q >> s;s--;
    dist[s]=0;
    que.push(s);
    while(!que.empty()){
        ll v=que.front();
        que.pop();
        for(auto nv:g[v]){
            if(dist[nv.fi]!=-1)continue;
            dist[nv.fi]=dist[v]+nv.se;
            que.push(nv.fi);
        }
    }
    rep(i,q){
        ll a,b;cin >> a >> b;
        a--;b--;
        cout << dist[a]+dist[b] <<endl;
    }
}

Measured memory_bytes: 10880
#include<bits/stdc++.h>
using namespace std;
#define ll long long 
#define mod 1000000007
vector<int>graph[100005];
double dp[3005][3005];
double solve(double a[],int n)
{
    int i,j;
    int x=(n+1)/2;
    for(i=0;i<=x;i++)
    dp[0][i]=0.0;
    for(i=0;i<=n;i++)
    dp[i][0]=1.0;
    dp[0][0]=1.0;
    for(i=1;i<=n;i++)
    {
        for(j=1;j<=x;j++)
        {
            dp[i][j]=a[i]*dp[i-1][j-1]+(1-a[i])*dp[i-1][j];
        }
    }
    /*for(i=0;i<=n;i++)
    {
        for(j=0;j<=x;j++)
        {
            cout<<dp[i][j]<<" ";
        }
        cout<<"\n";
    }*/
    return dp[n][x];
}
int main() {
    int n,i;
    cin>>n;
    double a[3005];
    for(i=1;i<=n;i++)
    cin>>a[i];
    memset(dp,-1,sizeof(dp));
    double k=solve(a,n);
    cout<<fixed<<setprecision(10)<<k<<"\n";
	return 0;
}

Measured memory_bytes: 73216
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const ll MOD = 1e9 + 7;
vector<P> G[100000];
int color[100000];
void dfs(int v, int p, int k, int c) {
	for (P e : G[v]) {
		if (e.first == p) continue;
		color[e.second] = (c + 1) % k;
		dfs(e.first, v, k, color[e.second]);
		(c += 1) %= k;
	}
}
int main() {
	int N;
	cin >> N;
	for (int i = 0; i < N - 1; i++) {
		int a, b;
		cin >> a >> b;
		a--; b--;
		G[a].emplace_back(b, i);
		G[b].emplace_back(a, i);
	}
	int K = 0;
	for (int i = 0; i < N; i++) {
		K = max(K, (int)G[i].size());
	}
	dfs(0, -1, K, 0);
	cout << K << endl;
	for (int i = 0; i < N - 1; i++) {
		cout << color[i] + 1 << endl;
	}
}


Measured memory_bytes: 8448
let divisor a b =
  let i = a / b in
  let q = a mod b in
  let f = (float_of_int a)/. (float_of_int b) in
  print_string ((string_of_int i)^" "^(string_of_int q)^" ");
  Printf.printf "%.10f\n" f

let f s = Scanf.sscanf s "%d %d" divisor ;;
f (read_line ()) ;;


Measured memory_bytes: 2460
#include <iostream>
#include <bits/stdc++.h>
#include <time.h>
#include <sys/timeb.h>
#include <cstdio>
#include <sys/time.h>

using namespace std;
#define ll long long
#define uint unsigned int
#define ulong unsigned long long int

template<typename T> bool InRange(T t, T l, T r){ return l <= t && t < r; }

int main(){
	
	string S,T;
	cin >> S >> T;
	
	int cnts[26];
	int cntt[26];
	for(int i=0;i<26;i++) cnts[i] = cntt[i] = 0;
	
	for(int i=0;i<S.length();i++){
		cnts[S[i] - 'a']++;
		cntt[T[i] - 'a']++;
	}
	
	sort(cnts, cnts + 26);
	sort(cntt, cntt + 26);
	for(int i=0;i<26;i++) if(cnts[i] != cntt[i]){
//cerr << "i:" << i << " cs:ct " << cnts[i] << "," << cntt[i] << endl;
		cout << "No" << endl;
		return 0;
	}
	cout << "Yes" << endl;
	
    return 0;
}

Measured memory_bytes: 776
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define x first
#define y second
typedef pair<int, int> pii;
typedef long long ll;
const int MOD = 1000000007;
const int N = 2 * 100000 + 1;
const ll oo = 2e18;
const int LOGN = 62;
int n, a[N];
ll k, dp[N][LOGN];
vector<int> g[N];
vector<ll> ans;

int main() {
  cin >> n >> k;
  for (int i = 0; i < n; ++i)scanf("%d", a + i);
  for (int i = 0; i < n; ++i)g[a[i]].push_back(i);
  for (int i = 0; i < n; ++i) {
    auto it = ++lower_bound(g[a[i]].begin(), g[a[i]].end(), i);
    if (it == g[a[i]].end())it = g[a[i]].begin();
    int dist = (*it > i ? *it - i : n - 1 - i + *it + 1);
    dp[i][0] = dist + 1;
   // cout << i << " " << dp[i][0] << endl;
  }
  for (ll i = 1; i < LOGN; ++i)
    for (int u = 0 ; u  < n ; ++u) {
      ll ds = dp[u][i - 1];
      int nxtIdx = (dp[u][i - 1] + u) % n;
      dp[u][i] = min(oo, ds + dp[nxtIdx][i - 1]);
    }
  ll idx = 0;
  while (idx < n * k) {
    bool add = true;
    for (ll i = LOGN - 1; i >= 0 ; --i) {
      ll realIdx = idx % n;
      ll nxt = dp[realIdx][i];
      if (nxt + idx <= n * k) {
        idx = nxt + idx;
        add = false;
      }
    }
    if (add && idx < n*k) {
      ans.push_back(idx);
      idx++;
    }
  }
  for (int i = 0; i < ans.size(); ++i) {
    if (i)printf(" ");
    printf("%d", a[ans[i] % n]);
  }
  puts("");
  return 0;
}

Measured memory_bytes: 111732
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <cstring>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <list>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <unordered_set>
#include <unordered_map>
#include <array>
#include <cassert>
#include <bitset>
using namespace std;
using LL = long long;

LL H, N;

LL dp[12345][1 << 3];
bool cell[4][12345] = {};

int main(void)
{
	cin >> H >> N;
	for (int i = 0; i < N; ++i)
	{
		int x, y;
		cin >> x >> y;
		cell[x][y] = true;
	}
	for (int i = 0; i < 4; ++i)cell[i][H] = true;
	for (int X = 0; X <= H + 114; ++X)
	{
		for (int i = 0; i < (1 << 3); ++i)
		{
			dp[X][i] = -114514810;
		}
	}
	dp[0][0] = 0;
	for (int i = 1; i <= H; ++i)
	{
		for (int S = 0; S < (1 << 3); ++S)
		{
			for (int T = 0; T < (1 << 3); ++T)
			{
				bool tmp[4][2] = {};
				for (int j = 0; j < 4; ++j)
				{
					tmp[j][0] = cell[j][i - 1];
					tmp[j][1] = cell[j][i];
				}
				int cost = 0;
				if (S & (1 << 0))
				{
					++cost;
					if (tmp[0][0] || tmp[0][1] || tmp[1][0] || tmp[1][1])
					{
						//??????
						continue;
					}
					tmp[0][0] = tmp[0][1] = tmp[1][0] = tmp[1][1] = true;
				}
				if (S & (1 << 1))
				{
					++cost;
					if (tmp[1][0] || tmp[1][1] || tmp[2][0] || tmp[2][1])
					{
						//??????
						continue;
					}
					tmp[1][0] = tmp[1][1] = tmp[2][0] = tmp[2][1] = true;
				}
				if (S & (1 << 2))
				{
					++cost;
					if (tmp[2][0] || tmp[2][1] || tmp[3][0] || tmp[3][1])
					{
						//??????
						continue;
					}
					tmp[2][0] = tmp[2][1] = tmp[3][0] = tmp[3][1] = true;
				}
				if (T & (1 << 0))
				{
					if (tmp[0][0] || tmp[1][0])
					{
						//??????
						continue;
					}
					tmp[0][0] = tmp[1][0] = true;
				}
				if (T & (1 << 1))
				{
					if (tmp[1][0] || tmp[2][0])
					{
						//??????
						continue;
					}
					tmp[1][0] = tmp[2][0] = true;
				}
				if (T & (1 << 2))
				{
					if (tmp[2][0] || tmp[3][0])
					{
						//??????
						continue;
					}
					tmp[2][0] = tmp[3][0] = true;
				}
				dp[i][S] = max(dp[i][S], dp[i - 1][T] + cost);
			}
		}
	}
	cout << dp[H][0] << endl;
	return 0;
}

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

using namespace std;

class Node {
public:
	int key;
	Node *left;
	Node *right;

	Node(int key) {
		this->key = key;
		left = right = NULL;
	}
};

Node* insert(Node *pRoot,Node *z) {
	Node *y = NULL;
	Node *x = pRoot;

	while (x != NULL) {
		y = x;
		if (z->key < x->key) {
			x = x->left;
		}
		else {
			x = x->right;
		}
	}

	if (y == NULL) {
		pRoot = z;
	}
	else if (z->key < y->key) {
		y->left = z;
	}
	else {
		y->right = z;
	}

	return pRoot;
}

void printInOrder(Node *pCur) {

	if (pCur == NULL) {
		return;
	}
	printInOrder(pCur->left);
	cout << " " << pCur->key;
	printInOrder(pCur->right);
}

void printPreOrder(Node *pCur) {

	if (pCur == NULL) {
		return;
	}
	cout << " " << pCur->key;
	printPreOrder(pCur->left);
	printPreOrder(pCur->right);
}

void freeTree(Node *p) {

	if (p == NULL) {
		return;
	}
	if (p->left != NULL) {
		p = p->left;
	}
	if (p->right != NULL) {
		p = p->right;
	}

	delete p;
	p = NULL;
}

bool findKey(Node *pCur, int key) {

	while (pCur != NULL) {
		if (key < pCur->key) {
			pCur = pCur->left;
		}
		else if (key > pCur->key) {
			pCur = pCur->right;
		}
		else {
			return true;
		}
	}
	return false;
}

int main() {
	int m, z;
	string cmd;
	Node *pRoot = NULL;

	cin >> m;
	for (int i = 0; i < m; ++i) {
		cin >> cmd;
		if (cmd == "insert") {
			cin >> z;
			Node *pNode = new Node(z);
			pRoot = insert(pRoot, pNode);
		}
		else if (cmd == "find") {
			cin >> z;
			if (findKey(pRoot, z)) {
				cout << "yes" << endl;
			}
			else {
				cout << "no" << endl;
			}
		}
		else {
			printInOrder(pRoot);
			cout << endl;
			printPreOrder(pRoot);
			cout << endl;
		}
	}
	freeTree(pRoot);

	return 0;
}


Measured memory_bytes: 15580
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<map>
#include<set>
#include<utility>
#include<cmath>
#include<limits.h>
using namespace std;

int main(){
    long long N;
    cin >> N;
    long long ans = LLONG_MAX;
    for(int i = 1; i <= sqrt(N); i++){
        if(N % i == 0){
            ans = min(ans, (N /i - 1) + (i - 1));
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3676
n,x,y=map(int,input().split())
anslist = [0]*(n)
temp = 0
for i in range(1,n):
    for j in range(i+1,n+1):
        temp = min(abs(j-i),(abs(x-i)+1+abs(y-j)),(abs(y-i)+1+abs(x-j)))
        anslist[temp] += 1

anslist.pop(0)

for i in anslist:
    print(i)

Measured memory_bytes: 9344
#define _USE_MATH_DEFINES
#include <cassert>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <sstream>
#include <vector>
#include <queue>
#include <stack>
#include <list>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <complex>
#include <cmath>
#include <numeric>
#include <bitset>
#include <functional>

using namespace std;

#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cerr << name << ": " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
  const char* comma = strchr(names + 1, ',');
  cerr.write(names, comma - names) << ": " << arg1 << " |";
  __f(comma + 1, args...);
}

typedef long long int64;
typedef pair<int, int> ii;
const int INF = 1 << 29;
const int MOD = 1e9 + 7;

const int N = 1e5 + 10;
vector<int> a[N];
bool visit[N];
vector<int> topo;
int dp[N];

void DFS(int u) {
  visit[u] = true;
  for (auto& v : a[u]) {
    if (!visit[v]) DFS(v);
  }
  topo.push_back(u);
}

int main() {
  int n, m;
  scanf("%d%d", &n, &m);
  while (m--) {
    int x, y;
    scanf("%d%d", &x, &y);
    --x; --y;
    a[x].push_back(y);
  }
  for (int i = 0; i < n; ++i) {
    if (!visit[i]) DFS(i);
  }
  for (auto& u : topo) {
    dp[u] = 0;
    for (auto& v : a[u]) {
      dp[u] = max(dp[u], dp[v] + 1);
    }
  }
  int ret = 0;
  for (int i = 0; i < n; ++i) ret = max(ret, dp[i]);
  printf("%d\n", ret);
  return 0;
}


Measured memory_bytes: 8824
local read = setmetatable({}, {__index = function(t, k) local a = {} for i=1,#k do table.insert(a, '*'..string.sub(k, i, i)) end local r = io.read local u = table.unpack or unpack return function() return r(u(a)) end end})
read.N = function(N) local t={} for i=1,N do t[i]=read.n() end return t end
string.totable = function(s) local t={} local u=string.sub for i=1,#s do t[i] = u(s, i, i) end return t end
string.split = function(s) local t={} for w in string.gmatch(s, "[^%s]+") do table.insert(t, w) end return (table.unpack or unpack)(t) end
local function array(dimension, default_val) local n=dimension local m={}if default_val~=nil then m[1]={__index=function()return default_val end}end for i=2,n do m[i]={__index=function(p, k)local c=setmetatable({},m[i-1])rawset(p,k,c)return c end}end return setmetatable({},m[n])end
----

---
local MOD = math.floor(10^9) + 7
local L = read.l():totable()
local N = #L
local tbl = array(2, 0)
local FIT = 0
local SMALLER = 1
tbl[0][FIT] = 1

-- "Pull" DP
-- smaller: a+b < L
for i=1,N do
    -- decide tbl[i] from tbl[i-1]
    local ld = L[i]
    -- next a+b: 0
    do
        if ld == '1' then
            -- (0,0) => ai + bi = 0; (SMALLER or FIT) -> SMALLER
            tbl[i][SMALLER] = 1 * (tbl[i-1][FIT] + tbl[i-1][SMALLER]) % MOD
        else -- ld == 0
            -- (0,0) => ai + bi = 0; FIT -> FIT
            tbl[i][FIT] = tbl[i-1][FIT]
            -- (0,0) => ai + bi = 0; SMALLER -> SMALLER
            tbl[i][SMALLER] = tbl[i-1][SMALLER]
        end
    end
    -- next a+b: 1
    do
        if ld == '1' then
            -- (0,1), (1,0) => ai + bi = 1; FIT -> FIT
            tbl[i][FIT] = (tbl[i][FIT] + 2 * tbl[i-1][FIT] % MOD) % MOD
            -- (0,1), (1,0) => ai + bi = 1; SMALLER -> SMALLER
            tbl[i][SMALLER] = (tbl[i][SMALLER] + 2 * tbl[i-1][SMALLER] % MOD) % MOD
        else -- ld == 0
            -- (0,1), (1,0) => ai + bi = 1; SMALLER -> SMALLER
            tbl[i][SMALLER] = (tbl[i][SMALLER] + 2 * tbl[i-1][SMALLER]% MOD) % MOD
        end
    end
end
local ans = (tbl[N][FIT] + tbl[N][SMALLER]) % MOD
print(ans)

Measured memory_bytes: 18832
#define _USE_MATH_DEFINES
#include <iostream>
#include <algorithm>
#include <queue>
#include <stack>
#include <deque>
#include <climits>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
//#include <tuple>

#define INF INT_MAX>>1 
#define SIZE 100010
#define MOD 1000000007
#define rep(i, n) for(int i=0; i<(int)(n); i++)
#define rep2(i, from, to) for(int i=(from); i<(int)(to); i++)
#define repr(i, n) for(int i=(n-1); 0<=i; i--)
#define repr2(i, from, to) for(int i=(from-1); (int)(to)<=i; i--)
#define ALL(obj) (obj).begin(), (obj).end()
typedef long long ll;

using namespace std;

struct Point { int x, y; };
struct Edge { int to, cost; };
struct gNode { int from, to, cost; };
struct tNode { int value; int parent; vector<int> child; };


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

int gcd(int a, int b){ return a % b == 0 ? b : gcd(b, a%b); }
int lcm(int a, int b){ return a * b/ gcd(a, b); }
int extgcd(int a, int b, int& x, int& y){
	int d = a;
	if(b != 0){
		d = extgcd(b, a%b, y, x);
		y -= (a/b) * x;
	} else{
		x = 1; y = 0;
	}
	return d;
}
ll mod_pow(ll x, ll n){
	if(n == 0) return 1;
	ll res = mod_pow(x*x % MOD, n/2);
	if(n & 1) res = res * x % MOD;
	return res;
}

int main(void){
	ll n; cin >> n;
	cout << (n*(n-1))/2 << endl;
	return 0;
}

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

const int N = 1e2 + 5;
const int W = 1e5 + 5;

long long dp [W];
long long cache [W];

int main () {
  ios::sync_with_stdio(0);
  cin.tie(0);
  int n, w;
  cin >> n >> w;
  for (int i = 0; i < n; i++) {
    int tempo, lucro;
    cin >> tempo >> lucro;
    for (int j = tempo; j <= w; j++) {
      cache[j] = dp[j - tempo] + lucro;
    }
    for (int j = tempo; j <= w; j++) {
      dp[j] = max (dp[j], cache[j]);
    }
  }
  cout << dp[w] << '\n';
  return 0;
}

Measured memory_bytes: 1792
#include <iostream>
#include <algorithm>

using namespace std;

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

int main(){
  int N, i, j, flag=0;
  cin >> N;
  long long int A[N], min, tmp;
  for(i=0; i<N; i++) cin >> A[i];
  while(1){
    flag = 0;
    sort(A, A+N);
    min = A[0];
    for(i=0; i<N; i++){
      if(min != A[i]){
        flag = 1; break;
      }
    }
    if(flag == 0) break;
    for(j=1; j<N; j++){
      tmp = gcd(A[0], A[j]);
      A[j] = tmp;
    }
  }
  cout << min << endl;
  return 0;
}


Measured memory_bytes: 1024
#include <iostream>

int main(){
    int n;
    unsigned long long ans;
    std::string s1, s2;
    std::cin >> n >> s1 >> s2;
    int i;
    if(s1[0]==s1[1]){
        i = 2;
        ans = 6;
    } else {
        i = 1;
        ans = 3;
    }
    int p;
    for(; i < n; i++){
        if(s1[i]==s1[i+1]){
            if(s1[i-2]==s1[i-1]) p = 3;
            else p = 2;
            i++;
        } else {
            if(s1[i-2]==s1[i-1]) p = 1;
            else p = 2;
        }
        ans = (ans * p) % 1000000007;
    }
    std::cout << ans << std::endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<(b);++i)
#define erep(i,a,b) for(int i=a;i<=(int)(b);++i)
#define per(i,a,b) for(int i=(a);i>(b);--i)
#define eper(i,a,b) for(int i=(a);i>=b;--i)
#define pb push_back
#define mp make_pair
#define INF 100100100100
#define MOD 1000000007
#define ALL(x) begin(x),end(x)
using namespace std;
typedef long long ll;
typedef pair<int,int> Pii;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; }
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int lcm(int a,int b){return a/gcd(a, b)*b;}

int n;
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
    string ans = "";
    cin >> n;
    if (n == 0) {
        cout << 0 << endl;
        return 0;
    }
    while (n != 0) {
        if (n & 1) {
            ans += "1";
            n--;
        }
        else {
            ans += "0";
        }
        n /= -2;
    }
    reverse(ALL(ans));
    cout << ans << endl;
    return 0;
}


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

const int MOD = 1000000007;
const ll INF = numeric_limits<ll>::max();
const int inf = 1e8;

//少数点表示
//cout << std::fixed << std::setprecision(14) <<double値

int main(){
    cin.tie( 0 ); ios::sync_with_stdio( false );
    int n,k;
    cin >> n >> k;
    vector<double> h(n);
    rep(i,n) cin >> h[i];
    int count = 0;
    rep(i,n){
        if(h[i] >= k){
            count++;
        }
    }
    cout << count;

}

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

#define ll long long
#define ull unsigned long long

using namespace std;

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

	// vector <int> A(N, 0);
	map<int, int> m{};
	set<int> s;
	vector<int> A(N, 0);
	for (int ii = 0; ii < N; ++ii){
		int tmp;
		cin >> tmp;
		tmp--;
		m[tmp]++;
		s.insert(tmp);
		A[ii] = tmp;
	}

	ll total = 0;
	auto itr = s.begin();
	while (itr != s.end()) {
		ll val = *itr;
		ll num = m[val];
		if (num > 1){
			total += num *(num-1)/2;
		}
		itr++;
	}

	for (int ii = 0; ii < N; ++ii){
		ll num = m[A[ii]];
		ll ans = 0;
		if (num < 1){
			ans = total;
		} else {
			ans = total - num *(num-1)/2 + (num-1) *(num-2)/2;
		}
		cout << ans << "\n";		
	}	


	return 0;
}


Measured memory_bytes: 14208
#include <iostream>
#define rep(i, N) for(int i=1; i<(int)(N); i++)
using namespace std;

int main() {
	// your code goes here
	int n = 0;
	cin >> n;
	int ans = 0;
	int nans = 0;
	int h[n + 1] = {0};
	rep(i, (n + 1))
	{
		cin >> h[i];
		if(h[i] <= h[(i - 1)])
		{
			nans += 1;
		}
		else if(nans > ans)
		{
			ans = nans;
			nans = 0;
		}
		else
		{
			nans = 0;
		}
	}
	if(nans > ans)
	{ans = nans;}
	
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <bitset>

int main()
{	
	unsigned int a, b; std::cin >> a >> b;
	std::bitset<32> bs1(a);
	std::bitset<32> bs2(b);
	
	std::cout << (bs1 & bs2) << std::endl;
	std::cout << (bs1 | bs2) << std::endl;
	std::cout << (bs1 ^ bs2) << std::endl;
	
	return 0;
}



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

typedef long long ll;
typedef vector<long long> vecll;
typedef vector<string> vecstr;

#define rep0(i, n) for(ll i=0; i<(ll)(n); i++)
#define rep1(i, n) for(ll i=1; i<=(ll)(n); i++)
#define rep(i, a, b) for(ll i=(ll)a; i<=(ll)(b); i++)
#define rep0r(i, n) for(ll i=(ll)(n)-1; i>=0; i--)
#define rep1r(i, n) for(ll i=(ll)(n); i>0; i--)
#define repr(i, a, b) for(ll i=(ll)b; i>=(ll)(a); i--)
#define gcd(a, b) __gcd(a, b)
#define lcm(a, b) a * b / __gcd(a, b)
#define len(x) x.size()
#define Sort(x) sort(x.begin(), x.end())
#define rSort(x) sort(x.begin(), x.end(), greater<ll>())

const ll mod_const = 1000000007;

ll modpow(ll a, ll n, ll m) {
    ll result = 1;
    while(n > 0) {
        if(n&1) {
            result = result * a % m;
        }

    a = a * a % m;
    n >>= 1;
    }

    return result;
}

ll modinv(ll a, ll n) {
    if(a <= 1) {
        return 1;
    } else {
        return  n - modinv(n%a, n) * (n/a) % n;
    }
}

ll comb(ll n, ll r, ll m = mod_const) {
    vecll fac = {1, 1};
    vecll inv ={1, 1};
    vecll facinv = {1 , 1};

    rep(i, 2, n) {
        fac.push_back(fac[i-1] * i % m);
        inv.push_back(modinv(i, m));
        facinv.push_back(facinv[i-1] * inv[i] % m);
    }

    if (n<r || n<0 || r<0) {
        return 0;
    } else {
        return fac[n] * (facinv[r] * facinv[n-r] % m) % m;
    }
}
void solve() {
    ll n;
    cin >> n;

    vecstr s(n);
    rep0(i, n) {
        cin >> s[i];
    }

    Sort(s);

    ll cnt = 1;
    rep1(i, n-1) {
        if(s[i-1] != s[i]) {
            cnt++;
        }
    }
    cout << cnt << endl;
}

signed main() {
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    solve();
    return 0;
}

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

# define pb push_back
# define fr first
# define sc second
# define mk make_pair

using namespace std;

const int inf = 1000000000 + 7;
const int N = 1e5 + 5;

typedef long long ll;

ll n, w, a[N], b[N], ans;
map <ll, int> mp, u;
vector <int>v;

int main()
{
    cin >> n >> w;

    for(int i = 1; i <= n; i ++)
        cin >> a[i] >> b[i];

    v.pb(0);
    for(int i = 1; i <= n; i ++)
    {
        vector < pair <int, int> > f;
        vector <int> vec;
        for(int j = 0; j < v.size(); j ++)
        {
            int aa = v[j] + a[i], bb = mp[v[j]] + b[i];
            if(u[aa] == 0 && aa <= w) vec.pb(aa), u[aa] = 1;
            if(mp[aa] < bb && aa <= w)
                f.pb(mk(aa, bb));
        }
        for(int j = 0; j < f.size(); j ++)
            mp[f[j].fr] = f[j].sc;
        for(int j = 0; j < vec.size(); j ++)
            v.pb(vec[j]);
    }

    for(int i = 0; i < v.size(); i ++)
    {
        if(v[i] <= w)
            ans = max(mp[v[i]] * 1ll, ans * 1ll);
    }

    cout << ans << endl;
}


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

#define int long long
#define fi first
#define se second
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define rep1(i,n) for(int i=1;i<=(int)(n);++i)
#define repo(i,o,n) for(int i=o;i<(int)(n);++i)
#define repm(i,n) for(int i=(int)(n)-1;i>=0;--i)
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define sperase(v,n) (v).erase(remove(all(v), n), (v).end());
#define vdelete(v) (v).erase(unique(all(v)), (v).end());
#define pb(n) push_back(n);
#define mp make_pair
#define MOD 1000000007
#define INF 9223372036854775807

int ans,tmp;
string s,a = "ACGT";

main() {
    cin >> s;
    rep(i,s.size()) {
        rep(j,4) if (s[i] == a[j]) {
            tmp++;
            goto hoge;
        }
        ans = max(ans,tmp);
        tmp = 0;
        hoge:;
    }
    ans = max(ans,tmp);
    cout << ans << endl;
}



Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <bitset>
#include <algorithm>
#include <complex>
#include <array>
using namespace std;
 
#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()
 
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<long double> VD;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef vector<VD> VVD;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

template<typename T> void chmin(T &a, T b) { if (a > b) a = b; }
template<typename T> void chmax(T &a, T b) { if (a < b) a = b; }

int in() { int x; scanf("%d", &x); return x; }
ll lin() { ll x; scanf("%lld", &x); return x; }

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

    return 0;
}


Measured memory_bytes: 256
import math
N = int(input())
def is_prime(n):
    if n == 1: return False
    for k in range(2, int(math.sqrt(n)) + 1):
        if n % k == 0:
            return False
    return True
i = 2
primedic = {}
primelist = []#len = 168
while i <= 1000:
  if is_prime(i) == True:
    primedic[i] = 0
    primelist.append(i)
  i += 1
def usage(n):
    fct = factorize(n)
    return(fct)
def factorize(n):
    fct = []  # prime factor
    b, e = 2, 0  # base, exponent
    while b * b <= n:
        while n % b == 0:
            n = n // b
            e = e + 1
        if e > 0:
            fct.append((b, e))
        b, e = b + 1, 0
    if n > 1:
        fct.append((n, 1))
    return fct
def num(fct):
    a = 1
    for base, exponent in fct:
        a = a * base**exponent
    return a
j = 2
while j <= N:
  li = usage(j)
  for array in li:
    primedic[array[0]] += array[1]
  j += 1
ans = 1
for keys in primedic:
  ans = (ans*(primedic[keys]+1))%(10**9+7)
print(ans)

Measured memory_bytes: 3192
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
const int INF = 1000000000;
int gcd(int p, int q){
  while(q != 0){
  int r = p % q;
  p = q;
  q = r;
  }
  return p;
}

int main() {
  int x;
  cin >>  x;
  while(1){
    bool ok = true;
    for(int i = 2; i < x; ++i){
      if(x%i==0){
        ok = false;
        break;
      }
    }
    if(ok) break;
    ++x;
  }
  cout << x << endl;
  
  
  return 0;
}

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

int main() {
  int n;
  string s;
  int k;
  cin >> n;
  cin >> s;
  cin >> k;
  char x = s[k - 1];
  string ans = "";
  for (int i = 0; i < n; i++) {
    if (s[i] == x) {
      ans += s[i];
    }
    else {
      ans += '*';
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
s = input()

S = []
for i in range(len(s)):
    S.append(s[i:])
    for j in range(len(s) - i - 1):
        S.append(s[i:-(j+1)])

ans = []
for i in range(len(S)):
    if (('A' in set(S[i])) + 
        ('C' in set(S[i])) + 
        ('G' in set(S[i])) + 
        ('T' in set(S[i])) == len(set(S[i]))):
        ans.append(len(S[i]))
    else:
        ans.append(0)

print(max(ans))


Measured memory_bytes: 3064
import java.util.*

fun main(args : Array<String>) {
    val scanner = Scanner(System.`in`)
    println(inOutExec(scanner))
}

fun inOutExec(scanner: Scanner): String {
    val (numOfPref, numOfCity) = readLine()!!.split(" ").map { it.toInt() }

    val citiesIn = mutableListOf<Pair<Int, Int>>()
    repeat(numOfCity) {
        val (pref, year) = readLine()!!.split(" ").map { it.toInt() }
        citiesIn.add(Pair(pref, year))
    }

    val cityCodeMap = citiesIn
            .groupByTo(mutableMapOf()) { it.first }
            .flatMap { entry -> entry.value // List<Pair<Int, Int>>
                    .sortedBy { info -> info.second }
                    .mapIndexed { index, pair ->
                        pair to "%06d%06d".format(pair.first, index + 1) } } // Pair<Pair<Int, Int>, String>
            .toMap()

    return citiesIn.joinToString(separator = "\n", postfix = "\n") { cityCodeMap[it]!! }
}


Measured memory_bytes: 155464
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
const ll MOD = 1e9 + 7;
const ll INF = 1LL << 60;

int main() {
	int N;
	cin >> N;
	for (int i = 1; i <= 9; i++) {
		if (N%i == 0 && (N / i) <= 9) {
			cout << "Yes" << endl;
			return 0;
		}
	}
	cout << "No" << endl;
}

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

using namespace std;

int main(){
    string num;
    int ans;

    while(1){
        cin >> num;
        if ( num[0] == '0' ) {
            break;
        }
        ans = 0;
        for ( int i = 0; i < (int)num.size(); ++i ){
            ans += (int)(num[i] - '0');
        }

        cout << ans << endl;
    }

    return 0;
}


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

int main() {
    int n;
    cin >> n;
    int a[3*n];
    // deque<int> q(n);
    rep(i,3*n) {
        cin >> a[i];
    }
    sort(a, a+3*n, greater<>());   
    int64_t ans = 0;
    int cnt = 1;
    int index = 1;
    while (cnt <= n) {
        ans += a[index];
        index += 2;
        cnt++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 1408
N, M = map(int, input().split())
#a = [int(input()) for _ in range(M)]
issafe = [True] * (N + 1)
for i in range(M):
    issafe[int(input())] = False

dp = [0] * (N + 1)
dp[0] = 1
if issafe[1]:
    dp[1] = 1

mod = 1000000007
for i in range(2, N + 1):
    if issafe[i - 1]:
        dp[i] += dp[i - 1]
    if issafe[i - 2]:
        dp[i] += dp[i - 2]
    dp[i] = dp[i] %mod

print(dp[N])

Measured memory_bytes: 7764
#include<cstdio>
#include<iostream>
#include<map>
#include<cmath>
#include<algorithm>
#include<cstring>
#include<string>
using namespace std;
int a[100005],x,ans;
int main(){
	int n;
	cin >> n;
	for(int i = 1;i <= n;i++){
		cin >> x;
		a[x]++;
	}
	for(int i = 1;i <= 100003;i++){
		if(a[i]>1)ans+=(a[i]-1);
		}
	if(ans%2)ans+=1;
	cout << n - ans <<endl;
	return 0;
	}
////adadad

Measured memory_bytes: 640
import java.util.*;
 
public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        String first = s.substring(0,1);
        String second = s.substring(1,2);
        String third = s.substring(2,3);
        String forth = s.substring(3,4);
        if (first.equals(second)) {
            if (third.equals(forth)&& !first.equals(forth)) {
                
                System.out.println("Yes");
                return;
            }
            System.out.println("No");
            return;
        }
        
        if (first.equals(third)) {
            if (second.equals(forth)&& !first.equals(forth)) {
                
                System.out.println("Yes");
                return;
            }
            System.out.println("No");
            return;
        }
        
        if (first.equals(forth)) {
            if (second.equals(third)&& !first.equals(third)) {
                
                System.out.println("Yes");
                return;
            }
            System.out.println("No");
            return;
        }
        System.out.println("No");
    }
}

Measured memory_bytes: 21844
#include <stdio.h>
int N[6]={1,5,2,3,0,4},S[6]={4,0,2,3,5,1};
int E[6]={3,1,0,5,4,2},W[6]={2,1,5,0,4,3},O[6]={0,1,2,3,4,5};
int PT[8]={3,1,2,4,3,1,2,4};
void cpy(int *a,int *b,char dir){
    int i,*d;
    if (dir=='N'){d=N;}
    else if (dir=='S'){d=S;}
    else if (dir=='E'){d=E;}
    else if (dir=='W'){d=W;}
    else {d=O;}
    for(i=0;i<6;i++){b[i]=a[d[i]];}
}
int chk(int *a,int *b){
    int i;
    for(i=0;i<6;i++){
        if (a[i]!=b[i]){break;}
    }
    return (i==6)? 1:0;
}
int main(void){
    int i,j,q,buf,d[6],c[6],e[6],ca[8],cb[4],fl=0;
    for(i=0;i<6;i++){scanf("%d",&e[i]);}
    for(i=0;i<6;i++){scanf("%d",&d[i]);}
    while(1){
        if(chk(d,e)) break;
        if (d[1]==e[0] || d[4]==e[0] || d[5]==e[0]){cpy(d,c,'O');cpy(c,d,'N');}
        else if (d[3]==e[0] || d[2]==e[0]){cpy(d,c,'O');cpy(c,d,'E');}
        else {break;}
    }
    for(i=0;i<8;i++){
        ca[i]=e[PT[i]];
        if(i<4){cb[i]=d[PT[i]];}
    }
    for(i=0;i<5;i++){
        if (ca[i]==cb[0] && ca[i+1]==cb[1] && ca[i+2]==cb[2] && ca[i+3]==cb[3]){fl=1;break;}
    }
    printf("%s\n",(fl)? "Yes":"No");
    return 0;
}


Measured memory_bytes: 2092
#include <algorithm>
#include <cassert>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <iostream>
#include <vector>
#include <sstream>
#include <set>
using namespace std;
using ll = long long;

class range {private: struct I{int x;int operator*(){return x;}bool operator!=(I& lhs){return x<lhs.x;}void operator++(){++x;}};I i,n;
public:range(int n):i({0}),n({n}){}range(int i,int n):i({i}),n({n}){}I& begin(){return i;}I& end(){return n;}};

const int MOD = 1000*1000*1000+7;
int add(int a, int b) { return ((ll)a+b)%MOD; }
int mul(int a, int b) { return ((ll)a*b)%MOD; }

int N, C;
int A[404], B[404];
int X[404][404];
int dp[404][404];

int main() {
  while (cin >> N >> C) {
    for (int i : range(N)) cin >> A[i];
    for (int i : range(N)) cin >> B[i];

    // X[i][c] := \sum_{xi=Ai}^{Bi} xi^{c}
    memset(X, 0, sizeof(X));
    for (int i : range(N)) {
      for (int x : range(A[i], B[i] + 1)) {
        int prod = 1;
        for (int c : range(C + 1)) {
          X[i][c] = add(X[i][c], prod);
          prod = mul(prod, x);
        }
      }
    }

    memset(dp, 0, sizeof(dp));
    dp[0][0] = 1;
    for (int i : range(1, 1 + N)) {
      for (int c : range(C + 1)) {
        int val = 0;
        for (int ci : range(c + 1)) {
          val = add(val, mul(X[i - 1][ci], dp[i - 1][c - ci]));
        }
        dp[i][c] = val;
      }
    }

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


Measured memory_bytes: 1536