akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
#define rep(i, n) for (int i = 0, i##_len = (int)(n); i < i##_len; i++)
#define reps(i, n) for (int i = 1, i##_len = (int)(n); i <= i##_len; i++)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rreps(i, n) for (int i = ((int)(n)); i > 0; i--)
#define repi(i, x) \
	for (auto i = (x).begin(), i##_fin = (x).end(); i != i##_fin; i++)
#define all(x) (x).begin(), (x).end()
#define F first
#define S second
#define mp make_pair
#define pb push_back
#define solve(a) ((a) ? "Yes" : "No")
typedef vector<int> Vi;
typedef vector<Vi> VVi;
typedef pair<int, int> Pi;
typedef vector<Pi> VPi;
typedef vector<long long> V;
typedef vector<V> VV;
typedef pair<long long, long long> P;
typedef vector<P> VP;
template <class T>
inline bool chmax(T& a, T b) {
	if (a < b) {
		a = b;
		return 1;
	}
	return 0;
}
template <class T>
inline bool chmin(T& a, T b) {
	if (a > b) {
		a = b;
		return 1;
	}
	return 0;
}
const long long INFLL = 1LL << 60;
const int INF         = 1 << 30;
const double PI       = acos(-1);
int main() {
	int n;
	cin >> n;
	Vi ans(n + 2, 0);
	for (int x = 1; x <= sqrt(n); x++) {
		for (int y = 1; y <= sqrt(n); y++) {
			for (int z = 1; z <= sqrt(n); z++) {
				if (x * x + y * y + z * z + z * y + y * x + z * x > n) {
					continue;
				}
				ans[x * x + y * y + z * z + z * y + y * x + z * x]++;
			}
		}
	}
	for (int i = 1; i <= n; i++) {
		cout << ans[i] << endl;
	}
	// cout << ans << endl;
}

Measured memory_bytes: 3636
#include<bits/stdc++.h>
using namespace std;
int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	int n;
	cin >> n;
	map<string, int> mp;
	int mx = 0;
	for (int i = 0; i < n; ++i){
		string s;
		cin >> s;
		
		if (mp.count(s)){
			++mp[s];
		}
		else{
			mp[s] = 1;
		}
		mx = max(mx, mp[s]);
	}
	for (auto i : mp){
		if (i.second == mx){
			cout << i.first << '\n';
		}
	}
}


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

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef complex<double> P;
typedef pair<int,int> pii;
#define REP(i,n) for(int i=0;i<n;++i)
#define REPR(i,n) for(int i=1;i<n;++i)

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG_VEC(v) REP(i,v.size())cout<<#v<<"["<<i<<"]: "<<v[i]<<endl
#define ALL(a) (a).begin(),(a).end()

int N,M;
vector< vector<pii> > pots(300);

double dfs(vector<int> used, int rest){
  // used[n] = n's pot's upperbound
  // rest = rest of water
  double result = 0.0;

  REP(i,N){
    int before_s = 1e9;
    int ui = used[i];
    double i_result = 0.0;
    int now_rest = rest;
    while(pots[i].size() > ui){
      int pot_s = pots[i][ui].first;
      int pot_h = pots[i][ui].second;
      if(pot_s > before_s){
        vi next_used = used;
        next_used[i] = ui;
        result = max(result, i_result+dfs(next_used,now_rest));
        break;
      }
      if(pot_s*pot_h >= now_rest){
        result = max(result, i_result+(double)now_rest/(double)pot_s);
        break;
      }
      i_result += pot_h;
      now_rest -= pot_s*pot_h;
      before_s = pot_s;
      ++ui;
      if(pots[i].size() == ui){
        vi next_used = used;
        next_used[i] = ui;
        result = max(result, i_result+dfs(next_used,now_rest));
        break;
      }
    }
    result = max(result,i_result);
  }
  return result;
}

double solve(){
  cin>>N>>M;
  int K = 0;
  REP(i,N){
    int k;
    cin>>k;
    K = max(k,K);
    REP(j,k){
      int S,H;
      cin>>S>>H;
      pots[i].push_back(make_pair(S,H));
    }
  }
  // vi used(N);
  // REP(i,N)used[i]=0;
  // return dfs(used,M);
  double dp[N][K+1][M+1];
  REP(i,N)REP(j,K+1)REP(k,M+1)dp[i][j][k]=0.0;
  for(int i=N-1;i>=0;--i){
    vector<pii> pot = pots[i];
    int pot_k = pot.size();
    for(int k=K;k>=0;--k){
      if(k>pot_k)continue;
      int pot_s = pot[k].first;
      int pot_h = pot[k].second;
      for(int m=0;m<=M;++m){
        if(m==0)continue;
        if(pot_s*pot_h>=m)dp[i][k][m]=(double)m/(double)pot_s;
        else dp[i][k][m]=dp[i][k+1][m-pot_s*pot_h]+pot_h;
      }
    }
  }
  // REP(m,M+1){
  //   cout << "M=" << m << endl;
  //   REP(i,N){
  //     REP(j,K+1){
  //       cout << dp[i][j][m] << " ";
  //     }
  //     cout << endl;
  //   }
  // }
  double result = 0.0;
  REPR(i,N){
    int k=0;
    REP(_m,M+1){
      int m = M-_m;
      REP(mm,m+1){
        if(dp[i][k][m] < dp[i][k][mm]+dp[i-1][k][m-mm]){
          dp[i][k][m] = dp[i][k][mm]+dp[i-1][k][m-mm];
        }
        // dp[i][k][m] = max(dp[i][k][m], dp[i][k][mm]+dp[i-1][k][m-mm]);
      }
    }
  }
  return dp[N-1][0][M];
}

int main(){
  cout.precision(20);
  cout << fixed << solve() << endl;
  return 0;
}

Measured memory_bytes: 7280
#include <bits/stdc++.h>
#define FI freopen ("inp.txt", "r", stdin)
#define FO freopen ("out.txt", "w", stdout)
#define FOR(v) for(int i : v) {printf("%d ", i);} printf("\n");
#define DEBUG(x) printf("*%d*\n", x);
using namespace std;

int main() {
    //FI;

    int n;
    scanf("%d", &n);
    vector<int> dp(3); // dp[i] - total point such that we did activity i considered last.

    for (int day = 0; day < n; ++day) {
        vector<int> new_dp(3, 0);
        vector<int> c(3);
        for (int i = 0; i < 3; ++i) {
            scanf("%d", &c[i]);
        }
        for (int i = 0; i < 3; ++i) {
            for (int j = 0; j < 3; ++j) {
                if (i != j) {
                    new_dp[j] = max(new_dp[j], dp[i] + c[j]);
                }
            }
        }
        dp = new_dp;
    }

    printf("%d", max(max(dp[0], dp[1]), dp[2]));

    return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {

  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    String a = sc.next();
    String s = sc.next();
    String c = sc.next();
    String s_new = s.substring(0,1);

    System.out.println("A"+s_new+"C");

  }

}


