akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
struct SegTree {
	int size;
	LL *dat,*lazy;
	SegTree(int n) {
		size=1;
		while(size<n) size*=2;
		dat=(LL*)malloc(sizeof(LL)*(size*2-1));
		fill(dat,dat+(size*2-1),0);
		lazy=(LL*)malloc(sizeof(LL)*(size*2-1));
		fill(lazy,lazy+(size*2-1),0);
	}
	void eval(int k,int len) {
		dat[k]+=lazy[k]*len;
		if(k<size-1) lazy[k*2+1]+=lazy[k],lazy[k*2+2]+=lazy[k];
		lazy[k]=0;
	}
	void add(int a,int b,int  x,int k,int l,int r) {
		eval(k,r-l);
		if(r<=a||b<=l) return;
		if(a<=l&&r<=b) {
			lazy[k]+=x;
			eval(k,r-l);
		}else {
			add(a,b,x,k*2+1,l,(l+r)/2);
			add(a,b,x,k*2+2,(l+r)/2,r);
			dat[k]=dat[k*2+1]+dat[k*2+2];
		}
	}
	LL sum(int a,int b,int k,int l,int r) {
		eval(k,r-l);
		if(r<=a||b<=l) return 0;
		if(a<=l&&r<=b) return dat[k];
		return sum(a,b,k*2+1,l,(l+r)/2)+sum(a,b,k*2+2,(l+r)/2,r);
	}
};
int main() {
	int n,q;
	scanf("%d %d",&n,&q);
	SegTree S(n);
	for(int i=0;i<q;i++) {
		int type,s,t,x;
		scanf("%d",&type);
		if(type==0) {
			scanf("%d %d %d",&s,&t,&x);s--;
			S.add(s,t,x,0,0,S.size);
		}else {
			scanf("%d %d",&s,&t);s--;
			printf("%lld\n",S.sum(s,t,0,0,S.size));
		}
	}
}

Measured memory_bytes: 7296
#include <iostream>

using namespace std;

int main()
{
    ios_base::sync_with_stdio(0);
    string a;
    cin >> a;
    int n = a.size();
    if (n == 1)
    {
        cout << "No";
        return 0;
    }
    for (int i = 0; i < n - 1; ++i)
    {
        if (a[i] == 'A' && a[i + 1] == 'C')
        {
            cout << "Yes";
            return 0;
        }
    }
    cout << "No";
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#include<iostream>
#include<string>
#include<algorithm>
#include<vector> 
#include<limits>
#include<numeric>
#include<type_traits>
#include<math.h>
using namespace std;
typedef long long ll;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repi(i,a,b) for(int i = (int)(a); i < (int)(b); i++)
#define in(x) cin >> x
#define out(str) cout << str << endl

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

int N,A,B,temp;

int main(){
    cin>>N>>A>>B;
    int cnt[3];
    rep(i,3){
        cnt[i]=0;
    }
    rep(i,N){
        cin>>temp;
        if(temp<=A){
            cnt[0]++;
        }
        else if (temp>B)
        {
            cnt[2]++;
        }
        else{
            cnt[1]++;
        }
    }
    out(min(cnt[0],min(cnt[1],cnt[2])));
}


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

typedef long long ll;
const int N = 2000006;

int main(){
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	
	string s,t;
	cin>>s>>t;
	int n,m;
	cin>>n>>m;
	string h;
	cin>>h;
	
	if(h == s){
		cout<<n-1<<" "<<m;
	}else{
		cout<<n<<" "<<m-1;
	}
	
	return 0;
}


Measured memory_bytes: 3600
#include <bits/stdc++.h>
using namespace std;
int main(){
    int N,T; cin >> N >> T;
    int c[110];
    int t[110];
    for(int i=0; i < N; i++) cin >> c[i] >> t[i];
    int minc=1001;
    for(int i=0; i < N; i++){
        if(t[i] <= T){
            if(minc > c[i]) minc = c[i];
        }
    }
    if(minc == 1001) cout << "TLE" << endl;
    else cout << minc << endl;
}

Measured memory_bytes: 256
import java.util.*;
 
public class Main {
  public static void main(String[] args) {
    Scanner in = new Scanner(System.in);
    int num = in.nextInt();
    int[] count = new int[3];
    while(in.hasNextInt()) {
      int tmp = in.nextInt() & 3;
      if ((tmp & 1) == 1) {
        count[0]++;
      } else if ((~tmp & 3) == 1) {
        count[1]++;
      } else {
        count[2]++;
      }
    }
    String ans = "Yes";
    int t = count[1] > 0 ? 1 : 0;
    if (count[2] + 1 < count[0] + t) ans = "No"; 
    System.out.println(ans);
  }
}

Measured memory_bytes: 58456
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <queue>
#include <climits>
#include <set>
#include <map>
#include <stack>
#include <iomanip>
#include <tuple>
#define ll long long
using namespace std;
struct all_init
{
    all_init()
    {
        cout << fixed << setprecision(12);
    }
} All_init;

int main()
{
    string s;
    cin >> s;
    vector<ll> a(26, 0);
    for (ll i = 0; i < s.size(); i++)
    {
        a[s[i] - 'a']++;
    }
    for (ll i = 0; i < 26; i++)
    {
        if (a[i] <= 0)
        {
            cout << (char)('a' + i) << endl;
            exit(0);
        }
    }
    cout << "None" << endl;
}


Measured memory_bytes: 512
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

func out(x ...interface{}) {
	fmt.Println(x...)
}

var sc = bufio.NewScanner(os.Stdin)

func getInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func getString() string {
	sc.Scan()
	return sc.Text()
}

func min(a, b int) int {
	if a > b {
		return b
	}
	return a
}

func main() {
	sc.Split(bufio.ScanWords)

	N, T := getInt(), getInt()
	t := make([]int, N)
	for i := 0; i < N; i++ {
		t[i] = getInt()
	}

	total := 0
	for i := 1; i < N; i++ {
		total += min(T, t[i]-t[i-1])
	}
	total += T

	out(total)
}


Measured memory_bytes: 4608
#include <iostream>
#include <cstring>
using namespace std;
const int INF=0x3f3f3f3f,maxn=1001;
string s,t;
int a[maxn],n,m;
int main()
{
	int i,j,k,ans=INF;
	cin>>s>>t;
	for(i=0;i<=s.size()-t.size();i++)
	{
		int dif=0;
		for(j=0;j<t.size();j++)
			dif+=!(s[i+j]==t[j]);
		a[i]=dif;
	}
	for(i=0;i<s.size()-t.size()+1;i++)
	{
		ans=min(a[i],ans);

}	cout<<ans;
	return 0;
}


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

int main() {
	// your code goes here
	double l = 0.0;
	cin>>l;
	double a = 3.0;
	double t = (l/a);
	double ans = t*t*t;
	cout<<fixed;
	cout<<ans;
	return 0;
}

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



int main(){

    int N=0,D=0,count=0;
    scanf("%d %d",&N,&D);
    for(int i=0;i<N;i++){
	double x=0,y=0;
	scanf("%lf %lf",&x,&y);
	if(sqrt(x*x+y*y)<=D)
	    count++;
    }

    printf("%d\n",count);
    return 0;
}



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

int main()
{
	long N, A[100005], i = 0;
	long sum = 0;
	cin >> N;
	A[0] = 0;
	for (i = 1; i <= N; ++i) {
		cin >> A[i];
	}
	A[i] = 0;

	for (i = 0; i <= N; ++i) {
		sum += abs(A[i + 1] - A[i]);
	}

	for (i = 1; i <= N; ++i) {
		if (((A[i - 1] < A[i]) && (A[i] < A[i + 1])) || ((A[i - 1] > A[i]) && (A[i] > A[i + 1]))) {
			cout << sum << endl;
		}
		else if (abs(A[i - 1] - A[i]) < abs(A[i + 1] - A[i])) {
			cout << sum - abs((A[i - 1] - A[i]) * 2) << endl;
		} else {
			cout << sum - abs((A[i + 1] - A[i]) * 2) << endl;			
		}
	}
}

Measured memory_bytes: 2048
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<cassert>
#include<iostream>
#include<sstream>
#include<string>
#include<vector>
#include<queue>
#include<set>
#include<map>
#include<utility>
#include<numeric>
#include<algorithm>
#include<bitset>
#include<complex>

using namespace std;

typedef long long Int;
typedef vector<int> vint;
typedef pair<int,int> pint;
#define mp make_pair

template<class T> void pv(T a, T b) { for (T i = a; i != b; ++i) cout << *i << " "; cout << endl; }
template<class T> void chmin(T &t, T f) { if (t > f) t = f; }
template<class T> void chmax(T &t, T f) { if (t < f) t = f; }
int in() { int x; scanf("%d", &x); return x; }

int cards[100010];

int main() {
	int n,k;
	while(n=in(),k=in()){
		memset(cards,0,sizeof(cards));
		int i;
		for(i=0;i<k;i++){
			cards[in()]++;
		}
		if(cards[0]){
			int mx=0,beg1=1,beg2=0;
			for(i=1;i<=n;i++){
				if(cards[i]){
					if(beg2==0){
						beg2=i;
						beg1=i;
					}else if(beg1==0){
						beg1=i;
					}
				}else{
					beg2=beg1;
					beg1=0;
				}
//cout<<i<<" "<<cards[i]<<" "<<beg1<<" "<<beg2<<endl;
				if(beg2)chmax(mx,i-beg2+1);
			}
			cout<<mx<<endl;
		}else{
			int mx=0,beg=0;
			for(i=1;i<=n;i++){
				if(cards[i]){
					if(beg==0)beg=i;
					chmax(mx,i-beg+1);
				}else{
					beg=0;
				}
			}
			cout<<mx<<endl;
		}
	}
	return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i, n) for(ll i=0; i<(ll)n; i++)
#define REPR(i, n) for(ll i=(ll)n-1; i>=0; i--)
#define FOR(i, m, n) for(ll i=(ll)m; i<(ll)n; i++)
#define FORR(i, m, n) for(ll i=(ll)m-1; i>=(ll)n; i--)
#define ALL(x) (x).begin(), (x).end()
#define ASC(v) sort(ALL(v));
#define DESC(v) sort(ALL(v), greater<int>());
#define UNIQ(a) sort(ALL(a));(a).resize(unique(ALL(a)) - a.begin());
#define PRINTD(x, d) cout << fixed << setprecision(d) << x << "\n";
#define DEBUG(x) cout<<#x<<": "<<x<<"\n"
const double PI = acos(-1);
ll lcm(ll a, ll b) { return a / __gcd(a, b) * b; }
bool isprime(int x){ int i; if(x<2)return 0; else if(x==2) return 1; if(x%2==0) return 0; for(i=3; i*i<=x; i+=2) if(x%i==0) return 0; return 1; }
int digsum(int n) { int r=0; while(n>0) { r+=n%10; n/=10; } return r; }
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; }
struct nya{ nya(){ cin.tie(0); ios::sync_with_stdio(false); } }nyan;


