akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<cstdio>
#include<cmath>
#include<vector>
#include<list>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<string>
#include<cstring>
#include<utility>
#include<algorithm>
#include<functional>
#include<deque>
#include<cctype>
#include<ctime>
#include<cstdlib>
#include<iomanip>
using namespace std;

int main(){
   int n;
   cin >> n;
   int a[n];
   for (int i = 0; i < n; i++) cin >> a[i];
   long long ans = 0;
   for (int i = 0; i < n; i++){
      if ((a[i]&1) == 0){
         while ((a[i]&1)== 0) ans++, a[i] /= 2;
      }
   }
   cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
string s1,s2;
int main(){
	cin >> s1 >> s2;
	int n = s1.size();
	int m = s2.size();
	if(n != m-1)	puts("No");
	else{
		int ok = 1;
		for(int i(0);i < n;++i)
			if(s1[i] != s2[i]){ok = 0;break;}
		if(ok)	puts("Yes");
		else puts("No");
	}
	return 0;
}

Measured memory_bytes: 3624
loop do
h, w = gets.split.map(&:to_i)
  if h == 0 && w == 0
    break
  end
h.times do|i|
  w.times do|j|
    if i == 0 || i == (h-1) || j == 0 || j == (w-1)
      print "#"
    else
      print "."
    end
  end
  puts ""
end
puts ""
end



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

int i=-1;

int findnumber(int sum,int score,vector<bool> v,int D,int G,vector<int> p,vector<int> c,int i){

    if(score >= G){
        /*cout << "scoreclear" << score <<endl;*/
        return sum;
    }//終了条件1 探索途中で目標スコア超える場合
    
    if(i == D-1){
        for(int k=(D-1);-1<k;k--){//点数多い問題から解いてないやつを
                if(v.at(k)==false){ //ここで解いたかどうかチェック
                    for(int l=0;l<p.at(k)-1;l++){
                        score += 100*(k+1);
                        sum++;
                        /*cout <<sum<< "中途半端"<< k <<":"<< score<<endl;*/
                        if(score >= G){/*cout << "調整clear" << endl;*/return sum;}
                    }//目標score達成するか、その点数の問題を１つ除いて解き終わるまで解く
                    /*cout << "無理" << endl;*/
                    return 10000;//中途半端はある点数の問題のみ、一門除いてすべて解いて足りなかったらＯＵＴ
                }
        }
    }//終了条件２　最後まで調べたけどまだ足りない場合
    
    vector<bool> vsub;
    vsub = v;
    i++;
    vsub.at(i) = true;//ここ↓
    return min(findnumber(sum,score,v,D,G,p,c,i),findnumber(sum+p.at(i),score+100*(i+1)*p.at(i)+c.at(i),vsub,D,G,p,c,i));
    //左は解かない場合、右は100i点問題を完全に解く場合
}//関数定義する場合、変数を渡しておかないと分岐先の各処理で増えたままになる

int main (){
    int D,G,ans=10000;
    i=-1;
    cin >> D >> G;
    vector<int> p(D);
    vector<int> c(D);
    vector<bool> v(D,false);
    for(int j=0;j<D;j++){
        cin >> p.at(j) >> c.at(j);
    }
    
    cout << findnumber(0,0,v,D,G,p,c,i) <<endl;
}

Measured memory_bytes: 256
import           Control.Monad
import           Data.Array.IO
import           Data.Bits
import qualified Data.ByteString.Char8       as BS
import           Data.Char
import           Data.Maybe
import qualified Data.Vector.Unboxed         as V
import qualified Data.Vector.Unboxed.Mutable as VM

readInt = fst . fromJust . BS.readInt
getInt = readInt <$> BS.getLine
getIntVec n = V.unfoldrN n (BS.readInt . BS.dropWhile isSpace) <$> BS.getLine

main = do
  n <- getInt
  as <- getIntVec n

  cs <- VM.new 61
  VM.set cs (0::Int)

  forM_ [0..n-1] $ \i -> do
    let a = as V.! i
    forM_ [0..60] $ \j ->
      when (testBit a j) $ do
        c <- VM.read cs j
        VM.write cs j (c+1)
  cs' <- V.unsafeFreeze cs

  let calc i c a = let c1 = fromIntegral c :: Integer
                       c2 = fromIntegral (n-c) :: Integer
                   in
                     c1 * c2 * bit i + a

  print $ V.ifoldr calc 0 cs' `mod` 1000000007


Measured memory_bytes: 15868
#pragma GCC optimize(3,"Ofast","inline")
#pragma GCC target("avx,avx2")
#include <bits/stdc++.h>
using namespace std;
template<class t> inline t read(t &x){
	char c=getchar();bool f=0;x=0;
	while(!isdigit(c)) f|=c=='-',c=getchar();
	while(isdigit(c)) x=(x<<1)+(x<<3)+(c^48),c=getchar();
	if(f) x=-x;return x;
}
template<class t,class ...A> inline void read(t &x,A &...a){
	read(x);read(a...);
}
template<class t> inline void write(t x){
	if(x<0) putchar('-'),write(-x);
	else{if(x>9) write(x/10);putchar('0'+x%10);}
}

const int N=1005;
char a[N],b[N];
int ans,n,m;

signed main(){
	scanf("%s%s",a+1,b+1);
	n=strlen(a+1);
	m=strlen(b+1);
	ans=m;
	for(int i=1;i+m-1<=n;i++){
		int cnt=0;
		for(int j=1;j<=m;j++) cnt+=a[i+j-1]!=b[j]; 
		ans=min(ans,cnt);
	}
	write(ans);
}

Measured memory_bytes: 3680
#include <stdio.h>

int main(void)
{

    int inputNumber;
    char c_existFlag = 0;
    scanf("%d", &inputNumber);

    while (c_existFlag == 0)
    {
        for (int num = inputNumber; num > 1; num--)
        {
            if (num != inputNumber && inputNumber % num == 0)
            {
                inputNumber++;
                break;
            }
            if (num == 2)
            {
                c_existFlag = 1;
            }
        }

    }

    printf("%d", inputNumber);

}

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

public class Main {

	public static void main(String[] args) throws NumberFormatException, IOException {

		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		int n = Integer.parseInt(br.readLine());

		long min = 999999999;

		for (int i = 1; i < n; i++) {
			String a = String.valueOf(i);
			String b = String.valueOf(n - i);
			int asum = 0;
			int bsum = 0;
			for (int j = 0; j < a.length(); j++) {
				asum += a.charAt(j) - 48;
			}
			for (int j = 0; j < b.length(); j++) {
				bsum += b.charAt(j) - 48;
			}
			min = Math.min(min, asum + bsum);
		}

		System.out.println(min);

	}

}


Measured memory_bytes: 31776
#include <iostream>
#include <algorithm>
#include <cmath>
#include <limits>
#include <vector>
#include <cstdio>
#include <bits/stdc++.h>
#include <set>
#include <map>
#include <stdio.h>
#include <stack>
#include <queue>
#include <deque>
#include <numeric>
#include<bits/stdc++.h>
#include <utility>

#define ALL(obj) (obj).begin(), (obj).end()
#define FOR(i,a,b) for(int i = (a); i < (b); i++)
#define RFOR(i,a,b) for(int i = (a); (b) <= i; i--)
#define REP(i,n) for(int i = 0; i < (n); i++)
#define RREP(i,n) for(int i = n; n <= i; i--)
#define ABS(a) ((a < 0) ? ((-1)*(a)) : (a))
#define elif else if
#define MOD 1000000007
#define INF (1<<29)

using namespace std;
using ll = long long;
map <int ,int> mpa,mpb;
typedef pair<ll, ll> P;
priority_queue<P, vector<P>, greater<P>> pque;

int main(){
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  int R;
  cin >> R;
  cout << (R<1200?"ABC":R<2800?"ARC":"AGC") << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define repit(it, li) for(auto it=li.begin(); it!=li.end(); it++)
using namespace std;
using ll = long long;
using P = pair<int,int>;

int main(){
   int n;
   cin>>n;
   vector<int> a(n);
   rep(i, n) cin>>a[i];

   map<int, int> ma;
   for(int i=n-1; i>=0; i--){
      auto it=ma.upper_bound(a[i]);
      if(it!=ma.end()){
         if(it->second==1) ma.erase(it);
         else it->second--;
      }
      ma[a[i]]++;
   }
   int ans=0;
   for(P p : ma){
      ans+=p.second;
   }

   cout<<ans<<endl;
   return 0;
}


Measured memory_bytes: 8212
import itertools
inf = float("inf")
n,m,r = map(int,input().split())
ra = list(map(int,input().split()))
dist = [[inf for i in range(n)] for i in range(n)]
for i in range(m):
    a,b,c = map(int,input().split())
    dist[a-1][b-1] = c
    dist[b-1][a-1] = c

for a in range(n):
    for b in range(n):
        for c in range(n):
            dist[b-1][c-1] = min(dist[b-1][c-1],dist[b-1][a-1]+dist[a-1][c-1])

#print("距離行列は以下")
#for i in range(n+1):
    #print(dist[i])

ans = inf
for p in itertools.permutations(ra):
    subt = 0
    for i in range(r-1):
        subt += dist[p[i]-1][p[i+1]-1]
    if subt < ans:
        ans = subt
print(ans)


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

int chain(string s)
{
  while(true)
  {
    int cnt = 1;
    char c = 'a';
    bool b = false;
    for(int i = 0; i < s.length(); i++)
    {
      if(c == s[i])
        cnt++;
      else
        cnt = 1;
      c = s[i];
      if(cnt == 4)
      {
        b = true;
        int st = i - 3;
        for(; c == s[i]; i++)
          c = s[i - 1];
        s.erase(st, i - st);
      }
      if(b)
        break;
    }
    if(!b)
      return s.length();
  }
}

int main()
{
  while(true)
  {
    int N;
    cin >> N;
    if(!N)
      return 0;
    string s = "";
    for(int i = 0; i < N; i++)
    {
      char c;
      cin >> c;
      s += c;
    }
    int ans = 1 << 30;
    for(int i = 0 ; i < s.length(); i++)
    {
      char tmp = s[i];
      for(char j = '1'; j <= '3'; j++)
      {
        if(s[i] == j)
          continue;
        s[i] = j;
        ans = min(ans, chain(s));
      }
      s[i] = tmp;
    }
    cout << ans << endl;
  }
}

Measured memory_bytes: 1260
/**
*    author:  Taichicchi
*    created: 13.09.2020 14:33:51
**/

#include <bits/stdc++.h>

#include <algorithm>
#include <iostream>
#include <vector>

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

int main() {
    int D, T, S;
    cin >>D>>T>>S;
    
    if(S * T >= D){
        cout <<"Yes"<<endl;
    }else{
        cout <<"No"<<endl;
    }
    
    return 0;
}

Measured memory_bytes: 3608
#include<iostream>
using namespace std;
int main(){
  int N, M, P, X[100];
  while(cin >> N >> M >> P , N){
    int sum = 0;
    for(int i = 0 ; i < N ; sum += X[i++] ) cin >> X[i];
    if(X[--M]) cout << sum * (100 - P) / X[M] << endl;
    else cout << 0 << endl;
  }
}


Measured memory_bytes: 3044
//This Code was made by Chinese_zjc_.
#include <iostream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <bitset>
#include <cmath>
#include <queue>
#include <stack>
#include <string>
#include <cstring>
#include <cstdio>
#include <cstdlib>
#include <map>
#include <set>
#include <ctime>
// #include<windows.h>
#define int long long
#define double long double
using namespace std;
const double PI = acos(-1);
const double eps = 0.0000000001;
const int INF = 0x3fffffffffffffff;
int n, w[11][11] = {
           {},
           {0, 0, 1, 2, 7, 45, 512, 9925, 321381, 15870550, 1069877351},
           {0, 1, 0, 4, 14, 90, 1024, 19850, 642762, 31741100, 2139754702},
           {0, 2, 4, 0, 28, 180, 2048, 39700, 1285524, 63482200, 4279509404},
           {0, 7, 14, 28, 0, 315, 3584, 69475, 2249667, 111093850, 7489141457},
           {0, 45, 90, 180, 315, 0, 6144, 119100, 3856572, 190446600, 12838528212},
           {0, 512, 1024, 2048, 3584, 6144, 0, 198500, 6427620, 317411000, 21397547020},
           {0, 9925, 19850, 39700, 69475, 119100, 198500, 0, 9320049, 460245950, 31026443179},
           {0, 321381, 642762, 1285524, 2249667, 3856572, 6427620, 9320049, 0, 603080900, 40655339338},
           {0, 15870550, 31741100, 63482200, 111093850, 190446600, 317411000, 460245950, 603080900, 0, 56703499603},
           {0, 1069877351, 2139754702, 4279509404, 7489141457, 12838528212, 21397547020, 31026443179, 40655339338, 56703499603, 0},
};
signed main()
{
    ios::sync_with_stdio(false);
    cin >> n;
    for (int i = 1; i <= n; ++i)
    {
        for (int j = 1; j <= n; ++j)
        {
            cout << w[i][j] << ' ';
        }
        cout << endl;
    }
    return 0;
}

Measured memory_bytes: 3568
<?php
fscanf(STDIN, "%d %d", $A, $P);
define('NEED_FOR_PIE', 2);

$pieces = 0;
$answer = 0;

for ($i = 0; $i < $A; $i++) {
    $pieces++;
    $pieces++;
    $pieces++;
}
for ($i = 0; $i < $P; $i++) {
    $pieces++;
}
while($pieces >= NEED_FOR_PIE) {
    for ($i = 0; $i < NEED_FOR_PIE; $i++) {
        $pieces--;
    }
    $answer++;
}
echo $answer;


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

int main(){
  string O,E; cin >>O >>E;
  rep(i,0,O.size()-1) {
    cout <<O[i] <<E[i];
  }
  if (O.size()==E.size()) cout <<O[O.size()-1] <<E[E.size()-1];
  else cout <<O[O.size()-1];
  cout <<endl;
  return 0;
}


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

int main() {
  
  double A,B;
  cin >> A >> B ;
  
  int form = min(A,B); ///繰り返しの範囲を求める。
  int Pf = 1; ///素因数を蓄積する。
  
  for(int i=2; i<=form; i++){
    
    ///
    int An = A/i;
    double Ad =A/i;
    int Bn = B/i;
    double Bd = B/i;
    ///それぞれiで割った時のintとdoubleの値を出す。比較用。
    
    if(An==Ad && Bn==Bd){///A,Bがそれぞれiで割れるという条件
      A/=i;
      B/=i;
      Pf*=i;
      i=1;///iを2に戻して再スタート(返った時にi++されるため1)
    }
    
  }
  
  int64_t Ans = A*B*Pf;///最小公倍数を求める公式
  
  cout << Ans << endl;
  
      
}


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

using namespace std;

typedef long long int ll;

const ll N = 2 * 1e5, MOD = 1e9 + 7;

vector <int> edges[N], children[N];
ll dp[N][2];

ll numberOfWays(ll curr, int parentColor) {
  if (dp[curr][parentColor])
    return dp[curr][parentColor];

  ll ans = 0, localAns = 1;

  for (int i = 0; i < (int)children[curr].size(); i++)
    localAns *= numberOfWays(children[curr][i], !parentColor) % MOD, localAns %= MOD;
  
  ans += localAns % MOD;
  localAns = 1;

  if (!parentColor) {
    for (int i = 0; i < (int)children[curr].size(); i++)
      localAns *= numberOfWays(children[curr][i], parentColor) % MOD, localAns %= MOD;
    ans += localAns % MOD;
  }
  
  return dp[curr][parentColor] = (ans % MOD);
}

void dfs(int node, int parent) {
  for (int i = 0; i < (int)edges[node].size(); i++)
    if (edges[node][i] != parent) {
      children[node].push_back(edges[node][i]);
      dfs(edges[node][i], node);
    }
}

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

  for (int i = 0; i < n-1; i++) {
    cin >> x >> y;
    x--, y--;
    edges[x].push_back(y);
    edges[y].push_back(x);
  }

  dfs(0, -1);
  cout << (numberOfWays(0, 0) % MOD) << endl;
}


Measured memory_bytes: 27720
use proconio::input;

fn main() {
    input! {
        n: usize,
        m: usize,
        k: u32,
        a: [u32; n],
        b: [u32; m],
    }

    let mut s: u32 = 0;
    let mut i: usize = 0;
    let mut j: usize = 0;

    while i < n && a[i] + s <= k {
        s += a[i];
        i += 1;
    }
    while j < m && b[j] + s <= k {
        s += b[j];
        j += 1;
    }

    let mut n: usize = i + j;
    let mut ans: usize = n;
    while i > 0 && j < m {
        i -= 1;
        n -= 1;
        s -= a[i];
        while j < m && b[j] + s <= k {
            s += b[j];
            j += 1;
            n += 1;
        }
        if n > ans {
            ans = n;
        }
    }
    println!("{}", ans);
}


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

#define NORMAL 195;
#define URU 200;

int main(){
    int n, y, m, d;
    int uru, small;
    int days;
    cin >> n;
    for(int i=0;i<n;++i){
        days = 0;
        cin >> y >> m >> d;
        uru = 999/3 - y/3;
        days += uru * URU;
        days += (999-y-uru) * NORMAL;
        if(y % 3){
            small = 10/2 - m/2;
            days += small * 19;
            days += (10-m-small) * 20;
            if(m % 2){
                days += 20-d;
            }else{
                days += 19-d;
            }
        }else{
            days += (10-m) * 20;
            days += 20-d;
        }
        cout << days+1 << endl;
    }
}

Measured memory_bytes: 1160
#include<iostream>
using namespace std;
int add(int n)
{
    int i,sum=0;
    for(i=1; i<=n; i++)
    {
        sum+=i;
    }
    return sum;
}
int main()
{
    int n,i,sum=0;
    cin>>n;
    for(i=1; i<=n; i++)
    {
        sum=add(n);
    }
    cout<<sum<<endl;

    return 0;
}



Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define EACH(i,a) for (auto& i : a)
#define FOR(i,a,b) for (ll i=(a);i<(b);i++)
#define RFOR(i,a,b) for (ll i=(b)-1;i>=(a);i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
template<typename T> ostream& operator<<(ostream& os, const vector<T>& v) {
REP(i,v.size()){if(i)os<<" ";os<<v[i];}return os;}
template<typename T> ostream& operator<<(ostream& os, const vector<vector<T>>& v) {
REP(i,v.size()){if(i)os<<endl;os<<v[i];}return os;}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    // メインプログラムここから
    ll R1, R2; cin >> R1 >> R2;
    double R3 = (double)R1*R2/(R1+R2);
    cout << fixed << setprecision(10) << R3 << endl;
    // ここまで
}


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

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

    int count = 0;
    while(1){
        n /= k;
        if( n == 0){
            count++;
            break;
        }
        count++;
    }
    cout << count << endl;

    return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
