akhauriyash/Code-Regression huggingface dataset:
import sys
input = sys.stdin.readline
N, K, Q = map(int, input().split())
a = list(map(int, input().split()))
tt = a[: ]
inf = 10 ** 10
res = inf + 0
for mn in sorted(set(a)):
  t = [[]]
  for i in range(N):
    if tt[i] == inf:
      if t[-1] != []: t.append([])
    else: t[-1].append(a[i])
  ttt = []
  for i in range(len(t)):
    t[i].sort()
    for j in range(len(t[i]) - K + 1):
      ttt.append(t[i][j])
  if len(ttt) < Q: break
  ttt.sort()
  res = min(res, ttt[Q - 1] - ttt[0])
  for i in range(N):
    if a[i] == mn: tt[i] = inf
print(res)

Measured memory_bytes: 48476
#include<iostream>
#define N 32768
long a[N],b[N],n,k,i=N,j;main(){for(std::cin>>n>>k;--i;b[i]=i<n?i:n)a[i]=n/i;while(--k){for(std::swap(a,b);++i<N;)b[i]+=b[i-1];for(j=b[n/--i];--i;a[i]=j%=0x3B9ACA07)j+=a[i]*=n/i-n/(i+1);}std::cout<<j;}

Measured memory_bytes: 768
#include <algorithm>
#include <iostream>
#include <vector>

using namespace std;

typedef long long ll;

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

int main(void) {
    int P, Q, R;
    cin >> P >> Q >> R;

    int x = P + Q;
    int y = Q + R;
    int z = R + P;

    cout << min(min(x, y), z) << endl;
    
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
typedef long long ll;
typedef pair<int, int> P;

ll a[100000] = {};

int main(){
    ll n, i, tem = 0, out;
    cin >> n;
    for(i=0; i<n; i++){
        cin >> a[i];
        if(i != n-1){
            if(i%2 == 0){
                tem += a[i];
            }else{
                tem -= a[i];
            }
        }
    }
    out = tem + a[n-1];
    cout << out << ' ';
    for(i=0; i<n-1; i++){
        out = 2*(a[i] - out/2);
        cout << out << ' ';
    }
    return 0;
}

Measured memory_bytes: 2048
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		String S = sc.next();

		List <String> kekka = new ArrayList<String>();
		String [] alphabet = {"A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z"};

		for(int i=0; i < S.length();i++) {

			String Sone = String.valueOf(S.charAt(i));

			for(int j=0; j < 26;j++) {
				String alphabetOne = alphabet[j];
				if(Sone.equals(alphabetOne)) {

					if((j+N)<26) {
						kekka.add(alphabet[j+N]);
					}else {
						int N2 = N - 26;
						kekka.add(alphabet[j+N2]);
					}

				}
			}
		}

		for(String a:kekka) {
			System.out.print(a);
		}


	}

}


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

using namespace std;

typedef long long LL;

const int N = 1010;

int n, m, c;
int b[N];

int main()
{
    cin >> n >> m >> c;
    for(int i = 0; i < m; i++) cin >> b[i];

    int res = 0;
    for(int i = 0; i < n; i++)
    {
        int sum = 0;
        for(int j = 0; j < m; j++)
        {
            int x;
            cin >> x;
            sum += x * b[j];
        }
        if(sum + c > 0) res++;
    }

    cout << res << endl;

    return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
#include <stack>
#include <queue>
#include <deque>
#include <vector>
#include <string>
#include <string.h>
#include <cstdlib>
#include <ctime>
#include <cmath>
#include <map>
#include <set>
#include <iostream>
#include <sstream>
#include <numeric>
#include <cctype>
#include <bitset>
#include <cassert>
#include <random>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define gep(i,g,j) for(int i = g.head[j]; i != -1; i = g.e[i].next)
#define each(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();it++)
#define rng(a) a.begin(),a.end()
#define maxs(x,y) x = max(x,y)
#define mins(x,y) x = min(x,y)
#define pb push_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcount
#define uni(x) x.erase(unique(rng(x)),x.end())
#define snuke srand((unsigned)clock()+(unsigned)time(NULL));
#define df(x) int x = in()
#define dame { puts("-1"); return 0;}
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,vector<T>,greater<T> >
#define bn(x) ((1<<x)-1)
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
inline int in() { int x; scanf("%d",&x); return x;}
inline void priv(vi a) { rep(i,sz(a)) printf("%d%c",a[i],i==sz(a)-1?'\n':' ');}
template<typename T>istream& operator>>(istream&i,vector<T>&v)
{rep(j,sz(v))i>>v[j];return i;}
template<typename T>string join(vector<T>&v)
{stringstream s;rep(i,sz(v))s<<' '<<v[i];return s.str().substr(1);}
template<typename T>ostream& operator<<(ostream&o,vector<T>&v)
{if(sz(v))o<<join(v);return o;}
template<typename T1,typename T2>istream& operator>>(istream&i,pair<T1,T2>&v)
{return i>>v.fi>>v.se;}
template<typename T1,typename T2>ostream& operator<<(ostream&o,pair<T1,T2>&v)
{return o<<v.fi<<","<<v.se;}
const int MX = 100005, INF = 1001001001;
const ll LINF = 1e18;
const double eps = 1e-10;

int n,m;
ll f(vi a) {
  rep(i,n) a[i] = max(0,a[i]);
  ll res = LINF, now = 0;
  rep(i,m) now += a[i];
  res = now;
  for (int i = m; i < n; ++i) {
    now += a[i];
    now -= a[i-m];
    mins(res,now);
  }
  return res;
} 

int main() {
  scanf("%d%d",&n,&m);
  vi a(n);
  cin >> a;
  ll ans = -LINF, sum = 0;
  rep(i,n) sum += max(0,a[i]);
  ans = f(a);
  rep(i,n) a[i] = -a[i];
  mins(ans, f(a));
  ans = sum-ans;
  cout<<ans<<endl;
  return 0;
}































Measured memory_bytes: 1028
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int n, m, q; cin >> n >> m >> q;
  vector<int> s(q); vector<int> t(q); vector<int> u(q); vector<int> v(q);
  for(int i=0; i<q; i++) cin >> s[i] >> t[i] >> u[i] >> v[i];
  
  int score = 0, answer = 0;
  vector<int> A(10);
  
  for(int j=1; j<=m; j++){
    for(int i=1; i<=j; i++){
      for(int h=1; h<=i; h++){
        for(int g=1; g<=h; g++){
          for(int f=1; f<=g; f++){
            for(int e=1; e<=f; e++){
              for(int d=1; d<=e; d++){
                for(int c=1; c<=d; c++){
                  for(int b=1; b<=c; b++){
                    for(int a=1; a<=b; a++){
                      A[0] = a; A[1] = b; A[2] = c; A[3] = d; A[4] = e;
                      A[5] = f; A[6] = g; A[7] = h; A[8] = i; A[9] = j;
                      for(int k=0; k<q; k++){
                        if(A[t[k]-1] - A[s[k]-1] == u[k]) score += v[k];
                      }
                      answer = max(answer, score);
                      score = 0;
                    }
                  }
                }
              }
            }
          }
        }
      }
    }
  }
  
    
  cout << answer << endl;
}

