akhauriyash/Code-Regression huggingface dataset:
n,m,x=map(int,input().split())
A=[list(map(int,input().split())) for _ in range(n)]
a=float('inf')
for i in range(2**n):
  S=[0]*(m+1)
  for j in range(n):
    if (i>>j)&1:
      S=[S[k]+A[j][k] for k in range(m+1)]
  if all([s >= x for s in S[1:]]):
    a=min(a,S[0])
print(-1 if a==float('inf') else a)

Measured memory_bytes: 9172
mod = 998244353

N, S, *A = map(int, open(0).read().split())

dp = [1] + [0] * S
for i, a in enumerate(A, 1):
    dp = [(2 * dp[j] + (dp[j - a] if j >= a else 0)) % mod for j in range(S + 1)]

print(dp[S])

Measured memory_bytes: 9452
#include "bits/stdc++.h"
using namespace std;
#define REP(i,a) for(int i = 0; i < (a);i++)
#define ALL(a) (a).begin(),(a).end()
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1e9;
const int MOD = 1e9 + 7;
using Graph = vector < vector<int>>;
/*第二引数で第一引数を割ったときの切り上げの計算*/
long long int maxtime(long long int x, long long int y) {
	return(x + y - 1) / y;

}
/*最大公約数*/
long long int lcm(long long int number1, long long int number2) {
	long long int m = number1;
	long long int n = number2;

	if (number2 > number1) {
		m = number2;
		n = number1;
	}
	long long int s = -1;
	while (s != 0) {
		s = m % n;
		m = n;
		n = s;
	}
	return m;
}
/*最大公倍数*/
long long int gcd(long long int number1, long long int number2) {
	long long int m = number1;
	long long int n = number2;
	return m / lcm(m, n) * n;
}
int k[100030];
int s[100030];
int main() {
	int A, B, C;
	cin >> A >> B >> C;
	cout << A * B * 0.5;
}


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++)
#define MOD 1000000007LL

ll pow2(ll r) {
    ll ans = 1, a = 2;
    while(r > 0) {
        if(r & 1) ans = ans * a % MOD;
        a = a * a % MOD;
        r >>= 1;
    }
    return ans;
}

int main() {
    map<pair<ll,ll>,pair<ll,ll>> mp;
    int N;
    cin >> N;
    ll cnt = 0;
    rep(i, N) {
        ll A, B;
        cin >> A >> B;
        if(!A && !B) {
            cnt++;
        } else {
            ll g = __gcd(A,B);
            A /= g; B /= g;
            if(B < 0) { A = -A; B = -B; }
            if(A <= 0) mp[{B,-A}].second++;
            else mp[{A,B}].first++;
        }
    }

    ll ans = 1;
    for(auto p : mp) {
        ans = ans * ((pow2(p.second.first) + pow2(p.second.second) - 1 + MOD) % MOD) % MOD;
    }    
    cout << (ans + cnt - 1 + MOD) % MOD << endl;
    return 0;
}

Measured memory_bytes: 19144
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc=new Scanner(System.in);
        int i;
        int a[]=new int[6];
        for(i=0;i<6;i++)a[i]=sc.nextInt();
        Dice d=new Dice(a);
        String str=sc.next();
        for(i=0;i<str.length();i++)d.rollDice(str.charAt(i));
        System.out.println(d.getUp());
    }
}

class Dice{
    private int up;
    private int front;
    private int right;
    private int left;
    private int rear;
    private int down;
    Dice(int a[]){
        this.up=a[0];
        this.front=a[1];
        this.right=a[2];
        this.left=a[3];
        this.rear=a[4];
        this.down=a[5];
    }
    void rollDice(char d){
        int tmp=this.up;
        switch(d){
            case 'N':
                this.up=this.front;
                this.front=this.down;
                this.down=this.rear;
                this.rear=tmp;
                break;
            case 'E':
                this.up=this.left;
                this.left=this.down;
                this.down=this.right;
                this.right=tmp;
                break;
            case 'S':
                this.up=this.rear;
                this.rear=this.down;
                this.down=this.front;
                this.front=tmp;
                break;
            case 'W':
                this.up=this.right;
                this.right=this.down;
                this.down=this.left;
                this.left=tmp;
                break;
        }
    }
    int getUp(){
        return this.up;
    }
}


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

#define rep(i,a,b)      for(int i=a;i<=b;i++)
#define revp(i,a,b)     for(int i=b;i>=a;i--)

char d;
int main()
{
  

    cin>>d;
    if(d=='a' || d=='o'||d=='i'||d=='e'||d=='u')
        cout<<"vowel";
    else
        cout<<"consonant";
}




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

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

       int t=1;
       //cin>>t;
       while(t--)
       {
               string s;
               cin>>s;
               if(s[1]=='B')
                    cout<<"ARC";
               else
                    cout<<"ABC";
       }
}


Measured memory_bytes: 3612
#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;
#define fastio() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define loop(i,a,b) for(int i=a;i<b;i++)
#define test() int t;cin>>t;loop(test,1,t+1)
#define pb push_back
#define eb emplace_back
#define mkp make_pair
#define nl cout<<"\n"
#define sp cout<<" "
#define F first
#define S second
#define vi vector<int>
#define vl vector<ll>
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vii vector<pii>
#define vll vector<pll>
#define prsp(v) loop(i,0,v.size())cout<<v[i],sp;nl;
#define prpsp(v) loop(i,0,v.size())cout<<v[i].F<<" "<<v[i].S<<" , ";nl;
#define prnl(v) loop(i,0,v.size())cout<<v[i],nl;nl;
#define prpnl(v) loop(i,0,v.size())cout<<v[i].F<<" "<<v[i].S,nl;nl;
#define MOD 1000000007
#define mod(n) (((n%MOD)+MOD)%MOD)
#define all(x) x.begin(),x.end()

const int N = 1e5+5;
int dx[] = {1,0,-1,0};
int dy[] = {0,1,0,-1};

