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

#define int long long

bool cd(int n){
	int c = 0 ;
	while(n){
		n/=10 ;
		c++ ;
	}
	return c&1 ;
}

int32_t main() {
	string s ;
	cin >> s ;
	int n = s.size() ;
	int ans[n] = {0} ;
	int sum = 0 ;
	for(int i = 0 ; i < n-1 ;){
		while(i < n-1 && s[i] == 'L') i++ ;
		if(i >= n-1) break ;
		if(s[i] == 'R' && s[i+1] == 'L' ){
			ans[i] = 1 , ans[i+1] = 1 ;
			// cout << i << ": " ;
			int j = i-1 ;
			while(j >= 0 && s[j] == 'R' ){
				// cout << i + (j+1)%2 <<" ";
				if(i%2 == j%2) ans[i]++ ; 
				else ans[i+1]++ ;
				j-- ;
			}
			j = i + 2 ;
			while(j < n && s[j] == 'L'){
				if(i%2 == j%2) ans[i]++ ; 
				else ans[i+1]++ ;
				j++ ;
			}
			// cout << endl ;
			i += 2;
		}else i++ ;
	}
	for(auto i : ans) cout << i <<" ";
	return 0;
}

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

using namespace std;
typedef long long int ll;
typedef pair<ll, ll > pi;  
typedef pair<pair<ll, ll >, ll > pii;  
vector<ll > vec;
vector<vector<ll > > vec2;
ll MOD = 1000000007;
ll INF = 1145141919454519;

int main() {

    ll a, b;
    cin >> a >> b;

    if(a <= 0 && b >= 0 ){
        cout << "Zero" << endl;
        return 0;
    }
    
    if(a >= 1 && b >= 1){
        cout << "Positive" << endl;
        return 0;
    }

    if(a < 0 && b < 0){
        if((b-a+1)%2==0) cout << "Positive" << endl;
        else cout << "Negative" << endl;
        return 0;
    }

    cout << "Positive" << endl;

}

Measured memory_bytes: 256
#include <stdio.h>

typedef struct{
    int d,x,y;
}Edge;

void addHeap(int n,Edge a[]){
    int dd,xx,yy;
    while(n>1){
        if(a[n/2-1].d>a[n-1].d){
            dd=a[n-1].d;xx=a[n-1].x;yy=a[n-1].y;
            a[n-1].d=a[n/2-1].d;a[n-1].x=a[n/2-1].x;a[n-1].y=a[n/2-1].y;
            a[n/2-1].d=dd;a[n/2-1].x=xx;a[n/2-1].y=yy;
        }else{break;}
        n/=2;
    }
}

void heap(int i,int n,Edge a[]){
    int min,mnum,dd,xx,yy;
    if(i*2>n){
        return;
    }
    min = a[i-1].d;mnum=i;
    if(min>a[i*2-1].d){
        min=a[i*2-1].d;mnum=i*2;
    }
    if(i*2+1<=n&&min>a[i*2].d){
        min=a[i*2].d;mnum=i*2+1;
    }
    if(mnum!=i){
        dd=a[i-1].d;xx=a[i-1].x;yy=a[i-1].y;
        a[i-1].d=a[mnum-1].d;a[i-1].x=a[mnum-1].x;a[i-1].y=a[mnum-1].y;
        a[mnum-1].d=dd;a[mnum-1].x=xx;a[mnum-1].y=yy;
        heap(mnum,n,a);
    }
}

Edge get(int n,Edge a[]){
    int i;
    Edge k;
    k.d=a[0].d;k.x=a[0].x;k.y=a[0].y;
    a[0].d=a[n-1].d;a[0].x=a[n-1].x;a[0].y=a[n-1].y;n--;
    heap(1,n,a);
    return k;
}

void chenge(int a,int b,int f[],int n){
    int i;
    for(i=0;i<n;i++){
        if(f[i]==a){
            f[i]=b;
        }
    }
}

int main(void){
    int n,i,j,k,len,sum;
    int flg[100];
    Edge a[5000];
    Edge e;
    int anum=0;
    scanf("%d",&n);
    for(i=0;i<n;i++){
        flg[i]=i;
    }
    for(i=0;i<n;i++){
        for(j=0;j<n;j++){
            scanf("%d",&k);
            if(i<j&&k!=-1){
                a[anum].d=k;a[anum].x=i;a[anum].y=j;
                anum++;
                addHeap(anum,a);
            }
        }
    }
    sum=0;len=0;
    while(len<n-1){
        e=get(anum,a);anum--;
        if(flg[e.x]!=flg[e.y]){
            sum += e.d;len++;
            chenge(flg[e.x],flg[e.y],flg,n);
        }
    }
    printf("%d\n",sum);
    
}


Measured memory_bytes: 2084
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll gya(ll n,ll p,ll m){
	ll b=1;
	while(p>0){
		if(p%2)b=(b*n)%m;
		n=(n*n)%m;
		p/=2;
	}
	return b;
}
int main(){
	ll n,a,b;
	cin>>n>>a>>b;
	ll mod=1e9+7;
	ll numa=1,numb=1,na=1,nb=1;
	for(int i=1;i<=a;i++){
		numa*=i;
		numa%=mod;
		na*=n-i+1;
		na%=mod;
	}
	for(int i=1;i<=b;i++){
		numb*=i;
		numb%=mod;
		nb*=n-i+1;
		nb%=mod;
	}
	numa=gya(numa,mod-2,mod);
	numb=gya(numb,mod-2,mod);
	na*=numa;
	na%=mod;
	nb*=numb;
	nb%=mod;
	ll ans=gya(2,n,mod);
	ans+=mod-1;
	ans%=mod;
	ans+=2*mod-na-nb;
	ans%=mod;
	cout<<ans;
	return 0;
}


Measured memory_bytes: 3640
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
#include<cmath>
#include<queue>
#include<stack>
#include<list>

#define endl "\n"
using namespace std;
using ll = long long;
const ll MOD = 1e9+7;
const ll INF = 1e18;
#define REP(i, n) for(int i = 0; i < n; i++)
using Graph = vector<vector<int>>;

