akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,n) for(int i=(a);i<(n);i++)
#define per(i,a,n) for(int i=(n)-1;i>=(a);i--)
#define MP make_pair

typedef double db;

const db EPS = 1e-8;

inline int sign(db a) {
	return a < -EPS ? -1 : a > EPS;
}

struct P {
	db x, y;
	P() {
	}
	P(db _x, db _y) :
			x(_x), y(_y) {
	}
	P operator+(P p) {
		return P(x + p.x, y + p.y);
	}
	P operator-(P p)  {
		return P(x - p.x, y - p.y);
	}
	P operator*(db d) {
		return P(x * d, y * d);
	}
	P operator/(db d) {
		return P(x / d, y / d);
	}
	bool operator<(P p) const {
		int c = sign(x - p.x);
		if (c)
			return c == -1;
		return sign(y - p.y) == -1;
	}
	db dot(P p) {
		return x * p.x + y * p.y;
	}
	db det(P p) {
		return x * p.y - y * p.x;
	}
	db distTo(P p) { return (*this-p).abs(); }

	db alpha() {
		return atan2(y, x);
	}
	void read() {
		cin>>x>>y;
	}
	db abs() {
		return sqrt(abs());
	}
	db abs2() {
		return x * x + y * y;
	}
	P rot90(){
		return P(-y,x);
	}
};

#define cross(p1,p2,p3) ((p2.x-p1.x)*(p3.y-p1.y)-(p3.x-p1.x)*(p2.y-p1.y))
#define crossOp(p1,p2,p3) sign(cross(p1,p2,p3))

P isSS(P p1, P p2, P q1, P q2) {
	db a1 = cross(q1, q2, p1), a2 = -cross(q1, q2, p2);
	return (p1 * a2 + p2 * a1) / (a1 + a2);
}

bool isMiddle(db a, db m, db b) {
    return sign(a - m) == 0 || sign(b - m) == 0 || (a < m != b < m);
}
 
bool isMiddle(P a, P m, P b) {
    return isMiddle(a.x, m.x, b.x) && isMiddle(a.y, m.y, b.y);
}

bool onSegment(P p1, P p2, P q){
	return crossOp(p1,p2,q) == 0 && isMiddle(p1, q, p2);
}

P proj(P p1, P p2, P q) {
    P dir = p2 - p1;
    return p1 + dir * (dir.dot(q - p1) / dir.abs2());
}

P reflect(P p1, P p2, P q){
	return proj(p1,p2,q) * 2 - q;
}

db nearest(P p1,P p2,P q){
	P h = proj(p1,p2,q);
	if(isMiddle(p1,h,p2))
		return q.distTo(h);
	return min(p1.distTo(q),p2.distTo(q));
}

db getrad(P p1,P p2){
	return atan2l(p1.det(p2),p1.dot(p2));
}

db incircle(P p1, P p2, P p3){
	db A = p1.distTo(p2);
	db B = p2.distTo(p3);
	db C = p3.distTo(p1);
	return sqrtl(A*B*C/(A+B+C));
}

int main(){
	int n;cin>>n;
	rep(i,0,n){
		P p1,p2,q1,q2;
		p1.read(),p2.read(),q1.read(),q2.read();
		P a = p2 - p1;
		P b = q2 - q1;

		if(a.det(b) == 0){
			puts("2");
		} else if(a.dot(b) == 0){
			puts("1");
		} else {
			puts("0");
		}
	}

	return 0;
}

Measured memory_bytes: 3216
import java.util.*;
import java.io.*;
public class Main {

	public static void main(String[] args) throws java.lang.Exception
    {		
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		StringTokenizer st=new StringTokenizer(br.readLine());
		int n=Integer.parseInt(st.nextToken()),x=Integer.parseInt(st.nextToken()),t=Integer.parseInt(st.nextToken());
		System.out.println( (int)Math.ceil((n/(float)x))*t);
	}

}

Measured memory_bytes: 32660
def f(n, k):
    if k == 0:
        return 1
    if k == 1 and n < 10:
        return n

    s = str(n)
    length = len(s)

    ans = g(length - 1, k)
    for i in range(1, int(s[0])):
        if 1 < k:
            ans += g(length - 1, k - 1)
        else:
            ans += 1
    if 1 < k:
        ans += f(n % 10 ** (length - 1), k - 1)
    elif k == 1:
        ans += 1
    return ans


def g(n, k):
    if n == 0:
        return 0
    if n < k:
        return 0
    if k == 1:
        return n * 9
    elif k == 2:
        return n * (n - 1) // 2 * 9 ** 2
    elif k == 3:
        return n * (n - 1) * (n - 2) // 6 * 9 ** 3


N = int(input())
K = int(input())
print(f(N, K))

Measured memory_bytes: 38256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;

using System.Collections;

class Program
{
    static void Main()
    {
        int[] ab = Console.ReadLine().Split(' ').Select(s => int.Parse(s)).ToArray();
        int a = ab[0];
        int b = ab[1];


        Console.WriteLine(b % a == 0 ? a + b : b - a);
        
    }
    
}

Measured memory_bytes: 13268
let ans = Scanf.sscanf (read_line ()) "%s %s %s" (fun a b c ->
  [
    int_of_string (a ^ b) + (int_of_string c); 
    int_of_string (a ^ c) + (int_of_string b);
    int_of_string (b ^ a) + (int_of_string c);
    int_of_string (b ^ c) + (int_of_string a);
    int_of_string (c ^ a) + (int_of_string b);
    int_of_string (c ^ b) + (int_of_string a);
  ]
)
let _ = print_endline (string_of_int (List.hd (List.rev (List.sort compare ans))))


Measured memory_bytes: 384
import java.util.Scanner;

public class Main{
    public static void main(String[] args){
        Scanner scan = new Scanner(System.in);
        int a = scan.nextInt();
        int b = scan.nextInt();
        int c = scan.nextInt();
        if(a < b && b < c && a < c){
            System.out.println("Yes");
        }else{
            System.out.println("No");
        }
    }
}


Measured memory_bytes: 26240
//文字列大好きいろはちゃんイージー

#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,x,y) for(int i=x;i<y;i++)
#define gcd(a,b) __gcd(a,b)
#define lcm(a,b) (a/__gcd(a, b)*b)
#define range(a) (a).begin(),(a).end()
#define pb push_back
#define mp make_pair
#define nnn "\n"
const int inf = 2147483647;

int main (){
    int n,l;cin>>n>>l;
    vector<string>s(n);
    rep(i,0,n)cin>>s[i];
    stable_sort(range(s));
    rep(i,0,n)cout<<s[i];
    cout<<nnn;
    return 0;
}

Measured memory_bytes: 256
#include<cstdio>                                          
#include<cctype>                                          
#include<iostream>                                        
using namespace std;                                      
                                                          
int main(){                                               
  char ch;                                                
                                                          
  while(1){                                               
    scanf("%c",&ch);                                      
     if(islower(ch)) printf("%c",toupper(ch));            
       else  printf("%c",tolower(ch));                    
                                                          
    if(ch == '\n') break;                                 
  }                                                       
                                                          
  return 0;                                               
} 

