akhauriyash/Code-Regression huggingface dataset:
/* ---------- STL Libraries ---------- */

// IO library
#include <cstdio>
#include <fstream>
#include <iomanip>
#include <ios>
#include <iostream>

// algorithm library
#include <algorithm>
#include <cmath>
#include <numeric>
#include <random>

// container library
#include <array>
#include <bitset>
#include <deque>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <tuple>
#include <vector>

/* ---------- Namespace ---------- */

using namespace std;

/* ---------- Type Abbreviation ---------- */

template <typename T>
using PQ = priority_queue<T>;
template <typename T>
using GPQ = priority_queue<T, vector<T>, greater<T>>;

using ll = long long;

#define fst first
#define snd second
#define mp make_pair
#define mt make_tuple

#define FOR(i, a, b) for (ll i = (a); i < (b); i++)
#define REP(i, n) FOR(i, 0, n)


/* ---------- conversion ---------- */

#define INT(c) static_cast<int>(c)
#define CHAR(n) static_cast<char>(n)
#define LL(n) static_cast<ll>(n)
#define DOUBLE(n) static_cast<double>(n)

/* ---------- container ---------- */

#define ALL(v) (v).begin(), (v).end()
#define SIZE(v) (LL((v).size()))
#define each(itr,v) for(auto (itr):(v))

#define FIND(v, k) (v).find(k) != (v).end()
#define VFIND(v, k) find(ALL(v), k) != (v).end()

#define gsort(b, e) sort(b, e, greater<decltype(*b)>())

/* ----------- debug ---------- */

template <class T>
ostream& operator<<(ostream& os, vector<T> v) {
	os << "[";
	for (auto vv : v)
		os << vv << ",";
	return os << "]";
}

template <class T>
ostream& operator<<(ostream& os, set<T> v) {
	os << "[";
	for (auto vv : v)
		os << vv << ",";
	return os << "]";
}

template <class L, class R>
ostream& operator<<(ostream& os, pair<L, R> p) {
	return os << "(" << p.fst << "," << p.snd << ")";
}

/* ---------- Constants ---------- */

// const ll MOD = 1e9 + 7;
// const int INF = 1 << 25;
// const ll INF = 1LL << 50;
// const double PI = acos(-1);
// const double EPS = 1e-10;
// mt19937 mert(LL(time(0)));

/* ---------- Short Functions ---------- */

template <typename T>
T sq(T a) {
	return a * a;
}

template <typename T>
T gcd(T a, T b) {
	if (a > b) return gcd(b, a);
	return a == 0 ? b : gcd(b % a, a);
}

template <typename T, typename U>
T mypow(T b, U n) {
	if (n == 0) return 1;
	if (n == 1) return b /* % MOD */;
	if (n % 2 == 0) {
		return mypow(b * b /* % MOD */, n / 2);
	}
	else {
		return mypow(b, n - 1) * b /* % MOD */;
	}
}

ll pcnt(ll b) {
	return __builtin_popcountll(b);
}



// const ll dx[4] = {0, -1, 1, 0};
// const ll dy[4] = {-1, 0, 0, 1};
// const ll dx[8] = {-1, 0, 1, -1, 1, -1, 0, 1};
// const ll dy[8] = {-1, -1, -1, 0, 0, 1, 1, 1};

/* v-v-v-v-v-v-v-v-v Main Part v-v-v-v-v-v-v-v-v */

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll N;
	cin >> N;
	ll X[N];
	REP(i, N) {
		cin >> X[i];
	}
	ll cpX[N];
	REP(i, N) {
		cpX[i] = X[i];
	}
	sort(cpX, cpX + N);
	REP(i, N) {
		if (X[i] <= cpX[N / 2 - 1]) cout << cpX[N / 2] << endl;
		else cout << cpX[N / 2 - 1] << endl;
	}
	return 0;
}

Measured memory_bytes: 5376
#include<stdio.h>
int fun(long long int x)
{
    int i,m=0;
    do
    {
        if((i=x%10)!=9)
           return 0;
        x=x/10;
        m++;
    }while(x>10);
    return x+9*m;
}
int main()
{
    long long int n;
    int time=0,x;
    scanf("%lld",&n);
    if(fun(n))
    {
        printf("%d\n",fun(n));
        return 0;
    }
    do
    {
        x=n%10;
        n=n/10;
        time++;
    }while(n);
    if(time==1)
    {
        printf("%d\n",x);
        return 0;
    }
    x=x-1+(time-1)*9;
    printf("%d\n",x);
    return 0;
}


Measured memory_bytes: 128
#include <stdio.h>

int findOfDigits(int n){
    int sum=0;
    while(n>0){
        sum += n%10;
        n /= 10;
    }
    return sum;
}

int main(){
    int N, HarshadNumber=0;
    scanf("%d", &N);
    HarshadNumber = findOfDigits(N);
    if(N%HarshadNumber==0) printf("Yes");
    else puts("No");
}

Measured memory_bytes: 128
STDOUT.sync= true
def solve(n)
  return 0 if n>36
  c=0
  10.times do |i|
    10.times do |j|
      10.times do |k|
        10.times do |l|
          c+=1 if i+j+k+l == n
        end
      end
    end
  end
  c
end

while n = gets do
  n=n.to_i
  puts solve(n)
end 

Measured memory_bytes: 2292
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <numeric>
#include <stdio.h>
#include <stack>
#include <queue>
#include <cstdio>
#include <cmath>
#include <iterator>
#include <map>
#include <fstream>
#include <functional>
#include <list>
#include <iomanip>
#include <cctype>
#include <math.h>
#include <utility>
#include <numeric>

#define REP(i,first,end) for(int i = first; i < end; i++)
#define rep(i,end) for(int i = 0; i < end; i++)

typedef long long ll;
#define mod =1000000007;

using namespace std;

int main() {
    cin.tie(0); ios::sync_with_stdio(false);
    int n;
    cin >> n;
    
    double c = 0.0;
    int x;
    rep(i,n){
        cin >> x;

        c += (double)1/x;

    }
    
    cout << (double)1/c << endl;
}
    




Measured memory_bytes: 256
n,x,y = map(int,input().split())
ans = [0] * (n-1)
l = list(range(1,n+1))

import itertools

for a,b in itertools.combinations(l, 2):
    dis = min(b-a, abs(b-y)+abs(x-a)+1)
    ans[dis-1] += 1

for i in ans:
    print(i)

Measured memory_bytes: 74488
(defn solve [s b acc]
  (if (empty? s)
    acc
    (let [c (first s)]
      (if (= b c)
        (recur (next s) b acc)
        (recur (next s) c (inc acc))))))

(let [n (read-line)
      s (read-line)]
  (println (solve (next s) (first s) 1)))

Measured memory_bytes: 69156
from collections import deque
S = list(input())
Q = int(input())
num = 1
q = deque(S)
for _ in range(Q):
    L = [i for i in input().split()]
    if len(L) == 1:
        num += 1
        num %= 2
    else:
        if int(L[1])%2 == num:
            q.appendleft(L[2])
        else:
            q.append(L[2])

