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

using namespace std;

int main() {

	int a, b, k, cnt=0, ste, flag, l, r;
	char tmp;
	vector<int> x, y;
	vector< vector<int> > board;

	cin >> a >> b >> k;

	a += 2;
	b += 2;

	board.resize(a);
	for (int i = 0;i<a;i++) board[i].resize(b);

	for (int i = 0;i<a;i++) {
		board[i][0] = -9;
		board[i][b - 1] = -9;
	}
	for (int i = 0;i<b;i++) {
		board[0][i] = -9;
		board[a - 1][i] = -9;
	}

	for (int i = 0;i<a - 2;i++) {
		for (int j = 0;j<b - 2;j++) {
			//'#='0, '.'=-1
			cin >> tmp;
			if(tmp=='.') board[i+1][j+1]=-1;
			else {
				board[i + 1][j + 1] = 0;
				x.emplace_back(i + 1);
				y.emplace_back(j + 1);
			}
		}
	}

	for (int i = 0;i < k;i++) {
		cnt++;
		board[x[i]][y[i]] = cnt;
		
		//left
		ste = 0;
		while (1) {
			ste++;
			if (board[x[i]][y[i] - ste] == -1) {
				board[x[i]][y[i] - ste] = cnt;
			}
			else {
				l = y[i] - ste + 1;
				break;
			}
		}

		//right
		ste = 0;
		while (1) {
			ste++;
			if (board[x[i]][y[i] + ste] == -1) {
				board[x[i]][y[i] + ste] = cnt;
			}
			else {
				r = y[i] + ste - 1;
				break;
			}
		}

		//up
		ste = 0;
		flag = 1;
		while (1) {
			ste++;
			for (int j = l;j <= r;j++) {
				if (board[x[i] - ste][j] != -1) {
					flag = 0;
					break;
				}
			}
			if (flag) {
				for (int j = l;j <= r;j++) board[x[i] - ste][j] = cnt;
			}
			else {
				break;
			}
		}

		//down
		ste = 0;
		flag = 1;
		while (1) {
			ste++;
			for (int j = l;j <= r;j++) {
				if (board[x[i] + ste][j] != -1) {
					flag = 0;
					break;
				}
			}
			if (flag) {
				for (int j = l;j <= r;j++) board[x[i] + ste][j] = cnt;
			}
			else {
				break;
			}
		}
	}

	/*for (int i = 0;i < k;i++) {
		cout << x[i] << " " << y[i] << endl;
	}*/

	for (int i = 1;i<a-1;i++) {
		for (int j = 1;j<b-1;j++) {
			cout << board[i][j] << " ";
		}
		cout << endl;
	}

}


Measured memory_bytes: 1956
import static java.lang.Integer.parseInt;
import static java.lang.Long.parseLong;
import static java.lang.Math.max;
import static java.lang.Math.min;
import static java.lang.System.exit;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;

public class Main {

	static char op[] = new char[200000];
	static int opI[] = new int[200000];
	static int opJ[] = new int[200000];
	static int opK[] = new int[200000];
	static int opCnt;

	static void add(int i, int j, int k) {
		op[opCnt] = '+';
		opI[opCnt] = i;
		opJ[opCnt] = j;
		opK[opCnt] = k;
		++opCnt;
	}

	static void less(int i, int j, int k) {
		op[opCnt] = '<';
		opI[opCnt] = i;
		opJ[opCnt] = j;
		opK[opCnt] = k;
		++opCnt;
	}

	static final int MAXPOW = 29;
	static int rA, rB, rZero, rOne, rAcc, rAcc2;

	static void solve() throws Exception {
		rA = 0;
		rB = 1;
		rZero = 2;
		rOne = 3;
		add(rA, rB, rOne);
		less(rZero, rOne, rOne);
		for (int i = 1; i <= MAXPOW; i++) {
			add(rOne + i - 1, rOne + i - 1, rOne + i);
		}
		int rFree = rOne + MAXPOW + 1;
		rAcc = rFree++;
		rAcc2 = rFree++;
		int powsA = rFree;
		toPows(rA, powsA);
		rFree += MAXPOW + 1;
		int powsB = rFree;
		toPows(rB, powsB);
		rFree += MAXPOW + 1;
		int rDest = 2;
		for (int i = 2 * MAXPOW; i >= 0; i--) {
			if (i != 2 * MAXPOW) {
				add(rDest, rDest, rDest);
			}
			for (int j = max(0, i - MAXPOW); j <= min(MAXPOW, i); j++) {
				add(powsA + j, powsB + i - j, rAcc2);
				less(rOne, rAcc2, rAcc2);
				add(rDest, rAcc2, rDest);
			}
		}
		out.println(opCnt);
		for (int i = 0; i < opCnt; i++) {
			out.println(op[i] + " " + opI[i] + " " + opJ[i] + " " + opK[i]);
		}
	}

	static void toPows(int rSrc, int rDest) {
		add(rOne, rSrc, rSrc);
		for (int i = MAXPOW; i >= 0; i--) {
			add(rAcc, rOne + i, rAcc2);
			less(rAcc2, rSrc, rDest + i);
			int cur = rDest + i;
			for (int j = 0; j < i; j++) {
				add(cur, cur, rAcc2);
				cur = rAcc2;
			}
			add(rAcc, cur, rAcc);
		}
		add(rZero, rZero, rAcc);
	}

	static int scanInt() throws IOException {
		return parseInt(scanString());
	}

	static long scanLong() throws IOException {
		return parseLong(scanString());
	}

	static String scanString() throws IOException {
		while (tok == null || !tok.hasMoreTokens()) {
			tok = new StringTokenizer(in.readLine());
		}
		return tok.nextToken();
	}

	static BufferedReader in;
	static PrintWriter out;
	static StringTokenizer tok;

	public static void main(String[] args) {
		try {
			in = new BufferedReader(new InputStreamReader(System.in));
			out = new PrintWriter(System.out);
			solve();
			in.close();
			out.close();
		} catch (Throwable e) {
			e.printStackTrace();
			exit(1);
		}
	}
}

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

// 総数を1000000007（素数）で割った余り
const long long mod = 1e9 + 7;

using ll = long long;
using pii  = pair<int, int>;
using pll = pair<ll, ll>;
#define ull unsigned long long
#define ld long double
#define vi vector<int>
#define vll vector<ll>
#define vc vector<char>
#define vs vector<string>
#define vpii vector<pii>
#define vpll vector<pll>

#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; i++)
#define rep1(i, n) for (int i = 1, i##_len = (n); i <= i##_len; i++)
#define repr(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rep1r(i, n) for (int i = ((int)(n)); i >= 1; i--)

#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define RSORT(x) sort(rall(x));
#define pb push_back
#define mp make_pair

#define INF (1e9)
#define PI (acos(-1))
#define EPS (1e-7)

