akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;

int main() {
	int N;
	cin >> N;
	vector<ll> L(N);
	rep(i, N) cin >> L[i];

	int cnt = 0;
	for(int i = 0; i < N - 2; i++) {
		for(int j = i + 1; j < N - 1; j++) {
			if(L[i] == L[j]) continue;
			for(int k = j + 1; k < N; k++) {
				if(L[i] == L[k]) continue;
				if(L[j] == L[k]) continue;
				ll m = max(L[i], max(L[j], L[k]));
				if(m < L[i] + L[j] && m < L[i] + L[k] && m < L[j] + L[k])
					cnt++;
			}
		}
	}

	cout << cnt << endl;

	return 0;
}

Measured memory_bytes: 3632
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 t = sc.nextInt();
	    int returnT = 0;
	    returnT = (int)Math.ceil((double)n / (double)x) * t;
	    System.out.println(returnT);
	}
}


Measured memory_bytes: 35768
#include<bits/stdc++.h>
const int N=100001;
using namespace std;
int main(){
    int n,x[N],y[N],t[N];
    cin>>n;
    for(int i=1;i<=n;i++){
        cin>>t[i]>>x[i]>>y[i];
    }
    for(int i=1;i<=n;i++)
        if(x[i]+y[i]>t[i]||(t[i]-x[i]-y[i])%2!=0){
        cout<<"No"<<endl;
            return 0;   
            }
            cout<<"Yes"<<endl;
            return 0;
}

Measured memory_bytes: 1408
a, b, c, d = map(int, input().split())

turn = 1
while a > 0 and c > 0:
   # Takahashi
   if turn % 2 == 1:
      c -= b

   # Aoki
   else:
      a -= d

   turn += 1

if a > 0 and c <= 0:
   print('Yes')
elif a <= 0 and c > 0:
   print('No')


Measured memory_bytes: 9180
n=int(input())
a=[int(x) for x in input().split()]
b=[int(x) for x in input().split()]
ans=0
for i in range(n):
    if b[i]<=a[i]:
        a[i]-=b[i]
        ans+=b[i]
        b[i]=0
    else:
        b[i]-=a[i]
        ans+=a[i]
        a[i]=0
        if b[i]<=a[i+1]:
            a[i+1]-=b[i]
            ans+=b[i]
            b[i]=0
        else:
            ans+=a[i+1]
            b[i]-=a[i+1]
            a[i+1]=0
print(ans)

Measured memory_bytes: 97692
#include <bits/stdc++.h>
#define VI vector<int>
#define VVI vector<vector<int>>
#define REP(i, n) for (int i = 0; i < (n); i++)
#define MOD 1000000007
#define INF 1e9
#define All(x) (x).begin(), (x).end()
typedef long long ll;
using namespace std;

int main() {
  double A, B, C, D;
  cin >> A >> B >> C >> D;
  int a = ceil(A / D);
  int b = ceil(C / B);
  if(a>=b){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }

  return 0;
}


Measured memory_bytes: 3736
#include <stdio.h>

int N, a[100011], L;
int Q;
int d[17][100011];

// Search max_i (a(i)) such that a(i) <= x
int lo(int x)
{
        int l, m, h;
        l = 0;
        h = N-1;
        while(l < h){
                m = (l + h) >> 1;
                if((a[m] <= x && (m+1 == N || a[m+1] > x)))
                        return m;
                else if(a[m] < x)
                        l = m+1;
                else
                        h = m-1;
        }
        return l;
}
int main()
{
        int i, j;
        int s, e;
        int days;
        scanf("%d", &N);
        for(i = 0; i < N; i++)
                scanf("%d", &a[i]);
        scanf("%d%d", &L, &Q);

        for(j = 0; j < N; j++){
                d[0][j] = lo(a[j] + L);
        }
        for(i = 1; i < 17; i++){
                for(j = 0; j < N; j++){
                        d[i][j] = d[i-1][d[i-1][j]];
                }
        }

/*
        for(i = 0; i < 17; i++){
                for(j = 0; j < N; j++)
                        printf("%d ", d[i][j]);
                printf("\n");
        }
*/

        for(i = 0; i < Q; i++){
                scanf("%d%d", &s, &e);
                j = 16;
                days = 0;
                s--; e--;
                if(s > e){
                        int tmp = s; s = e; e = tmp;
                }
                while(s < e){
                        while(j > 0 && d[j][s] >= e) j--;
                        days += (1 << j);
                        s = d[j][s];
//                      fprintf(stderr, "%d %d %d\n", s, e, j);
                }
                printf("%d\n", days);
        }

}


Measured memory_bytes: 7808
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long LL;
typedef vector<ll>VI;
typedef pair<ll,ll>P;
typedef pair<double,double>P_D;
#define VV(T) vector<vector<T>>
#define PI 3.1415926535897932384626433832795
#define rep(i, n) for (ll i = 0; i < (ll)n; i++)
#define reprev(i, n) for (ll i = (ll)n - 1; i >= 0; i--)
#define ALL(a)  (a).begin(),(a).end()
#define c_max(a, b) (((ll)a)>((ll)b)?(a):(b))
#define c_min(a,b) (((ll)a)<((ll)b)?(a):(b))
#define chmax(x,a) x=max(x,a)
#define chmin(x,a) x=min(x,a)
#define vmax(v) *max_element(ALL(v))
#define vmin(v) *min_element(ALL(v))
#define $(x) {cout<<#x<<" = " <<(x)<<endl;}
#define fi first
#define se second
#define MAX 100100//5
#define MAX2 200100
#define MAX_6 1001001//6
#define MAX_7 10010010//7
#define SENTINEL 2000000000//9
#define NIL -1
const int MOD = 1000000007;
#define INF 1<<30
#define INFTY 1LL<<61
#define MAX_INT INT_MAX
#define Endl '\n'
inline ll GCD(ll a,ll b){return b?GCD(b,a%b):a;}
inline ll lcm(ll a,ll b){return a*b/GCD(a,b);}
using Edge=pair<int,ll>;
using Graph=vector<vector<int> >;//ll or Edge
using Edge=pair<int,ll>;
const int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};
// sort_reverse...greater<ll>()
// g++ -o a a.cpp -Wall -lm -std=c++17
ll d[3010][3010];
ll dp[3010][3010][4];//dp[i][j]:=i,jにいるときの価値の最大値
int main(){
    ll R,C,K;cin>>R>>C>>K;
    memset(d,0,sizeof(d));
    rep(i,K){
        ll r,c,v;
        cin>>r>>c>>v;
        d[r-1][c-1]=v;
    }
    rep(i,R)rep(j,C){
        if(d[i][j]>0){
        for(int k=2;k>=0;k--){
            chmax(dp[i][j][k+1],dp[i][j][k]+d[i][j]);
        }
        }
        rep(k,4){
            chmax(dp[i+1][j][0],dp[i][j][k]);
            chmax(dp[i][j+1][k],dp[i][j][k]);
        }
    }
    cout<<*max_element(dp[R-1][C-1],dp[R-1][C-1]+4)<<endl;
}

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

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

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

