akhauriyash/Code-Regression huggingface dataset:
import java.util.*;

public class Main {
	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		int N = sc.nextInt();
		char[] s = sc.next().toCharArray();
		
		long B1 = 1007;
		long B2 = 1009;
		long MOD1 = 1000000007;
		long MOD2 = 1000000009;
		
		long[][][] hash = new long[2][N/2+1][N];
		for(int i=0; i<2; i++)
			Arrays.fill(hash[i][0], 1);
		for(int i=0; i<N; i++) {
			for(int j=0; j<N/2 && i+j<N; j++) {
				hash[0][j+1][i] = (hash[0][j][i]*B1+(s[i+j]-'a'))%MOD1;
//				hash[1][j+1][i] = (hash[1][j][i]*B1+(s[i+j]-'a'))%MOD2;
//				hash[2][j+1][i] = (hash[2][j][i]*B2+(s[i+j]-'a'))%MOD1;
//				hash[3][j+1][i] = (hash[3][j][i]*B2+(s[i+j]-'a'))%MOD2;
				hash[1][j+1][i] = (hash[1][j][i]*B2+(s[i+j]-'a'))%MOD2;
			}
		}
		
		for(int i=N/2; i>=0; i--) {
			HashSet<Long> set1 = new HashSet<>();
			HashSet<Long> set2 = new HashSet<>();
//			HashSet<Long> set3 = new HashSet<>();
//			HashSet<Long> set4 = new HashSet<>();
			for(int j=i; j<=N-i; j++) {
				set1.add(hash[0][i][j-i]);
				set2.add(hash[1][i][j-i]);
//				set3.add(hash[2][i][j-i]);
//				set4.add(hash[3][i][j-i]);
//				if(set1.contains(hash[0][i][j]) && set2.contains(hash[1][i][j]) && set3.contains(hash[2][i][j]) && set4.contains(hash[3][i][j])) {
				if(set1.contains(hash[0][i][j]) && set2.contains(hash[1][i][j])) {
					System.out.println(i);
					sc.close();
					return;
				}
			}
		}
		
		sc.close();
	}
}



Measured memory_bytes: 455704
#![allow(unused_imports)]

use text_io::*;
use proconio::*;
use std::collections::*;
use itertools::Itertools;
use std::process::exit;
use std::cmp::*;
use num::*;
use num::integer::Roots;

fn main() {
    input! {
    a:usize,
    b:String,
    c:String,
    d:String,
    }
    let mut b=b.chars().collect_vec();
    let mut c=c.chars().collect_vec();
    let mut d=d.chars().collect_vec();
    let mut e=0;
    for i in 0..b.len(){
        if b[i]==c[i]&&c[i]==d[i]{e+=0}
        else if b[i]==c[i]||c[i]==d[i]||d[i]==b[i]{e+=1}
        else{e+=2}
    }
    println!("{}",e)
}

Measured memory_bytes: 2160
#include "bits/stdc++.h"
using namespace std;

//?????????
#pragma region MACRO 
#define putans(x)  std::cerr << "[ answer ]: " ; cout << (x) << endl
#define dputans(x) std::cerr << "[ answer ]: "; cout << setprecision(27) << (double)(x) << endl
#define REP(i,a,n) for(int i=(a); i<(int)(n); i++)
#define RREP(i,a,n) for(int i=(int)(n-1); i>= a; i--)
#define rep(i,n) REP(i,0,n)
#define rrep(i,n) RREP(i,0,n)
#define all(a) begin((a)),end((a))
#define mp make_pair
#define exist(container, n) ((container).find((n)) != (container).end())
#define equals(a,b) (fabs((a)-(b)) < EPS)
#ifdef _DEBUG //???????????????????????????????????????????????????
std::ifstream ifs("data.txt");
#define put ifs >>
#else //?????£????????????????????§?????????????????????
#define put cin >>
#endif
#pragma endregion
//???????????°??????????????´
#pragma region CODING_SUPPORT
#ifdef _DEBUG
#define dbg(var0) { std::cerr << ( #var0 ) << "=" << ( var0 ) << endl; }
#define dbg2(var0, var1) { std::cerr << ( #var0 ) << "=" << ( var0 ) << ", "; dbg(var1); }
#define dbg3(var0, var1, var2) { std::cerr << ( #var0 ) << "=" << ( var0 ) << ", "; dbg2(var1, var2); }
#define dbgArray(a,n) {std::cerr << (#a) << "=";  rep(i,n){std::cerr <<(a[i])<<",";} cerr<<endl;} 
#else
#define dbg(var0) {}
#define dbg2(var0, var1) {}
#define dbg3(var0, var1, var2) {}
#define dbgArray(a,n) {}
#endif 
#pragma endregion 
//typedef????????????????????????????¶????????????§?????????
#pragma region TYPE_DEF
typedef long long ll;
typedef pair<int, int> pii; typedef pair<string, string> pss; typedef pair<int, string>pis;
typedef vector<string> vs; typedef vector<int> vi;
#pragma endregion
//??????????????°(???????????????????????§??????)
#pragma region CONST_VAL
#define PI (2*acos(0.0))
#define EPS (1e-10)
#define MOD (ll)(1e9 + 7)
#define INF (ll)(2*1e9)
#pragma endregion

struct edge { int to, cap, rev; };

static const int MAX_V = 1000;
vector<edge> G[MAX_V];
bool used[MAX_V];

void addEdge(int from, int to, int cap) {
	G[from].push_back({ to,cap,(int)G[to].size() });
	G[to].push_back({ from,0,(int)G[from].size() - 1 });
}

int dfs(int v, int t, int f) {
	if (v == t) return f;
	used[v] = true;
	for (int i = 0; i < G[v].size(); i++) {
		edge &e = G[v][i];
		if (!used[e.to] && e.cap > 0) {
			int d = dfs(e.to, t, min(f, e.cap));
			if (d > 0) {
				e.cap -= d;
				G[e.to][e.rev].cap += d;
				return d;
			}
		}
	}
	return 0;
}

int maxFlow(int s, int t) {
	int flow = 0;
	for (;;) {
		fill(used, used + MAX_V, 0);
		int f = dfs(s, t, INF);
		if (f == 0) return flow;
		flow += f;
	}
}


int main() {
	int x, y, e; put x >> y >> e;
	int s = x+y;
	int t = s+1;
	rep(i, x) {
		addEdge(s, i, 1);
	}
	rep(i, y) {
		addEdge(x + i, t, 1);
	}
	rep(i, e) {
		int xi, yi;
		put xi >> yi;
		addEdge(xi, x + yi, 1);
	}
	cout << maxFlow(s, t) << endl;
END:
	return 0;
}

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

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            var rl = Console.ReadLine().Split(' ');
            var a = int.Parse(rl[0]);
            var b = int.Parse(rl[1]);
            var c = int.Parse(rl[2]);

            var list = new List<int>();
            list.Add(a + b);
            list.Add(c + b);
            list.Add(a + c);

            Console.WriteLine(list.Min());

        }
    }
}

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