int main() 
{
    fastio();

    ll n,k;
    cin>>n>>k;
    cout<<(n-k+1),nl;

    cerr << "\nTime elapsed: " << 1000 * clock() / CLOCKS_PER_SEC << "ms\n";
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>
// #include <ext/pb_ds/detail/standard_policies.hpp>
// using namespace __gnu_pbds;
using namespace std;
// template <typename T>
// using ordered_set = tree<T, null_type, less<T>, rb_tree_tag,
//     tree_order_statistics_node_update>;
 
typedef long long int ll;
const ll N = 2e5 + 9;
// const ll m = 1e9 + 7;
const ll inf= 1ll<<62;
#define x first
#define y second
#define pb push_back
#define mp make_pair
using pii = pair<ll, ll>;
const ll mod = 1e9;
ll powm(ll a, ll b) { a = a%mod;ll res = 1; while (b) { if (b & 1) res = (res * a) % mod; a = (a * a) % mod; b >>= 1; } return res; }
int main()
{   
                            
     ll T= 1;
     // cin>>T;
     ll ca = 1;
     while(T--){
          ll n;cin>>n;
          ll p[n+1];
          ll ct[n+1];
          memset(ct,0,sizeof(ct));
          for(int i = 2;i<=n;i++){
               cin>>p[i];
               ct[p[i]]++;
          }
          for(int i = 1;i<=n;i++){
               cout<<ct[i]<<'\n';
          }
     }
    return 0;
}

Measured memory_bytes: 6776
def gcd(x,y):
    p=min(x,y)
    q=max(x,y)
    while p != q:
        if q > p:
            q = q - p
        else:
            p = p - q
    return q

n=int(input())
a=sorted(set(list(map(int, input().split()))))
while len(a) > 1:
    p=a[0]
    q=a[1]
    g=gcd(p,q)
    a.append(p*q//g)
    a.pop(0)
    a.pop(0)
    a=sorted(a)
print(*a)

Measured memory_bytes: 7800
#include <stdio.h>
#include <string.h>

#define forN(i, N) for (i = 0; i < N; i++)
#define MAXLEN 1001

int main(int argc, char *argv[]) {
  char str[MAXLEN];
  int num;

  scanf("%s", str);
  scanf("%d", &num);

  for (int i = 0; i < strlen(str); i += num) {
    putchar(str[i]);
  }

  return 0;
}


Measured memory_bytes: 128
class UnionFind(object):
  def __init__(self,n):
    self.parent={i:i for i in range(1,n+1)}
    self.size={i:1 for i in range(1,n+1)}
  def find(self,a):
    if self.parent[a]!=a:
      self.parent[a]=self.find(self.parent[a])
    return self.parent[a]
  def unite(self,a,b):
    a=self.find(a)
    b=self.find(b)
    if a==b:return
    if self.size[a]>self.size[b]:
      self.size[a]+=self.size[b]
      self.parent[b]=a
    else:
      self.size[b]+=self.size[a]
      self.parent[a]=b
  def isunited(self,a,b):
    return self.find(a)==self.find(b)

N=int(input())
l=[[i+1]+list(map(int,input().split())) for i in range(N)]
o=[]

l.sort(key=lambda x:x[1])
for i in range(N-1):
    o.append((l[i][0],l[i+1][0],l[i+1][1]-l[i][1]))

l.sort(key=lambda x:x[2])
for i in range(N-1):
    o.append((l[i][0],l[i+1][0],l[i+1][2]-l[i][2]))

o.sort(key=lambda x:x[2])

ans=0
uft=UnionFind(N)
for town1,town2,cost in o:
    if not uft.isunited(town1,town2):
        uft.unite(town1,town2)
        ans+=cost

print(ans)

Measured memory_bytes: 70764
A,B,C=map(int,input().split())
K=int(input())

if A<B<C:
    print("Yes")
    exit()
else:
    for k in range(1,K+1):
        for i in range(3**k):
            a,b,c=A,B,C
            for _ in range(k):
                if i%3==0:
                    a*=2
                elif i%3==1:
                    b*=2
                else:
                    c*=2
                i//=3
            if a<b<c:
                print("Yes")
                exit()
print("No")

Measured memory_bytes: 9196
import Data.List
import Control.Monad

main :: IO ()
main = do
  [n, t_lim] <- map read . words <$> getLine :: IO [Int]
  xs <- replicateM n $ (\[x,y] -> (x,y)) . map read . words <$> getLine :: IO [(Int, Int)]
  let ys = map fst $ filter ((<= t_lim) . snd) xs
  putStrLn $ if null ys then "TLE" else show $ minimum ys


Measured memory_bytes: 1020
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i,n) for(long long i = 0; i < (n); ++i)
#define ll long long
#define P pair<ll,ll>
#define all(v) (v).begin(),(v).end()

const ll mod = 1e9+7;
const ll INF = 1e18;
const double pi = acos(-1.0);

int main(void)
{
    ll n; cin>>n;
    ll bili=0,mini=INF;
    rep(i,n){
        ll a,b;
        cin>>a>>b;
        bili=max(bili,a);
        mini=min(mini,b);
    }
    cout<<bili+mini<<endl;
    return 0;
}

Measured memory_bytes: 3584
import sys
a,b,c,d = [c for c in raw_input()]
for op1 in ('+','-'):
  for op2 in ('+','-'):
    for op3 in ('+','-'):
       t = a + op1 + b + op2 + c + op3 + d
       if eval(t) == 7:
         print t + '=7'
         sys.exit()


Measured memory_bytes: 2696
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N;
  int t[100010],x[100010],y[100010];
  bool checker = true;
  cin >> N;
  t[0]=x[0]=y[0]=0;
  for (int i = 1; i<=N ;++i)cin>>t[i]>>x[i]>>y[i];
  //cout<<endl;
  for (int i = 1; i<=N ;++i){
    //cout<<"t="<<t[i]<<"のとき,x="<<x[i]<<",y="<<y[i]<<endl;
    if((t[i]<(x[i]+y[i])) || ((t[i]&1)!=((x[i]+y[i])&1))){
        //cout<<"条件外です"<<endl;
        checker = false;
        break;
    }
  }
  if(checker)cout <<"Yes"<<endl;
  else cout<<"No"<<endl;

}


Measured memory_bytes: 1408
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<n+1;i++)
#define sort(A) sort(A.begin(),A.end())
#define reverse(A) reverse(A.begin(),A.end())
typedef long long ll;
typedef pair<int,int> P;

int main(){
  int n,k;
  cin >> n >> k;
  const ll INF = pow(10,9)+7;
  vector<vector<ll>> comb(10500, vector<ll>(10500));
  comb[0][0] = 1;
  rep(i,10250){
    rep(j,i+1){
      comb[i][j] %= INF;
      comb[i+1][j] += comb[i][j];
      comb[i+1][j+1] += comb[i][j];
    }
  }
  rep1(i,k){
    ll comb1 = comb[n-k+1][i];
    ll comb2 = comb[k-1][i-1];
    cout << comb1*comb2%INF << endl;
  }
}

