akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <boost/range/irange.hpp>

using namespace std;
using namespace boost;

main() {
    int64_t n;
    cin >> n;

    if (n == 100000) {
        n = 99999;
    }
    if (n >= 10000) {
        cout << n - 9999 + 999 - 99 + 9 << endl;
        return 0;
    }
    if (n >= 1000) {
        n = 999;
    }
    if (n >= 100) {
        cout << n - 99 + 9 << endl;
        return 0;
    }
    if (n >= 10) {
        n = 9;
    }
    cout << n << endl;
    return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LINF = 1e18;

/*
<url:https://arc062.contest.atcoder.jp/tasks/arc062_b>
問題文============================================================
 シカのAtCoDeerくんは友達のTopCoDeerくんとあるゲームをして対戦しています。
 このゲームは N ターンからなります。各ターンではそれぞれのプレイヤーはじゃんけんのグーかパーを出します。
 ただし、各プレイヤーは次の条件を満たす必要があります。
 
 (※) 各ターンの後で、(今までにパーを出した回数)≦(今までにグーを出した回数)　を満たす
 
 このゲームでの各プレイヤーの得点は、(勝ったターンの数) − (負けたターンの数) です。
 AtCoDeerくんは特殊能力を持っているので、
 ゲームが始まる前にTopCoDeerくんの出す N ターンの手を全て知ることが出来ました。
 AtCoDeerくんの各ターンでの手を決めて、AtCoDeerくんの得点を最大化してください。
 TopCoDeerくんの出す手の情報は文字列 s で与えられます。
 s の i(1≦i≦N) 文字目が gのときは i ターン目でTopCoDeerくんがグーを出すことを、
 pのときはパーを出すことを表します。
=================================================================

解説=============================================================

================================================================
*/
int main(void) {
	cin.tie(0); ios::sync_with_stdio(false);
    string s; cin >> s;
    int ans = 0;
    for(int i = 0; i < (int)s.length();i++){
        if(i%2 == 0){
            if(s[i] == 'p') ans--;
        }else{
            if(s[i] == 'g') ans++;
        }
    }
    cout << ans << endl;
	return 0;
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
#define rep(i,x,y) for(int i=x;i<y;i++)
#define print(A,x,n) rep(i,0,n){cout<<(i ? " ":"")<<A[i]x;}cout<<endl;
#define pprint(A,y,m,n) rep(j,0,m){print(A[j],y,n);}
const long mod=1e9+7;
const int size=1e4;
const long inf=1e18;
int main(){
	int N,R;cin>>N>>R;
	if(N>=10){
		cout<<R<<endl;
	}else{
		cout<<R+100*(10-N)<<endl;
	}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fastio ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define ll long long
#define int ll
#define float double
#define pb push_back
using namespace std;
signed main()
{
    fastio;
    int n;
    cin>>n;
    float d;
    cin>>d;
    int sum=0;
    for(int i=0;i<n;i++)
    {
        int x,y;
        cin>>x>>y;
        float dist=sqrt(pow(x,2)+pow(y,2));
        if(dist<=d)
        sum++;
    }      
    cout<<sum;
           
return 0;
}

Measured memory_bytes: 3784
#!/usr/bin/env python3
from queue import Queue

def II(): return int(input())
def MII(): return map(int, input().split())
def LII(): return list(map(int, input().split()))


def main():
    H, W = MII()
    S = [input() for _ in range(H)]
    dp = [[10**9] * W for _ in range(H)]

    dp[0][0] = (S[0][0] == '#') + 0
    for i in range(H):
        for j in range(W):
            a = dp[i-1][j]
            b = dp[i][j-1]

            if S[i-1][j] == '.' and S[i][j] == '#':
                a += 1
            if S[i][j-1] == '.' and S[i][j] == '#':
                b += 1
            
            dp[i][j] = min(dp[i][j], a, b)
                 
    print(dp[H-1][W-1])


if __name__ == '__main__':
    main()

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

public class Main {

	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		int spitCount = Integer.valueOf(scanner.nextLine()) * 2;

		int spits[] = new int[spitCount];
		for (int i = 0; i < spitCount; i++) {
			spits[i] = scanner.nextInt();
		}
		Arrays.sort(spits);
		int dishSum = 0;
		for (int i = 0; i < spitCount; i++) {
			if (i % 2 == 0) {
				dishSum += spits[i];
			}
		}
		System.out.println(dishSum);
	}

}


Measured memory_bytes: 22736
#include<bits/stdc++.h>
#include<atcoder/math>
 
using namespace std;
using ll = long long;
inline int ri() { int n; cin >> n; return n;}
 
 
void solve() {
	int n = ri(),  m = ri(), a = ri(), b = ri();
	cout << atcoder::floor_sum(n, m, a, b) << endl;	
}
 
int main()
{
	int T;
	cin >> T;
	while(T--)solve();
}

Measured memory_bytes: 3616
N = int(input())
import math

A = []
B = []
for i in range(N):
  a, b = map(int,input().split())
  A.append(int(a))
  B.append(int(b))

n=0
for i in range(N):
  #print(i,A[N-1-i]+n,B[N-1-i]+n)
  
  if (A[N-1-i]+n)%(B[N-1-i])==0:
    n+=0
  elif A[N-1-i]+n>B[N-1-i]:
    n+=math.ceil((A[N-1-i]+n)/B[N-1-i])*(B[N-1-i])-A[N-1-i]-n
    #print('!',n,math.ceil((A[N-1-i]+n)/(B[N-1-i])))
  elif A[N-1-i]+n<B[N-1-i]:
    n+= B[N-1-i]-A[N-1-i]-n
  #print(n)  
    
  #count +=n
  #print(n)
  #for j in range(N-i):
    #A[j]+=n

print(n)

Measured memory_bytes: 11060
#include <bits/stdc++.h>
#include <stdlib.h>
#include <fstream>
#include <iostream>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<ll,ll> llP;

ll mod(ll a, ll b){
  ll ret=a%b;
  if(ret<0) ret+=b;
  return ret;
}

ll modpow(ll a,ll b,ll c){
  ll res=1;
  while(b>0){
    if(b&1) res=mod(res*a,c);
    a=mod(a*a,c);
    b>>=1;
  }
  return res;
}

int GCD(int x,int y){
  if(x<y){
    swap(x,y);
  }
  while(x%y!=0){
    int temp=x;
    x=y;
    y=temp%y;
  }
  return y;
}

int digitsum(int x){
  int sum=0;
  while(x>0){
    sum+=(x%10);
    x/=10;
  }
  return sum;
}

int main() {
  int n;
  cin>>n;
  if(n==0){
    cout<<0<<endl;
    return 0;
  }
  vector<int> memo;
  int cnt=0;
  while(n!=0){
    if(n%2==0){
      memo.push_back(0);
      n/=2;
    }
    else{
      memo.push_back(1);
      if(cnt%2==0){
        n--;
        n/=2;
      }
      else{
        n++;
        n/=2;
      }
    }
    cnt++;
  }
  for(int i=(int)memo.size()-1;i>=0;i--){
    cout<<memo[i];
  }
  cout<<endl;
  return 0;
}

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

using namespace std;

int main(){

  map<int,int> m;
  int n, input, ans= 0;
  cin >>n;

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

  for(auto i:m){
    if(i.second > i.first){
      ans+= (i.second - i.first);
    }else{
      if(i.second < i.first){
        ans+=i.second;
      }
    }
  }

  cout << ans << "\n";
  return 0;
}


Measured memory_bytes: 7928
#include<bits/stdc++.h>
#define maxn 1010000
#define mod 1000000007
using namespace std;
int ans,dp[maxn],n,s[maxn];
int main(){
	scanf("%d",&n);
	dp[1]=n,s[1]=dp[1];
	dp[2]=1ll*n*n%mod,s[2]=(dp[1]+dp[2])%mod; 
	for(int i=3;i<=n;++i){
		dp[i]=(dp[i-1]+s[i-3]+1ll*(n-1)*(n-1)+n-i+2)%mod;
		s[i]=(s[i-1]+dp[i])%mod;
	}
	printf("%d",dp[n]);
}

Measured memory_bytes: 8064
#!/usr/local/bin/python3
# https://atcoder.jp/contests/sumitrust2019/tasks/sumitb2019_b

N = int(input())
ans_cand = int(N / 1.08)
if int((ans_cand) * 1.08) == N:
    print(ans_cand)
elif int((ans_cand+1) * 1.08) == N:
    print(ans_cand+1)
elif int((ans_cand-1) * 1.08) == N:
    print(ans_cand-1)
else:
    print(":(")


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

const int maxn = 1e5 + 15;

int n;
int cnt[maxn];

bool is[maxn];

set<int> st[maxn];
vector<int> g[maxn];

int main() {
	cin >> n;
	for(int i = 0; i < n - 1; i++) {
		int u, v;
		cin >> u >> v;
		u--, v--;
		cnt[u]++;
		cnt[v]++;
		st[u].insert(v);
		st[v].insert(u);		
		g[u].push_back(v);
		g[v].push_back(u);
	}
	queue<int> q;
	for(int i = 0; i < n; i++) {
		if(cnt[i] == 1) {
			q.push(i);
		}
	}
	while(q.size()) {
		int u = q.front();
		if(!cnt[u]) {
			return cout << "First", 0;
		}
		int v = *st[u].begin();
		is[u] = true;
		is[v] = true;
		for(auto it = st[v].begin(); it != st[v].end(); it++) {
			cnt[*it]--;
			st[*it].erase(v);
			if(cnt[*it] == 1)
				q.push(*it);
		}
		q.pop();
	}
	string a = "Second";
	for(int i = 0; i < n; i++) {
		if(!is[i])
			a = "First";
	}
	cout << a;
	
	return 0;
}


Measured memory_bytes: 20608
from collections import Counter

from sys import stdin
nii=lambda:map(int,stdin.readline().split())
lnii=lambda:list(map(int,stdin.readline().split()))

n=int(input())
a=lnii()

count=Counter(a)
ans=0
for k,v in count.items():
  ans+=k*v

q=int(input())
for i in range(q):
  b,c=nii()

  b_cnt=count[b]

  if b_cnt!=0:
    count[b]=0
    if c in count:
      count[c]+=b_cnt
    else:
      count[c]=b_cnt

  ans=ans-(b*b_cnt)+(c*b_cnt)
  print(ans)

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

int main(){
  string S;
  bool easy=true;
  cin >> S;
  rep(i,S.length()){
    if( (i%2==0 && S[i]=='L') || (i%2==1 && S[i]=='R') ){
      easy = false;
      break;
    }
  }
  
  if(easy) cout << "Yes";
  else cout << "No";
  
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>	
#include<map>
#include<set>
#include<utility>
#include<cmath>
#include<cstring>
#include<queue>
#include<stack>
#include<cstdio>
#include<sstream>
#include<iomanip>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define mp make_pair
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
using namespace std;
//kaewasuretyuui
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef vector<double> vd;
typedef pair<int,pii> pip;
typedef vector<pip>vip;
const double PI=acos(-1);
const double EPS=1e-8;
const int inf=1e8;
int main(){
	double a,b;
	cin>>a>>b;
	cout<<shosu(9)<<(a*b)/(a+b)<<endl;
}









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

int main()
{
    int n,arr[60],sum=0;
    scanf("%d",&n);
    for(int i=1;i<=n;i++)
    {
        scanf("%d",&arr[i]);
    }
    for(int i=1;i<n;i++)
    {
        for(int j=i+1;j<=n;j++)
        {
            sum+=(arr[i]*(arr[j]));
        }
    }
    printf("%d\n",sum);


}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstring>
using namespace std;
const int Mod=1000000007;
int A,B;
int f[5010][5010];
int g[5010][5010];
int sumg[5010];
int sumg2[5010][5010];
int F(int n,int x);
int G(int n,int x);
int SumG(int n);
int SumG2(int n,int x);
int F(int n,int x)
{
	if(n<=0||x<0)return 0;
	if(f[n][x]!=-1)
		return f[n][x];
	f[n][x]=(SumG(n-1)-SumG(n-B)+Mod)%Mod;
	if(x>=B)f[n][x]=(f[n][x]+SumG2(n-B,x-B))%Mod;
	return f[n][x];
}
int G(int n,int x)
{
	if(n<0||x<0)return 0;
	if(n==0)return 1;
	if(g[n][x]!=-1)
		return g[n][x];
	return g[n][x]=(G(n-1,x-1)+F(n-1,x-1))%Mod;
}
int SumG(int n)
{
	if(n<0)return 0;
	if(sumg[n]!=-1)
		return sumg[n];
	return sumg[n]=(SumG(n-1)+G(n,A-1))%Mod;
}
int SumG2(int n,int x)
{
	if(n<0||x<0)return 0;
	if(sumg2[n][x]!=-1)
		return sumg2[n][x];
	return sumg2[n][x]=(SumG2(n-1,x-1)+G(n,x))%Mod;
}
int main()
{
	memset(f,-1,sizeof(f));
	memset(g,-1,sizeof(g));
	memset(sumg,-1,sizeof(sumg));
	memset(sumg2,-1,sizeof(sumg2));
	int n;scanf("%d %d %d",&n,&A,&B);
	if(A<B)swap(A,B);
	int ans=1;
	for(int i=1;i<=n;i++)
		ans=ans*2ll%Mod;
	ans=(ans-F(n,A-1)+Mod)%Mod;
	ans=(ans-G(n,A-1)+Mod)%Mod;
	printf("%d\n",ans);
	return 0;
}

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

int main(){
    int n;
    cin >> n;
    int a[n];
    int i,count=1;
    for(i=0;i<n;i++)
        cin >> a[i];
    int tmp = a[0];
    if(tmp==2)
        cout << count << endl;
    if(tmp!=2){
        for(i=1;i<n;i++){
            tmp = a[tmp-1];
            count++;
            if(tmp==2){
                cout << count << endl;
                break;
            }   
        
        }
    }
    if(count==n || tmp!=2)
        cout << -1 << endl;
}

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

public class Main {
    public static void main(String[] args) {
        MyScanner sc = new MyScanner();

        int n = sc.nextInt();

        long ans = 0;
        for (int i = 1; i < n; i++) {
            int tmp = n / i;
            if (n % i == 0)
                tmp--;
            ans += tmp;
        }

        System.out.println(ans);
    }

    static class MyScanner {
        BufferedReader reader = new BufferedReader(new InputStreamReader(System.in), 1 << 15);
        StringTokenizer tokenizer;

        String next() {
            try {
                while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                    tokenizer = new StringTokenizer(reader.readLine());
                }
            } catch (IOException ignored) {
            }
            return tokenizer.nextToken();
        }

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

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

Measured memory_bytes: 32844
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using System.Text;
using System.Globalization;
using System.Diagnostics;
using System.Threading.Tasks;



class Myon
{
    public Myon() { }
    public static int Main()
    {
        new Myon().calc();
        return 0;
    }

    Scanner cin;

    int N;
    void calc()
    {
        cin = new Scanner();
        N = cin.nextInt();
        Console.WriteLine(dfs(0, false, false, false));
    }

    int dfs(long now, bool is3, bool is5, bool is7)
    {
        if (now > N) return 0;
        int ans = 0;
        if (is3 && is5 && is7) ans++;
        ans += dfs(now * 10 + 3, true, is5, is7);
        ans += dfs(now * 10 + 5, is3, true, is7);
        ans += dfs(now * 10 + 7, is3, is5, true);
        
        return ans;
    }
    
}




class Scanner
{
    string[] s;
    int i;

    char[] cs = new char[] { ' ' };

    public Scanner()
    {
        s = new string[0];
        i = 0;
    }

    public string next()
    {
        if (i < s.Length) return s[i++];
        string st = Console.ReadLine();
        while (st == "") st = Console.ReadLine();
        s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
        if (s.Length == 0) return next();
        i = 0;
        return s[i++];
    }

    public int nextInt()
    {
        return int.Parse(next());
    }
    public int[] ArrayInt(int N, int add = 0)
    {
        int[] Array = new int[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextInt() + add;
        }
        return Array;
    }

    public long nextLong()
    {
        return long.Parse(next());
    }

    public long[] ArrayLong(int N, long add = 0)
    {
        long[] Array = new long[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextLong() + add;
        }
        return Array;
    }

    public double nextDouble()
    {
        return double.Parse(next());
    }


    public double[] ArrayDouble(int N, double add = 0)
    {
        double[] Array = new double[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextDouble() + add;
        }
        return Array;
    }
}



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

using namespace std;

typedef long long ll;

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

int main(){
	int n;
	scanf("%d", &n);
	ll l[100];
	l[0]=2;
	l[1]=1;
	REP(i, n-1){
		l[i+2]=l[i]+l[i+1];
	}
	printf("%lld\n", l[n]);
	return 0;
}


Measured memory_bytes: 256
def resolve():
    '''
    code here
    '''
    import collections
    H, W = [int(item) for item in input().split()]
    grid = [[item for item in input()] for _ in range(H)]

    fp = [[-1 for _ in range(W)] for _ in range(H)]

    que = collections.deque()
    next_y_x = [[0, 1], [1, 0], [-1, 0], [0, -1]]
    

    for i in range(H):
        for j in range(W):
            if grid[i][j] == '#':
                que.append([i, j, 0])
                fp[i][j] = 0




    while que:
        temp = que.popleft()

        for dy, dx in next_y_x:
            ny = temp[0] + dy
            nx = temp[1] + dx

            if 0 <= ny <= H-1 and 0 <= nx <= W-1:
                if fp[ny][nx] == -1:
                    que.append([ny, nx, temp[2]+1])
                    fp[ny][nx] = temp[2] + 1

    temp_max_list = []
    for line in fp:
        temp_max_list.append(max(line))

    print(max(temp_max_list))



if __name__ == "__main__":
    resolve()


Measured memory_bytes: 186076
#include <bits/stdc++.h>
#define ff first
#define ss second
#define endl '\n'
using namespace std;
const long long INF = (long long) 1e18;
const int mod = (int) 1e9+7;
const int MAXN = (int) 1e5+5;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
ll n, w;
ll dp[105][MAXN + 5];


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

    #ifdef Local
        freopen("../IO/int.txt","r",stdin);
        freopen("../IO/out.txt","w",stdout);
    #endif

    cin>>n>>w;
    for(int k = 0; k <= n; k++)
        for(int i = 0; i <= MAXN; i++){
            dp[k][i] = INF;
        }
    dp[0][0] = 0;
    for(int i = 1; i <= n; i++){
        ll we, v;
        cin>>we>>v;
        for(int j = 0; j <= MAXN; j++){
            dp[i][j] = min(dp[i - 1][j], (j >= v ? dp[i - 1][j - v] + we : INF));
        } 
    }
    ll ans = 0;
    for(ll i = 0; i <= MAXN; i++){
        if(dp[n][i] <= w){
            ans = max(ans, i);
        }
    }
    cout<<ans<<endl;
    #ifdef Local
        cout<<endl<<fixed<<setprecision(2)<<1000.0 * clock() / CLOCKS_PER_SEC<< " milliseconds ";
    #endif
}

Measured memory_bytes: 80128
#include <iostream>
#include <vector>
#include <cmath>
#include <string>
#include <cstdio>
#include <algorithm>
#include <map>
#include <queue>
#include <cstdlib>
#include <cstdio>
using namespace std;

#define next '\n'
#define rep(i, n) for(int (i) = (0); (i) < (n); (i++))
using ll = long long;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    ll a, b;
    cin >> a >> b;

    if(a % 2 != b % 2){
        cout << "IMPOSSIBLE";
    }else{
        cout << (a + b) / 2 << endl;
    }

    cout << next;
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS

#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <set>
#include <map>
#include <vector>
#include <math.h>
#include <queue>
#include <stack>
#include <list>
#include <functional>
#include <numeric>
#include <iostream>
#include <string>

using namespace std;
typedef long long ll;
#define rep(i, n) for (ll i = 0; i < (n); ++i)

int main() {

	int A, B;

	scanf("%d%d", &A, &B);

	if (A % 2 && B % 2)
		printf("Yes\n");
	else
		printf("No\n");

	return 0;
}

Measured memory_bytes: 256
import std.stdio;
import std.range;
import std.array;
import std.algorithm;
import std.string;
import std.conv;
import std.typecons;
import std.math;
import std.numeric;

void main() {
    int[] input;
    foreach (i; 0 .. 5) {
        input ~= readln().chomp().to!int;
    }
    immutable k = readln().chomp().to!int;

    solve(input, k).writeln();
}

string solve(int[] antennas, int distance) {
    auto result = true;

    foreach (i, antenna; antennas) {
        foreach (other; antennas[i + 1 .. $]) {
            if (other - antenna > distance) {
                result = false;
                break;
            }
            if (!result) {
                break;
            }
        }
    }

    if (result) {
        return "Yay!";
    }
    else {
        return ":(";
    }
}

unittest {
    assert(solve([1, 2, 4, 8, 9], 15) == "Yay!");
    assert(solve([15, 18, 26, 35, 36], 18) == ":(");
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
using namespace std;
const int mod = 1e9+7;
int f[301000][3][3],n;
char s[301000];
void upd(int&a,int b){a+=b;if(a>=mod) a-=mod;}
int main(){
	ios::sync_with_stdio(0);
	cin>>s+1;
	int n=strlen(s+1);
	f[1][0][0]=1;
	for(int i=1;i<=n;i++)
		for(int j=0;j<=2;j++)
			for(int k=0;k<=2;k++){
				if(s[i]!='0') upd(f[i+1][k?j:min(2,j+1)][max(0,k-1)],f[i][j][k]);
				if(s[i]!='1') upd(f[i+1][j][k+1>2?1:k+1],f[i][j][k]);
			}
	cout<<(0ll+f[n+1][1][0]+f[n+1][2][1]+f[n+1][2][2]+f[n+1][2][0])%mod<<'\n';
	return 0;
}


Measured memory_bytes: 11136
#include <stdio.h>
#include <assert.h>
#include <fstream>
#include <iostream>
#include <algorithm>
#include <array>
#include <vector>
#include <queue>
#include <set>
#include <cmath>
#include <unordered_map>
//#include <unordered_set>
//#include <boost/container/static_vector.hpp>
//#include <boost/unordered_set.hpp>
//#include <boost/unordered_map.hpp>
//#include <unistd.h>
 
const int MAX_N = 300;
const int MAX_M = MAX_N * MAX_N;
const long long INF = (long long)1000000000 * MAX_N;
 
const int MAX_R = 10;
const int BIT_MAX = (1 << MAX_R);
 
int N, M, R;
int r[MAX_R];
int A[MAX_M], B[MAX_M];
long long C[MAX_M];
 
long long dist[MAX_N][MAX_N];
 
long long dp[MAX_R][BIT_MAX];

int bit_count(const int num, const int loc1, const int loc2) {
    int ret = 0;
    for (int i = loc1; i <= loc2; i++) {
        if (((num >> i) & 1) == 1) {
            ret += 1;
        }
    }
    return ret;
}
 
long long res(const int i, const int bit) {
    //std::cout << "res:" << i << " " << bit << std::endl;
    if (dp[i][bit] != INF) {
        return dp[i][bit];
    }
    if (bit_count(bit, 1, R) == R) {
        dp[i][bit] = 0;
        return dp[i][bit];
    }
    //std::cout << "check:" << std::endl;
    long long ret = INF;
    for (int j = 1; j <= R; j++) {
        if (((bit >> j) & 1) == 0) {
            ret = std::min(ret, dist[r[i]][r[j]] + res(j, bit + (1 << j)));
        }
    }
    dp[i][bit] = ret;
    return ret;
}
 
int main(int argc, char **argv) {
    std::cin >> N >> M >> R;
    for (int i = 1; i <= R; i++) {
        std::cin >> r[i];
    }
 
    for (int i = 1; i <= M; i++) {
        std::cin >> A[i] >> B[i] >> C[i];
    }
 
    for (int i = 1; i <= N; i++) {
        for (int j = 1; j <= N; j++) {
            dist[i][j] = INF;
        }
        dist[i][i] = 0;
    }
 
    for (int i = 1; i <= M; i++) {
        dist[A[i]][B[i]] = C[i];
        dist[B[i]][A[i]] = C[i];
    }
 
    for (int k = 1; k <= N; k++) {
        for (int i = 1; i <= N; i++) {
            for (int j = 1; j <= N; j++) {
                dist[i][j] = std::min(dist[i][j], dist[i][k] + dist[k][j]);
            }
        }
    }
 
    for (int i = 1; i <= R; i++) {
        for (int b = 0; b < (1 << (R + 1)); b++) {
            dp[i][b] = INF;
        }
    }
 
    long long ret = INF;
 
    for (int i = 1; i <= R; i++) {
        int tmp = (1 << i);
        ret = std::min(ret, res(i, tmp));
    }
 
    std::cout << ret << std::endl;
 
    //std::cout << dp[3][5] << std::endl;
 
    return 0;
 
}

Measured memory_bytes: 1152
#include <stdio.h>
	#include <iostream>
	#include <vector>
	#include <algorithm>
	using namespace std;
	typedef long long ll;
	typedef std::vector<ll> lls;
	#define MIN(a, b) ( ((a)<(b)) ? (a) : (b) )
	#define MAX(a, b) ( ((a)>(b)) ? (a) : (b) )

	void cinv(lls& llVec, ll n) {
		ll val;
		llVec.reserve((size_t)(n));
		for (ll i = 0; i < n; i++) {
			cin >> val;
			llVec.push_back(val);
		}
	}


	int main()
	{
		ll N;
		lls A,B,C;

		cin >> N;
		cinv(A, N);
		cinv(B, N);
		cinv(C, N-1);

		ll manzoku = 0;
		for (int i = 0; i < N; i++) {
			ll ryori = A[i];
			manzoku += B[ryori-1];
			if (i >= 1) {
				ll preRyori = A[i - 1];
				if (preRyori + 1 == ryori) {
					manzoku += C[preRyori -1];
				}
			}
		}

		cout << manzoku << '\n';

		return 0;
	}



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

int pop();
void push();
int A[100],top=0;
  
int main(){
  int a,b;
  char s[100];
    
  while(scanf("%s",s)!=EOF){
    if(s[0]=='+'){
      a=pop();
      b=pop();
      push(a+b);
    }
    else if(s[0]=='-'){
      a=pop();
      b=pop();
      push(b-a);
    }
    else if(s[0]=='*'){
      a=pop();
      b=pop();
      push(a*b);
    }
    else
      push(atoi(s));
  }
  
  printf("%d\n",pop());
   
  return 0;
}
 
int pop(){
  top--;
  return A[top+1];
}
 
void push(int x){
  A[++top]=x;
}

Measured memory_bytes: 548
H,W,K = [int(i) for i in input().split()]
grid = [list(input()) for i in range(H)]
B = sum([i.count("#") for i in grid])
c = 0
for i in range(2**(H)):
    for j in range(2**(W)):
        gt = [[j for j in i] for i in grid]
        a,b = bin(i)[2:], bin(j)[2:]
        while len(a) < H:
            a = "0" + a
        while len(b) < W:
            b = "0" + b
        for x in range(H):
            if a[x] == "1":
                gt[x] = ["."]*W
        for y in range(W):
            for x in range(H):
                if b[y] == "1":
                    gt[x][y] = "."
        # print(gt)
        if sum([x.count("#") for x in gt]) == K:
            c += 1
        # k, p = 0,0
        # for x in range(H):
        #     for y in range(W):
        #         if a[x] == "1" or b[y] == "1":
        #             if grid[x][y] == "#":
        #                 if a[x] == "1" and b[y] == "1":
        #                     p += 1
        #                 else:
        #                     k += 1
        # if k + p/2 == K:
        #     print(a,b)
        #     print(k, p, K)
        #     c += 1
print(c)

Measured memory_bytes: 9172
#include <iostream>
#include <cassert>
#include <limits>
#include <cmath>
#include <algorithm>
#include <vector>
#include <unordered_map>
#include <unordered_set>
#include <string>
#include <array>
#include <map>
#include <set>
#include <deque>
#include <list>
#include <sstream>
#include <iomanip>
#include <numeric>
#include <climits>
#include <cstring>
#include <bitset>
#include <stack>
#include <queue>

#define MOD (1e9 + 7);
#define PI (3.14159265358979323846)

using ll = int64_t;
using ull = uint64_t;

using namespace std;

[[maybe_unused]] static auto __x = [](){ios_base::sync_with_stdio(0); cin.tie(0);};

int main() {
    string a;
    cin >> a;
    unordered_set<char> s;
    for (char ch : a) s.insert(ch);
    cout << (s.size() == 2 ? "Yes" : "No");
}


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

int main() {
  char s;
  cin >>s;
  
  if(s=='A'){
    cout <<'T' <<endl;
  }
  if(s=='T'){
    cout <<'A' <<endl;
  }
  if(s=='C'){
    cout <<'G' <<endl;
  }
  if(s=='G'){
    cout <<'C' <<endl;
  }

}

Measured memory_bytes: 256
#include<iostream>
#define loop(i,a,b) for(int i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)
#define INF 1e9
using namespace std;
typedef long long ll;

ll max(ll a,ll b){
	return (a>=b)?a:b;
}

ll min(ll a,ll b){
	return (a<b)?a:b;
}

int main(){
	ll h,w;
	cin>>h>>w;
	ll a,b,c,ans=INF;
	loop(i,1,h+1){
		if(i==h){
			if(w%3==0){
				ans=min(ans,0);
			}else ans=min(ans,h);	
		}else{
			a=i*(w/2);
			b=i*((w+1)/2);
			c=(h-i)*w;
			ll tmp=max(a,max(b,c)),bug=min(a,min(b,c));
			ans=min(ans,tmp-bug);
		}
	}
	ll alt=h;
	h=w;
	w=alt;
	loop(i,1,h+1){
		if(i==h){
			if(w%3==0){
				ans=min(ans,0);
			}else ans=min(ans,h);	
		}else{
			a=i*(w/2);
			b=i*((w+1)/2);
			c=(h-i)*w;
			ll tmp=max(a,max(b,c)),bug=min(a,min(b,c));
			ans=min(ans,tmp-bug);
		}
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
n=int(input())
A=list(map(int,input().split()))

ans=0
syaku=0
tmp=A[-1]
for i in range(n):
    tmp-=A[i-1]
    while(1):
        if(tmp & A[syaku]):
            break
        else:
            tmp+=A[syaku]
            syaku+=1
            if(syaku==n):
                break
    if(syaku==n):
        ans+=n*(n-i) - (i+n-1)*(n-i)//2
        break
    ans+=syaku-i


print(ans)

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

int main()
{
        int A, B, C;
        cin >> A >> B >> C;

        while(A != B)
        {
                if( A == C )
                {
                        cout << "Yes" << endl;
                        return 0;
                }
                if( A > B ) --A;
                else ++A;
        }

        cout << "No" << endl;

        return 0;
}

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

using namespace std;
typedef long long ll;
#define rep(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define erep(i, n) for (ll i = 0; i <= (ll)(n); ++i)
#define FOR(i,a,b) for (ll i = (a); i < (ll)(b); ++i)
#define EFOR(i,a,b) for (ll i = (a); i <= (ll)(b); ++i)
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } }

int main() {
    int n; cin >> n;
    vector<vector<int>> x(n, vector<int>());
    vector<vector<int>> y(n, vector<int>());
    rep(i, n) {
        int a; cin >> a;
        rep(j, a) {
            int tmp_x, tmp_y; cin >> tmp_x >> tmp_y;
            x[i].push_back(tmp_x);
            y[i].push_back(tmp_y);
        }
    }

    int ans = 0;


    // bit全探索
    for (int bit = 0; bit < (1<<n); ++bit) {
        set<int> honest;


        // bitが立っているのを正直者、立っていないのを嘘つきと仮定する
        for (int i = 0; i < n; ++i) {
            if (bit & (1<<i)) {
                honest.insert(i);
            }
        }

        bool flag = true;


        // 証言に矛盾がないか見ていく
        rep(i, n) {
            if(honest.count(i)) {
                // 正直者の場合だけ見れば、嘘つきの情報を無視する
                rep(j, x[i].size()) {

                    // 正直者の人が正直者に含まれていないとだめ
                    if(y[i][j] == 1 && !honest.count(x[i][j]-1)) {
                        flag = false;
                        break;
                    }

                    // 嘘つきが正直者に含まれてるとだめ
                    if(y[i][j] == 0 && honest.count(x[i][j]-1)) {
                        flag = false;
                        break;
                    }

                }
            }
            if(!flag) break;
        }

        if(flag) {
            chmax(ans, (int)honest.size());
        }

    }

    cout << ans << endl;

    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long lint;

#define PI acos(-1)
#define INF64 1LL << 60
#define INF32 1 << 29
#define all(a) (a).begin(), (a).end()
#define INV ((long long int)1000000007)

using namespace std;

void execute()
{
	lint N, T;

	cin >> N >> T;
	vector<lint> data(N, 0);
	lint ans = T;

	for (int i = 0; i < N; i++)
	{
		cin >> data[i];
		if (0 < i)
		{
			ans += min(data[i] - data[i - 1], T);
		}
	}
	cout << ans << endl;
	return;
}

int main()
{
	cin.tie(0);
	ios_base::sync_with_stdio(false);
	std::cout << std::fixed << std::setprecision(15);
	execute();

	int stop;
	cin >> stop;

	return 0;
}

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


 
using Edge = pair<int, long long>;
using Graph = vector<vector<Edge> >;
 
int N;
Graph G;
 
vector<int> dir;
void dfs(int v, int p, int c) {
    dir[v] = c;
    for (auto e : G[v]) {
        if (e.first == p) continue;
        if (e.second & 1) dfs(e.first, v, 1-c);
        else dfs(e.first, v, c);
    }
}
 
int main() {
    while (cin >> N) {
        G.assign(N, vector<Edge>());
        for (int i = 0; i < N-1; ++i) {
            int u, v;
            long long w;
            cin >> u >> v >> w;
            --u, --v;
            G[u].push_back(Edge(v, w));
            G[v].push_back(Edge(u, w));
        }
        dir.assign(N, 0);
        dfs(0, -1, 1);
        for (auto v : dir) cout << v << endl;
    }
}

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

"""
後ろから、到達不可能距離の集合を見ていきたい。
集合を持つと厳しいが、最小値だけ持っておけばよい。
"""

N,dist = map(int,input().split())
D = [int(x) for x in input().split()]

# 各ターンの出発位置
start_dist = [dist]
for d in D:
    x = start_dist[-1]
    y = x-d if x > d else d - x
    start_dist.append(x if x < y else y)

ng_dist = [None] * (N+1)
ng_dist[N] = 1

for i,d in enumerate(D[::-1]):
    x = ng_dist[N-i]
    y = x if x <= d//2 else x + d
    ng_dist[N-i-1] = y

input()
Q = [int(x) for x in input().split()]

answer = ['YES' if ng_dist[d] <= start_dist[d-1] else 'NO' for d in Q]

print('\n'.join(answer))

Measured memory_bytes: 106520
#include<bits/stdc++.h>
//#include <boost/multiprecision/cpp_int.hpp> 
//using namespace boost::multiprecision; 
using namespace std;
#define ll long long int
#define ld long long double
#define vi vector<int>
#define vl vector<ll>
#define pi pair<int, int>
#define pl pair<ll, ll>
#define pb push_back
#define pf push_front
#define pob pop_back
#define pof pop_front
#define nl '\n'
#define mp make_pair
#define debug1(x) cout <<#x<<" "<<x<<'\n';
#define debug2(x,y) cout <<#x<<" "<<x <<" "<<#y<<" "<<y <<'\n';
#define debug3(x,y,z) cout<<#x<<" "<<x<<" "<<#y<<" "<<y<<" "<<#z<<" "<<z<<'\n';
#define fi first
#define se second
#define boost ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define inf 1e18
const int mod = (int)1e9+7;
pair<ll,ll>s4[4]={{-1,0},{1,0},{0,-1},{0,1}};
pair<ll,ll>s8[8]={{-1,-1},{-1,0},{-1,1},{0,-1},{0,1},{1,1},{1,0},{1,-1}};

void solve() {
	ll n;
	cin >> n;
	unordered_map<int, int> m;
	for(int i=0;i<n;i++) {
		int x;
		cin >> x;
		m[x]++;
	}
	unordered_map<int, int>:: iterator it;
	for(it=m.begin();it!=m.end();it++) {
		if(it->second >1){
			break;
		}
	}
	if(it==m.end()) cout << "YES"<<endl;
	else{
		cout << "NO" <<endl;
	}


}

signed main() {
	boost;
	solve();
}

Measured memory_bytes: 8520
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sn = new Scanner(System.in);
        
        String s = sn.nextLine();
        
        if(s.equals("ABC")) {
            System.out.print("ARC");
        } else {
            System.out.print("ABC");
        }
    }
}


Measured memory_bytes: 35704
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#define INT long long
#define MOD 1000000007
#define oo 987654321ll
#define FOR(i,a,b) for(int (i)=a;(i)<(b);(i++))
using namespace std;

int n, s[200020], a[200020], l, r;

int main()
{
    cin.sync_with_stdio(0);
    cin>>n;
    l = 0, r = n-1;
    for(int i = 0 ; i < n ; i++ ) cin>>s[i];
    
    for(int i = n-1 ; i >= 0 ; i-- )
    {
        if( (n-1-i)%2 == (n-1)%2 ) a[l++] = s[i];
        else a[r--] = s[i];
    }
    if( n%2 == 0 ) for(int i = n-1 ; i >= 0 ; i-- ) cout<<a[i]<<" ";
    else for(int i = 0 ; i < n ; i++ ) cout<<a[i]<<" "; cout<<endl;
    return 0;
}


Measured memory_bytes: 3712
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define srep(i,s,t) for(int i = s; i < t; ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
#define yn {puts("Yes");}else{puts("No");}
#define MAX_N 200005

int main() {
    int d, t, s;
    cin >> d >> t >> s;
    if(t*s>=d)yn;
    return 0;
}




Measured memory_bytes: 3596
#!/usr/bin/env python3
import bisect
import numpy as np

N, M = list(map(int, input().split()))
a_list = list(map(int, input().split()))
bc_list = []

for i in range(M):
    b, c = list(map(int, input().split()))
    bc_list.append((b, c))

bc_list = sorted(bc_list, key=lambda x: x[1], reverse=True)
a_list = sorted(a_list)

fix_list = []
s = 0
b, c = bc_list[0]
bc_index = 0
count_b = 0

for a in a_list:
    if count_b >= b:
        bc_index += 1
        if bc_index >= len(bc_list):
            s += a
            continue
        count_b = 0
        b, c = bc_list[bc_index]

    if a < c:
        s += c
    else:
        s += a
    count_b += 1

ans = s
print(ans)


Measured memory_bytes: 31912
#include <iostream>
#include <vector>
#include <map>

using std::cout;
using std::endl;

int main()
{
	int A;

	std::cin >> A;

	std::map<int, int> S;

	for (int i = 2; i <= A; i++) {
		int a = 2;
		int n = i;

		while (n >= a * a) {
			if (n % a == 0) {
				try {
					S.at(a)++;
				}
				catch (const std::exception&) {
					S.insert(std::pair<int, int>(a, 1));
				}
				n /= a;
			}
			else {
				a++;
			}
		}

		try {
			S.at(n)++;
		}
		catch (const std::exception&) {
			S.insert(std::pair<int, int>(n, 1));
		}
	}

	int total = 0;

	for (auto&& s : S) {
		if (s.second >= 74) {
			total++;
		}

	}

	int count1;
	int count2;

	auto Count = [&S, &count1, &count2](int num1, int num2) {
		count1 = 0;
		count2 = 0;

		for (auto&& s : S) {

			if (s.second >= num1) {
				count1++;
				continue;
			}

			if (s.second >= num2) {
				count2++;
			}
		}
	};

	Count(24, 2);
	total += count1 * count2 + count1 * (count1 - 1);
	Count(14, 4);
	total += count1 * count2 + count1 * (count1 - 1);
	Count(4, 2);
	total += count1 * (count1 - 1) / 2 * count2 + count1 * (count1 - 1) / 2 * (count1 - 2);

	cout << total << endl;

	return 0;
}

Measured memory_bytes: 256
// God put a smile upon your face <3

#include <bits/stdc++.h>

#define slld(longvalue) scanf("%lld", &longvalue)

#define ll long long
#define ull unsigned long long
#define pll pair < long long, long long >

#define fastio ios_base:: sync_with_stdio(false); cin.tie(0); cout.tie(0)

#define pb push_back

#define bug printf("BUG\n")

#define mxlld LLONG_MAX
#define mnlld -LLONG_MAX

#define mxd 2e8
#define mnd -2e8

#define pi 3.14159265359

using namespace std;

bool check(ll n, ll pos)
{
	return n & (1LL << pos);
}

ll Set(ll n, ll pos)
{
	return n = n | (1LL << pos);
}

deque < char > dq;
string s;

int main()
{
    ll i, j, k, l, m, n, o, r, q;
    ll testcase;
    ll input, flag, tag, ans;

//    freopen("input.txt", "r", stdin);

//    freopen("output.txt", "w", stdout);

    while(cin >> s)
    {
		dq.clear();

		for(auto it: s) dq.push_back(it);

		bool rev = 0;

		cin >> m;

		for(ll i = 1; i <= m; i++)
		{
			ll t;

			cin >> t;

			if(t == 1) rev ^= 1;
			else
			{
				ll f;
				char c;
				cin >> f >> c;

				if(rev)
				{
					if(f == 2) dq.push_front(c);
					else dq.push_back(c);
				}
				else
				{
					if(f == 1) dq.push_front(c);
					else dq.push_back(c);
				}
			}
		}

		if(rev) reverse(dq.begin(),dq.end());

		for(auto it: dq) cout << it;

		cout << "\n";
    }


}




Measured memory_bytes: 3980
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;

//template<class T, size_t N> 
//size_t countof(const T (&array)[N]) { return N; }

int main() {
  int N;
  cin >> N;
  string s;
  cin >> s;
  int i=0;
  int num_w=0;
  int num_rev=0;
  int sum_b[N];
  int sum_w[N];
  //.を#に
  for (int i=N-1; i >=0; i-- ) {
    if (s[i] == '.'){
      num_w++;
      if(i==N-1) sum_w[i]=1;
      else sum_w[i]=sum_w[i+1] +1;
    }
    if (s[i] == '#'){
      num_rev += num_w;
      num_w=0;
      if(i==N-1) sum_w[i]=0;
      else sum_w[i]=sum_w[i+1];
    }
    //    cout << sum_w[i] << endl;
  }
  //#を.に
  int num_b=0;
  int num_rev2=0;
  for (int i=0; i < N; i++ ){
    if (s[i] == '#'){
      num_b++;
      if(i==0) sum_b[i]=1;
      else sum_b[i]=sum_b[i-1] +1;
    }
    if (s[i] == '.'){
      num_rev2 += num_b;
      num_b=0;
      if(i==0) sum_b[i]=0;
      else sum_b[i]=sum_b[i-1];
    }
    
    
  }

  int res=min(num_rev,num_rev2);


  for (int i=0; i < N; i++ ) {
    if(i < N-1)
      {
	res=min(res, sum_b[i]+sum_w[i+1]);
      }
      else
	res = min(res, sum_b[i]);
    }




  cout <<res << endl;
  



  //  int n = sizeof(s)/sizeof(*s);

  //  cout  <<  sizeof(s)/sizeof(*s) << endl;


}


Measured memory_bytes: 2180
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); i++)
#define rep1(i,n) for (int i = 1; i <= (n); i++)
#define repi(i,a,b) for (int i = (a); i < (b); i++)
#define all(x) (x).begin(),(x).end()
using namespace std;
using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;
using vi = vector<int>;
using vvi = vector<vi>;
using pii = pair<int, int>;
using vc = vector<char>;
using vvc = vector<vc>;
using vs = vector<string>;

int main() {
  int X, A, B;
  cin >> X >> A >> B;
  
  if (-A+B <= 0)
    cout << "delicious" << endl;
  else if(-A+B <= X)
    cout << "safe" << endl;
  else
    cout << "dangerous" << endl;
}

Measured memory_bytes: 256
#include <vector>
#include <iostream>
#include <functional>
using namespace std;
int main() {
	cin.tie(0);
	ios_base::sync_with_stdio(false);
	int N, Q; long long S, T;
	cin >> N >> Q >> S >> T;
	function<long long(long long)> diff = [&](long long x) {
		if (x >= 0) return -(x * S);
		return -(x * T);
	};
	vector<long long> A(N + 1);
	for (int i = 0; i <= N; ++i) cin >> A[i];
	vector<int> L(Q), R(Q);
	vector<long long> X(Q);
	for (int i = 0; i < Q; ++i) cin >> L[i] >> R[i] >> X[i], --L[i];
	vector<long long> D(N);
	for (int i = 0; i < N; ++i) D[i] = A[i + 1] - A[i];
	long long sum = 0;
	for (int i = 0; i < N; ++i) {
		sum += diff(D[i]);
	}
	for (int i = 0; i < Q; ++i) {
		sum -= diff(D[L[i]]); D[L[i]] += X[i]; sum += diff(D[L[i]]);
		if (R[i] != N) {
			sum -= diff(D[R[i]]); D[R[i]] -= X[i]; sum += diff(D[R[i]]);
		}
		cout << sum << '\n';
	}
	return 0;
}


Measured memory_bytes: 9184
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String line1 = br.readLine();
		String[] work = line1.split(" ");
		int a = Integer.parseInt(work[0]);
		int b = Integer.parseInt(work[1]);
		int c = Integer.parseInt(work[2]);
		int k = Integer.parseInt(work[3]);
		System.out.println(Math.min(a, k) - Math.max(0, (k - a - b)));
	}
}