ull gcd(ull a, ull b) { return b ? gcd(b, a % b) : a; }
ull lcm(ull a, ull b) { return a / gcd(a, b) * b; }

int main(){
    int n;
    cin >> n;
    vi d(n);
    rep(i, n) cin >> d[i];
    sort(all(d));
    int c = (1 + n) / 2;
    int ans = abs(d[c-1]-d[c]);
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 640
import java.util.*;
import java.*;


class Main{
   public static void main(String[] args)
   {
      Scanner scan = new Scanner(System.in);
      String  s = scan.next();
      int     ns = 0, nt = 0;

      char[] sss = new char[s.length()];

      for(int i = 0; i < s.length(); i++){
          sss[i] = s.charAt(i);
          ns++;
          }
      Arrays.sort(sss);

      /* int Mins = sss[0];
       * for(int i = 0; i < s.length; i++){
       *    Mins = Math.min(Mins, sss[0]);
       *  }*/
      String t   = scan.next();
      char[] ttt = new char[t.length()];
      for(int j = 0; j < t.length(); j++){
          ttt[j] = t.charAt(j);
          nt++;
          }

      int array = s.length() <= t.length() ? s.length() : t.length();
      Arrays.sort(ttt);
      if(sss[0] > ttt[t.length() - 1]){
         System.out.println("No");
         }
      else if(sss[0] == ttt[t.length() - 1]){
              for(int i = 1; i < array; i++){
                  if(sss[i] < ttt[t.length() - 1 - i]){
                     System.out.println("Yes");
                     return;
                     }
                  else if(sss[i] > ttt[t.length() - 1 - i]){
                          System.out.println("No");
                          return;
                          }
                  }
              if(s.length() < t.length()){
                 System.out.println("Yes");
                 }
              else{
                  System.out.println("No");
                  }
              }
      else{
          System.out.println("Yes");
          }
   }
}


Measured memory_bytes: 21972
#include<bits/stdc++.h>
#define ull unsigned long long
#define ll long long
#define vi vector<int>
#define vull vector<ull>
#define vll vector<ll>
#define pb push_back
#define rep(i,n) for(int i=0;i<n;i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define si set<int>
#define sll set<ll>
#define ins insert
#define vpp vector<pair<int,int>>
#define mp make_pair
#define ft first
#define sc second
using namespace std;

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int n;
	cin>>n;
	int h=n/2;
	string s;
	cin>>s;
	if(n%2!=0){
		cout<<"No";
		exit(0);
	}
	int flag=0;
	rep(i,h){
		if(s[i]!=s[i+h]){
			flag=1;
			break;
		}
	}
	if(flag==0)
	cout<<"Yes";
	else
	cout<<"No";
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
	long n,k;
	cin>>n>>k;
	long long int a[n+1],w[n+1];
	for(int i=0;i<n;i++)
		cin>>a[i]>>w[i];
	long long int dp[n+1][k+1];
	for(int i=0;i<=n;i++){
		for(int j=0;j<=k;j++){
			if(i==0 || j==0) dp[i][j]=0;
			else if (a[i-1]<=j) dp[i][j]=max(dp[i-1][j],dp[i-1][j-a[i-1]]+w[i-1]);
			else dp[i][j]=dp[i-1][j];
		}
	}
	cout<<dp[n][k]<<endl;
	return 0;
}
		


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

const int MOD = 1000000007;
const int INF = 1e9;

int main(){
  int n;
  const int max_n = 2 * 1e5;
  int a[max_n + 1];
  cin >> n;
  for(int i = 0; i < n; i++){
    cin >> a[i];
    a[i] -= i + 1;
    // cout << a[i] << endl;
  }

  sort(a, a+n);
  int mid = 0;
  mid = n / 2;
  if(n % 2 == 0) mid -= 1;
  long long ans = 0;
  long long ans2 = 0;
  for(int i = 0; i < n; i++){
    ans += abs(a[i] - a[mid]);
    if(n % 2 == 0) ans2 += abs(a[i] - a[mid+1]);
  }
  if(n%2 == 0) ans = min(ans, ans2);
  cout << ans << endl;

  return 0;
}

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

int main(){
    int a, b;
    char op;
    bool run = true;
    while(run){
        cin >> a >> op >> b;
        switch(op){
            case '?':
                run = false;
                break;
            case '+':
                cout << a + b << endl;
                break;
            case '-':
                cout << a - b << endl;
                break;
            case '*':
                cout << a * b << endl;
                break;
            case '/':
                cout << a/ b << endl;
                break;
        }
    }
    
    return 0;
}


Measured memory_bytes: 3068
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int m = sc.nextInt();
        boolean[] cleared = new boolean[n];
        int[] penalties = new int[n];
        int clearedQuestions = 0;

        boolean ac; int q;
        for(int i=0; i<m; i++){
            q = sc.nextInt()-1;
            ac = sc.next().equals("AC");
            if(cleared[q]) continue;
            if(ac){
                cleared[q] = true;
                clearedQuestions++;
            }else{
                penalties[q]++;
            }
        }

        int penalty = 0;
        for(int i=0; i<n; i++){
            penalty += cleared[i] ? penalties[i] : 0;
        }

        System.out.println(clearedQuestions+" "+penalty);
    }
}

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

// #define int long long
#define rep(i, n) for (long long i = (long long)(0); i < (long long)(n); ++i)
#define reps(i, n) for (long long i = (long long)(1); i <= (long long)(n); ++i)
#define rrep(i, n) for (long long i = ((long long)(n)-1); i >= 0; i--)
#define rreps(i, n) for (long long i = ((long long)(n)); i > 0; i--)
#define irep(i, m, n) for (long long i = (long long)(m); i < (long long)(n); ++i)
#define ireps(i, m, n) for (long long i = (long long)(m); i <= (long long)(n); ++i)
#define SORT(v, n) sort(v, v + n);
#define REVERSE(v, n) reverse(v, v+n);
#define vsort(v) sort(v.begin(), v.end());
#define all(v) v.begin(), v.end()
#define mp(n, m) make_pair(n, m);
#define cout(d) cout<<d<<endl;
#define coutd(d) cout<<std::setprecision(10)<<d<<endl;
#define cinline(n) getline(cin,n);
#define replace_all(s, b, a) replace(s.begin(),s.end(), b, a);
#define PI (acos(-1))
#define FILL(v, n, x) fill(v, v + n, x);
#define sz(x) long long(x.size())

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vs = vector<string>;
using vpll = vector<pair<ll, ll>>;
using vtp = vector<tuple<ll,ll,ll>>;
using vb = vector<bool>;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

const ll INF = 1e9;
const ll MOD = 1e9+7;
const ll LINF = 1e18;



signed main()
{
  cin.tie( 0 ); ios::sync_with_stdio( false );
  ll n; cin>>n;
  ll m=n%10;
  if(m==3) cout<<"bon"<<endl;
  else if(m==2 ||m==4||m==5||m==7||m==9) cout<<"hon"<<endl;
  else cout<<"pon"<<endl;
}


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