Measured memory_bytes: 3608
#include<iostream>
#include<cstdio>
#include<vector>
#include<string>
#include<functional>
#include<queue>
#include<map>
#include<limits>
#include<cmath>
#include<algorithm>
#include<bitset>
#include<utility>
#include<complex>
#include<cstdlib>
#include<set>
#include<cctype>

#define DBG cerr << '!' << endl;
#define REP(i,n) for(int (i) = (0);(i) < (n);++i)
#define rep(i,s,g) for(int (i) = (s);(i) < (g);++i)
#define rrep(i,s,g) for(int (i) = (s);i >= (g);--(i))
#define PB push_back
#define MP make_pair
#define FI first
#define SE second
#define SHOW1d(v,n) {for(int i = 0;i < (n);i++)cerr << v[i] << ' ';cerr << endl << endl;}
#define SHOW2d(v,i,j) {for(int a = 0;a < i;a++){for(int b = 0;b < j;b++)cerr << v[a][b] << ' ';cerr << endl;}cerr << endl;}
#define ALL(v) v.begin(),v.end()

using namespace std;

typedef long long ll;
typedef vector<int> iv;
typedef vector<iv> iiv;
typedef vector<string> sv;

int main()
{
		double r,g;
	cin >> r >> g;
	
	cout << g*2 - r << endl;

	
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <algorithm>
using namespace std;
int main()
{long int n,l,s;
int i,j,a[1000];
while(~scanf("%d%d",&n,&l))
  {s=0;
  for(i=1;i<=n;i++)
  a[i]=l+i-1;
  sort(a+1,a+n+1);
  if(a[1]>=0)
  {
  for(i=2;i<=n;i++)
  s+=a[i];
  printf("%ld\n",s);}
  else if(a[1]<0&&a[n]<=0)
      {for(i=1;i<n;i++)
      s+=a[i];
      printf("%ld\n",s);
      }
      else 
      {for(i=1;i<=n;i++)
      s+=a[i];
      printf("%ld\n",s);
      }
  }
}  

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

int main() {
  int n;
  cin >> n;
  for (int ans = 0; ans < 50000; ans++) {
    if ((int)((double)(ans*1.08)) == n) {
      cout << ans << endl;
      return 0;
    }
  }
  cout << ":(" << endl;
}

Measured memory_bytes: 256
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author silviase
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        ERoaming solver = new ERoaming();
        solver.solve(1, in, out);
        out.close();
    }

    static class ERoaming {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int n = in.nextInt();
            int k = in.nextInt();
            ModInt mi = new ModInt(0);
            ModComb mc = new ModComb(2 * n);
            for (int i = 0; i <= Math.min(n - 1, k); i++) {
                mi = mi.add(mc.combFac(n, i).mul(mc.combFac(n - 1, i)));
            }
            out.println(mi.getVal());
        }

    }

    static class ModInt {
        long val;
        int MOD = (int) 1e9 + 7;

        public ModInt(long i) {
            this.val = (int) ((i + MOD) % MOD);
        }

        public ModInt mul(long l) {
            return new ModInt(this.val * l);
        }

        public ModInt add(ModInt m) {
            return new ModInt(this.val + m.getVal());
        }

        public ModInt mul(ModInt m) {
            return new ModInt(this.val * m.getVal());
        }

        public ModInt inv() {
            return this.pow(MOD - 2);
        }

        public ModInt pow(long l) {
            ModInt res = new ModInt(1);
            ModInt v = new ModInt(this.val);
            while (l > 0) {
                if (l % 2 != 0) {
                    res = res.mul(v.val);
                }
                v = v.mul(v.val);
                l /= 2;
            }
            return res;
        }

        public long getVal() {
            return val;
        }

    }

    static class ModComb {
        private int size;
        private ModInt[] fac;
        private ModInt[] inv;

        public ModComb(int n) {
            size = n;
            fac = new ModInt[n + 1];
            inv = new ModInt[n + 1];
            makeFac();
        }

        private void makeFac() {
            for (int i = 0; i <= size; i++) {
                if (i == 0) {
                    fac[i] = new ModInt(1);
                } else {
                    fac[i] = fac[i - 1].mul(i);
                }
                inv[i] = fac[i].inv();
            }
        }

        public ModInt combFac(int n, int k) {
            if (n < k) {
                return new ModInt(0);
            }
            return fac[n].mul(inv[k].getVal()).mul(inv[n - k].getVal());
        }

    }
}



Measured memory_bytes: 185172
import java.util.Scanner;

class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int h = sc.nextInt();
        int w = sc.nextInt();
        int a = sc.nextInt();
        int b = sc.nextInt();
        StringBuilder sb = new StringBuilder();
        for (int i = 0; i < b; i++) {
            for (int j = 0; j < a; j++) {
                sb.append(1);
            }
            System.out.print(sb.toString());
            sb.setLength(0);
            for (int j = a; j < w; j++) {
                sb.append(0);
            }
            System.out.println(sb.toString());
            sb.setLength(0);
        }
        sb.setLength(0);
        for (int i = b; i < h; i++) {
            for (int j = 0; j < a; j++) {
                sb.append(0);
            }
            System.out.print(sb.toString());
            sb.setLength(0);
            for (int j = a; j < w; j++) {
                sb.append(1);
            }
            System.out.println(sb.toString());
            sb.setLength(0);
        }

        sc.close();
    }
}


Measured memory_bytes: 26196
import java.util.Scanner;
class Main {
  public static void main(String args[]) {
Scanner sc=new Scanner(System.in);
int n=sc.nextInt();
int m=sc.nextInt();
int l=sc.nextInt();
int [][]a=new int [n][m];
int [][]b=new int [m][l];
long [][]c=new long [n][l];
for(int i=0;i<n;i++) {
	for(int o=0;o<m;o++) {
		int s=sc.nextInt();
		a[i][o]=s;
	}
}
for(int p=0;p<m;p++) {
	for(int u=0;u<l;u++) {
		int d=sc.nextInt();
		b[p][u]=d;
	}
}
for(int q=0;q<n;q++) {
	for(int w=0;w<l;w++) {
		for(int e=0;e<m;e++) {
			c[q][w]+=a[q][e]*b[e][w];
		}
		if(w>0) {
			System.out.print(" ");
		}
		System.out.print(c[q][w]);
	}
	System.out.println();
}
sc.close();
  }
}



Measured memory_bytes: 55556
#include <bits/stdc++.h>
using namespace std;
int n;
void solve()
{
    int i,j,ans=0;
    for (i=1;i<=n;i++)
    {
        if (i%2)
        {
            for (j=i+1;j<=n;j++)
                if (j%2==0) ans++;
        }
        else
        {
            for (j=i+1;j<=n;j++)
                if (j%2) ans++;
        }
    }
    cout<<ans<<endl;
}
int main()
{
    while(cin>>n)
        solve();
}