#define ll long long
inline int read()
{
	int x;char c;
	while((c=getchar())<'0'||c>'9');
	for(x=c-'0';(c=getchar())>='0'&&c<='9';)x=x*10+c-'0';
	return x;
}
#define MN 300000
ll t[MN+5],s[MN+5],lf[MN+5],rf[MN+5],S[MN+5],ans[MN+5];
int n,q[MN+5],qn;
inline double cal(int a,int b){return (double)(S[a]-S[b])/(a-b);}
void cal(ll*f)
{
	int i;
	for(i=1;i<=n;++i)s[i]=s[i-1]+t[i];
	for(qn=0,i=1;i<=n;++i)
	{
		while(qn&&cal(q[qn],q[qn-1])<=i)--qn;
		f[i]=max(f[i-1],1LL*i*(i+1)/2-s[i]+S[q[qn]]-1LL*i*q[qn]);
		S[i]=f[i]+1LL*i*(i-1)/2+s[i];
		while(qn&&cal(i,q[qn])>=cal(q[qn],q[qn-1]))--qn;
		q[++qn]=i;
	}
}
void rev(ll*a)
{
	for(int i=1;i<n-i+1;++i)swap(a[i],a[n-i+1]);
}
void solve(int l,int r)
{
	if(l>r)return;
	int mid=l+r>>1,i;
	for(qn=-1,i=l;i<=mid;q[++qn]=i++)
	{
		S[i]=lf[i-1]+1LL*i*(i-3)/2+s[i-1];
		while(qn>0&&cal(i,q[qn])>=cal(q[qn],q[qn-1]))--qn;
	}
	for(i=mid;i<=r;++i)
	{
		while(qn&&cal(q[qn],q[qn-1])<=i)--qn;
		S[i+1]=rf[i+1]+1LL*i*(i+3)/2-s[i]+S[q[qn]]-1LL*i*q[qn]+1;
	}
	for(i=r;i>=mid;--i)
	{
		if(i<r)S[i+1]=max(S[i+1],S[i+2]);
		ans[i]=max(ans[i],S[i+1]);
	}
	for(qn=-1,i=r;i>=mid;q[++qn]=i--)
	{
		S[i]=rf[i+1]+1LL*i*(i+3)/2-s[i];
		while(qn>0&&cal(i,q[qn])<=cal(q[qn],q[qn-1]))--qn;
	}
	for(i=mid;i>=l;--i)
	{
		while(qn&&cal(q[qn],q[qn-1])>=i)--qn;
		S[i-1]=lf[i-1]+1LL*i*(i-3)/2+s[i-1]+S[q[qn]]-1LL*i*q[qn]+1;
	}
	for(i=l;i<=mid;++i)
	{
		if(i>l)S[i-1]=max(S[i-1],S[i-2]);
		ans[i]=max(ans[i],S[i-1]);
	}
	solve(l,mid-1);solve(mid+1,r);
}
int main()
{
	int i,x;
	for(n=read(),i=1;i<=n;++i)t[i]=read();
	rev(t);cal(rf);rev(rf);rev(t);cal(lf);
	memset(ans,200,sizeof(ans));solve(1,n);
	for(n=read();n--;)i=read(),x=read(),printf("%lld\n",max(lf[i-1]+rf[i+1],ans[i]+t[i]-x));
}

