akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <iostream>
#include <cmath>
#include <vector>

struct IsPrime {
 public:
   explicit IsPrime(int max);
   ~IsPrime() {};

   bool operator()(int n);

 private:
   std::vector<bool> is_prime;
};

IsPrime::IsPrime(int max) : is_prime(max + 1, true){
  for (auto i = 2; i <= std::sqrt(max); i++) {
    if (is_prime[i]) {
      for (int mult = 2 * i; mult <= max; mult += i) {
        is_prime[mult] = false;
      }
    }
  }
};

bool IsPrime::operator()(int n) {
  return is_prime[n];
}

std::vector<int> fetchInput() {
  int count;
  std::cin >> count;

  std::vector<int> inputs{};

  for (auto i = 0; i < count; i++) {
    int n;
    std::cin >> n;
    inputs.push_back(n);
  }

  return inputs;
}

int main(void) {
  auto inputs = fetchInput();
  auto max = *std::max_element(inputs.begin(), inputs.end());
  IsPrime is_prime{max};

  auto prime_cnt = 0;
  for (auto n: inputs) {
    if (is_prime(n)) {
      prime_cnt++;
    }
  }

  std::cout << prime_cnt << '\n';
  return 0;
}

Measured memory_bytes: 15124
#include <bits/stdc++.h>
using namespace std;
int main() {
  int K; cin >> K;
  long x = 0;
  for(int i = 1; i <= K; i++) {
    for(int j = 1; j <= K; j++) {
      for(int k = 1; k <= K; k++) {
        x += __gcd(__gcd(i, j), k);
      }
    }
  }
  cout << x << endl;
}

Measured memory_bytes: 3624
import sys

def main():
    N = int(sys.stdin.readline())
    a = list(map(int, input().split()))
    n = [0 for i in range(0, max(a)+1)]
    for i in a:
        n[i] += 1
    if len(n) < 3:
        print(sum(n))
    else:
        print(max([i+j+k for i, j, k in zip(n[:-2], n[1:-1], n[2:])]))

if __name__ == '__main__':
    main()


Measured memory_bytes: 13964
#include "iostream"
#include "vector"
#include "string"
#include "algorithm"
#include "math.h"
#include "cstring"
#include "stack"
#include "queue"

using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<vector<int> > mat;
ll mod = 1e9 + 7;

int main()
{
  int n, m;
  cin >> n >> m;
  ll x[100100];
  ll xans = 0;
  for (int i = 0; i < n; i++)
  {
    cin >> x[i];
    xans += x[i] * (2 * i - n + 1);
    xans %= mod;
  }
  ll y[100100];
  ll yans = 0;
  for (int i = 0; i < m; i++)
  {
    cin >> y[i];
    yans += y[i] * (2 * i - m + 1);
    yans %= mod;
  }
  cout << (xans * yans + mod) % mod << "\n";
}

Measured memory_bytes: 1792
fun main(args: Array<String>) {
	val n = readLine()!!.toInt()
	val ans = mutableListOf<Int>()

	for (i in 1 .. n) {
		var x = i
		while (x != 0) {
			if (x % 10 == 3 || i % 3 == 0) {
				ans.add(i)
				break
			}
			x /= 10
		}
	}
	println(" " + ans.joinToString(" "))
}



Measured memory_bytes: 28776
#!usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS():return [list(x) for x in sys.stdin.readline().split()]
def S():
    res = list(sys.stdin.readline())
    if res[-1] == "\n":
        return res[:-1]
    return res
def IR(n):
    return [I() for i in range(n)]
def LIR(n):
    return [LI() for i in range(n)]
def SR(n):
    return [S() for i in range(n)]
def LSR(n):
    return [LS() for i in range(n)]

sys.setrecursionlimit(1000000)
mod = 1000000007

def solve():
    t = LI()
    a = LI()
    b = LI()
    a[0] -= b[0]
    a[1] -= b[1]
    if t[0]*a[0] == -t[1]*a[1]:
        print("infinity")
        return
    if a[0] < 0:
        a[0] *= -1
        a[1] *= -1
    if t[0]*a[0]+t[1]*a[1] > 0:
        print(0)
        return
    l = 0
    r = 10**100
    A = t[0]*a[0]+t[1]*a[1]
    while r-l > 1:
        m = (l+r) >> 1
        x = m*A
        y = x+t[0]*a[0]
        if x*y <= 0:
            l = m
        else:
            r = m
    ans = r*2-1
    if l*A+t[0]*a[0] == 0:
        ans -= 1
    print(ans)
    return

#Solve
if __name__ == "__main__":
    solve()


Measured memory_bytes: 38576
#include <bits/stdc++.h>
#define INF 1000000000000
using namespace std;

int main() {
int N,W;
  int64_t ans=0;
cin>>N>>W;
vector<pair<int,int>> A(N);
for(int i=0; i<N; i++){cin >> A[i].first>>A[i].second;}
vector<vector<int64_t>> dp(N+1,vector<int64_t>(1e5+1));
//for(int i=0;i<=N;i++){
for(int j=0; j<=1e5;j++){ dp[0][j]=INF;}
  dp[0][0]=0;
for(int i=0;i<N;i++){
for(int j=0; j<=1e5;j++){
if(A[i].second>j)dp[i+1][j]=dp[i][j];
else dp[i+1][j]=min(dp[i][j],dp[i][j-A[i].second]+A[i].first);}}
  for(int j=0;j<1e5+1;j++){
    if(dp[N][j]<=W&&j>ans)ans=j;}
cout<<ans<<endl;
}

Measured memory_bytes: 80256
public class Main {
	public static void main(String[] args){
		java.util.Scanner sc = new java.util.Scanner (System.in);
			int a = sc.nextInt();
			int b = sc.nextInt();
			int c = sc.nextInt();
			if(a < b && b < c){
				System.out.println("Yes");
			}else {
				System.out.println("No");
			}
	}
}

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

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

using namespace std;

vector<int> mfprime;

void make_mfprime(){
  bool is_mfprime[300002];
  REP(i, 300002) is_mfprime[i] = true;
  REP(i, 300002){
    if(i == 0 or i == 1 or (i % 7 != 1 and i % 7 != 6)) is_mfprime[i] = false;
    if(is_mfprime[i]){
      REP(j, 300002){
        if(j == 0 or j == 1) continue;
        if(i * j > 300002) break;
        is_mfprime[i*j] = false;
      }
    }
  }
  REP(i, 300002) if(is_mfprime[i]) mfprime.push_back(i);
}

int main(){
  int n;
  make_mfprime();
  while(cin >> n and n != 1){
    bool first = true;
    cout << n << ": ";
    REP(i, mfprime.size()) {
      if(n % mfprime[i] == 0){
        if(!first) cout << " ";
         cout << mfprime[i];
        first = false;
      }
    }
    cout << endl;
  }
  return 0;
}