int main() {
  int A, B, M;
  cin >> A >> B >> M;
  vector<int>a(A);
  vector<int>b(B);
  vector<vector<int>>xyc(3, vector<int>(M));
  for(int i=0; i<A; i++)cin >> a.at(i);
  for(int i=0; i<B; i++)cin >> b.at(i);
  for(int i=0; i<M; i++){
    for(int j=0; j<3; j++){
      cin >> xyc.at(j).at(i);
    }
  }
  
  int mina = a.at(0);
  int minb = b.at(0);
  for(int i=0; i<A; i++){
    if(mina > a.at(i))mina = a.at(i);
  }
  for(int i=0; i<B; i++){
    if(minb > b.at(i))minb = b.at(i);
  }
  
  int ans = mina + minb;
  
  for(int i=0; i<M; i++){
    int waribiki = a.at(xyc.at(0).at(i)-1) + b.at(xyc.at(1).at(i)-1) - xyc.at(2).at(i);
    if(ans > waribiki)ans = waribiki;
  }
  
  cout << ans << endl;
}

Measured memory_bytes: 5552
#include <iostream>

using namespace std;

int main(){
	int high[10];
	int max;
	
	int i,j,k;
	
	for(i = 0;i < 10;i++){
		cin >> high[i];
	}
	
	for(j = 0;j < 10;j++){
		max = 0;
		k = j;
		for(i = j;i < 10;i++){
			if(max < high[i]){
	        	k = i;
				max = high[i];
			}
		}
		high[k] = high[j];
		high[j] = max;
	} 
	
	for(i = 0;i < 3;i++){
		cout<<high[i]<<endl;
	}
	
	return 0;
}

Measured memory_bytes: 1164
#include <iostream>
using namespace std;
int main(void){
    int n,cnt=0;
    int p[21]; 
    cin >>n;
    for (int i = 0; i < n; ++i) cin >> p[i];    
    for (int i = 1; i < n-1; ++i) {
        if(p[i]>p[i-1] and p[i]<p[i+1]){
            cnt++;
        }else if(p[i]<p[i-1] and p[i]>p[i+1])
        {
            cnt++;
        }
        
    }
    cout << cnt << endl;
}


Measured memory_bytes: 256
from collections import Counter
N, M = map(int, input().split())
mod = 10 ** 9 + 7


# 素因数分解
def prime_factorization(n):
    table = []
    for x in range(2, int(n ** 0.5) + 1):
        while n % x == 0:
            table.append(x)
            n //= x
    if n > 1:
        table.append(n)
    return table


# 重複組み合わせ
def nHk(n, k):
    value = 1
    nk = n + k - 1
    k = min(nk-k, k)
    for i in range(k):
        value = (value * nk) % mod
        nk -= 1
    for x in range(1, k + 1):
        value = (value * pow(x, mod-2, mod)) % mod
    return value


T = prime_factorization(M)
C = Counter(T)

ans = 1
for v in C.values():
    ans *= nHk(N, v)
    ans %= mod

print(ans)


Measured memory_bytes: 3444
//in the name of Allah
#include<bits/stdc++.h>
using namespace std;
#define ll long long
const int N = 55, mod = 1e9 + 7;
int a[N];

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n, cnt_odd = 0, p;
	cin >> n >> p;
	for(int i = 0; i < n; i ++){
		cin >> a[i];
		if(a[i] % 2 == 1)
			cnt_odd ++;
	}
	int cnt_even = n - cnt_odd;
	ll ans = 1ll << cnt_even;
	if(cnt_odd > 0)
		ans *= (1ll << (cnt_odd - 1));
	if(cnt_odd == 0 and p == 1)
		ans = 0;
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 384
import sys
from operator import itemgetter

sys.setrecursionlimit(10**9)
input = sys.stdin.readline

def ii(): return int(input())
def mi(): return map(int, input().split())
def lmi(): return list(map(int, input().split()))
def lmif(n): return [list(map(int, input().split())) for _ in range(n)]
def ss(): return input().split()

def main():
    n = ii()
    if n%1000 == 0:
        print(0)
    else:
        print(1000 - n%1000)
    return

main()


Measured memory_bytes: 9212
#import<iostream>
#import<map>
#import<queue>
#import<cstdlib>
#import<cstring>
using namespace std;struct B{int z[2];char s[14];bool operator<(const B&r)const{return strcmp(s,r.s)<0;}};main(){int a[13][5]={{2,-1},{2,5,-1},{0,1,3,6,-1},{2,7,-1},{5,-1},{1,4,6,9,-1},{2,5,7,10,-1},{3,6,8,11,-1},{7,-1},{5,10,-1},{6,9,11,12,-1},{7,10,-1},{10,-1}},X[]={2,1,2,3,0,1,2,3,4,1,2,3,2},Y[]={0,1,1,1,2,2,2,2,2,3,3,3,4},v,d,s,i,j,t,u;B g={0,0,"0123456789:;0"};for(;;){map<B,int>m;queue<B>q;B b={i=-1,-1};for(;++i<13;!v?b.z[*b.z>=0]=i:0){cin>>v;if(v<0)return 0;b.s[i]=48+v;}b.s[13]=0;m[b]=1;for(q.push(b);!q.empty();q.pop()){B&b=q.front();if(!strcmp(b.s,g.s))break;for(d=i=0;i<13;v?d+=abs(X[v]-X[i])+abs(Y[v]-Y[i]):0,i++)v=b.s[i]-48;s=m[b];if(s+d<22)for(j=2;j--;)for(i=0;~a[u=b.z[j]][i];i++){B n=b;t=n.z[j]=a[u][i];if(t-n.z[1-j]){swap(n.s[u],n.s[t]);int&r=m[n];if(!r)r=s+1,q.push(n);}}}printf(m[g]?"%d\n":"NA\n",m[g]-1);}}

Measured memory_bytes: 1480
#D - Dice in Line
N,K = map(int,input().split())
p = list(map(int, input().split()))
S = [0]*N
s = 0
s_t = 0
S[0] = (1+p[0])/2

if N == 1:
    print(S[0])
    exit()
else:
    pass

for i in range(N-1):
    S[i+1] =S[i]+(1+p[i+1])/2

if N == K:
    print(S[N-1])
    exit()
else:
    pass

for j in range(N-K):
    s_t = S[j+K]-S[j]
    if s_t >= s:
        s = s_t
    else:
        pass

print(s)

Measured memory_bytes: 71792
S=input()

p,q=0,1
dp = {0:1}
mod = 2019

for i in range(len(S)-1,-1,-1):
  p = (p+int(S[i])*q)%mod
  if p not in dp:dp[p]=0
  dp[p]+=1
  q= (q*10)%mod

cnt = 0
for i in dp:
  cnt += dp[i]*(dp[i]-1)//2
print(cnt)

