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

using namespace std;

typedef long long ll;

const int N = 1000 + 3;
const int MOD = 1000000000 + 7;

int n, m;
string s[N];
ll dp[N][N];

ll add(ll a, ll b) {
  a %= MOD;
  b %= MOD;
  return (a + b) % MOD;
}

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

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

  for(int i = 0; i < n; ++i) {
    if(s[i][0] == '#') break;
    dp[i][0] = 1ll;
  }

  for(int i = 0; i < m; ++i) {
    if(s[0][i] == '#') break;
    dp[0][i] = 1ll;
  }

  for(int i = 1; i < n; ++i) {
    for(int j = 1; j < m; ++j) {
      if(s[i][j] == '.') dp[i][j] = add(dp[i - 1][j], dp[i][j - 1]);
    }
  }

  cout << dp[n - 1][m - 1] << endl;
  return 0;
}


Measured memory_bytes: 9088
#include <iostream>
#include <vector>
#include <climits>
#include <algorithm>
#include <cmath>
#include <map>
#include <set>
#include <string>
#include <bitset>
#include <utility>
#include <numeric>
#include <queue>
#include <stack>

using ll = long long;
using namespace std;

constexpr int MOD = 1e9 + 7;
constexpr ll MOD_LL = ll(1e9) + 7;

int main(void) {
	int a1, a2, a3;
	cin >> a1 >> a2 >> a3;
	
	vector<int> a = {a1, a2, a3};
	sort(a.begin(), a.end());
	
	cout << a[1] - a[0] + a[2] - a[1] << endl;
	
	return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
 
int main(void){
    int a,b,sum;

    while(scanf("%d %d", &a, &b) != -1){
        sum = a+b;
        int i = 1;

        while(sum/10 != 0){
            sum = sum/10;
            i++;
        }
            printf("%d\n",i);
    }
    return 0;
}

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

void run(void){
  int n,t;
  scanf("%d%d",&n,&t);
  int *cnt=(int *)calloc(t+1,sizeof(int));
  while(n--){
    int l,r;
    scanf("%d%d",&l,&r);
    cnt[l]++;
    cnt[r]--;
  }
  int max=cnt[0];
  for(int i=1;i<=t;i++){
    cnt[i]+=cnt[i-1];
    if(cnt[i]>max) max=cnt[i];
  }
  printf("%d\n",max);
}

int main(void){
  run();
  return 0;
}



Measured memory_bytes: 2240
fn main() {
    let n = read();
    let s = solve(n);
    write(s);
}

fn read() -> i32 {
    let mut l1 = String::new();
    std::io::stdin().read_line(&mut l1).ok();
    l1.trim().parse::<i32>().unwrap()
}

fn write(s: &str) {
    println!("{}", s);
}

fn solve(n: i32) -> &'static str {
    let m = n % 10;
    match m {
        2 | 4 | 5 | 7 | 9 => "hon",
        0 | 1 | 6 | 8 => "pon",
        3 => "bon",
        _ => unimplemented!(),
    }
}


Measured memory_bytes: 2080
#include <stdio.h>

int main () {
	int h, w, n;
	scanf("%d", &h);
	scanf("%d", &w);
	scanf("%d", &n);
	
	int count = 0, result = 0;
	while ( n > result) {
		if ( w >= h) {
			result += w;
			count++;
		}
		else if ( h  > w) {
			result += h;
			count++;
		}
	}
	printf("%d", count);
	return 0;
}

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