Measured memory_bytes: 3140
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>

using namespace std;

long long computeComb(long long n) {
	return n * (n - 1) / 2;
}


int main() {
	long long N;
	cin >> N;

	long long* count = new long long[N + 1]();
	long long* A = new long long[N];

	for (long long i = 0; i < N; i++) {
		cin >> A[i];


		count[A[i]]++;
	}

	long long sum = 0;
	for (long long i = 0; i < N + 1; i++) {
			sum += computeComb(count[i]);
		
	}

	for (int i = 0; i < N; i++) {
		cout << sum - count[A[i]] + 1 << "\n";
	}
}


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



int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  rep(i, n) {
    cin >> a[i];
    a[i]--;
  }
  int cnt = 0;
  rep(i, n) {
    if (a[a[i]] == i) {
      cnt++;
    }
  }
  cout << cnt/2 << endl;
  return 0;
}

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

int main()
{
    int X, Y, A, B, C, count = 0;
    int64_t answer = 0;
    cin >> X >> Y >> A >> B >> C;
    vector<int> p(A, 0);
    vector<int> q(B, 0);
    vector<int> r(C, 0);
    vector<int> kai(X+Y, 0);

    for (int i = 0; i < A; i++)
    {
        cin >> p.at(i);
    }

    for (int j = 0; j < B; j++)
    {
        cin >> q.at(j);
    }

    for (int k = 0; k < C; k++)
    {
        cin >> r.at(k);
    }
    
    sort(p.begin(), p.end());
    sort(q.begin(), q.end());
    sort(r.begin(), r.end());

    for (int x = 0; x < X; x++)
    {
        kai.at(count) = p.at(A-1-x);
        count++;
    }

    for (int y = 0; y < Y; y++)
    {
        kai.at(count) = q.at(B-1-y);
        count++;
    }

    sort(kai.begin(), kai.end());
    count = 0;

    while (kai.at(count) < r.at(C-1-count))
    {
        kai.at(count) = r.at(C-1-count);
        count ++;
        if (C-1-count == -1)
        {
            break;
        }
        
    }

    for (int z = 0; z < X+Y; z++)
    {
        answer += kai.at(z);
    }

    cout << answer;
    
    
    
    
}

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

ans=0

if A >=K:
  print(K)
  exit()
else:
  ans +=A
  K -= A
  if B >=K:
    ans +=0
    print(ans)
    exit()
  else:
    ans +=0
    K -=B
    ans -= K
    print(ans)
    exit()
  

Measured memory_bytes: 9180
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <bitset>
#include <map>
#include <set>
#include <vector>
#include <list>
#include <queue>
#include <sstream>
#include <cmath>
#include <functional>
#include <climits>
using namespace std;

#define rep(i,n) for(int i=0;i<n;i++)
#define reps(s,i,n) for(int i=s;i<n;i++)
#define rev(i,n) for(int i=n-1;i>=0;i--)
#define skip(i,n,p) for(int i=0;i<n;i+=p)
#define all(a)  (a).begin(),(a).end()
#define int64 long long
#define debug cerr << __FILE__ << ":" << __LINE__ << endl;
#define INF 2147483647

struct Init {
    Init() {
        cin.tie(0);
        ios::sync_with_stdio(false);
        cout.precision(20);
        cout << fixed;
        // setw(6) << setfill('0')
    }
} init;

template <typename _Ty>
ostream& operator << (ostream& ostr, const vector<_Ty>& v) {
    for(int i = 0; i < (int) v.size(); i++) {
        ostr << v[i] << (i + 1 != v.size() ? " " : "");
    }
    return ostr;
}

template <typename _K, typename _V>
ostream& operator << (ostream& ostr, const map<_K, _V>& v) {
    ostr << "{";
    for (auto iter = v.begin(); iter != v.end(); ++iter) {
        ostr << (*iter).first << ": " << (*iter).second << ", ";
    }
    ostr << "}";
    return ostr;
}

template <typename _K>
ostream& operator << (ostream& ostr, const set<_K>& v) {
    for (auto iter = v.begin(); iter != v.end(); ++iter) {
        ostr << *iter << (iter != v.end() ? " " : "");
    }
    return ostr;
}

template <typename _K, typename _V>
ostream& operator << (ostream& ostr, const pair<_K, _V>& v) {
    ostr << "(" << v.first << ", " << v.second << ")";
    return ostr;
}

vector<string> split(const string &s, char delim) {
    vector<string> result;
    stringstream ss(s);
    string item;
    while (getline(ss, item, delim)) {
    if (!item.empty()) {
            result.push_back(item);
        }
    }
    return result;
}

int64 powmod(int64 n, int64 count, int64 mod) {
    if (count == 0) return 1;
    if (count % 2 == 0) {
        int64 t = powmod(n, count / 2, mod);
        return t * t % mod;
    }
    return n * powmod(n, count - 1, mod) % mod;
}

int64 ncr(int64 n, int64 r, int64 mod) {
    int64 a;
    if (n < r) a = min(n, r - n);
    else a = min(n - r, r);

    int64 res = 1;
    rep(i, a) {
        res = res * (n - i) % mod;
        res = res * powmod(i + 1, mod - 2, mod) % mod;
    }

    return res;
}