Measured memory_bytes: 3480
#include<iostream>
using namespace std;
bool check(char x){
    char a[12]="yuiophjklnm";
    for(int i=0;i<11;i++)if(a[i]==x)return true;
    return false;
}
int main(){
    string s;
    while(cin>>s,s!="#"){
        bool now = check(s[0]);
        int ans = 0;
        for(int i=1;i<s.size();i++){
            if(check(s[i]) != now)ans++,now = 1 - now;
        }
        cout<<ans<<endl;
    }
    return 0;
}

Measured memory_bytes: 1184
#include<iostream>
#include<vector>
using namespace std;
int main(){
	int n,k;
	cin>>n>>k;
	vector<int> brojevi(n);
	vector<long long > sume(n);
	vector<long long> psume(n);
	cin>>brojevi[0];
	sume[0]=brojevi[0];
	if(brojevi[0]>=0) psume[0]=brojevi[0];
	for(int i=1;i<n;i++){
		cin>>brojevi[i];
		sume[i]=sume[i-1]+brojevi[i];
		psume[i]=psume[i-1]+brojevi[i];
		if(psume[i]<psume[i-1]) psume[i]=psume[i-1];
	}
	long long sol=0;
	long long temp=0;
	for(int i=0;i<=n-k;i++){
		temp=0;
		if(i>0){
			temp+=psume[i-1];
		}
		
		 temp+=psume[psume.size()-1]-psume[i+k-1];
		if(i>0){
			if(sume[i+k-1]-sume[i-1]>0) temp+=sume[i+k-1]-sume[i-1];
		}
		else{
			if(sume[i+k-1]>0) temp+=sume[i+k-1];
		}
		if(temp>sol) sol=temp;
	}
	cout<<sol;
}

Measured memory_bytes: 2176
n = int(input())
ans=0
if n == 1:
  print(0)
  quit()

#test = 0
#for i in range(1, n):
#  if n//i == n%i:
#    test+=i
#print(test)
  
for i in range(1, n):
  #余り、商がi
  temp=n-i
  syou=temp/i
  #print(syou)
  if syou>i:
    if syou.is_integer():
      ans+=int(syou)
  else:
    break
print(ans)

Measured memory_bytes: 73464
#!/usr/bin/env perl
use strict;
use warnings;
use POSIX qw(floor);


chomp ( my $hp = <STDIN> );

my $attacks = 0;

my $log = log($hp) / log(2);
my $step = floor($log) + 1;

$attacks = (2 ** $step) - 1;

print "$attacks\n";


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

using namespace std;

const int inf = 0x7f7f7f7f;
const int N = 15;

int n, m, all;
int dis[N][N];
int dp[1 << N][N], sum[1 << N];

void checkMax(int& ret, const int& cp) {
  if (ret < cp)
    ret = cp;
}

int main()
{
  ios::sync_with_stdio(false);
  cin >> n >> m;
  memset(dis, -1, sizeof(dis));
  for (int i = 0; i < n; ++i)
    dis[i][i] = 0;
  for (int i = 0; i < m; ++i) {
    int u, v, c;
    cin >> u >> v >> c;
    --u; --v;
    all += dis[u][v] = dis[v][u] = c;
  }
  for (int i = 0; i < 1 << n; ++i) {
    sum[i] = 0;
    for (int j = 0; j < n; ++j) {
      if ((i & 1 << j) == 0)
        continue;
      for (int k = j + 1; k < n; ++k)
        if ((i & 1 << k) != 0 && dis[j][k] != -1)
          sum[i] += dis[j][k];
    }
  }
  memset(dp, -1, sizeof(dp));
  for (int i = 1; i < 1 << n; i += 2)
    dp[i][0] = sum[i];
  for (int i = 0; i < 1 << n; ++i) {
    for (int j = 0; j < n; ++j) {
      if ((i & 1 << j) == 0 || dp[i][j] == -1)
        continue;
      for (int k = 0; k < n; ++k) {
        if (dis[j][k] == -1 || (i & 1 << k) != 0)
          continue;
        int u = i | (1 << k);
        int add = (1 << n) - 1 ^ u;
        for (int v = add; v >= 0; --v) {
          v &= add;
          checkMax(dp[u | v][k], dp[i][j] + dis[j][k] + sum[v | 1 << k]);
        }
      }
    }
  }
  cout << sum[(1 << n) - 1] - dp[(1 << n) - 1][n - 1] << '\n';
  return 0;
}

Measured memory_bytes: 2304
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>

typedef long long ll;

const ll mod=1e9+7;

#define all(x) x.begin(),x.end()
#define allr(x) x.rbegin(),x.rend()
#define rc(x)  return cout<<x<<"\n",0
#define sz(s)  (int) s.size()
#define pb push_back
#define mp make_pair
#define fr first
#define sc second

using namespace std;

const int nax=3005;
ll dp[nax][nax];

ll t,n;

int main() {
ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	cin >> n;
	int a[n+5];
	for (int i=0; i<n; i++) {
		cin >> a[i];
	}
	for (int l=n-1; l>=0; l--) {
		for (int r=l; r<=n-1; r++) {
			if (l==r) {
				dp[l][r]=a[l];
			}
			else {
				dp[l][r]=max(a[l]-dp[l+1][r],a[r]-dp[l][r-1]);
			}
		}
	}
	cout << dp[0][n-1];	
}


Measured memory_bytes: 70016
#include <iostream> 
#include <cstdio> 
#include <cstdlib> 
#include <cstring> 
#include <cmath> 
#include <algorithm>
#include <vector>
#include <queue> 
using namespace std; 
inline int gi() { 
    register int data = 0, w = 1; 
    register char ch = 0; 
    while (!isdigit(ch) && ch != '-') ch = getchar(); 
    if (ch == '-') w = -1, ch = getchar(); 
    while (isdigit(ch)) data = 10 * data + ch - '0', ch = getchar(); 
    return w * data; 
} 
const int MAX_N = 2e3 + 5; 
int N, a[MAX_N], deg[MAX_N]; 
bool vis[MAX_N], Link[MAX_N][MAX_N]; 
vector<int> G[MAX_N]; 
void dfs(int x) { 
	vis[x] = 1; 
	for (int i = 1; i <= N; i++) if (!vis[i] && Link[x][i]) ++deg[i], G[x].push_back(i), dfs(i); 
} 
void TopSort() { 
	priority_queue<int> que; 
	for (int i = 1; i <= N; i++) if (!deg[i]) que.push(i); 
	while (!que.empty()) { 
		int x = que.top(); que.pop();
		printf("%d ", a[x]); 
		for (auto v : G[x]) que.push(v); 
	}
	putchar('\n'); 
} 