ans = list(q)
if num == 0:
    ans.reverse()
print("".join(ans))

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

int main() {
    int n, m, x, front = 0, back = 0;
    cin >> n >> m >> x;
    vector<int> a(m);
    for (int i = 0; i < a.size(); i++)
    {
        cin >> a[i];
    }
    
    for (int i = 0; i < a.size(); i++)
    {
        if (x < a[i])
        {
            front++;
        }
        else
        {
            back++;
        }
        
    }
    
    cout << min(front, back) << endl;
}

Measured memory_bytes: 256
#include<cstdio>
#include<vector>
#include<cstring>
#include<iostream>
#include<algorithm>

using namespace std;
typedef long long ll;
int getint(){
	int x=0,f=1; char ch=getchar();
	while(ch<'0'||ch>'9') { if(ch=='-')f=-1; ch=getchar();	}
	while('0'<=ch&&ch<='9') { x=x*10+ch-'0'; ch=getchar();	}
	return f*x;
}
#define N 123
vector<int> a[4];
int s[4][N];
int c[4];
int n,W; 
int main(){
	n=getint(),W=getint();
	ll w;
	for(int i=1;i<=n;i++) {
		int x=getint(),y=getint();
		if(i==1) w=x;
		a[x-w].push_back(y); c[x-w]++;
	}
	for(int i=0;i<4;i++) {
		sort(a[i].begin(),a[i].end());
		for(int j=1;j<=c[i];j++) s[i][j]=s[i][j-1]+a[i][c[i]-j];
	}
	int ans=0;
	for(int i=0;i<=c[0];i++)
		for(int j=0;j<=c[1];j++)
			for(int k=0;k<=c[2];k++)
				for(int l=0;l<=c[3];l++) {
					if(w*i+(w+1)*j+(w+2)*k+(w+3)*l>W) continue;
					ans=max(ans,s[0][i]+s[1][j]+s[2][k]+s[3][l]);
				}
	cout<<ans<<endl;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

void getAns(int r, int d, int x, int i){
    if(i == 10) return;
    i++;
    int xn = r * x - d;
    cout << xn << endl;
    getAns(r, d, xn, i);
}

int main(){
    int r, d, x2000;
    cin >> r >> d >> x2000;
    getAns(r, d, x2000, 0);
    return 0;
}

Measured memory_bytes: 256
import java.io.*;

public class Main {
	public static void main(String[] args) {
		BufferedReader r = new BufferedReader(new InputStreamReader(System.in));       
		try {
			String line;
			while((line=r.readLine())!=null){
				/* input from here */
				int n = Integer.parseInt(line);
				/* input till here */
				if(n==1||n==2){
					System.out.println(n);
					continue;
				}
				/* processing from here */
				int size=0,weight=4;
				if(n%2==1){
					size = 1;
					for(int i=3;i<=n;i+=2){
						size += weight;
						weight*= 3;
					}
				} else {
					size = 2;
					weight = 6;
					for(int i=4;i<=n;i+=2){
						size += weight;
						weight*= 3;
					}
				}
				/* processing till here */
				/* output */
				System.out.println(size);
			}
		} catch (IOException e) {
			e.printStackTrace();
		}
	}
}

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

#define int         long long
#define uint        unsigned int
#define ld          long double
#define showoff     ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define pb          push_back
#define pii         pair<int,int>
#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 f           first
#define se          second
#define maxn        200005
#define all(v)      v.begin(),v.end()
#define sz(x)       (int)x.size()
#define mod         1000000007
#define pqueue      priority_queue<int>
#define pdqueue     priority_queue< int,vector<int> ,greater< int >>

using namespace std;


//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());


int power(int a,int n)
{
    if(n == 1)return a;
    if(n == 0)return 1;
    if(n%2)return a*power(a*a,n/2);
    return power(a*a,n/2);
}
const int md = 998244353;
const int inf = (int) 1e18;

/*int inverse(int x){

    return power(x,mod-2)%mod;//little fermat....
}*/



signed main()
{
    showoff;
    int n,k;
    string s;
    cin >> n >> k >> s;
    vector<int>v;
    FOR(i,0,n){
        int l = 1;
        while(i+1 < n && s[i+1] == s[i]){
            ++i;
            ++l;
        }
        if(s[i] == '0')v.pb(l);
        else v.pb(-1*l);
    }
    int ans = 0,i = 0;
    while(k > 0 && i < sz(v)){
        ans += abs(v[i]);
        if(v[i] > 0)--k;
        ++i;
    }
    if(sz(v) == 1){
        cout << ans;
        return 0;
    }
    int ma = ans,pi;
    if(v[0] > 0)pi = 0;
    else pi = 1;
    FOR(j,i,sz(v)){
        if(v[j] > 0){
            ma -= v[pi];
            ma += v[j];
            if(pi > 0)ma += v[pi-1];
            pi += 2;
        }
        else ma -= v[j];
        ans = max(ans,ma);
    }
    cout << ans;
    return 0;
}
//*->for large size of matrix take int not long long if possible......
//*->always take maximum as inf for safer side ...    

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

const int mod = 1000000007;

int main(){
    int n;
    cin >> n;
    ve<ve<int>> a(n,ve<int>(n));
    rep(i,n)rep(j,n) cin >> a[i][j];
    ve<ll> dp(1<<n);
    rep(i,n)if(a[0][i]==1)dp[1<<i]=1;
    for(int i=1;i<n;i++){
        ve<ll> p(1<<n);
        swap(p,dp);
        rep(j,n){
            if(a[i][j]==0) continue;
            else{
                int mask = 1<<j;
                rep(k,1<<n){
                    if(mask&k) continue;
                    (dp[k|mask] += p[k])%=mod;
                }
            }
        }
    }
    cout << dp[(1<<n)-1] << endl;
    return 0;
}

Measured memory_bytes: 33148
#include<stdio.h>
#define N 101
 
int main()
{
  int i,j,n,count=0,v,c,c1,v1;
  int G[N][N],col[N],d[N],pi[N],mincost,i2;
 
  for(i = 0; i < N; i++){
 
    for(j = 0; j < N; j++)
      G[i][j] = -1;
 
  }
 
  scanf("%d",&n);
 
  for(i = 0; i < n; i++){
 
    scanf("%d%d",&v,&c);
 
    for(j = 0; j < c; j++){
      scanf("%d%d",&v1,&c1);
      G[v][v1] = c1;
    }
 
  }
  
  for(i = 0; i < n; i++){
 
    col[i] = 0;
    pi[i] = -1;
    d[i] = 10000001;
 
  }
 
  d[0] = 0;
  
  while(1){
 
    mincost = 10000001;
 
    for(i = 0; i < n; i++){
 
      if(col[i] != 2 && d[i] < mincost){
        mincost = d[i];
        i2 = i;
      }
 
    }
 
    if(mincost == 10000001)break;
 
    col[i2] = 2;
 
    for(i = 0; i < n; i++){
 
      if(G[i2][i] != -1 && col[i] != 2 && (G[i2][i]+d[i2]) < d[i]){
    pi[i] = i2;
    d[i] = G[i2][i] + d[i2];
    col[i] = 1;
      }
 
    }
 
  }
 
  for(i = 0; i < n; i++)printf("%d %d\n",i,d[i]);
 
  return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define FOR(i,start,end) for(int i=start;i<=end;i++)
const int INF = 1001001001;
typedef long long ll;
const ll MOD=1000000007;
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<class T>auto MAX(const T& a) { return *max_element(a.begin(),a.end()); }
template<class T>auto MIN(const T& a) { return *min_element(a.begin(),a.end()); }
template<class T, class U>U SUM(const T& a, const U& v) { return accumulate(a.begin(),a.end(), v); }
template<class T, class U>U COUNT(const T& a, const U& v) { return count(a.begin(),a.end(), v); }
template<class T, class U>int LOWER(const T& a, const U& v) { return lower_bound(a.begin(),a.end(), v) - a.begin(); }
template<class T, class U>int UPPER(const T& a, const U& v) { return upper_bound(a.begin(),a.end(), v) - a.begin(); }
int GCD(int a, int b) { return b ? GCD(b, a%b) : a; }
int LCM(int a, int b) { int g = GCD(a, b); return a / g * b; }

int main(void){
    // Your code here!
    int n,m,k; cin >> n >> m >> k;
    vector<ll> a(n+1),b(m+1);
    FOR(i,1,n) {
        ll aa; cin >> aa;
        a[i] = aa + a[i-1];
    }
    FOR(i,1,m) {
        ll bb; cin >> bb;
        b[i] = bb + b[i-1];
    }
    ll ans = 0; ll j = m;

    rep(i,n+1) {
        if (a[i] > k) break;
        while(b[j] > k - a[i]) {
            j--; // i が大きくなってもjはそれ以上を取る必要は無いので記録しておく
        }
        ans = max(ans, i+j);
    } 
    
    cout << ans << endl;
}


Measured memory_bytes: 6368
#include<bits/stdc++.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define HUGE_NUM 99999999999999999
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;



#define SIZE 100005

struct Info{

	ll all_sum,left_max,rigt_max,mid_max;
};

int N;
ll input[SIZE];
Info table[8*SIZE];


void init(int first_N){
	while(N < first_N)N *= 2;
}

void update(int loc,int value){
	loc += N-1;

	table[loc].all_sum = value;
	table[loc].left_max = value;
	table[loc].rigt_max = value;
	table[loc].mid_max = value;

	if(N == 1)return;

	int parent = (loc-1)/2;

	while(true){

		int left = 2*parent+1,right = 2*parent+2;
		table[parent].all_sum = table[left].all_sum+table[right].all_sum;
		table[parent].left_max = max(table[left].left_max,table[left].all_sum+table[right].left_max);
		table[parent].rigt_max = max(table[right].rigt_max,table[right].all_sum+table[left].rigt_max);
		table[parent].mid_max = max(table[left].rigt_max+table[right].left_max,max(table[left].mid_max,table[right].mid_max));

		if(parent == 0)break;
		else{
			parent = (parent-1)/2;
		}
	}
}

ll query(int search_left,int search_right,int node_id,int node_left,int node_right){

	//今回のノードが検索区間をカバーしていなければ、結果に関係ない値を返す
	if(search_right < node_left || search_left > node_right)return -HUGE_NUM;

	//今回のノードの区間が、検索区間の部分区間である場合、今回のノードの値を返す
	if(search_left <= node_left && search_right >= node_right){
		return table[node_id].mid_max;
	}

	//今回のノードの区間に、一部検索区間と重なっている区間がある場合→再帰的に子どもに尋ねる
	ll left_max = query(search_left,search_right,2*node_id+1,node_left,(node_left+node_right)/2);
	ll right_max = query(search_left,search_right,2*node_id+2,(node_left+node_right)/2+1,node_right);

	return max(left_max,right_max);
}

int main(){

	int first_N,num_query;
	scanf("%d %d",&first_N,&num_query);

	for(int i = 0; i < first_N; i++){

		scanf("%lld",&input[i]);
	}

	N = 1;
	init(first_N);

	for(int i = 0; i < first_N; i++){

		update(i,input[i]);
	}

	int loc;
	ll value;

	printf("%lld\n",max(0LL,query(0,N,0,0,N)));

	for(int loop = 0; loop < num_query; loop++){

		scanf("%d %lld",&loc,&value);
		loc--;

		update(loc,value);
		printf("%lld\n",max(0LL,query(0,N,0,0,N)));
	}

	return 0;
}



Measured memory_bytes: 10260
#include<bits/stdc++.h>
using namespace std;
int main(){
  string s,b;cin>>s;
  set<string> ss;
  int i,j,k;
  queue<string> q;
  q.push(s);
  bool f=false,ff;
  while(!q.empty()){
    s=q.front();q.pop();
    if(s=="ABC") f=true;
    if(f) break;
    if(ss.find(s)!=ss.end()) continue;
    if(s.find("ABC")==-1) continue;
    ss.insert(s);
    //cout << s << endl;
    for(i=0;i<3;i++){
      b="";ff=true;
      for(j=0;j<s.size();j++){
	if(j+2<s.size()&&s[j]=='A'&&s[j+1]=='B'&&s[j+2]=='C'){
	  b+=('A'+i);j+=2;
	}else if(s[j]=='A'+i) ff=false;
	else b+=s[j];
	if(!ff) break;
      }
      if(ff) q.push(b);
    }
  }
  cout << (f?"Yes":"No") << endl;
  return 0;
}

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

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

long long division(long long a,long long b) {
	if (a < 0)return 0;
	else return a / b;
}

int main() {
	long long a, b, c, d,lcm,ans;
	cin >> a >> b >> c >> d;
	lcm = c * d / gcd(c, d);

	ans = b - a + 1 -
		(division(b, c) - division(a - 1, c)) - (division(b, d) - division(a - 1, d)) +
		(division(b, lcm) - division(a - 1, lcm));
	cout << ans << endl;
}

Measured memory_bytes: 256
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Scanner;

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

	class Pair{
		int s;
		int t;
		Pair(int s, int t){
			this.s=s;
			this.t=t;
		}
		@Override
		public String toString() {
			return "Pair [s=" + s + ", t=" + t + "]";
		}
		@Override
		public int hashCode() {
			final int prime = 31;
			int result = 1;
			result = prime * result + getOuterType().hashCode();
			result = prime * result + s;
			result = prime * result + t;
			return result;
		}
		@Override
		public boolean equals(Object obj) {
			if (this == obj)
				return true;
			if (obj == null)
				return false;
			if (getClass() != obj.getClass())
				return false;
			Pair other = (Pair) obj;
			if (!getOuterType().equals(other.getOuterType()))
				return false;
			if (s != other.s)
				return false;
			if (t != other.t)
				return false;
			return true;
		}
		private Main getOuterType() {
			return Main.this;
		}

	}

	HashMap<Pair, Integer>I = new HashMap<>();

	ArrayList<Boolean> used = new ArrayList<>();
	boolean next[][];
	int N;
	int K = 0;
	int cs[];
	public void run() {
		Scanner sc = new Scanner(System.in);
		N=sc.nextInt();
		ArrayList<ArrayList<Integer>> G = new ArrayList<ArrayList<Integer>>();
		ArrayList<Pair> vp = new ArrayList<Pair>();

		cs = new int[N];
		for(int i=0; i<N; i++) {
			G.add(new ArrayList<Integer>());
		}

		for(int i=0; i<N-1; i++) {
			int a = sc.nextInt();
			a--;
			int b = sc.nextInt();
			b--;
			G.get(a).add(b);
			G.get(b).add(a);
			vp.add(new Pair(a,b));
		}
		ArrayDeque<Integer> que = new ArrayDeque<Integer>();
		for(int i=0; i<N; i++) {
			cs[i]=0;
			used.add(false);
		}
		used.set(0, true);
		que.add(0);
		while(!que.isEmpty()) {
			int v = que.poll();
			if(K < G.get(v).size()) {
				K = G.get(v).size();
			}
			int cur=1;
			for(int u : G.get(v)) {
				if(used.get(u)) {
					continue;
				}
				if(cur == cs[v]) {
					cur++;
				}
				cs[u] = cur;
				I.put(new Pair(u,v), cur);
				I.put(new Pair(v,u), cur);
				cur++;
				used.set(u, true);
				que.add(u);
			}
		}
		System.out.println(K);
		for(Pair p : vp) {
			System.out.println(I.get(p));
		}
		sc.close();
	}


}

Measured memory_bytes: 104644
#include <iostream>
#include <fstream>
#include <algorithm>
#include <vector>
#include <math.h>
#include <cmath>
#include <string>
#include <string.h>
#include <map>
#include <set>
#include <stdio.h>
#include <queue>
#define pb push_back
#define ppb pop_back
#define nd second
#define st first
#define ll long long
#define pi 3.1415926535897932384626433832795028841971
using namespace std;

int h, w; 
vector <string> s; 

bool check(int a, int b)
{
	if ((a - 1 < 0) || (b - 1 < 0) || (a + 1 == h) || (b + 1 == w))
		return false; 
	return true; 
}

int main()
{
	cin >> h >> w; 
	for (int i = 0; i < h; i++)
	{
		string si; 
		cin >> si; 
		s.pb(si); 
	}
	
	for (int i = 0; i < h; i++)
		for (int j = 0; j < w; j++)
			if (check(i, j)) 
				if ((s[i][j + 1] == '.')
				&& (s[i][j - 1] == '.')
				&& (s[i + 1][j] == '.')
				&& (s[i - 1][j] == '.')
				&& (s[i][j] == '#'))
				{
					puts("No"); 
					return 0; 
 				}
	puts("Yes"); 
	
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int INF = 1 << 30;
typedef tuple< int, int, int, int > State;
const int vy[2][7] = {
  {1, 0, -1, -1, -1, 0, 0},
  {1, 1, 0, -1, 0, 1, 0}
};
const int vx[7] = {0, 1, 1, 0, -1, -1, 0};

int sx, sy, gx, gy, N;
bool s[300][300];
int min_cost[300][300][6];
int lx, ly;

int Dijkstra()
{
  fill_n(**min_cost, 300 * 300 * 6, INF);
  priority_queue< State, vector< State >, greater< State > > que;
  que.emplace(0, sy, sx, 0);
  min_cost[sy][sx][0] = 0;
  while(!que.empty()) {
    int cost, y, x, mod;
    tie(cost, y, x, mod) = que.top(); que.pop();
    if(gx == x && gy == y) return(cost);
    if(cost > min_cost[y][x][mod]) continue;
    for(int i = 0; i < 7; i++) {
      int ny = y + vy[x & 1][i], nx = x + vx[i];
      if(abs(ny - 150) > ly - 150 || abs(nx - 150) > lx - 150) continue;
      if(s[ny][nx]) continue;
      int ncost = cost + (abs((x - 150) * (y - 150) * mod) % 6 != i);
      if(ncost >= min_cost[ny][nx][(mod + 1) % 6]) continue;
      min_cost[ny][nx][(mod + 1) % 6] = ncost;
      que.emplace(ncost, ny, nx, (mod + 1) % 6);
    }
  }
  return(-1);
}

int main()
{  
  cin >> sx >> sy >> gx >> gy;
  sx += 150, sy += 150;
  gx += 150, gy += 150;
  cin >> N;
  for(int i = 0; i < N; i++) {
    int x, y;
    cin >> x >> y;
    s[y + 150][x + 150]++;
  }
  cin >> lx >> ly;
  lx += 150, ly += 150;
  cout << Dijkstra() << endl;
}

Measured memory_bytes: 5376
import sys

n = int(input())
while n != 0:
    max_seq = []
    max_val = int(input())
    for i in range(n-1):
        num = int(input())
        if num >= 0 and max_val >= 0:
            max_val += num
        else:
            if max_val >= 0:
                max_seq.append(max_val)
            if max_val >= 0 and max_val+num >= 0:
                max_val += num
            elif max_val >= 0 and max_val+num < 0:
                max_val = num
            elif max_val < 0 and max_val < num:
                max_val = num
    max_seq.append(max_val)
    print(max(max_seq))
    n = int(input())


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

signed main()
{
   int H,W,S,T; cin>>H>>W>>S>>T;
   if(H%2==0 or W%2==0){
      cout<<"Yes"<<endl;
   }else{
      if((S+T)%2==0){
         cout<<"Yes"<<endl;
      }else{
         cout<<"No"<<endl;
      }
   }
}




Measured memory_bytes: 3104
#include <stdio.h>
#include <string.h>

int main(void)
{
	char str[21];
	int i,j;
	
	scanf("%s",str);
	
	i = strlen(str) -1;
	
	for(j = i;j >= 0;j--){
		printf("%c",str[j]);
	}
	printf("\n");
	
	return(0);
}

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

int main() {
  int N;
  cin >> N;
  vector <tuple<string, int, int>> a;
  for(int i = 1; i <= N; ++i){
    string s;
    int p;
    cin >> s >> p;
    p = -p;
    a.push_back(tie(s, p, i));         
  }
  sort(a.begin(), a.end());
  for(int i =0; i < N; i++){
	cout << get<2>(a[i]) << endl;
  }
}

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

#define pb push_back
#define mp make_pair
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef complex<double> point;
#define xx real()
#define yy imag()

#define REP(i, a, b) for(int i = (a); i < (int)(b); i++)
#define REPN(i, a, b) for(int i = (a); i <= (int)(b); i++)
#define FA(it, x) for(__typeof((x).begin()) it = (x).begin(); it != (x).end(); it++)
#define SZ(x) (int)(x).size()
#define BE(x) (x).begin(), (x).end()
#define SORT(x) sort(BE(x))
#define _1 first
#define _2 second

#define x1 gray_cat_x1
#define y1 gray_cat_y1

template<class T> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }

#define file "I1"

const double EPS = 1e-9;
const double PI = acos(-1.);
const int INF = 1e9;
const ll MOD = 1e9 + 7;

const int MAXN = 6e2 + 5;

int v[MAXN][MAXN];

vector<pii> ee[2];

int col[2][MAXN][MAXN];

int col_cnt[3][3];

int n;

void dfs(int si, int sj, int ind, int cl){
	col[ind][si][sj] = cl;
	//return;
	REP(k, 0, SZ(ee[ind])){
		int di = ee[ind][k]._1;
		int dj = ee[ind][k]._2;
		int i1 = si + di, j1 = sj + dj;
		if (i1 >= 0 && i1 < 2 * n && j1 >= 0 && j1 < 2 * n && !col[ind][i1][j1]){
			dfs(i1, j1, ind, 3 - cl);
		}
	}
}

void solve(){
	int d[2];
	cin >> n >> d[0] >> d[1];
	REP(i, -2 * n + 1, 2 * n){
		REP(j, -2 * n + 1, 2 * n){
			REP(k, 0, 2){
				if (i * i + j * j == d[k]){
					ee[k].pb(mp(i, j));
				}
			}
		}
	}
	
	REP(k, 0, 2){
		REP(i, 0, 2 * n){
			REP(j, 0, 2 * n){
				if (!col[k][i][j]){
					dfs(i, j, k, 1);
				}
			}
		}
	}
	
	REP(i, 0, 2 * n){
		REP(j, 0, 2 * n){
			col_cnt[col[0][i][j]][col[1][i][j]]++;
		}
	}
	
	int maxi = 1, maxj = 1;
	REPN(i, 1, 2){
		REPN(j, 1, 2){
			if (col_cnt[i][j] > col_cnt[maxi][maxj]){
				maxi = i;
				maxj = j;
			}
		}
	}
	
	int printed = 0;
	REP(i, 0, 2 * n){
		REP(j, 0, 2 * n){
			if (printed < n * n && col[0][i][j] == maxi && col[1][i][j] == maxj){
				printf("%d %d\n", i, j);
				printed++;
			}
		}
	}
}   

int main(){

    //freopen(file".in", "r", stdin); freopen(file".out", "w", stdout);
    int t = 1;
    //cin >> t;
    while(t--){
        solve();    
    }
}


Measured memory_bytes: 33152
#include<stdio.h>
#include<stdlib.h>
#include<string.h>

int top, S[1000];

void push(int x){
	S[++top]=x;
}

int pop(){
	top--;
	return S[top+1];
}

int main(){
	int a,b;
	char s[100];
	top=0;
	
	while(scanf("%s",s) !=EOF){
		if(s[0]=='+'){
			a=pop();
			b=pop();
			push(a+b);
		}else if(s[0]=='-'){
			b=pop();
			a=pop();
			push(a-b);
		}else if(s[0]=='*'){
			a=pop();
			b=pop();
			push(a*b);
		}else{
			push(atoi(s));
		}
	}
	
	printf("%d\n",pop());
	
	return 0;
}

Measured memory_bytes: 548
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>

int main(void){
    long long int i, j, k, n, ans=0, po=0, d;
    scanf("%lld", &d);
    long long int c[26], s[d+1][26], t[d+1], l[26];
    for(i=0; i<26; i++) l[i] = 0;
    for(i=0; i<26; i++) scanf("%lld", &c[i]);
    for(i=0; i<d; i++){
        for(j=0; j<26; j++) scanf("%lld", &s[i+1][j]);
    }
    for(i=0; i<d; i++) scanf("%lld", &t[i+1]);
    for(i=0; i<d; i++) t[i+1]--;
    ans = 0;
    for(i=1; i<d+1; i++){
        ans += s[i][t[i]];
        l[t[i]] = 0;
        for(j=0; j<26; j++){
            if(j != t[i]){
                l[j]++;
                ans -= c[j]*l[j];
            }
        }
        printf("%lld\n", ans);
    }

    
}

Measured memory_bytes: 1804
#include<cstring>
#include<iostream>
using namespace std;
string s1;
int main() {
    cin>>s1;
    int a=s1[s1.length()-1]-'0';
    if(a==2||a==4||a==5||a==7||a==9) puts("hon");
    if(a==0||a==1||a==6||a==8) puts("pon");
    if(a==3) puts("bon");
    return 0;
}

Measured memory_bytes: 3136
class UnionFind:
    MAX_N = 0
    PAR  = [] 
    RANK = []

    def __init__(self,n):
        self.MAX_N = n
        self.PAR = [ i for i in range(n)]
        self.RANK= [ 0 ] * n

    def find(self,x):
        if self.PAR[x] == x:
            return x
        else:
            self.PAR[x] = self.find(self.PAR[x])
            return self.PAR[x] 

    def union(self,x,y):
        x = self.find(x)
        y = self.find(y)
        if x == y:
            return
        if self.RANK[x] < self.RANK[y]:
            self.PAR[x] = y
        else:
            self.PAR[y] = x
            if self.RANK[x] == self.RANK[y]:
                self.RANK[x] += 1

    def same(self,x,y):
        return self.find(x) == self.find(y)

N,M = map(int,input().split())
Data = list(map(int,input().split()))
graph = UnionFind(N+1)
for _ in range(M):
    x1,y1 = map(int,input().split())
    graph.union(x1,y1)

ans = 0
for i in range(1,N+1):
    if graph.same(i,Data[i-1]):
        ans+=1

print(ans)


Measured memory_bytes: 13812
N, M = map(int, input().split())
guess = [-1] * N
 
for i in range(M):
  s, c = map(int, input().split())
  s = s - 1
  if s == 0 and c == 0 and N>1:
    print(-1)
    exit()
  if guess[s] == -1:
    guess[s] = c
  elif guess[s] == c:
    continue
  else:
    print(-1)
    exit()
 
if len(guess) > 1 and guess[0] == -1:
  guess[0] = 1
for i in range(len(guess)):
  if guess[i] == -1:
    guess[i] = 0
    
res = map(str, guess)
print(''.join(res))

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
#define int long long int
#define error(x) cerr << #x << " = " << x << endl


int32_t main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int t,n,m,i,j,k,sum=0;
	string a;
	cin>>a;
	set<int> s;
	for(i=0;i<a.size();i++){
		s.insert(a[i]);
	} 
	if(s.size()>1) cout<<"Yes"<<'\n';
	else cout<<"No"<<'\n';
	
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
int vx[3000],vy[3000];
char a[5001][5001];

int main(){
  int n,i,j,max,tsz,mx,my;
  for (i=0;i<3000;i++) {
    vx[i]=0;
    vy[i]=0;
  } 

  scanf("%d", &n);
  while(n !=0){
    max=0;
    tsz=0;
    //printf("%d",n);
    for (i=0;i<n;i++){
      scanf("%d %d",&vx[i],&vy[i]);
      a[vx[i]][vy[i]]=1;
    }
    //   printf("test\n");
    for (i=0;i<n;i++){
      for (j=0;j<n;j++){
	//printf ("%d, %d\n",vy[i]-vy[j]+vx[i],vx[i]-vx[j]+vy[i]);
	mx=vy[i]-vy[j];
	my=vx[j]-vx[i];
	if(mx+vx[i]>=0 && my+vy[i] >=0 && mx+vx[j]>=0 && my+vy[j] >=0 &&
	   mx+vx[i]<=5000 && my+vy[i] <=5000 && mx+vx[j]<=5000 && my+vy[j] <=5000){
	  if (a[mx+vx[i]][my+vy[i]]==1 && a[mx+vx[j]][my+vy[j]]==1)
	    tsz=mx*mx+my*my;
	}
	if(vx[i]-mx>=0 && vy[i]-my >=0 && vx[j]-mx>=0 && vy[j]-my >=0 &&
	   vx[i]-mx<=5000 && vy[i]-my <=5000 && vx[j]-mx<=5000 && vy[j]-my <=5000){
	  if (a[vx[i]-mx][vy[i]-my]==1 && a[vx[j]-mx][vy[j]-my]==1)
	    tsz=mx*mx+my*my;
	}
	if (tsz>max) max=tsz;
      }
    }
    printf("%d\n",max);
    scanf("%d", &n);
  }
  return 0;
}

Measured memory_bytes: 24468
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  char C;
  cin>>C;
  if(C=='a'){
    cout<<"vowel"<<endl;
  }
  else if(C=='i'){
    cout<<"vowel"<<endl;
  }
  else if(C=='u'){
    cout<<"vowel"<<endl;
  }
  else if(C=='e'){
    cout<<"vowel"<<endl;
  }
  else if(C=='o'){
    cout<<"vowel"<<endl;
  }
  else{
    cout<<"consonant"<<endl;
  }
}