Measured memory_bytes: 16512
#include<bits/stdc++.h>
#define ll long long 
#define pb push_back
#define ff first
#define ss second
#define setbits(x)          __builtin_popcountll(x)
#define lp(a,n) for(ll i=a; i<n; i++)
#define lpi(a,n) for(int i=a; i<n; i++)
#define w(t) int t; cin>>t; while(t--)
#define vi vector<int> 
#define vll vector<ll>
#define pll pair<ll, ll>
#define pii pair<int, int>
#define inf 1e9
#define LB lower_bound
#define UB upper_bound
const int mod = 1000000007;
using namespace std;
ll gcd(ll a,ll b){
    if(a==0)return b;
    return gcd(b%a,a);
}
ll lcm(ll a, ll b){
    return (a*b)/gcd(a,b);
}

int prime[100007];
void SieveOfEratosthenes(int n) 
{ 
    memset(prime, -1, sizeof(prime)); 
  
    for (int p=2; p*p<=n; p++) 
    { 
         
        if (prime[p] == -1) 
        { 
            for (int i=p*p; i<=n; i += p) 
                prime[i] = p; 
        } 
    } 
    
} 
int lps(string s){
    int len = 0;
    int n = s.length();
    int dp[n];
    dp[0] = 0;
    for(int i=1; i<n; i++){
        if(s[i] == s[len]){
            len++;
            dp[i] = len;
            continue;
        }
        if(len!=0){
            len = dp[len-1];
            i--;
            continue;
        }
        dp[i]=0;
    }
    return dp[n-1];
}
 
