akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
using namespace std;

int main(){
  long long A,B;
  cin >> A >> B;
  long long C,D;
  cin >> C >> D;
  long long c = C;
  long long d = D;
  long long tmp;
  if(C<D){
    tmp = C;
    C = D;
    D = tmp;
  }
  long long r = C % D;
  while(r!=0){
    C = D;
    D = r;
    r = C % D;
  }
  long long lcm = c*d/D;
  long long C_first = 0;
  if(A%c == 0){
    C_first = A/c;
  }else{
    C_first = A/c + 1;
  }
  long long C_end = B/c;
  long long D_first = 0;
  if(A%d == 0){
    D_first = A/d;
  }else{
    D_first = A/d + 1;
  }
  long long D_end = B/d;
   long long CD_first = 0;
  if(A%lcm == 0){
    CD_first = A/lcm;
  }else{
    CD_first = A/lcm + 1;
  }
  long long CD_end = B/lcm;
  long long range = B-A + 1;
  long long devided_num = (C_end - C_first + 1) + (D_end - D_first + 1)
   - (CD_end - CD_first + 1);
   long long ans  = range - devided_num;
   if(range - devided_num <= 0){
     ans = 0;
   }
  cout << ans << 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();
        int ans = -1;
        for (int i = 1; i <= N; i++) {
            if (Math.floor(i * 1.08) == N) {
                ans = i;
                break;
            }
        }
        
        System.out.println(ans == -1 ? ":(" : ans);
    }
}


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

using namespace std;

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

int main(){

	string s1,s2,s3;
	cin>>s1>>s2>>s3;

	int i=0,j=0,k=0;
	int turn=1;
	while(true){
		if(turn==1){
			if(s1[i]=='b')turn=2;
			else if(s1[i]=='c')turn=3;
			i++;
		}
		else if(turn==2){
			if(s2[j]=='a')turn=1;
			else if(s2[j]=='c')turn=3;
			j++;
		}
		else if(turn==3){
			if(s3[k]=='a')turn=1;
			else if(s3[k]=='b')turn=2;
			k++;
		}

		if(i==s1.size()+1){
			cout<<"A"<<endl;
			break;
		}
		if(j==s2.size()+1){
			cout<<"B"<<endl;
			break;
		}
		if(k==s3.size()+1){
			cout<<"C"<<endl;
			break;
		}
	}


	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    cin >> n;
    int sn = pow(2, n);
    multiset<int> org;
    for(int i = 0; i < sn; i++)
    {
        int s;
        cin >> s;
        org.insert(s);
    }

    multiset<int> make;
    make.insert(*org.rbegin());
    org.erase(*org.rbegin());
    for(int i = 0; i < n; i++)
    {
        multiset<int> tmp;
        auto itr = make.begin();
        int size = make.size();
        for(int j = 0; j < size; j++)
        {
            auto oitr = org.lower_bound(*itr);
            if(oitr == org.begin())
            {
                cout << "No" << endl;
                return 0;
            }
            oitr--;
            tmp.insert(*oitr);
            org.erase(oitr);
            itr++;
        }
        make.insert(tmp.begin(), tmp.end());
    }
    cout << "Yes" << endl;
}


Measured memory_bytes: 18688
using System;

class Program
{
    static void Main(string[] args)
    {
        var s = Console.ReadLine().Split(' ');
        var a = int.Parse(s[0]);
        var b = int.Parse(s[1]);
        var c = int.Parse(s[2]);

        if (c <= a + b)
        {
            Console.WriteLine("Yes");
        }
        else
        {
            Console.WriteLine("No");
        }
    }
}


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

// 型定義
typedef long long ll;
typedef pair<ll, ll> P;

// forループ
#define REP(i,n) for(ll i=0; i<(ll)(n); ++i)

// 定数宣言
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

// グラフ表現
using Graph = vector<vector<int>>;

// グラフの辺表現
using Edge = map<pair<int,int>,int>;

// n次元配列の初期化。第２引数の型のサイズごとに初期化していく。
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

// 最大公約数
ll gcd(ll a,ll b){
   if (a%b == 0) return(b);
   else return(gcd(b, a%b));
}

// 最小公倍数
ll lcm(ll a, ll b){
    return a/gcd(a, b) * b;
}