Measured memory_bytes: 9336
#include <stdio.h>
#include <math.h>

int main(void){
    int a, b, c;
    double s, l, h;
    double rad;
    double PI = acos(-1);

    scanf("%d %d %d\n", &a, &b, &c);
    rad = c * (2 * PI / 360);
    
    h = b * sin(rad);
    s = a * h / 2;
    l = a + b + sqrt(a*a + b*b - 2*a*b*cos(rad));
    printf("%.8lf\n%.8lf\n%.8lf\n", s, l, h);
    
    return 0;
}



Measured memory_bytes: 2132
#include <cstdio>
#include <vector>
#include <algorithm>
#define mod 1000000007
using namespace std;

int n;
vector< pair<int, int> > v;

int main() {

    scanf("%d", &n);
    for(int i = 1; i <= n; ++i) {
        int x;
        scanf("%d", &x);
        v.push_back(make_pair(x, 0));
    }
    for(int i = 1; i <= n; ++i) {
        int x;
        scanf("%d", &x);
        v.push_back(make_pair(x, 1));
    }

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

    int cnt0 = 0, cnt1 = 0, sol = 1;
    for(auto x: v) {
        if(x.second == 0) {
            if(cnt1 > 0) {
                sol = (1LL * sol * cnt1) % mod;
                --cnt1;
            }
            else ++cnt0;
        }
        else {
            if(cnt0 > 0) {
                sol = (1LL * sol * cnt0) % mod;
                --cnt0;
            }
            else ++cnt1;
        }
    }

    printf("%d\n", sol);

    return 0;
}

Measured memory_bytes: 2548
// Last Change: 05/25/2019 21:27:26.
#include <algorithm>
#include <array>
#include <bitset>
#include <cmath>
#include <cstdlib>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <memory>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

using namespace std;
using ll = long long;

namespace NS {
void LoopUntilZeroInpput() {
  int hogegegege = 0;
  while (cin >> hogegegege && hogegegege != 0) {
  }
}
} // namespace NS

int main() {
  ll N, M;
  cin >> N >> M;
  vector<ll> card(N + 1, 0);

  ll l, r;
  for (ll i = 0; i < M; ++i) {
    cin >> l >> r;
    ++card[l - 1];
    --card[r];
  }

  ll tmp = 0, ans = 0;
  for (auto &&e : card) {
    e = tmp += e;
    if (e == M) {
      ++ans;
    }
  }
  cout << ans << endl;

  //NS::LoopUntilZeroInpput();
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep_s(i, s, n) for (int i = (int)(s); i < (int)(n); i++)
using ll = long long;
using vi = vector<int>;
using vll = vector<ll>;

#define MOD 1000000007

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

  vi a, b;
  rep(i, n)
  {
    ll _a;
    cin >> _a;
    a.push_back(_a);
  }

  rep(i, m)
  {
    ll _b;
    cin >> _b;
    b.push_back(_b);
  }

  int ans = 0;

  ll a_k = 0;
  int a_index = -1;

  ll b_k = 0;
  int b_index = -1;

  // b全部読む
  rep(i, m) {
    b_k += b[i];
  }
  b_index = m - 1;

  rep(i, n + 1) {
    if (i > 0) {
      a_index++;
      a_k += a[a_index];
    }

    // bを減らす
    while(a_k + b_k > k && b_index >= 0) {
      b_k -= b[b_index];
      b_index--;
    }

    if (a_k + b_k <= k) {
      ans = max(ans, a_index + b_index + 2);
    }
  }

  cout << ans << endl;
}


Measured memory_bytes: 5628
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
const ll mod=1e9+7;
int dy[]={1,-1,0,0};
int dx[]={0,0,1,-1};

int main(){
  string N;
  cin>>N;
  int cnt[26]={0};
  for(int i=0;i<4;i++){
    cnt[N[i]-'A']++;
    
  }
  int two=0;
  for(int i=0;i<26;i++){
    if(cnt[i]==2) two++;
  }
  if(two==2) cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
  return 0;
}



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

using namespace std;
int main(int argc, char *argv[]) {
	int n, k;
	cin >> n >> k;
	int h[n];
	for (int i = 0; i < n; i++) {
		cin >> h[i];
	}
	
	int ans = 0;
	for (int i = 0; i < n; i++) {
		if (h[i] >= k) {
			ans++;
		}
	}
	
	cout << ans << endl;
}

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

bool cmp(pair<int, int> x, pair<int, int> y) {
	return x.second > y.second;
}

int n;

int main(){
    ios_base::sync_with_stdio(false); //Fast I/O
    cin.tie(NULL);

    cin >> n;
    map<int, int> a, b;
	vector<int> v1, v2;
	vector<pair<int, int>> va, vb;

	for(int i=0;i<n;i++) {
		int t;
		cin >> t;
		if(i % 2) {
			if(b[t] == 0)
				v2.push_back(t);
			b[t]++;
		} else {
			if(a[t] == 0)
				v1.push_back(t);
			a[t]++;
		}
	}
	for(int x:v1) {
		va.push_back({x, a[x]});
	}
	for(int x:v2) {
		vb.push_back({x, b[x]});
	}
	int k = (n+1)/2, m = n/2;
	sort(va.begin(), va.end(), cmp);
	sort(vb.begin(), vb.end(), cmp);
	int v = k - va[0].second,
	    u = m - vb[0].second;
	int ans = u + v;
	if(va[0].first == vb[0].first) {
		int u1, v1;
		if(va.size()>1)
			u1 = k - va[1].second;
		else
			u1 = k;
		if(vb.size()>1)
			v1 = m - vb[1].second;
		else
			v1 = m;
		ans = min(v+v1, u+u1);
	}
	cout << ans << endl;

    return 0;
}

Measured memory_bytes: 6516
/*****include*****/
#include <iostream>

/*****デバッグ定義*****/
//#define DEBUG
/*****マクロ定義*****/

/*****名前空間*****/
using namespace std;

/*****グローバル変数置き場*****/

/*****その他関数置き場*****/

