akhauriyash/Code-Regression huggingface dataset:
import java.util.*;
import java.io.*;
public class Main{
static BufferedReader s1;
static BufferedWriter out;
static String read() throws IOException{String line="";while(line.length()==0){line=s1.readLine();continue;}return line;}
static int int_v (String s1){return Integer.parseInt(s1);}
static long long_v(String s1){return Long.parseLong(s1);}
static int[] int_arr() throws IOException{String[] a=read().split("\\s+");int[] b=new int[a.length];for(int i=0;i<a.length;i++){b[i]=int_v(a[i]);}return b;}
static long[] long_arr() throws IOException{String[] a=read().split("\\s+");long[] b=new long[a.length];for(int i=0;i<a.length;i++){b[i]=long_v(a[i]);}return b;}
static void assign(){s1=new BufferedReader(new InputStreamReader(System.in));out=new BufferedWriter(new OutputStreamWriter(System.out));}
//......................................@uthor_Alx..............................................

public static void main(String[] args) throws  IOException{
                assign();
                	int[] x=int_arr();
                	int n=x[0],k=x[1];
                	List<List<Integer>> cycles=new ArrayList<>();
                	int[] p=int_arr();
                	int[] c=int_arr();
                	for(int i=0;i<n;i++){p[i]--;}
                	boolean[] b=new boolean[n];
                    for(int i=0;i<n;i++){
                    	if(b[i]) continue;
                    	List<Integer> tmp=new ArrayList<>();
                    	tmp.add(i);b[i]=true;
                    	int z=p[i];
                    	while(!b[z]){
                    		b[z]=true;
                    		tmp.add(z);
                    		z=p[z];
                    	}
                    	cycles.add(tmp);
                    }
                    long res=Long.MIN_VALUE;
                    for(int i=0;i<cycles.size();i++){
                    	long tmp=Long.MIN_VALUE; int sz=cycles.get(i).size();
                    	long sum=0;
                    	for(int j=0;j<sz;j++){sum+=c[cycles.get(i).get(j)];}
                    	for(int j=0;j<sz;j++){
                    		long tmp1=0;
                    		int f=k/sz,kr=k%sz;
                    		if(f>0&&sum>0) tmp1=(long)f*sum;
                    	    if(f>0&&sum<0){
                    	    	kr=Math.min(k,sz);
                    	    }
                    	    if(k%sz==0&&f>0&&tmp1>0){tmp1-=sum;kr=sz;}
                    		long ss1=0,ss2=Long.MIN_VALUE;
                    		for(int j1=1;j1<=kr;j1++){
                    			ss1+=c[cycles.get(i).get((j+j1)%sz)];
                    			ss2=Math.max(ss2,ss1);
                    		}
                    		 tmp1+=ss2;
                    		 tmp=Math.max(tmp1,tmp);
                    	}
                    	res=Math.max(res,tmp);
                    }
                    out.write(res+"\n");            
                out.flush();
    }
}