Measured memory_bytes: 256
from collections import defaultdict
from itertools import accumulate


def main():
    n = int(input())
    prime_counter = defaultdict(int)
    acc = tuple(accumulate(range(1, 42)))  # 10^12 < 2^39

    f = 2
    while n % f == 0:
        n //= f
        prime_counter[f] += 1
    f = 3
    while f * f <= n:
        if n % f == 0:
            n //= f
            prime_counter[f] += 1
        else:
            f += 2
    if n != 1:
        prime_counter[n] += 1

    ans = 0
    for c in prime_counter.values():
        for i, x in enumerate(acc):
            if c < x:
                tmp = i
                break
        ans += tmp
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 9484
#include<bits/stdc++.h>
#define INF 1e9
#define llINF 1e18
#define MOD 1000000007
#define pb push_back
#define mp make_pair 
#define F first
#define S second
#define ll long long
#define vi vector<ll>
#define vvi vector<vi>
#define BITLE(n) (1LL<<((ll)n))
#define SHIFT_LEFT(n) (1LL<<((ll)n))
#define SUBS(s,f,t) ((s).substr((f)-1,(t)-(f)+1))
#define ALL(a) (a).begin(),(a).end()
using namespace std;

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll n;cin>>n;
  vi A(n);
  vector<pair<ll,ll>>pll(n);
  for(int i = 0;i < n;i++){
    cin>>A[i];
    pll[i] = mp(abs(A[i]),i);
  }
  sort(ALL(pll));
  ll hoge = pll[0].S;
  for(int i = 0;i < hoge;i++){
    if(A[i] < 0){A[i]*=-1;A[i+1]*=-1;}
  }
  for(int i = n-1;i > hoge;i--){
    if(A[i] < 0){
      A[i] *= -1;
      A[i-1] *= -1;
    }
  }
  ll ans = 0;
  for(auto a:A)ans += a;
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 2560
#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; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; }
//---------------------------------------------------------------------------------------------------
/*---------------------------------------------------------------------------------------------------
　　　　　　　　　　　 ∧＿∧  
　　　　　 ∧＿∧ 　（´<_｀ ）　 Welcome to My Coding Space!
　　　　 （ ´_ゝ`）　/　 ⌒i     
　　　　／　　　＼　 　  |　|     
　　　 /　　 /￣￣￣￣/　　|  
　 ＿_(__ﾆつ/　    ＿/ .| .|＿＿＿＿  
　 　　　＼/＿＿＿＿/　（u　⊃  
---------------------------------------------------------------------------------------------------*/











int N, W[1010], S[1010], V[1010];
ll dp[1010][30101];
//---------------------------------------------------------------------------------------------------
void _main() {
    cin >> N;
    rep(i, 0, N) cin >> W[i] >> S[i] >> V[i];

    vector<int> ord;
    rep(i, 0, N) ord.push_back(i);
    sort(all(ord), [&](int a, int b) {
        // x <= S[b] - W[a]
        // x <= S[a] - W[b]
        return S[b] - W[a] > S[a] - W[b];
    });


    rep(i, 0, N) rep(tot, 0, 20101) {
        int a = ord[i];
        chmax(dp[i + 1][tot], dp[i][tot]);
        if(tot <= S[a]) chmax(dp[i + 1][tot + W[a]], dp[i][tot] + V[a]);
    }

    ll ans = 0;
    rep(tot, 0, 20101) chmax(ans, dp[N][tot]);
    cout << ans << endl;
}


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

using namespace std;

#define IOS                       \
    ios_base::sync_with_stdio(0); \
    cin.tie(NULL);                \
    cout.tie(NULL);
#define pb push_back
#define mp make_pair
#define Debug(x) cout << #x " = " << (x) << endl
#define SORT(a) sort(a.begin(), a.end())
#define SORTR(a) sort(a.rbegin(), a.rend())

int main()
{
    IOS;

    int n, y = 0;
    cin >> n;

    vector<int> a;
    for (int i = 0; i < n; i++)
    {
        int x;
        cin >> x;

        a.pb(x);

        y ^= x;
    }

    int z;
    for (int i = 0; i < n; i++)
    {
        z = y ^ a[i];
        cout << z << " ";
    }

    return 0;
}


Measured memory_bytes: 4248
#include <stdio.h>
 int main() {
 int k, a, b;
 scanf("%d", &k);
 scanf("%d%d", &a, &b);
 int largest = (b / k) * k;
 if (a <= largest) {
 puts("OK");
 } else {
 puts("NG");
}
 return 0;
  }

Measured memory_bytes: 1664
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
#define ALL(A) A.begin(), A.end()

using namespace std;

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

int N, K;
int cum_sum[2001][2001];

int add(int x, int y, int d){
	x += 1;
	y += 1;
	cum_sum[y][x] += d;
}

void build(void){
	for (int i = 1; i <= 2*K; ++i){
		for (int j = 1; j <= 2*K; ++j){
			cum_sum[i][j] += cum_sum[i][j-1] + cum_sum[i-1][j] - cum_sum[i-1][j-1];
		} // end for
	} // end for
}

int count(int left, int right, int top, int bottom){
	int res = 0;
	res += cum_sum[bottom][right];
	res -= cum_sum[bottom][left];
	res -= cum_sum[top][right];
	res += cum_sum[top][left];
	return res;
}

int main()
{
	memset(cum_sum, 0, sizeof(cum_sum));
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cin >> N >> K;
	for (int i = 0; i < N; ++i){
		int x, y; char c;
		cin >> x >> y >> c;
		if (c == 'W'){
			add(x % (2*K), (y + K) % (2*K), 1);
		}else{
			add(x % (2*K), y % (2*K), 1);
		} // end if
	} // end for

	build();
	int res = 0;
	for (int y = 0; y < K; ++y){
		for (int x = 0; x < K; ++x){
			int curr = 0;
			curr += count(0, x, 0, y);
			curr += count(0, x, y + K, 2*K);
			curr += count(x, x + K, y, y + K);
			curr += count(x + K, 2*K, 0, y);
			curr += count(x + K, 2*K, y + K, 2*K);
			res = max(res, curr);
			res = max(res, N - curr);
		} // end for
	} // end for
	
	cout << res << endl;

	return 0;
}

Measured memory_bytes: 15872
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <string>
#include <map>
#include <math.h>
#include <set>
using namespace std;

int main(){
    int n;
    cin >> n;
    map<int, int> mp;
    for (int i = 0; i < n; i++) {
        int a;
        cin >> a;
        mp[a]++;
    }
    int ans = 0;
    for (auto p: mp) {
        int x = p.first;
        int n = p.second;
        if(n >= x)ans += n-x;
        else ans += n;
    }
    cout << ans << endl;
    return 0;
}

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