Measured memory_bytes: 21844
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <math.h>
using namespace std;
typedef long long ll;

const int maxn = 105;
int n, A[maxn];

int main()
{
    //ios_base::sync_with_stdio(false); cin.tie(NULL);
    cin >> n;
    int ans = 0;
    for (int i = 0; i < n; i++) {
        cin >> A[i];
        if (i > 0) {
            if (A[i] == A[i-1]) {
                A[i] = -1;
                ans++;
            }
        }
    }
    cout << ans << '\n';

    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main()
{
    int a,b,c,d,i,j,p,q;
    scanf("%d%d%d",&a,&b,&c);
    int ch[3];
    ch[0]=a;
    ch[1]=b;
    ch[2]=c;
    for(i=0;i<3;i++)
    {
   
      for(j=i+1;j<3;j++)
        {
            if(ch[i]>ch[j])
            {
            d=ch[i];
            ch[i]=ch[j];
            ch[j]=d;
                }
            
        }
    }
    
    p=ch[1]-ch[0];
    q=ch[2]-ch[1];
    int w=p+q;
    printf("%d\n",w);
    return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int inf = 0x3f3f3f3f;
const int N = 2e5+5;
int main()
{
	int a,b,c,k,ans=0;
	cin>>a>>b>>c>>k;
	if(k>=a)
	{
		ans+=a;
		k-=a;
		if(k>=b)
		{
			k-=b;
			if(k>=c)
			ans-=c;
			else ans-=k;
		}
	}
	else ans+=k;
	cout<<ans;
	return 0;
}

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

const int ALPHABET = 26;
int main() {
	string S;
	cin >> S;
	bool abc[ALPHABET]; // abc[i]はi+1番目のアルファベットが出現したか否かを表す
	for (int i = 0;i < ALPHABET;i ++) abc[i] = false; // 初期化
	for (int i = 0;i < S.length();i ++) {
		abc[S[i] - 'a'] = true; // 出現した文字をtrueに
	}
	for (int i = 0;i < ALPHABET;i ++) {
		if (!abc[i]) { // もしi+1番目のアルファベットが出現していないなら
			cout << (char)('a' + i);
			return 0;
		}
	}
	cout << "None"; // 見つからなかった
	return 0;
}
/*
31536000のコメント解説欄
ここテンプレで用意してるから、A問題とかだとこの先空欄の危険あり

各文字が出現したか否かだけが分かれば判定ができるので、まずは各アルファベットの出現したか否かを記録する箱を持つ
後は、文字列の先頭から順に出現した文字を見て、その箱に出現を記録すれば良い
オーダーはO(|S|)
*/

Measured memory_bytes: 512
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

const int MOD = 1e9 + 7;
const int iINF = 1000000000;
const long long int llINF = 1000000000000000000;

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

typedef pair<ll, ll> pll;
bool paircomp(const pll &a, const pll &b) {
  if (a.first == b.first)
    return a.second < b.second;
  return a.first < b.first;
}
struct multi {
  ll first;
  ll second;
  ll third;
};
bool multicomp(const multi &a, const multi &b) {
  if (a.first == b.first)
    return a.second < b.second;
  return a.first < b.first;
}
#define REP(i, n) for (ll i = 0; i < (n); i++)
#define RREP(i, n) for (ll i = (n)-1; i >= 0; i--)
#define FOR(i, a, b) for (ll i = (a); i < (b); i++)
#define AUTO(i, m) for (auto &i : m)
#define ALL(a) (a).begin(), (a).end()
#define MAX(vec) *std::max_element(vec.begin(), vec.end())
#define MIN(vec) *std::min_element(vec.begin(), vec.end())
#define ARGMAX(vec)                                                            \
  std::distance(vec.begin(), std::max_element(vec.begin(), vec.end()))
#define ARGMIN(vec)                                                            \
  std::distance(vec.begin(), std::min_element(vec.begin(), vec.end()))
#define REV(T) greater<T>()
#define PQ(T) priority_queue<T, vector<T>, greater<T>>
#define VVL(a, b, c) vector<vector<ll>>(a, vector<ll>(b, c))
#define VVVL(a, b, c, d)                                                       \
  vector<vector<vector<ll>>>(a, vector<vector<ll>>(b, vector<ll>(c, d)))
#define SP(a) setprecision(a)
#define SQRT(a) sqrt((long double)(a))
#define DPOW(a, b) pow((long double)(a), (long double)(b))

ll POW(ll n, ll m) {
  if (m == 0) {
    return 1;
  } else if (m % 2 == 0) {
    ll tmp = POW(n, m / 2);
    return (tmp * tmp);
  } else {
    return (n * POW(n, m - 1));
  }
}

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

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

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  ll N;
  cin >> N;
  vl A(N);
  REP(i, N) cin >> A[i];

  if (N == 2) {
    cout << max(A[0], A[1]) << endl;
    return 0;
  }

  ll min1 = 0;
  ll minarg = 0;
  ll gcd = MIN(A);
  REP(i, N) {
    ll tmp = GCD(gcd, A[i]);
    if (gcd - tmp > min1) {
      min1 = gcd - tmp;
      minarg = i;
    }
  }

  ll ans1 = MIN(A);
  REP(i, N) {
    if (i != minarg)
      ans1 = GCD(ans1, A[i]);
  }

  ll ans2 = MAX(A);
  ll argmin = ARGMIN(A);

  REP(i, N) if (argmin != i) ans2 = GCD(ans2, A[i]);
  cout << max(ans1, ans2) << endl;

  return 0;
}


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

int main(){
  int h,a;
  cin >> h >> a;
  int ans = (h+a-1)/a;
  cout << ans << endl;
  return 0;
}

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

int main(){
    int n ; cin  >> n;
    string s; cin >> s;
    if(n%2==1){
        cout << "No" << endl;
    }else{
        bool flag=true;
        for(int i=0;i<n/2;i++){
            if(s[i]!=s[i+n/2]) flag=false;
        }
        if(flag) cout << "Yes" << endl;
        else cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <string.h>
#include <limits.h>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <set>

typedef unsigned long long ULLONG;
typedef long long LLONG;

template <class _T> static _T tp_abs(const _T& a) {
	return ((a < 0) ? (a * -1) : a);
}
template <class _T> static _T tp_min(_T a, _T b) {
	return a < b ? a : b;
}
template <class _T> static _T tp_max(_T a, _T b) {
	return a > b ? a : b;
}
template<class _T> static void get1int(_T& a) {
	const char* fmt = " %d";
	if (sizeof(_T) == sizeof(long long)) {
		fmt = " %lld";
	}

	if (scanf(fmt, &a) < 0) {
		printf("g1int Error\n");
	}
}
template<class _T> static void get2int(_T& a, _T& b) {
	const char* fmt = " %d %d";
	if (sizeof(_T) == sizeof(long long)) {
		fmt = " %lld %lld";
	}

	if (scanf(fmt, &a, &b) < 0) {
		printf("g2int Error\n");
	}
}
template<class _T> static void get3int(_T& a, _T& b, _T& c) {
	const char* fmt = " %d %d %d";
	if (sizeof(_T) == sizeof(long long)) {
		fmt = " %lld %lld %lld";
	}

	if (scanf(fmt, &a, &b, &c) < 0) {
		printf("g3int Error\n");
	}
}
static void getstring(char* buff) {
	if (scanf(" %s", buff) < 0) {
		printf("getstr error!\n");
	}
}

static const long long MOD_NUM = 1000000007LL;

static void C_task();

int main()
{
	C_task();
	fflush(stdout);
	return 0;
}

static int C_getNum(int N, std::vector<int>& status, std::vector<std::vector<std::pair<int, int>>>& evid)
{
	bool nocount = false;
	
	for (int i = 0; i < N; i++) {
		if (status[i]) {
			int count = evid[i].size();
			for (int j = 0; j < count; j++) {
				int x = evid[i][j].first;
				int y = evid[i][j].second;

				if(status[x] != y) {
					nocount = true;
					break;
				}
			}
		}
		if (nocount) break;
	}

	int honest = 0;
	if (!nocount) {
		for (int i = 0; i < N; i++) {
			if (status[i] == 1) honest++;
		}
	}
	return honest;
}

static int C_dfs(int N, int now, std::vector<int>& status, std::vector<std::vector<std::pair<int, int>>>& evid)
{
	if (now >= N) {
		return 0;
	}

	int honest = 0;
	status[now] = 1;
	honest = tp_max(honest, C_getNum(N, status, evid));
	honest = tp_max(honest, C_dfs(N, now + 1, status, evid));
	status[now] = 0;
	honest = tp_max(honest, C_getNum(N, status, evid));
	honest = tp_max(honest, C_dfs(N, now + 1, status, evid));

	return honest;
}

static void C_task()
{
	int N;
	get1int(N);

	std::vector<std::vector<std::pair<int, int>>> evid(N);
	for (int i = 0; i < N; i++) {
		int A;
		get1int(A);
		for (int j = 0; j < A; j++) {
			int x, y;
			get2int(x, y); x--;
			evid[i].push_back(std::make_pair(x, y));
		}
	}

	std::vector<int> status(N, 0);
	printf("%d\n", C_dfs(N, 0, status, evid));
}


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

signed main() {
  ll n, k;
  cin >> n >> k;
  
  ll ext = n % k;
  ll ext_neg = k - ext;
  ll ans = min(ext, abs(ext_neg));
  
  cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define re register
#define min(a,b) ((a)<(b)?(a):(b))
#define max(a,b) ((a)>(b)?(a):(b))
inline int read() {
	char c=getchar();int x=0;while(c<'0'||c>'9') c=getchar();
	while(c>='0'&&c<='9') x=(x<<3)+(x<<1)+c-48,c=getchar();return x;
}
const int mod=998244353;
const int maxn=2005;
int n,m,a[maxn];
int dp[maxn][maxn],f[maxn][maxn];
inline int qm(int x) {return x>=mod?x-mod:x;}
inline int dqm(int x) {return x<0?x+mod:x;}
inline int calc(int n,int a,int b) {
	int now=0;
	for(re int j=0;j<=n;j++)
		now=qm(now+1ll*dp[a][j]*f[b][n-j]%mod);
	return now;
}
int main() {
	scanf("%d%d",&m,&n);
	a[0]=1;dp[0][0]=1;for(re int i=1;i<=m;i++) dp[i][0]=1;
	for(re int i=1;i<=m;i++) {
		for(re int j=1;j<=n;j++)
			a[j]=qm(a[j-1]+dp[i-1][j]);
		for(re int j=1;j<=n;j++)
			dp[i][j]=qm(2ll*a[j-1]%mod+dp[i-1][j]);
	}
	for(re int i=0;i<=m;i++) f[i][0]=1;
	for(re int i=1;i<=m;i++)
		for(re int j=1;j<=n;j++)
			f[i][j]=qm(f[i][j-1]+f[i-1][j]);
	int cnt1=0,cnt2=0,ans=0;
	for(re int i=2;i<=2*m;++i) {
		cnt1=cnt2=0;
		for(re int j=1;j<=m;j++) {
			if(i-j==j) continue;
			if(i-j>=1&&i-j<=m) {
				if(j<i-j) ++cnt1;
			}
			else ++cnt2;
		}
		ans=calc(n,cnt1,cnt2);
		if(!(i&1)) ans=qm(ans+calc(n-1,cnt1,cnt2));
		printf("%d\n",ans);
	}
	return 0;
}



Measured memory_bytes: 31616
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define rep(i, n) for (ll i = 0; i < n; i++)
#define FOR(i, a, b) for (ll i = a; i < b; i++)
#define len(v) ll(v.size())
#define fi first
#define se second

template <class T>
void cout_vec(const vector<T> &vec){
  for(auto itr:vec) cout<<itr<<' ';
  cout<<endl;
}

typedef pair<ll,ll> P;
const ll mod=1e9+7;
const ll inf=1e15;

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll n,k;
  cin>>n>>k;
  vector<ll> a(n);
  rep(i,n) cin>>a[i];
  ll ans=0;
  k++;
  rep(i,50){
    if(!(k & (1ll<<i))) continue;
    ll now=0;
    rep(j,i){
      ll cnt=0;
      rep(x,n){
        if(a[x] & (1ll<<j)) cnt++;
      }
      now+=(1ll<<j)*max(cnt,n-cnt);
    }
    FOR(j,i,50){
      ll cnt=0;
      rep(x,n){
        if(a[x] & (1ll<<j)) cnt++;
      }
      if(j==i){
        now+=(1ll<<j)*cnt;
        continue;
      }
      if(k & (1ll<<j)) now+=(1ll<<j)*(n-cnt);
      else now+=(1ll<<j)*cnt;
    }
    ans=max(ans,now);
  }
  cout<<ans<<endl;
}

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

public class Main{
  public static void main(String[] args){
     Scanner scanner = new Scanner(System.in);
     int n = scanner.nextInt();
     int q = scanner.nextInt();

     int[] member = new int[n];

     int m = 0;
     int mn = 0;

     for(int i=0;i<q;i++){
       int a = scanner.nextInt();
       int v = scanner.nextInt();
       member[a-1] += v;

       if(i==0){
         m=member[a-1];
         mn = a-1;
       }else{



         if(v<0){
           mn = most(member);
           m=member[mn];
         }else if((member[a-1]==m)&&(mn > a-1)){
           mn = a-1;
         }else if(m < member[a-1]){
           m=member[a-1];
           mn = a-1;
         }





       }

       System.out.println((mn+1) + " " + m);

     }

  }

static int most(int[] member){
    int m = member[0];
    int n = 0;
    for(int i=1;i<member.length;i++){
      if(m<member[i]){
        m=member[i];
        n=i;
      }
    }
    return n;
  }

}


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

using namespace std;

long long prime = 998244353;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n, p;
    string s;
    cin >> n >> p;
    cin >> s;
    long long answer = 0;
    if (p == 2 || p == 5) {
        for (int i = 0; i < n; ++i) {
            int digit = (int) (s[i] - '0');
            if (digit % p == 0) {
                answer += i + 1;
            }
        }
    } else {
        vector<int> counts(p, 0);
        counts[0] = 1;
        int current_sum = 0;
        int pow_10 = 1;
        for (int i = n - 1; i >= 0; --i) {
            int digit = (int) (s[i] - '0');
            current_sum = (digit * pow_10 + current_sum) % p;
            answer += counts[current_sum];
            ++counts[current_sum];
            pow_10 = pow_10 * 10 % p;
        }
    }
    cout << answer << endl;
    return 0;
}


Measured memory_bytes: 720
using System;
using System.Text;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
class Program
{
    static void Main(string[] args)
    {
		string input = Console.ReadLine();
		int l = input.Length;
		char[] s = new char[l];
		int ans = 0;
        for(var i = 0; i < l; i++)
		{
			s[i] = input[i];
		}
        for(var i = 0; i < l; i++)
		{
			if (i == 0) { continue; }
			if (s[i] == s[i - 1]&&s[i]=='0')
			{
				s[i] = '1';
				ans++;
			}
			else if (s[i] == s[i - 1] && s[i] == '1')
			{
				s[i] = '0';
				ans++;
			}
		}
		Console.WriteLine(ans);

	}
}

Measured memory_bytes: 13176
n,m=map(int,input().split())

items=[]
for i in range(m):
    p,y=map(int,input().split())
    items.append((p,y,i))
items.sort()

now=0
p1=items[0][0]
ans=[]
for p,y,ind in items:
    if p==p1:
        now+=1
        tmp=str(p*10**6+now)
        tmp=(12-len(tmp))*"0"+tmp
        ans.append((ind,tmp))
    else:
        now=1
        p1=p
        tmp=str(p*10**6+now)
        tmp=(12-len(tmp))*"0"+tmp
        ans.append((ind,tmp))

ans.sort()
for _,j in ans:
    print(j)

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

using namespace std;

typedef long long int lli;

int main(int argc, char const *argv[]) {
  lli n, k;
  cin >> n >> k;
  vector<lli> x(n);
  lli ans=1<<30;
  for (lli i = 0; i < n; i++) cin >> x[i];
  for (lli i = 0; i < n-k+1; i++) {
    lli ansr, ansl;
    ansr = abs(x[i])+abs(x[i+k-1]-x[i]);
    ansl = abs(x[i+k-1])+abs(x[i+k-1]-x[i]);
    ans = min(ans,min(ansr,ansl));
  }
  
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 1024
from bisect import bisect_left


def main():
    N = int(input())
    L = list(map(int, input().split()))
    L.sort()
    ans = 0
    for i in range(2, N):
        for j in range(1, i):
            x = L[i] - L[j] + 1
            k = bisect_left(L, x)
            ans += max(j - k, 0)
    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 42588
///******* In the name of Allah *******///

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

//long int ar[10013];
//long int gcd(long int a, long int b)
//{
//    if(b==0)
//        return a;
//    return gcd(b,a%b);
//}
//long int sieve(long long int a)
//{
//    long long int i,j,k = 0;
//    memset(ar,0,sizeof(ar));
//    ar[1] = 1;
//    for(i=2; i<=713; i++)
//    {
//        if(ar[i]==0)
//        {
//            for(j=i+i; j<=713; j+=i)
//            {
//                ar[j] = 1;
//            }
//        }
//    }
//    return ar[a];
//}

void Ok()
{
    long int a[10013],b,c,d,h,t,i,j,k,l,m,n;
    long int ans_1,ans_2,ans_3,ans_4,cnt = 0,Max,Min,flag,temp,sum;
    double aa,bb,cc,dd,ee,ff,gg;
    char aaa[113],bbb[113],ccc,ddd;
    string spc,in,store[13];

    cin>>aaa;
    cin>>bbb;
    flag = 1;
    l = strlen(aaa);
    for(i=0;i<l;i++)
    {
        if(aaa[i]!=bbb[i])
        {
            flag = 0;
            break;
        }
    }
    if(flag)
        cout<<"Yes"<<endl;
    else
        cout<<"No"<<endl;

    return;
}

int main()
{
    Ok();

    return 0;
}


Measured memory_bytes: 3632
import java.util.Scanner;

public class Main{
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		int n = Integer.parseInt(sc.next());
		Point point1 = new Point(0, 0);
		Point point2 = new Point(100, 0);
		System.out.println(point1);
		koc(n, point1, point2);
		System.out.println(point2);
	}

	private static void koc(int n, Point point1, Point point2) {
		if (n == 0)
			return;

		Point[] point = new Point[3];
		point[0] = new Point((2 * point1.x + point2.x) / 3, (2 * point1.y + point2.y) / 3);
		point[1] = new Point((point1.x + 2 * point2.x) / 3, (point1.y + 2 * point2.y) / 3);

		double x = (point[1].x - point[0].x) * Math.cos(60 * Math.PI / 180)
				- (point[1].y - point[0].y) * Math.sin(60 * Math.PI / 180) + point[0].x;
		double y = (point[1].x - point[0].x) * Math.sin(60 * Math.PI / 180)
				+ (point[1].y - point[0].y) * Math.cos(60 * Math.PI / 180) + point[0].y;
		point[2] = new Point(x, y);

		koc(n - 1, point1, point[0]);
		System.out.println(point[0]);
		koc(n - 1, point[0], point[2]);
		System.out.println(point[2]);
		koc(n - 1, point[2], point[1]);
		System.out.println(point[1]);
		koc(n - 1, point[1], point2);
	}
}

class Point {
	double x;
	double y;

	public Point(double x, double y) {
		this.x = x;
		this.y = y;
	}

	@Override
	public String toString() {
		return (x + " " + y);
	}
}

Measured memory_bytes: 32760
import sys
import math
import itertools
import bisect
from copy import copy
from collections import deque,Counter
from decimal import Decimal
def s(): return input()
def k(): return int(input())
def S(): return input().split()
def I(): return map(int,input().split())
def X(): return list(input())
def L(): return list(input().split())
def l(): return list(map(int,input().split()))
def lcm(a,b): return a*b//math.gcd(a,b)
def gcd(*numbers): reduce(math.gcd, numbers)
sys.setrecursionlimit(10 ** 9)
mod = 10**9+7
count = 0
ans = 0

N = k()
ans = N-1

for i in range(1,int(N**0.5)+1):
    if N % i == 0:
        b = N // i
        ans = min(ans, b+i-2)

print(ans)


Measured memory_bytes: 10256
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <vector>
#define ll long long
#define inf 0x3f3f3f3f
#define maxn 100010
inline ll read()
{
    ll x=0; char c=getchar(),f=1;
    for(;c<'0'||'9'<c;c=getchar())if(c=='-')f=-1;
    for(;'0'<=c&&c<='9';c=getchar())x=x*10+c-'0';
    return x*f;
}
inline void write(ll x)
{
    static int buf[20],len; len=0;
    if(x<0)x=-x,putchar('-');
    for(;x;x/=10)buf[len++]=x%10;
    if(!len)putchar('0');
    else while(len)putchar(buf[--len]+'0');
}
inline void writeln(ll x){write(x); putchar('\n');}
inline void writesp(ll x){write(x); putchar(' ');}
int u[2*maxn],v[2*maxn];
std::vector<int> nxt[maxn];
int a[maxn],fa[maxn],col[maxn],id[maxn];
int n,m;
int cmp(int x,int y){return a[x]<a[y];}
void dfs(int now)
{
    // printf("%d %d\n",now,col[now]);
    for(int i=0;i<nxt[now].size();i++)
        if(!col[nxt[now][i]]){
            col[nxt[now][i]]=-col[now];
            dfs(nxt[now][i]);
        }
}
int main()
{
	n=read(); m=read();
    for(int i=1;i<=n;i++)
        a[i]=read();
    for(int i=1;i<=m;i++){
        u[i]=read(); v[i]=read();
        nxt[u[i]].push_back(v[i]);
        nxt[v[i]].push_back(u[i]);
    }
    for(int i=1;i<=n;i++){
        int mn=inf,mnid=0;
        for(int j=0;j<nxt[i].size();j++)
            if(a[nxt[i][j]]<mn){
                mn=a[nxt[i][j]];
                mnid=nxt[i][j];
            }
        if(mn>a[i]){
            puts("-1");
            return 0;
        }
        fa[i]=mnid;
    }
    // for(int i=1;i<=n;i++)
    //     writesp(fa[i]);
    // putchar('\n');
    for(int i=1;i<=n;i++)
        nxt[i].clear();
    for(int i=1;i<=n;i++){
        nxt[i].push_back(fa[i]);
        nxt[fa[i]].push_back(i);
    }
    for(int i=1;i<=n;i++)
        if(!col[i]){
            col[i]=1;
            dfs(i);
        }
    for(int i=1;i<=n;i++)
        if(col[i]==1)putchar('B');
        else putchar('W');
    putchar('\n');
    for(int i=1;i<=m;i++)
        if(fa[u[i]]==v[i]||fa[v[i]]==u[i])writeln(std::max(a[u[i]],a[v[i]]));
        else writeln(1e9);
    return 0;
}

Measured memory_bytes: 11264
#include "bits/stdc++.h"

using namespace std;

typedef pair<string, string> P;
typedef pair<string, int> S;

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

	int n;
	while (cin >> n, n) {
		vector<P> v(n);
		for (int i = 0; i < n; i++) {
			string a, b; cin >> a >> b;
			v[i] = P(a, b);
		}
		string c, d; cin >> c >> d;
		queue<S> q;
		q.push(S(c,0));
		bool flag = false;
		while (!q.empty()) {
			S next = q.front(); q.pop();
			string st = next.first;
			int cnt = next.second;
			if (st == d) {
				cout << cnt << endl;
				flag = true;
				break;
			}
			if (st.length() > d.length()) continue;
			for (int i = 0; i < n; i++) {
				string from = v[i].first, to = v[i].second;
				string str = st;
				string::size_type pos = str.find(from);
				while (pos != string::npos) {
					str.replace(pos, from.size(), to);
					pos = str.find(from, pos + to.size());
				}
				if (str == st) continue;
				q.push(S(str, cnt + 1));
			}
		}
		if (!flag) cout << -1 << endl;
	}
}

Measured memory_bytes: 4108
package main

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

// I/O
type Scanner struct {
	sc *bufio.Scanner
}

func NewScanner() *Scanner {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 1024), int(1e+9))
	return &Scanner{sc}
}

