akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;

#define DEBUG(x) cout<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cout<<#v<<":";for(int i=0;i<v.size();i++) cout<<" "<<v[i]; cout<<endl

typedef long long ll;
#define vi vector<int>
#define vl vector<ll>
#define vii vector< vector<int> >
#define vll vector< vector<ll> >
#define vs vector<string>
#define pii pair<int,int>
#define pis pair<int,string>
#define psi pair<string,int>
const int inf=1000000001;
const ll INF=1e16;
#define MOD 1000000007
#define mod 1000000009
#define pi 3.14159265358979323846
#define Sp(p) cout<<setprecision(15)<<fixed<<p<<endl;
int dx[4]={1,0,-1,0}, dy[4]={0,1,0,-1};

int main() {
	int n, i;
	cin >> n;
	i = 0;
	while (n != 1) {
		n /= 2;
		i++;
	}
	cout << pow(2, i) << endl;
}


Measured memory_bytes: 384
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <stdio.h>
#include <sstream>
#include <math.h>
#include <queue>
#include <map>
#include <set>
#include <ios>     // std::left, std::right
#include <iomanip> // std::setw(int), std::setfill(char)
using namespace std;


int main(){
int N;
cin>>N;
cout<<180*(N-2)<<"\n";
return 0;
}


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

const int lim = 10e5 + 5;
const int INF = 10e9 + 5;

void minSelf(int &a, int b) {
	a = min(a,b);
	return;
}

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

	int h[lim];
	int dp[lim]={0};

	for (i=0;i<n;i++) {
		cin>>h[i];
		dp[i] = INF;
	}

	dp[0]=0;

	int j;
	for (i=0;i<n;i++) {

		for (j=1;j<=k;j++) {
			if (i+j<n) minSelf(dp[i+j], dp[i]+abs(h[i+j]-h[i]));
		}
	}
	cout<<dp[n-1]<<"\n";

	return 0;
}

Measured memory_bytes: 8064
// inputに入力データ全体が入る
function Main(input) {
	// 1行目がinput[0], 2行目がinput[1], …に入る
  inputs = input.split("\n");

  const N = Number(inputs[0]);


  console.log(N*2*Math.PI);
}
//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));



Measured memory_bytes: 29620
#include<bits/stdc++.h>
using namespace std;
int main()
{   int n,k;
    cin>>n>>k;
    vector<int> v(n+1);
    for(int i=1;i<=n;i++)
    cin>>v[i];
    int dp[n+1];
    for(int i=0;i<=n;i++)
    dp[i]=INT_MAX;
    dp[1]=0;
    for(int i=1;i<n;i++)
    {   for(int j=i+1;j<=min(i+k,n);j++)
        dp[j]=min(dp[j],dp[i]+abs(v[j]-v[i]));
    }
    cout<<dp[n];
}

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

signed main() {
  int n; cin >> n;
  bool ans = false;

  for(int i = 0; i < n; i++) {
    char c; cin >> c;
    if(c == 'Y') ans = true;
  }

  cout << (ans ? "Four" : "Three") << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vb=vector<bool>;
using vvb=vector<vb>;
using vd=vector<double>;
using vvd=vector<vd>;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using pll=pair<ll,ll>;
using tll=tuple<ll,ll>;
using tlll=tuple<ll,ll,ll>;
using vs=vector<string>;
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rep(i,n) range(i,0,n)
#define rrep(i,n) for(ll i=(n)-1;i>=0;i--)
#define range(i,a,n) for(ll i=(a);i<(n);i++)
#define LINF ((ll)1ll<<60)
#define INF ((int)1<<30)
#define EPS (1e-9)
#define MOD (1000000007ll)
#define fcout(a) cout<<setprecision(a)<<fixed
#define fs first
#define sc second
#define PI (3.1415926535897932384)

int dx[]={1,0,-1,0,1,-1,-1,1},dy[]={0,1,0,-1,1,1,-1,-1};
template<class T>bool chmax(T&a,T b){if(a<b){a=b; return true;}return false;}
template<class T>bool chmin(T&a,T b){if(a>b){a=b; return true;}return false;}
template<class S>S sum(vector<S>&a){return accumulate(all(a),S());}
template<class S>S max(vector<S>&a){return *max_element(all(a));}
template<class S>S min(vector<S>&a){return *min_element(all(a));}
ll max(int a,ll b){return max((ll)a,b);} ll max(ll a,int b){return max(a,(ll)b);}
int sgn(const double&r){return (r>EPS)-(r<-EPS);} // a>0  : sgn(a)>0
int sgn(const double&a,const double&b){return sgn(a-b);} // b<=c : sgn(b,c)<=0

template<class T>void puta(T&&t){cout<<t<<"\n";}
template<class H,class...T>void puta(H&&h,T&&...t){cout<<h<<' ';puta(t...);}
template<class S,class T>void tf(bool b,S t,T f){if(b)puta(t);else puta(f);}
void YN(bool b){tf(b,"YES","NO");}
void Yn(bool b){tf(b,"Yes","No");}
void yn(bool b){tf(b,"yes","no");}
template<class S,class T>ostream&operator<<(ostream&os,pair<S,T>p){os<<"["<<p.first<<", "<<p.second<<"]";return os;};
template<class S>auto&operator<<(ostream&os,vector<S>t){bool a=1;for(auto s:t){os<<(a?"":" ")<<s;a=0;}return os;}
template<class S>auto&operator>>(istream&is,vector<S>&t){for(S&a:t)cin>>a;return is;}

/*他のライブラリを入れる場所*/


int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n,t;
    cin>>n>>t;
    vector<pll> p(n);
    rep(i,n){
        cin>>p[i].fs>>p[i].sc;
    }
    sort(all(p));
    // puta(p);
    vvl dp(n+1,vl(t,0));//t未満
    vl use(n+1,0);
    rrep(i,n)use[i]=max(use[i+1],p[i].sc);
    // puta(use);
    ll ans=0;
    rep(i,n){
        rep(j,t){
            chmax(dp[i+1][j],dp[i][j]);
            if(j+p[i].fs<t)chmax(dp[i+1][j+p[i].fs],dp[i][j]+p[i].sc);
        }
        chmax(ans,max(dp[i+1])+use[i+1]);
    }
    puta(ans);
    return 0;
}

Measured memory_bytes: 70784
#include <algorithm>
#include<iostream>
#include<vector>
#include<map>
#include<set>
#include<string>

#include<stdlib.h>
#include<string.h>
#include<math.h>
#include<limits.h>
using lll = long long;
using ull = unsigned long long;
using namespace std;