int main(){
    int N;
    cin>>N;
    int res = N;
    for(int i=0;i<=N;i++){
        int cc = 0;
        int t = i;
        while(t>0)cc+=t%6,t/=6;
        t = N - i;
        while(t>0)cc+=t%9,t/=9;
        if(res>cc)res = cc;
    }
    cout<<res<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
template <class T> inline bool chmin(T &a, T b) {if (a > b){a = b;return true;}return false;}
template <class T> inline bool chmax(T &a, T b) {if (a < b){a = b;return true;}return false;}

int main(){
    int n; cin >> n;
    int ans = 0;
    for(int i=1; i<=n; i++) {
        if(to_string(i).size() % 2) {
            ans++;
        }
    }
    cout << ans << endl;

}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cmath>
#include <string>

using namespace std;
typedef long long ll;

int main(){
  int a, b, x;cin>>a>>b>>x;
  if(a<=x&&x<=a+b){
    cout<<"YES"<<endl;
  }else{
    cout<<"NO"<<endl;
  }

}

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

int main(void){

  string a,b;
  cin>>a>>b;
  int can = 0;
  for(int i=0;i<a.length();++i){
  rotate(a.begin(),a.begin()+1,a.end());
  if(a==b){
      can = 1;
      break;
  }
  }
  
  if(can){
      cout<<"Yes";
  }
  else{
      cout<<"No";
  }

}

Measured memory_bytes: 256
import sys
input=sys.stdin.readline
N=int(input())
m=[]
a=[-float("inf"), float("inf")]
b=[-float("inf"), float("inf")]
for _ in range(N):
    x, y = map(int, input().split())
    a[0] = max(a[0], x+y)
    a[1] = min(a[1], x+y)
    b[0] = max(b[0], x-y)
    b[1] = min(b[1], x-y)
print(max(abs(a[0]-a[1]), abs(b[0]-b[1])))


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

#define dk23      ios_base :: sync_with_stdio(false);
#define inp       freopen("input.txt","r",stdin);
#define ll        long long

int main()
{
    ll n,k;
    cin>>n>>k;
    if(n%k==0){
        cout<<0<<endl;
    }
    else{
        cout<<min(n,k-(n%k))<<endl;
    }
    return 0;
}


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

int main(){
  int N,M,dr,ti,ans;
  cin >> N;
  vector<int>ques(N);
  for (int i=0; i<N; i++){
    cin >> ques.at(i);
  }
  cin >> M;
  for (int i=0; i<M; i++){
    cin >> dr >> ti;
    dr--;
    ans = 0;
    for (int j=0; j<N; j++){
      if (j==dr){
        ans += ti;
      }else{
        ans += ques.at(j);
      }
    }
    cout << ans << endl;
  }
}

Measured memory_bytes: 256
from collections import Counter

n = int(input())
d = list(map(int, input().split()))
m = int(input())
t = list(map(int, input().split()))

cd = Counter(d)
ct = Counter(t)

ans = "YES"
for k, v in ct.items():
    if cd[k] < v:
        ans = "NO"

print(ans)


Measured memory_bytes: 57056
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.HashMap;
import java.util.Map;

public class Main {
	public static void main(String[] args) throws Exception {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String[] sa = br.readLine().split(" ");
		int n = Integer.parseInt(sa[0]);
		int k = Integer.parseInt(sa[1]);
		sa = br.readLine().split(" ");
		int[] a = new int[n];
		for (int i = 0; i < n; i++) {
			a[i] = Integer.parseInt(sa[i]) - 1;
			a[i] %= k;
		}
		br.close();

		int[] b = new int[n + 1];
		for (int i = 0; i < n; i++) {
			b[i + 1] = b[i] + a[i];
			b[i + 1] %= k;
		}

		long ans = 0;
		Map<Integer, Integer> map = new HashMap<>();
		for (int i = 0; i < b.length; i++) {
			addCntMap(map, b[i]);
			if (i >= k) {
				delCntMap(map, b[i - k]);
			}
			ans += map.get(b[i]) - 1;
		}
		System.out.println(ans);
	}

	static void addCntMap(Map<Integer, Integer> map, Integer key) {
		if (map.containsKey(key)) {
			map.put(key, map.get(key) + 1);
		} else {
			map.put(key, 1);
		}
	}

	static void delCntMap(Map<Integer, Integer> map, Integer key) {
		if (key != null && map.containsKey(key)) {
			int val = map.get(key);
			if (val == 1) {
				map.remove(key);
			} else {
				map.put(key, val - 1);
			}
		}
	}
}


Measured memory_bytes: 61296
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
constexpr ll MOD = 1e9 + 7;
//constexpr ll MOD = 998244353;
//constexpr ll MOD = ;
ll mod(ll A, ll M) {return (A % M + M) % M;}
constexpr ll INF = 1LL << 60;
template<class T> bool chmin(T& a, T b) {if (a > b) {a = b; return true;} return false;}
template<class T> bool chmax(T& a, T b) {if (a < b) {a = b; return true;} return false;}
ll divceil(ll A, ll B) {return (A + (B - 1)) / B;}
#define FINALANS(A) do {cout << (A) << '\n'; exit(0);} while (false)

int main()
{
  ll D;
  cin >> D;
  if (D == 25)
    FINALANS("Christmas");

  cout << "Christmas ";
  ll X = 25 - D;
  for (ll i = 0; i < X; i++)
  {
    cout << "Eve" << ((i == X - 1) ? '\n' : ' ');
  }
}

Measured memory_bytes: 256
import itertools
n,c=map(int,input().split())
C=[i for i in range(c)]
D=[]
for i in range(c):
  Di=[int(i) for i in input().split()]
  D.append(Di)
C0,C1,C2=[],[],[]
for i in range(n):
  ci=[int(i) for i in input().split()]
  for j in range(n):
    if (i+j)%3==0:
      C2.append(ci[j])
    elif (i+j)%3==1:
      C0.append(ci[j])
    else:
      C1.append(ci[j])
C0C,C1C,C2C=[],[],[]
for i in range(c):
  c0,c1,c2=0,0,0
  for j0 in range(len(C0)):
    c0+=D[C0[j0]-1][i]
  for j1 in range(len(C1)):
    c1+=D[C1[j1]-1][i]
  for j2 in range(len(C2)):
    c2+=D[C2[j2]-1][i]
  C0C.append(c0)
  C1C.append(c1)
  C2C.append(c2)
ans=float("inf")
for i,j,k in itertools.permutations(C,3):
  ans=min(ans,C0C[i]+C1C[j]+C2C[k])
print(ans)

Measured memory_bytes: 5248
n,k=[int(i) for i in input().split()]
p=[(int(i)+1)/2 for i in input().split()]

ans=0
sum_num=sum(p[:k])
for i in range(n-k+1):
    if i==0:
        sum_num = sum(p[:k])
    else:
        sum_num+=p[i+k-1]-p[i-1]
    ans=max(ans,sum_num)
print(ans)

Measured memory_bytes: 32000
import java.util.Scanner;

public class Main {
    public static void main(String[] c) {
        Scanner scan = new Scanner(System.in);
        int ftMonth = scan.nextInt();
        int ftDay = scan.nextInt();
        int scMonth = scan.nextInt();
        int scDay = scan.nextInt();

        if (ftMonth != scMonth) {
            System.out.println(1);
        } else {
            System.out.println(0);
        }
    }
}


Measured memory_bytes: 22740
import sys
input = sys.stdin.buffer.readline

#sys.setrecursionlimit(10**9)
#from functools import lru_cache

def RD(): return sys.stdin.read()
def II(): return int(input())
def MI(): return map(int,input().split())
def MF(): return map(float,input().split())
def LI(): return list(map(int,input().split()))
def LF(): return list(map(float,input().split()))
def TI(): return tuple(map(int,input().split()))
# rstrip().decode()

from collections import defaultdict
from heapq import *

def main():
	t=II()
	while t:
		t-=1
		n,a,b,c,d=MI()
		Q=[-n,0]
		heapify(Q)
		D=defaultdict(lambda:10**18)
		D[n]=0
		k=n+1
		while Q:
			now=-heappop(Q)
			#print(now,"a")
			if now==0:
				print(D[0])
				break

			if now<k:
				q2,r2=divmod(now,2)
				q3,r3=divmod(now,3)
				q5,r5=divmod(now,5)

				#print(now)
				if D[q5]>D[now]+c+r5*d:
					D[q5]=D[now]+c+r5*d
					heappush(Q,-q5)
				if r5!=0 and D[q5+1]>D[now]+c+(5-r5)*d:
					D[q5+1]=D[now]+c+(5-r5)*d
					heappush(Q,-q5-1)

				if D[q3]>D[now]+b+r3*d:
					D[q3]=D[now]+b+r3*d
					heappush(Q,-q3)
				if r3!=0 and D[q3+1]>D[now]+b+(3-r3)*d:
					D[q3+1]=D[now]+b+(3-r3)*d
					heappush(Q,-q3-1)

				if D[q2]>D[now]+a+r2*d:
					D[q2]=D[now]+a+r2*d
					heappush(Q,-q2)
				if r2!=0 and D[q2+1]>D[now]+a+(2-r2)*d:
					D[q2+1]=D[now]+a+(2-r2)*d
					heappush(Q,-q2-1)

				D[0]=min(D[0],D[now]+now*d)







if __name__ == "__main__":
	main()


Measured memory_bytes: 11492
#include <bits/stdc++.h>
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; }

using ll = long long;

const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int INF = 1<<30;
const ll mod = 1000000007LL;

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

int main(){
    int N,K;
    cin>>N>>K;
    vector<int> v(N);
    rep(i,N) cin>>v[i];
    sort(v.begin(),v.end());
    int ans = 0;
    rep(i,K) ans+=v[i];
    cout<<ans<<endl;
}