def main():
	h,w=MI()

	S=["#"*(w+1)]
	for _ in range(h):
		S.append("#"+input().rstrip().decode())
	#print(S)

	G=[[10**10]*(w+1) for _ in range(h+1)]

	if S[1][1]=="#":
		G[1][1]=1
	else:
		G[1][1]=0

	for i in range(1,h+1):
		for j in range(1,w+1):
			#print(G)
			if i==j==1:
				continue
			a=G[i-1][j]+(S[i-1][j]=="." and S[i][j]=="#")
			b=G[i][j-1]+(S[i][j-1]=="." and S[i][j]=="#")
			#print(i,j,a,b)
			G[i][j]=min(a,b)

	print(G[h][w])













if __name__ == "__main__":
	main()


Measured memory_bytes: 9372
def dist(a, b)
  Math.sqrt((a[0] - b[0])**2 + (a[1] - b[1])**2)
end

n = gets.to_i
xys = n.times.map { gets.split.map(&:to_i) }

routes = [*0..n - 1].permutation
ans = 0

routes.each do |r|
  r.each_cons(2) do |a, b|
    ans += dist(xys[a], xys[b])
  end
end

puts ans / routes.count


Measured memory_bytes: 4092
/*
    Mbak Sana Dong
    Mbak Chaeyoung Dong
    Mbak Seulgi Dong
*/
#include<bits/stdc++.h>
#define ll long long int
using namespace std;
const int mod = 998244353;
ll dp[200200];
ll bit[200200];
void add(int x, ll val)
{
    for(x;x<=200000;x+=(x&-x))  {
        bit[x]+=val;
        bit[x]%=mod;
    }
}
ll get(int x)
{
    ll res = 0;
    for(x;x>0;x-=(x&-x)) {
        res += bit[x];
        res %= mod;
    }
    return res;
}
int main()
{
    int n,i,j,k,x,y,ans,curr,temp,m;
    int tc;
    cin >> n >> k;
    add(1, 1);
    vector<pair<int,int> > v;
    for(i=1;i<=k;i++) {
        cin >> x >> y;
        v.push_back({x, y});
    }
    sort(v.begin(), v.end());
    for(i=2;i<=n;i++) {
        dp[i]=0;
        for(auto x : v) {
            if(x.first > i - 1) break;
            int r = i - x.first;
            int l = i - min(i - 1, x.second);
            dp[i] += get(r);
            dp[i] %= mod;
            dp[i] -= get(l-1);
            while(dp[i] < 0) dp[i] += mod;
        }
        add(i, dp[i]);
    }
    cout << dp[n] << endl;
    return 0;
}


Measured memory_bytes: 6744
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const double pi=3.141592653589793;
typedef unsigned long long ull;
typedef long double ldouble;
const ll INF=1e18;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)

// 最大文字数　注意
const int MAX_S = 55;

int main(){
    string ss, tt;
    cin >> ss;
    cin >> tt;
    int n = ss.length(), m = tt.length();
    vector<char> s(n);
    vector<char> t(m);
    rep(i, n) s.at(i) = (char)ss.at(i);
    rep(i, m) t.at(i) = (char)tt.at(i);

    int last = -1;
    for(int i = n-1; i >= 0; i--){
        bool tmp = true;
        for(int j = i; j > i - m; j--){
            if(j < 0 || (s.at(j) != '?' && s.at(j) != t.at(m-i+j-1))){
                tmp = false;
                break;
            }
        }
        if(tmp == true) {
            last = i;
            break;
        }
    }
    if(last == -1) {
        cout << "UNRESTORABLE" << endl;
        return 0;
    }
    int first = last - m + 1;
    for(int i = 0; i < n; i++){
        if(i == first){
            for(i; i <= last; i++){
                cout << t.at(i-first);
            }
            i--;
        }
        else if(s.at(i) == '?') cout << 'a';
        else cout << s.at(i);
    }
    cout << endl;
}

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

struct Data{
    int w, h;
};

int main(){
    int n, w, d;
    while(cin >> n >> w >> d, n||w||d){
        Data data[128];
        data[1] = (Data){w, d};
        int ptr = 2;
        for(int i = 0; i < n; i++){
            int p, s;
            cin >> p >> s;
            Data tmp = data[p];
            s %= tmp.w + tmp.h;

            for(int j = p; j < ptr - 1; j++){
                swap(data[j], data[j+1]);
            }

            if(s < tmp.w){
                int Pos = min(s, tmp.w - s);
                data[ptr++] = (Data){tmp.w - Pos, tmp.h};
                data[ptr - 2].w = Pos;
            }
            else{
                s -= tmp.w;
                int Pos = min(s, tmp.h - s);
                data[ptr++] = (Data){tmp.w, tmp.h - Pos};
                data[ptr - 2].h = Pos;
            }
        }
        vector<int> dat;
        for(int i = 1; i < ptr; i++){
            dat.push_back(data[i].w * data[i].h);
        }
        sort(dat.begin(), dat.end());
        bool first = false;
        for(int i = 0; i < dat.size(); i++){
            if(first++) printf(" ");
            printf("%d", dat[i]);
        }
        printf("\n");
    }
}


Measured memory_bytes: 3276
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
#define FOR(i,a,n) for(int i=(a); i<(n); i++)
#define all(v) v.begin(), v.end()
#define fi first
#define se second
#define sz(x) int(x.size())
using namespace std;
using ll = long long;
using P = pair<int ,int>;
const int INF = 1001001001;
const int MOD = 1000000007;
template<class T> inline bool chmax(T &a, T b) { if (a<b) {a=b; return 1;} return 0;}
template<class T> inline bool chmin(T &a, T b) { if (b<a) {a=b; return 1;} return 0;}

#ifdef _DEBUG
#include "debug.h"
#else
#define debug(...)
#define print(...)
#endif

int main() {
    int n; cin >> n;
    bool ok = false;
    int cnt = 0;
    rep(i, n) {
        int a, b; cin >> a >> b;
        if (a==b) {
            cnt++;
        } else {
            cnt = 0;
        }
        if (cnt>=3) ok = true;
    }
    if (ok) puts("Yes");
    else puts("No");
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
#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()

void no(){
  cout << -1 << endl;
  exit(0);
}

int main(){
  string s,t; cin >> s >> t;
  vector<vector<ll>> dic(26);
  ll n = s.size();
  REP(i,n){
    ll c = s[i] - 'a';
    dic[c].push_back(i+1);
  }
  ll m = t.size();
  ll prev = 0;
  ll ans = 0;
  ll i = 0; //tの何もじめ？
  while(i<m){
    vector<ll> pos(26,0);
    while(i<m){
      ll c = t[i] - 'a';
      if(dic[c].empty()) no();
      bool f = false;
      while(1){
        if(pos[c] == (ll)dic[c].size()){
          f = true;
          break;
        }
        if(prev >= dic[c][pos[c]]) pos[c]++;
        else{
          prev = dic[c][pos[c]];
          pos[c]++; i++;
          break;
        }
      }
      if(f){
        ans += n;
        prev = 0;
        break;
      }
    }
  }
  ans += prev;
  cout << ans << endl;
}



Measured memory_bytes: 1724
#include <bits/stdc++.h>
using namespace std;
 int main(){
    string s, t;
    int ans=0;
    cin >> s >> t;
    for(int i= 0; i < s.length(); i++){
        if(s[i] != t[i])
            ans++;
    }
  
    cout << ans;
    return 0;
}

Measured memory_bytes: 3912
#include <iostream>
#include <cmath>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define loop(i, a, n) for(int i = a; i < n; i++)

int main() {
	int x, max = 0;
	cin >> x;
	loop(i, 2, x) {
		int n = 2;
		while (pow(i, n) <= x) {
			if (pow(i, n) > max) max = pow(i, n);
			n++;
		}
	}
	if (max == 0)	max = 1;
	cout << max << endl;

	return 0;
}

Measured memory_bytes: 512
#include<algorithm>
#include<cmath>
#include<cstring>
#include<cstdio>
#include<iostream>
#include<vector>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<string>
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)n; i++)
#define ll long long 
using namespace std;
int main(){
  int n;
  string s;
  cin >>n;
  cin >>s;
  ll r=0;
  ll g=0;
  ll b=0;
  ll key=0;
  for(int i=0;i<n;i++){
    if(s[i]=='R'){
      r++;
    }
  }
  for(int i=0;i<n;i++){
    if(s[i]=='G'){
      g++;
    }
  }
  for(int i=0;i<n;i++){
    if(s[i]=='B'){
      b++;
    }
  }
  if(n<3){
    cout <<0<<endl;
  }else{
   for(int i=1;i<(n-1)/2+1;i++){
     if(n-2*i<1){
       cout <<0<<endl;
     }else{
     for(int j=0;j<n-2*i;j++){
     if ( s[j]!=s[j+i]&&s[j]!=s[j+2*i]&&s[j+i]!=s[j+2*i]){
       key++;
      }
     }
     }
   }
    cout <<r*g*b-key<<endl;
  }
}
   