Measured memory_bytes: 3620
#include <cstdio>
#include <climits>
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <cmath>
#include <stack>
#include <algorithm>
#include <iomanip>
#include <map>
#include <queue>
#include <functional>
#include <numeric>
#include <chrono>
#include <cstdlib>
using ll = long long;
using namespace std;

const ll MOD = 1e9 + 7;
const double pi = acos(-1);
typedef pair<int, int> P;
#define REP(i, n) for (int(i) = 0; (i) < (n); ++(i))
#define repi(i, a, b) for (int i = int(a); i < int(b); ++i)
#define EPS 1e-4
#define OUTPUT(i) (cout << (ll)i << endl)

/*unsigned int xor128(void)
{
    static unsigned int x = 123456789, y = 362436069, z = 521288629, w = 88675123;
    unsigned int t = (x ^ (x << 11));
    x = y;
    y = z;
    z = w;
    return (w = (w ^ (w >> 19)) ^ (t ^ (t >> 8)));
}
unsigned int xor128rnd(unsigned int m)
{
    return xor128() % m;
}*/

bool operator<(const pair<ll, ll> &a, const pair<ll, ll> &b)
{

    if (a.first == b.first)
        return a.second < b.second;

    return a.first < b.first;
}

vector<ll> v;

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

    //cout << fixed << setprecision(15);
    ll N;
    cin >> N;

    int minV = 10000;
    for (ll i = 1; i * i <= N; ++i)
    {
        if (N % i == 0)
        {
            ll a = N / i;
            ll b = i;
            int cnt1 = 0, cnt2 = 0;
            while (a)
            {
                cnt1++;
                a /= 10;
            }

            while (b)
            {
                cnt2++;
                b /= 10;
            }
            minV = min(minV, max(cnt1, cnt2));
        }
    }
    cout << minV << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long int64;