int main(){
    int n;
    cin>>n;
    int l[n];
    int sum = 0;
    int lmax = 0;
    for(int i=0;i<n;i++){
        cin>>l[i];    
        sum += l[i];
        lmax = max(lmax,l[i]);
    }
    if(sum-lmax > lmax) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
using namespace std;

typedef long long ll;
typedef pair<int, int> P;

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

// Self settings
// clang-format off
#define MAX_N 100000
#define REP(i, N) for (int i = 0; i < (int)(N); ++i)
#define SLN(i,N) (i == N-1 ? "\n" : " ")
ll fact(ll n) { ll res = 1; for(ll i=2;i<=n;++i) res = res * i; return res;}
ll nCr(ll n, ll r) {return (fact(n)/fact(n-r)*fact(r)) ;}
ll gcd(ll a,ll b){if(b==0)return a;return gcd(b,a%b);}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
const ll MOD = 1e9+7;
const ll INF = 1LL << 60;
const int inf = 1000100011;
// clang-format on

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

  int ans = ceil((double)N / 2.0);
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>

#define rep(i,n) for(int i=0;i<n;i++)
#define ll long long int
#define MAX 1000000007

using namespace std;

struct UnionFind{
  vector<int> par,num;

  UnionFind(int N) : par(N),num(N){
    for(int i=0;i<N;i++){
      par[i] = i;
      num[i] = 1;
    }
  }

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

  void unite(int x, int y){
    int rx = root(x);
    int ry = root(y);
    if(rx == ry) return;
    par[rx] = ry;
    num[ry] = num[ry]+num[rx]; 
  }

  int get_num(int x){
    int rx = root(x);
    return num[rx];
  }

  bool same(int x, int y){
    int rx = root(x);
    int ry = root(y);
    return rx == ry;
  }
};


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

  ll ans = 1,work = k;
  while(work <= n){
    ans++;
    work *= k;
  }

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


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define FOR(i,s,n) for(int i = (s); i < (n); i++)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) for(int i = (n); i >= 0; i--)
#define ALL(n) (n).begin(), (n).end()
#define RALL(n) (n).rbegin(), (n).rend()
#define ATYN(n) cout << ( (n) ? "Yes":"No") << '\n';
#define CFYN(n) cout << ( (n) ? "YES":"NO") << '\n';
#define OUT(n) cout << (n) << '\n';
using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>;
using pll = pair<ll,ll>;

int main(void)
{
    IOS
    int H, W, M;
    cin >> H >> W >> M;
    map<pii,bool> mp;
    vector<int> bh(H), bw(W);
    REP(i,M) {
        int h, w;
        cin >> h >> w;
        h--; w--;
        bh[h]++; bw[w]++;
        mp[{h,w}] = true;
    }
    vector<pii> bhr, bwr;
    REP(i,H) bhr.emplace_back(bh[i],i);
    REP(i,W) bwr.emplace_back(bw[i],i);
    sort(RALL(bhr));
    sort(RALL(bwr));

    int ans = bhr[0].first + bwr[0].first-1;
    int hmax = bhr[0].first;
    int hi = 0;
    bool loop = true;
    while(bhr[hi].first == hmax && hi < H) {
        int wmax = bwr[0].first;
        int wi = 0;
        while(bwr[wi].first == wmax && wi < W) {
            if (mp[{bhr[hi].second,bwr[wi].second}] == false) {
                loop = false;
                ans++;
                break;
            }
            wi++;
        }
        if (!loop) break;
        hi++;
    }

    cout << ans << '\n';

    return 0;
}

Measured memory_bytes: 32696
require 'matrix'
n = gets.to_i
 
n.times{
  x1, y1, x2, y2, x3, y3 = gets.split.map(&:to_f)
  a = Math.sqrt((x2-x3)**2+(y2-y3)**2)
  b = Math.sqrt((x3-x1)**2+(y3-y1)**2)
  c = Math.sqrt((x1-x2)**2+(y1-y2)**2)
  ar = Math.acos((b**2+c**2-a**2)/(2*b*c))
  r = 0.5*(a/Math.sin(ar))

  lmn = Matrix[
    [x1, y1, 1],
    [x2, y2, 1],
    [x3, y3, 1]
  ].lup.solve([x1**2+y1**2, x2**2+y2**2, x3**2+y3**2])

  x0 = lmn[0]/2
  y0 = lmn[1]/2

  puts "#{sprintf "%.3f", (x0*1000).round / 1000.0} #{sprintf "%.3f", (y0*1000).round / 1000.0} #{sprintf "%.3f", (r*1000).round / 1000.0}"
}

Measured memory_bytes: 9384
import java.util.Scanner;

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

    long N = scanner.nextInt();
    long M = scanner.nextInt();

    N -= 2;
    M -= 2;
    if (N < 0) N = 1;
    if (M < 0) M = 1;

    System.out.println(N * M);
  }
}


Measured memory_bytes: 21332
e = input()
f = input()
g = input()
h = input()

a = int(e)
b = int(f)
c = int(g)
x = int(h)

answer = 0

arrays = []
for i in range(125001):
    arrays.append(0)

for i in range(a + 1):
    for j in range(b + 1):
        for k in range(c + 1):
            arrays[500 * i + 100 * j + 50 * k] += 1

answer = arrays[x]
print(answer)

Measured memory_bytes: 9924
#include<bits/stdc++.h>
using namespace std;
#define ll  long long
#define endl '\n'
#define FASTINOUT ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
const ll mod = 1000000007;
const double PI = 3.141592653589793238463;
const int N=5e5+10;
int main()
{
    FASTINOUT;
    int r,c;
    cin>>r>>c;
    char a[r+1][c+1];
    for (int i=1; i<=r; i++)
        for (int j=1; j<=c; j++)
            cin>>a[i][j];
    for (int i=1; i<=r; i++)
    {
        for (int j=1; j<=c; j++)
        {
            if (a[i][j]=='#'){
                if (i+1<=r&&a[i+1][j]=='#')
                    continue;
                else if (i-1>0&&a[i-1][j]=='#')
                    continue;
                else if (j+1<=c &&a[i][j+1]=='#')
                    continue;
                else if (j-1>0&&a[i][j-1]=='#')
                    continue;
                else{
                    cout<<"No\n";
                    return 0;
                }
            }
        }
    }
    cout<<"Yes\n";
    return 0;
}


Measured memory_bytes: 256
N,x = map(int,input().split())
A = list(map(int,input().split()))

ans = 0
c = sum(A)
for i,a in enumerate(A) :
    if i == 0 :
        if A[i] <= x :
            continue
        else :
            A[i] = x
    else :
        if A[i-1] + A[i] <= x :
            continue
        else :
            #A[i] -= (A[i-1]+A[i]-x)
            A[i] = max(0, x-A[i-1])
ans = c - sum(A)

print(ans)

Measured memory_bytes: 14252
import java.util.*;
public class Main {

  private static int MOD = 998244353;