Measured memory_bytes: 3628
# -*- coding: utf-8 -*-
import sys
sys.setrecursionlimit(10**9)
INF=10**18
MOD=10**9+7
input=lambda: sys.stdin.readline().rstrip()
YesNo=lambda b: bool([print('Yes')] if b else print('No'))
YESNO=lambda b: bool([print('YES')] if b else print('NO'))
int1=lambda x:int(x)-1

def main():
    N=int(input())
    if N>999:
        print('ABD')
    else:
        print('ABC')

if __name__ == '__main__':
    main()


Measured memory_bytes: 38640
#include<stdio.h>
#define MAX 50
int fibonacci(int);
int F[MAX];
int main(){
  int n,sum,i;
  for(i=0;i<50;i++)F[i] = -1;
  scanf("%d",&n);
  sum  = fibonacci(n);

  printf("%d\n",sum);

  return 0;
}

int fibonacci(int n){
  if(n == 0 || n == 1)return F[n] = 1;
  if(F[n] != -1)return F[n];
  else return F[n] = fibonacci(n-2)+fibonacci(n-1);
}

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

int main(){

    int n;
    cin >> n;
    vector<int> a(n);
    int amax = 0;

    for(int i = 0; i < n; ++i){
        cin >> a.at(i);
        amax = max(a.at(i), amax);
    }

    for(int i = 0; i < n; ++i){
        if(a.at(i) == amax){
            a.at(i) = 0;
            break;
        } 
    }

    for(int i = 0; i < n; ++i){
        if(a.at(i) == 0)cout << *max_element(a.begin(), a.end()) << endl;
        else cout << amax << endl;
    }

}

Measured memory_bytes: 2432
import java.util.Deque;
import java.util.HashMap;
import java.util.LinkedList;
import java.util.Queue;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		
		Deque<Integer> queue = new LinkedList<>();
		Deque<String> name = new LinkedList<>();
		
		int time = 0;
		int n = sc.nextInt();
		int q = sc.nextInt();
		
		for(int i=0;i<n;i++)
		{
			name.add(sc.next());
			queue.add(sc.nextInt());
		}
		
		while(queue.size()>0)
		{
			queue.addLast(queue.poll()-q);//减去
			name.addLast(name.poll());
			time += q; //时间累加
			if(queue.peekLast()<=0)
			{
				//以P2为例
				//P1 150 - 100 50 p1 50 time =100
				//p2 80 -20  -20+200 180
				time += queue.pollLast();
				System.out.println(name.pollLast()+" "+time);
			}
			
		}
		
		

		
	}
}



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

long long func(string S, int idx, long long sum) {
	if (idx == S.size()) {
		return sum;
	}

	long long res = 0;
	long long t = S[idx] - '0';
	for(int l = 1; idx + l <= S.size(); ++l) {
		res += func(S, idx + l, sum + t);
		if (idx + l < S.size())
			t = t * 10 + S[idx + l] - '0';
	}
	return res;
}

void solve(string S){
	long long res = func(S, 0, 0);
	cout << res << endl;
}

int main(){	
	string S;
	cin >> S;
	solve(S);
	return 0;
}



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