Measured memory_bytes: 3636
x,k,d=map(int,input().split())
x=abs(x)
if k>=round(x/d):
  if (k-round(x/d))%2==0:
    print(abs(x-d*round(x/d)))
  else:
    print(d-abs(x-d*round(x/d)))
else:
  print(x-d*k)

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

int main() {
  string s;
  cin >>s;
  int ma,count;
  count =0;ma=0;
  for(int i=0;i<s.size();i++){
  	if(s[i]=='A'||s[i]=='C'||s[i]=='G'||s[i]=='T'){
    count++; ma=max(count,ma);
    }
    else {count=0;}
  }
  cout <<ma;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <string>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <tuple>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cassert>
#include <cstdint>
#include <cctype>
#include <numeric>
#include <bitset>
#include <functional>

using namespace std;

using ll =  long long;
using Pll = pair<ll, ll>;
using Pii = pair<int, int>;

constexpr int INF = 1 << 30;
constexpr ll LINF = 1LL << 60;
constexpr ll MOD = 1000000007;
constexpr long double EPS = 1e-10;
constexpr int dyx[4][2] = {
    { 0, 1}, {-1, 0}, {0,-1}, {1, 0}
};

int main() {
    ios::sync_with_stdio(false); cin.tie(nullptr);
    int n, k, c;
    cin >> n >> k >> c;
    string s;
    cin >> s;
    vector<int> l(n, 0), l_max(n, 0), min_day(k+1, n+1);
    for(int i=0;i<n;++i) {
        if(s[i] == 'o') {
            l[i] = ((i-c-1>=0)?l_max[i-c-1]:0) + 1;
            if(l[i] <= k) {
                min_day[l[i]] = min(i+1, min_day[l[i]]);
            }
        }
        if(i) l_max[i] = max(l[i], l_max[i-1]);
        else l_max[0] = l[i];
    }
    vector<int> r(n, k+1), r_min(n, k+1), max_day(k+1, 0);
    for(int i=n-1;i>=0;--i) {
        if(s[i] == 'o') {
            r[i] = ((i+c+1 <= n-1)?r_min[i+c+1]:k+1) - 1;
            if(r[i] > 0) {
                max_day[r[i]] = max(i+1, max_day[r[i]]);
            }
        }
        if(i != n-1) r_min[i] = min(r[i], r_min[i+1]);
        else r_min[i] = r[i];
    }

    for(int i=1;i<=k;++i) {
        if(min_day[i] == max_day[i]) cout << min_day[i] << endl;
    }
}


Measured memory_bytes: 6548
N,L =map(int,input().split())

list=[]

num = 0

for i in range(N):
  
  num += L+i
  list.append(abs(L+i))
  
min_num = min(list)

if L+i-1 >=0:
  print(num - min_num)

else:
  print(num+min_num)

Measured memory_bytes: 2940
import java.util.Scanner;
public class Main{
    public static void main(String[]args){
        Scanner scan = new Scanner(System.in);
        int h,n,sum;
        sum=0;
        h=scan.nextInt();
        n=scan.nextInt();
        for(int i=0;i<n;i++){
            sum+=scan.nextInt();
        }
        if(h-sum<=0) System.out.println("Yes");
        else System.out.println("No");
    }
}

Measured memory_bytes: 48072
/*     !ya khoda!     */
#include <bits/stdc++.h>

#define ll long long
#define ld long double

#define pp push
#define po pop()
#define pb push_back
#define pf push_front
#define pob pop_back()
#define pof pop_front()
#define I insert
#define E erase

#define F first
#define S second

#define mkp make_pair
#define pll pair<ll,ll>
#define smax(a,b) a=max(a,b)
#define smin(a,b) a=min(a,b)
#define all(a) a.begin(),a.end()

#define coutghat(x)      cout<<tolower(x);
#define coutashar(x,d)   cout<<fixed<<setprecision(x)<<(ld)d
#define IOS ios_base::sync_with_stdio(false) , cin.tie(0);

#define LB(x) ((x) & -(x))
#define BIT(a , b) (((a)>>(b)) & 1)
//#define poow(a,b,M)   b?(poow((a*a)%M,b/2)%M * (b&1?a))%M:1 ;
/*==========================================================================*/
using namespace std;
ll poow(ll x,ll n,ll Mod=1e9+7) { return (n==0?1:poow(x*x%Mod,n/2)*(n&1?x:1)%Mod); }
//#pragma optimize O3
// 107,109, 211,223, 307, 401,409, 503,509, 601,607, 701,709, 809, 907, 1009
/*==========================================================================*/
const int N=5e6+10  , M=1e4+10  , SQ=320 , LG=23 , base=2;
const int mod=1e9+7 , MOD=1e9+9;
const ll  INF=1e9   , inf=1e18 , super_inf=~0ull/4;
ll n,a[N],b[N] , p;
string s;
/*==========================================================================*/
ll check(ll x)
{   ll sum=0,p=0;
	for(int i=0;i<n;++i)   b[i]=a[i];
	b[0]+=x;
	for(int i=0;i<n;++i)
    {
		b[i]+=p;
		p=b[i]/10;
		b[i]%=10;
	}
	for(int i=0;i<n;++i)   sum+=b[i];
	if(sum<=x)   return 1;
	else         return 0;
}
/*==========================================================================*/
int main()
{
    IOS;
    cin>>s , n=s.size();
	reverse(all(s));
	for(int i=0;i<n;++i)   a[i]=s[i]-'0';
	for(int i=0;i<n;++i)   a[i]*=9;

	n+=20 , p=0;
	for(int i=0;i<n;++i)
    {
		a[i]+=p;
		p=a[i]/10;
		a[i]%=10;
	}

	ll l=0,r=INF;
	while(r-l>1)
    {   ll mid=l+r>>1;
		if(check(mid))   r=mid;
		else             l=mid;
	}

	cout<<(r+8)/9<<"\n";
	return 0;
}


Measured memory_bytes: 9116
#include<bits/stdc++.h>
using namespace std;
int ans=1,n,k;

int main()
{
	scanf("%d %d",&n,&k);
	for(int i=1;i<=n;i++)
	{
		ans+=min(ans,k);
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#define SIZE 200001

int max(int num1, int num2){ //function to return the greater of the arguments
    if(num1 < num2){
        return num2;
    }
    else{
        return num1;
    }
}

int main(void){
    int N, M, K, i, j, ans;
    long int A[SIZE], B[SIZE], a[SIZE], b[SIZE];
    scanf("%d %d %d",&N,&M,&K);
    for(i = 0; i < N; ++i){
        scanf("%ld",&A[i]);
    }
    for(i = 0; i < M; ++i){
        scanf("%ld",&B[i]);
    }
    for(i = 0; i < N+1; ++i){
        if(i==0){
            a[i] = 0;
        }
        else{
            a[i] = a[i-1] + A[i-1];
        }
    }
    for(i = 0; i < M+1; ++i){
        if(i==0){
            b[i] = 0;
        }
        else{
            b[i] = b[i-1] + B[i-1];
        }
    }
    j = M;
    ans = 0;
    for(i = 0; i < N+1; ++i){
        if(a[i]>K){
            break;
        }
        while(b[j]>K-a[i]){
            --j;
        }
        ans = max(ans, i+j);
    }
    printf("%d\n",ans);
    return 0;
}

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

/*int n;
  cin >> n;
  vector<int> h(n);*/

int main() {

  int a,b;
  cin >> a >> b;

  if(a < 10 && b < 10){
    cout << a*b << endl;
  }else{
    cout << -1 << endl;
  }

  return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <iomanip>
#include <iostream>
#include <queue>
#include <set>
#include <string>
#include <vector>
#define SORT(a) sort(a.begin(), a.end())
#define RSORT(a) sort(a.rbegin(), a.rend())
#define REP(i, n) for (int i = 0; i < n; i++)
#define RREP(i, n) for (int i = n; 0 <= i; i--)
#define FOR(i, start, end) for (int i = start; i < end; i++)
#define FORSTEP(i, start, end, step) for (int i = start; i < end; i += step)
#define RFOR(i, start, end) for (int i = start; end <= i; i--)
#define ALL(a) a.begin(), a.end()
#define MOD(a) a %= 1000000007
typedef long long ll;
const int INF32 = 2147483647;
const ll INF64  = 9223372036854775807;
using namespace std;

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

    int a, b, t;
    cin >> a >> b >> t;

    int ans = b * (t / a);
    cout << ans << endl;

    return 0;
}

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

int main(){
  int h,w; cin>>h>>w;
  vector<string> s(h);
  for(int i=0; i<h; ++i)cin>>s[i];

  vector<vector<int>> lighth(h, vector<int>(w,0));
  vector<vector<int>> lightw(h, vector<int>(w,0));

  for(int i=0; i<h; ++i){
    int l=0;
    for(int j=0; j<w; ++j){
      if(s[i][j]=='.'){++l; lighth[i][j]=l;}
      else {l=0; lighth[i][j]=l;}
    }
    for(int j=w-2; j>=0; --j){
      if(s[i][j+1]=='.')lighth[i][j]=lighth[i][j+1];
    }
  }

  for(int j=0; j<w; ++j){
    int l=0;
    for(int i=0; i<h; ++i){
      if(s[i][j]=='.'){++l; lightw[i][j]=l;}
      else {l=0; lightw[i][j]=l;}
    }
    for(int i=h-2; i>=0; --i){
      if(s[i+1][j]=='.')lightw[i][j]=lightw[i+1][j];
    }
  }

  int ans=0;
  for(int i=0; i<h; ++i){
    for(int j=0; j<w; ++j){
      ans=max(ans, lighth[i][j]+lightw[i][j]-1);
    }
  }

  cout<<ans<<endl;
}


Measured memory_bytes: 35712
#include<vector>
#include<cmath>
#include<map>
#include<cstdlib>
#include<iostream>
#include<sstream>
#include<fstream>
#include<string>
#include<algorithm>
#include<cstring>
#include<cstdio>
#include<set>
#include<stack>
#include<bitset>
#include<functional>
#include<ctime>
#include<queue>
#include<deque>
#include<complex>
#include<cassert>
using namespace std;
#define pb push_back
#define pf push_front
typedef long long lint;
typedef complex<double> P;
#define mp make_pair
#define fi first
#define se second
typedef pair<int,int> pint;
typedef pair<lint,pint> tint;
#define All(s) s.begin(),s.end()
#define rAll(s) s.rbegin(),s.rend()
#define REP(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)
ostream &operator<<(ostream &os, const vector<int> &a) {
	os<<"[";
	rep(i,a.size()){
		os<<a[i];
		if(i<a.size()-1) os<<",";
	}
	os<<"]";
	return os; 
}
//問題文および制約はちゃんと確認しよう！
//サイズは10^5じゃなくて2×10^5とかかもしれないし、重要な制約・条件を見落としているかも
//とりあえずサンプルを読んでから解法を考えよう？
lint dp[610][310][310][2];
lint co[610][610];
int sum[610];
bool sumi[610];
lint mo=1000000007;
int main()
{
	rep(i,605){
		co[i][0]=co[i][i]=1;
		REP(j,1,i) co[i][j]=(co[i-1][j]+co[i-1][j-1])%mo;
	}
	int n,a,b;
	vector<int> v;
	cin>>n;
	rep(i,n){
		cin>>a>>b;
		a--;b--;
		if(a>=0 && b>=0) sum[a]++,sum[b]++;
		else if(a>=0) v.pb(a);
		else if(b>=0) v.pb(b);
	}
	rep(i,605) sum[i+1]+=sum[i];
	rep(i,v.size()) v[i]-=sum[v[i]];
	int m=v.size(),x=0;
	rep(i,m) sumi[v[i]]=true;
	n-=sum[603]/2;
	if(n==0){
		cout<<1<<endl;return 0;
	}
	if(m==0){
		lint t=co[2*n][n]-co[2*n][n-1];
		rep(i,n){
			t*=i+1;t%=mo;
		}
		t+=mo;t%=mo;
		cout<<t<<endl;return 0;
	}
	memset(dp,0,sizeof(dp));dp[0][0][n-m][0]=1;
	lint out=0;
	//cout<<n<<' '<<m<<' '<<v<<endl;
	rep(i,2*n){
		if(sumi[i]){
			x++;
			if(m==x){
				rep(k,n-m+1) rep(l,2){
					lint t=dp[i][0][k][l];
					if(k>0) t*=(co[2*n-1-i][k]-co[2*n-1-i][k-1]);
					t%=mo;
					rep(j,k){
						t*=j+1;t%=mo;
					}
					t+=mo;t%=mo;
					out+=t;out%=mo;
				}
				break;
			}
			else{
				rep(j,n+1) rep(k,n-m+1) rep(l,2){
					//if(dp[i][j][k][l]>0) cout<<i<<j<<k<<l;
					dp[i+1][j][k][0]+=dp[i][j][k][l];
					dp[i+1][j][k][0]%=mo;
					if(j>0){
						dp[i+1][j-1][k][1]+=dp[i][j][k][l]*j;
						dp[i+1][j-1][k][1]%=mo;
					}
				}
			}
			continue;
		}
		rep(j,n+1) rep(k,n-m+1){
			if(dp[i][j][k][0]+dp[i][j][k][1]<1) continue;
			//cout<<i<<' '<<j<<' '<<k<<' '<<dp[i][j][k][0]<<' '<<dp[i][j][k][1]<<endl;
			//今のところで使う
			dp[i+1][j][k][1]+=dp[i][j][k][0];
			dp[i+1][j][k][1]%=mo;
			//まだ持っておく
			rep(l,2){
				dp[i+1][j+1][k][l]+=dp[i][j][k][l];
				dp[i+1][j+1][k][l]%=mo;
			}
			//どこかに飛ばす
			if(k>0){
				rep(l,2){
					dp[i+1][j][k-1][l]+=dp[i][j][k][l]*k;
					dp[i+1][j][k-1][l]%=mo;
				}
			}
			//前の隙間を埋める
			rep(l,2){
				if(x+n-m-k-(i-x-l-j-(n-m-k))>0){
					dp[i+1][j][k][l]+=dp[i][j][k][l];
					dp[i+1][j][k][l]%=mo;
				}
			}
		}
	}
	cout<<out<<endl;
}


Measured memory_bytes: 919168
// AOJ 0184: Tsuruga Castle
// 2017.8.2 bal4u@uu
// 2017.12.10

#include <stdio.h>
#include <stdlib.h>
#include <string.h>

char buf[10];
int cnt[7];
int tr['9'+1]['9'+1];

void init()
{
	int n1, n2;
	
	// age < 10
	for (n1 = '0'; n1 <= '9'; n1++) for (n2 = 0; n2 < ' '; n2++) tr[n1][n2] = 0;

	// 10 <= age
	for (n1 = 1; n1 <= 9; n1++) for (n2 = '0'; n2 <= '9'; n2++) tr[n1+'0'][n2] = n1; 

}

int main()
{
	int n, i, s;

	init();	
	while (fgets(buf, 10, stdin) && *buf != '0') {
		memset(cnt, 0, sizeof(cnt));

		n = atoi(buf);
		i = n; while (i--) {
			fgets(buf, 10, stdin);
			if (buf[2] < ' ') cnt[tr[buf[0]][buf[1]]]++;
		}

		for (s = 0, i = 0; i <= 5; i++) printf("%d\n", cnt[i]), s += cnt[i];
		printf("%d\n", n - s);
	}
	return 0;
}

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

int main(){
  int n,l;
  cin >> n >> l;
  
  vector<string> moji(n);
  for (int i=0; i<n; i++){
    cin >> moji.at(i);
  }
  
  sort(moji.begin(), moji.end());
  
  for(int i=0; i<n; i++){
    cout << moji.at(i);
  }
  cout << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
//整数 aが入力されます。値 a+a2+a3を出力してください。
//1≤a≤10,aは整数である。

int main()
{
    int a,n,m,w,o;
    scanf("%d", &a);
    n = a;
    m = a*a;
    w = a*a*a;
    o = n + m + w;
    printf("%d",o);
    return 0;
}

Measured memory_bytes: 1732
#include<iostream>
using namespace std;
long long a[110],ans;
int check(long long x,long long y,long long z)
{
    if(x==y||y==z||x==z) return 0; 
    //cout<<x<<" "<<y<<" "<<z<<endl;
    if(x+y<=z) return 0;
    if(x+z<=y) return 0;
    if(y+z<=x) return 0;
    return 1;
}
int main()
{
    int i,j,k,n;
    cin>>n;
    for(i=1;i<=n;i++) cin>>a[i];
    for(i=1;i<=n;i++)
     for(j=i+1;j<=n;j++)
      for(k=j+1;k<=n;k++)
       ans+=check(a[i],a[j],a[k]);
    cout<<ans;
    system("pause");
}


Measured memory_bytes: 3696
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
from itertools import permutations, accumulate, combinations, combinations_with_replacement
from math import sqrt, ceil, floor, factorial
from bisect import bisect_left, bisect_right
from copy import deepcopy
from operator import itemgetter
from functools import reduce
#from fractions import gcd
#from math import gcd
import sys
def I(): return int(input())
def Is(): return map(int, input().split())
def LI(): return list(map(int, input().split()))
def TI(): return tuple(map(int, input().split()))
def IR(n): return [I() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def TIR(n): return [TI() for _ in range(n)]
def S(): return input()
def Ss(): return input().split()
def LS(): return list(input())
def SR(n): return [S() for _ in range(n)]
def SsR(n): return [Ss() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
sys.setrecursionlimit(10**6)
MOD = 10**9+7
INF = float('inf')


s = S()
t = S()

ans = 0
for i in range(3):
    if s[i]==t[i]:
        ans += 1
print(ans)

Measured memory_bytes: 38384
#include<cstdio>
#include<algorithm>
#include<queue>
#include<vector>
using namespace std;
static const int MAX_V = 100000;
static const int INF = 1 << 30;

struct edge{int to, cost;};
typedef pair<int, int> P;

int V;
vector<edge> G[MAX_V];
int d[MAX_V];

void dijkstra(int s){
	priority_queue<P, vector<P>, greater<P> > que;
	fill(d, d + V, INF);
	d[s] = 0;
	que.push(P(0, s));

	while(!que.empty()){
		P p = que.top(); que.pop();
		int v = p.second;
		if(d[v] < p.first) continue;
		for(int i = 0; i < G[v].size(); i++){
			edge e = G[v][i];
			if(d[e.to] > d[v] + e.cost){
				d[e.to] = d[v] + e.cost;
				que.push(P(d[e.to], e.to));
			}
		}
	}
	for(int i = 0; i < V; i++){
		if(d[i] == INF) printf("INF\n");
		else printf("%d\n", d[i]);
	}
}

int main(){
	int E, r;
	scanf("%d %d %d", &V, &E, &r);
	for(int i = 0; i < E; i++){
		int s, t, c;
		scanf("%d %d %d", &s, &t, &c);
		G[s].push_back((edge){t, c});
	}
	dijkstra(r);
	return 0;
}

Measured memory_bytes: 12636
#pragma GCC optimize("O3")
#pragma G++ optimize("O3")
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define ull unsigned ll
#define mst(a, b) memset((a), (b), sizeof(a))
#define mp(a, b) make_pair(a, b)
#define pi acos(-1)
#define pii pair<int, int>
#define pll pair<ll, ll>
#define pdd pair<double, double>
#define vi vector<int>
#define vl vector<ll>
#define pb push_back
#define lson l, mid, rt << 1
#define rson mid + 1, r, rt << 1 | 1
const int INF = 0x3f3f3f3f;
const double eps = 1e-8;
const int maxn = 1e3 + 7;
const int maxm = 1e5 + 7;
const int mod = 1e9 + 7;
#define IO ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
int main()
{
    IO;
    int a,b;
    cin>>a>>b;
    cout<<a*b<<endl;
    return 0;
}

Measured memory_bytes: 3632
#include <stdio.h>
using namespace std;
int main(void){
    
    int W,H,x,y,r;
    scanf("%d %d %d %d %d" ,&W, &H, &x, &y, &r );
    
    if(W>=x+r && 0<=x-r && H>=y+r && 0<=y-r){
        printf("Yes\n");
    }else{
        printf("No\n");
    }
    
}



Measured memory_bytes: 2680
package main

import "fmt"

func main() {
	var N int
	fmt.Scan(&N)
	b := 0
	n := N
	for n > 0 {
		b += n % 10
		n /= 10
	}

	ans := "No"
	if N%b == 0 {
		ans = "Yes"
	}
	fmt.Println(ans)
}


Measured memory_bytes: 512
import java.util.Scanner;

public class Main {

    private static Scanner scanner = new Scanner(System.in);

    public static void main(String[] args) {
        int W, H, N;
        W = scanner.nextInt();
        H = scanner.nextInt();
        N = scanner.nextInt();

        int[] x = new int[N];
        int[] y = new int[N];
        int[] a = new int[N];
        for (int i = 0; i < N; i++) {
            x[i] = scanner.nextInt();
            y[i] = scanner.nextInt();
            a[i] = scanner.nextInt();
        }

        int[][] map = new int[W][H];
        for (int i = 0; i < W; i++) for (int j = 0; j < H; j++) map[i][j] = 0;

        for (int n = 0; n < N; n++) {
            switch (a[n]) {
                case 1:
                    for (int i = 0; i < x[n]; i++) for (int j = 0; j < H; j++) ++map[i][j];
                    break;
                case 2:
                    for (int i = x[n]; i < W; i++) for (int j = 0; j < H; j++) ++map[i][j];
                    break;
                case 3:
                    for (int i = 0; i < y[n]; i++) for (int j = 0; j < W; j++) ++map[j][i];
                    break;
                case 4:
                    for (int i = y[n]; i < H; i++) for (int j = 0; j < W; j++) ++map[j][i];
                    break;
            }
        }

        int ans = 0;
        for (int i = 0; i < W; i++) {
            for (int j = 0; j < H; j++) {
                ans += map[i][j] == 0 ? 1 : 0;
            }
        }

        System.out.println(ans);
    }

}


Measured memory_bytes: 22356
n=int(input())
s=input()

r=0
g=0
b=0
for i in range(n):
    if s[i]=="R":
        r+=1
    elif s[i]=="G":
        g+=1
    else:
        b+=1

m=0
for i in range(1,(n+1)//2):
    for j in range(n-2*i):
        A=s[j]
        B=s[j+i]
        C=s[j+2*i]
        if A!=B and B!=C and C!=A:
            m+=1

ans=r*g*b
print(ans-m)

Measured memory_bytes: 9212
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const ll mxn= 5e4+5;
// check for forloop
// intialize variable
// overflow
// go for easy solution
#define mod 1000000007
ll INF = 1000000000000000005LL;
//#define endl '\n'
void rishabh(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
}
int main(){
    rishabh();
    set<int> s;
    int n;
    cin>>n;
    for(int i=0;i<n;i++){
        int x;
        cin>>x;
        if(s.count(x)){
            s.erase(x);
        }
        else  s.insert(x);
    }
    cout<<s.size();

}

Measured memory_bytes: 8320
#include<iostream>
using namespace std;
 
int main(){
  char s[200001],t[200001];
  int ct = 0;
  cin >> s;
  cin >> t;
  for(int i = 0;s[i] != '\0';i++){
    ct += (s[i] != t[i]);
  }
  cout << ct << endl;
  return 0;
}

Measured memory_bytes: 3996
#include <iostream>
#include <vector>

int main() {
  uint32_t N = 0;
  std::cin >> N;
  std::string S;
  std::cin >> S;

  std::vector<uint32_t> W_sum(N + 1, 0);
  std::vector<uint32_t> E_sum(N + 1, 0);
  for (size_t i = 1; i < N + 1; i++) {
    W_sum[i] += W_sum[i - 1] + (S[i - 1] == 'W');
    E_sum[i] += E_sum[i - 1] + (S[i - 1] == 'E');
  }

  uint32_t min = -1;
  for (size_t i = 1; i < N + 1; i++) {
    uint32_t left_W = W_sum[i - 1];
    uint32_t right_E = E_sum.back() - E_sum[i];
    min = std::min(min, left_W + right_E);
  }

  std::cout << min << std::endl;

  return 0;
}

Measured memory_bytes: 3076
#include <bits/stdc++.h>
#define ll long long int
#define mp make_pair
#define pa pair<int,int>
#define ld long double
#define BOOST ios_base::sync_with_stdio(false)
#define pb push_back
#define st first
#define nd second
using namespace std;
int dp[3003][3003];
int main()
{
  BOOST;
  string a,b;
  cin>>a>>b;
  int n=a.length();
  int m=b.length();

  for (int i=1;i<=n;i++)
  {
      for (int j=1;j<=m;j++)
      {
          if (a[i-1]==b[j-1])
          {
              dp[i][j]=max(dp[i][j],dp[i-1][j-1])+1;
          }
          else dp[i][j]=max(dp[i-1][j],dp[i][j-1]);
      }
  }
  int aktuali=n;
  int aktualj=m;
  string wynik="";
  while (wynik.size()!=dp[n][m])
  {
    if (a[aktuali-1]==b[aktualj-1])
    {
      wynik+=a[aktuali-1];
      aktuali=aktuali-1;
      aktualj=aktualj-1;
    }
    else if (dp[aktuali-1][aktualj]>dp[aktuali][aktualj-1])
    {
      aktuali=aktuali-1;
    }
    else
    {
      aktualj=aktualj-1;
    }
  }
  reverse(wynik.begin(),wynik.end());
  //cout<<dp[n][m];
  cout<<wynik;
    return 0;
}



Measured memory_bytes: 35456
N = int(input())
H = list(map(int,input().split()))

state = 0
for i in range(1,len(H))[::-1]:
    if H[i]<H[i-1]:
        H[i-1] = H[i-1] -1

for i in range(1,len(H)):
    if H[i] - H[i-1]<0:
        state = 1
        break
if state == 1:
    print("No")
else:
    print("Yes")


Measured memory_bytes: 14396
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 100000 + 10;
const int M = 1000000007;
const double PI = atan(1) * 4;
const int oo = 1000000000;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> ii;
#define pb push_back 
#define all(c) (c).begin(),(c).end()
int n,k,g,v[N],mx;
int gcd(int a, int b){
	if(!b)return a;
	return gcd(b,a%b);
}
void no(){
	cout<<"IMPOSSIBLE\n";
	exit(0);
}
void yes(){
	cout<<"POSSIBLE\n";
	exit(0);
}
int main(){
	cin>>n>>k;
	for(int i=0; i<n; ++i){
		scanf("%d",&v[i]);
		if(!i)g=v[i];
		else g=gcd(g,v[i]);
		mx=max(mx,v[i]);
	}
	if(k>mx)no();
	if(g==1)yes();
	if(k%g==0)yes();
	no();
}




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

int main(){
	int n;
	while(cin >> n, n){
		int ans = 0;
		while(n != 1){
			if(n % 2 == 0) n /= 2;
			else n = n * 3 + 1;
			ans++;
		}
		cout << ans << endl;
	}
}

Measured memory_bytes: 1160
import java.util.Scanner;

public class Main {

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

        String s = sc.next();
        int length = s.length();
        int half = length / 2;
        int lastIndex = length - 1;
        int hag = 0;
        for (int i = 0; i < half; i++) {
            if (s.charAt(i) != s.charAt(lastIndex - i)) {
                hag++;
            }
        }
        System.out.println(hag);
    }

}


Measured memory_bytes: 21844
N = int(input())
g = [1] + [0] * (N-1)
map = [(i, int(input())-1) for i in range(N)]

ans = 0
current = 0
while g[1] != 1:
    dst = map[current][1]
    if g[dst] == 1:
        ans = -1
        break
    ans += 1
    current = dst
    g[dst] = 1
print(ans)

Measured memory_bytes: 17252
# 初期入力
from collections import defaultdict
import sys
#input = sys.stdin.readline  #文字列では使わない
S =list(input())
T =list(input())

#
S_conversion =defaultdict(str)
T_conversion =defaultdict(str)
ans ="Yes"
if S ==T:
    ans ="Yes"
else:
    for i in range(len(S)):
        if S_conversion[S[i]] =="" and T_conversion[T[i]] =="":
            S_conversion[S[i]] =T[i] 
            T_conversion[T[i]] =S[i]
        elif S_conversion[S[i]] ==T[i]:
            continue
        elif T_conversion[T[i]] ==S[i]:
            continue
        else:
            ans ="No"
            #print(i)
            break
print(ans)

Measured memory_bytes: 12588
#include<bits/stdc++.h>
#define PI acos(-1)
using namespace std;
char s[200], a[200], b[200];
int main()
{
    int n; cin >> n >> s;
    if(n % 2  != 0)
    {
        cout << "No\n";

    }
    else {
            //n /= 2;
       for(int i = 0; i < n/2 ; i++)
       {
           a[i] = s[i];

       }
       strcpy(b,a);
       strcat(a,b);
       if(strcmp(a,s) == 0)
       {
           cout << "Yes\n";
       }
       else {
        cout << "No\n";
       }

    }
}


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

using namespace std;

typedef long long ll;

int main() {
  int r[2000000],n;
  int maxans = -999999999;

  scanf("%d",&n);

  for(int i = 0; i < n; i++){
    scanf("%d",&r[i]);
  }

  int minans = r[0];

  for(int i = 1; i < n; i++){
    maxans = max(maxans, r[i]-minans);
    minans = min(minans, r[i]);
  }

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

	return 0;
}

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

int main() {
  int R, G, B, N;
  cin >> R >> G >> B >> N;

  int ans = 0;

  for(int r=0;R*r<=N;r++) {
    for(int g=0;R*r+G*g<=N;g++) {
      if((N - R * r - G * g) % B == 0) ans++;
    }
  }

  cout << ans << endl;
}

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

int a[100002];
int main(){
	int n, s, ans = 1e9;
	scanf("%d%d", &n, &s);
	for(int i = 1;i <= n;i++)scanf("%d", &a[i]);
	for(int i = 2;i <= n;i++)a[i] += a[i-1];
	int l = 0, r = 1;
	
	while(r <= n){
		if(a[r]-a[l] >= s)ans = min(ans, r-l);
		if(a[r]-a[l] < s)r++;
		else l++;
	}
	
	if(ans == 1e9)printf("0\n");
	else printf("%d\n", ans);
	return 0;
}


Measured memory_bytes: 3620
#include <iostream>
#include <vector>
#include <set>
#include <algorithm>
#include <ctime>
using namespace std;


int main() {



    int n, k;
    cin >> n;
    cin >> k;

    time_t start_t = time(0);
    struct tm * start = localtime(&start_t);

    vector<int> a(n);
    for(int i=0; i<n; i++) cin >> a[i];
    sort(a.begin(), a.end());
    vector<vector<int> > prefix(n+1, vector<int>(k+1));

    prefix[0][0] = 1;
    for(int i=0; i<n; i++) {
        for(int j=0; j<=k; j++) {
            int v = prefix[i][j];
            if(v == 1) {
                prefix[i+1][j] = 1;
                if(j+a[i] <=k){
                    prefix[i+1][j + a[i]] = 1;
                }
            }
        }
    }
    time_t end_t = time(0);
    struct tm * end = localtime(&end_t);
    
   // cout << double(end_t - start_t) << endl;
    
    vector<vector<int> > suffix(n+1, vector<int>(k+1));
    suffix[n][0] = 1;
    for(int i=n-1; 0<=i; i--) {
        for(int j=0; j<=k; j++) {
            int v = suffix[i+1][j];
            if(v == 1) {
                suffix[i][j] = 1;
                if(j+a[i]<=k) {
                    suffix[i][j+a[i]] = 1;
                }
            }
        }
    }

    // cumulative sums
    int c_suffix_i_plus_1[5001];

    int res = 0;
    for(int i=0; i<n; i++) {
        if(k<=a[i])
            continue;
        c_suffix_i_plus_1[0] = 0;
        for(int j=0; j<k; j++) {
            bool is_in = suffix[i+1][j] > 0;
            c_suffix_i_plus_1[j+1] = c_suffix_i_plus_1[j] + is_in;
        }
        bool ok = true;
        for(int j=0; j<k; j++) {
            int s = prefix[i][j];
            if(s == 1) {
                int start = k-a[i]-j;
                if(start<0) start = 0;
                int stop = k-j;
                if (c_suffix_i_plus_1[stop] - c_suffix_i_plus_1[start] > 0){
                    ok = false;
                    break;
                }
            }
        }
        if(ok) {
            res++;

        }
    }
    cout << res << endl;

}

Measured memory_bytes: 196092
array = Array.new(4).map{Array.new(3).map{Array.new(10,0)}}
n = gets.to_i
n.times do
   b,f,r,v = gets.split(" ").map(&:to_i)
   array[b-1][f-1][r-1] += v

end
i = 0
while i < 3
j = 0
    while j < 3
        puts " " + array[i][j].join(" ")
        j += 1
    end
   puts "#"*20
   i+=1
end

for k in 0..2 
    puts " " + array[3][k].join(" ")
end

Measured memory_bytes: 8792
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < n; ++i)
using namespace std;
using ll = long long;
const ll mod = 1000000007;//998244353;
int main() {
    cin.tie(nullptr); ios::sync_with_stdio(false);
    int n;cin >> n;
    vector<ll> a(n+1), b, c(n+2,0);
    rep(i,n+1)cin >> a[i];
    rep(i,n+1)c[n-i] += c[n-i+1] + a[n-i];
    b.push_back(1-a[0]);
    rep(i,n)
        b.push_back(min(2*b[i]-a[i+1], c[i+2]));
    ll ans = 0;
    rep(i,n+1){
        if (b[i]<0){
            cout << -1 << endl;
            return 0;
        }
        ans += a[i]+b[i];
    }
    cout << ans << endl;
}

Measured memory_bytes: 5848
#include <stdio.h>
typedef long long Int;

bool is_rect(Int x, Int y, Int t) {
    return t*t == x*x+y*y;
}

bool is_loze(Int x, Int y, Int t) {
    return x == y;
}

int main() {
    int a = 0, b = 0;
    int x, y, t;
    while (scanf("%d,%d,%d", &x, &y, &t) != EOF) {
        if (is_rect(x, y, t)) a++;
        if (is_loze(x, y, t)) b++;
    }
    printf("%d\n", a);
    printf("%d\n", b);
    return 0;
}

Measured memory_bytes: 0
// AtCoder My Practice
// author: Leonardoen @ NEETSDKASU

// 解説読後

fn main() {
	let mut stdin = String::new();
    std::io::Read::read_to_string(
    	&mut std::io::stdin(),
        &mut stdin).unwrap();
	let mut stdin = stdin.split_whitespace();
    let mut get = || stdin.next().unwrap();
    macro_rules! get {
    	($t:ty) => (get().parse::<$t>().unwrap());
        () => (get!(i64));
    }
    
    let n = get!(usize);
    let s = get().as_bytes();
    
    let mut mp = std::collections::HashMap::new();
    
    let c = 1 << n;
    
    for x in 0..c {
    	let mut s1 = String::new();
        let mut s2 = String::new();
    	for i in 0..n {
        	if x & (1 << i) == 0 {
            	s1.push(s[i] as char);
            } else {
            	s2.push(s[i] as char);
            }
        }
        s1.push('_');
        s1.push_str(&s2);
        *mp.entry(s1).or_insert(0) += 1;
    }
	
    let mut ans = 0i64;
    
    for x in 0..c {
    	let mut s1 = String::new();
        let mut s2 = String::new();
    	for i in 0..n {
        	if x & (1 << i) == 0 {
            	let i = s.len() - 1 - i;
            	s1.push(s[i] as char);
            } else {
            	let i = s.len() - 1 - i;
            	s2.push(s[i] as char);
            }
        }
        s1.push('_');
        s1.push_str(&s2);
        ans += *mp.get(&s1).unwrap_or(&0);
    }

	println!("{}", ans);
}


Measured memory_bytes: 41144
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
    
         //変数x, yを宣言する
         int x, y;
    
        //変数x, yの値を入力する
        x = sc.nextInt();
        y = sc.nextInt();
        
        while(x != 0 || y != 0){
            //大小を関係の比較
            if(x < y) System.out.println(x + " " + y);
            else System.out.println(y + " " + x);
            
            //変数x = 0, y = 0になるまで値を入力を繰り返す
            x = sc.nextInt();
            y = sc.nextInt();
        }
        
    }
}



/*覚えよう！！
 
〇もう1つの繰り返し

・while(条件式)：条件を満たす間はずっと繰り返す

　※今回は x = 0  &&  y = 0　が入力されない間は繰り返す(両方0が入力されてない意味)
　
*/
  
  
/*前回の内容！！

〇import java.util.Arrays;は重要↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓

・Arrays：ソート（並べ変え）や検索など、配列を操作するための機能

・並べ変えするとき
　import java.util.Arrays;を上に書く
　class Main内に Arrays.sort(a); と書く　←　このとき()内は配列の変数名
　
〇配列とは、同じ変数名に複数の値を入力できる箱

　※イメージ
    前回まで、a = 1, b = 2, c = 3など各変数名は1箱に値を代入できない
    今回の配列はa[0] = 1, a[1] = 2, a[2] = 3 のように変数名aは3つの箱に値を代入できる。
    注意：配列の箱は｢ 0 ｣から開始する


・複数のif(条件)：かつ｢ && ｣とまたは｢ || ｣の２つを使用する
　※かつ｢ && ｣：「真 && 真 = 真」, 「真 && 偽 = 偽」, 「偽 && 真 = 偽」 ,「偽 && 偽 = 偽」の4つの条件
　　または｢ || ｣：「真 && 真 = 真」, 「真 && 偽 = 真」, 「偽 && 真 = 真」 ,「偽 && 偽 = 偽」の4つの条件


・関係を比較する：if(条件式)
　例：if(2 < 3) この条件は｢真（成立）｣　→　何か命令があれば実行する
　　　if(5 < 3) この条件は｢偽（不成立）｣　→　何か命令があれば実行しない
　　　
・比較の条件式：等しいか比較｢==｣、等しくないか比較｢!=｣ 
　　　　　　　　大きいか比較｢<｣、小さいか比較｢>｣
　　　　　　　　以上の比較｢<=｣、以下の比較｢>=｣
 
 
・else；ifの条件以外の場合に使用する。
　例：if(雨 == 降っている) System.out.println("傘を持って行く");
　　　else System.out.println("傘を持って行かない");
　
 
・else if：詳細な場合分けしたいときに使用
　例：if(雨 == 降っている) System.out.println("傘を持って行く");
　　　else if(雨 == 午後から降るかも) System.out.println("念のため傘を持って行く");
　　　else System.out.println("傘を持って行かない");
 

 
・変数に計算結果を代入する：面積　＝　縦　×　横
　※計算は変数名でも数値でもいける
  
・四則演算：足し算｢＋｣、引き算｢－｣、掛け算｢＊｣、割り算｢／｣
　1 + 2 = 3;
　4 - 3 = 1;
　2 * 5 = 10;
　8 / 2 = 4;
  
・余りの計算：割り算の余り｢％｣
  5 % 3 = 2;
    
    
・printlnの複数表示：｢＋｣を使用
　例：println("Kobe" + "Kagikou"); = KobeKajikou
　　　println("明治 + 20 + "年"); = 明治20年　数値が入ってもOK！
  
  
  
・変数の宣言は｢型｣と｢変数名｣の２つ必要
　例：型＿変数名　→　int x;
　
・キーボードから入力するときは・・・｢ import java.util.Scanner; ｣ と ｢  Scanner sc = new Scanner(System.in) ; ｣が必要
  
・入力するとき・・・変数名 = sc.nextInt(); nextの後は型を書く、頭文字は大文字　
　※  scは変更しても大丈夫しかし全て変更後の文字に統一　例：nyuryoku
  
・println・・・画面に出力するときに使用
  
・文字列の表示・・・"〇〇〇の間に入力"ことが約束
  
*/



Measured memory_bytes: 35752
#include <iostream>
#include <string>

int main() {
	int h, w;
	std::string s;
	std::cin >> h >> w;
	for (int i = 0; i < h; i++) {
		for (int j = 0; j < w; j++) {
			std::cin >> s;
			if (s == "snuke") {
				std::cout << char(j + 'A') << (i + 1) << std::endl;
			}
		}
	}
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
    string s;
    cin >> s;
    int c = 0;
    if(s[0] == '+') c++;
    if(s[1] == '+') c++;
    if(s[2] == '+') c++;
    if(s[3] == '+') c++;
    cout << c + (4 - c) * -1 << endl;
    return 0;
}

Measured memory_bytes: 256
from collections import defaultdict
def main():
    n = int(input())
    a = list(map(int, input().split()))
    d = defaultdict(lambda: 0)
    ans = 0
    for i, ai in enumerate(a, 1):
        d[i+ai] += 1
        if d[i-ai]:
            ans += d[i-ai]
    print(ans)

if __name__ == "__main__":
    main()

Measured memory_bytes: 150516
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pb push_back
#define all(v) v.begin(),v.end()
#define PI acos(-1)
#define EPS 1e-15


 
int main(){
	int n;
	cin >> n;
	vector<int> p(n + 1);
	for(int i = 1; i <= n;i++){
		cin >> p[i];
	}
	int cnt = 0;
	for(int i = 1; i <= n; i++){
		if(p[i] == i){
			cnt++;
			if(i+1 <= n && p[i+1] == i + 1){
				i++;
			}
		}
	}
	cout << cnt << endl;
	return 0;
}



Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  string a;
  cin >> a;
  int count = 0;
  vector<int> x(n+1);
  for (int i = 0; i < n; i++) {
    if (i == 0) {
      x[0] = 0;
    }
    if (a[i] == 'I') {
      count++;
      x[i+1] = count;
    }
    else {
      count--;
      x[i+1] = count;
    }
  }
  sort(x.begin(), x.end());
  cout << x[n] << endl;
}
       

Measured memory_bytes: 3588