akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Linq;
using System.Collections.Generic;

public class Test
{
	public static void Main()
	{
        int n = int.Parse(Console.ReadLine());
        bool can = true;

        int t = 0;
        int t2 = 0;
        int x = 0;
        int x2 = 0;
        int y = 0;
        int y2 = 0;
        int d = 0;
        int d2 = 0;
        
        for(int i = 0 ; i < n ; i++){
           
            string[] str = Console.ReadLine().Split(' ');
            t2 = int.Parse(str[0]);
            x2 = int.Parse(str[1]);
            y2 = int.Parse(str[2]);

            d = (t2 - t);
            d2 = Math.Abs(x2 - x) + Math.Abs(y2 - y);
            if(d2 > d){
                can = false;
            }
            if(d2 % 2 != d % 2){
                can = false;
            }
            x = x2;
            y = y2;
            t = t2;
        }

        if (can) Console.WriteLine("Yes");
        else Console.WriteLine("No");

	}                                                                                                                                                                       
}

Measured memory_bytes: 15292
//Author:xht37
#include <bits/stdc++.h>

#define ui unsigned int
#define ll long long
#define ul unsigned ll
#define ld long double

#define pi pair <int, int>
#define fi first
#define se second
#define mp make_pair

#define ls (p << 1)
#define rs (ls | 1)
#define md ((t[p].l + t[p].r) >> 1)

#define vi vector <int>
#define pb push_back
#define pq priority_queue

#define dbg(x) cerr << #x" = " << x << endl
#define debug(...) fprintf(stderr, __VA_ARGS__)

#define fl(x) freopen(x".in", "r", stdin), freopen(x".out", "w", stdout)

using namespace std;

namespace io {
	const int SI = 1 << 21 | 1;
	char IB[SI], *IS, *IT, OB[SI], *OS = OB, *OT = OS + SI - 1, c, ch[100];
	int f, t;
	#define gc() (IS == IT ? (IT = (IS = IB) + fread(IB, 1, SI, stdin), IS == IT ? EOF : *IS++) : *IS++)
	inline void flush() {
		fwrite(OB, 1, OS - OB, stdout), OS = OB;
	}
	inline void pc(char x) {
		*OS++ = x;
		if (OS == OT) flush();
	}

	template <class I>
	inline void rd(I &x) {
		for (f = 1, c = gc(); c < '0' || c > '9'; c = gc()) if (c == '-') f = -1;
		for (x = 0; c >= '0' && c <= '9'; x = (x << 3) + (x << 1) + (c & 15), c = gc());
		x *= f;
	}
	template <class I>
	inline void rd(I &x, I &y) {
		rd(x), rd(y);
	}
	template <class I>
	inline void rd(I &x, I &y, I &z) {
		rd(x), rd(y), rd(z);
	}
	template <class I>
	inline void rda(I *a, int n) {
		for (int i = 1; i <= n; i++) rd(a[i]);
	}
	inline void rdc(char &c) {
		for (c = gc(); c < 33 || c > 126; c = gc());
	}
	inline void rds(char *s, int &n) {
		for (c = gc(); c < 33 || c > 126; c = gc());
		for (n = 0; c >= 33 && c <= 126; s[++n] = c, c = gc());
		s[n+1] = '\0';
	}
	inline void rds(string &s) {
		for (c = gc(); c < 33 || c > 126; c = gc());
		for (s.clear(); c >= 33 && c <= 126; s.pb(c), c = gc());
	}

	template <class I>
	inline void print(I x, char k = '\n') {
		if (!x) pc('0');
		if (x < 0) pc('-'), x = -x;
		while (x) ch[++t] = x % 10 + '0', x /= 10;
		while (t) pc(ch[t--]);
		pc(k);
	}
	template <class I>
	inline void print(I x, I y) {
		print(x, ' '), print(y);
	}
	template <class I>
	inline void print(I x, I y, I z) {
		print(x, ' '), print(y, ' '), print(z);
	}
	template <class I>
	inline void printa(I *a, int n) {
		for (int i = 1; i <= n; i++) print(a[i], " \n"[i==n]);
	}
	inline void printc(char c) {
		pc(c);
	}
	inline void prints(char *s, int n) {
		for (int i = 1; i <= n; i++) pc(s[i]);
		pc('\n');
	}
	inline void prints(string s) {
		int n = s.length();
		while (t < n) pc(s[t++]);
		pc('\n'), t = 0;
	}
	struct Flush {
		~Flush() {
			flush();
		}
	} flusher;
}
using io::rd;
using io::rda;
using io::rdc;
using io::rds;
using io::print;
using io::printa;
using io::printc;
using io::prints;

const int N = 1e5 + 7;
int n;
ll s, x[N], p[N];

ll f(int l, int r, int o) {
	if (s < x[l] || x[r] < s) return abs(s - x[o]);
	if (p[l] >= p[r]) return p[l] += p[r], f(l, r - 1, l) + abs(x[l] - x[o]);
	return p[r] += p[l], f(l + 1, r, r) + abs(x[r] - x[o]);
}

int main() {
	rd(n), rd(s);
	for (int i = 1; i <= n; i++) rd(x[i], p[i]);
	print(f(1, n, s < x[1] ? n : x[n] < s ? 1 : p[1] >= p[n] ? n : 1));
	return 0;
}

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

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> pll;
typedef vector<ld> vd;
typedef vector<ll> vll;
typedef vector<string> vstr;
typedef vector<vector<ll>> vvll;
typedef vector<pair<ll, ll>> vpll;
typedef priority_queue<ll, vector<ll>, greater<ll>> spqll;  // 小さい順に取り出し
typedef priority_queue<ll, vector<ll>, less<ll>> bpqll;     // 大きい順に取り出し

#define REP(i, n) for (ll i = 0; i < (ll)(n); i++)
#define FOR(i, a, b) for (ll i = (ll)a; i < (ll)b; i++)
#define IREP(i, v) for (auto i = (v).begin(); i != (v).end(); i++)
#define FI first
#define SE second
#define MP make_pair
#define MT make_tuple
#define PB push_back
#define TS to_string
#define NP next_permutation
#define ALL(v) (v).begin(), (v).end()
#define SZ(x) (ll) x.size()
#define SP(x) setprecision((ll)x)


ll INF = 1e9;
ll NIL = -1;
ll MOD = 1000000007;
ll LINF = 1e18;
ld EPS = 1e-9;
ld PI = M_PI;
vll dx = {1, 0, -1, 0, 1, -1, -1, 1};
vll dy = {0, 1, 0, -1, 1, 1, -1, -1};
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a;} //最大公約数
ll lcm(ll a, ll b) { return a / gcd(a, b) * b;}     //最小公倍数

void yes(){ cout << "Yes" << endl;}
void no(){ cout << "No" << endl;}

//-----------------------------------------
#define N_MAX 100000+10;
int n;
vll h;
vll dp;