int main() {
    int n; cin >> n;
    vector<string> l(n); rep(i, n) cin >> l[i];
    int q; cin >> q;
    vector<string> ql(q); rep(i, q) cin >> ql[i];

    map<string, int> m;
    for (auto v : l) m[v]++;
    for (auto v : ql) m[v]--;

    int _max = 0;
    for (auto v : m) _max = max(_max, v.second);

    cout << _max <<  endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<functional>
#include<cmath>
#include<string>
#include<vector>
#include<queue>
using namespace std;
#define ll long long
const int mod = 1000000007;
const ll INF = 1000000000000000000;

int main()
{
	int N;
	string S;
	cin >> N >> S;
	if (N % 2 != 0) {
		cout << "No" << endl;
		return 0;
	}
	for (int i = 0; i < S.size()/2; i++) {
	//	cout << S[i] << " " << S[i + S.size()/2] << endl;
		if (S[i] != S[i + S.size()/2]) {
			cout << "No" << endl;
			return 0;
		}
	}
	cout << "Yes" << endl;
}

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

int maxcost(ll arr[][3],ll n)
    {
        ll dp[n][3];
        
        for(ll i=0;i<3;i++)
            dp[0][i]=arr[0][i];
        
        for(ll i=1;i<n;i++)
        for(ll j=0;j<3;j++)
            {
                if(j==0)
                    dp[i][j] = arr[i][j]+ max(dp[i-1][j+1],dp[i-1][j+2]); 
                else if(j==1)
                    dp[i][j] = arr[i][j]+ max(dp[i-1][j-1],dp[i-1][j+1]); 
                else if(j==2)
                    dp[i][j] = arr[i][j]+ max(dp[i-1][j-1],dp[i-1][j-2]); 
            }
       
        ll a=0;  
        for(ll i=0;i<3;i++)
            a=max(a,dp[n-1][i]);
            
        return a;
    }

int main()
{
    ll n;
    cin>>n;
    
    ll arr[n][3];
    
    for(ll i=0;i<n;i++)
        for(ll j=0;j<3;j++)
            cin>>arr[i][j];
            
            
    cout<<maxcost(arr,n);
    
	return 0;
}

Measured memory_bytes: 8304
#include<cstdio>
#include<cstring>
#include<vector>
#include<queue>
#include<algorithm>
#include<cmath>
#include<cstring>
#include<climits>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
#define reg(i,a,b) for(int i=(a);i<=(b);i++)
#define irep(i,n) for(int i=((int)(n))-1;i>=0;i--)
#define ireg(i,a,b) for(int i=(b);i>=(a);i--)
typedef long long int lli;
typedef pair<int,int> mp;
#define fir first
#define sec second
#define IINF INT_MAX
#define LINF LLONG_MAX

char s[105];

int vd[7][2]={
	{1,2},
	{6,3},
	{1,6},
	{4,5},
	{5,2},
	{2,1},
	{6,6}
};

int main(void){
	while(1){
		scanf("%s",s);
		if(s[0]=='#')break;
		int ls = strlen(s);
		int no=0;
		rep(i,ls){
			no = vd[no][s[i]-'0'];
		}
		if(no==5)printf("Yes\n");
		else printf("No\n");
	}
	return 0;
}

Measured memory_bytes: 948
#include <iostream>

using namespace std;

bool IsPrime(int num)
{
    if (num < 2) {
        return false;
    }

    for (auto i = 2; i * i <= num; i += 1) {
        if (num % i == 0) {
            return false;
        }
    }
    return true;
}

int GetExponent(int factor, int n)
{
    auto exp = 0;
    auto pow = factor;

    while (pow <= n) {
        exp += n / pow;
        pow *= factor;
    }
    return exp;
}

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

    const int kMod = 1e9 + 7;
    auto res = 1;

    for (int i = 2; i <= n; i += 1) {
        if (IsPrime(i)) {
            res = 1LL * res * (GetExponent(i, n) + 1) % kMod;
        }
    }

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


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

#define int         long long
#define pb          push_back
#define pii         pair<int,int>
#define vi          vector<int>
#define vii         vector<pii>
#define mi          map<int,int>
#define mii         map<pii,int>
#define all(a)      (a).begin(),(a).end()
#define sz(x)       (int)x.size()
#define endl        "\n"
#define repp(i,a,b) for(int i=a;i<b;i++)
#define rep(i,a,b) 	for(int i=a;i<=b;i++)
#define IOS         ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);

const int N=1e5 + 5;
const int M=1e9 + 7;

vector<string> v;
int c=1;
int k;

string inttos(int num)
{
    return to_string(num);
}

int stoint(string sss)
{
    return stoi(sss);
}

int32_t main()
{
	IOS;
	//memset(dp,-1,sizeof(dp));	
	cin >> k;
	map<string,int> mp;
	rep(i,1,9)
	{
		v.push_back(to_string(i));
		mp[to_string(i)]=1;
	}
	int i=0;
	while(v.size()<k)
	{
		if(v[i].size()>c)
		{
			c++;
		}
		else
		{
			string s = v[i];
			int cur = s[s.size()-1] - '0';
			int prev  = cur - 1;
			int next  =  cur +1;
			string ss;
			if(prev>=0)
			{
				ss = s + inttos(prev);
				if(mp[ss]==0)
				{
					v.pb(ss);
					mp[ss]=1;
				}
			}
			ss = s + inttos(cur);
			if(mp[ss]==0)
			{
				v.pb(ss);
				mp[ss]=1;
			}
			if(next<=9)
			{
				ss = s + inttos(next);
				if(mp[ss]==0)
				{
					v.pb(ss);
					mp[ss]=1;
				}
			}
			i++;
		}
	}
//	for(string s: v)
//		cout << s << " ";
//	cout << endl;
	cout << v[k-1] << endl;
	
}


Measured memory_bytes: 12020
R,G,B,N = map(int,input().split())
count = 0
for i in range(int(N/R) + 1):
    for j in range(int(N/G) + 1):
        temp = (N - i * R - j * G)/B
        if temp >= 0 and temp - int(temp) == 0:
            count += 1
print(count)

Measured memory_bytes: 41068
#include<iostream>
#include<cstring>
#include<cstdlib>
#include<algorithm>
#include<map>
#include<vector>

#define fs first
#define sc second
using namespace std;
typedef long long ll;
typedef pair<ll,ll> Line;

int deq[10001];
int N,M,D,X;
ll p[10000],x[10000],y[10000];
ll w[101][10000];
ll dp[2][10000];
Line ch[10000];
const ll INF = 1e14;

ll f(int d,int j,int x){
  return w[d][j] * p[x] + dp[d&1][j] - w[d][j]*p[j];
}

bool check(int d, int f1,int f2, int f3){
  ll a1 = w[d][f1], b1 = dp[d&1][f1] - w[d][f1]*p[f1];
  ll a2 = w[d][f2], b2 = dp[d&1][f2] - w[d][f2]*p[f2];
  ll a3 = w[d][f3], b3 = dp[d&1][f3] - w[d][f3]*p[f3];
  return (a2-a1)*(b3-b2) >= (b2-b1)*(a3-a2);
}

int main(){
  cin >> N >> M >> D >> X;
  for(int i=0;i<N;i++)cin >> p[i];

  for(int i=0;i<M;i++){
    cin >> x[i] >> y[i];
    x[i] -= abs(y[i]);
  }
  sort(x,x+M);

  for(int d=0;d<D;d++){
    int cur = 0;
    for(int i=0;i<N;i++){
      while(cur<M && p[i]>x[cur]+d*X)cur++;
      w[d][i] = M-cur;
    }
  }

  for(int i=0;i<N;i++)dp[0][i] = INF;
  dp[0][0] = 0;
  
  for(int i=0;i<D;i++){
    int now = i&1, nxt = 1-now;
    for(int j=0;j<N;j++)dp[nxt][j] = INF;

    int s = 0, t = 1;
    deq[0] = 0;

    for(int j=0;j<N;j++){
      if(j-1>=0){
	while(s+1<t && check(i, deq[t-2], deq[t-1], j-1))t--;
	deq[t++] = j-1;
      }

      while(s+1<t && f(i,deq[s],j) >= f(i,deq[s+1],j))s++;

      dp[nxt][j] = min(dp[nxt][j], dp[now][j]);
      dp[nxt][j] = min(dp[nxt][j], f(i,deq[s],j));
    }
  }

  cout << dp[D&1][N-1] << endl;
}

Measured memory_bytes: 9648
main(){
  int hs[10],i,j,t;
  for (i=0;i<10;i++) scanf("%d",&hs[i]);
  for (i=0;i<3;i++)
    for (j=i+1;j<10;j++)
      if (hs[i]<hs[j]){
        t=hs[i];
        hs[i]=hs[j];
        hs[j]=t;
      }
  for (i=0;i<3;i++) printf("%d\n",hs[i]);
  return 0;
}

Measured memory_bytes: 0
#include<cstdio>
#include<functional>
#include<algorithm>
#include<cstring>
using namespace std;
int main(void)
{
	int n,i,c[4],j;
	char s[4],a[4][4]={"AC","WA","TLE","RE"};
	scanf("%d",&n);
	for(i=0;i<4;i++)	c[i]=0;
	for(i=0;i<n;i++)	{
		scanf("%s",s);
		for(j=0;j<4;j++)	{
			if(strcmp(s,a[j])==0)	c[j]++;
		}
	}
	for(i=0;i<4;i++)	printf("%s x %d\n",a[i],c[i]); 
	return 0;
}

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

#define int long long

#define rep(i,n) for(int i=0;i<(n);i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;

template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}

