akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define vll vector<ll>
#define vi vector<int>
#define vpll vector<pair<ll,ll>>
#define pii pair<int,int>
#define REP(i,a) for(int (i)=0; (i)<(a); (i)++)
#define RREP(i,a) for(int (i)=a-1; (i)>=(0); (i)--)
#define REP2(i,a,b) for(int (i)=(a); (i)<(b); (i)++)
#define MOD 1000000007
#define ALL(v) v.begin(), v.end()
#define m0(x) memset(x,0,sizeof(x))
typedef long long ll;

using namespace std;

int gcd(int a,int b){return b?gcd(b,a%b):a;}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

int main(){
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int K,X;
  cin >> K >> X;
  for(int i = K-1 ;i>0;i--){
    cout <<  X - i << " "; 
  }
  cout << X << " ";
  for(int i=1;i <= K-1;i++){
    cout <<  X + i << " "; 
  }  

  return 0;
}

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

#sを辞書に入れてカウントする
d = {}
for _ in range(n):
    s = input()
    if s in d:
        d[s] += 1
    else:
        d[s] = 1

#valueが最大であるkeyを辞書順にプリントする
m = max(d.values())
for s in sorted(k for k in d if d[k] == m):
    print(s)

Measured memory_bytes: 32096
using System;
using System.Collections.Generic;
using System.Linq;
using static AtCoder;
using System.Threading.Tasks;
using System.ComponentModel;

public class Hello
{
    private const int INF = 1000000007;
    public static void Main()
    {
        string s = Console.ReadLine();
        string ans = "";
        if (s[0] == s[s.Length - 1])
        {
            if ((s.Length - 2) % 2 == 0) ans = "First";
            else ans = "Second";
        }
        else
        {
            if (s.Length % 2 == 0) ans = "Second";
            else ans = "First";
        }
        Console.WriteLine(ans);
    }
}

public class AtCoder
{
    public static void Swap<T>(ref T a, ref T b)
    {
        var t = a;
        a = b;
        b = t;
    }
    public static int GCD(int a, int b)
    {
        if (a < b) Swap(ref a, ref b);
        int d = a % b;
        while (b != 0)
        {
            d = a % b;
            a = b;
            b = d;
        }
        return a;
    }
    public static long LCM(int a, int b)
    {
        return (long)a * b / GCD(a, b);
    }
    public static string StrReverce(string s)
    {
        return new string(s.Reverse().ToArray());
    }
    public static int IntRead()
    {
        return int.Parse(Console.ReadLine());
    }
    public static bool IsPrime(int n)
    {
        if (n < 2) return false;
        if (n == 2) return true;
        if (n % 2 == 0) return false;

        //double sqrtNum = Math.Sqrt(n);
        for (int i = 3; i < n; i += 2)
        {
            if (n % i == 0) return false;
        }
        return true;
    }
    public static string[] SpRead(char c)
    {
        return Console.ReadLine().Split(c);
    }
    public static long[] LSRead()
    {
        return Console.ReadLine().Split(' ').Select(long.Parse).ToArray();
    }
    public static long Combination(int n, int r)
    {
        if (n == r) return 1;
        return
            Enumerable.Range((n - r + 1), r).ToList().Aggregate((now, next) => now * next) /
            Enumerable.Range(1, r).ToList().Aggregate((now, next) => now * next);
    }
    public static long Permutation(int n, int r)
    {
        if (n == r) return 1;
        return
            Enumerable.Range((n - r), r).ToList().Aggregate((now, next) => now * next);
    }
    public static long RepPow(long x, long p, long m = 1000000007)
    {
        if (p == 1) return x % m;
        long b = RepPow(x, p / 2, m) % m;
        if (p % 2 == 0) { return (b * b) % m; }
        else { return (x * ((b * b) % m)) % m; }
    }
    public static long LongRead()
    {
        return long.Parse(Console.ReadLine());
    }
    public static long[] LongLine()
    {
        return Console.ReadLine().Split(' ').Select(long.Parse).ToArray();
    }
    public static int[] IntLine()
    {
        return Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
    }
}


Measured memory_bytes: 13280
inp = require('fs').readFileSync('/dev/stdin', 'utf8').split('\n')
S = inp.shift()
b = 1
b = b && S[0] == 'A'
cnt = 0
for (i=1; i<S.length; i++) {
    if ((2 <= i && i < S.length - 1) && S[i] == 'C') {
        cnt++
    } else {
        if (S[i] != S[i].toLowerCase()) {
            b = 0
        }
    }
}
b = b && cnt == 1
console.log(b ? 'AC' : 'WA')