func (s *Scanner) nextStr() string {
	s.sc.Scan()
	return s.sc.Text()
}

func (s *Scanner) nextInt() int {
	i, e := strconv.Atoi(s.nextStr())
	if e != nil {
		panic(e)
	}
	return i
}

func (s *Scanner) nextFloat() float64 {
	f, e := strconv.ParseFloat(s.nextStr(), 64)
	if e != nil {
		panic(e)
	}
	return f
}

func (s *Scanner) nextRuneSlice() []rune {
	return []rune(s.nextStr())
}

func (s *Scanner) nextIntSlice(n int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ {
		res[i] = s.nextInt()
	}
	return res
}

func (s *Scanner) nextFloatSlice(n int) []float64 {
	res := make([]float64, n)
	for i := 0; i < n; i++ {
		res[i] = s.nextFloat()
	}
	return res
}

// Arithmetic
func max(nums ...int) int {
	m := nums[0]
	for _, i := range nums {
		if m < i {
			m = i
		}
	}
	return m
}

func min(nums ...int) int {
	m := nums[0]
	for _, i := range nums {
		if m > i {
			m = i
		}
	}
	return m
}

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

func pow(x, y int) int {
	res := 1
	for i := 0; i < y; i++ {
		res *= x
	}
	return res
}

// Sort
type Val struct {
	id, num int
}
type ByNum []Val