int64 sum = 0;
string S;
void Calc(string s,int i);
int main(){
  string s;
  cin >> S;
  Calc(s,0);
  cout << sum << endl;
  return 0;
}
void Calc(string s,int i){
  s += S[i];
  if(i + 1 == S.size()){
    int64 ans = 0;
    for(int j = 0;j < s.size();j++){
      if(isdigit(s[j])){
	ans *= 10;
	ans += s[j] - '0';
      }else{
	sum += ans;
	ans = 0;
      }
    }
    sum += ans;
    return;
  }
  Calc(s,i + 1);
  s += '+';
  Calc(s,i + 1);
  return;
}


Measured memory_bytes: 256
(function main(){
  const lines = require('fs').readFileSync('/dev/stdin', 'utf8').trim().split('\n');
  const n = Number(lines.shift());
  console.log(' ' + buildMaxHeap(lines.shift().split(' ').map(Number)).join(' '));
})();

function buildMaxHeap(arr) {
  const n = arr.length;
  const maxHeapify = (i) => {
    let left, right, largest;
    left = 2 * i + 1;
    right = 2 * i + 2;
    if (left < n && arr[left] > arr[i]) largest = left;
    else largest = i;
    if (right < n && arr[right] > arr[largest]) largest = right;
    if (largest != i) {
      arr[largest] = [arr[i], arr[i] = arr[largest]][0];
      maxHeapify(largest);
    }
    return;
  };

  for (let i = Math.floor(arr.length / 2); i >= 0; i--) maxHeapify(i);
  return arr;
}



