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

#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define st first
#define nd second
#define endl '\n'
#define what_is(x) cerr << #x << " is " << x << endl;
#define what_is_v(x) cerr << #x << " is "; for(auto&e: (x)) cerr << e << ' '; cerr << '\n'; //vector, set
#define what_is_a(x, n) cerr << #x << " is "; for(int i=0;i<n;i++) cerr << x[i] << ' '; cerr <<  '\n'; //n first element of array
#define cerr_pair(x) '{' << x.st << ", " << x.nd << '}'
#define pwhat_is(x) cerr << #x << " is " << cerr_pair(x) << endl;
#define pwhat_is_v(x) cerr << #x << " is "; for(auto&e: (x)) cerr << cerr_pair(e) << ' '; cerr << '\n'; //vector, set
#define pwhat_is_a(x, n) cerr << #x << " is "; for(int i=0;i<n;i++) cerr << cerr_pair(x[i]) << ' '; cerr <<  '\n'; //n first element of array
// #define int long long

typedef pair<int,int> pii;
const int N = 1e5+5;
const int INF = 1e9;
const int MOD = 1e9+7;

string s, t;
int32_t main()
{
	IOS
	//freopen("input.txt", "r", stdin);
	int n; cin >> n;
	cin >> s >> t;
	string ans;
	for(int i=0; i<n; i++){
		ans += s[i];
		ans += t[i];
	}
	cout << ans << endl;
	
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <ios> 
#include <vector>
#include <string>
#include <algorithm>
#include <functional>
#include <queue>
#include <stack>
#include <set>
#include <cmath>
#include <bitset>
#include <map>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
 
using namespace std;
typedef long long int lli;
const int MAX=1e5+5;
 
int main(){
	int N;
	cin>>N;
	lli A[MAX],B[MAX];
	rep(i,N)cin>>A[i]>>B[i];
	lli d[MAX];
	rep(i,N)d[i]=A[i]+B[i];
	sort(d,d+N,greater<lli>());
	
	lli s=0;
	rep(i,N){
		s+=B[i];
	}
	
	lli sum=0;
	rep(i,N){
		if(i%2==0)sum+=d[i];
	}
	cout<<sum-s;
}

Measured memory_bytes: 2560
import java.util.Scanner;
public class Main{
    public static void main(String[]args){
        Scanner s = new Scanner(System.in);
 
        String S = s.nextLine();
        if(S.equals("ABC")){
            System.out.println("ARC");
        }else {
            System.out.println("ABC");
        }
    }
}

Measured memory_bytes: 35692
_,*s=$<.map &:chop
eval"_,*A="+_.split*?,
f=->i{s[i]&.bytes{|x|$*[i]=""<<y=s[i].sum-x;A[y-=65]+=1;f[i+1]if~0<A[x-=65]-=1;A[x]+=1;A[y]-=1}||puts(:Yes,$*)+exit}
f[0]
puts:No

Measured memory_bytes: 150988
N, K = list(map(int, input().split()))
P = list(map(lambda x: (int(x) * (int(x) + 1)) / 2 / int(x), input().split()))
#print(P)
ans = sum(P[:K])
tmp = ans
#print(ans)
for i in range(1, N - K + 1):
  tmp = tmp - P[i - 1] + P[i + K - 1]
  #print(tmp, P[i - 1], P[i + K - 1])
  if tmp > ans:
    ans = tmp
print(ans)

Measured memory_bytes: 23588
#include <iostream>
#include <cstdio>
#include <queue>
#include <functional>
#include <vector>
using namespace std;
long long q, b, nums[201000], psz;
priority_queue<long long> small;
priority_queue<long long,vector<long long>,greater<long long> > big;
long long ss, bs;
inline long long bass( long long r ){
	return r < 0 ? -r : r;
}
void ahh( long long ip ){
	if( !small.size() ){
		small.push(ip);
		ss += ip;
		return ;
	}
	if( ip > small.top() )
		big.push(ip), bs += ip;
	else
		small.push(ip), ss += ip;
	if( bass((long long)(small.size() - big.size())) > 1 ){
		if( big.size() > small.size() )
			ss += big.top(), bs -= big.top(), small.push(big.top()), big.pop();
		else
			bs += small.top(), ss -= small.top(), big.push(small.top()), small.pop();
	}
}
void aah(){
	long long ur = big.size() > small.size() ? big.top() : small.top();
	printf("%lld ", ur);
	long long cnt = 0;
	cnt = bs - ss + (small.size()-big.size()) * ur;
	printf("%lld\n", cnt+b);
}
int main(){
	scanf("%lld", &q);
	while( q-- ){
		long long swit, r, t;
		scanf("%lld", &swit);
		if( swit == 1 ){
			scanf("%lld%lld", &r, &t);
			b += t;
			nums[++psz] = r;
			ahh(r);
		} else
			aah();
	}
	return 0;
}

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

int a[100][100];
int b[100];

int main() {
  int n, m;
  cin >> n >> m;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      cin >> a[i][j];
    }
  }
  for (int i = 0; i < m; i++) {
    cin >> b[i];
  }
  for (int i = 0; i < n; i++) {
    int c = 0;
    for (int j = 0; j < m; j++) {
      c += a[i][j] * b[j];
    }
    cout << c << "\n";
  }
  return 0;
}


Measured memory_bytes: 3108
//12-2 たのしいカードゲーム
#include<iostream>
#include<fstream>
#include<stdio.h>
#include<math.h>
#include<time.h>
#include<string>
#include<vector>
#include<map>
#include<list>
#include<set>
#include<stack>
#include<queue>
#include<cstdlib>
#include<algorithm>
#include<random>
#include<cassert>
using namespace std;
#include<boost/multiprecision/cpp_int.hpp>
namespace boost_multiprecision = boost::multiprecision;
#define LL long long
#define CINT boost_multiprecision::cpp_int
#undef INT_MIN
#undef INT_MAX
#define INT_MIN -2147483648
#define INT_MAX 2147483647
#define LL_MIN -9223372036854775808
#define LL_MAX 9223372036854775807
#define segment_size 65536
#define ROOP() while(true)