ll q(ll k){
    if(dp[k]!=-1) return dp[k];

    dp[k] = min(q(k-1)+abs(h[k]-h[k-1]),q(k-2)+abs(h[k]-h[k-2]));

    return dp[k];
}


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

    cin >> n;
    vll vec(n,-1);

    h = vec;
    dp = vec;

    REP(i,n){
        cin >> h[i];
    }

    dp[0] = 0;
    dp[1] = abs(h[1]-h[0]);

    ll ans = q(n-1);

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



Measured memory_bytes: 7148
x,k,d = map(int,input().split())
x = abs(x)
k = abs(k)
d = abs(d)

a,b = divmod(x,d)
if a <= k:
    if (k-a) % 2 == 0:
        print(b)
    else:
        print(min(abs(b-d),abs(b+d)))
else:
    print(x - k*d)

Measured memory_bytes: 9192
#include <bits/stdc++.h> 
#include <time.h>
#define F(i,a,b) for(long long i=a;i<=(b);++i)
#define dF(i,a,b) for(long long i=a;i>=(b);--i) 
#define inf 0x3f3f3f3f
#define infll 0x3f3f3f3f3f3f3f3f
#define pb push_back
#define maxnkp make_pair
#define fi first
#define se second
#define eps 1e-10
#define PI acos(-1.0)
using namespace std;
typedef long long ll;
const int mods = 1e9+7;
const int maxn = 500+10;
const int N = 1e5+10;
const int E = 1e6+10;  
int x,n;
int tmp;
bool vis[110];
int main(){
	cin>>x>>n;
	F(i,1,n){
		cin>>tmp;
		vis[tmp]=1;
	}
	int sum = inf;
	int ans = 0;
	F(i,0,101){
		if(vis[i]) continue;
		if(abs(i-x)<sum){
			sum = abs(i-x);
			ans = i;
			
		}
	} 
	cout<<ans<<endl;
}


Measured memory_bytes: 3632
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <cmath>
#include <cstring>
#include <iomanip>
#include <random>
#include <chrono>
#include <queue>
#include <math.h>
#include <string>
#include <sstream>
#include <stack>
 
using namespace std;
 
#define ll long long
#define rep(i,n) for(ll i=0;i<n;i++)
#define PI 3.14159265359


int main() {
    ll n;
    cin >> n;
    ll h[n];
    rep(i,n) cin >> h[i];
    ll ans=0;
    bool OK=true;
    while(OK){
        bool renzoku=false;
        ll ans1=ans;
        for(ll i=0;i<n;i++){
            if(renzoku && h[i]>0){
                h[i]--;
            }
            else if(renzoku && h[i]==0){
                renzoku=false;
                continue;
            }
            else if(h[i]>0){
                renzoku=true;
                ans++;
                h[i]--;
            }
            else{
                continue;
            }
        }
        if(ans==ans1) OK=false;
    }
    cout << ans << endl;
}