signed main(){
    map<string,int>m;

    int n;cin>>n;
    rep(i,n){
        string s;cin>>s;
        m[s]++;
    }
    cin>>n;
    rep(i,n){
        string s;cin>>s;
        m[s]--;
    }

    int ans=0;
    for(auto &p:m)chmax(ans,p.se);
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
using namespace std;
int main()
{
	char f[8][8];
	int x,y,i,j;
	while(1)
	{
		x=y=-1;
		for(i=0;i<8;i++)cin >> f[i];
		if(cin.eof())break;
		for(x=0;x<8;x++)
		{
			for(y=0;y<8;y++)
			{
				if(f[x][y]=='1')
				{
					i=x;
					j=y;
					break;
				}
			}
			if(i==x&&j==y)break;
		}
		if(i<7&&j<7&&f[i+1][j]=='1'&&f[i][j+1]=='1'&&f[i+1][j+1]=='1')printf("A\n");
		else if(i<5&&f[i+3][j]=='1')printf("B\n");
		else if(j<5&&f[i][j+3]=='1')printf("C\n");
		else if(i<6&&j>0&&f[i+2][j-1]=='1')printf("D\n");
		else if(i<7&&j<6&&f[i+1][j+2]=='1')printf("E\n");
		else if(i<6&&j<7&&f[i+2][j+1]=='1')printf("F\n");
		else if(i<7&&j<7&&j>0&&f[i][j+1]=='1'&&f[i+1][j-1]=='1')printf("G\n");
	}
	return 0;
}

Measured memory_bytes: 1096
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;

namespace Tasks
{
    public class D
    {
        static void Main(string[] args)
        {
            var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);
            Solve();
            Console.Out.Flush();
        }

        public static void Solve()
        {
            var (N, K) = Scanner.Scan<int, int>();
            var P = Scanner.ScanEnumerable<double>().ToArray();
            P = CumulativeItems(P.Select(x => x + 1)).ToArray();
            var answer = 0.0;
            for (var i = 0; i <= N - K; i++)
            {
                answer = Math.Max(answer, (P[i + K] - P[i]) / 2);
            }
            Console.WriteLine(answer);
        }

        public static IEnumerable<double> CumulativeItems(IEnumerable<double> items)
        {
            var arr = items.ToArray();
            var ret = new double[arr.Length + 1];
            for (var i = 0; i < arr.Length; i++) ret[i + 1] = arr[i] + ret[i];
            return ret;
        }

        public static class Scanner
        {
            private static Queue<string> queue = new Queue<string>();
            public static T Next<T>()
            {
                if (!queue.Any()) foreach (var item in Console.ReadLine().Trim().Split(" ")) queue.Enqueue(item);
                return (T)Convert.ChangeType(queue.Dequeue(), typeof(T));
            }
            public static T Scan<T>() => Next<T>();
            public static (T1, T2) Scan<T1, T2>() => (Next<T1>(), Next<T2>());
            public static (T1, T2, T3) Scan<T1, T2, T3>() => (Next<T1>(), Next<T2>(), Next<T3>());
            public static (T1, T2, T3, T4) Scan<T1, T2, T3, T4>() => (Next<T1>(), Next<T2>(), Next<T3>(), Next<T4>());
            public static (T1, T2, T3, T4, T5) Scan<T1, T2, T3, T4, T5>() => (Next<T1>(), Next<T2>(), Next<T3>(), Next<T4>(), Next<T5>());
            public static IEnumerable<T> ScanEnumerable<T>() => Console.ReadLine().Trim().Split(" ").Select(x => (T)Convert.ChangeType(x, typeof(T)));
        }
    }
}


Measured memory_bytes: 52072
#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() {
    int n;
    cin >> n;

    int odd{};
    for (int i = 0; i <= n; ++i) {
        if (i % 2 != 0) ++odd;
    }
    cout << setprecision(10) << fixed << ((double)odd / n);

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <vector>
#include <utility>
#include <cstdio>
#include <iomanip>
#include <cmath>
#include <string>
#include <stack>
#include <queue>
#include <map>
#include <stdlib.h>
#include <set>
typedef long long ll;
using namespace std;

int main() {
	int n;
	cin>>n;
	if(n<1200){
		cout<<"ABC"<<endl;
	}else{
		cout<<"ARC"<<endl;
	}
	return 0;
}



Measured memory_bytes: 256
fun main(args:Array<String>){
    val k = readLine()!!.toInt()
    val line = readLine()!!.split(" ").map { it.toInt() }
    if((k - line[0]%k)%k <= line[1]-line[0]){
        println("OK")
    }else{
        println("NG")
    }
}

Measured memory_bytes: 36296
#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()
{
    int x, y, z;
    cin >> x >> y >> z;
    printf("%d %d %d\n", z, x, y);
    return 0;
}

Measured memory_bytes: 3748
#include<bits/stdc++.h>
using namespace std;
#define ll long long
const ll mod=1e9+7;
int a[200010];
multiset<int>s;
int main() {
	int n;
	scanf("%d",&n);
	for(int i=1; i<=n; i++)scanf("%d",a+i);
	s.insert(a[1]);
	for(int i=2;i<=n;i++){
		if(a[i]<=*s.begin())s.insert(a[i]);
		else {
			s.insert(a[i]);
			auto x=s.lower_bound(a[i]);
			while(*x==a[i])x--;
			s.erase(x);
		}
	}
	printf("%d\n",s.size());
}

Measured memory_bytes: 5376
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <numeric>
#include <utility>
#include <tuple>

#define REP(i, a, b) for (int i = int(a); i < int(b); i++)
using namespace std;
using ll = long long int;
using P = pair<ll, ll>;