int main () {
	N = gi(); for (int i = 1; i <= N; i++) a[i] = gi(); 
	sort(&a[1], &a[N + 1]); 
	for (int i = 1; i <= N; i++)
		for (int j = i + 1; j <= N; j++) 
			if (__gcd(a[i], a[j]) != 1) Link[i][j] = Link[j][i] = 1; 
	for (int i = 1; i <= N; i++) if (!vis[i]) dfs(i); 
	TopSort(); 
	return 0; 
} 

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

int main() {
    int N, K;
    cin >> N >> K;
    int* h = new int[N];
    int count = 0;
    for (int i = 0; i < N; i++) {
        cin >> h[i];
        if (h[i] >= K) {
            count++;
        }
    }
    cout << count << endl;
}

Measured memory_bytes: 640
def main():
    A = []
    for _ in range(3):
        a1,a2,a3 = map(int, input().split()) 
        AA = [[a1,0],[a2,0],[a3,0]]
        A.append(AA)
    N = int(input())
    # print(A)

    for _ in range(N):
        b = int(input())
        for i in range(3):
            for j in range(3):
                if A[i][j][0] == b:
                    A[i][j][1] = 1
        
        # row
        for i in range(3):
            if 3 == sum([v[1] for v in A[i]]):
                print('Yes')
                return
        # column
        for j in range(3):
            if 3 == sum([a[j][1] for a in A]):
                print('Yes')
                return
        # cross
        if 3 == (A[0][0][1]+A[1][1][1]+A[2][2][1]):
            print('Yes')
            return
        if 3 == (A[0][2][1]+A[1][1][1]+A[2][0][1]):
            print('Yes')
            return

    print('No')
        

main()

Measured memory_bytes: 3064
#include<iostream>
#include<algorithm>
using namespace std;int t[1024],i,j,k,r,c,a[10000],m,z;main(){for(;i<1024;t[i++]=k)for(k=j=10;j--;i&1<<j||--k);for(;cin>>r>>c,i=r;cout<<m<<'\n'){for(fill(a,a+c,m=0);i--;)for(j=c;j--;k?a[j]|=1<<i:0)cin>>k;for(i=1<<r;i--;z=0)for(j=c;j--;m=max(m,z+=max(r-k,k=t[a[j]^i])));}}

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

int c[8];

class DICE{
public:
    void setdice(char a);
};

void DICE::setdice(char a){
    if(a == 'S'){
        c[7] = c[1];
        c[1] = c[5];
        c[5] = c[6];
        c[6] = c[2];
        c[2] = c[7];
    }
    else if(a == 'W'){
        c[7] = c[1];
        c[1] = c[3];
        c[3] = c[6];
        c[6] = c[4];
        c[4] = c[7];
    }
    else if(a == 'N'){
        c[7] = c[1];
        c[1] = c[2];
        c[2] = c[6];
        c[6] = c[5];
        c[5] = c[7];
    }
    else{
        c[7] = c[1];
        c[1] = c[4];
        c[4] = c[6];
        c[6] = c[3];
        c[3] = c[7];
    }
}

int main(void){
    string std;
    DICE dice;
    for(int i = 1; i <= 6; i++){
        cin >> c[i];
    }
    cin >> std;
    for(int i = 0; i < std.size(); i++){
        dice.setdice(std[i]);
    }
    cout << c[1] << endl;
    
    return 0;
}



Measured memory_bytes: 3164
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>


using namespace std;

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

	int ans;
	ans = (t) / a * b;
	cout << ans << endl;
	return 0;
}



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

using namespace std;

typedef long long ll;

const int MAX_H = 105;
const int MAX_G = 35;

int arr [MAX_H];
int cov [MAX_H];

int n;
ll ans;
vector<int> cur;
void dfs () {
  ll cans = 0;

  for (int i = 1; i <= min(n, MAX_G - 1); i++) {
    if (cov[i] == 0) cans += arr[i];
  }

  for (int i = MAX_G; i <= n; i++) {
    if (!cov[i] && 2 * i <= n) {
      if (cov[2 * i]) {
        if (arr[i] > 0) {
          cans += arr[i];
        }
      } else {
        cans += max(arr[i] + arr[2 * i], max(arr[i], 0));
      }
    } else if (!(i % 2 == 0 && i / 2 >= MAX_G)) {
      if (!cov[i] && arr[i] > 0) {
        cans += arr[i];
      }
    }
  }
  ans = max(ans, cans);
  
  int bk = cur.empty() ? 1 : cur.back() + 1;
  for (int i = bk; i < MAX_G; i++) {
    if (!cov[i]) {
      for (int j = i; j < MAX_H; j += i) {
        cov[j]++;
      }
      cur.push_back(i);

      dfs();
      
      cur.pop_back();
      for (int j = i; j < MAX_H; j += i) {
        cov[j]--;
      }
    }
  }
}

int main () {
  ios::sync_with_stdio(false);

  cin >> n;
  for (int i = 1; i <= n; i++) {
    cin >> arr[i];
  }
  
  dfs();

  cout << ans << endl;
}


Measured memory_bytes: 256
import sys
sys.setrecursionlimit(500000)

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

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

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

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


def main():
    N = ii()
    S = [input() for i in range(N)]
    ac = 0
    wa = 0
    tle = 0
    re = 0
    for i in range(N):
        if S[i] == 'AC':
            ac += 1
        if S[i] == 'TLE':
            tle += 1
        if S[i] == 'WA':
            wa += 1
        if S[i] == 'RE':
            re += 1

    print('AC x', ac)
    print('WA x', wa)
    print('TLE x', tle)
    print('RE x', re)


if __name__ == '__main__':
    main()


Measured memory_bytes: 74484
#include <cstdio>
#include <cstring>

#define rep(i,n) for(int i=0;i<(n);i++)

using namespace std;

int main(){
	int n;
	scanf("%d",&n);

	int ans=0;
	for(int i=1;i<=n;i++){
		char s[8];
		sprintf(s,"%d",i);
		if(strlen(s)%2==1) ans++;
	}
	printf("%d\n",ans);

	return 0;
}


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

int main(){
	int n;
	cin >> n;
	for(int i = 1;i<=n ;i++){
		double x[5];
		double y[5];
		for(int j= 1;j<=4;j++) {
			cin >> x[j];
			cin >> y[j];
		}
		if ((y[2]-y[1])*(x[4]-x[3])==(y[4]-y[3])*(x[2]-x[1])) cout << "YES" << endl;
		else cout << "NO" << endl;
	}
	return 0;
}

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

using namespace std;

#define ALL(x) (x).begin(), (x).end()
#define ALLTRUE(xs) all_of(ALL(xs),[](bool x){return x;})
#define AND(x,y,z) set_intersection((x).begin(),(x).end(),(y).begin(),(y).end(),inserter((z),(z).end()))
#define ANYTRUE(xs) any_of(ALL(xs),[](bool x){return x;})
#define CONCAT(x,y) (x).insert((x).end(),(y).begin(),(y).end())
#define DUMP(xs) for (auto x:xs) cout<<x<<' ';cout<<endl
#define FOR(i,a,b) for (int i=(int)(a);i<(int)(b);++i)
#define OR(x,y,z) set_union((x).begin(),(x).end(),(y).begin(),(y).end(),inserter((z),(z).end()))
#define OUT(x) cout<<x<<endl
#define REP(i,n) FOR(i,0,n)

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

