akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstdio>
#include <vector>
#include <map>
#include <string>
#include <stack>
#include <queue>
#include <algorithm>
using namespace std;

void debug(const vector<int>& v){
	for(int i=0 ; i < v.size() ; i++ ){
		cout << v[i] << " ";
	}
	cout << endl;
}

// ツ青板療アツづ茎[i]ツつゥツづァs[j]ツづ個堕債和ツづーツ陛板つキ. (a[i] := s[i] + s[i+1] + ... + s[n-1])
int sum(const vector<int>& a, int i , int j){
	return a[i] - a[j+1];
}

int main(){
	int n, m;
	//while( cin >> n >> m , n || m ){
	while( scanf("%d %d", &n , &m ) , n || m ){
		// h,w : ツ禿シツ療?
		// H[i] := h[i] + h[i+1] + ... + h[n-1]
		// W[i] := w[i] + w[i+1] + ... + w[m-1]
		vector<int> h(n), w(m), H(n+1), W(m+1);
		
		int sum_h=0;
		for(int i=0 ; i < n ; i++ ){
			int e;
			scanf("%d", &e );
			h[i] = e;
			sum_h += h[i];
		}
		H[0] = sum_h;
		for(int i=0 ; i < h.size() ; i++ ){
			H[i+1] = H[i] - h[i] ;
		}
		
		int sum_w=0;
		for(int i=0 ; i < m ; i++ ){
			int e;
			scanf("%d", &e );
			w[i] = e;
			sum_w += w[i];
		}
		W[0] = sum_w;
		for(int i=0 ; i < w.size() ; i++ ){
			W[i+1] = W[i] - w[i] ;
		}
		
		// ツ連ツ堕アツつキツづゥ cnt ツ古つづ個堕債和ツづーツ仰?づ淞づゥ 
		for(int cnt=2 ; cnt <= n ; cnt++ ){
			// h[i] .. h[i+cnt-1] ツづ個堕債和
			for(int i=0 ; i <= n-cnt ; i++ ){
				h.push_back( sum( H , i , i+cnt-1 ) );
			}
		}
		// ツ連ツ堕アツつキツづゥ cnt ツ古つづ個堕債和ツづーツ仰?づ淞づゥ 
		for(int cnt=2 ; cnt <= m ; cnt++ ){
			// w[i] .. w[i+cnt-1] ツづ個堕債和
			for(int i=0 ; i <= m-cnt ; i++ ){
				w.push_back( sum( W , i , i+cnt-1 ) );
			}
		}
		// debug( h );
		// debug( w );
		
		sort( h.begin() , h.end() );
		sort( w.begin() , w.end() );
		
		int ans = 0;
		for(int i=0 ; i < h.size() ; i++ ){
			int k1 = h[i];
			int k2 = upper_bound(w.begin(),w.end(),k1) - lower_bound(w.begin(),w.end(),k1);
			ans += k2;
		}
		printf("%d\n", ans);
	}
}

Measured memory_bytes: 10000
#include<bits/stdc++.h>
using namespace std;
using Graph = vector<vector<long long>>;
int main() {
    long long N, M;
    cin >> N >> M;
    Graph G(N);
    for (long long i=0; i<M; i++) {
        long long a, b;
        cin >> a >> b;
        G[a-1].push_back(b-1);
        G[b-1].push_back(a-1);
    }
    vector <long long> dist(N, -1);
    vector <long long> sirushi(N, -1);
    queue <long long> que;
    dist[0] = 0;
    sirushi[0] = 0;
    que.push(0);
    while(!que.empty()) {
        long long v = que.front();
        que.pop();

        for (long long nv : G[v]) {
            if (dist[nv] != -1) continue;
            dist[nv] = dist[v]+1;
            sirushi[nv] = v;
            que.push(nv);
        }
    }
    cout << "Yes\n";
    for (long long v=1; v<N; v++) {
        cout << sirushi[v]+1 << endl;
    }
}

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

using namespace std;

const int N = 105;

int n, m, x, y, a[N], b[N];

int main(){
    cin >> n >> m >> x >> y;
    for (int i = 1; i <= n; i++) cin >> a[i];
    for (int i = 1; i <= m; i++) cin >> b[i];
    sort(a + 1, a + n + 1);
    sort(b + 1, b + m + 1);
    
    if (a[n] >= b[1]) cout << "War";
    else {
        for (int j = a[n] + 1; j <= b[1]; j++) {
            if (x < j && j <= y) return cout << "No War", 0;
        }
        
        cout << "War";
    }
	return 0;
}


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