Measured memory_bytes: 862208
#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define RFOR(i,a,b) for(int i=(b) - 1;i>=(a);i--)
#define REP(i,n) for(int i=0;i<(n);i++)
#define RREP(i,n) for(int i=n-1;i>=0;i--)

#define PB push_back
#define INF INT_MAX/3
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define CLR(a) memset(a,0,sizeof(a))

typedef long long int ll;

using namespace std;

void ins(vector< pair<int,pair<int,char> > > &a){
    int s = a.size() - 1;
    if(s == 0) return ;
    while(a[s].first > a[s-1].first){
	swap(a[s],a[s-1]);
	s--;
	if(s==0) break;
    }
    if(s ==0) return;
    while(a[s].first == a[s-1].first && a[s].second.first < a[s-1].second.first){
	swap(a[s],a[s-1]);
	s--;
	if(s==0) break;
    }
    return ;
}

int main(){
    while(true){
	int n;
	cin >> n;
	vector< pair<int,pair<int,char> > > ans;
	if(n == 0) break;
	REP(i,n){
	    char t;
	    int temp;
	    int w,l;
	    w =0 ;
	    l = 0;
	    cin >> t;
	    REP(i,n-1) {
		cin >> temp;
		if(temp == 0) w++;
		else if( temp == 1) l++;
	    }
	    ans.PB( pair<int,pair<int,char> >( w , pair<int,char>(l,t) ));
	    ins(ans);
	}
	REP(i,n) cout << ans[i].second.second << endl;
    }
    return 0;
}

Measured memory_bytes: 1192
import sys
import math
from collections import deque

sys.setrecursionlimit(1000000)
MOD = 10 ** 9 + 7
input = lambda: sys.stdin.readline().strip()
NI = lambda: int(input())
NMI = lambda: map(int, input().split())
NLI = lambda: list(NMI())
SI = lambda: input()


def make_grid(h, w, num): return [[int(num)] * w for _ in range(h)]

ans = 0

def main():
    N = NI()

    def dfs(num):
        global ans
        if "3" in str(num) and "5" in str(num) and "7" in str(num):
            ans += 1
        if num * 10 + 3 <= N:
            dfs(num * 10 + 3)
        if num * 10 + 5 <= N:
            dfs(num * 10 + 5)
        if num * 10 + 7 <= N:
            dfs(num * 10 + 7)

    dfs(0)
    print(ans)

if __name__ == "__main__":
    main()

Measured memory_bytes: 9380
import java.util.*;

public class Main {
  private static boolean valid4(String s) {
    // invalid XACG AXCG, ACXG
    return !s.matches(".AGC") && !s.matches("A.GC") && !s.matches("AG.C") && !s.matches("AGC.")
        && !s.matches(".AGC") && !s.matches(".ACG") && !s.matches(".GAC");
  }
  
  private static boolean valid3(String s) {
    return !s.equals("AGC") && !s.equals("ACG") && !s.equals("GAC");
  }
  
  private static long solve(int n) {
    if (n == 1) {
      return 4;
    } else if (n == 2) {
      return 16;
    }
    
    char[] atcg = new char[]{'A', 'T', 'C', 'G'};
    
    long[] init = new long[64];
    ArrayList<ArrayList<Integer>> transform = new ArrayList<ArrayList<Integer>>();
    for (int i = 0; i < 64; i++) {
      transform.add(new ArrayList<Integer>());
    }
    
    for (int a = 0; a < atcg.length; a++) {
      for (int b = 0; b < atcg.length; b++) {
        for (int c = 0; c < atcg.length; c++) {
          int indexSrc = (a << 4) | (b << 2) | c;
          String str3 = "" + atcg[a] + atcg[b] + atcg[c];
          if (valid3(str3)) {
            init[indexSrc] = 1;
          } else {
            init[indexSrc] = 0;
            continue;
          }
          
          for (int d = 0; d < atcg.length; d++) {
            int indexDst = (b << 4) | (c << 2) | d;
            String str4 = str3 + atcg[d];
            if (valid4(str4)) {
              transform.get(indexDst).add(indexSrc);
//              System.out.println(str3 + " - " + str4);
            }
          }
        }
      }
    }
    
    long[] src = init;
    for (int i = 3; i < n; i++) {
      long[] dst = new long[64];
      for (int j = 0; j < 64; j++) {
        dst[j] = 0;
        for (int indexSrc: transform.get(j)) {
          dst[j] += src[indexSrc];
          dst[j] %= 1000000007;
        }
      }
      src = dst;
    }
    
    long sum = 0;
    for (int i = 0; i < 64; i++) {
      sum += src[i];
      sum %= 1000000007;
    }
    return sum;
  }
  
  public static void main(String[] args) {
    Scanner s = new Scanner(System.in);
    
    System.out.println(solve(s.nextInt()));
  }
}


Measured memory_bytes: 26192
# -*- coding: utf-8 -*-

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

a.sort()
a.reverse()

alice = 0
bob = 0

for i in range(n):
    if i % 2 == 0:
        alice += a[i]
    else:
        bob += a[i]

print(alice-bob)


Measured memory_bytes: 3060
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int m = sc.nextInt();
         
        int[][] A = new int[n][m];
        int[] B = new int[m];
        int[] C = new int[n];
        for(int i = 0; i < n; i++) {
            for(int j = 0; j <  m; j++) {
                A[i][j] = sc.nextInt();
            }
        }
        for(int i = 0; i < m; i++) {
            B[i] = sc.nextInt();
        }
         
        for(int i = 0; i < n; i++) {
            for(int j = 0; j < m; j++) {
                C[i] += A[i][j] * B[j];
            }
        }
         
        for(int i = 0; i < n; i++) {
            System.out.println(C[i]);
        }

	}

}


Measured memory_bytes: 40608
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();
		int d = sc.nextInt();
		
		if((Math.abs(a - b) <= d && Math.abs(b - c) <= d) || Math.abs(a - c) <= d) {
			System.out.println("Yes");
		}else {
			System.out.println("No");
		}

	}

}

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

vector<int> v;