int main() {
  int H,W,N;cin>>H>>W>>N;
  vector<int> as(N);
  REP(i,N) cin>>as[i];

  int mas[H][W];
  int cur = 0;
  int tmp = 0;
  // 一筆書きで塗っていく
  REP(h,H) {
    if (h%2==1) {
      for (int w=W-1;w>=0;w--) {
        if (as[cur]==tmp) {
          cur++;
          tmp = 0;
        }
        mas[h][w] = cur+1;
        tmp++;
      }
    } else {
      REP(w,W) {
        if (as[cur]==tmp) {
          cur++;
          tmp = 0;
        }
        mas[h][w] = cur+1;
        tmp++;
      }
    }
  }
  REP(h,H) {
    DUMP(mas[h]);
  }

  return 0;
}

Measured memory_bytes: 384
import sys,collections,math,random,fractions,bisect;sys.setrecursionlimit(10**7)
sr = sys.stdin.readline; P = print; P2 = lambda x: print(*x, sep="\n")
def I(i=0): t = [int(x)-i for x in sr().split()];return t
def S(): t = sr().split(); return t if len(t) > 1 else t[0]
L1,L2,L3,L4, = [],[],[],[]
 
N = I()
a = I()
ans = "APPROVED"
for e in a:
    if e%2 == 0:
        if e/3 != e//3 and e/5 != e//5:
            ans = "DENIED"
            break
print(ans)


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

int main() {
    string s;
    cin >> s;
    vector<char> ans;
    rep (i, s.size()) {
        if (s.at(i) == 'B') {
            //ansの中ないときエラー出た
            if (ans.size() != 0) {
              ans.pop_back();
            }
        }
        else {
          ans.push_back(s.at(i));
        }
    }
    rep(i, ans.size()) {
        cout << ans.at(i); 
    }
    cout << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);++i)
using ll = long long;
using P = pair<int, int>;
#include<algorithm>
#include<math.h>
#include<map>
#include<queue>

int main() {
	int k, x;
	cin >> k >> x;
	int s = x - k + 1;
	int l = x + k - 1;
	for (int i = s; i <= l; ++i) {
		cout << i << " ";
	}
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <set>
#include <string>
#include <cstring>
#include <cmath>
#include <map>
#include <stack>
#define N 1005
using namespace std;
typedef long long ll;

int main()
{
    int n,y;
    while(scanf("%d%d",&n,&y)==2){
       int a=y/10000,s1=-1,s2=-1,s3=-1;
       for(int i=a;i>=0;i--){
        int j=(y-1000*n-9000*i)/4000;
        if(i*9000+4000*j==y-1000*n&&i+j<=n&&i>=0&&j>=0)
        {
            s1=i,s2=j,s3=n-i-j;
            break;
        }
       }
       printf("%d %d %d\n",s1,s2,s3);

    }
}


Measured memory_bytes: 256
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <chrono>
#include <climits>
#include <cmath>
#include <complex>
#include <cstddef>
#include <cstdint>
#include <cstdio>
#include <cstdlib>
#include <deque>
#include <forward_list>
#include <functional>
#include <initializer_list>
#include <iomanip>
#include <iostream>
#include <limits>
#include <list>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <random>
#include <regex>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
// using namespace std;
constexpr int64_t MOD = 1000000007;

int main()
{
	std::cin.tie(0);
	std::ios::sync_with_stdio(false);
	size_t N;
	std::cin >> N;
	std::vector<int> A(N, 0);
	for (size_t i = 0; i < N; i++) std::cin >> A[i];
	std::vector<int> id(N);
	for (size_t i = 0; i < N; i++) id[i] = i;
	std::sort(id.begin(), id.end(), [&A](int a, int b) { return A[a] != A[b] ? A[a] < A[b] : a > b; });
	std::set<int> col;
	for (auto& i: id)
	{
		auto it = col.lower_bound(i);
		if (it == col.begin())
			col.insert(i);
		else
		{
			col.erase(*(--it));
			col.insert(i);
		}
	}
	std::cout << col.size() << std::endl;
	// for (auto& i : col) std::cout << i << std::endl;
	std::cout << std::flush;
	return 0;
}


Measured memory_bytes: 5760
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
typedef long long ll;
int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  // AGC021A - Digit Sum
  // 最上位の桁を1減らしてあとは全て9にする
  // ただし、199のように二桁目以降が全て9ならそのままが答え
  // 1桁の場合もそれが答え
  string S;
  cin >> S;
  int N = S.size();
  int ans = 0;
  if(N == 1){
    cout << S << endl;
  }else{
    for(int i = 1; i < N; i++){
      if(S.at(i) - '0' != 9){
        ans += S.at(0) - '0' - 1;
        ans += 9 * (N - 1);
        cout << ans << endl;
        return 0;
      }
    }
    ans += S.at(0) - '0';
    ans += 9 * (N - 1);
    cout << ans << endl;   
  }
}

Measured memory_bytes: 256
#include<cstdio>
#include<bits/stdc++.h>
typedef long long int ll;
#define REP(i, n) for(int i = 0; i < (n); i++)
#define FOR_IN(i, a, b) for(int i = (a); i < (b); i++)
#define BETWEEN(x, a, b) ((x) >= (a) && (x) <= (b))
#define LOG(...) fprintf(stderr, __VA_ARGS__)

using namespace std;

/*
a
b
h
 */

int a,b,h;

int main(){
  cin >> a >> b >> h;
  cout << (a+b)*h/2 << endl;

  return 0;
}


Measured memory_bytes: 256
MOD = 1000000007

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

vec = [0, 0, 0]
num = 1

for a in A:
    idx = [i for i, x in enumerate(vec) if x == a]
    if len(idx) == 0:
        print(0)
        exit()
    num = (num * len(idx)) % MOD
    vec[idx[0]] += 1

print(num)


Measured memory_bytes: 14056
#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n) FOR(i,0,n)
using namespace std;
using ll = long long;
template <class T> void chmin(T& a, const T& b) { a = min(a, b); }
template <class T> void chmax(T& a, const T& b) { a = max(a, b); }

struct P { ll x, y; };
constexpr ll INF = 1LL << 62;

inline ll max(ll a, ll b, ll c, ll d) { return max(a, max(b, max(c, d))); }
inline ll min(ll a, ll b, ll c, ll d) { return min(a, min(b, min(c, d))); }