Measured memory_bytes: 256
#include<iostream>
int main(){
int a,b,c,d;
  std::cin>>a>>b>>c>>d;
  if(a>b){
  if(c>d){
  std::cout<<b+d<<std::endl;
  }
    else{
    std::cout<<b+c<<std::endl;
    }
  }
     else{
     if(c>d){
     std::cout<<a+d<<std::endl;
     }
       else{
       std::cout<<a+c<<std::endl;
       }
     }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long int
#define ull unsigned long long int
#define mod 1000000007
using namespace std;
int a[100];
int main()
{
    #ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    #endif
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n;
    cin>>n;
    
    for(int i=0;i<n;i++)
    {
        int x,y;
        cin>>x>>y;
        if(x==y)
        {
            a[i]=1;
        }
    }
    int ans=0;
    bool flag=0;
    for(int i=0;i<n;i++)
    {
        if(a[i]==1) ans++;
        else ans=0;
        if(ans==3)
        {
            flag=1;
            break;
        }
    } 
    if(flag) cout<<"Yes";
    else cout<<"No";
    return 0;
}

Measured memory_bytes: 3648
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
const int maxn=1e6+5;
int main() {
    ll a,b,c;cin>>a>>b>>c;
    cout<<(b*c>=a?"Yes":"No")<<endl;
    return 0;
}

Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
int x;
bool vis[50];
int main(){

	for(int i=1;i<=4;i++){
		cin>>x;
		vis[x]=1;
	}
	if(vis[1]==1&&vis[9]==1&&vis[7]==1&&vis[4]==1){
		printf("YES");
	}
	else{
		printf("NO");
	}

	return 0;
}

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

using namespace std;

int main() {
#ifdef LOCAL
  freopen("input.txt", "r", stdin);
#endif
  ios::sync_with_stdio(false);
  cin.tie(0);
  long long s;
  cin >> s;
  int d = 1e9;
  int y = (s + d - 1) / d;
  cout << 0 << " " << 0 << " " << d << " " << 1 << " " << (long long) d * y - s << " " << y << "\n";
  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
  
int main(void){
    int i,j,k,a,b,dice[2][7],
        side[5] = {2,3,5,4,2},
        n = 0;
      
    for(i=0;i<2;i++)
      for(j=1;j<7;j++)
        scanf("%d", &dice[i][j]);
     
    for(i=0;i<6;i++){
      if(dice[0][1]==dice[1][1])
        for(j=0;j<4;j++){
 
  //一致判定
          for(k=1;k<7;k++)
            if(dice[0][k]!=dice[1][k]) break;
  
          if(k==7){
            printf("Yes\n");
            return 0;
          }
 
  //スピン
          dice[1][0] = dice[1][2];
          dice[1][2] = dice[1][3];
          dice[1][3] = dice[1][5];
          dice[1][5] = dice[1][4]; 
          dice[1][4] = dice[1][0]; 
 
       
      }
          
       //回転  
      
      dice[1][0] = dice[1][1];
          
      switch(i){
                  
          case 2:
              dice[1][1] = dice[1][3];
              dice[1][3] = dice[1][6];
              dice[1][6] = dice[1][4];
              dice[1][4] = dice[1][0]; 
              break;
              
          default:
              dice[1][1] = dice[1][2];
              dice[1][2] = dice[1][6];
              dice[1][6] = dice[1][5];
              dice[1][5] = dice[1][0]; 
              break;
         
          }
    }
 
    printf("No\n");
    return 0;
}


Measured memory_bytes: 2112
#include <stdio.h>

int main(){

  int a,b,r;
  scanf("%d%d",&a,&b);

  r = a % b;
  while(r != 0){
    a = b;
    b = r;
    r = a % b;
  }

  printf("%d\n",b);
  return 0;
}

Measured memory_bytes: 2728
#include <stdio.h>
#define MAX1 10000
#define MAX2 10000

int main(){
    int n,q,i,j;
    int a[MAX1];
    int b[MAX2];
    int count=0;

    scanf("%d",&n);
    for(i=0;i<n;i++){
        scanf("%d",&a[i]);
    }
     scanf("%d",&q);
    for(i=0;i<q;i++){
        scanf("%d",&b[i]);
    }

    for(i=0;i<q;i++){
        for(j=0;j<n;j++){
            if(a[j]==b[i]){
                count++;
                break;
            }
        }
    }
    printf("%d\n",count);
}


Measured memory_bytes: 2052
# https://atcoder.jp/contests/abc130/tasks/abc130_b



N, X = gets.split.map(&:to_i)
Ls = gets.split.map(&:to_i)

ans = 1
x = 0
Ls.each do |l|
  x += l
  break if x > X
  ans += 1
end
puts ans


Measured memory_bytes: 1788
#include <iostream>

using namespace std;
int main(void){
    // Your code here!
    long long a;
    cin >> a;
    long long s = (a + 1)* a * 1/2;
    long long m = a/3;
    long long f = a/5;
    long long y = a/15;
    long long t = (m)*(3*m + 3)*1/2;
    long long x = (f)*(5*f + 5)*1/2;
    long long z = (y)*(15*y + 15)*1/2;
    
   cout << s - t - x + z << endl; 
   
}


Measured memory_bytes: 3164
N=int(input())
xy=[list(map(int,input().split())) for i in range(N)]

total=0
for i in range(N-1):
  for j in range(i+1,N):
    total+=((xy[i][0]-xy[j][0])**2+(xy[i][1]-xy[j][1])**2)**0.5

n=2/N
ans=total*n
print(ans)

Measured memory_bytes: 3188
import java.util.*;
import java.io.*;
import java.math.BigDecimal;

public class Main {	

	private static void solve(){
		//Implement solution here.
		int N = ni();
		int M = ni();
		int[] A = na(N);
		int tv = 0;
		for(int i:A)tv += i;
		int cnt = 0;
		for(int i = 0; i < N; i++) {
			if(cnt >= M) break;
			if(A[i] >= (double)tv / (4 * M))cnt++;
		}
		System.out.println(cnt >= M ? "Yes" : "No");
	}

	//Switch input source (stdin/file)
	private static BufferedReader br;
	public static void main(String[] args){
		br = new BufferedReader(new InputStreamReader(System.in));
		String debugDataPath = System.getenv("DD_PATH");        
		if(debugDataPath != null){
			try{
				br = new BufferedReader(new InputStreamReader(new FileInputStream(new File(debugDataPath))));
			}catch(Exception e){
				throw new RuntimeException(e);
			}
		}
		boolean hasNext = true;
		while(hasNext){
			solve();	
			try{
				br.mark(1);
				if(br.read() > 0){
					br.reset();			
					System.out.println("---");
				} else {
					hasNext = false;
				}
			}catch(Exception e){
				throw new RuntimeException(e);
			} 
		}
	}

	//Input read utility
	private static StringTokenizer tokenizer = null;
	public static String next() {
		while (tokenizer == null || !tokenizer.hasMoreTokens()) {
			try {
				tokenizer = new StringTokenizer(br.readLine());
			} catch (Exception e) {
				throw new RuntimeException(e);
			}
		}
		return tokenizer.nextToken();
	}
	//Get next single int
	private static int ni() {
		return Integer.parseInt(next());
	}
	//Get next single long
	private static long nl() {
		return Long.parseLong(next());
	}
	//Get next single double
	private static double nd() {
		return Double.parseDouble(next());
	}
	//Get next int array from one line
	private static int[] na(int n) {
		int[] a = new int[n];
		for (int i = 0; i < n; i++)
			a[i] = ni();
		return a;
	}
	//Get next char array from one line
	private static char[] ns() {
		return next().toCharArray();
	}
	//Get next long array from one line
	private static long[] nal(int n) {
		long[] a = new long[n];
		for (int i = 0; i < n; i++)
			a[i] = nl();
		return a;
	}
}

Measured memory_bytes: 22996
#include<stdio.h>
#include<algorithm>
#include<stack>
#include<utility>
using namespace std;

const int MAX = 1400;

int main() {
	int H, W;
	int tile[MAX][MAX];
	int ans = 0;

	scanf("%d%d", &H, &W);
	for (int i = 0; i < H; i++) {
		for (int j = 0; j < W; j++) {
			scanf("%d", &tile[i][j]);
		}
	}

	for (int y = 0; y < H; y++) {
		for (int x = W - 1; x >= 0; x--) {
			if (tile[y][x] == 1)tile[y][x] = 0;
			else if (x == W - 1)tile[y][x] = 1;
			else tile[y][x] = tile[y][x + 1] + 1;
		}
	}

	for (int x = 0; x < W; x++) {
		stack<pair<int, int>> s;
		s.push(pair<int, int>(-1, -1));
		for (int y = 0; y < H; y++) {
			if (s.top().second < tile[y][x]) {
				s.push(pair<int, int>(y, tile[y][x]));
			}
			else if (s.top().second > tile[y][x]) {
				int m = y;
				int t = s.top().second;
				while (s.top().second > tile[y][x]) {
					ans = max(ans, (y - s.top().first) * s.top().second);
					m = min(m, s.top().first);
					s.pop();
				}
				if (s.top().second != tile[y][x]) s.push(pair<int, int>(m, tile[y][x]));
			}
		}
		while (!s.empty()) {
			ans = max(ans, (H - s.top().first) * s.top().second);
			s.pop();
		}
	}

	printf("%d\n", ans);

	return 0;
}

Measured memory_bytes: 10296
n,t = map(int,input().split())
ans = 10**9
l = []
for i in range(n):
  l.append(list(map(int,input().split())))
for i in range(n):
  if l[i][1] <= t:
    ans = min(l[i][0],ans)
if ans == 10**9:
  print("TLE")
else:
  print(ans)

Measured memory_bytes: 9048
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#include <algorithm>
#include <utility>
#include <functional>
#include <sstream>
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>
using namespace std;
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v;}
template<class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str();}
typedef vector<int> vi;
typedef vector<vi>  vvi;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef long long ll;
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define EACH(t,i,c) for(t::iretator i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define FOR(i,a,b) for(int i=(a);i<=(b);++i)
#define REP(i,n) FOR(i,0,n-1)
const double EPS = 1e-10;
const double PI = acos(-1.0);
 
int main() {
	int N, M;
	
	while(cin >> N >> M, N) {
		vvi enemy(N, vi(2));
		int total = 0;

		REP(i, N) {
			cin >> enemy[i][1] >> enemy[i][0];
			total += enemy[i][0]*enemy[i][1];
		}
		sort(RALL(enemy));

		REP(i, N) {
			if(M-enemy[i][1] <= 0) {
				total -= M*enemy[i][0];
				break;
			} else {
				M -= enemy[i][1];
				total -= enemy[i][0]*enemy[i][1];
			}
		}

		cout << total << endl;
	}

	return 0;
}

Measured memory_bytes: 1604
#include <iostream>
#include <utility>
#include <iomanip>
#include <cmath>
#include <vector>
#include <algorithm>
#include <set>
#include <unordered_set>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <unordered_map>
typedef long long ll;
using namespace std;
const int N = 2e5 + 5;
const int MOD = 1000000007;

int main()
{
    int n;
    cin >> n;
    if (n == 0)
    {
        cout << '1' << endl;
    }
    else
    {
        cout << '0' << endl;
    }
}


Measured memory_bytes: 3632
#include <iostream>
using namespace std;
#include <string>
 
int main(){
    string u;
  	int minTmp = 9999999;
  
  	cin >> u;
    for (int i=0; i<u.length()-2; i++){
        int tmp = (u[i]-'0')*100 + (u[i+1]-'0')*10 + (u[i+2]-'0') -753;
        minTmp = min(abs(tmp),minTmp);    
    }  
  
    cout << minTmp << endl;

    return 0; 
}

Measured memory_bytes: 256
N, H = tuple(map(int, input().split(' ')))
katanas = [list(map(int, input().split(' '))) for _ in range(0, N)]

normaldmbs = list(map(lambda x: x[0], katanas))
max_normal_dmg = max(normaldmbs)

throwables = list(map(lambda x: x[1], filter(lambda x: x[1] > max_normal_dmg, katanas)))
throwables.sort(reverse=True)

cnt = 0

for v in throwables:
    H -= v
    cnt += 1
    if H <= 0:
        break

if H > 0:
    if H % max_normal_dmg == 0:
        cnt += int(H / max_normal_dmg)
    else:
        cnt += int(H / max_normal_dmg) + 1


print(cnt)

Measured memory_bytes: 29328
#include <bits/stdc++.h>
using namespace std;
#define ll long long 
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    
    ll n;
    cin>>n;
    
    vector<ll> vec;
    
    
    while(n>0)
    {
       n--;
       
       vec.push_back(n%26);
       n = n/26;
    }
    
    reverse(vec.begin(),vec.end());
    
    for(auto x : vec)
    {
        cout<<char(x + 'a');
    }
    
    cout<<"\n";
    
    return 0;
}


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