int main(){
    ll K, A, B;
    cin >> K >> A >> B;
    bool can = false;
    FOR(i, A, B+1) if (i%K == 0) can = true;
    if (can) cout << "OK\n";
    else cout << "NG\n";
}


Measured memory_bytes: 3608
#include <iostream>
#include <vector>
#include <algorithm>
#include <iomanip>
using namespace std;

typedef long long ll;

const int INF = 1001001001;

int main() {
    int N, M;
    cin >> N >> M;
    vector<pair<int,int>> key; //first: 集合、second:コスト
    for (int i=0;i<M;i++){
        int A, B;
        cin >> A >> B;
        int s = 0;
        for (int j=0;j<B;j++){
            int c;
            cin >> c;
            c--;
            s |= 1<<c;
        }
        key.emplace_back(s,A);
    }

    vector<int> dp(1<<N,INF);
    dp[0] = 0;
    for (int s=0;s<(1<<N);s++){
        for (int i=0;i<M;i++){
            int t = s | key[i].first;
            int cost = dp[s] + key[i].second;
            dp[t] = min(dp[t], cost);
        }
    }
    int ans = dp.back();
    if (ans == INF) ans = -1;
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
/*package whatever //do not write package name here */

import java.io.*;
import java.util.*;
public class Main {
    
	public static void main (String[] args) {
		Scanner s=new Scanner(System.in);
		long m=s.nextLong();
		long n=s.nextLong();
		if(n>=m)
		System.out.println("unsafe");
		else
		System.out.println("safe");
		
	}
}
		
		
		   

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

int main(){
    int X, Y, A[3];
    cin >> X >> Y >> A[0] >> A[1] >> A[2];
    vector<pair<int, int>> vs;
    for(int k=0; k<3; k++) for(int i=0; i<A[k]; i++){
        int a;
        cin >> a;
        vs.emplace_back(a, k);
    }
    sort(vs.rbegin(), vs.rend());

    int S = X+Y;
    int64_t ans = 0;
    for(auto& p : vs){
        int v = p.first, c = p.second;
        if(c == 0){
            if(S > 0 && X > 0){
                S--;
                X--;
                ans += v;
            }
        }else if(c == 1){
            if(S > 0 && Y > 0){
                S--;
                Y--;
                ans += v;
            }
        }else{
            if(S > 0){
                S--;
                ans += v;
            }
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 6512
s = input()
S = s[::-1]
n = len(s)
#print(s, n)
i = int(((n-1)/2)-1)
j = int(((n+3)/2)-1)
#print(i, j)
l = s[:i+1]
l2 = l[::-1]
r = s[j:]
r2 = r[::-1]
#print(l, l2, r, r2)
if l == l2 and r == r2 and s == S:
  print('Yes')
else:
  print('No')

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define mem(a,b) memset(a,b,sizeof(a))
using namespace std;
typedef long long ll;
const int maxn = 100005;
int a,b,c;
int main() {
 //   freopen("input.txt", "r", stdin);
    ios::sync_with_stdio(false);
    cin.tie(0);
    cin >> a >> b >> c;
    if(c >= a && c <= b)
        cout << "Yes";
    else cout << "No";
    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int infty = 1e9;
vector<vector<pair<int, int>>> grh;
vector<int> dst;
void dijk (int start) {
  priority_queue<pair<int, int>, vector<pair<int, int>>, greater<pair<int, int>>> prq;
  for (int i = 0; i < dst.size(); i++) {
    dst[i] = infty;
  }
  prq.push({0, start});
  while (!prq.empty()) {
    auto e = prq.top();
    prq.pop();
    int d = e.first;
    int t = e.second;
    dst[t] = min(dst[t], d);
    for (auto f : grh[t]) {
      int w = f.first;
      int u = f.second;
      if (w + d < dst[u]) {
        prq.push({w + d, u});
      }
    }
  }
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  grh.resize(n);
  dst.resize(n);
  for (int i = 0; i < n - 1; i++) {
    int s, t, w;
    cin >> s >> t >> w;
    grh[s].push_back({w, t});
    grh[t].push_back({w, s});
  }
  dijk(0);
  int start = 0;
  int rad = 0;
  for (int i = 0; i < n; i++) {
    if (rad < dst[i]) {
      start = i;
      rad = dst[i];
    }
  }
  dijk(start);
  int diam = 0;
  for (int i = 0; i < n; i++) {
    diam = max(diam, dst[i]);
  }
  cout << diam << '\n';
  return 0;
}


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

#define li long long int
#define rep(i, to) for (li i = 0; i < ((li)(to)); i++)
#define repp(i, start, to) for (li i = (li)(start); i < ((li)(to)); i++)

li a[10100];
li b[10100];
li n;

inline bool check() {
	cin >> n;
	li sa = 0;
	rep(i, n) {
		cin >> a[i];
		sa += a[i];
	}
	li sb = 0;
	rep(i, n) {
		cin >> b[i];
		sb += b[i];
	}
	li num = sb - sa;
	li sum = 0;
	rep(i, n) {
		if (a[i] < b[i]) {
			li cnt = (b[i] - a[i] + 1) / 2;
			sum += cnt;
		}
	}
	return sum <= num;
}

int main() {
	cout << (check() ? "Yes" : "No") << endl;

	return 0;
}


Measured memory_bytes: 384
from statistics import mean, median,variance,stdev
import sys
import math
import fractions

def j(q):
    if q==1: print("YES")
    else:print("NO")
    exit(0)


def ct(x,y):
    if (x>y):print("")
    elif (x<y): print("")
    else: print("")

def ip():
    return int(input())

#n = ip()                              #入力整数1つ
#x,y= (int(i) for i in input().split())      #入力整数横2つ
#a,b,k = (int(i) for i in input().split())    #入力整数横3つ
#n,m,x,y= (int(i) for i in input().split())  #入力整数横4つ
#a = [int(i) for i in input().split()]        #入力整数配列
#a = input()                                  #入力文字列
#a = input().split()                          #入力文字配列

#jの変数はしようできないので注意
#全足しにsum変数使用はsum関数使用できないので注意

a =[]
for i in range(3):
    b = [int(i) for i in input().split()]
    b.sort()
    a.append(b)
if [1,2] in a and [3,4] in a:j(1)
if [1,3] in a and [2,4] in a:j(1)
if [1,4] in a and [2,3] in a:j(1)
j(0)


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


string ans;
string S;
int main() {
    cin >> S;
    if(S[0]=='A'&&S[1]=='B'&&S[2]=='C'){
        ans = "ARC";
    }else{
        ans = "ABC";
    }

    cout << ans << endl;
}

Measured memory_bytes: 3640
x, y = list(map(int, input().split()))

if abs(x) >= abs(y):
  if x>=0 and y>0:
    print(x-y+2)
  elif x>0 and y<=0:
    print(x+y+1)
  elif x<0 and y>0:
    print(-x-y+1)
  else:
    print(y-x)

if abs(x) < abs(y):
  if x>=0 and y>=0:
    print(y-x)
  elif x>=0 and y<0:
    print(-y-x +1)
  elif x<0 and y>=0:
    print(y+x + 1)
  else:
    print(x-y + 2)

Measured memory_bytes: 3064
import std.stdio, std.conv, std.string, std.array, std.range, std.algorithm, std.container;
import std.math, std.random, std.bigint, std.datetime, std.format;
void main(string[] args){ if(args.length > 1) if(args[1] == "-debug") DEBUG = 1; solve(); } bool DEBUG = 0; 
void log(A ...)(lazy A a){ if(DEBUG) print(a); }
void print(){ writeln(""); } void print(T)(T t){ writeln(t); } void print(T, A ...)(T t, A a){ write(t, " "), print(a); }
string unsplit(T)(T xs){ return xs.array.to!(string[]).join(" "); }
string scan(){ static string[] ss; while(!ss.length) ss = readln.chomp.split; string res = ss[0]; ss.popFront; return res; }
T scan(T)(){ return scan.to!T; } T[] scan(T)(int n){ return n.iota.map!(i => scan!T()).array; }
T lowerTo(T)(ref T x, T y){ if(x > y) x = y; return x; } T raiseTo(T)(ref T x, T y){ if(x < y) x = y; return x; }

// ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- //

void solve(){
    int n = scan!int;
    print(["pon", "pon", "hon", "bon", "hon", "hon", "pon", "hon", "pon", "hon"][n % 10]);
}



Measured memory_bytes: 3280
#include <bits/stdc++.h>
using namespace std;
using namespace std::chrono;
#define idfc ios_base::sync_with_stdio(false),cin.tie(nullptr),cout.tie(nullptr)
//#define ll long long
#define pb emplace_back
#define mp make_pair
#define nt _ll128
#define ld long double
long double PI =3.14159265358979323846;
using ll = long long;



const ll modo=1e9+7;
const ll inf=LONG_LONG_MAX;
const ll ms=(1e5)+5;

int ar[ms];
vector<int> vv[ms];

int main()
{
    idfc;
    int n,m;
    cin>>n>>m;
    int i;
    for(i=1;i<=n;i++)cin>>ar[i];
    int an=n;
    int u,v;
    while(m--)
    {
        cin>>u>>v;
        vv[u].pb(v);
        vv[v].pb(u);
    }

    for(i=1;i<=n;i++)
    {
        for(int ii:vv[i])
        {
            if(ar[ii]>=ar[i]){
                an--;
                break;
            }
        }
    }
    cout<<an;

    return 0;
}

Measured memory_bytes: 9188
#include <iostream>
#include <cmath>
#include <algorithm>
#include <string>
#include <vector>
#include <set>
using namespace std;
 
int main(){
    long long X;
    cin >> X;

    long long m = 0;
    m += (X / 500) * 1000;
    m += ((X % 500) / 5 ) * 5;

    cout << m << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
    char A,B;
    cin >> A >>B;
    if(A == 'H'){
        if(B == 'H')cout << 'H' << endl;
        else cout << 'D' << endl;
    }
    else{
        if(B == 'H')cout << 'D' << endl;
        else cout << 'H'<< endl;
    }
}

Measured memory_bytes: 256
/*
　　　　 ∧＿∧　にっぽんちゃちゃちゃ
　／＼（　・∀・）／ヽ
（ ●　と　　　つ　● ）　にっぽんちゃちゃちゃ
　＼/⊂、 ノ　　＼ノ
　　　　　し'
*/
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define repone(i,n) for(int i=1;i<(int)(n);++i)
#define repo(i,o,n) for(int i=o;i<(int)(n);++i)
#define Rep(j,n) for(int j=0;j<(int)(n);++j)
#define Repo(j,o,n) for(int j=o;j<(int)(n);++j)
#define Repone(j,n) for(int j=1;j<(int)(n);++j)
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define int long long
#define MOD 1000000007
#define INF 9223372036854775807

signed main(){
  int x=0,y=0,z=0,w=0;
  std::cin >> x>>y;
  if(x>=y)std::cout << 1 << '\n';
  else {
    if(y%x==0)std::cout << y/x << '\n';
    else std::cout << y/x+1 << '\n';
  }
}



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

using namespace std;

// Common DS shorteners
using ll = long long; using ull = unsigned long long;
using pii = pair<int, int>; using pll = pair<ll, ll>;
template <typename T> using vec = vector<T>;
template <typename K, typename V> using mp = unordered_map<K, V>;
template <typename K> using us = unordered_set<K>;
using vi = vec<int>; using vl = vec<ll>; using vpi = vec<pii>; using vpl = vec<pll>;
// Shorthand Macros
#define INF 0x3f3f3f3f
#define LLINF 0x3f3f3f3f3f3f3f3f
#define mpr make_pair
#define pb push_back
// Shorthand Functions
template<typename T> inline void maxa(T& st, T v) { st = max(st, v); }
template<typename T> inline void mina(T& st, T v) { st = min(st, v); }
// Out operators and printing for arrays and vectors
template <typename T> ostream& operator<<(ostream& out,vector<T> iter){out<<"[";for(auto t:iter){out<<t<<", ";}out<<"]";return out;}
template <typename T> void printDebug(T *arr,int sz){cout<<"[";for(int i=0;i<sz;i++){cout<<arr[i]<<", "; } cout<<"]\n";}
template <typename T> void printArray(T *arr,int sz){for(int i=0;i<sz;i++){cout<<arr[i]<<" "; } cout<<"\n";}
#define OUT_OPERATOR(type, propa, propb) ostream& operator<<(ostream& out,type obj){out<<"("<<#propa<<"="<<obj. propa<<", "<<#propb<<"="<<obj. propb<<")";return out;}
// I/O Operations
inline void scan(){}
template<typename F, typename... R> inline void scan(F &f,R&... r){cin>>f;scan(r...);}
inline void println(){cout<<"\n";}
template<typename F, typename... R> inline void println(F f,R... r){cout<<f<<" ";println(r...);}
inline void print(){}
template<typename F, typename... R> inline void print(F f,R... r){cout<<f;print(r...);}
// Debugging
int di_; string dnms_, co_ = ",";
void debug_(){cout<<endl;}
template<typename F, typename... R>
void debug_(F f,R... r){int bc=0;while (bc != 0 || dnms_[di_] != ','){if (dnms_[di_] == '(') {bc++;}else if (dnms_[di_] == ')') {bc--;}cout << dnms_[di_++];}di_++;cout << ": " << f << ",";debug_(r...);}
#define debug(...) do{dnms_=#__VA_ARGS__+co_,di_=0,debug_(__VA_ARGS__);}while(0)

int a;
string s;

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    scan(a, s);

    if (a >= 3200)
        println(s);
    else
        println("red");

    return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
#include <stack>
#include <queue>
#include <deque>
#include <vector>
#include <string>
#include <string.h>
#include <cstdlib>
#include <ctime>
#include <cmath>
#include <map>
#include <set>
#include <iostream>
#include <sstream>
#include <numeric>
#include <cctype>
#include <bitset>
#include <cassert>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define gep(i,g,j) for(int i = g.head[j]; i != -1; i = g.e[i].next)
#define each(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();it++)
#define rng(a) a.begin(),a.end()
#define maxs(x,y) x = max(x,y)
#define mins(x,y) x = min(x,y)
#define pb push_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcount
#define uni(x) x.erase(unique(rng(x)),x.end())
#define snuke srand((unsigned)clock()+(unsigned)time(NULL));
#define df(x) int x = in()
#define dame { puts("-1"); return 0;}
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,vector<T>,greater<T> >
#define bn(x) ((1<<x)-1)
#define newline puts("")
#define v(T) vector<T>
#define vv(T) vector<vector<T>>
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
inline int in() { int x; scanf("%d",&x); return x;}
inline void priv(vi a) { rep(i,sz(a)) printf("%d%c",a[i],i==sz(a)-1?'\n':' ');}
template<typename T>istream& operator>>(istream&i,vector<T>&v)
{rep(j,sz(v))i>>v[j];return i;}
template<typename T>string join(const vector<T>&v)
{stringstream s;rep(i,sz(v))s<<' '<<v[i];return s.str().substr(1);}
template<typename T>ostream& operator<<(ostream&o,const vector<T>&v)
{if(sz(v))o<<join(v);return o;}
template<typename T1,typename T2>istream& operator>>(istream&i,pair<T1,T2>&v)
{return i>>v.fi>>v.se;}
template<typename T1,typename T2>ostream& operator<<(ostream&o,const pair<T1,T2>&v)
{return o<<v.fi<<","<<v.se;}
const int MX = 100005, INF = 1001001001;
const ll LINF = 1e18;
const double eps = 1e-10;

int f(vp& p) {
  int n = sz(p);
  multiset<int> s;
  rep(i,n) {
    s.insert(p[i].fi);
  }
  int res = *(s.rbegin())-*(s.begin());
  rep(i,n) {
    s.erase(s.find(p[i].fi));
    s.insert(p[i].se);
    mins(res,*(s.rbegin())-*(s.begin()));
  }
  return res;
}

int main() {
  int n;
  scanf("%d",&n);
  vp p(n);
  cin>>p;
  rep(i,n) if (p[i].fi > p[i].se) swap(p[i].fi,p[i].se);
  sort(rng(p));
  P rx(0,0);
  rep(i,n) maxs(rx,P(p[i].se,i));
  int ri = rx.se;
  ll ans = LINF;
  {
    int r = 0, l = INF;
    rep(i,n) maxs(r,p[i].fi);
    rep(i,n) mins(l,p[i].se);
    ll now = ll(r-p[0].fi)*(p[ri].se-l);
    mins(ans,now);
  }
  if (ri != 0) {
    ll s = p[ri].se-p[0].fi;
    p[0].fi = p[0].se;
    p[ri].se = p[ri].fi;
    sort(rng(p));
    mins(ans,s*f(p));
  }
  cout<<ans<<endl;
  return 0;
}






















Measured memory_bytes: 11136
d,i;main(m){for(;~scanf("%d%d",&m,&d);m&&printf("%sday\n","Thurs\0Fri\0  Satur\0Sun\0  Mon\0  Tues\0 Wednes"+(d+(m+1+i*12)*26/10-i*2)%7*6))i=m<3;}

Measured memory_bytes: 0
#include<cstdio>
#include<cstring>
#include<iostream>
#include<string>
#include<algorithm>
#include<map>
#include<vector>
using namespace std;
typedef pair<int,string> P;
int n;
int D[31];
P C[21];
vector<int> d_dat[21];
int main(){
  while(1){
    cin >> n;
    if(!n) break;
    memset(D,0,sizeof(D));
    for(int i=0;i<n;i++){
      d_dat[i].clear();
      string s;
      int m;
      cin >> s >> m;
      for(int j=0;j<m;j++){
	int d;
	cin >> d;
	d_dat[i].push_back(d);
	D[d]++;
      }
      C[i]=P(0,s);
    }
    for(int i=0;i<n;i++){
      for(int j=0;j<(int)d_dat[i].size();j++){
	int p = n-D[d_dat[i][j]]+1;
	C[i].first += p;
      }
      //      cout << C[i].first << " " << C[i].second << "\n";
    }
    sort(C,C+n);
    cout << C[0].first << " " << C[0].second << "\n";
  }
}

Measured memory_bytes: 1244
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define all(v) v.begin(), v.end()
using in = int64_t;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl
#define yes cout<<"yes"<<endl
#define no cout<<"no"<<endl
const double PI=3.14159265358979323846;
const in MOD = 1000000007;
const in INF=1e18+7;
const int inf=1e9+7;
using P=pair<int,int>;
vector<int> dx={0,1,-1,0};
vector<int> dy={1,0,0,-1};


int main(){
ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
cout << fixed << setprecision(10);
    in a;
    string b;
    cin>>a>>b;
    in x,y,z;
    x=b[0]-'0';
    y=b[2]-'0';
    z=b[3]-'0';
    in ans=(100ll*a*x+10*a*y+a*z)/100ll;
    cout<<ans<<endl;
}/*
./problem.exe
*/

Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,s,n) for(ll i = (s); i < (n); i++)

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(18);
  
  ll n;
  cin >> n;
  ll odd = 0;
  rep(i, 0, n) {
    ll a;
    cin >> a;
    if(a %2 == 1) odd++;
  }
  cout << ( odd %2 == 0 ?"YES" :"NO") << "\n";
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N;
  cin >> N;
  string S, T, ans;
  cin >> S >> T;
  for(int i=0; i<2*N; i++){
    int k=i;
    if(k%2==0){
      k/=2;
      ans[i]=S[k];
 //     cout<<"S[k]:"<<S[k]<<" ans[i]:"<<ans[i]<<endl;
    }
    else{
      k/=2;
      ans[i]=T[k];
    }
  }
  for(int i=0; i<2*N; i++){
    cout << ans[i]; 
  }
  cout << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<cmath>
#include<cstdlib>
#include<string>
#include<cstring>
#include<algorithm>
#include<vector>
#include<map>
#include<iomanip>
#include<queue>

using namespace std;

typedef long long ll;

typedef std::pair<int, int> ipair;
bool lessPair(const ipair& l, const ipair& r){return l.second < r.second;}
bool morePair(const ipair& l, const ipair& r){return l.second > r.second;}

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

const ll MOD = 1e9 + 7;
// const long long INF = 1LL<<60;
void add(long long &a, long long b) { a += b; if (a >= MOD) a -= MOD; }
void sub(long long &a, long long b) { a -= b; if (a < 0) a += MOD; }
void mul(long long &a, long long b) { a *= b; a %= MOD; }
ll llmin(ll a, ll b) { if (a < b) return a; else return b; }
ll llmax(ll a, ll b) { if (a < b) return b; else return a; }
ll llabs(ll a) { if (a >= 0) return a; else return - a; }
ll llmodpow(ll a, ll n) {
   if (n == 0) return 1;
   ll tmp = llmodpow(a, n / 2);
   mul(tmp, tmp);
   if (n & 1) mul(tmp, a);
   return tmp;
}

int main() {
   int N;
   cin >> N;
   int a[N];
   bool flg = true;
   for (int i = 0; i < N; i++) {
      cin >> a[i];
      if (a[i] % 2 != 0) {
         flg = false;
         break;
      }
   }
   if (flg) cout << "second" << endl;
   else cout << "first" << endl;
   return 0;
}


Measured memory_bytes: 640
#include<iostream>
#include<vector>
#include<algorithm>

using namespace std;

int main () {
    int N, L;
    cin >> N >> L;

    vector<string> S(N);
    for (int i = 0; i < N; i++) {
        cin >> S.at(i);
    }

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

    string result = "";
    for (int i = 0; i < N; i++) {
        result += S.at(i);
    }

    cout << result << endl;
}

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

using namespace std;

using ll = long long;

const double eps = 1e-10;
const int MOD = 1000000007;
const int INF = 1000000000;
const ll LINF = 1ll<<50;

template<typename T>
void printv(const vector<T>& s) {
  for(int i=0;i<(int)(s.size());++i) {
    cout << s[i];
    if(i == (int)(s.size())-1) cout << endl;
    else cout << " ";
  }
}

int main () {
  cin.tie(0);
  cout << fixed << setprecision(10);

  ll r, d, x; cin >> r >> d >> x;
  for(int i=0;i<10;++i) {
    x = r * x - d;
    cout << x << endl;
  }
}


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

#define ALL(a)  (a).begin(),(a).end()
#define ALLR(a)  (a).rbegin(),(a).rend()
#define spa << " " <<
#define MP make_pair
#define test cout<<"test"<<endl;
#define fi first
#define se second
typedef long long ll;
typedef long double ld;
const ll MOD = 1e9+7;
//const ll MOD = 998244353;
const ll INF = 1e18;
const ll zero=0;
using P = pair<ll, ll>;
void chmin(ll &a,ll b){if(a>b)a=b;}
void chmax(ll &a,ll b){if(a<b)a=b;}
void pmod(ll &a,ll b){a=(a+b)%MOD;}
void pmod(ll &a,ll b,ll c){a=(b+c)%MOD;}
void qmod(ll &a,ll b){a=(a*b)%MOD;}
void qmod(ll &a,ll b,ll c){a=(b*c)%MOD;}
void ans1(bool x){if(x) cout<<"Yes"<<endl;else cout<<"No"<<endl;}
void ans2(bool x){if(x) cout<<"YES"<<endl;else cout<<"NO"<<endl;}
void ans3(bool x){if(x) cout<<"Yay!"<<endl;else cout<<":("<<endl;}
void ans(bool x,ll y,ll z){if(x)cout<<y<<endl;else cout<<z<<endl;}
void ans(bool x,string y,string z){if(x)cout<<y<<endl;else cout<<z<<endl;}   
ll gcd(ll x,ll y){ll r;while((r=x%y)!=0){x=y;y=r;}return y;}

int main(){
  ll i,j,o;
  ll res=0,res1=INF,res2=-INF,buf=0;
  bool judge = true;
  ll n;cin>>n;
  vector<ll>a(n),b(n);
  for(i=0;i<n;i++)cin>>a[i]>>b[i];
  reverse(ALL(a));
  reverse(ALL(b));
  for(i=0;i<n;i++){
    if((a[i]+res)%b[i]!=0)
      res+=b[i]-((a[i]+res)%b[i]);
      //cout<<res<<endl;
  }
  cout<<res<<endl;


  return 0;
}

Measured memory_bytes: 1792
#include <algorithm>
#include <bitset>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <cctype>
#include <assert.h>
#include <stdlib.h>
#include <stdio.h>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <limits>
#include <map>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
#include <math.h>
using namespace std;
using ll = long long;
using vl = vector<long long>;
using vll = vector<vector<long long>>;
using vs = vector<string>;
using vc = vector<char>;
using vcc = vector<vector<char>>;
using vm = vector<short>;
using vmm = vector<vector<short>>;
using pii = pair<int, int>;
using psi = pair<string, int>;
int main() {
	ll a, b, c;
	cin >> a >> b >> c;
	ll x, y;
	cin >> x >> y;
	ll counta = 0;
	ll countb = 0;
	ll countc = 0;
	bool fang = 0;
	if (c * 2 <= a + b) {
		countc += min(x, y)*2;
		if (x != y) {
			if (max(x, y) == x) {
				fang = true;
			}
			else {
				fang = false;
			}
			if (fang) {
				if (a <= c*2) {
					counta += x - y;
				}
				else {
					countc += (x - y)*2;
				}
			}
			else {
				if (b <= c*2) {
					countb += y - x;
				}
				else {
					countc += (y - x)*2;
				}
			}
		}
	}
	else {
		counta += x;
		countb += y;
	}
	cout << counta * a + countb * b + countc * c << endl;
}

Measured memory_bytes: 3604
import sys
import math
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
sys.setrecursionlimit(10 ** 8)
INF = float('inf')
MOD = 10 ** 9 + 7


def main():
    A, B, C, D =map(int, readline().split())
    if math.ceil(C/B)<=math.ceil(A/D):
        print('Yes')
    else:
        print('No')


if __name__ == '__main__':
    main()

Measured memory_bytes: 9132
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define FOR(I,A,B) for(ll I = (A); I < (B); ++I)
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin()) //ai>=v  x is sorted
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin()) //ai>v  x is sorted
#define NUM(x,v) (POSU(x,v)-POSL(x,v))  //x is sorted
#define SORT(x) (sort(x.begin(),x.end())) // 0 2 2 3 4 5 8 9
#define REV(x) (reverse(x.begin(),x.end())) //reverse
#define TO(x,t,f) ((x)?(t):(f))
#define CLR(mat) memset(mat, 0, sizeof(mat))
#define FILV(x,a) fill(x.begin(),x.end(),a)
#define FILA(ar,N,a) fill(ar,ar+N,a)
#define NEXTP(x) next_permutation(x.begin(),x.end())
ll gcd(ll a,ll b){if(a<b)swap(a,b);if(a%b==0)return b;else return gcd(b,a%b);}
ll lcm(ll a,ll b){ll c=gcd(a,b);return ((a/c)*(b/c)*c);}//saisyo kobaisu
#define pb push_back
#define pri(aa) cout<<(aa)<<endl
const ll INF=1e9+7;
const ll N = 102;

ll n,m=INF,x;
vector <ll> v;

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	cin>>n>>x;
	FOR(i,0,n){
		ll w;cin>>w;
		m=min(m,w);
		x-=w;
	}
	pri(n+x/m);
	return 0;
}

Measured memory_bytes: 256
import sys

sys.setrecursionlimit(10 ** 6)
INF = float("inf")
MOD = 10 ** 9 + 7


def input():
    return sys.stdin.readline().strip()


class UnionFind:
    def __init__(self, n_nodes):
        self.n_nodes = n_nodes
        self.parents = [-1] * n_nodes

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def unite(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def get_size(self, x):
        return -self.parents[self.find(x)]

    def check(self, x, y):
        return self.find(x) == self.find(y)

    def get_parent_list(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def get_members(self, x):
        parent = self.find(x)
        return [i for i in range(self.n_nodes) if self.find(i) == parent]

    def get_members_dict(self):
        return {par: self.get_members(par) for par in self.get_parent_list()}


def main():
    N, K, L = map(int, input().split())
    tree_road = UnionFind(N)
    tree_subway = UnionFind(N)

    for _ in range(K):
        p, q = map(int, input().split())
        p -= 1
        q -= 1
        tree_road.unite(p, q)

    for _ in range(L):
        r, s = map(int, input().split())
        r -= 1
        s -= 1
        tree_subway.unite(r, s)

    d = {}
    for i in range(N):
        p1 = tree_road.find(i)
        p2 = tree_subway.find(i)
        if (p1, p2) not in d:
            d[(p1, p2)] = 1
        else:
            d[(p1, p2)] += 1

    for i in range(N):
        p1 = tree_road.find(i)
        p2 = tree_subway.find(i)
        print(d[(p1, p2)], end=" ")


if __name__ == "__main__":
    main()


Measured memory_bytes: 41192
import sys

sys.setrecursionlimit(10**7)
def I(): return int(sys.stdin.readline().rstrip())
def MI(): return map(int,sys.stdin.readline().rstrip().split())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))  #空白あり
def LI2(): return list(map(int,sys.stdin.readline().rstrip()))  #空白なし
def S(): return sys.stdin.readline().rstrip()
def LS(): return list(sys.stdin.readline().rstrip().split())  #空白あり
def LS2(): return list(sys.stdin.readline().rstrip())  #空白なし

N = I()
a = LI()

if N % 3 != 0:
    for i in range(N):
        if a[i] != 0:
            print('No')
            break
    else:
        print('Yes')
    exit()

B = list(set(a))
b = len(B)
n = N//3
if b > 3:
    print('No')
elif b == 1:
    for i in range(N):
        if a[i] != 0:
            print('No')
            break
    else:
        print('Yes')
elif b == 2:
    x,y = B
    c = a.count(x)
    d = a.count(y)
    if x != 0 and y != 0:
        print('No')
    elif x == 0:
        if c == n:
            print('Yes')
        else:
            print('No')
    else:
        if d == n:
            print('Yes')
        else:
            print('No')
else:
    x,y,z = B
    c = a.count(x)
    d = a.count(y)
    if not (c == d == n):
        print('No')
    else:
        if x ^ y == z:
            print('Yes')
        else:
            print('No')


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

using namespace std;

const int mod = 1e9 + 7;

int add() { return 0; }
template<typename... M> int add(int a, M... b) {
  int x = add(b...);
  return a + x - mod * (a + x >= mod);
}

int mul() { return 1; }
template<typename... M> int mul(int a, M... b) {
  return int(1ll * a * mul(b...) % mod);
}

int pwr(int a, long long x) {
  return (x ? mul(pwr(mul(a, a), x >> 1), (x & 1 ? a : 1)) : 1);
}

int dvd(int a, int b) {
  return mul(a, pwr(b, mod - 2));
}

int sub(int a, int b) {
  return a - b + mod * (a < b);
}

void inc(int& a, int b) {
  a = add(a, b);
}

void dec(int& a, int b) {
  a = sub(a, b);
}

vector<int> fact = {1}, invf = {1};
int C(int n, int k) {
  if (n < k or 0 > k) return 0;
  while (fact.size() <= n) {
    fact.push_back(mul(fact.back(), fact.size()));
    invf.push_back(dvd(1, fact.back()));
  }
  return mul(fact[n], invf[k], invf[n - k]);
}

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

  int n;
  cin >> n;
  int cur = 0, ans = 0;
  for (int i = 0, x; i < n; ++i) {
    cin >> x;
    inc(ans, mul(x, cur));
    inc(cur, x);
  }
  cout << ans;

  return 0;
}