// clang-format off
#ifdef _DEBUG_
#define dump(...) do{ cerr << __LINE__ << ":\t" << #__VA_ARGS__ << " = "; PPPPP(__VA_ARGS__); cerr << endl; } while(false)
template<typename T> void PPPPP(T t) { cerr << t; }
template<typename T, typename... S> void PPPPP(T t, S... s) { cerr << t << ", "; PPPPP(s...); }
#else
#define dump(...) do{ } while(false)
#endif
template<typename T> vector<T> make_v(size_t a, T b) { return vector<T>(a, b); }
template<typename... Ts> auto make_v(size_t a, Ts... ts) { return vector<decltype(make_v(ts...))>(a, make_v(ts...)); }
template<typename T> bool chmin(T &a, T b) { if (a > b) {a = b; return true; } return false; }
template<typename T> bool chmax(T &a, T b) { if (a < b) {a = b; return true; } return false; }
template<typename T> void print(T a) { cout << a << endl; }
template<typename T, typename... Ts> void print(T a, Ts... ts) { cout << a << ' '; print(ts...); }
template<typename T> istream &operator,(istream &in, T &t) { return in >> t; }
// clang-format on

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int d, t, s;
    cin, d, t, s;
    print(s * t >= d ? "Yes" : "No");
    return 0;
}


Measured memory_bytes: 3648
def main():
    N = int(input())
    if N <= 3:
        print(N - 1)
        return
    # (1) 2 <= k <= sqrt(N) で題意を満たすkの個数
    ans_1 = 0
    k = 2
    while k ** 2 <= N:
        n = N
        while n % k == 0:
            n //= k
        n %= k
        if n == 1:
            ans_1 += 1
        k += 1
    # (2) sqrt(N) < k <= N で題意を満たすkの個数
    # sqrt(N)より大きいN-1の約数の個数 + 1 (k = N)
    ans_2 = 1
    n = 1
    while n ** 2 < N:
        if (N - 1) % n == 0 and ((N - 1) // n) ** 2 > N:
            ans_2 += 1
        n += 1
    # 答え
    print(ans_1 + ans_2)


if __name__ == '__main__':
    main()

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

int main(){
    int x,y;
    cin >> x >> y;

    if(y % 2==0){
        if(x*2 <= y && x*4 >= y){
            cout << "Yes\n"; 
        }else{
            cout << "No\n";
        }
    }else{
        cout << "No\n";
    }


    //int end;
    //cin >> end;
    return 0;
}

Measured memory_bytes: 3632
using System;

public class AtCoder{
	public static void Main(){
		string[] s;
		s = NextS();
		
		int n, m;
		n = int.Parse(s[0]);
		m = int.Parse(s[1]);
		 
		int[] num = new int[n];
		bool[] red = new bool[n];
		red[0] = true;
		for (int i = 0; i < n; i++) num[i] = 1;
		int[] x = new int[m];
		int[] y = new int[m];
		for (int i = 0; i < m; i++){
		    s = NextS();
		    x[i] = int.Parse(s[0]) - 1;
		    y[i] = int.Parse(s[1]) - 1;
		}
		
		for (int i = 0; i < m; i++){
		    if(red[x[i]]) red[y[i]] = true;
		    num[y[i]]++;
		    num[x[i]]--;
		    if(num[x[i]] == 0) red[x[i]] = false;
		}
		int ans = 0;
		for (int i = 0; i < n; i++){
		    if(red[i]) ans++;
		}
		
		
		
		Console.WriteLine(ans);
	}

	public static void DebugWL(object x){ System.Diagnostics.Debug.WriteLine(x); }
	public static string[] NextS(){ return Console.ReadLine().Trim().Split(' '); }
}


Measured memory_bytes: 17320
#include<bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0;i<(n);i++)
#define REP2(i,a,b) for(int i=(a);i<(b);i++)
#define ALL(v) (v).begin(),(v).end()
#define INF 2e9
typedef long long ll;

int main()
{
  int n;
  ll k;
  cin>>n>>k;
  vector<pair<int,int>> p(n);
  REP(i,n){
    int a,b;
    cin>>a>>b;
    p[i]=make_pair(a,b);
  }

  sort(ALL(p));
  REP(i,n){
    k-=p[i].second;
    if(k<=0){
      cout<<p[i].first<<endl;
      return 0;
    }
  }

	return 0;
}

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

const long long mod = 1e9 + 7;

using ll = long long;
using pii  = pair<int, int>;
using pll = pair<ll, ll>;
#define ull unsigned long long
#define ld long double
#define vi vector<int>
#define vll vector<ll>
#define vc vector<char>
#define vs vector<string>
#define vpii vector<pii>
#define vpll vector<pll>

#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; i++)
#define rep1(i, n) for (int i = 1, i##_len = (n); i <= i##_len; i++)
#define repr(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rep1r(i, n) for (int i = ((int)(n)); i >= 1; i--)

#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define RSORT(x) sort(rall(x));
#define pb push_back
#define mp make_pair

#define INF (1e9)
#define PI (acos(-1))
#define EPS (1e-7)

ull gcd(ull a, ull b) { return b ? gcd(b, a % b) : a; }
ull lcm(ull a, ull b) { return a / gcd(a, b) * b; }

int main(){
    ll ln;
    cin >> ln;
    for (ll h=1; h<=3500; ++h) for (ll n=1; n<=3500; ++n) {
        ll den = 4*h*n - ln*n - ln*h, num = ln * h * n;
        if (den == 0) continue;
        if (num%den==0 && num/den>0) {
            printf("%lld %lld %lld\n", h, n, num/den);
            return 0;
        }
    }
    return 0;
}


Measured memory_bytes: 3764
import java.util.*;
import java.io.*;
import java.math.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        long n = sc.nextLong();
        System.out.println(solve(n));
    }

    public static long solve(long n){
        if(n % 2 != 0 || n < 10){
            return 0;
        }
        long ret = 0;
        int i=0;
        while(10*Math.pow(5,i) <= n){
            long def = 10*(long)Math.pow(5,i);
            ret += n/def;
            i++;
        }
        return ret;
    }
}

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

#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define all(x) (x).begin(), (x).end()
#define ll long long
#define ii pair<int,int>
#define vi vector<int>
#define vll vector<ll>
#define vii vector<ii>

const int INF = 0x3f3f3f3f;
const ll  LINF = 0x3f3f3f3f3f3f3f3fLL;
const int maxn = 45+10;
const int mod = 1e9+7;

using namespace std;

int32_t main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

	int x;

	cin >> x;

	if(x >= 30) cout << "Yes\n";
	else cout << "No\n";

    return 0;
}



Measured memory_bytes: 3636
#![allow(unused_imports)]
#![allow(unused_variables)]
#![allow(dead_code)]
use proconio::input;
use proconio::marker::*;
use std::cmp::{min, max};
use std::collections::{HashSet, HashMap, BinaryHeap};

struct UnionFind{
    n: usize,
    parent: Vec<usize>,
    size: Vec<usize>,
}

impl UnionFind{
    fn new(n: usize ) -> UnionFind{
        let mut parent = vec![0; n];
        for i in 0..n {
            parent[i] = i;
        }
        let size = vec![1; n];
        UnionFind{n, parent, size}
    }