ll power(unsigned ll x,unsigned  ll y) 
{ 
    ll res = 1;     
    while (y > 0) 
    { 
        if (y & 1) 
            res = res*x; 
   
        y = y>>1;
        x = x*x;  
    } 
    return res; 
}

//to calculate p1^x  *  p2^x2  *p3^x3 ----------
//i.e. prime factorization and store pi and xi in vector 
vector<pair<ll, ll>> pFactor;

void factorize(long long n) 
{ 
    int count = 0; 
  
    // count the number of times 2 divides  
    while (!(n % 2)) { 
        n >>= 1; // equivalent to n=n/2; 
        count++; 
    } 
  
    // if 2 divides it 
    if (count) 
        pFactor.pb({2,count}); 
  
    // check for all the possible numbers that can  
    // divide it 
    for (long long i = 3; i <= sqrt(n); i += 2) { 
        count = 0; 
        while (n % i == 0) { 
            count++; 
            n = n / i; 
        } 
        if (count) 
            pFactor.pb({i,count});
    } 
  
    // if n at the end is a prime number. 
    if (n > 2) 
        pFactor.pb({n,1}); 
} 



int main(){
ios_base::sync_with_stdio(false);
cin.tie(NULL);
   ll n, k;
   cin>>n>>k;
   ll a[n];
   lp(0,n) cin>>a[i];
   int j=0;
   lp(k, n){
       if(a[i]>a[j]){
           cout<<"Yes\n";
       }else cout<<"No\n";
       j++;
   }
}

Measured memory_bytes: 5256
import java.io.PrintWriter;
import java.util.*;

public class Main {
    public static void main(String[] args) {
        PrintWriter out = new PrintWriter(System.out);
        Scanner sc = new Scanner(System.in);
        Task task = new Task();
        task.solve(sc, out);
        out.flush();
        sc.close();
    }

    static class Task {
        void solve(Scanner sc, PrintWriter out) {
            int N = nint(sc);
            List<Integer> aList = getIntegerList(sc, N);
            int ans = 0;
            for (int i = 0; i < N; i++) {
                int a = aList.get(i);
                int b = aList.get(a - 1);
                if (b - 1 == i) {
                    ans++;
                }
            }
            out.println(ans/2);
        }
    }

    static int nint(Scanner sc) {
        return Integer.parseInt(sc.next());
    }

    static long nlong(Scanner sc) {
        return Long.parseLong(sc.next());
    }

    static double ndouble(Scanner sc) {
        return Double.parseDouble(sc.next());
    }

    static float nfloat(Scanner sc) {
        return Float.parseFloat(sc.next());
    }

    static String nstr(Scanner sc) {
        return String.valueOf(sc.next());
    }

    static long[] longLine(Scanner sc, int size) {
        long[] lLine = new long[size];
        for (int i = 0; i < size; i++) {
            lLine[i] = nlong(sc);
        }
        return lLine;
    }

    static int[] intLine(Scanner sc, int size) {
        int[] iLine = new int[size];
        for (int i = 0; i < size; i++) {
            iLine[i] = nint(sc);
        }
        return iLine;
    }

    static String[] strLine(Scanner sc, int size) {
        String[] strLine = new String[size];
        for (int i = 0; i < size; i++) {
            strLine[i] = nstr(sc);
        }
        return strLine;
    }

    static long maxFromList(List<Long> longList) {
        return longList.stream().max(Comparator.naturalOrder()).get();
    }

    static long minFromList(List<Long> longList) {
        return longList.stream().min(Comparator.naturalOrder()).get();
    }

    public static int sumDigits(int n) {
        int sum = 0;
        while (n != 0) {
            sum += n % 10;
            n /= 10;
        }
        return sum;
    }

    public static long sumDigits(long n) {
        long sum = 0;
        while (n != 0) {
            sum += n % 10;
            n /= 10;
        }
        return sum;
    }