Measured memory_bytes: 7372
r, g, b, n = map(int, input().split())
ans = 0
for i in range(n//r+1):
    for j in range(n//g+1):
        nn = n - r*i - g*j
        if nn < 0:
            break
        if nn % b == 0:
            ans += 1
print(ans)


Measured memory_bytes: 67684
// Five Dishes

#include <iostream>
#include <cmath>
#include <vector>
#include <algorithm>
#include <unordered_map>
#include <ios>
#include <iomanip>
#include <string>
#include <numeric>

using namespace std;

int last_menu(int arr[5]) {
    int min = 20;
    int ret;
    for (int i = 0; i < 5; i++) {
        int tmp = arr[i] % 10;
        if (0 < tmp && tmp < min) {
            min = tmp;
            ret = i;
        }
    }

    return ret;
}

int ceil_up(int n) {
    return (n + 9) - ((n + 9) % 10);
}

int main() {
    int a, b, c, d, e;
    cin >> a >> b >> c >> d >> e;
    int arr[5] = {a, b, c, d, e};

    int last = last_menu(arr);
    int ret = 0;
    for (int i = 0; i < 5; i++) {
        if (i == last) {
            continue;
        }
        ret += ceil_up(arr[i]);
    }
    ret += arr[last];

    cout << ret << endl;
    return 0;
}


Measured memory_bytes: 256
//Tax Rate Changed
//所要時間　４０分　学んだこと：　Generating and filtering
//http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=1192&lang=jp
//座席の位置 {左}×{中央}

#include <iostream>
#include <math.h>

using namespace std;

// xを消費税率として金額iの消費税込みの値段を返す
int tax(int x,int i) {
  int result = 0;
  result = i * (100 + x) / 100;
  result = floor(result);
  return result;
}

int main() {
  int x, y, s;  // x, 変更前の消費税率  y, 変更後の消費税率  s, 合計価格
  int maximum;  // 消費税変更後の合計価格の合計値
  
  while (cin >> x >> y >> s) {

    if (x == 0 && y == 0 && s == 0) {
      break;
    }

    maximum = 0;
    for (int i = 1; i < s; ++i) {
      for (int j = i; j < s; j++) {
	if (tax(x,i) + tax(x,j) == s) {
	  maximum = max(maximum, tax(y,i) + tax(y,j));
	}
      }
    }

    cout << maximum << endl;

  }
}




Measured memory_bytes: 3100
#include <sstream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <iostream>
#include <utility>
#include <set>
#include <list>
#include <cctype>
#include <queue>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <iomanip>
#include <iterator> 
#include <limits>

#define REP(i,n) for (int i=0;i<(n);i++)
#define FOR(i,a,b) for (int i=(a); i<(b); i++)
#define ALL(a) (a).begin(),(a).end()
#define RALL(A) (a).rbegin(),(a).rend()
#define PB push_back
#define MP make_pair

#define dump(x) cerr << #x << " = " << (x) << endl;

using namespace std;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const int INF = numeric_limits<int>::max() / 2;
const int NEG_INF = numeric_limits<int>::min() / 2;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

LL n, s;

LL fn(LL b, LL n) {
    LL res = 0;
    while (n >= b) {
        res += n % b;
        n = n / b;
    }
    res += n;
    return res;
}

void solve() {
    if (n < s) {
        cout << -1 << endl;
        return;
    }
    if (n == s) {
        cout << n + 1 << endl;
        return;
    }
    LL ans = 1e18;
    for (LL b = 2; b * b <= n; b++) {
        if (fn(b, n) == s) {
            ans = min(ans, b);
        }
    }
    for (LL p = 1; p * p <= n; p++) {
        if ((n - s) % p != 0) {
            continue;
        }
        LL b = (n - s) / p + 1;
        if (fn(b, n) == s) {
            ans = min(ans, b);
        }
    }
    if (ans == 1e18) {
        ans = -1;
    }
    cout << ans << endl;
    return;
}

int main(int argc, char const* argv[])
{
    cin >> n;
    cin >> s;
    solve();
    return 0;
}


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

int a;

int main() {
	scanf("%d", &a);
	int mew = a%1000;
	if(mew == 0){
		printf("0\n");
	}
	else{
		mew = 1000 - mew;
		printf("%d\n", mew);
	}
}

Measured memory_bytes: 3732
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,mxx=0;
    string s;
    map <string , int> maap;
    map <string , int> :: iterator it;
    cin>>n;
    for(int i=0;i<n;i++)
        {
        cin>>s;
        maap[s]++;
        }
    for(it=maap.begin();it!=maap.end();it++)
        {
            if(it->second>mxx){
                mxx=it->second;
            }
        }
    for(it=maap.begin();it!=maap.end();it++)
        {
            if(mxx==it->second){
                cout<<it->first<<endl;
            }
        }

}

Measured memory_bytes: 25216
#include <stdio.h>

int main(){
    int rodadas, somado, numero = 1;
    scanf("%d", &rodadas);
    scanf("%d", &somado);
    for (int i = 0; i < rodadas; i++){
        if (2*numero <= numero+somado)
            numero = 2*numero;
        else
            numero =  numero + somado;
    }
    printf("%d\n", numero);
    return 0;
}


Measured memory_bytes: 128
//Relive your past life.
//Face your demons.
//The past is never dead,it is not even past.
//The memories are not only the key to the past but...also to the future.
//coded in Rusty Lake
#include<cmath>
#include<math.h>
#include<ctype.h>
#include<algorithm>
#include<bitset>
#include<cassert>
#include<cctype>
#include<cerrno>
#include<cfloat>
#include<ciso646>
#include<climits>
#include<clocale>
#include<complex>
#include<csetjmp>
#include<csignal>
#include<cstdarg>
#include<cstddef>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<ctime>
#include<cwchar>
#include<cwctype>
#include<deque>
#include<exception>
#include<fstream>
#include<functional>
#include<iomanip>
#include<ios>
#include<iosfwd>
#include<iostream>
#include<istream>
#include<iterator>
#include<limits>
#include<list>
#include<locale>
#include<map>
#include<memory>
#include<new>
#include<numeric>
#include<ostream>
#include<queue>
#include<set>
#include<sstream>
#include<stack>
#include<stdexcept>
#include<streambuf>
#include<string>
#include<typeinfo>
#include<utility>
#include<valarray>
#include<vector>
#include<string.h>
#include<stdlib.h>
#include<stdio.h>
#define ll   long long
#define pb   push_back
#define mp   make_pair
#define orz  998244353
using namespace std;
int a[50005][105],b[5000005][3],k,n;
ll A[50005][105];
ll dfs(int L,int n){
    if(!n) return 1;
    if(n==1) return a[L][1]+1;
    int r=0;
    for(int i=1;i<=n;++i){
        int &o=b[r][a[L][i]];
        if(!o){
            o=++k;
            b[k][2]=-1;
            r=k;
        }
        else r=o;
    }
    if(b[r][2]!=-1) return b[r][2];
    for(int i=1;i<n;++i)a[L+1][i]=a[L][i+1];
    ll ans=(a[L][1]+1ll)*dfs(L+1,n-1);
    for(int i=1;i<=n;++i)A[L][i]=0;
    for(int i=1;i<=n/2;++i){
        for(int j=1;j<=i;++j)a[L+1][j]=a[L][j];
        for(int j=i*2;j<=n;j+=i){
            int J=j-i;
            for(int _=1;_<=i;++_)a[L+1][_]&=a[L][J+_];
            A[L][j]+=dfs(L+1,i);
        }
    }
    for(int i=1;i<=n;++i){
        if(!A[L][i]) continue;
        A[L][i]%=orz;
        for(int j=i+1;j<=n;++j)a[L+1][j-i]=a[L][j];
        (ans+=A[L][i]*dfs(L+1,n-i))%=orz;
    }
    ans%=orz;
    b[r][2]=ans;
    return ans;
}
int main(){
    char c=getchar();
    while(c>47)a[1][++n]=c-48,c=getchar();
    printf("%lld\n",dfs(1,n));
    //system("pause");
    return 0;
}


Measured memory_bytes: 4480
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repm(i, m, n) for (int i = (m); i < (int)(n); i++)
#define repr(i, n) for (int i = (n); i > 0; i--)
#define all(vec) vec.begin(), vec.end()
using namespace std;

int main(){
  int a;
  cin >> a;
  vector<char> c(a);
  rep(i, a) cin >> c.at(i);
  
  //int ans = 0;
  string ans;
  int y = 0;
  rep(i, a){
    if (c.at(i) == 'Y') y++;
  }
  if (y == 0) ans = "Three";
  else ans = "Four";

  cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <tuple>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <cmath>
#include <iomanip>
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) (int)(x).size()
using namespace std;
using ll = long long;
constexpr ll INF = 3000000000000000000;

int main() {
    int A, B, X;
    cin >> A >> B >> X;
    if (X >= A && X <= A + B) cout << "YES\n";
    else cout << "NO\n";
    return 0;
}


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

int main(){
    string S;
    int i,j,t;
    cin >> S;

    i = (S[0]-'0')*100 + (S[0]-'0')*10+(S[0]-'0');
    j = ((S[0]-'0')+1)*100 + ((S[0]-'0')+1)*10+((S[0]-'0')+1);
    t = (S[0]-'0')*100 + (S[1]-'0')*10+(S[2]-'0');
    
    if((min(abs(t-i),abs(t - j)) == abs(t - i))&&(t <= i)){
        cout <<  i << endl;
    }else {
        cout <<  j << endl;
    }

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i,k,n)  for(int i = (k);i < (n);++i)
#define REP(i,n)    FOR(i,0,n)
#define ALL(x)      begin(x),end(x)

using namespace std;
using vecint = vector<int>;
using ll = int64_t;

int main()
{
  int n,k;
  cin>>n>>k;
  vecint a(n);
  REP(i,n)cin>>a[i];
  int sum=0;
  REP(i,n) sum+=a[i];
  vector<int> divisors;
  for (int i = 1; i*i <= sum; ++i) {
    if ((sum%i) == 0) {
      divisors.push_back(i);
      if (i*i < sum) {
        divisors.push_back(sum/i);
      }
    }
  }
  sort(ALL(divisors));
  int mx = 1;
  for (int d : divisors) {
    int add = 0, sub = 0;
    vecint va, vs;
    REP(i,n) {
      int rem = a[i] % d;
      if (rem == 0) continue;
      if (rem < d-rem) {
        sub += rem;
        vs.push_back(rem);
      } else {
        add += d-rem;
        va.push_back(d-rem);
      }
    }
    sort(ALL(va));
    sort(ALL(vs));
    while (add > sub) {
      int a = va.back();
      va.pop_back();
      vs.push_back(d-a);
      add -= a;
      sub += d-a;
    }
    while (sub > add) {
      int s = vs.back();
      vs.pop_back();
      va.push_back(d-s);
      sub -= s;
      add += d-s;
    }
    if (sub <= k) mx = d;
  }
  cout<<mx<<endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef		vector<int>				 vi;
typedef 	vector<vi>				vii;
typedef		pair<int,int>			pii;
typedef		unsigned long long		ull;
typedef		long long				ll ;
#define MOD (int)(1e9+7)
#define INF (int)(1<<29) 
#define fori(i,a,b)		for(int i=a ; i <= b ; i++) 			
#define ford(i,a,b)  	for(int i=a ; i >= b ; i-- ) 
#define rep(i,n)   		for(int i=0; i < n ; i++ ) 
#define DEBUG(x)		cout << '>' << #x << ':' << x << endl;


int main()
{
	ios_base::sync_with_stdio(0);	
	int n ;
	cin >> n ;
	ll t[n] ;
	rep(i,n) 
	{
		cin >> t[i] ; 
	}
	ll res = 1 ;
	for(int i = 0 ; i < n ; ++i ) 
	{
		res *= t[i]/__gcd(res , t[i] ) ; 
	}
	cout << res << endl ; 
	return 0 ;
}



Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10**6)


def mod_inverse(n, mod=10**9+7):
    return pow(n, mod-2, mod)


def combination(n, k, mod=10**9+7):
    numer = denom = 1
    for i in range(k):
        numer = (numer * (n-i)) % mod
        denom = (denom * (i+1)) % mod
    return (numer * mod_inverse(denom, mod)) % mod


def factorial(n):
    if n == 0:
        return 1
    return n * factorial(n-1) % mod


mod = 10**9+7
N = int(input())
x = [0] + list(map(int, input().split()))
fact = factorial(N-1)

ans = 0
for k in range(2, N):
    ans = (ans + x[k] * (1 - mod_inverse(k)))

for k in range(1, N-1):
    ans = (ans - x[k] * (1 - mod_inverse(N-k))) % mod

ans = ans * fact % mod

ans = (ans + fact * sum((x[N] - x[k]) * mod_inverse(N-k) for k in range(1, N))) % mod

print(ans)


Measured memory_bytes: 88464
class SegmentTree:
    def __init__(self,siz,v = 0):
        self.n = 1
        self.v = v
        while self.n < siz: self.n *= 2
        self.node = [self.v]*(2*self.n-1)

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

    def update(self,i,x):
        i += self.n-1
        self.node[i] = x
        while i > 0:
            i = (i-1)//2
            self.node[i] = self.merge(self.node[i*2+1],self.node[i*2+2])
    
    def query(self,a,b):
        vl = vr = self.v
        a += self.n-1
        b += self.n-1
        while a < b:
            if a & 1 == 0: vl = self.merge(vl,self.node[a])
            if b & 1 == 0: vr = self.merge(vr,self.node[b-1])
            a //= 2
            b = (b-1)//2
        return self.merge(vl,vr)
    
n = int(input())
st = SegmentTree(n)
s = list(input())
def f(c): return 1<<(ord(c) - ord("a"))
for i in range(n): st.update(i,f(s[i]))
q = int(input())
for _ in range(q):
    typ,x,y = input().split()
    if typ == "1":
        i,c = int(x)-1,y
        if s[i] == c: continue
        st.update(i,f(c))
        s[i] = c
    else:
        l,r = int(x)-1,int(y)
        print(bin(st.query(l,r)).count("1"))

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

const double PI = 3.1415926535897932384626433;
int main()
{
    double a, b, x;
    cin >> a >> b >> x;
    if (a * a * b <= 2 * x)
    {
        // cout<<"More!";
        cout << fixed << setprecision(10)
             << atan(2.0 * (a * a * b - x) / (a * a * a)) / PI * 180;
    }
    else
    {
        // cout<<"Less";
        cout << fixed << setprecision(10)
             << atan( (a * b * b)/(2.0 * x) ) / PI * 180;
    }
}


Measured memory_bytes: 256
import java.io.*;
import java.math.*;

class Main{
  public static void main(String[] args)throws IOException{
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    BigDecimal radius = new BigDecimal(br.readLine());
    BigDecimal pi = new BigDecimal(Math.PI);

    BigDecimal area = radius.multiply(radius).multiply(pi);
    area = area.setScale(6,BigDecimal.ROUND_HALF_UP);

    BigDecimal two = new BigDecimal(2);
    BigDecimal circumference = radius.multiply(two).multiply(pi);
    circumference = circumference.setScale(6,BigDecimal.ROUND_HALF_UP);

    System.out.println(area + " " + circumference);
  }
}



Measured memory_bytes: 24552
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
using namespace std;
const int RANDOM1 = chrono::high_resolution_clock::now().time_since_epoch().count();
struct chash {
    int operator()(int x) const { return hash<int>{}(x ^ RANDOM1); }
};
#define ll long long
#define mod 1000000007
#define pb push_back
#define mp make_pair
#define deb(x) cout<<#x<<" : "<<x<<"\n";
#define debug(x,y) cout<<#x<<" : "<<x<<"\t"<<#y<<" : "<<y<<"\n";
#define ff first
#define ss second
#define ub upper_bound
#define lb lower_bound
#define all(a) (a).begin(),(a).end()
#define bs binary_search
#define sz size()
#define vi vector<int>
#define pii pair<int,int>
#define pll pair<ll,ll>
#define ld long double
#define clr fflush(stdout);
//#define clr cout.flush();
#define N 100001
#define fpr(i,a,b) for(int i=a;i<b;i++)
#define fdr(i,a,b) for(int i=a;i>b;i--)
#define repp(i,a,b,d) for(int i=a;i<b;i+=d)
#define repd(i,a,b,d) for(int i=a;i>b;i-=d)
#define LLMIN LLONG_MIN
#define LLMAX LLONG_MAX
#define AKASH_PATEL ios_base::sync_with_stdio(false);
#define SVNIT_SURAT cin.tie(NULL);cout.tie(NULL);
#define mset(x,a) memset(x,a,sizeof(x));
#define nl cout<<'\n';
#define print(c) cout<<c<<'\n';
#define setp(n) cout << fixed << setprecision(n)
#define take_arr(a,n) fpr(i,0,n) cin>>a[i];
#define print_arr(a,n) for(int i=0;i<n;i++) {cout<<a[i]<<" ";} cout<<'\n';
#define take_mat(mat,n,m) fpr(i,0,n) fpr(j,0,m) cin>>mat[i][j];
#define set_mat(mat,n,m,k) fpr(i,0,n) fpr(j,0,m) mat[i][j]=k;
#define print_mat(dist,n,m) for(int i=0;i<n;i++){for(int j=0;j<m;j++){cout<<dist[i][j]<<" ";}cout<<'\n';}
template< class T > bool inside(T a, T b, T c) { return a<=b && b<=c; }
int main()
{
    AKASH_PATEL;
    SVNIT_SURAT;
    ll n;
    cin>>n;
    ll c1=n/500;
    ll rem=n%500;
    rem=rem/5;
    cout<<c1*1000+rem*5;
    return 0;
}





Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner scan = new Scanner(System.in);
        
        int n = scan.nextInt();
        int k = scan.nextInt();
        int ans = 1;
        
        while(n>0)
        {
            ans = Math.min(ans+k,2*ans);
            n--;
        }
        System.out.println(ans);
    }
}