int main(){
  int N,K,X,Y,sum=0;
  cin>>N>>K>>X>>Y;
  int i=0;
  while(i<K && i<N){
	sum+=X;
  	i++;
  }
  while(i<N){
    sum+=Y;
    i++;
  }
  cout<<sum;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define zero_pad(num) setfill('0') << std::right << setw(num)
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;

int main() {
    string s, t;
    cin >> s >> t;
    rep(i, (int)t.size()) cout << s[i] << t[i];
    if(s.size() != t.size()) cout << s[(int)s.size() - 1];
    cout << endl;
}

Measured memory_bytes: 256
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    long N = sc.nextLong();
    long tmp = 1;
    for(int i = 2; i <= Math.sqrt(N); i++){
      if(N % i == 0){
        tmp = i;
      }
    }
    System.out.println(f(tmp, N/tmp));
  }
  
  public static int f(long a, long b){
    int cnt1 = 0;
    int cnt2 = 0;
    while(a != 0){
      cnt1++;
      a /= 10;
    }
    while(b != 0){
      cnt2++;
      b /= 10;
    }
    return Math.max(cnt1, cnt2);
  }
}

Measured memory_bytes: 21844
#include<iostream>
#include<bits/stdc++.h>
#include<iomanip>
#include<math.h>
#include<vector>
#include<cctype>
#include<string>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
std::string line;
typedef long long ll; 