/*****main関数*****/
int main(){
	/*****変数置き場*****/
	double time_50,time_100;
	int level_50;
	int level_100;
	int level;
	/*****処理部*****/
	while(1){
		cin >> time_50 >> time_100;
		if(cin.eof())	break;
		if(time_50 < 35.5)
			level_50 = 7;
		else if(time_50 < 37.5)
			level_50 = 6;
		else if(time_50 < 40)
			level_50 = 5;
		else if(time_50 < 43)
			level_50 = 4;
		else if(time_50 < 50)
			level_50 = 3;
		else if(time_50 < 55)
			level_50 = 2;
		else if(time_50 < 70)
			level_50 = 1;
		else
			level_50 = 0;
		
		if(time_100 < 71)
			level_100 = 7;
		else if(time_100 < 77)
			level_100 = 6;
		else if(time_100 < 83)
			level_100 = 5;
		else if(time_100 < 89)
			level_100 = 4;
		else if(time_100 < 105)
			level_100 = 3;
		else if(time_100 < 116)
			level_100 = 2;
		else if(time_100 < 148)
			level_100 = 1;
		else
			level_100 = 0;
		
		if(level_100 > level_50)
			level = level_50;
		else
			level = level_100;
		
		switch(level){
		case 0:
			cout << "NA" << endl;
			break;
		case 1:
			cout << "E" << endl;
			break;
		case 2:
			cout << "D" << endl;
			break;
		case 3:
			cout << "C" << endl;
			break;
		case 4:
			cout << "B" << endl;
			break;
		case 5:
			cout << "A" << endl;
			break;
		case 6:
			cout << "AA" << endl;
			break;
		case 7:
			cout << "AAA" << endl;
			break;
		}
	}
	/*****処理終了後*****/
	return 0;
}

Measured memory_bytes: 1216
n,m=map(int,input().split())
a=[0]*m
b=[0]*m
for i in range(m):
    a[i],b[i]=map(int,input().split())
ans=[0]*n
for j in range(m):
    ans[a[j]-1]+=1
    ans[b[j]-1]+=1
#print(ans)
for k in range(n):
    print(ans[k])

Measured memory_bytes: 3064
#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>
using namespace std;
typedef long long int lli;
typedef unsigned long long int ulli;
#define vec(s) vector

#define vvec(s) vector<vector
>
typedef vector<lli> vi;
typedef vector<vi> vvi;
typedef pair<lli,lli> pii;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define YN(x) cout<<(x?"Yes":"No")<<endl;
#define out(s) cout<<s<<endl;
#define pb(s) push_back(s);
#define sp " ";
#define INF 10000000000
#define all(s) s.begin(),s.end()
void vout(vi v){
    for(int i=0;i<v.size();i++)
    cout<<v.at(i)<<endl;
}
int main(){
    long double m, n,s=0;
    cin >> n >> m;
    vec(long double) a(n);
    rep(i,n){
        cin >> a[i];
        s += a[i];
    }
    sort(all(a));
    YN(a[n - m ] >=  s/ (4.0 * m));
}

Measured memory_bytes: 3736
N, M = map(int, input().split())
idcard = [[int(j) for j in input().split()] for i in range(M)]

L = 0
R = 10**10
for i in idcard:
    L = max(L, i[0])
    R = min(R, i[1])
if R >= L:
    print(R - L + 1)
else:
    print(0)

Measured memory_bytes: 21156
# coding: utf-8

(x1, y1, x2, y2) = [int(i) for i in input().rstrip().split(" ")]

(x3, y3, x4, y4) = [0,0,0,0]
if x1 == x2:
    x3 = x1 - (y2 - y1)
    y3 = y2
    x4 = x3
    y4 = y1

elif y1 == y2:
    x3 = x2
    y3 = y2 + (x2 - x1)
    x4 = x1
    y4 = y3
else:
    x_diff = x2 - x1
    y_diff = y2 - y1
    x3 = x2 - y_diff
    y3 = y2 + x_diff
    x4 = x3 - x_diff
    y4 = y3 - y_diff

print(" ".join([str(i) for i in [x3, y3, x4, y4]]))


Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
         
#define IOS ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define int long long
#define rep(i,a,b)    for(int i=a;i<b;i++)
#define repn(i,a,b)   for(int i=a;i>=b;i--)
#define F first
#define S second
#define pii pair<int,int>
#define vi vector<int>
#define vii vector<pii>
#define pb push_back
#define all(v) (v).begin(), (v).end()
#define mod 1000000007  
const int N = 100001; 



void solve(){
	int n,k;cin>>n>>k;
	vi a(n);
	int mx=0;
	rep(i,0,n){
		cin>>a[i];
		mx=max(mx,a[i]);
	}
	int l=0,r=mx;
	// if(mx==1){cout<<1;return;}
	while(l<r){
		int mid=(l+r)/2;
		if(r==1)break;
		int ans=0;
		rep(i,0,n)ans=ans+(a[i]-1)/mid;
		if(ans<=k)r=mid;
		else l=mid+1;
	}
	cout<<r;

    return;
}
         
signed main(){
        IOS;    
        

        int t=1;
        // cin>>t;
        // fac[0] = 1; 
        // for (int i=1 ; i<=2000001; i++) fac[i] = fac[i-1]*i%mod; 
        rep(i,0,t){
            solve();
            cout<<"\n";
        //   cout<<" * "<<t<<"\n";
        }
    //    return 0;
}

Measured memory_bytes: 4776
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
//??¢???????§???????,?§??????°????¨???????????????????,???????????¨?????¨??????????§?
int main(){

    int n,m,p,min,mintmp;

    cin >> n >> m >> p;
    vector<int> vec(m);
    for(int i=0;i<m;i++){
      cin >> vec[i];
    }
    sort(vec.begin(),vec.end());

    bool flag = true;
    int i = 0;
    while(flag){
      flag = false;

      if(vec[i] < p){
        vec.push_back(vec[i]+n);
        i++;
        flag = true;
      }
    }

    vec.erase(vec.begin(),vec.begin() + i);

    reverse(vec.begin(),vec.end());

    int start,finish,startdif,finishdif;
    min = 1000000;

    i=0;

    while(1){
      if(i==vec.size()-1){
        mintmp = p + n - vec[i] ;
        if(min > mintmp){
          min = mintmp;
        }
        break;
      }

      start = vec[i];
      finish = vec[i+1];

      startdif = 2 * (p + n - start );
      finishdif = finish - p;

      mintmp = startdif + finishdif;

      if(min > mintmp){
        min = mintmp;
      }

      i++;

    }


    reverse(vec.begin(),vec.end());



    i=0;

    while(1){
      if(i==vec.size()-1){
        mintmp = vec[i] - p;
        if(min > mintmp){
          min = mintmp;
        }
        break;
      }

      start = vec[i];
      finish = vec[i+1];

      startdif = 2 * (start - p);
      finishdif = n + p - finish;

      mintmp = startdif + finishdif;

      if(min > mintmp){
        min = mintmp;
      }

      i++;

    }

    cout << min * 100 << endl;

    return 0;
}