Measured memory_bytes: 22740
#include <bits/stdc++.h> 
using namespace std;
vector<int>vi[100005];
const int mod = 1e9 + 7 ;
bool vis[100005];
long long dp[100005][2]; 
void dfs(int node){
    vis[node] = 1;
    long long  ans1 = 1, ans2 = 1;
    for(auto i : vi[node]){
        if(!vis[i]){
            dfs(i);

            ans1 = ((ans1 * dp[i][1]) % mod + (ans1 * dp[i][0]) % mod) % mod;
            ans2 = (ans2 * dp[i][1]) % mod;
        }
    }
    dp[node][1] = ans1, dp[node][0] = ans2;
}
int main(){
    int n;
    cin>>n;
    for(int i = 0; i < n- 1 ; i++){
        int x, y;
        cin>>x>>y;
        vi[x].push_back(y);
        vi[y].push_back(x);
    }
    dfs(1);
    cout<<(dp[1][0] + dp[1][1]) % mod;
	return 0;
}  


Measured memory_bytes: 14336
n = gets.chomp.to_i

trump = {}
trump["S"] = [1,2,3,4,5,6,7,8,9,10,11,12,13]
trump["H"] = [1,2,3,4,5,6,7,8,9,10,11,12,13]
trump["C"] = [1,2,3,4,5,6,7,8,9,10,11,12,13]
trump["D"] = [1,2,3,4,5,6,7,8,9,10,11,12,13]