Measured memory_bytes: 3656
#include<iostream>
using namespace std;
int main() {
	string a, b;
	cin >> a >> b;
	if (a=="H"){
		cout << b << endl;
	}
	if (a=="D"&&b=="H"){
		cout << "D" << endl;
	}
	if (a=="D"&&b=="D"){
		cout << "H" << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <map>
#include <iostream>
#include <algorithm>
using namespace std;
int X, Y, Z, p, q, r, v[5], a[69], b[69], vis[69][5509][2]; long double dp[69][5509][2];
long double solve(int pos, int cost, int e) {
	if (pos >= Y) return (long double)(cost);
	if (vis[pos][cost][e]) return dp[pos][cost][e];
	int pcost = cost;
	if (e == 0) {
		if (a[pos] == 1) return solve(pos + b[pos], cost, 1);
		cost = max(cost + (a[pos] == 2 ? b[pos] : 0), 0);
	}
	long double sum = 0.0;
	for (int i = 0; i < X; i++) sum += solve(pos + v[i], cost, 0);
	vis[pos][pcost][e] = true;
	return dp[pos][pcost][e] = sum / X;
}
int main() {
	while (cin >> X >> Y >> Z, X) {
		fill(a, a + 61, -1);
		fill(b, b + 61, -1);
		for (int i = 0; i < X; i++) cin >> v[i];
		for (int i = 0; i < Z; i++) {
			cin >> p >> q >> r;
			if (q == 3) q = 2, r = -r;
			a[p] = q; b[p] = r;
		}
		for (int i = 0; i <= 60; i++) {
			for (int j = 0; j <= 5500; j++) {
				for (int k = 0; k < 2; k++) {
					vis[i][j][k] = false;
					dp[i][j][k] = 0.0;
				}
			}
		}
		long double ret = solve(0, 0, 0);
		cout << (int)(ret + 1.0e-10L) << endl;
	}
	return 0;
}

Measured memory_bytes: 16240
//#define _GRIBCXX_DEBUG
#include <algorithm>
#include <cctype>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iostream>
#include <iomanip>
#include <list>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
using namespace std;


// 基本テンプレート
#pragma region MACRO
#define P(x) cout << (x) << endl
#define p(x) cout << (x)
#define PED cout << "\n"
#define rep(i,n) for(int i=0; i<(int)n; ++i)
#define REP(i,x,n) for(int i=x; i<(int)n; ++i)
#define repi(i,n) for(int i=0; i<=(int)n; ++i)
#define REPI(i,x,n) for(int i=x; i<=(int)n; ++i)
#define ILP while(true)
#define FOR(i,c) for(__typeof((c).begin())!=(c).begin(); i!=(c).end(); ++i)
#define ALL(c) (c).begin(), (c).end()
#define mp make_pair
#pragma endregion

// 型
#pragma region TYPE_DEF
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<string, string> pss;
typedef pair<string, int> psi;
typedef pair<int, string> pis;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<long> vl;
typedef vector<long long> vll;
typedef vector<string> vs;
#pragma endregion

// Effective std
#pragma region ESTD
template<typename C, typename T>
int count(C& c, T t) { return count(ALL(c), t); }
template<typename C, typename F>
int count_if(C& c, F f) { return count_if(ALL(c), f); }
template<typename C, typename T>
void erase(C& c, T t) { remove(ALL(c), t), c.end(); }
template<typename C>
void remove(vector<C>& c, unsigned int index) { c.erase(c.begin()+index); }
template<typename C, typename T, typename U>
void replace(C& c, T t, U u) { replace(ALL(c), t, u); }
template<typename C, typename F, typename U>
void replace_if(C& c, F f, U u) { (ALL(c), f, u); }
template<typename C>
void reverse(C& c) { reverse(ALL(c)); }
template<typename C>
void sort(C& c) { sort(ALL(c)); }
template<typename C, typename Pred>
void sort(C& c, Pred p) { sort(ALL(c), p); }
#pragma endregion

// 定数
#pragma region CONST_VAL
#define PI (2*acos(0.0))
#define EPS (1e-9)
#define MOD (int)(1e9+7)
#pragma endregion

ll dp[2501][52];

int main() {
    int n, a;
    cin >> n >> a;
    rep(I, n) {
        int x;
        cin >> x;
        for(int j=2500; j>=0; --j) {
            for(int k=51; k>0; --k) {
                if(dp[j][k-1]) {
                    dp[j+x][k] += dp[j][k-1];
                }
            }
        }
        dp[x][1]++;
    }
    ll ans = 0;
    for(int i=1; i<=n; ++i) ans += dp[i*a][i];
    P(ans);
}


Measured memory_bytes: 768
#include <iostream>
#include <vector>
#include <array>
#include <set>
#include <cmath>
#include <string>
#include <queue>
#include <list>
#include <unordered_map>
#include <algorithm>
#include <functional>
#include <iomanip> // std::std::setprecision(X)
#include <limits>  //std::numeric_limits<int>::max(), min()

typedef long long ll;

int main (void) {

  int N; std::cin >> N;
  std::vector<ll> A(N); for(int i=0; i<N; i++) std::cin >> A[i];

  ll Asum = 0, Aodd = 0, Aeven = 0;
  for(int i=0; i<N; i++) {
    Asum += A[i];
    if ( i % 2 == 0 ) Aeven += A[i];
    else Aodd += A[i];
  }
  Asum /= 2;

  std::vector<ll> hans(N);
  hans[0] = Aeven - Asum;
  for(int i=0; i<N-1; i++) hans[i+1] = A[i] - hans[i];

  for(int i=0; i<N; i++) std::cout << hans[i]*2 << " ";
  std::cout << std::endl;

  return 0; 
}


Measured memory_bytes: 2944
n = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))