int main(){
	vector<int> a;
	vector<int> b;
	int A,B;
	cin >> A >> B;
	for(int i=0; i<A; i++){
		int tmp;
		cin >> tmp;
		a.push_back(tmp);
	}
	for(int i=0; i<B; i++){
		int tmp;
		cin >> tmp;
		b.push_back(tmp);
	}

	int ans = 0;
	for(int i=0; i<b.size(); i++){
		int now = 0;
		int ans_now = 0;
		for(int j=i; j<b.size(); j++){
			while(now<a.size()){
				if(a[now]==b[j]){
					now++;
					ans_now++;
					break;
				}
				else{
					now++;
				}
			}
		}
		ans = max(ans,ans_now);
	}
	cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3244
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int main() {
	int n;
	cin >> n;
	int na = n / 1000;
	n -= na * 1000;
		if (n > 0) {
			cout << 1000 - n;
		}
		else if (n <= 0) {
			cout << 0 << endl;
		}
}

Measured memory_bytes: 3584
from math import floor, sqrt

cubics = [ x * x * x for x in range(101)]
squares = [ x * x for x in range(1000)]
while True:
    m = 1000000
    e = int(input())
    if e == 0: break
    for z in range(len(cubics)):
        if e < cubics[z]: break
        tmp = e - cubics[z]
        y = floor(sqrt(tmp))
        x = tmp - y ** 2
        m = min(m, x + y + z)
    print(m)

Measured memory_bytes: 6816
rc = input().split()
r, c = map(int, rc)

ss= [[int(i) for i in input().split()] for j in range(r)]
colsum = [0 for i in range(c+1)]

for row in ss:
    row.append(sum(row))
    colsum = [x+y for (x, y) in zip(colsum, row)]
    print(' '.join(map(str, row)))

print(' '.join(map(str, colsum)))

Measured memory_bytes: 7752
s = input()
K = int(input())

ans = ''
for i, c in enumerate(s):
    dif = ord('z') - ord(c) + 1
    dif %= 26
    if i == len(s) - 1:
        K %= 26
        if ord(c) + K > ord('z'):
            K -= 26
        ans += chr(ord(c) + K)
    elif dif <= K:
        ans += 'a'
        K -= dif
    else:
        ans += c
print(ans)


Measured memory_bytes: 3444
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int h = sc.nextInt();
    int w = sc.nextInt();
    char[] c = {'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'};
    for(int i = 1;i <= h;i++){
      for(int j = 0;j<=w-1;j++){
        String s = sc.next();
        if(s.equals("snuke"))System.out.println(String.valueOf(c[j])+String.valueOf(i));
      }
    }
  }
}

Measured memory_bytes: 21460
unittest
{
	assert( [ "5", "2 6 1 4 5" ].parse.expand.solve == "YES" );
	assert( [ "6", "4 1 3 1 6 2" ].parse.expand.solve == "NO" );
	assert( [ "2", "10000000 10000000" ].parse.expand.solve == "NO" );
}



import std.conv;
import std.range;
import std.stdio;
import std.typecons;

void main()
{
	stdin.byLineCopy.parse.expand.solve.writeln;
}

auto parse( Range )( Range input )
if( isInputRange!Range && is( ElementType!Range == string ) )
{
	input.popFront;
	auto as = input.front.split.to!( long[] );
	return tuple( as );
}

auto solve( long[] as )
{
	bool[ long ] bs;
	foreach( a; as )
	{
		if( a in bs ) return "NO";
		bs[ a ] = true;
	}
	return "YES";
}


Measured memory_bytes: 25528
object Main {
  def main(args: Array[String]): Unit = {
    val in  =new java.util.Scanner(System.in)
    rec(in)
  }
  def rec(in:java.util.Scanner):Unit ={
    val a = in.nextInt
    val op = in.next
    val b = in.nextInt
    op match{
      case "+" => println(a+b);rec(in)
      case "-" => println(a-b);rec(in)
      case "*" => println(a*b);rec(in)
      case "/" => println(a/b);rec(in)
      case "?" => return
    }
  }
}

Measured memory_bytes: 45004
/**
 *    author:  tourist
 *    created: 11.01.2020 00:10:58       
**/
#include <bits/stdc++.h>

using namespace std;

vector<int> Solve(long long n) {
  if (n == 0) {
    return vector<int>();
  }
  if (n % 2 == 1) {
    auto a = Solve(n / 2);
    int c = (a.empty() ? 0 : *max_element(a.begin(), a.end())) + 1;
    a.insert(a.begin() + (int) a.size() / 2, c);
    a.push_back(c);
    return a;
  }
  auto a = Solve(n - 1);
  int c = (a.empty() ? 0 : *max_element(a.begin(), a.end())) + 1;
  a.insert(a.begin() + (int) a.size() / 2, {c, c});
  return a;
}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  long long n;
  cin >> n;
  auto a = Solve(n);
  cout << a.size() << '\n';
  for (int i = 0; i < (int) a.size(); i++) {
    if (i > 0) {
      cout << " ";
    }
    cout << a[i];
  }
  cout << '\n';
  return 0;
}


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

long long int N, A, B, C, l, r, m;

int main(){
    scanf("%lld", &N);
    for(int i = 0; i < N; ++i){
        scanf("%lld%lld", &A, &B);
        if(A > B)swap(A, B);
        if(A == B){printf("%lld\n", (A - 1) * 2);continue;}
        l = A;
        r = B;
        C = A * B;
        while(r > l + 1){
            m = (l + r) / 2;
            (m * m > C - 1 ? r : l) = m;
        }
        C = l;
        printf("%lld\n", (C - 1) * 2 + (C * (C + 1) < A * B));
    }
    return 0;
}


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

int main()
{
    int a, b, c, x, y, z, t;

    cin >> x >> y >> z;
    a = x;
    b = y;
    c = z;

    t = a;

    a = b;

    b = t;

    t = a;

    a = c;

    c = t;

    cout << a << " " << b << " " << c << "\n";

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<(n); ++i)
#define chmin(x,y) x = min(x,y)
#define chmax(x,y) x = max(x,y)
using namespace std;
typedef long long ll;
typedef pair<int, int> P; 
const int inf = 1<<21;
const ll INF = 1LL << 60;
const ll mod = 1e9+7;
const int dx[4] = {-1, 0, 1, 0};
const int dy[4] = {0, -1, 0, 1};

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    vector<int> x(n);
    rep(i, n) cin >> x[i];
    sort(x.begin(), x.end());
    int ans = inf;
    for(int i=x[0]; i<=x[n-1]; i++){
        int tmp = 0;
        rep(j, n){
            tmp += (x[j]-i)*(x[j]-i);
        }
        chmin(ans, tmp);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define ll long long
#define rep(i,l,r)for(ll i=(l);i<(r);i++)
#define max(p,q)((p)>(q)?(p):(q))
#define min(p,q)((p)<(q)?(p):(q))
ll gcd(ll p,ll q){for(ll t;q;)t=p%q,p=q,q=t;return p;}

int main(){
	ll a,b,c;
	scanf("%lld%lld%lld",&a,&b,&c);
	puts(c%gcd(a,b)==0?"YES":"NO");
}

Measured memory_bytes: 128
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int a=scan.nextInt();
		int b=scan.nextInt();
		int c=Math.max(a+b, a-b);
		int d=Math.max(c, a*b);
		System.out.println(d);

	}

}


Measured memory_bytes: 26932
#include<stdio.h>