int main(){
	int n;
	for(int i = 0; i < 10; i++){
		cin >> n;
		v.push_back(n);
	}
	
	sort(v.begin(), v.end());
	reverse(v.begin(), v.end());
	
	for(int i = 0; i < 3; i++)cout << v[i] << endl;
	
	return 0;
}


Measured memory_bytes: 3160
while True:
	try:
		a,b,n = [eval(x) for x in input().split()]
		_,fra = str(a/b).split('.') if '.' in str(a/b) else '0'
		print(sum([eval(fra[i]) for i in range(n if n <= len(fra) else len(fra))]))
	except EOFError:
		break

Measured memory_bytes: 7496
N=int(input())
S=[input() for i in range(N)]
l=[None]*N
ni=1
b=[0]
l[0]=False
while b:
    a=[]
    for i in b:
        for j in range(N):
            if S[i][j]=="1":
                if l[j]==None:
                    l[j]=not l[i]
                    a.append(j)
                else:
                    if l[j]==l[i]:
                        ni=0
    b=a
s=[[1000]*N for i in range(N)]
for i in range(N):
    s[i][i]=0
for i in range(N):
    for j in range(N):
        if S[i][j]=="1":
            s[i][j]=1
for i in range(N):
    for j in range(N):
        for k in range(N):
            s[j][k] = min(s[j][k],s[j][i] + s[i][k])
M=0
for i in s:
    M=max(M,max(i))
print(M+1 if ni else -1)

Measured memory_bytes: 42348
import javax.print.DocFlavor;
import java.awt.*;
import java.io.PrintWriter;
import java.lang.reflect.Array;
import java.math.BigInteger;
import java.util.*;
import java.util.List;

public class Main {

    static String br = System.getProperty("line.separator");
    static Scanner sc = new Scanner(System.in);
    static PrintWriter out = new PrintWriter(System.out);

    public static void main(String[] args) {
        int N = nextInt();
        int M = nextInt();

        int[] s = new int[M];
        int[] c = new int[M];

        for(int i=0; i<M; i++){
            s[i] = nextInt();
            c[i] = nextInt();
        }

        List<Integer> num = new ArrayList<>();
        for(int i=0; i<N; i++){
            num.add(-1);
        }

        for(int i=0; i<M; i++){
            if(num.get(s[i]-1) == -1 || num.get(s[i]-1) == c[i]) {
                num.remove(s[i] - 1);
                num.add(s[i] - 1, c[i]);
            }else{
                println(-1);
                return;
            }
        }

        if(N != 1 && num.get(0)==0){
            println(-1);
        }else{
            for(int i=0; i<N; i++){
                int number = Math.max(num.get(i), 0);
                if(N!= 1 && i == 0 && num.get(i) == -1) number = 1;
                print(number);
            }
        }
    }

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

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

    static String next() {
        return sc.next();
    }

    static String nextLine(){
        return sc.nextLine();
    }

    static void println(Object o) {
        out.println(o);
        out.flush();
    }

    static void print(Object o) {
        PrintWriter out = new PrintWriter(System.out);
        out.print(o);
        out.flush();
    }
}


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

int main()
{
    int odd = 0, eve = 0;
    string str;
    cin >> str;
    for (int i = 0; i < str.size();i++){
        if((i+1)%2==1){
            if(str.at(i)=='R'|| str.at(i)=='U'||str.at(i)=='D'){
            }
            else{
                odd = 1;
            }
        }
        else{
            if (str.at(i) == 'L' || str.at(i) == 'U' || str.at(i) == 'D')
            {

            }
            else{
                eve = 1;
            }
        }
    }
    //cout << odd << " " << eve << endl;
    if(odd==1||eve==1){
        cout << "No" << endl;
    }
    else{
        cout << "Yes" << endl;
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <cstdio>
#include <string>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cmath>
#include <functional>
#include <numeric>
#include <iomanip>
#define fi first
#define se second
#define fcout(n) cout<<fixed<<setprecision((n))
#define cinl(str) getline(cin,(str))
using namespace std;
bool value(int y,int x,int R,int C){return 0<=y&&y<R&&0<=x&&x<C;}
typedef pair<int,int> pii;
typedef long long ll;
typedef vector<int> vi;
typedef vector<long long > vll;
typedef vector< vi > vvi;
double pie=acos(-1);
int INF=1000000007;
int dx[4] = { 0,-1,0,1 };
int dy[4] = { -1,0,1,0 };


int main() {
	int n;
	int d,x;
	int a[105];
	int eat=0;
	int ans;

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

	for(int i=0;i<n;i++){
		eat += (d-1)/a[i] + 1;
	}

	//cout<<eat<<endl;

	ans = eat + x;
	cout<<ans<<endl;

}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>

#include <iostream>
#include <complex>
#include <string>
#include <algorithm>
#include <numeric>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>

#include <functional>
#include <cassert>

typedef long long ll;
using namespace std;

#ifndef LOCAL
#define debug(x) ;
#else
#define debug(x) cerr << __LINE__ << " : " << #x << " = " << (x) << endl;

template <typename T1, typename T2>
ostream &operator<<(ostream &out, const pair<T1, T2> &p) {
  out << "{" << p.first << ", " << p.second << "}";
  return out;
}

template <typename T>
ostream &operator<<(ostream &out, const vector<T> &v) {
  out << '{';
  for (const T &item : v) out << item << ", ";
  out << "\b\b}";
  return out;
}
#endif

#define mod 1000000007 //1e9+7(prime number)
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define SIZE 200010


int main(){
  int N, K, Q;
  int score[SIZE] = {};

  cin >> N >> K >> Q;

  for(int i=0; i<Q; i++) {
    int a;
    cin >> a;
    score[a-1]++;
  }

  for(int i=0; i<N; i++) {
    if(K + score[i] - Q > 0) {
      puts("Yes");
    } else {
      puts("No");
    }
  }

  return 0;
}


Measured memory_bytes: 1408
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        CTaxIncrease solver = new CTaxIncrease();
        solver.solve(1, in, out);
        out.close();
    }

    static class CTaxIncrease {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int a = Integer.parseInt(in.next());
            int b = Integer.parseInt(in.next());

            int r = -1;
            for (double i = 1; i <= 1000; i++) {
                boolean result = (int) (i * 0.08) == a && (int) (i * 0.1) == b;
                if (result) {
                    r = (int) i;
                    break;
                } else if ((int) (i * 0.08) > a || (int) (i * 0.1) > b) {
                    break;
                }
            }
            out.append(String.valueOf(r));
        }

    }
}



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