int main(){
  lll ii,jj,kk,cnt,pos,alpha;
  string s,t;
  string buf;
  lll ans = -1;
  
  cin >> s >> t;

  lll next[26][s.size()*2];
  lll prevPos[26],tmp;
  lll snum[26],tnum[26];
  memset(next,-1,sizeof(next));

  memset(prevPos,0,sizeof(prevPos));

  memset(snum,-1,sizeof(snum));
  memset(tnum,-1,sizeof(tnum));
  
  for(ii=0;ii<s.size();ii++){
    alpha = s[ii] - 'a';
    snum[alpha] += 1;
  }

  for(ii=0;ii<t.size();ii++){
    alpha = t[ii] - 'a';
    tnum[alpha] += 1;
  }

  for(ii=0;ii<26;ii++){
    if(tnum[ii] >= 0 && snum[ii] == -1){
      goto end;
    }
  }
  buf = s+s;
  
  for(ii=0;ii<buf.size();ii++){
    alpha = buf[ii] - 'a';
    tmp = prevPos[alpha];
    cnt =0;

    for(jj=ii;jj>=tmp;jj--){
      next[alpha][jj] = cnt;
      cnt++;
    }
    prevPos[alpha] = ii+1;
  }
  

  
  //for(ii=0;ii<s.size();ii++){
  //  for(jj=0;jj<26;jj++){
  //    printf("%02d ",next[jj][ii]);
  //  }
  //  cout << endl;
  //}
  pos = 0;
  ans = 0;
  for(ii=0;ii<t.size();ii++){
    alpha = t[ii] - 'a';
    ans += next[alpha][pos ] + 1;
    tmp = next[alpha][pos];
    pos = (pos+tmp+1) % s.size();
    //cout << "pos:" << pos << endl;
  }
  
 end:
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 41344
using System;
using System.Collections.Generic;
class Program
{
	static void Main(string[] args)
	{
		string s = Console.ReadLine();
      long mod = 1000000007;
      long[,]E = new long[s.Length,13];
		if(s.Substring(s.Length-1,1)=="?"){
			for(var i=0;i<=9;i++){
				E[s.Length-1,i]=1;
            }
		} else {
			E[s.Length-1,int.Parse(s.Substring(s.Length-1,1))]=1;
		}
      	long c = 10;
		for(var i=s.Length-2;i>=0;i--){
			if(s.Substring(i,1)=="?"){
				for(var k=0;k<=9;k++){
					for(var j=0;j<=12;j++){
						E[i,(k*c+j)%13] += E[i+1,j];
	                    E[i,(k*c+j)%13] %= mod;
					}
				}
			} else {
				for(var j=0;j<=12;j++){
					E[i,(int.Parse(s.Substring(i,1))*c+j)%13] = E[i+1,j];
				}
			}
          	c = c * 10 % 13;
		}
		Console.WriteLine(E[0,5]%mod);
	}
}

Measured memory_bytes: 26172
# -*- coding: utf-8 -*-
import sys
import math
from bisect import bisect_left
from bisect import bisect_right
import collections
input = sys.stdin.readline

# bisect_left(lists, 3)
# bisect_right(lists, 3)

def main():
	S = input()
	S = list(S)

	if len(S) == 2:
		print(0)
		sys.exit()

	fst = []
	snd = []
	for i, val in enumerate(S):
		if i == len(S)-1:
			break
		if i % 2 == 0:
			fst.append(val)
		else:
			snd.append(val)

	fst1 = collections.Counter(fst)
	snd1 = collections.Counter(snd)

	#print(fst1["0"])
	#print(snd1["0"])

	ans = 0
	if fst1["0"] <= snd1["0"]:
		ans = fst1["0"] + snd1["1"]
	else:
		ans = fst1["1"] + snd1["0"]
	

	print(ans)

	
	
if __name__ == "__main__":
	main()
	

Measured memory_bytes: 5072
#include <iostream>

using namespace std;

int main(){
    string a;
    string b;
    cin >>  a >> b;
    if(a[0] == b[2] && a[1] == b[1] && a[2] == b[0]){
        cout << "YES" << endl;
    }
    else{
        cout << "NO" << endl;
    }
}

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

int main() {
    ll n;
    cin >> n;
    set<string> m;
    for (int i = 0; i < n; i++) {
        string s;
        cin >> s;
        if (m.count(s) == 0) m.insert(s);
    }
    cout << m.size() << endl;
}

Measured memory_bytes: 19224
use whiteread::parse_line;

fn main() {
    let (_a, _b, m): (usize, usize, usize) = parse_line().unwrap();
    let ap: Vec<u32> = parse_line().unwrap();
    let bp: Vec<u32> = parse_line().unwrap();
    let mut min_cost: u32 = ap.iter().min().unwrap() + bp.iter().min().unwrap();
    for _ in 0..m {
        let (xi, yi, ci): (usize, usize, u32) = parse_line().unwrap();
        /*
        if ap[xi - 1] + bp[yi - 1] - ci < min_cost {
            min_cost = ap[xi - 1] + bp[yi - 1] - ci;
        }
        */
        min_cost = min_cost.min(ap[xi - 1] + bp[yi - 1] - ci);
    }
    println!("{}", min_cost);
}


Measured memory_bytes: 3472
#include<bits/stdc++.h>
using namespace std;
int main() {
	long long q, h, s, d; cin >> q >> h >> s >> d;
	long long n; cin >> n;

	long long res1, res2;
	res1 = min({q * 4, h * 2, s}) * n;
	res2 = n / 2 * d + min({q * 4, h * 2, s}) * (n % 2);

	cout << min(res1, res2) << endl;
	return 0;
}


Measured memory_bytes: 3608
import java.util.Scanner;

public class Main {
    public static void main(String[] agrs) {
        Scanner input = new Scanner(System.in);
        double r = input.nextDouble();
        double area = r * r * Math.PI;
        double circumference = 2 * r * Math.PI;
        
        System.out.printf("%.10f %.10f\n", area, circumference);
    }
}


Measured memory_bytes: 28360
N,M = map(int, input().split())
A = list(map(int, input().split()))
total = sum(A)
A.sort(reverse=True)
#print(A)
ans = 'No'
if A[M-1]>=total/(4*M):
  ans = 'Yes'


print(ans)
#print(*ans,sep=' ')

Measured memory_bytes: 3060
// https://atcoder.jp/contests/abc095/tasks/abc095_b

#include <bits/stdc++.h>
#define REP(i, n) for (int(i) = 0; (i) < (n); (i)++)
#define REPR(i, n) for (int(i) = (n); (i) >= 0; (i)--)
#define FOR(i, m, n) for (int(i) = (m); (i) < (n); i++)
#define INF 1e9
#define ALL(v) (v).begin(), (v).end()
using namespace std;
typedef long long ll;

int main()
{
  /* Magic word */
  // cin.tie(0);
  // ios::sync_with_stdio(false);
  /* ---------- */

  int n, x, s = 0, m = INF;

  cin >> n >> x;
  REP(i, n)
  {
    int mi;
    cin >> mi;
    s++;
    x -= mi;
    if (mi < m)
      m = mi;
  }

  s += x / m;

  cout << s << '\n';

  return 0;
}


Measured memory_bytes: 256
X,N=map(int,input().split())
P = list(map(int,input().split()))
value = float('inf')
if(N==0):
    print(X)
    exit()
ans_value= 101
for i in range(0,102):
    if (i not in P):
        if(abs(X-i)<value):
            value=abs(X-i)
            ans_value=i
print(ans_value)



Measured memory_bytes: 9192
#include <bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(), (x).end()
#define SZ(X) ((int)(X).size())
#define endl "\n";
int main()
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	// freopen("input.txt", "r", stdin);
	// freopen("output.txt", "w", stdout);
  int n;
  cin>>n;
  for (int i = 1; i <=9; ++i)
   	{ 
   		 for (int j = 1; j <= 9; ++j)
   	{
   		if (i*j==n)
   		{
   			cout<<"Yes";
   			return 0;
   		}
   	}
  		
   	}	
  	cout<<"No";

   return 0;
}