func (a ByNum) Len() int           { return len(a) }
func (a ByNum) Less(i, j int) bool { return a[i].num < a[j].num }
func (a ByNum) Swap(i, j int)      { a[i], a[j] = a[j], a[i] }

func main() {
	sc := NewScanner()
	wtr := bufio.NewWriter(os.Stdout)
	N := sc.nextInt()
	dp := make([]int, N+1)
	dp[0] = 0
	for i := 1; i <= N; i++ {
		dp[i] = 1 + dp[i-1]
		power := 6
		for i >= power {
			dp[i] = min(dp[i], 1+dp[i-power])
			power *= 6
		}
		power = 9
		for i >= power {
			dp[i] = min(dp[i], 1+dp[i-power])
			power *= 9
		}
	}

	fmt.Fprintln(wtr, dp[N])
	wtr.Flush()
}


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

using namespace std;

typedef double db;
typedef long long ll;
typedef long double ld;
typedef unsigned int ui;
typedef unsigned long long ull;

typedef pair < db, db > pdd;
typedef pair < db, ld > pdl;
typedef pair < ld, db > pld;
typedef pair < ld, ld > ldp;

typedef pair < ll, ll > pll;
typedef pair < int, ll > pil;
typedef pair < ll, int > pli;
typedef pair < int, int > pii;