using namespace std;

int main() {
  int N;
  cin >> N;
  vector<int64_t> A(N);
  for (int i = 0; i < N; i++) cin >> A[i];
  int64_t answer = 0;
  int64_t max_A = 0;
  for (int i = 0; i < N; i++) {
    if (A[i] < max_A) {
      answer += max_A - A[i];
    } else {
      max_A = A[i];
    }
  }
  cout << answer << endl;
  return 0;
}


Measured memory_bytes: 4840
#include<bits/stdc++.h>
using namespace std;
const int N = 1e5 + 10;

int n, k, a[N];

int main() {
   cin >> n >> k;
   for (int i = 1; i <= n; ++i)
      scanf("%d", &a[i]);
   for (int i = 1; i < n; ++i) {
      if (a[i] + a[i + 1] >= k) {
	 puts("Possible");
	 for (int j = 1; j < i; ++j)
	    printf("%d\n", j);
	 for (int j  = n - 1; j >= i; --j)
	    printf("%d\n", j);
	 return 0;
      }
   }
   return 0 * puts("Impossible");
}


Measured memory_bytes: 1152
#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <queue>
#include <assert.h>
#include <numeric>
#include <math.h>
#include <climits>

using namespace std;
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
typedef long long ll;

template <typename T>
T gcd(T a, T b) {
    if(a < b) gcd(b, a);
    if (b == 1) return 1;
    T r;
    while ((r=a%b)) {
        a = b;
        b = r;
    }
    return b;
}

int l[100001];
int r[100001];
int main() {
    int N;
    cin >> N;
    
    vector<int> As;
    REP(i, N) {
        int a;
        cin >> a;
        As.push_back(a);
    }
    
    int ld = 0;
    int rd = 0;
    REP(i, N) {
        if (i == 0) {
            ld = As[i];
            rd = As[N-i-1];
        } else {
            ld = gcd<int>(ld, As[i]);
            rd = gcd<int>(rd, As[N-i-1]);
        }
        l[i] = ld;
        r[N-i-1] = rd;
    }
    
    int m = 0;
    REP(i, N) {
        int d;
        if (i == 0) {
            d = r[1];
        } else if (i == N-1) {
            d = l[N-2];
        } else {
            d = gcd(l[i-1], r[i+1]);
        }
        
        m = max(m, d);
    }
    cout << m << endl;
}


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

void find(string s, string *str){

    int numStart = 0;
    int num = 0;
    int mode = 2;  // 0:num 1:() 2:numStart
    int strStart = 0;
    int cnt = 0;
    for(int i = 0; i < (int)s.size(); i++){
        char temp = s[i];
        if(mode == 2){
            if(isalpha(temp)){
                *str += temp;
            }
            else{
                numStart = i;
                mode = 0;
            }
        }
        else if(mode == 0 && !isdigit(temp)){
            num = stoi(s.substr(numStart, i - numStart));
            mode = 1;
            if(isalpha(temp)){
                for(int j = 0; j < num; j++){
                    *str += temp;
                }
                mode = 2;
            }
            else{
                strStart = i + 1;
                cnt++;
            }
        }
        else if(mode == 1 && temp == '('){
            cnt++;
        }
        else if(mode == 1 && temp == ')'){
            cnt--;
            if(cnt == 0){
                string temp = s.substr(strStart, i - strStart);
                string tempStr = "";
                find(temp, &tempStr);

                for(int j = 0; j < num; j++){
                    if((*str).size() >= 1000050){
                        break;
                    }
                    *str += tempStr;
                }
                mode = 2;
            }
        }

        if((*str).size() >= 1000050){
            break;
        }
    }
}

int main(){

    while(1){
        string s;
        int i;
        cin >> s >> i;
        if(s == "0" && i == 0){
            break;
        }

        string str = "";
        find(s, &str);
        if((int)str.size() > i){
            cout << str[i] << endl;
        }
        else{
            cout << 0 << endl;
        }
    }

    return 0;
}


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

string pat[] = { "dreamer", "eraser", "dream", "erase" };

bool match_pat( const string& s, int& index ) {
	bool result = false;
	int i = index;

	for( int j = 0; !result && j < 4; ++j ) {
		int n = pat[j].size();
		int m = 0;

		for( int k = 0; k < n; ++k ) {
			if( i-k < 0 || s.at( i-k ) != pat[j].at( n-1 - k ) ) {
				break;
			}

			m += 1;
		}

		if( m == n ) {
			result = true;
			i -= n;
		}
	}

	index = i;
	return result;
}

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

	string s;
	cin >> s;

	int i = s.size() - 1;

	while( i >= 0 ) {
		if( !match_pat( s, i ) ) {
			break;
		}
	}

	cout << (i == -1 ? "YES" : "NO") << endl;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <string>
using namespace std;
typedef long long int ll;
#define rep(i, n) for (int(i) = 0; (i) < (n); (i)++)