cards = {}
cards["S"] = []
cards["H"] = []
cards["C"] = []
cards["D"] = []
i = 0
while true do
   if i == n
      break
   end
   egara, temp_num = gets.split
   num = temp_num.to_i
   cards["#{egara}"] << num
   i += 1
end

empty_s = trump["S"] - cards["S"]
empty_s.each do |i|
   puts "S #{i}"
end

empty_h = trump["H"] - cards["H"]
empty_h.each do |i|
   puts "H #{i}"
end

empty_c = trump["C"] - cards["C"]
empty_c.each do |i|
   puts "C #{i}"
end

empty_d = trump["D"] - cards["D"]
empty_d.each do |i|
   puts "D #{i}"
end

Measured memory_bytes: 8720
#include <algorithm>
#include <cassert>
#include <climits>
#include <cstdio>
#include <deque>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <unordered_map>
#include <utility>
#include <vector>

using namespace std;

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;
}

const int INF = 1e9;
const long long LINF = 1e18;

int main() {
    int S, W;
    cin >> S >> W;

    if (W >= S) {
        cout << "unsafe" << endl;
    } else {
        cout << "safe" << endl;
    }

    return 0;
}


Measured memory_bytes: 3128
#include <cstdio>
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <map>
#include <set>

#define MIN_INT -2147483648
#define MAX_INT 2147483647
#define MIN_LONG -9223372036854775808L
#define MAX_LONG 9223372036854775807L
#define PI 3.141592653589793238462643383279502884L

#define long long long int

using std::vector;
using std::map;
using std::set;
using std::string;
using std::pair;
using std::cin;
using std::cout;
using std::cerr;

// @author: pashka

int main() {
#ifdef LOCAL
	freopen("input.txt", "r", stdin);
#endif
    std::ios::sync_with_stdio(false);

    int n, k;
    cin >> n >> k;

    vector<int> x(n);
    vector<int> y(n);

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

    long res = MAX_LONG;
    for (int l = 0; l < n; l++) {
    	for (int r = 0; r < n; r++) {
    		if (x[r] <= x[l]) continue;
    		for (int t = 0; t < n; t++) {
    			for (int b = 0; b < n; b++) {
    				if (y[b] <= y[t]) continue;
    				int c = 0;
    				for (int i = 0; i < n; i++) {
    					if (x[i] >= x[l] && x[i] <= x[r] && y[i] >= y[t] && y[i] <= y[b]) {
    						c++;
    					}
    				}
    				if (c >= k) {
    					long s = 1l * (x[r] - x[l]) * (y[b] - y[t]);
    					if (s < res) res = s;
    				}
    			}
    		}

    	}
    }

    cout << res;




    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define REP(i,n) for((i)=0;(i)<(int)(n);(i)++)
typedef long long ll;
typedef pair<ll, ll> P;
const int MOD = 1000000007;



int main(){
    int a[3], b[3], c[3][3];
    for (int i = 0; i < 3; i++){
        for (int j = 0; j < 3; j++){
            cin >> c[i][j];
        }
    }

    a[0] = 0;
    for (int i = 0; i < 3; i++){
        b[i] = c[0][i] - a[0];
    }
    for (int i = 0; i < 3; i++){
        a[i] = c[i][0] - b[0];
    }

    for (int i = 0; i < 3; i++){
        for (int j = 0; j < 3; j++){
            if (c[i][j] != a[i] + b[j]){
                cout << "No" << endl;
                return 0;
            }
        }
    }

    cout << "Yes" << endl;
    
    return 0;
}

Measured memory_bytes: 384
#include<iostream>
#include<algorithm>
#include<vector>
#include<stdio.h>
#include<complex>
#include<map>
using namespace std;

int gcd(int x, int y){
  if(x % y == 0) return y;
  return gcd(y, x%y);
}

int main(){
  int x,y;
  cin >> x >> y;
  int ans = gcd(x,y);
  cout << ans << endl;
  return 0;
}



Measured memory_bytes: 3084
import sys
read = sys.stdin.read

M = int(input())
dc = map(int, read().split())
dig_sum = 0
dig = 0
for d, c in zip(*[iter(dc)] * 2):
    dig_sum += d * c
    dig += c

answer = (dig_sum - 1) // 9 + dig - 1
print(answer)

Measured memory_bytes: 21316
#include<bits/stdc++.h>
using namespace std;
constexpr int64_t mod=1e9+7;

int main()
{
  int64_t h,n;
  cin>>h>>n;
  vector<int> a(n);
  for(auto&& e: a) 
  {
    cin>>e;
  }
  int64_t sum=accumulate(a.begin(), a.end(),(int64_t)0);
  cout<<(sum>=h? "Yes":"No");
}

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

#define FAST ios_base::sync_with_stdio(false); cin.tie(0);
#define pb push_back
#define eb emplace_back
#define ins insert
#define f first
#define s second
#define cbr cerr << "hi\n"
#define mmst(x, v) memset((x), v, sizeof ((x)))
#define siz(x) ll(x.size())
#define all(x) (x).begin(), (x).end()
#define lbd(x,y) (lower_bound(all(x),y)-x.begin())
#define ubd(x,y) (upper_bound(all(x),y)-x.begin())
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());    //can be used by calling rng() or shuffle(A, A+n, rng)
inline long long rand(long long x, long long y) { return (rng() % (y+1-x)) + x; } //inclusivesss
string inline to_string(char c) {string s(1,c);return s;} template<typename T> inline T gcd(T a,T b){ return a==0?llabs(b):gcd(b%a,a); }