int main()
{
    int ans = 0;
    string s, t;
    cin >> s >> t;
    rep(i, s.size()) {
        if (s[i] != t[i]) ans++;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3916
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <cmath>
#include <climits>

#define X first
#define Y second
#define vsort(v) sort((v).begin(), (v).end())
#define vrev(v) reverse((v).begin(), (v).end())

// stoi(s): string to int
// stod(s): string to double

// INT_MAX
// INT_MIN
// LLONG_MAX
// LLONG_MIN
// DBL_MIN
// DBL_MAX
// LDBL_MIN
// LDBL_MAX

// A-Z: 65~90
// a-z: 97~122
// |a-z| = 26

using namespace std;
using ll = long long;

int main(int argc, const char * argv[]) {
    int d;
    cin >> d;
    switch (d) {
        case 25:
            cout << "Christmas" << endl;
            break;
        case 24:
            cout << "Christmas Eve" << endl;
            break;
        case 23:
            cout << "Christmas Eve Eve" << endl;
            break;
        case 22:
            cout << "Christmas Eve Eve Eve" << endl;
            break;
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
typedef long double ld;
const int inf=1e9+7;
const ll longinf=1LL<<60;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define F first
#define S second
 
const int mx=200010;
const ll mod=1e9+7;

int main(){  
  int n,c;
  cin >> n >> c;
  vector<int> w(n,0);
  vector<int> v(n,0);
  vector<vector<ll>> dp(110, vector<ll>(mx,longinf));
  rep(i,n){ cin >> w[i] >> v[i]; }
  dp[0][0]=0;
    
  rep(i,n){ rep(j,100010){
    dp[i+1][j+v[i]] = min(dp[i+1][j+v[i]], dp[i][j]+w[i]);
    dp[i+1][j] = min(dp[i+1][j], dp[i][j]);
  } }

  ll ans=0;
  rep(i,100010){ if(dp[n][i]<=c){ ans=i; } }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 173952
#include <bits/stdc++.h>
#define ll long long
#define mk make_pair
using namespace std;
const int N = 1e5 + 5;
const int mod = 998244353;
const int g = 3;
inline ll Pow(ll a, int x) {
	ll res = 1;
	while (x) {
		if (x & 1) res = res * a % mod;
		a = a * a % mod;
		x >>= 1;
	}
	return res;
}
void NTT(int *a, int n, int rev) {
	for (int i = 0, j = 0; i < n; ++i) {
		if (i > j) swap(a[i], a[j]);
		for (int k = n >> 1; (j ^= k) < k; k >>= 1);
	}	
	for (int i = 2; i <= n; i <<= 1) {
		int m = i >> 1;
		int w = Pow(g, (mod - 1) / i);
		if (rev == -1) w = Pow(w, mod - 2);
		for (int j = 0; j < n; j += i) {
			ll Wx = 1;
			for (int k = 0; k != m; k++) {
				ll z = a[j + m + k] * Wx % mod;
				a[j + m + k] = a[j + k] - z + mod;
				if (a[j + m + k] >= mod) a[j + m + k] -= mod;
				a[j + k] = a[j + k] + z;
				if (a[j + k] >= mod) a[j + k] -= mod;
				Wx = Wx * w % mod;
			}
		}
	}
	if (rev == -1) {
		ll inv = Pow(n, mod - 2);
		for (int i = 0; i < n; i++) a[i] = a[i] * inv % mod;
	}
}
ll fac[N], inv[N];
char A[N], B[N];
int n, a, b, len;
int aa[N], bb[N], cc[N], dd[N];
void solve(int x) {
	if (x == 0) {
		for (int i = 1; i < len; i++) aa[i] = 0;
		aa[0] = 1;
		return;
	}
	if (x == 1) {
		for (int i = 0; i < len; i++) aa[i] = 0; 
		for (int i = 0; i <= a; i++) aa[i] = inv[i + 1];
		return;
	}
	solve(x / 2);
	if (x & 1) {
		for (int i = 0; i < len; i++) bb[i] = 0;
		for (int i = 0; i <= a; i++) bb[i] = inv[i + 1];
		NTT(aa, len, 1);
		NTT(bb, len, 1);
		for (int i = 0; i < len; i++) bb[i] = (ll)bb[i] * aa[i] % mod;
		NTT(bb, len, -1);
		for (int i = a + 1; i < len; i++) bb[i] = 0;
		NTT(bb, len, 1);
		for (int i = 0; i < len; i++) aa[i] = (ll)aa[i] * bb[i] % mod;
		NTT(aa, len, -1);
		for (int i = a + 1; i < len; i++) aa[i] = 0;
	} else {
		NTT(aa, len, 1);
		for (int i = 0; i < len; i++) aa[i] = (ll)aa[i] * aa[i] % mod;
		NTT(aa, len, -1);
		for (int i = a + 1; i < len; i++) aa[i] = 0;
	}
}
int main() {
	fac[0] = 1;
	for (int i = 1; i < N; i++) fac[i] = fac[i - 1] * i % mod;
	inv[N - 1] = Pow(fac[N - 1], mod - 2);
	for (int i = N - 2; i >= 0; i--)
		inv[i] = inv[i + 1] * (i + 1) % mod;
	scanf("%s", A + 1);
	scanf("%s", B + 1);
	n = strlen(A + 1);
	for (int i = 1; i <= n; i++) {
		if (A[i] == '1' && B[i] == '1') a++;
		if (A[i] == '1' && B[i] == '0') b++;
	}
	len = 1;
	while (len <= 2 * a) len <<= 1;
	solve(b);
	ll ans = 0;
	for (int i = 0; i <= a; i++) {
		ans += (ll)aa[i] * fac[a] % mod;
		ans %= mod;
	}
	ans *= fac[b] * fac[a + b] % mod;
	ans %= mod;
	cout << ans << endl;
} 

Measured memory_bytes: 2048
def b_sort(lst):
  limit = len(lst) - 1
  cnt = 0
  while limit:
    for i in range(limit):
      if lst[i] > lst[i + 1]:
        lst[i], lst[i + 1] = lst[i + 1], lst[i]
        cnt += 1
    limit -= 1
  return cnt

while True:
  n = int(input())
  if n == 0:
    break
  alst = []
  for _ in range(n):
    alst.append(int(input()))
  print(b_sort(alst))


Measured memory_bytes: 5596
a = int(input())
b = int(input())
c = int(input())
x = int(input())

ans = 0
for i in range(a+1):
    for j in range(b+1):
        for k in range(c+1):
            if 500*i + 100*j + 50*k == x :
                ans += 1

print(ans)


Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
 
int main() {
  int n, a, b;
  cin >> n;
  vector<tuple<string, int, int>> A(n);
  vector<int> B(n);
  rep(i, n) {
    cin >> get<0>(A[i]) >> get<1>(A[i]);
    get<1>(A[i]) = -get<1>(A[i]);
  }
  rep(i , n){
    get<2>(A[i]) = i+1;
  }

  sort(A.begin(), A.end());
  //reverse(A.begin(), A.end());
  rep(i, n) cout << get<2>(A[i]) << endl;
 
}

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

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    cout.precision(10);
    cout<<fixed;
#ifdef _DEBUG
    freopen("input.txt", "r", stdin);
#endif
	int x[3];
	for (auto &i : x) cin>>i;
	swap(x[0], x[1]);
	swap(x[0], x[2]);
	for (auto i : x) cout<<i<<" ";
	cout<<"\n";
	return 0;
}

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

using namespace std;

#define ll long long
#define M 1005000
#define ii pair<ll, ll>
#define iii pair<ll, ii>
#define fi first
#define se second
#define pb push_back
#define all(x) (x).begin(),(x).end()

ll n, m, id, a, b;
map<ll, ll> ac, wa;
string s;

int main(){
    ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    
    cin >> n >> m;
    for (int i = 1; i <= m; i++){
        cin >> id >> s;
        if (s == "AC" && ac[id] == 0) ac[id]++; 
        else if (s == "WA" && ac[id] == 0) wa[id]++;
    }
    for (int i = 1; i <= n; i++){
        if (ac[i] > 0) a++, b += wa[i];
    }
    cout << a << ' ' << b;
    return 0;
}


Measured memory_bytes: 12800
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i ++)
#define rep1(i, n) for(int i = 1; i <= (int)(n); i ++)
#define MP make_pair

using namespace std;
typedef long long LL;
typedef pair<int, int> PII;
const int MOD = 998244353;

int n, m, v, p;
int a[100005];

int main()
{
	scanf("%d%d%d%d", &n, &m, &v, &p);
	rep(i, n) scanf("%d", &a[i]);
	
	sort(a, a + n);
	reverse(a, a + n);
	LL ps = 0;
	int ans = p;
	for(int i = p; i < n; i ++) {
		ps += a[i - 1];
		if(a[i] + m < a[p - 1]) continue;
		int hv = min(p - 1 + n - i, v);
		if(1LL * (a[i] + m) * (i - p + 1) < ps + 1LL * m * (v - hv)) continue;
		ans ++;
	}
	printf("%d\n", ans);
	return 0;
}

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

int main()
{
    ll a, b, n;
    cin >> a >> b >> n;
    ll x = min(n, b - 1);
    ll ans = a*x/b - a*(x/b);
    cout << ans << endl;
    return 0;
}

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

using ll = long long;
using ull = unsigned long long;
using st = string;
using db = double;
using vll = vector<long long>;
using vdb = vector<db>;
using vvll = vector<vll>;
using vst = vector<st>;
using vchar = vector<char>;
using pll = pair<ll, ll>;
using vpll = vector<pll>;
using vvpll = vector<vpll>;
#define rep(i, m, n) for (ll i = (ll)(m); i < (ll)(n); i++)
#define vrep(i, vec) for(auto& i : vec)
#define vin(vec) for(auto& i : vec) cin >> i
#define all(v) v.begin(), v.end()
template<class T> inline bool chmin(T& a, T b){if(a > b){a = b;return true;} return false;}
template<class T> inline bool chmax(T& a, T b){if(a < b){a = b;return true;} return false;}
const ll mod = 1000000007;
const ll inf = 1LL << 60;


int main(){
  db r;
  cin >> r;
  cout << fixed << setprecision(3);
  cout << r * 3.141592 * 2 << endl;
}


Measured memory_bytes: 3792
#include <iostream>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <cmath>
#include <algorithm>
#include <utility>
#include <functional>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const int MOD = 1000000007;
const double EPS = 1e-9;


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

int a,b,h;
cin>>a>>b>>h;
cout << (a + b) * h / 2 << endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
#define pb push_back
#define pf push_front
#define ff first
#define ss second
#define vll vector<ll>
#define pll pair<ll, ll>
#define vpll vector<pll>
#define endl "\n"
const ll maxn = 2*(1e5 + 5);
const ll mod = 1e9+7;

int main()
{
    ll i, j, k, t, n, m, a[maxn], maxi, mini, c=0;

    cin>>n>>k;

    for ( i = 1; i <= 200001; i++)
    {
        c+=i;
        a[i]=c;
    }
    ll ans=0;
    for ( i = k; i <= n; i++)
    {
        maxi = a[n]-a[n-i];
        mini = a[i-1];

        ans+= (maxi-mini+1)%mod;
        ans%=mod;
    }
    cout<<(ans+1)%mod<<endl;


    return 0;
}

Measured memory_bytes: 5208
#include <algorithm>
#include <cassert>
#include <cctype>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstring>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <vector>
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
//#define cerr if(false) cerr
#ifdef DEBUG
#define show(...) cerr << #__VA_ARGS__ << " = ", debug(__VA_ARGS__);
#else
#define show(...) 42
#endif
using namespace std;
using ll = long long;
using pii = pair<int, int>;
template <typename T, typename S>
ostream &operator<<(ostream &os, pair<T, S> a) {
    os << '(' << a.first << ',' << a.second << ')';
    return os;
}
template <typename T>
ostream &operator<<(ostream &os, vector<T> v) {
    for (auto x : v) os << x << ' ';
    return os;
}
void debug() {
    cerr << '\n';
}
template <typename H, typename... T>
void debug(H a, T... b) {
    cerr << a;
    if (sizeof...(b)) cerr << ", ";
    debug(b...);
}
int main(){
    int n, x;
    cin >> n >> x;
    int ans = 1;
    int d = 0;
    rep(i,n){
        int a;
        cin >> a;
        d += a;
        if(d <= x)ans++;
    }
    cout << ans << endl;
}

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

using namespace std;

int main(){
  vector <int> a, b, c;
  int tmp;
  int n;
  cin >> n;
  cin.ignore();

  for(int i = 0; i < n; i++){
    cin >> tmp;
    a.push_back(tmp - 1);
  }
  cin.ignore();
  for(int i = 0; i < n; i++){
    cin >> tmp;
    b.push_back(tmp);
  }
  cin.ignore();
  for(int i = 0; i < n - 1; i++){
    cin >> tmp;
    c.push_back(tmp);
  }
  cin.ignore();

  int sum = accumulate(b.begin(), b.end(), 0);

  for (int i = 0; i < n - 1; i++){
    if(a[i+1] == a[i] + 1){
      sum += c[a[i]];
    }
  }
  cout << sum << endl;
  return 0;
}


Measured memory_bytes: 256
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		// 整数の入力
        int n = sc.nextInt();
   	    HashSet hs = new HashSet();
        for(int i = 0;i < n; i++){
			hs.add(sc.nextInt());
        }
        System.out.println(hs.size());
    }
}

Measured memory_bytes: 35804
#include <bits/stdc++.h>
using namespace std;
const string ANS3[] = {
  "aa.",
  "..b",
  "..b"
};
const string ANS4[] = {
  "aacd",
  "bbcd",
  "efgg",
  "efhh"
};
const string ANS5[] = {
  "aabc.",
  "..bcd",
  "eff.d",
  "e.ghh",
  "iigjj"
};
const string ANS6[] = {
  "aabbcc",
  "ddeeff",
  "g.h.i.",
  "g.h.i.",
  ".j.k.l",
  ".j.k.l"
};
const string ANS7[] = {
  "aabbc..",
  "d...cee",
  "d.fgg..",
  "hhf.i..",
  ".j..ikk",
  ".j...lm",
  "..nn.lm"
};

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

  if (n < 3) cout << -1 << endl;
  else if (n == 3)
  {
    for (int i = 0; i < 3; i++)
      cout << ANS3[i] << '\n';
  }
  else
  {
    vector<string> a(n, string(n, '.'));
    int nn = n;
    while (nn > 7)
    {
      for (int i = 0; i < 4; i++)
        for (int j = 0; j < 4; j++)
          a[nn - 4 + i][nn - 4 + j] = ANS4[i][j];
      nn -= 4;
    }
    for (int i = 0; i < nn; i++)
      for (int j = 0; j < nn; j++)
        if (nn == 4) a[i][j] = ANS4[i][j];
        else if (nn == 5) a[i][j] = ANS5[i][j];
        else if (nn == 6) a[i][j] = ANS6[i][j];
        else a[i][j] = ANS7[i][j];

    set<char> col[1010], row[1010];
    for (int i = 0; i < n; i++)
      for (int j = 0; j < n; j++)
        if (a[i][j] != '.')
        {
          row[i].insert(a[i][j]);
          col[i].insert(a[i][j]);
        }
    for (int i = 0; i < n; i++)
    {
      assert(col[i].size() == 3);
      assert(row[i].size() == 3);
    }
    for (int i = 0; i < n; i++)
      cout << a[i] << '\n';
  }
}