int main(void)
{
    int a, b, i, t;
    for (i=0; i<3000; i++) {
        scanf("%d%d", &a, &b);
        if (a==0 && b==0) break;
        if (a>b) {
            t=b;
            b=a;
            a=t;
        }
        printf("%d %d\n", a, b);
    }
}

    


Measured memory_bytes: 2036
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <string>
#include <cmath>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>


using namespace std;
typedef long long ll;

#define mod 1000000007
#define INF 2000000000
#define LLINF 4000000000000000000
#define SIZE 50010

int num[4];
int n,c,ans=0;

int dfs(int h){
    int k=0;
    bool f = true;
    
    if(h==n){
        
        for(int i=0;i<n;i++){
            k+=(int)(pow(10,i)+pow(10,2*n-i))*num[i];
        }
        
        k+=(int)pow(10,n)*c;
        
        for(int i=2;i*i<=k;i++){
            if (k%i==0) {
                f =false;
                break;
            }
        }
        
        if(f)
            return k;
        else
            return 0;
    }
    
    for(int i=0;i<=9;i++){
        num[h] = i;
        k=max(k,dfs(h+1));
    }
    
    return k;
}

int main(){
    
    scanf("%d%d",&n,&c);
    
    if(c <  0){
        if(n==1){
            puts("11");
            return 0;
        }
        
        for(int i=0;i<2*n;i++)
            printf("9");
        printf("\n");
        return 0;
    }
    
    ans = dfs(0);
    
    if(ans==0){
        for(int i=0;i<2*n+1;i++){
            if(i==n)
                printf("%d",c);
            else
                printf("9");
        }
        printf("?\n");
        return 0;
    }
    
    printf("%d\n",ans);
    
    return 0;
}

Measured memory_bytes: 1232
def MI():
    return map(int, input().split())

def LI():
    return list(map(int, input().split()))

# N = int(input())
# group = 0
# tmp = 0

# while tmp < N: 
#     tmp += 26**group
#     group += 1
    
# print(group)

from collections import Counter

N = int(input())
A = LI()
ans = sum(A)
Q = int(input())
A_c = Counter(A)

for _ in range(Q):
    B, C = MI()
    tmp_B = A_c[B]
    tmp_C = A_c[C]
    A_c[B] = 0
    
    if B in A_c.keys():
        A_c[C] += tmp_B
    else:
        A_c[C] = tmp_B
    
    ans = ans - B * tmp_B + C * (A_c[C] - tmp_C)
    print(ans)

Measured memory_bytes: 91036
import sys
input = sys.stdin.readline
m = int(input())
C = [list(map(int,input().split())) for i in range(m)]

cs = sum([i[1] for i in C])
ans = cs-1
mo = 0
for i in range(m):
    mo += C[i][0] * C[i][1]
    ans += mo // 9
    mo %= 9

if mo == 0:
    ans -= 1
print(ans)

Measured memory_bytes: 87772
s,m=map(int,input().split())
l=[]
for _ in range(s):
  n=[]
  n=list(map(int,input().split()))
  n.pop(0)
  l=l+n
m=dict()
for i in l:
  if i in m:
    m[i]+=1
  else:
    m[i]=1
cnt=0
for j in m:
  if m[j]==s:
    cnt+=1
print(cnt)


Measured memory_bytes: 3060
import java.util.Scanner;
class Main{
    public static void main(String[] av){
	Scanner sc=new Scanner(System.in);
	int n=sc.nextInt();
	char[] ch=new char[]{'S','H','C','D'};

	boolean[][] b=new boolean[4][13];

	for(int i=0;i<n;i++){
	    char k=sc.next().charAt(0);
	    int a=sc.nextInt();
	    if(k=='S')	b[0][a-1]=true;
	    if(k=='H')	b[1][a-1]=true;
	    if(k=='C')	b[2][a-1]=true;
	    if(k=='D')	b[3][a-1]=true;
	}
	for(int i=0;i<4;i++){
	    for(int j=0;j<13;j++){
		if(!(b[i][j])){
		    System.out.println(ch[i]+" "+(j+1));
		}
	    }
	}
	}
}


Measured memory_bytes: 26212
#include<stdio.h>
#include<iostream>

int N, K;

int main(){
    int num;
    scanf("%d %d", &N, &K);

    num = 1;
    for(int i = 0; i < N; i++){
        num = 2*num < num+K ? 2*num : num+K;
    }
    std::cout << num;
    return 0;
}

Measured memory_bytes: 256
import java.util.*;
class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int blackCnt = 0;
        HashSet<Integer> set = new HashSet<>();
        for(int i = 0; i<n; i++) {
            int a = sc.nextInt();
            if(1<=a&&a<=399) set.add(0);
            else if(400<=a&&a<=799) set.add(1);
            else if(800<=a&&a<=1199) set.add(2);
            else if(1200<=a&&a<=1599) set.add(3);
            else if(1600<=a&&a<=1999) set.add(4);
            else if(2000<=a&&a<=2399) set.add(5);
            else if(2400<=a&&a<=2799) set.add(6);
            else if(2800<=a&&a<=3199) set.add(7);
            else blackCnt++;
        }
        int min = (set.size() == 0 && blackCnt >= 1)? 1: set.size();
        System.out.println( min+" "+(set.size()+blackCnt));
    }
}

Measured memory_bytes: 23636
#include <bits/stdc++.h>
using namespace std;
int X, Y;
string board[110];
bool goodx[110], goody[110];

int main() {
  cin >> X >> Y;
  for(int i =0; i < X; i++){
    cin>> board[i];
  }
  
  for(int i =0; i<X; i++){
  for(int j = 0; j<Y; j++){
    if(board[i][j] == '#'){
      goodx[i]=true;
      goody[j]=true;
    }
  }
  }
  
  for(int i=0; i<X;i++){
    if(goodx[i]){
      for(int j = 0; j<Y; j++){
        if(goody[j]){
          cout<<board[i][j];
        }
      }
      cout<<endl;
    }
  }
  return 0;


}


Measured memory_bytes: 3664
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1LL<<62
#define inf 1000000007

ll a[102],b[102];
int main() {
	ll n;
	cin>>n;
	for(int i=0;i<n-1;i++){
		cin>>b[i];
	}
	a[0]=b[0];a[1]=b[0];
	for(int i=1;i<n-1;i++){
		if(b[i]<a[i]){
			a[i]=b[i];
		}
		a[i+1]=b[i];
	}
	ll ans=0;
	for(int i=0;i<n;i++){
		ans+=a[i];
	}
	cout <<ans;
	return 0;
}

Measured memory_bytes: 256
w, h, n = map(int, input().split())
xya = [list(map(int, input().split())) for i in range(n)]