Measured memory_bytes: 3172
#include<stdio.h>
int main(){
int x[4],y[4],sidex,sidey;
scanf("%d%d%d%d",&x[0],&y[0],&x[1],&y[1]);
if(x[0]>x[1])
sidex=x[0]-x[1];
else
sidex=x[1]-x[0];
if(y[0]>y[1])
sidey=y[0]-y[1];
else
sidey=y[1]-y[0];
//printf("x=%d y=%d\n",sidex,sidey);
if(x[0]<=x[1]&&y[0]>=y[1]){
x[2]=x[1]+sidey;
y[2]=y[1]+sidex;
x[3]=x[2]-sidex;
y[3]=y[2]+sidey;
}
else if(x[0]<=x[1]&&y[0]<y[1]){
x[2]=x[1]-sidey;
y[2]=y[1]+sidex;
x[3]=x[2]-sidex;
y[3]=y[2]-sidey;
}
else if(x[0]>=x[1]&&y[0]<=y[1]){
x[2]=x[1]-sidey;
y[2]=y[1]-sidex;
x[3]=x[2]+sidex;
y[3]=y[2]-sidey;
}
else if(x[0]>=x[1]&&y[0]>=y[1]){
x[2]=x[1]+sidey;
y[2]=y[1]-sidex;
x[3]=x[2]+sidex;
y[3]=y[2]+sidey;
}
printf("%d %d %d %d\n",x[2],y[2],x[3],y[3]);
return 0;
}


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


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


Measured memory_bytes: 256
def isValid(tmp_r, tmp_c):
    ret = 0
    for row in range(H):
        for col in range(W):
            ret += 1 if c[row][col] == '#' and not row in tmp_r and not col in tmp_c else 0
    return ret == K

def solve():
    ret = 0
    for ri in range(pow(2, H)):
        tmp_r = []
        for rj in range(H):
            if ri >> rj & 1:
                tmp_r.append(rj)
        for ci in range(pow(2, W)):
            tmp_c = []
            for cj in range(W):
                if ci >> cj & 1:
                    tmp_c.append(cj)

            ret += 1 if isValid(tmp_r, tmp_c) else 0
    print(ret)

if __name__ == "__main__":
    H, W, K = map(int, input().split())
    c = []
    for _ in range(H):
        c.append(list(input()))
    solve()

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

int main(){
    long long n;cin>>n;
    vector<long long> bricks(n+1);for (int i=1;i<n+1;i++){cin>>bricks[i];}

    long long acc, present_index;
    acc = 0;
    present_index = 1;
    for (auto brick: bricks){
        if (brick == present_index){
            present_index++;
        } else {
            acc++;
        }
    }
    if (acc == n+1){
        cout << -1 << endl;
    } else {
        cout << acc - 1 << endl;
    }
    return 0;
}

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

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;

#define fi first
#define se second
#define repl(i,a,b) for(ll i=(ll)(a);i<(ll)(b);i++)
#define rep(i,n) repl(i,0,n)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define mmax(x,y) (x>y?x:y)
#define mmin(x,y) (x<y?x:y)
#define maxch(x,y) x=mmax(x,y)
#define minch(x,y) x=mmin(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt __builtin_popcountll

#define INF 1e16
#define mod 1000000007

ll N;
ll A[510][510];
ll lpsum[510][510];
ll psum[510][510],nsum[510][510];
ll dp[510][510];

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

  cin>>N;
  ll tot=0;
  rep(i,N){
    rep(j,N){
      if(i==j)continue;
      cin>>A[i][j];
      tot+=A[i][j];
    }
  }

  rep(i,N){
    repl(j,i+1,N){
      lpsum[i][j]=lpsum[i][j-1]+A[j][i];
    }
    for(ll j=i-1;j>=0;j--){
      psum[j][i]=psum[j+1][i]+A[i][j];
    }
    for(ll j=i-1;j>=0;j--){
      nsum[j][i]=nsum[j+1][i]+A[j][i];
    }
  }

  ll res=0;
  rep(i,N)rep(j,N)dp[i][j]=-INF;
  repl(i,1,N){
    dp[i][0]=psum[0][i]+nsum[0][i];
    for(ll j=i-1;j>=0;j--){
      dp[i][0]+=psum[0][j];
    }

    ll crt=dp[i][0];
    repl(k,i+1,N){
      crt+=nsum[0][k]-nsum[i][k];
      crt+=psum[0][k];
    }
    maxch(res,crt);
  }

  repl(i,1,N)repl(j,1,i){
    ll vp=psum[j][i];
    for(ll k=i-1;k>=j;k--){
      vp+=lpsum[k][i-1];
    }
    ll vn=nsum[0][i];
    for(ll k=i-1;k>j;k--){
      vn+=nsum[0][k]-nsum[j][k];
    }
    for(ll k=j-1;k>=0;k--){
      vp+=lpsum[k][i-1]-lpsum[k][j];
      maxch(dp[i][j],dp[j][k]+vp+vn);
    }

    ll crt=dp[i][j];
    repl(k,i+1,N){
      crt+=nsum[0][k]-nsum[i][k];
      crt+=psum[j][k];
    }
    maxch(res,crt);
  }

  cout<<tot-res<<endl;

  return 0;
}


Measured memory_bytes: 10368
#include<iostream>
#include<vector>
#include<map>
#include<algorithm>
#include<math.h>
#include<queue>
#include<stack>
#include<iomanip>
#include<cstring>
#include<string>
#include<set>

#define REP(i, n) for (int i = 0; i < n; i++)
#define ALL(v) v.begin(), v.end()

using namespace std;
using ll = long long int;

const ll INF = 1<<30;
const ll LINF = 1LL<<60;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int main(void) {
    int n, k; cin >> n >> k;
    vector<int> a(n);
    REP(i, n) cin >> a[i];
    if (k > 41) {
        cout << n;
        REP(i, n - 1) cout << " " << n;
        cout << endl;
    }
    else {
        REP(j, k) {
            vector<int> b(n, 0);
            REP(i, n) {
                int l = max(0, i - a[i]);
                int r = min(n - 1, i + a[i]);
                b[l]++;
                if (r + 1 < n) b[r + 1]--;
            }
            for (int i = 1; i < n; i++) b[i] += b[i - 1];
            REP(i, n) a[i] = b[i];
        }
        cout << a[0];
        for (int i = 1; i < n; i++) cout << " " << a[i];
        cout << endl;
    }
}

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

int main() {
 int N,K;
  cin >> N>> K;
  int sum=0;
  int count[150]={0};
  int d[150];
  int A[150];
  for (int i=0;i<K;i++){
    cin>>d[i];
    for (int m=0;m<d[i];m++){
      cin >> A[m];
      count[A[m]-1]++;
    }
  }
  for(int l=0;l<N;l++){
    if(count[l]==0){
      sum++;
    }
  }
  cout <<sum <<endl;
      
  
}

Measured memory_bytes: 3624
/**
 *    Coded by : lucky_21
 *               --------Lokesh Singh
**/

#include<bits/stdc++.h>
using namespace std;

#include<ext/pb_ds/tree_policy.hpp>
#include<ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
template<class T> using oset=tree<T,null_type,less<T>,rb_tree_tag,tree_order_statistics_node_update>;

#define     F           first
#define     S           second
#define     pb          push_back
#define     lb          lower_bound
#define     ub          upper_bound
#define     pii         pair<int,int>
#define     all(x)      x.begin(),x.end()
#define     fix         fixed<<setprecision(10)
#define     rep(i,a,b)  for(int i=int(a);i<=int(b);i++)
#define     repb(i,b,a) for(int i=int(b);i>=int(a);i--)
#define     FastIO      ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)