  public static void main(String[] args) { 
      Scanner sc = new Scanner(System.in);
      int n = sc.nextInt();
      Map<Integer, Integer> distMap = new HashMap<>();
      for(int i = 0; i < n; i++)  {
        int num = sc.nextInt();
        if(i == 0 && num != 0) {
          System.out.println(0);
          return;
        }
        distMap.put(num, distMap.getOrDefault(num, 0) + 1);
      }

      if(distMap.getOrDefault(0, 0) != 1) {
        System.out.println(0);
        return;
      }

      long res = 1;
      long prev = 1;
      for(int i = 1; i < distMap.size(); i++) {
        int curCnt = distMap.getOrDefault(i, 0);
        if(curCnt == 0) {
          res = 0;
          break;
        }
        long curRes = modPow(prev, curCnt) % MOD;
        res = (res % MOD) * curRes % MOD;
        prev = curCnt;
      }

      System.out.println(res % MOD);
  }

  private static long modPow(long a, long b) {
    if(b == 0)
      return 1;
    if(b == 1)
      return a;

    long res = modPow(a, b / 2) % MOD;
    if(b % 2 == 1)
      return (res * res % MOD) * a % MOD;
    return res * res % MOD;
  }
}

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

using namespace std;

const double pi=acos(-1.0);
const double eps=1e-11;

#define size(A) ((int)A.size())
#define length(A) ((int)A.length())
#define mp(A,B) make_pair(A,B)
#define pb(x) push_back(X);

using int64=long long int;
using ipair=pair<int,int>;
using vi=vector<int>;
using vd=vector<double>;

int a,b,c;

int main(){
	cin>>a>>b>>c;
	int xt[20];
	++xt[a];
	++xt[b];
	++xt[c];
	if(xt[5]==2 && xt[7]==1) cout<<"YES"<<endl;
	else cout<<"NO"<<endl;
	return 0;
}

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

typedef long long i64;
typedef pair<i64, i64> pii;

#define fi first
#define se second

int main() {
	i64 a, b;
	vector<pii> seg;
	scanf("%lld%lld", &a, &b);
	seg.push_back(pii(a, b));
	i64 lst = a - 1, sum = 0;
	i64 cur = 0;
	for (int i = 62; i >= 0; --i) {
		bool c = a >> i & 1, d = b >> i & 1;
		if (c == d) {
			if (c) cur += 1ll << i;
		} else {
			i64 p = 1ll << i;
			i64 tmp = a & (p - 1);
			a -= tmp;
			cur ^= p;

			//0xx
			//1xx
			seg.push_back(pii(cur + tmp, cur + p - 1));
		}
	}

	
	sort(seg.begin(), seg.end());

	for (pii s : seg) {
		i64 l = max(lst + 1, s.fi);
		if (l <= s.se) sum += s.se - l + 1,lst = s.se;
		
	}

	printf("%lld\n", sum);
	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
  #define MAX 101
  #define INFINITY 1048576
  #define WHITE -1
  #define GRAY 0
  #define BLACK 1

  int M[MAX][MAX];

  void search(int n,int *d){
    int u, v, min, i, j, p[MAX], c[MAX];

    for(i = 0; i < n; i++){
      c[i] = WHITE;
      d[i] = INFINITY;
    }

    d[0] = 0;
    c[0] = GRAY;

    while(1){
      min = INFINITY;
      u = -1;

      for(i = 0; i < n; i++){
        if(min > d[i] && c[i] != BLACK){
          u = i;
          min = d[i];
        }
      }

      if(u == -1) break;

      c[u] = BLACK;

      for(v = 0; v < n; v++){
        if(c[v] != BLACK && M[u][v] != INFINITY){
          if(d[v] > M[u][v] + d[u]){
            d[v] = M[u][v] + d[u];
            c[v] = GRAY;
          }
        }
      }
    }

    return;

  }

  int main(void){
    int n,i,j,k,v,a,d[MAX];

    scanf("%d",&n);
    for(i = 0; i < n; i++){
      for(j = 0; j < n; j++){
        M[i][j] = INFINITY;
      }
    }

    for(i = 0; i < n; i++){
      scanf("%d%d",&a,&k);
      for(j = 0; j < k; j++){
        scanf("%d",&v);
        scanf("%d",&M[i][v]);
      }
    }

    search(n,d);

    for(j = 0; j < n; j++){

      printf("%d ",j);

      if(d[j] == INFINITY) printf("%d",-1);

      else printf("%d\n",d[j]);
    }
    return 0;
  }



Measured memory_bytes: 2032
#include <bits/stdc++.h>
#define PI 3.14159265358979323846
#define MAXINF (1e18L)
#define INF (1e9L)
#define EPS (1e-9)
#define MOD ((ll)(1e9+7))
#define REP(i, n) for(int i=0;i<int(n);++i)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define ALL(v) v.begin(),v.end()
#define FIND(v,x) (binary_search(ALL(v),(x)))
#define SORT(v) sort(ALL(v))
#define RSORT(v) sort(ALL(v));reverse(ALL(v))
#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cerr<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" "<<v[i]; cerr<<endl
#define Yes(n) cout<<((n)?"Yes":"No")<<endl
#define YES(n) cout<<((n)?"YES":"NO")<<endl
#define pb push_back
#define fi first
#define se second
using namespace std;
template<class A>void pr(A a){cout << (a) << endl;}
template<class A,class B>void pr(A a,B b){cout << a << " "  ;pr(b);}
template<class A,class B,class C>void pr(A a,B b,C c){cout << a << " " ;pr(b,c);}
template<class A,class B,class C,class D>void pr(A a,B b,C c,D d){cout << a << " " ;pr(b,c,d);}
template<class T> void pr_vec(vector<T> &v, char ep=' '){int n=v.size();REP(ni,n){cout<<v[ni];if(ni!=n-1)cout<<ep;}cout<<endl;};
template<class T> inline bool chmin(T& a, T b){return a>b ? a=b, true : false;}
template<class T> inline bool chmax(T& a, T b){return a<b ? a=b, true : false;}
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll,ll> pll;

int main(void)
{
    int D;
    cin >> D;
    vector<int> c(26);
    REP(i,26) cin >> c[i];
    vector<vector<int>> s(D, vector<int>(26));
    REP(i, D)REP(j, 26) cin >> s[i][j];
    REP(i, D){
        pr(max_element(ALL(s[i]))-s[i].begin()+1);
    }
}

Measured memory_bytes: 3668
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n;
    string s;
    cin >> n;
    cin >> s;
    int64_t r=0;
    int64_t g=0;
    int64_t b=0;
    for(int i=0; i<s.size(); i++){
        if(s.at(i) == 'R') r++;
        else if(s.at(i) == 'G') g++;
        else b++;
    }
    int64_t minus=0;
    for(int i=0; i<s.size()-2; i++){
        for(int j=1; i+2*j<s.size(); j++){
            if(s.at(i)!=s.at(i+j) && s.at(i+j)!=s.at(i+2*j) && s.at(i)!=s.at(i+2*j)){
                minus++;
            }
        }
    }
    cout << r*g*b - minus << endl;
}


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