    static List<Integer> getIntegerList(Scanner sc, int size) {
        List<Integer> list = new ArrayList<>();
        for (int i = 0; i < size; i++) {
            list.add(nint(sc));
        }
        return list;
    }

    static List<Long> getLongList(Scanner sc, int size) {
        List<Long> list = new ArrayList<>();
        for (int i = 0; i < size; i++) {
            list.add(nlong(sc));
        }
        return list;
    }
}


Measured memory_bytes: 49104
#include <bits/stdc++.h>
using namespace std;
using pint = pair<int, int>;
using ll = long long;
using pll = pair<ll, ll>;
#define FOR(i, begin, end) for (int i = (begin), i##_end_ = (end); i < i##_end_; i++)
#define IFOR(i, begin, end) for (int i = (end)-1, i##_begin_ = (begin); i >= i##_begin_;i--)
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
#define FI first
#define SE second
#define endl "\n"
#define ciosup cin.tie(0);ios::sync_with_stdio(false);
#define eb emplace_back
constexpr ll INF = 1e9 + 7;
constexpr ll MOD = 1e9 + 7;

int main()
{
    ciosup;
    ll m, k;
    cin >> m >> k;
    if (k < pow(2,m)){
    if (m == 0){
        if (k == 0){
            cout << 0 << " " << 0 << endl;
        }else{
            cout << -1 << endl;
        }
    }else if (m == 1){
        if (k == 0){
            cout << 0 << " " << 0 << " " << 1 << " " << 1 << endl;
        }
        else
        {
            cout << -1 << endl;
        }
    }else
    {
        REP(i, pow(2, m))
        {
            if (i != k){
                cout << i << " ";
            }
        }
        cout << k << " ";
        IREP(i,pow(2,m))
        {
            if (i != k)
            {
                cout << i << " ";
            }
        }
        cout << k;
    }
    }else{
        cout << -1 << endl;
    }
}

Measured memory_bytes: 1792
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cctype>
#include <set>
#include <map>
#include <cmath>
#include <queue>
#include <stack>
#include <iomanip>
#include <cstdio>
#include <numeric>
#include <functional>
int main() {
	int n, k;
	std::cin >> n >> k;
	std::vector<int> l(n);
	int sum = 0;
	for (int i = 0;i < n;++i) {
		std::cin >> l[i];
	}
	std::sort(l.begin(), l.end(), std::greater<>());
	int L = l[k];
	for (int j = 0;j < n;++j) {
		if (l[j] > L) {
			sum += l[j];
		}
		else {
			sum += 0;
		}
	}
	std::cout << sum << std::endl;
	return 0;
}

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