typedef double db;
typedef long long ll;

const int N=2e5+5;
const int mod=1e9+7;

signed main(){
    FastIO;
    int n;
    string s;
    cin>>n>>s;
    map<char,vector<int>>m;
    rep(i,0,n-1) m[s[i]].pb(i);
    string tp="BGR";
    ll ans=0;
    do{
        for(int i:m[tp[0]]){
            for(auto it=lb(all(m[tp[1]]),i);it!=m[tp[1]].end();it++){
                ans+=m[tp[2]].end()-lb(all(m[tp[2]]),*it);
                if(2*(*it)-i<n and s[2*(*it)-i]==tp[2]) ans--;
            }
        }
    }
    while(next_permutation(all(tp)));
    cout<<ans;
    return 0;
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rrep(i, n) for (int i = (int)(n - 1); i >= 0; i--)
#define all(x) (x).begin(), (x).end()
#define sz(x) int(x.size())
#define get_unique(x) x.erase(unique(all(x)), x.end());
typedef long long ll;
typedef complex<double> Complex;
const int INF = 1e9;
const ll MOD = 1e9 + 7;
const ll LINF = 1e18;
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;
}
template <class T>
vector<T> make_vec(size_t a) {
    return vector<T>(a);
}
template <class T, class... Ts>
auto make_vec(size_t a, Ts... ts) {
    return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}
template <typename T>
ostream& operator<<(ostream& os, vector<T> v) {
    for (int i = 0; i < sz(v); i++) {
        os << v[i];
        if (i < sz(v) - 1) os << " ";
    }
    return os;
}
void hakidashi(vector<ll>& v) {
    int pos = 0;
    for (int d = 60; d >= 0; d--) {
        bool flg = 0;
        for (int i = pos; i < sz(v); i++) {
            if (!(v[i] >> d & 1)) continue;
            flg = 1;
            swap(v[pos], v[i]);
            break;
        }

        for (int i = pos + 1; i < sz(v); i++) {
            if (v[i] >> d & 1) v[i] ^= v[pos];
        }
        if (flg) pos++;
    }
}
bool isin(vector<ll> v, ll bit) {
    ll ret = 0;
    for (ll x : v) {
        for (int d = 60; d >= 0; d--) {
            if (x >> d & 1) {
                if ((bit >> d & 1) ^ (ret >> d & 1)) ret ^= x;
                break;
            }
        }
    }
    return ret == bit;
}
int main() {
    int tt;
    cin >> tt;
    while (tt--) {
        int n;
        cin >> n;
        vector<ll> a(n);
        rep(i, n) cin >> a[i];
        string s;
        cin >> s;
        int ans = 0;
        vector<vector<ll>> dp(220);
        dp[n] = {0};
        for (int i = n - 1; i >= 0; i--) {
            if (s[i] == '0') {
                dp[i] = dp[i + 1];
                for (ll x : dp[i + 1]) dp[i].push_back(a[i] ^ x);
                hakidashi(dp[i]);
                dp[i].resize(64);
            } else {
                if (isin(dp[i + 1], a[i]))
                    dp[i] = dp[i + 1];
                else
                    ans = 1;
            }
        }
        cout << ans << endl;
    }
}


Measured memory_bytes: 3840
use whiteread::parse_line;

fn main() {
    let n: usize = parse_line().unwrap();
    let mut s: Vec<u32> = Vec::new();
    for _ in 0..n {
        s.push(parse_line().unwrap());
    }
    let mut ans = s.iter().sum();

    if ans % 10 == 0 {
        s.sort();
        if let Some(i) = s.iter().find(|&x| x % 10 != 0) {
            ans -= i;
        } else {
            ans = 0;
        }
    }
    println!("{}", ans);
}


Measured memory_bytes: 2100
#include<bits/stdc++.h>
#include <iostream>
#include <string>
#include <cmath>
using namespace std;
#define ll long long
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define FORR(i,a,b)for(ll i=(a);i<=(b);i++)
#define repR(i,n) for(ll i=n;i>=0;i--)
#define all(v)(v).begin(),(v).end()
#define rall(v)(v).rbegin(),(v).rend()
#define F first
#define S second
#define pb push_back
#define pu push
#define COUT(x) cout<<(x)<<endl
#define PQ priority_queue<ll>
#define PQR priority_queue<ll,vector<ll>,greater<ll>>
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define mp make_pair
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define sz(x) (int)(x).size()
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const ll MOD = 1000000007LL;
const ll INF = 1LL << 60;
using vll = vector<ll>;
using vb = vector<bool>;
using vvb = vector<vb>;
using vvll = vector<vll>;
using vstr = vector<string>;
using pll = pair<ll, ll>;
using vc = vector<char>;
using vvc = vector<vc>;
ll dx[4]={0,1,0,-1};
ll dy[4]={1,0,-1,0};
int main(){
  string a,b,c;
  ll n,k;
  cin>>a>>b;
  cin>>n>>k;
  cin>>c;
  if(a==c){
    cout<<n-1<<" "<<k<<endl;
  }
  else{
    cout<<n<<" "<<k-1<<endl;
  }
}

Measured memory_bytes: 256
#include<iostream>

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

    std::cin >> a >> b >> c;

    char flag;
    int max = a; flag = 'a';
    if(max < b) {max = b; flag = 'b';}
    if(max < c) {max = c; flag = 'c';}
    int count;
    if(flag == 'a'){count = a*10 + b + c;}
    if(flag == 'b'){count = b*10 + a + c;}
    if(flag == 'c'){count = c*10 + a + b;}

    std::cout << count << '\n';
    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 M = sc.nextInt();
		int C = sc.nextInt();
		int B[] = new int[M];
		int A[][] = new int [N][M];
		int counter =0;
		for(int i=0; i<M;i++) {
			B[i] = sc.nextInt();
		}
		for(int i = 0; i<N; i++) {
			for(int j = 0; j<M; j++) {
				A[i][j] = sc.nextInt();
			}
		}
		
		for(int i =0; i<N; i++) {
			int sum =0;
			for(int j = 0; j<M; j++) {
				int K = A[i][j]*B[j];
				sum+=K;
			}
			sum+=C;
			if(sum>0)counter++;
		}
		System.out.println(counter);
		
		
		
		
	}}

Measured memory_bytes: 22356
#include <bits/stdc++.h>
using namespace std;
const int MaxN = 50;
typedef pair<int,int> PII;
PII op[2*MaxN+1];int tot;
int n,a[MaxN+3];