Measured memory_bytes: 2688
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
#include <stdio.h>
#include <queue>
#include <deque>
#include <cstdio>
#include <set>
#include <map>
#include <bitset>
#include <stack>
#include <cctype>
using namespace std;
int main() {
	long long x;
	cin >> x;
	for (long long i = -1000; i * i * i < x; i++) {
		for (long long j = 100000; j * j * j > -1000000000; j--) {
			if (i * i * i * i * i - j * j * j * j * j == x) {
				cout << i << " " << j << endl;
				return 0;
			}
		}
	}
	return 0;
	return 0;
}

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

int main() {
	int n, m;
	cin >> n >> m;
	int s[n], t[n], c[n];
	for (int i = 0; i < n; i++) {
		cin >> s[i] >> t[i] >> c[i];
		c[i]--;
	}
	int a[30][100002]{};
	for (int i = 0; i < n; i++) {
		a[c[i]][s[i]]++;
		a[c[i]][t[i] + 1]--;
	}
	for (int i = 0; i < 30; i++) {
		for (int j = 1; j <= 100000; j++) {
			a[i][j] += a[i][j - 1];
		}
	}
	int ans = 0;
	for (int i = 0; i <= 100000; i++) {
		int count = 0;
		for (int j = 0; j < 30; j++) {
			count += min(1, a[j][i]);
		}
		ans = max(ans, count);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 13184
import java.util.Scanner;
import java.text.DecimalFormat;

class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int inta = sc.nextInt();
        int intb = sc.nextInt();
        if(inta<1 || 1e9<inta){
            System.exit(-1);
        }else if(intb<1 || 1e9<intb){
            System.exit(-1);
        }
        double doublea = inta;
        double doubleb = intb;
        DecimalFormat n = new DecimalFormat();
        System.out.println(inta/intb + " " + inta%intb + " " + String.format("%f", doublea/doubleb));
    }
}

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

