akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<cstdio>
#include<vector>
#include<string>
#include<functional>
#include<queue>
#include <iomanip>
#include<map>
#include<limits>
#include<cmath>
#include<algorithm>
#include<bitset>
#include<utility>
#include<complex>
#include<cstdlib>
#include<set>
#include<cctype>

#define DBG cerr << '!' << endl;
#define REP(i,n) for(int (i) = (0);(i) < (n);++i)
#define rep(i,s,g) for(int (i) = (s);(i) < (g);++i)
#define rrep(i,s,g) for(int (i) = (s);i >= (g);--(i))
#define PB push_back
#define MP make_pair
#define FI first
#define SE second
#define SHOW1d(v,n) {for(int i = 0;i < (n);i++)cerr << v[i] << ' ';cerr << endl << endl;}
#define SHOW2d(v,i,j) {for(int aaa = 0;aaa < i;aaa++){for(int bbb = 0;bbb < j;bbb++)cerr << v[aaa][bbb] << ' ';cerr << endl;}cerr << endl;}
#define ALL(v) v.begin(),v.end()

using namespace std;

typedef long long ll;
typedef vector<int> iv;
typedef vector<iv> iiv;
typedef vector<string> sv;

int A[5010],B[5010];

int main()
{
	int a,b;cin >> a >> b;
	
	REP(i,a)cin >> A[i];
	REP(i,b)cin >> B[i];
	
	int ans = 0;
	REP(i,b)
	{
		int tmp = 0,now = i;
		for(int j = 0;j < a;j++)
		{
			if(A[j] == B[now])
			{
				tmp++;
				if(now == b-1)break;
				now++;
			}
		}
		ans = max(ans,tmp);
	}
	
	cout << ans << endl;
			
	
	return 0;
}

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

int a[1005];
int main() {
    int n, res = 0;
    cin >> n;
    for (int i = 0; i < n; i++)
        cin >> a[i];
    for (int i = 0; i < n; i++) {
        for (int j = i+1; j < n; j++) {
            for (int k = j+1; k < n; k++) {
                if (a[i]+a[j]>a[k] && a[j]+a[k]>a[i] && a[k]+a[i]>a[j] && a[i]!=a[j] && a[i]!=a[k] && a[k]!=a[j])
                    ++res;
            }
        }
    }
    cout << res;
}

Measured memory_bytes: 3616
#!/usr/bin/env python3
from collections import deque

def 周辺埋め(grid, W):
    U = "#" * (W + 2)
    return [list(U)] + [["#"] + list(g) + ["#"] for g in grid] + [list(U)]

H, W, *grid = open(0).read().split()
H, W = map(int, (H, W))

C = sum(g.count(".") for g in grid)

grid = 周辺埋め(grid, W)

grid[1][1] = "!"
grid[H][W] = "G"

D = [(0,1), (1,0), (0,-1), (-1, 0)]

def bfs():
    que = deque()
    que.append((1, 1, 0))

    while que:
        cy, cx, c = que.popleft()

        for my, mx in D:
            nx = cx + mx
            ny = cy + my

            if grid[ny][nx] == ".":
                # 未探索
                que.append((ny, nx, c + 1))
                grid[ny][nx] = "!"  # 探索済み
            
            elif grid[ny][nx] == "G":  # ゴール
                return C - (c + 2)

    return -1

print(bfs())

Measured memory_bytes: 3316
#include <bits/stdc++.h>
#define ll long long int
using namespace std;
bool cmp(pair<ll, ll>& a, pair<ll, ll>& b)
{
  if(a.first == b.first)
  {
    return a.second < b.second;
  }
  return a.first > b.first;
}

int main()
{
 ll q,n, r, avg, i, j;
 while(cin >> n)
 {
   ll v[n + 5], c[n + 5];
   map<pair<ll, ll> , ll> m;
   map<ll, ll>::iterator it;
   vector<ll> vc(n + 5);
   for(i = 0; i < n; i++)
   {
     cin >> v[i];
   }
  for(i = 0; i < n; i++)
   {
     cin >> c[i];
   }
   
   ll x = 0, y = 0;
   for(i = 0; i < n; i++)
   {
      if(v[i] > c[i]){
        x += v[i] - c[i];
      }
   }
   cout << x << endl;
  
 }
 return 0;
}

Measured memory_bytes: 256
N, Q= map(int,input().split())
S = input()
ans = [0]*N
ans[N-1] = 0
for i in range(N-2, -1, -1):
    if S[i:i+2] == 'AC':
        ans[i] = ans[i+1] + 1
    else:
        ans[i] = ans[i+1]

for i in range(Q):
    l,r = map(int,input().split())
    print(ans[l-1] - ans[r-1])




Measured memory_bytes: 6188
import java.util.Scanner;

public class Main{

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int d = sc.nextInt();
        int n = sc.nextInt();
        if (d == 0) {
            if (n < 100) {
                System.out.println(n);
            } else {
                System.out.println(101);
            }
        } else if (d == 1) {
            if (n < 100) {
                System.out.println(100 * n);
            } else {
                System.out.println(10100);
            }

        } else {
            if (n < 100) {
                System.out.println(10000 * n);
            } else {
                System.out.println(1010000);
            }
        }

    }

}


Measured memory_bytes: 20948
import itertools
import math

def euclid(a,b):
    return math.sqrt((a[0]-b[0])**2 + (a[1]-b[1])**2)

x,y = [],[]
n = int(input())
for val in range(n):
    x_tmp,y_tmp = map(int,input().split())
    x.append(x_tmp)
    y.append(y_tmp)

comb = list(itertools.combinations(range(n), 2))
zyun = list(itertools.permutations(range(n)))
distance_L = {}

# あらかじめ2転換を計算
for val in comb:
    tenkan = list(sorted(list(val)))
    a = [x[val[0]],y[val[0]]]
    b = [x[val[1]],y[val[1]]]
    
    distance_L[val] = euclid(a,b)

ans = 0
counter = 0

for i in zyun:
    for j in range(n-1):
        tmp = tuple(sorted(i[j:j+2]))
        #print(tmp)
        ans += distance_L[tmp]
    counter += 1

print(ans/counter)



Measured memory_bytes: 48676
N = int(input())
a = [[[0]]]
k = 0
while k < N-1:
  c = a[k]
  a.append([])
  for r in c:
    for i in range(max(r)+2):
      x = r + [i]
      a[k+1].append(x)
  
  k += 1