typedef long long int LL;
typedef long long int LLint;

//Faster Program
#define endl "\n"

//Faster Coding
#define ED return
#define GET(a) int a;cin >> a
#define DGET(a) double a;cin >> a
#define SGET(a) string a;cin >> a
#define CGET(a) char a;cin >> a
#define PRINT(a) cout << a << "\n"
#define ANS(a,b) int a;cin >> a;cout << b << "\n"
#define FOR(n) for(int i = 0;i < n;i++)
#define SORT(vec) sort(vec.begin(),vec.end())
#define REV(vec) reverse(vec.begin(),vec.end())

//As Function
#define UP(a,b) ((a+(b-1))/b)
#define ipow(x,y) LL(pow(x,y))

//Debug
#define TEST cout << "OK\n"

const double PI = M_PI;
const long long INF = int(999999999);
const long long MOD = int(1000000007);

//Settings
const bool DO_BENCHMARK = false;
const int DOUBLE_ACCURACY = 15;

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(DOUBLE_ACCURACY);
    void solve();
    if(DO_BENCHMARK){
        clock_t clock_start = clock();
        solve();
        clock_t clock_end = clock();
        const double time = static_cast<double>(clock_end-clock_start)/CLOCKS_PER_SEC*1000.0;
        cout << "\n" << time << "[ms]\n";
    }
    else solve();
}

void solve(){
    char a;
    cin >> a;
    a += 1;
    cout << a << endl;
}


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

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
const ull mod = 1e9 + 7;
#define REP(i,n) for(int i=0;i<(int)n;++i)

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

int main(){
    int N, P;
    cin >> N >> P;
    int oddN=0;
    REP(i, N){
        int tmp;
        cin >> tmp;
        if(tmp%2==1) oddN++;
    }
    if(oddN==0){
        if(P==0){
            cout << powLL(2, N) << endl;
        }else{
            cout << 0 << endl;
        }
    }else{
        cout << powLL(2, N-1) << endl;
    }
    return 0;
}

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

int main()
{
    int A, B;
    int count = 0;
    cin >> A >> B;

    for (int i = A; i <= B; i++)
    {
        int s = i % 10, t = i / 10000 % 10;
        int u = i / 10 % 10, v = i / 1000 % 10;
        if (s == t && u == v)
            count++;
    }
    cout << count << endl;
}


Measured memory_bytes: 3636
#include<iostream>
#include <stdio.h>
#include <cmath>
#include <string>
#include <sstream>
using namespace std;

int main()
{
    // 整数の入力
    int a;
    cin >> a;
    int b;
    b = fmod(a,2);
    int c;
    c = a/2;
    if(b == 1)
    {
        c++;
    }

 
    cout << c << endl;
 
    return 0;
}

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

using namespace std;

int main()
{

int n;
cin>>n;

int arr[n];

for(int i=0; i<n; i++)
    cin>>arr[i];

    int counter=1;
    int mini=arr[0];

 for(int i=1; i<n; i++){

        if(arr[i]<mini){
            mini=arr[i];
            counter++;
        }
    }


 cout<<counter<<endl;

    return 0;
}


Measured memory_bytes: 1024
N = int(input())
H = [int(h) for h in input().split()]

Total = 0
Fin = [0] * N
while H != Fin:
    Group = []
    MinH = 1000
    for i in range(N):
        if H[i] != 0:
            Group.append(i)
            MinH = min(MinH, H[i])
            if i == N - 1:
                Total += MinH
                for g in Group:
                    H[g] -= MinH
        elif Group:
            Total += MinH
            for g in Group:
                H[g] -= MinH
            Group = []
            MinH = 1000

print(Total)

Measured memory_bytes: 3064
//by Top1
#include <bits/stdc++.h>
          
#define f first
#define s second
#define int long long
#define ld long double
#define ull unsigned long long
#define pii pair <int, int>
#define pll pair <long, long>
#define mp make_pair
#define pb push_back
#define pf push_front
#define pp pop_back
#define cerr cout
#define rev reverse
#define all(s) s.begin(), s.end()
#define sz(s) (int)s.size()
#define forn(i, a, b) for (int i = a; i <= b; i++)
#define boost ios_base::sync_with_stdio(false); cin.tie(0),cout.tie(0);
#define nxtp next_permutation
#define pvtp prev_permutation
#define KZ return 
#define x1 x21212121
#define y1 y21212121
#define sqr(x) x * x 
      
const int inf = (1e18) + 1;
const int mod = 479001599;
const int maxn = 5e5 + 111;
        
using namespace std;          

int n, sum;

void solve(){
	cin >> n;

    for (int i = 1; i <= n; i++){
    	if (i % 3 != 0 && i % 5 != 0)
    		sum += i;
    }

    cout << sum;                                                         
}                              
      
main(){
	//freopen(".in", "r", stdin);
	//freopen(".out", "w", stdout);

    boost;
    
    int q = 1;
 
    //cin >> q;
    
    while (q--){
        solve();
    }
}

Measured memory_bytes: 3648
def solution
  k, s = gets.split(' ').map(&:to_i)
  answer = 0
  (0..k).each do |x|
    (0..k).each do |y|
      z = s - x - y
      answer += 1 if (0..k).include?(z)
    end
  end
  answer
end

puts solution


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

using ll = long long;
#define ld long double
#define ull unsigned long long int

#define rep(i, n) for (int i = 0; i < (int)(n); i++)  // (i, 10) i=0～i=9まで
#define repr(i, n) for (int i = n; i >= 0; i--)   // (i, 10) i=10～i=0まで
#define FOR(i, m, n) for (int i = m; i < n; i++)  // (i, 3, 10) i=3～i=9まで
#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) ((int)(x).size())
#define pb push_back
#define ret return

typedef pair<int, int>    pii;
typedef vector<int>       vi;
typedef vector<vi>        vii;
typedef vector<long long> vl;

// 総数を1000000007で割った余り
const long long mod = 1e9 + 7;
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

int main() {
    // cin.tie(0);
    // ios::sync_with_stdio(false);
    // cout << fixed << setprecision(5);

    // 入力
    int n;  // nは100<n<999
    cin >> n;

    // 処理
    // 出力
    for (int i = 111; i < 1000; i += 111) {
        if (n <= i) {
            cout << i << endl;
            break;
        }
    }

    return 0;
}


Measured memory_bytes: 256
using System;
using System.IO;
using System.Collections.Generic;