int main(){
    int n,l;
    cin >> n >> l;
    string s[110];

    rep(i,n) cin >> s[i];

    sort(s, s+n);

    string ans ;

    rep(i,n){
        ans += s[i];
    }
  
    cout << ans << endl;



   return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
using namespace std ;
int main()
{
	int A,B,X;
	cin>>A>>B>>X;
	if(A==X)
	{
		cout<<"YES";
		return 0;
	}
	else if (A>X)
	{
		cout<<"NO";
		return 0; 
	}
	else 
	{
		if(A+B>=X)
		{
			cout<<"YES";
			return 0;
		}
		else 
			cout<<"NO";
	}

	return 0;
}

Measured memory_bytes: 768
# -*- coding: utf-8 -*-
import math
import sys
import itertools
import numpy as np
import functools
import collections
mo = 1000000007
INF = 10**100
r = range

class infix(object):
    def __init__(self, function):
        self.function = function

    def __ror__(self, other):
        self.left = other
        return self

    def __or__(self, other):
        return self.function(self.left, other)

    def __call__(self, value1, value2):
        return self.function(value1, value2)

@infix
def c(f_t_u, f_u_r): return lambda t: f_u_r(f_t_u(t))

class _Ap(object):
    def __rlshift__(self, other):
        self.value = other
        return self

    def __rshift__(self, other):
        return other(self.value)
Ap = _Ap()
ap = Ap

#d = {1:2, 3:5, 6:10, 1000043:3814}
#zip(d.keys(), d.values())<<ap>>(list |c| sorted |c| reversed |c| list |c| print)



n = input()<<ap>>(int)
k = input()<<ap>>(int)
x = input()<<ap>>(int)
y = input()<<ap>>(int)

if n <= k:
    print(n*x);
else:
    print(k*x+(n-k)*y);


Measured memory_bytes: 20252
#include <bits/stdc++.h>
#define  ll long long int

using namespace std;

int main()
{
    ll a,b,flag=0;
    cin>>a>>b;
    ll ans=0;
    if((a+b)%2==0)
        cout<<(a+b)/2<<endl;
    else
        cout<< "IMPOSSIBLE"<<endl;
    return 0;
}


Measured memory_bytes: 256
import itertools

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

def c2i(c):
    if c == '.':
        return 0
    elif c == '#':
        return 1

m = []
lines = []
rows = [0] * W
total = 0

for idx in range(H):
    c = input()
    m.append([*c])

    black_num = c.count('#')
    total += black_num
    lines.append(black_num)
    rows = [row + c2i(c[i]) for i, row in enumerate(rows)]

patterns = []
count = 0

for yy in itertools.product([0, 1], repeat=(H)):
    for xx in itertools.product([0, 1], repeat=(W)):
        sub = 0
        r = 0
        l = 0
        for idx_l, line in enumerate(yy):
            if line == 1:
                l += lines[idx_l]

        for idx_r, row in enumerate(xx):
            if row == 1:
                r += rows[idx_r]

        for idx_l, line in enumerate(yy):
            for idx_r, row in enumerate(xx):
                if not line or not row:
                    continue
                if m[idx_l][idx_r] == '#':
                    sub += 1
        black_num = total - (l + r) + sub
        if black_num == K:
            patterns.append([xx, yy])
            count += 1
print(count)

Measured memory_bytes: 74268
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long LL;
typedef pair<LL,LL> P;
const LL mod=1e9+7;
const LL LINF=1LL<<62;

vector<LL> A,B;

bool check(int k){
    LL mask=1<<k;
    vector<LL> AA,BB;
    for(int i=0;i<A.size();i++){
        AA.pb(A[i]%(1<<(k+1)));
        BB.pb(B[i]%(1<<(k+1)));
    }
    sort(ALL(BB));
    int cnt=0;
    for(int i=0;i<A.size();i++){
        cnt+=lower_bound(ALL(BB),2*mask-AA[i])-lower_bound(ALL(BB),mask-AA[i]);
        cnt+=lower_bound(ALL(BB),4*mask-AA[i])-lower_bound(ALL(BB),3*mask-AA[i]);
    }
    if(cnt&1) return true;
    else return false;
}


int main(){
    int N;
    cin >> N;
    LL a,b;
    for(int i=0;i<N;i++){
        cin >> a;
        A.pb(a);
    }
    for(int i=0;i<N;i++){
        cin >> b;
        B.pb(b);
    }
    int ans=0;
    for(int i=0;i<30;i++){
        if(check(i)) ans+=1<<i;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 8976
#include <bits/stdc++.h>
#define int long long
#define double long double
#define F first
#define S second
using namespace std;

int mod=1e9+7;


int32_t main() {
    int T;
    T=1;
    //cin>>T;
    while(T--){
        int n,k;
        cin>>n>>k;
        int a[n];
        for(int i=0;i<n;i++){
            cin>>a[i];
        }
        vector<bool>dp(k+1);
        for(int i=0;i<=k;i++){
            for(int x:a){
                if(i>=x && dp[i-x]==false){
                    dp[i]=true;
                }
            }
        }
        cout<<(dp[k]?"First":"Second");

        cout<<'\n';
    }
	return 0;
}

Measured memory_bytes: 256
import java.util.*

fun main(args: Array<String>) {
    val sc = Scanner(System.`in`)
    val a = sc.nextInt()
    val b = sc.nextInt()

    println(abc158c(a, b))
}

private fun abc158c(a: Int, b: Int): Int {

    for (i in 1..1000) {
        val oka = calc8(i) == a
        val okb = calc10(i) == b
        if (oka && okb) return i
    }
    return -1
}

private fun calc8(n: Int): Int {
    return n * 8 / 100
}

private fun calc10(n: Int): Int {
    return n * 10 / 100
}

Measured memory_bytes: 31400
/*
https://t.me/unstoppabIesoIvemachinechannel
*/
#pragma ARCENIY_KIRILLOV_POVELITEL_KROKODILOV
//#pragma comment(linker, "/stack:200000000")
//#pragma GCC optimize("Ofast")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//#pragma GCC optimize("no-stack-protector")
//#pragma GCC push_options
//#pragma GCC optimize ("unroll-loops")
//#pragma GCC pop_options
//#pragma GCC target("popcnt")
//#pragma GCC target("sse4")
#include<bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define rng(a) a.begin(),a.end()
#define fast ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define rep(i, n) for (int i = 0; i < n; i++)
#define per(i, n) for (int i = n - 1; i > -1; i--)
#define rer(i, x, n) for (int i = x; i < n; i++)
#define int long long
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef long double ld;















signed main(){
    int n;
    cin >> n;
    vector<int> a(n);
    for(int i = 0;i<n;i++) cin >> a[i];
    sort(a.begin(), a.end());
    int ans = 0;
    for (int i = 0; i < n; i++){
        for (int j = i + 1; j < n; j++){
            int k = (int)(lower_bound(rng(a), a[i] + a[j]) - a.begin());
          //  cout << i << ' ' << j << ' ' << k << endl;
          //  cout << a[i] << ' ' << a[j] << ' ' << a[k] << endl;
            int f = (n - k);
            ans += (f);
        }
    }
    cout << n * (n - 1) * (n - 2) / 6 - ans;

}


Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <cassert>
#include <string>
#include <algorithm>
#include <cstring>
#include <utility>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <cmath>
#include <deque>
#include <unordered_map>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define IOS ios_base::sync_with_stdio(0); cin.tie(0)

using namespace std;
using namespace __gnu_pbds;
typedef long long LL;
typedef pair<int, int> pii;
typedef pair<LL, LL> pll;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> order_set;
const int MAXN = 2345;
int dis[MAXN][MAXN];
int cnt[MAXN];

int main() {
    int N, X, Y;
    scanf("%d %d %d", &N, &X, &Y);
    for (int i = 1; i <= N; i++) {
        for (int j = i + 1; j <= N; j++) {
            dis[i][j] = min({j - i, abs(X - i) + 1 + abs(Y - j), abs(Y - i) + 1 + abs(X - j)});
            cnt[dis[i][j]]++;
        }
    }
    for (int i = 1; i < N; i++)
        printf("%d\n", cnt[i]);
    return 0;
}
/* stuff you should look for
	* int overflow, array bounds
	* special cases (n=1?)
	* do smth instead of nothing and stay organized
	* WRITE STUFF DOWN
by Benq;
*/


Measured memory_bytes: 18688
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000
#define int long long int

int C[51][51];

void comb_table(int N) {
    rep(i, N+1) {
        for (int j = 0; j <= i; j++){
            if(j == 0 || j == i) C[i][j] = 1;
            else C[i][j] = C[i-1][j-1] + C[i-1][j];
        }
    }
}

signed main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N, A, B;
    cin >> N >> A >> B;
    comb_table(N);
    int v[N];
    rep(i, N) cin >> v[i];
    sort(v, v+N, greater<int>());
    double ans = 0;
    rep(i, A) {
        ans += v[i];
    }
    ans /= A;

    int cnt = 0;
    int X = 0, Y = 0;
    rep(i, N) {
        if (v[i] == v[A-1]) {
            X++;
            if(i < A) Y++;
        } 
    }

    if (Y == A) {
        for (int i = A; i <= B; i++) cnt += C[X][i];
    } else {
        cnt += C[X][Y];
    }

    cout.precision(20);
    cout << fixed << ans << endl;
    cout << cnt << endl;

    return 0;
}


Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Scanner;

public class Main {

	static Scanner sc = new Scanner(System.in);

	public static void main(String[] args) {
		int[] c = new int[3];
		int[] len = new int[3];
		while (true) {
			for (int i = 0; i < 3; ++i) {
				len[i] = sc.nextInt();
			}
			Arrays.sort(len);
			if (len[0] + len[1] <= len[2]) {
				System.out.println((c[0] + c[1] + c[2]) + " " + c[0] + " " + c[1] + " " + c[2]);
				break;
			}
			int s = len[0] * len[0] + len[1] * len[1];
			if (s < len[2] * len[2]) {
				c[2]++;
			} else if (s == len[2] * len[2]) {
				c[0]++;
			} else {
				c[1]++;
			}
		}
	}

}

Measured memory_bytes: 20324
#include<iostream>
#include<cstring>
#include<cstdio>
#include<algorithm>
#include<cmath>
#define maxn 100010
#define inf 2147483647
using namespace std;
typedef long long ll;
int pos[maxn];
int n,k;
int res[maxn];
int a[maxn];
int main()
{
    cin>>n>>k;
    for(int i=1;i<=n;i++)  cin>>a[i];
    int sum=0;
    for(int i=1;i<=n;i++)
    {
        if(a[i]<0)
        {
            sum++;
        }
    }
    res[sum]=0-a[sum];
    for(int i=sum-1;i>=1;i--)
    {
        res[i]=res[i+1]+(a[i+1]-a[i]);
    }   
    res[sum+1]=a[sum+1];
    for(int i=sum+2;i<=n;i++){
        res[i]=res[i-1]+(a[i]-a[i-1]);
    }
    //for(int i=1;i<=n;i++)  cout<<res[i]<<" ";
    //cout<<endl;
    //cout<<sum<<"%"<<endl;
    int ans=inf;
    for(int i=0;i<=min(sum,k);i++)
    {
        int tmp=k-i;
        if(tmp>n-sum)  continue;
        int dis1,dis2;
        if(i==0) dis1=0;
        else     dis1=res[sum-i+1];
        if(tmp==0)  dis2=0;
        else     dis2=res[sum+tmp];
        // /cout<<sum+tmp<<endl;
        ans=min(dis1*2+dis2,min(ans,dis2*2+dis1));
    }
    printf("%d\n",ans);
    return 0;
}

Measured memory_bytes: 1024
n = int(input())
if n >= 10000:
	if n >= 100000:
		print(90909)
	else:
		print(n-9999 + 909)
elif n >= 100:
	if n >= 1000:
		print(909)
	else:
		print(n-99 + 9)
else:
	if n >= 10:
		print(9)
	else:
		print(n)



Measured memory_bytes: 2940
#define _GLIBCXX_DEBUG
#include<algorithm>
#include<cmath>
#include<cstring>
#include<cstdio>
#include<iostream>
#include<vector>
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)n; i++)
#define rep2(i,s,n) for(int i=s;i< (int)n; i++)
#define ll long long 
#define all(v) v.begin(),v.end()
using namespace std;
int main(){
  double n,k;
  cin >>n>>k;
  vector<double> p(n);
  rep(i,n) cin >>p[i];
  vector<double> q(n);
  rep(i,n) q[i]=(p[i]+1)/2;
  double  ans=0;
  rep(i,k) ans+=q[i];
  vector<double> r(n-k+1);
  r[0]=ans;
  rep2(i,1,n-k+1){
    r[i]=r[i-1]-q[i-1]+q[i+k-1];
  }
  rep(i,n-k+1){
    ans=max(ans,r[i]);
  }
  cout <<fixed<<setprecision(6)<<ans<<endl;
}