int main(){
    string s; cin >> s;
    int ans;
    if(s=="SUN")ans=7;
    else if(s=="MON")ans=6;
    else if(s=="TUE")ans=5;
    else if(s=="WED")ans=4;
    else if(s=="THU")ans=3;
    else if(s=="FRI")ans=2;
    else if(s=="SAT")ans=1; 
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include<vector>
#include<cmath>
#include<map>
#include<cstdlib>
#include<iostream>
#include<sstream>
#include<fstream>
#include<string>
#include<algorithm>
#include<cstring>
#include<cstdio>
#include<set>
#include<stack>
#include<bitset>
#include<functional>
#include<ctime>
#include<queue>
#include<deque>
#include<complex>
using namespace std;
#define pb push_back
#define pf push_front
typedef long long lint;
typedef complex<double> P;
#define mp make_pair
#define fi first
#define se second
typedef pair<int,int> pint;
#define All(s) s.begin(),s.end()
#define rAll(s) s.rbegin(),s.rend()
#define REP(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)
lint a[19];
int main()
{
	rep(i,7) cin>>a[i];
	lint out=0,mi=min(a[0],min(a[3],a[4]));
	out=max(out,mi*3+(a[0]-mi)/2*2+(a[3]-mi)/2*2+(a[4]-mi)/2*2);
	if(mi>0LL){
		mi--;
		out=max(out,mi*3+(a[0]-mi)/2*2+(a[3]-mi)/2*2+(a[4]-mi)/2*2);
	}
	cout<<out+a[1]<<endl;
}


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

const int INF = 1e+9;
typedef long long ll;

int main() {
	int n, m, a[300010] = {0}, b[300010] = {0};
	ll sum[300010] = {0}, c[300010] = {0};
	cin >> n;
	for(int i = 0; i < n; ++i)
		scanf("%d", &a[i]);
	sort(a, a + n);
	a[n] = INF;
	for(int i = 1; i <= n; ++i)
		sum[i] = sum[i - 1] + a[i - 1];
	
	cin >> m;
	for(int i = 0; i < m; ++i)
		scanf("%d", &b[i]);
	for(int i = 0; i < m; ++i)
		scanf("%lld", &c[i]);
		
	bool check[300010] = {0};
	for(int i = 0; i < m; ++i){
		int idx = upper_bound(a, a + n + 1, b[i]) - a;
		if(sum[idx] >= c[i])
			check[i] = true;
	}
	for(int i = 0; i < m; ++i){
		if(check[i])
			printf("Yes\n");
		else
			printf("No\n");
	}
	return 0;
}

Measured memory_bytes: 8548
#include <iostream>
#include <cstdlib>

using namespace std;

#define N 5

int main() {
  int a[N];

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

  int k;
  cin >> k;
  for(int i=0; i<N; i++) {
    for(int j=0; j<N; j++) {
      if(abs(a[i] - a[j]) > k) {
	cout << ":(" << endl;
	return 0;
      }
    }
  }

  cout << "Yay!" << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i,n) for (int i = 0; i < (n); i++)
#define RREP(i, s, n) for (int i = s; i < (n); i++)
#define ALL(a) a.begin(), a.end()
#define RALL(a) a.rbegin(), a.rend()
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
using namespace std;
using ll = long long;
typedef pair<int, int> pint;
typedef pair<ll, ll> pll;
const ll MOD = 1000000007;
const ll INF = MOD * MOD;
const int inf = (1<<29);

int main() {

    int N, M;
    cin >> N >> M;
    vector<int> hen(N, 0);

    for(int i = 0; i < M; i++) {
        int a, b;
        cin >> a >> b;
        a--; b--;
        hen[a]++;
        hen[b]++;
    }

    for(int i = 0; i < N; i++) {
        if (hen[i] % 2) {
            cout << "NO" << endl;
            return 0;
        }
    }

    cout << "YES" << endl;
    

    return 0;
}

Measured memory_bytes: 3748
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin >> N;
 
  for(int i = 0; i < N; i++){
    
	string s;
	cin >> s;

	if (s=="Y"){
	cout << "Four" << endl;
     break;
  }
    if (i ==(N-1)){
      cout << "Three" << endl;
    }    
    
 }
	
}

Measured memory_bytes: 256
A,B,T = gets.chomp.split(" ").map(&:to_i)
ans = 0
baisuu = []
for i in 1..20 do
    baisuu[i] = A * i
end
for i in 1..T do 
    if baisuu.any? {|w| w == i }
        ans = ans + B
    end
end

puts ans

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

const int N = 20000, B = int(1e9) + 1;

int n, p[N], a[N], b[N];

int main(){
    scanf("%d", &n);
    for(int i = 0, x; i < n; i++){
        scanf("%d", &x);
        p[x - 1] = i;
    }
    a[0] = 1;
    b[0] = B - 1;
    for(int i = 1; i < n; i++){
        int t = B + (p[i] - p[0]);
        a[i] = max(a[i - 1] + 1, t - b[i - 1] + 1);
        b[i] = t - a[i];
    }
    for(int i = 0; i < n; i++) printf("%d ", a[i]);
    puts("");
    for(int i = 0; i < n; i++) printf("%d ", b[i]);
    puts("");
}

Measured memory_bytes: 896
/*
 * Contest156_C.cpp
 *
 *  Created on: 2020/02/22
 *      Author: black
 */

#include <iostream>

using namespace std;

int main(){
	int n;
	cin >> n;
	int *x = new int[n];

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

	int min = 100000000;
	int sum = 0;
	//int p = 0;
	//int tmp = 0;

	/*
	for (int i=0; i< n; ++i){
		for (int j=0; j<n; ++j){
			tmp = x[j] - x[i];
			if (tmp < 0){
				tmp *= -1;
			}
			sum += tmp;
		}
		if (sum < min){
			min = sum;
			p = i;
		}
	}
	*/
	for (int j=1; j<=100; ++j){
		sum = 0;
		for (int k=0; k< n; ++k){
			sum += (x[k] - j)*(x[k] - j);
			//sum += (x[k] - j])*(x[k] - j);
		}
		if (sum < min){
			min = sum;
		}
	}

	cout << min << endl;


	return 0;
}




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

typedef long long ll;
#define REP(i,n) for(int i=0;i<(n);i++)
#define REAP(i,a,n) for(int i=(a);i<(n);i++)
#define YES cout<<"Yes"<<endl
#define NO cout<<"No"<<endl
#define fr first
#define sc second
#define pb push_back
#define All(v) v.begin(),v.end()

bool check(ll ma,ll a,ll b){

    bool flg=true;
    for(ll i=ma/2-1000;i<=ma/2+1000;i++){
        if(i<1||i>ma)continue;
        ll x=i,y=ma-i+1;
        if(x>=a)x++;
        if(y>=b)y++;
        if(x*y>=a*b){
            flg=false;
        }
    }
    return flg;
}

ll solve(ll a,ll b){
    ll left = 0;
    ll right = a+b;
    while(right-left>1){
        ll mid = (left+right)/2;
        if(check(mid,a,b)){
            left=mid;
        }else{
            right=mid;
        }
    }
    return left;
}

int main(){
    int q;
    cin >> q;
    ll a,b,ans;
    while(q--){
        cin >> a >> b;
        ans = solve(a,b);
        cout << ans << endl;
    }
}


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

using namespace std;

struct Dsu {
    int n;
    vector<int> p;
    vector<int> r;
    
    Dsu(int _n) { n = _n; p.resize(n); r.resize(n); init(); }
    inline void init() {
        for (int i = 0; i < n; i++) {
            p[i] = i;
            r[i] = 1;
        }
    }
    inline int find(int x) {
        return p[x] == x ? x: p[x] = find(p[x]);
    }
    inline bool join(int x, int y) {
        x = find(x); y = find(y);
        if (x == y) return false;
        if (r[x] < r[y]) swap(x, y);
        p[y] = x; r[x] += r[y];
        return true;
    }
    inline bool check(int x, int y) {
        return find(x) == find(y);
    }
};