namespace ABC119A
{
    public partial class Program
    {
        void Solve(StreamScanner ss, StreamWriter sw)
        {
            //---------------------------------
            var S = ss.Next(DateTime.Parse);
            sw.WriteLine(S <= new DateTime(2019, 4, 30) ? "Heisei" : "TBD");
            //---------------------------------
        }
    }

    public class StreamScanner
    {
        static readonly char[] Separator = {' '};
        readonly StreamReader streamReader;

        string[] line = new string[0];
        int index = 0;

        public StreamScanner(Stream stream)
        {
            this.streamReader = new StreamReader(stream);
        }

        public string Next()
        {
            return Next(s => s);
        }

        public string[] Next(int x)
        {
            return Next(s => s, x);
        }

        public string[][] Next(int x, int y)
        {
            return Next(s => s, x, y);
        }

        public T Next<T>(Func<string, T> parser)
        {
            if (index < line.Length) return parser(line[index++]);
            index = 0;
            line = streamReader.ReadLine()?.Split(Separator, StringSplitOptions.RemoveEmptyEntries);
            return Next(parser);
        }

        public T[] Next<T>(Func<string, T> parser, int x)
        {
            var ret = new T[x];
            for (var i = 0; i < x; ++i) ret[i] = Next(parser);
            return ret;
        }

        public T[][] Next<T>(Func<string, T> parser, int x, int y)
        {
            var ret = new T[y][];
            for (var i = 0; i < y; ++i) ret[i] = Next(parser, x);
            return ret;
        }
    }

    public partial class Program
    {
        static void Main()
        {
            Excute(Console.OpenStandardInput(), Console.OpenStandardOutput());
        }

        public static void Excute(Stream input, Stream output)
        {
            var ss = new StreamScanner(input);
            var sw = new StreamWriter(output);
            new Program().Solve(ss, sw);
            sw.Flush();
        }
    }
}

Measured memory_bytes: 13536
#include <algorithm>
#include <cmath>
#include <cstdint>
#include <cstdio>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
#define rep(i, n) for(int(i) = 0; (i) < (n); (i)++)
#define FOR(i, m, n) for(int(i) = (m); (i) < (n); (i)++)
#define All(v) (v).begin(), (v).end()
#define pb push_back
#define MP(a, b) make_pair((a), (b))
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
const int INF = 1 << 30;
const ll LINF = 1LL << 60;
const int MOD = 1e9 + 7;

template <typename T> struct edge {
    int to;
    T cost;
    edge(int t, T c) : to(t), cost(c) {}
};

template <typename T> using Graph = vector<vector<edge<T>>>;

template <typename T> void dijkstra(int s, T inf, vector<T> &d, Graph<T> &G) {
    priority_queue<pair<T, int>, vector<pair<T, int>>, greater<pair<T, int>>>
        que;
    fill(All(d), inf);
    d[s] = 0;
    que.push(make_pair(0, s));
    while(!que.empty()) {
        pair<T, int> p = que.top();
        que.pop();
        int v = p.second;
        if(d[v] < p.first)
            continue;
        for(auto e : G[v]) {
            if(d[e.to] > d[v] + e.cost) {
                d[e.to] = d[v] + e.cost;
                que.push(make_pair(d[e.to], e.to));
            }
        }
    }
}

int main() {
    int N, M;
    cin >> N >> M;
    Graph<ll> G(N, vector<edge<ll>>());
    rep(i, M) {
        int l, r;
        ll c;
        cin >> l >> r >> c;
        l--, r--;
        G[l].pb(edge<ll>(r, c));
    }
    rep(i, N - 1) { G[i + 1].pb(edge<ll>(i, 0)); }
    vector<ll> dist(N);
    dijkstra<ll>(0, LINF, dist, G);
    cout << (dist[N - 1] == LINF ? -1 : dist[N - 1]) << endl;
    return 0;
}

Measured memory_bytes: 12128
import sys
rs = lambda: sys.stdin.readline().rstrip()
ri = lambda: int(rs())
rf = lambda: float(rs())
rs_ = lambda: [_ for _ in rs().split()]
ri_ = lambda: [int(_) for _ in rs().split()]
rf_ = lambda: [float(_) for _ in rs().split()]

N = ri()
p = ri_()
cnt = 0
for i in range(N):
    if p[i] != i + 1:
        cnt += 1
if cnt == 0 or cnt == 2:
    print('YES')
else:
    print('NO')

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

char* p;

int number();
int term();
int expression();
int program();

int main(){
	int n;	cin>>n;
	char x[100];
	for(int i=0;i<n;i++){
		scanf("%s",x);
		p=x;
		cout<<expression()<<endl;
	}

	return 0;
}

int program(){
	int num;
	if(*p=='('){
		p++;
		num=expression();
		p++;
	}else num=number();

	return num;
}

int number(){
	int num=0;
	while('0'<=*p &&*p<='9'){
		num*=10;	num+=(*p-'0');
		p++;
	}

	return num;
}

int expression(){
	int num=term();
	while(1){
		if(*p=='+'){
			p++;
			num+=term();
		}else if(*p=='-'){
			p++;
			num-=term();
		}else break;
	}

	return num;
}

int term(){
	int num=program();
	while(1){
		if(*p=='*'){
			p++;
			num*=program();
		}else if(*p=='/'){
			p++;
			num/=program();
		}else break;
	}

	return num;
}



Measured memory_bytes: 3144
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <cstdlib>
using namespace std;

int main(){
	int n, a, minimum = 1000000000, maximum = 1;
	cin >> n;
	for (int i = 0; i < n; ++i) {
		cin >> a;
		minimum = min(minimum, a);
		maximum = max(maximum, a);
	}
	cout << maximum - minimum << endl;
}

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

typedef long long ll;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	
	ll a, b, c, d;
	cin >> a >> b >> c >> d;
	ll res = max({a * c, b * d, a * d, b * c});
	cout << res << '\n';

	return 0;
}

Measured memory_bytes: 3660
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<climits>
#include<iostream>
#include<string>
#include<stack>
#include<queue>
#include<vector>
#include<map>
#include<set>
#include<algorithm>
#include<numeric>
#include<bitset>

#define rep(n) for(int i=0;i<n;i++)
#define repp(j, n) for(int j=0;j<n;j++)
#define reppp(i, m, n) for(int i=m;i<n;i++)
#define all(c) c.begin(), c.end()
#define rall(c) c.rbegin(), c.rend()
#define MOD 1000000007
#define EPS 1e-9
 
using namespace std;

typedef long long ll;
typedef pair<ll, ll> Pll;
typedef pair<int, int> Pii;
struct edge{int from, to; ll cost;};