Measured memory_bytes: 32444
#include<iostream>
#include<string>
#include<algorithm>
using namespace std;

int main(){
  int n;
  while(cin >>n){

  int count=0;
  

  for(int i=0 ; i<=9 ; i++){
    for(int j=0 ; j<=9 ; j++){
      for(int k=0 ; k<=9 ; k++){
        for(int l=0 ; l<=9 ; l++){
          if(i+j+k+l == n) count++;
        }
      }
    }
  }
  cout << count<<endl;
}
}



Measured memory_bytes: 3076
#include <bits/stdc++.h>
using namespace std;
int main(){
    int N, M;
    cin >> N >> M;
    vector<int> vec(M);
    vector<string> res(M);
    for(int i=0; i<M; i++){
        cin >> vec[i] >> res[i];
    }
    vector<vector<int>> result(N,vector<int>(3,0));
    for(int i=0; i<N; i++){
        result[i][0] = i+1;
    }
    for(int i=0; i<M; i++){
        if((res[i] == "AC")&&(result[vec[i]-1][1] == 0)){
            result[vec[i]-1][1] = 1;
        }
        else if((res[i] == "WA")&&(result[vec[i]-1][1] == 0)){
            result[vec[i]-1][2] += 1;
        }
    }
    int acnum = 0;
    int ptnum = 0;
    for(int i=0; i<N; i++){
        if(result[i][1] == 1){
            acnum++;
            ptnum += result[i][2];
        }
    }
    cout << acnum << " " << ptnum << endl;
}