#define F first
#define S second

#define en end()
#define bg begin()

#define rev reverse
#define mp make_pair
#define pb push_back

#define y1 y1234567890
#define um unordered_map

#define all(x) x.bg, x.en
#define sz(x) (int)x.size()
#define len(x) (int)strlen(x)

#define sqr(x) ((x + 0ll) * (x))
#define sqrd(x) ((x + 0.0) * (x))

#define forn(i, n) for (int i = 1; i <= n; i++)

const ll inf = (ll)1e18;
const ll mod = (ll)1e9 + 7;

const db eps = (db)1e-9;
const db pi = acos(-1.0);

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

const int N = 100500;

ll n, x, ans;

int main() {
	//freopen(".in", "r", stdin);
	//freopen(".out", "w", stdout);
	//freopen(".err", "w", stderr);

	//srand(time(NULL));

	//cin.tie(NULL);
	//cout.tie(NULL);
	//ios_base::sync_with_stdio(false);

	//cout << setprecision(10) << fixed;
	
	cin >> n >> x;

	ans = n;
	n = n - x;

	while (n) {
		if (n % x == 0) {
			ans += n + n - x;
			break;
		}
		ans += n / x * x * 2;
		n %= x;
		swap(n, x);
	}

	cout << ans;
	
	//cerr << (clock() + 0.0) / CLOCKS_PER_SEC;

	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
    int x;
    cin>>x;
    vector<double>dp(x+1);
    dp[0]=1.00;
    for(int i=1;i<=x;i++){
        double p;
        cin>>p;
        for(int j=i;j>=0;j--){
            
            dp[j]=((j!=0)?dp[j-1]*p:0)+dp[j]*(1-p);
        }
    }
    double ans=0;
    for(int i=1;i<=x;i++){
        // cout<<dp[i];
        if(x/2<i) ans+=dp[i];
    }
    printf("%.10lf",ans);
    return 0;
    
}