int main() {
    int n, k; cin >> n >> k;
    vector<P> p(n);
    rep(i, n) {
        cin >> p[i].x >> p[i].y;
    }
    
    ll ans = INF;

    rep(p1, n) {
        rep(p2, n) {
            rep(p3, n) {
                rep(p4, n) {
                    ll x_min = min(p[p1].x, p[p2].x, p[p3].x, p[p4].x);
                    ll x_max = max(p[p1].x, p[p2].x, p[p3].x, p[p4].x);
                    ll y_min = min(p[p1].y, p[p2].y, p[p3].y, p[p4].y);
                    ll y_max = max(p[p1].y, p[p2].y, p[p3].y, p[p4].y);

                    int cnt = 0;
                    rep(i, n) {
                        if(x_min <= p[i].x && p[i].x <= x_max && y_min <= p[i].y && p[i].y <= y_max)
                            cnt++;
                    }
                    if(cnt < k) continue;

                    ll w = x_max - x_min;
                    ll h = y_max - y_min;
                    chmin(ans, h * w);
                }
            }
        }
    }

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


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


using namespace std;

int main(){
	int a, b, c, d, ans = 0; cin >> a >> b >> c >> d;
	bool alice[100];
	bool bob[100];
	fill(alice, alice + 100, false);
	fill(bob, bob + 100, false);
	fill(alice + a, alice + b, true);
	fill(bob + c, bob + d, true);
	for(int i = 0; i < 100; ++i) if(alice[i] && bob[i]) ans++;
	cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define finish(x) return cout << x << endl, 0
#define ll long long

int n;
vector <int> a;

int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cin >> n;
    a.resize(n);
    for(auto &i : a) cin >> i;
    ll l = 2, r = 2;
    for(int i = n - 1 ; i >= 0 ; i--){
        ll d = l / a[i] * a[i];
        if(d < l) d += a[i];
        l = d;
        r = r / a[i] * a[i];
        r += a[i] - 1;
        if(r < l) finish(-1);
    }
    cout << l << " " << r << endl;
}


Measured memory_bytes: 640
Scanf.scanf "%d" (fun n ->
    let nei = Array.make n [] in
    for i = 1 to n - 1 do
        Scanf.scanf " %d %d %d" (fun a b c ->
            let a, b = a - 1, b - 1 in
            nei.(a) <- (c, b) :: nei.(a);
            nei.(b) <- (c, a) :: nei.(b);
        )
    done;
    Scanf.scanf " %d %d" (fun q k ->
        let k = k - 1 in
        let dist = Array.make n max_int in
        dist.(k) <- 0;
        let rec loop next = function
            | [] -> if next <> [] then loop [] next
            | hd :: tl ->
                    let cur = dist.(hd) in
                    let next = List.fold_left (fun next (c, v) ->
                        if dist.(v) > cur + c then (
                            dist.(v) <- cur + c;
                            v :: next
                        ) else next
                    ) next nei.(hd) in
                    loop next tl
        in
        loop [] [ k ];
        for i = 1 to q do
            Scanf.scanf " %d %d" (fun x y ->
                let x, y = x - 1, y - 1 in
                Printf.printf "%d\n" (dist.(x) + dist.(y))
            )
        done
    )
)

Measured memory_bytes: 19880
import copy

N = int(input())
SP = []
ss = set()
for i in range(N):
    s, p = input().split()
    ss.add(s)
    SP.append([i+1, s, int(p)])

calSP = copy.deepcopy(SP)
calSP = sorted(calSP, key=lambda x:(x[2]), reverse=True)
ss = sorted(ss)
num = 1
for sss in ss:
    for cal in calSP:
        if cal[1] == sss:
            cal.append(num)
            num += 1
calSP = sorted(calSP, key=lambda x:(x[3]))
for cal in calSP:
    print(cal[0])

Measured memory_bytes: 38512
#include <iostream>
#include <string>
using namespace std;
int main() {
	int A, B, C, D;
		cin >> A >> B >> C >> D;
		if (A*B <= C*D) { cout << C*D; }
		else if (A*B >= C*D) { cout << A*B; }
		return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<queue>
#include<map>
#include<set>
#include<algorithm>
#include<deque>
using namespace std;
int main(){
    int a,b,c;
    cin>>a>>b>>c;
    cout<<min(a+b,min(b+c,a+c))<<endl;
   // system("pause");
    return 0;
}


Measured memory_bytes: 256
#define _USE_MATH_DEFINES

#include <cmath>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <limits>
#include <cstring>
#include <string>
#include <queue>
#include <map>
#include <set>
#include <bitset>

using namespace std;

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

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

vector<int> prime_list(int n) {
    vector<int> ret;
    vector<bool> prime(n + 1, true);
    for (int i = 2; i <= n; ++i) {
        if (prime[i]) {
            if (i % 5 == 1) ret.emplace_back(i);
            for (int j = 2 * i; j <= n; j += i) prime[j] = false;
        }
    }
    return ret;
}

int main() {
    /*
    ios::sync_with_stdio(false);
    cin.tie(0);
     */
    auto v = prime_list(55555);
    int n;
    cin >> n;
    for (int i = 0; i < n; ++i) {
        if (i != 0) cout << " ";
        cout << v[i];
    }
    cout << endl;
}


Measured memory_bytes: 256
#[allow(unused_imports)]
use itertools::Itertools;
#[allow(unused_imports)]
use num::*;
use proconio::input;
#[allow(unused_imports)]
use proconio::marker::*;
#[allow(unused_imports)]
use std::collections::*;

fn main() {
  input! {
    s: String,
    t: String
  };

  let res = if s == &t[0..s.len()] { "Yes" } else { "No" };
  println!("{}", res);
}


Measured memory_bytes: 2112
#include <iostream>
#include <cmath>
#include <numeric>
#include <algorithm>
#include <deque>
#include <vector>
#include <unordered_map>
#include <unordered_set>
#include <set>
#include <iomanip>
#include <map>
#include <stack>
#include <queue>
#include <functional>
#include <climits>
#include <numeric>
#include <bitset>
#include <random>
#include <tuple>
#include <initializer_list>
#include <fstream>
#include <cctype>
#include <string>
#include <cfloat>
#include <array>


int main() {
	long long int n; std::cin >> n;
	long long int result{ n * (n + 1) / 2 };
	const auto m3 = n / 3;
	result -= m3 * (m3 + 1) / 2 * 3;
	const auto m5 = n / 5;
	result -= m5 * (m5 + 1) / 2 * 5;
	const auto m15 = n / 15;
	result += m15 * (m15 + 1) / 2 * 15;
	std::cout << result << std::endl;
}

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

//conversion
//------------------------------------------
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; }
template<class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str(); }

//math
//-------------------------------------------
template<class T> inline T sqr(T x) { return x * x; }

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

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

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

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI = acos(-1.0);

//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))

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

const LL mod = (LL)1e9 + 7;


#define Yes_ cout<<"Yes"<<endl; return 0;
#define No_ cout<<"No"<<endl; return 0;