Measured memory_bytes: 3636
#include<iostream>
using namespace std;
#define MAX 100000
typedef long long llong;
int n, k;
llong T[100000];

int check(llong P) {
    int i = 0;
    for(int j = 0; j < k; j++){
        llong s = 0;
        while( s + T[i] <= P ){
            s += T[i];
            i++;
            if (i == n) return n;
        }
    }
    return i;
}



int solve(){
    llong left = 0;
    llong right = 100000 * 100000;
    llong mid;
    while (right > left + 1){
        mid = (left + right) / 2;
        int v = check(mid);
        if (v >= n) right = mid;
        else left = mid;
    }
    return right;
}



int main(){
    cin >> n >> k;
    for (int i = 0; i < n; i++) cin >> T[i];
    llong ans = solve();
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3848
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <algorithm>
#include <sstream>
#include <cmath>
#include <set>
#include <iomanip>
#include <deque>
using namespace std;
typedef long long ll;

#define REP(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define RREP(i,n) for(int (i)=(int)(n)-1;i>=0;i--)
#define FOREACH(i,Itr) for(auto (i)=(Itr).begin();(i)!=(Itr).end();(i)++)
#define REMOVE(Itr,n) (Itr).erase(remove((Itr).begin(),(Itr).end(),n),(Itr).end())
#define UNIQUE(Itr) sort((Itr).begin(),(Itr).end()); (Itr).erase(unique((Itr).begin(),(Itr).end()),(Itr).end())
#define LBOUND(Itr,val) lower_bound((Itr).begin(),(Itr).end(),(val))
#define UBOUND(Itr,val) upper_bound((Itr).begin(),(Itr).end(),(val))

long long gcd(long long a, long long b){
    if(b==0)return a;
    return gcd(b,a%b);
}

int main(){
    
    ll A,B,C,D; cin>>A>>B>>C>>D;
    
    ll v=abs(A-C);
    ll h=abs(B-D);
    
    if(v==h){
        cout<<v<<endl;
    }else{
        ll g=gcd(v,h);
        cout<<(max(h,v)/g+(min(h,v)/g-1))*g<<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=(b) - 1;i>=(a);i--)
#define REP(i,n) for(int i=0;i<(n);i++)
#define RREP(i,n) for(int i=n-1;i>=0;i--)

#define PB push_back
#define INF INT_MAX/3
#define ALL(a) (a).begin(),(a).end()
#define CLR(a) memset(a,0,sizeof(a))

typedef long long int ll;

using namespace std;

int cubert(int y){
    double low,mid,high;
    low = 0;
    high = y;
    mid = (high + low)/2;
    for(int i=0;i<32;i++){
	if(mid*mid*mid > y){
	    high = mid;
	}else low = mid;
	mid = (high + low)/2;
    }
    return (int)mid;
}

int main(){

    int n;
    while(scanf("%d",&n)){
	if(n==0) break;
	int res = INF;
	int m = 0;
	REP(x,n){
	    int y = cubert( (int)(n*n*n - x*x*x) );
	    for(int i = y -1;i<y+2;i++){
		if(n*n*n - x*x*x -i*i*i > 0)
		res = min(res , n*n*n - x*x*x - i*i*i);
	    }
	}
	cout << res << endl;
    }
    return 0;
}

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

void    Koch(vector<double> &p0, vector<double> &p1, vector<vector<double>> &P) {
    double x0=p0.at(0);
    double y0=p0.at(1);
    double x1=p1.at(0);
    double y1=p1.at(1);
    double dx=x1-x0;
    double dy=y1-y0;
    P.push_back({(x0+x0+x1)/3, (y0+y0+y1)/3});
    double xx=(dx*3-sqrt(3)*dy)/6+x0;
    double yy=(sqrt(3)*dx+dy*3)/6+y0;
    P.push_back({xx, yy});
    P.push_back({(x0+x1+x1)/3, (y0+y1+y1)/3});
    P.push_back({x1, y1});
}

int main() {
    vector<vector<double>> P;
    P.push_back({0, 0});
    P.push_back({100, 0});
    int n;
    cin >>n;
    for (int i=0; i<n; i++) {
        vector<vector<double>> P0;
        P0.push_back(P.at(0));
        for (int j=1; j<P.size(); j++)
            Koch(P.at(j-1), P.at(j), P0);
        P=P0;
    }
    for (int i=0; i<P.size(); i++)
        cout <<fixed <<setprecision(6) <<P.at(i).at(0) <<' ' <<P.at(i).at(1) <<endl;
    return 0;
}


Measured memory_bytes: 3332
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
#define loop(i, a, b) for(li i=a; i<=b; i++)
#define stuff ios::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
using namespace std;
typedef long long li;
typedef long double ld;
typedef pair<int, int> ii;
typedef pair<li, li> lii;
typedef vector<int> vi;
typedef vector<li> vli;
typedef vector<ii> vii;
typedef vector<lii> vlii;
li mod = 2019;
li expo(li base, li exponent)
{
	li ans=1;
	while(exponent)
	{
		if(exponent&1) ans = (ans*base)%mod;
		base = (base*base)%mod;
		exponent >>= 1;
	}
	return ans;
}
li gcd(li x, li y)
{
	if(y==0) return x;
	return gcd(y, x%y);
}


typedef tree<li, null_type, less<li>,
rb_tree_tag, tree_order_statistics_node_update> ordered_set;

int main()
{
	stuff;

	string s;
	cin >> s;
	li len = s.length();
	// li mod = 2019;
	// cout << len << endl;
	map<li, li> m;
	m[0]++;
	li sum=0;
	li ans=0, ten=1;
	for(int i=len-1; i>=0; i--)
	{
		sum = (sum+(s[i]-'0')*ten)%mod;
		ten = (ten*10)%mod;
		ans += m[sum];
		m[sum]++;
		// if(i==8) cout << sum;
	}
	cout << ans;
	return 0;
}


Measured memory_bytes: 3716
import java.util.*;

public class Main {

	public static void main(String[] args) {
		Main main = new Main();
		main.run();
	}

	public void run() {
		Scanner sc = new Scanner(System.in);
		char s[] = (sc.next()+"T").toCharArray();
		int x = sc.nextInt();
		int y = sc.nextInt();
		int cnt=0;
		int c=0;
		ArrayList<Integer> xl = new ArrayList<Integer>();
		ArrayList<Integer> yl = new ArrayList<Integer>();
		int sp=0;
		for(int i=0; i<s.length; i++) {
			if(s[i]=='T') {
				if(c==0) {
					sp=cnt;
				}
				else if(c%2==0) {
					xl.add(cnt);
				}else {
					yl.add(cnt);
				}
				cnt=0;
				c++;
			}else {
				cnt++;
			}
		}

		boolean dpx[][] = new boolean[xl.size()+1][16001];
		dpx[0][8000+sp]=true;
		for(int i=0; i<xl.size(); i++) {
			for(int j=0; j<16001; j++) {
				if(dpx[i][j]) {
					dpx[i+1][j+xl.get(i)] |= dpx[i][j];
					dpx[i+1][j-xl.get(i)] |= dpx[i][j];
				}
			}
		}
		boolean dpy[][] = new boolean[yl.size()+1][16001];
		dpy[0][8000]=true;
		for(int i=0; i<yl.size(); i++) {
			for(int j=0; j<16001; j++) {
				if(dpy[i][j]) {
					dpy[i+1][j+yl.get(i)] |= dpy[i][j];
					dpy[i+1][j-yl.get(i)] |= dpy[i][j];
				}
			}
		}

		if(dpx[xl.size()][8000+x] && dpy[yl.size()][8000+y]) {
			System.out.println("Yes");
		}else {
			System.out.println("No");
		}
		sc.close();
	}

}


Measured memory_bytes: 162324
// AOJ ITP2_11_A Enumeration of Subsets I
// 2019.3.9 bal4u

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

#if 1
#define gc() getchar_unlocked()
#define pc(c) putchar_unlocked(c)
#else
#define gc() getchar()
#define pc(c) putchar(c)
#endif
int in()
{
	int n = 0, c = gc();
	do n = 10 * n + (c & 0xf), c = gc(); while (isdigit(c));
	return n;
}

void out(int n)
{
	int i;
	char ob[30];

	if (!n) pc('0');
	else {
		i = 0; while (n) ob[i++] = n % 10 + '0', n /= 10;
		while (i--) pc(ob[i]);
	}
}

int main()
{
	int i, j, k, n, max;

	n = in(), max = 1 << n;
	for (i = 0; i < max; i++) {
		out(i), pc(':');
		k = i; for (j = 0; k; j++) {
			if (k & 1) pc(' '), out(j);
			k >>= 1;
		}
		pc('\n');
	}
	return 0;
}


Measured memory_bytes: 2092
#include<iostream>
#include<string>
int main(){
	int n,pre=2;
	std::cin>>n;
	if(n==1){
		std::cout<<"1\n";
		return 0;
	}
	else if(n==2){
		std::cout<<"2\n";
		return 0;
	}
	for(int i=0;i<7;i++){
		if(pre*2==n){
			std::cout<<pre*2<<"\n";
			return 0;
		}
		if(pre*2>n){
			std::cout<<pre<<"\n";
			return 0;
		}
		pre*=2;
	}
}

Measured memory_bytes: 256
import java.util.Scanner;

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

		String s = sc.next();
		String t = sc.next();

		String newStr = s + t.charAt(t.length() -1);
		if (t.equals(newStr))
			System.out.println("Yes");
		else
			System.out.println("No");

	}
}