Measured memory_bytes: 110732
#include <bits/stdc++.h>
using namespace std;
// type alias
typedef long long LL;
typedef pair<int,int> II;
typedef tuple<int,int,int> III;
typedef vector<int> VI;
typedef vector<string> VS;
typedef unordered_map<int,int> MAPII;
typedef unordered_set<int> SETI;
template<class T> using VV=vector<vector<T>>;
// minmax
template<class T> inline T SMIN(T& a, const T b) { return a=(a>b)?b:a; }
template<class T> inline T SMAX(T& a, const T b) { return a=(a<b)?b:a; }
// repetition
#define FORE(i,a,b) for(int i=(a);i<=(b);++i)
#define REPE(i,n)  for(int i=0;i<=(n);++i)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  for(int i=0;i<(n);++i)
#define FORR(x,arr) for(auto& x:arr)
#define SZ(a) int((a).size())
// collection
#define ALL(c) (c).begin(),(c).end()
// DP
#define MINUS(dp) memset(dp, -1, sizeof(dp))
#define ZERO(dp) memset(dp, 0, sizeof(dp))
// stdout
#define println(args...) fprintf(stdout, ##args),putchar('\n');
// debug cerr
template<class Iter> void __kumaerrc(Iter begin, Iter end) { for(; begin!=end; ++begin) { cerr<<*begin<<','; } cerr<<endl; }
void __kumaerr(istream_iterator<string> it) { (void)it; cerr<<endl; }
template<typename T, typename... Args> void __kumaerr(istream_iterator<string> it, T a, Args... args) { cerr<<*it<<"="<<a<<", ",__kumaerr(++it, args...); }
template<typename S, typename T> std::ostream& operator<<(std::ostream& _os, const std::pair<S,T>& _p) { return _os<<"{"<<_p.first<<','<<_p.second<<"}"; }
#define __KUMATRACE__ true
#ifdef __KUMATRACE__
#define dump(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); __kumaerr(_it, args); }
#define dumpc(ar) { cerr<<#ar<<": "; FORR(x,(ar)) { cerr << x << ','; } cerr << endl; }
#define dumpC(beg,end) { cerr<<"~"<<#end<<": "; __kumaerrc(beg,end); }
#else
#define dump(args...)
#define dumpc(ar)
#define dumpC(beg,end)
#endif

