akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
#define F first
#define S second
const ll inf = 1e18;
const int N = 16;
ll ps[N], px[N];
void cal(vector<pii> & v, ll dp[N][N][2])
{
    sort(v.begin(), v.end());
    int n = v.size();
    memset(dp, 0x3f, N * N * 2 * sizeof(ll));
    ps[0] = px[0] = 0;
    for (int i = 1; i <= n; ++i) {
        ps[i] = v[i - 1].S + ps[i - 1];
        px[i] = v[i - 1].S * 1ll * v[i - 1].F + px[i - 1];
    }
    for (int i = 0; i <= n; ++i)
        for (int j = i; j < N; ++j)
            dp[i][j][0] = dp[i][j][1] = 0;
    for (int i = 0; i <= n; ++i) {
        for (int j = 0; j < N; ++j)
            dp[i][j][1] = min(dp[i][j][1], dp[i][j][0]);
        int mi = i + 1;
        ll c0 = 0;
        for (int rt = i; rt < n; ++rt) {
            c0 += abs(v[rt].F) * 1ll * v[rt].S;
            // calculate f(i, rt), update dp[rt + 1][j + 1][]
            while ((ps[mi] - ps[i]) * 2 <= ps[rt + 1] - ps[i])
                ++mi;
            ll mx = v[mi - 1].F;
            ll cw = px[rt + 1] - px[mi] - (ps[rt + 1] - ps[mi]) * mx + (ps[mi] - ps[i]) * mx - (px[mi] - px[i]);
            for (int j = 0; j < N; ++j) {
                dp[rt + 1][j][1] = min(dp[rt + 1][j][1], dp[i][j][0] + c0);
                if (j + 1 < N) {
                    dp[rt + 1][j + 1][0] = min(dp[rt + 1][j + 1][0], dp[i][j][0] + cw);
                    dp[rt + 1][j + 1][1] = min(dp[rt + 1][j + 1][1], dp[i][j][1] + cw);
                }
            }
        }
    }
}
ll dp1[N][N][2], dp2[N][N][2];
ll ans[N];
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    int n;
    cin >> n;
    vector<array<int, 3>> v(n);
    for (int i = 0; i < n; ++i)
        for (int j = 0; j < 3; ++j)
            cin >> v[i][j];
    memset(ans, 0x3f, sizeof ans);
    for (int S = 0; S < (1 << n); ++S) {
        vector<pii> vx, vy;
        for (int i = 0; i < n; ++i)
            if (S >> i & 1)
                vx.emplace_back(v[i][0], v[i][2]);
            else
                vy.emplace_back(v[i][1], v[i][2]);
        cal(vx, dp1);
        cal(vy, dp2);
        int L = vx.size(), R = vy.size();
        for (int k = 0; k <= n; ++k)
            for (int i = 0; i <= k; ++i)
                ans[k] = min(ans[k], dp1[L][i][1] + dp2[R][k - i][1]);
    }
    for (int i = 0; i <= n; ++i)
        cout << ans[i] << endl;
}


Measured memory_bytes: 3692
s,x=gets.split;l=s.size-1;a=[*?0..?9]-gets.split
(puts s;exit)if !j=(0..l).find{|i|!a.find{|e|e==s[i]}}
k=j.downto(0).find{|i|x=a.find{|e|e>s[i]}}||-1
puts (k<0?a[0]>?0?a[0]:a[1]:s[0...k]+x)+a[0]*(l-k)

Measured memory_bytes: 1916
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n,k;
	cin>>n>>k;
	int a[n+1]={0};
	a[0]=-1;
	for(int i=0;i<k;i++){
		int d;
		cin>>d;
		for(int j=0;j<d;j++){
			int b;
			cin>>b;
			a[b]++;
		}
	}
	int count=0;
	for(int i=1;i<n+1;i++){
		if(a[i]==0){
			count++;
		}
	}
	cout<<count<<endl;
	
	return 0;
}

Measured memory_bytes: 3640
#include<iostream>
#include<string>
#include<algorithm>
#include<math.h>
using namespace std;

/*int par[100000];

void init(int n){
    for(int i=0; i<n; i++) par[i] = i;
}

int find(int x){
    if(par[x] == x) return x;
    else{
        par[x] = find(par[x]);
        return par[x];
    }
}

int min(int a, int b){
    if(a > b) return b;
    else return a;
}

void unite(int x, int y){
    x = find(x);
    y = find(y);
    if(x == y) return;

    par[x] = y;
}*/

int main(){

	int p,m,c;
	cin >> p >> m >> c;
	cout << p+m+c << endl;
/*int W;
cin>>W;
cout<<W*32<<endl;*/
    return 0;
}


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