int main(){
    string S;
    cin >> S;
    int N = S.size();
    ll ans = 0;
    int r = -1;
    for (int i = 0; i < N; i++) {
        if (S[i] == 'W') r = i;
    }
    if (r == -1) {
        cout << 0 << endl;
        return 0;
    }
    int t = r;
    for (int i = 0; i < N; i++) {
        
        if (i > r) break;
        if (S[i] == 'B') {
            ans += t-i;
            t--;
        }
            
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 640
s = input().rstrip()

ans = 'WA'
if s[0] == 'A' and s[2:len(s) - 1].count('C') == 1:
    i = s[2:len(s) - 1].find('C')
    if s[1:i + 2].islower() and s[i + 2 + 1:].islower():
        ans = 'AC'
print(ans)


Measured memory_bytes: 3060
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#define ms(a,b) memset(a,b,sizeof(a))
using namespace std;
typedef long long ll;
const int maxn = 100 + 5;

struct node{
    int x, y, h;
}a[maxn];
bool cmp(node a, node b){
    return a.h > b.h;
}
int n;

int main(){
    scanf("%d", &n); 
    for (int i = 0; i < n; i++) scanf("%d%d%d", &a[i].x, &a[i].y, &a[i].h);
    sort(a, a + n, cmp);
    for (int i = 0; i <= 100; i++) for (int j = 0; j <= 100; j++){
        int h = a[0].h + abs(i - a[0].x) + abs(j - a[0].y);
        int flag = 1;
        for (int k = 1; k < n; k++){
            int t = max(0, h - abs(i - a[k].x) - abs(j - a[k].y));
            if (t != a[k].h){
                flag = 0; break;
            }
        }
        if (flag){
            printf("%d %d %d", i, j, h); return 0;
        }
    }
    return 0;
}

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

using namespace std;

int TwoCount = 0;
int FourCount = 0;
int AnyCount = 0;

bool Solve()
{
	if ((FourCount >= AnyCount - 1) && FourCount > 0)
		return true;

	if (AnyCount == 0 && FourCount == 0 && TwoCount > 1)
		return true;

	return false;
}

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

	int a;
	for (int i = 0; i < N; i++)
	{
		cin >> a;
		if (a % 4 == 0)
			FourCount++;
		else if (a % 2 == 0)
			TwoCount++;
		else
			AnyCount++;
	}

	if (TwoCount > 0 && AnyCount != 0)
		AnyCount++;

	if (Solve())
	{
		cout << "Yes" << endl;
	}
	else
		cout << "No" << endl;

	return 0;
}


Measured memory_bytes: 256
//
// Created by Myabu on 2020/01/25.
//

#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <map>
#include <utility>
#include <math.h>
#include <stack>
#include <queue>
#include <cstdio>
#include <numeric>
#include <iomanip>

using namespace std;


int main(void){
    int X,Y;

    cin>>X>>Y;

    cout<<X+Y/2<<endl;


    return 0;
}

Measured memory_bytes: 256
void main()
{
    dchar[] s = rdDchar;
    dchar[] t = rdDchar;

    LCS!dchar(s, t).writeln;
}

T[] LCS(T)(T[] x, T[] y)
{
    T[] result;
    long xlen = x.length, ylen = y.length;
    long[][] dp = new long[][](xlen+1, ylen+1);
    foreach (i, u; x)
    {
        foreach (j, v; y)
        {
            if (u == v) dp[i+1][j+1] = dp[i][j] + 1;
            else dp[i+1][j+1] = max(dp[i][j+1], dp[i+1][j]);
        }
    }

    for (long i = xlen, j = ylen; i && j; )
    {
        if (x[i-1] == y[j-1])
        {
            result ~= x[i-1];
            --i, --j;
        }
        else
        {
            if (dp[i][j-1] < dp[i-1][j]) --i;
            else --j;
        }
    }

    reverse(result);

    return result;
}

enum long mod = 10^^9 + 7;
enum long inf = 1L << 60;
enum double eps = 1.0e-9;

T rdElem(T = long)()
if (!is(T == struct))
{
    return readln.chomp.to!T;
}

alias rdStr = rdElem!string;
alias rdDchar = rdElem!(dchar[]);

T rdElem(T)()
if (is(T == struct))
{
    T result;
    string[] input = rdRow!string;
    assert(T.tupleof.length == input.length);
    foreach (i, ref x; result.tupleof)
    {
        x = input[i].to!(typeof(x));
    }
    return result;
}

T[] rdRow(T = long)()
{
    return readln.split.to!(T[]);
}

T[] rdCol(T = long)(long col)
{
    return iota(col).map!(x => rdElem!T).array;
}

T[][] rdMat(T = long)(long col)
{
    return iota(col).map!(x => rdRow!T).array;
}

void rdVals(T...)(ref T data)
{
    string[] input = rdRow!string;
    assert(data.length == input.length);
    foreach (i, ref x; data)
    {
        x = input[i].to!(typeof(x));
    }
}

void wrMat(T = long)(T[][] mat)
{
    foreach (row; mat)
    {
        foreach (j, compo; row)
        {
            compo.write;
            if (j == row.length - 1) writeln;
            else " ".write;
        }
    }
}

import std.stdio;
import std.string;
import std.array;
import std.conv;
import std.algorithm;
import std.range;
import std.math;
import std.numeric;
import std.mathspecial;
import std.traits;
import std.container;
import std.functional;
import std.typecons;
import std.ascii;
import std.uni;
import core.bitop;

Measured memory_bytes: 74364
#include <iostream>
    #include <cstdio>
    #include <cstring>
    #include <string>
    #include <algorithm>
    using namespace std;
    int main()
    {
        int a,b,c,d;
        scanf("%d%d%d%d",&a,&b,&c,&d);
        printf("%d\n",min(a,b)+min(c,d));
        return 0;
    }


Measured memory_bytes: 256
/*	Author
@ Pranjal Walia
IIIT Bangalore
*/
#include<bits/stdc++.h>
using namespace std;

void fastscan(int &x){
bool neg = false;register int c;
x = 0;c = getchar();
if(c=='-'){neg = true;c = getchar();}
for(; (c>47 && c<58); c=getchar()){x = x *10 + c - 48;}
if(neg){x *= -1;}}

#define ff              				first
#define ss              				second
#define int             				long long
#define pb              				push_back
#define mp              				make_pair
#define pii             				pair<int,int>
#define vi              				vector<int>
#define mii             				map<int,int>
#define pqb             				priority_queue<int>
#define pqs             				priority_queue<int,vi,greater<int> >
#define setbits(x)      				__builtin_popcountll(x)
#define zrobits(x)      				__builtin_ctzll(x)
#define mod             				1000000007
#define inf             				1e18
#define mem(a,x,n)					memset(a,x,sizeof(a))		//initialise only 0 ans -1 with memset
#define ps(x,y)         				fixed<<setprecision(y)<<x
#define mk(arr,n,type)  				type *arr=new type[n];
#define w(x)            				int x; cin>>x; while(x--)
#define sortv(v)        				sort(v.begin() , v.end())
#define rsortv(v)       				sort(v.rbegin() , v.rend())
#define pw(b,p)         				pow(b,p) + 0.1
#define __          	   				ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define FOR(i,a,b)	   					for(int i=a;i<b;i++)
#define repb(i,a,b) 	   				for(int i=a;i>=b;i--)
#define endl			   				"\n"    

#define tr(x) cout<<x<<endl;
#define tr2(x,y) cout<<x<<" "<<y<<endl;
#define tr3(x,y,z) cout<<x<<" "<<y<<" "<<z<<endl;
#define tr4(w,x,y,z) cout<<w<<" "<<x<<" "<<y<<" "<<z<<endl;
#define tr5(v,w,x,y,z) cout<<v<<" "<<w<<" "<<x<<" "<<y<<" "<<z<<endl;
#define tr6(u,v,w,x,y,z) cout<<u<<" "<<v<<" "<<w<<" "<<x<<" "<<y<<" "<<z<<endl;

#define sd(x) cin >> x;
#define sd2(x,y) cin >> x >> y;
#define sd3(x,y,z) cin >> x >> y >> z;
#define sd4(w,x,y,z) cin >> w >> x >> y >> z;

int mypow(int a, int b){	//(logn) --> faster than recursive --> binary expo
    int res = 1;            // call int x = mypow(2,5);
    while (b > 0) {
        if (b & 1)
            res = res * a;
        a = a * a;
        b >>= 1;
    }
}

void file(){
    #ifndef ONLINE_JUDGE
    freopen("input.txt" , "r" , stdin);
    freopen("output.txt" , "w" , stdout);
    #endif
}

int32_t main(){
    __;	
    int n,w; sd2(n,w);
    int wt[n];
    int val[n];
    FOR(i ,0 , n) sd2(wt[i] , val[i]);
    int dp[n+1][w+1];

    for(int i=0 ; i<=n ; i++) dp[i][0]=0;
    for(int i=0 ; i<=w ; i++) dp[0][i]=0;

    for(int i=1 ; i<=n ; i++){
        for(int j=1 ; j<= w ; j++){
            if(wt[i-1] <= j){
                dp[i][j] = max(val[i-1] + dp[i-1][j-wt[i-1]] , dp[i-1][j]);
            }
            else{
                dp[i][j] = dp[i-1][j];
            }
        }
    }
    tr(dp[n][w]);

    return 0;
}

Measured memory_bytes: 79104
using System;
using System.Linq;

namespace C_sharp
{
    class Program
    {
        static void Main(string[] args)
        {
            var line = Console.ReadLine()
                .Split()
                .Select(x => int.Parse(x))
                .ToArray();

            var W = line[0];
            var H = line[1];
            var a = line[2];
            var b = line[3];
            var r = line[4];

            if (a - r >= 0 && a + r <= W && b - r >= 0 && b + r <= H)
            {
                Console.WriteLine("Yes");
            }
            else
            {
                Console.WriteLine("No");
            }
        }
    }
}



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

int main() {
	// your code goes here
	int n,i,j,s=0;
	long long x[105],y[105];
	pair<long long,long long> dif[3000];
	cin >> n;
	if(n==1){
		cout << "1" << endl;
		return 0;
	}
	for(i=1;i<=n;i++) cin >> x[i] >> y[i];
	for(i=1;i<n;i++){
		for(j=i+1;j<=n;j++){
			long long a,b;
			a=x[j]-x[i];
			b=y[j]-y[i];
			if(a<=0){
				a=-a;
				b=-b;
			}
			if(a==0&&b<0) b=-b;
			dif[s]=make_pair(a,b);
			s++;
		}
	}
	sort(dif,dif+s);
	long long flag=1,max=1;
	for(i=1;i<s;i++){
		if(dif[i].first==dif[i-1].first&&dif[i].second==dif[i-1].second){
			flag++;
			if(max<flag) max=flag;
		} else {
			flag=1;
		}
	}
	cout << n-max << endl;
	return 0;
}


Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10**7)
def input():
    return sys.stdin.readline()[:-1]

def main():
    n, q = map(int, input().split())
    g = [[] for _ in range(n)]
    for _ in range(n-1):
        a, b = map(lambda x: int(x)-1, input().split())
        g[a].append(b); g[b].append(a)
    node = [0]*n
    for i in range(q):
        p, x = map(int, input().split())
        p -= 1
        node[p] += x

    def dfs(v, p=-1):
        for u in g[v]:
            if u==p:
                continue
            node[u] += node[v]
            dfs(u, v)
    dfs(0)
    print(*node)