Measured memory_bytes: 256
/*  ex3_2
    ruuu0048 */
#include <stdio.h>
 
int main(void){
 
    int pencil_number,a_digit; //本の数とその数の一桁の変数を宣言
 
    scanf("%d",&pencil_number); //変数に本の数を入力する
 
    a_digit = pencil_number % 10; //本の一桁を計算し代入
 
    
    //条件分岐して助数詞を出力
    if(a_digit == 3){ //一桁目が3なら
        printf("bon\n");
    }
    else if(a_digit == 0 || a_digit == 1 || a_digit == 6 || a_digit == 8) //一桁目が0,1,6,8なら
    {
        printf("pon\n");
    }
    else //それ以外なら
    {
        printf("hon\n");
    }
    
 
    return 0; 
}


Measured memory_bytes: 1616
n=int(input())
A=list(map(int,input().split()))
B=list(map(int,input().split()))
ans=0
for i in range(n):
  if A[i] > B[i]:
    ans += B[i]
  else:
    ans += A[i]
    if A[i+1] >= B[i] - A[i]:
      ans += B[i] - A[i]
      A[i+1] -= B[i] - A[i]
    else:
      ans += A[i+1]
      A[i+1] = 0
print(ans)

Measured memory_bytes: 18624
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
	    // input A B C
        // A だけ入る容器1に B だけ入っており、
        // C だけ入っている容器2から容器1へ移したとき、
        // 容器2にどれだけ残るか。
        Scanner sc = new Scanner(System.in);
        int numA = sc.nextInt();
        int numB = sc.nextInt();
        int numC = sc.nextInt();
        int retNum = 0;
        if(numA < numB + numC){
            retNum = numB + numC - numA;
        }
        System.out.println(retNum);
    }
}


Measured memory_bytes: 22612
import java.util.*;

public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        final int N = sc.nextInt();
        int M = sc.nextInt();
        int[] P = new int[N+1];
        for(int i = 1;i <= N;i++){
            int pi = sc.nextInt();
            P[pi] = i;
        }
        int[] par = new int[N+1];
        int[] rank = new int[N+1];
        init(N, par, rank);
        for(int i = 0;i < M;i++){
            int xi = sc.nextInt();
            int yi = sc.nextInt();
            unite(xi, yi, par, rank);
        }
        int ans = 0;
        for(int i = 1;i <= N;i++){
            if(same(i, P[i], par, rank))    ans++;
        }
        System.out.println(ans);
    }
    /**
     *  initialization
     */
    public static void init(int n, int[] par, int[] rank){
        for(int i = 1;i <= n;i++){
            par[i] = i;
            rank[i] = 0;
        }
    }
    /**
     *  find the root
     */
    public static int find(int x, int[] par, int[] rank){
        if(par[x] == x) return x;
        else    return par[x] = find(par[x], par, rank);
    }
    /**
     *  unite x and y
     */
    public static void unite(int x, int y, int[] par, int[] rank){
        x = find(x, par, rank);
        y = find(y, par, rank);
        if(x == y)  return;
        if(rank[x] < rank[y]){
            par[x] = y;
        }else{
            par[y] = x;
            if(rank[x] == rank[y])  rank[x]++;
        }
    }
    public static boolean same(int x, int y, int[] par, int[] rank){
        return find(x, par, rank) == find(y, par, rank);
    }
}

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

int main(void){
    int N;
    int a[100];
    cin >> N;
    
    int c = 0;
    for (int i = 0; i < N; i++) {
        cin >> a[i];
        if (i%2 == 0) {
            if(a[i]%2 == 1) c++;
        }
    }
    
    cout << c;
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
#define repr(i,from,to) for(int (i)=(from);(i)<(to);(i)++)
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
// const bool debug=true;
const bool debug=false;
#define DEBUG if(debug==true)
#define all(x) begin((x)), end((x))
#define vprint(x) for(auto a:(x)) cout << x << endl;
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const ll MOD = 1000000007;
const ll MOD2 = 998244353;
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;
}

