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

using namespace std;

typedef long long LL;

const int MX=4005,N=MX/2,MXV=200005,md=1000000007,iv2=(md+1)/2;
int n,m,ch,ff,ans;
int a[MXV],b[MXV];
int s[MX][MX],C[MX][MX];

int main(){
	int i,j;
	cin>>n;
	for(i=1;i<=n;i++)cin>>a[i]>>b[i];
	for(i=1;i<=n;i++)s[N-a[i]][N-b[i]]++;
	for(i=1;i<MX;i++)C[i][0]=C[0][i]=1;
	for(i=1;i<MX;i++)
		for (j=1;j<MX;j++) {
			s[i][j]=(s[i-1][j]+s[i][j-1]+s[i][j])%md;
			C[i][j]=(C[i-1][j]+C[i][j-1])%md;
		}
	for(i=1;i<=n;i++)ans=(ans+s[N+a[i]][N+b[i]])%md;
	for(i=1;i<=n;i++)ans=(ans+md-C[a[i]*2][b[i]*2])%md;
	ans=(LL)ans*iv2%md;
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 127104
#include <stdio.h>
int main(void){
    // Your code here!
    int sx,sy,tx,ty;
    
    scanf("%d%d%d%d",&sx,&sy,&tx,&ty);
    
    for(int z = 0;z < 2; z++){
        char op1,op2;
        if(z == 0){
            op1 = 'U';
            op2 = 'R';
        }
        else{
            op1 = 'D';
            op2 = 'L';
        }
        
        for(int i = 0;i<ty-sy;i++){
            printf("%c",op1);
        }
        
        for(int j = 0;j<tx-sx;j++){
            printf("%c",op2);        
        }
    }
    
    for(int z = 0;z < 2; z++){
        char op1,op2;
        if(z == 0){
            op1 = 'U';
            op2 = 'R';
        }
        else{
            op1 = 'D';
            op2 = 'L';
        }
        
        if(z == 0){
            printf("L");
        }else{
            printf("R");
        }
        
        for(int i = 0;i<ty-sy+1;i++){
            printf("%c",op1);
        }
        
        for(int j = 0;j<tx-sx+1;j++){
            printf("%c",op2);        
        }
        
        if(z == 0){
            printf("D");
        }
        else{
            printf("U");
        }
    }
}

Measured memory_bytes: 128
import math
X, Y = map(int,input().split())
if (X+Y)%3 != 0:
    print(0)
    exit(0)

k = (X+Y)//3
if k > X or k > Y:
    print(0)
    exit(0)

def cmb(n, r, mod):
    if ( r<0 or r>n ):
        return 0
    r = min(r, n-r)
    return g1[n] * g2[r] * g2[n-r] % mod

mod = 10**9 + 7 #出力の制限
N = 10**6 + 1
g1 = [1, 1] # 元テーブル
g2 = [1, 1] #逆元テーブル
inverse = [0, 1] #逆元テーブル計算用テーブル

for i in range( 2, N + 1 ):
    g1.append( ( g1[-1] * i ) % mod )
    inverse.append( ( -inverse[mod % i] * (mod//i) ) % mod )
    g2.append( (g2[-1] * inverse[-1]) % mod )

print(cmb(k,abs(k-X),mod))


Measured memory_bytes: 128012
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <vector>
#include <utility>
#include <cstdio>
#include <iomanip>
#include <cmath>
#include <string>
#include <stack>
#include <queue>
#include <map>
#include <stdlib.h>
#include <set>
typedef long long ll;
using namespace std;

int main() {
	int sum;
	string s;
	cin>>s;
	for(int i=0;i<s.length();i++){
		if(s.substr(i,1)=="+"){
			sum++;
		}else{
			sum--;
		}
	}
	cout<<sum<<endl;
	return 0;
}


Measured memory_bytes: 256
n,m=map(int,input().split())
a=[list(map(int,input().split())) for i in range(n)]
cnt=[0]*m
for i in range(n):
    k=a[i].pop(0)
    for j in range(k):
        cnt[a[i][j]-1]+=1
ans=0
for c in cnt:
    if c==n:
        ans+=1
print(ans)


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define REP(i,x,n) for(int i=x;i<(int)n;i++)
#define rep(i,n) REP(i,0,n)
#define sp(p) cout<<setprecision(16)<<fixed<<p<<endl;
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define SORT(a) sort(all(a))
#define RSORT(a) sort(rall(a))
#define UNIQ(a) unique(all(a))
#define UNIQNUM(a) UNIQ(a)-a.begin()
#define UNIQIT(a) a.erase(UNIQ(a), a.end());
#define VOUT(v,i) rep(i,v.size())cout<<v[i]<<(i==v.size()-1?"\n":" ");
#define vout(v) VOUT(v,z);
#define vdbg(v,i) cout<<#v<<": ";for(int i=0;i<(int)v.size();i++){cout<<v[i]<<" ";}cout<<"\n";
#define vmin(v) *min_element(all(v))
#define vmax(v) *max_element(all(v))
#define vsum(v) accumulate(all(v), 0LL)
#define MOUT(m,r,c) rep(i,r){rep(j,c){cout<<m[i][j]<<" ";}cout<<endl;}
#define mout(m) MOUT(m,m.size(),m[0].size())
#define debg(a) cout<<#a<<": "<<a<<endl;
#define show(a) for(cont &y:a){for(cont &x:y){cout<<x<<" ";}cout<<endl;}
#define digit(a) to_string(a).length();
template<class T>inline int out(const T &t){ print(t); putchar('\n'); return 0; }
// template<class T>inline T gcd(T a,T b){if(b==0)return a; return(gcd(b,a%b));}
// template<class T>inline T lcm(T a,T b){return a/gcd(a,b)*b;}
bool is_palindrome(string s){return s == string(s.rbegin(),s.rend());}
#define popcount __builtin_popcount
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> P;
typedef vector<ll> V;
typedef vector<vector<ll>> VV;
// const long long MOD=1000000007;
const long long INF = 1e18;
#define EPS (1e-7)
#define PI (acos(-1))
template<class T>
inline bool chmax(T &a, T b) {
    if(a < b) { a = b; return true; }
    return false;
}
template<class T>
inline bool chmin(T &a, T b) {
    if(a > b) { a = b; return true; }
    return false;
}

const string YES = "Yes";
const string NO = "No";
#define judge(f) cout<<((f)?YES:NO)<<"\n";


int main(){
    std::string N;
    std::cin >> N;
    ll sum=0;
    for (long long i = 0; i < N.length(); i++) {
        sum+=(N[i]-'0');
    }
    judge(!(sum%9));
    return 0;
}


Measured memory_bytes: 3756
n = int(input())
num = [0] * 10001
for i in range(1, 142):
    for j in range(1, 142):
        for k in range(1, 142):
            temp = i + j + k
            if temp % 2 == 0:
                if i + j > k and j + k > i and k + i > j:
                    temp2 = (i ** 2 + j ** 2 + k ** 2) // 2
                    if 0 <= temp2 <= 10000:
                        num[temp2] += 1
for i in range(1, n + 1):
    print(num[i])

Measured memory_bytes: 68944
#include <bits/stdc++.h>
using namespace std;
const long inf = 1e18;
int n;
long a[200000];
long dp[5][200001];
int main() {
  cin >> n;
  for (int i = 0; i < n; ++i) cin >> a[i];
  
  for (int i = 0; i <= n; ++i) {
    for (int k = 0; k < 5; ++k) {
      dp[k][i] = inf;
    }
  }
  
  dp[0][0] = 0;
  for (int i = 0; i < n; ++i) {
    for (int k = 0; k < 5; ++k) {
      for (int nk = k; nk < 5; ++nk) {
        long c;
        if (nk == 0 || nk == 4) c = a[i];
        if (nk == 1 || nk == 3) c = a[i] == 0 ? 2 : a[i] % 2;
        if (nk == 2) c = a[i] % 2 == 0;
        dp[nk][i + 1] = min(dp[nk][i + 1], dp[k][i] + c);
      }
    }
  }
  
  long mn = inf;
  for (int k = 0; k < 5; ++k) {
    mn = min(mn, dp[k][n]);
  }
  cout << mn << endl;
}



Measured memory_bytes: 13000
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>
#include <climits>
using namespace std;

#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;


int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, c;
    cin >> n >> c;
    vector<vector<bool>> t_tab(c, vector<bool>((int)1e5 + 1, false));
    REP(i, n) {
        int s, t, c;
        cin >> s >> t >> c;
        c--;
        FOR(j, s, t) t_tab[c][j] = true;
    }

    int ans = 0;
    FOR(i, 1, (int)1e5) {
        int c_sum = 0;
        REP(j, c)if(t_tab[j][i]) c_sum++;
        ans = max(ans, c_sum);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 640
using System.Collections.Generic;
using System.Linq;
using System;

namespace bla2
{
    class Program
    {
        static void Main()
        {
            string[] s = Console.ReadLine().Split();
            int n = int.Parse(s[0]);
            int k = int.Parse(s[1]);
            List<long> x = Console.ReadLine().Split().ToList().ConvertAll(long.Parse);
            List<long> neg = new List<long>();
            List<long> pos = new List<long>();
            int i;
            for (i = 0; i < x.Count && x[i] < 0; i++)
            {
                neg.Add(-x[i]);
            }
            if (i < x.Count)
            {
                if (x[i] == 0) { k--; i++; }
                for (; i < x.Count; i++)
                {
                    pos.Add(x[i]);
                }
            }
            neg.Reverse();
            if (k <= 0) { Console.WriteLine(0); return; }
            long best = long.MaxValue;
            if(k <= pos.Count) best = pos[k - 1];
            if (k <= neg.Count) best = Math.Min(best, neg[k - 1]);
            if (neg.Count != 0 && pos.Count != 0)
            {
                for (int j = 1; j < k; j++)
                {
                    if (j - 1 >= pos.Count) break;
                    if (k - j < 1) break;
                    if (k - j - 1 >= neg.Count) continue;
                    best = Math.Min(best, pos[j - 1] * 2 + neg[k - j - 1]);
                }
                for (int j = 1; j < k; j++)
                {
                    if (j - 1 >= neg.Count) break;
                    if (k - j < 1) break;
                    if (k - j - 1 >= pos.Count) continue;
                    best = Math.Min(best, neg[j - 1] * 2 + pos[k - j - 1]);
                }
            }
            Console.WriteLine(best);
        }
    }
}

Measured memory_bytes: 25696
#include<stdio.h>
int main(){
 	int i;	
  long a,b,c,d,x,y,p,q;	
  int ans = 0;
  
  scanf("%ld %ld %ld %ld",&a,&b,&c,&d);
  
  if(a*c>=a*d&&a*c>=b*c&&a*c>=b*d){
   printf("%ld",a*c);
    return 0;
  }else if(a*d>=b*c&&a*d>=b*d){
   printf("%ld",a*d);
    return 0; 
  }else if(b*c>=b*d){
   printf("%ld",b*c);
    return 0; 
  }else{
   printf("%ld",b*d);
    return 0; 
  }
  
  
  return 0;
}

Measured memory_bytes: 1736
from sys import stdin,stdout
from collections import Counter
n=int(stdin.readline())
a=sorted(map(int,stdin.readline().split()))
d=Counter(a)
m1=max(a);ans=0
vis=[0]*(m1+1)
for v in a:
    if not vis[v]:
        if d[v]==1:ans+=1
        for mul in range(v,m1+1,v):
            vis[mul]=1
stdout.write(str(ans))



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

#define DEBUG(x) cerr << #x << ": " << x << endl;
#define ll long long

int main() {
    int a, b, c;
    cin >> a >> b >> c;

    if (b - a == c - b) {
        puts("YES");
    } else {
        puts("NO");
    }

    return 0;
}

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

using namespace std;

#define DUMP(x) std::cout << (#x) << " = " << (x) << "\n"
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define ALL(r) r.begin(), r.end()

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

void Main() {
    int a, b;
    cin >> a >> b;
    int m = max(max(a + b, a - b), a*b);
    cout << m << endl;
}

int main() {
    std::cin.tie(nullptr);
    std::ios_base::sync_with_stdio(false);
    std::cout << std::fixed << std::setprecision(15);
    Main();
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <array>
#include <cstdlib>
#include <functional>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stdlib.h>
#include <string>
#include <vector>

#define INF 1000000000
#define MOD 1000000007
#define ll long long
#define rep(i,a,b) for(i = (a); i < (b); i++)
#define bitget(a,b) (((a) >> (b)) & 1)
#define vint vector<int>
#define vvint vector<vector<int>>
#define vsort(x) sort(x.begin(),x.end())

using int64 = uint64_t;

using namespace std;

int main() {

	int i, j, k;
	int n;
	cin >> n;
	int t[102] = {}, v[102] = {};
	rep(i, 0, n)
		cin >> t[i];
	rep(i, 0, n)
		cin >> v[i];
	int nowv = 0;
	int nowl = 0;
	int now = 0;
	long long int ans = 0;
	int ans5 = 0;
	int maxv[102] = {};
	int nowmax = 0;
	int p;
	for (i = n - 2;i != -1;i--) {
		nowmax += t[i + 1];
		nowmax = min(nowmax, v[i + 1]);
		maxv[i] = nowmax;
	}
	while (1) {
		p = maxv[now] + (t[now] - nowl) - nowv;
		if (p > 1) {
			if (nowv < v[now]) {
				if (ans5>1) {
					ans += nowv + 1;
					ans5 -=2;
				}
				else {
					ans += nowv;
					ans5 += 2;
				}
				nowv++;
			}
			else {
				ans += nowv;
			}
		}
		else if (p > 0) {
			if (nowv < v[now]) {
				if (ans5 == 3) {
					ans += nowv + 1;
					ans5 = 0;
				}
				else {
					ans += nowv;
					ans5++;
				}
			}
			else {
				ans += nowv;
			}
		}
		else {
			nowv--;
			if (ans5 > 1) {
				ans += nowv + 1;
				ans5 -= 2;
			}
			else {
				ans += nowv;
				ans5 += 2;
			}
		}
		nowl++;
		if (nowl == t[now]) {
			nowl = 0;
			now++;
		}
		if (now == n) {
			break;
		}
	}
	cout << ans;
	if (ans5 == 1) {
		cout << ".25" << endl;
	}
	else if (ans5 == 2) {
		cout << ".5" << endl;
	}
	else if (ans5 == 3) {
		cout << ".75" << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

const ll mod = 1000000007;

int main() {
    ll A, ans;
    long double B;
    cin >> A >> B;
    ans = (ll)(A * B);
    cout << ans << endl;
    
    return 0;
}


Measured memory_bytes: 3736
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#define FOR(i, a, n) for(int i = (int)(a); i < (int)(n); ++i)
#define REP(i, n) FOR(i, 0, n)
#define SORT(a) sort(a.begin(),a.end())
using namespace std;
int main(){
    //Seiranchan!
    int S,E;
    cin >> S >> E;
    int cnt=0;
    for(int i=S;i<=E;i++){
    string st = to_string(i);
    if(st[0]==st[4]&&st[1]==st[3]){
        cnt ++;
    }
    }
    cout << cnt << endl;

}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
const int N = 707;
bool dp[2][N], graph[N][N];
int cnt[2];
int col[N];
int n, m;
bool dfs (int cur) {
  cnt[col[cur]]++;
  for (int nxt = 0; nxt < n; nxt++) {
    if (!graph[cur][nxt]) continue;
    if (col[nxt] != -1) {
      if (col[cur] == col[nxt]) return false;
    } else {
      col[nxt] = 1 ^ col[cur];
      if (!dfs(nxt)) return false;
    }
  }
  return true;
}
signed main() { 
  ios::sync_with_stdio(false); cin.tie(0);
  cin >> n >> m;
  for (int i = 0; i < n; i++) for (int j = 0; j < n; j++) if (i != j) graph[i][j] = graph[j][i] = 1;
  for (int i = 0; i < m; i++) {
    int a, b;
    cin >> a >> b;
    a--;
    b--;
    graph[a][b] = graph[b][a] = 0;
  }
  dp[0][0] = 1;
  memset(col, -1, sizeof(col));
  for (int i = 0; i < n; i++) {
    if (col[i] != -1) continue;
    col[i] = 0;
    cnt[0] = cnt[1] = 0;
    if (!dfs(i)) {
      cout << -1 << endl;
      return 0;
    }
    for (int j = 0; j <= n; j++) if (dp[0][j]) {
      if (j + cnt[0] < N) dp[1][j + cnt[0]] = 1;
      if (j + cnt[1] < N) dp[1][j + cnt[1]] = 1;
    }
    for (int j = 0; j <= n; j++) {
      dp[0][j] = dp[1][j];
      dp[1][j] = 0;
    }
  }
  int res = n / 2;
  while (!dp[0][res]) res--;
  cout << (res * (res - 1) / 2 + (n - res) * (n - res - 1) / 2) << endl;
  return 0;
}

Measured memory_bytes: 896
#include <stdio.h>

int main(void) {

	int n, m, l;
	int a[100][100] = { 0 };
	int b[100][100] = { 0 };
	long c[100][100] = { 0 };

	scanf("%d %d %d", &n, &m, &l);

	for (int n_i = 0; n_i < n; n_i++) {
		for (int m_i = 0; m_i < m; m_i++) {
			scanf("%d", &a[n_i][m_i]);
		}
	}

	for (int m_i = 0; m_i < m; m_i++) {
		for (int l_i = 0; l_i < l; l_i++) {
			scanf("%d", &b[m_i][l_i]);
		}
	}

	for (int i = 0; i < n; i++) {
		for (int j = 0; j < l; j++) {
			for (int k = 0; k < m; k++) {
				c[i][j] += (a[i][k] * b[k][j]);
			}
			if (j == l - 1) {
					printf("%ld\n", c[i][j]);
			}
			else {
				printf("%ld ", c[i][j]);
			}
			
		}
	}

	return 0;
}




Measured memory_bytes: 2036
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file 
#include <ext/pb_ds/tree_policy.hpp> 
#include <functional> // for less 
#define pb push_back
#define For(i,s,e) for (ll i=(s); i<(e); i++)
#define Debug_array(a,n) for (ll i=(0); i<(n); i++) cout<<a[i]<<" "
#define Foe(i,s,e) for (ll i=(s); i<=(e); i++)
#define Fod(i,s,e) for (ll i=(s)-1; i>=(e); i--)
#define Mod 1000000007
#define pii pair<ll,ll>
#define fi first
#define se second
#define endl "\n"
#define mp make_pair
#define big_prime 15486277
#define bigger_prime 179424697
#define biggest_prime 32416188691
//#define random_shuffle(indices.begin(), indices.end());
//std::random_device rd;
//std::mt19937 g(rd());
//std::shuffle(v.begin(), v.end(), g);
using namespace __gnu_pbds; 
using namespace std;

typedef long long ll;
typedef tree<ll, null_type, less<ll>, rb_tree_tag,tree_order_statistics_node_update> ordered_set; 

#define MAX 5002

int main(){
	ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
	
	ll n,m;cin>>n>>m;
	bitset<11> s[m];
	For(i,0,m){
		ll k;cin>>k;
		s[i] = bitset<11>(0);
		For(w,0,k){
			ll x;cin>>x;x--;
			s[i][x]=1;
		}
	}
	ll p[m];
	For(i,0,m) cin>>p[i];

	ll ans=0;
	For(b,0,(1<<n)){	
		bool ok=1;	
		For(i,0,m){
			bitset<11> B(b);
			B = B&s[i];
			if(B.count()%2==p[i]) continue;
			else{
				ok=0;
				break;
			} 
		}
		if(ok) ans++;
	}
	cout<<ans<<endl;









	
}

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

using namespace std;

int main() {
    int t = 0, k, s;
    cin >> k >> s;
    for(int x=0; x<=k; x++) {
        for(int y=0; y<=k; y++) {
           if(s-x-y >= 0 && s-x-y <= k) {
               t += 1;
           }
        }
    }
    cout << t << endl;
}

Measured memory_bytes: 256
from collections import deque
N,X,M = map(int, input().split())

nodeset = set()
nodeset.add(X)

nodeq = deque()
nodeq.append(X)

is_finish = False
s,e = 0, N
for i in range(N-1):
    X = (X*X) % M
    if X in nodeset:
        is_finish = True
        
        for p, start in enumerate(nodeq):
            if X == start:
                s = p
                break
        # ループ終了
        break

    nodeq.append(X)
    nodeset.add(X)

nodelist = list(nodeq)
if is_finish:
    loop_size = len(nodelist) - s # 繰り返し部分のサイズ
    loop_cnt = (N - s) //loop_size # 繰り返し回数
    loop_sum = sum(nodelist[s:]) # 繰り返し部分の和
    alpha = (N - s) % loop_size # すべてやったあとの繰り返し部分の余り
    result = sum(nodelist[:s]) + loop_cnt * loop_sum + sum(nodelist[s:s+alpha])
    print(result)
else:
    print(sum(nodelist))



Measured memory_bytes: 13904
#include "bits/stdc++.h"
using namespace std;
#ifdef _DEBUG
#include "dump.hpp"
#else
#define dump(...)
#endif

//#define int long long
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)
const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9 + 7);
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; }

signed main() {
	int N, M; cin >> N >> M;
	vector<string> A(N); rep(i, 0, N) { cin >> A[i]; }
	vector<string> B(M); rep(i, 0, M) { cin >> B[i]; }
	rep(i, 0, N - M + 1)rep(j, 0, N - M + 1) {
		dump(i, j);
		bool flag = false;
		if (A[i][j] != B[0][0])continue;
		rep(k, 0, M)rep(l, 0, M) {
			if (A[i + k][j + l] != B[k][l]) { dump(i, j); flag = true; k = INF; break; }
		}
		if (flag)continue;
		cout << "Yes" << endl;
		return 0;
	}
	cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
int main(void)
{
  int l;
  int hiyou[12][2];
  int i;

  while(1){
    int sum=0;
    int m=0;
    scanf("%d",&l);
    if(l==0)
      break;

    for(i=0;i<12;i++)
      scanf("%d %d",&hiyou[i][0],&hiyou[i][1]);

    for(i=0;i<12;i++){
      sum+=hiyou[i][0]-hiyou[i][1];
      if(sum>=l){
	m=i+1;
	break;
      }
    }

    if(m)
      printf("%d\n",m);
    else
      printf("NA\n");
  }

  return 0;
}

Measured memory_bytes: 612
#include<algorithm>
#include<iostream>
#include<cstring>
#include<iomanip>
#include<sstream>
#include<cstdio>
#include<string>
#include<vector>
#include<bitset>
#include<queue>
#include<cmath>
#include<stack>
#include<set>
#include<map>
#define rep(i,x,n) for(int i=x;i<=n;i++)
#define per(i,n,x) for(int i=n;i>=x;i--)
#define sz(a) int(a.size())
#define rson mid+1,r,p<<1|1
#define pii pair<int,int>
#define lson l,mid,p<<1
#define ll long long
#define pb push_back
#define mp make_pair
#define se second
#define fi first
using namespace std;
const double eps=1e-8;
const int mod=1e9+7;
const int N=2e5+10;
const int inf=1e9;
int n,k;
int a[N];
bool ck(int x){
	int cnt=0;
	rep(i,1,n){
		int y=a[i];
		cnt+=(y-1)/x;
		if(cnt>k) return false;
	}
	return cnt<=k;
}
int main(){
	ios::sync_with_stdio(false);
	//freopen("in","r",stdin);
	cin>>n>>k;
	rep(i,1,n){
		cin>>a[i];
	}
	int l=1,r=1e9;
	while(l<=r){
		int mid=(l+r)/2;
		if(ck(mid)) r=mid-1;
		else l=mid+1;
	}
	printf("%d\n",l);
	return 0;
}

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

#define rep(i, n) for(int (i) = 0; (i) < (n); (i)++)
#define repp(i, n, m) for(int (i) = (n); (i) < (m); (i)++)
#define repn(i, n) for(int (i) = 1; (i) <= (n); (i)++)
#define repr(i, n) for(int (i) = (n-1); (i) >= 0; (i)--)
#define all(x) (x).begin(), (x).end()
#define lint long long
#define ulint unsigned long long
#define ldou long double
#define fi first
#define se second
#define setpre(x) std::cout << fixed << setprecision(x)
#define ii(x) int x; cin >> (x)
#define ii2(x, y) int x, y; cin >> (x) >> (y)
#define ii3(x, y, z) int x, y, z; cin >> (x) >> (y) >> (z)
#define out(x) cout << (x) << endl
#define outs(x) cout << (x) << " "
#define yn(x) cout << ((x)?("Yes"):("No")) << endl
#define YN(x) cout << ((x)?("YES"):("NO")) << endl
#define bit_c(x) __builtin_popcountll(x)

inline void logger(){ std::cout << " [LOGGER] " << endl; }
template<typename A, typename... B>
void logger(const A& a, const B&... b){
    cout << a << " , ";
    logger(b...);
}

typedef pair<lint, lint> P;
const lint MOD = 1000000007;
const lint MOD9 = 998244353;
const lint INF = MOD * MOD;
const int MAX = 100005;

/* ...o(^-^)o... */
int dp[3005][3005];

int main(){
    string s, t; cin >> s >> t;
    int n = s.size(), m = t.size();

    rep(i, n) rep(j, m){
        if(s[i]==t[j]){
            dp[i+1][j+1] = max({dp[i][j+1], dp[i+1][j], dp[i][j]+1});
        }
        else{
            dp[i+1][j+1] = max(dp[i][j+1], dp[i+1][j]);
        }
    }

    string ans = ""; int c = dp[n][m];
    repr(i, n) repr(j, m){
        if(dp[i+1][j+1]==c && dp[i][j+1]==c-1 && dp[i+1][j]==c-1){
            ans += string{s[i]};
            c--;
            break;
        }
    }
    reverse(all(ans));
    out(ans);
}

Measured memory_bytes: 35456
H,W=map(int,input().split())
S=[list(map(str,input())) for _ in range(H)]

for i in range(H):
    for j in range(W-1):
        if S[i][j]!='.' and S[i][j+1]!='.':
            S[i][j]='x'
            S[i][j+1]='x'

for j,s in enumerate(zip(*S)):
    for i in range(H-1):
        if s[i]!='.' and s[i+1]!='.':
            S[i][j]='x'
            S[i+1][j]='x'

for i in range(H):
    for j in range(W):
        if S[i][j]=='#':
            print('No')
            exit()
print('Yes')

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

#define forn(i,x,y) for(int i = int(x); i<int(y); i++)
#define debug(x) cerr << #x << " == " << (x) << '\n';
#define all(V) V.begin(), V.end()
#define on(x, b) (x & (1LL << b))
#define trav(x, v) for(auto &x : v)

#define f first
#define s second

const int N = 1e5 + 10;

int main() {
    ios::sync_with_stdio(false); cin.tie(NULL);
    int L; cin >> L;
    double l = (double)L / 3.0;
    cout << fixed << setprecision(12) << l * l * l << "\n";

    return 0;
}

/* don't forget to check:
   int overflow
   min/max cases (n = 1)
   printing index of sorted array
   limits for ans (start with inf)
   s = 'x' + s is linear! dont use it!
 */

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

public class Main {

    Node rootNode;

    class Node {
        int value;
        Node p, l, r;

        public Node(int value) {
            this.value = value;
        }
    }

    void insert(Node n) {
        if (rootNode == null) {
            rootNode = n;
            return;
        }
        Node x = rootNode;
        Node y = x;
        while (x != null) {
            y = x;
            n.p = x;
            if (x.value < n.value) {
                x = x.r;
            } else {
                x = x.l;
            }
        }
        if (y.value < n.value) {
            y.r = n;
        } else {
            y.l = n;
        }
    }

    void print() {
        preorder(rootNode);
        System.out.println();
        inorder(rootNode);
        System.out.println();
    }

    void inorder(Node n) {
        if (n == null) return;
        System.out.print(" " + n.value);
        inorder(n.l);
        inorder(n.r);
    }

    void preorder(Node n) {
        if (n == null) return;
        preorder(n.l);
        System.out.print(" " + n.value);
        preorder(n.r);
    }

    void run() {
        Scanner sc = new Scanner(System.in);

        int n = sc.nextInt();

        for (int i = 0; i < n; i++) {
            String s = sc.next();
            if (s.equals("insert")) {
                int k = sc.nextInt();
                insert(new Node(k));
            } else if (s.equals("print")) {
                print();
            }
        }
    }

    void debug(Object... os) {
        System.err.println(Arrays.deepToString(os));
    }

    public static void main(String[] args) {
        new Main().run();
    }
}



Measured memory_bytes: 222604
import sys, math
from functools import lru_cache
from collections import deque
sys.setrecursionlimit(500000)
MOD = 10**9+7

def input():
    return sys.stdin.readline()[:-1]

def mi():
    return map(int, input().split())

def ii():
    return int(input())

def i2(n):
    tmp = [list(mi()) for i in range(n)]
    return [list(i) for i in zip(*tmp)]

def main():
    A, B, C = mi()
    if A < C < B or A > C > B:
        print('Yes')
    else:
        print('No')


if __name__ == '__main__':
    main()

Measured memory_bytes: 9416
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i, c) for (int i = 0; i < (int)c; i++)
#define all(v) v.begin(), v.end()
const int inf = 1000000000; //10^9
using ll = long long;
using P = pair<int, int>;
//加算代入演算子は+=！！！！！

int main()
{
    string s, ans;
    ans = "";
    cin >> s;
    rep(i, s.size())
    {
        if (s.at(i) == '0')
        {
            ans += "0";
        }
        if (s.at(i) == '1')
        {
            ans += "1";
        }
        if (s.at(i) == 'B' and ans.size() != 0)
        {
            ans.erase(--ans.end());
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
n=int(input())
l=[list(map(int,input().split())) for i in range(n)]
dp=[[0 for i in range(3)] for j in range(n+1)]
dp[1]=l[0]
for i in range(2,n+1):
  for j in range(3):
    dp[i][j]=max(dp[i-1][j-1],dp[i-1][j-2])+l[i-1][j]
print(max(dp[-1]))

Measured memory_bytes: 75736
// ?????¬???????????¬??????

#include <cstdio>
#include <algorithm>
#include <vector>
#include <functional>
using namespace std;

#define rep(i,a,n) for(int (i)=(a); (i)<(n); (i)++)
#define repq(i,a,n) for(int (i)=(a); (i)<=(n); (i)++)
#define repr(i,a,n) for(int (i)=(a); (i)>=(n); (i)--)
#define int long long int

template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}

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

int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
constexpr ll INF = 1001001001001001LL;
constexpr ll MOD = 1000000007LL;

// ????????¢?´¢ (kD ??¨???2 ?¬???????????????§???)
struct Node {
    int loc, p, l, r;
};

struct Point {
    int id, x, y;
};

Node T[500010];
Point P[500010];
int np = 0, NIL = -1;

// [l, r) ??????????????????????????????????§????
int make(int l, int r, int depth=0) {
    if(l >= r) return NIL;
    int mid = (l + r) / 2, t = np++;
    if(depth % 2 == 0) {
        sort(P+l, P+r, [](const Point &a, const Point &b){return a.x < b.x;});
    }
    else {
        sort(P+l, P+r, [](const Point &a, const Point &b){return a.y < b.y;});
    }
    T[t].loc = mid;
    T[t].l = make(l, mid,   depth+1);
    T[t].r = make(mid+1, r, depth+1);
    return t;
}

// ?????? (sx, ty)????????? (tx, sy) ???????????¢???????????????????????????
// v ??? kD-tree ??????????????????????????????
void find(int v, int sx, int tx, int sy, int ty, vector<int> &ans, int depth=0) {
    int x = P[T[v].loc].x, y = P[T[v].loc].y;
    if(sx <= x && x <= tx && sy <= y && y <= ty) {
        // ans.push_back(Point{x, y});
        ans.push_back(P[T[v].loc].id);
    }

    if(depth % 2 == 0) {
        if(T[v].l != NIL && sx <= x) find(T[v].l, sx, tx, sy, ty, ans, depth+1);
        if(T[v].r != NIL && x <= tx) find(T[v].r, sx, tx, sy, ty, ans, depth+1);
    }
    else {
        if(T[v].l != NIL && sy <= y) find(T[v].l, sx, tx, sy, ty, ans, depth+1);
        if(T[v].r != NIL && y <= ty) find(T[v].r, sx, tx, sy, ty, ans, depth+1);
    }
}

// kD-tree end

int N, Q;

signed main() {
    scanf("%lld", &N);
    rep(i,0,N) {
        int x, y; scanf("%lld%lld", &x, &y);
        P[i] = Point{i, x, y};
        T[i].l = T[i].r = T[i].p = NIL;
    }
    int root = make(0, N);

    scanf("%lld", &Q);
    rep(i,0,Q) {
        vector<int> ans;
        int sx, tx, sy, ty;
        scanf("%lld%lld%lld%lld", &sx, &tx, &sy, &ty);
        find(root, sx, tx, sy, ty, ans);
        sort(ans.begin(), ans.end());

        for(auto x : ans) printf("%lld\n", x);
        printf("\n");
    }
    return 0;
}

Measured memory_bytes: 29300
#include<stdio.h>

int main(void)
{
	int a,b,c;
	scanf("%d%d%d",&a,&b,&c);
	if(a==b&&b==c){
		printf("No");
	}else{
		if(a!=b&&a!=c){
			if(b!=c)
				printf("No");
			else
				printf("Yes");
		}else
			printf("Yes");
		}
	
	return 0;
	
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#define rep(i, a, b) for (int i = a; i < (b); i++)
#define rrep(i, a, b) for (int i = a; i >= b; i--)
#define all(x) (x).begin(), (x).end()
using namespace std;
using ll = long long;
using P = pair<int, int>;

const int INF = 2e9;
const int MOD = 1e9 + 7;

int main() {
   int r, D, x;
   cin >> r >> D >> x;
   rep(i, 0, 10) {
      x = r * x - D;
      cout << x << endl;
   }
   return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <vector>
#include <array>

using namespace std;

int main() {
    // read input
    int n;
    vector<int> a;
    vector<int> b;

    cin >> n;
    int tmp;
    for (int i=0; i<n+1; i++) {
        cin >> tmp;
        a.push_back(tmp);
    }

    for (int i=0; i<n; i++) {
        cin >> tmp;
        b.push_back(tmp);
    }

    // calculate
    long sum = 0;
    for (int i=0; i<n; i++) {
        int atk_i = 0;
        int atk_i1 = 0;
        if (a[i] >= b[i]) {
            atk_i = b[i];
        } else {
            atk_i = a[i];
            atk_i1 = min(b[i]-a[i], a[i+1]);
        }
        a[i] -= atk_i;
        a[i+1] -= atk_i1;
        sum += atk_i + atk_i1;
    }

    cout << sum;
}

Measured memory_bytes: 1400
using System;
using System.Linq;
using System.Collections.Generic;

using E = System.Linq.Enumerable;

public class Program
{
    public static void Main()
    {
        var nm = Console.ReadLine().Split().Select(x => int.Parse(x)).ToArray();
        var (n, m) = (nm[0], nm[1]);
        var seqH = Console.ReadLine().Split().Select(x => int.Parse(x)).ToArray();
        var pairsAB = new (int A, int B)[m];
        for (int i = 0; i < pairsAB.Length; ++i)
        {
            var ab = Console.ReadLine().Split().Select(x => int.Parse(x)).ToArray();
            pairsAB[i] = (ab[0], ab[1]);
        }

        var highestNeighborhood = new int[seqH.Length + 1];
        for (int i = 0; i < pairsAB.Length; ++i)
        {
            var (a, b) = pairsAB[i];
            highestNeighborhood[a] = Math.Max(highestNeighborhood[a], seqH[b - 1]);
            highestNeighborhood[b] = Math.Max(highestNeighborhood[b], seqH[a - 1]);
        }

        var k = 0;
        for (int i = 1; i < highestNeighborhood.Length; ++i)
        {
            if (highestNeighborhood[i] < seqH[i - 1])
            {
                ++k;
            }
        }

        Console.WriteLine(k);
    }
}


Measured memory_bytes: 49352
n = int(input())
h = list(map(int, input().split()))

#aとbで小さい方を返す
def chmin(a,b):
    if a > b:
        return b
    else:
        return a

f_inf = float('inf')

dp = [f_inf] * (10**5+10)

dp[0] = 0

for i in range(1, n):
    dp[i] = chmin(dp[i], dp[i-1] + abs(h[i] - h[i-1]))

    if i > 1:
        dp[i] = chmin(dp[i], dp[i-2] + abs(h[i] - h[i-2]))

print(dp[n-1])

Measured memory_bytes: 13980
// Problem : D - .. (Double Dots)
// Contest : AtCoder - AtCoder Beginner Contest 168
// URL : https://atcoder.jp/contests/abc168/tasks/abc168_d
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

//mst,pq,mp,st,q
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define io ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define pb push_back
#define all(x) begin(x),end(x)

int mod = 1e9+7;
int inf = 4e18;
const int N = 5e5+5;
vector<int> adj[N];
bool vis[N];

int par[N];


signed main()
{
    io
    int tt = 1;
    //cin>>tt;
    while(tt--)
    {
		int n,m;
		cin>>n>>m;
		for(int i=0,u,v;i<m;++i)
		{
			cin>>u>>v;
			adj[u].pb(v);
			adj[v].pb(u);
		}
		queue<int> q;
		q.push(1);
		vis[1] = true;
		while(!q.empty())
		{
			int x = q.front();
			q.pop();
			for(auto it:adj[x])
			{
				if(!vis[it])
				{
					vis[it] = true;
					par[it] = x;
					q.push(it);
				}
			}
		}
		bool flag = true;
		for(int i=1;i<=n;++i)
		if(vis[i]==false)
		{
			flag = 0;
			break;
		}
		if(!flag)
		{
			cout<<"No";
			return 0;
		}
		cout<<"Yes\n";
		for(int i=2;i<=n;++i)
		cout<<par[i]<<"\n";  	
    }
    return 0;
}


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

#define ll long long

int main()
{
    string s, t;
    cin >> s >> t;
    
    int n = s.length() + 1, m = t.length() + 1;
    int dp[n][m], bk[n][m][3];
    
    int ans[2] = {};
    
    for (int i = 0; i < n; ++i)
    {
        for (int j = 0; j < m; ++j)
        {
            if (i == 0 || j == 0)
            {
                dp[i][j] = 0;
                
                bk[i][j][0] = bk[i][j][1] = 0;
                bk[i][j][2] = ' ';
            }
            else if (s[i - 1] == t[j - 1])
            {
                dp[i][j] = dp[i - 1][j - 1] + 1;
                
                bk[i][j][0] = i - 1;
                bk[i][j][1] = j - 1;
                
                bk[i][j][2] = s[i - 1];
                
                if (dp[i][j] > dp[ans[0]][ans[1]])
                    ans[0] = i, ans[1] = j;
            }
            else if (dp[i - 1][j] > dp[i][j - 1])
            {
                dp[i][j] = dp[i - 1][j];
                
                bk[i][j][0] = i - 1;
                bk[i][j][1] = j;
                
                bk[i][j][2] = bk[i - 1][j][2];
            }
            else
            {
                dp[i][j] = dp[i][j - 1];
                
                bk[i][j][0] = i;
                bk[i][j][1] = j - 1;
                
                bk[i][j][2] = bk[i][j - 1][2];
            }
        }
    }
    
    int prev = -1;
    
    string str = "";
    
    int i = ans[0], j = ans[1], temp;
    while (i != 0 && j != 0)
    {
        if (dp[i][j] != prev && dp[i][j] != 0)
        {
            str.push_back((char)bk[i][j][2]);
            prev = dp[i][j];
        }
        
        temp = i;
        i = bk[temp][j][0], j = bk[temp][j][1];
    }
    
    reverse(str.begin(), str.end());
    
    cout << str;
    
    return 0;
}

Measured memory_bytes: 140928
import java.util.*;

public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        final int N = sc.nextInt();
        long[] l = new long[N]; 
        long x = 0;
        long y = 0;
        long ans = 0;
        for(int i = 0;i < N;i++){  
            l[i] = sc.nextLong();
            if(i == 0)  x += l[i];
            else y += l[i];
        }
        ans = Math.abs(x-y);
        for(int i = 1;i < N-1;i++){
            x += l[i];
            y -= l[i];
            ans = Math.min(ans, Math.abs(x-y));
        }
        System.out.println(ans);
    }
}

Measured memory_bytes: 77856
A=int(input())
B=int(input())

if A==1:
    if B==2:
        print(3)
    if B==3:
        print(2)
if A==2:
    if B==3:
        print(1)
    if B==1:
        print(3)
if A==3:
    if B==1:
        print(2)
    if B==2:
        print(1)

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

int main()
{
  int N,M,x,y;
  string a;
  cin>>a;
    if(a=="a"||a=="i"||a=="u"||a=="e"||a=="o"){
      cout<<"vowel";
    }else{
      cout<<"consonant";
    }
  return 0;
}



Measured memory_bytes: 256
#template
from collections import Counter
def inputlist(): return [int(i) for i in input().split()]
#template
N,K,S = inputlist()
ans = []
for i in range(K):
    ans.append(S)
for i in range(N-K):
    if S == 1:
        ans.append(S+1)
    else:
        ans.append(S-1)
print(*ans)

Measured memory_bytes: 10020
(h,w,m),*e=[[*map(int,i.split())]for i in open(0)]
a,b=[0]*h,[0]*w
for y,x in e:
    a[y-1]+=1
    b[x-1]+=1
ans=max(a)+max(b)
c=a.count(max(a))*b.count(max(b))-sum(a[y-1]+b[x-1]==ans for y,x in e)
print(ans-(c<=0))

Measured memory_bytes: 68444
#include<bits/stdc++.h>
#include <array>
using namespace std;
#define rep(i, n) for(int i = 0; i < (n); i++)
using ULL = unsigned long long;
using UL = unsigned;
using LL = long long;

const UL maxDif = 15000;
bool dp[80][80][maxDif * 2 + 1] = {};

void Solve() {
	UL h, w; cin >> h >> w;
	UL A[80][80]; rep(y, h)rep(x, w) cin >> A[x][y];
	UL B[80][80]; rep(y, h)rep(x, w) cin >> B[x][y];
	rep(y, h) {
		rep(x, w) {
			UL a = A[x][y], b = B[x][y];
			if (x == 0 && y == 0) {
				dp[x][y][maxDif + b - a] = true;
				dp[x][y][maxDif + a - b] = true;
			}
			if (x != 0) {
				rep(i, maxDif * 2 + 1) {
					if (dp[x - 1][y][i])
						dp[x][y][i + b - a] = dp[x][y][i + a - b] = true;
				}
			}
			if (y != 0) {
				rep(i, maxDif * 2 + 1) {
					if (dp[x][y - 1][i])
						dp[x][y][i + b - a] = dp[x][y][i + a - b] = true;
				}
			}
		}
	}
	UL ans = maxDif;
	rep(i, maxDif * 2 + 1) {
		if (dp[w - 1][h - 1][i]) {
			ans = min(ans, (UL)abs((int)i - (int)maxDif));
		}
	}
	cout << ans << endl;
}

int main() {
	Solve();
	return 0;
}


Measured memory_bytes: 186240
from heapq import*
I=float("inf")
def m():
 n=int(input())
 A=[]
 for _ in range(n):
  e=list(map(int,input().split()))
  A+=[zip(e[2::2],e[3::2])]
 d=[0]+[I]*n
 H=[(0,0)]
 while H:
  u=heappop(H)[1]
  for v,c in A[u]:
   t=d[u]+c
   if d[v]>t:
    d[v]=t
    heappush(H,(t,v))
 for i in range(n):print(i,d[i])
m()


Measured memory_bytes: 40072
import java.util.*;
public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int M = sc.nextInt();
		int[][] data = new int[M][4];
		for(int i=0; i<M; i++){
			data[i][0] = i;
			data[i][1] = sc.nextInt();	//P
			data[i][2] = sc.nextInt();	//Y
			data[i][3] = 0;
		}
		Arrays.sort(data, (x, y) -> x[1]==y[1] ? x[2]-y[2] : x[1]-y[1]);
		int a = 0;
		int b = 0;
		for(int i=0; i<M; i++){
			if(data[i][1] != a){
				a = data[i][1];
				b = 0;
			}
			data[i][3] = ++b;
		}
		Arrays.sort(data, (x, y) -> x[0]-y[0]);
		StringBuilder string = new StringBuilder();
		for(int i=0; i<M; i++){
			string.append(String.format("%06d%06d\n", data[i][1], data[i][3]));
		}
		System.out.print(string.toString());
		return;
	}
}


Measured memory_bytes: 167952
n = int(input())
A = [int(x) for x in input().split()]
A = [0] + A + [0]

s = 0 #全体の合計値
for i in range(1, n+2):
  s += abs(A[i-1] - A[i])

for j in range(1, n+1):
  ans = s - abs(A[j-1] - A[j]) - abs(A[j] - A[j+1]) + abs(A[j-1] - A[j+1])
  print(ans)

Measured memory_bytes: 14048
//おまじない
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <utility>
#define INF 1e9+7
#define roop(i,m,n) for(int i=m;i<n;i++)
#define mroop(i,m,n) for(int i=m;i<n;i--)
#define NO cout<<"NO"<<endl;
#define YES cout << "YES"<<endl;
#define No cout << "No"<<endl;
#define Yes cout << "Yes"<<endl;
using namespace std;
typedef long long int ll;


//(int)'a'は97 (int)'A'は65
//おまじない



int main() {

	int w, h, n;
	int ans = 0;
	int rect[100][100] = { 0 };
	vector <pair<int, int>> po;
	int type[100] = { 0 };

	cin >> w >> h >> n;
	roop(i, 0, n) {
		pair<int, int> pa;
		cin >> pa.first >> pa.second >> type[i];
		po.push_back(pa);
	}

	roop(i, 0, n) {
		if (type[i] == 1) {
			roop(j, 0, h) {
				roop(k, 0, po[i].first) {
					rect[j][k] = 1;
				}
			}
		}
		else if (type[i] == 2) {
			roop(j, 0, h) {
				roop(k, po[i].first, w) {
					rect[j][k] = 1;
				}
			}
		}
		else if (type[i] == 4){
			roop(j, po[i].second, h) {
				roop(k, 0, w) {
					rect[j][k] = 1;
				}
			}
		}
		else if (type[i] == 3) {
			roop(j, 0, po[i].second) {
				roop(k, 0, w) {
					rect[j][k] = 1;
				}
			}
		}
		
	}

	roop(i, 0, h) {
		roop(k, 0, w) {
			if (rect[i][k] == 0)ans++;
		}
	}

	cout << ans << endl;

	return 0;
}


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

int main() {
  string S;
  int Q;
  cin >> S >> Q;
  vector<int> N(Q);
  vector<int> F(Q, 0);
  vector<char> C(Q);
  for (int i = 0; i < Q; i++) {
    int n; cin >> n;
    N[i] = n;
    if (n == 2) cin >> F[i] >> C[i];
  } 

  deque<char> deq(S.size());
  for (int i = 0; i < S.size(); i++) deq[i] = S[i];
  // 奇数なら反転のフラグ
  int flag = 0;
  for (int i = 0; i < Q; i++) {
    if (N[i] == 1) flag++;
    else {
      if (F[i] == 1 && flag % 2 == 0) deq.push_front(C[i]);
      if (F[i] == 2 && flag % 2 == 0) deq.push_back(C[i]);
      if (F[i] == 1 && flag % 2 == 1) deq.push_back(C[i]);
      if (F[i] == 2 && flag % 2 == 1) deq.push_front(C[i]);
    }
  }
  if (flag % 2 == 1) reverse(deq.begin(), deq.end());

  for (int i = 0; i < deq.size(); i++) cout << deq[i];
  cout << endl;
}


Measured memory_bytes: 2688
#include <iostream>
#include <string>
int main() {
	unsigned long long int n;
	std::cin >> n;
	if (n <= 6) std::cout << 1 << std::endl;
	else {

		std::cout << (n / 11 * 2 + ((n % 11 == 0) ? 0 : (n % 11 <= 6) ? 1 : 2)) << std::endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define R cin>>
#define Z class
#define ll long long
#define ln cout<<'\n'
#define in(a) insert(a)
#define pb(a) push_back(a)
#define pd(a) printf("%.10f\n",a)
#define mem(a) memset(a,0,sizeof(a))
#define all(c) (c).begin(),(c).end()
#define iter(c) __typeof((c).begin())
#define rrep(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define rep(i,n) REP(i,0,n)
#define tr(it,c) for(iter(c) it=(c).begin();it!=(c).end();it++)
template<Z A>void pr(A a){cout<<a;ln;}
template<Z A,Z B>void pr(A a,B b){cout<<a<<' ';pr(b);}
template<Z A,Z B,Z C>void pr(A a,B b,C c){cout<<a<<' ';pr(b,c);}
template<Z A,Z B,Z C,Z D>void pr(A a,B b,C c,D d){cout<<a<<' ';pr(b,c,d);}
template<Z A>void PR(A a,ll n){rep(i,n){if(i)cout<<' ';cout<<a[i];}ln;}
ll check(ll n,ll m,ll x,ll y){return x>=0&&x<n&&y>=0&&y<m;}
const ll MAX=1e9+7,MAXL=1LL<<61,dx[4]={-1,0,1,0},dy[4]={0,1,0,-1};
typedef pair<int,int> P;

void Main() {
  ll n;
  R n;
  ll dp[n+1];
  fill(dp,dp+n+1,MAX);
  dp[0]=0;
  rep(i,n) {
    if(i+1<=n) dp[i+1]=min(dp[i+1],dp[i]+1);
    ll x=6;
    rep(j,50) {
      if(i+x<=n) dp[i+x]=min(dp[i+x],dp[i]+1);
      else break;
      x*=6;
    }
    x=9;
    rep(j,50) {
      if(i+x<=n) dp[i+x]=min(dp[i+x],dp[i]+1);
      else break;
      x*=9;
    }
  }
  pr(dp[n]);
}

int main(){ios::sync_with_stdio(0);cin.tie(0);Main();return 0;}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define REP(i, n) for (long long i = 0, max_i = (n); i < max_i; i++)
#define REPI(i, a, b) for (long long i = (a), max_i = (b); i < max_i; i++)
#define ALL(obj) begin(obj), end(obj)
#define RALL(obj) rbegin(obj), rend(obj)
#define fi first
#define se second
using ii = pair<int, int>;
vector<ii> dirs = {
  {1, 0}, {0, 1}, {-1, 0}, {0, -1},  // 4方向
  {1, 1}, {-1, 1}, {-1, -1}, {1, -1},  // 斜め
  {0, 0},  // 自身
};
template <class T> inline bool chmax(T& a, const T& b) { if (a < b) { a = b; return true; } return false; }
template <class T> inline bool chmin(T& a, const T& b) { if (a > b) { a = b; return true; } return false; }
template <class T, class S> vector<T> make_vec(size_t n, S x) { return vector<T>(n, x); }
template <class T, class... Ts> auto make_vec(size_t n, Ts... ts) { return vector<decltype(make_vec<T>(ts...))>(n, make_vec<T>(ts...)); }

// debug
template <class T> ostream& operator<<(ostream& s, vector<T>& d) { REP (i, d.size()) s << d[i] << (i == d.size() - 1 ? "" : " "); return s; }
template <class T> ostream& operator<<(ostream& s, vector<vector<T>>& d) { REP (i, d.size()) s << d[i] << (i == d.size() - 1 ? "" : "\n"); return s; }
template <class T, class S> ostream& operator<<(ostream& s, pair<T, S>& p) { s << "{" << p.first << ", " << p.second << "}"; return s; }
template <class T, class S> ostream& operator<<(ostream& s, map<T, S> m) { for (auto it = m.begin(); it != m.end(); it++) { s << *it << (next(it) == m.end() ? "" : "\n"); } return s; }
#ifdef _MY_DEBUG
  #define dump(...) cerr << "/* " << #__VA_ARGS__ << " :[" << __LINE__ << ":" << __FUNCTION__ << "]" << endl, dump_func(__VA_ARGS__), cerr << "*/\n\n";
#else
  #define dump(...)
  #define endl "\n"
#endif
void dump_func() { cerr << endl; }
template <class Head, class... Tail> void dump_func(Head&& h, Tail&&... t) { cerr << h << (sizeof...(Tail) == 0 ? "" : ", "), dump_func(forward<Tail>(t)...); }

struct Fast { Fast() { cin.tie(0); ios::sync_with_stdio(false); } } fast;
mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());
constexpr int MOD = 1000000007;
// *************** TEMPLATE END *************** 

bool month(int x) {
  return 1 <= x && x <= 12;
}
signed main() {
  string s; cin >> s;
  int a = stoi(s.substr(0, 2));
  int b = stoi(s.substr(2, 2));
  if (month(a) && month(b)) {
    cout << "AMBIGUOUS" << endl;
  } else if (month(a)) {
    cout << "MMYY" << endl;
  } else if (month(b)) {
    cout << "YYMM" << endl;
  } else {
    cout << "NA" << endl;
  }
}


Measured memory_bytes: 256
import sys
input = sys.stdin.readline

from collections import Counter

N = int(input())
A = list(map(int, input().split()))

C = Counter(A)
if len(C) == 1:
    X = A[0]
    if N >= 2*X or N == X + 1:
        ans = "Yes"
    else:
        ans = "No"
elif len(C) == 2:
    Xs = sorted(C.keys())
    if Xs[0] + 1 != Xs[1]:
        ans = "No"
    else:
        X = Xs[0]
        if C[X] <= X and C[X+1] >= 2*(X-C[X]+1):
            ans = "Yes"
        else:
            ans = "No"
else:
    ans = "No"

print(ans)

Measured memory_bytes: 18584
#include <bits/stdc++.h>
#define mp make_pair
#define pb push_back
#define sz(x) (int)x.size()
#define all(x) begin(x), end(x)
#define debug(x) cerr << #x << " " << x << '\n'
using namespace std;
using ll = long long;
using pii = pair<int,int>;
using pli = pair<ll,int>;
const int INF = 0x3f3f3f3f, N = 2e5 + 5;
const ll LINF = 1e18 + 5;
int n, a[N];
int main()
{
 	ios::sync_with_stdio(false);
 	cin.tie(0);
 	cin >> n;
 	for(int i=1; i<=n; i++) cin >> a[i];
 	int cur = 1, cnt = 0;
 	for(int i=1; i<=n; i++)
 	{
 		if(a[i]==cur) cur++;
 		else cnt++;
 	}
 	if(cnt==n) cnt = -1;
 	cout << cnt;
	return 0;
}


Measured memory_bytes: 1152
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
//#pragma GCC optimize ("-O3")
using namespace std;

int main() {
  
  int a,b,c,d;
  string s,ss,sss;
  
  int ans = 0;
  string anss = "";
  
  int ab [] = {0 , 1 , 3 , 1 , 2 , 1 , 2 , 1 , 1 , 2 , 1 , 2 , 1};
  
  cin >> a >> b >> c;

  int result3 = std::max({a, b, c});
  
  if (b - c >= 0) anss = "delicious";
  else if (a+b-c >= 0) anss = "safe";
  else anss = "dangerous";
  
  cout << a+b+c-result3 << endl;

}

Measured memory_bytes: 256