int main(){
    int N,i,j;
    int result;
    int cn;
    int result_max=0;
    cin>>N;
    vector<int> H(N);
    for(i=0;i<N;i++)cin>>H[i];

    for(i=0;i<N-1;i++){
        if(N-1-i<result_max){
            break;
        }else{
            result=0;
            cn=H[i];
            for(j=i+1;j<N;j++){
                if(cn>=H[j]){
                    result+=1;
                    cn=H[j];
                }else{
                    break;
                }
            }
            if(result>result_max){
                result_max=result;
            }
        }
    }
    cout<<result_max<<endl;
    return 0;
}

Measured memory_bytes: 640
// K - One Card Poker
#include <iostream>
using namespace std;
int main (){
double a,b;
cin>>a>>b;
if (a>=1&&a<=10^100&&b>=1&&b<=10^100)
    if (a>b)
    cout<<"GREATER"<<endl;
else if(a<b)
    cout<<"LESS"<<endl;
    else
    cout<<"EQUAL"<<endl;

return 0;

}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
int main(){
    int n; cin>>n;
    int ac=0,wa=0,tle=0,re=0;
    string status[n];
    for(int i = 0; i<n; i++){
        cin>>status[i];
        if(status[i]=="AC"){
            ac++;
        }
        if(status[i]=="WA"){
            wa++;
        }
        if(status[i]=="TLE"){
            tle++;
        }
        if(status[i]=="RE"){
            re++;
        }
    }
    cout << "AC x " << ac << endl << "WA x " << wa << endl << "TLE x " << tle << endl << "RE x " << re << endl;
}

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

void main() {
    int n = readln.chomp.to!int;
    int[] a = 0~readln.split.map!(to!int).array;
    int ans = 0;
    for(int i = 1; i <= a.length; i++)
        if(i%2 == 1 && a[i]%2 == 1)
            ans += 1;
    ans.writeln;
}


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

using namespace std;

int main() {
	int n, y;
	scanf("%d %d", &n, &y);
	int c1 = y / 10000;
	int c2 = y / 5000;
	int c3 = y / 1000;
	for (int i = 0; i <= c1; i++) {
		for (int j = 0; j <= c2; j++) {
			for (int k = 0; k <= c3; k++) {
				if (i + k + j == n) {
					int cur = i * 10000 + j * 5000 + k * 1000;
					if (cur == y) {
						printf("%d %d %d\n", i, j, k);
						return 0;
					}
				}
				else if (i + k + j > n) {
					   break;
				}
			}
		}
	}
	printf(" -1 -1 -1\n");
	return 0;
}

Measured memory_bytes: 256
const double = Float64
const int = Int64
const vint = Vector{int}
const vdouble = Vector{double}

int(x) = parse(int,x)

parseint(x) = parse(int, x)
readint() = map(parseint, split(readline()))

function main()
  a,b,n = readint()
  

  c = div(a*min(n,b-1),b) - a * div(min(n,b-1),b)
  println(c)
end

main()

Measured memory_bytes: 214192
import math
s = int(input())
r = math.floor(math.sqrt(s)) + 1
k = r**2 - s
if r == 10**9 + 1:
    print("{} {} {} {} {} {}".format(0, 0, 1,r - 1,r - 1, 0))
    exit()
def search_prime(k):
    p = math.floor(math.sqrt(k))
    for i in range(2,p + 1):
        if k % i == 0:
            return i
    return 1
prime = search_prime(k)
print("{} {} {} {} {} {}".format(0, 0, prime,r,r, int(k / prime)))


Measured memory_bytes: 3064
# Hcm(横線可能位置は1~H), 縦線W本, goal K
H, W, K = gets.split.map(&:to_i)

dp = Array.new(H + 1) { Array.new(W, 0) }
dp[0][0] = 1
0.upto(H-1) do |h|
  0.upto(W-1) do |w|
    0.upto(2 ** (W - 1) - 1) do |i|
      valid = true
      1.upto(W - 2) do |j|
        if i[j] == 1 && i[j-1] == 1
          valid = false
          break
        end
      end
      next unless valid

      dp[h+1][w-1] += dp[h][w] if w > 0 && i[w - 1] == 1
      dp[h+1][w] += dp[h][w] if i[w] != 1 && (w == 0 || i[w-1] != 1)
      dp[h+1][w+1] += dp[h][w] if w < W - 1 && i[w] == 1
      # p "#{h} #{w} #{('%07d' % i.to_s(2).to_i).reverse} #{dp}"
    end
  end
end

# p dp
puts dp[H][K - 1] % 1_000_000_007

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

using namespace std;
#define all(a)a.begin(),a.end()
using ll=long long;
const int INF = 1<<30;
const ll INFll =1LL<<62;
const int mod= int(1e9)+7;
using P = pair<ll,ll>;
using ld=long double;

int main(){
    int h,w;cin >>h>>w;
    vector<string>s(h);
    for (int i = 0; i < h; ++i) {
        cin >>s[i];
    }
    vector<int>al(26,0);
    for (int i = 0; i < h; ++i) {
        for (int j = 0; j < w; ++j) {
           al[s[i][j]-'a']++;
        }
    }
    if(h%2==0&&w%2==0){
        for (int i = 0; i < 26; ++i) {
            if(al[i]%4!=0){
                puts("No");
                return 0;
            }
        }
        puts("Yes");
    }
    else if(h%2==1&&w%2==1){
        int k=h/2+w/2;
        int cnt1=0;
        int cnt2=0;
        for (int i = 0; i < 26; ++i) {
//            cout <<char('a'+i)<<" "<<al[i]<<endl;
            if(al[i]%4==1){
                cnt1++;
                if(cnt1>1){
                    puts("No");
                    return 0;
                }
            }
            if(al[i]%4==2){
                cnt2++;
                if(cnt2>k){
                    puts("No");
                    return 0;
                }
            }
        }
        if(cnt1==0){
            puts("No");
        }
        else {
            puts("Yes");
        }
    }
    else {
        int k;
        if(h%2==1)k=w/2;
        else k=h/2;
        int cnt2=0;
        for (int i = 0; i < 26; ++i) {
            if(al[i]%4==0)continue;
            if(al[i]%4==2)cnt2++;
            else {
                puts("No");
                return 0;
            }
            if(cnt2>k){
                puts("No");
                return 0;
            }
        }
        puts("Yes");
    }
}


Measured memory_bytes: 3644
# 1つづつ順に
# V << W なので、 dp[N][W]ではなく、 dp[N][V]で作成
def resolve():
    N, W = map(int, input().split())
    w_l = []
    v_l = []
    for _ in range(N):
        w, v = map(int, input().split())
        w_l.append(w)
        v_l.append(v)

    max_v = sum(v_l) + 1
    dp = [[10**10] * (max_v) for _ in range(N+1)] 
    dp[0][0] = 0

    for i in range(N):
        for j in range(max_v):
            #print(i, j)
            w = w_l[i]
            v = v_l[i]
            if j < v:
                dp[i+1][j] = dp[i][j]
            else:
                dp[i+1][j] = min(dp[i][j], dp[i][j - v] + w)
 
    res = 0
    for j in range(max_v):
        if dp[N][j] <= W:
            res = j

    print(res)