int main(){
 string p,s;
 cin>>p>>s;
 p=p+p;
 bool flag=false;
 for(int i=0;i<(int)p.size()-(int)s.size()+1;i++){
 string t=p.substr(i,s.size());
 if(t==s){
 flag=true;
 break;
}
}
 if(flag){
 cout<<"Yes"<<endl;
 }else{
 cout<<"No"<<endl;
}
}


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

#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define intll int long long
const int INF = 1e9;
const int MOD = 1e9 + 7;

int main() {
  int a , b , c ;
  cin >> a >> b >> c ;
  string ans = "No";
  if((a ==b) ||(b == c) || (c== a)){
    ans =  "Yes" ;
  }
  else
    ans =  "No" ;
  if( (a == b) && (a == c) )
    ans = "No" ;
  
  cout << ans ;


}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
using namespace std;
int memo[17][17];
int road(int f,int d);
int x,y;
int w,h;
int n;
int c=0;

int main(){
  while(1){
    for(int i=0;i<17;i++){
      for(int j=0;j<17;j++){
	memo[i][j]=-1;
      }
    }
    cin >> w >> h;
    if(w==0&&h==0)break;
    cin >> n;
    for(int i=0;i<n;i++){
      cin >> x >> y;
      memo[y][x]=0;
    }
    cout << road(h,w) << endl;
  }

  return 0;
}

int road(int i,int j){
  if(i>h||j>w||i<=0||j<=0)return memo[i][j]=0;
  if(i==1&&j==1)return memo[i][j]=1;
  if(memo[i][j]!=-1)return memo[i][j];
  return memo[i][j]=(road(i-1,j)+road(i,j-1));
}

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

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

    char s[52] = {};
    int a=0;
    for(int i=0; i<2; i++){
        for(char c='A'; c <= 'Z'; c++){
            s[a] = c;
            a++;
        }
    }

    for(int i=0; i<S.size(); i++){
        for(int j=0; j<26; j++){
            if(S[i] == s[j]){
                //S.replace(i, 1, s[j+N]);
                S[i] = s[j+N];
                break;
            }
        }
    }

    cout << S << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

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

        int N = sc.nextInt();
        int H = sc.nextInt();
        int W = sc.nextInt();

        int vh = N - H + 1;
        int vw = N - W + 1;

        System.out.println(vh * vw);
    }
}


Measured memory_bytes: 22740
import copy
n = int(input())
s = input()
total = 0
rgb = {'R', 'G', 'B'}
rgb_count = {key:s.count(key) for key in rgb}

for i in range(n):
    a = s[i]
    rgb_count[a] -= 1
    rgb_copy = copy.copy(rgb_count)
    for j in range(i+1, n):
        rgb_copy[s[j]] -= 1
        if s[j] != a:
            b = s[j]
            remain = rgb - {a, b}
            c = [i for i in remain][0]
            total += rgb_copy[c]
            if 2*j-i < n and s[2*j-i] == c:
                total -= 1

print(total)


Measured memory_bytes: 70868
# coding: utf-8
# Your code here!
# coding: utf-8
from fractions import gcd 
from functools import reduce
import sys
sys.setrecursionlimit(200000000)
from inspect import currentframe


# my functions here!
#標準エラー出力
def printargs2err(*args):
    names = {id(v):k for k,v in currentframe().f_back.f_locals.items()}
    print(', '.join(names.get(id(arg),'???')+' : '+repr(arg) for arg in args),file=sys.stderr)
def debug(x):
    print(x,file=sys.stderr)
def printglobals():
    for (symbol, value) in globals().items():
        print('symbol="%s"、value=%s' % (symbol, value),file=sys.stderr)
def printlocals():
    for (symbol, value) in locals().items():
        print('symbol="%s"、value=%s' % (symbol, value),file=sys.stderr)
#入力（後でいじる）
def pin(type=int):
    return map(type,input().split())

#繰り返し自乗法だよ
#これはnのp乗をmで割ったあまりをだすよ
def modular_w_binary_method (n,m,p):
    ans=1 if n>0 else 0
    while(p>0):
        if p%2==1:
            ans=(ans*n)%m
        n=(n**2)%m
        p//=2
    return ans
#mod上でのaの逆元を出すよ
"""
    フェルマーの小定理より a**(p)%p==a isTrue
    これを利用すれば a**(p-2)%p==a**(-1) isTrue
    元と逆元とをかけてpで割れば1が余るよ！
"""
def modular_inverse(a,prime):
    return(modular_w_binary_method(a,prime,prime-2))
#逆元を使うと容易に頑張れるｃ
def conbination(n,a,mod=10**9+7):
    #cはイラない
    res=1 
    for s in range(a):
        res=(res*(n-s)*(modular_inverse(s+1,mod)))%mod

        
    return res
#操作から作れるものの組み合わせは何個かー＞同じものでも違う方法で構成できるかから考える方法もある
"""
"""

#solution:

#input
N,A,B=pin()
X=list(pin())
t=(B+1)//A
ans=0
for i in range(1,N):
    f=X[i]-X[i-1]
    ans+=min(A*f,B)
print(ans)
#print(["No","Yes"][cond])
#print([["NA","YYMM"],["MMYY","AMBIGUOUS"]][cMMYY][cYYMM])
"""
#printデバッグ消した？
#前の問題の結果見てないのに次の問題に行くの？
"""
"""
お前カッコ閉じるの忘れてるだろ
"""

Measured memory_bytes: 93800
# C - Count Order
N = int(input())
P = list(map(int,input().split()))
Q = list(map(int,input().split()))
L = []

def rec(l,s):
    if len(l)==N:
        L.append(l)
    else:
        for x in s:
            tmp_l = l[:]
            tmp_l.append(x)
            tmp_s = s[:]
            tmp_s.remove(x)
            rec(tmp_l,tmp_s)

rec(list(),[i+1 for i in range(N)])

a = 0
while P!=L[a]:
    a += 1
b = 0
while Q!=L[b]:
    b += 1
print(abs(a-b))

Measured memory_bytes: 77512
from itertools import product


def solve(n, a_list, b_list):

    res = 10 ** 9 + 7

    for p in product([0, 1], repeat=n):
        if sum(p) % 2 == 1:
            continue

        r = 0

        c_list = [a for a in a_list]
        for i in range(n):
            if p[i] == 1:
                c_list[i] = b_list[i]
        c_list_s = list(sorted(c_list))

        used = [0] * n
        d_list = [0] * n
        for k in range(n):
            j = -1
            for i in range(n):
                if c_list[i] == c_list_s[k] and not used[i] and (i - k + p[i]) % 2 == 0:
                    used[i] = 1
                    j = i
                    break
            if j >= 0:
                d_list[j] = k
            else:
                r += 10 ** 9 + 7

        # r
        for i in range(n - 1):
            for j in range(i + 1, n):
                if d_list[i] > d_list[j]:
                    r += 1

        res = min(res, r)
    # print(res)
    if res < 10 ** 9 + 7:
        return res
    else:
        return -1