    fn root(&mut self, x: usize) -> usize{
        if x == self.parent[x]{
            self.parent[x]
        }else{
            let res = self.root(self.parent[x]);
            self.parent[x] = res;
            self.parent[x]
        }
    }

    fn unite(&mut self, x: usize, y: usize){
        let a = self.root(x);
        let b = self.root(y);
        if a == b{
            return;
        }
        if self.size[a] <= self.size[b]{
            self.parent[b] = a;
            self.size[a] += self.size[b];
        }else{
            self.parent[a] = b;
            self.size[b] += self.size[a];
        }
    }

    fn is_same(&mut self, x: usize, y: usize) -> bool{
        self.root(x) == self.root(y)
    }

    fn get_size(&mut self, x: usize) -> usize{
        let a = self.root(x);
        self.size[a]
    }
}

fn main() {
    input! {
        n: usize,
        a: [i64; n],
    }
    let mut ans = 0i64;
    let mut t = a[0];
    for i in 1..n{
        ans += max(t - a[i], 0);
        t = max(t, a[i]);
    }
    println!("{}", ans);
}


Measured memory_bytes: 5424
N,M=map(int,input().split(" "))

B=[0]*(M+1)

for i in range(0,N):
  A=list(map(int,input().split(" ")))
  #print(A)
  for j in range (1,A[0]+1):
    jj=A[j]
    B[jj]+=1
    
#print (B)
print (B.count(N))

Measured memory_bytes: 3060
import std.stdio, std.string, std.conv, std.algorithm;


void main()
{
    int[][] dp = new int[][](1001, 10001);

    int cases = 1;
    while(true)
    {
        int w = readln.chomp.to!int;
        if(!w)break;
        int n = readln.chomp.to!int;
        int[1001] treValue, treWeit;
        foreach(i; 1 .. n + 1)
        {
            auto f = readln.chomp.split(",").map!(to!int);
            treValue[i] = f[0];
            treWeit[i] = f[1];
        }
        foreach(i; 1 .. n + 1)
        {
            foreach(j; 1 .. w + 1)
            {
                if(treWeit[i] > j || dp[i - 1][j - treWeit[i]] + treValue[i] <= dp[i - 1][j])
                {
                    dp[i][j] = dp[i - 1][j];
                }
                else
                {
                    dp[i][j] = dp[i - 1][j - treWeit[i]] + treValue[i];
                }
            }
        }
        int maxValue = int.min, minWeit;
        foreach(i; 1 .. w + 1)
        {
            if(dp[n][i] > maxValue)
            {
                maxValue = dp[n][i];
                minWeit = i;
            }
        }
        writeln("Case ", cases, ":");
        maxValue.writeln;
        minWeit.writeln;
        ++cases;
    }
}

Measured memory_bytes: 41660
N = input()
L = list(map(int, input().split()))
cnt = 0

for i in range(len(L)-2):
    for j in range(i+1,len(L)-1):
        for k in range(j+1,len(L)):
            if L[i]!=L[j] and L[j]!=L[k] and L[k]!=L[i]:
                m = max(list([L[i],L[j],L[k]]))
                if 2*m < L[i]+L[j]+L[k]:
                    cnt += 1

print(cnt)