Measured memory_bytes: 4992
import math
a,b = map(int,input().split())
a1 = round(a/0.08)
b1 = round(b/0.1)
c = min(a1,b1)
while True:
	if math.floor(c*0.08) == a and math.floor(c*0.1) == b:
		print(c)
		break
	elif math.floor(c*0.08) > a and math.floor(c*0.1) > b:
		print(-1)
		break
	else:
		c+=1


Measured memory_bytes: 3060
from __future__ import (division, absolute_import, print_function,
                        unicode_literals)
from sys import stdin
from collections import namedtuple
Point = namedtuple('Point', 'x y')

def make_test(p1, p2):
    if p1.x == p2.x:
        gradient = p1.x
        return lambda p: gradient > p.x
    gradient = (p1.y - p2.y) / (p1.x - p2.x)
    y_intercept = p1.y - gradient * p1.x
    return lambda p: gradient * p.x + y_intercept > p.y

for line in stdin:
    it = (float(s) for s in line.split(','))
    A, B, C, D = (Point(next(it), next(it)) for _ in xrange(4))

    f = make_test(A, C)
    g = make_test(B, D)
    if f(B) == f(D) or g(A) == g(C):
        print('NO')
    else:
        print('YES')

Measured memory_bytes: 4792
#include <bits/stdc++.h>
//#include <atcoder/all>
#define rep(i, n) for (int i = 0; i < (n); ++i)
 //using namespace atcoder;
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
//マクロ
// forループ関係
//引数は、(ループ内変数,動く範囲)か(ループ内変数,始めの数,終わりの数)、のどちらか
// Dがついてないものはループ変数は1ずつインクリメントされ、Dがついてるものはループ変数は1ずつデクリメントされる
#define FOR(i, a, b) for (ll i = a; i < (ll)(b); i++)
#define _GLIBCXX_DEBUG
// xにはvectorなどのコンテナ
#define ALL(x) (x).begin(), (x).end()  // sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size())       // sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x))    //最大値を求める
#define MIN(x) *min_element(ALL(x))    //最小値を求める
//定数
#define INF 1000000000000  // 10^12:極めて大きい値,∞
#define inf 2147483647     // int値の最大値
#define MOD 1000000007     // 10^9+7:合同式の法
#define MAXR 100000        // 10^5:配列の最大のrange(素数列挙などで使用)
//略記
#define PB push_back                             // vectorヘの挿入
#define MP make_pair                             // pairのコンストラクタ
#define F first                                  // pairの一つ目の要素
#define S second                                 // pairの二つ目の要素
#define CST(x) cout << fixed << setprecision(x)  //小数点以下の桁数指定
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;
}
int gcd(int a, int b) {
    if (b == 0)
        return a;
    else
        return gcd(b, a % b);
}
int lcm(int a, int b) {
    return a * b / gcd(a, b);
}
//各桁の和
int sumDight(int x) {
    int sum = 0;
    while (x > 0) {
        sum += (x % 10);
        x /= 10;
    }
    return sum;
}
//回文数
int divideReverse(int x) {
    int reverse = 0;
    int r;
    while (x > 0) {
        r = x % 10;
        reverse = reverse * 10 + r;
        x /= 10;
    }
    return reverse;
}

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

    int n;
    cin >> n;
    string s;
    cin >> s;
    if (n % 2 == 1) cout << "No" << endl;
    else{
        string t = s.substr(0, n / 2);
        string a = s.substr(n / 2, n - 1);
       // cout << t<<a;
        if (t == a) cout << "Yes" << endl;
        else
            cout << "No" << endl;
    }
}


Measured memory_bytes: 3552
#include <iostream>

using namespace std;

int main () {
    int m, f, r;
    while (true) {
        cin >> m >>f >> r;
        
        if (m == -1 && f == -1 && r == -1) break;

        if (m == -1 || f == -1) cout << 'F' << endl;
        else if (m + f >= 80) cout << 'A' << endl;
        else if (m + f >= 65) cout << 'B' << endl;
        else if (m + f >= 50 || (m + f >= 30 && r >= 50)) cout << 'C' << endl;
        else if (m + f >= 30) cout << 'D' << endl;
        else cout << 'F' << endl;
    }
}


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

typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;