typedef long long ll; 
typedef long double ld;
#define FOR(i,s,e) for(ll i=s;i<=ll(e);++i)
#define DEC(i,s,e) for(ll i=s;i>=ll(e);--i)
typedef pair<ll,ll>pi; typedef pair<ll,pi>spi; typedef pair<pi,pi>dpi;

#define LLINF ((long long)1e18)
#define INF int(1e9+1e6)
#define MAXN (5006)
ll n,A[MAXN],dp[MAXN][MAXN],sz[MAXN];// if 0 then max, 1 then min
bitset<MAXN> dp2[MAXN];
vector<int>v[MAXN];
void dfs(ll x,ll p){
	sz[x]=1;
	dp[x][0]=A[x];
	for(auto i:v[x]) if(i^p) dfs(i,x), sz[x]+=sz[i];
	FOR(k,1,sz[x]) dp[x][k]=LLINF;
	ll cur = 1;
	if(A[x]>0)dp2[x][0]=1;
	for(auto i:v[x]) if(i^p) {
		DEC(j,cur+sz[i],0){
			if(dp[x][j]<LLINF) dp[x][j] += dp[i][0];
			dp2[x][j] = dp2[x][j] & dp2[i][0];
			FOR(k,max(j-cur,1ll),min(j,sz[i])){
				dp[x][j]=min(dp[x][j],dp[x][j-k]+dp[i][k]);
				if(dp2[i][k-1]) dp[x][j]=min(dp[x][j],dp[x][j-k]);
				dp2[x][j]=dp2[x][j]|(dp2[x][j-k]&dp2[i][k]);
				if(dp[i][k-1] < 0) dp2[x][j]=dp2[x][j]|dp2[x][j-k];
			}
		}
		cur += sz[i];
	}
}
int main(){
	FAST
	cin>>n;
	FOR(i,1,n)cin>>A[i];
	FOR(i,2,n){
		ll a,b;cin>>a>>b;
		v[a].eb(b),v[b].eb(a);
	}
	dfs(1,1);
	ll ans = n-1;
	FOR(k,0,n-1) if(dp[1][k] < 0) ans = min(ans, k);
	FOR(k,0,n-1) if(dp2[1][k]) ans = min(ans, k);
	cout<<ans<<'\n';
}



Measured memory_bytes: 200064
<?php
list($n) = explode(" ", trim(fgets(STDIN)));

$bit=1<<10;

$f=[];
$p=[];
for($i=0;$i<$n;$i++){
  $a = array_map('intval', explode(" ", trim(fgets(STDIN))));
  $x=0;
  for($j=0;$j<count($a);$j++){
    if($a[$j]==1){
      $x+=1<<$j;
    }
  }
  $f[]=$x;
}

for($i=0;$i<$n;$i++){
  $p[] = array_map('intval', explode(" ", trim(fgets(STDIN))));
}

$ans=PHP_INT_MIN;

for($i=1;$i<$bit;$i++){
  $profit=0;
  $cnt=array_fill(0, $n+1, 0);
  for($k=0;$k<10;$k++){
//    echo ($i >> $k).PHP_EOL;
    if(($i >> $k) & 1 == 1){
//      echo $i." ";
      for($j=0;$j<$n;$j++){
        //echo $f[$j]." ".$k.":";
        if(($f[$j] >> $k) & 1 == 1){
          $cnt[$j]++;
        }
      }
    }
  }
  for($j=0;$j<$n;$j++){
//    echo $cnt[$j]." ";
    $profit+=$p[$j][$cnt[$j]];
  }
//  echo $profit." ";
  $ans=max($ans,$profit);
}

echo $ans;

Measured memory_bytes: 16192
n = int(input())
s = input()
a = 0
ans = 0
for i in range(n):
  if s[i] == '.':
    ans += 1
a = ans
for i in range(n):
  if s[i] == '.':
    a -= 1
  else:
    a += 1
  if a < ans:
    ans = a
print(ans)

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

vector<long long> w(101), v(101); 
int n,m;
long long tb[101][100001];

int main(){
	// ios_base::sync_with_stdio(false);
	// cin.tie(NULL);
	
	cin >> n >> m;
	
	for(int i = 1; i <= n; ++i){
		cin >> w[i] >> v[i];
	}
	
	for(int i = 0; i <= n; ++i){
		tb[i][0] = 0;
		for(int j = 1; j <= 100000; ++j)
			tb[i][j] = 10000000000000000LL;
	}
	
	for(int i = 1; i <= n; ++i){
		for(int j = 0; j <= 100000; ++j){
			if(j >= v[i]){
				tb[i][j] = min(tb[i-1][j-v[i]] + w[i], tb[i-1][j]);
			}else{
				tb[i][j] = tb[i-1][j];
			}
			//cout << tb[i][j] << " ";
		}//cout << endl;
	}
	
	int max = 0;
	for(int j = 0; j <= 100000; ++j){
		if(tb[n][j] <= m)
			max = j;	
	}
	
	cout << max << endl;
	
	return 0;
}

Measured memory_bytes: 79104
n, x, y = map(int, input().split())

ans =  [0] * (n-1)

for i in range(1, n):
    for j in range(i+1, n+1):
        ans[min(j-i, abs(y-j)+abs(x-i)+1, abs(y-i)+abs(j-x)+1)-1] += 1

print(*ans, sep='\n')



Measured memory_bytes: 3444
import java.util.Scanner;