try:one = sorted(list(filter(lambda x:x[2]==1, xya)), key=lambda x:x[0])[-1][0]
except: one = 0
try: two = sorted(list(filter(lambda x:x[2]==2, xya)), key=lambda x:x[0])[0][0]
except: two = w
try: three = sorted(list(filter(lambda x:x[2]==3, xya)), key=lambda x:x[1])[-1][1]
except: three = 0
try: four = sorted(list(filter(lambda x:x[2]==4, xya)), key=lambda x:x[1])[0][1]
except: four = h

print(max(0,two-one) * max(0,four-three))

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

int main()
{
  const char *weather[3] = { "Sunny", "Cloudy", "Rainy" };
  
  string S;
  int ans_index;
  
  cin >> S;
  
  for (int i = 0; i < 3; i++) {
    if (strcmp(weather[i], S.c_str()) == 0) {
  		ans_index = (i + 1) % 3;
      	break;
    }
  }
  
  cout << weather[ans_index] << endl;
  return 0;
}

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

struct rest{
	int i;
	int u;
};

int index(char c){
	return (int)c - 48;
}

bool three(int a, int b, int c){
	if(a == b && a == c) return true;
	if(b == a + 1 && c == b + 1) return true;
	return false;
}

bool head(int a, int b){
	if(a == b){
		return true;
	}else{
		return false;
	}
}

int threes(rest a[12]){
	int i = 0;
	while(a[i].u == 0) i++;
	int num = a[i].i;
	a[i].u = 0;
	int j = 0;
	while(j < 12 && (a[j].u == 0 || a[j].i != num)) j++;
	if(j < 12){
		a[j].u = 0;
		int k = 0;
		while(k < 12 && (a[k].u == 0 || a[k].i != num)) k++;
		if(k < 12){
			a[k].u = 0;
			return 1;
		}else  {
			a[j].u = 1;
		}
	}
	j = 0;
	while(j < 12 && (a[j].u == 0 || a[j].i != num+1)) j++;
	if(j < 12){
		a[j].u = 0;
		int k =0;
		while(k < 12 && (a[k].u == 0 || a[k].i != num + 2)) k++;
		if(k < 12){
			a[k].u = 0;
			return 1;
		}
	}
	return 0;
}



bool able(int num[14]){
	rest a[12];
	for(int i = 0; i < 13; i++){
		if(head(num[i], num[i+1])){
			int j = 0;
			while(j < i){
				a[j].i = num[j];
				a[j].u = 1;
				j++;
			}
			while(j < 12){
				a[j].i = num[j+2];
				a[j].u = 1;
				j++;
			}
			threes(a);
			threes(a);
			threes(a);
			threes(a);
			int k = 0;
			for(int l = 0; l < 12; l++){
				if(a[l].u) k++;
			}
			if(k == 0) return true;
		}
	}
	return false;
}

bool judge(int num[14]){
	sort(num, num+14);
	if(able(num)) return true;
	return false;
}


int main(){
	string s;
	while(cin >> s){
		int nums[14];
		int count = 0;
		string::size_type size = s.size();
		for(int i = 1; i <= 9; i++){
			for(string::size_type st = 0; st < size; st++)
			{
				nums[st] = index(s[st]);
			}
			int c = 0;
			for(int j = 0; j < 13; j++){
				if(nums[j] == i) c++;
			}
			if(c < 4){
				nums[13] = i;
				if(judge(nums)){
					if(count){
						cout << " " << i;
					}else {
						cout<< i;
					}
					count++;
				}
			}
		}
		if(count == 0) cout << 0;
		cout << endl;
	}
	return 0;
}

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

int main() {
  int A;
  int B;
  int C;
  int D;
  cin >> A >> B >> C >> D;
  
  if (A+B > C+D) {
    cout << "Left" << endl;
  }
  
  else if(A+B == C+D) {
    cout << "Balanced" << endl;
  }

  else if(A+B < C+D) {
    cout << "Right" << endl;
  }

}


Measured memory_bytes: 3616
#include<stdio.h>
int main(void)
{
	int i,x;
	i =1;
	do{
		scanf("%d", &x);
		if (x!=0)
			printf("Case %d: %d\n", i, x);
		i = i + 1;

	} while (x != 0);
	
	

	return 0;
}

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