using namespace std;
typedef long long ll;

int main()
{
    ll a,b,k;
    cin >> a >> b >> k;
    ll bla  = k&1;
    ll temp = 0;
    temp = min(a,k);
    a -= temp;
    k -= temp;
    temp = min(b,k);
    b -= temp;
    cout << max(a,0ll) << ' ' << max(b,0ll) << endl;



}


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

void main()
{
    auto nmc = readln.split.to!(int[]);
    auto N = nmc[0];
    auto M = nmc[1];
    auto C = nmc[2];

    auto bs = readln.split.to!(int[]);
    int cnt;
    foreach (_; 0..N) {
        int d;
        foreach (i, a; readln.split.to!(int[])) {
            auto b = bs[i];
            d += a * b;
        }
        if (d + C > 0) ++cnt;
    }
    writeln(cnt);
}

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

int main(){
    int x,y,c,t;
    cin >> x >> y;
    t = (y/2)-x;
    c = 2*x - (y/2);
    if(y%2==0 && c>=0 && t>=0){cout << "Yes\n";}
    else{cout << "No\n";}
    return 0;
}


Measured memory_bytes: 3612
#include <bits/stdc++.h>
#include <iomanip>
using namespace std;
int main(){
  int a,b,c;
  cin >> a >> b >> c;
  if(c*c == a*a + b*b){
    int S = a*b/2;
    cout << S << endl;
  }
  if(b*b == a*a + c*c){
    int S = a*c/2;
    cout << S << endl;
  }
  if(a*a == b*b + c*c){
    int S = b*c/2;
    cout << S << endl;
  }
     
}


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

using namespace std;

typedef long long int ll;
typedef long double ld;
inline void debugMode() {
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif // ONLINE_JUDGE
}
inline void PrintYes() { cout << "YES\n"; }
inline void PrintNo() { cout << "NO\n"; }

const int NMax = 1005;

int DP[300];

ll ret = 0;

void BK(int lvl, int k, int ans) {
    if(lvl > k) {
        if(ans % 2 == 0) {
            ret++;
        }
        return;
    }

    BK(lvl + 1, k, ((DP[lvl] - 1) * ans) % 10);
    BK(lvl + 1, k, ((DP[lvl]) * ans) % 10);
    BK(lvl + 1, k, ((DP[lvl] + 1) * ans) % 10);
}
int main(){
    //debugMode();

    int n;
    cin >> n;

    for(int i = 1; i <= n; ++i) cin >> DP[i];

    BK(1, n, 1);

    cout << ret;
    return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize("O3")
#include<bits/stdc++.h> 
using namespace std;
using ll=long long;
using P=pair<ll,ll>;
template<class T> using V=vector<T>; 
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
const ll inf=(1e18);
const ll mod=998244353;
//const ll mod=1000000007;
ll GCD(ll a,ll b) {return b ? GCD(b,a%b):a;}
ll LCM(ll c,ll d){return c/GCD(c,d)*d;}
struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}} __init;
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
struct mint{
    using ull=unsigned long long int;
    ull v;
    mint(ll vv=0){s(vv%mod+mod);}
    mint& s(ull vv){
        v=vv<mod?vv:vv-mod;
        return *this;
    }
    //オーバーロード
    mint operator-()const{return mint()-*this;}//mint型にキャスト
    mint&operator+=(const mint&val){return s(v+val.v);}
    mint&operator-=(const mint&val){return s(v+mod-val.v);}
    mint&operator*=(const mint&val){
        v=ull(v)*val.v%mod;
        return *this;
    }
    mint&operator/=(const mint&val){return *this*=val.inv();}
    mint operator+(const mint&val){return mint(*this)+=val;}
    mint operator-(const mint&val){return mint(*this)-=val;}
    mint operator*(const mint&val){return mint(*this)*=val;}
    mint operator/(const mint&val){return mint(*this)/=val;}
    mint pow(int n)const{
        mint res(1),x(*this);
        while(n){
            if(n&1)res*=x;
            x*=x;
            n>>=1;
        }
        return res;
    }
    mint inv()const{return pow(mod-2);}
    //拡張ユークリッドの互除法
    /* mint inv()const{
        int x,y;
        int g=extgcd(v,mod,x,y);
        assert(g==1);
        if(x<0)x+=mod;
        return mint(x);
    }*/
    friend ostream& operator<<(ostream&os,const mint&val){
        return os<<val.v;
    }//出力
    bool operator<(const mint&val)const{return v<val.v;}
    bool operator==(const mint&val)const{return v==val.v;}
    bool operator>(const mint&val)const{return v>val.v;}
};
mint dp[3005][3005];
bool used[3005][3005];
int main(){
  ll n,s;
  cin>>n>>s;
  V<ll> a(n);
  for(int i=0;i<n;i++)cin>>a[i];
  used[0][0]=true;
    mint ans=0;
    dp[0][0]=1;
  for(int i=0;i<n;i++){
      for(int j=0;j<=s;j++){
        if(used[i][j]&&j+a[i]<=s){
            dp[i+1][j+a[i]]+=dp[i][j];
            used[i+1][j+a[i]]=true;
         }
         if(used[i][j]){
           used[i+1][j]=true;
           dp[i+1][j]+=dp[i][j]*mint(2);
         }
      }
  }
  cout<<dp[n][s]<<"\n";
}

Measured memory_bytes: 83036
#define _GLIBCXX_DEBUG

#include"bits/stdc++.h"
using namespace std;

//loops
#define REP(i,n) for(int i=0;i<(ll)(n);i++)
#define REPD(i,n) for(int i=(ll)(n)-1;i>=0;i--)
#define OneToN(i,n) for(int i=1;i<(ll)(n+1);i++)
#define ZeroToN(i,n) for(int i=0;i<(ll)(n+1);i++)
#define AToB(i,a,b) for(int i=a;i<(ll)(b+1);i++)
#define FOR(i,a,b) for(int i=(a);i<=(b);i++)
#define FORD(i,a,b) for(int i=(a);i>=(b);i--)