Measured memory_bytes: 11520
#include<bits/stdc++.h>
using namespace std;
int main()
{
  long long int a,b,c;
  cin>>a>>b>>c;
  long long int rem =a-c;
  if(rem>=0)
  {cout<<rem<<" "<<b<<endl;}
  else
  {
    long long int rem2=b+rem;
    if(rem2<0)rem2=0;
    cout<<0<< " "<<rem2<<endl;

  }
}


Measured memory_bytes: 256
import java.util.*;

class Main {
    static  long knap(int[] w , int[] v, int n, int W) { 
        long arr[][] = new long[n+1][W+1];
        for (int i =1 ; i<=n; i++) {
            for (int j =1 ;j<=W ; j++) {
                if(j>=w[i-1]) {
                    arr[i][j] = Math.max(arr[i-1][j],v[i-1]+arr[i-1][j-w[i-1]]);
                }
                else {
                    arr[i][j] = arr[i-1][j];
                }
            }
        }
        return arr[n][W];
    }
  public static void main(String[] args) {
    Scanner s = new Scanner(System.in);
    int n = s.nextInt();
    int W = s.nextInt();
    //int  k = s.nextInt();
    int w[] = new int[n];
    int v[] = new int[n];
    for (int i =0 ; i<n ;i++) {
        w[i] = s.nextInt();
        v[i] = s.nextInt();
    }
    System.out.println(knap(w,v,n,W));
  
  }
}