Measured memory_bytes: 38880
#include<bits/stdc++.h>
using namespace std;
#define sz 10010
#define MOD 1000000007
#define ll long long

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


	ll n; cin >> n;
	vector<ll>ans;

	ll cnt = 0;

	for (ll i = 2; i * i <= n; i++)
	{
		if (n % i == 0)
		{
			ll cur = 0;
			ll add = 0;
			while (n % i == 0)
			{
				n = n / i;
				cur++;
				if ((add + 1) * (add + 2) / 2 <= cur)
					add++;
			}
			cnt += add;
		}
	}

	if (n != 1)
		cnt++;

	cout << cnt;

	return 0;
}

Measured memory_bytes: 3568
/**
 *    author:  math2do
 *    created: 22.03.2020 17:58:13
**/

#include <bits/stdc++.h>

using namespace std;

template <typename T>
bool palin(const T &s) {
  int n = s.size();
  for (int i = 0; i < n / 2; i++) {
    int j = n - i - 1;
    if (s[i] != s[j]) return false;
  } 
  return true;
} 

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  string s;
  cin >> s;
  bool found = true;
  int len = s.length();
  int m = len >> 1;
  if (palin(s) && palin(s.substr(0, m)) && palin(s.substr(m + 1, m))) {
    cout << "Yes" << '\n';
  } else {
    cout << "No" << '\n';
  } 
  return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
int main(){
	int a;
  	string b;
  	cin >> a;
  	cin >> b;
  	if(a%2==0){
      	//cout << "0, a/2" << b.substr(0, a/2) << endl;
      	//cout << "a/2+1" << b.substr(a/2) << endl;
    	if(b.substr(0, a/2) == b.substr(a/2)){cout << "Yes";}else cout << "No";
    } else cout << "No";

}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <cmath>
#include <cstring>
#include <iomanip>
#include <random>
#include <chrono>
#include <queue>
#include <math.h>
#include <stdio.h>
#include <string>
#include <sstream>
#define inf 10e8
#define rep(i,n) for(long i=0;i<n;i++)
using namespace std;