int N,M,s; bool ok; char c;
int main(){
  cin>>N>>M;
  string ans = string(N,'x');
  ok = true;
  REP(i,M){
    cin>>s>>c; --s;
    if(ans[s]=='x'){ans[s]=c;}
    else if(ans[s]!=c){ ok=false;break;}
  }
  if(N>1 && ans[0]=='0'){ok=false;}
  if(ok){
    if(N==1){ if(ans[0]=='x'){ans[0]='0';} }
    else{
      if(ans[0]=='x'){ans[0]='1';}
      for(int i=1;i<N;++i){ if(ans[i]=='x'){ans[i]='0';}}
    }
    cout << ans <<"\n";
  }else{
    cout << "-1\n";
  }
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <deque>
#include <algorithm>
#include <bitset>
#define range(i, r) for(int i=0;i<r;i++)
#define ranges(i, l, r) for(int i=l;i<r;i++)
#define vv(a, b, c, d) vector<vector<d> >(a, vector<d>(b, c))
#define vvi std::vector<std::vector<int> >
#define vvl std::vector<std::vector<ll> >
#define MODs 1000000007;
#define MODn 1000000009;
typedef long long int ll;
using namespace std;

int main(int argc, char const *argv[]) {
  int A, B;
  std::cin >> A >> B;
  if(A>=13) std::cout << B << '\n';
  else if(A>=6 && A<=12) std::cout << B/2 << '\n';
  else std::cout << 0 << '\n';
  return 0;
}


Measured memory_bytes: 888
k, n = map(int, input().split())
a = list(map(int, input().split()))

lgt_dist = 0
for i in range(n):
    if i == 0:
        lgt_dist = a[i] + (k - a[i - 1])
    else:
        lgt_dist = max(lgt_dist, abs(a[i] - a[i - 1]))

print(k - lgt_dist)


Measured memory_bytes: 26444
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ABC122D
{
    class Program
    {
        public static int N;
        public const int mod = 1000000007;
        public static int[,] mojis;
        public static int[] ng = new int[] { 6, 70, 134, 198, 24, 25, 26, 27, 9, 73, 137, 201, 36, 37, 38, 39, 18, 82, 146, 210, 72, 74, 75, 22, 30, 54 };
        static void Main(string[] args)
        {

            N = int.Parse(Console.ReadLine());
            if (N == 3) { Console.WriteLine(61); return; }
            
            mojis = new int[256, N];


            //初期化
            for (int i = 0; i < 256; i++)
            {
                if (!ng.Contains(i)) { mojis[i, 3] = 1; }
            }
            for (int i = 3; i < N-1; i++)
            {
                for (int k = 0; k < 256; k++)
                {
                    int h = k % 64;
                    int ne = h * 4;
                    for (int l = 0; l < 4; l++)
                    {
                        if (!ng.Contains(ne+l))
                        {
                            mojis[ne+l, i + 1] += mojis[k, i];
                            mojis[ne+l, i + 1] %= mod;
                        }
                    }

                }
            }
            int ans = 0;
            for (int i = 0; i < 256; i++)
            {
                ans += mojis[i, N - 1];
                ans %= mod;
            }
            Console.WriteLine(ans);
            
        }
    }
}


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

using namespace std;

#define REP1(i,n) for(int i=1, i##_len=(n); i<i##_len; ++i)
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define pow(x) x*x
#define ll long long
static const ll MAX = 1000000;
static const ll INFTY = 1e12;
static const ll MOD = 1000000007;

template < typename T > inline string toString( const T &a ) { ostringstream oss; oss << a; return oss.str(); };

struct edge {
    ll to, cost;
};

using Graph = vector<set<int>>;
using _Graph = vector<vector<edge>>;


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

// 深さ優先探索
vector<bool> seen;
vector<int> colors;

// int H, W, N;
int sx, sy, gx, gy; 
vector<vector<char>> field;
vector<vector<int>> dist;
//vector<pair<int, int>> gx, gy;
deque<pair<int, int>> que;

typedef vector<vector<int> > Matrix;

const int INF = 100000000;


int main() {

  ll N;
  cin >> N;
  vector<ll> A(N+1);
  map<ll, ll> numi;
  REP1(i, N+1){
    cin >> A[i];
    numi[i+A[i]]++;
  }
  ll ans=0;
  REP1(i, N+1){
    if(i-A[i]>=0){
      ans += numi[i-A[i]];
    }
  }
  cout << ans << endl;

}


/*
                   _ooOoo_
                  o8888888o
                  88" . "88
                  (| -_- |)
                  O\  =  /O
               ____/`---'\____
             .'  \\|     |//  `.
            /  \\|||  :  |||//  \
           /  _||||| -:- |||||-  \
           |   | \\\  -  /// |   |
           | \_|  ''\---/''  |   |
           \  .-\__  `-`  ___/-. /
         ___`. .'  /--.--\  `. . __
      ."" '<  `.___\_<|>_/___.'  >'"".
     | | :  `- \`.;`\ _ /`;.`/ - ` : | |
     \  \ `-.   \_ __\ /__ _/   .-` /  /
======`-.____`-.___\_____/___.-`____.-'======
                   `=---='
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
         pass System Test!
*/


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

//typedef
//------------------------------------------
typedef long long LL;
typedef vector<LL> VL;
typedef vector<VL> VVL;
typedef vector<string> VS;
typedef pair<LL, LL> PLL;

//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())

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

// grid
//--------------------------------------------
VL dx = {0, 1, 0, -1};
VL dy = {1, 0, -1, 0};
VL dx2 = {-1, 0, 1, -1, 1, -1, 0, 1};
VL dy2 = {-1, -1, -1, 0, 0, 1, 1, 1};

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

//IO accelerate
//--------------------------------------------
struct InitIO {
    InitIO() {
        cin.tie(nullptr);
        ios_base::sync_with_stdio(false);
        cout << fixed << setprecision(30);
    }
} init_io;

//template
//--------------------------------------------
template<typename T>
istream& operator >>(istream& is, vector<T>& vec) {
  for(T& x: vec) is >> x;
  return is;
}
template<typename T>
ostream& operator <<(ostream& os, const vector<T>& vec) {
  for(int i=0; i<vec.size(); i++){
    os << vec[i] << ( i+1 == vec.size() ? "" : "\t" );
  }
  return os;
}
template<typename T>
ostream& operator <<(ostream& s, const vector<vector<T>>& vv) {
	for (int i = 0; i < vv.size(); ++i) {
		s << vv[i] << endl;
	}
	return s;
}

// 多重vector
// auto dp=make_v<int>(4,h,w) みたいに使える
template<typename T>
vector<T> make_v(size_t a){return vector<T>(a);}

template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
  return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}

// 多重vectorのためのfill
// fill_v(dp,0) みたいに使える
template<typename T,typename V>
typename enable_if<is_class<T>::value==0>::type
fill_v(T &t,const V &v){t=v;}

template<typename T,typename V>
typename enable_if<is_class<T>::value!=0>::type
fill_v(T &t,const V &v){
  for(auto &e:t) fill_v(e,v);
}

//main code

int main(int argc, char const* argv[])
{
	int n;
	cin >> n;
	cout << (double)(n/2 + (int)n%2) / (double)n << endl;
	return 0;

}


Measured memory_bytes: 256
from collections import deque
n, m = map(int, input().split())
way = [[] for i in range(n + 1)]
ans = [-1 for i in range(n + 1)]
reached = [0 for i in range(n + 1)]
for i in range(m):
    a, b = map(int, input().split())
    way[a].append(b)
    way[b].append(a)
D = deque([1])
while D:
    go = D.popleft()
    for i in way[go]:
        if reached[i] == 0:
            D.append(i)
            reached[i] = 1
            ans[i] = go
print('Yes')
for i in range(2, n + 1):
    print(ans[i])

Measured memory_bytes: 34748
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <functional>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> P;
typedef vector<vector<P>> vvP;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define exrep(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) cout << x << endl
#define exout(x) printf("%.10f\n", x)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define re0 return 0
const ll mod = 1000000007;
const ll INF = 1e16;
const ll MAX_N = 100010;

ll dp[110][110][310];  // dp[i+1][j][k] : i番目の品物まででj個選んで重さの総和k以下のときの価値の総和の最大値

int main() {
    ll n, W;
    cin >> n >> W;

    vl weight(n), value(n);
    rep(i, n) {
        cin >> weight[i] >> value[i];
    }

    ll w0 = weight[0];
    rep(i, n) {
        weight[i] -= w0;
    }
    
    rep(i, n) {
        rep(j, n) {
            exrep(k, 0, 3*n) {
                chmax(dp[i+1][j+1][k], dp[i][j+1][k]);
                if(k >= weight[i]) {
                    chmax(dp[i+1][j+1][k], dp[i][j][k - weight[i]] + value[i]);
                }
            }
        }
    }
    
    ll ans = 0;
    exrep(j, 1, n) {
        exrep(k, 0, 3*n) {
            if(w0*j + k <= W) {
                chmax(ans, dp[n][j][k]);
            }
        }
    }
    
    out(ans);
    re0;
}

Measured memory_bytes: 28544
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(int i = 0; i < (n); i++)
#define all(v) v.begin(), v.end()
#define MOD 1000000007
const int INF = 1LL<<30;