Measured memory_bytes: 126292
import java.io.IOException;
import java.io.InputStream;
import java.util.NoSuchElementException;

public class Main {

	public static void main(String[] args) {

		FastScanner sc = new FastScanner();
		int H = sc.nextInt();
		int W = sc.nextInt();
		int h = sc.nextInt();
		int w = sc.nextInt();
		System.out.println(H * W - (h * W + w * H - w * h));
	}
	//以下、自作ライブラリ

	//最大公約数
	public static long gcd(long a, long b) {
		if (a < b)
			return gcd(b, a);
		long c = 0;
		c = a % b;
		if (c == 0)
			return b;
		return gcd(b, c);
	}

	//最小公倍数
	public static long lcm(long m, long n) {
		return m * n / gcd(m, n);
	}

	//素数判定
	public static boolean isPrime(int n) {
		if (n < 2)
			return false;
		if (n == 2)
			return true;
		if (n % 2 == 0)
			return false;

		for (int i = 3; i * i <= n; i += 2) {
			if (n % i == 0)
				return false;
		}
		return true;
	}
}

//以下、高速スキャナークラス
class FastScanner {
	private final InputStream in = System.in;
	private final byte[] buffer = new byte[1024];
	private int ptr = 0;
	private int buflen = 0;

	private boolean hasNextByte() {
		if (ptr < buflen) {
			return true;
		} else {
			ptr = 0;
			try {
				buflen = in.read(buffer);
			} catch (IOException e) {
				e.printStackTrace();
			}
			if (buflen <= 0) {
				return false;
			}
		}
		return true;
	}