A = a[-1]
for s in A:
  ans = ""
  for i in range(N):
    ans += chr(s[i]+97)
  print(ans)

Measured memory_bytes: 27460
# include <stdio.h>

int main(){
  int h ,w ,a,b;
  scanf("%d %d",&h,&w);
    scanf("%d %d",&a,&b);
   
    if((h%a) == 0 || w%b == 0)printf("%d\n",(h%a)*(w) + (w%b)*h);
    else {printf("%d\n",(h%a)*(w) + (w%b)*(h) - ((h%a)*(w%b))  );}
    
  return 0;
}



Measured memory_bytes: 2060
#include <bits/stdc++.h>
using namespace std;
typedef long double ld;
typedef long long ll;
typedef unsigned long long ull;
#define MP make_pair
#define FOR(i,a,b) for(int i=(a);i<=(b);i++)
#define VI vector<int>
#define PII pair<int, int>
#define FI first
#define SE second
#define ALL(x) (x).begin(), (x).end()
const int INF=1<<30;
const ll LINF=1LL<<60 ;
const ll MOD=1e9+7 ;
///////////////////
const int MX = 30;
//int a[MX][MX];
int b[MX];

int main(){
	int n,m,c; cin >> n >> m >> c;
	FOR(i,1,m){
		cin >> b[i];
	}
	int cnt=0;
	FOR(i,1,n){
		ll ans=0;
		FOR(j,1,m){
			int a; cin >> a;
			ans += b[j]*a;
		}
		ans += c;
		if(ans > 0) cnt += 1;
	}

	cout << cnt;
    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 a = sc.nextInt();
  int b = sc.nextInt();
  int c = sc.nextInt();
  if( a < b && b < c ){
    System.out.println( "Yes" );
  }else{
    System.out.println( "No" );
  }
 }
}


Measured memory_bytes: 26180
#include <cstdio>
#include <vector>
#include <algorithm>
#include <stdint.h>

int64_t prev[100000];
int64_t next[100000];
int64_t as[100000];
int64_t bs[100000];
int64_t slope[100000];
int64_t total_slope;
int64_t t;

std::vector<int64_t> vanish[100001];

void calc_slope(int64_t x){
  bs[x]+=t*slope[x];
  total_slope-=slope[x]*as[x];
  slope[x]=(as[next[x]]>as[x])-(as[x]>as[prev[x]]);
  bs[x]-=t*slope[x];
  total_slope+=slope[x]*as[x];
  if(slope[x]<0){
    //printf("VVV %ld %ld\n",bs[x],x);
    vanish[bs[x]].push_back(x);
  }
}

int main(){
  int64_t N,X;
  scanf("%ld %ld",&N,&X);
  for(int64_t i=0;i<N;i++){
    scanf("%ld",&as[i]);
  }
  for(int i=0;i<N;i++){
    prev[i]=(i+N-1)%N;
    next[i]=(i+1)%N;
  }
  int64_t sum=0;
  total_slope=X;
  std::fill(bs,bs+N,1);
  for(int64_t i=0;i<N;i++){
    calc_slope(i);
    sum+=as[i];
    //printf("as[%ld]=%ld\n",i,as[i]);
  }
  int64_t best=sum;
  //printf("SUM[0]=%ld\n",sum);
  for(t=1;t<=N;t++){
    sum+=total_slope;
    //printf("SUM+=%ld\n",total_slope);
    //printf("SUM[%ld]=%ld\n",t,sum);
    for(int64_t a:vanish[t]){
      //printf("VANISH %ld\n",a);
      total_slope-=slope[a]*as[a];
      prev[next[a]]=prev[a];
      next[prev[a]]=next[a];
      calc_slope(prev[a]);
      calc_slope(next[a]);
    }
    best=std::min(best,sum);
    for(int64_t i=0;i<N;i++){
      //printf("as[%ld]=%ld\n",i,as[i]);
      //printf("bs[%ld]=%ld\n",i,bs[i]);
      //printf("slope[%ld]=%ld\n",i,slope[i]);
    }
  }
  printf("%ld\n",best);
  return 0;
}


Measured memory_bytes: 6400
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author anand.oza
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        DBinomialCoefficients solver = new DBinomialCoefficients();
        solver.solve(1, in, out);
        out.close();
    }

    static class DBinomialCoefficients {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int n = in.nextInt();
            Long[] a = new Long[n];
            for (int i = 0; i < n; i++) {
                a[i] = in.nextLong();
            }

            Arrays.sort(a);

            long first = a[n - 1];
            long cost = Long.MAX_VALUE;
            long second = -1;
            for (int i = 0; i < n - 1; i++) {
                long c = Math.abs(2 * a[i] - first);
                if (c < cost) {
                    second = a[i];
                    cost = c;
                }
            }

            out.println(first + " " + second);
        }

    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

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

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

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

    }
}



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

const int MOD = 1000000007;

//long long
using ll = long long;

//出力系
#define print(x) cout << x << endl
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl
 
// begin() end()
#define all(x) (x).begin(),(x).end()

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

//最大公約数 
unsigned gcd(unsigned a, unsigned b) {
  if(a < b) return gcd(b, a);
  unsigned r;
  while ((r=a%b)) {
    a = b;
    b = r;
  }
  return b;
}

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

int main(){
  ll N, K;
  cin >> N >> K;
  vector<ll>A(100001, 0);
  REP(i, N){
    int x, y;
    cin >> x >> y;
    A.at(x) += y;
  }
REP(i, 100001){
  if(K <= A.at(i)) {
    print(i);
    return 0;
}
  K -= A.at(i);
}
}

Measured memory_bytes: 1024
#include <iostream>
#include <fstream>
#include <vector>

using namespace std;

int main(){
    int tmp = 0;
    int k = 0;

    int i_min = 99999;
    int i_max = 0;

    for(int i = 0; i < 5; i++)
    {
        cin >> tmp;
        if(i_max <= tmp)i_max = tmp;
        if(i_min >= tmp)i_min = tmp;
    }
    cin >> k;

    if(i_max - i_min <= k)
    {
        cout << "Yay!" << endl;
    }
    else
    {
        cout << ":(" << endl;        
    }
}