def main():
    n = int(input())
    a_list = list(map(int, input().split()))
    b_list = list(map(int, input().split()))
    res = solve(n, a_list, b_list)
    print(res)


def test():
    assert solve(3, [3, 4, 3], [3, 2, 3]) == 1
    assert solve(2, [2, 1], [1, 2]) == -1
    assert solve(4, [1, 2, 3, 4], [5, 6, 7, 8]) == 0


if __name__ == "__main__":
    test()
    main()


Measured memory_bytes: 49628
n,m,k=map(int,input().split())
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 = 3*10**5
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 )

xans,yans=0,0
for i in range(1,n):
  xans+=i*cmb(n*m-2,k-2,mod)*(n-i)*m**2%mod
for i in range(1,m):
  yans+=i*cmb(n*m-2,k-2,mod)*(m-i)*n**2%mod
print((xans+yans)%mod)

Measured memory_bytes: 38928
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <functional>
#include <algorithm>

using namespace std;

#define rep(i,j) REP((i), 0, (j))
#define REP(i,j,k) for(int i=(j);(i)<(k);++i)
#define BW(a,x,b) ((a)<=(x)&&(x)<=(b))
#define ALL(v) (v).begin(), (v).end()
#define LENGTHOF(x) (sizeof(x) / sizeof(*(x)))
#define AFILL(a, b) fill((int*)a, (int*)(a + LENGTHOF(a)), b)
#define SQ(x) ((x)*(x))
#define Mod(x, mod) (((x)+(mod)%(mod))
#define MP make_pair
#define PB push_back
#define Fi first
#define Se second
#define INF (1<<29)
#define EPS 1e-10
#define MOD 1000000007

typedef pair<int, int> P;
typedef vector<int> vi;
typedef queue<int> qi;
typedef long long ll;

P ma[256];
int dp[256];

int main(){
  int n;
  while(scanf("%d", &n) && n){
    rep(i,n) scanf("%d%d", &ma[i].first, &ma[i].second);
    int m;
    scanf("%d", &m);
    rep(i,m) scanf("%d%d", &ma[n+i].first, &ma[n+i].second);
    int V = n+m;
    sort(ma, ma+V);

    int res = 0;
    for(int i =0;i<V;i++){
      dp[i] = 1;
      for(int j=0;j<i;j++) if(ma[j].first < ma[i].first && ma[j].second < ma[i].second)
	  dp[i] = max(dp[i], dp[j]+1);
      res = max(res, dp[i]);
    }
    printf("%d\n", res);
  }
  return 0;
}

Measured memory_bytes: 1188
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const ll MOD = 1e9+7;
const ll INF = 1e18;
#define rep(i,m,n) for(ll i = (m); i <= (n); i++)
#define zep(i,m,n) for(ll i = (m); i < (n); i++)
#define rrep(i,m,n) for(ll i = (m); i >= (n); i--)
#define print(x) cout << (x) << endl;
#define printa(x,m,n) for(ll i = (m); i <= n; i++){cout << (x[i]) << " ";} cout<<endl;

int main(){
    cin.tie(0); ios::sync_with_stdio(false);
    
    ll x; cin >> x;
    
    ll ans = 1;
    for(ll i = 2; i*i <= x; i++){
        ll buf = i*i;
        while(buf*i <= x){
            buf *= i;
        }
        ans = max(ans, buf);
    }
    print(ans)
    return 0;
}

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


int main() {
  int N,X,Y;
  cin >> N >> X >> Y;
  vector< vector<int> > G(N);
  X--; Y--;
  REP(i,N) {
    if (i != 0 ) G[i].push_back(i-1);
    if (i != N-1 ) G[i].push_back(i+1);
  }
  G[X].push_back(Y);
//  REP(i,N) {cout << i << " : ";
//    for ( auto a : G[i] ) cout << a << " ";
//    cout << endl;
//  }
  
  vector<int> d(N,0);
  
  REP(i,N) {
    queue<int> q;
    vector<int> D(N,-1);
    q.push(i);
    D[i] = 0;
    while( !q.empty() ) {
      int v = q.front();
      q.pop();
      for( auto nv : G[v] ) {
        if (D[nv] != -1) continue;
        D[nv] = D[v] + 1;
        if ( nv > i ) d[D[nv]] += 1;
        q.push(nv);
      }
    }
  }
  for( int i=1;i<N;i++) {
    cout << d[i] << endl;
  }
}

  


Measured memory_bytes: 384
#include <limits.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#include <algorithm>
#include <cassert>
#include <cfloat>
#include <complex>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>

using namespace std;

#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define repLRE(i, l, r) for (ll i = (l); i <= (r); ++i)
#define Sort(v) sort(v.begin(), v.end())
#define Reverse(v) reverse(v.begin(), v.end())
#define Lower_bound(v, x) \
  distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) \
  distance(v.begin(), upper_bound(v.begin(), v.end(), x))

using ll = long long;
using ull = unsigned long long;
using P = pair<ll, ll>;
using T = tuple<ll, ll, ll>;
using vll = vector<ll>;
using vP = vector<P>;
using vT = vector<T>;
using vvll = vector<vector<ll>>;
using vvP = vector<vector<P>>;
using dqll = deque<ll>;

ll dx[9] = {-1, 1, 0, 0, -1, -1, 1, 1, 0};
ll dy[9] = {0, 0, -1, 1, -1, 1, -1, 1, 0};

/* Macros reg. ends here */

const ll INF = 1LL << 50;

static const long long mod = 1000000007;