int main(){
    int n,k;
    cin >> n >>k;
    int h[n+10];
    int ans=0;
    for (int i=0;i<n;i++){
        cin >> h[i];
        if(h[i]>=k) ans++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 640
n,k = map(int,input().split())
cnt = 0
for i in range(k,n+2):
    if 0.5*(n-i)*(n-i+1) >= 0:
        minus = 0.5*(n-i)*(n-i+1)
    else:
        minus = 0
    front = 0.5*(i-1)*i
    end = 0.5*n*(n+1) - minus
    cnt += end-front+1
print(int(cnt%(10**9+7)))

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

struct Team {
	string name;
	int score, no;
	Team(const string &na, int sc, int no) : name(na), score(sc), no(no) {}

	bool operator <(const Team &t) const {
		if(score != t.score) return score > t.score;
		return no < t.no;
	}
};

int main() {
	bool first = true;
	for(int N; cin >> N, N; ) {
		if(first) first = false;
		else cout << endl;
		vector<Team> v;
		for(int i = 0; i < N; i++) {
			string s;
			int w, l, d;
			cin >> s >> w >> l >> d;
			v.push_back(Team(s, 3 * w + d, i));
		}
		sort(v.begin(), v.end());

		for(auto it : v) {
			cout << it.name << ',' << it.score << endl;
		}
	}
}

Measured memory_bytes: 1220
package main

import (
	"fmt"
)

// SumFor adds a + (a+1) + ... + (b -1) + b
func SumFor(a, b int) int {
	if a == b {
		return a
	}
	if a > b {
		return 0
	}
	sum := (a + b) * ((b - a + 1) / 2)
	if (a+b)%2 == 0 { // i.e. (b-a+1)%2 == 1
		sum += (a + b) / 2
	}
	return sum
}

func main() {
	var n, m int
	fmt.Scan(&n, &m)

	A := make([]int, n)
	for i := 0; i < n; i++ {
		fmt.Scan(&A[i])
	}

	sum := 0
	M := make(map[int]int)
	M[0] = 1 // A_0

	for i := 0; i < n; i++ {
		sum += A[i]
		mod := sum % m
		v, ok := M[mod]
		if ok {
			M[mod] = v + 1
		} else {
			M[mod] = 1
		}
	}

	res := 0
	for _, size := range M {
		res += SumFor(1, size-1)
	}

	fmt.Println(res)
}


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

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

int ao[203][203];

int main() {
  int n, a, b, ans = 0;
  cin >> n;
  rep(i, n) cin >> a >> b, ao[b][a] = 1;

  vector<pair<int, int>> p(n);
  rep(i, n) cin >> p[i].second >> p[i].first;
  sort(p.begin(), p.end());

  rep(i, n) {
    int x = -1, y = -1;
    rep(j, p[i].second) {
      rep(k, p[i].first) {
        if (ao[k][j]) x = j, y = k;
      }
    }
    if (x != -1) ao[y][x] = 0, ans++;
  }

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


Measured memory_bytes: 384
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define REP(i, n) rep(i, 0, n)
#define repb(i, a, b) for(int i = a; i >= b; i--)
#define all(a) a.begin(), a.end()
#define int long long
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
using namespace std;
typedef pair<int, int> P;
const int mod = 1000000007;
const int INF = 1e12;

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    vector<int> t(n);
    int ans = 1;
    rep(i, 0, n){
        cin >> t[i];
    }
    rep(i, 0, n){
        ans = ans / __gcd(ans, t[i]) * t[i];
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define repk(i,k, n) for (ll i = k; i < (ll)(n); ++i)
#define MAX 50000001
#define MOD 1000000007
typedef long long  ll;

using namespace std;

ll ans,cnt;


int main() {
	ll N;
	cin >> N;
	string S;
	cin >> S;
	
	rep(i, N) {
		if (S[i] == 'A') {
			if (S[i + 1] == 'B' && S[i + 2] == 'C') {
				ans++;
			}
		}
	}
	cout << ans << endl;
	
	return 0;
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-
import bisect
import heapq
import math
import random
import sys
from pprint import pprint
from collections import Counter, defaultdict, deque
from decimal import ROUND_CEILING, ROUND_HALF_UP, Decimal
from functools import lru_cache, reduce
from itertools import combinations, combinations_with_replacement, product, permutations
from operator import add, mul, sub

sys.setrecursionlimit(10000)


def read_int():
    return int(input())


def read_int_n():
    return list(map(int, input().split()))


def read_float():
    return float(input())


def read_float_n():
    return list(map(float, input().split()))


def read_str():
    return input().strip()


def read_str_n():
    return list(map(str, input().split()))


def error_print(*args):
    print(*args, file=sys.stderr)


def mt(f):
    import time

    def wrap(*args, **kwargs):
        s = time.time()
        ret = f(*args, **kwargs)
        e = time.time()

        error_print(e - s, 'sec')
        return ret

    return wrap


@mt
def slv(N, T, A):
    ma = [-1] * N
    ma[-1] = A[-1]
    for i in range(N-2, -1, -1):
        ma[i] = max(ma[i+1], A[i])

    c = Counter()
    for i in range(N):
        c[ma[i]-A[i]] += 1

    return c[max(c.keys())]


def main():
    N, T = read_int_n()
    A = read_int_n()

    print(slv(N, T, A))


if __name__ == '__main__':
    main()


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

using namespace std;

int arr[] = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};

int main() {
	int k; scanf("%d", &k);
	printf("%d\n", arr[k - 1]);
	return 0;
}


Measured memory_bytes: 256
from queue import Queue

def solve():
    N = int(input())
    b = list(map(int, input().split()))
    idx = [i+1 for i in reversed(range(N))]
    
    l = []
    for i in range(N):
        for bi, j in zip(reversed(b), idx):
            if j == bi:
                l.append(str(j))
                break
        del idx[0], b[j-1]
    
    return '\n'.join(reversed(l)) if len(l) == N else -1

print(solve())

Measured memory_bytes: 3952
#include<iostream>
#define int long long
using namespace std;
int n,W;
int wt[101];
int val[101];
//int dp[101][100005];
/*
int knapsack1(int i,int W){

	//Base Case
	if(i==0 || W==0)
	{
		dp[i][W]=0;
	}

	if(dp[i][W]!=-1)
		return dp[i][W];

	//Recursive Case
	if(wt[i-1]>W)
		return dp[i][W] = knapsack1(i-1,W);

	else
	{
		int op1 = val[i-1] + knapsack1(i-1,W-wt[i-1]);
		int op2 = knapsack1(i-1,W);
		return dp[i][W] = max(op1,op2);
	}

}*/

int knapsack1_bu(int n,int W){

	int dp[n+1][W+1]={0};

	for(int i=0;i<=n;i++){
		for(int w=0;w<=W;w++){
			if(i==0||w==0)
				dp[i][w]=0;
			else{

				dp[i][w] = dp[i-1][w];
				if(wt[i-1]<=w)
					dp[i][w] = max(dp[i][w],dp[i-1][w-wt[i-1]]+val[i-1]);

			}
		}
	}

	return dp[n][W];


}





int32_t main(){

#ifndef ONLINE_JUDGE
    // for getting input from input.txt
    freopen("input.txt", "r", stdin);
    // for writing output to output.txt
    freopen("output.txt", "w", stdout);
#endif
	cin>>n>>W;
/*
	for(int i=0;i<=n;i++)
		for(int j=0;j<=W;j++)
			dp[i][j]=-1;
*/
	for(int i=0;i<n;i++){
		cin>>wt[i]>>val[i];
	}
	
	cout<<knapsack1_bu(n,W)<<endl;

}

Measured memory_bytes: 82520
package main

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

func main() {
  io := IO{bufio.NewReaderSize(os.Stdin,100),bufio.NewWriterSize(os.Stdout,100)}
  n,m := io.NextInts()
  g := make([][]int,n)
  for i:=0;i<m;i++ {
    s,t := io.NextInts()
    g[s-1] = append(g[s-1],t-1)
  }
  dp := make([]float64,n)
  for v:=n-2;v>=0;v-- {
    now := 0.0
    for _,u := range g[v] { now += dp[u] }
    now /= float64(len(g[v]))
    dp[v] = now+1
  }
  ans := dp[0]
  for nv:=0;nv<n-1;nv++ {
    if len(g[nv]) == 1 { continue }
    nu := g[nv][0]
    for _,u := range g[nv] {
      if dp[nu] < dp[u] { nu = u }
    }
    tmp := make([]float64,n)
    for v:=n-2;v>=0;v-- {
      now := 0.0
      for _,u := range g[v] {
        if v == nv && u == nu { continue }
        now += tmp[u]
      }
      deg := len(g[v])
      if v == nv { deg-- }
      now /= float64(deg)
      tmp[v] = now+1
    }
    if ans > tmp[0] { ans = tmp[0] }
  }
  fmt.Printf("%.12f",ans)
}

type IO struct {
  reader *bufio.Reader
  writer *bufio.Writer
}
func(io *IO) NextLine() string {
  var buffer []byte
  for {
    line,isPrefix,err := io.reader.ReadLine()
    if err != nil { panic(err) }
    buffer = append(buffer,line...)
    if !isPrefix { break }
  }
  return string(buffer)
}
func(io *IO) Println(a ...interface{}) (int,error) {
  return fmt.Fprintln(io.writer,a...)
}
func(io *IO) Flush() error {
  return io.writer.Flush()
}
func(io *IO) NextInts() (int,int) {
  s := strings.Fields(io.NextLine())
  x,_ := strconv.Atoi(s[0])
  y,_ := strconv.Atoi(s[1])
  return x,y
}

Measured memory_bytes: 5888
using System;
using System.Collections.Generic;
using System.Linq;
using BitArray = System.Collections.BitArray;
using BigInteger = System.Numerics.BigInteger;
using TextReader = System.IO.TextReader;
using System.Text;

namespace AtCoderProject
{
    public class Program
    {
        public object Calc()
        {
            var a = consoleReader.Int;
            var b = consoleReader.Int ;
            var c = consoleReader.Int;
            var d = consoleReader.Int ;
            return Math.Max(0, Math.Min(b, d) - Math.Max(a, c));
        }

        #region いつもの
#pragma warning disable
        private ConsoleReader consoleReader;
        public Program(ConsoleReader consoleReader) { this.consoleReader = consoleReader; }
        static void Main() => Console.WriteLine(new Program(new ConsoleReader(Console.In)).Calc()); static string AllLines<T>(IEnumerable<T> source) => string.Join("\n", source);
    }
    static class Ext
    {
        public static Dictionary<TKey, int> GroupCount<TSource, TKey>(this IEnumerable<TSource> source, Func<TSource, TKey> keySelector) => source.GroupBy(keySelector).ToDictionary(g => g.Key, g => g.Count());
        public static Dictionary<TKey, int> GroupCount<TKey>(this IEnumerable<TKey> source) => source.GroupCount(i => i);
    }
    public class ConsoleReader { private string[] ReadLineSplit() => textReader.ReadLine().Split(Array.Empty<char>(), StringSplitOptions.RemoveEmptyEntries); private string[] line = Array.Empty<string>(); private int linePosition; private TextReader textReader; public ConsoleReader(TextReader tr) { textReader = tr; } public int Int => int.Parse(String); public long Long => long.Parse(String); public double Double => double.Parse(String); public string String { get { if (linePosition >= line.Length) { linePosition = 0; line = ReadLineSplit(); } return line[linePosition++]; } } public class SplitLine { private string[] splited; public SplitLine(ConsoleReader cr) { splited = cr.ReadLineSplit(); cr.line = Array.Empty<string>(); } public int[] Int => String.Select(x => int.Parse(x)).ToArray(); public int[] Int0 => String.Select(x => int.Parse(x) - 1).ToArray(); public long[] Long => String.Select(x => long.Parse(x)).ToArray(); public double[] Double => String.Select(x => double.Parse(x)).ToArray(); public string[] String => splited; } public SplitLine Split => new SplitLine(this); public class RepeatReader : IEnumerable<ConsoleReader> { ConsoleReader cr; int count; public RepeatReader(ConsoleReader cr, int count) { this.cr = cr; this.count = count; } public IEnumerator<ConsoleReader> GetEnumerator() => Enumerable.Repeat(cr, count).GetEnumerator(); System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator() => GetEnumerator(); public IEnumerable<string> String => this.Select(cr => cr.String); public IEnumerable<int> Int => this.Select(cr => cr.Int); public IEnumerable<int> Int0 => this.Select(cr => cr.Int - 1); public IEnumerable<long> Long => this.Select(cr => cr.Long); public IEnumerable<double> Double => this.Select(cr => cr.Double); } public RepeatReader Repeat(int count) => new RepeatReader(this, count); }
    #endregion
}


Measured memory_bytes: 13140
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <string>
#include <functional>
#include <utility>
#include <vector>
using namespace std;
typedef long long int ll;
const int MOD = 1000000007;

int main(){
  int N;
  cin >> N;
  int input[1000];
  for(int i=0;i<N*2;i++){
    cin >> input[i];
  }
  sort(input,input+N*2);
  int ans = 0;
  for(int i=0;i<N;i++){
    ans += input[i*2];
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
N, M, K = map(int, input().split())
flag = False

for j in range(M + 1):
    for i in range(N + 1):
        # t = i * j + (N - i) * (M - j)
        # area = M * N - t
        area = (M - j) * i + (N - i) * j
        if area == K:
            flag = True

if flag:
    print('Yes')
else:
    print("No")

Measured memory_bytes: 9132
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define FOR(i, a, b) for(int i = (int)a; i <= (int)b; i++)
#define DEC(i, a, b) for(int i = (int)a; i >= (int)b; i--)
typedef pair<int, int> pi;
typedef pair<int, pi> pii;
typedef pair<pi, pi> pipi;
#define f first
#define s second
typedef vector<int> vi;
typedef vector<pi> vpi;
typedef vector<pii> vpii;
#define pb push_back
#define pf push_front
#define all(v) v.begin(), v.end()
#define disc(v) sort(all(v)); v.resize(unique(all(v)) - v.begin());
#define INF (int) 1e9 + 100
#define LLINF (ll) 1e18
#define fastio ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());    //can be used by calling rng() or shuffle(A, A+n, rng)
inline ll rand(ll x, ll y) { ++y; return (rng() % (y-x)) + x; } //inclusivesss

int n, arr[105], ans;

bool check(int x, int y, int z) {
	if (x == y or y == z or x == z) return 0;
	return (x+y>z and x+z>y and y+z>x);
}

int main() {
	fastio; cin >> n;
	FOR(i, 1, n) cin >> arr[i];
	FOR(i, 1, n) FOR(j, i+1, n) FOR(k, j+1, n) ans += check(arr[i], arr[j], arr[k]);
	cout << ans;
}


Measured memory_bytes: 3620
N,A,B = (int(i) for i in input().split())

total = 0

for i in range(N+1):
    summy = 0
    char = str(i)
    for j in range(len(char)):
        summy = summy + int(char[j])

    if (summy>=A and summy<=B):
        total = total + i
        
print(total)

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

int main(){
  int n, a, b;
  cin >> n >> a >> b;
  ll v[n];
  vector<vector<ll>> comb(51,vector<ll>(51));
  rep(i,51) comb[i][0] = 1;
  for(int i = 1; i < 51; i++) {
    for(int j = 1; j <= i; j++) comb[i][j] = comb[i-1][j-1] + comb[i-1][j];
  }
  rep(i,n) cin >> v[i];
  sort(v,v+n,greater<ll>());
  map<ll,int> m;
  rep(i,n) m[v[i]]++;
  double ave = 0;
  rep(i,a) ave += v[i];
  ave /= a;
  ll ans;
  if(v[0] != v[a-1]) {
    int p = INF;
    rep(i,a) {
      if(v[i] == v[a-1]) p = min(p,i);
    } 
    ans = comb[m[v[a-1]]][a-p];
  } else {
    ans = 0;
    for(int i = a; i <= min(b,m[v[0]]); i++) ans += comb[m[v[0]]][i];
  }
  printf("%.9lf\n",ave);
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
A,B = [int(i) for i in input().split()]
S = input()
Sa = S[:A]
Sb = S[A+1:]
def hoge(S) :
    if S[A] == "-" :
        return True
    else :
        return False
if Sa.isdecimal() and hoge(S) and Sb.isdecimal() :
    print("Yes")
else :
    print("No")

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin >> n;
  char a[n+2],b[n+2],c[n+2];
  cin >> a >> b >> c;; 
  int ans=0;
  for(int i=0;i<n;i++){
    if(a[i]!=b[i]&&b[i]!=c[i]&&c[i]!=a[i])ans+=2;
    else if(!(a[i]==b[i]&&b[i]==c[i]))ans+=1;
  }
  cout << ans;
}

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 a = sc.nextInt();
		int b = sc.nextInt();
		
		int maxX = Math.min(a, b);
		int cand = (a + b) - n;
		int minX = Math.max(cand, 0);
		
		System.out.println(maxX + " " + minX);
	}

}

Measured memory_bytes: 22224
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define mod 1000000007
#define int long long
#define ll long long
#define EPS 0.000000001
#define ld long double
#define inf 5e18
#define N 2000001
#define K 17


int fact[N],ifact[N];

ll fastexpom(ll a,ll b,ll m)
{
  ll res=1;
      while(b>0)
      {
        if(b%2==1)
          res=(((res)%m)*((a)%m))%m;
        a=(((a)%m)*((a)%m))%m;
        b/=2;
      }
      return res;
}
ll modinv(ll a, ll m=1000000007)
{
  return fastexpom(a,m-2,m);
}
void preprocess()
{
    fact[0] = 1;
    ifact[0] = 1;
    for(int i = 1;i < N;i++)
    {
        fact[i] = (fact[i-1] * i)%mod;
        ifact[i] = modinv(fact[i],mod);
    }
}
int nCr(int n,int r)
{
    if(n == 0 and r == 0)
        return 1;
    if(r > n or r < 0 or n == 0)
        return 0;
    int ans = (fact[n] * ifact[n-r])%mod;
    ans = (ans * ifact[r])%mod;
    return ans;
}


int32_t main()
{
    IOS;
    #ifndef ONLINE_JUDGE
    freopen("int.txt","r",stdin);
    freopen("out.txt","w",stdout);
    #endif
    int k;
    string s;
    cin >> k >> s;
    int n = s.length();
    preprocess();
    int ans = 0;
    for(int i = n;i <= n + k;i++)
    {
        int  lans = fastexpom(26, n + k - i, mod);
        lans = (lans * ((nCr(i - 1, n - 1) * fastexpom(25, i - n, mod)) % mod)) %mod;
        // assert(lans >= 0);
        ans = (ans + lans)  % mod;
    }
    cout << ans;
    return 0;
    
}   

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

#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for (int i = x; i < n; i++)
#define OP(m) cout << m << endl
typedef long long ll;
typedef unsigned long long ull;

char m[100][100];
pair<int, int> a[4] = {{1, 0}, {0, -1}, {-1, 0}, {0, 1}};
int h, w;
bool used[100][100];

void dfs(int y, int x, char c)
{
    used[y][x] = 1;
    rep(i, 4)
    {
        int ny = y + a[i].second, nx = x + a[i].first;
        if (used[ny][nx] || m[ny][nx] != c || !((0 <= ny && ny < h) && (0 <= nx && nx < w)))
            continue;
        dfs(ny, nx, c);
    }
}

int main()
{
    while (cin >> h >> w, h)
    {
        rep(i, h) rep(j, w) cin >> m[i][j];
        rep(i, h) rep(j, w) used[i][j] = 0;

        int cnt = 0;

        rep(i, h)
        {
            rep(j, w)
            {
                if (!used[i][j])
                {
                    cnt++;
                    dfs(i, j, m[i][j]);
                }
            }
        }
        OP(cnt);
    }

    return 0;
}


Measured memory_bytes: 3484
#include <stdio.h>

int main (){
	int n;
	scanf ("%d", &n);
	char str[n + 1];
	scanf ("%s", str);
	if (n % 2 != 0){
		printf ("No\n");
		return 0;
	}
	for (int i = 0; i < n/2; i++){
		if (str[i] != str[(n/2) + i]){
			printf("No\n");
			return 0;
		}
	}
	printf("Yes\n");
	return 0;
}

Measured memory_bytes: 1636
//#include <bits/stdc++.h>
//#pragma GCC optimize(2)
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<string>
#include<vector>
#include<set>
#include<map>
#include<queue>
#include<cmath>
#include<cstring>
#include<bitset>
#include<stack>
#include<time.h>



#define X first
#define Y second
#define PB push_back
#define MP make_pair
#define scd(a) scanf("%d",&a)
#define scdd(a,b) scanf("%d%d",&a,&b)
#define scddd(a,b,c) scanf("%d%d%d",&a,&b,&c)
#define ALL(x) x.begin(),x.end()
#define sz(a) ((int)a.size())
#define getmid ((l+r)>>1)
#define mst(var,val) memset(var,val,sizeof(var))
#define IOS ios::sync_with_stdio(false);cin.tie(0)
#define lowbit(x) x&(-x)
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
#define ls rt<<1
#define rs rt<<1|1
using namespace std;
#ifdef local
#define dbg(args...) cout << #args << " -> ", err(args);
void err(){ cout << endl; }
template<typename T, typename... Args>
void err(T a, Args... args){ cout << a << ' '; err(args...); }
#else
#define dbg(args...)
#endif // local

typedef long long ll;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
typedef pair <ll, int> pli;
typedef pair <double, double> pdd;
const int inf=0x3f3f3f3f;
const long long INF=0x3f3f3f3f3f3f3f3fLL;
const double PI=acos(-1.0);
const long double eps=1e-8;
const int mod=1e9+7;
const int maxn=3e5+100;
const int N=1e6+100;
const int M=500+10;
const ll mm=(1LL<<32);

template <class T>
inline void read(T &x)
{
    x = 0;
    char c = getchar();
    bool f = 0;
    for (; !isdigit(c); c = getchar())
        f ^= c == '-';
    for (; isdigit(c); c = getchar())
        x = x * 10 + (c ^ 48);
    x = f ? -x : x;
}

template <class T>
inline void write(T x)
{
    if (x < 0)
    {
        putchar('-');
        x = -x;
    }
    T y = 1;
    int len = 1;
    for (; y <= x / 10; y *= 10)
        ++len;
    for (; len; --len, x %= y, y /= 10)
        putchar(x / y + 48);
}
ll qpow(ll a,ll b,ll mod)
{
    ll ans=1;
    while(b)
    {
        if(b&1)
            ans=(ans*a)%mod;
        b>>=1;
        a=(a*a)%mod;
    }
    return ans;
}


int pos[N],ans[N],a[N],cnt[N],res;
struct node{
    int l,r,id;
    bool operator<(const node&b)const{
        return pos[l]==pos[b.l]?r<b.r:pos[l]<pos[b.l];
    }
}q[N];
void add(int x)
{
    if(++cnt[a[x]]==1) res++;
}
void del(int x)
{
    if(--cnt[a[x]]==0) res--;
}
int main()
{
#ifdef local
    freopen("in.txt","r",stdin);
#endif // local
    IOS;cout.tie(0);
    int n,m;cin>>n>>m;
    rep1(i,n) cin>>a[i];
    int blo=sqrt(n+0.5);
    for(int i=1;i<=m;++i) pos[i]=(i-1)/blo+1;
    rep1(i,m)
    {
        cin>>q[i].l>>q[i].r;q[i].id=i;
    }
    sort(q+1,q+1+m);
    int l=1,r=0;
    res=0;
    for(int i=1;i<=m;++i)
    {
        while(r<q[i].r) add(++r);
        while(r>q[i].r) del(r--);
        while(l<q[i].l) del(l++);
        while(l>q[i].l) add(--l);
        ans[q[i].id]=res;
    }
    rep1(i,m) cout<<ans[i]<<"\n";
    return 0;
}



Measured memory_bytes: 17432
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;

typedef long long ll;
typedef pair<int,int> ii;
typedef tree<ii,null_type,less<ii>,rb_tree_tag,tree_order_statistics_node_update> indexed_set;

int main() {
	cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);
	int N,x; cin>>N>>x;
	vector<int> a(N);
	for (int i=0; i<N; i++)
		cin>>a[i];
	ll ret=0;
	for (int i=1; i<N; i++) {
		if(a[i-1]+a[i]<=x)
			continue;
		int cur=a[i-1]+a[i]-x;
		ret+=cur;
		a[i]-=min(a[i],cur);
	}
	cout<<ret<<"\n";
	return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
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.at(i);
    vector<int> buka(N + 1, 0);

    rep(i,N) ++buka.at(A.at(i));
    for(int i = 1; i <= N; ++i) {
        cout << buka.at(i) << endl;
    }
}

Measured memory_bytes: 4852
#include <cstdio>  
#include <cstring>  
#include <cmath>  
using namespace std;  
//dp   dp[i][j]=max(dp[i-1][j],dp[i][j-1])+a[i][j]  
const int maxn=1e2+10;   
int n;  
int a[maxn][maxn];  
int dp[maxn][maxn];  
  
int max(int a,int b)  
{  
    return a>b?a:b;  
 }   
  
void solve()  
{  
    dp[1][1]=a[1][1];  
    for(int i=1;i<=2;i++)  
    {  
        for(int j=1;j<=n;j++)  
        {  
            if(i==1)  
                dp[i][j]=dp[i][j-1]+a[i][j];  
            else  
                dp[i][j]=max(dp[i-1][j],dp[i][j-1])+a[i][j];   
        }  
    }  
}   
int main()  
{  
    while(~scanf("%d",&n))  
    {  
      
    memset(a,0,sizeof(a));  
    memset(dp,0,sizeof(dp));  
    for(int i=1;i<=2;i++)  
    {  
        for(int j=1;j<=n;j++)  
        {  
            scanf("%d",&a[i][j]);  
        }  
    }  
    solve();  
    printf("%d\n",dp[2][n]);  
}  
    return 0;  
}  

Measured memory_bytes: 256
import java.util.Scanner;

class Main {
	public static void main(String[] args){
		Scanner input = new Scanner(System.in);
		int i;
		int n;
		int x, y;
		int h, w;
		int fee = 0;
		int lar;
		
		while (fee != 1){
			n = input.nextInt();
			
			if (n == 0){
				break;
			}
			
			fee = 0;
			for (i = 0; i < n; i++){
				x = input.nextInt();
				y = input.nextInt();
				h = input.nextInt();
				w = input.nextInt();
			
				lar = x + y + h;
				if (lar <= 60 && w <= 2){
					fee += 600;
				}
				else if (lar <= 80 && w <= 5){
					fee += 800;
				}
				else if (lar <= 100 && w <=10){
					fee += 1000;
				}
				else if (lar <= 120 && w <= 15){
					fee += 1200;
				}
				else if (lar <= 140 && w <= 20){
					fee += 1400;
				}
				else if (lar <= 160 && w <= 25){
					fee += 1600;
				}
			}
			System.out.println(fee);
		}
	}
}

Measured memory_bytes: 56456
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); ++i)

int n, m, a;

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

    cin >> n >> m;

    rep(i,m) cin >> a;

    cout << n - m - 1 << endl;

    return 0;
}

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