int n,k;
int black[4004][4004];

int main(){
    std::ios::sync_with_stdio(0); cin.tie(0);
    int xx,yy;
    char cc;
    cin >> n >> k;
    
    int kk = 2*k;
    rep(n){
        cin >> xx >> yy >> cc;
        if(cc == 'W') xx = (xx + k);
        xx %= kk;
        yy %= kk;
        black[xx][yy]++;
        black[xx+kk][yy]++;
        black[xx][yy+kk]++;
        black[xx+kk][yy+kk]++;
        /*
        cout << yy << " " << xx << endl;
        for(int i=kk-1;i>=0;i--){
            repp(j, kk){
                printf("%3d", black[i][j]);
            }
            printf("\n");
        }
        printf("\n");
        */
    }
    reppp(j, 1, 2*kk) black[0][j] += black[0][j-1];
    reppp(i, 1, 2*kk) black[i][0] += black[i-1][0];
    reppp(i, 1, 2*kk){
        reppp(j, 1, 2*kk){
            black[i][j] += black[i-1][j]+black[i][j-1]-black[i-1][j-1];
        }
    }
    /*
    for(int i=2*kk-1;i>=0;i--){
        repp(j, 2*kk){
            printf("%3d", black[i][j]);
        }
        printf("\n");
    }
    */
    

    int ans = 0;
    reppp(i, 1, kk+1){
        reppp(j, 1, kk+1){
            int tmp = black[i+k-1][j+k-1] - black[i-1][j+k-1] - black[i+k-1][j-1] + black[i-1][j-1];
            tmp += black[i+kk-1][j+kk-1] - black[i+k-1][j+kk-1] - black[i+kk-1][j+k-1] + black[i+k-1][j+k-1];
            // cout << tmp << endl;
            // printf("%d,%d = %d\n", i, j, tmp);
            ans = max(tmp, ans);
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 62848
// clang-format off
#include <bits/stdc++.h>
#define int long long
#define main signed main()
// #define main int main()
#define loop(i, a, n) for (int i = (a); i < (n); i++)
#define rep(i, n) loop(i, 0, n)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define prec(n) fixed << setprecision(n)
#define stlice(from, to) substr(from, (to) - (from) + 1)
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
using namespace std;
using pii = pair<int, int>;
using vi = vector<int>;
using vd = vector<double>;
using vc = vector<char>;
using vb = vector<bool>;
using vs = vector<string>;
using vpii = vector<pii>;
using vvi = vector<vi>;
using vvb = vector<vb>;
using vvpii = vector<vpii>;
template<typename A> using fn = function<A>;
constexpr int INF = sizeof(int) == sizeof(long long) ? 1000000000000000000LL : 1000000000;
constexpr int MOD = 1000000007;
constexpr double PI = acos(-1);
template<typename A, typename B> bool cmin(A &a, const B &b) { return a > b ? (a = b, true) : false; }
template<typename A, typename B> bool cmax(A &a, const B &b) { return a < b ? (a = b, true) : false; }
constexpr bool odd(const int &n) { return n & 1; }
constexpr bool even(const int &n) { return !odd(n); }
void solve();
main { solve(); return 0; }
// clang-format on

using Weight = int;
struct Edge {
  int src, dst;
  Weight weight;
  Edge(int s = 0, int d = 0, Weight w = 0)
    : src(s), dst(d), weight(w) {
  }
};

using Edges  = vector<Edge>;
using Graph  = vector<Edges>;
using Array  = vector<Weight>;
using Matrix = vector<Array>;

void addArc(Graph &g, const int &a, const int &b, const Weight &w = 1) {
  g[a].emplace_back(a, b, w);
}

void addEdge(Graph &g, const int &a, const int &b, const Weight &w = 1) {
  addArc(g, a, b, w);
  addArc(g, b, a, w);
}

vector<Weight> dijkstra(const Graph &g, const int &s) {
  using state = tuple<Weight, int>;
  priority_queue<state, vector<state>, greater<state>> q;
  vector<Weight> dist(g.size(), INF);
  dist[s] = 0;
  q.emplace(0, s);
  while (q.size()) {
    Weight d;
    int v;
    tie(d, v) = q.top();
    q.pop();
    if (dist[v] < d) continue;
    for (auto &e : g[v]) {
      if (cmin(dist[e.dst], dist[v] + e.weight)) {
        q.emplace(dist[e.dst], e.dst);
      }
    }
  }
  return dist;
}

void solve() {
  int v, e, r;
  cin >> v >> e >> r;
  Graph g(v);
  while (e--) {
    int s, t, d;
    cin >> s >> t >> d;
    addArc(g, s, t, d);
  }
  vector<Weight> dist = dijkstra(g, r);
  rep(i, dist.size()) cout << (dist[i] == INF ? "INF" : to_string(dist[i])) << endl;
}

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

int main(){
  string S;
  cin >> S;
  if(S=="ABC"){
    cout << "ARC" << endl;
  }else{
    cout << "ABC" << endl;
  }
}

Measured memory_bytes: 3576
#include <iostream>
#include <algorithm>
#include <utility>
#include <vector>
#include <stack>
#include <set>

using namespace std;

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef pair<int, int> P;
typedef long long LL;
#define ALL(a) (a).begin(),(a).end()
#define PB push_back
#define MP make_pair
#define SORT(c) sort((c).begin(),(c).end())
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define IFOR(v,it) for(auto it=(v).begin();it!=(v).end();++it)
#define RIFOR(v,it) for(auto it=(v).rbegin();it!=(v).rend();++it)
#define IN_LL(v) LL v;cin>>v;
#define IN(v) int v;cin>>v;
#define OUT(v) cout<<v<<endl
#define MOD 1000000007


int main() {
  IN(N);

  VI h(N);
  REP(i, N)
    cin >> h[i];

  int index = 0, count = 0;
  while (index < N) {
    if (h[index] != 0) {
      int d = 0;
      while (index+d+1 < N && h[index+d+1] != 0)
        ++d;
      REP(i, d+1)
        --h[index+i];
      ++count;
    } else
      ++index;
  }
  OUT(count);

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
#include <cstring>
#include <utility>
#include <numeric>
#include <queue>

using namespace std;

int main(){

    int N;
    cin >> N;
    vector<int> A(N);
    vector<int> B(N);

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

    for(int i = 0; i < N; i++){
        cin >> B[i];
    }

    vector<bool> on(N, false);

    for(int i = 0; i < N; i++){
        if(A[i] > B[i]){
            cout << -1 << endl;
            return 0;
        }
    }

    queue<int> q;

    if(B[0] > B[1] + B[N - 1]){
        q.push(0);
        on[0] = true;
    }
    for(int i = 1; i < N - 1; i++){
        if(B[i] > B[i - 1] + B[i + 1]){
            q.push(i);
            on[i] = true;
        }
    }
    if(B[N - 1] > B[N - 2] + B[0]){
        q.push(N - 1);
        on[N - 1] = true;
    }

    long long ans = 0;
    while(!q.empty()){
        int temp = q.front();
        q.pop();

        if(A[temp] == B[temp]){
            continue;
        }

        if(!on[temp]){
            continue;
        }
        on[temp] = false;

        int leftIndex;
        if(temp == 0){
            leftIndex = N - 1;
        }
        else{
            leftIndex = temp - 1;
        }
        int left = B[leftIndex];
        
        int rightIndex;
        if(temp == N - 1){
            rightIndex = 0;
        }
        else{
            rightIndex = temp + 1; 
        }
        int right = B[rightIndex];

        int center = B[temp];
        int target = A[temp];

        int lrSum = left + right;
        if(center > lrSum){
            if(lrSum > target){
                int rest = center % lrSum;
                if(rest < target){
                    cout << -1 << endl;
                    return 0;
                }
                else{
                    if(!on[rightIndex]){
                        q.push(rightIndex);
                        on[rightIndex] = true;
                    }
                    if(!on[leftIndex]){
                        q.push(leftIndex);
                        on[leftIndex] = true;
                    }

                    ans += (center / lrSum);
                    B[temp] = rest;
                }
            }
            else{
                int diff = center - target;
                if(diff % lrSum == 0){
                    ans += (diff / lrSum);
                    B[temp] = target;
                    if(!on[rightIndex]){
                        q.push(rightIndex);
                        on[rightIndex] = true;
                    }
                    if(!on[leftIndex]){
                        q.push(leftIndex);
                        on[leftIndex] = true;
                    }
                }
                else{
                    cout << -1 << endl;
                    return 0;
                }
            }
        }
    }

    for(int i = 0; i < N; i++){
        if(A[i] != B[i]){
            cout << -1 << endl;
            return 0;
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 2304
fun main(args: Array<String>) {
    val (N, M) = readLine()!!.split(" ").map(String::toLong)
    val Am = readLine()!!.split(" ").map(String::toLong)
   listOf(N - Am.fold(0L) {a, b -> a + b}, -1).max()!!.run(::println)
}

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

#define x first
#define y second
#define y1 Y1
#define y2 Y2
#define mp make_pair
#define pb push_back

using namespace std;

typedef long long LL;
typedef pair<int, int> pii;

template <typename T> inline int Chkmax (T &a, T b) { return a < b ? a = b, 1 : 0; }
template <typename T> inline int Chkmin (T &a, T b) { return a > b ? a = b, 1 : 0; }

inline void proc_status()
{
	ifstream t ("/proc/self/status");
	cerr << string (istreambuf_iterator <char> (t), istreambuf_iterator <char> ()) <<endl;
}

template <typename T> T read ()
{
	T sum = 0, fl = 1; char ch = getchar();
	for (; !isdigit(ch); ch = getchar()) if (ch == '-') fl = -1;
	for (; isdigit(ch); ch = getchar()) sum = (sum << 3) + (sum << 1) + ch - '0';
	return sum * fl;
}

const int Maxn = 100 + 10, Maxm = 1e5 + 10;

int N, M;
LL Dp[Maxm];
pii A[Maxn];

inline void Solve ()
{
	LL ans = 0;
	for (int i = 1; i <= N; ++i)
	{
		for (int j = M; j >= A[i].x; --j)
		{
			Chkmax(Dp[j], Dp[j - A[i].x] + A[i].y);
			if (i == N) Chkmax(ans, Dp[j]);
		}
	}
	cout<<ans<<endl;
}

inline void Input ()
{
	N = read<int>(), M = read<int>();
	for (int i = 1; i <= N; ++i) A[i].x = read<int>(), A[i].y = read<int>();
}

int main()
{
#ifdef hk_cnyali
	freopen("D.in", "r", stdin);
	freopen("D.out", "w", stdout);
#endif
	Input();
	Solve();
	return 0;
}


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


int main() {
	int i, j, k, f = 0, n, s, t;
	int a, b, c, d, e, x, y, z;

	scanf("%d %d", &a, &b);
	scanf("%d %d", &c, &d);
	x = (a - c)*(b - d);

	printf("%d", x);

	return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
int main(){
  string s;
  cin >> s;
  int dif=1000;
  for (int i=0; i<s.size()-2; i++){
    int a=stoi(s.substr(i,3));
    if (abs(a-753) < dif ) dif = abs(a-753);
  }
  cout << dif << endl;
 return 0;
}
    

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

#define d(x) cerr << #x ":" << x << endl;
#define dd(x, y) cerr << "(" #x "," #y "):(" << x << "," << y << ")" << endl
#define rep(i, n) for (int i = (int)(0); i < (int)(n); i++)
#define repp(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define all(v) v.begin(), v.end()
#define dump(v)                  \
    cerr << #v ":[ ";            \
    for (auto macro_vi : v) {    \
        cerr << macro_vi << " "; \
    }                            \
    cerr << "]" << endl;
using lint       = long long;
const int INF    = 1e9;
const lint LINF  = 1e18;
const lint MOD   = 1e9 + 7;
const double EPS = 1e-10;

int main() {
    int n, m;
    cin >> n >> m;
    cout << (n == m ? "Yes" : "No") << endl;

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define LL long long
using namespace std;
#define inf 0x3fffffff

int n,m,a[10];

int main()
{
    cin>>n>>m;
    int x,y;
    memset(a,-1,sizeof(a));
    int flag=0;
    for (int i=1;i<=m;i++)
    {
        cin>>x>>y;
        if (a[x]==-1) a[x]=y;
        else if (a[x]!=y) {flag=1;}
    }
    if (flag||n>1&&a[1]==0) puts("-1");
    else
    {
        if (n==1&&a[1]==-1) puts("0");
        else
        {
            if (a[1]==-1) a[1]=1;
            if (a[2]==-1) a[2]=0;
            if (a[3]==-1) a[3]=0;
            for (int i=1;i<=n;i++)
                cout<<a[i];
            cout<<endl;
        }

    }

    return 0;
}


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

int main() {
  int N,K;
  cin >> N >> K;
  int num=1;
  for(int i=0;i<N;i++){
    if(num*2 < num+K) num *= 2;
    else num += K;
  }
  cout << num << endl;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;main(){string r, k="hijklmnopyu";while(cin>>r,r!="#"){bool f,s;int ans=0;f = ~(k.find(r[0]));for(char c:r){s=~(k.find(c));if(f^s)ans++;f=s;}cout<<ans<<endl;}}

Measured memory_bytes: 1192
A,B,K = [int(num) for num in input().split(' ')]

if A >= K:
	print('{} {}'.format(A-K, B))
elif (A < K) and (K-A <= B):
	print('{} {}'.format(0, B-(K-A)))
else:
	print('{} {}'.format(0, 0))

Measured memory_bytes: 3060
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <iomanip>
#include <utility>
#include <tuple>
#include <functional>
#include <bitset>
#include <cassert>
#include <complex>
#include <stdio.h>
#include <time.h>
#include <numeric>
#include <unordered_map>
#include <unordered_set>
# define ll int64_t
# define str string
# define rep(i,n) for(ll i=0;i<n;i++)
# define rrep(i,n) for(ll i=1;i<=n;i++)
# define ALL(x) (x).begin(), (x).end()
# define SZ(x) ((int)(x).size())
# define pb push_back
# define mod 1000000007
# define PI 3.141592653589793
# define vec vector
#define dump(x) cerr<<#x<<"="<<x<<endl
using namespace std;



#define INF 2000000000
#define MAX_V 10



bool compare_by_b(pair<string,ll> a,pair<string,ll> b){
    if(a.second != b.second) return a.second<b.second;
    else return a.first<b.first;
}

bool my_compare(pair<ll,ll> a,pair<ll,ll> b){
    if(a.first != b.first) return a.first<b.first;
    if(a.second != b.second) return a.second>b.second;
    else return true;
}

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

ll factorial(ll n){
    ll x=1;
    rrep(i,n) (x*=i)%=mod;
    return x;
}

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;
}
const ll MAX = 5100000;
const ll MOD = 1000000007;
 
ll fac[MAX], finv[MAX], inv[MAX];
 
// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (ll i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
ll COM(ll n, ll k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

using graph = vector<vector<ll>>;
pair<pair<ll,ll>,ll> p[100010];

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    ll k,a,b,sum=1;
    cin>>k>>a>>b;
    if(b-a<=2 || a>k){
        cout<<k+1<<endl;
        return 0;
    }
    k-=(a-1);
    sum+=(a-1);
    if(k%2==0) sum+=(b-a)*(k/2);
    else{
        sum+=(b-a)*(k-1)/2;
        sum++;
    }
    cout<<sum<<endl;
    return 0;
}

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

#define INF 1e9
#define llINF 1e18
#define MOD 1e9+7
#define pb push_back
#define mp make_pair 
#define F first
#define S second
#define ll long long
using namespace std;
int main(){
vector<int>prime;
 
  prime.pb(2);
  for(int i=3;i<=55555;i+=2){
    bool flag=true;
    for(int j=2;j<=sqrt(i);j++){
      if(i%j==0){flag=false;break;}
    }
    if(flag){prime.pb(i);}
  }

  int n;cin>>n;
  vector<int>ans;
  int po=0;
  while(ans.size()!=55){
    if(prime[po]%10==7){
      ans.pb(prime[po]);
    }
    po++;
  }
  for(int i=0;i<n;i++){
    cout<<ans[i];
    if(i!=n-1)cout<<" ";
  }
  cout<<endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define inf 1000000007
#define mod 1000000007
//#pragma GCC optimize(2)
#define int long long
using namespace std;
template <typename T> void read(T &x){
	x=0;char ch=getchar();int fh=1;
	while (ch<'0'||ch>'9'){if (ch=='-')fh=-1;ch=getchar();}
	while (ch>='0'&&ch<='9')x=x*10+ch-'0',ch=getchar();
	x*=fh;
}
template <typename T> void write(T x) {
	if (x<0) x=-x,putchar('-');
	if (x>9) write(x/10);
	putchar(x%10+'0');
}
template <typename T> void writeln(T x) {
	write(x);
	puts("");
}
int n,m,k;
int cut[15],cnt[15],sum[15];
char mp[15][1005];
signed main()
{
	//freopen(".in","r",stdin);
	//freopen(".out","w",stdout);
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	cin>>n>>m>>k;
	for(int i=1;i<=n;i++)
		for(int j=1;j<=m;j++)
			cin>>mp[i][j];
	int res=inf;
	for(int id=0;id<1<<(n-1);id++)
	{
		int t=id;
		for(int i=1;i<=n-1;i++)
		{
			cut[i]=t%2;
			t/=2;
		}
		cut[n]=1;
		memset(cnt,0,sizeof(cnt));
		int ans=__builtin_popcount(id);
		for(int i=1;i<=m;i++)
		{
			memset(sum,0,sizeof(sum));
			int cur=0;
			for(int j=1;j<=n;j++)
			{
				cur+=mp[j][i]-'0';
				if(cut[j])
				{
					sum[j]=cur;
					cur=0;
				}
			}
			bool flag=false;
			for(int j=1;j<=n;j++)
				if(cut[j]&&cnt[j]+sum[j]>k)
					flag=true;
			if(flag)
			{
				ans++;
				memcpy(cnt,sum,sizeof(cnt));
				bool cc=false;
				for(int j=1;j<=n;j++)
					if(cnt[j]>k)
						cc=true;
				if(cc)
				{
					ans=inf;
					break;
				}
			}
			else
			{
				for(int j=1;j<=n;j++)
					if(cut[j])
						cnt[j]+=sum[j];
			}
		}
		res=min(res,ans);
	}
	cout<<res<<endl;
	return 0;
}


Measured memory_bytes: 256
A, B = map(int, input().split())

pfa = {}
for i in range(2, int(A**0.5) + 1):
    while A % i == 0:
        pfa[i] = pfa.get(i, 0) + 1
        A //= i
if A > 1:
    pfa[A] = pfa.get(A, 0) + 1

pfb = {}
for i in range(2, int(B**0.5) + 1):
    while B % i == 0:
        pfb[i] = pfb.get(i, 0) + 1
        B //= i
if B > 1:
    pfb[B] = pfb.get(B, 0) + 1

s = set(pfa.keys()) & set(pfb.keys())
print(len(s) + 1)

Measured memory_bytes: 3064
#include<iostream>
using namespace std;
int main(){
  int a ,b;
  char op;

  
  while(1){
  cin >> a >> op >> b;
  
  // cout << op << endl;
 
    if (op == '+'){ //???????????????????????°????????????????????§???

      cout << a+b << endl;

    }

    else if (op == '-'){

      cout << a-b << endl;
    }

    else if (op == '*'){

      cout << a*b << endl;
    }

    else if (op == '/'){
      cout << a/b << endl;
 
    }
    else break;

  }
  return 0;
}

Measured memory_bytes: 1160