vector<ll> divisors(ll num) {
    ll now = 1;
    vector<ll> divs;
    while(now*now<=num) {
        if (num % now==0) {
            divs.push_back(now);
            if (now*now!=num){
                divs.push_back(num/now);
            }
        }
        now++;
    }
    return divs;
}

int main(void) {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n;cin>>n;
    vector<ll> a(n);
    vector<ll> count(1e+6+50,0);
    rep(i,n) {
        cin>>a[i];
        count[a[i]]++;
    }
    ll res = 0;
    rep(i,n) {
        auto divs = divisors(a[i]);
        bool flg = true;
        for(auto x:divs) {
            if (count[x] > (x==a[i])) {
                flg = false;
                break;
            }
        }
        if (flg) res++;
    }

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


Measured memory_bytes: 12712
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <functional>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <string>
#include <list>
#include <math.h>
#include <string.h>
#include <bitset>
using namespace std;

typedef pair<int, int> P;
#define INF (1LL<<60)
#define int long long
#define ll long long
#define mod 1000000007


//int all[123456], a[123456], ab[123456], abc[123456];
map<int, int> all, a, ab, abc;

signed main(){
	string s;
	cin >> s;

	all[-1] = 1;
	a[-1] = 0;
	ab[-1] = 0;
	abc[-1] = 0;
	for (int i = 0; i < s.length(); i++){

		// all
		if (s[i] == '?')
			all[i] = all[i - 1] * 3;		//?3
		else
			all[i] = all[i - 1];			//?以外でカウントを進めない場合

		// a
		if (s[i] == '?'){
			a[i] += all[i - 1];		//カウントを進める
			a[i] += a[i - 1] * 3;			//?3
		}
		else if (s[i] == 'A'){
			a[i] += all[i - 1];		//カウントを進める
			a[i] += a[i - 1];				//?以外でカウントを進めない場合
		}
		else
			a[i] += a[i - 1];				//?以外でカウントを進めない場合

		// ab
		if (s[i] == '?'){
			ab[i] += a[i - 1];		//カウントを進める
			ab[i] += ab[i - 1] * 3;			//?3
		}
		else if (s[i] == 'B'){
			ab[i] += a[i - 1];		//カウントを進める
			ab[i] += ab[i - 1];				//?以外でカウントを進めない場合
		}else
			ab[i] += ab[i - 1];				//?以外でカウントを進めない場合

		// abc
		if (s[i] == '?'){
			abc[i] += ab[i - 1];	//カウントを進める
			abc[i] += abc[i - 1] * 3;		//?3
		}
		else if (s[i] == 'C'){
			abc[i] += ab[i - 1];	//カウントを進める
			abc[i] += abc[i - 1];			//?以外でカウントを進めない場合
		}else
			abc[i] += abc[i - 1];			//?以外でカウントを進めない場合

		all[i] %= mod;
		a[i] %= mod;
		ab[i] %= mod;
		abc[i] %= mod;
	}

	cout << abc[s.length()-1] << endl;

	return 0;
}


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

#define ll long long
#define ld long double
#define fi first
#define se second
#define pi 3.1415926535
#define mod1 1000000007
#define mod2 1000000009
#define no_of_digits(n) floor(log10(n)) + 1
#define lcm(a, b) (a/__gcd(a,b)*b

using namespace std;


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

	int n, m;
	 cin >> n >> m;
	 cout << ((m == n)?"Yes":"No");
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define SORT(a) sort((a).begin(), (a).end())
#define RSORT(a) reverse((a).begin(), (a).end())
#define rep(i, n) for (int i = 0; i < n; i++)
#define all(a) ((a).begin(), (a).end())
typedef long long ll;
// const long long INF = 1LL << 60;
const int INF = 1010101010;
// using Graph = vector<vector<int>>;
const int MOD = 1000000007;

int main() {
  string s;
  cin >> s;
  if (s[2] == s[3] && s[4] == s[5])
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}

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

using namespace std;

using VI = vector<int>;
using VVI = vector<VI>;
using VB = vector<bool>;
using VVB = vector<VB>;
using VD = vector<double>;
using VVD = vector<VD>;
using VS = vector<string>;
using PII = pair<int, int>;
using VPII = vector<PII>;
using VL = vector<long long>;
using VVL = vector<VL>;

#define sz(var) (int)var.size()
#define REP(var, start, end) for(int var = start; var < (int)end; ++var)
#define CLEAR(var, with) memset(var, with, sizeof(var))
#define ALL(x) x.begin(), x.end()
#define LL long long
#define ULL unsigned long long
#define TIME cout << "Time elapsed: " << 1000 * clock() / CLOCKS_PER_SEC << "ms" << endl;

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

int n;
int afterExercise()
{
	int ret = 1;
	for(int i = 1; i <= n; ++i)
		ret = mul(ret, i);
	return ret;
}

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
#ifndef ONLINE_JUDGE
	//freopen("tmp.in", "r", stdin);
//	freopen("tmp.out", "w", stderr);
#endif
	cin >> n;

	cout << afterExercise() << endl;

	return 0;
}

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

int  main()
{
  string s ,r ,t ;
  int n;
  cin>>n;
  cin>>s>>r;
  int x =0 ,y=0;
  for(int i =0;x<s.size()&&y<r.size();i++)
  {
    if(i%2==0){
    t+=s[x++];
    }
    else{
        t+=r[y++];
    }
  }
t+=r[n-1];

  cout<<t<<endl;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void){
  int i, n, s[4]={0,0,0,0};
  char a[3];
  
  scanf("%d", &n);
  for(i=0; i<n; i++){
    scanf("%s", a);
    switch(a[0]){
      case 'A':
        s[0]++;
        break;
      case 'W':
        s[1]++;
        break;
      case 'T':
        s[2]++;
        break;
      case 'R':
        s[3]++;
    }
  }
  printf("AC x %d\nWA x %d\nTLE x %d\nRE x %d\n", s[0], s[1], s[2], s[3]);
return 0;}


Measured memory_bytes: 1732
//Artie WANG
//io
#include <iostream>
#include <cstdio>
#include <iomanip>
#include <fstream>
#include <sstream>

//data structure
#include <cstring>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <set>
#include <map>
//#include <unordered_map>
//#include <unordered_set>
#include <utility>
#include <bitset>
#include <complex>
#include <functional>

//algorithm
#include <algorithm>
#include <cmath>
#include <cstdlib>

//debug
#include <cassert>
#include <ctime>
#include <climits>

using namespace std;

typedef pair<int, int> ii;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> l4;

#define mp make_pair
#define pb push_back
#define debug(x) cerr << #x << " = " << x << endl

const int maxn = 1e5+1;
int cnt[maxn], n;