if __name__ == "__main__":
    main()


Measured memory_bytes: 268464
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<cmath>
#include<algorithm>
#include<cstdlib>
#include<utility>
#include<map>
#include<stack>
#include<set>
#include<vector>
#include<queue>
#include<deque>
#include<sstream>
#include<bitset>
#include<bits/stdc++.h>
using namespace std;
int main()
{
	string a[5];
	for (int i=0;i<3;i++)
	{
		cin>>a[i];
	 } 
	 cout<<a[0][0]<<a[1][1]<<a[2][2];
	return 0;
}

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


string s;
string t;

int main() {
	cin >> s;
	cin >> t;

	int l = (int)s.size();

	bool b = false;
	for( int i = 0; i < l; i++ ) {
		if( s == t ) {
			b = true;
			break;
		}
		s = s[l-1] + s;
		s.pop_back();
	}

	if( b == true ) {
		cout << "Yes" << "\n";
	}
	else {
		cout << "No" << "\n";
	}
 
	return 0;
}


Measured memory_bytes: 384
package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
	"strconv"
	"strings"
)

/*-----------Main-----------*/

func main() {
	s := readS()
	t := readS()
	if strings.HasPrefix(t, s) && len(t) == len(s)+1 {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
}

/*-----------Utilities-----------*/

var sc = bufio.NewScanner(os.Stdin)

func init() {
	if len(os.Args) >= 2 {
		if os.Args[1] == "debug" {
			debug()
		}
	}
	const maxBuf = 200100
	var buf []byte = make([]byte, maxBuf)
	sc.Split(bufio.ScanWords)
	sc.Buffer(buf, maxBuf)
}

func debug() {
	testFile, err := os.Open("./test/sample-1.in")
	if err != nil {
		fmt.Fprintln(os.Stderr, "Error : There is no testfile.")
		os.Exit(1)
	}
	sc = bufio.NewScanner(testFile)
}

func readS() string {
	sc.Scan()
	return sc.Text()
}

func readSs(a int) []string {
	b := make([]string, a)
	for i := 0; i < a; i++ {
		b[i] = readS()
	}
	return b
}

func readI() int {
	sc.Scan()
	r, _ := strconv.Atoi(sc.Text())
	return r
}

func readIs(a int) []int {
	b := make([]int, a)
	for i := 0; i < a; i++ {
		b[i] = readI()
	}
	return b
}

func readF() float64 {
	sc.Scan()
	r, _ := strconv.ParseFloat(sc.Text(), 64)
	return r
}

func readFs(a int) []float64 {
	b := make([]float64, a)
	for i := 0; i < a; i++ {
		b[i] = readF()
	}
	return b
}

func max(a []int) int {
	l := len(a)
	m := a[0]
	for i := 1; i < l; i++ {
		if a[i] > m {
			m = a[i]
		}
	}
	return m
}

func min(a []int) int {
	l := len(a)
	m := a[0]
	for i := 1; i < l; i++ {
		if a[i] < m {
			m = a[i]
		}
	}
	return m
}

func sortI(a []int) []int {
	sort.Ints(a)
	return a
}

func reverse(a []int) []int {
	l := len(a)
	r := make([]int, l)
	for i := 0; i < l; i++ {
		r[i] = a[l-i-1]
	}
	return r
}

func countI(a []int, b int) int {
	l := len(a)
	var c int
	for i := 0; i < l; i++ {
		if a[i] == b {
			c++
		}
	}
	return c
}


Measured memory_bytes: 1780
#include<bits/stdc++.h>
#include <fstream>
#define input "frog1.inp"
#define output "frog1.out"
int n,a[100005],f[100005];
using namespace std;
int main()
{
 	ios_base::sync_with_stdio(false);
	cin.tie(0);cout.tie(0);
	//freopen(input,"r",stdin);
	//freopen(output,"w",stdout);
	cin>>n;
    for(int i=1;i<=n;i++) cin>>a[i];
    f[1]=0;
    f[2]=abs(a[1]-a[2]);
    for (int i=3;i<=n;i++) f[i]=min(abs(a[i-2]-a[i])+f[i-2],abs(a[i-1]-a[i])+f[i-1]);
    cout<<f[n];
}


Measured memory_bytes: 1024
N, K = map(int, input().split())
MOD = 998244353
D = []
for _ in range(K):
    l, r = map(int, input().split())
    D.append((l,r))
imos = [0]*(N+2)
dp = [0]*(N+1)
imos[0]=1
imos[1]=-1
for i in range(N):
    dp[i] = dp[i-1] + imos[i]
    dp[i] %= MOD
    for a, b in D:
        imos[min(i+a,N+1)] += dp[i]
        imos[min(i+b+1,N+1)] -= dp[i]

print(dp[N-1])

Measured memory_bytes: 85264
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int A = sc.nextInt();
    int B = sc.nextInt();
    int X = sc.nextInt();
    if(A <= X && (A+B) >= X){
      System.out.println("YES");
    }else{
      System.out.println("NO");
    }
  }
}


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

int main()
{
  int N;
  cin >> N;
  
  bool flag = false;
  rep(i, 3)
  {
    int amari = N % 10;
    
    if (7 == amari)
    {
      flag = true;
      break;
    }
    
    N /= 10;
  }
  
  if (flag)
  {
    printf("Yes");
  }
  else
  {
    printf("No");
  }

  return 0;
}

Measured memory_bytes: 3628
/* monkukui 競技プログラミング用のテンプレート  (ここから) */
#include <iostream>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <functional>
#include <bitset>

using namespace std;
using lint = long long int;
using ll = long long int;
using lnt = long long int;
using graph = vector<vector<int>>;
using wgraph = vector<vector<pair<int, long long int>>>;
long long int INF = 1001001001001001LL;
int inf = 100100100;
long long int MOD = 1000000007LL;
double PI = 3.1415926535897932;
long long int di[] = {-1, 0, 1, 0, -1, 1, 1, -1};
long long int dj[] = {0, 1, 0, -1, 1, 1, -1, -1};

template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}
inline void yes(){ cout << "yes" << endl; }
inline void Yes(){ cout << "Yes" << endl; }
inline void YES(){ cout << "YES" << endl; }
inline void no(){ cout << "no" << endl; }
inline void No(){ cout << "No" << endl; }
inline void NO(){ cout << "NO" << endl; }
inline void possible(){ cout << "possible" << endl; }
inline void Possible(){ cout << "Possible" << endl; }
inline void POSSIBLE(){ cout << "POSSIBLE" << endl; }
inline void impossible(){ cout << "impossible" << endl; }
inline void Impossible(){ cout << "Impossible" << endl; }
inline void IMPOSSIBLE(){ cout << "IMPOSSIBLE" << endl; }