res = 0
for ai in range(len(A)):
    if ai == 0:
        res += B[A[ai] -1]
    else:
        res += B[A[ai] -1]
        if A[ai-1] +1 == A[ai]:
            res += C[A[ai-1]-1]
print(res)

Measured memory_bytes: 3064
#include <iostream>
#include <vector>
#include<list>
#include <algorithm>
#include <string>
#include <math.h>
#include<map>
#include <utility>
#include <cstring>
#include <iomanip>
#include<queue>
using namespace std;
#define REP(i,k,n) for(int i=k;i<n;i++)
 
#define INF 1000000000
typedef long long  ll;
#define SIZE_OF_ARRAY(array) (sizeof(array)/sizeof(array[0]))
#define MOD 1000000007

template<typename T>
int vector_finder(std::vector<T> vec, T number) {
  auto itr = std::find(vec.begin(), vec.end(), number);
  size_t index = std::distance( vec.begin(), itr );
  if (index != vec.size()) { // 発見できたとき
    return 1;
  }
  else { // 発見できなかったとき
    return 0;
  }
}

template<typename T>
T gcd(T a,T b){
	if(b>0){
		return gcd(b, a % b);
	}else{
		return a;
	}
}

template<typename T>
T lcm(T a,T b){
	T g = gcd(a, b);
	return a /g* b ;
}