if __name__ == "__main__":
    resolve()

Measured memory_bytes: 119152
#include<cstdio>
#include<cstdlib>
#include<cstring>
struct Node{
 int key;
 Node *next,*prev;
};
Node *nil;
Node* listSearch(int key){
 Node *cur=nil->next;
 while(cur!=nil&&cur->key!=key){
  cur=cur->next;
 }
 return cur;
}
void init(){
 nil=(Node *)malloc(sizeof(Node));
 nil->next=nil;
 nil->prev=nil;
}
void printList(){
 Node *cur=nil->next;
 int isf=0;
 while(1){
  if(cur==nil)break;
  if(isf++>0)printf(" ");
  printf("%d",cur->key);
  cur=cur->next;
 }
 printf("\n");
}
void deleteNode(Node *t){
 if(t==nil)return;
 t->prev->next=t->next;
 t->next->prev=t->prev;
 free(t);
}
void deleteFirst(){
 deleteNode(nil->next);
}
void deleteLast(){
 deleteNode(nil->prev);
}
void deleteKey(int key){
 deleteNode(listSearch(key));
}
void insert(int key){
 Node *x=(Node *)malloc(sizeof(Node));
 x->key=key;
 x->next=nil->next;
 nil->next->prev=x;
 nil->next=x;
 x->prev=nil;
}
int main(){
 int key,n,i;
 int size=0;
 char com[20];
 int np=0,nd=0;
 scanf("%d",&n);
 init();
 for(i=0;i<n;i++){
  scanf("%s%d",com,&key);
  if(com[0]=='i'){insert(key);np++;size++;}
  else if(com[0]=='d'){
   if(strlen(com)>6){
    if(com[6]=='F')deleteFirst();
    else if(com[6]=='L')deleteLast();
   }else{
    deleteKey(key);nd++;
   }
   size--;
  }
 }
 printList();
 return 0;
}


Measured memory_bytes: 33888
#include <algorithm>
#include <cmath>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <stack>
#include <string>
#include <vector>
typedef long long ll;
using namespace std;
const int MOD = (int)1e9 + 7;
const ll INF = (ll)1e18 + 7;
#define int long long
#define vint vector<int>
#define pint pair<int, int>
#define pb(a) push_back(a)
#define all(v) v.begin(), v.end()
#define dbg(x) cerr << #x << " = " << (x) << endl
#define yn(b) cout << ((b) ? "Yes" : "No") << endl
#define YN(b) cout << ((b) ? "YES" : "NO") << endl

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

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

	int N;
	cin >> N;

	bool flg = false;
	int ans = 0;

	for (int i = 0; i < 500000; i++) {
		if (N == i * 108 / 100) {
			flg = true;
			ans = i;
		}
	}

	if (flg) {
		cout << ans << endl;
	} else {
		cout << ":(" << endl;
	}

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <vector>
#include <queue>
#include <numeric>
#include <string>
#include <string.h>
#include <map>
#include <set>
#include <functional>
#include <complex>
#include <stack>
#include <tuple>

#define ll long long int

using namespace std;

const int INF = (1<<30) - 1;


int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    int W, D;
    while(cin>>W>>D, W|D){
        vector<vector<int>> table(2, vector<int>(20));
        
        for(int i=0; i<W; i++){
            int t; cin >> t; t--;
            table[0][t]++;
        }
        for(int i=0; i<D; i++){
            int t; cin >> t; t--;
            table[1][t]++;
        }
        
        int ans = 0;
        for(int i=0; i<20; i++){
            int m = min(table[0][i], table[1][i]);
            ans += (table[0][i] + table[1][i] - m) * (i+1);
        }
        
        cout << ans << endl;
    }
    
    return 0;
}

Measured memory_bytes: 1208
#include <stdio.h>

int main(int argc, const char * argv[])
{
    int min,max,tmp;
    while(1){
        scanf("%d %d",&min,&max);
        
        if(min==0 && max==0){
            break;
        }
        
        if(min>max){
            printf("%d %d\n",max,min);
        }else{
            printf("%d %d\n",min,max);
        }
    }
    return 0;
}

Measured memory_bytes: 600
N=input()
name=[]
sec=[]
for i in range(int(N)):
  p=input()
  plist=p.split(" ")
  name.append(plist[0])
  sec.append(plist[1])
X=input()
flag=0
sec_total=0
for i in range(int(N)):
  if(flag==1):
    sec_total+=int(sec[i])
  if(X==name[i]):
    flag=1
print(sec_total)


Measured memory_bytes: 3060
#include <cmath>
#include <vector>
#include <string>
#include <iostream>
#include <algorithm>
#include <map>
#include <set>
using namespace std;
#define REP(i,n) for(int i = 0; i < n; i++)

int main(void)
{
    int N, D, X;
    cin >> N;
    cin >> D >> X;
    int a[N];

    for(int i = 0; i < N; i++){
        cin >> a[i];
    }

    int d[N] = {0};
    for(int i = 0; i < N; i++){
        int c = 0;
        while(c * a[i] + 1 <= D)
        {
            d[i]++;
            c++;
        }
    }

    int sum = 0;
    for(int i = 0; i < N; i++){
        sum += d[i];
    }
    cout << sum + X << endl;

}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main (){
    while(true){
    int n;
    cin >> n;
    int max=0;
    int min = 10000;
    int sum = 0;
    int x;
    int count =0;
    
    if(n==0)return 0;
    for(int i=0;i<n;i++){
        cin >> x;
        if(min>x)min=x;
        if(max<x)max=x;
        sum = sum + x;
        count++;
    }
    int average;
    average = (sum -min -max)/(count-2);
    cout << average << endl;
    }

}

Measured memory_bytes: 3016
#include<bits/stdc++.h>
using namespace std;
int n, i, temp, a[200100];
int main()
{
    cin >> n;
    for(i=2;i<=n;i++)
    {
        cin >> temp;
        a[temp]++;
    }
    for(i=1;i<=n;i++)
    {
        cout << a[i] << endl;
    }
}


Measured memory_bytes: 4336
#ifdef _DEBUG
#include "MyLib.h"
#else
#define main_B main
#include "bits/stdc++.h" 
#include <regex>
#define _USE_MATH_DEFINES
#include <math.h>
#define FOR(i,s,e) for (int i = int(s); i < int(e); ++i)
#define REP(i,e) FOR(i,0,e)
#define INF (INT_MAX/2)
#define EPS (1.0e-8)
#define LINF (LONG_MAX/2)
const int MGN = 8;
const int ARY_SZ_MAX = 10000000;
using namespace std;
using ll = long long; using ull = unsigned long long;
using vi = vector<int>; using vvi = vector<vi>; using vvvi = vector<vvi>;
using vb = vector<bool>; using vvb = vector<vb>; using vvvb = vector<vvb>;
using vl = vector<ll>; using vvl = vector<vl>;
using vd = vector<double>; using vs = vector<string>;
using pii = pair<int, int>; using pll = pair<ll, ll>;
// functions