int main()
{
    cout << fixed << setprecision(15);
    string w;
    cin >> w;

    map<ll, ll> M;

    REP(i, w.length()){
        M[w[i]]++;
    }

    for(auto iter=M.begin(); iter!=M.end(); iter++){
        if(iter->second % 2 == 1){
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
    return 0;
}

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

using namespace std;

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

	bool _res = false;

	if (N <= 81) 
	{
		int x = 1;
		while (x <= 9)
		{
			if (N % x == 0 && N / x >= 1 && N / x <= 9)
			{
				_res = true;
				break;
			}
			x += 1;
		}
	}

	string res = _res ? "Yes" : "No";
	cout << res << endl;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int x,y,count=0;
    cin>>x>>y;
    for(int i=0;i<x;i++)
        for(int j=0;j<y;j++)
    {
        if(i+j==x && 2*i+4*j==y || i+j==x && 2*j+4*i==y)
            count++;
    }
    if(count>0)
        cout<<"Yes"<<endl;

    else
        cout<<"No";
    cout<<endl;

return 0;

}


Measured memory_bytes: 3612
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using llpair=pair<ll,ll>;
using llvec=vector<ll>;
using llmat=vector<vector<ll>>;
#define llmattp(name,a,b,num) name(a,vector<ll>(b,num))
#define LLINF 1LL<<60
#define ABS(x) ( (x)>0 ? (x) : -(x) )

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

ll gcd(ll a, ll b) {
	if(a==0||b==0) return 0;
	if(a<b) swap(a,b);
	ll tmp = a%b;
	while(tmp!=0) {
		a = b;
		b = tmp;
		tmp = a%b;
	}
	return b;
}

ll lcm(ll a, ll b) {
	return a*b/gcd(a,b);
}

ll factorial(ll x) {
	ll f=1;
	for(ll i=2; i<x; i++) {
		f*=i;
	}
	return f;
}

ll nPr(ll n, ll r) {
	ll result=1;
	for(ll i=r+1; i<=n; i++) result*=i;
	return result;
}

ll nCr(ll n, ll r) {

	if (n == 0) { return 0; }
	if (r == 0) { return 1; }
	if (r == 1) { return n; }
	if (n == r) { return 1; }

	if (r > n / 2) { r = n / 2; }

	double result = 1;
	for (double i = 1; i <= r; i++) {
		result *= (n - i + 1) / i;
	}

	return (ll)result;
}

bool IsPrime(ll num) {
	if (num < 2) return false;
	else if (num == 2) return true;
	else if (num % 2 == 0) return false; // 偶数はあらかじめ除く

	double sqrtNum = sqrt(num);
	for (ll i = 3; i <= sqrtNum; i += 2)
	{
		if (num % i == 0)
		{
			// 素数ではない
			return false;
		}
	}

	// 素数である
	return true;
}

ll GreaterBinarySearch(ll *array, ll key, ll max, ll min) {
	if(array[max]<array[min]) {
		return NULL;
	} else {
		ll mid = max + (min-max)/2;
		if(array[mid]<key) {
			return GreaterBinarySearch(array,key,max,mid-1);
		} if(array[mid]>key) {
			return GreaterBinarySearch(array,key,mid+1,min);
		} else {
			return mid;
		}
	}
}

int main() {
	int n; cin>>n;
	string str[n]; cin>>str[0];
	for(int i=1; i<n; i++) {
		cin>>str[i];
		if(str[i-1].back()!=str[i].front()) {
			cout<<"No"<<endl;
			return 0;
		}
		for(int j=0; j<i; j++) {
			if(str[i]==str[j]) {
				cout<<"No"<<endl;
				return 0;
			}
		}
	}
	cout<<"Yes"<<endl;
}


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

#define debug(x) cerr<<#x<<'='<<x<<'\n'

long long a[66];

const long long n=50;

int main(void) {
	long long k;
	cin>>k;
	for (int i=1; i<=n; i++) {
		a[i]=i+k/n-1;
	}
	k%=50;
	for (int i=1; i<=k; i++) {
		a[i]+=n+1;
	}
	puts("50");
	for (int i=1; i<=n; i++) {
		cout<<a[i]-k<<' ';
	}
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <vector>

using namespace std;

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    
    string a, b, u;
    
    cin >> a >> b;
    
    int x, y;
    cin >> x >> y;
    
    cin >> u;
    if(u == a){
        cout << x-1 << " " << y;
    }
    else{
        cout << x <<" " << y-1;
    }
    

    return 0;
}


Measured memory_bytes: 256
n = int(input())
a = []
for _ in range(n):
    x, y = map(int, input().split())
    a.append(complex(x, y))
ans = 0.0
p = a[0]
for i in range(n - 2):
    q, r = a[i + 1], a[i + 2]
    ans += (((q - p).conjugate() * (r - p)).imag) / 2
print(abs(ans))



Measured memory_bytes: 5628
#include<bits/stdc++.h>
#define ll long long int 
#define pb push_back
#define mp make_pair
#define ff first
#define se second
#define MAX 1000001
#define MAXN 300010
#define mod 1000000007 
using namespace std;

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n,i;
    double count=0,x;
    string s;
    cin>>n;
    for(i=0;i<n;i++){
        cin>>x>>s;
        if(s=="JPY"){
            count+=x;
        }
        else{
            count+=x*380000.0;
        }
    }
    cout<<fixed<<setprecision(5)<<count;
}

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

using namespace std;

int main(){
    int N;
    cin >> N ;
    vector<int> A(N);
    int count = 0;
    int count_1 = 0;
    for(int i =0;i < N;i++){
        cin >> A.at(i);
        if(A.at(i) % 2 ==0){
            count++;
            if(A.at(i)%3 ==0 || A.at(i)%5 == 0){
                count_1++;
            }
        }
    }
    if(count == count_1){
        cout << "APPROVED" << endl;
    }
    else{
        cout << "DENIED" << endl;
    } 
    return 0;
}

Measured memory_bytes: 3556
//basic c++ code is given here

#include<bits/stdc++.h>

using namespace std;


    int answer(int idx){


                return 0 ;

    }




    int main (  )
    {
      char n;
      cin >> n;
        if( (n - 'A') >= 0 && ('Z'- n) >= 0  ) cout << 'A';
        if( (n - 'a') >= 0 && ('z'- n) >= 0 ) cout << 'a' ;
    return 0;
    }


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

int main(){
  string s, t;
  cin >> s >> t;
  sort(s.begin(), s.end());
  sort(t.begin(), t.end());
  reverse(t.begin(), t.end());
  if(s < t) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}


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

template <class Abel> struct BIT {
  vector<Abel> dat[2];
  Abel UNITY_SUM = 0;                     // to be set

  /* [1, n] */
  BIT(int n) { init(n); }
  void init(int n) { for (int iter = 0; iter < 2; ++iter) dat[iter].assign(n + 1, UNITY_SUM); }

  /* a, b are 1-indexed, [a, b) */
  inline void sub_add(int p, int a, Abel x) {
    for (int i = a; i < (int)dat[p].size(); i += i & -i)
      dat[p][i] = dat[p][i] + x;
  }
  inline void add(int a, int b, Abel x) {
    sub_add(0, a, x * -(a - 1)); sub_add(1, a, x); sub_add(0, b, x * (b - 1)); sub_add(1, b, x * (-1));
  }

  /* a is 1-indexed, [a, b) */
  inline Abel sub_sum(int p, int a) {
    Abel res = UNITY_SUM;
    for (int i = a; i > 0; i -= i & -i) res = res + dat[p][i];
    return res;
  }
  inline Abel sum(int a, int b) {
    return sub_sum(0, b - 1) + sub_sum(1, b - 1) * (b - 1) - sub_sum(0, a - 1) - sub_sum(1, a - 1) * (a - 1);
  }

  /* debug */
  void print() {
    for (int i = 1; i < (int)dat[0].size(); ++i) cout << sum(i, i + 1) << ",";
    cout << endl;
  }
};

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

  vector<int> lefts(Q), rights(Q), ids(Q);
  for (int i = 0; i < Q; ++i) {
    cin >> lefts[i] >> rights[i];
    --lefts[i];
    ids[i] = i;
  }
  sort(ids.begin(), ids.end(), [&](int i, int j) {
      return rights[i] < rights[j];});

  BIT<int> bit(N+5);
  vector<int> prev(1100000, -1);
  vector<int> res(Q, 0);
  int r = 0;
  for (auto i : ids) {
    for (; r < rights[i]; ++r) {
      bit.add(prev[a[r]]+2, r+2, 1);
      prev[a[r]] = r;
    }
    int tmp = bit.sum(lefts[i]+1, lefts[i]+2);
    res[i] = max(res[i], tmp);
  }
  for (int i = 0; i < Q; ++i) cout << res[i] << endl;
}


Measured memory_bytes: 21728
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int k = sc.nextInt();
        int a = sc.nextInt();
        int b = sc.nextInt();
        int count = k;
        boolean bool = false;
        while (count<=b){
            if (a<=count&&count<=b)bool=true;
            count+=k;
        }
        if (bool)System.out.println("OK");
        else System.out.println("NG");
    }
}


Measured memory_bytes: 35608
package main