void clear( std::queue<pair<int,int> > &q )
{
   std::queue<pair<int,int> > empty;
   std::swap( q, empty );
}
bool IsPrime(int num)
{
    if (num < 2) return false;
    else if (num == 2) return true;
    else if (num % 2 == 0) return false; // 偶数はあらかじめ除く

    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2)
    {
        if (num % i == 0)
        {
            // 素数ではない
            return false;
        }
    }

    // 素数である
    return true;
}
template<typename T>
int  GetDigit(T num){
    int digit=0;
    while(num!=0){
        num /= 10;
        digit++;
    }
    return digit;
}

template<typename T>
std::vector<T> enum_div(T n)//nの約数を列挙
{
	std::vector<T> ret;
	for(T i=1 ; i*i<=n ; ++i)
	{
		if(n%i == 0)
		{
			ret.push_back(i);
			if(i!=1 && i*i!=n)
			{
				ret.push_back(n/i);
			}
		}
	}
	return ret;
}


class DisjointSet{
    public:
        vector<int> rank, p;

        DisjointSet(){
        }

        DisjointSet(int size){
            rank.resize(size, 0);
            p.resize(size, 0);
            for (int i = 0; i < size;i++){
                makeSet(i);
            }
        }
        void makeSet(int x){
            p[x] = x;
            rank[x] = 0;
        }