int main(){
    int n,m;
    cin>>n>>m;
    vector<int> a(n);
    rep(i,n) cin>>a[i];
    vector<pair<int,int>> v(m);
    rep(i,m){
        int b,c;
        cin>>b>>c;
        v[i]={c,b};
    }

    sort(all(a));
    sort(all(v));
    reverse(all(v));
    vector<int> com(n,0);
    vector<pair<int,int>> v2;
    int cnt=0;
    rep(i,m){
        if(cnt+v[i].second>n){
            int x=n-cnt;
            v2.push_back({v[i].first,x});
        }
        else{
            cnt+=v[i].second;
            v2.push_back(v[i]);
        }
    }
    int id=0;
    rep(i,v2.size()){
        int add=v[i].second;
        for(int j=id;j<min(id+add,n);j++){
            com[j]=v[i].first;
        }
        id+=add;
        if(id>=n) break;
    }

    //rep(i,n) cout<<com[i]<<" ";
    //cout<<endl;

    ll ans=0;
    rep(i,n){
        ans+=max(a[i],com[i]);
    }

    cout<<ans<<endl;
}

Measured memory_bytes: 5820
#include <iostream>
#include <string>
#include <cstring>
#include <cstdio>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <iomanip>
#if __cplusplus >= 201103L
#include <unordered_map>
#include <unordered_set>
#endif
#define ls ro<<1
#define fi first
#define se second
#define rs ro<<1|1
#define ll long long
#define pb push_back
#define vi vector<int>
#define lowbit(x) x&(-x)
#define pii pair<int,int>
#define lson ro<<1,l,mid
#define umap unordered_map
#define uset unordered_set
#define rson ro<<1|1,mid+1,r
#define int long long
#define mem(a,b) memset(a,b,sizeof(a))
#define IOS ios_base::sync_with_stdio(0); cin.tie(0);cout.tie(0);

using namespace std;

const int INF = 0x3f3f3f3f;
const int N=2e5+10;

struct node{
	int x,w;
}s[N];

int cmp(node a,node b){
	return a.x<b.x;
}

int cmp1(node a,node b){
	return a.x>b.x;
}

int c[N];

signed main() {
	IOS;
	int n,d,a;
	cin>>n>>d>>a;
	for(int i=0;i<n;i++)
		cin>>s[i].x>>s[i].w;
	sort(s,s+n,cmp);
	int ans=0;
	for(int i=0,j=0;i<n;i++){
		while(j<n && s[j].x<=s[i].x+2*d)
			++j;
		int need=max((s[i].w-c[i]*a+a-1)/a,0LL);
		ans+=need;
		c[i]+=need;
		c[j]-=need;
		c[i+1]+=c[i];
	}
	cout<<ans<<endl;
	
}


Measured memory_bytes: 4992
#include<algorithm>
#include<cmath>
#include<iostream>
#include<vector>
#include<string>
using namespace std;
typedef long long ll;

#define REP(i, n) for(ll i=0;i<ll(n); i++)

int main(){
    int N, M;
    int count = 0;
    int i;
    cin >> N >> M;
    for(i=0;i<M;i++){
        int ai;
        cin >> ai;
        count += ai;
    }
    if(N - count >= 0){cout << N - count << endl; return 0;}
    else{cout << "-1" << endl;return 0;}

    return 0;
}


Measured memory_bytes: 3156
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0; i<n; i++)
using namespace std;
int s[1000000];
int n;
bool search(int x){
  int left = 0;
  int right = n;
  int mid;
  while(left<right){
    mid = (left + right)/2;
    if(x==s[mid]) return 1;
    if(x>s[mid]) left = mid+1;
    else if(x<s[mid]) right = mid;
  }
  return 0;
}
int main(){
  int m,cnt=0;
  int t[1000000];
  cin >> n;
  rep(i,n) cin >> s[i];
  cin >> m;
  rep(i,m) cin >> t[i];
  sort(s,s+n);
  sort(t,t+m);
  rep(i,m){
    int x = t[i];
    if(search(x)) cnt++;
  }
  cout << cnt << endl;
  return 0;
}



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

using namespace std;

int main() {

    long long int x = 100;
    long long int y;
    cin>>y;

    int res = 0;
    for(res = 0; res < 100000;res++)
    {
        if( x >=y)
            break;
        x += (x/100);
    }

    cout<<res<<endl;
  return 0;
}


Measured memory_bytes: 3628
#include<bits/stdc++.h>
using namespace std;
int x_1,x2,x3,x4;
int y_1,y2,y3,y4;
int a,b;
int main() {
	cin>>x_1>>y_1>>x2>>y2;
	a=x_1-x2;
	b=y_1-y2;
	x3=x2+b;
	y3=y2-a;
	x4=x_1+b;
	y4=y_1-a;
	cout<<x3<<" "<<y3<<" "<<x4<<" "<<y4;
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	static int N;
	static int[][] cost;

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		N = Integer.parseInt(sc.nextLine());
		cost = new int[N][3];
		for (int i = 0; i < N; i++) {
			String[] line = sc.nextLine().split(" ");
			cost[i][0] = Integer.parseInt(line[0]);
			cost[i][1] = Integer.parseInt(line[1]);
			cost[i][2] = Integer.parseInt(line[2]);
		}

		int[][] dp = new int[N + 1][3];
		for (int i = 0; i < N; i++) {
			for (int j = 0; j < 3; j++) {
				for (int k = 0; k < 3; k++) {
					if (j == k)
						continue;
					dp[i + 1][k] = Math.max(dp[i + 1][k], dp[i][j] + cost[i][k]);
				}
			}
		}
		System.out.println(Math.max(dp[N][0], Math.max(dp[N][1], dp[N][2])));
	}
}

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

using ll = long long;

constexpr ll mod = 1000000007;

int solve() {
	int N, M; cin >> N >> M;
	ll r = 0, c = 0;
	vector<bool> nr(N*M, false), nc(N*M, false);
	for (int i = 0; i < N; i++) {
		int x; cin >> x; x--; if (nr[x]) return 0;
		nr[x] = true;
	}
	for (int i = 0; i < M; i++) {
		int x; cin >> x; x--; if (nc[x]) return 0;
		nc[x] = true;
	}
	ll res = 1;
	for (int i = N * M - 1; i >= 0; i--) {
		if (nr[i]) r++;
		if (nc[i]) c++;
		if (nr[i] && nc[i]) continue;
		else if (nr[i]) res = res * c % mod;
		else if (nc[i]) res = res * r % mod;
		else res = res * (r * c - (N * M - 1 - i)) % mod;
		// cout << r << " " << c << " " << res << " " << i + 1 << endl;
	}
	return res;
}

int main() {
	cout << solve() << endl;
}

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

const int64_t MOD = 1e9+7;
void add(int64_t& a, int64_t b){
    a = (a+b) % MOD;
}
void mul(int64_t& a, int64_t b){
    a = a*b % MOD;
}

vector<int64_t> fact, seq_inv, fact_inv;

void create_fact_mod(int num){
    fact[0] = fact[1] = 1;
    for(int i=2; i<=num; i++) fact[i] = fact[i-1] * i % MOD;
}