	private int readByte() {
		if (hasNextByte())
			return buffer[ptr++];
		else
			return -1;
	}

	private static boolean isPrintableChar(int c) {
		return 33 <= c && c <= 126;
	}

	public boolean hasNext() {
		while (hasNextByte() && !isPrintableChar(buffer[ptr]))
			ptr++;
		return hasNextByte();
	}

	public String next() {
		if (!hasNext())
			throw new NoSuchElementException();
		StringBuilder sb = new StringBuilder();
		int b = readByte();
		while (isPrintableChar(b)) {
			sb.appendCodePoint(b);
			b = readByte();
		}
		return sb.toString();
	}

	public long nextLong() {
		if (!hasNext())
			throw new NoSuchElementException();
		long n = 0;
		boolean minus = false;
		int b = readByte();
		if (b == '-') {
			minus = true;
			b = readByte();
		}
		if (b < '0' || '9' < b) {
			throw new NumberFormatException();
		}
		while (true) {
			if ('0' <= b && b <= '9') {
				n *= 10;
				n += b - '0';
			} else if (b == -1 || !isPrintableChar(b)) {
				return minus ? -n : n;
			} else {
				throw new NumberFormatException();
			}
			b = readByte();
		}
	}

	public int nextInt() {
		long nl = nextLong();
		if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE)
			throw new NumberFormatException();
		return (int) nl;
	}

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