#define rep(i,n) for(int i = 0; i < (n); i++)
#define rrep(i,n) for(int i = 1; i <= (n); i++)
#define drep(i,n) for(int i = (n)-1; i >= 0; i--)
#define srep(i,s,t) for(int i = s; i < t; i++)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define pb push_back

/* monkukui 競技プログラミング用のテンプレート (ここまで)*/


// z-algo
struct ZAlgo {
  vector<int> a;
  ZAlgo(){}
  ZAlgo(const string &s) {
    a.resize(s.size());
    a[0] = s.size();
    int i = 1, j = 0;
    while (i < s.size()) {
      while (i+j < s.size() && s[j] == s[i+j]) ++j;
      a[i] = j;
      if (j == 0) { ++i; continue;}
      int k = 1;
      while (i+k < s.size() && k+a[k] < j) a[i+k] = a[k], ++k;
      i += k; j -= k;
    }
  }
  int & operator [](int n) {return a[n];}
  int size() {return a.size();}
};

int main(){
  
  int n; cin >> n;
  string s; cin >> s;
  int ans = 0;
  for (int i = 0; i < n; i++) {
    string t = s.substr(i);
    ZAlgo za(t);
    for(int j = 0; j < za.size(); j++) {
      int tmp = min(j, za[j]);
      ans = max(ans, tmp);
    }
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int tail,i,l,ans[15];
string f;
int main()
{
	cin>>f;
	l=f.size();
	for(i=0;i<l;i++)
	{
		if(f[i]=='0')ans[tail++]=0;
		if(f[i]=='1')ans[tail++]=1;
		if(f[i]=='B')
		{
			if(tail!=0)tail--;
		}
	}
	for(i=0;i<tail;i++)cout<<ans[i];
	cout<<endl;
	return 0;
 } 

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

int main()
{
  ios::sync_with_stdio(false);  cin.tie(0); cout.tie(0);
  int n,k;
  cin>>n>>k;
  int in[n],dp[n];
  rep(i,n){
    cin>>in[i];
    dp[i] = INF;
  }
  dp[0] = 0;
  for(int i = 0;i < n;i++){
    for(int j = 1;j <= k; j++){
      if(i+j < n)
        dp[i+j] = min(dp[i+j], dp[i] + abs(in[i+j] - in[i]));
    }
  }
  cout << dp[n-1] << endl;
}
  

Measured memory_bytes: 1024
#include<cstdio>
#include<cstring>
#include<string>
#include<iostream>
#include<vector>
#include<utility>
#include<algorithm>
#include<set>
#include<queue>
#include<map>
#include<cmath>
#define ll long long
#define mp make_pair
#define pii pair<int,int>
#define fi first
#define se second
#define inf 0x7fffffff
#define llinf 0x7fffffffffffffffll
using namespace std;
int a[3][1000],dp[3][110];
int main()
{
	int i,j,k,n,m;
	scanf("%d",&n);
	for(i=0;i<2;i++)
	{
		for(j=0;j<n;j++)
		{
			scanf("%d",&a[i][j]);
		}
	}
	dp[0][0]=a[0][0];
	for(j=1;j<n;j++)
	{
		dp[0][j]=dp[0][j-1]+a[0][j];
	}
	dp[1][0]=dp[0][0]+a[1][0];
	for(j=1;j<n;j++)
	{
		dp[1][j]=max(dp[0][j],dp[1][j-1])+a[1][j];
	}
	printf("%d",dp[1][n-1]);
	return 0;
}

Measured memory_bytes: 256
// finish date: 2018/01/24
#include <iostream>
#include <cmath>
#include <vector>
#include <bitset>
#include <algorithm>
#include <stack>
#include <map>
#include <climits>

using namespace std;

#define FOR(i, a, b) for(int (i)=a;(i)<(b);(i)++)
#define rep(i, n)  FOR(i,0,n)
#define ll long long
#define vi vector<int>
#define vvi vector<vector<int>>
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define bigmod 1000000007
#define INF 500000000


int main() {
    string S, T;
    cin >> S >> T;
    for (int i = (int)S.length() - (int)T.length(); i >= 0; i--) {
        rep(j, T.length()) {
            if (!(S[i + j] == T[j] || S[i + j] == '?')) break;
            if (j == T.length() - 1) {
                rep(k, S.length()) {
                    if (S[k] == '?') {
                        if (k < i || k>=i+T.length()) S[k] = 'a';
                        else S[k] = T[k - i];
                    }
                }
                cout << S << endl;
                return 0;
            }
        }
    }
    cout << "UNRESTORABLE" << endl;


    return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <string.h>
#include <algorithm>
#include <array>
#include <vector>
#include <cmath>
#include <set>

using namespace std;

int main( void ) {

    int N;
    cin >> N;

    int d[N];

    for ( int i = 0; i < N; i++ ) cin >> d[i];

    int res = 0;
    for ( int i = 0; i < N - 1; i++ ) {
        for ( int j = i + 1; j < N; j++ ) {
            res += d[i] * d[j];
        }
    }

    cout << res << endl;

    return 0;
}

Measured memory_bytes: 256
h,w = map(int,input().split())
fi = [input() for _ in range(h)]
row = [False]*h
col = [False]*w
for i in range(h):
    for j in range(w):
        if fi[i][j]=='#':
            row[i]=True
            col[j]=True
for i in range(h):
    if row[i]:
        for j in range(w):
            if col[j]:
                print(fi[i][j],end='')
        print()

Measured memory_bytes: 4468
import math


def main():
    N = int(input())

    count = 0
    sqr = int(math.sqrt(N-1))
    for a in range(1, sqr+1):
        count += (len([m+1 for m in range((N-1)//a) if m+1 >= a]) - 1) * 2 + 1
    print(count)

main()


Measured memory_bytes: 213876
#include<iostream>
#include<string>
#include<string.h>
#include<algorithm>
#include<stdio.h>
#include<cmath>
#include<vector>
#include<utility>
#include<stack>
#include<queue>
#include<list>
#include<bitset>
#include<functional>

#define FOR(i, a, b) for(int i=(a);i<=(b);i++)
#define RFOR(i, a, b) for(int i=(a);i>=(b);i--)
#define MOD 1000000007
#define INF 1000000000

using namespace std;

int main(void) {
	string s;
	int k;

	cin >> s >> k;

	FOR(i, 0, s.size() - 1) {
		if (s[i] == 'a') {
			continue;
		}
		else if ('z' - s[i] + 1 <= k) {
			k -= 'z' - s[i] + 1;
			s[i] = 'a';
		}
		else {
			continue;
		}
	}
	if (k % 26==0&&k!=0) {
		s[s.size() - 1] = 'a';
	}
	else {
		s[s.size() - 1] += k%26;
	}
	
	/*RFOR(i, s.size()-1, 0) {
		if (s[i] == 'a') {
			continue;
		}
		else {
			s[i] += k;
			break;
		}
	}*/
	cout << s << endl;
	return 0;
}

Measured memory_bytes: 512