//bitsearch
#define BITSEARCH(bit, n) for (int bit = 0; bit < (1<<n); ++bit)
#define isOne(bit, i) bit & (1<<i)


//arrays
#define ALL(x) (x).begin(),(x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define add push_back


#define remove_unique(v) v.erase(unique(ALL(v)), v.end())

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

//pair
#define fir first
#define sec second
#define mp make_pair

//types
#define ll long long
#define vec vector
#define cord2d pair<int,int>
//UNCOMMENT WHEN NEEDED
//#define int ll

//input
template <class T> T get(){ T s; cin >> s; return(s);}
#define gi get<int>()
#define gs get<string>()

template <class T> vector<T> getv(int n) { vec<T> v(n); REP(i, n) cin >> v[i]; return v; }
#define gim(n) getv<int>(n)
#define gsm(n) getv<string>(n)

//output
void print(int a){ cout << a << endl; }
void print(long long a){ cout << a << endl; }
void print(string a){ cout << a << endl; }
void print(char a){ cout << a << endl; }
void print(double a){ cout << a << endl; }
void print(double a, int dig){ cout << std::setprecision(dig) << a << endl; }

template <class T>ostream &operator<<(ostream &o,const vector<T>&v)
{o<<"{";for(int i=0;i<(int)v.size();i++)o<<(i>0?", ":"")<<v[i];o<<"}";return o;}

template <class T = int>
void print(vec<T> v){ cout << v << endl; }

template <class T = int>
void print2dVec(vec<vec<T>> v2d){for(vec<T> v: v2d) {print(v);}}

void YesNo1(bool i = true){ return print(i?"Yes":"No"); }
void YESNO2(bool i = true){ return print(i?"YES":"NO"); }

//debug output
#define var_name(var) #var
template <class T> void debug(T &var, int nest = 0, string before = "") { cout << string("          ", nest) << before; print(var); }

//name replacement
#define y0 y0__
#define y1 y1__
#define j0 j0__
#define j1 j1__

//bool lambdas
#define lamb(exp) [](auto i){return exp;}
#define isEven [](int i){return i % 2 == 0;}
#define isOdd [](int i){return i % 2 != 0;}

//constants
const ll INF = 1e18;
const int MOD = 10000007;

//maths
int factorial(int k){ int sum = 1; for (int i = 1; i <= k; ++i) { sum *= i; } return sum; }
int gcd(int a, int b) {
    if (b == 0)
        return a;
    return gcd(b, a % b);
}

////////////////////

void Main() {
    //code here
    int n = gi, x = gi;
    vec<int> nums = gim(n);
    int value = 0;
    int res = 1;
    REP(i, n) {
        value += nums[i];
        if (value <= x) res += 1;
    }
    print(res);
}

signed main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    Main();
}