Measured memory_bytes: 21332
#include <stdio.h>

int main(void){

    int W,H,x,y,r;
    scanf("%d %d %d %d %d",&W,&H,&x,&y,&r);
    if (W >= x + r && 0 <= x - r && H >= y + r && 0 <= y - r){
        printf("Yes\n");
    }else{
        printf("No\n");
    }
    return 0;
    }

Measured memory_bytes: 1012
#include <iostream>
#include <map>

int main() {
  uint32_t N = 0, M = 0;
  std::cin >> N;

  std::map<std::string, int32_t> dict;
  for (size_t i = 0; i < N; i++) {
    std::string s;
    std::cin >> s;
    dict[s]++;
  }

  std::cin >> M;
  for (size_t i = 0; i < M; i++) {
    std::string t;
    std::cin >> t;
    dict[t]--;
  }

  int32_t max = 0;
  for (auto &&d : dict) {
    if (d.second > max) max = d.second;
  }
  std::cout << max << std::endl;

  return 0;
}

Measured memory_bytes: 256
N = int(input())
A = sorted(list(map(int, input().split())))
cr_A = []
if N%2:
	cr_A.append(0)
	for i in range(1, N//2 + 1):
		cr_A.extend([2*i]*2)
else:
	for i in range(1, N//2 + 1):
		cr_A.extend([2*i - 1]*2)

if A == cr_A:
	if N > 1:
		print((2**(N//2))%(10**9 + 7))
	else:
		print(1)
else:
	print(0)

Measured memory_bytes: 13880