#define mp make_pair
#define pb(x) push_back(x)
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repp(i, s, e) for (int i = (s); i < (e); i++)
#define all(x) x.begin(), x.end()

#define INF 2123456789
#define IINF 9123456789123456789

void use_cio() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
}
// template <typename... Args>
// void dbg(Args... args) {
//     ((cout << args << " "), ...);
//     cout << endl;
// }

//--------------------------------------------------//
int main() {
    string s, t;
    cin >> s >> t;
    rep(i, s.size()) {
        if (s == t) {
            cout << "Yes";
            return 0;
        }
        s = s.substr(1, s.size() - 1) + s[0];
    }
    cout << "No";
}

Measured memory_bytes: 256
/*
* @author:  codancer
*/
#include<bits/stdc++.h>

using namespace std;
typedef long long ll;
const ll mod = 1e9+7;
#define pb push_back
#define SZ(x) ((int)(x).size())
#define fi first
#define se second
typedef vector<int> VI;
typedef pair<int,int> pii;
int main(){
	int a[3][3];
	for(int i=0;i<3;i++){
		for(int j=0;j<3;j++){
			cin>>a[i][j];
		}
	}
	map<int,int> mp;
	int n,x;
	cin>>n;
	for(int i=1;i<=n;i++){
		cin>>x;
		mp[x]=1;
	}
	bool bingo=0;
	for(int i=0;i<3;i++){
		if(mp[a[i][0]]&&mp[a[i][1]]&&mp[a[i][2]]) bingo=1;
	}
	for(int i=0;i<3;i++){
		if(mp[a[0][i]]&&mp[a[1][i]]&&mp[a[2][i]]) bingo=1;
	}
	if(mp[a[1][1]]&&mp[a[0][0]]&&mp[a[2][2]]) bingo=1;
	if(mp[a[0][2]]&&mp[a[1][1]]&&mp[a[2][0]]) bingo=1;
	if(bingo){
		cout<<"Yes"<<endl;
	}else{
		cout<<"No"<<endl;
	}
	return 0;
}


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

int main() {
    int A, N, a;
    cin >> N;
    cin >> A;
    a = N%500;
    if (a <= A) {
        cout << "Yes" << endl;
    }
    else {
        cout << "No" << endl;
    }
}

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

#define pb push_back

#define int ll
using ll = long long;
using pii = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vi>;
using vpii = vector<pii>;
using vvpii = vector<vpii>;

template<typename T, typename U>
ostream& operator<<(ostream& o, const pair<T,U>& p) {
  return o << "(" << p.first << "," << p.second << ")";
}

template<typename T>
ostream& operator<<(ostream& o, const vector<T>& v) {
  o << "[";
  for (const T& x : v)
    o << x << ",";
  return o << "]";
}

const int INF = 1e18;

signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);

  int a, b;
  cin >> a >> b;
  double h, m;
  cin >> h >> m;

  double hal = (h+m/60)/12*2*M_PI;  // BUG was here: forgot to add minutes term
  double xh = sin(hal)*a;
  double yh = cos(hal)*a;

  double mal = m/60*2*M_PI;
  double xm = sin(mal)*b;
  double ym = cos(mal)*b;

  //cerr << "dbg " << xh << " " << yh << ", " << xm << " " << ym << endl;
  cout << setprecision(18) << sqrt((xm-xh)*(xm-xh) + (ym-yh)*(ym-yh)) << endl;
}


Measured memory_bytes: 4072
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <vector>
#include <algorithm>
#include <set>
using namespace std;

int main()
{
    string s;
    cin >> s;
    cout << s.at(0) << s.size()-2 << s.at(s.size()-1);
    return 0;
}

Measured memory_bytes: 256
abc = list(map(int, input().split()))

abc.sort()
ans = 0

while True:
    if abc[0] == abc[1] and abc[1] == abc[2]:
        print(ans)
        break

    if abc[1] != abc[2]:
        abc[0] += 1
        abc[1] += 1
        ans += 1
    elif abc[1] == abc[2] and abc[1] + 1 == abc[0]:
        abc[1] += 1
        abc[2] += 1
        ans += 1
    else:
        abc[0] += 2
        ans += 1
    

Measured memory_bytes: 3064
#include<stdio.h>
#define SZ 1001
int k, n, A[SZ][SZ];
int main() {
	int i, j;
	scanf("%d", &k);
	if (k <= 500) {
		printf("%d\n", k);
		for (i = 1; i <= k; i++) {
			for (j = 1; j <= k; j++) {
				printf("%d ", i);
			}
			printf("\n");
		}
	}
	else {
		n = 500;
		for (i = 0; i < n; i++) {
			for (j = 0; j < n; j++) {
				A[i][j] = (i % 2 == 0) ? (i + j) % (n) : (i + j) % n + n;
				if (A[i][j] >= k) {
					A[i][j] -= n;
				}
			}
		}
		printf("%d\n", n);
		for (i = 0; i < n; i++) {
			for (j = 0; j < n; j++) {
				printf("%d ", 1 + A[i][j]);
			}
			printf("\n");
		}
	}
}

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

// a is subseq of b (b is ordering)
bool is_subseq(const string &a, const string &b){
    int used[256] = {};
    for(char c: a) used[(int)c]++;
    string tmp = "";
    for(char c: b){
        if(used[(int)c] == 1) tmp += c;
    }
    return a == tmp;
}
string remstr(const string &a, const string &b){
    int used[256] = {};
    for(char c: a) used[(int)c]++;
    string res = "";
    for(char c: b){
        if(used[(int)c] == 0) res += c;
    }
    return res;
}

