akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <cassert>
#include <cfloat>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <deque>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <vector>
 
#define FOR(i,k,n) for (int (i)=(k); (i)<(n); ++(i))
#define rep(i,n) FOR(i,0,n)
#define all(v) begin(v), end(v)
#define debug(x) std::cerr<< #x <<": "<<x<<"\n"
#define debug2(x,y) std::cerr<< #x <<": "<< x <<", "<< #y <<": "<< y <<"\n"
 
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vector<int> > vvi;
typedef vector<ll> vll;
typedef vector<vector<ll> > vvll;
typedef deque<bool> db;
template<class T> using vv=vector<vector< T > >;

// cout vector
template<typename T> ostream& operator<<(ostream& s, const vector<T>& v) {
  int len = v.size(); s << "\n";
  for (int i = 0; i < len; ++i) {
    s << v[i]; if (i < len - 1) s << "\t";
  }
  s << "\n"; return s;
}

// cout 2-dimentional vector
template<typename T> ostream& operator<<(ostream& s, const vector< vector<T> >& vv) {
  int len = vv.size();
  for (int i = 0; i < len; ++i) { s << vv[i]; }
  return s;
}

int main() {
  int h, w;
  scanf("%d %d", &h, &w);
  vvi a(h, vi(w, 0));
  rep (i, h) {
    rep (j, w) {
      scanf("%d", &a[i][j]);
    }
  }
  vvi ans;
  rep (i, h) {
    rep (j, w-1) {
      if (a[i][j] % 2 == 1) {
        a[i][j] -= 1;
        a[i][j+1] += 1;
        ans.push_back((vi){i, j, i, j+1});
      }
    }
  }
  rep (i, h-1) {
    if (a[i][w-1] % 2 == 1) {
      a[i][w-1] -= 1;
      a[i+1][w-1] += 1;
      ans.push_back((vi){i, w-1, i+1, w-1});
    }
  }

  int sz = ans.size();
  printf("%d\n", sz);
  rep (i, sz) {
    rep (j, 3) {
      printf("%d ", ans[i][j] + 1);
    }
    printf("%d\n", ans[i][3] + 1);
  }

  return 0;
}


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

using namespace std;
using LL = long long;
using P = pair<int, int>;

#define FOR(i, a, n) for(int i = (int)(a); i < (int)(n); ++i)
#define REP(i, n) FOR(i, 0, n)

#define pb(a) push_back(a)
#define all(x) (x).begin(),(x).end()

const int INF = (int)1e9;
const LL INFL = (LL)1e19;
const int MOD = 1e9 + 7;

// UnionFind木を構築します
// 使用例:
// UnionFind uni(n);
// cout << uni.Same(1, 2) ? "YES" : "NO" << endl; <- NO
// uni.Unite(1, 2);
// cout << uni.Same(1, 2) ? "YES" : "NO" << endl; <- YES
// cout << uni.GetSize(1) << endl;                <- 2
class UnionFind
{
    private:
      vector<int> par;
      vector<int> rank;
      vector<int> sz;

    public:
      UnionFind(int n) : par(n), rank(n, 0), sz(n, 1)
      {
          iota(par.begin(), par.end(), 0);
      }
      int Find(int x)
      {
          if (par[x] == x) return x;
          else
          {
              int r = Find(par[x]);
              return par[x] = r;
          }
      }
      bool Unite(int x, int y)
      {
          x = Find(x);
          y = Find(y);
          if (x == y) return false;

          if (rank[x] < rank[y]) swap(x, y);
          par[y] = x;
          if (rank[x] == rank[y]) rank[x]++;
          sz[x] += sz[y];
          return true;
      }
      bool Same(int x, int y)
      {
          if (Find(x) == Find(y)) return true;
          else return false;
      }
      int GetSize(int x)
      {
          return sz[Find(x)];
      }
};

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

    int n, q;
    cin >> n >> q;
    UnionFind uni(n);
    REP(i, q)
    {
        int c, x, y;
        cin >> c >> x >> y;
        if(c == 0) uni.Unite(x, y);
        else cout << (uni.Same(x, y) ? 1 : 0) << endl;
    }
}


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

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int M = sc.nextInt();
        if (N >= M) {
            System.out.println(0);
            System.exit(0);
        }
        int[] X = new int[M];
        for (int i = 0; i < X.length; i++) {
            X[i] = sc.nextInt();
        }
        Arrays.sort(X);
        int[] dif = new int[M - 1];
        for (int i = 0; i < X.length - 1; i++) {
            dif[i] = X[i + 1] - X[i];
        }
        Arrays.sort(dif);
        int res = X[M - 1] - X[0];
        for (int i = 0; i < N - 1; i++) {
            res -= dif[M - 2 - i];
        }
        System.out.println(res);
        sc.close();
    }
}

Measured memory_bytes: 50580
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rrep(i, n) for(int i = n-1; i >= 0; i--)
#define  all(x) (x).begin(),(x).end()     // 昇順ソート
#define  rall(v) (v).rbegin(), (v).rend() // 降順ソート
#define  FastIO ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
typedef long long ll;
using P = pair<int,int>;
using VI = vector<int>;
using VVI = vector<vector<int>>;
using VL = vector<ll>;
using VVL = vector<vector<ll>>;
using VP = vector<P>;
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return true; } return false; }