        bool same(int x,int y){
            return findSet(x) == findSet(y);
        }
        void unite(int x,int y){
            link(findSet(x), findSet(y));
        }
        void link(int x,int y){
            if(rank[x]>rank[y]){
                p[y] = x;
            }else{
                p[x] = y;
                if(rank[x]==rank[y]){
                    rank[y]++;
                }
            }
        }
        int findSet(int x){
            if(x!=p[x]){
                p[x] = findSet(p[x]);
            }
            return p[x];
        }
};


int main()
{
    string s;
    cin >> s;
    int N = s.size();

    if(N==0){
        cout << 1 << endl;
        return 0;
    }
    int prev = s[0];
    int ans = 0;
    REP(i, 1, N)
    {
        if(s[i]!=prev){
            ans++;
        }
        prev = s[i];
    }
    cout << ans << endl;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> V;
#define rep(cnt,e) for(ll cnt=0;cnt<e;cnt++ )
typedef pair<ll,ll> P;
const ll mod = 1e9+7;
const ll INF = INT64_MAX;
typedef tuple<ll,ll,ll,ll> T;

ll i,j,k;


int main(){
   ll N;
   cin>>N;
   V a(N);
   rep(i,N)cin>>a[i];
   vector<bool> jud(N,true);
   ll ans=0;
   ll current=0;
   jud[0]=false;
   while(true){
      ans++;
      if(jud[a[current]-1]){
          if(a[current]-1==1){
              cout<<ans<<endl;
              break;
          }
          else{
              jud[a[current]-1]=false;
              current=a[current]-1;
              
          }

      }
      else{
          cout<<-1<<endl;
          break;
      }
   }
}


Measured memory_bytes: 1024
#include <iostream>
#include <string>

using namespace std;

int main()
{
	std::string a,b,c;

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

	if (a[a.size()-1] == b[0])
		if (b[b.size()-1] == c[0]) {
			cout << "YES" << endl;
			return 0;
		}
	cout << "NO" << endl;
	return 0;
}


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

int main() {
  ll n,q;
  cin >> n;
  vector<ll> a(n);
  map<ll,ll> mp;
ll sum=0;
  rep(i,n){
    cin>>a[i];
    mp[a[i]]++;
    sum+=a[i];
  }
  cin>>q;
  rep(i,q){
    ll b1,c1;
    cin>>b1>>c1;
    ll now=mp[b1];
    mp[b1]-=now;
    mp[c1]+=now;
    sum-=now*b1;
    sum+=now*c1;
    cout<<sum<<endl;
  }

}


Measured memory_bytes: 9940