public class Main{
    public static void main(String[] args){
	Scanner sc = new Scanner(System.in);
	int x=0,y=0,count=0;

	while(sc.hasNext()){
	    count = 0;

	    x = sc.nextInt();
	    y = sc.nextInt();
	    if(x == 0 && y == 0) break;

	    int t;
	    if(x<y){
		t = x;
		x = y;
		y = t;
	    } 

	    while(y!=0){
		x = x%y;
		t = y;
		y = x;
		x = t;
		count++;
	    }

	    System.out.println(x +" "+ count);
	}
    }
}

Measured memory_bytes: 24636
from statistics import median

n = int(input())
a_list = [0] * n
b_list = [0] * n

for i in range(n):
     a, b = map(int, input().split())
     a_list[i] = a
     b_list[i] = b
    
min_median = median(a_list)
max_median = median(b_list)

median_range = max_median - min_median

if n%2 == 0:
    print(int(median_range/0.5 + 1))
else:
    print(int(median_range/1 + 1))


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

// 定義
typedef long long         ll;
typedef pair<ll, ll>      P;
#define ALL(x)            (x).begin(),(x).end()
#define REP(i, n)         for(ll i = 0 ; i < (ll)n ; ++i)
#define REPN(i, m, n)     for(ll i = m ; i < (ll)n ; ++i)
#define REVREP(i, n)      for(ll i = n - 1; i >= 0 ; i--)
#define VL                vector<ll>
#define VVL               vector<vector<ll>>
#define VVVL              vector<vector<vector<ll>>>
#define VC                vector<char>
#define VVC               vector<vector<char>>
#define INF               (ll)2e9
#define INF_LL            1LL<<60
#define MOD               998244353

ll Ceil(ll val, ll div)   { return (val + div - 1) / div; }
ll CeilN(ll val, ll div)  { return Ceil(val, div) * div; }
ll FloorN(ll x, ll n)     { return (x - x % n); }
bool IsOdd(ll x)          { return ((x & 1) == 1); }
bool IsEven(ll x)         { return ((x & 1) == 0); }
template<class T> bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

void Solve()
{
	ll N, K;
	cin >> N >> K;
	VL A(N);
	REP(i, N) cin >> A[i];

	VL ansNow = A;
	REP(i, K) {
		VL valSum(N + 1, 0);
		REP(i, N) {
			ll idxL = max((ll)0, i - ansNow[i]);
			ll idxH = min((ll)N, i + ansNow[i] + 1);
			valSum[idxL]++;
			valSum[idxH]--;
		}

		ll nowOne = 0;
		VL ansNext(N, 0);
		REP(i, N) {
			nowOne += valSum[i];
			ansNext[i] = nowOne;
		}

		if (ansNext == ansNow) {
			break;
		}
		swap(ansNext, ansNow);
	}

	for (auto one : ansNow) {
		cout << one << " ";
	}
}

// メイン
int main()
{
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	Solve();
	return 0;
}


Measured memory_bytes: 9512
#include <bits/stdc++.h>
using namespace std;
const int INF = 1e9 + 5;

int main() {

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

	ios_base::sync_with_stdio(false);
	cin.tie(NULL);

	//rotation of dp states
	long long n, W;
	cin >> n >> W;
	vector<long long> wt(n), val(n);

	for (int i = 0; i < n; i++)
		cin >> wt[i] >> val[i];
	int val_sum = 0;
	for (int v : val)
		val_sum += v;
	vector<long long> dp(val_sum + 5, INF);

	dp[0] = 0;
	for (int i = 0; i < n; i++)
		for (long long j = val_sum; j >= val[i]; j--)
			dp[j] = min(dp[j], wt[i] + dp[j - val[i]]);

	long long ans = 0;
	for (long long i = 0; i <= val_sum; i++)
		if (dp[i] <= W)
			ans = max(ans, i);

	cout << ans << endl;
}

Measured memory_bytes: 3984
#include <iostream>
#include <vector>
using namespace std;
// 簡潔なスタイル
int N; // 少しだけ多めに取る
int min111(vector<long long>A) {
    long long ans = A.at(0);
    for(int i=0;i<A.size();i++) {
        if (ans > A.at(i)){
            ans = A.at(i);
        }
    }
return ans;
}
long long max111(vector<long long> A) {
    long long ans = A.at(0);
    for(int i=0;i<A.size();i++) {
        if (ans < A.at(i)){
            ans = A.at(i);
        }
    }
return ans;
}
long long sum111(vector<long long> A) {
    long long sum=0;
    for(int i=0;i<A.size();i++) {
        sum += A.at(i);
    }
return sum;
}
int main() {
int N;    
cin >> N;
vector<long long> A(N);
for (int i=0; i<N; ++i){
cin >> A.at(i);
}
cout <<min111(A)<<' '<<max111(A)<<' '<<sum111(A)<<endl;

}


Measured memory_bytes: 3240
#include<iostream>
#include<stdio.h>
#include<vector>
#include<algorithm>
#include<set>
#include<string>
#include<map>
#include<string.h>
#include<complex>
#include<math.h>
#include<queue>
#include <functional>
#include<time.h>
#include <stack>
#include<iomanip>
using namespace std;
#define rep(i,a,n) for(llint i=(a);i<(n);i++)
#define ll long long
#define llint long long int
#define reverse(v)  reverse(v.begin(), v.end());
#define Yes(ans) if(ans)cout<<"Yes"<<endl; else cout<<"No"<<endl;
#define YES(ans) if(ans)cout<<"YES"<<endl; else cout<<"NO"<<endl;
#define hei(a) vector<a>
#define whei(a) vector<vector<a>>
#define UF  UnionFind 
#define Pint pair<int,int>
#define Pll pair<llint,llint>
#define keta(a)  fixed << setprecision(a)
const ll mod = 1000000007;
//辞書順はnext_permutation( begin( v ), end( v ) );やで！
const ll INF = 1000000000;

class UnionFind {
public:
	//親の番号を格納する
	vector<int> par;

	//最初は全てが根であるとして初期化
	UnionFind(int N) {
		par.resize(N);
		for (int i = 0; i < N; i++)par[i] = i;
	}

	//Aがどのグループに属しているか調べる
	int root(int A) {
		if (par[A] == A) return A;
		return par[A] = root(par[A]);
	}


	//AとBをくっ付ける
	bool unite(int A, int B) {
		//AとBを直接つなぐのではなく、root(A)にroot(B)をくっつける
		A = root(A);
		B = root(B);
		if (A == B) {
			//すでにくっついてるからくっ付けない
			return false;
		}

		//Bの親をAに変更する
		par[B] = A;

		return true;
	}
	bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
		int rx = root(x);
		int ry = root(y);
		return rx == ry;
	}
};