struct Edge {
    int r, c, x;
    Edge() {}
    Edge(int _r, int _c, int _x) : r(_r), c(_c), x(_x) {}
    bool operator<(const Edge& _e) const {
        return x > _e.x;
    }
};

void solve() {
    int n, h,w;
    cin >> n >> h >> w;
    vector<Edge> e(n);
    for (int i = 0; i < n; i++) {
        int r,c,a;
        cin >> r >> c >> a;
        r--; c += h-1;
        e[i] = {r,c,a};
    }
    Dsu d(h+w);
    sort(e.begin(), e.end());
    vector<int> sz(h+w, 0);
    long long res = 0;
    for (auto& p: e) {
        int u = d.find(p.r), v = d.find(p.c);
        if (u == v) {
            if (sz[u] < d.r[u]){
                res += p.x;
                sz[u]++;
            }
        } else {
            if (sz[u]+sz[v] < d.r[u]+d.r[v]) {
                res += p.x;
                d.join(u,v);
                int s = sz[u]+sz[v]+1;
                sz[u] = sz[v] = s;
            }
        }
    }
    cout << res;
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    solve();
    cout << endl;
}


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

using namespace std;

const int MAX_N = 1e2+10;

int main(int argc, char const *argv[])
{
    int n, w[MAX_N];
    cin >> n;
    for (int i = 0; i < n; ++i) {
        cin >> w[i];
    }

    int dp[MAX_N] = {0};
    dp[0] = w[0];

    for (int i = 1; i < n; ++i) {
        dp[i] = dp[i-1] + w[i];
    }

    int min_s = dp[n-1];

    for (int i = 0; i < n-1; ++i) {
        min_s = min(min_s, abs(dp[n-1]-2*dp[i]));
    }

    cout << min_s << endl;

    return 0;
}

Measured memory_bytes: 256
// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}
 
#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};
 
    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}
 
#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };
 
    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };
 
    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };
 
    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };
 
    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };
 
    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

// -----------------------------------------------------------------------------
// main
// -----------------------------------------------------------------------------
fn main(){
    input!{
        r: usize
    }
    let ans;
    if r<1200{
        ans = "ABC";
    }else if r<2800{
        ans = "ARC"
    }else{
        ans = "AGC"
    }
    println!("{}", ans);
}



Measured memory_bytes: 4352
#include<iostream>
#include<algorithm>
using namespace std;
#define REP(i,b,n) for(int i=b;i<n;i++)
#define rep(i,n)   REP(i,0,n)

const int N = 300;
const int inf = (1 << 21);
int cost[2][N][N];

void calc(bool a,int n){
  rep(k,n)
    rep(i,n)
    rep(j,n)
      cost[a][i][j]=min(cost[a][i][j],cost[a][i][k]+cost[a][k][j]);
}

main(){
  int n,m;
  while(cin>>m>>n && n){
    rep(i,n){
      rep(j,n)cost[0][i][j]=cost[1][i][j]=inf;
      cost[0][i][i]=cost[1][i][i]=0;
    }
    
    rep(i,m){
      int f,t,mo,ti;
      cin>>f>>t>>mo>>ti;
      f--;t--;
      cost[0][f][t]=cost[0][t][f]=mo;
      cost[1][f][t]=cost[1][t][f]=ti;
    }

    calc(0,n);
    calc(1,n);

    int q;
    cin>>q;
    rep(i,q){
      int f,t,r;
      cin>>f>>t>>r;
      f--;t--;
      cout << cost[r][f][t] << endl;

    }

  }
  return 0;
}

Measured memory_bytes: 1104
#include <cstdio>
#include <vector>
#include <algorithm>
#include <functional>
#include <map>
#include <set>
#include <string>
#include <iostream>
#include <cassert>
#include <cmath>
using namespace std;

const long long MOD = 1e9 + 7;

long long Pow(long long x, long long a) {
	long long res = 1;
	while (a > 0) {
		if (a & 1) res = res * x % MOD;
		x = x * x % MOD;
		a >>= 1;
	}
	return res;
}

int main() {
	int n, k;
	scanf("%d%d", &n, &k);
	vector<vector<vector<long long>>> dp(n + 1, vector<vector<long long>> (n + 2, vector<long long> (2)));
	dp[n][0][0] = 1;
	for (int i = n; i >= 1; i --) {
		for (int j = n; j >= 0; j --) {
			(dp[i - 1][j][0] += dp[i][j][0] + dp[i][j][1]) %= MOD;
			(dp[i - 1][j + 1][1] += dp[i][j][0] + dp[i][j][1]) %= MOD;
			if (j > 0) {
				(dp[i][j - 1][0] += dp[i][j][0]) %= MOD;
			}
		}
	}
	long long ans = dp[1][n - k][0] + dp[1][n - k][1];
	(ans *= (n == k ? 1 : Pow(2, n - k - 1))) %= MOD;
	printf("%lld\n", ans);
        return 0;
}


Measured memory_bytes: 219520
#include <stdio.h>

#include <math.h>

int hantei(int h1,int h2,int tai);

int main(){
    
	int h1,h2,tai,i,tyou=0,hisi=0;
    
	while(scanf("%d,%d,%d",&h1,&h2,&tai)!=EOF){
        
		if(hantei(h1,h2,tai)==1){
            
			tyou++;
            
		}else if(hantei(h1,h2,tai)==2){
            
			hisi++;
            
		}
        
	}
    
	printf("%d\n",tyou);
    
	printf("%d\n",hisi);
    
	
    
	return 0;
    
}

int hantei(int h1,int h2,int tai){
    
	if((tai*tai)==(h1*h1)+(h2*h2)){
        
		return 1;
        
	}else if(h1==h2){
        
		return 2;
        
	}
    
	return 0;
    
}

Measured memory_bytes: 596
#include <iostream>
#include <bitset>
#include <iomanip>
#include <string>
#include <vector>
#include <cmath>
#include <queue>
#include <algorithm>

#define ll long long
#define vecll vector<long long>
#define vec2ll vector<vector<long long>>
#define forll(s,a,b) for(long long s = a;s < b;s++)

using namespace std;