Measured memory_bytes: 9100
#include<cstdio>
#include<iostream>
#include<cstring>
#include<cmath>
#include<queue>
#include<vector>
#include<cstdlib>5
#include<string>
#include<algorithm>
#define LL long long
#define INF 1000000009
using namespace std;
const int maxn=110;
int main()
{
	int r,g,b;
	scanf("%d %d %d",&r,&g,&b);
	if((r*100+g*10+b)%4)
	printf("NO\n");
	else
	printf("YES\n");
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long  
template <typename T>
bool PN(T x)
{
  if (x <= 1)
    return false;
  if (x == 2)
    return true;
  for (int i = 2; i < sqrt(x) + 1; i++)
    if (x % i == 0)
      return false;
  return true;
}

const long long MOD = 1e9+7;

void solve()
{
  ll n, k;
  scanf("%lld %lld", &n, &k);
  map<int,ll> mp;
  for(int i = 0; i < n; ++i){
    int a, b;
    cin >> a >> b;
    mp[a] += b;
  }
  ll cnt = 0;
  for(auto mm: mp){
    cnt += mm.second;
    if(k <= cnt) {
      cout << mm.first << endl;
      return;
    }
  }  
}

int main()
{
  solve();
  return 0;
}

Measured memory_bytes: 7472
import java.io.*;
import java.util.*;
public class Main {

	public static void main(String[] args) {
		Scanner in=new Scanner(System.in);
		
		int n=in.nextInt();
		List<Card> Am=new ArrayList<>(),Aq=new ArrayList<>();
		for(int i=0;i<n;i++) {
			Card c=new Card();
			c.symbol=in.next().charAt(0); c.num=Integer.parseInt(in.next());
			Am.add(c); Aq.add(c);
		}
		
		Am=mergeSort(Am);
		quickSort(Aq, 0, n-1);
		
		boolean chk=true;
		for(int i=0;i<n;i++) {
			if(Am.get(i).symbol != Aq.get(i).symbol) {
				chk=false;
				break;
			}
		}
		
		PrintWriter out=new PrintWriter(System.out);
		if(chk)out.println("Stable");
		else out.println("Not stable");
		
		for(int i=0;i<n;i++) {
			Card cm=Am.get(i),cq=Aq.get(i);
			out.println(cq.symbol+" "+cq.num);
		}
		out.flush();
	}
	
	static List<Card> mergeSort(List<Card> A){
		int size=A.size();
		if(size==1)return A;
		
		int mid=size/2;
		Queue<Card> l=new ArrayDeque<>(mergeSort(A.subList(0, mid)));
		Queue<Card> r=new ArrayDeque<>(mergeSort(A.subList(mid, size)));
		return merge(l, r);
	}
	
	static List<Card> merge(Queue<Card> A, Queue<Card> B){
		
		List<Card> C=new ArrayList<>();
		
		while(!A.isEmpty() && !B.isEmpty()) {
			
			int a=A.element().num,b=B.element().num;
			
			if(a<=b) C.add(A.remove());
			else C.add(B.remove());
		}
		
		if(A.isEmpty()) while(!B.isEmpty()) C.add(B.remove());
		else while(!A.isEmpty()) C.add(A.remove());
		
		return new ArrayList<Card>(C);
		
	}
	
	static void quickSort(List<Card> A, int p, int r){
		if(p<r) {
			int q=partition(A, p, r);
			quickSort(A, p, q-1);
			quickSort(A, q+1, r);
		}
	}
	
	static int partition(List<Card> A, int p, int r) {
		
		int x=A.get(r).num,i=p-1;
		
		for(int j=p;j<r;j++) {
			if(A.get(j).num<=x) {
				i++;
				Collections.swap(A, i, j);
			}
		}
		i++;
		Collections.swap(A, i, r);
		return i;
	}

}

class Card{
	char symbol=0;
	int num=0;
}



Measured memory_bytes: 119940
#include<cstdio>

#define NUM 5

int main()
{
	int n;
	scanf("%d", &n);

	bool spade[13] = {false};
	bool hart[13] = {false};
	bool club[13] = {false};
	bool dia[13] = {false};

	char suit;
	char str[NUM];
	int rank = 0;

	getchar();

	for (int id = 0; id < n ; id++) {

		
		fgets(str, NUM, stdin);
		sscanf(str, "%c %d", &suit, &rank);

		//printf("suit = %d, id = %d, rank = %d\n", suit,id,rank);

		switch (suit) {
			case 'S':
				scanf(" %d", &rank);
				for (int i = 0; i < 13; i++) {
					if (i+1 == rank)
						spade[i] = true;
				}
				break;
			case 'H':
				scanf(" %d", &rank);
				for (int i = 0; i < 13; i++) {
					if (i+1 == rank)
						hart[i] = true;
				}
				break;
			case 'C':
				scanf(" %d", &rank);
				for (int i = 0; i < 13; i++) {
					if (i+1 == rank)
						club[i] = true;
				}
				break;
			case 'D':
				scanf(" %d", &rank);
				for (int i = 0; i < 13; i++) {
					if (i+1 == rank)
						dia[i] = true;
				}
				break;
			default:
				break;
		}
	}

	for (int i = 0; i < 13; i++) {
		if (spade[i] == false)
			printf("S %d\n",i+1);
	}
	for (int i = 0; i < 13; i++) {
		if (hart[i] == false)
			printf("H %d\n",i+1);
	}
	for (int i = 0; i < 13; i++) {
		if (club[i] == false)
			printf("C %d\n",i+1);
	}
	for (int i = 0; i < 13; i++) {
		if (dia[i] == false)
			printf("D %d\n",i+1);
	}	
	return 0;
}


Measured memory_bytes: 2704
n = gets.to_i
as = gets.chomp.split.map(&:to_i)
as.map!.with_index(1) do |a, i|
  a - i
end
as.sort!
b = as.size % 2 == 0 ? as[as.size / 2 - 1, 2].inject(:+) / 2 : as[as.size / 2]
as.map! do |a|
  (a - b).abs
end
puts as.inject(:+).to_i


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

#define max(a,b) (a>b?a:b)

int mv[4][2] = {{-1,0},{1,0},{0,-1},{0,1}};
int ori[10][10];
int map[10][10];
int fa[100];
int color[100];

int x,y,tar;

int find(int now){
  if(fa[now]==-1)return now;
  return fa[now] = find(fa[now]);
}

void chkun()
{
  int i,j,k;
  int dx,dy;
  for(i=0;i<x;i++){
    for(j=0;j<y;j++){
      for(k=0;k<4;k++){
        dx = i + mv[k][0];
        dy = j + mv[k][1];
        if(0<=dx && dx<x && 0<=dy && dy<y){
          if(find(map[dx][dy])!=find(map[i][j]) && color[find(map[dx][dy])]==color[find(map[i][j])]){
            fa[find(map[dx][dy])] = find(map[i][j]);
          }
        }
      }
    }
  }
}

int dfs(int a,int b, int c, int d, int e){

    int i,j;

    memset(fa,-1,sizeof(fa));
    int cn = 0;
    int tem,total;

    for(i=0;i<x;i++){
      for(j=0;j<y;j++){

        tem = ori[i][j];
        map[i][j] = cn;
        color[cn] = tem;
        cn++;
      }
    }
    chkun();

    color[find(map[0][0])] = a;
    chkun();
    color[find(map[0][0])] = b;
    chkun();
    color[find(map[0][0])] = c;
    chkun();
    color[find(map[0][0])] = d;
    chkun();
    color[find(map[0][0])] = e;
    chkun();

    tem = find(map[0][0]);
    if(color[tem]!=tar)return 0;

    total = 0;
    for(i=0;i<x;i++){
      for(j=0;j<y;j++){
        if(find(map[i][j])==tem)total++;
      }
    }
    return total;

}

int main()
{
  int i,j,k,l,m;
  int ans;
  while(scanf("%d%d%d",&x,&y,&tar)!=EOF){
    if(!(x+y+tar))break;
    for(i=0;i<x;i++){
      for(j=0;j<y;j++){
        scanf("%d",&ori[i][j]);
      }
    }

    ans = 1;
    for(i=1;i<=6;i++){
      for(j=1;j<=6;j++){
        for(k=1;k<=6;k++){
          for(l=1;l<=6;l++){

              ans = max(ans,dfs(i,j,k,l,tar));


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

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

#define int long long
#define double long double
#define ff first
#define ss second
#define endl '\n'
#define ii pair<int, int>
#define mp make_pair
#define mt make_tuple
#define DESYNC                      \
  ios_base::sync_with_stdio(false); \
  cin.tie(0);                       \
  cout.tie(0)
#define pb push_back
#define vi vector<int>
#define vii vector<ii>
#define all(x) x.begin(), x.end()
#define EPS 1e-9
#define INF 1e18
#define ROOT 1
#define M 1000000007
#define curtime chrono::steady_clock::now().time_since_epoch().count
#define rep(i, beg, n, s) for (int i = beg; i < n; i += s)
const double PI = acos(-1);

using namespace std;

inline int mod(int n, int m = M) {
  int ret = n % m;
  if (ret < 0) ret += m;
  return ret;
}

int exp(int n, int k) {
  if (k == 0) return 1;
  if (k == 1) return n;
  int ax = exp(n, k / 2);
  ax = mod(ax * ax);
  if (k % 2) ax = mod(ax * n);
  return ax;
}

int gcd(int a, int b) {
  if (a == 0)
    return b;
  else
    return gcd(b % a, a);
}
//#define MULTIPLE_TEST_CASE
void solution() {
  int n, x;
  cin >> n >> x;
  int cur = 0;
  int ans = 1;
  for (int i = 0; i < n; i++) {
    int l;
    cin >> l;
    cur += l;
    if (cur <= x) ans++;
  }
  cout << ans << endl;
}

int32_t main() {
  DESYNC;
  mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
  int t = 1;
#ifdef MULTIPLE_TEST_CASE
  cin >> t;
#endif
  while (t--) solution();
}


Measured memory_bytes: 3624
using System;
using System.Linq;
using System.Collections.Generic;

namespace program
{
    class Program
    {
        static void Main()
        {
          string w = Input.ScanStr();
          int res=0;
          for(int i=0;i<4;i++) if(w[i]=='2') res++;
          Console.WriteLine(res);
          
        }
    }

    static class Input
    {
        static public int ScanInt() { return int.Parse(Console.ReadLine()); }
        static public uint ScanUint() { return uint.Parse(Console.ReadLine()); }
        static public double ScanDouble() { return double.Parse(Console.ReadLine()); }
        static public long ScanLong() { return long.Parse(Console.ReadLine()); }
        static public ulong ScanUlong() { return ulong.Parse(Console.ReadLine()); }
        static public int[] ScanIntArray() { return Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray(); }
        static public uint[] ScanUintArray() { return Console.ReadLine().Split(' ').Select(x => uint.Parse(x)).ToArray(); }
        static public double[] ScanDoubleArray() { return Console.ReadLine().Split(' ').Select(x => double.Parse(x)).ToArray(); }
        static public long[] ScanLongArray() { return Console.ReadLine().Split(' ').Select(x => long.Parse(x)).ToArray(); }
        static public ulong[] ScanUlongArray() { return Console.ReadLine().Split(' ').Select(x => ulong.Parse(x)).ToArray(); }

        static public string ScanStr() { return Console.ReadLine(); }
        static public string[] ScanStrArray() { return ScanStr().Split(' '); }
    }

    static class MyMath
    {
        public static int GCD(int a, int b)
        {
            Func<int, int, int> gcd = null;
            gcd = (x, y) => y == 0 ? x : gcd(y, x % y);
            return a > b ? gcd(a, b) : gcd(b, a);
        }
        public static ulong GCD(ulong a, ulong b)
        {
            Func<ulong, ulong, ulong> gcd = null;
            gcd = (x, y) => y == 0 ? x : gcd(y, x % y);
            return a > b ? gcd(a, b) : gcd(b, a);
        }
        public static int LCM(int a, int b)
        {
            return a * b / GCD(a, b);
        }
        public static ulong LCM(ulong a, ulong b)
        {
            return a * b / GCD(a, b);
        }
    }
}


Measured memory_bytes: 13140
import sys

if __name__ == '__main__':
    S = sys.stdin.readline().rstrip()

    ls = ['dream', 'dreamer', 'erase', 'eraser']
    lenS = len(S)
    dp = [False for i in range(lenS + 10)]

    dp[0] = True

    for i in range(lenS):
        if not dp[i]:
            continue

        for w in ls:
            if S[i:i+len(w)] == w:
                dp[i+len(w)] = True

    r = 'YES' if dp[len(S)] else 'NO'

    print(r)


Measured memory_bytes: 3956
#include <iostream>
#include<math.h>
#include<list>
#include <algorithm>
#include<set>
#include<vector>
#include<math.h>
#include<map>
using namespace std;
using ll = long long;
using vll = vector<long long>;
using sll = set<long long>;

template<typename T>
T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }

#define in(x) cin >> x
#define out(x) cout << x
#define outn(x) cout << x << '\n'
#define outs(x) cout << x << ' '
#define rep(i,s,e) for(long i=s;i<e;i++)
#define repeq(i,s,e) for(long i=s;i<=e;i++)


int main() {
	ll n,ans=0,tmp;
	in(n);
	vll a(n), b(n), c(n - 1);

	rep(i, 0, n) {
		in(tmp);
		a[i] = tmp - 1;
	}
	rep(i, 0, n) {
		in(b[i]);
	}
	rep(i, 0, n-1) {
		in(c[i]);
	}

	rep(i, 0, n) {
		ans += b[a[i]];
		if (i > 0 && a[i] - a[i - 1] == 1) {
			ans += c[a[i - 1]];
		}
	}

	outn(ans);
	return 0;
}

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

int main()
{
  static char s[200000];
  int K;
  scanf("%s%d",s,&K);
  int n=strlen(s);
  for(int i=0;i<n&&K>0;i++){
    int k=s[i]-'a';
    if(k>0&&26-k<=K){
      K-=26-k;
      s[i]='a';
    }
  }
  s[n-1]='a'+(s[n-1]-'a'+K)%26;
  printf("%s\n",s);
  return 0;
}


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

int main() {
    int x,y;
    char cell[60][60];
    cin >> y >> x;
    for(int i=1;i<=y;i++){
        for(int j=1;j<=x;j++){
            cin >> cell[i][j];
        }
    }
    for(int i=1;i<=y;i++){
        for(int j=1;j<=x;j++){
            if(cell[i][j]=='.'){
                int total=0;
                if(cell[i-1][j]=='#')total++;
                if(cell[i][j-1]=='#')total++;
                if(cell[i+1][j]=='#')total++;
                if(cell[i][j+1]=='#')total++;
                if(cell[i-1][j-1]=='#')total++;
                if(cell[i+1][j-1]=='#')total++;
                if(cell[i-1][j+1]=='#')total++;
                if(cell[i+1][j+1]=='#')total++;
                cell[i][j]=total+'0';
            }
        }
    }
    for(int i=1;i<=y;i++){
        for(int j=1;j<=x;j++){
            cout << cell[i][j];
        }
        cout << endl;
    }
}

Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n,i;
	long long a[200005],x=0,s=0,ans=1e18;
	cin>>n;
	for(i=0;i<n;i++){
		cin>>a[i];
		s+=a[i];
	}
	for(i=0;i<n-1;i++){
		x+=a[i];
		ans=min(ans,abs(2*x-s));
	}
	cout<<ans;
	return 0;
}


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

int main() {
  int a,b;
  cin >> a >> b;
  
  if(a!=1 && b!=1){
    cout << 1 << endl;
  }
  else if(a!=2 && b!=2){
    cout << 2 << endl;
  }
  else{
    cout << 3 << endl;
  }
}

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

typedef struct Point{
  double x,y;
}P;

void koch(int ,P,P);

int main()
{
  P a1,a2;
  int n;
  scanf("%d",&n);

  a1.x=0.0;
  a1.y=0.0;
  a2.x = 100.0;
  a2.y = 0.0;


  printf("%.8f %.8f\n",a1.x,a1.y);
  koch(n,a1,a2);
  printf("%.8f %.8f\n",a2.x,a2.y);

  return 0;

}

void koch(int n, P a1,P a2)
{
  double raz;
  P s,t,u;
  if(n==0) return;
  raz =  M_PI *60.0/180.0;
  s.x= (2.0*a1.x +1.0*a2.x) /3.0;
  s.y= (2.0*a1.y +1.0*a2.y) /3.0;
  t.x= (1.0*a1.x +2.0*a2.x) /3.0;
  t.y= (1.0*a1.y +2.0*a2.y) /3.0;
  u.x = (t.x-s.x)*cos(raz) - (t.y-s.y)*sin(raz) + s.x;
  u.y = (t.x-s.x)*sin(raz) + (t.y-s.y)*cos(raz) + s.y;
  
  
  koch(n-1,a1,s);
  printf("%.8f %.8f\n",s.x ,s.y);
  koch(n-1,s,u);
  printf("%.8f %.8f\n",u.x ,u.y);
  koch(n-1,u,t);
  printf("%.8f %.8f\n",t.x ,t.y);
  koch(n-1,t,a2);
}


  

Measured memory_bytes: 640
#include<iostream>
#include<cstdio>
#define Lens 50
using namespace std;

int n;
int F[Lens];
int main()
{
	F[0] = F[1] = 1;
	for (int i = 2; i <= Lens; i++)
		F[i] = F[i - 1] + F[i - 2];
	cin >> n;
	cout << F[n] << endl;
	return 0;
}


Measured memory_bytes: 3116