#endif


int main_B() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int A, B; cin >> A >> B;
    
    int ans = 0;

    FOR(i,A,B+1) {
        // abcba : a (0,9], b [0,9], c [0,9]
        FOR(a,1,10){
            REP(b,10){
                REP(c,10) {
                    if (10001 * a + 1010 * b + 100 * c == i) ans++;
                }
            }
        }
    }
  
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
from sys import exit

n = int(input())
data = [[int(j) for j in input().split()] for i in range(n)]

t = 0
data.sort(key=lambda x: x[1])
for d in data:
    t += d[0]
    if t > d[1]:
        print('No')
        exit()
print('Yes')


Measured memory_bytes: 41176
// include
// ------------------------------------------------
#include <bits/stdc++.h>
#include <vector>
#include <algorithm>
#include <math.h>

using namespace std;

// func
// ------------------------------------------------
int CalcSumOfDigit(int n);      // 各桁の和を計算する。

// define
// ------------------------------------------------
#define all(a)        (a).begin(),(a).end()
#define rall(a)       (a).rbegin(),(a).rend()
#define pb            push_back
#define sz(a)         int((a).size())
#define rep(i,n)      for(int(i)=0;(i)<(n);(i)++)
#define repe(i,n)     for(int(i)=0;(i)<=(n);(i)++)
#define vsort(v)      sort((v).begin(),(v).end())
#define rvsort(v)     sort(rall((v)))
#define vi            vector<int>

const int INF = 1e9;

// code
// ------------------------------------------------
int main() {

  int a,b,c,d;

  cin >> a >> b >> c >> d;

  int s,t;
  s = a * b;
  t = c * d;

  cout << (s >= t ? s : t) << endl;

  return 0;
}

// funcの実体
// ------------------------------------------------
int CalcSumOfDigit(int n)
{
  int s = 0;
  while(n)
  {
    s += n % 10;
    n = n / 10;
  }
  return s;
}

Measured memory_bytes: 256
#pragma GCC optimize("O3")
#include<bits/stdc++.h> 
using namespace std;
using ll=long long;
using P=pair<ll,ll>;
template<class T> using V=vector<T>; 
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
const ll inf=(1e18);
//const ll mod=998244353;
const ll mod=1000000007;
ll GCD(ll a,ll b) {return b ? GCD(b,a%b):a;}
ll LCM(ll c,ll d){return c/GCD(c,d)*d;}
struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}} __init;
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 (a>b) { a=b; return 1; } return 0; }
ll dp[105][10005];
int main(){
   ll n,W;
   cin>>n>>W;
   V<ll> v(n),w(n);
   for(int i=0;i<n;i++)cin>>v[i]>>w[i];
   for(int i=0;i<105;i++)for(int j=0;j<10005;j++)dp[i][j]=inf;
   dp[0][0]=0;
   for(int i=0;i<n;i++){
       for(int j=0;j<10005;j++){
           if(j+v[i]<10005)chmin(dp[i+1][j+v[i]],dp[i][j]+w[i]);
           chmin(dp[i+1][j],dp[i][j]);        
       }
   }
   ll ans=0;
   for(int i=0;i<10005;i++)if(dp[n][i]<=W)ans=i;
   cout<<ans<<"\n";
}


Measured memory_bytes: 11408
from sys import stdin
import numpy as np
import math
from itertools import accumulate

n = int(stdin.readline().rstrip())
li = list(map(int,stdin.readline().rstrip().split()))

point = 0
lin = li[:]
lin = [0] + lin + [0]
for i in range(1,len(lin)):
    point += abs(lin[i]-lin[i-1])

for j in range(1,len(lin)-1):
    print(point-(abs(lin[j]-lin[j-1])+abs(lin[j+1]-lin[j]))+abs(lin[j+1]-lin[j-1]))

Measured memory_bytes: 22924
using System;
using System.Collections;
using System.Collections.Generic;
using System.Text;
using System.Linq;
using static MyIO;


public class A
{
	public static void Main()
	{
		char[] S = GetString().ToCharArray();
		Console.WriteLine(S.Count(x => x == '1'));
	}
}


public static class MyIO
{
	private static string[] args = null;
	private static int num = -1;
	private static int used = -1;

	private static string getArg()
	{
		if(used == num)
		{
			args = Console.ReadLine().Split(' ');
			num = args.Length;
			used = 0;
		}
		return args[used++];
	}

	public static int GetInt(){ return int.Parse(getArg()); }
	public static long GetLong(){ return long.Parse(getArg()); }
	public static double GetDouble(){ return double.Parse(getArg()); }
	public static string GetString(){ return getArg(); }
}

Measured memory_bytes: 13268
import sys
sys.setrecursionlimit(10 ** 9)

n = int(input())

hs = list(map(int, input().split()))

cost = {n-1:0, n-2:abs(hs[n-1]-hs[n-2])}

def calc(k):
    if k not in cost:
        cost[k] = min(abs(hs[k+1] - hs[k]) + calc(k+1), abs(hs[k+2] - hs[k]) + calc(k+2))
    return cost[k]

print(calc(0))

Measured memory_bytes: 128120
import numpy as np

def popcount(n):
    return bin(n).count("1")
d = {c:(1 << (ord(c)-ord('a'))) for c in 'abcdefghijklmnopqrstuvwxyz'}