// $ cp-batch GettingDifference | diff GettingDifference.out -
// $ g++ -std=c++14 -Wall -O2 -D_GLIBCXX_DEBUG -fsanitize=address GettingDifference.cpp && ./a.out

/*

 7/14/2020

 20:43-

 */

const int MAX_N=1e6+1;
LL A[MAX_N],K;
int N;

LL gcd(LL a, LL b) { return b==0?a:gcd(b,a%b); }
bool solve() {
  sort(A,A+N);
  if(A[N-1]<K) return false;
  LL g=A[0];
  REP(i,N) g=gcd(g,A[i]);
  //dump(g,K);
  return (K%g)==0;
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout<<setprecision(12)<<fixed;

  cin>>N>>K;
  REP(i,N) cin>>A[i];
  cout<<(solve()?"POSSIBLE":"IMPOSSIBLE")<<endl;

  return 0;
}


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

#define mod 1000000007

// 根付き木の各頂点の親を求める
// ある頂点を親として部分木の頂点の個数
int root;
#define MAX_N 200001
vector<int> graph[MAX_N];
int par[MAX_N], dp[MAX_N]; // 0で初期化
void tree_init(int r){
    for (int i = 1; i < MAX_N; ++i) {
        dp[i] = 1;
    }
    root = r;
    par[root] = -1;
    stack<int> st_op, st_cl;
    st_op.push(root);
    while (! st_op.empty()) {
        int t = st_op.top(); st_op.pop();
        st_cl.push(t);
        for (int x: graph[t]) {
            if (x == par[t]) continue;
            par[x] = t;
            st_op.push(x);
        }
    }
    while (! st_cl.empty()) {
        int t = st_cl.top(); st_cl.pop();
        for (int x: graph[t]) {
            if (x == par[t]) continue;
            dp[t] += dp[x];
        }
    }
}