int main() {
	int n, m;
	cin >> n >> m;
	UnionFind tree(n);
	rep(i, 0, m) {
		int a, b;
		cin >> a >> b;
		a--;
		b--;
		tree.unite(a, b);
	}
	map<int, int> s;
	int ans = -1;
	rep(i, 0, n) {
		int z = tree.root(i);
		if (!s[z]) {
			ans++;
			s[z] = 1;
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 7584
using System;
using System.Collections.Generic;
using static System.Console;

class Program {
    static void Main() {
        var q = NextInt();
        var h = NextInt();
        var s = NextInt();
        var d = NextInt();
        var n = (long)NextInt();

        foreach (var v in new int[] { 4 * q, 2 * h }) {
            s = Math.Min(s, v);
        }
        WriteLine(s * (n % 2) + Math.Min(2 * s, d) * (n / 2));
    }

    static int NextInt() {
        return int.Parse(NextString());
    }

    static string NextString() {
        var result = new List<char>();
        while (true) {
            int next = Read();
            if (next < 0)
                break;
            var nextChar = (char)next;
            if (!char.IsWhiteSpace(nextChar))
                result.Add(nextChar);
            else if (nextChar != '\r')
                break;
        }
        return string.Join("", result);
    }
}

Measured memory_bytes: 13268
#include<bits/stdc++.h>
using namespace std;
#define ALL(x) x.begin(),x.end()
#define rep(i,n) for(int i=0;i<n;i++)
#define debug(v) cout<<#v<<":";for(auto x:v){cout<<x<<' ';}cout<<endl; 
#define INF 1000000000
#define mod 1000000007
typedef long long ll;
const ll LINF = 1001002003004005006ll;
int dx[]={1,0,-1,0};
int dy[]={0,1,0,-1};
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
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; }

signed main(){
    cin.tie(0);
    ios::sync_with_stdio(0);
    ll n,m;cin>>n>>m;
    vector<ll> b(n,1);
    vector<bool> red(n,false);
    red[0]=true;
    while(m--){
        ll x,y;
        cin>>x>>y;x--,y--;
        if(red[x]){
            if(b[x]==1){
                red[x]=false;
                red[y]=true;
            }
            else{
                red[y]=true;
            }
        }
        b[x]--;b[y]++;
    }
    ll ans=0;
    rep(i,n) ans+=red[i];
    cout<<ans<<endl;
    return 0;
}


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

int main()
{
	
	int i, count=0, x, n, tmp=0;
	int p[100];
  
	scanf("%d %d", &n, &x);
  	
  	for (i=0;i<n;i++){
    	scanf("%d", &p[i]);
    }
  
  	count++;
  	for(i=0;i<n;i++){
      	tmp+=p[i];
    	if(tmp>x) break;
      	count++;
    }
  
  	printf("%d\n", count);
      
  	return 0;
}

Measured memory_bytes: 128
import heapq

n, m = list(map(int, input().split()))
nums = [-x for x in list(map(int, input().split()))]

heapq.heapify(nums)

for _ in range(m):
	x = heapq.heappop(nums)
	heapq.heappush(nums, ((-1 * x) // 2) * -1)

print(-sum(nums))


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

int main() {
  int N;
  cin >> N;
  int l,r,sum;
  sum = 0;
  for (int i = 0; i < N; i++){
    cin >> l >> r;
    sum += r - l + 1;
  } 
  cout << sum << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<math.h>
using namespace std;

int main() {
  long n;
  cin >> n;
  long sum = 0;

  for (int i = 1; i <= n; i++) {
    if ((i % 3 != 0) && (i % 5 != 0)) sum += i; 
  }

  cout << sum << endl;
}


Measured memory_bytes: 3160
x, y = map(int, input().split())
print('Brown' if abs(x - y) <= 1 else 'Alice')

# 総和<=1なら後手勝利（ベース）
# 総和>1かつ差<=1なら、どうしても差>1で相手に手を渡すことになるが、
#   総和>1が確定するので、後手の負けはない
# 総和>1かつ差>1なら、差<=1にできるが、
#   このとき、総和<=1になれば、後手に負けを押し付けられるので、先手勝利

# 総和>1かつ初手で差>1なら、相手に差<=1を押し付けられるので、自分の負けはなく、
# 差<=1を押し付け続けながら、総和<=1にできるのを待てばよいので、先手必勝

# 総和>1かつ初手で差<=1なら、後手は差>1を持てるので、後手必勝
# また、総和<=1のとき、後手必勝だが、差<=1を満たす

# 初手の差で決まる

Measured memory_bytes: 2940
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace _0240
{
    class Program
    {
        static void Main(string[] args)
        {
            while (true)
            {
                double max = double.MinValue;
                int maxnum = 0;
                int n = int.Parse(Console.ReadLine());
                if (n == 0) { break; }
                int y = int.Parse(Console.ReadLine());
                for(int i = 0; i < n; i++)
                {
                    int[] f = Console.ReadLine().Split().Select(int.Parse).ToArray();
                    double ans = 100;
                    if (f[2] == 1)
                    {
                        ans *= 1 + y * f[1]/(double)100;
                    }
                    else
                    {
                        ans *= Math.Pow(1 +f[1]/(double)100,y);
                    }
                    if (ans > max) { max = ans;maxnum = f[0];
                            }
                }Console.WriteLine(maxnum);

            }
        }
    }
}

Measured memory_bytes: 10064
r,g,b,n = gets.split.map &:to_i

ans = 0
0.upto(n/r) do |i|
  0.upto(n/g) do |j|
    k = n - i * r - j * g
    if k >= 0 && k % b == 0
      ans += 1
    end
  end
end

puts ans

Measured memory_bytes: 3836
/*
 * Problem Description: Linear Search
 * Category:
 * Author: Khan
 * Date: 13th October, 2017
 */

#include <cstdio>
#include <algorithm>

int main(int argc, char const *argv[])
{
    //freopen("sample.txt", "r", stdin);
    int i, n, A[1000000], q, key, sum = 0;
    scanf("%d", &n);
    for (int i = 0; i < n; ++i)
    {
        scanf("%d", &A[i]);
    }
    scanf("%d", &q);
    for (int i = 0; i < q; ++i)
    {
        scanf("%d", &key);
        if(std::binary_search(A, A + n, key))
            sum++;
    }
    printf("%d\n", sum);
    return 0;
}

Measured memory_bytes: 3048
#include <iostream>

using namespace std;

int main() {
    int a, b;
    cin >> a >> b;

    int m = a + b;
    int n = a - b;
    int o = a * b;

    int max = m;
    if (max < n) {
        max = n;
    }
    if (max < o) {
        max = o;
    }

    cout << max << '\n';
    return 0;
}

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

#define N 8

int A[N][N], row[N], col[N], dpos[2 * N - 1], deng[2 * N - 1];

void put_queen();
void print();

int main(){
  int i, j, n, a, b;

  for(i = 0; i < N; i++){
    for(j = 0; j < N; j++){
      A[i][j] = -1;
    }
    row[i] = -1;
    col[i] = -1;
  }

  for(i = 0; i < 2 * N - 1; i++){
    dpos[i] = -1;
    deng[i] = -1;
  }

  scanf("%d", &n);

  for(i = 0; i < n; i++){
    scanf("%d%d", &a, &b);
    A[a][b] = 1;
  }
  
  put_queen(0);

  return 0;
}

void put_queen(int x){
  int i, j;

  if(x == N){
    print();
    return;
  }

  for(i = 0; i < N; i++){
    if(col[i] == 1 || dpos[x + i] == 1 || deng[x - i + N - 1] == 1)
     continue;

    row[x] = i;
    col[i] = 1;
    dpos[x + i] = 1;
    deng[x - i + N - 1] = 1;

    put_queen(x + 1);

    row[x] = -1;
    col[i] = -1;
    dpos[x + i] = -1;
    deng[x - i + N - 1] = -1;

  }
}

void print(){
  int i,j;

  for(i = 0; i < N; i++)
    for(j = 0; j < N; j++){
      if(A[i][j] == 1){
        if(row[i] != j)
          return;
      }
    }

  for(i = 0; i < N; i++){
    for(j = 0; j < N; j++){
      if(row[i] == j)
       printf("Q");
      else
        printf(".");
    }
    printf("\n");
  }
}


Measured memory_bytes: 2148
import std.stdio;
import std.string;
import std.array;

string[9] s;

void main(){
	int n;
	readf("%d\n", &n);
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < 9; j++) {
			s[j] = replace(chomp(readln()), " ", "");
		}
		// solve
		for (int y = 0; y < 9; y++) {
			for (int x = 0; x < 9; x++) {
				write(check(x,y), s[y][x]);
			}
			writeln();
		}
		if(i+1 != n) writeln();
	}
}

char check(int x, int y){
	int bx = x/3*3;
	int by = y/3*3;
	for (int i = 0; i < 9; i++) {
		if (y != i && s[y][x] == s[i][x]) return '*';
		if (x != i && s[y][x] == s[y][i]) return '*';
		if (x != bx+i%3 && y != by+i+3 && s[y][x] == s[by+i/3][bx+i%3]) return '*';
	}
	return ' ';
}

Measured memory_bytes: 992
#include <stdio.h>
int main(){
	int n,x,m,i,j;
	int score[101] = {0},tar[101],yosou[101][101];
	scanf("%d%d",&n,&m);
	for(i = 1;i <= m;i++){
		scanf("%d",&tar[i]);
	}
	for(i = 1;i <= m;i++){
		for(j = 1;j <= n;j++){
			scanf("%d",&yosou[i][j]);
		}
	}
	for(i = 1;i <= m;i++){
		for(j = 1;j <= n;j++){
			if( yosou[i][j] == tar[i]){
				score[j]++;
			}else {
				score[tar[i]]++;
			}
		}
	}
	for(i = 1;i <= n;i++){
		printf("%d\n",score[i]);
	}
	return 0;
}

Measured memory_bytes: 636
s = input()

a = int(s[0])
b = int(s[1])
c = int(s[2])
d = int(s[3])

one = -1
flg = False

for i in range(2):
	for j in range(2):
		for k in range(2):
			if a + b*one**i + c*one**j + d*one**k == 7:
				flg = True
				break
		if flg:
			break
	if flg:
		break
                
if i == 0 :
	i_flg = "+"
else:
	i_flg = "-"

if j == 0 :
	j_flg = "+"
else:
	j_flg = "-"

if k == 0 :
	k_flg = "+"
else:
	k_flg = "-"

print(a,i_flg,b,j_flg,c,k_flg,d,"=7",sep='')

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

using namespace std;

// Queue キューの実装
// 配列を%剰余でリングバッファーとして使う。
// enqueue,dequeueともにO(1)で処理できる。

const int MAX = 100000;

typedef struct Process {
    string name;
    int time;
} Process;

class Queue
{
public:
    Queue() : head(0), tail(0), Q()
    {
    }
    void enqueue(Process x)
    {
        if (isFull())
        {
            cerr << "overflow" << endl;
            return;
        }
        Q[tail] = x;
        // MAXが100の場合、
        // tail=99なら、Q[99]で最後の要素を指している。そのためQ[99+1]は、エラーとなる。
        // エラーにしないため、99+1がMAXなら、tailを0にする。
        if (tail + 1 == MAX)
            tail = 0;
        else
            tail++;
    }
    // 先頭からデータを取り出す。
    Process dequeue()
    {
        if (isEmpty())
        {
            cerr << "underflow" << endl;
            Process x;
            return x;
        }
        Process x = Q[head];
        if (head + 1 == MAX)
            head = 0;
        else
            head++;
        return x;
    }
    bool isEmpty()
    {
        return head == tail;
    }
    bool isFull()
    {
        return head == (tail + 1) % MAX;
    }


private:
    Process Q[MAX];
    int head;
    // 最後の要素の１つ後ろを指す。新しい要素が追加される場所
    int tail;
};


int main(int argc, char *argv[])
{
    /* test
    Queue queue;
    Process p1;
    p1.name = "hello1";
    p1.time = 10;
    queue.enqueue(p1);
    Process p2;
    p2.name = "hello2";
    p2.time = 22;
    queue.enqueue(p2);
    cout << queue.dequeue().name << endl;
    cout << queue.dequeue().name << endl;
    */

    Queue queue;
    // 行数、クオンタム
    int n, q;
    cin >> n;
    cin >> q;
    // データ読み込み
    string name;
    int time;
    while (cin >> name >> time) {
        Process x = { name, time };
        queue.enqueue(x);
    }

    int t1 = 0;
    while (!queue.isEmpty()) {
        Process x = queue.dequeue();
        //t1 += q;
        //x.time -= q;

        int m = std::min(x.time, q);
        t1 += m;
        x.time -= m;

        if (x.time > 0)
            queue.enqueue(x);
        else
            cout << x.name << " " << t1 << endl;
    }

    return 0;
}


Measured memory_bytes: 6940
/// kAAzuki Hoshino
/*
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")
*/
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define int long long
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>ordered_set;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int,int> pi;
typedef vector<pi> vpi;
#define inf 1000000000
#define mod 1000000007
#define rep(i,a,b) for (int i = a; i <= b; i++)
#define rep1(i, a, b) for(int i =a; i >=b; i--)
#define dmp(x) cerr<<"line "<<__LINE__<<" "<<#x<<":"<<x<<endl
#define fs first
#define sc second
#define pb push_back
#define all(c) (c).begin(),(c).end()
#define mt make_tuple

string s;
int ans = 0,l,r;
stack<int> st;

signed main(){
ios::sync_with_stdio(0);
cin.tie(0);
//freopen("input.txt", "r", stdin);
//freopen("output.txt", "w", stdout);


cin >> s;
for(auto t:s){
    if(t=='1'){
        r++;
        if(l){
            r--;
            l--;
            ans+=2;
        }
    }
    else {
        l++;
        if(r){
            r--;
            l--;
            ans+=2;
        }
    }
}
cout << ans << endl;
/*
for(auto t:s){
    //cout << t << endl;
    if(t=='1' && !st.empty() ){
        st.pop();
        ans+=2;
    }
    else {
        st.push(t);
    }
}
int res = ans;
ans = 0;
while(!st.empty())st.pop();
for(auto t:s){
    //cout << t << endl;
    if(t=='0' && !st.empty() ){
        st.pop();
        ans+=2;
    }
    else {
        st.push(t);
    }
}
cout << max(ans,res)  << endl;
*/
return 0;}
///....


Measured memory_bytes: 512