int main(){
	int a, b;
	cin >> a >> b;
	if(a > 8 || b > 8) cout << ":(" << endl;
	else cout << "Yay!" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  long long int x;
  cin >> x;
  
  int a=0;
  
  if(x%11>6)
    a+=2;
  else if(x%11>0)
    a++;
  cout << x/11*2+a << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define pb(a) push_back(a)
#define pbp(a,b) push_back({a,b})
#define rep(p,a,b)    for(int p=a;p<b;p++)
#define sz(v) ((int)(v).size())
#define all(v) (v).begin(), (v).end()
#define INF 0x3f3f3f3f

ll nextPowerOf2(ll n)   
{ 
	n--; 
	n |= n >> 1ll; 
	n |= n >> 2ll; 
	n |= n >> 4ll; 
	n |= n >> 8ll; 
	n |= n >> 16ll; 
	n++; 
	return n; 
}


int main() {
	
	#ifndef ONLINE_JUDGE
	// for getting input from input.txt
	freopen("input.txt", "r", stdin);
	// for writing output to output.txt
	freopen("output.txt", "w", stdout);
	#endif

	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	
	// ll n,t,i;
	// cin>>t;
	// while(t--)
	// {

	// }
	char c;
	cin>>c;
	if(c<95)cout<<"A";
	else cout<<"a";
	return 0;
}

Measured memory_bytes: 3648
N, Q = [int(x) for x in input().split()]
S = input()

t = [0] * (N + 1)

for i in range(N):
    if S[i:i+2] == 'AC':
        t[i+1] = t[i] + 1
    else:
        t[i+1] = t[i]

for i in range(Q):
    l, r = [int(x) for x in input().split()]
    print(t[r-1] - t[l-1])


Measured memory_bytes: 6188
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <functional>
#include <bitset>
#include <cmath>
using namespace std;


int main()
{
    string s;
    cin >> s;
    int res = 1000;
    for (int i = 0; i < s.size() - 2; i++)
    {
        int a,b,c;
        a = s[i] - '0';
        b = s[i + 1] - '0';
        c = s[i + 2] - '0';
        int t = a * 100 + b * 10 + c;
        if(abs(t - 753) < res)
        {
            res = abs(t - 753);
        }

    }
    cout << res << endl;
}

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

using namespace std; 
using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>; 

#define INF INT_MAX;
#define MOD 1000000007
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()

int main(){
  int K,T;
  cin>>K>>T;
  vector<int>a(T);
  for(int i=0;i<T;i++)cin>>a[i];
  sort(rng(a));
  int summ=0;
  for(int i=0;i<T-1;i++)summ+=a[i];
  cout<<max(a[T-1]-summ-1,0)<<endl;
  return 0;
}


Measured memory_bytes: 256
//Krunal_Mathukiya
#include<bits/stdc++.h>
using namespace std;
#define lli long long int
#define li long int
#define pb push_back
#define mkp make_pair
#define nikalL return
#define chalavo continue
#define basHo break
#define umap unordered_map
#define fr(i,s,n) for(int i=s;i<=n;++i)
#define frr(i,s,n) for(int i=s;i>=n;--i)
#define jaldiKarNe ios_base::sync_with_stdio(false);cin.tie(NULL);
#define mod 1000000007
int n,m;
vector<int> g[100001];
int dp[100001];
int vis[100001];
void fn(int node) {
	vis[node]=1;
	dp[node]=0;
	for(auto child:g[node]) {
		if(!vis[child]) fn(child);
		dp[node]=max(dp[node],1+dp[child]);
	}
}
void TestingChaluKarEyy(){
	cin>>n>>m;
	fr(i,1,m) {
		int u,v;
		cin>>u>>v;
		g[u].pb(v);
	}
	fr(i,1,n) {
		if(!vis[i]) fn(i);
	}
	int ans=0;
	fr(i,1,n) ans=max(ans,dp[i]);
	cout<<ans;
}
int main(){
//	#ifndef ONLINE_JUDGE
//	freopen("input.txt", "r", stdin);
//	freopen("output.txt", "w", stdout);
//	#endif
	jaldiKarNe;
	int TestingKaravvuChhe=1;
	// cin>>TestingKaravvuChhe;
	while(TestingKaravvuChhe--){
		TestingChaluKarEyy();
	}
}

Measured memory_bytes: 12492
#include<bits/stdc++.h>
#define io ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0)
#define PI atan(1)*4
typedef long long ll;
using namespace std;
int a[85];
int main(){
	io;
	int n;
	cin >> n;
	ll cur = 1000;
	for(int i = 0;i < n;++i){
		cin >> a[i];
	}
	bool f = 1;
	int i = 1;
	int st = 0;
	while(i < n){ 
		while(f){
			if(a[i] < a[i-1]){
				f = 0;
				break;
			}
			i++;
			if(i == n){
				break;
			}
		}
		if(i == n && st != -1){
			ll ys = cur % a[st];
			ll num = (cur-ys) / a[st];
			st = -1;
			cur = ys + num*a[i-1];
			break ;
		}
	//	cout << "OK" <<endl;
		ll ys = cur % a[st];
		ll num = (cur-ys)/a[st];
		st = -1;
		cur = ys + num*a[i-1];
		while(!f){
			if(a[i] > a[i-1]){
				f = 1;
				st = i-1;
				break;
			}
			i++;
			if(i == n){
				break;
			}
		}
	} 
	cout << cur;
	return 0;
}

Measured memory_bytes: 3652
n=int(input())
y=[list(map(int,input().split())) for i in range(n-1)]
for s in range(n):
  x=0
  for k,g in enumerate(y[s:]):
    a,b,c=g[0],g[1],g[2]
    if k==0:
      x=b+a
    elif x>b:
      if (x-b)%c==0:
        x=x+a
      else:
        x=(x//c+1)*c+a
    elif x<b:
      x=b+a
  print(x)

Measured memory_bytes: 3188
N = gets.to_i
a = gets.split.map(&:to_i)
dp = N.times.map{[0]*(N)}
N.times do |i|
	dp[i][i] = a[i]
end
1.upto(N-1) do |i|
	(N-i).times do |j|
		v1 = a[j] - dp[j+1][i+j]
		v2 = a[i+j] - dp[j][i+j-1]
		dp[j][i+j] = v1 > v2 ? v1 : v2
	end
end
p dp[0][N-1]


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

int main(){
  //////////////////
  int N, X, number = 0;
  cin >> N >> X;
  vector<int> L(N), D(N+1);
  
  for(int i = 0;i < N;i++){
  cin >> L.at(i);
  }
  for(int i = 0;i < N ;i++){
    D.at(0) = 0;
    D.at(i + 1) = D.at(i) + L.at(i);
  }

  
  for(int i = 0;i <= N;i++){ 
  	if(D.at(i) <= X){
      number += 1;
    }
  }
  
  cout << number << endl;
}

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

def insertionSort(NUM_LIST, g, cnt):
    for i in range(g, len(NUM_LIST)):
        v = NUM_LIST[i]
        j = i - g
        while j >= 0 and NUM_LIST[j] > v:
            NUM_LIST[j+g] = NUM_LIST[j]
            j -= g
            cnt += 1
        NUM_LIST[j+g] = v
    return NUM_LIST, cnt

def shellSort(NUM_LIST):
    cnt = 0
    G = [1]
    a=1
    i=1
    while (a+3**i) < len(NUM_LIST):
        a += 3**i
        i+=1
        G.append(a)
    m = len(G)
    G = G[::-1]
    for i in G:
        NUM_LIST, cnt = insertionSort(NUM_LIST, i, cnt)
    return m, cnt, NUM_LIST, G

NUM_LIST = []
n = int(input())
for _ in range(n):
    NUM_LIST.append(int(input()))

m, cnt, NUM_LIST, G = shellSort(NUM_LIST)

print(m)
print(" ".join(list(map(str, G))))
print(cnt)
for num in NUM_LIST:
    print(num)


Measured memory_bytes: 45824
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#include<cstdlib>
#include<tuple>
#include<iomanip>
#include<stack>
#include<map>
#include<queue>
#include<set>
#define int long long
using namespace std;
const int INF = 1e10;
const int ZERO = 0;

signed main() {
	int D;
	cin >> D;
	if(D == 22) {
		cout << "Christmas Eve Eve Eve" << endl;
	}
	else if(D == 23) {
		cout << "Christmas Eve Eve" << endl;
	}
	else if(D == 24) {
		cout << "Christmas Eve" << endl;
	}
	else {
		cout << "Christmas" << endl;
	}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 100010;
int a[N],n;
ll f[N];
int q[N],head,tail,g[N];
int l,r,mid;

int main(){
	scanf("%d",&n);
	for(int i=1;i<=n;i++)scanf("%d",a+i);
	head = tail = 0;
	q[1] = 1; q[0] = 0;
	for(int i=1;i<=n;i++){
		if(a[q[tail]]>=a[i]){
			l = head, r = tail;
			while(l<r){
				mid = (l+r)>>1;
				if(a[q[mid]]>=a[i]) r = mid; else l = mid+1;	
			}
			g[l]++;
			f[q[l]]-=a[q[l]]-a[i];
		} else{
			q[++tail] = i;
			g[tail] = 1;
		}
	}
	for(int i = tail;i>0;i--){
		f[q[i]]+=1ll*(a[q[i]]-a[q[i-1]])*g[i];
		g[i-1]+=g[i];
	}
	for(int i=1;i<=n;i++) printf("%lld\n",f[i]);
	return 0;
}

Measured memory_bytes: 3072
#include <bits/stdc++.h>
#define SZ(x) ((int)(x).size())
typedef long long ll;
using namespace std;

int main() {
    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); cout.setf(ios::fixed); cout.precision(20);
    int n; cin >> n;
    vector<tuple<string, int, int>> a;
    for (int i = 0; i < n; i++) {
        string s; int score; cin >> s >> score;
        a.emplace_back(s, score, i);
    }
    vector<int> ans(n);
    sort(a.begin(), a.end(), [&](tuple<string, int, int> x, tuple<string, int, int> y) {
        if (get<0>(x) != get<0>(y)) {
            return get<0>(x) < get<0>(y);
        }
        return get<1>(x) > get<1>(y);
         });
    for (int i = 0; i < n; i++) {
        cout << get<2>(a[i]) + 1 << "\n";
    }
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
	public static void main(String[] args){
		
		Scanner sc = new Scanner(System.in);
		int h, w, d, q, l, r;
		h = sc.nextInt();
		w = sc.nextInt();
		d = sc.nextInt();
		
		int[] px = new int[h * w + 1];
		int[] py = new int[h * w + 1];
		int[] m  = new int[h * w + 1];
		
		for(int i = 0; i < h; i++){
			for(int j = 0; j < w; j++){
				int a = sc.nextInt();
				px[a] = i;
				py[a] = j;
			}
		}
		for(int i = d + 1; i < h * w + 1; i++){
			m[i] = m[i-d] + Math.abs(px[i] - px[i - d]) + Math.abs(py[i] - py[i - d]);
		}
		q = sc.nextInt();
		
		for(int i = 0; i < q; i++){
			l = sc.nextInt();
			r = sc.nextInt();
			System.out.println(m[r] - m[l]);
		}
	}
}


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

namespace ConsoleApp2
{
    class Program
    {
        static void Main(string[] args)
        {
            string input1 = Console.ReadLine();
            string input2 = Console.ReadLine();
            string input3 = Console.ReadLine();

            var strings = input1.Split(' ');
            var counts = input2.Split(' ').Select(x => int.Parse(x)).ToList();
            string throwed = input3;

            Dictionary<string, int> countTable = new Dictionary<string, int>();
            for (int i = 0; i < counts.Count; i++)
            {
                countTable.Add(strings[i], counts[i]);
            }

            countTable[throwed]--;

            string o = "";
            foreach (KeyValuePair<string, int> pair in countTable)
            {
                o += pair.Value + " ";
            }
            o.TrimEnd(new char[] { ' ' });
            Console.Write(o);
        }
    }
}


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

using namespace std;

#define int long long
#define MP make_pair
#define PB push_back
#define FI first
#define SE second
typedef tuple<int,int> T1;
static const int INF = 1ll<<60;
static const int dx[] = { 1, -1, 0, 0, };
static const int dy[] = { 0, 0, 1, -1 };

int N,D;
int V[35],W[35];
int dat[16777216*2-1];
int ans=0;
vector<T1> P1,P2;

class Segment{
public:
    int n;
    void init(int _n){
        n=1;
        while(n<_n)n*=2;
        for(int i=0;i<2*n-1;++i)dat[i]=-INF;
    }
    void update(int k,int a){
        k+=n-1;
        dat[k]=a;
        while(k>0){
            k=(k-1)/2;
            dat[k]=max(dat[k*2+1],dat[k*2+2]);
        }
    }
    int query(int a,int b,int k,int l,int r){
        if(r<=a||b<=l)return -INF;
        if(a<=l&&r<=b)return dat[k];
        int vl=query(a,b,k*2+1,l,(l+r)/2);
        int vr=query(a,b,k*2+2,(l+r)/2,r);
        return max(vl,vr);
    }
};


void half(int n,int End,int v,int w,vector<T1> &S){
    if(n==End){
        S.push_back(make_tuple(v,w));
        return ;
    }
    half(n+1,End,v+V[n],w+W[n],S);
    half(n+1,End,v-V[n],w-W[n],S);
    half(n+1,End,v,w,S);
}

signed main(){
    cin>>N>>D;
    for(int i=0;i<N;++i)cin>>V[i]>>W[i];
    half(0,N/2,0,0,P1);
    half(N/2,N,0,0,P2);
    sort(P1.begin(),P1.end());
    sort(P2.begin(),P2.end());
    Segment seg;
    seg.init(P2.size());
    for(int i=0;i<P2.size();++i)seg.update(i,get<1>(P2[i]));
    for(int i=0;i<P1.size();++i){
        int x,y;
        int a,b;
        tie(x,y)=P1[i];
        a=min(D-x,-D-x);
        b=max(D-x,-D-x);
        int lit=lower_bound(P2.begin(),P2.end(),make_tuple(a,-INF))-P2.begin();
        int rit=upper_bound(P2.begin(),P2.end(),make_tuple(b,INF))-P2.begin();
        if(rit==P2.size()||lit==rit)continue;
        if(lit>rit)continue;
        ans=max(ans,abs(y+seg.query(lit,rit,0,0,seg.n)));
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 713312
import java.util.*;

public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int A[] = new int[N];
    int B[] = new int[N];
    int M = 0;

    for (int i=0; i<=N-1; i++) {
      A[i] = sc.nextInt();
    }
    for (int i=N; i>=1; i--) {
      int sum = 0;
      for (int k=1; k<=N/i; k++) {
        sum += B[i*k - 1];
      }
      if(sum%2 != A[i - 1]){
        B[i - 1] = 1;
        M++;
      }
    }

    System.out.println(M);
    for (int i=1; i<=N; i++) {
      if(B[i - 1] == 1){
        System.out.print(i+" ");
      }
    }
    System.out.println("");
  }
}

Measured memory_bytes: 68004
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll dp[3005][3005],n,x,sum=0ll;
vector<ll>v;
ll score(int l,int r)
{
    if(r<l)return 0;
    if(l==r)return v[l];
    if(dp[l][r]!=-1)return dp[l][r];
    ll ans1=0,ans2=0;
    ans1=v[l]+min(score(l+2,r),score(l+1,r-1));
    ans2=v[r]+min(score(l+1,r-1),score(l,r-2));
    dp[l][r]=max(ans1,ans2);
    return dp[l][r];
}
int main()
{
	for(int i=0;i<3005;i++)for(int j=0;j<3005;j++)dp[i][j]=-1; 
	cin>>n;	
	for(int i=0;i<n;i++)
	{
        cin>>x;
        v.push_back(x);
        sum+=x;
	}
	cout<<2*score(0,n-1)-sum;
}

Measured memory_bytes: 74344
#include <bits/stdc++.h>
 
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define FFOR(i,a,b) for(int i=(a);i<=(b);i++)
#define REP(i,b) FOR(i,0,b)
#define RREP(i,b) FFOR(i,1,b)
#define PB push_back
#define F first
#define S second
#define BE(c) c.begin(),c.end()
using namespace std;
typedef long long LL;
typedef LL ut;
typedef long double ld;
typedef pair<ut,ut> pr;
typedef vector<pr> Vpr;
typedef vector<ut> VI;
typedef pair<pr, ut> ppr;
typedef priority_queue<pr,Vpr, greater<pr> > PQ;
const int SIZE=5+3*1e+4;
const ut INF=1<<30;
const ld eps=1e-6;
const LL mod=7+1e+9;

int main() {
	vector<int> v;
	int a, b, c;
	cin >> a >> b >> c;
	v.PB(a); v.PB(b); v.PB(c);
	sort(BE(v));
	v.erase(unique(BE(v)), v.end());
	cout << v.size() << endl;
    return 0;	
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
 
int main() {
    int n,ans;
    ans=0;
    cin>>n;
    int a[n],b[n],c[n-1];
    rep(i,n){
      cin>>a[i];
    }
    rep(i,n){
      cin>>b[i];
      ans+=b[i];
    }
    rep(i,n-1){
      cin>>c[i];
    }
    rep(i,n-1){
       if(a[i]+1==a[i+1]){
           ans+=c[a[i]-1];
       }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>

int compare_long(const void *a, const void *b) {long *A = (long *)a;long *B = (long *)b;if (*A > *B) return 1;if (*A < *B) return -1;return 0;}

int main(void){
	int N,i;
	long long M;
	scanf("%d%lld",&N,&M);
	long long A[N+1],B[N+1],ans=0;
	A[0] = 0;
	for(i=1;i<=N;i++)scanf("%lld",&A[i]);
	for(i=1;i<=N;i++)A[i] = (A[i]+A[i-1])%M;
	qsort(A, N+1, sizeof(long long), compare_long);
	
	int j=0;
	B[0]=1;
	for(i=1;i<=N;i++){
		if(A[i]==A[i-1])B[j]++;
		else B[++j] = 1;
	}
	for(i=0;i<=j;i++){
		ans += (B[i]*(B[i]-1))/2;
	}
	
	printf("%lld",ans);
	return 0;
}

Measured memory_bytes: 1788
#include<bits/stdc++.h>
using namespace std;
// struct ord{
// 	string a = "AC", b = "WA" , c = "TLE", d = "RE";
// };


int main(){
	int n;
	string s;
	cin >> n;
	map<string, int> mapa;
	for(int i = 0; i < n; i++){
		cin >> s;
		mapa[s]++;
	}
	// it = 0;
	cout << "AC x " << mapa["AC"] << endl;
	cout << "WA x " << mapa["WA"] << endl;
	cout << "TLE x " << mapa["TLE"] << endl;
	cout << "RE x " << mapa["RE"] << endl;

	return 0;
}

Measured memory_bytes: 3636
using System;
using System.Linq;

class name
{

    static void Main()
    {
        int [] kyu = Console.ReadLine().Split().Select(int.Parse).ToArray();
        int s = 400;
        int ans =9;
        for(int f = 0; f < 10; f++)
        {
            if (kyu[0] >= s) {
                s += 200;
                ans--;
            }
            else
            {
                break;
            }

        }

        Console.WriteLine(ans);

    }





}

Measured memory_bytes: 28116
n,k=map(int,input().split())
a=list(map(int,input().split()))
mod=1000000007
dp=[[0]*(k+1) for i in range(n+1)] 
dp[0][0]=1
for i in range(n):
  sm=0
  for j in range(k+1):
    sm+=dp[i][j]
    sm%=mod
    dp[i+1][j]=sm
    if j>=a[i]:
      sm-=dp[i][j-a[i]]
      sm=(sm+mod)%mod
print(dp[n][k])

Measured memory_bytes: 147236
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <numeric>
#include <functional>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> P;
#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;
 
int main() {
    ll n;
    string s;
    cin >> n >> s;

    char c = s[0];
    ll ans = 1;
    rep(i, n) {
        if(c != s[i]) {
            ans++;
            c = s[i];
        }
    }

    out(ans);
    re0;
}

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

using namespace std;
using ll = long long;
using P = pair<int, int>;


int main() {
	int n,k,max;
    ll p;
	cin >> n;
	vector<int>s;
	rep(i, n) {
		cin >> k;
		s.push_back(k);
	}
	max = s[0];
	p = 0;
	rep(j, n-1) {
		if (s[j + 1] < max) {
			p = p + (max - s[j + 1]);
		}
		if(s[j+1]>=max) {
			max = s[j + 1];
		}
	}
	cout << p << endl;
	return 0;
}

Measured memory_bytes: 4288
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		int n,r,i,p,c,j,k,l,m,v;
		while(true){
			n=sc.nextInt();
			r=sc.nextInt();
			if(n==0 && r==0) break;
			int card[]=new int[n+1];
			int copy[]=new int[n+1];
			int ans[]=new int[n+1];
			for(i=0;i<n+1;i++)
				card[i]=i;
			for(i=0;i<r;i++){
				p=sc.nextInt();
				c=sc.nextInt();
				k=0;l=0;
				for(v=n-p+1;l<c;l++){
					copy[k++]=card[v--];
				}
				v=n-p-c+2;
				for(j=n-p+2;j<=n;j++){
					card[v++]=card[j];
				}
				for(l=0;l<c;l++){
					card[n-l]=copy[l];
				}
//				for(m=0;m<=n;m++){
//					System.out.println(m+1+" card= "+card[m]);
//				}
			}//r for
			System.out.println(card[n]);
		}//while
	}
}

Measured memory_bytes: 12000
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ull unsigned long long
#define ui unsigned int
#define ld long double
#define mod 1000000007LL
#define eps 1e-13
// #define PI 3.141592653589793238L
#define INF 1000000011
#define INFLL 1000000000000000011LL
#define vi vector<int>
#define vll vector<long long>
#define pii pair<int, int>
#define pll pair<long long, long long>
#define pil pair<int, long long>
#define pli pair<long long, int>
#define mp make_pair
#define F first
#define S second
#define pb push_back
#define fo(i,a,n) for(i = (a); i < (n); i++)
#define gtl(x) getline(cin, (x))
#define flsh fflush(stdout)
#define sws ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define gcd __gcd
#define all(a) (a).begin(), (a).end()
#define sz(a) (int)((a).size())
#define io_file freopen("D:/Coding Problems/Contest/input_file.in", "r", stdin); freopen("D:/Coding Problems/Contest/output_file.out", "w", stdout)

ll modx(ll Base, ll exponent)
{
	ll ans = 1;
	if(Base == 1)
		return Base;
	while(exponent)
	{
		if(exponent & 1)
			ans = (ans * Base)%mod;
		Base = (Base * Base)%mod;
		exponent = exponent >> 1;
	}
	return ans;
}

ll inmodx(ll num)
{
	return (modx(num, mod-2LL));
}

bool cmp(pii a, pii b)//true for a before b
{
	if(a.S < b.S)
		return 1;
	if(a.S > b.S)
		return 0;
	if(a.F <= b.F)
		return 1;
	return 0;
}

const int N = (1e7) + 9;
const int M = (672*672) + 9;
const int LOGN = ((int)log2(N)) + 3;
const int LOGM = ((int)log2(M)) + 3;
const int BUCK = 900;

string s;

void solve()
{
	int n, d1, d2;
	cin >> s;
	d1 = -1;
	for(auto x : s)
	{
		d2 = x-'0';
		if(d1 == d2)
		{
			cout << "Bad\n";
			return;
		}
		d1 = d2;
	}
	cout << "Good\n";
	return;
}

int main()
{
	sws;
	clock_t clk;
	clk = clock();
	// io_file;
	// srand(clock());

	//Code here
	int t = 1, cs;
	cout << fixed << setprecision(15);
	// cin >> t;
	fo(cs,1,t+1)
	{
		// cout << "Case #" << cs << ": ";
		solve();
	}
	// Code ends here

	clk = clock() - clk;
	cerr << fixed << setprecision(6) << "Time: " << ((double)clk)/CLOCKS_PER_SEC << "\n";
	return 0;
}

Measured memory_bytes: 256
import sys
 
input = sys.stdin.readline

def main():
    n = int(input())
    a = list(map(int, input().strip().split()))
    
    if 0 in a:
        print(0)
        return
    ans = 1
    for ai in a:
        ans *= ai
        if(ans > 10**18):
            print(-1)
            return
    print(ans)
    
if __name__ == "__main__":
    main()

Measured memory_bytes: 21640
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.StringTokenizer;

public class Main {
	static class FastReader {
		BufferedReader br;
		StringTokenizer st;

		public FastReader() {
			br = new BufferedReader(new InputStreamReader(System.in));
		}

		String next() {
			while (st == null || !st.hasMoreElements()) {
				try {
					st = new StringTokenizer(br.readLine());
				} catch (IOException e) {
					e.printStackTrace();
				}
			}
			return st.nextToken();
		}

		int nextInt() {
			return Integer.parseInt(next());
		}

		long nextLong() {
			return Long.parseLong(next());
		}

		double nextDouble() {
			return Double.parseDouble(next());
		}

		String nextLine() {
			String str = "";
			try {
				str = br.readLine();
			} catch (IOException e) {
				e.printStackTrace();
			}
			return str;
		}
	}

	public static void main(String[] args) {
		FastReader fr = new FastReader();

		int N = fr.nextInt();
		int[] a = new int[N];
		int[] b = new int[N];
		int[] c = new int[N];

		for (int i = 0; i < N; i++) {
			a[i] = fr.nextInt();
			b[i] = fr.nextInt();
			c[i] = fr.nextInt();
		}

		int[][] dp = new int[2 * N][3]; // 3 for 3 activities

		for (int i = 0; i < N; i++) {
			for (int j = 0; j < 3; j++) {
				if (i == 0) {
					switch (j) {
					case 0:
						dp[i][j] = a[i];
						break;
					case 1:
						dp[i][j] = b[i];
						break;
					case 2:
						dp[i][j] = c[i];
						break;
					}
				} else {
					for (int k = 0; k < 3; k++) {
						if (j == k) {
							/* Do nothing */ } else if (j == 0)
							dp[i][j] = Math.max(dp[i][j], dp[i - 1][k] + a[i]);
						else if (j == 1)
							dp[i][j] = Math.max(dp[i][j], dp[i - 1][k] + b[i]);
						else 
							dp[i][j] = Math.max(dp[i][j], dp[i - 1][k] + c[i]);
					}
				}
			}
		}
		
		int ret = 0;
		
		ret = Math.max(ret, dp[N-1][0]);
		ret = Math.max(ret, dp[N-1][1]);
		ret = Math.max(ret, dp[N-1][2]);
		
		System.out.println(ret);
	}

}


Measured memory_bytes: 63184
#include<bits/stdc++.h>
#define int long long
using namespace std;
main()
{
	//freopen("input.txt","rt",stdin);
	int a,b,c;
	cin>>a>>b>>c;
	if(a+b+c >= 22)
	{
		cout<<"bust"<<endl;
	}
	else
	{
		cout<<"win"<<endl;
	}
}

Measured memory_bytes: 256
from math import factorial
N = int(input())
P = list(map(int, input().split()))
Q = list(map(int, input().split()))
P1 = [1,2,3,4,5,6,7,8]
Q1 = [1,2,3,4,5,6,7,8]
Pcnt = 0
Qcnt = 0
for i in range(N-1):
  Pcnt += P1.index(P[i])*(factorial(N-1-i))
  P1.remove(P[i])
  Qcnt += Q1.index(Q[i])*(factorial(N-1-i))
  Q1.remove(Q[i])
print(abs(Pcnt-Qcnt))

Measured memory_bytes: 3064
n = gets.to_i
towns = []
for i in 0..n-1
  towns << gets.split.map(&:to_f)
end
distances = 0
towns.combination 2 do |a, b|
  distances += Math.sqrt((a[0] - b[0])**2 + (a[1] - b[1])**2)
end
puts distances / n * 2


Measured memory_bytes: 1788
N, x = map(int,input().split())
a_list = list(map(int,input().split()))

b_list = [a_list[i]+a_list[i+1] for i in range(0,N-1)]

excess_list = [max(0,val -x) for val in b_list]
ans = 0
for i in range(0,len(excess_list)-1):
    min_val = min(a_list[i+1],excess_list[i],excess_list[i+1])
    a_list[i+1] -= min_val
    excess_list[i] -= min_val
    excess_list[i+1] -= min_val
    ans += min_val
ans += sum(excess_list)
print(ans)

Measured memory_bytes: 14948
#include<cstdio>
#include<cmath>
#include<cstring>
#include<iostream>
#include<algorithm>
#include<cstdlib>
using namespace std;
int s[10];
int main(){
	int count=0;
	for(int i=1;i<=4;i++)
		scanf("%1d",&s[i]);
	for(int i=1;i<=3;i++){
		count=0;
		for(int j=i+1;j<=4;j++){
			if(s[i]==s[j]) count++;
			if(s[i]!=s[j]) break;
			if(count>=2) {
				printf("Yes\n");
				break;
			}
		}
		if(count>=2) break;
	}
	if(count<2) printf("No\n");
	return 0;
}

Measured memory_bytes: 256
while (l = gets.chomp) && l != 'END OF INPUT'
  puts l.split('').each_with_index.select{ |e| e[0] == ' ' }
        .map{ |e| e[1] }.unshift(-1).push(l.size)
        .each_cons(2).map{ |i, j| j - i - 1 } * ''
end

Measured memory_bytes: 8628
/*Step by step, my body’s bouncing
Close your eyes and dance like the flow of the waves
Feels like I could fly to space
I keep humming lululu
A fair skinned child
Like going to an amusement park
Holding up her arms
Like riding the Viking
She has fallen in love, feel
Heartbeat beating so loud
As if she’ll kiss you
On your fluffy cheeks

Ok turn up the rhythm
That flirty girl
Who smiled at you last time
She’s kinda pretty today
Maybe I’m crazy
The ambulance goes beep bo beep bo
But then again
I’m dancing along

Jumping with my round butt
High till I can touch the clouds
Bungee jumping from above
Where am I right now?

Up on the jelly
Up on the jelly
Up on the up on the
Up on the jelly
Up on the jelly
Up on the jelly
Up on the up on the
Up on the jelly

Step by step, my body’s bouncing
Close your eyes and dance like the flow of the waves
Feels like I could fly to space
I keep humming lululu

Drunk with the scent of sweet fruit
My clear eyes get hazy
I feel good even if someone calls me ugly
I’ll stick my tongue out to the antis
My smile will reach my ears
Like a big eyed frog
The taste of the voice in my ears
Like sugar coated lemon

Jumping with my round butt
High till I can touch the clouds
Bungee jumping from above
Where am I right now?
Up on the jelly
Up on the jelly
Up on the up on the
Up on the jelly
Up on the jelly
Up on the jelly
Up on the up on the
Up on the jelly

Up on the jelly
Up on the jelly
Up on the up on the
Up on the jelly
Up on the jelly
Up on the jelly
Up on the up on the
Up on the jelly*/

#include <bits/stdc++.h>
#define int long long
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define fi first
#define se second
#define for1(i, a, b) for(i = a; i <= b; ++i)
#define for0(i, a, b) for(i = a; i < b; ++i)
#define forw1(i, a, b) for(i = a; i >= b; --i)
#define forw0(i, a, b) for(i = a - 1; i >= b; --i)
#define fora(v, a) for(auto v : a)
#define bp __builtin_popcount
#define bpll __builtin_popcountll

using namespace std;
using cd = complex<double>;

typedef vector<int> vi;
typedef pair<int, int> ii;
typedef vector<cd> vcd;
typedef vector<ii> vii;
typedef vector<vector<int> > vvi;

const int modd1 = 1e9 + 7, modd2 = 998244353, maxn = 10, K = 26, inf = 1e9, infll = 1e18;
const double pi = acos(-1);

void solve(){
    int a, b, i, j; 
    cin >> a >> b;
    int ans = 0; int it = a;
    if(b <= 4){
        for1(i, a, b){
            ans ^= i;
        }
        cout << ans ; return;
    }
    while(it % 4 != 2){
        it++;
    }
    int ed = b;
    while(ed % 4 != 1){
        ed--;
    }
    if(ed < it){
        for1(i, a, b){
            ans ^= i;
        }
    }
    else{
        for1(i, a, it - 1){
            ans ^= i;
        }
        for1(i, ed + 1, b){
            ans ^= i;
        }
    }
    cout << ans;
}

signed main() {
    //freopen(".INP", "r", stdin); 
    //freopen(".OUT", "w", stdout);
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    solve();
}


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

int main() {
  int n, a, b;
  string s;
  cin >> n >> a >> b >> s;
  rep(i, n){
    if(s[i] == 'a' && a + b > 0){
      cout << "Yes" << endl;
      if(a > 0) --a;
      else --b;
    }
    else if(s[i] == 'b' && b > 0){
      cout << "Yes" << endl;
      --b;
    }
    else cout << "No" << endl;
  }
  return 0;
}

Measured memory_bytes: 896
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <cstring>
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <cmath>
#include <numeric>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef unsigned long long ll;


int main(){
	bool flag = true;
	int K , A , B; cin >> K >> A >> B;
	int i = 1;
	int X = K;
	while(X <= B){
		if(A <= X && X <= B){
			
			flag = false;
			break;
		}
		X = i * K;
		i++;
	}
	if(flag) cout << "NG" << endl;
	else cout << "OK" << endl;


}

Measured memory_bytes: 3596
#include<bits/stdc++.h>
using namespace std;
#define FASTIO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define FOR(i,s,n) for(int i=s;i<n;i++)
typedef long long ll;
int diff(string a,string b){
	int res=0;
	for(int i=0;i<a.length();i++){
		if(a[i]!=b[i])res++;
	}
	return res;	
}
int main(){
	FASTIO
	int ans=9999;
	string s,t;
	cin>>s;
	cin>>t;
	for(int i=0;i<=s.length()-t.length();i++){
		string temp=s.substr(i,t.length());
		ans=min(ans,diff(temp,t));
	}
	cout<<ans<<"\n";
	return 0;
}


Measured memory_bytes: 3664
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <fstream>
#include <complex>
#include <stack>
#include <queue>

using namespace std;
typedef long long LL;
typedef pair<int, int> P;
static const double EPS = 1e-5;

#define FOR(i,k,n) for (int i=(k); i<(int)(n); ++i)
#define REP(i,n) FOR(i,0,n)

int main(void){
  int a,b,c;
  while(cin>>a>>b>>c){
    if(a==0) break;
    vector< vector<int> > wrong;
    int right[310]={0};
    int m;
    cin>>m;
    REP(i,m){
      int x[3],k;
      REP(i,3)cin>>x[i];
      cin>>k;
      if(k==1){
        REP(i,3)right[x[i]]=1;
      }else{
        vector<int> tmp;
        REP(i,3)tmp.push_back(x[i]);
        wrong.push_back(tmp);
      }
    }
    REP(i,wrong.size()){
      int c=0;
      REP(j,3){
        if(right[wrong[i][j]]==1)c++;
      }
      if(c==2){
        REP(j,3)if(right[wrong[i][j]]!=1){
          right[wrong[i][j]]=2;
        }
      }
    }
    FOR(i,1,a+b+c+1){
      switch(right[i]){
        case 1:
          cout<<1<<endl;
          break;
        case 2:
          cout<<0<<endl;
          break;
        case 0:
          cout<<2<<endl;
          break;
      }
    }
  }        
  return 0;
}

Measured memory_bytes: 0
// https://atcoder.jp/contests/abc165/tasks/abc165_a

#include "algorithm"
#include "bitset"
#include "cmath"
#include "functional"
#include "iomanip"
#include "iostream"
#include "map"
#include "numeric"
#include "queue"
#include "set"
#include "string"
#include "vector"
#define rep(i, to) for (ll i = 0; i < (to); ++i)
#define rep1(i, to) for (ll i = 1; i <= (to); ++i)
#define repf(i, from, to) for (ll i = from; i < (to); ++i)
#define repr(i, from) for (ll i = from - 1; i >= 0; --i)
#define all(vec) vec.begin(), vec.end()
#define unless(cond) if (!(cond))
#define fi first
#define se second
using namespace std;
typedef long long ll;
typedef long double ld;
template <typename T>
using V = vector<T>;
using VL = V<ll>;
using VVL = V<VL>;
template <typename T, typename U>
using P = pair<T, U>;
using PL = P<ll, ll>;
using VPL = V<PL>;

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

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

struct exit_exception : public std::exception {
  const char* what() const throw() { return "Exited"; }
};

template <typename T>
void drop(T res) {
  cout << res << endl;
  throw exit_exception();
}

const ll INF = 1e18;

void solve();

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

  try {
    solve();
  } catch (exit_exception& e) {
  }

  return 0;
}
#endif

void solve() {
  ll K, A, B;
  cin >> K >> A >> B;

  for (auto a = A; a <= B; a++) {
    if (a % K == 0) {
      drop("OK");
    }
  }

  drop("NG");
}


Measured memory_bytes: 3684
using System;
using System.Text;
using System.Collections.Generic;
using static System.Math;
using System.Linq;
using static System.Array;
using System.Globalization;

namespace ConsoleApp2
{
    class Program
    {
        static long K;
        static long N;
        static long[] A;
        static void Main(string[] args)
        {
            //var UV = Console.ReadLine().Split(' ').Select(x => long.Parse(x)).ToArray();

            var S = Console.ReadLine();
            if (S.Contains('7'))
            {
                Console.WriteLine("Yes");
            }
            else
            {
                Console.WriteLine("No");
            }
            
        }
    }
}


Measured memory_bytes: 17320
#include<iostream>
#include<cstdio>
#include<cstring> 
using namespace std;
char s[55],t[55];
int sc,tc,a,b;
int pd(int b)
   {
   	for(int i=b;i<b+tc;i++)
   	if(s[i]!='?'&&s[i]!=t[i-b])return 0;
   	return 1;
   }

int main()
{
	scanf("%s %s",s,t);
	sc=strlen(s),tc=strlen(t);
	a=sc-tc;
	for(int i=a;i>=0;i--)
	{
	if(pd(i))
	{
		for(int j=0;j<i;j++)
		if(s[j]=='?')s[j]='a';
		for(int j=i;j<i+tc;j++)
		s[j]=t[j-i];
		for(int j=i+tc;j<sc;j++)
		if(s[j]=='?')s[j]='a';
		printf("%s",s);
		return 0;
	}
	}
	printf("UNRESTORABLE");	
  return 0;		
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define int long long
#define PB push_back
#define MP make_pair
#define FI first
#define SE second
using namespace std;
static const int INF = 1ll<<60;
static const int dx[] = {0,0,1,-1};
static const int dy[] = {1,-1,0,0};
typedef pair< int,int > PII;
typedef pair< int,pair<int,int> > PPII;

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


Measured memory_bytes: 640
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<iostream>
#include<string>
#include<vector>
#include<stack>
#include<bitset>
#include<cstdlib>
#include<cmath>
#include<set>
#include<list>
#include<deque>
#include<map>
#include<queue>
#include<sstream>
using namespace std;
typedef long long LL;
const int INF = 0x3f3f3f3f;
const int MAXN = 2e4 + 5;
int dp[MAXN];
int a[MAXN];
int b[MAXN];
int n,h;
int main()
{
	cin >> h >> n;
	int maxn = h;
	for(int i = 0;i < n;i++){
		scanf("%d%d",&a[i],&b[i]);
		maxn = max(a[i],maxn);
	}
	memset(dp,0x3f,sizeof(dp));
	dp[0] = 0;
	for(int i = 0;i < n;i++){
		for(int j = 1;j <= 2 * maxn;j++){
			if(a[i] >= j)
				dp[j] = min(dp[0] + b[i],dp[j]);
			else
				dp[j] = min(dp[j - a[i]] + b[i],dp[j]); 
		}
	}
	int ans = INF;
	for(int i = h;i <= maxn;i++){
		ans = min(ans,dp[i]);
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 384
import java.util.*;
class Main{
 public static void main(String[]  args){
  Scanner sc = new Scanner(System.in);
  int n = sc.nextInt();
   int k = sc.nextInt();
   int a[] = new int[n];
   for(int i=0;i<n;i++){
    a[i]=sc.nextInt(); 
   }
   Arrays.sort(a);
   int sum=0;
   int j=0;
   while(k-->0){
     sum+=a[j];
     j++;
   }
   System.out.println(sum);
   
   
 }
  
  
  
}

Measured memory_bytes: 38916
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cassert>
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)
#define rep(i,n) FOR(i,0,n)
#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define vint vector<int>
#define vdouble vector<double>
#define vstring vector<string>
using namespace std;

#include<map>
#include<set>
#include<queue>

typedef long long ll;
typedef unsigned long long ull;

const int MAX_N = 1000000;
int S[MAX_N];
int T[MAX_N];
int SN, ST;

int main() {

	cin >> SN;
	rep(i, SN){ cin >> S[i]; }
	cin >> ST;
	rep(i, ST){ cin >> T[i]; }

	int ct = 0;
	rep(i, ST){
		int flag = 0;
		rep(j, SN){ if (S[j] == T[i]) { flag++; break; } }
		ct += flag;
	}
	cout << ct << endl;
}

Measured memory_bytes: 3052
#include <stdio.h>

int main(void) {

  int x, y, z;

  scanf("%d %d", &x, &y);

  while(x!=0||y!=0) {

    if(x > y) {
      z = x;
      x = y;
      y = z;
    }

    printf("%d %d\n", x ,y);
    
    scanf("%d %d", &x, &y);
  }

  return 0;
 
}

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

typedef long long LL;

const int N=10000;

int n,a[N+9];

void into(){
  scanf("%d",&n);
  for (int i=n;i>=0;--i)
	scanf("%d",&a[i]);
}

int b[N+9],pr[N+9],cp;

void Sieve(){
  for (int i=2;i<=n+1;++i){
	if (!b[i]) pr[++cp]=i;
	for (int j=1;j<=cp&&i*pr[j]<=n;++j){
	  b[i*pr[j]]=1;
	  if (i%pr[j]==0) break;
	}
  }
}

int ans[N*2+9],ca;

void Get_ans(int n){
  int t=n;
  for (int i=2;i*i<=n;++i)
	if (t%i==0){
	  ans[++ca]=i;
	  for (;t%i==0;t/=i);
	}
  if (t>1) ans[++ca]=t;
}

int tmp[N+9];

bool Check_ans(int p){
  if (a[0]%p) return 0;
  for (int i=0;i<p;++i) tmp[i]=0;
  for (int i=0;i<=n;++i){
	int t=i%(p-1);
	tmp[t]=(tmp[t]+a[i])%p;
  }
  for (int i=0;i<p;++i)
	if (tmp[i]) return 0;
  return 1;
}

void Get_ans(){
  int g=abs(a[0]);
  for (int i=1;i<=n;++i) g=__gcd(g,abs(a[i]));
  Get_ans(g);
  for (int i=1;i<=cp;++i)
	if (Check_ans(pr[i])) ans[++ca]=pr[i];
  sort(ans+1,ans+ca+1);
  ca=unique(ans+1,ans+ca+1)-ans-1;
}

void work(){
  Sieve();
  Get_ans();
}

void outo(){
  for (int i=1;i<=ca;++i)
	printf("%d\n",ans[i]);
}

int main(){
  into();
  work();
  outo();
  return 0;
}

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

using Graph=vector<vector<int>>;

Graph g;
vector<int> used;
pair<int,int> dfs(int v){
    pair<int,int> res={used[v],!used[v]};
    for(auto to:g[v]){
        if(used[to]==-1){
            used[to]=!used[v];
            auto tmp=dfs(to);
            res.first+=tmp.first,res.second+=tmp.second;
        }
        else if(used[to]==used[v]){
            throw std::runtime_error("BAD");
        }
    }
    return res;
}
int main(){
    int n,m;
    cin>>n>>m;
    vector<vector<int>> mat(n,vector<int>(n));
    for(int i=0;i<m;i++){
        int a,b;
        cin>>a>>b;
        a--,b--;
        mat[a][b]=true;
        mat[b][a]=true;
    }
    g.resize(n);
    used.assign(n,-1);
    for(int i=0;i<n;i++){
        for(int j=0;j<i;j++){
            if(!mat[i][j]){
                g[i].push_back(j);
                g[j].push_back(i);
            }
        }
    }
    
    vector<pair<int,int>> bag;
    for(int i=0;i<n;i++){
        if(used[i]==-1){
            try{
                used[i]=0;
                auto ret=dfs(i);
                bag.push_back(ret);
            }
            catch(...){
                cout<<-1<<endl;
                return 0;
            }
        }
    }

    vector<vector<int>> dp(bag.size()+1,vector<int>(n+1));
    dp[0][0]=true;
    for(int i=0;i<bag.size();i++){
        int a=bag[i].first,b=bag[i].second;
        for(int j=0;j<=n;j++){
            if(j+a<=n) dp[i+1][j+a]|=dp[i][j];
            if(j+b<=n) dp[i+1][j+b]|=dp[i][j];
        }
    }
    int res=m;
    for(int i=0;i<=n;i++){
        if(dp[bag.size()][i]) res=min(res,i*(i-1)/2+(n-i)*(n-i-1)/2);
    }
    cout<<res<<endl;
    return 0;
}

Measured memory_bytes: 4992
package main

import "fmt"

func main() {
        var n int
        fmt.Scan(&n)

        for i := 0; i < 3; i++ {
                if n%10 == 7 {
                        fmt.Println("Yes")
                        return
                }
                n /= 10
        }
        fmt.Println("No")
} 

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

int main() {
	int n, sum;
	int s[1000];
	double m, variance;

	for(int i=0; i<1000; i++) s[i] = 0;
	
	cout.precision(8);

	while(cin >> n) {
		if(n==0) break;

		sum=0;
		for(int i=0; i<n; i++) {
			cin >> s[i];
			sum += s[i];
		}

		//HINT: times 1.0
		m = sum*1.0/n;
		variance = 0.0;
		for(int i=0; i<n; i++) variance += (s[i]-m)*(s[i]-m);

		cout << fixed << sqrt(variance/n) << endl;
	}
	return 0;
}


Measured memory_bytes: 3292
import sys
input = sys.stdin.readline
 
from heapq import heappop,heappush
import math
 
xs,ys,xt,yt = map(int,input().split())
n = int(input())
 
v = [[xs,ys,0]]
for _ in range(n):
    x,y,r = map(int,input().split())
    v.append([x,y,r])
v.append([xt,yt,0])
 
def dd(a,b):
    return max(0,math.sqrt((a[0]-b[0])**2 + (a[1]-b[1])**2) - a[2] - b[2])

edges=[[0]*(n+2) for _ in range(n+2)]
for i in range(n+2):
    for j in range(i+1,n+2):
        edges[i][j] = dd(v[i],v[j])
        edges[j][i] = dd(v[i],v[j])

def dijkstra(s,n,edges):
    #edges[i][j] : the cost of i→j
    #import 'heap'
    d = [float('inf') for _ in range(n)]
    d[s] = 0
    q = [(0, s)]
    while q:
        dist_u, u = heappop(q)
        if d[u] < dist_u:
            continue
        for v, c in enumerate(edges[u]):
            if d[v] > dist_u + c:
                d[v] = dist_u + c
                heappush(q, (d[v], v))
    return d

ans = dijkstra(0,n+2,edges)
print(ans[n+1])

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

int main() {
    int n;
    cin >> n;
    int count[4] = {};
    for (int a; cin >> a; count[a % 4]++) {
    }
    if (count[0] >= count[1] + count[3] || count[2] == 0 && count[0] + 1 >= count[1] + count[3]) {
        cout << "Yes";
    } else {
        cout << "No";
    }
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;
public class Main
{
	public static void main(String[] args) 
	{
		Scanner in=new Scanner(System.in);
		int N=in.nextInt();
		while(N-->0)
		{
			String s[]=in.next().split(":");
			double S=Double.valueOf(s[0]);
			double L=Double.valueOf(s[1]);
			S=360*(60*S+L)/720.0;
			L=360.0*L/60.0;
			double dif=Math.min(Math.abs(S-L), 360-Math.abs(S-L));
			System.out.println(0<=dif&&dif<30 ? "alert":90<=dif&&dif<=180 ? "safe":"warning");
		}
	}
}

Measured memory_bytes: 12000