int main() {
  ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  cout << fixed << setprecision(15);

  ll n;
  cin >> n;

  ll ans = 0;
  rep(i, n) {
    ll l, r;
    cin >> l >> r;
    ans += r - l + 1;
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
def main():
  num = list(map(int,input().split()))
  if num[0]+num[1]>num[0]-num[1]:
    if num[0]+num[1]>num[0]*num[1]:
      print(num[0]+num[1])
    else:
      print(num[0]*num[1])
  else:
    if num[0]-num[1]>num[0]*num[1]:
      print(num[0]-num[1])
    else:
      print(num[0]*num[1])
main()

Measured memory_bytes: 3064
#include<stdio.h>

void t(int A[],int N)
{
	int i,j,k,v;
	
	for(i=1;i<N;i++)
	{
		v=A[i];
		j=i-1;
		
		while (j>=0&&A[j]>v)
		{
			A[j+1]=A[j];
			j--;
		}
		A[j+1]=v;
		for(k=0;k<N;k++)
		{
			if(k>0)
			{
				printf(" ");
			}
			printf("%d",A[k]);
		}
		printf("\n");
	}
}
int main(void)
{
	int N;
	
	scanf("%d",&N);
	
	int A[N];
	int i;
	int v,j;
	
	for(i=0;i<N;i++)
	{
		scanf("%d",&A[i]);
	}
	
	for(i=0;i<N;i++)
	{
		if(i>0)
		{
			printf(" ");
		}
		printf("%d",A[i]);
	}
	printf("\n");
	
	t(A,N);
}



Measured memory_bytes: 2128
#include<bits/stdc++.h> //ABC 166_d
#define ll long long
using namespace std;
ll x;
int main(){
	cin>>x;
	for(ll i=-120;i<=120;i++){
		for(ll j=-120;j<=120;j++){
			if(i*i*i*i*i-j*j*j*j*j==x){
				cout<<i<<" "<<j;
				return 0;
			}
		}
	}
	return 0;
}

Measured memory_bytes: 3564
#include <bits/stdc++.h>
#define rep(i, a, n) for (int i = a; i < n; i++)
#define repr(i, a, n) for (int i = n - 1; i >= a; i--)
using namespace std;
using ll = long long;
using P = pair<int, int>;
template <typename T> void chmin(T &a, T b) { a = min(a, b); }
template <typename T> void chmax(T &a, T b) { a = max(a, b); }

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

  int H, W, h, w;
  cin >> H >> W >> h >> w;
  int b_row = W * h;
  int b_col = (H - h) * w;
  cout << H * W - (b_row + b_col) << endl;
}


Measured memory_bytes: 256
#include <iostream>

int main()
{
    double d;
    double t;
    double s;
    std::cin >> d >> t >> s;
    if (s >= (d / t))
    {
        std::cout << "Yes" << std::endl;
    }
    else
    {
        std::cout << "No" << std::endl;
    }

    return 0;
}


Measured memory_bytes: 3716
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
using vl = vector<ll>;
using Map = map<ll,vl>;
using Tu = tuple<ll,ll,ll>;
using vvl = vector<vector<ll>>;
const ll INF=1LL<<60;
const ll MOD=1000000007;

class UnionFind {
public:
    vector < ll > par; // 各元の親を表す配列
    vector < ll > siz; // 素集合のサイズを表す配列(1 で初期化)

    // Constructor
    UnionFind(ll sz_): par(sz_), siz(sz_, 1) {
        for (ll i = 0; i < sz_; ++i) par[i] = i; // 初期では親は自分自身
    }
    void init(ll sz_) {
        par.resize(sz_);
        siz.assign(sz_, 1);
        for (ll i = 0; i < sz_; ++i) par[i] = i; // 初期では親は自分自身
    }

    // Member Function
    // Find
    ll root(ll x) { // 根の検索
        while (par[x] != x) {
            x = par[x] = par[par[x]]; // x の親の親を x の親とする
        }
        return x;
    }

    // Union(Unite, Merge)
    bool unite(ll x, ll y) {
        x = root(x);
        y = root(y);
        if (x == y) return false;
        // merge technique（データ構造をマージするテク．小を大にくっつける）
        if (siz[x] < siz[y]) swap(x, y);
        siz[x] += siz[y];
        par[y] = x;
        return true;
    }

    bool same(ll x, ll y) { // 連結判定
        return root(x) == root(y);
    }

    ll size(ll x) { // 素集合のサイズ
        return siz[root(x)];
    }
};


int main(){
    ll N;
    cin >> N;
    ll M;
    cin >> M;
    vector<ll> A(M,0);
    vector<ll> B(M,0);
    for(ll i=0;i<M;i++){
        cin>>A[i]>>B[i];
        A[i]--;B[i]--;
    ;}
    reverse(A.begin(), A.end());
    reverse(B.begin(), B.end());
    UnionFind tree(N);
    vector<ll> ans(M,0);
    ll Ans=N*(N-1)/2;
    multiset<ll> S;
    for(ll i=0;i<N;i++){
        S.insert(1)
    ;}  
    for(ll i=0;i<M;i++){
        ans[M-1-i]=Ans;
        if(!tree.same(A[i],B[i])){
            ll x=tree.size(A[i]);
            ll y=tree.size(B[i]);
            Ans-=x*y;
            tree.unite(A[i],B[i]);
            S.erase(*S.lower_bound(x));
            S.erase(*S.lower_bound(y));
            S.insert(x+y);
        }
        
    ;}
    for(ll i=0;i<M;i++){
        cout<<ans[i]<<endl;
    ;}



    return 0;
}


Measured memory_bytes: 9984
// inputに入力データ全体が入る
function Main(input) {
	// 1行目がinput[0], 2行目がinput[1], …に入る
	input = input.split("\n");
	tmp = input[0].split(" ");
	//文字列から10進数に変換するときはparseIntを使います
	var a = tmp[0];
	var b = tmp[1];
	var c = tmp[2];
	var arr_a =  String(a).split('');
	var arr_b =  String(b).split('');
	var arr_c =  String(c).split('');
	//出力
	if (arr_a[arr_a.length-1]== arr_b[0] && arr_b[arr_b.length-1]==arr_c[0]) {
		console.log('YES');
	}else {
	console.log('NO');
	}
 
	//console.log('%s %s %s',arr_a,arr_b,arr_c);
}
//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

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

#define int long long int

int dfs(int s,vector<int> v[],int vis[])
{
    if(vis[s]) return 0;
    int t=1;
    vis[s]=1;
    for(auto x:v[s]) t+=dfs(x,v,vis);
    return t;
}

signed main()
{
    int n,m;
    cin>>n>>m;
    int x,y,i,j;

    vector<int> v[n];

    for(i=0;i<m;i++)
    {
        cin>>x>>y;
        x--;
        y--;
        v[x].push_back(y);
        v[y].push_back(x);
    }
    int mx=0;
    int vis[n]={0};
    for(i=0;i<n;i++)
    {
        if(vis[i]==0) mx=max(mx,dfs(i,v,vis));
    }
    cout<<mx<<endl;
}


Measured memory_bytes: 25472
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> P;
typedef pair<int,int> Pi;
#define rep(i,n) for(ll i=0;i<n;i++)
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define fi first
#define se second
#define endl "\n"

template<typename T> inline bool chmax(T &a, T b){if(a<b){a=b;return true;}return false;}
template<typename T> inline bool chmin(T &a, T b){if(a>b){a=b;return true;}return false;}
template<typename T> ostream& operator<<(ostream& s,const complex<T>& d) {return s<<"("<<d.real()<<", "<<d.imag()<< ")";}
template<typename T1, typename T2> ostream& operator<<(ostream& s,const pair<T1,T2>& d) {return s<<"("<<d.first<<", "<<d.second<<")";}
template<typename T> ostream& operator<<(ostream& s, const vector<T>& d){int len=d.size();rep(i,len){s<<d[i];if(i<len-1) s<<" ";}return s;}
template<typename T> ostream& operator<<(ostream& s,const vector<vector<T>>& d){int len=d.size();rep(i,len){s<<d[i]<<endl;}return s;}
template<typename T> ostream& operator<<(ostream& s,const set<T>& v){s<<"{ ";for(auto itr=v.begin();itr!=v.end();++itr) {if (itr!=v.begin()) {s<< ", ";}s<<(*itr);}s<<" }";return s;}
template<typename T> ostream& operator<<(ostream& s,const multiset<T>& v){s<<"{ ";for(auto itr=v.begin();itr!=v.end();++itr) {if (itr!=v.begin()) {s<< ", ";}s<<(*itr);}s<<" }";return s;}
template<typename T1, typename T2> ostream& operator<<(ostream& s,const map<T1,T2>& m){s<<"{"<<endl;for(auto itr=m.begin();itr!=m.end();++itr){s<<" "<<(*itr).first<<" : "<<(*itr).second<<endl;}s<<"}"<<endl;return s;}

const ll mod=1'000'000'007;
const ll inf=1'000'000'000'000'000'00;
const int INF=1'000'000'000;
const double EPS=1e-10;
const double PI=acos(-1);

struct state{
    ll k,l,r;
};

void solve(){
    ll n;
    cin>>n;
    ll ans=0;
    vector<vector<ll>> left(n+1),right(n+1);
    rep(i,n){
        ll k,l,r;
        cin>>k>>l>>r;
        if(l>=r){
            left[k].push_back(l-r);
            ans+=r;
        }else{
            right[k].push_back(r-l);
            ans+=l;
        }
    }
    priority_queue<ll,vector<ll>,greater<ll>> que;
    FOR(k,1,n+1){
        for(auto x:left[k]) que.push(x);
        while(que.size()>k) que.pop();
    }
    while(!que.empty()){
        ans+=que.top();
        que.pop();
    }
    for(int k=n;k>=1;k--){
        for(auto x:right[k]) que.push(x);
        while(que.size()>n-k) que.pop();
    }
    while(!que.empty()){
        ans+=que.top();
        que.pop();
    }
    cout<<ans<<endl;
}

int main(){
    cin.tie(0);ios::sync_with_stdio(false);
    int t;
    cin>>t;
    while(t--) solve();
}

Measured memory_bytes: 18260
#include<bits/stdc++.h>
using namespace std;
typedef long long unsigned int ll;

// definition {{{ 1

// scaning {{{ 2
#define Scd(x) scanf("%d", &x)
#define Scd2(x,y) scanf("%d%d", &x, &y)
#define Scd3(x,y,z) scanf("%d%d%d", &x, &y, &z)

#define Scll(x) scanf("%llu", &x)
#define Scll2(x,y) scanf("%llu%llu", &x, &y)
#define Scll3(x,y,z) scanf("%llu%llu%llu", &x, &y, &z)

#define Scc(c) scanf("%c", &c);
#define Scs(s) scanf("%s", s);
#define Scstr(s) scanf("%s", &s);
// }}} 2

// constants {{{ 2
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
// }}} 2

// systems {{{ 2
#define Rep(x,y) for(int x = 0; x < y; x++)
#define Repe(x,y,z) for(int x = z; x < y; x++)
// }}} 2

// output {{{ 2
#define YesNo(a) (a)?printf("Yes\n"):printf("No\n");
// }}} 2

// }}} 1

int main() {

    int N;
    int X;
    Scd2(N,X);

    vector<int> L(N);

    int tmp = 0;
    int ans = 1;
    int l;
    Rep(i,N){
        Scd(l);
        tmp += l;
        if( tmp <= X ){
            ans++;
        }
    }
    printf ("%d\n", ans );

    return 0;
}



Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <list>
#include <vector>
#include <queue>
#include <algorithm>
#include <climits>
#include <cstring>
#include <cmath>
#include <stack>
#include <iomanip>
#include <tuple>
#include <functional>
#include <cfloat>
#include <map>

#define int long long
#define CONTAINS(v,n) (find((v).begin(), (v).end(), (n)) != (v).end())
#define SORT(v) sort((v).begin(), (v).end())
#define RSORT(v) sort((v).rbegin(), (v).rend())
#define ARY_SORT(a, size) sort((a), (a)+(size))
#define MAX(a,b) (((a) > (b)) ? (a) : (b))
#define MIN(a,b) (((a) < (b)) ? (a) : (b))
#define REMOVE(v,a) (v.erase(remove((v).begin(), (v).end(), (a)), (v).end()))
#define REVERSE(v) (reverse((v).begin(), (v).end()))
#define LOWER_BOUND(v,a) (lower_bound((v).begin(), (v).end(), (a)))
#define UPPER_BOUND(v,a) (upper_bound((v).begin(), (v).end(), (a)))
#define REP(i, n) for (int (i) = 0; (i) < (n); (i)++)
#define CONTAINS_MAP(m, a) (m).find((a)) != m.end()
using namespace std;

int c[3][3];

signed main()
{
	REP(y, 3)REP(x, 3)
	{
		cin >> c[x][y];
	}

	if (   c[0][0] + c[1][1] == c[0][1] + c[1][0]
		&& c[0][0] + c[1][2] == c[0][2] + c[1][0]
		&& c[0][0] + c[2][1] == c[0][1] + c[2][0]
		&& c[0][0] + c[2][2] == c[0][2] + c[2][0]
		&& c[1][0] + c[2][1] == c[1][1] + c[2][0]
		&& c[1][0] + c[2][2] == c[1][2] + c[2][0]
		&& c[0][1] + c[1][2] == c[0][2] + c[1][1]
		&& c[0][1] + c[2][2] == c[0][2] + c[2][1]
		&& c[1][1] + c[2][2] == c[1][2] + c[2][1])
	{
		cout << "Yes" << endl;
	}
	else
	{
		cout << "No" << endl;
	}
}








Measured memory_bytes: 888
x1, y1, x2, y2 = map(int, input().split())

if x1 >= x2 and y1 >= y2:
    x3 = x2 - (y2 - y1)
    y3 = y2 + (x2 - x1)
    x4 = x1 - (y2 - y1)
    y4 = y1 + (x2 - x1)
elif x1 >= x2 and y1 < y2:
    x3 = x2 + (y1 - y2)
    y3 = y2 + (x2 - x1)
    x4 = x1 + (y1 - y2)
    y4 = y1 + (x2 - x1)
elif x1 < x2 and y1 >= y2:
    x3 = x2 - (y2 - y1)
    y3 = y2 - (x1 - x2)
    x4 = x1 - (y2 - y1)
    y4 = y1 - (x1 - x2)
elif x1 < x2 and y1 < y2:
    x3 = x2 + (y1 - y2)
    y3 = y2 - (x1 - x2)
    x4 = x1 + (y1 - y2)
    y4 = y1 - (x1 - x2)

print(str(x3) + " " + str(y3) + " " + str(x4) + " " + str(y4))

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

using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vll>;
using vvvll = vector<vvll>;
using ull = unsigned long long;
using vb = vector<bool>;
using vvb = vector<vb>;
using vd = vector<double>;
using vvd = vector<vd>;
using vvvd = vector<vvd>;
using vs = vector<string>;
using vvs = vector<vs>;
using vc = vector<char>;
using vvc = vector<vc>;
using ii = pair<int,int>;
using vii = vector<ii>;
using vvii = vector<vii>;
using dd = pair<double, double>;
using vdd = vector<dd>;
using vvdd = vector<vdd>;
using Mii = map<int,int>;
using vMii = vector<Mii>;

#define fi first
#define se second
#define INF INT_MAX
#define mod(a,m) (a%m+m)%m
#define PB push_back
#define MP make_pair

const int MOD = 1e9 + 7;

int modul(int a, int m) {
	return (a + 10*m) % m;
}

int main(){
//	cout.setf(ios::fixed);
//	cout.precision(4);
	string k;
	int d;
	while (cin >> k >> d) {
		int n = k.size();
		vvvll dp(n, vvll(d, vll(2, 0)));
		for (int i = 0; i < k[0] - '0'; ++i) {
			dp[0][modul(i, d)][0]++;
		}
		dp[0][modul(k[0] - '0', d)][1] = 1;
		for (int i = 1; i < n; ++i) {
		//	cerr << "i: " << i << endl;
			for (int j = 0; j < d; ++j) {
		//		cerr << "j: " << j << endl;
				for (int l = 0; l < 10; ++l) {
		//			cerr << "l: " << l << endl;
					dp[i][j][0] = (dp[i][j][0] + dp[i-1][modul(j - l, d)][0]) % MOD;
					if(l < k[i] - '0') 	{
						dp[i][j][0] = (dp[i][j][0] + dp[i-1][modul(j - l, d)][1]) % MOD;
					}
					else if (l == k[i] - '0') {
						dp[i][j][1] = (dp[i][j][1] + dp[i-1][modul(j - l, d)][1]) % MOD;
					}
				}
			}
		}
		ll ans = (dp[n-1][0][0] + dp[n-1][0][1]) % MOD;
		ans = (ans - 1 + MOD) % MOD;
		cout << ans << '\n';
	}
}




Measured memory_bytes: 55296
#include <iostream>
#include <algorithm>
#include <vector>
#define ll long long
using namespace std;

int n;

void compress(int *x1,int *x2){
	vector<int> pos;
	for(int i = 0;i < n;i++){
		pos.push_back(x1[i]);
		pos.push_back(x2[i]);
	}
	sort(pos.begin(),pos.end());
	pos.erase(unique(pos.begin(),pos.end()),pos.end());
	for(int i = 0;i < n;i++){
		x1[i] = find(pos.begin(),pos.end(),x1[i]) - pos.begin();
		x2[i] = find(pos.begin(),pos.end(),x2[i]) - pos.begin();
	}
}

int main(){
	int kk;
	int x1[50],x2[50],y1[50],y2[50],d1[50],d2[50];
	int x1p[50],x2p[50],y1p[50],y2p[50],d1p[50],d2p[50];
	int fill[100][100][100] = {},coor[3][100];
	cin >> n >> kk;
	for(int i = 0;i < n;i++){
		cin >> x1[i] >> y1[i] >> d1[i] >> x2[i] >> y2[i] >> d2[i];
		x1p[i] = x1[i];
		x2p[i] = x2[i];
		y1p[i] = y1[i];
		y2p[i] = y2[i];
		d1p[i] = d1[i];
		d2p[i] = d2[i];
	}
	compress(x1,x2);
	compress(y1,y2);
	compress(d1,d2);
	for(int i = 0;i < n;i++) coor[0][x1[i]] = x1p[i];
	for(int i = 0;i < n;i++) coor[0][x2[i]] = x2p[i];
	for(int i = 0;i < n;i++) coor[1][y1[i]] = y1p[i];
	for(int i = 0;i < n;i++) coor[1][y2[i]] = y2p[i];
	for(int i = 0;i < n;i++) coor[2][d1[i]] = d1p[i];
	for(int i = 0;i < n;i++) coor[2][d2[i]] = d2p[i];
	for(int i = 0;i < n;i++){
		for(int j = x1[i];j < x2[i];j++){
			for(int k = y1[i];k < y2[i];k++){
				for(int l = d1[i];l < d2[i];l++){
					fill[j][k][l]++;
				}
			}
		}
	}
	long long int res = 0;
	for(int i = 0;i < 100;i++){
		for(int j = 0;j < 100;j++){
			for(int k = 0;k < 100;k++){
				if(fill[i][j][k] >= kk){
					res += (ll)(coor[0][i + 1] - coor[0][i]) * (ll)(coor[1][j + 1] - coor[1][j]) * (ll)(coor[2][k + 1] - coor[2][k]);
				}
			}
		}
	}
	cout << res << endl;
	return 0;
}

Measured memory_bytes: 7044
#include <iostream>
#include <set>

using namespace std;

int d[114514];

int main()
{
	int k;
	cin >> k;
	d[1] = 1;
	set<pair<int, int>> q;
	q.insert(make_pair(1, 1));
	while (q.begin()->second) {
		int u = q.begin()->second;
		q.erase(q.begin());
		for (int i = 0; i < 2; i++) {
			int v = (i ? u + 1 : u * 10) % k;
			if (d[v] && d[v] <= d[u] + i)
				continue;
			auto it = q.find(make_pair(d[v], v));
			if (it != q.end())
				q.erase(it);
			d[v] = d[u] + i;
			q.insert(make_pair(d[v], v));
		}
	}
	cout << *d << endl;
	return 0;
}


Measured memory_bytes: 2944
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define INF 2147483647//int max
const int MOD = 1000000007;
using namespace std;
using ll = long long;
using P = pair<int,int>;


int main() {
    vector<int> a(3,0);
    int k;
    cin >> a[0] >> a[1] >> a[2] >> k;
    sort(a.begin(),a.end());
    ll sum = a[0] + a[1] + a[2]*pow(2,k);
    cout << sum << endl;
    return 0;
}

/*
やっほい！
　　　　　　　やほほい！
　　　　+　　 　*
　　　 ∧∧　　. ∧∞∧　*
*　ヽ(=´ω｀)人(´ω｀*)ﾉ
　.～（ O x.） （ 　 O)～　+
。*　 　∪　　　　∪
*/

Measured memory_bytes: 384
import Control.Applicative
import Control.Monad
import Data.IORef

func :: [[Int]] -> Int -> Int -> Int -> Int -> Int
func ((x:y:a:_):xs) r l d t =
  case a of
     1 -> func xs (max r x) l d t
     2 -> func xs r (min l x) d t
     3 -> func xs r l (max d y) t
     4 -> func xs r l d (min t y)
     otherwise -> 0
    
func [] r l d t = width*height
  where
    width = if l-r > 0 then l-r else 0
    height = if t-d > 0 then t-d else 0

main :: IO ()
main = do
  [w,h,n] <- return . map (read::String->Int) . words =<< getLine
  dat <- return . map (map (read::String->Int) . words) . lines =<< getContents
  print $ func dat 0 w 0 h



Measured memory_bytes: 1020