import "fmt"

func main() {
	H := make([]int, 0)
	W := make([]int, 0)
	for {
		var h, w int
		fmt.Scan(&h, &w)
		if h == 0 && w == 0 {
			break
		}
		H = append(H, h)
		W = append(W, w)
	}
	for i := 0; i < len(H); i++ {
		/*
			if i > 0 {
				fmt.Println()
			}
		*/
		for h := 0; h < H[i]; h++ {
			for w := 0; w < W[i]; w++ {
				fmt.Print("#")
			}
			fmt.Println()
		}
		fmt.Println()
	}
}



Measured memory_bytes: 1160
#include<iostream>
#include<stdio.h>
#include<algorithm>
#include<vector>
#include<string.h>
#include<math.h>
#include<map>

using namespace std;

int main(){
	int a,b,c;
	cin >> a >> b >> c;
	if(b-a==c-b){
		cout << "YES" << endl;
	}else{
		cout << "NO" << endl;
	}
	return 0;
	
}


Measured memory_bytes: 256
n,m,x,y = map(int,input().split())
lstx = list(map(int,input().split()))
lsty = list(map(int,input().split()))
max_x = max(lstx)
min_y = min(lsty)
for z in range(x+1,y+1):
    if (max_x<z) and (min_y>=z):
        print('No War')
        exit()
print('War')

Measured memory_bytes: 3064
//AtCoder ABC066 B - ss
#include <bits/stdc++.h>
using namespace std;
using ll=int64_t;