Measured memory_bytes: 256
class SegmentTree:
    def __init__(self, size, f=lambda x,y : x+y, default=0):
        self.size = 2**(size-1).bit_length()
        self.default = default
        self.dat = [default]*(self.size*2-1)
        self.f = f

    def update(self, i, x):
        i += self.size-1
        self.dat[i] = x
        while i > 0:
            i = (i-1) >> 1
            self.dat[i] = self.f(self.dat[i*2+1], self.dat[i*2+2])

    def query(self, l, r, k=0, L=0, R=None):
        if R is None:
            R = self.size
        if R <= l or r <= L:
            return self.default
        if l <= L and R <= r:
            return self.dat[k]
        else:
            lres = self.query(l, r, k*2+1, L, (L+R) >> 1)
            rres = self.query(l, r, k*2+2, (L+R) >> 1, R)
            return self.f(lres, rres)

n, q = map(int, input().split())
s = SegmentTree(n)
for i in range(q):
    com, x, y = map(int, input().split())
    if com == 0:
        i = x-1
        s.update(i, s.query(i,i+1)+y)
    else:
        print(s.query(x-1, y))



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

#define int long long
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define rep(i, n) for (int i = 0; i < n; ++i)
#define REP(i, n) for (int i = 0; i < n; ++i)
#define range(i,a,b) ((a)<=(i) && (i)<(b))
#define debug(x) cout << #x << " = " << (x) << endl;
#define fs first
#define sc second
#define pb push_back
#define eb emplace_back
#define SP << " " <<

typedef long long ll;
typedef pair<int, int> P;
typedef tuple<int, int, int> T;
typedef vector<int> vec;
typedef vector<P> pvec;
typedef vector<vector<int>> vvec;
typedef vector<vector<P>> pvvec;
typedef priority_queue<int> PQI;
typedef priority_queue<P> PQP;
typedef priority_queue<int,vector<int>,greater<int>> PQIG;
typedef priority_queue<P,vector<P>,greater<P>> PQPG;

const vector<int> DX = {0, -1, 0, 1, 1, 1, -1, -1};
const vector<int> DY = {1, 0, -1, 0, 1, -1, 1, -1};
constexpr int MOD = (1000000007);
// const int MOD = (998244353);
// const int INF = (1 << 30); // 1073741824
const ll INF = (1LL << 60); // 1152921504606846976
const double PI = (3.141592653589794);
const double EPS = (0.0000000001); // 10^(-10)

template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b; return 1;} return 0;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b; return 1;} return 0;}
template<class T> inline T ceil(T a, T b) {return T((a + b - 1) / b);}
template<class T> inline T round(T a, T b) {return T(a / b);}
template< typename T1, typename T2 > istream &operator>>(istream &is, pair< T1, T2 > &p) { is >> p.first >> p.second; return is; }
template <class T> inline void out(T &a) { bool flag=true; for(auto&x:a){if(flag) {flag=false;} else{ cout << ' '; } cout<<x; } cout << endl; }



//----------------------------------------------------------------
int nmax=200000; // 2*(10^5)
vvec G(nmax);





void solve4ts()
{
  
  
  int n;
  cin>>n;
  pvec a(n);
  rep(i,n) cin>>a[i];
  sort(rall(a));
  int ans=a[0].sc+a[0].fs;
  cout<<ans<<endl;
  
}
//-----------------------------------------------------------------

signed main(){ ios::sync_with_stdio(false); cin.tie(0); cout << fixed << setprecision(15);
    int repeat = 1;
    // cin >> repeat;
    while(repeat--) solve4ts();
}

/*

g++ -std=c++1z code.cpp
./a.out

*/

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

#define      pb    push_back
#define      ff    first
#define      ss    second
#define      ll    long long int
#define      endl  "\n"
#define      FASTIO        ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define      TEST    ll t ; cin >> t ; while( t -- )


//------------------------------------------------------------------------//

#define sc(a) scanf("%d",&a)
#define sc2(a,b) scanf("%d%d",&a,&b)
#define sc3(a,b,c) scanf("%d%d%d",&a,&b,&c)
#define sc4(a,b,c,d) scanf("%d%d%d%d",&a,&b,&c,&d)

//------------------------------------------------------------------------//


const ll big = 10e10 + 11 ;


int  main (  ) {

    FASTIO ;

    ll  x , ans = 0 ;

    cin >> x ;

    for( ll i = 100 ; ;  ){
        ll z = i / 100 ;

        i += z ;
        ans ++ ;

        if( i >= x ) break ;
    }

    cout <<  ans << endl ;

    return  0 ;
}


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

int main(void){
    // Your code here!
   int  a, b, c;
   cin >> a >> b >> c;
   if(a == b && a==c){
       cout << 1 << endl;
   } else if(a != b && a!=c && b!=c){
       cout << 3 << endl;
   } else {
       cout << 2 << endl;
   }
}


Measured memory_bytes: 256
package main

import "fmt"

func main() {
	var N, A, B int
	fmt.Scanf("%d %d %d", &N, &A, &B)
	waru := N / (A + B)
	mod := N % (A + B)
	if mod > A {
		mod = A
	}
	fmt.Println(A*waru + mod)
}