#define YES_ cout<<"YES"<<endl; return 0;
#define NO_ cout<<"NO"<<endl; return 0;



int main() {
		
	int a, b, c;
	//cin >> a >> b >> c;
	string s;
	cin >> s;
	if (s.find("a") != string::npos&&s.find("b") != string::npos&&s.find("c") != string::npos) {
		Yes_;
	}
	else {
		No_;
	}





}

Measured memory_bytes: 256
import java.util.*;
import java.util.Map.*;   // Entryを使うときは、paizaではこれを宣言する

public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here!
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        
        Map<String, Integer> map = new HashMap<String, Integer>();
        int max = 0;
        while (n-- > 0) {
            String w = sc.next();
            if (!map.containsKey(w)) {
                map.put(w, 1);
                max = Math.max(max, 1);
            } else {
                int v = map.get(w);
                map.put(w, v + 1);
                max = Math.max(max, v + 1);
            }
        }
        
        List<String> list = new ArrayList<String>();
        for (Entry<String, Integer> entry : map.entrySet()) {
            String key = entry.getKey();
            int val = entry.getValue();
            if (val == max) {
                list.add(key);
            }
        }
        list.sort(Comparator.naturalOrder());
        
        for (String s : list) {
            System.out.println(s);
            
        }
    }
}


Measured memory_bytes: 85024
n = int(input())
p = list(map(int, input().split()))
s = sorted(p)

for i in range(n-1):
    for j in range(i,n):
        tmp = p.copy()
        tmp[i],tmp[j] = p[j],p[i]
        if tmp == s:
            print("YES")
            exit()
print("NO")

Measured memory_bytes: 3060
/// I won't go back on my word, that's my ninja way!
#include<bits/stdc++.h>
using namespace std;
const int N = 2e5+5 ;
int n ,m ,p[N] ,u ,v ;
vector<int> adj[N] ,vec ;
bool vis[N] ;
int here[N] ,vid ,ans ;
void dfs(int p){
    vis[p] = 1 ;
    vec.push_back(p);
    here[p] = vid ;
    for(int ch:adj[p])
        if(!vis[ch])dfs(ch);
}
int main(){
    scanf("%d%d",&n,&m);
    for(int i=1;i<=n;++i)scanf("%d",p+i);
    while(m--){
        scanf("%d%d",&u,&v);
        adj[u].push_back(v);
        adj[v].push_back(u);
    }
    for(int i=1;i<=n;++i){
        if(vis[i])continue;
        ++vid ;
        vec.clear();
        dfs(i);
        for(int j:vec)if(here[p[j]]==vid)++ans ;
    }
    printf("%d",ans);
    return 0 ;
}


Measured memory_bytes: 12668
# A - Colorful Transceivers

# A,B,Cの3人が、直接的あるいは間接的に会話できるなら Yes を、
# そうでないなら No を返す

a, b, c, d = map(int, input().split())

ac = abs(a - c)
ab = abs(a - b)
bc = abs(b - c)

if ac <= d \
or (ab <= d and bc <= d):
    print('Yes')
else:
    print('No')


Measured memory_bytes: 9076
#include <algorithm>
#include <cassert>
#include <cstring>
#include <iostream>
#include <numeric>
#include <vector>

#define TRACE(x) std::cout << #x << " = " << x << "\n"
#define _ << " _ " <<

using namespace std;

template <int32_t P>
struct ModInt_t {
  int32_t value;

  static_assert(P < (1 << 30) - 1, "2xP must fit into signed 32-bit int");

  ModInt_t() : value{0} {};

  explicit ModInt_t(int32_t v) : value(v) {
    if (value >= P || value <= -P) value %= P;
    if (value < 0) value += P;
  };

  explicit operator int32_t() const { return value; }

  ModInt_t& operator+=(const ModInt_t& other) {
    value += other.value;
    if (value >= P) value -= P;
    return *this;
  }

  ModInt_t& operator-=(const ModInt_t& other) {
    value -= other.value;
    if (value < 0) value += P;
    return *this;
  }

  ModInt_t& operator*=(const ModInt_t& other) {
    int64_t result = static_cast<int64_t>(value) * other.value;
    value = static_cast<int32_t>(result % P);
    return *this;
  }

  static ModInt_t inverse(ModInt_t x) { return ModInt_t{inverse(x.value)}; }
};

template <int32_t P>
ModInt_t<P> operator+(const ModInt_t<P>& a, const ModInt_t<P>& b) {
  auto res = a;
  return res += b;
};

template <int32_t P>
ModInt_t<P> operator-(const ModInt_t<P>& a, const ModInt_t<P>& b) {
  auto res = a;
  return res -= b;
};

template <int32_t P>
ModInt_t<P> operator*(const ModInt_t<P>& a, const ModInt_t<P>& b) {
  auto res = a;
  return res *= b;
};

template <int32_t P>
bool operator==(const ModInt_t<P>& a, const ModInt_t<P>& b) {
  return a.value == b.value;
};

template <int32_t P>
std::ostream& operator<<(std::ostream& os, const ModInt_t<P>& a) {
  os << a.value;
  return os;
}

using ModInt = ModInt_t<998244353>;

int main() {
  ios_base::sync_with_stdio(false);

  int N;
  cin >> N;
  string S;
  cin >> S;

  ModInt ret{1};
  vector<int> cnt(1 << 3);

  for (int i = 0; i < 3 * N; ++i) {
    int c = S[i] == 'R' ? 0 : (S[i] == 'G' ? 1 : 2);

    bool done = false;
    for (int j = 7; j > 0; --j) {
      if (cnt[j] > 0 && (j & (1 << c)) == 0) {
        ret = ret * ModInt{cnt[j]};
        cnt[j]--;
        cnt[j | (1 << c)]++;
        done = true;
        break;
      }
    }

    if (!done) cnt[1 << c]++;
  }

  for (int i = 1; i <= N; ++i) {
    ret = ret * ModInt{i};
  }

  cout << ret << '\n';
  return 0;
}


Measured memory_bytes: 720
#include <stdio.h>
#include <stdlib.h>
#include <limits.h>

void Merge(long *A, char *mark, long left, long mid, long right) {
  long n1,n2,*L,*R,i,j,k;
  char *L_mark,*R_mark;
  n1 = mid -left;
  n2 = right - mid;
  L = (long*)malloc(sizeof(long) * (n1+1));
  L_mark = (char*)malloc(sizeof(char) * (n1+1));
  R = (long*)malloc(sizeof(long) * (n2+1));
  R_mark = (char*)malloc(sizeof(char) * (n2+1));
  for (i = 0; i< n1; i++) {
    L[i] = A[left+i];
    L_mark[i] = mark[left+i];
  }
  for (i = 0; i < n2; i++) {
    R[i] = A[mid+i];
    R_mark[i] = mark[mid+i];
  }
  L[n1] = LONG_MAX; R[n2] = LONG_MAX;
  i = 0;j = 0;
  for(k = left; k < right; k++) {
    if (L[i] <= R[j]) {
      A[k] = L[i];
      mark[k] = L_mark[i];
      i++;
    }else {
      A[k] = R[j];
      mark[k] = R_mark[j];
      j++;
    }
  }
  free(L);
  free(L_mark);
  free(R);
  free(R_mark);
}