Measured memory_bytes: 256
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String {
            bytes
                .by_ref()
                .map(|r| r.unwrap() as char)
                .skip_while(|c| c.is_whitespace())
                .take_while(|c| !c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, [ $t:tt ]) => {
        {
            let len = read_value!($next, usize);
            (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
        }
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

#[allow(unused_imports)]
use std::cmp::{min, max};

fn main() {
    input!{
        n: usize,
        mut v: [usize; n]
    }
    let mut f = true;
    loop {
        let es = v.iter().filter(|&x| x % 2 == 0).count();
        if es % 2 == 1 {
            println!("{}", if f {"First"} else {"Second"});
            return;
        } else if n - es > 1 {
            println!("{}", if f {"Second"} else {"First"});
            return;
        }
        let mut g = 0;
        for i in 0..n {
            if v[i] == 1 {
                println!("{}", if f {"Second"} else {"First"});
                return;
            }
            if v[i] % 2 == 1 {
                v[i] -= 1;
            }
            g = gcd(g, v[i]);
        }
        for i in 0..n {
            v[i] /= g;
        }
        f ^= true;
    }
}

fn gcd(n: usize, m: usize) -> usize {
    let mut l = min(n, m);
    let mut r = max(n, m);
    while l > 0 {
        let t = l;
        l = r % l;
        r = t;
    }
    r
}


Measured memory_bytes: 4352
import java.io.*;
class Main
{
    public static void main(String args[])throws IOException
    {
	BufferedReader input=new BufferedReader(new InputStreamReader(System.in));
	String str;
	
	while((str=input.readLine())!=null)
	    {
		for(int i=0;i<str.length();)
		    {
			
			if(str.charAt(i)=='@')
			    {
				int n=Integer.parseInt(str.charAt(i+1)+"");
				
				i+=2;
				for(int j=0;j<n-1;j++)
				    {
					
					System.out.print(str.charAt(i));
					
				    }
			    }
			else 
			    {
				System.out.print(str.charAt(i));
				i++;
			    }
		    }
		System.out.println();
	    }
	
    }
}

Measured memory_bytes: 16876
#include<iostream>

using namespace std;

int main() {

	int N,max,look=1,i;
	int Mount[100];

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

	max = Mount[0];

	for (i = 1; i < N; i++) {
		if (max < Mount[i]) {
			max = Mount[i];
			look = look + 1;
		}
		else if (max == Mount[i])
			look = look+1;
	}

	printf("%d", look);
	 
	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;
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const int INF = (1<<30) - 1;
const ll LINF = (1LL<<60) - 1;

int main(){
    int n;
    cin >> n;
    vector<int> a(n);
    vector<vector<pii>> t(n);
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
        int x, y;
        for (int j = 0; j < a[i]; ++j) {
            cin >> x >> y;
            x--;
            t[i].push_back(pii(x, y));
        }
    }

    int res = 0;
    for (int i = 0; i < (1<<n); ++i) {
        vector<bool> v(n, false);
        for (int j = 0; j < n; ++j) {
            if (i & (1<<j)) v[j] = true;
        }

        for (int j = 0; j < n; ++j) {
            if (!v[j]) continue;

            for (auto &p : t[j]) {
                if (p.second == 1 && !v[p.first]) goto next;
                if (p.second == 0 && v[p.first]) goto next;
            }
        }
        chmax(res, __builtin_popcount(i));
        next:;
    }
    cout << res << endl;
}

Measured memory_bytes: 3588
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll MOD = 1e9+7;
int main(){
  ios::sync_with_stdio(0);
  cin.tie(0);
  ll n,d;
  cin >> n >> d;
  d = 2*d+1;
  if(n%d == 0) cout << n/d;
  else cout << n/d+1;
  return 0;
}

Measured memory_bytes: 256
from collections import Counter
n=int(input())
a=list(map(int, input().split()))
l=[i+a for i,a in enumerate(a)]
r=[i-a for i,a in enumerate(a)]
cl=Counter(l)
cr=Counter(r)
ans=0
for j in cl.keys():
  ans+=cl[j]*cr[j]
print(ans)

Measured memory_bytes: 63452
#include <iostream>
#include <vector>
#include <queue>
#include <utility>
#include <math.h>
#include <functional>
using namespace std;

typedef long long ll;

int v, e, r;
struct edge{
	int cost;
	int to;
};
vector<edge> edges[100001];


int main(){
	
	
	
	cin >> v >> e >> r;
	for(int i = 0;i < e;i ++){
		int s, t, d;
		cin >> s >> t >> d;
		edge pre = {d, t};
		edges[s].push_back(pre);
	}
	ll ans[100001];
	for(int i = 0;i < 100001;i ++) ans[i] = 2001001001;
	ans[r] = 0;
	
	typedef pair<ll, ll> P;
	priority_queue<P, vector<P>, greater<P> > pq;
	
	pq.push(P(0,r));
	while(!pq.empty()){
		P miria = pq.top();
		pq.pop();
		r = miria.second;
		if(ans[r] < miria.first){
			continue;
		}
		for(int i = 0;i < edges[r].size();i ++){
			if(ans[edges[r][i].to] > ans[r] + edges[r][i].cost){
				pq.push(P(ans[r] + edges[r][i].cost, edges[r][i].to));
				ans[edges[r][i].to] = ans[r] + edges[r][i].cost;
			}
		}
	}
	
	for(int i = 0;i < v;i ++){
		if(ans[i] < 2001001000) cout << ans[i] << endl;
		else cout << "INF" << endl;
	}
	
	return 0;
}


Measured memory_bytes: 14520
#include <iostream>

using namespace std;

int main()
{
    int a, b, c;
    cin>>a>>b>>c;
    if(a<=b && a<=c)
    {
        if(b<=c) cout<<a<<" "<<b<<" "<<c;
        else cout<<a<<" "<<c<<" "<<b;
    }
    else
    if(b<=a && b<=c)
    {
        if(a<=c) cout<<b<<" "<<a<<" "<<c;
        else cout<<b<<" "<<c<<" "<<a;
    }
    else
    if(c<=a && c<=b)
    {
        if(a<=b) cout<<c<<" "<<a<<" "<<b;
        else cout<<c<<" "<<b<<" "<<a;
    }
    cout<<"\n";
    return 0;
}


Measured memory_bytes: 3092
N=gets.to_i
as=gets.split.map(&:to_i)
s=Array.new(N+1,0)
for i in 1..N
    s[i]=s[i-1]+as[i-1]
end
cnt=Float::INFINITY
N.times do |i|
    j=(s[i]-s[N]+s[i]).abs
    cnt=j<cnt ? j : cnt
end
puts cnt

Measured memory_bytes: 17668
dice=input().split()
dice=[int(s) for s in dice]
deg=list(input())
for i in deg:
    if i=="E":
        dice[0],dice[2],dice[5],dice[3]=dice[3],dice[0],dice[2],dice[5]
    if i=="W":
        dice[0],dice[2],dice[5],dice[3]=dice[2],dice[5],dice[3],dice[0]
    if i=="N":
        dice[0],dice[1],dice[5],dice[4]=dice[1],dice[5],dice[4],dice[0]
    if i=="S":
        dice[0],dice[4],dice[5],dice[1]=dice[4],dice[5],dice[1],dice[0]
print(dice[0])


Measured memory_bytes: 5612
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <unordered_map>
#include <functional>
#include <utility>
#include <tuple>
#include <cctype>
#include <bitset>
#include <complex>
#include <cmath>
#include <array>
#include <numeric>
using namespace std;
#define INF 0x3f3f3f3f
#define INFLL 0x3f3f3f3f3f3f3f3fLL
//#define mod 998244353
#define MOD 1000000007
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define eb emplace_back
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int, int> pint;
typedef pair<ll,ll> pll;
typedef tuple<int,int,int> tint;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<ull> vull;
typedef vector<pint> vpint;
int dx[8]={0,0,-1,1,1,1,-1,-1};
int dy[8]={-1,1,0,0,1,-1,1,-1};
const int SIZE=550;
//↑templete
int main() {
	string S;
	cin>>S;
	if(S[0]=='S')
		cout<<"Cloudy"<<endl;
	else if(S[0]=='C')
		cout<<"Rainy"<<endl;
	else
		cout<<"Sunny"<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<list>
#include<map>
#include<algorithm>

using namespace std;

int main()
{
    string s1, s2;
    cin >> s1 >> s2;

    bool flag = true;

    if (s1[0] != s2[2]) {
        flag = false;
    }
    if (s1[1] != s2[1]) {
        flag = false;
    }
    if (s1[2] != s2[0]) {
        flag = false;
    }

    if (flag) {
        puts("YES");
    } else {
        puts("NO");
    }

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,N) for (int i = 0; i < (N); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;
int main(void){
  int N, K;
  cin >> N >> K;
  int x[N];
  rep(i,N) cin >> x[i];

  int sum = 0;
  rep(i,N){
    sum += min( 2 * x[i], abs(2 * (K - x[i])));
  }

  cout << sum << endl;
}


Measured memory_bytes: 3600
#include <iostream>
using namespace std;
 
int main() {
	long n,a=1,b,c=1;
	cin>>n;
	for(int i=0;i<n;i++){
		b=(a*c)%1000000007;
		c=b;

		a++;
	}
	cout<<b<<endl;
	return 0;
}

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

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

    map<int, int> even, odd;

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

        if (i % 2) even[x]++;
        else odd[x]++;
    }

    int mx1 = 0;
    int mx2 = 0;
    int v1 = 0;

    for (const auto& e : even) {
        if (e.second > mx1) {
            mx2 = mx1;
            mx1 = e.second;
            v1 = e.first;
        } else {
            mx2 = max(mx2, e.second);
        }
    }

    int ans = n;
    for (const auto& o : odd) {
        if (o.first == v1) {
            ans = min(ans, n - o.second - mx2);
        } else {
            ans = min(ans, n - o.second - mx1);
        }
    }

    cout << ans << endl;
    
    return 0;
}

Measured memory_bytes: 4992
#include <iostream>
#include <stdio.h>

#define ll long long

using namespace std;

ll n, a[100007], hero, res = 0;

int main()
{
	cin >> n;
	for (int i = 1; i <= n + 1; ++ i) cin >> a[i];
	for (int i = 1; i <= n; ++ i)
	{
		cin >> hero;
		ll t0 = min(hero, a[i]);
		res += t0;
		hero -= t0;
		ll t1 = min(hero, a[i + 1]);
		res += t1;
		a[i + 1] -= t1;
	}
	cout << res;
}

Measured memory_bytes: 1024