int main(){
    int n,m;
    cin >> n >> m;
    vector<string> str(n);
    for(int i=0; i<n; i++){
        cin >> str[i];
    }
    vector<vector<string>> other(n);
    for(int i=0; i<n; i++){
        bool used[256] = {};
        for(char c: str[i]) used[(int)c] = true;
        string unused = "";
        for(int j=0; j<n; j++){
            if(!used['A'+j]) unused += 'A'+j;
        }
        do{
            other[i].push_back(unused);
        }while(next_permutation(unused.begin(), unused.end()));
    }

    vector<vector<map<string, string>>> dp(1<<n, vector<map<string, string>>(n));
    for(int i=0; i<n; i++){
        for(string &t: other[i]){
            dp[1<<i][i][t] = string(1, 'A'+i);
        }
    }
    for(int i=1; i<(1<<n); i++){
        for(int j=0; j<n; j++){
            for(string &s: other[j]){
                if(dp[i][j].count(s) == 0) continue;
                for(int k=0; k<n; k++){
                    if(i>>k&1) continue;
                    string tmp = s+str[j];
                    reverse(tmp.begin(), tmp.end());
                    if(!is_subseq(str[k], tmp)) continue;
                    int ni = i | (1<<k);
                    string t = remstr(str[k], tmp);
                    reverse(t.begin(), t.end());
                    if(dp[ni][k].count(t) == 0){
                        dp[ni][k][t] = dp[i][j][s] + string(1, 'A'+k);
                    }else{
                        dp[ni][k][t] = min(dp[ni][k][t], dp[i][j][s] + string(1, 'A'+k));
                    }
                }
            }
        }
    }
    string ans = string(n, 'Z');
    for(auto &vm: dp[(1<<n)-1]){
        for(auto &p: vm){
            ans = min(ans, p.second);
        }
    }
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 153164
#include<bits/stdc++.h>
using namespace std;
int main()
{
map<char,int>m,n;
int a,b,i,j;
string s,ss;
cin>>a;
ss="abcdefghijklmnopqrstuvwxyz";
for(j=1;j<=a;j++)
{
  cin>>s;
  for(i=0;i<s.size();i++)
  m[s[i]]++;
  if(j==1)n=m;
  else
   {
  for(i=0;i<ss.size();i++)
   {
   n[ss[i]]=min(n[ss[i]],m[ss[i]]);
   }
   }
  m.clear();

}
for(i=0;i<ss.size();i++)
{
 b=n[ss[i]];
for(j=1;j<=b;j++)cout<<ss[i];
}
}

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

int main(){
	int N, M, C;
	cin >> N >> M >> C;
	int B[M];
	int A[N][M];
	for(int i=0;i<M;i++){
		cin >>B[i];
	}
	for(int j = 0;j<N;j++){
		for(int i=0;i<M;i++){
			cin >> A[j][i];
		}
	}
	int count = 0;
	for(int j=0;j<N;j++){
		int sum = 0;
		for(int i=0;i<M;i++){
			sum += A[j][i] * B[i];
		}
		sum += C;
		if(sum > 0) count++;
	} 
	cout << count << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <sstream>
#include <iomanip> 
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <queue>
#include <stack>
#include <vector>
#include <map>
#include <set>
#include <functional>
#include <algorithm>
#include <unordered_map>
#include <unordered_set>
#include <bitset>

using namespace std;


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

	int n, i, j, k, s;
	cin >> n >> k;
	vector<int> a(n);
	for (i = 0; i < n; i++) cin >> a[i];
	sort(a.rbegin(), a.rend());
	s = 0;
	for (i = 0; i < k; i++) s += a[i];
	cout << s << "\n";

	return 0;
}


Measured memory_bytes: 504
#include<cstdio>
#include<algorithm>
#include<vector>
using namespace std;
int w[3010], D[3010], n;
vector<int>E[3010];
void DFS(int a, int pp){
    int i, x, ck = 0;
    D[a] = 0;
    for(i=0;i<E[a].size();i++){
        x = E[a][i];
        if(x==pp)continue;
        DFS(x, a);
        if(!D[x] && w[a] > w[x]) D[a] = 1;
    }
}
int main(){
    int i, a, b;
    scanf("%d",&n);
    for(i=1;i<=n;i++)scanf("%d",&w[i]);
    for(i=1;i<n;i++){
        scanf("%d%d",&a,&b);
        E[a].push_back(b);
        E[b].push_back(a);
    }
    for(i=1;i<=n;i++){
        DFS(i,0);
        if(D[i])printf("%d ",i);
    }
}

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

using namespace std;

int main(){
  int n;
  string s;
  cin >> n >> s;
  int wcnt=0;
  for(int i=0;i<n;++i){
    if(s[i]=='.') wcnt++;
  }
  int min=n,lb=0,rw=wcnt;
  for(int i=0;i<n;++i){
    if(min>lb+rw) min = lb+rw;
    if(s[i]=='#') lb++;
    else if(s[i]=='.') rw--;
  }
  if(min>lb+rw) min = lb+rw;
  cout << min << endl;
  
  return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include<algorithm>
#include <stdio.h>
#include <string.h>

#include<vector>
#include<map>
#include<math.h>
#include<stack>
#include<unordered_map>

using namespace std;
int n,h,l,r;
const int N = 1e6;
int arr[N];
const int M = 3000;
int dp[M];
int main() {
   int n; cin >> n;
   int h[n];
   for (int i = 0; i < n; i ++) cin >> h[i];
   // 4
   // 10 30 40 20
   // dp[0] = 10
   // dp[1] = 20
   // dp[2] = dp[i - 1] + abs(h[i - 1] - h[i])
   // 0 -> 1, 0-> 2
   // 20
   //
   dp[0] = 0; dp[1] = abs(h[0] - h[1]);
   for (int i = 2; i < n; i ++) {
       dp[i] = min(dp[i - 1] + abs(h[i - 1] - h[i]), dp[i - 2] + abs(h[i - 2] - h[i]));
   }

   cout << dp[n - 1];


    return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <sstream>
#include <algorithm>
#include <cstdio>
#include <cmath>
#include <set>
#include <map>
#include <queue>
#include <string>
#include <cstring>
#include <bitset>
#include <functional>
#include <random>
#define REP(_i,_a,_n) for(int _i=_a;_i<=_n;++_i)
#define PER(_i,_a,_n) for(int _i=_n;_i>=_a;--_i)
#define hr putchar(10)
#define pb push_back
#define lc (o<<1)
#define rc (lc|1)
#define mid ((l+r)>>1)
#define ls lc,l,mid
#define rs rc,mid+1,r
#define x first
#define y second
#define io std::ios::sync_with_stdio(false)
#define endl '\n'
#define DB(_a) ({REP(_i,1,n) cout<<_a[_i]<<',';hr;})
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
const int P = 1e9+7, INF = 0x3f3f3f3f;
ll gcd(ll a,ll b) {return b?gcd(b,a%b):a;}
ll qpow(ll a,ll n) {ll r=1%P;for (a%=P;n;a=a*a%P,n>>=1)if(n&1)r=r*a%P;return r;}
ll inv(ll x){return x<=1?1:inv(P%x)*(P-P/x)%P;}
inline int rd() {int x=0;char p=getchar();while(p<'0'||p>'9')p=getchar();while(p>='0'&&p<='9')x=x*10+p-'0',p=getchar();return x;}
//head



#ifdef __APPLE__
const int N = 1e2+50;
#else
const int N = 1e6+50;
#endif


char s[N];
int n;
int chk(int x) {
	REP(k,0,1) {
		int a=k, b=x;
		if (a%2!=b%2) --b;
		REP(i,1,n) {
			if (s[i]=='0') --a,--b;
			else if (s[i]=='1') ++a,++b;
			else --a,++b;
			if (a<0) a+=2;
			if (b>x) b-=2;
			if (b<a) break;
			if (i==n) return 1;
		}
	}
	return 0;
}
int main() {
	scanf("%s", s+1);
	n = strlen(s+1);
	if (n==1) return puts("1"),0;
	int l = 0, r = n, ans;
	while (l<=r) {
		if (chk(mid)) ans=mid,r=mid-1;
		else l=mid+1;
	}
	printf("%d\n", ans);
}

Measured memory_bytes: 4804