void Merge_Sort(long *A,char* mark, long left, long right) {
  if(left+1 < right) {
    long mid = (left + right)/2;
    Merge_Sort(A,mark,left,mid);
    Merge_Sort(A,mark,mid,right);
    Merge(A,mark,left,mid,right);
  }
}


void swap(long *A, long i, long j) {
  long temp;
  temp = A[i];
  A[i] = A[j];
  A[j] = temp;
}

void swap_mark(char *A, long i, long j) {
  char temp;
  temp = A[i];
  A[i] = A[j];
  A[j] = temp;
}

long Partition(long *A,char *mark, long p, long r) {
  long i,j,x;
  x = A[r];
  i = p-1;
  for(j = p; j < r; j++) {
    if(A[j] <= x) {
      i++;
      swap(A,i,j);
      swap_mark(mark,i,j);
    }
  }
  swap(A,i+1,r);
  swap_mark(mark,i+1,r);
  return i+1;
}

void Quicksort(long *A, char *mark, long p, long r) {
  if (p < r) {
    long q = Partition(A,mark,p,r);
    Quicksort(A,mark,p,q-1);
    Quicksort(A,mark,q+1,r);
  }
}

int main()
{
  long i,n,*A,*B;
  char *mark,*mark2;
  scanf("%ld ", &n);
  A = (long*)malloc(sizeof(long) * n);
  B = (long*)malloc(sizeof(long) * n);
  mark = (char*)malloc(sizeof(char) * n);
  mark2 = (char*)malloc(sizeof(char) * n);
  for (i = 0; i < n; i++) {
    scanf("%c %ld ", mark+i, A+i);
    B[i] = A[i];
    mark2[i] = mark[i];
  }

  Quicksort(A,mark,0,n-1);
  Merge_Sort(B,mark2,0,n);
  i = 0;
  while (1) {
    if(mark[i] != mark2[i]) {
      printf("Not stable\n");
      break;
    }
    if(i == n-1) {
      printf("Stable\n");
      break;
    }
    i++;
  }

  for (i = 0; i < n; i++) {
    printf("%c %ld\n",mark[i],A[i]);
  }

  return 0;
}

Measured memory_bytes: 2968
#include <iostream>
#include <numeric>
#include <math.h>
#include <algorithm>
#include <float.h>
#include <limits>
#include <vector> 
#include <string.h>

#define rep(i,a,n) for(ll int (i) = (a);(i) < (n);(i)++)
#define urep(i,a,n) for(ll int (i) = (a);(i) > (n);(i)--)
#define MOD 1000000007
#define ll long long
#define asort(a) sort(a.begin(),a.end());

using namespace::std;

int jo(ll int jxo, ll int jyo){//累乗
	ll int jhogeo = 1;
	rep(jinto,0,jyo) jhogeo=jhogeo*jxo;
	return jhogeo;
}
char tobig(char toxbig){//char大文字化
  return (toxbig-0x20);
}
char tolow(char toxlow){//char小文字化
  return (toxlow+0x20);
}
int ctoi(char cctoi){//char->int
  if('0' <= cctoi && cctoi <= '9') return (cctoi-'0');
  return -1;
}
int gcd(int gcad, int gcbd) {//最大公約数
  if(gcad < gcbd) return gcd(gcbd, gcad);
  int gcrd;
  while ((gcrd=gcad%gcbd)) {
    gcad = gcbd;
    gcbd = gcrd;
  }
  return gcbd;
}
int lcm(int lcam, int lcbm){//最小公倍数
 return (lcam*lcbm)/gcd(lcam,lcbm);
}


int main(){
  int n;
  cin>>n;
  vector<int> a(n);
  vector<int> b(n);
  rep(i,0,n) a[i]=0;
  rep(i,0,n-1) cin>>b[i];
  a[0]=b[0];
  a[n-1]=b[n-2];
  rep(i,1,n-1){
    if(b[i-1]<b[i]) a[i]=b[i-1];
    else a[i]=b[i];
  }
  ll int max=0;
  rep(i,0,n){
    max+=a[i];
  }
    cout<<max;
  
}
// int *p = new int[N];

//  vector<int> 変数名(要素数);
//  sort(変数名.begin(),変数名.end());//昇順ソート

// vector<vector<int>> 変数名(左の個数, vector<int>(右の個数));

//

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

int main(){
    int n;cin >> n;
    string s;
    int ans = 0;
    queue<int> q;
    q.push(0);
    int k;cin >> k;
    cin >> s;
    bool zero_before = false;
    bool one_before = false;
    for(int i=0;i<n;i++){
        //cout << i << endl;
        if(s[i] == '0'){
            if(one_before&&(q.size()>k)){
                ans = max(i-q.front(),ans);
                q.pop();
            }
            zero_before = true;
            one_before = false;
        }
        else{
            if(zero_before){
                q.push(i);
            }
            zero_before = false;
            one_before = true;
        }

    } 
    ans = max(n-q.front(),ans);
    cout <<ans << endl;
}

Measured memory_bytes: 512
#include<iostream>
#include<algorithm>
#include<numeric>
#include<vector>
#include<set>
#include <math.h>
#include <string>
#define cinf(n,x,y) for(int i=0;i<(n);i++) cin >> x[i]>>y[i];
typedef long long int ll;
const ll INF =1LL << 62;
using namespace std;
int MAX_E=1000010;
ll dp[1000010];
int main(){
	while(1){
		int e; cin >>e;
		if(e==0) break;
		int ans=1e9;
		for(int i=0;i*i*i<=e;i++){
			for(int j=0;j*j<=e-i*i*i;j++){
				ans=min(ans,i+j+(e-i*i*i-j*j));
			}
		}
		cout << ans << endl;
	}
}


Measured memory_bytes: 3076
n,k = map(int,input().split())
v = [0]+[int(i) for i in input().split()]+[0]
ans = 0
cnt1 = 0
m1 = []
for i in range(n+1):
    cnt1 += v[i]
    if v[i] < 0: m1.append(v[i])
    cnt2 = cnt1
    m2 = m1[:]
    for j in range(n-i+1):
        if i + j > k: break
        r = k - i - j
        cnt2 += v[n+1-j]
        tmp = cnt2
        if v[n+1-j] < 0: m2.append(v[n+1-j])
        m2.sort()
        tmp -= sum(m2[:r])
        ans = max(tmp,ans)
print(ans)