void create_seq_inv_mod(int num){
    seq_inv[0] = seq_inv[1] = 1;
    for(int i=2; i<=num; i++) seq_inv[i] = (MOD - MOD/i) * seq_inv[MOD%i] % MOD;
}

void create_fact_inv_mod(int num){
    fact_inv[0] = fact_inv[1] = 1;
    for(int i=2; i<=num; i++) fact_inv[i] = fact_inv[i-1] * seq_inv[i] % MOD;
}

void create_mod_tables(int num){
    fact.resize(num+1);
    seq_inv.resize(num+1);
    fact_inv.resize(num+1);
    create_fact_mod(num);
    create_seq_inv_mod(num);
    create_fact_inv_mod(num);
}

int64_t comb_mod(int n, int k){
    return fact[n] * fact_inv[n-k] % MOD * fact_inv[k] % MOD;
}

int64_t perm_mod(int n, int k){
    return fact[n] * fact_inv[n-k] % MOD;
}

int64_t power_mod(int64_t num, int64_t power){
    int64_t prod = 1;
    num %= MOD;
    while(power > 0){
        if(power&1) prod = prod * num % MOD;
        num = num * num % MOD;
        power >>= 1;
    }
    return prod;
}

int64_t extgcd(int64_t a, int64_t b, int64_t& x, int64_t& y){
    int64_t d = a;
    if(b != 0){
        d = extgcd(b, a%b, y, x);
        y -= (a/b) * x;
    }else{
        x = 1; y = 0;
    }
    return d;
}

int64_t inv_mod(int64_t a){
    int64_t x, y;
    extgcd(a, MOD, x, y);
    return (MOD + x%MOD) % MOD;
}

int main(){
    int N, K;
    cin >> N >> K;
    K = min(K, N-1);
    create_mod_tables(400000);
    int64_t ans = 0;
    for(int i=0; i<=K; i++){
        int64_t res = comb_mod(N, i);
        mul(res, comb_mod(N-1, i));
        add(ans, res);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 9600
/*
 *
 *    I am o0o0oo00.
 *
 */
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define ll          long long
#define p7          1000000007
#define p9          998244353
#define pb          push_back
#define ff          first
#define ss          second
#define vll         vector<ll>
#define pll         pair<ll,ll>
#define vpll        vector<pll>
#define mll         map<ll,ll>
#define test        ll T;cin>>T;while(T--)
#define ad(a,n)     vll a;a.resize(n);for(ll i=0;i<n;i++)cin>>a[i];
#define as(a,n)     for(ll i=0;i<n;i++){cout<<a[i]<<" ";}cout<<endl;
#define all(x)      x.begin(),x.end()

typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> pbds;

ll powm(ll x, ll y, ll m = p7) {
    x = x % m; ll res = 1; while (y)
    {if (y & 1)res = res * x; res %= m; y = y >> 1; x = x * x; x %= m;} return res;
}
ll modi(ll a, ll m = p7) {return powm(a, m - 2, m);}
void yesno(bool f) {f ? cout << "YES" << endl : cout << "NO" << endl;}


void ss99()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
}

ll dp[105][100005];

int32_t main()
{
    ss99();
//    test
    {
        ll n, k; cin >> n >> k;
        ll a[n + 1] = {0};
        for (ll i = 1; i <= n; i++)
            cin >> a[i];
        for (ll i = 0; i <= n; i++)
        {
            for (ll j = 0; j <= k; j++)
            {
                if (j == 0)
                    dp[i][j] = 1;
                else if (i == 0)
                    dp[i][j] = 0;
                else
                {
                    dp[i][j] = (dp[i - 1][j] + dp[i][j - 1]) % p7;
                    if (j > a[i])
                    {
                        dp[i][j] = (dp[i][j] - dp[i - 1][j - a[i] - 1] + p7) % p7;
                    }
                }
            }
        }
        /*    for (ll i = 0; i <= n; i++)
            {
                for (ll j = 0; j <= k; j++)
                {
                    cout << dp[i][j] << " ";
                }
                cout << endl;
            }*/
        cout << dp[n][k] << endl;
    }
    return 0;
}

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

using namespace std;
using ll = long long;
using vec = vector<ll>;
using mat = vector<vec>;
using pll = pair<ll,ll>;

#define INF (1LL << 60)
#define MOD 1000000007
#define PI 3.14159265358979323846

#define REP(i,m,n) for(ll (i)=(m),(i_len)=(n);(i)<(i_len);++(i))
#define FORR(i,v) for(auto (i):v)
#define ALL(x) (x).begin(), (x).end()
#define PR(x) cout << (x) << endl
#define PS(x) cout << (x) << " "
#define SZ(x) ((ll)(x).size())
#define MAX(a,b) (((a)>(b))?(a):(b))
#define MIN(a,b) (((a)<(b))?(a):(b))
#define REV(x) reverse(ALL((x)))
#define ASC(x) sort(ALL((x)))
#define DESC(x) ASC((x)); REV((x))
#define pb push_back
#define eb emplace_back

int main()
{
    ll N;
    cin >> N;
    vec P(N);
    REP(i,0,N) cin >> P[i];

    ll m = P[0], cnt = 1;
    REP(i,1,N) {
        if(m > P[i]) {
            m = MIN(m,P[i]);
            ++cnt;
        }
    }
    PR(cnt);

    return 0;
}

/*


4 2 5 1 3
*/

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


ll no[10000005];


int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
//    ll x;
//    x=1ll << 59;
//    ll y=(1ll << 59) - 1ll;
//    cout<<((double)(x)==(double)(x-1))<<endl;
    ll n;
    cin>>n;
    no[1]=1;
    for(int i=2;i<=n;i++){no[i]++;
        for(int j=i;j<=n;j+=i)no[j]++;
    }
    ll s=0;
    for(int i=1;i<=n;i++)s+=(ll)(i*no[i]);
    cout<<s;
}


Measured memory_bytes: 81772
from sys import stdin
input = stdin.readline

N, A, B = map(int, input().split())
S = input().rstrip()

a = 0
b = 0

for s in S:
    if s == "a":
        if a + b < A + B:
            a += 1
            print("Yes")
        else:
            print("No")
    elif s == "b":
        if a + b < A + B and b < B:
            b += 1
            print("Yes")
        else:
            print("No")
    else:
        print("No")


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

int main(){
    string S;
    cin >> S;
    int n = S.size();
    vector<int> T(n+1,0);
    int p = 1;
    for(int i = n - 1;i >= 0;i--){
        T[i] = T[i + 1] + p*(S[i] - '0');
        T[i] %= 2019;
        p *= 10;
        p %= 2019;
    }
    vector<int> count(2019,0);
    for(int i=0;i < n+1;i++){
        count[T[i]]++;
    }
    int ans = 0;
    for(int i=0;i < 2019;i++){
        ans += count[i]*(count[i] - 1)/2;
    }
    cout << ans << endl;
}