int main(){
  int h, n, sum=0; cin>>h >>n;
  for(int i=0;i<n;i++){
    int a; cin>>a;
    sum+=a;
    if(sum>=h){
      cout<<"Yes"<<endl;
      return 0;
    }
  }
  
  cout<<"No"<<endl;
  return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <tuple>
#include <vector>
using namespace std;
typedef long long ll;
ll const INF = 1LL << 60;
ll const MOD = 1000000007;

int main() {
  ll N;
  cin >> N;
  vector<ll> A(N), accum(N, 0);
  for (int i = 0; i < N; i++) {
    cin >> A[i];
    if (i == 0)
      accum[0] = A[0];
    else
      accum[i] = accum[i - 1] + A[i];
  }
  ll ans = 0;
  for (int i = 0; i < N; i++) {
    ll suma = A[i] * ((accum[N - 1] - accum[i]) % MOD);
    suma %= MOD;
    ans = (ans + suma) % MOD;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 6368
n = int(input())
s = [input() for _ in range(n)]

a = 0
b = 0
ba = 0
ans = 0
for v in s:
    ans += v.count("AB")
    if v[0] == "B" and v[-1] == "A":
        ba += 1
    elif v[0] == "B":
        b += 1
    elif v[-1] == "A":
        a += 1

ans += max(0, ba - 1)
if ba:
    if a:
        ans += 1
        a -= 1
    if b:
        ans += 1
        b -= 1

ans += min(a, b)

print(ans)

Measured memory_bytes: 44248
/*
    Code written by Talant I.D.
*/
   
#include <bits/stdc++.h>
   
using namespace std;
   
typedef long long ll;
typedef pair <int, int> pii;
typedef tuple <int, int, int> tiii;
   
#define precision(n) fixed << setprecision(n)
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define mod (int)1e9+7
#define eps (double)1e-9
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define do_not_disturb ios::sync_with_stdio(0);cin.tie(0);
#define curMod 998244353

int main(){
		//do_not_disturb
		ll a[3];
		cin >> a[0] >> a[1] >> a[2];
		sort(a, a+3);
		
		if(a[2]%2 == 0 || a[1]%2==0 || a[0]%2==0){
			cout << 0;
		}
		else{
			cout << a[1]*a[0];
		}
		
    return 0;
} // What is to be written here?


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

using namespace std;

typedef long long ll;

const double pi = 3.14159265358979323846;

#define rep(i, n) for (ll i = 0; i < n; i++)
#define mod 1000000007LL
#define PS(p) cout << setprecision(15) << fixed << p << endl;
#define UNIQUE(v) v.erase(std::unique(v.begin(), v.end()), v.end());
#define ALL(c) c.begin(), c.end()
#define COUT(v) cout << v << endl;

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

  switch (D) {
  case 25:
    COUT("Christmas");
    break;
  case 24:
    COUT("Christmas Eve");
    break;
  case 23:
    COUT("Christmas Eve Eve");
    break;
  case 22:
    COUT("Christmas Eve Eve Eve");
    break;

  default:
    break;
  }
  return 0;
}


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

int main(){
	int N,M; cin>>N>>M;
	int maxi = 1;//answer. max(gcd({a1~aN}))
	for(int g=1; g*g<=M; ++g){//g: max divisor candidate
		if(M%g) continue;
		int pg = M/g;//pg: pair divisor (g, pg)
		if((ll)g*N<=M) maxi = max(maxi, g);
		if((ll)pg*N<=M) maxi = max(maxi, pg);
	}
	cout<< maxi <<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(),(x).end()
using ll = long long;
using ld = long double;
#define vpl vector<pair<long long,long long>>
#define vl vector<long long>
#define vvl vector<vector<long long>>
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define rep2(i, s, n) for (ll i = (s); i < (ll)(n); i++)
using pll = pair<long long,long long>;
#define cY cout<<"Yes"<<endl
#define cN cout<<"No"<<endl
const long long INF = 1LL << 60;
long long MOD = 1000000007;
const long double pi = 3.1415926535897932;
#define pb push_back
#define mp make_pair
#define mt make_tuple
using Grid = vector<vector<char>>;
#define vc vector<char>
//(mod m)でのaの逆元を計算する
//a/b(mod m)=a(mod m)*modinv(b,m)
long long modinv(long long a, long long m) {
    long long b = m, u = 1, v = 0;
    while (b) {
        long long t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}

//最大最小の入れ替え
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<long long> divisor(long long n) {
    vector<long long> ret;
    for (long long i = 1; i * i <= n; i++) {
        if (n % i == 0) {
            ret.push_back(i);
            if (i * i != n) ret.push_back(n / i);
        }
    }
    sort(ret.begin(), ret.end()); // 昇順に並べる
    return ret;
}
//コンビネーション
ll nCr(ll n, ll r) {
    ll ans = 1;
    for (ll i = n; i > n - r; --i) {
        ans = ans*i;
    }
    for (ll i = 1 ; i < r + 1; ++i) {
        ans = ans / i;
    }
    return ans;
}
//素因数分解
map< ll, ll > prime_factor(ll n) {
  map< ll, ll > ret;
  for(ll i = 2; i * i <= n; i++) {
    while(n % i == 0) {
      ret[i]++;
      n /= i;
    }
  }
  if(n != 1) ret[n] = 1;
  return ret;
}

//切り上げの割り算は(a + b - 1) / bでできる

//ここから
int main(){
    string s;
    cin>>s;
    ll count=0;
    ll N=s.size();
    rep(i,N){
        if(i%2==0&&s[i]=='p'){
            count--;
        }else if(i%2==1&&s[i]=='g'){
            count++;
        }
    }
    cout<<count<<endl;
}

Measured memory_bytes: 512
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <cmath>
#include <iomanip>
#include <stack>
#include <queue>
#include <numeric>
#include <map>
#include <unordered_map>
#include <set>
#include <fstream>
#include <chrono>
#include <random>
#include <bitset>
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define sz(x) ((int)(x).size())
#define pb push_back
using ll = long long;
using namespace std;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
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;}

int main(){
  int N; cin >> N;
  vector<ll> A(N); rep(i,N) cin >> A[i];
  map<ll,ll> mp;
  ll ans = 0;
  rep(i,N){
    ans += mp[-A[i]+i+1];
    mp[A[i]+i+1]++;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 27380
#include "bits/stdc++.h"
#define Rep(i,n) for(int i=0;i<(int)(n);i++)
#define For(i,n1,n2) for(int i=(int)(n1);i<(int)(n2);i++)
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define RREP(i,n) for(ll i=((ll)(n)-1);i>=0;i--)
#define FOR(i,n1,n2) for(ll i=(ll)(n1);i<(ll)(n2);i++)
#define RFOR(i,n1,n2) for(ll i=((ll)(n1)-1);i>=(ll)(n2);i--)
#define all(a)  (a).begin(),(a).end()
#define IOS std::cin.tie(0),std::ios::sync_with_stdio(false)

namespace idaten {

	using namespace std;
	using ll = int_fast64_t;
	using ull = uint_fast64_t;
	using P = std::pair<int64_t, int64_t>;
	template<typename T1, typename T2> inline bool chmin(T1& a, T2 b) { if (a > b) { a = b; return 1; }return 0; }
	template<typename T1, typename T2> inline bool chmax(T1& a, T2 b) { if (a < b) { a = b; return 1; }return 0; }
	template<class T> inline std::istream& operator >> (std::istream& is, std::vector<T>& v) { for (T& x : v) { is >> x; }return is; }
	template<class T> inline std::ostream& operator << (std::ostream& os, const std::vector<T>& v) {
		for (auto itr = v.begin(); itr != v.end();) { os << (*itr) << ((++itr != v.end()) ? " " : ""); }
		return os;
	}
	template<class V, typename T>inline void fill(V& v, const T& val) { v = val; }
	template<class V, typename T>inline void fill(std::vector<V>& v, const T& val) { for (V& x : v) { fill(x, val); } }
	template<class V, typename H>inline void resize(std::vector<V>& v, const H h) { v.resize(h); }
	template<class V, typename H, typename... T>inline void resize(std::vector<V>& v, const H& h, const T& ... t) { v.resize(h); for (auto& x : v) { resize(x, t...); } }
	inline void put() {}
	template<class T> inline void put(const T& first) { std::cout << first << "\n"; }
	template<class T, class... N> inline void put(const T& first, const N& ... rest) { std::cout << first << " "; put(rest...); }

	void solve() {
		IOS;
		int k;
		cin >> k;
		string s;
		cin >> s;
		int n = s.size();
		if (n <= k) {
			put(s);
		} else {
			REP(i, k) {
				cout << s[i];
			}
			put("...");
		}
	}
} // namespace idaten

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


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

int main(void) {
    string str;
    char order[16];
    int n;
    int a, b;
    char word[1000];
    
    cin >> str;
    cin >> n;
    
    for(int i = 0; i < n; ++i) {
        cin >> order;
        
        if(strstr(order, "print")) {
            cin >> a >> b;
            for(int j = a; j < b + 1; ++j) {
                cout << str[j];
            }
            cout << endl;
        } else if(strstr(order, "reverse")) {
            cin >> a >> b;
            for(int j = 0; j < (double)(b - a + 1) / 2; ++j) {
                char cpy = str[a + j];
               str[a + j] = str[b - j];
                str[b - j] = cpy;
            }
        } else if(strstr(order, "replace")) {
            cin >> a >> b >> word;
            str.replace(a, b - a + 1, word);
        }
    }
    return 0;
}




Measured memory_bytes: 3220
import java.util.*;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
 
		long h = sc.nextLong();
		
		int k = 0;
		while(h>0) {
			k++;
			h = h/2;
		}
		
		long time = 0, c = 1;
		for(int i=1;i<=k;i++) {
			time+=c;
			c*=2;
		}
		
		System.out.println(time);
	}
}

Measured memory_bytes: 21844
# coding: utf-8
import sys

def main(argv=sys.argv):
  
  n = int(input())
  k = int(input())
  x = int(input())
  y = int(input())
  
  if n <= k:
    print(n * x)
  else:
    print(k * x + (n - k) * y)
  
  
  return 0

if __name__ =='__main__':
  sys.exit(main())

Measured memory_bytes: 3060
#include <bits/stdc++.h>
            #include <ext/pb_ds/assoc_container.hpp>
            #include <ext/pb_ds/tree_policy.hpp>
            using namespace std;
            using namespace __gnu_pbds;
            #define rep(i,a,b) for(ll i =a; i<b;++i)
            #define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
            #define endl "\n"
            #define pb push_back
            #define F first
            #define S second
            #define print(a)       for(auto x : a) cout << x << " "; cout << endl
            #define print1(a)      for(auto x : a) cout << x.F << " " << x.S << endl
            #define print2(a,x,y)  for(int i = x; i < y; i++) cout<< a[i]<< " "; cout << endl
            #define mk(x,y)  make_pair(x,y)
            typedef long long int ll;
            const ll N =  1e6+ 5 ;
            const ll mod = 998244353;
            ll   n  ,ans[N] , dp[3005][3005] , a , b ,c , d;
    ll pow_mod_m(ll a , ll n)
    {
        if(!n)
            return 1;
        ll pt =  pow_mod_m(a,n/2);
        pt *= pt , pt %= mod;
        if(n&1)
            pt *= a  ,pt %= mod;
        return pt;
    }


    int main()
    {
         IOS;
         int ts =1;
///      cin >> ts;
         while(ts--)
         {
            cin >> a >> b >> c >> d;
            dp[a][b] = 1;
            rep(i,a , c+1)
            {
                rep(j , b ,d+1)
                {
                    dp[i][j] += (j)*dp[i-1][j];
                    dp[i][j] += (i)*dp[i][j-1];
                    dp[i][j]  -= (i-1)*(j-1)*dp[i-1][j-1];
                    if(dp[i][j] < 0)
                    {
                        dp[i][j] = ( mod - llabs( dp[i][j] ) % mod );
                    }
                    dp[i][j] %= mod;
                }
               /// cout << endl;
            }
            cout << dp[c][d]% mod << endl;
         }
    }


Measured memory_bytes: 73952
def lscan; gets.split.map(&:to_i); end

n,m = lscan
sc = m.times.map{lscan}

0.upto(999) do |x|
  t = x.to_s
  next if t.size != n

  if sc.all?{|s,c| t[s-1] == c.to_s}
    p x
    exit
  end
end
p -1

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

using ll = long long;

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

  int A[N];
  for (int i = 0; i < N; i++) {
    cin >> A[i];
  }
  sort(A, A+N, greater<int>());

  ll ans = A[0];

  int i = 1;
  int count = 0;
  while (count<N-2){
    ans += A[i];
    count++;
    if (count%2==0){
      i++;
    }
  }

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

Measured memory_bytes: 4404
import std.stdio, std.array, std.string, std.conv, std.algorithm;
import std.typecons, std.range, std.random, std.math, std.container;
import std.numeric, std.bigint, core.bitop, std.bitmanip, std.regex;

void main() {
    auto N = readln.chomp.to!int;
    auto E = new Tuple!(int, int, int, long)[](N-1);
    foreach (i; 0..N-1) {
        auto s = readln.split.map!(to!int);
        E[i] = tuple(i, s[0]-1, s[1]-1, s[2].to!long);
    }
    E.sort!"a[3] > b[3]";

    if (N == 1) {
        writeln(0);
        return;
    }


    auto G = new Tuple!(int, long)[][](N + N - 1);
    auto uf = new UnionFind(N);

    foreach (e; E) {
        int i = e[0] + N;
        int u = uf.find(e[1]);
        int v = uf.find(e[2]);
        long w = e[3];
        if (u == v) continue;
        G[i] ~= tuple(uf.par[u], w * -uf.table[v]);
        G[i] ~= tuple(uf.par[v], w * -uf.table[u]);
        uf.unite(u, v, i);
    }

    auto ans = new long[](N);

    void dfs(int n, long w) {
        if (n < N) {
            ans[n] += w;
            return;
        }
        foreach (to; G[n]) {
            dfs(to[0], w + to[1]);
        }
    }

    dfs(E.back[0] + N, 0);
    ans.each!writeln;
}

class UnionFind {
    int N;
    int[] table;
    int[] par;

    this(int n) {
        N = n;
        table = new int[](N);
        fill(table, -1);
        par = N.iota.array;
    }

    int find(int x) {
        return table[x] < 0 ? x : (table[x] = find(table[x]));
    }

    void unite(int x, int y, int p) {
        x = find(x);
        y = find(y);
        if (x == y) return;
        if (table[x] > table[y]) swap(x, y);
        table[x] += table[y];
        table[y] = x;
        par[x] = p;
    }
}


Measured memory_bytes: 25340
#include <bits/stdc++.h>
using namespace std;
#define itn int
#define nibu(K,x) binary_search(K.begin(),K.end(),x)
#define rep**(i,n) for(int i=0;i<n;i++)
#define all(x) x.begin(),x.end()
#define sz(x) x.size()
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define out(x) cout<<x<<endl
#define put(x) out(x)
#define in(x) cin>>x
#define maxx(a,b,c) max(a,max(b,c))
#define minn(a,b,c) min(a,min(b,c))
using ll = long long;
using vl = vector<ll>;
using vs = vector<string>;
const double pi = 3.14159265358979;
const ll mod = 1000000007;
int keta(ll N){
  if(N == 0) return 1;
 int a =  log10(N);
  return a+1;
}


int atama(ll N){
  int s = keta (N);
  return N/(pow(10,s-1));
}

int main() {
ll N;
  in(N);
  int s = atama(N);
  int k=keta(N);
  ll ans ;
  
  if(keta(N+1)!=keta(N)) out(9*k);
  else if(s != atama(N+1)) out(9*(k-1)+s);
  else out(9*(k-1)+s-1);
}

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


int main(){
  string str;
  int count;
  while(cin>>str){
 for(int i=0;i<str.size();i++){
   if(str[i]=='@'){
     i++;
     count=i+1;
      for(int j=0;j<str[i]-'0';j++){
      cout<<str[count];
      }
      i++;
      continue;
   }
   cout<<str[i];
 }
 cout<< endl;
  }
 return 0;

}

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

int main() {
  string ss;
  cin>>ss;
  int n = ss.length();
  int s[n];
  reverse(ss.begin(), ss.end());
  for (int i=0; i<n; i++) {
    s[i] = ss[i] - '0';
  }
  if (n < 4) {
    cout<<0<<endl;
    return 0;
  }
  long long acc[n+1];
  long long tmp = 1;
  acc[0] = 0;
  for (int i=0; i<n; i++) {
    acc[i+1] = acc[i] + (tmp * s[i]) % 2019;
    acc[i+1] %= 2019;
    tmp = (tmp * 10) % 2019;
  }
  map<int, long long> m;
  for (int i=0; i<n+1; i++) {
    ++m[acc[i]];
  }
  long long ans = 0;
  for (auto e: m) {
    long long cnt = e.second;
    ans += cnt * (cnt - 1) / 2;
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 6104
N, M, C = input().split()
N = int(N)
M = int(M)
C = int(C)
B_list = list(map(int, input().split()))
A_matrix = [list(map(int, input().split())) for i in range(N)]
answer = 0
for i in range(N):
    AB = 0
    for j in range(M):
        AB_j = B_list[j] * A_matrix[i][j]
        AB += AB_j
    if AB + C > 0:
        answer += 1
print(answer)

Measured memory_bytes: 3064
// ABC063 B - Varied
#include <stdio.h>
#include <string.h>

int main(void) {
    char S[27];
    scanf("%s", S);
    int slen = strlen(S);

    int flag[26] = {0};
    for (int i = 0; i < slen; i++) {
        if (flag[S[i] - 97] == 1) {
            printf("no\n");
            return 0;
        } else {
            flag[S[i] - 97] = 1;
        }
    }
    printf("yes\n");

    return 0;
}

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

int main(){

int n;
cin>>n;

if(n/10<1) {
    cout<<n<<endl;
    return 0;
}
if(n/10>=1 && n/100<1) {
    cout<<9<<endl;
    return 0;
}
if(n/100>=1 && n/1000<1){
    cout<<9+n-99<<endl;
    return 0;
}
if(n/1000>=1 && n/10000<1){
    cout<<909<<endl;
    return 0;
}
if(n/10000>=1 && n/100000<1){
    cout<<909+n-9999<<endl;
    return 0;
}else{
    cout<<90909<<endl;
}

return 0;
}

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

int main() {

int n,a,b;
cin >> n >> a >> b;
//int *num=new int[3];

//int num[]={300000,200000,100000,0};
//string *name=new string[N+1];

int beg=min(a,b);

int big=a+b;
big=big-n;
if(big<0)big=0;

cout << beg <<" " <<big << endl;


}


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

#define vec     vector<int>
#define vecll   vector<ll>
#define vec2    vector<vector<int>>
#define vec2ll  vector<vector<ll>>
#define vpair   vector<pair<int, int>>
#define vpairll vector<pair<ll, ll>>

#define rep(i,n)         for(ll i=(ll)0; i<(ll)n; i++)
#define REP(i,m,n)       for(ll i=(ll)m; i<(ll)n; i++)
#define arr(var, n)      vec var(n); rep(i,n){cin >> var[i];}
#define arrll(var, n)    vecll var(n); rep(i,n){cin >> var[i];}
#define all(var)         (var).begin(), (var).end()
#define sortall(var)     sort(all(var))
#define f_sum(var)       accumulate(all(var), 0)
#define f_sumll(var)     accumulate(all(var), 0LL)
#define chmin(v1, v2)    v1 = min(v1, v2)
#define chmax(v1, v2)    v1 = max(v1, v2)
#define mpair(v1, v2)    make_pair(v1, v2)
#define pb(var)          push_back(var)
#define prt(var)         cout << var << "\n"
#define scn(var)         cin >> var;
#define pYes()           prt("Yes")
#define pNo()            prt("No")
#define prtd(n, var)     cout << fixed << setprecision(n) << var << "\n"
#define prt2(v1, v2)     cout << v1 << " " << v2 << "\n"
#define prt3(v1, v2, v3) cout << v1 << " " << v2 << " " << v3 << "\n"
#define prtall(var)      rep(i,var.size()){cout << var[i] << " ";} cout << "\n"
//----------------------------------------------------------------

int main(void) {
  int n, k;
  cin >> n;
  string s;
  cin >> s >> k;

  char x=s[k-1];
  rep(i,n){
    if(s[i]!=x){
      s[i]='*';
    }
  }
  prt(s);
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<string>
#include<math.h>
#include<string>
#include<vector>
#include<stack>
#include<cstdio>
#include<queue>
using namespace std;
const int N=100005;
long long  a[N];
int main()
{

	int n;
	scanf("%d",&n);
	
	for(int i=0;i<n;i++)
	{
		scanf("%lld",&a[i]);
	}
	if(n==2) 
	{
		cout<<fabs(a[0]-a[1])<<endl;
		return 0;
	}
	 sort(a,a+n);
	
	 long long ans1=0,ans2=0;
	 
	 	int i=0,j=n-1,k=0;
		while(1)
		{

			ans1+=-2*a[i];
			i++;
			k++;
			if(k>=n-2) break;
			
			ans1+=2*a[j];
			j--;
			k++;  
			if(k>=n-2) break;
		}
		ans1+=a[j];
		if(n%2==0)
			ans1-=a[i];
		else
			ans1+=a[i];
		
		i=0,j=n-1,k=0;
		while(1)
		{
			ans2+=2*a[j];
			j--;
			k++;  
			if(k>=n-2) break;
			
			ans2+=-2*a[i];
			i++;
			k++;
			if(k>=n-2) break;
		}
	    ans2-=a[i];
		if(n%2==0)
			ans2+=a[j];
		else
			ans2-=a[j];
	 
	cout<<max(ans1,ans2)<<endl;
    return 0;
}


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

signed main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int A, B, K;
    cin >> A >> B >> K;
    int eat = min(A, K);
    A -= eat;
    K -= eat;
    eat = min(B, K);
    B -= eat;
    K -= eat;
    cout << A << " " << B << endl;

    return 0;
}


Measured memory_bytes: 256
// ~/Remember,remember the 6th of March
#include <functional>
#include <iomanip>
#include <stdio.h>
#include <vector>
#include <algorithm>
#include<complex>
#include <unordered_map>
#include<unordered_set>
#include <numeric>
#include <string>
#include<iostream>
#include <fstream>
#include <assert.h>
#include <ctype.h>
#include <limits.h>
#include <math.h>
#include<cmath>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#include <time.h>
#include <bitset>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <sstream>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const double PI = acos(-1.0);
const double  EPS = 1e-11;
const ll MOD = 1000000007;
const int N = 100000 + 7;
void fast()
{
	std::ios_base::sync_with_stdio(0);
}
int main()
{
/*#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	//freopen("output.txt","w",stdout);
#endif*/
	int n, h, w, a, b, cnt = 0;
	scanf("%d%d%d", &n, &h, &w);
	while (n--)
	{
		scanf("%d%d", &a, &b);
		if (a >= h && b >= w)
			cnt++;
	}
	printf("%d\n", cnt);
	return 0;
}

Measured memory_bytes: 256
import sys
import math
from collections import defaultdict
from collections import deque
from itertools import permutations

sys.setrecursionlimit(1000000)
MOD = 10 ** 9 + 7
input = lambda: sys.stdin.readline().strip()
NI = lambda: int(input())
NMI = lambda: map(int, input().split())
NLI = lambda: list(NMI())
SI = lambda: input()


def main():
    N, M, R = NMI()
    targets = NLI()
    targets = [t-1 for t in targets]
    dist = [[10**9] * N for _ in range(N)]
    for _ in range(M):
        a, b, c = NMI()
        dist[a-1][b-1] = c
        dist[b-1][a-1] = c
    for i in range(N):
        dist[i][i] = 0

    for k in range(N):
        for i in range(N):
            for j in range(N):
                dist[i][j] = min(dist[i][j], dist[i][k] + dist[k][j])

    ans = 10**9
    for case in permutations(targets, R):
        now = case[0]
        cost = 0
        for goto in case[1:]:
            cost += dist[now][goto]
            now = goto
        ans = min(ans, cost)
    print(ans)

if __name__ == "__main__":
    main()

Measured memory_bytes: 75504
import std.stdio, std.conv, std.string;
import std.algorithm, std.array, std.container, std.typecons;
import std.numeric, std.math;
import core.bitop;

T RD(T = string)() { static string[] ss; while(!ss.length) ss = readln.chomp.split; string res = ss[0]; ss.popFront; return res.to!T; }
string RDR()() { return readln.chomp; }
T[] ARR(T)(in string str) { return str.split.to!(T[]); }
size_t[] MAKE_IDX(alias less = "a < b", Range)(Range range) { auto idx = new size_t[](range.length); makeIndex!(less)(range, idx); return idx;}
size_t MIN_POS(alias less = "a < b", Range)(Range range) { auto r = minPos!(less)(range); return range.length - r.length; }

bool INSIDE(T)(T x, T b, T e) { return x >= b && x < e; }

long mod = pow(10, 9) + 7;
void moda(ref long x, long y) { x = (x + y) % mod; }
void mods(ref long x, long y) { x = ((x + mod) - (y % mod)) % mod; }
void modm(ref long x, long y) { x = (x * y) % mod; }

struct UnionFind
{
	void init(long n) { par = new long[](n); foreach (i; 0..n) par[i] = i; }
	long root(long i) { return par[i] == i ? i : (par[i] = root(par[i])); }
	bool same(long i, long j) { return root(i) == root(j); }
	void unite(long i, long j) { i = root(i); j = root(j); if (i == j) return; par[i] = j; }
	long[] par;
}

void main()
{
	auto S = RD!string;
	auto x = RD!long;
	auto y = RD!long;

	long cnt;
	foreach (c; S)
	{
		if (c == 'F')
			++cnt;
		else
			break;
	}
	x -= cnt;
	long[][2] moves;
	long streak;
	long mode;
	foreach (c; S[cnt..$])
	{
		if (c == 'T')
		{
			moves[mode] ~= streak;
			streak = 0;
			mode ^= 1;
		}
		else
		{
			++streak;
		}
	}
	if (streak != 0) moves[mode] ~= streak;
	stderr.writeln(moves);
	
	bool ans = true;
	{
		long[long] memoLast;
		memoLast[0] = 1;
		foreach (e; moves[0])
		{
			long[long] memo;
			foreach (key; memoLast.keys)
			{
				memo[key+e] = 1;
				memo[key-e] = 1;
			}
			memoLast = memo;
		}
		stderr.writeln(memoLast);
		ans &= memoLast.get(x, 0) == 1;
	}
	{
		long[long] memoLast;
		memoLast[0] = 1;
		foreach (e; moves[1])
		{
			long[long] memo;
			foreach (key; memoLast.keys)
			{
				memo[key+e] = 1;
				memo[key-e] = 1;
			}
			memoLast = memo;
		}
		stderr.writeln(memoLast);
		ans &= memoLast.get(y, 0) == 1;
	}

	writeln(ans ? "Yes" : "No");
	stdout.flush();
}

Measured memory_bytes: 13692
#include <bits/stdc++.h>
using namespace std;
int main() {
    long n,k; cin>>n>>k;
    vector<pair<long,long>> a(n);
    for(int i=0;i<n;i++)
        cin>>a[i].first>>a[i].second;
    long MAX=0,mask=0;
    for(int i=0;i<=30;i++){
        if(i==0||(k&(1<<i))!=0){
            long cmask= mask|((k>>(i+1))<<(i+1));
            if(i==0) cmask=k;
            long sum=0;
            for(int i=0;i<n;i++){
                if((cmask|a[i].first) == cmask)
                    sum+=a[i].second;
            }
            MAX=max(sum,MAX);
        }
        mask|=(1<<i);
    }
    cout<<MAX;
}

Measured memory_bytes: 1916
#include <iostream>
#include <string>
#include <vector>
#include <cstdlib>
#include <numeric>
#include <algorithm>
#include <cmath>
#include <iomanip>

#define rep(i,m,n) for(int i=(m);i<(n);++i)

using namespace std;
using std::swap;

vector<long long int> v;
vector<long long int> w;



int main() {
	long long int ANS = 0;
	int K;
	cin >> K;
	rep(i,1,K+1)rep(j, 1, K + 1)rep(m, 1, K + 1)ANS += gcd(m, gcd(i, j));
	cout << ANS << "\n";
	return 0;
}

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

int main() {
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	double L; cin >> L; L /= 3;
	cout << fixed << setprecision(20) << L * L * L << '\n';

	return 0;
}


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

int main()
{
    string s; cin >> s;
    int max_op_num = (int)(s.size() - 1);
    long sum = 0;
    for (int tmp = 0; tmp < (1 << max_op_num); tmp++)
    {
        bitset<9> bs(tmp);
        string tmp_s = s;
        for (int i = 9; i >= 1; i--)
        {
            if (bs.test(i-1) == true)
            {
                sum += stol(tmp_s.substr(i));
                tmp_s.erase(i);
            }
        }
        sum += stol(tmp_s);
    }
    cout << sum << endl;
}

Measured memory_bytes: 256
#pragma gcc optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(V) (V).begin(),(V).end()
#define SORT(V) sort(ALL(V)) //小さい方からソート
#define REV(V) reverse(ALL(V)) //リバース
#define RSORT(V) SORT(V);REV(V) //大きい方からソート
#define NPN(V) next_permutation(ALL(V)) //順列
#define pb(n) push_back(n)
#define endl '\n'
#define Endl '\n'
#define DUMP(x)  cout << #x << " = " << (x) << endl
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define yes(n) cout << ((n) ? "yes" : "no"  ) << endl
#define Yay(n) cout << ((n) ? "Yay!": ":(") << endl
#define RAPID cin.tie(0);ios::sync_with_stdio(false)
#define VSUM(V) accumulate(ALL(V), 0)
#define MID(a,b,c) (a) < (b) && (b) < (c)
#define MIDe(a,b,c) (a) <= (b) && (b) <= (c)
#define IN(n) cin >> n
#define IN2(a,b) cin >> a >> b
#define IN3(a,b,c) cin >> a >> b >> c 
#define IN4(a,b,c,d) cin >> a >> b >> c >> d
#define VIN(V) for(int i = 0; i < (V).size(); i++) {cin >> (V).at(i);}
#define OUT(n) cout << n << endl
#define VOUT(V) REP(i, (V).size()) {cout << (V)[i] << endl;}
#define VOUT2(V) REP(i, (V).size()) {cout << (V)[i] << " ";} cout<<endl;
#define FIX cout << fixed << setprecision(15)

// 型マクロ定義
#define int long long
#define P pair<ll,ll>
#define Vi vector<ll>
#define VVi vector<vector<ll>>
#define Vd vector<double>
#define Vb vector<bool>
#define Vs vector<string>
#define Vc vector<char>
#define M map<ll,ll>
#define S set<ll>
#define PQ priority_queue<ll>
#define PQG priority_queue<ll,V,greater<ll>
//

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;}

using ll = long long;
using Graph = vector<vector<int>>;

const int MOD = 1000000007;
const int INF = 1061109567;
const double EPS = 1e-10;
const double PI  = acos(-1.0);
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

int gcd(int a,int b){return b != 0 ? gcd(b, a % b) : a;} //最大公約数
int lcm(int a, int b){return a * b / gcd(a, b);}
string toStrUp(string str){char diff = 'A'-'a';REP(i,str.size()) str[i] += diff;return str;}
string gCh(string str, int key){return str.substr(key,1);}

signed main() {
  RAPID;
  // デフォルト変数定義
  int n=0,m=0,a=0,b=0,c=0,d=0,x=0,y=0,z=0;
  string s="",t="";
  //

  // ここから
  IN(x);
  x--;
  int div = x / 11;
  int per = x % 11;
  if(per > 5) OUT(div * 2 + 2);
  else OUT(div * 2 + 1);
}

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

using namespace std;
using llong = long long;
using P = pair<llong, llong>;

#define BE(x) x.begin(), x.end()

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

int main(){
	string s;
	for(int i= 0; i < 3; i++){
		cin >> s;
		cout << (char)(s[0]-'a'+'A');
	}
	cout << endl;

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  string S,T;
  cin >> S >> T;
  int ans=0;
  for(int i=0;i<3;i++){
    if(S.at(i)==T.at(i)){
      ans++;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 764
#include<vector>
#include<iostream>
#include<algorithm>
#include<functional>
#include<string>
#include<limits.h>
using namespace std;

int main(){
  
  int p,q,r;
  cin >> p >> q >> r;
  
  cout << (p+q+r)-max(max(p,q),r) << endl;
 
  return 0;
}


Measured memory_bytes: 256
#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 n,k;
  cin >>n >>k;
  vector<double> p(n);
  rep(i,n) {
    cin >>p[i];
    p[i]++;
  }
  double sum = 0;
  double ans = 0;
  queue<double> q;
  rep(i,n){
    sum += p[i];
    q.push(p[i]);
    if (q.size()>k){
      sum -= q.front();
      q.pop();
    }
    if (q.size()==k){
      ans = max(sum, ans);
    }
  }
  cout << fixed << setprecision(12) << ans/2 << endl;
  return 0;
}

Measured memory_bytes: 3456
#include <bits/stdc++.h>
#define DUMP(x)  cout << #x << " = " << (x) << endl;
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define IFOR(i, m, n) for(int i = n - 1; i >= m; i-- )
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
#define FOREACH(x,a) for(auto& (x) : (a) )
#define ALL(v) (v).begin(), (v).end()
using namespace std;
typedef long long ll;
const ll INF = 1e18;
/* テンプレートここまで */

int main() {
  ll n; cin >> n;
  vector<ll> d(n); REP(i, n) cin >> d[i];
  sort(ALL(d));
  cout << d[n/2] - d[n/2-1] << endl;
}


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

int main(){
  int h, w;
  cin >> h >> w;
  char array[h][w];
  for(int i=0;i<h;i++){
    for(int j=0;j<w;j++){
      cin >> array[i][j];
    }
  }
  
  for(int i=0;i<h;i++){
    for(int j=0;j<w;j++){
      if(array[i][j] == '.'){
        int count=0;
        if(i!=0&&j!=0){
          if(array[i-1][j-1]=='#') count++;
        }
        if(i!=0){
          if(array[i-1][j]=='#') count++;
        }
        if(i!=0&&j+1!=w){
          if(array[i-1][j+1]=='#') count++;
        }
        if(j!=0){
          if(array[i][j-1]=='#') count++;
        }
        if(j+1!=w){
          if(array[i][j+1]=='#') count++;
        }
        
        if(i+1!=h&&j!=0){
          if(array[i+1][j-1]=='#') count++;
        }
        if(i+1!=h){
          if(array[i+1][j]=='#') count++;
        }
        if(i+1!=h&&j+1!=w){
          if(array[i+1][j+1]=='#') count++;
        }
        cout << count;
      }
      if(array[i][j]=='#') cout << '#';
    }
    cout << endl;
  }
}

Measured memory_bytes: 256
s=input()
q=int(input())
queri=[]
rv=0
forward=[]
back=[]
for i in range(q):
    queri=list(map(lambda x:x,input().split()))
    if queri[0]=="2":
        rvt=(rv+int(queri[1]))%2
        if rvt==1: forward.append(queri[2])
        else: back.append(queri[2])

    else: rv=(rv+1)%2

if rv==0:
    for i in range(len(forward)-1,-1,-1):
        print(forward[i],end="")
    print(s,end="")
    for i in range(len(back)):
        print(back[i],end="")
        
if rv==1:
    for i in range(len(back)-1,-1,-1):
        print(back[i],end="")
    print(s[::-1],end="")
    for i in range(len(forward)):
        print(forward[i],end="")


Measured memory_bytes: 86768
#include<cmath>
#include<cstdio>
#include<algorithm>
using namespace std;
const int MAXK=15;
int n,k,d[MAXK];
int l,p,s[MAXK],t;
int main(){
	scanf("%d%d",&n,&k);
	for(int i=1;i<=k;i++){
		int x;
		scanf("%d",&x);
		d[x]++;
	}
	while(n){
		s[++l]=n%10;
		n/=10;
	}
	for(int j=0;j<=9;j++)
		if(!d[j]){
			t=j;
			break;
		}
	for(int i=l;i>=1;i--){
		int you=0;
		if(p)s[i]=t,you=1;
		else for(int j=s[i];j<=9;j++)
			if(!d[j]){
				if(s[i]<j)p=1;
				s[i]=j;you=1;
				break;
			}
		if(!you){
			for(int j=1;j<=9;j++)
				if(!d[j]){
					s[++l]=j;
					break;
				}
			for(int j=1;j<l;j++)
				s[j]=t;
			break;
		}
	}
	for(int i=l;i>=1;i--)
		printf("%d",s[i]);
	printf("\n");
}

Measured memory_bytes: 128
import java.util.Scanner;

class Main{
    public static void main(String[] args) {
        Scanner sc =  new Scanner(System.in);
        while(true){
            int a = sc.nextInt();
            String op = sc.next();
            int b = sc.nextInt();
            if(op.equals("?")) break;
            if(op.equals("+")) System.out.println(a + b);
            if(op.equals("-")) System.out.println(a - b);
            if(op.equals("*")) System.out.println(a * b);
            if(op.equals("/")) System.out.println(a / b);
        }
    }
}


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

#define ll long long
#define ar array

const int mxN=2e5+5,INF=999999999;
const int modr=1e9+7;
int  n,m,a[mxN];

bool vis[mxN];
vector<int> adj[mxN];
int t;
void dfs(int s){
	vis[s]=true;t++;
	for(auto child : adj[s]){
		if(!vis[child]){
			dfs(child);
		}
	}
}

void solve() {
	cin >> n>>m;
	int x,y;
	for(int i=0;i<=n;i++){
		adj[i].clear();
		vis[i]=false;
	}
	for(int i=0;i<m;i++){
	    cin>>x>>y;
	    adj[x].push_back(y);
	    adj[y].push_back(x);
	}
	int maxm=-1;
	for(int i=0;i<=n;i++){
		if(!vis[i]){
		    t=0;
		    dfs(i);
		    maxm=max(maxm,t);
		}}
		    
	cout<<maxm;
}

int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);cout.tie(0);
	#ifndef ONLINE_JUDGE
		freopen("input.txt","r",stdin);
		freopen("output.out","w",stdout);
	#endif
	int t=1;

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



Measured memory_bytes: 21000
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<climits>
#include<iostream>
#include<sstream>
#include<utility>
#include<map>
#include<vector>
#include<queue>
#include<algorithm>
#include<set>
#include<stack>
#include<tuple>
using namespace std;
typedef long long ll;
typedef pair<int, int>P;

int main()
{
	vector<vector<int> >C = vector<vector<int> >(3, vector<int>(3, 0));
	for (int i = 0; i<3; i++)
		for (int j = 0; j<3; j++)
		{
			int t;
			cin >> t;
			C[i][j] = t;
		}
	vector<tuple<int, int, int> > L;
	set<int> r;
	L.push_back(make_tuple(0, 11, 22));
	L.push_back(make_tuple(0, 21, 12));
	L.push_back(make_tuple(10, 1, 22));
	L.push_back(make_tuple(10, 21, 2));
	L.push_back(make_tuple(20, 11, 2));
	L.push_back(make_tuple(20, 1, 12));
	for (tuple<int, int, int> a : L)
	{
		int x= get<0>(a), y= get<1>(a), z= get<2>(a);
		r.insert(C[x/10][x%10]+C[y/10][y%10]+C[z/10][z%10]);
	}
	puts(r.size() == 1 ? "Yes" : "No");
}


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

int main(){
	
	int n;
	for(cin>>n;n--;){
		string a,b;
		cin>>a>>b;
		if(a.size()<b.size())swap(a,b);
		while(a.size()>b.size())b="0"+b;
		int f=0;
		for(int i=a.size()-1;i>=0;i--){
			a[i]+=(f+b[i]-'0');
			if(a[i]>'9'){
				f=1;
				a[i]-=10;
			}
			else f=0;
		}
		if(f)a="1"+a;
		if(a.size()>80){
			cout<<"overflow"<<endl;
			continue;
		}
		cout<<a<<endl;
		
		
	}
	
	return 0;
}

Measured memory_bytes: 1216
#include <bits/stdc++.h> 
using namespace std;
#define ld long double 
#define float long double 
#define ll long long
#define int long long
#define vl vector<ll> 
#define mp make_pair
#define pb push_back
#define sd second
#define ft first
#define all(x) x.begin(),x.end()
#define alr(x) x.rbegin(),x.rend()
#define endl '\n'
#define cnl cout<<endl;
#define pi  3.141592653589793238
#define ms(x,v) ((x), v, sizeof((x)))
#define MAXN 100009
#define CASET int ___T; scanf("%lld", &___T); for(int cs=1; cs <= ___T; cs++)
template<class T> bool umin(T& a, T b) { if(a > b){ a = b;return 1;}return 0;}
template<class T> bool umax(T& a, T b) { if(a < b){ a = b;return 1;}return 0;}
const int N = 200 * 1000 + 9;
const int  inf = 1e18;
const int mod=1e9+7;
int i,j,k;
void solve(){
   ll n,m; cin >> n >> m;
   map<int,int> mpp;
   for(i =0;i<m;i++){
    ll x; cin >> x;
    ll y; cin >> y;

     if(x == 1 and y == 0  and n > 1){
      cout << -1 << endl;
      return ;
    }
    y= y+1;
   
    if(mpp[x] and mpp[x] != y){
      cout<< -1 << endl;
      return;
    }
    mpp[x]  = y;
   }
   if(mpp[1] == 0 and n > 1 ) mpp[1] = 2;
   for(i = 0;i < n;i++){
     if(mpp[i+1]) cout << mpp[i+1] - 1;
     else cout << 0 ;
   }



 return ;
}
    signed main(){
   
   // CASET
    solve();
    
   
    return 0;
  }


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int h,w;
  cin>>h>>w;
  vector<string> s(h);
  for(int i=0;i<h;i++)
    cin>>s.at(i);
  for(int i=0;i<h;i++)
    for(int j=0;j<w;j++)
      if((i+j)%2==0)
        s.at(i).at(j)='.'+'#'-s.at(i).at(j);
  vector<int> ki={0,0,-1,1};
  vector<int> kj={-1,1,0,0};
  int64_t c=0;
  vector<vector<bool>> v(h,vector<bool>(w,0));
  for(int i=0;i<h;i++){
    for(int j=0;j<w;j++){
      if(v.at(i).at(j))
        continue;
      vector<int> p(2,0);
      queue<vector<int>> q;
      q.push({i,j});
      while(!q.empty()){
        int xi=q.front().at(0);
        int xj=q.front().at(1);
        q.pop();
        if(v.at(xi).at(xj))
          continue;
        v.at(xi).at(xj)=1;
        p.at((xi+xj)%2)++;
        for(int m=0;m<(int)ki.size();m++){
          int mi=xi+ki.at(m);
          int mj=xj+kj.at(m);
          if(mi>=0&&mi<h&&mj>=0&&mj<w&&s[mi][mj]==s[xi][xj])
            q.push({mi,mj});
        }
      }
      c+=(int64_t)p.at(0)*p.at(1);
    }
  }
  cout<<c<<endl;
}

Measured memory_bytes: 3824
#include<stdio.h>

int main(void)
{
    long long n,k;
    long long t=0;
    long long ans=0;

    scanf("%lld %lld",&n,&k);
    // printf("n=%lld k=%lld\n",n,k);

    t=n%k;
    // printf("t=%lld\n",t);

    if (t==0){
        ans=0;
    }else if (n<k){
        if ((k-n)<n)
            ans=k-n;
        else
            ans=n;
    }else{
        ans=k-t;
    }  
    
    printf("%lld\n",ans);


}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
struct Fast {
    Fast() {
        cin.tie(0);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(20);
    }
} fast;

long long mod = 1000000007;

long long div(long long a, long long b, long long c) { return b / c - (a - 1) / c; }

void print_binary(long long a) {
    for (int i = 31; i >= 0; i--) {
        cout << (a >> i & 1);
    }
    cout << endl;
}
long long modpow(long long m, long long n) {
    if (n == 0) return 1;
    if (n % 2 == 0) {
        long long t = modpow(m, n / 2);
        return t * t;
    } else {
        return modpow(m, n - 1) * m;
    }
}
void yes() {
    cout << "Yes" << endl;
    exit(0);
}
void no() {
    cout << "No" << endl;
    exit(0);
}

int main() {
    long long n, k;
    cin >> n;
    vector<int> a(n);
    vector<int> b(n);
    vector<int> c(n);
    vector<vector<int>> dp(n + 1, vector<int>(3));  // max happines at day i
    for (int i = 0; i < n; i++) {
        cin >> a[i] >> b[i] >> c[i];
    }
    for (int i = 1; i <= n; i++) {
        dp[i][0] = max({dp[i - 1][1], dp[i - 1][2]}) + a[i - 1];
        dp[i][1] = max({dp[i - 1][0], dp[i - 1][2]}) + b[i - 1];
        dp[i][2] = max({dp[i - 1][1], dp[i - 1][0]}) + c[i - 1];
    }
    // for (int i = 0; i < n; i++) {
    cout << max({dp[n][0], dp[n][1], dp[n][2]}) << endl;
    // }
}

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

// 最小値と最大値を覚えておいて、その差をとればよいはず。

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

    int min_n= 1000000001, max_n = 0;
    int current_n;
    for (int i = 0; i < N; i++)
    {
        cin >> current_n;
        min_n = min(min_n, current_n);
        max_n = max(max_n, current_n);
    }

    cout << max_n - min_n << endl;
}

Measured memory_bytes: 256
n, x = gets.split.map(&:to_i)
l = gets.split.map(&:to_i)
arr = [0] + Array.new(n)
ans = 1

n.times do |i|
  if arr[i] + l[i] > x
    break
  else
    arr[i+1] = arr[i] + l[i]
    ans += 1
  end
end

puts ans

Measured memory_bytes: 1788
#include <iostream>
#include <string>
#include <math.h>
#include <algorithm>
#include <map>
#include <set>
#include <vector>
using namespace std;
typedef long long  ll;
#define rep(i,s,n)for(ll i=s;i<n;i++)
#define repe(i,s,n)for(ll i=s;i<=n;i++)

static const double PI = 3.14159265358979;
static const ll MOD = 1e9 + 7;
static const ll INF = (ll)1 << 62;

ll a[100000] = {};
char x[3] = { '3','5','7' };
char c[10] = {};
ll cnt = 0;
ll p = 0;

ll convert(char *c, ll d) {
	ll a = 0;
	rep(i, 0, d) {
		a = a * 10 + (c[i] - '0');
	}
	return a;
}
void dfs(ll n, ll d) {
	if (n == d) {
		cnt++;
		a[p++] = convert(c, d);
		return;
	}

	rep(i, 0, 3) {
		c[n] = x[i];
		dfs(n + 1, d);
		c[n] = ' ';
	}
}

bool is753(ll n) {
	bool ok[3] = {};
	ll k = n;
	while (k) {
		if (k % 10 == 3) ok[0] = true;
		else if (k % 10 == 5) ok[1] = true;
		else if (k % 10 == 7) ok[2] = true;
		k /= 10;
	}

	return (ok[0] && ok[1] && ok[2]);
}

int main() {
	repe(i, 1, 10) {
		dfs(0, i);
	}
	ll n; cin >> n;
	ll ans = 0;

	rep(i, 0, 100000) {
		if (a[i] <= n) {
			if (is753(a[i])) {
				ans++;
			}
		}
		else {
			break;
		}
	}
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 896