const int mod = 998244353;
struct mint {
    ll x; // typedef long long ll;
    mint(ll x=0):x((x%mod+mod)%mod){}
    mint operator-() const { return mint(-x);}
    mint& operator+=(const mint a) {
        if ((x += a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator-=(const mint a) {
        if ((x += mod-a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
    mint operator+(const mint a) const { return mint(*this) += a;}
    mint operator-(const mint a) const { return mint(*this) -= a;}
    mint operator*(const mint a) const { return mint(*this) *= a;}
    mint pow(ll t) const {
        if (!t) return 1;
        mint a = pow(t>>1);
        a *= a;
        if (t&1) a *= *this;
        return a;
    }
    // for prime mod
    mint inv() const { return pow(mod-2);}
    mint& operator/=(const mint a) { return *this *= a.inv();}
    mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}

struct combination {
    vector<mint> fact, ifact;
    combination(int n):fact(n+1),ifact(n+1) {
        assert(n < mod);
        fact[0] = 1;
        for (int i = 1; i <= n; ++i) fact[i] = fact[i-1]*i;
        ifact[n] = fact[n].inv();
        for (int i = n; i >= 1; --i) ifact[i-1] = ifact[i]*i;
    }
    mint operator()(int n, int k) {
        if (k < 0 || k > n) return 0;
        return fact[n]*ifact[k]*ifact[n-k];
    }
};

int main(){
    int n, m, k;
    cin >> n >> m >> k;
    mint ans = 0;
    mint col = m-1;
    combination c(n);
    for(int i = 0; i <= k; i++){
        ans += c(n-1, i) * m * col.pow(n-1-i);
    }
    cout << ans << endl;
    return 0;
}


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

int main(){
    ll D,T,S;
    cin>>D>>T>>S;

    if(D<=T*S)cout<<"Yes";
    else cout<<"No";
    return 0;
}

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

#define mid(s,e)        (s+(e-s)/2)
#define YES             cout << "YES" << endl
#define NO              cout << "NO" << endl
#define ll              long long
#define ull             unsigned long long
#define dd              double
#define mx 1000005


int main()
{
    //freopen("A.txt","r",stdin);
    //freopen("A.txt","w",stdout);
    ios_base::sync_with_stdio(0);
    int a,b;
    cin>>a>>b;
    int m=a+b;
    if(m%2==1)
        cout<<m/2+1;
    else
        cout<<m/2;

}


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

const int mod = 998244353;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
  mint operator+(const mint a) const { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= a;}
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const { return pow(mod-2);}
  mint& operator/=(const mint a) { return *this *= a.inv();}
  mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}

struct combination {
  vector<mint> fact, ifact;
  combination(int n):fact(n+1),ifact(n+1) {
    assert(n < mod);
    fact[0] = 1;
    for (int i = 1; i <= n; ++i) fact[i] = fact[i-1]*i;
    ifact[n] = fact[n].inv();
    for (int i = n; i >= 1; --i) ifact[i-1] = ifact[i]*i;
  }
  mint operator()(int n, int k) {
    if (k < 0 || k > n) return 0;
    return fact[n]*ifact[k]*ifact[n-k];
  }
}comb(200005);


int main()
{
    int n,m,k;
    cin >> n >> m >> k;
    mint ans = 0;
    rep(i,k+1){
        if(i!=0) ans += mint(m) * mint(m-1).pow(n-i-1) * comb(n-1,i);
        else ans += mint(m) * mint(m-1).pow(n-i-1);
    }

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

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

#define MOD 1000000007
#define rep(i, n) for(ll i=0; i < (n); i++)
#define ALL(v) v.begin(),v.end()
#define DUMP(i, v)for(ll i=0;i<v.size();i++)cout<<v[i]<<" "

using namespace std;
typedef long long int ll;
typedef vector<ll> llvec;
typedef vector<double> dvec;
typedef pair<ll, ll> P;
struct Edge{ll from, to, cost;};
struct node{ll cost, to;
  bool friend operator>(node a, node b){
    return a.cost>b.cost;
  }
};

ll mod(ll a, ll mod){
  ll res = a%mod;
  if(res<0)res=res + mod;
  return res;
}

ll modpow(ll a, ll n, ll mod){
  ll res=1;
  while(n>0){
    if(n&1) res=res*a%mod;
    a=a*a%mod;
    n>>=1;
  }
  return res;
}

ll modinv(ll a, ll mod){
  return modpow(a, mod-2, mod);
}

ll gcd(ll a, ll b){
  ll r = a%b;
  if(r==0) return b;
  else return gcd(b, a%b);
}

bool is_prime(ll n){
  ll i = 2;
  if(n==1)return false;
  if(n==2)return true;
  bool res = true;
  while(i*i <n){
    if(n%i==0){
      res = false;
    }
    i = i+1;
  }

  //if(i==1)res = false;
  if(n%i==0)res=false;
  return res;
}

ll N;
map<char, ll>c;
ll dp[101][4][4][4][4];
ll flg[101][4][4][4][4];

ll dpf(ll n, ll a, ll b, ll c, ll d){
  if(flg[n][a][b][c][d]!=0){
    return dp[n][a][b][c][d];
  }else{
    flg[n][a][b][c][d]=1;
    bool chk = false;
    chk = chk or (a==0 and b==1 and c==2);//AGC*
    chk = chk or (a==0 and b==2 and c==1);//ACG*
    chk = chk or (a==1 and b==0 and c==2);//CAG*

    chk = chk or (b==0 and c==1 and d==2);//*AGC
    chk = chk or (b==0 and c==2 and d==1);//*ACG
    chk = chk or (b==1 and c==0 and d==2);//*CAG

    chk = chk or (a==0 and c==1 and d==2);//A*CG
    chk = chk or (a==0 and b==1 and d==2);//AC*G
    if(chk){dp[n][a][b][c][d]=0;}
    else{
      if(n>=5){
        rep(i, 4){
          dp[n][a][b][c][d]=mod(dp[n][a][b][c][d]+dpf(n-1, b, c, d, i), MOD);
        }
      }else{
        dp[n][a][b][c][d]=1;
      }
    }

    return dp[n][a][b][c][d];
    /*flg[n][a][b][c]=1;
    if(n==3){
      bool chk = false;
      chk = chk or (a==0 and b==1 and c==2);
      chk = chk or (a==0 and b==2 and c==1);
      chk = chk or (a==1 and b==0 and c==2);
      dp[n][a][b][c]=(chk?0:1);
    }else{
      if(a==0){//頭がA
        rep()
        if(b==1){
          dp[n][a][b][c] = mod(dpf(n-1, 1, 1, 2) + dpf(n-1, 1, 3, 2),MOD);
        }else if(b==2){
          dp[n][a][b][c] = mod(dpf(n-1, 2, ))
        }
        
        }*/
    
  }
}


/**************************************
** A main function starts from here  **
***************************************/
int main(){
  c['A']=0;
  c['G']=1;
  c['C']=2;
  c['T']=3;
  cin >> N;
  if(N==3){
    cout << 61;
  }else{
    ll ans = 0;
    rep(i, 4){
      rep(j, 4){
        rep(k, 4){
          rep(l, 4){
            ans = mod(ans+dpf(N, i, j, k, l), MOD);
          }
        }
      }
    }
    cout << ans;
  }
  return 0;
}


Measured memory_bytes: 640
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

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

			int n = sc.nextInt();
			
			Map<String, Integer> countHash = new HashMap<>(); 

			//sort strings a to z
			for( int i = 0 ; i < n ; i++ ) {
				String s = sc.next();
				char[] chars = s.toCharArray(); 
				Arrays.sort(chars);
				String sorted_s = new String(chars);
//				System.out.println(sorted_s);
				
				int currentCount = 1;
				if ( countHash.containsKey(sorted_s)) {
					currentCount = countHash.get(sorted_s) + 1;
				}
				countHash.put(sorted_s, currentCount);
			}
			
			long answerCombination = 0;
			for(String key : countHash.keySet()) {
				long count = (long)countHash.get(key);
				if ( count > 1 ) {
					//2 --> 2C2
					//3 --> 3C2
					//4 --> 4C2
					long combination = count * (count - 1) / 2; 
					answerCombination += combination;
				}
			}
			
			System.out.println(answerCombination);
			
		}
	}
}

Measured memory_bytes: 56072
#include <iostream>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>

using namespace std;

int main(){
  string sin;
  cin >> sin;
  string sout = "";
  for(int i=0; i<sin.size(); i++)
    if(i % 2 == 0)
      sout += sin[i];
  cout << sout << endl;
  return 0;
}


Measured memory_bytes: 512
/*input
39
RBRBGRBGGBBRRGBBRRRBGGBRBGBRBGBRBBBGBBB
*/

#include <bits/stdc++.h>

using namespace std;
using ll = long long;
using ld = long double;

ll MOD = 1000000007;
const int SINF = 1000000009;
const ll INF =  1000000000000000018;

#define sp          cout << " "
#define nl          cout << "\n"
#define inv(a)      powr((a), (MOD - 2))
#define all(c)      (c).begin(),(c).end()
#define rep(i,a,b)  for(ll i = (a); i < (b); i ++)
#define prec(n)     cout << fixed << setprecision(n)
#define PI          3.14159265358979323846264338327951
#define ifalse      ios_base::sync_with_stdio(false), cin.tie(NULL)

template<typename T> void toInt(string s, T &a) { istringstream(s) >> a; }
ll gcd(ll a, ll b) { ll t; while(a) { t = a; a = b%a; b = t; } return b; }
ll sub(ll a, ll b) { a -= b; a = (a + MOD) % MOD; return a; }
ll mul(ll a, ll b) { return ((a % MOD) * (b % MOD)) % MOD; }
ll add(ll a, ll b) { a += b; a %= MOD; return a; }
ll lcm(ll a, ll b) { return (a * b) / gcd(a, b); }

ll powr(ll a, ll b) {
  ll x = 1LL;
  while(b) {
    if(b & 1) x = mul(x, a);
    a = mul(a, a), b >>= 1;
  }
  return x;
}

bool check(ll n)
{
  if(n == 1) return 0;
  if(n == 2 or n == 3) return 1;
  if(n%2 == 0 or n%3 == 0) return 0;
  for(ll i = 5; i*i <= n; i += 6) if(n%i == 0 or n % (i+2) == 0) return 0;
  return 1;
}

/*********************************START**********************************/
const int N = 100005;

int main()
{
  ifalse;
  int n;
  string s;
  cin >> n >> s;
  map < char, int > mp1;
  for(auto x: s) {
    mp1[x] ++;
  }

  map < char, int > mp2;
  ll ans = 0;
  for(auto x: s) {
    if(x == 'R') {
      ll cnt1 = mp2['G'];
      ll cnt2 = mp2['B'];
      ll cnt3 = mp1['B'];
      ll cnt4 = mp1['G'];
      ans += (cnt1 * cnt3) + (cnt2 * cnt4);
    } else if(x == 'G') {
      ll cnt1 = mp2['R'];
      ll cnt2 = mp2['B'];
      ll cnt3 = mp1['B'];
      ll cnt4 = mp1['R'];
      ans += (cnt1 * cnt3) + (cnt2 * cnt4);
    } else {
      ll cnt1 = mp2['G'];
      ll cnt2 = mp2['R'];
      ll cnt3 = mp1['R'];
      ll cnt4 = mp1['G'];
      ans += (cnt1 * cnt3) + (cnt2 * cnt4);
    }
    mp2[x] ++;
    mp1[x] --;
  }

  for(int i = 1; i < n - 1; i ++) {
    int j = i - 1;
    int k = i + 1;
    while(j >= 0 and k < n) {
      if(s[i] != s[j] and s[j] != s[k] and s[k] != s[i]) {
        j --, k ++;
        ans --;
      } else {
        j --, k ++;
      }
    }
  }
  cout << ans, nl;
  return 0;
}

Measured memory_bytes: 3656
x,y,z = gets.split(' ').map(&:to_i)
arr = {a:x, b:y, c:z}
# A=>B
rep = arr[:a]
arr[:a] = arr[:b]
arr[:b] = rep
# A=>C
rep = arr[:a]
arr[:a] = arr[:c]
arr[:c] = rep
puts  arr.values.join(' ')

Measured memory_bytes: 14296
/* ---------- STL Libraries ---------- */
// IO library
#include <cstdio>

#include <fstream>
#include <iomanip>
#include <ios>
#include <iostream>

// algorithm library
#include <algorithm>

#include <cmath>
#include <numeric>
#include <random>
#include <cstring>

// container library
#include <array>
#include <bitset>
#include <deque>
#include <map>
#include <unordered_map>
#include <queue>
#include <set>
#include <string>
#include <tuple>
#include <vector>
#include <stack>

// type
#include <cstdint>

/* ---------- Namespace ---------- */
using namespace std;

/* ---------- Type ---------- */
using ll = long long;
#define int ll
#define P pair<ll, ll>

/* ---------- Constants  */
const double PI = 3.141592653589793238462643383279;
const ll MOD = 1e9 + 7;
const int INF = 1LL << 55;

/* v-v-v-v-v-v-v-v-v Main Part v-v-v-v-v-v-v-v-v */
int dp[3005][3005];
P from[3005][3005];

signed main() {
    int N, T;
    cin >> N >> T;
    vector<int> A(N);
    vector<int> B(N);
    for (int i = 0; i < N; i++) cin >> A[i] >> B[i];
    int W = T - 1;

    for (int i = 0; i <=3000; i++) for (int j = 0; j <= 3000; j++) dp[i][j] = -INF;
    for (int j = 0; j <= 3000; j++) dp[0][j] = 0;
    from[0][0] = P(-1, -1);

    for (int i = 1; i <= N; i++) {
        for (int j = 0; j <= W; j++) {
            if (dp[i-1][j] >= dp[i][j]) {
                from[i][j] = P(i-1, j);
                dp[i][j] = dp[i-1][j];
            }

            if (j - A[i-1] >= 0) {
                if (dp[i-1][j - A[i-1]] + B[i-1] > dp[i][j]) {
                    dp[i][j] = dp[i-1][j - A[i-1]] + B[i-1];
                    from[i][j] = P(i-1, j - A[i-1]);
                }
            }
        }
    }

    set<int> used;
    int x = W;
    int y = N;
    while (true) {
        int nextx = from[y][x].second;
        int nexty = from[y][x].first;

        if (nextx < 0 || nexty < 0) break;

        if (nextx < x) {
            used.insert(y-1);
        }

        x = nextx;
        y = nexty;
    }

    int mx = 0;
    for (int i = 0; i < N; i++) {
        if (used.find(i) == used.end()) {
            mx = max(mx, B[i]);
        }
    }

    cout << dp[N][W] + mx << endl;

    return 0;
}

Measured memory_bytes: 211968
import heapq
from collections import deque
from enum import Enum
import sys
import math
from _heapq import heappush, heappop

#------------------------------------------#

BIG_NUM = 2000000000
HUGE_NUM = 9999999999999999
MOD = 1000000007
EPS = 0.000000001


def MIN(A,B):
    if A <= B:
        return A
    else:
        return B

def MAX(A,B):
    if A >= B:
        return A
    else:
        return B

#------------------------------------------#

class Point:
    def __init__(self,arg_x,arg_y):
        self.x = arg_x
        self.y = arg_y


def roll(div1,div2):
    tmp_start = Point(div2.x-div1.x,div2.y-div1.y)
    tmp_end = Point(tmp_start.x*math.cos(math.pi/3) -tmp_start.y*math.sin(math.pi/3),
                    tmp_start.x*math.sin(math.pi/3) + tmp_start.y*math.cos(math.pi/3))
    ret = Point(tmp_end.x + div1.x,tmp_end.y + div1.y)
    return ret;


def outPut(point):
    print("%.8f %.8f"%(point.x,point.y))


def calc(left,right,count):
    div1 = Point((2*left.x + right.x)/3,(2*left.y + right.y)/3)
    div2 = Point((2*right.x + left.x)/3,(2*right.y + left.y)/3)
    peek = roll(div1,div2)

    if count > 1:
        calc(left,div1,count-1)
        calc(div1,peek,count-1)
        calc(peek,div2,count-1)
        calc(div2,right,count-1)
    else:
        outPut(left);
        outPut(div1);
        outPut(peek);
        outPut(div2);


N = int(input())
left = Point(0,0)
right = Point(100,0)

if N == 0:
    outPut(left)
    outPut(right)
else:
    calc(left,right,N)
    outPut(right)




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

using namespace std;

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

    int ans = 0;
    int cnt = 0;
    bool g[1000]; fill(g, g + 1000, false);

    for(int i = 0; i < 10; i++){
        for(int j =0; j<10; j++){
            for(int k =0; k < 10; k++){
                cnt = 0;
                for(int l = 0; l <N; l++){
                    if(i == int(S[l] - '0') && cnt == 0){
                        cnt = 1;
                        continue;
                    }
                    if(j == int(S[l] - '0') && cnt == 1){
                        cnt = 2;
                        continue;
                    }
                    if(k == int(S[l] - '0') && cnt == 2){
                        cnt = 3;
                    
                        if(!g[i*100 + j*10 + k]){
                            ans ++;
                        }
                        g[i*100 + j*10 + k] = true;
                        break;
                    }
                }
            }
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std ;
#define ll long long int 
#define pb push_back 
#define mp make_pair 
int main(){
	ios_base::sync_with_stdio(false) ;
	cin.tie(NULL) ;
	int n , x ;
	cin >> n >> x ;
	int l[n + 1] = {0} ; 
	for(int i = 1 ; i<= n ; i++) cin >> l[i ] ;
	int i = 1 , ans = 0 , d = 0;
	while(i <= n && d <= x){
		d+= l[i] ;
		i++ ;
		ans++ ;
	}
	if(d <= x) ans++ ;
	cout << ans  ;
}

Measured memory_bytes: 256
N,M = map(int, input().split())
sbit = [0] * M
for i in range(M):
  l = list(map(int, input().split()))
  bit = 0
  for j in range(1, l[0] + 1):
    bit += 1 << (l[j] - 1)
  sbit[i] =  bit
p = list(map(int, input().split()))

total = 0
for tbit in range(2 ** N):
  flg = True
  for i in range(M):
    bit = sbit[i] & tbit
    bits = 0
    while bit > 0:
      if bit & 1:
        bits += 1
      bit = bit >> 1
    if bits % 2 != p[i]:
      flg = False
      break
  if flg:
    total += 1
print(total)

Measured memory_bytes: 3064
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<map>
#include<set>
#include<cstdio>
#include<cmath>
#include<numeric>
#include<queue>
#include<stack>
#include<cstring>
#include<limits>
#include<functional>
#include<unordered_set>
#define rep(i,a) for(int i=(int)0;i<(int)a;++i)
#define pb push_back
#define eb emplace_back
using ll=long long;
static const ll mod = 1e9 + 7;
static const ll INF = 1LL << 50;
using namespace std;

void solve(){
	int n;
	cin>>n;
	vector<ll>a(n+1);
	ll ans=0;
	a[0]=0;
	//自分自身でできるだけペアを作って、余りをつぎの数で使う(引き継ぎ続けないように)
	for(int i=1;i<=n;++i)cin>>a[i];
	for(int i=1;i<=n;i++){
		ans+=(a[i]+a[i-1]%2)/2;
		if(a[i]==0)a[i]=0;//自分が0のときは残すという手段が取れないため、繰り上がり0
		else if((a[i]%2)^(a[i-1]%2))a[i]=1;
		else a[i]=0;
	}
	cout<<ans<<endl;
}

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


Measured memory_bytes: 1024
#include<iostream>
#include<map>
#include<string>
#include<vector>
#include<cmath>
#include<algorithm>
#define rep(i, n) for(int i=0; i<n; i++)
#define rrep(i, n) for(int i=n-1; i>=0; i--)
#define FOR(i, a, b) for(int i=a; i<b; i++)
#define rFOR(i, a, b) for(int i=b; i>=a; i--)
#define MAX 2001
typedef long long ll;
using namespace std;

int main(void){
  string s; cin >> s;
  bool cfind = false;
  bool accept = true;
  rep(i, s.length()){
    if(i==0){
      if(s[i]!='A'){
        accept = false;
        break;
      }
    }
    else if(i>=2&&i<=s.length()-2){
      if(s[i]=='C') {
        if(!cfind){
          cfind = true;
        }else{
          accept = false;
          break;
        }
      }
      if(i==s.length()-2&&!cfind){
        accept = false;
        break;
      }
    }
    else{
      if(s[i]-'Z'<=0){
        accept = false;
        break;
      }
    }
  }
  if(accept)  cout << "AC" << endl;
  else  cout << "WA" << endl;
  return 0;
}


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

// template {{{
#define  range(i, l, r) for (int i = (int)(l); i < (int)(r); (i) += 1)
#define rrange(i, l, r) for (int i = (int)(r) - 1; i >= (int)(l); (i) -= 1)

#define  whole(f, x, ...) ([&](decltype((x)) container) { return (f)(  begin(container),  end(container), ## __VA_ARGS__); })(x)
#define rwhole(f, x, ...) ([&](decltype((x)) container) { return (f)( rbegin(container), rend(container), ## __VA_ARGS__); })(x)

#define debug(x) cerr << "(" << __LINE__ << ")" << #x << ": " << (x) << endl

using i32 = int;
using u32 = unsigned int;
using i64 = long long;
using u64 = unsigned long long;

// constexpr i32 mod   = 998244353;
constexpr i32 mod   = 1e9 + 7;
constexpr i32 inf   = 1001001001;
constexpr i64 infll = 1001001001001001001ll;

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

struct IoSetup { IoSetup(int x = 15){ cin.tie(0); ios::sync_with_stdio(0); cout << fixed << setprecision(x); cerr << fixed << setprecision(x); } } iosetup;

template <typename T = i64> T input() { T x; cin >> x; return x; }

template <typename T> ostream &operator<<(ostream &os, vector<T> &v) { range(i, 0, v.size()) { os << v[i] << (i + 1 != v.size() ? " " : ""); } return os; }
template <typename T> istream &operator>>(istream &is, vector<T> &v) { for (T &in : v) is >> in; return is; }

template <typename T1, typename T2> ostream &operator<<(ostream &os, pair<T1, T2> p) { os << "(" << p.first << ", " << p.second << ")"; return os; }
template <typename T1, typename T2> istream &operator>>(istream &is, pair<T1, T2> &p) { is >> p.first >> p.second; return is; }

template <typename T> vector<T> make_vector(size_t a, T b) { return vector<T>(a, b); }
template <typename... Ts> auto make_vector(size_t a, Ts... ts) { return vector<decltype(make_vector(ts...))>(a, make_vector(ts...)); }

template <typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template <typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }
// }}}

void solver() {
    string s, t;
    cin >> s >> t;

    if (s.size() + 1 !=  t.size()) {
        cout << "No" << endl;
        return;
    }

    range(i, 0, s.size()) {
        if (s[i] != t[i]) {
            cout << "No" << endl;
            return;

        }
    }

    cout << "Yes" << endl;
}

signed main(int argc, char *argv[]) {
    solver();
}


Measured memory_bytes: 3644
import Control.Applicative
import Control.Monad
import Control.Monad.ST
import Data.Functor
import Data.Function
import Data.Monoid
import Data.Maybe
import Data.List
import qualified Data.Foldable as Foldable
import qualified Data.Set as Set
import qualified Data.Sequence as Sequence
import Data.List.Split
import Data.Bits
import Data.Char
import Data.Ix
import Data.Ratio
import Data.Ord
import Data.Tuple
--import Data.Array
import Data.Array.IArray
--import Data.Array.Unboxed
import Data.Array.MArray
import Data.Array.IO
import Data.Array.ST
import Data.IORef
import Data.STRef
-- import System.IO.Unsafe
 
readInt = read :: String -> Int
readInteger = read :: String -> Integer
readDouble = read :: String -> Double
getInt = readLn :: IO Int
getInts = map readInt . words <$> getLine
getInteger = readLn :: IO Integer
getIntegers = map readInteger . words <$> getLine
getDouble = readLn :: IO Double
sjoin :: (Show a) => [a] -> String
sjoin = unwords . map show
cond :: a -> a -> Bool -> a
cond t f c = if c then t else f
apply2 :: (a -> a -> b) -> [a] -> b
apply2 f [x,y] = f x y
apply3 :: (a -> a -> a -> b) -> [a] -> b
apply3 f [x,y,z] = f x y z
apply4 :: (a -> a -> a -> a -> b) -> [a] -> b
apply4 f [x,y,z,w] = f x y z w
fnBin :: (b -> c -> d) -> (a -> b) -> (a -> c) -> a -> d
fnBin op f g x = op (f x) $ g x
fnTuple :: (a -> b, a -> c) -> a -> (b, c)
fnTuple (f,g) a = (f a, g a)
replace :: (Eq a) => a -> a -> [a] -> [a]
replace x y = map (\z -> if z==x then y else z)
modifyArray :: (Ix i, MArray a e m) => a i e -> i -> (e -> e) -> m ()
modifyArray arr ix f = readArray arr ix >>= writeArray arr ix . f
dictCompare :: [a -> a -> Ordering] -> a -> a -> Ordering
dictCompare [] _ _ = EQ
dictCompare (f:fs) x y = let c = f x y in if c==EQ then dictCompare fs x y else c
binMap :: (a -> a -> b) -> [a] -> [b]
binMap f (x:xs@(y:_)) = f x y : binMap f xs
binMap _ _ = []
splitRec :: Int -> [a] -> [[a]]
splitRec _ [] = []
splitRec n xs = let (y,ys) = splitAt n xs in y : splitRec n ys
-- end of templete


main = do
    [n,h] <- getInts
    xs <- map (apply2 (,)) <$> replicateM n getInts
    let da = maximum $ map fst xs
    let bs = sortBy (flip compare) $ filter (>=da) $ map snd xs
    let fd = scanl (-) h bs
    let r = last fd
    print $ if r>0 then length bs + (r + da - 1) `div` da else length $ filter (>0) fd
    
    return ()

Measured memory_bytes: 155004
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define ALL(x) (x).begin(), (x).end()
typedef long long ll;
typedef pair<int, int> P;
typedef vector<vector<int>> Matrix;
static const int INF = 2000000000;

int main(){
  int n;
  string s;
  cin >> n >> s;
  vector<int> l(n+2), r(n+2);
  l[0] = 0;
  r[n+1] = 0;
  rep(i, n){
    if (s[i] == 'W') l[i+1] = l[i] + 1;
    else l[i+1] = l[i];
  }
  for (int i = n-1; i >= 0; i--){
    if (s[i] == 'E') r[i+1] = r[i+2] + 1;
    else r[i+1] = r[i+2];
  }

  int ans = INF;
  for (int i = 1; i <= n; i++){
    ans = min(ans, l[i-1] + r[i+1]);
  }
  cout << ans << endl;
}

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

#define endl "\n"

//typedef
//------------------------------------------
typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef vector<PII> VP;

//REPEAT
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

//container util
//------------------------------------------
#define pb push_back
#define paired make_pair
#define ALL(a) (a).begin(),(a).end()
#define PRINT(V) for (auto v : (V)) cout << v << " "
#define SORT(V) sort((V).begin(),(V).end())
#define RSORT(V) sort((V).rbegin(), (V).rend())

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

//math
//------------------------------------------
int QP(int a,int b){int ans=1;do{if(b&1)ans=1ll*ans*a%MOD;a=1ll*a*a%MOD;}while(b>>=1);return ans;}
int QP(int a,int b,int MOD){int ans=1;do{if(b&1)ans=1ll*ans*a%MOD;a=1ll*a*a%MOD;}while(b>>=1);return ans;}
int GCD(int a,int b){return b?GCD(b,a%b):a;}

//debug
//------------------------------------------
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

//grobal variable
//------------------------------------------
int N,M;
VI Vec;

//動的計画法で役に立つ関数
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

//最大公約数と最小公倍数
ll gcd(ll a, ll b) {
    if(b==0)return a;
    return gcd(b, a%b);
}

ll lcm(ll a, ll b) {
  ll g = gcd(a, b);
  return a/g*b;
}

int main() 
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    
    int N;cin >> N;
    vector<pair<int, int> > V(N);
    REP(i,N)
    {
        int a, b;
        cin >> a >> b;
        V.at(i) = make_pair(b, a);
    }

    SORT(V);
    
    int t=0;
    bool is_ok=true;
    REP(i, N)
    {
        int a, b;
        b = V.at(i).first;
        a = V.at(i).second;
        t += a;
        if (t > b) 
        {
            is_ok = false;
            break;
        }
    }
    if (is_ok) cout << "Yes" << endl;
    else cout << "No" << endl;
  
    return 0;
}



Measured memory_bytes: 1792
"use strict"
function Main(input) {
  input = input.trim().split('\n');
  const N = Number(input[0].trim());
  const A = input[1].trim().split(' ').map(Number);

  if(N === 1) {
    console.log('1');
    return;
  }

  let ret = {};
  for(let n of A){
    ret[n - 1] = ret[n - 1] ? ret[n - 1] + 1 : 1;
    ret[n] = ret[n] ? ret[n] + 1 : 1;
    ret[n + 1] = ret[n + 1] ? ret[n + 1] + 1 : 1;
  }
  
  let ans = 0;
  Object.keys(ret).map((k) => {
    if(ret[k] > ans) ans = ret[k];
  })

  console.log(ans);
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 34204
#include<stdio.h>
int main(void){
  int n,a[1000],b[1000],i,j;
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&a[i]);
  }
  for(j=n-1,i=0;j>=0;j--,i++){
    b[i] = a[j];
  }
  for(i=0;i<n;i++){
    printf("%d",b[i]);
    if(i!=n-1){
      printf(" ");
    }
  }
  printf("\n");
  return(0);
}

Measured memory_bytes: 1852
#include <iostream>
#include <vector>

using namespace std;

int main()
{
    int N,M;
    int temp;
    vector<int> Target;
    vector<vector<int > > Guess;
    vector<int> P;

    cin >> N >> M;

    for(int i=0; i<M; ++i) {
        cin >> temp;
        Target.push_back(temp);
    }

    Guess.resize(M);

    for(int i=0; i<M; ++i) {
        Guess[i].push_back(-1);
        P.push_back(-1);

        for(int j=1; j<=N; ++j) {
            cin >> temp;
            Guess[i].push_back(temp);
            P.push_back(0);
        }
    }

    for(int i=0; i<M; ++i) {
        for(int j=1; j<=N; ++j) {
            if(Guess[i][j]==Target[i]) {
                ++P[j];
            } else {
                ++P[Target[i]];
            }
        }
    }

    for(int i=1; i<=N; ++i) {
        cout << P[i] << endl;
    }
    return 0;
}

Measured memory_bytes: 3220
from collections import deque

H,W = map(int,input().split())
MAP = [input() for i in range(H)]

explored = [[False for i in range(W)] for j in range(H)]
dxy = [(-1,0),(1,0),(0,-1),(0,1)]
ans = 0

for h in range(H) :
    for w in range(W) :
        if not explored[h][w] :
            q = deque([(h,w)])
            black = 0
            white = 0
            
            while q :
                y,x = q.popleft()
                explored[y][x] = True
                
                if MAP[y][x] == "#" :
                    black += 1
                else :
                    white += 1
                
                for dy,dx in dxy :
                    ny = y+dy
                    nx = x+dx
                    
                    if (ny < 0) or (ny >= H) or (nx < 0) or (nx >= W) :
                        continue
                    if explored[ny][nx] :
                        continue
                    if MAP[ny][nx] == MAP[y][x] :
                        continue
                    if (ny,nx) in q :
                        continue
                    q.append((ny,nx))
                    
            ans += black*white

print(ans)


Measured memory_bytes: 50524
#include "bits/stdc++.h"
using namespace std;
typedef unsigned long long ULL;
int main() {
	vector<ULL>zero(19, 1);
	ULL N;
	cin >> N;
	if (N % 2 != 0) {
		cout << 0 << endl;
		return 0;
	}
	else {
		ULL ans = 0, k = 10;
		while (k <= N) {
			ans += N / k;
			k *= 5;
		}
		cout << ans << endl;
	}
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
#define reg register
#define maxn 3001
#define int long long
using namespace std;
inline int  read() {
    reg int s = 0, t = 0; reg char ch = getchar();
    while(ch > '9' || ch < '0') t |= ch == '-', ch = getchar();
    while(ch >= '0' && ch <= '9') s = (s << 1) + (s << 3) + (ch ^ 48), ch = getchar();
    return t ? -s : s;
}
int T, a[maxn], b[maxn], p[maxn], n;
char s[maxn];
void insert(int x) {
	for(int i = 60; i >= 0; i--) {
		if(!(x & (1ll << i))) continue;
		if(!p[i]) {p[i] = x; break;}
		else x ^= p[i];
	}
}
bool check(int x) {
	for(int i = 60; i >= 0; i--) {
		if(!(x & (1ll << i))) continue;
		if(!p[i]) return false;
		else x ^= p[i];
	}
	return true;
}
signed main()
{
	int T = read();	
	while(T--) {
		for(int i = 0; i <= 60; i++) p[i] = 0;
		n = read();
		for(int i = 1; i <= n; i++) a[i] = read();
		scanf("%s", s + 1); bool flag = 1;
		for(int i = n; i >= 1; i--) {
			if(s[i] == '0') insert(a[i]);
			else flag &= check(a[i]);
		}
		if(!flag) puts("1");
		else puts("0");
	}
    return 0;
}


Measured memory_bytes: 3656
#include <stdio.h>
#include <stdlib.h>

// 1-origin to 0-origin
int o1(int i) {
    return i-1;
}

void printArray(int array[], int n) {
    for (int i = 0; i < n; i++) {
        if (i != 0) printf(" ");
        printf("%d", array[i]);
    };
}

void countingSort(int Array[], int Brrby[], int length, int upperBound) {
    int Crrcy[upperBound+1];
    int i, j;
    
//    printf("Array:   ");printArray(Array, length);printf(", upperBound: %d\n", upperBound);
    
    for (i = 0; i <= upperBound; i++)
        Crrcy[i] = 0;
    
    for (j = 1; j <= length; j++)
        Crrcy[Array[o1(j)]]++;
    
//    printf("Counted: ");printArray(Crrcy, upperBound+1);printf("\n");
    
    for (i = 1; i <= upperBound; i++)
        Crrcy[i] = Crrcy[i] + Crrcy[i-1];
    
//    printf("Indexed: ");printArray(Crrcy, upperBound+1);printf("\n");
    
    for (j = length; j >= 1; j--) {
        Brrby[o1(Crrcy[Array[o1(j)]])] = Array[o1(j)];
        Crrcy[Array[o1(j)]]--;
    }
    
//    printf("Sorted:  ");printArray(Brrby, length);printf("\n");
}

int main(int argc, char** argv) {
    int nArray, max_num = 0;
    scanf("%d", &nArray);
    
    int array[nArray], brrby[nArray];
    
    for (int iArray = 0; iArray < nArray; iArray++) {
        scanf("%d", &array[iArray]);
        
        if (array[iArray] > max_num)
            max_num = array[iArray];
    }
    
    countingSort(array, brrby, nArray, max_num);
    
    printArray(brrby, nArray);printf("\n");

    return (EXIT_SUCCESS);
}




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

using namespace std;
using namespace std::chrono;

#define rep(i,a,b) for(int i = a;i<(b);++i)
#define trav(a,v) for(auto& a : v)
#define all(x) x.begin(), x.end()
#define sz(x) (int)(x).size()

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

ll big = 1000000007ll;
ll big2 = 1000000009ll;
ll n,m,T,k,q;

ll M[301][301] = {0};
ll F[301] = {0};
ll ARE[301] = {0};
bool mark[301] = {0};

int main()
{
    //freopen("input.txt","r",stdin);
    //freopen("autput.txt","w",stdout);
    ll a,b,c,d,e,f;


    cin >> n >> m;
    for(ll c1 = 0; c1 < n; c1++){
        for(ll c2 = 0; c2 < m; c2++){
            cin >> a;
            a--;
            M[c1][c2] = a;
        }
    }
    ll ans = 0;

    for(ll c1 = 0; c1 < n; c1++){
        F[M[c1][0]]++;
        ans = max(ans, F[M[c1][0]]);
    }

    for(ll c1 = 0; c1 < m; c1++){
        ll ma = 0;
        ll i = 0;
        for(ll c2 = 0; c2 < m; c2++){
            if(!mark[c2]){
                if(ma < F[c2]){
                    ma = F[c2];
                    i = c2;
                }
            }
        }
        ans = min(ans,ma);
        mark[i] = 1;
        if(c1 == m-1)break;
        for(ll c2 = 0; c2 < n; c2++){
            if(M[c2][ARE[c2]] == i){
                ARE[c2]++;
                while(mark[M[c2][ARE[c2]]]){
                    ARE[c2]++;
                }
                F[i]--;
                F[M[c2][ARE[c2]]]++;
            }
        }
    }

    cout << ans << "\n";

    return 0;
}


Measured memory_bytes: 896
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <math.h>
#include <string.h>
#include <queue>
#include <vector>

#define testin freopen("1.txt","r",stdin);
#define testout freopen("out.txt","w",stdout);

using namespace std;

const int maxn=(int)1e5+10;

int m[maxn];
int s[maxn];

int main(){
    int n;
    long long ans=0;
    cin>>n;
    for(int i=0;i<=n;i++)  scanf("%d",m+i);
    for(int i=0;i<n;i++) {
        scanf("%d",s+i);
        if(s[i]<=m[i]) ans+=s[i];
        else{
            ans+=m[i];
            s[i]-=m[i];
            if(m[i+1]>=s[i]){
                ans+=s[i];
                m[i+1]-=s[i];
            }else{
                ans+=m[i+1];
                m[i+1]=0;
            }
        }
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <array>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <string>
#include <sstream>
#include <algorithm>
#include <random>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <cmath>
#include <cassert>
#include <climits>
#include <bitset>
#include <functional>
#include <iomanip>
#include <random>


#define FOR_LT(i, beg, end) for (int i = beg; i < end; i++)
#define FOR_LE(i, beg, end) for (int i = beg; i <= end; i++)
#define FOR_DW(i, beg, end) for (int i = beg; end <= i; i--)

using namespace std;

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout << fixed << setprecision(20);

	int n, m; cin >> n >> m;
	vector<pair<int, int>> cs(m);
	FOR_LT(i, 0, m) {
		cin >> cs[i].first >> cs[i].second;
	}

	int s = 1;
	FOR_LT(i, 0, n - 1) {
		s *= 10;
	}
	int e = s * 10;
	if (s == 1) s = 0;

	int ans = -1;
	FOR_LT(k, s, e) {
		bool is_ok = true;
		for (auto c :cs) {
			int nc = n - c.first;
			int d = k;
			FOR_LT(i, 0, nc) {
				d /= 10;
			}
			d %= 10;
			if (d != c.second) {
				is_ok = false;
				break;
			}
		}
		if (is_ok) {
			ans = k;
			break;
		}
	}
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
S= input().split() 
 

a=0
 
sum=0
for i in S[0]:
	
	sum=sum+int(i)
 
 
 
anser=int(S[0])%sum
 
 
 
 
 
 
if anser == 0:
	print("Yes")
 
else : print("No")

Measured memory_bytes: 2940
def main():
    N = int(input())
    A = [int(input()) for _ in range(N)]
    exist_odds = False
    for a in A:
        if a % 2 == 1:
            exist_odds = True
            break
    if exist_odds:
        print('first')
    else:
        print('second')


if __name__ == '__main__':
    main()

Measured memory_bytes: 13076
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <queue>
#include <climits>
#include <set>
#include <map>
#include <stack>
#define ll long long
using namespace std;



int main()
{
    ll n;
    cin >> n;
    vector<ll> p(n),q(n),a(n);
    for (ll i = 0; i < n;i++){
        cin >> p[i];
        a[i] = p[i];
    }
    for (ll i = 0; i < n; i++)
    {
        cin >> q[i];
    }
    sort(a.begin(), a.end());
    ll count = 0, countp = 0,countq=0;
    do
    {
        /*for (auto i = a.begin(); i != a.end(); i++)
        {
            cout << *i << "";
        }
        cout << endl;
        */
        count++;
        if (a ==p){
            countp = count;
        }
        if(a==q){
            countq = count;
        }
    } while (next_permutation(a.begin(), a.end()));
    cout << abs(countq - countp) << endl;
    ;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
    using namespace std;
long long read()
{
    long long  x=0,f=1;
    char ch=getchar();
    while(ch-'0'<0||ch-'0'>9){if(ch=='-') f=-1;ch=getchar();}
    while(ch-'0'>=0&&ch-'0'<=9){x=x*10+ch-'0';ch=getchar();}
    return x*f;
}
    long long n,x[100005],i,j,y[100005],z[100005],top,top2,top3,book1[100005],book2[100005];
    int main(){
        n=read();
        for(i=1;i<=n;i++){
            x[i]=read();
            if(x[i]<0){
                top++;
                y[top]=x[i];
            }
            else{
                top2++;
                z[top2]=x[i];
            }
        }
        if(top==0){
            sort(z+1,z+top2+1);
            for(j=3;j<=top2;j++){
                top3++;
                book1[top3]=z[1];
                book2[top3]=z[j];
                z[1]-=z[j];
            }
            top3++;
            book1[top3]=z[2];
            book2[top3]=z[1];
            z[2]-=z[1];
            cout<<z[2]<<endl;
            for(i=1;i<=top3;i++)
                cout<<book1[i]<<" "<<book2[i]<<endl;
        }
        else if(top2==0){
            sort(y+1,y+top+1);
            for(j=top-1;j>=1;j--){
                top3++;
                book1[top3]=y[top];
                book2[top3]=y[j];
                y[top]-=y[j];
            }
            cout<<y[top]<<endl;
            for(i=1;i<=top3;i++)
                cout<<book1[i]<<" "<<book2[i]<<endl;
        }
        else{
            sort(y+1,y+top+1);
            sort(z+1,z+top2+1);
            if(top==1){
                for(i=1;i<=top2-1;i++){
                    top3++;
                    book1[top3]=y[top];
                    book2[top3]=z[i];
                    y[top]-=z[i];
                }
                top3++;
                book1[top3]=z[top2];
                book2[top3]=y[top];
                z[top2]-=y[top];
                cout<<z[top2]<<endl;
                for(i=1;i<=top3;i++)
                    cout<<book1[i]<<" "<<book2[i]<<endl;
            }
            else{
                for(i=1;i<=top2-1;i++){
                    top3++;
                    book1[top3]=y[top];
                    book2[top3]=z[i];
                    y[top]-=z[i];
                }
                for(i=1;i<=top;i++){
                    top3++;
                    book1[top3]=z[top2];
                    book2[top3]=y[i];
                    z[top2]-=y[i];
                }
                cout<<z[top2]<<endl;
                for(i=1;i<=top3;i++)
                    cout<<book1[i]<<" "<<book2[i]<<endl;
            }
        }
        return 0;
    }

Measured memory_bytes: 4992
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define repl(i,l,r) for(ll i=(l);i<(r);i++)
#define per(i,n) for(ll i=n-1;i>=0;i--)
#define perl(i,r,l) for(ll i=r-1;i>=l;i--)
#define fi first
#define se second
#define pb push_back
#define ins insert
#define pqueue(x) priority_queue<x,vector<x>,greater<x>>
#define all(x) (x).begin(),(x).end()
#define CST(x) cout<<fixed<<setprecision(x)
#define vtpl(x,y,z) vector<tuple<x,y,z>>
#define rev(x) reverse(x);
using ll=long long;
using vl=vector<ll>;
using vvl=vector<vector<ll>>;
using pl=pair<ll,ll>;
using vpl=vector<pl>;
using vvpl=vector<vpl>;
const ll MOD=1000000007;
const ll MOD9=998244353;
const int inf=1e9+10;
const ll INF=4e18;
const ll dy[8]={1,0,-1,0,1,1,-1,-1};
const ll dx[8]={0,-1,0,1,1,-1,1,-1};
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 main(){
  ll n;cin >> n;
  vl v(n);rep(i,n)cin >> v[i];
  ll ng=0,ok=INF;
  while(abs(ok-ng)>1){
    ll mid=(ok+ng)/2;
    ll res=mid;
    rep(i,n){
      res-=res%v[i];
    }
    if(res>=2)ok=mid;
    else ng=mid;
  }
  pl ans={ok,-1};
  ok=0;ng=INF;
  while(abs(ok-ng)>1){
    ll mid=(ok+ng)/2;
    ll res=mid;
    rep(i,n){
      res-=res%v[i];
    }
    if(res<=2)ok=mid;
    else ng=mid;
  }
  ans.se=ok;
  bool check=true;
  ll res=ans.fi;
  rep(i,n)res-=res%v[i];
  if(res!=2)check=false;
  rep(i,n)ok-=ok%v[i];
  if(ok!=2)check=false;
  if(check&&ans.fi<=ans.se)cout << ans.fi <<" " << ans.se << endl;
  else cout << -1 <<endl;
}

Measured memory_bytes: 1024
use std::io::prelude::*;
use std::io::stdin;
use std::str::FromStr;

fn main() {
    let r: i32 = read();
    let g: i32 = read();

    println!("{}", g + (g - r));
}

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let token: String = stdin
        .lock()
        .bytes()
        .map(|b| b.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().unwrap()
}


Measured memory_bytes: 4352
#include <iostream>
#include <string>
#include <cstring>
using namespace std;
string S,T;
int n,cnt,k;
int main(){
	cin>>S;
	cin>>n;
	for(int i=0;i<n;i++){
		cin>>T;
		T+=T;
		for(int j=0;j<=T.size();j++){
			for(k=0;k<S.size();k++){
				if(T[j+k]!=S[k]){break;}
			
			}
			if(k==S.size()){cnt++;
				break;}
		}
	}
	cout<<cnt<<endl;
	return 0;
}

Measured memory_bytes: 1208