Measured memory_bytes: 4452
r,g,b,n = map(int, input().split())
ans = 0
#print('i,r,j,g,k,b')
r,g,b = sorted([r,g,b], reverse=True)
for i in range(n//r+1):
    for j in range((n-r*i)//g+1):
        k = n-i*r-j*g
        #print(i,r,j,g,k,b, '===', i+j+k, i*r + j*g + k*b)
        if k%b==0:
            ans += 1
print(ans)

Measured memory_bytes: 3060
#include "bits/stdc++.h"
#include <math.h>
#include <time.h>
using namespace std;
const long long mod = 1000000007;
#define dump(x)                             \
    if (dbg) {                              \
        cout << #x << " = " << (x) << endl; \
    }
bool dbg = false;
long long gcd(long long a, long long b){
   if (a % b == 0)
   {
       return(b);
   }
   else
   {
       return(gcd(b, a % b));
   }
}
long long lcm(long long a, long long b){
   return (a / gcd(a, b))* b;
}
//---------------------------------------------------------------------------------------------------
/*ここからいじる*/
//---------------------------------------------------------------------------------------------------

void solve(){
    int n;
    string x;
    cin >> n;
    vector<string>sn(n);
    vector<int>tn(n);
    int ans = 0;
    for(int i = 0; i < n; i++){
        cin >> sn.at(i) >> tn.at(i);
        ans += tn.at(i);
    }
    cin >> x;
    for(int i = 0; i < n; i++){
        ans -= tn.at(i);
        if(sn.at(i) == x){
            break;
        }
    }
    cout << ans << endl;

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



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

int main()
{
	int x = 0;
	int ans = 0;
	int N;
	char c[100];
	cin >> N;
	for (int i = 0; i < N; i++) {
		cin >> c[i];
		if (c[i] == 'I') {
			x++; 
			
		}
		else x--;

		ans = max(ans, x);
	}
	cout << ans;

    return 0;
}

Measured memory_bytes: 256
#include<algorithm>
#include<iostream>
#include<utility>

typedef std::pair<int, int> P;

int main()
{
	int s1, s2;
	while( std::cin >> s1 >> s2, s1 | s2 )
	{
		P ans( s1 + s2, 0 );
		for( int i = 0; i != 4; ++i )
		{
			std::cin >> s1 >> s2;
			ans = std::max( ans, P( s1 + s2, i + 1 ) );
		}
		std::cout << char( 'A' + ans.second ) << ' ' << ans.first << std::endl;
	}

	return 0;
}

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

int main(){
	string s;
	cin>>s;
	long long int n = s.length();
	// set <pair<int, int> > palin;
	long long int ans = 0;
	vector <int> pos[26];
	for(int j = 0; j<n; j++){
		pos[s[j]-'a'].push_back(j);
	}
	for(int i = 0; i<26; i++){
		long long int k = pos[i].size();
		ans+=k*(k-1)/2;
	}
	cout<<(n*(n-1))/2 - ans + 1<<endl;
	return 0;
}

Measured memory_bytes: 1908
// Never let them see you bleed...

#include<bits/stdc++.h>

#define F first
#define S second
#define PB push_back
#define sz(s) int((s).size())
#define bit(n,k) (((n)>>(k))&1)

using namespace std;

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

const int maxn = 1e5 + 10, mod = 1e9 + 7;
const ll inf = 1e18;

map<ll, ll> mp;
ll a, b, c, d;

ll solve(ll n){
    if(n == 0)
	return 0;
    if(n == 1)
	return d;
    if(mp.count(n))
	return mp[n];
    ll r = n % 2;
    ll ans = inf;
    if(d <= (inf / n))
	ans = min(ans, d * n);
    if(r == 0)
    	ans = min(ans, a + solve(n/2));
    else
	ans = min(ans, a + min(d + solve((n-1)/2), d + solve((n+1)/2)));
    r = n % 3;
    if(r == 0)
    	ans = min(ans, b + solve(n/3));
    else
	ans = min(ans, b + min(r * d + solve((n-r)/3), (3-r) * d + solve((n+3-r)/3)));
    r = n % 5;
    if(r == 0)
    	ans = min(ans, c + solve(n/5));
    else
	ans = min(ans, c + min(r * d + solve((n-r)/5), (5-r) * d + solve((n+5-r)/5)));
    return mp[n] = ans;
}

int main(){
    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie();
    
    int q;
    cin >> q;    
    while(q--){
	ll n;
	cin >> n >> a >> b >> c >> d;
	mp.clear();
	cout << solve(n) << "\n";
    }    	
}


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

int main() {
  string s;
  cin >> s;
  int ans = 0;
  for(int i = 0; i < s.size(); ++i) {
    if(s[i] == '1') {
      ans++;
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
import sys

stdin = sys.stdin

ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline().rstrip()  # ignore trailing spaces


s, t = ns().split()
a, b = na()
u = ns()
if s == u:
    a -= 1
else:
    b -= 1
print(a, b)


Measured memory_bytes: 3060
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<cmath>
#include<set>
#include<map>
//#include<bits/stdc++.h>
#define int long long
#define mod 1000000007
#define for0(i, n) for(int i = 0; i < (n); i++)
#define for1(i, n) for(int i = 1; i <= (n);i++)
#define mp make_pair
#define all(x) x.begin(),x.end()
using namespace std;
signed main() {
	string s; cin >> s;
	for (char ch : s)cout << (ch == '1' ? 9 : 1); cout << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
using namespace std;
#define BIG_NUM 1000000000000000000LL
 
int main()
{
    int n;
    cin >> n;
    vector<unsigned long long> vec(n);
    long long int ans = 1;
    for(int i = 0; i < n; ++i)
    {
        cin >> vec[i];
        if(vec[i] == 0)
        {
            ans = 0;
        }
    }
 
    if(ans == 0)
    {
        cout << ans << endl;
        return 0;
    }
 
    for(int i = 0; i < n; ++i)
    {
        long long preb = ans;
        ans *= vec[i];
        if(ans > BIG_NUM
        || ans <= 0
        || (preb * (long long)vec[i]) % (BIG_NUM+1) != ans)
        {
            cout << -1 << endl;
            return 0;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 4016
#include <bits/stdc++.h>
using namespace std;
using u64 = uint64_t;

int main() {
	u64 N, M;
	cin >> N >> M;
	
	u64 asum = 0;
	vector<u64> A(N);
	for(u64 i=0; i<N; i++) {
		cin >> A[i];
		asum += A[i];
	}
	
	sort(A.begin(), A.end(), greater<u64>());
	
	for(u64 i=0; i<M; i++) {
		if(A[i] * 4 * M < asum) {
			cout << "No";
			return 0;
		}
	}
	
	cout << "Yes";
	return 0;
}


Measured memory_bytes: 256