int main() {
	// your code goes here
	string s;
	int i, j, n;
	cin>>s;
	n=s.length();
	bool a, b, c, d;
	a=b=c=d=false;
	for(i=0; i<n; ++i) {
		if(s[i]=='N')	a=true;
		if(s[i]=='S')	b=true;
		if(s[i]=='E')	c=true;
		if(s[i]=='W')	d=true;
	}
	if((a && !b) || (b && !a) || (c && !d) || (d && !c)) {
		cout<<"No";
	}
	else {
		cout<<"Yes";
	}
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h> 
 #include <stdbool.h> 
 
 
 int main(){ 
     int i, j, n; 
     char mark; 
     char marks[4]={'S', 'H', 'C', 'D'}; 
     int num; 
     bool cards[4][13]={false}; 
 
 
     scanf("%d ", &n); 
     for(i=0;i<n;i++){ 
         scanf("%c %d ", &mark, &num); 
         for(j=0;j<4;j++){ 
             if(mark==marks[j]){ 
                 cards[j][num-1]=true; 
                 break; 
            } 
         } 
     } 
     for(i=0;i<4;i++){ 
         for(j=0;j<13;j++){ 
            if(!cards[i][j]){ 
                 printf("%c %d\n", marks[i], j+1); 
            } 
         } 
     } 
     return 0; 
 } 


Measured memory_bytes: 2104
#include <bits/stdc++.h>
#include <iomanip>
#define rep(i,n) for (int i = 0;i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;
const double PI = acos(-1);

int main() { 
  int a, b, h, m;
  cin >> a >> b >> h >> m;
  double th = double(h*60+m)/720 * 2*PI;
  double tm = double(m)/60 * 2*PI;
  // 時針Aの座標
  double xh = a * cos(th), yh = a * sin(th);
  // 分針Bの座標
  double xm = b * cos(tm), ym = b * sin(tm);
  // 座標の差
  double dx = xh - xm, dy = yh - ym;
  double ans = sqrt(dx*dx + dy*dy);
  printf("%.10f\n", ans);
  return 0;
}

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

#define endl '\n'
#define fi first
#define se second
#define pb push_back
#define debug(x) cout << "[debug] " << #x << ": " << x << endl
using namespace std;
typedef long long ll;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;
const int MOD = 1e9 + 7;
const int maxn = 1e6 + 5;
const int inf = 0x3f3f3f3f;
const ll INF = 0x3f3f3f3f3f3f3f3f;
const double eps = 1e-8;
const double PI = acos(-1.0);

void header() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
}

ll a[maxn];

void solve() {
    int n;
    cin >> n;
    for (int i = 1; i <= n; i++) cin >> a[i];
    ll s = a[1];
    for (int i = 2; i <= n; i++) s ^= a[i];

    for (int i = 1; i <= n; i++) cout << (s ^ a[i]) << " ";
    cout << endl;
}

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


Measured memory_bytes: 5168