// F_mod 上でのべき乗, 蟻本p115
ll modPow(ll x, ll n) {
    ll res = 1;
    while(n > 0){
        if(n & 1) res = res * x % mod;
        x = x * x % mod;
        n >>= 1;
    }
    return res;
}

// Fermat の小定理を用いた F_mod 上での逆元計算x^(mod-2)
inline ll Inverse(ll x){
    return modPow(x, mod - 2);
}

ll pow2[MAX_N];
void pow2_init(){
    pow2[0]=1;
    for(int i = 1; i < MAX_N; ++i) {
        pow2[i] = pow2[i-1] * 2 % mod;
    }
}

ll sub(ll x, ll y) {
    x -= y;
    if (x < 0) return x + mod;
    return x;
}



int N;
ll calc(vector<int>v){
    if(v.size() == 0)
        return 0;
    int s = N - 1;
    for (int i = 0; i < v.size(); ++i) {
        s -= v[i];
    }
    v.push_back(s);

    ll res = sub(pow2[N-1], 1);
    for (int i = 0; i < v.size(); ++i) {
        res = sub(res, pow2[v[i]]);
        res += 1;
        res %= mod;
    }
    return res;
}



int main() {
    pow2_init();

    cin >> N;
    for (int i = 0; i < N - 1; ++i) {
        int a, b;
        cin >> a >> b;
        graph[a].push_back(b);
        graph[b].push_back(a);
    }
    tree_init(1);
    ll ans = 0;
    for (int i = 1; i <= N; ++i) {
        vector<int>value;
        for (int x: graph[i]) {
            if(x == par[i]) continue;
            value.push_back(dp[x]);
        }
        ans += calc(value);
        ans %= mod;
    }


    ans *= Inverse(pow2[N]);
    ans %= mod;
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 16368
N, K, Q = map(int, input().split())
A = [int(input()) for _ in range(Q)]
lis = [K-Q]*N
if K > Q:
    for _ in range(N):
        print("Yes")
    exit()
for i in A:
    lis[i-1] += 1
for j in range(N):
    if lis[j] > 0:
        print("Yes")
    else:
        print("No")

Measured memory_bytes: 55896
#include<cstdio>
#include<bits/stdc++.h>
#include<iostream>
#include<algorithm>
#include<queue>
#include<string>
#include<vector>
#include<float.h>
#include<math.h>
#include<map>
#include<iomanip>
#include<numeric>
using  ll = long long;
using namespace std;
const ll M = 1000000007;

int main(){
  int n, sum = 0, ans; cin >> n;
  int a[2][101];
  for(int i = 0; i < 2; i++){
    for(int j = 0; j < n; j++){
      cin >> a[i][j];
    }
  }

  for(int i = 0; i < n; i++){
    sum += a[0][i];
  }
  sum += a[1][n-1];
  ans = sum;
  for(int i = n-1; i >= 1; i--){
    sum -= a[0][i];
    sum += a[1][i-1];

    if(sum > ans) ans = sum;
  }

  cout << ans << endl;
}


Measured memory_bytes: 256
/*dismint|jjc*/
#include <bits/stdc++.h>
using namespace std;
#define forl(V, S, E) for(int V = S; V < E; V++)
#define ford(V, S, E) for(int V = S; V >= E; V--)
#define fore(E, X) for(auto &E:X)
#define println(X) cout << X << endl
#define printe(X) for(auto &E:X) cout << E << " "; cout << endl
typedef unordered_map<int, unordered_set<int>> graph;
typedef long long ll;

int main() {
	ios_base::sync_with_stdio(false); cin.tie(NULL);
	int n, m; cin >> n >> m;
	int ans = n*(n-1)/2 + m*(m-1)/2;
	println(ans);
}


Measured memory_bytes: 256
//author:luckYrat(twitter:@luckYrat_)
//#include <bits/stdc++.h>

//def
#include <iostream>

#include <cmath>
#include <algorithm>
#include <iomanip>

//array
#include <vector>
#include <set>
#include <stack>
#include <queue>
#include <map>
#include <utility>
#include <climits>



using namespace std;

using ll = long long;
using P = pair<ll,ll>;

#define anyfill(n,s) setw(n) << setfill(s)
#define loop(s) for(int i = 0; s > i; i++)
#define rep(i,q) for(int i = 0; (q) > i; i++)
#define repp(i,n,q) for(int i = n; (q) > i; i++)
#define dep(i,q) for(int i = (q); 0 < i; i--)


#define MAX 1000000000
const int mod = 1000000007;
#define EPS (1e-10)

#define pb push_back
#define fir first
#define scn second
#define ednl endl

#define YesNo(a) (a?"Yes":"No")
#define YESNO(a) (a?"YES":"NO")
#define yesno(a) (a?"yes":"no")


P ar4[4] = {{0,1},{0,-1},{1,0},{-1,0}};
P ar8[8] = {{-1,-1},{-1,0},{-1,1},{0,-1},{0,1},{1,-1},{1,0},{1,1}};
/*
確認ポイント
cout << fixed << setprecision(n) << 小数計算//n桁の小数表記になる
vector.unique()は隣接した同じ要素を削除するので先にソートをする

計算量は変わらないが楽できるシリーズ
C++11以降でmin({a,b,c...})で複数個のmic,maxを処理できる
min(max)_element(iter,iter)で一番小さい(大きい)値のポインタが帰ってくる
count(iter,iter,int)でintがiterからiterの間にいくつあったかを取得できる

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


int gcd(int a,int b){
  if(a%b)return gcd(b,a%b);
  else return b;
}
int main(){
  int r,d,x;cin>>r>>d>>x;
  for(int i = 0; 10 > i; i++){
    cout << r*x-d << endl;
    x = r*x-d;
  }
  
}


Measured memory_bytes: 256
/* ITP1_6_B:Finding Missing Cards */
/* 20181122 AOJ */

#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>

int main(void) {
	int A[4][13] = {0};
	int n = 0;
	int i, j, m;
	char ch;

	scanf("%d", &n);
	while(n--) {
		getchar();
		scanf("%c %d", &ch, &m);
		switch(ch) {
			case 'S' : A[0][m - 1] = 1; break;
			case 'H' : A[1][m - 1] = 1; break;
			case 'C' : A[2][m - 1] = 1; break;
			case 'D' : A[3][m - 1] = 1; break;
			default  : break;
		}
	}

	for(i = 0; i < 4; i++) {
		for(j = 0; j < 13; j++) {
			if(A[i][j] == 0) {
				switch(i) {
					case 0 : printf("S %d\n", j + 1); break;
					case 1 : printf("H %d\n", j + 1); break;
					case 2 : printf("C %d\n", j + 1); break;
					case 3 : printf("D %d\n", j + 1); break;
					default : break;
				}
			}
		}
	}

	return 0;
}


Measured memory_bytes: 2044
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int N, ans(0);
    cin >> N;
    int A[N];
    for (int i = 0; i < N; ++i)
        cin >> A[i];
    bool flag(true);
    while (flag)
    {
        flag = !flag;
        for (int j = N - 1; j >= 1; --j)
        {
            if (A[j] < A[j - 1])
            {
                swap(A[j], A[j - 1]);
                ans++;
                flag = true;
            }
        }
    }
    for (int i = 0; i < N; ++i)
    {
        cout << A[i] << flush;
        if (i != N - 1)
            cout << ' ' << flush;
    }
    cout << endl
         << ans << endl;
}