int main()
{
	ll n;
	string s;

	cin >> n;

	vector<pair<ll,ll>> a(n);

	forll(i, 0, n)
	{
		cin >> a[i].first;
		a[i].second = i;
	}

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

	forll(i,0,n)
		cout << a[i].second+1 << " ";
}

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

#define int long long
const int mod = 1e9+7;

class FermatCombination{
private:
	vector<int> fac, inv;
	
	int Pow(int x, int n){
		int ans = 1;
		while(n > 0){
			if(n & 1)ans = (ans*x)%mod;
			x = (x*x)%mod;
			n >>= 1;
		}
		return ans;
	}
	void Factrial(int n){
		fac[0] = inv[0] = 1;
		for(int i = 1;i <= n;i++){
			fac[i] = (fac[i-1]*i)%mod;
			inv[i] = Pow(fac[i], mod-2);
		}
	}
	
public:
	void init(int n){	//nCk
		fac.resize(n+1);
		inv.resize(n+1);
		Factrial(n);
	}
	int combine(int n, int k){
		int tmp = (fac[n]*inv[k])%mod;
		return (tmp*inv[n-k])%mod;
	}
};

FermatCombination C;
int a[100002], b[100002];
const int MAX_N = 100010;

int comb(int x, int y){
	if(x < y)return 0;
	if(y == 0)return 1;
	return C.combine(x, y);
}

signed main(){
    int n, l1, l2;
    int hash[MAX_N] = {};
    fill(hash, hash + MAX_N, -1);
	scanf("%lld", &n);
	for(int i = 0;i < n+1;i++){
        int a;
		scanf("%lld", &a);
        if(hash[a] != -1){
            l1 = hash[a];
            l2 = i;
        }
        hash[a] = i;
    }
	
	C.init(n+1);
	for(int k = 1;k <= n+1;k++){
        int ans = comb(n + 1, k) - comb(n + l1 - l2, k - 1) + mod;
        cout << ans % mod << "\n";
    }

    return 0;
}


Measured memory_bytes: 3584
use std::io::{self, Stdin};
use std::str::{self, FromStr};
use std::error::Error;
fn exec() {
    let mut sc = Scanner::new();
    let (n, m): (usize, usize) = (sc.ne(), sc.ne());
    let mut adj = vec![Vec::new(); n];
    for _ in 0..m {
        let u = sc.ne::<usize>() - 1;
        let v = sc.ne::<usize>() - 1;
        adj[u].push(v);
        adj[v].push(u);
    }
    fn dfs(cur: usize,
           adj: &Vec<Vec<usize>>,
           mut path: &mut Vec<usize>,
           mut used: &mut Vec<bool>) {
        used[cur] = true;
        for &nxt in &adj[cur] {
            if used[nxt] {
                continue;
            }
            path.push(nxt);
            dfs(nxt, adj, path, used);
            break;
        }
    }
    let mut path = Vec::new();
    let mut used = vec![false; n];
    dfs(0, &adj, &mut path, &mut used);
    path.reverse();
    path.push(0);
    dfs(0, &adj, &mut path, &mut used);
    println!("{}", path.len());
    for x in path {
        print!("{} ", x + 1);
    }
    println!("");
}

fn main() {
    const STACK: usize = 16 * 1024 * 1024;
    let _ = std::thread::Builder::new()
        .stack_size(STACK * 4)
        .spawn(|| { exec(); })
        .unwrap()
        .join()
        .unwrap();
}

#[allow(dead_code)]
struct Scanner {
    stdin: Stdin,
    id: usize,
    buf: Vec<u8>,
}

#[allow(dead_code)]
impl Scanner {
    fn new() -> Scanner {
        Scanner {
            stdin: io::stdin(),
            id: 0,
            buf: Vec::new(),
        }
    }
    fn next_line(&mut self) -> Option<String> {
        let mut res = String::new();
        match self.stdin.read_line(&mut res) {
            Ok(0) => None,
            Ok(_) => Some(res),
            Err(why) => panic!("error in read_line: {}", why.description()),
        }
    }
    fn next<T: FromStr>(&mut self) -> Option<T> {
        while self.buf.len() == 0 {
            self.buf = match self.next_line() {
                Some(r) => {
                    self.id = 0;
                    r.trim().as_bytes().to_owned()
                }
                None => return None,
            };
        }
        let l = self.id;
        assert!(self.buf[l] != b' ');
        let n = self.buf.len();
        let mut r = l;
        while r < n && self.buf[r] != b' ' {
            r += 1;
        }
        let res = match str::from_utf8(&self.buf[l..r]).ok().unwrap().parse::<T>() {
            Ok(s) => Some(s),
            Err(_) => {
                panic!("parse error, {:?}",
                       String::from_utf8(self.buf[l..r].to_owned()))
            }
        };
        while r < n && self.buf[r] == b' ' {
            r += 1;
        }
        if r == n {
            self.buf.clear();
        } else {
            self.id = r;
        }
        res
    }
    fn ne<T: FromStr>(&mut self) -> T {
        self.next::<T>().unwrap()
    }
}


Measured memory_bytes: 17276
#include <iostream>
#include<iomanip>
#include <map>
#include <algorithm>
#include <vector>
#include <string>
#include <utility>
#include <queue>
#define INF 1e9+7
#define rep(i,n) for(int i=0;i<n;i++)
#define NO cout<<"NO"<<endl;
#define YES cout<< "YES"<<endl;
#define No cout<< "No"<<endl;
#define Yes cout<< "Yes"<<endl;
#define all(a) a.begin(),a.end()
#define P pair<int,int>
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;

//(int)'a'は97 (int)'A'は65 (int)'1'は49
//おまじない

int main(){
    
    int a,b,c;
    string s;
    cin >> a>>s;
    if(a>=3200){
        cout << s<<endl;
    }else{
        cout <<"red"<<endl;
    }
    
    return 0;
}


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

int main() 
{
  int a,b,c,d;
  cin>>a>>b>>c>>d;
  int ans=0;
  while(d>0)
  {
    if(a==0)
    {
      break;
    }
    ans++;
    a--;
    d--;
  }
  
  while(d>0)
  {
    if(b==0)
    {
      break;
    }
    b--;
    d--;
  }
  while(d>0)
  {
    if(c==0)
    {
      break;
    }
    ans--;
    c--;
    d--;

  }
  cout<<ans<<endl;
}


Measured memory_bytes: 3636