int main()
{
  scanf("%d", &n);
  for (int i = 1; i <= n; ++i)
    cnt[i] = cnt[i/10] + i%10;
  function<int(int)> solve;
  solve = [&](int x)
    {
      return cnt[x] + cnt[n-x];
    };
  int ans = solve(1);
  for (int i = 1; i <= n-1; ++i)
    ans = min(ans, solve(i));
  printf("%d\n", ans);
}


Measured memory_bytes: 640
#include <iostream>
#include <cstdio>
#include <cmath>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <algorithm>

using namespace std;

long long MOD = 1000000007;


int main() {

  int N, A[100005];
  cin>>N;
  for(int i=0; i<N; i++) cin>>A[i];

  /*
  int m[100005];
  fill(m, m+N, 0);

  for(int i=0; i<N; i++){
    m[(N-1)/2 - A[i]/2]++;
    if((N-1)/2 - A[i]/2 != (N-1)/2 + A[i]/2) m[(N-1)/2 + A[i]/2]++;
  }

  long long ans = 1;
  for(int i=0; i<=(N-1)/2; i++){
    if(m[i] == 0 || m[i]> 2 || (i == N/2 && m[i] >1)){
      cout<<0<<endl;
      return 0;
    }
    if(i == N/2) ans = ans;
    else ans = (ans % MOD) * 2 % MOD;
  }
  cout<<ans % MOD<<endl;
  */

  sort(A, A+N);

  int BE[100005], BO[100005], cnt;

  cnt = 0;
  for(int i=1; i<=N-1; i += 2){
    BE[cnt] = i;
    BE[cnt+1] = i;
    cnt+=2;
  }
  cnt = 1;
  BO[0] = 0;
  for(int i=2; i<=N-1; i += 2){
    BO[cnt] = i;
    BO[cnt+1] = i;
    cnt+=2;
  }

  /*
  cout<<"BO"<<" : ";
  for(int i=0; i<N; i++){
    cout<<BO[i]<<" ";
  }cout<<endl;
  cout<<"BE"<<" : ";
  for(int i=0; i<N; i++){
    cout<<BE[i]<<" ";
  }cout<<endl;
  cout<<" A"<<" : ";
  for(int i=0; i<N; i++){
    cout<<A[i]<<" ";
  }cout<<endl;
  */

  if(N % 2 == 0){
    for(int i = 0; i < N; i++){
      if(A[i] != BE[i]){
        cout<<"0"<<endl;
        return 0;
      }
    }
  }else{
    for(int i = 0; i < N; i++){
      if(A[i] != BO[i]){
        cout<<"0"<<endl;
        return 0;
      }
    }
  }

  long long ans = 1;
  for(int i=1; i<=N/2; i++) ans = ans * 2 % MOD;
  cout<<ans % MOD<<endl;

  return 0;
}


Measured memory_bytes: 1408
n = gets.to_i
min = n

# 入力された正整数の各桁の和を求める関数
def digits_sum(number)
  if !number.kind_of?(Integer)
    # 整数以外の場合
    puts "[ERROR] digits_sum: argument must be an INTEGER"
    -1
  elsif number < 0
    # 負の整数の場合
    puts "[ERROR] digits_sum: argument must be a POSITIVE integer"
    -1
  else
    # 0もしくは正の整数の場合
    sum = 0
    while number > 0 do
      sum += number % 10
      number /= 10
    end
    sum
  end
end

(1..(n+1)/2).each do |a|
  b = n - a
  sum = digits_sum(a) + digits_sum(b)
  min = sum if sum < min
end

puts min


Measured memory_bytes: 1788
import bisect, copy, heapq, math, sys
from collections import *
from functools import lru_cache
from itertools import accumulate, combinations, permutations, product
def input():
    return sys.stdin.readline()[:-1]
def ruiseki(lst):
    return [0]+list(accumulate(lst))
def celi(a,b):
    return -(-a//b)
sys.setrecursionlimit(5000000)
mod=pow(10,9)+7
al=[chr(ord('a') + i) for i in range(26)]
direction=[[1,0],[0,1],[-1,0],[0,-1]]

xy=list(map(int,input().split()))
n=int(input())
xyr=[list(map(int,input().split())) for i in range(n)]

def dijkstra(s,e):
    hq = [(0, s)]
    heapq.heapify(hq) # リストを優先度付きキューに変換
    cost = [float('inf')] * n # 行ったことのないところはinf
    cost[s] = 0 # 開始地点は0
    while hq:
        c, v = heapq.heappop(hq)
        if c > cost[v]: # コストが現在のコストよりも高ければスルー
            continue
        for d, u in e[v]:
            tmp = d + cost[v]
            if tmp < cost[u]:
                cost[u] = tmp
                heapq.heappush(hq, (tmp, u))
    return cost

################################
n,w = n,(n+2)*(n+1)//2 #n:頂点数　w:辺の数

edge = [[] for i in range(n+2)]
#edge[i] : iから出る道の[重み,行先]の配列
for i in range(n):
    for j in range(i+1,n):
        x1,y1,r1=xyr[i]
        x2,y2,r2=xyr[j]
        dis=math.sqrt((x2-x1)**2+(y2-y1)**2)
        edge[i+1].append((max(0,dis-r1-r2),j+1))
        edge[j+1].append((max(0,dis-r1-r2),i+1))
for i in range(n):
    x1,y1,r1=xyr[i]
    dis=math.sqrt((xy[0]-x1)**2+(xy[1]-y1)**2)
    edge[0].append((max(0,dis-r1),i+1))
    edge[i+1].append((max(0,dis-r1),0))
    dis=math.sqrt((xy[2]-x1)**2+(xy[3]-y1)**2)
    edge[n+1].append((max(0,dis-r1),i+1))
    edge[i+1].append((max(0,dis-r1),n+1))
edge[0].append((math.sqrt((xy[0]-xy[2])**2+(xy[1]-xy[3])**2),n+1))
edge[n+1].append((math.sqrt((xy[0]-xy[2])**2+(xy[1]-xy[3])**2),0))
# print(edge)
n=n+2
print(dijkstra(0,edge)[-1])

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

int main(){
  int h, w;
  
  while ( true ){
    cin >> h >> w;
    
    if(h==0 && w==0)break;
    
    rep(i, h) {
      rep(j, w) {
        if((i==0 || i==h-1) || (j==0 || j==w-1))
          cout << "#";
        else
          cout << ".";
      }
      cout << endl;
    }
    cout << endl;
  }
  return 0;
}



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

long long int max(long long int a,long long int b){
	return a > b ? a : b;
}
int main(){
	long long int a, b, c, d;
	cin >> a >> b >> c >> d;
	long long int ans = max(a * c, a * d);
	ans = max(ans,b*c);
	ans = max(ans,b*d);
	cout << ans <<endl;
	return 0;
} 

Measured memory_bytes: 3608