Measured memory_bytes: 3104
N = int(input()) # ボールの数
K = int(input()) # Bの位置
xs = [int(i) for i in input().split()] # ボールの位置

half = K / 2

total = 0
for x in xs:
    if x < half:
        total += x
    else:
        total += (K-x)

# 最後に二倍すればよい
print(2*total)



Measured memory_bytes: 8976
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define rep2(i,x,n) for(int i=x; i<(n); i++)
#define all(n) begin(n),end(n)
struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;
const long long INF = numeric_limits<long long>::max();
int main(){
    int A,B;
    cin>>A>>B;
    string ans;
    if(A==B){
        ans="Draw";
    }else if(A==1){
        ans="Alice";
    }else if(B==1){
        ans="Bob";
    }else if(A<B){
        ans="Bob";
    }else{
        ans="Alice";
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <string>
#include <map>
#include <cstdio>
#include <numeric>
#include <iomanip>

using namespace std;

using ll = long long;

ll H, W, K;
ll G[32][32];



int main()
{
    cin >> H >> W >> K;
    string s[10];
    for(ll i = 0;i < H;i++)
    {
        cin >> s[i];
    }
    ll ans = 0;
    for(ll i = 0;i < (1 << H);i++)
    {
        for(ll j = 0;j < (1 << W);j++)
        {
            ll cnt = 0;
            for(ll y = 0;y < H;y++)
            {
                for(ll x = 0;x < W;x++)
                {
                    if(s[y][x] == '#' && !((i >> y) & 1) && !((j >> x) & 1))
                    {
                        cnt++;
                    }
                }
            }
            if(cnt == K){ans++;}
            //cout << i << " " << j << " " << cnt << endl;
        }
    }
    cout << ans << endl;
    return 0;
}

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

int main()
{
  int n, p; cin >> n >> p;
  vector<int> a(n);
  int odd = 0;
  rep(i, n) {
    cin >> a[i];
    if (a[i]%2 == 1) odd++;
  }
  if (odd == 0) {
    if (p == 0) cout << (ll)pow(2, n) << endl;
    else cout << 0 << endl;
  } else cout << (ll)pow(2, n-1) << endl;

  return 0;
}


Measured memory_bytes: 256
s=input()
ls=len(s)
if ls%2:
    s1="10"*(ls//2)+"1"
    s2="01"*(ls//2)+"0"
else:
    s1="10"*(ls//2)
    s2="01"*(ls//2)
d=int(s,2)
d1=int(s1,2)
d2=int(s2,2)
h1=format(d^d1,"b").count("1")
h2=format(d^d2,"b").count("1")
print(min(h1,h2))

Measured memory_bytes: 3444
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 = new int[n];

		for (int i = 0; i < n; i++) {
			A[i] = sc.nextInt();
		}

		int sw = bubbleSort(A);
		for (int i = 0; i < n; i++) {
			System.out.print(i!=(n-1) ? (A[i] + " ") : A[i] + "\n");
		}
		System.out.println(sw);

		sc.close();
	}

	static int bubbleSort(int[] A) {
		// 各要素を交換する
		// フラグがtrueの間やる
		int sw = 0; //交換した回数
		boolean flag = false;
		while (!flag) {
			flag = true;
			for (int i = A.length - 1; i > 0; i--) {
				if (A[i] < A[i-1]) {
					int w  = A[i];
					A[i]   = A[i-1];
					A[i-1] = w;
					flag = false;
					++sw;
				}
			}
		}
		return sw;
	}
}



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

public class Main {

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

  public void run() {
    
    try(BufferedReader in = new BufferedReader(new InputStreamReader(System.in))) {

      int n = Integer.parseInt(in.readLine());
      String line = in.readLine();
      int ans = 0;

      int offset=0, next=0;
      char regex = ' ';
      boolean isContinue = true;
      for(int i=0; isContinue; i++) {
        if((next = line.indexOf(regex, offset)) == -1) {
          next = line.length();
          isContinue = false;
        }

        ans += Integer.numberOfTrailingZeros(
          Integer.parseInt(line.substring(offset, next)) );

        offset = ++next;
      }

      System.out.println(ans);
    }
    catch(IOException e) {
      System.err.println(e);
    }
  }
}

Measured memory_bytes: 27348