int main() {
    string S;
    cin>>S;
    ll ans=0;
    S.pop_back();
    while(!S.empty()){
        if (S.size()%2==0){
            auto p = S.size()/2;
            if (strncmp(&S[0],&S[p],p) == 0){
                ans=S.size();
                break;
            }
        }
        S.pop_back();
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
using namespace std;
int main(void){
  long long A, B, K;
  cin >> A >> B >> K;
  long long diff = K - A;
  long long out_A, out_B;
  if(diff > 0){
    if(B-diff>0){
      out_A = 0;
      out_B = B - diff;
    }else{
      out_A = 0;
      out_B = 0;
    }
  }else{
    out_A = A - K;
    out_B = B;
  }
  
  cout << out_A << " " << out_B;
  return 0;
}

Measured memory_bytes: 3612
#include<bits/stdc++.h>
using namespace std;
 
#define ff              first
#define ss              second
#define ll              long long
#define dd              double
#define pb              push_back
#define mp              make_pair
#define pii             pair<int,int>
#define vi              vector<int>
#define vll             vector<long long>
#define vdd             vector<double>
#define vpii            vector<pair<int,int>>
#define vpll            vector<pair<long long,long long>>
#define vvi             vector<vector<int>>
#define vvll            vector<vector<long long>>
#define mii             map<int,int>
#define mll             map<long long,long long>
#define umii            unordered_map<int,int>
#define umll            unordered_map<long long,long long>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define rep(i,n)        for(int i=0;i<n;i++)
#define rep2(i,a,b)     for(int i=a;i<b;i++)
#define rev(i,n)        for(int i=n;i>=0;i--)
#define rev2(i,a,b)     for(int i=a;i>=b;i--)
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define inf             9e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define mk(arr,n,type)  type *arr=new type[n];
#define w(x)            int x; cin>>x; while(x--)
#define fio             ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl            '\n'
#define all(x)          x.begin(),x.end()
#define d0(x)           cout <<x<<" "
#define d1(x)           cout <<x<<endl
#define d2(x,y)         cout <<x<<" "<<y<<endl
#define d3(x,y,z)       cout <<x<<" "<<y<<" "<<z<<endl
#define d4(x,y,z,w)     cout <<x<<" "<<y<<" "<<z<<" "<<w<<endl
#define read2(x,y)      cin>>x>>y
#define read3(x,y,z)    cin>>x>>y>>z
#define read4(x,y,z,w)  cin>>x>>y>>z>>w
#define read5(x,y,z,w,a)cin>>x>>y>>z>>w>>a
#define sz(a)           (int)a.size()
const ll mod=1e9+7;
const double PI = 3.14159265359;
const ll MOD=998244353;
void i_o()
{
   #ifndef ONLINE_JUDGE
   freopen("input.txt", "r", stdin);
   freopen("output.txt", "w", stdout);
   #endif
}
vi A,dp;
int n;
int solve(int k){
   if(k==0) return 0;
   if(dp[k]!=-1) return dp[k];
   int& res=dp[k];
   res=0;
   rep(i,n){
      if(A[i]<=k){
         res|=(1-solve(k-A[i]));
      }
   }
   return res;
}
int main() {
   fio
   //i_o();
   int k;
   cin>>n>>k;
   A=vi(n);
   rep(i,n) cin>>A[i];
   dp=vi(k+1,-1);
   if(solve(k)) d1("First");
   else d1("Second");
}



Measured memory_bytes: 5376
#include <iostream>
using namespace std;
int main(void){
    while(1){
    int m, f, r;
    cin>>m>>f>>r;
    if(m==-1&&f==-1&&r==-1) break;
    if(m==-1||f==-1||m+f<30){
        cout<<"F"<<endl;
    }else if(m+f<50){
        if(r<50){
            cout<<"D"<<endl;
        }else{
            cout<<"C"<<endl;
        }
    }else if(m+f<65){
        cout<<"C"<<endl;
    }else if(m+f<80){
        cout<<"B"<<endl;
    }else{
        cout<<"A"<<endl;
    }
    
  }
  
}



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

int n;
int remTaro, remHanako;
bool taro[202], hanako[202];

void play(bool *card, int &rem, int &ba){
  int limMin = (ba == -1 ? 0 : ba + 1);
  int i;

  for(i = limMin; i < 2 * n; i++){
    if(card[i]){
      card[i] = false;
      rem--;
      break;
    }
  }

  if(i == 2 * n){
    ba = -1;
  }
  else{
    ba = i;
  }
}

int main(){
  while(cin >> n, n){
    memset(taro, 0, sizeof(taro));
    memset(hanako, 0, sizeof(hanako));
    remTaro = n;
    remHanako = n;

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

    for(int i = 0; i < 2 * n; i++){
      if(!taro[i]){
        hanako[i] = true;
      }
    }

    int ba = -1;
    bool taroNow = true;

    while(remTaro > 0 && remHanako > 0){
      if(taroNow){
        play(taro, remTaro, ba);
      }
      else{
        play(hanako, remHanako, ba);
      }

      taroNow = !taroNow;
    }

    cout << remHanako << endl;
    cout << remTaro << endl;
  }
}

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

vector<int> union_find_parent;
int union_find_init(int n);
int union_find_unite(int a,int b);
int union_find_root(int a);

int main()
{

	int n,m;
	cin >> n >> m;

	union_find_init(n+1);
	for (int i=0;i<m;++i)
	{
		int a,b;
		cin >> a >> b;
		union_find_unite(a,b);
	}

	map<int,int> rootcount;
	int maxcount=0;
	for (int i=1;i<=n;++i)
	{
		int count=++rootcount[union_find_root(i)];
		maxcount=max(maxcount,count);
	}
	cout << maxcount << endl;
}


int union_find_init(int n)
{
	for (int i=0;i<n;++i)
	{
		union_find_parent.push_back(i);
	}
	return 0;
}

int union_find_unite(int a,int b)
{
	a=union_find_root(a);
	b=union_find_root(b);
	if (a!=b)
	{
		union_find_parent[a]=b;
	}
	return 0;
}

int union_find_root(int a)
{
	if (union_find_parent[a]==a)
	{
		return a;
	}
	else
	{
		return union_find_parent[a]=union_find_root(union_find_parent[a]);
	}
}





Measured memory_bytes: 13444
input = raw_input

a, b, c, d = map(int, input().split(" "))

if a % d == 0:
    r1 = a // d
else:
    r1 = a // d
    r1 += 1

if c % b == 0:
    r2 = c // b
else:
    r2 = c // b
    r2 += 1

if r1 == r2:
    out = "Yes"
elif r1 > r2:
    out = "Yes"
else:
    out = "No"

print(out)

Measured memory_bytes: 64264
N,W=map(int,input().split())
C=[0]*-~W
for _ in[0]*N:
 v,w=map(int,input().split())
 for i in range(W,w-1,-1):
  t=v+C[i-w]
  if t>C[i]:C[i]=t
print(C[W])


Measured memory_bytes: 5916
import java.util.Scanner;

public class Main{
	
	public static void main(String[] args){
		Scanner sc= new Scanner(System.in);
		int N = sc.nextInt();
		int X = sc.nextInt();
		
		int[] array=new int[N];
		for(int i=0;i<N;i++){
			array[i]=sc.nextInt();
		}
		
		int count=1;
		int[] D=new int[N+1];
		D[0]=0;
		
		for(int j=1;j<=N;j++){
			D[j]=D[j-1]+array[j-1];
			if(D[j]<=X)count++;
			else break;
		}
		
		System.out.println(count);
		
	}

}


Measured memory_bytes: 21844
#include<iostream>
#include<set>
#include<vector>
#include<iterator>
#include<utility>
#include<algorithm>
#include<cstdio>
#include<string>

using namespace std;

int main(){
  int T;
  cin>>T;
  cin.ignore(1);
  while(T--){
    set<set<pair<int,int> > >ss[2];
    for(int i=0;i<2;i++){
      string str;
      getline(cin,str);
      for(int j=0;j<6;j++){
	set<pair<int,int> > s;
	int y=0,x=0;
	for(int k=0;;k++){
	  s.insert(make_pair(x,y)).second;
	  if(k==str.size())break;
	  static int dy[]={-1,-1,0,1,1,0};
	  static int dx[]={0,-1,-1,0,1,1};
	  int idx=(j+str[k]-'a')%6;
	  y+=dy[idx];
	  x+=dx[idx];
	}
	int mx=999,my=999;
	for(auto e:s){
	  mx=min(mx,e.first);
	  my=min(my,e.second);
	}
	set<pair<int,int> > ns;
	for(auto e:s){
	  ns.insert(make_pair(e.first-mx,e.second-my));
	}
	ss[i].insert(ns);
      }
    }  
    cin.ignore(2);
    vector<set<pair<int,int> > > v;
    set_intersection(begin(ss[0]),end(ss[0]),begin(ss[1]),end(ss[1]),back_inserter(v));
    cout<<boolalpha<<(!v.empty())<<endl;
  }
}

	
	  

Measured memory_bytes: 1276
/*------------------------------------
........Bismillahir Rahmanir Rahim....
..........created by Abdul Aziz.......
------------------------------------*/
#include <iostream>
#include <algorithm>
#include <stdio.h>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <cstring>
#include <unordered_map>
#include <queue>
#define   mod  998244353
#define   int  long long 
#define   ld   long double
#define   pb   push_back
#define   vi  vector<int> 
#define   dbg(x)  cerr << #x << " = " << x << '\n'
#define   sz(x)  (int)x.size()
#define   all(a) (a.begin(),a.end())
#define   ff   first
#define   ss   second
#define   pii  pair<int,int> 
#define   lcm(a,b) (a*b)/__gcd(a,b) 
using namespace std;

inline void solve(){
    string  s; cin >> s; 
    int  n = sz(s),ans=0; 
    for (int i=0,b=0;i<n;i++) {
    	if (s[i]=='B') b++; 
    	else ans += b;
    }
    cout << ans << endl;
}

signed main()
{
    int n=1; // cin>>n;
    while (n--) solve();
    return 0;
}


Measured memory_bytes: 3708
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define FOR(i, m, n) for (ll i = m; i < n; i++)
#define IFOR(i, m, n) for (ll i = n - 1; i >= m; i--)
#define REP(i, n) FOR(i, 0, n)
#define IREP(i, n) IFOR(i, 0, n)
#define FOREACH(x, a) for (auto&(x) : (a))
#define ALL(v) (v).begin(), (v).end()
#define SZ(x) ll(x.size())

void pr(char c, ll cnt) {
  REP(i, cnt) { cout << c; }
}

int main() {
  vector<vector<ll>> x(2, vector<ll>(2));
  REP(i, 2) {
    REP(j, 2) { cin >> x[i][j]; }
  }
  ll dx = x[1][0] - x[0][0];
  ll dy = x[1][1] - x[0][1];

  pr('D', 1);
  pr('R', dx + 1);
  pr('U', dy + 1);
  pr('L', dx + 1);
  pr('D', dy);
  pr('R', dx);
  pr('U', dy + 1);
  pr('L', dx + 1);
  pr('D', dy + 1);
  pr('R', 1);
  cout << endl;
}

Measured memory_bytes: 256
using System;

namespace ABC113_a
{
    class Program
    {
        static void Main(string[] args)
        {
            int c;
            string[] array = Console.ReadLine().Split(' ');
            int a = int.Parse(array[0]);
            int b = int.Parse(array[1]);
            c = a + b / 2;
            Console.WriteLine(c);
        }
    }
}


Measured memory_bytes: 13140
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <map>
#include <cmath>
#include <set>
#include <algorithm>
#include <iomanip>

typedef long long ll;
const ll MOD = 1e9 + 7;
const long long INF = 1LL<<60;
const double PI=3.14159265358979323846;
const int NMAX=100005;
using namespace std;


int main(){
    ll n, d;
    cin >> n >> d;
    int ans = 0;
    for(int i = 0; i < n; i++){
        ll x, y;
        cin >> x >> y;
        if(x*x+y*y <= d*d) ans++;
    }

    cout << ans << endl;

    return 0;
}

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

int main() {
	
	while(true){
		int m, nmin, nmax;
		cin >> m >> nmin >> nmax;
		
		if(m == 0){
			break;
		}
		
		int a[1000];
		
		for(int i = 0; i < m; i++){
			cin >> a[i];
		}
		
		int mm = 0;
		int ans = 0;
		
		for(int i = nmin; i <= nmax; i++){
			if(a[i - 1] - a[i] >= mm){
				mm = a[i - 1] - a[i];
				ans = i;
			}
		}
		
		cout << ans << endl;
		
	}
	return 0;
}




Measured memory_bytes: 3104
#include <stdio.h>
int main(void){
    long a,b,x;
    scanf("%ld%ld%ld",&a,&b,&x);
    
    long c = a/x, d = b/x;
    long ans = d-c;
    
    if(!(a%x))
    {
        ans++;
    }
    
    printf("%ld",ans);
    return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long int ull;
typedef long long int ll;
typedef long double ld;
#define mod 1000000007
#define pub(a) push_back(a)
#define mp(a,b) make_pair(a,b)

ll gcd(ll a , ll b){
    if(b==0){
        return a;
    }
    else{
        return gcd(b,a%b);
    }
}
ll lcm(ll a,ll b){
    return (a*b)/gcd(a,b);
}
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    ll a,b;
    cin>>a>>b;
    cout<<lcm(a,b);
   
    return 0;
}


Measured memory_bytes: 3592
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.Arrays;

class Main
{
	public static void main(String[] args) throws Exception
	{
		invoke(System.in);
	}
	public final static int	N = 100000;

	public static void	invoke(InputStream is) throws IOException
	{
		// input
		BufferedReader	reader = new BufferedReader(new InputStreamReader(is));
		String	line = reader.readLine();

		boolean[]	isPrime = new boolean[N];

		Arrays.fill(isPrime, true);
		isPrime[0] = false;
		isPrime[1] = false;
		int	sqrtN = (int)(Math.sqrt(N));
		for (int i = 2; i <= sqrtN; ++i)
		{
			if (isPrime[i])
			{
				for (int mul = i + i; mul < N; mul += i)
				{
					isPrime[mul] = false;
				}
			}
		}

		int[]	is2017 = new int[N];
		int	sum2017 = 0;

		for (int i = 3; i < N; i += 2)
		{
			if (isPrime[i] && isPrime[(i + 1) / 2])
			{
				++sum2017;
			}
			is2017[i] = sum2017;
		}


		int	q = Integer.parseInt(line);
		for (int i = 0 ; i < q; ++i)
		{
			line = reader.readLine();
			String[]	va = line.split(" ");
			int l = Integer.parseInt(va[0]) - 2;
			int r = Integer.parseInt(va[1]);

			if (l < 0)
			{
				l = 0;
			}
			System.out.println(is2017[r] - is2017[l]);
		}
	}

}

Measured memory_bytes: 59540
import copy
N = int(input())
list_x = list(map(int,input().split()))
sorted_x = copy.copy(list_x)
sorted_x.sort()

L = sorted_x[(N-1)//2]
M = sorted_x[(N+1)//2]
base = (L+M)/2


for i in  list_x:
    if i >= base:
        print(L)
    else:
        print(M)

Measured memory_bytes: 25732
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <time.h>

#define _CRT_SECURE_NO_WARNINGS
#define TLong long long
#define TBMod 1000000007

int main(int argc, char const *argv[])
{
	int n,point[10000007],pat[10000007] = { 0 };
	int sum = 0,i = 1;
	scanf("%d",&n);
	for (i = 1; (i <= n && sum < n); ++i)
	{
		sum += i;
		point[i] = i;
		pat[i] = 1;
	}
	if(sum == n){
		for (int k = 1; k < i; ++k)
		{
			if(pat[k])	printf("%d\n",point[k]);
		}
	}
	else{
		pat[abs(sum - n)] = 0;
		for (int k = 1; k < i; ++k)
		{
			if(pat[k])	printf("%d\n",point[k]);
		}
	}
	return 0;
}


Measured memory_bytes: 41216
from collections import Counter

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

length = len(a)
ans = 0

for i in range(length-k):
    ans += a[-1][1]
    a.pop(-1)
    
print(ans)

Measured memory_bytes: 37780
package main

import (
	"fmt"
	"sort"
)

func main() {
	var k, n int
	fmt.Scan(&k, &n)
	nums := make([]int, n)
	for i:=0; i<n; i++{
		fmt.Scan(&nums[i])
	}
	sort.Ints(nums)

	maxnum := 0
	for l:=0; l<n-1; l++{
		if (nums[l+1] - nums[l]) >= maxnum{
			maxnum = nums[l+1] - nums[l]
		}
	}
	if (k-nums[n-1]) + nums[0] >= maxnum{
		maxnum = (k-nums[n-1]) + nums[0]
	}
	fmt.Println(k - maxnum)

}

Measured memory_bytes: 6144
#入力部
N,T = map(int,input().split())
t_list = list(map(int,input().split()))
#処理部
T_sum = 0
for i in range(N-1):
    if t_list[i+1]-t_list[i] < T:
        T_sum += t_list[i+1]-t_list[i]
    else:
        T_sum += T
T_sum += T
print(T_sum)

Measured memory_bytes: 25200
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author
 */

#include <iostream>
#include <fstream>

#include <iostream>
#include <limits.h>
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>

#include <list>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <queue>
#include <unordered_map>
#include <unordered_set>

using namespace std;

typedef long long ll;

template<class T> struct WarshallFloyd{
	int n;
	std::vector<std::vector<T>> d;
	WarshallFloyd(int _n){
		n = _n;
		d = std::vector<std::vector<T>>(n,std::vector<T>(n,(INT_MAX)));
	}
	void add(int a,int b,T c = 1){
		d[a][b] = c;
	}
	void run(){
		for(int k = 0;k < n;k++){
			for(int i = 0;i < n;i++){
				for(int j = 0;j < n;j++){
					d[i][j] = min(d[i][j],d[i][k] + d[k][j]);
				}
			}
		}
	}
};

class ETravelByCar {
public:
	void solve(std::istream& cin, std::ostream& cout) {
		int n,m,l;cin >> n >> m >> l;
		WarshallFloyd<ll> WF(n);
		for (int i = 0; i < m; ++i)
		{
			int a,b;ll c;cin >> a >> b >> c;
			a--,b--;
			WF.add(a,b,c);
			WF.add(b,a,c);
		}
		WF.run();
		WarshallFloyd<ll> WF2(n);
		for (int i = 0; i < n; ++i)
		{
			for (int j = 0; j < n; ++j)
			{
				if(i != j and WF.d[i][j] <= l)WF2.d[i][j] = min(WF.d[i][j],1LL);
			}
		}
		WF2.run();
		int q;cin >> q;
		for (int i = 0; i < q; ++i)
		{
			int s,t;cin >> s >> t;s--,t--;
			if(WF2.d[s][t] >= INT_MAX)cout << -1 << endl;
			else cout << WF2.d[s][t]-1 << endl;
		}
	}
};


int main() {
	ETravelByCar solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 1920
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define inf 1001001001001001001
#define mod 1000000007
#define mod2 998244353
#define pi acos(-1)
#define all(v) v.begin(),v.end()

int main(){
    string s;cin>>s;
    string ans="";
    ans+=s.at(0);
    int size=s.size()-2;
    ans+=to_string(size);
    ans+=s.at(s.size()-1);
    cout<<ans<<endl;
}

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

using namespace std;

int main() {
    int n;

    cin >> n;

    vector<int> h(n);

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

    vector<int> dp(n);

    dp.at(0) = 0;
    dp.at(1) = abs(h.at(1) - h.at(0));

    for(int i = 2; i < n; ++i) {
        dp.at(i) = min(dp.at(i - 2) + abs(h.at(i) - h.at(i - 2)), dp.at(i - 1) + abs(h.at(i) - h.at(i - 1)));
    }

    printf("%d\n", dp.at(n - 1));

    return 0;
}

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

const int MAX_K = 3;

ll dp[100][3+1];

int main(){
    string N;
    cin >> N;
    long long K;
    scanf("%lld",&K);

    int d = N.length();

    dp[0][0]=1;

    for(int i=1; i<d; i++) {
        for (int j=3; j>=0; j--) {
            dp[i][j] = dp[i-1][j] + (j ? 9*dp[i-1][j-1] : 0);
            // cout << dp[i][j] << " ";
        }
        // cout << endl;
    }

    ll ans = 0;
    for(int i=0; i<d && K>=0; i++) {
        int a = N[i] - '0';
        if (a > 0) {
            ans += K ? dp[d-i-1][K] : 0;
            ans += K ? (a-1)*dp[d-i-1][K-1] : 0;
            K--;
        }
    }
    if (K <= 0) ans++;
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vl = vector<ll>;
using vvl = vector<vl>;
using vi = vector<int>;
using vvi = vector<vi>;
#define ote(x) cout<<(x)<<endl
#define all(x) (x).begin(),(x).end()
#define allr(x) (x).rbegin(),(x).rend()
#define rp(i,s,e) for(int i=(s);i<(e);++i)
#define rpz(i,e) rp(i,0,e)

bool solve(string &s, string &t){
	sort(all(s));
	sort(allr(t));
	if(s<t) return true;
	else if(s.size()>t.size()) return false;
	else false;
}

int main(){
	string s,t; cin>>s>>t;
	ote(solve(s,t)?"Yes":"No");
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int DGT = 31;
void err () {
  cout << -1 << '\n';
  exit(0);
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  vector<long long> x(n), y(n);
  for (int i = 0; i < n; i++) {
    cin >> x[i] >> y[i];
  }
  vector<long long> d;
  vector<string> s(n, "");
  if ((x[0] & 1) == (y[0] & 1)) {
    d.push_back(1);
    for (int i = 0; i < n; i++) {
      s[i].push_back('U');
      y[i]--;
    }
  }
  for (int i = 0; i < n; i++) {
    if ((x[i] & 1) == (y[i] & 1)) {
      err();
    }
  }
  long long step = 1;
  while (step < (1LL << DGT)) {
    d.push_back(step);
    for (int i = 0; i < n; i++) {
      if (x[i] & 1) {
        if (((x[i] - 1) & 2) != (y[i] & 2)) {
          s[i].push_back('R');
          x[i]--;
        } else {
          s[i].push_back('L');
          x[i]++;
        }
      } else {
        if ((x[i] & 2) != ((y[i] - 1) & 2)) {
          s[i].push_back('U');
          y[i]--;
        } else {
          s[i].push_back('D');
          y[i]++;
        }
      }
      x[i] >>= 1;
      y[i] >>= 1;
    }
    step <<= 1;
  }
  d.push_back(step);
  for (int i = 0; i < n; i++) {
    assert(x[i] * x[i] + y[i] * y[i] == 1);
    s[i].push_back(x[i] == 1 ? 'R' : (x[i] == -1 ? 'L' : (y[i] == 1 ? 'U' : 'D')));
  }
  int m = d.size();
  cout << m << '\n';
  for (int i = 0; i < m; i++) {
    if (i) {
      cout << ' ';
    }
    cout << d[i];
  }
  cout << '\n';
  for (int i = 0; i < n; i++) {
    cout << s[i] << '\n';
  }
  return 0;
}

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

int main() {
    int n, nmin, nmax;
    while (cin >> n >> nmin >> nmax, n || nmin || nmax) {
        vector<int> p(n);
        for (auto& i : p) cin >> i;

        int ans = 0, c = 0;
        for (int i = nmin; i <= nmax; i++) {
            if (c <= p[i-1] - p[i]) {
                ans = i;
                c = p[i-1] - p[i];
            }
        }

        cout << ans << endl;
    }

    return 0;
}



Measured memory_bytes: 3100
#include<iostream>
#include <stdio.h>
#include<string>
#include <cmath>
#include <algorithm>
#include <vector>
#include <cstdint>
#include <queue> 
#include <map>
#define MOD 1000000007
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n)  FOR(i,0,n)
#define dump(x)  cout << #x << " = " << (x) << endl;
#define debug(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
typedef long long ll;
using namespace std;

int main(){

  int n,h;
  cin >> n >> h;
  
  int a[100010],b[100010];
  
  int max_a = 0;
  REP(i,n){
    cin >> a[i] >> b[i];
    max_a = max(max_a,a[i]);
  }
  
  sort(b,b+n);
  
  int ans = 0;
  // 	Aの最大値を超えるBを大きい方から消費｡
  for(int i=n-1; max_a < b[i] && i >= 0;i--){
    h -= b[i];
    ans++;
    if(h <= 0){
      cout << ans << endl;
      return 0;
    }
  }
  
  if(h % max_a != 0) ans++; 
  ans += h/max_a;
  
  cout << ans << endl;
  
 return 0;
}

Measured memory_bytes: 1024
#include<cstdio>
#include<vector>
#include<cstring>
#include<algorithm>
using namespace std;
const int MAX_V=10000+5;
const int INF=1<<30;
int pre[MAX_V];
int cost[MAX_V][MAX_V];//cost[u][v]表示边e=(u,v)的权值（不存在这条边时设为INF）
bool visited[MAX_V][MAX_V];
int d[MAX_V];//顶点s出发的最短距离
bool used[MAX_V];//已经使用过的图
int V,E;//顶点数，边数
//求从起点s出发到各个顶点的最短距离
void dijkstra(int s)
{
    fill(d+1,d+V+1,INF);
    fill(used+1,used+V+1,false);
    fill(pre+1,pre+V+1,-1);
    d[s]=0;
    while(true)
    {
        int v=-1;
        //从尚未使用过的顶点中选择一个距离最小的顶点
        for(int u=1; u<=V; u++)
        {
            if(!used[u]&&(v==-1||d[u]<d[v]))
                v=u;
        }
        if(v==-1)
            break;
        used[v]=true;
        for(int u=1; u<=V; u++)
        {
            if(d[u]>d[v]+cost[v][u])
            {
                d[u]=d[v]+cost[v][u];
                pre[u]=v;
            }
        }
    }
}
vector<int> get_path(int t)
{
    vector<int>path;
    for(; t!=-1; t=pre[t])
        path.push_back(t);
    reverse(path.begin(),path.end());
    return path;
}
int main()
{
    scanf("%d%d",&V,&E);
    int a,b,c;
    for(int i=1;i<=V;i++)
    {
        for(int j=1;j<=V;j++)
            cost[i][j]=INF;
    }
    for(int i=0;i<E;i++)
    {
        scanf("%d%d%d",&a,&b,&c);
        cost[a][b]=cost[b][a]=c;
    }
    memset(visited,false,sizeof(visited));
    int ans=E;
    for(int i=1;i<=V;i++)
    {
        dijkstra(i);
        for(int j=1;j<=V;j++)
        {
            if(i==j)
                continue;
            vector<int>v=get_path(j);
            for(int i=0;i<v.size()-1;i++)
            {
                int a=v[i];
                int b=v[i+1];
                if(!visited[v[i]][v[i+1]]&&!visited[v[i+1]][v[i]])
                {
                    visited[v[i]][v[i+1]]=visited[v[i+1]][v[i]]=true;
                    ans--;
                }
            }
        }
    }
    printf("%d\n",ans);
    return 0;
}


Measured memory_bytes: 102656
N = int(input())
counter = 0
second = 0
row = False
while N > 0:
    details = input().split()
    first = details[0]
    second = details[1]
    if first == second:
        counter += 1
    if first != second:
        counter = 0
    if counter >= 3:
        row = True
    N -= 1

if row == True:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 9188
n = int(input())
a = []
b = []
for _ in range(n):
    x, y = map(int, input().split())
    a.append(x)
    b.append(y)

ans = 0
for i in range(n-1, -1, -1):
    a[i] += ans
    mod = a[i] % b[i]
    if mod != 0:
        if a[i] > b[i]:
            ans += b[i] - mod
        else:
            ans += b[i] - a[i]

print(ans)


Measured memory_bytes: 21704
#include <bits/stdc++.h>
using namespace std;
int main(void){
    // Your code here!
    int A, B;
    int Left, Right;
    cin >> A >> B;
    int Agyaku = A / 1000;
    Agyaku = Agyaku / 10 + (Agyaku - Agyaku / 10 * 10) * 10;
    int Bgyaku = B / 1000;
    Bgyaku = Bgyaku / 10 + (Bgyaku - Bgyaku / 10 * 10) * 10;
    if (Agyaku >= A - A / 100 * 100){
        Left = A / 100;
    }else {
        Left = A / 100 + 1;
    }
    if (Bgyaku <= B - B / 100 * 100){
        Right = B / 100;
    }else {
        Right = B / 100 - 1;
    }
    cout << Right - Left + 1 << endl;
    
}


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

int main(){
  int H,W;
  cin >>H>>W;
  char S[H+2][W+2];
  
  for (int i=0;i<H+2;i++)
    for (int j=0;j<W+2;j++) S[i][j] = '.';
  
  for (int i=0;i<H;i++){
    string instring;
    cin >> instring;
    for (int j=0;j<W;j++){
      S[i+1][j+1] = instring[j];
    }
  }
  
   for (int i=1;i<H+1;i++){
    for (int j=1;j<W+1;j++){
      if (S[i][j] == '#') cout << '#';
      else{
        int ans = 0;
        if (S[i-1][j-1] == '#') ans ++;
        if (S[i][j-1] == '#') ans ++;
        if (S[i+1][j-1] == '#') ans ++;
        if (S[i-1][j] == '#') ans ++;
        if (S[i+1][j] == '#') ans ++;
        if (S[i-1][j+1] == '#') ans ++;
        if (S[i][j+1] == '#') ans ++;
        if (S[i+1][j+1] == '#') ans ++;
        cout << ans;
      }
    }
    cout << endl;
  }
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<utility>
#include<queue>
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<complex>
#define INF 2147483647
#define llINF 9223372036854775807
#define pb push_back
#define mp make_pair 
#define F first
#define S second
#define ll long long

using namespace std;
int main(){
  int n;cin>>n;
  int ans[n]={};
  for(int i=0;i<n-1;i++){
    int a,b,c;cin>>a>>b>>c;
    ans[i]=a+b;
    for(int j=0;j<i;j++){
      if(ans[j]<b)
	ans[j]=ans[i];
      else if(ans[j]%c==0)
	ans[j]+=a;
      else
	ans[j]+=c-(ans[j]%c)+a;
    }
  }
  for(int i=0;i<n;i++)
    cout<<ans[i]<<endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define FastIO      ios_base::sync_with_stdio(0);cin.tie(0),cout.tie(0)
#define pb          push_back
#define siz         100009
#define inf         1e9+8
#define mp          make_pair
#define rep(i,n)    for(int i=0;i<n;i++)
#define repo(i,m,n) for(int i=m;i<=n;i++)
#define ll          long long
#define pii         pair<int,int >
#define sc(n)       scanf("%d",&n)
#define sc2(m,n)    scanf("%d%d",&m,&n);
#define MOD         4294967296
#define fileout     freopen("output.txt","w",stdout)
#define filein      freopen("input.txt","r",stdin)
#define mem(x,i)    memset(x,i,sizeof x)
#define PI          acos(-1.0)
#define ff          first
#define ss          second
using namespace std;

int main()
{
    int n,k;
    cin>>n>>k;
    double ans=0.0;
    for(int i=1;i<=n;i++)
    {
        double x=(log(k/(i*1.0)))/(log(2.0));
        //cout<<"x: "<<x<<endl;
        x=ceil(x);
        x=max(0.0,x);
        x=(1.0/n)*powl(0.5,x);
        //cout<<x<<'\n';
        ans+=x;
    }
    printf("%.9f\n",ans);
}


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

using namespace std;
int arr[101];
void make_money(int n){
    if(n>100) return;
    arr[n]=1;
    make_money(n+4);
    make_money(n+7);
}
int main()
{
    int N;
    cin>>N;
    make_money(4);
    make_money(7);
    if(arr[N])cout<<"Yes";
    else cout<<"No";
}


Measured memory_bytes: 256
#移動できる回数が限られている。
#具体的には、#の数がh+w個ピッタリじゃなくてはならない
h, w = map(int, input().split())
grid = []
sharp_count = 0
for i in range(h):
    grid.append(list(input()))
    sharp_count += grid[i].count('#')
if sharp_count != h+w-1:
    print("Impossible")
else:
    print("Possible")


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

static int compare_char (const void *a, const void *b) {
    return *(char*)a - *(char*)b;
}

static int compare_str (const void *a, const void *b) {
    return strncmp((char*)a, (char*)b, 10);
}

int main (void) {
    int n, i;
    scanf("%d", &n);
    char s[n][11];
    for ( i=0; i<n; i++ ) {
        scanf("%s", s[i]);
    }

    /* 各文字列内のソート */
    for ( i=0; i<n; i++ ) {
        qsort(s[i], 10, sizeof(char), compare_char);
    }
    /* 文字列同士のソート */
    qsort(s, n, sizeof(char)*11, compare_str);

    /* アナグラム組の計算 */
    long long n_ident, ans=0;
    for ( i=1; i<n; i++ ) {
        n_ident = 1;
        while ( !strncmp(s[i-1], s[i], 10) ) {
            n_ident++;
            i++;
        }
        ans += n_ident*(n_ident-1)/2;
    }
    printf("%lld\n", ans);
    return EXIT_SUCCESS;
}


Measured memory_bytes: 2300
N, M = map(int, input().split())
L = [0] * M
R = [0] * M
count = 0
for i in range(M):
    L[i], R[i] = map(int, input().split())
Lmax = max(L)
Rmin = min(R)
if Lmax <= Rmin:
    print(Rmin - Lmax + 1)
else:
    print(0)


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

using namespace std;

#define int long long

const int inf = 1LL<<55;

struct SegmentTree {
  vector<int> data;
  int sz;
  SegmentTree(int n) {
    sz = 1; while(sz < n) sz *= 2;
    data.resize(2*sz-1, inf);
  }
  void update(int k, int x) {
    k += sz-1;
    data[k] = x;
    while(k > 0) {
      k = (k-1)/2;
      data[k] = min(data[2*k+1], data[2*k+2]);
    }
  }
  int query(int a, int b, int k, int l, int r) {
    if(r <= a || b <= l) return inf;
    if(a <= l && r <= b) return data[k];
    int vl = query(a, b, 2*k+1, l, (l+r)/2);
    int vr = query(a, b, 2*k+2, (l+r)/2, r);
    return min(vl, vr);
  }
  int query(int a, int b) {
    return query(a, b, 0, 0, sz);
  }
};

signed main() {
  int n, m, k, d, s;
  cin >> n >> m >> k >> d >> s;
  if(n > m) {
    cout << d*k << endl;
    return 0;
  }
  vector<int> a(m), b(m), c(m);
  vector<int> cmpC;
  for(int i = 0; i < m; ++i) {
    cin >> a[i] >> b[i] >> c[i];
    --c[i];
    //cmpC.push_back(c[i]);
  }
  /*
  for(int i = 0; i < m; ++i) {
    c[i] = lower_bound(cmpC.begin(), cmpC.end(), c[i])-cmpC.begin();
  }
  */
  struct State {
    int t, a, b, c;
    State(){}
    State(int t, int a, int b, int c):t(t), a(a), b(b), c(c){}
    bool operator < (const State& s) const {
      return a == s.a ? t > s.t : a > s.a;
    }
  };
  priority_queue<State> que;
  for(int i = 0; i < m; ++i) que.emplace(1, a[i], b[i], c[i]);
  que.emplace(2, s+d, 0, 0);
  int sz = n;//max(n, (int)cmpC.size());
  SegmentTree seg(sz);
  for(int i = 0; i < sz; ++i) seg.update(i, 0);
  while(!que.empty()) {
    State st = que.top(); que.pop();
    //cout<<st.t<<" "<<st.a<<" "<<st.b<<" "<<st.c<<endl;
    if(st.t == 1) {
      int tmp = seg.query(st.c, st.c+1);
      //cout<<tmp<<endl;
      seg.update(st.c, max(st.a, tmp)+st.b);
    } else {
      int tmp = seg.query(0, sz);
      //cout<<sz<<endl;
      //cout<<tmp<<endl;
      --k;
      if(k == 0) {
	cout << max(st.a, tmp)-s << endl;
	return 0;
      }
      que.emplace(2, max(st.a, tmp)+d, 0, 0);
    }
  }
  return 0;
}



Measured memory_bytes: 10364
use std::io::*;
use std::str::FromStr;

#[allow(dead_code)]
fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let n = read::<usize>();
    let k = read::<usize>();
    let mut seq = vec![0; n];
    for i in 0..n {
        seq[i] = read::<i64>();
    }
    let mut ans = 1i64 << 60;
    for l in 0..(n - k + 1) {
        let r = l + k - 1;
        ans = std::cmp::min(ans, seq[l].abs() + (seq[l] - seq[r]).abs());
        ans = std::cmp::min(ans, seq[r].abs() + (seq[l] - seq[r]).abs());
    }
    println!("{}", ans);
}


Measured memory_bytes: 4352
from itertools import accumulate
import sys

mod = 10 ** 9 + 7

N, K = map(int, sys.stdin.readline().rstrip().split())
if K == N + 1:
    print(1)
    sys.exit()

l = list(accumulate(range(N + 1)))

ans = 0
for k in range(K, N + 2):
    if k == N + 1:
        ans += 1
    else:
        ans += k * N - (2 * l[k-1]) + 1

if ans >= mod:
    print(ans % mod)
else:
    print(ans)

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


namespace ACprac
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] num1 = Console.ReadLine().Split(' ');
            string[] num2 = Console.ReadLine().Split(' ');

            int[] HW = new int[2];
            int[] hw = new int[2];

            HW[0] = int.Parse(num1[0]);
            HW[1] = int.Parse(num1[1]);
            hw[0] = int.Parse(num2[0]);
            hw[1] = int.Parse(num2[1]);

            int ANS1 = (HW[0] - hw[0]);
            int ANS2 = (HW[1] - hw[1]);
            int ANS = ANS1 * ANS2;

            Console.WriteLine(ANS);

        }
    }
}


Measured memory_bytes: 11092