Measured memory_bytes: 39216
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;
using PLL = pair<ll, ll>;
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define repn(i,n) for(int i = 0; i <= (int)(n); i++)
#define srep(i,l,n) for(int i = l; i < (int)(n); i++)
#define srepn(i,l,n) for(int i = l; i <= (int)(n); i++)
#define drep(i,n) for(int i = (int)(n-1); i >= 0; i--)
#define drepn(i,n) for(int i = (int)(n); i >= 0; i--)
#define size(s) (int)s.size()
#define debug(var)  do{std::cout << #var << " : ";view(var);}while(0)
template<typename T> void view(T e){std::cout << e << std::endl;}
template<typename T> void view(const std::vector<T>& v){for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void view(const std::vector<std::vector<T> >& vv){ for(const auto& v : vv){ view(v); } }
template<typename T> inline istream& operator>>(istream &i, vector<T> &v) {rep(j, size(v)) i >> v[j]; return i;}
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
template<class T> T gcd(T a, T b) {if(b==0)return a; else return gcd(b,a%b);}
template<class T> T lcm(T a, T b) {return a/gcd(a,b)*b;}
template<class T = int> using V = vector<T>;
template<class T = int> using VV = vector<V<T>>;
bool isIn(int i, int j, int h, int w) {return i >= 0 && i < h && j >= 0 && j < w;}
void Yes(){cout << "Yes" << endl;}
void No(){cout << "No" << endl;}
void YES(){cout << "YES" << endl;}
void NO(){cout << "NO" << endl;}
void err() {cout << -1 << endl;}
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define pb push_back
#define ep emplace_back

const int MOD = 1000000007;
const int INF = 1e9;

#define PI acos(-1);
int dx[4] = {1,-1,0,0};
int dy[4] = {0,0,1,-1};
int ddx[8] = {1,1,1,-1,-1,-1,0,0};
int ddy[8] = {0,1,-1,0,1,-1,1,-1};


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

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

int main(){
	long int N;
	cin >> N;
	vector<long int> vec (N);
	for(long int i = 0;i < N;i++){
		cin >> vec.at(i);
	}
	sort(vec.begin(),vec.end());
	reverse(vec.begin(),vec.end());
	long int a = 0;
	long int b = 0;
	for(long int i = 0;i < N - 1;i++){
		if(vec.at(i) == vec.at(i+1)){
			a = vec.at(i);
			break;
		}
	}
	for(int i = 0;i < N - 1;i++){
		if(vec.at(i) == vec.at(i+1) && vec.at(i) != a){
			b = vec.at(i);
			break;
		}
		if(i < N - 3 && vec.at(i) == vec.at(i+1) && vec.at(i+1) == vec.at(i+2) && vec.at(i+2) == vec.at(i+3)){
			b = a;
			break;
		}
	}
	cout << a * b << endl;
}

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

int main(){
	int a, b; cin >> a >> b;
	
	if(a == b) cout << "Draw" << endl;
	else if(a == 1) cout << "Alice" << endl;
	else if(b == 1)  cout << "Bob" << endl;
	else if(a < b) cout << "Bob" << endl;
	else cout << "Alice" << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define For(i, a, b) for(int (i)=(a); (i)<(b); ++(i))
#define rFor(i, a, b) for(int (i)=(a)-1; (i)>=(b); --(i))
#define rep(i, n) For((i), 0, (n))
#define rrep(i, n) rFor((i), (n), 0)
#define fi first
#define se second
using namespace std;
typedef long long lint;
typedef unsigned long long ulint;
typedef pair<int, int> pii;
typedef pair<int, lint> pil;
typedef pair<lint, int> pli;
template<class T>bool chmax(T &a, const T &b){if(a<b){a=b; return true;} return false;}
template<class T>bool chmin(T &a, const T &b){if(a>b){a=b; return true;} return false;}

constexpr lint mod = 1e9+7;
constexpr lint INF = mod*mod;
constexpr int MAX = 15000010;

int main(){
        int n, m, a[110], b[110];
        while(scanf("%d%d", &n, &m) && n){
                int asum=0, bsum=0;
                rep(i, n){
                        scanf("%d", &a[i]);
                        asum+=a[i];
                }
                rep(i, m){
                        scanf("%d", &b[i]);
                        bsum+=b[i];
                }
                bool flag=false;
                rep(i, n){
                        rep(j, m)if(2*a[i]-2*b[j]==asum-bsum){
                                printf("%d %d\n", a[i], b[j]);
                                flag=true;
                                break;
                        }
                        if(flag) break;
                }
                if(!flag) printf("-1\n");
        }
}


Measured memory_bytes: 3100
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a,n) for(int i=(a); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define FOR(it,c) for(__typeof((c).begin()) it=(c).begin(); it!=(c).end(); ++it)
#define ALLOF(c) (c).begin(), (c).end()
typedef long long ll;
typedef unsigned long long ull;


int main(){
  int N;
  cin >> N;
  
  cout << N * N * N << endl;
  
  return 0;
}


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

#define ll  long long
#define pb  push_back
#define fi  first
#define se  second
#define mp  make_pair

#define FOR(i,n,m)  for(int i=0;i<n;i+=m)
#define For(i,n,m)  for(int i=1;i<=n;i+=m)
#define clr(x,val)  memset(x,val,sizeof(x))
#define __          int t; scanf("%d",&t); while(t--)
const double pi=acos(-1.0);

int main(){
  //ios_base::sync_with_stdio(false); cin.tie(NULL);
  string s;
  cin>>s;
  map<char,ll> m;
  for(int i=0;i<s.length();i++){
  	m[s[i]]++;
  }
  vector<ll> v;
  for(auto it=m.begin();it!=m.end();it++){
  	  v.push_back(it->second);
  }
  for(int i=v.size()-2;i>=0;i--){
  	v[i]+=v[i+1];
  }
  ll ans=1;
  for(int i=0;i<v.size()-1;i++){
  	ans=ans+(v[i+1]*(v[i]-v[i+1]));
  }
  cout<<ans<<endl;
  
return 0;
}



Measured memory_bytes: 640
N,D=map(int,input().split(' '))
#X=[]
#Y=[]
D2=D**2
ans=0

for i in range(N):
  x,y=map(int,input().split(' '))
  if x**2+y**2<=D2:
    ans+=1
  #X.append(x)
  #Y.append(y)



print(ans)

Measured memory_bytes: 9160
n=int(input())

sub=[1,6,9,36,81,216,729,1296,6561,7776,46656,59049]
cost=[0]*(n+1)
for i in range(n+1):
    cost[i]=i
for i in range(n+1):
    for j in range(len(sub)):
        if sub[j]<=i:
            cost[i]=min(cost[i], cost[i-sub[j]]+1)
print(cost[n])



Measured memory_bytes: 74408
def main():
    n = int(input())
    s = input()

    l, r = 0, 0

    for i in s:
        if i == ")":
            if l:
                l -= 1
            else:
                r += 1
        else:
            l += 1

    print(r * "(" + s + ")" * l)


if __name__ == '__main__':
    main()


Measured memory_bytes: 2940
import java.util.Scanner;

public class Main {
  int[] dx = {0,1,0,-1,0};
  int[] dy = {0,0,1,0,-1};
  int h,w,ay,ax,by,bx;
  String ghostpat;
  int patiter;
  int[][] mp;
  int qiter;
  int[][][] queue;
  int[] qsize;
  int nowdist,ans;
  public static void main(String[] args){
    new Main();
  }
  void step(){
    // ghost step
    {
      int id = 0;
      char c = ghostpat.charAt(patiter);
      if(c=='5')id = 0;
      else if(c=='6')id = 1;
      else if(c=='2')id = 2;
      else if(c=='4')id = 3;
      else if(c=='8')id = 4;
      int nby = by+dy[id];
      int nbx = bx+dx[id];
      if(0<=nby && nby<h && 0<=nbx && nbx<w){
        by = nby;
        bx = nbx;
      }
      patiter ++;
      if(patiter >= ghostpat.length()){
        patiter = 0;
      }
    }
    // player step
    {
      int now = qiter;
      int nxt = now^1;
      qsize[nxt] = 0;
      for(int i=0;i<qsize[now];i++){
        int y = queue[now][i][0];
        int x = queue[now][i][1];
        // System.out.println(y+" "+x);
        for(int j=1;j<5;j++){
          int ny = y+dy[j];
          int nx = x+dx[j];
          if(ny<0 || nx<0 || ny>=h || nx>=w)continue;
          if(mp[ny][nx]!=0)continue;
          mp[ny][nx] = 1;
          int s = qsize[nxt];
          queue[nxt][s][0] = ny;
          queue[nxt][s][1] = nx;
          qsize[nxt]++;
        }
      }
      qiter ^= 1;
    }
    // check
    if(mp[by][bx]==1){
      ans = nowdist;
    }
  }
  public Main(){
    Scanner sc = new Scanner(System.in);
    while(true){
      h = sc.nextInt();
      w = sc.nextInt();
      if(h==0 && w==0)break;
      mp = new int[h][w];
      ay=0;ax=0;by=0;bx=0;
      for(int i=0;i<h;i++){
        String s = sc.next();
        for(int j=0;j<w;j++){
          char c = s.charAt(j);
          if(c=='#'){
            mp[i][j] = -1;
          }else{
            mp[i][j] = 0;
            if(c=='A'){
              ay = i;
              ax = j;
            }else if(c=='B'){
              by = i;
              bx = j;
            }
          }
        }
      }
      ghostpat = sc.next();
      patiter = 0;
      queue = new int[2][1000][2];
      qsize = new int[2];
      qiter = 0;
      queue[0][0][0]=ay;
      queue[0][0][1]=ax;
      qsize[0] = 1;
      mp[ay][ax] = 1;
      nowdist = 0;
      ans = -1;
      for(int i=0;i<10000;i++){
        nowdist++;
        step();
        if(ans!=-1)break;
      }
      if(ans!=-1){
        System.out.println(ans+" "+by+" "+bx);
      }else{
        System.out.println("impossible");
      }
    }
  }
}

Measured memory_bytes: 33412
#ifndef LOCAL
#pragma GCC optimize("O3")
#endif
#include "bits/stdc++.h"
using namespace std;
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
typedef long long ll;

int main(){
	int n , m , c ; 
	cin >> n >> m >> c ; 
	vector<int> b(m) ; 
	for(int &x : b){
		cin >> x ; 
	}
	int cnt = 0 ; 
	for(int i=0;i<n;i++){
		int ans = 0 ; 
		for(int j=0;j<m;j++){
			int x ; 
			cin >> x ; 
			ans += x*b[j] ; 
		}
		ans += c ; 
		if ( ans > 0 ) cnt++ ; 
	}
	cout << cnt << endl;
    return 0 ;
}


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

using namespace std;

#ifdef DEBUG_MODE
	#define DBG(n) n;
#else
	#define DBG(n) ;
#endif

#define REP(i,n) for(ll (i) = (0); (i) < (n); ++i)
#define PB push_back
#define MP make_pair
#define FI first
#define SE second
#define ALL(v) v.begin(),v.end()
#define INF 1100000000
#define LLINF 1000000000000000000LL
#define MOD 1000000007

typedef long long ll;
typedef pair<ll, ll> P;


int main()
{
  int N;
  cin >> N;
  if (100 <= N && N <= 111) cout << 111;
  if (112 <= N && N <= 222) cout << 222;
  if (223 <= N && N <= 333) cout << 333;
  if (334 <= N && N <= 444) cout << 444;
  if (445 <= N && N <= 555) cout << 555;
  if (556 <= N && N <= 666) cout << 666;
  if (667 <= N && N <= 777) cout << 777;
  if (778 <= N && N <= 888) cout << 888;
  if (889 <= N && N <= 999) cout << 999;
  cout << endl;

	return 0;
}



Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#define PI 3.14159265358979323

//void quick(int *,long long,long long);
//int comp(char *a,char *b);

int main(){
	
	char a[21],b[21];
	int i,j;
	
	scanf("%s",a);
	i=0;
	while(a[i]!='\0')
		i++;
	i--;
	for(j=0;i>=0;j++,i--)
		b[j]=a[i];
	b[j]='\0';
	printf("%s\n",b);
	//for(i=0;i<=1000000000;i++);
	return 0;
}

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

using namespace std;

int main(){
	long long n;
	cin >>n;
	string name="";
	while(n>0){
		long long r=n%26;
		char t;
		if(r==0){
			t='z';
			r=26;
		}else{
			t=(char)(r+96);
		}
		name = t+name;
		n=(n-r)/26;
	}
	cout <<name<<endl;
	return 0;
}

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

#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define pb push_back
#define in insert
#define er erase
#define fi first
#define se second
#define mp make_pair
#define all(x) x.begin(),x.end()
#define le(x) (int) x.length()
#define rsz resize

using namespace std;
typedef vector <int> vi;
typedef vector <vector <int> > vii;
typedef pair <int, int> pii;
typedef queue <int> qi;
typedef double db;
typedef long long ll;
typedef long double ld;
 
const long double PI=3.141592653589793238462643383279502884;
const long long PRIME1=1e9+787;
 
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}
ll minll(ll a,ll b) {return a<=b?a:b;}
ll maxll(ll a,ll b) {return a>=b?a:b;}

int main () {
    fast;
    int t;
    cin>>t;
    if (t>=30) {
        cout<<"Yes";
        
    } else {
        cout<<"No";
    }
    return 0;
}
 
 


Measured memory_bytes: 3616
#include "bits/stdc++.h"

using namespace std;

void Main() {
    int N;
    cin >> N;
    vector<int> h(N, 0);
    for (int i = 0; i < N; ++i) {
        cin >> h[i];
    }

    int maxHeight = 100;
    vector<int> f(N, 0);
    int ans = 0;
    for (int i = 0; i < maxHeight; ++i) {
        for (int j = 0; j < N; ++j) {
            if (j == 0 && h[j] > 0) {
                ++ans;
            }
            else if (h[j - 1] == 0 && h[j] > 0) {
                ++ans;
            }
        }
        for (int j = 0; j < N; ++j) {
            if (h[j] > 0) {
                h[j] -= 1;
            }
        }
    }
    cout << ans << endl;
}

int main() {
    std::cout << std::fixed << std::setprecision(15);
    Main();
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
int linearSearch(int n, int key, int A[]){
  int i;
  for(i = 0; i < n-1; i++){
    if(A[i] == key)return 1;
  }
  return 0;
}

int main(){
  int i, n, q, key, sum = 0;
  int S[10000];

  scanf("%d",&n);
  for(i = 0; i < n; i++) scanf("%d",&S[i]);
  
  scanf("%d",&q);
  for(i = 0; i < q; i++){
    scanf("%d",&key);
    sum += linearSearch(n, key, S);
  }
 
  printf("%d\n",sum);

  return 0;
}



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

int main(){

  int N,l,r,ans;
  cin >> N;
  
  for(int i = 0; i < N; ++i){
  
    cin >> l >> r;
    ans += (r-l+1);
  
  }
  
  cout << ans << endl;
  
  return 0;
  
}

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

#define ll long long
#define vi vector<int>
#define vl vector<ll>
#define pii pair<int,int>
#define pll pair<ll,ll>
// pll pp; -> (pp.first,pp.second)
// vector<vl> pp(n,vl(2)); sort(pp.begin(),pp.end(),[](vl a,vl b){return a[0]<b[0];});

#define REP(i,n) for(ll (i)=0;(i)<(n);(i)++)
#define RREP(i,n) for(ll (i)=(n)-1;(i)>=0;(i)--)
#define FOR(i,a,b) for(ll (i)=(a);(i)<(b);(i)++)
#define FORR(i,a,b) for(ll (i)=(b)-1;(i)>=(a);(i)--)
#define DEBUG(x) cout << #x << ": " << x << endl
#define CHMAX(a,b) a=max((a),(b))
#define CHMIN(a,b) a=min((a),(b))
/*}}}*/
int main() {
  ll x,y;
  cin >> x >> y;
  ll ans = 0;
  if(x==1){
    ans += 300000;
  }else if(x==2){
    ans += 200000;
  }else if(x==3){
    ans += 100000;
  }
  if(y==1){
    ans += 300000;
  }else if(y==2){
    ans += 200000;
  }else if(y==3){
    ans += 100000;
  }
  if(x==1 && y== 1){
    ans += 400000;
  }
  
  //cout << fixed << setprecision(10);
  cout << ans << endl;
  return 0;
}


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

int main() {
  string s;
  cin >> s;
  string ans = "Yes";
  int len = s.length();
  if (len % 2 == 0) {
    for(int i=0; i<len; i += 2) {
      if (s[i] != 'h' || s[i+1] != 'i') {
        ans = "No";
        break;
      }
    }
  } else {
    ans = "No";
  }
  cout << ans << endl;
    
  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {

        Scanner in = new Scanner(System.in);
        int n = Integer.parseInt( in.nextLine() );
        String s = in.nextLine();

        if( n % 2 == 1 ){
            System.out.println( "No" );
            return;
        }

        String front = s.substring( 0 , n / 2 );
        String back = s.substring( n / 2 );

        System.out.println( front.equals(back) ? "Yes" : "No" );

    }

}


Measured memory_bytes: 21716
#include <iostream>
#include <iomanip>
using namespace std;
 
int main() {
  int a,b; char op;
  
  while(true){
  	cin>>a>>op>>b;
    if(op=='?') break;
    if(op=='+') cout<<a+b<<endl;
    if(op=='-') cout<<a-b<<endl;
    if(op=='*') cout<<a*b<<endl;
    if(op=='/') cout<<a/b<<endl;
    
  }
  
}



Measured memory_bytes: 3100
#include<iostream>
#include<algorithm>
#include<string>
#include<math.h>
#include<vector>
#include<numeric>
//#include <bits/stdc++.h>
#include<cstring>
#include<iostream>
using namespace std;

bool check(string a);
bool check(string a) {
	bool ret = true;
	for (int i = 0; i < a.size(); i++) {		
		if (a[i] != a[a.size() - 1 - i]) {
			ret = false;
		}
	}
		
	return ret;
}

int main() {



	int A, B;
	cin >> A >> B;
	
	//cout << check("1212") << endl;
	
	int cnt = 0;
	for (int i = A; i <= B; i++)
		if ( check( to_string(i)) )
		{
			cnt++;
		//	cout << "answer " << i << " "  << cnt << endl;
		}
			
	cout << cnt << endl;

	//cin >> A;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <vector>
#include <algorithm>
#include <math.h>
#include <unordered_map>
using namespace std;

void solve() {
    int n, d; cin >> n >> d;
    int i = 0;
    while(true){
        if(i*d*2 + i >= n) {
            cout << i << endl;
            break;
        }
        i++;
    }
}

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

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
typedef long long ll;
int main() {
	int n;	cin >> n;
	vector<ll> a(n);
	for (int i = 0; i < n; i++)	cin >> a[i];
	ll allow = 1;
	ll ret = 0;
	for (int i = 0; i < n; i++) {
		if (allow == a[i]) {
			allow++;
			continue;
		}
		ll times = a[i] / allow;
		if (times*allow == a[i])	times--;
		ret += times;
		allow = (allow == 1 ? allow+1 : allow);
	}
	cout << ret << endl;
	return 0;
}

Measured memory_bytes: 1024
import java.util.*;
class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int x = sc.nextInt();
        int y = sc.nextInt();
        int area = x * y;
        int perimeter = 2 * (x + y);
        System.out.println(area + " " + perimeter);
    }
}


Measured memory_bytes: 26148
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <memory.h>
#include <cmath>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <ctime>
#include <iostream>
#include <functional>
#include <random>

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<double, double> pdd;
typedef pair<pii, int> p3i;
typedef vector<int> vi;
typedef vector<pii> vii;
typedef vector<p3i> v3i;
typedef vector<vii> vvii;
typedef vector<p3i> vp3i;
typedef long double ld;
typedef vector<ld> vld;


#define pb push_back
#define mp make_pair
#define REP(i, n) for (int (i) = 0; (i) < (n); (i)++)
#define REPD(i, n) for (int (i) = (n) - 1; (i) >= 0; (i)--)
#define FOR(i, a, b) for (int (i) = (a); (i) < (b); (i)++)
#define FORD(i,a, b) for (int (i) = (a); (i) >= (b); (i)--)
#define sz(v) (int)(v).size()
#define all(v) (v).begin(), (v).end()
#define rv(v) reverse(all(v))
#define CL(v, val) memset((v), (val), sizeof((v)))
#define SORT(a) sort(all(a))
#define un(v) SORT(v), (v).resize(unique(all(v)) - (v).begin())
#define eps 1.0e-9
#define X first
#define Y second
#define bit(n) (1 << (n))
#define bit64(n) (ll(1) << (n))
#define sqr(x) ((x) * (x))
#define sq5(x) ((x) * (x) * (x) * (x) * (x))
#define N 200005

ll add[N];
ll mod = 998244353ll;
ll res[N];

int l[N], r[N];

int main(void) {
	int n, k;
	scanf("%d%d", &n, &k);
	REP(i, k) {
		scanf("%d%d", &l[i], &r[i]);
	}
	CL(res, 0);
	CL(add, 0);
	add[1] = 0;
	res[1] = 1;

	ll cur = 0;
	FOR(i, 1, n + 1) {
		cur = (cur + add[i]) % mod;
		if (i > 1)
			res[i] = cur;
		REP(j, k) {
			if (i + l[j] <= n) {
				add[i + l[j]] = (add[i + l[j]] + res[i]) % mod;
			}

			if (i + r[j] + 1 <= n) {
				add[i + r[j] + 1] = (add[i + r[j] + 1] - res[i] + mod) % mod;
			}
		}
	}

	printf("%lld\n", res[n]);
}

Measured memory_bytes: 6948
/* atcoder */
#include "bits/stdc++.h"
using namespace std;

/* typedef */
/* long系 */
typedef long long ll;   // long long
typedef long double ld; // long double
/* vector系 */
typedef vector<int> vi;                       // intのvector
typedef vector<double> vd;                    // doubleのvector
typedef vector<ll> vll;                       // llのvector
typedef vector<ld> vld;                       // ldのvector
typedef vector<vector<int>> vvi;              // intの2次元vector
typedef vector<vector<double>> vvd;           // doubleの2次元vector
typedef vector<vector<ll>> vvll;              // llの2次元vector
typedef vector<vector<ld>> vvld;              // ldの2次元vector
typedef vector<pair<int, int>> vi_i;          // i_iのvector
typedef vector<pair<double, double>> vd_d;    // d_dのvector
typedef vector<pair<ll, ll>> vl_l;            // l_lのvector
typedef vector<pair<ld, ld>> vld_ld;          // ld_ldのvector
typedef vector<string> vs;                    // stringのvector
/* pair系 */
typedef pair<int, int> i_i;       // int同士のpair
typedef pair<double, double> d_d; // double同士のpair
typedef pair<ll, ll> l_l;         // ll同士のpair
typedef pair<ld, ld> ld_ld;       // ld同士のpair

/* define */
#define all(v) v.begin(), v.end() // コンテナ全体
#define PI (acos(-1))             // 円周率pi

/* stringstream */
stringstream ss;
stringstream init_ss; // save default formatting

/* upper, lower */
struct ToUpper
{
    char operator()(char c)
    {
        return toupper(c);
    }
};
struct ToLower
{
    char operator()(char c)
    {
        return tolower(c);
    }
};

/* main */
void Main(void)
{
    char c;
    cin >> c;
    if (isupper(c))
    {
        cout << "A" << endl;
    }
    else
    {
        cout << "a" << endl;
    }
}

int main(int argc, char const *argv[])
{
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    Main();

    return 0;
}


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

int main() {
  int N, Ma, Mb;
  cin >> N >> Ma >> Mb;
  int med[N][3];  // med[i][2] = cost of i
  rep(i,N) rep(j,3) cin >> med[i][j];

  int dif[N];  // [target] some sum of dif = 0
  rep(i,N) {
    med[i][0] *= Mb;
    med[i][1] *= Ma;
    dif[i] = med[i][0] - med[i][1];
  }
  
  map<int, int> dps;
  dps[0] = 0;
  queue<int> check;
  check.push(0);
  priority_queue<int, vector<int>, greater<int>> ans;

  rep(i,N) {
    int num = check.size();
    int d = dif[i];
    queue<int> dps_q;

    rep(j,num) {  // keep value before update
      int p = check.front();
      check.pop();
      check.push(p);
      dps_q.push(dps[p]);
    }

    rep(j,num) {
      int p = check.front();
      check.pop();
      check.push(p);

      if (p+d == 0) {  // some sum of dif = 0
        ans.push(dps_q.front() + med[i][2]);
      }
      else if (!dps.count(p+d)) {  // for the first time
        check.push(p+d);
        dps[p+d] = dps_q.front() + med[i][2];
      }
      else if (dps_q.front() + med[i][2] < dps[p+d]) {  // less cost
        dps[p+d] = dps_q.front() + med[i][2];
      }
      dps_q.pop();
    }
  }
  if (ans.empty()) {
    cout << -1 << endl;
    return 0;
  }
  cout << ans.top() << endl;
  return 0;
}


Measured memory_bytes: 384
s = input()
num_list = list(map(int, input().split()))

flg_break = True

count = -1
while flg_break:
    count+=1
    num_tmp_list = []
    for n in num_list:
        if n % 2 != 0:
            flg_break = False
            break
        else:
            num_tmp = n / 2
            num_tmp_list.append(num_tmp)
    num_list = num_tmp_list
    

print(count)

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

#define int long long

signed main()
{
	int n;
	cin >> n;
	vector<int> a(n);
	vector<int> neg,pos;
	
	bool has1 = false;
	bool has2 = false;
	for(int i=0;i<n;++i)
	{
		cin >> a[i];
		if(a[i]>0)has1 = true;
		if(a[i]<0)has2 = true;
	}
	
	sort(a.begin(),a.end());
	
	int ans;
	
	if(has1 and has2)
	{
		ans = accumulate(a.begin(),a.end(),0LL,[](auto a,auto b){
			return abs(a) + abs(b);
		});
		cout << ans << '\n';
		int ind = distance(a.begin(),lower_bound(a.begin(),a.end(),0LL));
		//~ cout << ind << " ind ";
		int diff = a[0];
		for(int i=ind;i<n-1;++i)
		{
			cout << diff << " " << a[i] << '\n';
			diff -= a[i];
		}
		cout << a[n-1] << " " << diff << '\n';
		diff = a[n-1] - diff;
		for(int i=1;i<ind;++i)
		{
			cout << diff << " " << a[i] << '\n';
			diff -= a[i];
		}
	}
	else
	{
		if(has1)
		{
			ans = accumulate(a.begin()+1,a.end()-1,0LL);
			ans -= a[0];
			ans += a[n-1];			
			cout << ans << '\n';
			int diff = a[0];
			for(int i=1;i<n-1;++i)
			{
				cout << diff <<  " " << a[i] << '\n';
				diff -= a[i];
			}
			cout << a[n-1] << " " << diff;
		}
		else
		{
			ans = accumulate(a.begin(),a.end()-1,0LL);
			ans -= a[n-1];
			cout << -ans << '\n';
			int diff = a[n-1];
			for(int i = n-2; i>=0 ; --i)
			{
				cout << diff << " " << a[i] << '\n';
				diff -= a[i];
			}
		}
	}
	
	
}


Measured memory_bytes: 2688
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

def main():
    N, M = map(int, read().split())
    ans1 = N // 2
    ans2 = N // 2 + 1
    action = 0
    if N%2 == 0:
        action = -(-N//4)
    for _ in range(M):
        print(ans1, ans2)
        ans1 -= 1
        ans2 += 1
        if ans1 == action:
            ans2 += 1
    return

if __name__ == '__main__':
    main()


Measured memory_bytes: 9208
#include<iostream>
#include<algorithm>
#include<vector>
#include<map>
using namespace std;
typedef long long ll;

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

    map<int, int> v[50];
    ll a;

    for(int i = 0; i < n; i++){
        cin >> a;
        int lsb = 0;
        while((1<<lsb) & ~a)    lsb++;
        lsb++;
        a /= (1ll<<lsb);
        int cp = (int)a;
        v[lsb][cp]++;
    }

    int ans = 0;
    for(int i = 0; i < 50; i++){
        if(v[i].size() == 0)    continue;
        for(auto it = v[i].rbegin(); it != v[i].rend(); it++){
            if((*it).second == 0 || (*it).first == 0)   continue; // needless?
            int tmp = (*it).first;
            int want = 0, cur = 0;
            while(tmp > 0){
                if((tmp&1) == 0)    want += 1<<cur;
                cur++;
                tmp >>= 1;
            }
            tmp = (*it).first;
            if(v[i].count(want) == 0)   continue;
            int make = min((*it).second, v[i][want]);
            (*it).second -= make, v[i][want] -= make;
            ans += make;
        }
        if(v[i].count(0))   ans += v[i][0]/2;
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 9728
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define REP(i,n) for(long long i=0;i<n;++i)
#define REPP(i,m,n) for(long long i=m;i<n;++i)
#define rep(i,n) for(long long i = n-1;i>=0;--i)
#define repp(i,n,m) for(long long i = n-1; i >= m; --i)
#define ALL(N) (N.begin(),N.end())
#define de cout << "line : " << __LINE__ << " debug" << endl;
#define pb push_back
#define pq priority_queue
#define Dcout(N) cout << setprecision(20) << N << endl
constexpr int MOD = 1000000007;
constexpr int INF = 2147483647;
constexpr long long INFF = 9223372036854775807;

signed main() {
    cin.tie(0);
	ios::sync_with_stdio(false);
    int N,ans = 0,M;
    cin >> N >> M;
    if(500 * N >= M){
        cout << "Yes" << endl;
    }
    else cout << "No" << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<string>
#include<iostream>
using namespace std;

int main(){
    string str; 
    //cout << str << endl;
    int m; 
    int h;
    string head, bottom;

    while(true){
        cin >> str;
        if(str == "-")break;
        cin >> m;
        for (int i = 0; i < m; i++)
        {
            cin >> h;
            bottom = str.substr(0, h);
            head = str.substr(h, str.size()-h);
            str = head + bottom;
        }
        cout << str << endl;
    }
    
    return 0;
}


Measured memory_bytes: 3196
import math


def solve():
    N, D = map(int, input().split())
    X = [[int(i) for i in input().split()] for _ in range(N)]
    count = 0
    for i in range(N - 1):
        for j in range(i + 1, N):
            distance = 0
            for d in range(D):
                distance += (X[i][d] - X[j][d]) ** 2
            if math.sqrt(distance) % 1 == 0:
                # print('i:', i, 'j', j)
                count += 1
    print(count)


if __name__ == '__main__':
    solve()


Measured memory_bytes: 3060
#include<iostream>
#include<string>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
using namespace std;
int main(){
	int n, l,i;
	string s0;
	string sum="";
	vector<string> s;
	cin >> n >> l;
	for (i = 0; i < n; i++) {
		cin >> s0;
		s.push_back(s0);
	}
	sort(s.begin(), s.begin() + n);
	for (i = 0; i < n; i++) {
		sum += s[i];
	}
	cout << sum << endl;
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

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

		int a = sc.nextInt();
		int b = sc.nextInt();
		
		if(a == b) {
			System.out.println("Draw");
		} else {
			if(a == 1) {
				System.out.println("Alice");
			} else if(b == 1){
				System.out.println("Bob");
			} else if(a > b) {
				System.out.println("Alice");
			} else {
				System.out.println("Bob");
			}
		}
	}
}

Measured memory_bytes: 35632
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n,m;
	cin>>n>>m;
	vector<int>road(n);
	for(int i=0;i<m;i++){
		int a,b;
		cin>>a>>b;
		road.at(a-1)++;
		road.at(b-1)++;
	}
	for(int i=0;i<n;i++){
		cout<<road.at(i)<<endl;
	}
	return 0;
}

Measured memory_bytes: 256
from fractions import *
from collections import *
n, m = map(int,input().split())
a = sorted(map(int,input().split()))[::-1]
c = [0,2,5,5,4,5,6,3,7,6]
mi = min(a, key=lambda x: c[x])
x = sum(c[i]*c[mi]//gcd(c[i],c[mi]) for i in a if i!=mi)
q, r = divmod(max(0, n-x), c[mi])
n = min(n, x+r)
dp = [-float('inf')]*(n+1)
dp[0] = 0
for i in range(2, n+1):
    for j in a:
        if i >= c[j]:
            dp[i] = max(dp[i], dp[i-c[j]]+1)
d = Counter()
d[mi] += q
while n:
    i = max((i for i in a if n>=c[i]), key=lambda x: dp[n-c[x]])
    d[i] += 1
    n -= c[i]
print(''.join(str(k)*d[k] for k in sorted(d)[::-1]))

Measured memory_bytes: 5328
#include<bits/stdc++.h>
#define rep(i,n)for(int i=0;i<(n);i++)
using namespace std;
 
int b[200][200];
int n;
int ask(int i, int j) {
	string s = string(n, '0');
	s[i] = '1'; s[j] = '1';
	cout << "? " << s << endl;
	int res; cin >> res;
	return res;
}
int main() {
	cin >> n;
	int cnt = 0;
	memset(b, -1, sizeof(b));
	rep(i, n)for (int j = i + 1; j < n; j += 2) {
		if (cnt == n - 1)break;
		if (b[i][j] != -1) {
			j--; continue;
		}
		string s(n, '0'); s[i] = '1'; s[j] = '1';
		if (j + 1 < n)s[j + 1] = '1';
		cout << "? " << s << endl;
		int res; cin >> res;
		if (res == 0) {
			b[i][j] = 0; 
			if (j + 1 < n) {
				b[i][j + 1] = 0;
				b[j][j + 1] = 0;
			}
			continue;
		}
		if (j + 1 == n) {
			b[i][j] = 1; cnt++; continue;
		}
		int a = 0;
		if (ask(i, j)) {
			a++; b[i][j] = 1; cnt++;
		}
		else b[i][j] = 0;
		if (ask(i, j + 1)) {
			a++; b[i][j + 1] = 1; cnt++;
		}
		else b[i][j + 1] = 0;
		if (a == 2) {
			b[j][j + 1] = 0;
		}
		if (res == 2 && a != 2)b[j][j + 1] = 1;
	}
	cout << "!";
	rep(i, n)for (int j = i + 1; j < n; j++) {
		if (b[i][j]) {
			if (b[i][j] == -1)abort();
			cout << " ";
			cout << "(" << i << "," << j << ")";
		}
	}
	cout << endl;
}

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

int main() {
  int N;
  cin >> N;
  rep(i, N) {
    char a;
    cin >> a;
    if (a=='Y') {
      cout << "Four" << endl;
      return 0;
    }
  }
  cout << "Three" << endl;
  return 0;

}


Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
int pop(void);
void push(int);
int tail=0;
int stack[100];
int main(){
  int x,y,z;
  char s[100];
  while( scanf("%s", s) != EOF ){
    if ( s[0] == '+' ){
      y=pop();
      z=pop();
   
      push(z+y);
    } else if ( s[0] == '-' ){
      y=pop();
      z=pop();
      push(z-y);
    } else if ( s[0] == '*' ){
      y=pop();
      z=pop();
      push(y*z);
    } else {
      x = atoi(s);
      push(x);
    }
  }
  z=pop();
  printf("%d\n",z);
  return 0;
}
int pop(){
  tail--;
  return stack[tail];
}
void push(int a){
  stack[tail]=a;
  tail++;
}



Measured memory_bytes: 2052
import java.util.Scanner;

public class Main {
	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		while (true) {
			int n = sc.nextInt();
			if (n==0) {
				break;
			}
			int min = 1001,max = 0,sum = 0;
			for (int i=0;i<n;i++) {
				int s = sc.nextInt();
				if (min > s) {
					min = s;
				}
				if (max < s) {
					max = s;
				}
				sum+=s;
			}
			System.out.println((sum-max-min)/(n-2));
		}
	}
}

Measured memory_bytes: 20964
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#define REP(i,a) for (int i = 0;i < (a);++i)
#define FOR(i,a,b) for (int i = (a);i < (b); ++i)
#define FORR(i,a,b) for (int i = (a);i >= (b); --i)
#define ALL(obj) (obj).begin,(obj).end()
#define SORT(list) sort(ALL((list)));
using namespace std;
using ll = long long;
int main(){
    string a,b;
    cin >> a >> b;
    int answer = 0;
    REP(i,3){
        if(a.at(i) == b.at(i))answer++;
    }
    cout << answer << endl;
    
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ll long long
vector <vector <int > > G;
vector <int> vis;
int J = 0;
ll n;
vector <pair <ll, ll> > ds, cs;
vector <ll> ans;
void dfs(int u){
    ++J;
    ans[u] = cs[n - J].first;
    vis[u] = 1;
    for(int a : G[u]){
        if(!vis[a])dfs(a);
    }
}
main(){
    cin >> n;
    ll s = 0;
    ll mas = 0;
    ll M = 0;
    vector <ll> deg(n), c(n);
    vis.resize(n);
    ds.resize(n);
    cs.resize(n);
    G.resize(n);
    ans.resize(n);
    vector <pair <int,int> > ed;
    for(int i = 0; i + 1 < n; ++i){
        int a,b;
        cin >> a >> b;
        --a;
        --b;
        deg[a]++;
        deg[b]++;
        ed.push_back({a,b});
        G[a].push_back(b);
        G[b].push_back(a);
    }
    for(int i = 0; i < n; ++i){
        cin >> c[i];
        s += c[i];
        mas = max(mas, c[i]);
        cs[i] = {c[i], i};
    }
    s -= mas;
    cout << s << '\n';
    sort(cs.begin(), cs.end());
    dfs(0);
    for(int i : ans){
        cout << i <<  ' ';
    }
}

Measured memory_bytes: 1916
#include <cmath>
#include <iostream>
#include <vector>
using namespace std;
int main(int argc, char const* argv[]) {
    int n;
    vector<vector<int>> ds;
    cin >> n;
    for (int i = 0; i < n; ++i) {
        int x, y, h;
        cin >> x >> y >> h;
        vector<int> d = {{x, y, h}};
        ds.push_back(d);
    }
    for (int x = 0; x <= 100; ++x) {
        for (int y = 0; y <= 100; ++y) {
            int h = 1000000000;
            for (int i = 0; i < ds.size(); ++i) {
                if (ds[i][2] != 0) {
                    h = abs(ds[i][0] - x) + abs(ds[i][1] - y) + ds[i][2];
                    break;
                }
            }
            bool found = true;
            for (int i = 0; i < ds.size(); ++i) {
                if (ds[i][2] == 0) {
                    if (h - abs(ds[i][0] - x) - abs(ds[i][1] - y) > 0) {
                        found = false;
                        break;
                    }
                    continue;
                }
                auto j = abs(ds[i][0] - x) + abs(ds[i][1] - y) + ds[i][2];
                if (h != j) {
                    found = false;
                    break;
                }
            }
            if (found) {
                cout << x << " " << y << " " << h << endl;
            }
        }
    }
    return 0;
}


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

int main() {
  int N;
  cin >> N;
 
  if(N<10){
   cout<<N<<endl; 
  }
  
  else if(N<100){
    cout << 9 << endl;
  }
  
  else if(N<1000){
    cout << N-99+9 << endl;
  }
  
  else if(N<10000){
    cout << 909 << endl;
  }
  
  else if(N<100000){
   cout << N-9999+909 << endl;
  }
  
  else{
   cout << 90909 << endl; 
  }
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int m = sc.nextInt();
		int max = 1;//lの最大値格納先
		int min = n;//Rの最小値格納先
		int l;
		int r;
		for (int i = 1; i <= m; i++) {
			l = sc.nextInt();
			r = sc.nextInt();//ｌとｒを取得

			if (l > max) {
				max = l;
			}
			if (r < min) {
				min = r;
			}//普通にlとrの最大、最小をいつものやり方で出す
		}
		//lとrの最大、最小の差を取り、1を足す(2～6の鍵がOKの時、鍵は5本だが6-2=4になってしまうのでその分の調整)

		int ans = min - max + 1;
		if (ans >= 0) {//ansが正ならそのまま表示
			System.out.println(ans);
		} else {//ansが負なら鍵は存在しないので0を表示
			System.out.println(0);
		}
	}
}


Measured memory_bytes: 64976
import java.util.Scanner;

public class Main {
	public static void main (String args[]) {
		Scanner scan = new Scanner(System.in);
		String s = scan.next();
		if(s.equals("SAT")) System.out.print(1);
		if(s.equals("SUN")) System.out.print(7);
		if(s.equals("MON")) System.out.print(6);
		if(s.equals("TUE")) System.out.print(5);
		if(s.equals("WED")) System.out.print(4);
		if(s.equals("THU")) System.out.print(3);
		if(s.equals("FRI")) System.out.print(2);

	}
}

Measured memory_bytes: 21972
#include <cstdio>
#include <algorithm>
using namespace std;
int n,w,h;
int xs[1000002];
int ys[1000002];
int main(void){
	scanf("%d %d %d",&n,&w,&h);
	for(int i=0;i<n;i++){
		int x,y,we;
		scanf("%d %d %d",&x,&y,&we);
		xs[max(x-we,0)]++;
		xs[min(x+we,w+1)]--;
		ys[max(y-we,0)]++;
		ys[min(y+we,h+1)]--;
	}
	for(int i=1;i<=w;i++){
		xs[i]+=xs[i-1];
	}
	for(int i=1;i<=h;i++){
		ys[i]+=ys[i-1];
	}
	int cnt=2;
	for(int i=0;i<w;i++){
		if(xs[i]<=0){
			cnt--;
			break;
		}
	}
	for(int i=0;i<h;i++){
		if(ys[i]<=0){
			cnt--;
			break;
		}
	}
	printf("%s\n",cnt>=1?"Yes":"No");
	return 0;
}

Measured memory_bytes: 5508
str = list(input())
N = len(str)
str.append('EOF')
ans = [0] * N
i = 0
countR = 0
countL = 0

while str[i] != 'EOF':
    countR = 0
    countL = 0
    while str[i] == 'R':
        countR = countR + 1
        i = i + 1
    while str[i] == 'L':
        countL = countL + 1
        i = i + 1
    ans[i - countL] = int(countR / 2) + int(countL / 2) + countL % 2
    ans[i - countL - 1] = int(countL / 2) + int(countR / 2) + countR % 2

print(*ans)


Measured memory_bytes: 9016
n = int(input())

def factorize(n):
    fct = []
    b, e = 2, 0
    while b*b <= n:
        # √n 以上でまだ約数がある場合nが約数になるためそれ以下まで調べればいい
        while n%b == 0:
            n //= b
            e += 1
        if e > 0:
            fct.append((b, e))
        b, e = b+1, 0
    if n > 1:
        fct.append((n, 1))
    return fct

cnt = 0
for p, e in factorize(n):
    i = 1
    while e >= i:
        cnt += 1
        e -= i
        i += 1
print(cnt)

Measured memory_bytes: 9216
open System.Collections.Generic
open System.Linq

let S = stdin.ReadLine()
let Q = stdin.ReadLine() |> int

let mutable flag = true
let ll = new LinkedList<char>()

'*'
|> ll.AddLast
|> ignore

for i in [ 0..Q - 1 ] do
    let input = stdin.ReadLine()
    if (input.[0] = '1') then flag <- not flag
    else
        let q = input.Split().ToArray()
        match flag with
        | true ->
            if (q.[1] = "1") then
                q.[2]
                |> char
                |> ll.AddFirst
                |> ignore
            else
                q.[2]
                |> char
                |> ll.AddLast
                |> ignore
        | false ->
            if (q.[1] = "1") then
                q.[2]
                |> char
                |> ll.AddLast
                |> ignore
            else
                q.[2]
                |> char
                |> ll.AddFirst
                |> ignore

let str = (new string(ll.ToArray())).Replace("*", S)

if flag then str
else new string(str.Reverse().ToArray())
|> printfn "%s"


Measured memory_bytes: 39188
#include <iostream>
#include <cstring>
#define MAX_COL 10000

using namespace std;

int down_one_and_load_right(int b[],int sum){ // 高さが0であるかは考慮しない.
	int s = 0, i;
	for(i = 0;s < sum;i++){
		s += b[i];
		b[i]--;
	}
	int j;
	s = i;
	for(j = 0;s < sum;j++){
		s += b[j];
	}
	b[j] = i;
	return 1; // 操作としては1回なので常に１を返す.
}


int find_span(int b[],int sum){ // 隙間を探す関数
	int s = 0;
	for(int i = 0;s < sum;i++){
		if(b[i] == 0){
			return 1;
		}
		s += b[i];
	}
	return 0;
}
	

int judge_asc(int b[],int sum){
	int s = 0;
	for(int i = 0;s < sum;i++){
		if(b[i] != i + 1){
			return 0;
		}
		s += b[i];
	}
	return 1;
}


int shift_left(int b[],int sum){ // 左詰めにしながら,操作回数を返す
	int s = 0;
	int shift_num = 0;
	int block = 0;
	int res = 0;
	for(int i = 0;s < sum;i++){

		if(b[i] == 0){
			shift_num++;
			if(block){
				res = 1;
			}
		}else{
			b[i - shift_num] = b[i];
			s += b[i];
			if(shift_num > 0){
				b[i] = 0;
			}
			block = 1; // ブロックが参照位置より左にあるときに,隙間を判定
		}
	}
	return 0;
}



int main(void){
	int b[MAX_COL];
	int n, sum, ans;
	while(1){
		cin >> n;
		if(n == 0){
			break;
		}
		memset(b,0,sizeof(b));
		sum = 0;
		for(int i = 0;i < n;i++){
			cin >> b[i];
			sum += b[i];
		}

		ans = 0;
		while(ans <= 10000){
			// 昇順であるか確認
			if(judge_asc(b,sum)){
				break;
			}
			if(find_span(b,sum)){
				ans += shift_left(b,sum);
			}else{
				ans += down_one_and_load_right(b,sum);
			}
		}
		if(ans > 10000){
			cout << -1 << endl;
		}else{
			cout << ans << endl;
		}

	}
	return 0;
}

Measured memory_bytes: 1208
def main():
    def fun(n):
        if n % 2 == 0:
            return int(n / 2)
        else:
            return 3 * n + 1

    s = int(input())
    vals = [s]
    while True:
        new_v = fun(vals[-1])
        if new_v in vals:
            print(len(vals) + 1)
            break
        else:
            vals.append(new_v)


if __name__ == '__main__':
    main()


Measured memory_bytes: 61800
N=int(input())
k={}
def y(p):
  if p in k.keys():
    return k[p]
  if p == 0:
    return 2
  elif p == 1:
    return 1
  else:
    k[p] = y(p-2)+y(p-1)
    return k[p]
print(y(N))

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

using namespace std;
typedef long long int ll;

int dw[4] = {1,0,-1,0};
int dh[4] = {0,1,0,-1};

int main()
{
    int W,H;
    while(cin >> W >> H)
    {
        if(W == 0 && H == 0) break;
        vector<vector<vector<int>>>v(H,vector<vector<int>>(W,vector<int>(4,1)));
        for(int i = 0; i < H; i++)v[i][0][2] = 0;
        for(int i = 0; i < H; i++)v[i][W-1][0] = 0;
        for(int i = 0; i < W; i++)v[0][i][3] = 0;
        for(int i = 0; i < W; i++)v[H-1][i][1] = 0;
        for(int i = 0; i < W-1; i++)
        {
            int p;
            cin >> p;
            if(p) v[0][i][0] = 0,v[0][i+1][2] = 0;
        }
        for(int i = 1; i < H; i++)
        {
            for(int j = 0; j < W; j++)
            {
                int p;
                cin >> p;
                if(p) v[i-1][j][1] = 0,v[i][j][3] = 0;
            }
            for(int j = 0; j < W-1; j++)
            {
                int p;
                cin >> p;
                if(p) v[i][j][0] = 0,v[i][j+1][2] = 0;
            }
        }
        vector<vector<int>>G(H,vector<int>(W,-1));
        G[0][0] = 1;
        queue<pair<int,int>>que;
        que.push(make_pair(0,0));
        while(!que.empty())
        {
            int h = que.front().first;
            int w = que.front().second;
            que.pop();
            for(int i = 0; i < 4; i++)
            {
                if(v[h][w][i] == 0) continue;
                int nh = h + dh[i];
                int nw = w + dw[i];
                if(nh < 0 || nh >= H || nw < 0 || nw >= W) continue;
                if(G[nh][nw] != -1) continue;
                G[nh][nw] = G[h][w] + 1;
                que.push(make_pair(nh,nw));
            }
        }
        if(G[H-1][W-1] == -1) cout << 0 << endl;
        else cout << G[H-1][W-1] << endl;
    }
}


Measured memory_bytes: 3140
n = gets.to_i
a = gets.split.map(&:to_i)

r = Hash.new(0)
a.each do |x|
  r[x + 1] += 1
  r[x - 1] += 1
  r[x] += 1
end

ans = 0
r.each do |k, v|
  ans = v > ans ? v : ans
end
puts ans


Measured memory_bytes: 14212
s = input()

while(len(s)!=0):
    if s[-5:] == 'dream' or s[-5:] == 'erase':
        s = s[:-5]
    elif s[-6:]== 'eraser':
        s = s[:-6]
    elif s[-7:]=='dreamer':
        s = s[:-7]
    else:
        print('NO')
        break
else:
    print('YES')

Measured memory_bytes: 133880
def solver():
    n = int(input())
    s = input()
    if n%2 == 0:
        d = n // 2
        s_s = s[:d]
        s_t = s[d:]
        if s_s == s_t:
            print('Yes')
        else:
            print('No')
    else:
        print('No')


if __name__ == '__main__':
    solver()


Measured memory_bytes: 2940