Measured memory_bytes: 3064
import std.stdio, std.algorithm, std.conv, std.array, std.string;

void main()
{
    auto ks = readln.split.to!(int[]);
    auto k = ks[0];
    auto s = ks[1];

    long cnt;
    foreach (x; 0..k+1) {
        foreach (y; x..k+1) {
            auto  z = s - x - y;
            if (z < y || z > k) continue;
            if (x == y && y == z)
                ++cnt;
            else if (x == y || y == z || z == x)
                cnt += 3;
            else
                cnt += 6;
        }
    }
    writeln(cnt);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define mp make_pair
#define pb push_back
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)

template< typename T >
struct BinaryIndexedTree {
  vector< T > data;

  BinaryIndexedTree(int sz) {
    data.assign(++sz, 0);
  }

  T sum(int k) {
    T ret = 0;
    for(++k; k > 0; k -= k & -k) ret += data[k];
    return (ret);
  }

  void add(int k, T x) {
    for(++k; k < data.size(); k += k & -k) data[k] += x;
  }
};


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

  ll n,k;
  cin >> n >> k;
  ll a[n];
  rep(i,n){
    cin >> a[i];
    a[i]-=k;
  }
  ll sum[n+1];
  multiset<ll> ms;
  vector<pair<ll,ll>> v;
  sum[0]=0;
  //  ms.insert(0);
  v.pb(mp(0,0));
  rep(i,n){
    sum[i+1] = sum[i]+a[i];
    //    ms.insert(sum[i+1]);
    v.pb(mp(sum[i+1],i+1));
  }
  BinaryIndexedTree< ll > bit(n+1);
  sort(v.begin(),v.end());
  ll ans=0; //左側を見るときは小さいのを　右のときは大きいのを探す
  rep(i,n+1){
    int pos=v[i].second;
    ans += bit.sum(pos);
    bit.add(pos,1);
    //    hans += v.end() - upper_bound(v.begin(), v.end(),sum[i]);
    //    eans += upper_bound(v.begin(), v.end(),sum[i]) - lower_bound(v.begin(), v.end(),sum[i]);
    //    if(i==0) ans--;
  }
  cout << ans << endl;
  
  return 0;
    

}


Measured memory_bytes: 8944
require 'pp'

###################

inputType = :singleLine
# inputType = :2Lines
# inputType = :nLines
  
def main(query)
  ppp("hoge", query)
  n,x,t = tois(query[0].split(" "))
  t2 = t * (n / x)
  if (n % x > 0) then
    t2 = t2 + t
  end
  return [t2]
end

###################

TEST=false

def tois(l)
  l.map { | x | x.to_i}
end

def ppp(msg, val)
  if (TEST) then
    print msg
    pp val
  end
end

target = nil
if (ARGV.size == 0) then
  f = STDIN
end
if (ARGV.size > 0) then
  f = open(ARGV[0])
end
if (ARGV.size > 1) then
  target = ARGV[1].to_i
end

t = 1
ng = []
while true
  query = []
  if (inputType == :singleLine) then
    a = f.gets
    if ! a then
      exit
    end
    a.chomp!
    query.push a
  elsif (inputType == :l2Lines) then
    a = f.gets
    if ! a then
      exit
    end
    a.chomp!
    query.push a
    b = f.gets.chomp
    query.push b
  elsif (inputType == :l3Lines) then
    a = f.gets
    if ! a then
      exit
    end
    a.chomp!
    query.push a
    b = f.gets.chomp
    query.push b
    c = f.gets.chomp
    query.push c
  elsif (inputType == :nLines) then
    a = f.gets
    if ! a then
      exit
    end
    a.chomp!
    query.push a    

    n = a.split(" ")[2].to_i

    query = n.times { | i |
      query.push f.gets.chomp
    }    
  end
  
  aa = f.gets
  if ! aa then
    r = main(query) 
    r.each { | x | puts x }
    exit
  elsif ( aa.chomp == "---") then
    oks = []
    while true
      s = f.gets.chomp
      if (s == "===") then
        break
      end
      oks.push s
    end

    if (target == nil || t == target) then
      if target then
        TEST = true
      end

      puts "--- " + t.to_s + " ---"
      r = main(query)    

      if r.join('\n') == oks.join('\n') then
        puts "RESULT:"
        r.each { | x | puts x }
        puts "OK"
      else
        puts "RESULT:NG"
        r.each { | x | puts x }
        puts "NG!!!!!!!!!"
        ng.push t
      end
    end
  end
  t = t + 1
end
puts "---"
puts "NG targes = " + ng.to_s


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

void solve(std::string S, std::string T)
{
    int counter = 0;
    for (int i = 0; (unsigned)i < S.length(); i++)
    {
        char s = S.at(i);
        char t = T.at(i);
        if (s != t)
        {
            counter++;
        }
    }
    cout << counter << endl;
}

// Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main()
{
    std::string S;
    std::cin >> S;
    std::string T;
    std::cin >> T;
    solve(S, T);
    return 0;
}


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

#define debug(x) cout<<#x<<": "<<x<<endl
#define rep(i,n) for (int i=0;i<(n);i++)
#define FOR(i,a,b) for (int i=(a);i<=(b);i++)
#define all(a) (a).begin(),(a).end()
using namespace std;
typedef vector<int> VI;
typedef vector<vector<int>> VVI;
typedef long long ll;


void solve() {
#ifdef _WIN32
	istream &cin = ifstream("input.txt");
#endif
	int n, m;
	cin >> n >> m;

	VI v(n);
	rep(i, m) {
		int x, y;
		cin >> x >> y;
		v[--x]++; v[--y]++;
	}
	rep(i, n) {
		cout << v[i] << endl;
	}
}



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

	solve();
#ifdef _WIN32
	system("PAUSE");
#endif
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(ll i=ll(a);i<ll(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
#define PRINT(V) cout << V << "\n"
#define SORT(V) sort((V).begin(),(V).end())
#define RSORT(V) sort((V).rbegin(), (V).rend())
using namespace std;
using ll = long long int;
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; }
const ll INF = 1e11;
const ll MOD = 1000000007;
typedef pair<ll,ll> P;
vector<vector<int>> to(100005);
int n,m;
int d[100005];
bool done[100005] = {0};
int len(int x){
    int res = 0;
    if (done[x]) return d[x];
    if (to[x].empty()){
        d[x] = 0;
        done[x] = true;
        return 0;
    }
    else{
        for(int i:to[x]){
            chmax(res,len(i)+1);
        }
    }
    d[x] = res;
    done[x] = true;
    return res;
}
int main(){
    cin >> n >> m;
    int x,y;
    rep(i,m){
        cin >> x >> y;
        to[x-1].push_back(y-1);
    }
    int ans = 0;
    rep(i,n){
        chmax(ans,len(i));
    }
    PRINT(ans);
}

Measured memory_bytes: 8192