Measured memory_bytes: 512
{-# LANGUAGE ScopedTypeVariables #-}
import Control.Applicative
main = do
  [a, b] :: [Int] <- (map read . words) <$> getLine
  putStrLn $ solve a b

solve :: Int -> Int -> [Char]
solve a b
  |a > b  = "a > b"
  |a == b = "a == b"
  |a < b  = "a < b"

Measured memory_bytes: 3636
//libraries
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>

//namespace
using namespace std;
using namespace __gnu_pbds;

//typedef
typedef tree<long long,null_type,less<long long>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
typedef tree<long long,null_type,greater<long long>,rb_tree_tag,tree_order_statistics_node_update> ordered_set1;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<long,long> pll;

//define
#define inp(X) cin>>X;
#define inp_long(X) long long X; cin>>X;
#define inp_arr(A,N) long long A[N]; for(int i=0;i<N;i++) {cin>>A[i];}
#define sz(A) A.size()
#define pb push_back
#define pf push_front
#define fi first
#define se second
#define endl '\n'
#define vect(A) vector<long long> A;
#define inp_vect(A,N); for(int i=0;i<N;i++){long long q; cin>>q; A.push_back(q);}
#define forin(i,a,b) for(long long i=a;i<=b;i++)
#define forde(i,a,b) for(long long i=a;i>=b;i--)
#define fio ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);

const long long inf=(long long)1e18;
const long long MOD=(long long)(1e9+7);

ll power(ll x,ll y)
{
    if (y == 0)
        return 1;
    ll p = power(x, y/2) % MOD;
    p = (p * p) % MOD;

    return (y%2 == 0)? p : (x * p) % MOD;
}
ll modInverse(ll a)
{
   return power(a,MOD-2);
}
int main()
{
	fio;
	double s,t;
	cin>>s>>t;
	ll ans=0;
	ll a=1;
	while(a<t)
	{
		ans++;
		a+=s-1;
	}
	cout<<ans<<endl;
}



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

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

    int imax = std::max(a, b);
    int imin = std::min(a, b);
    for(int i = 0; i < imax; ++i){
        cout << imin;
    }

    cout << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#define ll long long
using namespace std;

const int N = 200000 + 10;

ll num[N];

int main()
{
	int n;
	cin>>n;
	for(int i=0; i<n; i++) scanf("%lld",&num[i]);
	sort(num, num+n);
	reverse(num, num+n);
	int cnt = 0;
	ll ans = 0;
	int tem = 1;
	while(tem < n)
	{
		ans += num[tem/2];
		tem++;
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 4812
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
int H,W,match_r[12],match_c[12];
string grid[12];
bool ok;
bool check(){
	memset(match_c,-1,sizeof match_c);
	for(int i=0;i<W;i++){
		if(match_c[i]!=-1) continue;
		for(int j=i+1;j<W;j++){
			if(match_c[j]!=-1) continue;
			bool succ=true;
			for(int k=0;k<H && succ;k++)
				if(grid[match_r[k]][i]!=grid[k][j])
					succ=false;
			if(succ){
				match_c[i]=j,match_c[j]=i;
				break;
			}
		}
	}
	int unmatch=0,mid;
	for(int i=0;i<W;i++)
		if(match_c[i]==-1){
			unmatch++;
			mid=i;
		}
	if(unmatch>=2 || (unmatch && W%2==0)) return false;
	if(!unmatch) return true;
	for(int i=0;i<H;i++)
		if(grid[match_r[i]][mid]!=grid[i][mid])
			return false;
	return true;
}
void dfs(int idx,bool is_skip){
	if(idx>=H){
		if(check()) ok=true;
	}else{
		if(match_r[idx]!=-1){
			dfs(idx+1,is_skip);
		}else{
			for(int i=idx+1;i<H;i++){
				if(match_r[i]==-1){
					match_r[idx]=i;
					match_r[i]=idx;
					dfs(idx+1,is_skip);
					match_r[idx]=match_r[i]=-1;
				}
			}
			if(!is_skip && H&1){
				match_r[idx]=idx;
				dfs(idx+1,true);
				match_r[idx]=-1;
			}
		}
	}
}
int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cin>>H>>W;
	for(int i=0;i<H;i++)
		cin>>grid[i];
	memset(match_r,-1,sizeof match_r);
	dfs(0,false);
	cout<<(ok?"YES":"NO")<<'\n';
	return 0;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <stdio.h>
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>
#include <limits>


#define FOR(i,k,n) for(int(i)=(k);(i)<(n);++(i))
#define rep(i,n) FOR(i,0,n)
#define all(v) begin(v),end(v)
#define deg_to_rad(deg) (((deg)/360)*2*M_PI)
#define rad_to_deg(rad) (((rad)/2/M_PI)*360)

using namespace std;

int main()
{
  int x;
  cin >>x;
  
  int s,m;
  
  s= x/100;
  m =x%100;
  
  double m1 =m;
  double mm = m1/5;
  if(s<mm)
  {
    
    cout <<0;
  }
  else
  {
        cout <<1;
  }

	return 0;
}





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

// {U}{INT,LONG,LLONG}_{MAX,MIN}
#define ALPHABET    (26)
#define INF         INT_MAX
#define MOD         (1000000007LL)
#define EPS         (1e-10)
#define EQ(a, b)    (abs((a)-(b)) < EPS)

using LL  = long long;

int di[] = {0, -1, 0, 1};
int dj[] = {1, 0, -1, 0};
// }}}

int main() {
    std::ios::sync_with_stdio(false);
    int x, y, z;cin >> x >> y >> z;
    cout << (x-z)/(y+z) << endl;
    return 0;
}


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

int main(){
    int x, y;
    while(cin >> x >> y, x != 0 || y != 0 ){
        if(x >= y){
            cout << y << " " << x << endl;
        }
        else{
            cout << x << " " << y << endl;
        }
    }
return 0;
}
    

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

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()

using namespace std;

int main(){

  int N;
  string S;
  cin >> N >> S;
  deque<char> q;
  rep(i,S.size()){
    if(S[i] == '(') q.push_back(S[i]);        //スタックに積み込む
    else{
      if(q.empty() == false && q.back() == '(') q.pop_back();       //かっこ成立
      else                q.push_back(S[i]);  //スタックに積み込む
    }
  }
  string headStr = "" , tailStr = "";
  while(q.empty() == false){
    if(q.back() == ')') headStr += '(';
    if(q.back() == '(') tailStr += ')';

    q.pop_back();
  }
  cout << headStr << S << tailStr << endl;
  return 0;
}


Measured memory_bytes: 256
import sys
import math
import itertools
import collections
from collections import deque

sys.setrecursionlimit(1000000)
MOD = 10 ** 9 + 7
input = lambda: sys.stdin.readline().strip()

NI = lambda: int(input())
NMI = lambda: map(int, input().split())
NLI = lambda: list(NMI())
SI = lambda: input()


def main():
    R,C = NMI()
    sy, sx = 0,0
    gy, gx = R-1,C-1
    board = [list(input()) for _ in range(R)]

    #移動4方向のベクトル
    dx = [1, 0, -1, 0]
    dy = [0, 1, 0, -1]

    #すべての点をINFで初期化
    INF = R*C*2
    distance = [[INF for _ in range(C)] for _ in range(R)]

    #地点を保存するqueを作成、スタート地点を入れる
    que = deque([])
    que.append((sy,sx))

    #スタート地点の距離は0
    distance[sy][sx] = 0
    
    #最短経路
    shortest = INF

    #queが空になるまでループ
    while len(que) != 0:
        #取り出してきた状態がゴールなら探索をやめる
        pop = que.popleft()
        if pop[0]==gy and pop[1]==gx:
            shortest = distance[gy][gx]+1


        #移動4方向をループ
        for i in range(len(dx)):
            #移動した後の点をny,nxとする
            ny = pop[0]+dy[i]
            nx = pop[1]+dx[i]

            #nyが0以上R未満   nxが0以上C未満     盤上で壁ではない        まだ訪れたことがない
            if 0<= ny < R and 0 <= nx < C and board[ny][nx]!='#' and distance[ny][nx] == INF:
                #つまり移動可能でまだ行ったことがなければqueへ入れる
                que.append((ny,nx))
                #その距離をもとのpopの最短距離+1でdistanceに記録
                distance[ny][nx] = distance[pop[0]][pop[1]]+1
    
    if shortest == INF:
        print(-1)
    else:
        dots = 0
        for r in range(R):
            for c in range(C):
                if board[r][c] == '.':
                    dots += 1
        print(dots-shortest)

if __name__ == '__main__':
    main()

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

public class Main{
	public static void main(String[] args)throws IOException{
		int count;
		int add=0;
		int ave3,ave2;
	
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		
		while(true){
			String line = br.readLine();
			String[] str = line.split(" ");
			int n = Integer.parseInt(str[0]);
			int x = Integer.parseInt(str[1]);
			
			if((n == 0) && (x == 0)){
				break;
			}
			
			count = 0;
			ave3 = x / 3;
			for(int i=1; i<ave3; i++){
				ave2 = (x - i) / 2;
				for(int j=i+1; j<=ave2; j++){
					int k = x - i - j;
					if((j < k) && (k <= n)){
						count++;
					}
				}
			}
			System.out.println(count);
		}
	}
}

Measured memory_bytes: 24252
#include<bits/stdc++.h>
#include<iomanip>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
typedef long long ll;
typedef pair<int,int> pl;
const int INF=100000001;

int main(){
  int n; cin>>n;
  vector<int> a(n);
  priority_queue<int> q;
  rep(i,n){
    cin>>a[i];
    q.push(a[i]);
  }
  rep(i,n){
    int ans;
    int t=q.top();
    if(a[i]==t){
      q.pop();
      ans=q.top();
      q.push(t);
    }else{
      ans=t;
    }
    cout<<ans<<endl;
  }
  return 0;
}


Measured memory_bytes: 3316
#include<bits/stdc++.h>
using namespace std;
int main(){
    
    int n,x;
    int ans;
    while(1){
        ans=0;
        cin>>n>>x;
        if(n==0&&x==0)break;
        for(int i=1;i<n-1;i++){
            for(int j=i+1;j<n;j++){
                for(int k=j+1;k<n+1;k++){
                    if(i+j+k==x)ans++;
                }
            }
        }
        cout<<ans<<endl;
    }
    return 0;
}


Measured memory_bytes: 3084
#include <bits/stdc++.h>
#define rep(i,n) for (int i=0;i < (n); ++i)
#define ALL(x) (x).begin(), (x).end()
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef vector<vector<int>> Graph;


int main() {
    int x;
    cin >> x;
    if(x>=30) cout << "Yes" << endl;
    else cout << "No" << endl;
}

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

#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
#define all(x) (x).begin(),(x).end()

template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
typedef long long ll;

const long long INF = 1LL << 60;

int main()
{

    int A, B, C, X;
    cin >> A >> B >> C >> X;

    int cnt = 0;
    rep(i, A + 1) {
        rep(j, B + 1) {
            rep(k, C + 1) {
                if (i * 500 + j * 100 + k * 50 == X) cnt++;
            }
        }
    }

    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 256
#! /usr/bin/env python
# -*- coding: utf-8 -*-

''' ?????\??? '''

# ?¨??????????O(1)


def round_robin_scheduling(process_name, process_time, quantum):
    result = []
    elapsed_time = 0

    while len(process_name) > 0:
        p_name = process_name.pop(0)
        p_time = process_time.pop(0)

        if p_time > quantum:
            elapsed_time += quantum
            process_name.append(p_name)
            process_time.append(p_time - quantum)
        else:
            elapsed_time += p_time
            result.append(p_name + ' ' + str(elapsed_time))

    return result


if __name__ == '__main__':
    N_p, quantum = map(int, input().split())
    p_name, p_time = [], []
    for i in range(N_p):
        p = list(input().split())
        p_name.append(p[0])
        p_time.append(int(p[1]))

    result = round_robin_scheduling(p_name, p_time, quantum)

    for i in range(len(result)):
        print(result[i])

Measured memory_bytes: 13736
# -*- coding: utf-8 -*-


def main():
    from math import ceil
    import sys
    input = sys.stdin.readline

    h, w = map(int, input().split())

    # 境界値
    if h == 1 or w == 1:
        print(1)
        exit()

    ans = h // 2 * w

    if h % 2 == 1:
        ans += ceil(w / 2)

    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 3060
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scan=new Scanner(System.in);
		String x=scan.next();
		char[] y=x.toCharArray();
		if(y[0]>='A' && y[0]<='Z') {
			System.out.println("A");
		}
		else {
			System.out.println("a");
		}
	}

}


Measured memory_bytes: 35668
import sys

sys.setrecursionlimit(4100000)


def inputs(num_of_input):
    ins = [input() for i in range(num_of_input)]
    return ins


def solve(inputs):
    [A, P] = string_to_int(inputs[0])
    pieces = A*3 + P
    return pieces//2


def string_to_int(string):
    return list(map(lambda x: int(x), string.split()))


if __name__ == "__main__":
    ret = solve(inputs(1))
    print(ret)


Measured memory_bytes: 2940
#ifdef LOCAL
#include <cstdio>
#include <vector>
#include <algorithm>
#include <iostream>
#include <cstring>
#else
#include <bits/stdc++.h>
#endif
using namespace std ;

typedef long long ll ;
typedef unsigned long long ull ;
#define rep(i , n ) for ( int i =0; i < n ; i++)
#define rrep(i , n) for ( int i = n-1; i >=0 ; i--)

#define _sort(arg) sort(begin(arg), end(arg))
#define MOD 1000000007
#define pb push_back
#define DEBUG(x) cout << #x << ": " << x << endl;

class UnionFind {
private:
	ull size_; 
	std::vector<ull> par, rank, count;

public:
	UnionFind() : size_(0), par(std::vector<ull>()), rank(std::vector<ull>()), count(std::vector<ull>()) {};
	UnionFind(ull size__) : size_(size__) {
		par.resize(size_); rank.resize(size_); count.resize(size__);
		for (ull i = 0; i < size_; i++) par[i] = i, rank[i] = 0, count[i] = 1;
	}
	ull size() { return size_; }
	// ull root(ull x) { return par[x] == x ? x : par[x] = root(par[x]); }
	
	ull root(ull x)
	{
		while(par[x] != x)
		{
			par[x] = par[par[x]];
			x = par[x];
		}
		return x;
	}
	
	bool same(ull x, ull y) { return root(x) == root(y); }

	void unite(ull x, ull y) {
		x = root(x), y = root(y);
		if (x == y) return;
		if (rank[x] < rank[y]) par[x] = y, count[y]+=count[x], count[x]=0;
		else if (rank[x] == rank[y]) par[y] = x, rank[x]++, count[x]+=count[y], count[y]=0;
		else par[y] = x, count[x] += count[y], count[y] = 0;
	}

	ull size__(ull x)
	{
		return count[root(x)];
	}

	bool operator==(const UnionFind &u) { return par == u.par; }
	bool operator!=(const UnionFind &u) { return par != u.par; }
};
/*
maybe sth wrong 
got wa in one problem
*/
ll modpow(ll a, ll b)
{
	if (b == 0)
	{
		return 1;
	}

	if (b % 2)
	{
		return a * modpow(a, b-1) % MOD;
	}
	else
	{
		ll halfB = b / 2;
		ll half = modpow(a, halfB);
		return half * half % MOD;
	}
}

ll calcComb(ll n, ll m)
{
	if (m > n-m)
	{
		return calcComb(n, n-m);
	}

	ll ansMul = 1;
	ll ansDiv = 1;

	rep(i, m)
	{
		ansMul *= (n-i);
		ansDiv *= (i+1);
		ansMul %= MOD;
		ansDiv %= MOD;
	}

	return ansMul * modpow(ansDiv, MOD - 2) % MOD;
}

__attribute__((constructor))
void initial()
{
	cin.tie(NULL);
	ios::sync_with_stdio(false);
}


int main()
{
	ll N, K;
	
	cin >> N >> K;

	double p[N];

	double s[N+1];
	s[0] = 0;
	rep(i, N)
	{
		double tmp ;
		cin >> tmp;

		p[i] = (1+tmp) / 2.0;
		s[i+1] = s[i] + p[i];
	}

	double max_ = 0.0;

	/*
	for(int i = K; i <= N; i++)
	{
		max_ = max(max_, s[i] - s[i-K]);
	}
	*/
	for (int j = 0; j < N-K+1; j++)
	{
		max_ = max(max_, s[j+K] - s[j]);
	}
	//cout << max_ << endl;
	printf("%lf\n", max_);
	
	return 0;
}


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

long long lucas(int n){
  vector<long long> l(n+1,0);
  l[0]=2;
  l[1]=1;
  for(int i=2 ;i<=n;++i){
    l[i]=l[i-1]+l[i-2];
  }
  return l[n];
}

int main(){
  int n;
  cin >> n;
  cout << lucas(n) << endl;
}

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

public class Main {
        public static void main(String[] args) {
                Scanner scan = new Scanner(System.in);
                int num = scan.nextInt();
                
                double sum = 0;
                double tmp = 0;

                for (int i=0; i<num; i++) {
                        double money = scan.nextDouble();
                        String unit = scan.next();
                        if ( unit.equals("BTC") ) {
                            tmp = money * 380000;
                        }
                        else {
                            tmp = money;
                        }
                        sum += tmp;
                }
                
                System.out.println( sum );
                scan.close();
        }
}

Measured memory_bytes: 23380
// #define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()
#define Graph vector<vector<int>>
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1000000007;

// #include <boost/multiprecision/cpp_dec_float.hpp>
// #include <boost/multiprecision/cpp_int.hpp>
// namespace mp = boost::multiprecision;
// using Bint = mp::cpp_int;
// using Real = mp::number<mp::cpp_dec_float<1024>>;

vector<string> BubbleSort(vector<string> C, int N){
    for(int i = 0; i < N; i++){
        for(int j = N - 1; j > i; j--){
            if(C[j][1] < C[j - 1][1]) swap(C[j], C[j-1]);
        }
    }
    return C;
}

vector<string> SelectionSort(vector<string> C, int N){
    for(int i = 0; i < N; i++){
        int minj = i;
        for(int j = i; j < N; j++){
            if(C[j][1] < C[minj][1]) minj = j;
        }
        swap(C[i], C[minj]);
    }
    return C;
}

int main(){
    int N;
    cin >> N;
    vector<string> C(N);
    rep(i, N) cin >> C[i];
    vector<string> A = BubbleSort(C, N);
    vector<string> B = SelectionSort(C, N);

    rep(i, N){
        if(i) cout << ' ';
        cout << A[i];
    }
    cout << endl;
    cout << "Stable" << endl;

    rep(i, N){
        if(i) cout << ' ';
        cout << B[i];
    }
    cout << endl;
    if(A == B) cout << "Stable" << endl;
    else cout << "Not stable" << endl;
    
}


Measured memory_bytes: 3188
from collections import defaultdict

N = int(input())
edge = defaultdict(list)
# 辺の情報と距離を記録
for i in range(N-1):
    u, v, w = map(int, input().split())
    edge[u].append((v, w))
    edge[v].append((u, w))

# 幅優先探索
distance = [0]*N
queue = [(1, -1)]
while True:
    if len(queue) == 0:
        break
    cur_id, parent_id = queue.pop()
    for child_id, w in edge[cur_id].copy():
        if child_id == parent_id:
            continue
        queue.append((child_id, cur_id))
        distance[child_id-1] = distance[cur_id-1] + w

for i in range(N):
    print(distance[i]%2)

Measured memory_bytes: 48408
def main():
  N = input()
  operators = [["+","+","+"],["+","+","-"],["+","-","+"],["-","+","+"],["+","-","-"],["-","+","-"],["-","-","+"],["-","-","-"]]
  for x,y,z in operators:
        tmp = N[0]+x+N[1]+y+N[2]+z+N[3]
        if eval(tmp) == 7:
              print(tmp+"=7")
              break

if __name__ == "__main__":
      main()

Measured memory_bytes: 3064
#include <algorithm>
#include <bitset>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <tuple>
#include <vector>

using namespace std;
typedef long long ll;
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define reps(i, f, n) for (ll i = (f); i < (n); i++)
#define repv(v) for (auto it = (v).begin(); it != (v).end(); it++)
ll const INF = 1LL << 60;
ll const MAX_N = 510000;
ll const MOD = 1000000007;

// 素因数分解 O(√n)
map<ll, ll> prime_factor(ll n) {
    map<ll, ll> res;

    for (ll i = 2; i * i <= n; i++) {
        while (n % i == 0) {
            ++res[i];
            n /= i;
        }
    }

    if (n != 1) res[n] = 1;

    return res;
}

// 約数の列挙 O(√n)
vector<ll> divisor(ll n) {
    vector<ll> res;

    for (ll i = 1; i * i <= n; i++) {
        if (n % i == 0) {
            res.push_back(i);
            if (i != n / i) res.push_back(n / i);
        }
    }

    return res;
}

ll getdigit(ll n) {
    ll digit = 0;
    while (n != 0) {
        n /= 10;
        digit++;
    }

    return digit;
}

int main() {
    ll N;
    cin >> N;
    ll ans = INF;

    vector<ll> divs = divisor(N);
    repv(divs) {
        ll A = *it;
        ll B = N / A;
        ll Adig = getdigit(A);
        ll Bdig = getdigit(B);
        // cout << "A:" << A << ", B:" << B << ", Adig:" << Adig
        //      << ", Bdig:" << Bdig << endl;
        ans = min(ans, max(Adig, Bdig));
    }

    cout << ans << endl;

    // map<ll, ll> primes = prime_factor(N);
    // for (auto p : primes) {
    //     cout << p.first << "," << p.second << endl;
    // }

    return 0;
}

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

def gen_div(n):
    for i in range(1, int(math.sqrt(n)) + 1):
        if n % i == 0:
            yield i
            if n // i != i:
                yield n // i

sum = 0
for i in gen_div(N):
    if i == 1:
        continue
    a = i - 1
    q, m = N // a, N % a
    if q == m:
        sum += a

print(sum)



Measured memory_bytes: 3060
n = int(input())
a = list(map(int, input().split()))
a.sort()
cnt = 1
ans = 0
if n == 1:
    if a[0] != 1:
        ans = 1
for i in range(1,n):
    if a[i] == a[i-1]:
        cnt += 1
    elif a[i] != a[i-1]:
        if cnt < a[i-1]:
            ans += cnt
        elif cnt > a[i-1]:
            ans += cnt - a[i-1]
        cnt = 1

    if i == n - 1:
        if cnt < a[i]:
            ans += cnt
        elif cnt > a[i]:
            ans += cnt - a[i]

print(ans)



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

using namespace std;

int main(){

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

    int H, W;
    char c;
    cin >> H >> W;

    for(int J = 0; J < W+2; J++){
        cout << "#";
    }
    cout << "\n";
    for(int I = 0; I < H; I++){
        cout << "#";
        for(int J = 0; J < W; J++){
            cin >> c;
            cout << c;
        }
        cout << "#\n";
    }
    for(int J = 0; J < W+2; J++){
        cout << "#";
    }
    cout << "\n";

    return 0;
}

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

int main() {
  int N,A,B;
  cin >> N >> A >> B;
  
  int plan1,plan2;
  plan1 = N * A;
  plan2 = B;
    
  if (plan1 < plan2)
    cout << plan1 << endl;
  else
    cout << plan2 << endl;
}


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

using namespace std;

int main() {
    vector<string> s(3);
    cin >> s[0] >> s[1] >> s[2];
    vector<int> i(3, 0);
    char c[] = {'A', 'B', 'C'};
    int t = 0;
    while (1) {
        if (i[t] == s[t].size()) {
            cout << c[t] << endl;
            return 0;
        }
        
        i[t]++;
        t = s[t][i[t]-1] - 'a';
    }
}

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


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

const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

int main()
{
    int X;
    cin >> X;
    for (int i = -200; i <= 200;i++)
    {
        for (int j = -200; j <= 200;j++)
        {
            if(pow(i,5) -pow(j,5) == X){
                cout << i << " " << j << endl;
                return 0;
            }
        }
    }
}


Measured memory_bytes: 4040
N=int(input())
A=list(map(int, input().split()))
L=[0]*(10**6)
for a in A:
    L[a-1]+=1
    L[a]+=1
    L[a+1]+=1

ans=0
now=0
for i,l in enumerate(L):
    if now<l:
        now=l
        ans=i

print(now)

Measured memory_bytes: 15868
#include <atcoder/all>
#include <iostream>
#include <numeric>
#include <cmath>
#include <limits>
#include <stdio.h>
#include <iomanip>
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
using namespace std;
using namespace atcoder;
using ll = long long;
#define rep(i, n) for (long long i = 0; i < (long long)(n); i++)
ll Max(ll(a), ll(b), ll(c)) {
	return max(max(a, b), c);
}
ll Min(ll(a), ll(b), ll(c)) {
	return min(min(a, b), c);
}
ll mod = 998244353;
int main() {
	ll N, M;
	cin >> N >> M;
	scc_graph AN(N);
	rep(i, M) {
		ll a, b;
		cin >> a >> b;
		AN.add_edge(a, b);
	}
	auto scc = AN.scc();
	cout << scc.size() << endl;
	for (auto v : scc) {
		cout << v.size() << " ";
		for (int x : v) {
			cout << x << " ";
		}
		cout << endl;
	}
}

Measured memory_bytes: 40552
N, X = [int(i) for i in input().split()]
L = [int(i) for i in input().split()]
ans = 0
prev = 0
for i in range(N + 1):
    D = 0 if i == 0 else prev + L[i - 1]
    if D <= X:
        ans += 1
    prev = D
print(ans)


Measured memory_bytes: 3060
dontt_use = input()
str_list = list(input().split())
n = map(int,str_list)

def foo(n):
    total = 1  
    for number in n:
        total = total * number
        if total > 10**18:
            print('-1')
            return
    print(total)
if '0' in str_list :
    print(0)
else:
    foo(n)

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

using namespace std;
#define _for(i,j,N) for(int i = (j);i < (N);i++)
#define _rep(i,j,N) for(int i = (j);i <= (N);i++)
#define _dec(i,N,j) for(int i = (N-1);i >= (j);i--)
#define _rec(i,N,j) for(int i = (N);i >=(j);i--)
#define ALL(x) x.begin(),x.end()
#define MEM(a,n) memset(a,n,sizeof(a))
#define fst first
#define scd second
#define PB push_back
#define MP make_pair

typedef long long LL;
typedef long double LD;
typedef pair<int,int> pii;
typedef pair<LL,LL> pll;

int get_int(){int x;scanf("%d",&x);return x;}
LL get_ll(){LL x;scanf("%lld",&x);return x;}
double get_db(){double x;scanf("%lf",&x);return x;}

template<typename T> int chmin(T &a,T b){if(a > b){a = b;return 1;}else return 0;}
template<typename T> int chmax(T &a,T b){if(a < b){a = b;return 1;}else return 0;}
template<typename T>
ostream& operator<<(ostream& os,const vector<T>& v) {_for(i,0,v.size()) os << v[i] << " ";return os;}
template<typename T>
ostream& operator<<(ostream& os,const set<T>& v){for(auto a:v) os << a <<" ";return os;}
template<typename T1,typename T2>
ostream& operator<<(ostream& os,const pair<T1,T2>& v){os << v.fst <<" "<<v.scd << " ";return os;}
template<typename T1,typename T2>
ostream& operator<<(ostream& os,const map<T1,T2>& v){for(auto a:v) cout << a << endl;return os;}

static const int dx[8] = { -1,  0, 1, 0,  1, -1,  1, -1};
static const int dy[8] = {0,  1, 0,  -1,  1, -1, -1,  1};
const double pi  = acos(-1.0);
const double eps = 1e-8;
//const LL  INF  = 0x3f3f3f3f3f3f3f3f;
const int inf  = 0x3f3f3f3f;

const int maxn = 1e5+5;

string a;

int main()
{
    cin >> a;
    int sz = a.size();
    int ans = 0;
    _for(i,0,sz/2){
        if(a[i] != a[sz - i - 1]) ans++;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
// abc156_a
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<unordered_map>
#include<utility>
#include<cmath>
#include<random>
#include<cstring>
#include<queue>
#include<stack>
#include<bitset>
#include<cstdio>
#include<sstream>
#include<iomanip>
#include<assert.h>
#include<typeinfo>
#define loop(i,a,b) for(int i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)
#define FOR(i,a) for(auto i:a)
#define pb push_back
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
#define show1d(v) rep(i,v.size())cout<<" "<<v[i];cout<<endl<<endl;
#define show2d(v) rep(i,v.size()){rep(j,v[i].size())cout<<" "<<v[i][j];cout<<endl;}cout<<endl;
using namespace std;
typedef long long ll;
typedef int Def;
typedef pair<Def,Def> pii;
typedef vector<Def> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<Def,pii> pip;
typedef vector<pip>vip;
template<typename A,typename B>bool cmin(A &a,const B &b){return a>b?(a=b,true):false;}
template<typename A,typename B>bool cmax(A &a,const B &b){return a<b?(a=b,true):false;}
const double PI=acos(-1);
const double EPS=1e-9;
Def inf = sizeof(Def) == sizeof(long long) ? 2e18 : 1e9+10;
int dx[]={0,1,0,-1};
int dy[]={1,0,-1,0};
int main(int argc, char *argv[])
{
  int n,r;
  cin>>n>>r;
  cout<<((n<10)?r+100*(10-n):r)<<endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <fstream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <utility>
#include <bitset>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cstdio>

using namespace std;

#define REP(i,n) for((i)=0;(i)<(int)(n);(i)++)
using ll = long long;
using P = pair<int,int>;

int main(void) {
  int R;
  cin >> R;

  if(R<1200){
    cout << "ABC" << endl;
  }
  else if(R<2800 && R>=1200){
    cout << "ARC" << endl;
  } else {
    cout << "AGC" << endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{

    char string_inputS[101];
    char string_inputT[101];
    char string_output[202];

    scanf("%s%s", string_inputS, string_inputT);

    sprintf(string_output, "%s%s", string_inputT, string_inputS);
    printf("%s", string_output);

}

Measured memory_bytes: 128
#include <iostream>
#include <algorithm>
#include <queue>

using namespace std;

long long n, a[3 * 100000 + 10], x[3 * 100000 + 10], y[3 * 100000 + 10];
priority_queue<long long, vector<long long> ,greater<long long>> h1;
priority_queue<long long> h2;

void read() {
    cin >> n;
    for(int i = 1; i <= 3 * n; i++) {
        cin >> a[i];
    }
}

void fil() {
    long long sum = 0;
    for(int i = 1; i <= n; i++) {
        h1.push(a[i]);
        sum += a[i];
    }
    x[n] = sum;
    for(int i = n + 1; i <= 2 * n; i++) {
        if(a[i] > h1.top()) {
            sum -= h1.top();
            h1.pop();
            h1.push(a[i]);
            sum += a[i];
        }
        x[i] = sum;
    }
    sum = 0;
    for(int i = 3 * n; i >= 2 * n + 1; i--) {
        sum += a[i];
        h2.push(a[i]);
    }
    y[2 * n + 1] = sum;
    for(int i = 2 * n; i >= n + 1; i--) {
        if(a[i] < h2.top()) {
            sum -= h2.top();
            h2.pop();
            h2.push(a[i]);
            sum += a[i];
        }
        y[i] = sum;
    }
    long long result = -100000000000000000;
    for(int i = n; i <= 2 * n; i++) {
        result = max(x[i] - y[i + 1], result);
    }
    cout << result;
}

int main()
{
    read();
    fil();
    return 0;
}

Measured memory_bytes: 7668
from collections import Counter
N = int(input())

A = list(map(int,input().split()))
Q = int(input())

counter = Counter(A)
sum_res = sum(A)
#print(sum_res,counter)
for _ in range(Q):
    bf,af = map(int,input().split())
    sum_res -= bf*counter[bf]
    sum_res += af*counter[bf]
    
    counter[af] += counter[bf]
    counter[bf] = 0
    
    print(sum_res)

Measured memory_bytes: 24008
import java.util.Scanner;
public class Main {
    public static void main(String args[]) {
        Scanner s = new Scanner(System.in);
        int N = s.nextInt();
        int[] V = new int[N];
        int[] C = new int[N];
        for (int i = 0; i < N; i++) {
            V[i] = s.nextInt();
        }
        for (int i = 0; i < N; i++) {
            C[i] = s.nextInt();
        }
        int ans = 0;
        for (int i = 0; i < N; i++) {
            if (V[i] > C[i])
                ans += V[i] - C[i];
        }
        System.out.print(ans);
    }
}


Measured memory_bytes: 22740