class SegmentTree:
    def __init__(self, A):
        N = len(A)
        n = (N-1).bit_length()
        self.N = 1 << n
        self.Seg = [0 for i in range(2*self.N)]
        for i in range(N):
            self.Seg[self.N+i-1] = d[A[i]]
        for i in range(0, self.N-1)[::-1]:
            self.Seg[i] = self.merge(self.Seg[i*2+1], self.Seg[i*2+2])

    def merge(self, x, y):
        return x | y

    def update(self, k, x):
        i = self.N+k-1
        self.Seg[i] = d[x]
        while i > 0:
            i = (i-1)//2
            self.Seg[i] = self.merge(self.Seg[i*2+1], self.Seg[i*2+2])

    def query(self, a, b):
        return self.query_(a, b, 0, 0, self.N)

    def query_(self, a, b, k, l, r):
        if r <= a or b <= l:
            return 0
        if a <= l and r <= b:
            return self.Seg[k]
        vl = self.query_(a, b, 2*k+1, l, (l+r)//2)
        vr = self.query_(a, b, 2*k+2, (l+r)//2, r)
        return self.merge(vl, vr)

import sys
sys.setrecursionlimit(10**7)
def input():
    return sys.stdin.readline()[:-1]

def main():
    N = int(input())
    S = input()
    Q = int(input())
    Seg = SegmentTree(S)

    for _ in range(Q):
        q, i, c = input().split()
        if q == '1':
            i = int(i)-1
            Seg.update(i, c)
        else:
            l, r = int(i), int(c)
            print(popcount(Seg.query(l-1, r)))
main()


Measured memory_bytes: 38556
N, M, C = map(int, input().split())
B = list(map(int, input().split()))
A = [list(map(int, input().split())) for j in range(N)]

ans = 0
for elem in A:
  sum_A = 0
  for j in range(M):
    sum_A += elem[j] * B[j]
  if sum_A + C > 0:
    ans += 1
print(ans)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
long long n,z,x;
char c[5];
int main()
{
    for(int i=1;i<=4;i++)cin>>c[i];
    if((c[1]=='0' && (c[2]>='1' && c[2]<='9')) || (c[1]=='1' && (c[2]=='1' || c[2]=='2'))){
         if((c[3]=='0' && (c[4]>='1' && c[4]<='9')) || (c[3]=='1' && (c[4]=='1' || c[4]=='2')))
                  cout<<"AMBIGUOUS"<<endl;
         else cout<<"MMYY"<<endl;
    }
    else {
         if((c[3]=='0' && (c[4]>='1' && c[4]<='9')) || (c[3]=='1' && (c[4]=='1' || c[4]=='2')))
            cout<<"YYMM"<<endl;
         else cout<<"NA"<<endl;
    }
}


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

class Main {
	double[][] p = new double[2][6];

	void run() {
		Scanner sc = new Scanner(System.in);
		int Na = sc.nextInt();
		int Nb = sc.nextInt();
		long[] xa = new long[Na];
		long[] ya = new long[Na];
		long[] xb = new long[Nb];
		long[] yb = new long[Nb];
		for (int i = 0; i < Na; ++i) {
			xa[i] = sc.nextLong();
			ya[i] = sc.nextLong();
		}
		for (int i = 0; i < Nb; ++i) {
			xb[i] = sc.nextLong();
			yb[i] = sc.nextLong();
		}

		double ans = Double.MAX_VALUE / 3;
		for (int t = 0; t < 2; ++t) {
			for (int i = 0; i < Na; ++i) {
				for (int j = 0; j < Na; ++j) {
					if (cross(xa[0], ya[0], xa[i], ya[i], xb[0], yb[0], xb[1], yb[1])) {
						continue;
					}
					if (cross(xa[i], ya[i], xa[j], ya[j], xb[0], yb[0], xb[1], yb[1])) {
						continue;
					}
					if (cross(xa[j], ya[j], xa[1], ya[1], xb[0], yb[0], xb[1], yb[1])) {
						continue;
					}
					ans = Math.min(ans, dist(xa[0], ya[0], xa[i], ya[i]) + dist(xa[i], ya[i], xa[j], ya[j])
							+ dist(xa[j], ya[j], xa[1], ya[1]) + dist(xb[0], yb[0], xb[1], yb[1]));
				}
			}
			Na ^= Nb;
			Nb ^= Na;
			Na ^= Nb;
			long[] tmp = new long[Na];
			tmp = Arrays.copyOf(xa, xa.length);
			xa = Arrays.copyOf(xb, xb.length);
			xb = Arrays.copyOf(tmp, tmp.length);
			tmp = Arrays.copyOf(ya, ya.length);
			ya = Arrays.copyOf(yb, yb.length);
			yb = Arrays.copyOf(tmp, tmp.length);
		}
		System.out.println(ans >= Double.MAX_VALUE / 4 ? "-1" : ans);
	}

	double dist(long xa, long ya, long xb, long yb) {
		long dx = xa - xb;
		long dy = ya - yb;
		return Math.sqrt(dx * dx + dy * dy);
	}

	boolean cross(long xa1, long ya1, long xb1, long yb1, long xa2, long ya2, long xb2, long yb2) {
		long v = f(xa1, ya1, xb1, yb1, xa2, ya2) * f(xa1, ya1, xb1, yb1, xb2, yb2);
		long u = f(xa2, ya2, xb2, yb2, xa1, ya1) * f(xa2, ya2, xb2, yb2, xb1, yb1);
		return v <= 0 && u <= 0;
	}

	long f(long xa, long ya, long xb, long yb, long x, long y) {
		return (ya - yb) * (x - xa) - (y - ya) * (xa - xb);
	}

	void tr(Object... objects) {
		System.out.println(Arrays.deepToString(objects));
	}

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


Measured memory_bytes: 36256
#include <bits/stdc++.h>
#define rep(i, n) for(ll i=0; i<(n); ++i)
#define rep1(i,n) for(ll i=1; i<=(n); ++i)
#define repi(i,a,b) for(ll i=a; i<=(b); ++i)
#define rrep(i,n) for(ll i=(n-1); i>=0; --i)
#define ALL(obj) (obj).begin(), (obj).end()
#define RALL(obj) (obj).rbegin(), (obj).rend()
#define pb push_back
#define mp make_pair
#define to_s to_string
#define sz(v) (int)v.size()
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() )
#define print(x) cout<<(x)<<'\n'
#define debug(x) cout << #x << ": " << (x) << '\n'
using namespace std;
using ll = long long;
using Edge = pair<ll,ll>;
using Graph = vector<vector<Edge>>;
typedef pair<ll,ll> P;
struct aaa{aaa(){ cin.tie(0); ios::sync_with_stdio(0); cout<<fixed<<setprecision(20);};}aaaaaaa;
int MOD = 1e9 + 7;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return (a*b)/gcd(a,b);}
ll devc(ll x, ll y){return 1 + (x-1)/y;}


int main(){
    ll N; cin >> N;
    ll ans = 0;
    ll x = 10;
    if(N % 2 != 0){
        print(0);
        return 0;
    }
    
    while(x <= N){
        ans += N/x;
        x *= 5;
    }
    print(ans);
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
using namespace std;
int main(void){
  string s[3];
  cin >> s[0] >> s[1] >> s[2];
  int turn=0;
  string a;
  while(s[turn].size()!=0){
    a=s[turn][0];
    s[turn].erase(s[turn].begin());
    if(a=="a")turn=0;
    else if(a=="b")turn=1;
    else turn=2;
  }
  cout << (char)('A'+turn) << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
# define mod 1000000007
# define INF (1 << 29)
# define MAX_N 1000010
/* ACはうれCすぎてうれD */

ll gcd(ll a, ll b){
    if(b == 0) return a;
    return gcd(b, a % b);
}


int main(void){ 
    int n;
    cin >> n;
    vector<ll> A;
    for(int i=0; i<n; i++){
        int a;
        cin >> a;
        A.push_back(a);
    }

    ll ans = A[0];
    for(int i=1; i<n; i++){
        ans = gcd(ans, A[i]);
    }

    cout << ans;

    return 0;
}

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

const int WH = 0;
const int GR = 1;

int size_v, size_e;
vector<int> G[10100];
vector<int> indeg(10100, 0);
vector<int> color(10100, WH);
queue<int> Q;
vector<int> out;


void bfs(int s) {
    Q.push(s);
    color[s] = GR;
    for (; Q.empty() == false; ) {
        int u = Q.front(); Q.pop();
        out.push_back(u);

        for (int i = 0; i < G[u].size(); i++) {
            int v = G[u][i];
            if (color[v] == WH) {
                indeg[v]--;
                if (indeg[v] == 0) {
                    Q.push(v);
                    color[v] = GR;
                }
            }
        }
    }
}

int main() {
    cin >> size_v >> size_e;

    for (int i = 0; i < size_e; i++) {
        int s, t;
        cin >> s >> t;
        G[s].push_back(t);
        indeg[t]++;
    }

    for (int u = 0; u < size_v; u++) {
        if (indeg[u] == 0 && color[u] == WH) {
            bfs(u);
        }
    }

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

    return 0;
}



Measured memory_bytes: 3876
#include <iostream>
#include <fstream>
#include <sstream>
#include <vector>
#include <string>
#include <algorithm>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <bitset>
#include <limits>
#include <random>
#include <complex>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <string.h>
#include <iomanip>
using namespace std;
 
#define REP(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define RREP(i,n) for(int (i)=(int)(n)-1;i>=0;i--)
#define REMOVE(Itr,n) (Itr).erase(remove((Itr).begin(),(Itr).end(),n),(Itr).end())
typedef long long ll;

struct LowLink {
    
    vector < vector < int > > G;
    vector < int > ord, low;
    vector < bool > used;
    vector < pair < int, int > > bridge;
    vector < int > articulation_point;
    const int INF = 1145141919;
    
    LowLink (int n) : G(n), ord(n), low(n), used(n) {}
    
    void add_edge(int a, int b) {
        G[a].push_back(b);
        G[b].push_back(a);
    }
    
    void build(int root) {
        fill(low.begin(), low.end(), INF);
        fill(used.begin(), used.end(), false);
        dfs(root, -1, 1);
    }
    
    int dfs(int v, int prev, int cnt) {
        used[v] = true;
        low[v] = ord[v] = cnt;
        int min_low = cnt;
        int route = 0;
        bool isArticulation = false;
        for (int i = 0; i < G[v].size(); i++) {
            if (!used[G[v][i]]) {
                route++;
                int low_nxt = dfs(G[v][i], v, cnt + 1);
                min_low = min(min_low, low_nxt);
                if (ord[v] < low_nxt) {
                    bridge.push_back(make_pair(v, G[v][i]));
                }
                if (prev != -1 && G[v].size() >= 2 && low_nxt >= cnt) {
                    isArticulation = true;
                }
            } else if (G[v][i] != prev) {
                min_low = min(min_low, low[G[v][i]]);
            }
        }
        if (prev == -1 && route > 1) isArticulation = true;
        if (isArticulation) articulation_point.push_back(v);
        return low[v] = min_low;
    }
    
};


int main() {

    int V,E; cin >> V >> E;
    LowLink inst(100010);

    REP(i,E) {
        int a,b; cin >> a >> b;
        inst.add_edge(a, b);
    }

    inst.build(0);

    vector < pair < int, int > > ans;

    REP(i,inst.bridge.size()) {
        int a = min(inst.bridge[i].first, inst.bridge[i].second);
        int b = max(inst.bridge[i].first, inst.bridge[i].second);
        ans.push_back(make_pair(a, b));
    }

    sort(ans.begin(), ans.end());
    REP(i,ans.size()) {
        cout << ans[i].first << " " << ans[i].second << endl;
    }

    return 0;
}

Measured memory_bytes: 7256
import numpy as np
N = int(input())
ans = np.zeros((10**4+5))
for i in range(1,101):
  for j in range(1,101):
    for l in range(1,101):
      f = (i+j)**2+(j+l)**2+(l+i)**2
      if((f%2==0) and (f<=2*10**4)):
        ans[int(f/2)] += 1

for i in range(1,N+1):
  print(int(ans[i]))

Measured memory_bytes: 26840
#include <iostream>
#include <string>
#include <vector>

using namespace std;

int main(void) {
	int n;
	cin >> n;
	vector<int> a;
	for (int i = 1; i <= n; i++) {
		if (i % 3 != 0 && i % 5 != 0) {
			a.push_back(i);
		}
	}

	unsigned long long int ans = 0;

	for (int i = 0; i < a.size(); i++) {
		ans += a[i];
	}

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


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

signed main() {
    string s; cin >> s;
    int ans = 0;
    rep(i, 1 << s.size() - 1) {
        int sum = 0;
        int base = s[0] - '0';
        REP(j, 1, s.size()) {
            if((i >> j - 1) & 1) base = base * 10 + (s[j] - '0');
            else {
                sum += base;
                base = s[j] - '0';
            }
        }
        sum += base;
        ans += sum;
    }
    cout << ans << endl;
}

Measured memory_bytes: 384
import sys
sys.setrecursionlimit(10**9)
INF=10**18
MOD=10**9+7
def input():
    return sys.stdin.readline().rstrip()

def main():
    class UnionFind():
        def __init__(self,n):
            self.par=[i for i in range(n)]
            self.siz=[1]*n
            
        def root(self,x):
            while self.par[x]!=x:
                self.par[x]=self.par[self.par[x]]
                x=self.par[x]
            return x
        
        def unite(self,x,y):
            x=self.root(x)
            y=self.root(y)
            if x==y:
                return False
            if self.siz[x]<self.siz[y]:
                x,y=y,x
            self.siz[x]+=self.siz[y]
            self.par[y]=x
            return True
        
        def is_same(self,x,y):
            return self.root(x)==self.root(y)
        
        def size(self,x):
            return self.siz[self.root(x)]
    
    N,M=map(int,input().split())
    Q=[]
    for _ in range(M):
        Q.append(tuple(map(lambda x:int(x)-1,input().split())))
    uf=UnionFind(N)
    l_ans=[]
    ans=N*(N-1)//2
    for _ in range(M):
        l_ans.append(ans)
        a,b=Q.pop()
        siz_a,siz_b=uf.size(a),uf.size(b)
        if uf.unite(a,b):
            ans-=siz_a*siz_b
    for _ in range(M):
        print(l_ans.pop())
        
    
    

if __name__ == '__main__':
    main()


Measured memory_bytes: 76124
#include <algorithm>
#include <iostream>
#include <string.h>
#include <queue>

using namespace std;

#define int_ int64_t
#define pb push_back
#define mp make_pair
#define ll long long
#define ull unsigned ll
#define db double
#define lb long double
#define INF 0x3f3f3f3f
#define MOD 1000000007
#define PII pair<int, int>

const ll N=1010;
ll n,m,x;
char grid[N][N];
bool vis[N][N];
ll u[10],v[10];
ll dir[4][2]={{-1,0},{1,0},{0,-1},{0,1}};

struct node {
    ll x,y,val;
};

ll solve(ll s,ll t) {
    memset(vis,0,sizeof(vis));
    queue<node> q;
    q.push({u[s],v[s],0});
    while (!q.empty()) {
        node cur=q.front();
        q.pop();
        if (vis[cur.x][cur.y]) continue;
        vis[cur.x][cur.y]=true;
        if (cur.x==u[t]&&cur.y==v[t]) {
            return cur.val;
        }
        for (ll i=0;i<4;i++) {
            ll xx=cur.x+dir[i][0];
            ll yy=cur.y+dir[i][1];
            if (xx>0&&xx<=n&&yy>0&&yy<=m&&!vis[xx][yy]&&grid[xx][yy]!='X') {
                q.push({xx,yy,cur.val+1});
            }
        }
    }
    return 0;
}

int main()
{
    scanf("%lld%lld%lld",&n,&m,&x);
    for (ll i=1;i<=n;i++) {
        scanf("%s",&grid[i][1]);
        for (ll j=1;j<=m;j++) {
            if (grid[i][j]=='S') {
                u[0]=i,v[0]=j;
            } else if (grid[i][j]!='.'&&grid[i][j]!='X') {
                ll idx=grid[i][j]-'0';
                u[idx]=i,v[idx]=j;
            }
        }
    }
    ll ans=0;
    for (ll i=1;i<=x;i++) {
        ans+=solve(i-1,i);
    }
    printf("%lld\n",ans);
}


Measured memory_bytes: 5152
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define mp make_pair

int main(){
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif

	int n;
	cin >> n;
	n%=1000;
	if(n==0)
		cout << 0;
	else
		cout << 1000-n;


	
	

	return 0;
}

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

int main() {

  string a;
  int sa,min=1000,num;
  int X,Y,Z;
  char x,y,z;
  cin >> a;


  for(int i=0;i<a.size()-2;i++){
  x=a[i];
  y=a[i+1];
  z=a[i+2];

  X=x-'0';
  Y=y-'0';
  Z=z-'0';

  num=X*100+Y*10+Z;

  sa=753-num;
  if(sa<0) sa*=-1;

  if(sa<min) min = sa;
  }

  cout << min << endl;


  return 0;


}

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


int main() {
	
	int n;
	string s;
	cin >> n >> s;
	int cnt =0;
	for(int i=0; i<n-2; i++){
		if(s.at(i)=='A' && s.at(i+1)=='B' && s.at(i+2)=='C') cnt++;
	}
	cout << cnt << endl;
	
	return 0;
}

Measured memory_bytes: 256
N = int(input())

A = [chr(ord("a") + i) for i in range(26)]


def dfs(S, i):
    if len(S) == N:
        print(S)
        return
    for j in range(i):
        dfs(S + A[j], i)
    dfs(S + A[i], i + 1)


dfs("", 0)


Measured memory_bytes: 4412
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<(n); i++)
#define int long long
#define double long double
#define P pair<long long,long long>
#define all(a) a.begin(),a.end()
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
using namespace std;

signed main(void){
    cin.tie(0); cout.tie(0);
    ios::sync_with_stdio(false);

    int a,b; cin>>a>>b;
    a=(a+11)%13; b=(b+11)%13;
    
    if(a==b)cout<<"Draw"<<endl;
    else if(a>b)cout<<"Alice"<<endl;
    else cout<<"Bob"<<endl;
    return 0;
    
}

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

int main()
{
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int r, c, h, w;
  cin >> r >> c >> h >> w;
  if (r % h == 0 && c % w == 0) {
    cout << "No" << endl;
    return 0;
  }
  const int C = 999999999 / (h * w - 1);
  vector<vector<long long>> a(r, vector<long long>(c, C));
  for (int i = h - 1; i < r; i += h) {
    for (int j = w - 1; j < c; j += w) {
      a[i][j] = -(C * (h * w - 1) + 1);
    }
  }
  cout << "Yes" << endl;
  for (int i = 0; i < r; ++i) {
    for (int j = 0; j < c; ++j) {
      cout << a[i][j] << ' ';
    }
    cout << endl;
  }
  return 0;
}


Measured memory_bytes: 4864
#include<bits/stdc++.h>
#include<time.h>
using namespace std;
int main()
{   string s1,s2,s3;
    int a,b;
    cin>>s1>>s2;
    cin>>a>>b;
    cin>>s3;
    if(s1==s3)
        a--;
    else if(s2==s3)
        b--;
    cout<<a<<' '<<b<<endl;
    return 0;
}


Measured memory_bytes: 256
// kari.cpp : このファイルには 'main' 関数が含まれています。プログラム実行の開始と終了がそこで行われます。
//

#include <iostream>

#include<iostream>
#include<algorithm>
using namespace std;

#define N 100010
int main() {
	int n, m, h[N], ma[N];
	cin >> n >> m;
	for (int i = 1;i <= n;i++) {
		cin >> h[i];
		ma[i] = 0;
	}
	for (int i = 0;i < m;i++) {
		int a, b;
		cin >> a >> b;
		ma[a] = max(ma[a], h[b]);
		ma[b] = max(ma[b], h[a]);
	}
	int ans = 0;
	for (int i = 1;i <= n;i++) {
		ans += h[i] > ma[i];
	}
	cout << ans << endl;
}





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

using ll = long long;
using ld = long double;
constexpr ll inf = static_cast<ll>(1e17);
constexpr int iinf = static_cast<int>(1e9);
constexpr ll mod = static_cast<ll>(1e9 + 7);
constexpr long long MOD(long long in) {
	return in % mod;
}

template<long long Mod, int Max>
class Comb
{
public:
	Comb() :fac(Max), finv(Max)
	{
		std::vector<long long> inv(Max);

		fac[0] = fac[1] = 1;
		finv[0] = finv[1] = 1;
		inv[1] = 1;
		for (int i = 2; i < Max; ++i)
		{
			fac[i] = fac[i - 1] * i % Mod;
			inv[i] = Mod - inv[Mod % i] * (Mod / i) % Mod;
			finv[i] = finv[i - 1] * inv[i] % Mod;
		}
	}

	constexpr long long C(int n, int k) {
		if (n < k) return 0;
		if (n < 0 || k < 0) return 0;
		return fac[n] * (finv[k] * finv[n - k] % Mod) % Mod;
	}

private:
	std::vector<long long> fac;
	std::vector<long long> finv;
};

int n, k;
Comb<mod, 2005> com;
int main() {
	std::cin >> n >> k;

	int l = n - k;
	for (int i = 1; i <= k; ++i)
	{
		std::cout << MOD(com.C(k - 1, i - 1) * com.C(l + 1, i)) << std::endl;
	}

	return 0;
}


Measured memory_bytes: 256
n = STDIN.gets.chomp.to_i

sum = 0.0
for i in 1..n
  data = STDIN.gets.chomp.split(" ")
  if data[1] == "JPY"
    sum += data[0].to_f
  else
    sum += data[0].to_f * 380000.0
  end
end
puts sum

Measured memory_bytes: 1788
#include <bits/stdc++.h>
#include <iostream>
#include <string>
#include <math.h>
#include <algorithm>
using namespace std;

int main() {
  int N;
  cin >> N;
  vector<int> V(N);
  vector<int> C(N);
  for(int i=0; i<N; ++i) cin >> V[i];
  for(int i=0; i<N; ++i) cin >> C[i];
  int ans =0;
  int tmp =0;
  for(int i=0; i<N; ++i){
    tmp = V[i] - C[i];
    if(tmp <0) tmp=0;
    ans +=tmp;
  }
  cout << ans << endl;
}

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

int main(){
  int a,array[100001]={},n,i,ans=0;
  cin>>n;
  for(i=0;i<n;i++){
    cin>>a;
    array[a]++;
    if(a>0){
      array[a-1]++;
      array[a+1]++;
    }
  }
  sort(array,array+100001);
  cout<<array[100000]<<endl;
}

Measured memory_bytes: 640
#!/usr/bin/env python3
# Based on
# https://en.wikipedia.org/wiki/Ford???Fulkerson_algorithm
# http://algoogle.hadrori.jp/algorithm/ford-fulkerson.html

import array
import collections
import sys


REC_LIMIT = 10000
INF = 10 ** 8


Edge = collections.namedtuple("Edge", "source sink capacity")


class FlowNetwork(object):

    def __init__(self, num_vertices):
        self.adj_edges = [set() for _ in range(num_vertices)]
        self.flow = None
        self.rev_edge = dict()
        self.used = None

    def get_edges_from(self, vertex):
        return self.adj_edges[vertex]

    def add_edge(self, source, sink, capacity):
        assert source != sink
        forward_edge = Edge(source, sink, capacity)
        backward_edge = Edge(sink, source, 0)
        self.rev_edge[forward_edge] = backward_edge
        self.rev_edge[backward_edge] = forward_edge
        self.adj_edges[source].add(forward_edge)
        self.adj_edges[sink].add(backward_edge)

    def dfs(self, source, sink, flow):
        if source == sink:
            return flow
        self.used[source] = True
        for edge in self.get_edges_from(source):
            rest = edge.capacity - self.flow[edge]
            if self.used[edge.sink] or rest <= 0:
                continue
            d = self.dfs(edge.sink, sink, min(flow, rest))
            if d > 0:
                self.flow[edge] += d
                self.flow[self.rev_edge[edge]] -= d
                return d
        return 0

    def ford_fulkerson(self, source, sink):
        self.flow = collections.defaultdict(int)
        max_flow = 0
        while True:
            self.used = collections.defaultdict(bool)
            df = self.dfs(source, sink, INF)
            if df == 0:
                return max_flow
            else:
                max_flow += df


def main():
    sys.setrecursionlimit(REC_LIMIT)
    v, e = map(int, input().split())
    network = FlowNetwork(v)
    for _ in range(e):
        network.add_edge(*map(int, input().split()))
    mf = network.ford_fulkerson(0, v - 1)
    print(mf)


if __name__ == '__main__':
    main()

Measured memory_bytes: 8800
#include <stdio.h>

int main(void) {
    int x,h,m,s;
    
    scanf("%d",&x);
    
    h = x /3600;
    x = x%3600; 
    m = x/60;
    s = x%60;
    printf("%d:%d:%d\n",h,m,s);
    return 0;
}



Measured memory_bytes: 2680
#include <stdio.h>
#include <string.h>
#include <limits.h>
#include <math.h>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <bitset>

typedef unsigned long long ULLONG;
typedef long long LLONG;
static const LLONG MOD_NUM = 1000000007; //998244353;

template<class _T> static void get(_T& a) {
	std::cin >> a;
}
template<class _T> static void get(_T& a, _T& b) {
	std::cin >> a >> b;
}
template<class _T> static void get(_T& a, _T& b, _T& c) {
	std::cin >> a >> b >> c;
}

static void exec();

int main()
{
	exec();
	fflush(stdout);
	return 0;
}

static void exec()
{
	LLONG N;
	get(N);

	std::vector<int> num;
	int digit = 0;
	LLONG tmp = N;
	while (tmp) {
		digit++;
		num.push_back(tmp % 10LL);
		tmp /= 10LL;
	}

	bool all9 = true;
	for (int i = 0; i < digit - 1; i++) {
		if (num[i] != 9) {
			all9 = false;
		}
	}

	int ans = 0;
	if (all9) {
		for (int i = 0; i < digit; i++) {
			ans += num[i];
		}
	}
	else {
		for (int i = 0; i < digit - 1; i++) {
			ans += 9;
		}
		ans += num[digit - 1] - 1;
	}
	printf("%d\n", ans);
}


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

typedef long long LL;
typedef long double LD;
typedef string ST;


#define REP(i,n) for(LL (i)=0;(i)<(n);(i)++)
#define ALL(v) v.begin(), v.end()
#define PRINTLN(v) for(auto (a): v )   cerr << a << endl
#define PRINTSP(v) for(auto (a): v ) {cerr << a << " ";} cerr << endl

vector<LL> P;
vector<LL> B;
LL N, X;
LL EB;
LL EP;
void recusive(LL level) {
  //cerr << EP+EB << " : " << EP << " : " << EB <<" : " << level << endl;
  if (level == 0) {
    EP++;
    return;
  }
  if (EB+EP < X) {        // まだ食べれる
    EB++;                 // バンを食べる
    if ((EB + EP) == X) {
      return;
    }
    //cerr << EP + EB << " a " << EP << " : " << EB << " : " << level << endl;
    if ((EP + EB + P[level - 1] + B[level - 1]) <= X) { // 一つ下のレベルを全部を食べてもOK？
      EP += P[level - 1];
      EB += B[level - 1];
      //cerr << EP + EB << " b " << EP << " : " << EB << " : " << level << endl;
    }
    else {
      recusive(level - 1);
    }

    if (EB + EP == X) {
      //cerr << EP + EB << " c " << EP << " : " << EB << " : " << level << endl;

      return;
    }
   
    EP++;
    if (EB + EP == X) {
      return;
    }
    if ((EP + EB + P[level - 1] + B[level - 1]) <= X) { // 一つレベルが下を食べてもOK？
      EP += P[level - 1];
      EB += B[level - 1];
    }
    else {
      recusive(level - 1);
    }
    if (EB + EP == X) {
      return;
    }
    EB++;
    if (EB + EP == X) {
      return;
    }
  }
}


void func() {
  cin >> N >> X;
  
  //N = 49;
  //X = 1837933630796584;
  //cerr << N << endl;
  //cerr << X << endl;


  P.resize(N+1);
  B.resize(N+1);
  P[0] = 1;
  B[0] = 0;
  for (LL i = 1; i <= N; ++i) {
    P[i] = P[i - 1] * 2 + 1;
    B[i] = B[i - 1] * 2 + 2;
  }

  for (LL i = 0; i <= N; ++i) {
    //cerr << i << " : " << P[i] << " : " << B[i] << " : " << B[i]+P[i] << endl;
  }
  EP = 0;
  EB = 0;
  recusive(N);
  cout << EP;
}








#ifdef CALC_TIME 
#include <windows.h>
int main()
{
  LARGE_INTEGER freq;
  QueryPerformanceFrequency(&freq);
  LARGE_INTEGER start, end;
  QueryPerformanceCounter(&start);
  // 何かの処理
  func();
  QueryPerformanceCounter(&end);
  double time = static_cast<double>(end.QuadPart - start.QuadPart) * 1000.0 / freq.QuadPart;
  fprintf(stderr, "\n%lf[ms]\n", time);
  return 0;
}
#else 
int main()
{
  func();
  return 0;
}
#endif





Measured memory_bytes: 256