int main() {
    scanf("%d",&n);for (int i=1;i<=n;++i) scanf("%d",a+i);
    int s0=0,s1=0;
    for (int i=1;i<=n;++i) if (a[i]<0) s0-=a[i];else s1+=a[i];
    a[n+1]=0x80000000,a[0]=0x7fffffff;
    if (s0<s1) { //positive
        int mn=0,mx=n+1;
        while (true) {
            for (int i=1;i<=n;++i) {
                if (a[i]<a[mn]) mn=i;
                if (a[i]>a[mx]) mx=i;
            }
            if (a[mn]<0) op[++tot]=PII(mx,mn),a[mn]+=a[mx];
            else break;
        }
        for (int i=1;i<n;++i) op[++tot]=PII(i,i+1);
    } else {
        int mn=0,mx=n+1;
        while (true) {
            for (int i=1;i<=n;++i) {
                if (a[i]<a[mn]) mn=i;
                if (a[i]>a[mx]) mx=i;
            }
            if (a[mx]>0) op[++tot]=PII(mn,mx),a[mx]+=a[mn];
            else break;
        }
        for (int i=n;i>1;--i) op[++tot]=PII(i,i-1);
    }
    printf("%d\n",tot);
    for (int i=1;i<=tot;++i) printf("%d %d\n",op[i].first,op[i].second);
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using lint = long long int;
template<class T = int> using V = vector<T>;
template<class T = int> using VV = V< V<T> >;
template<class T> void assign(V<T>& v, int n, const T& a = T()) { v.assign(n, a); }
template<class T, class... Args> void assign(V<T>& v, int n, const Args&... args) { v.resize(n); for (auto&& e : v) assign(e, args...); }


int main() {
  cin.tie(nullptr); ios::sync_with_stdio(false);
  int n; cin >> n;
  lint v; cin >> v;
  V<lint> a(n); for (int i = 0; i < n; ++i) cin >> a[i];
  V<lint> b(n); for (int i = 0; i < n; ++i) cin >> b[i];
  V<lint> c(n); for (int i = 0; i < n; ++i) cin >> c[i];
  V<lint> d(n); for (int i = 0; i < n; ++i) cin >> d[i];
  V<lint> ab(n * n);
  for (int i = 0; i < n; ++i) for (int j = 0; j < n; ++j) ab[n * i + j] = a[i] + b[j];
  V<lint> cd(n * n);
  for (int i = 0; i < n; ++i) for (int j = 0; j < n; ++j) cd[n * i + j] = c[i] + d[j];
  sort(begin(ab), end(ab));
  sort(begin(cd), end(cd));
  lint res = 0;
  for (lint e : ab) res += distance(lower_bound(begin(cd), end(cd), v - e), upper_bound(begin(cd), end(cd), v - e));
  cout << res << '\n';
}


Measured memory_bytes: 18404
s=input()
a=int(s[:2])
b=int(s[2:])
l=list(range(1,13))
ans="NA"
if a not in l and b in l:
    ans="YYMM"
elif a in l and b not in l:
    ans="MMYY"
elif a in l and b in l:
    ans="AMBIGUOUS"
print(ans)

Measured memory_bytes: 3064
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cstring>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <numeric>
#include <utility>
#include <iomanip>
#include <algorithm>
#include <functional>
#include <unordered_map>
using namespace std;

#define REP(i, s) for (int i = 0; i < s; ++i)
#define ALL(v) (v.begin(), v.end())
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }
template<class T> ostream& operator << (ostream &s, set<T> P)
{ EACH(it, P) { s << "<" << *it << "> "; } return s << endl; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P)
{ EACH(it, P) { s << "<" << it->first << "->" << it->second << "> "; } return s << endl; }


vector<vector<int> > G;

bool isbi = true;
bool seen[210000];
int Left[210000];
void dfs(int v, int dir) {
    seen[v] = true;
    Left[v] = dir;
    for (auto e : G[v]) {
        if (seen[e]) {
            if (Left[e] != 1 - dir) isbi = false;
            continue;
        }
        dfs(e, 1 - dir);
    }
}

int N, M;
int main() {
    while (cin >> N >> M) {
        G.clear(); G.resize(N);
        for (int i = 0; i < M; ++i) {
            int a, b; cin >> a >> b; --a, --b;
            G[a].push_back(b);
            G[b].push_back(a);
        }
        long long S = 0;
        long long BN = 0;
        long long NBN = 0;
        memset(seen, 0, sizeof(seen));
        memset(Left, -1, sizeof(Left));
        for (int v = 0; v < N; ++v) {
            if (seen[v]) continue;
            if (G[v].size() == 0) {
                ++S;
                continue;
            }
            isbi = true;
            dfs(v, 0);
            if (isbi) ++BN;
            else ++NBN;
        }
        
        long long res = (BN + NBN) * (BN + NBN);
        res += BN * BN;
        res += (S * N) * 2 - S * S;
        
        //COUT(S); COUT(BN); COUT(NBN);
        
        cout << res << endl;
    }
}










Measured memory_bytes: 9728
import math
def is_prime(n):
    if n == 1: return False
    for k in range(2, int(math.sqrt(n)) + 1):
        if n % k == 0:
            return False
    return True
Q = int(input())
ans = [0] * (10**5+1)
prime = [0] * (10**5+1)
for i in range(1,10**5+1):
    if is_prime(i):
        prime[i] = 1
        if prime[(i+1)//2] == 1:
            ans[i] = ans[i-1] + 1
            continue
    ans[i] = ans[i-1]
disp_ans = 0
for i in range(Q):
    l, r = map(int, input().split())
    print(ans[r]-ans[l-1])

Measured memory_bytes: 4980
use std::io::*;
use std::str::FromStr;

// https://qiita.com/tubo28/items/e6076e9040da57368845
fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
  let line: String = read();
  let replaced = line.replace("2017/01", "2018/01");
  println!("{}", replaced);
}


Measured memory_bytes: 4352
// ------------------------------------
// Date:2018/ 3/17
// Problem:_ _ _ a.cpp
//
// ------------------------------------

#include <bits/stdc++.h>

using namespace std;

#define EACH(i,a) for (auto& i : a)
#define FOR(i,a,b) for(int i=(int)a;i<(int)b;++i)
#define RFOR(i,a,b) for(int i=(int)b-1;i>=(int)a;--i)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define ALL(a) (a).begin(),(a).end()
#define debug(x) cerr << #x << ":" << x << endl

typedef long long ll;

void CINT(){}
template <class Head,class... Tail>
void CINT(Head&& head,Tail&&... tail) {
  cin >> head; CINT(move(tail)...);
}
#define CIN(...) int __VA_ARGS__;CINT(__VA_ARGS__)
#define LCIN(...) ll __VA_ARGS__;CINT(__VA_ARGS__)
#define SCIN(...) string __VA_ARGS__;CINT(__VA_ARGS__)

static const int MOD = 1e9 + 7;
static const int MAX_N = 1;

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


  CIN(a, b, c);
  bool ok = false;
  if (a + b  >= c) ok = true;
  cout << (ok ? "Yes" : "No") << endl;

  return 0;
}



Measured memory_bytes: 256