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

#define debug(x) cout<<#x<<" :: "<<x<<"\n";
#define debug2(x,y) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<"\n";
#define debug3(x,y,z) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<"\t"<<#z<<" :: "<<z<<"\n";

#define     SPEED       ios::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define 	setprecn(x) cout<<fixed<<setprecision(x);
#define 	ll          long long int
#define 	pb          push_back
#define 	pll         pair<ll,ll>
#define 	vll         vector<ll>
#define 	ff          first
#define 	ss          second
#define 	all(a)      (a).begin(),(a).end()
#define 	sz(x)       (ll)x.size()
#define 	hell        1000000007
#define 	rep(i,n)    for(ll i=0;i<n;i++)
#define 	repe(i,a,b) for(ll i=a;i<b;i++)
#define 	lbnd        lower_bound
#define 	ubnd        upper_bound
#define 	bs          binary_search

ll power(ll a,ll b)
{
	if(b==0)
		return 1;
	if(b==1)
		return a;
	ll c=power(a,b/2);
	if(b%2==0)
		return((c%hell)*(c%hell))%hell;
	return ((((c%hell)*(c%hell))%hell)*(a%hell))%hell;
}

/********************************************************/
//	d.erase(unique(all(d)), d.end());




int main()
{
	SPEED;
	ll n,k,m,i,j,c=0,cs=0,t;
	t=1;

	// cin>>t;
	string s;
	while(t--)
	{
		cin>>s;
		// n=s.length();
		// ll a[n];
		n=(s[0]-'0')*10+(s[1]-'0');
		m=(s[2]-'0')*10+(s[3]-'0');
		if(n>0 && n<13 && m>0 && m<13)
			cout<<"AMBIGUOUS";
		else if(n>0 && n<13)
			cout<<"MMYY";
		else if(m>0 && m<13)
			cout<<"YYMM";
		else cout<<"NA";
		if(t!=0)
	   		cout<<"\n";
	}
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(void)
{ char i[100000];
  scanf("%s",&i);
 int count=0;
 int j;
   for(j=1;j<strlen(i);j++)
   { if(i[j]==i[j-1] && i[j]=='1')
     { i[j]='0';count++;}
    if(i[j]==i[j-1] && i[j]=='0')
     { i[j]='1';count++;}
   }
 printf("%d",count);
 return 0;
}

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

int main() {
  int n; cin >>n;
  int wa=0;
  vector<int>a(n);
  for(int i=0;i<n;i++){
    cin>>a[i];
    wa+=a[i];
  }
  double heikin=(double)wa/(double)n;
  double sa=INT_MAX;
  int kotae=0;
  for(int i=n-1;i>=0;i--){
    double tmp=fabs((double)a[i]-heikin);
    if(sa>=tmp){
      sa=tmp;
      kotae=i;
    }
  }
  cout<<kotae<<endl;
  return 0;
}

Measured memory_bytes: 3568
#include<stdio.h>

#define N 200000


int main(void){

	int n;
	int A[N],max,min,value;
	
	scanf("%d",&n);
	
	for(int i = 0;i<n;i++){
		
		scanf("%d",&A[i]);
	}
	
	
	min =A[0];
	max=A[1]-A[0];
	
	for(int i=1;i<n;i++){
		
	value = A[i] - min;
	if(max<value){max=value;}
	if(min>A[i]){min = A[i];}
		
		
	}
	
	printf("%d\n",max);
	
	return 0;
	}


Measured memory_bytes: 3516
n, k = map(int, input().split())
s = 0
for i in range(k, k + 2 * n):
    s -= i
for i in range(k + 2 * n, k + 3 * n):
    s += i
if s >= 0:
    a = [0] * n
    b = list(range(k + n, k + 2 * n))
    c = [0] * n
    for i in range(n // 2):
        c[i * 2 + 1] = k + 2 * n + i
    for i in range(n - n // 2):
        c[i * 2] = k + 2 * n + n // 2 + i
    for i in range(n // 2):
        a[i * 2 + 1] = k + n // 2 - i - 1
    for i in range(n - n // 2):
        a[i * 2] = k + n - i - 1
    for i in range(n):
        print(a[i], b[i], c[i])
else:
    print(-1)


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

int main()
{
	int N,K;
	cin >> N >> K;
	int count[N];
	int i;
	for(i = 0;i < N;i++)
	{
		count[i] = 0;
	}
	for(i = 0;i < K;i++)
	{
		int tmpnum;
		cin >> tmpnum;
		vector<int> tmp(tmpnum);
		for(int j = 0;j < tmpnum;j++)
		{
			cin >> tmp[j];
			count[tmp[j]-1]++;
		}
	}
	int solution = 0;
	for(i = 0;i < N;i++)
	{
		if(count[i] == 0) solution++;
	}
	cout << solution << endl;

	return 0;
}

Measured memory_bytes: 3628
import java.util.Scanner;

public class Main {
	static Scanner scanner = new Scanner(System.in);
	static int n = scanner.nextInt();
	static int m = scanner.nextInt();
	static boolean[][] graph = new boolean[60][60];
	static boolean[] visited = new boolean[n];
	static int verSize = n;

	@SuppressWarnings("resource")
	public static void main(String args[]) {

		int a[] = new int[m];
		int b[] = new int[m];

		for (int i = 0; i < m; i++) {
			a[i] = scanner.nextInt() - 1;
			b[i] = scanner.nextInt() - 1;
		}

		for (int i = 0; i < m; i++) {
			graph[a[i]][b[i]] = true;
			graph[b[i]][a[i]] = true;
		}

		int count = 0;
		for (int i = 0; i < m; i++) {
			graph[a[i]][b[i]] = false;
			graph[b[i]][a[i]] = false;
			dfs(0);

			for (int j = 0; j < visited.length; j++) {
				if (!visited[j]) {
					count++;
					break;
				}
			}
			graph[a[i]][b[i]] = true;
			graph[b[i]][a[i]] = true;
			initVisited();
		}

		System.out.println(count);

	}

	public static void dfs(int vertex) {
		if (visited[vertex]) {
			return;
		} else {
			visited[vertex] = true;
		}
		for (int i = 0; i < verSize; i++) {
			if (graph[vertex][i]) {
				dfs(i);
			}
		}
	}

	public static void initVisited() {
		for (int i = 0; i < visited.length; i++) {
			visited[i] = false;
		}
	}
}


Measured memory_bytes: 23380
#include<stdio.h>
int main(void){
    int x, y;
    while(1){
        scanf("%d %d", &x, &y);
        if(x == 0 && y == 0) break;
    if(x < y){
        printf("%d %d\n", x, y);
    }
    else{
        printf("%d %d\n", y, x);
    }
    }
    return 0;
}


Measured memory_bytes: 2048
#define _USE_MATH_DEFINES
#include <iostream>
#include <stdlib.h>
#include <stdio.h>
#include <vector>
#include <algorithm>
#include <functional>
#include <string>
#include <string.h>
#include <math.h>
#include <map>
#include <time.h>
using namespace std;


int main(){
	int X, Y;
	cin >> X >> Y;

	cout << X + Y / 2 << endl;
	return 0;
}

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

std::string replaceWord(const std::string wrong_word, const std::string right_word, std::string str){
	
	std::string::size_type pos = str.find(wrong_word);
	
    while(pos != std::string::npos){
        str.replace(pos, wrong_word.length(), right_word);
        pos = str.find(wrong_word);
    }
	
	return str;
}

int main(){
    std::string w_word("Hoshino");
    std::string r_word("Hoshina");
	
    int num;
    std::cin >> num;
    std::cin.ignore();
      
    for(int i = 0; i < num; ++i){
        std::string str;
        std::getline(std::cin, str);
        std::cout << replaceWord(w_word, r_word, str) << std::endl;
    }
	
    return 0;
}

Measured memory_bytes: 3064
#include <iostream>
#include <algorithm>
#include <string>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <vector>
#include <queue>
#include <stack>
#include <cmath>
#include <map>
#include <iomanip>
#include <set>
#include <ctime>
#include <tuple>
#include <bitset>
#include <assert.h>
#include <deque>
using namespace std;
typedef long long ll;

#define fi first
#define se second
#define rep(i, n) for (ll i = 0; i < n; i++)
#define debugA cerr << "AAAAA" << endl
#define debug_ cerr << "-------------" << endl
#define debug(x) cerr << #x << ": " << x << endl
#define debug_vec(v)                   \
    cout << #v << endl;                \
    for (int i = 0; i < v.size(); i++) \
    {                                  \
        cout << v[i] << " ";           \
    }                                  \
    cout << endl;
#define debug_vec2(v)                         \
    cout << #v << endl;                       \
    for (int i = 0; i < v.size(); i++)        \
    {                                         \
        for (int j = 0; j < v[i].size(); j++) \
        {                                     \
            cout << v[i][j] << " ";           \
        }                                     \
        cout << endl;                         \
    }

template <typename T>
bool chmax(T &a, const T &b)
{
    if (a < b)
    {
        a = b;
        return true;
    }
    return false;
}

template <typename T>
bool chmin(T &a, const T &b)
{
    if (a > b)
    {
        a = b;
        return true;
    }
    return false;
}

using Graph = vector<vector<int>>;
using P = pair<int, int>;
using P1 = pair<int, pair<int, int>>; // クラスカル法とかで、{cost, {from, to}}的に使う。
const ll INF = 1001001001001001001;
const double pi = acos(-1);

int main()
{
    int n;
    cin >> n;
    ll tmp = 0;
    ll ans = 0;
    vector<ll> vec;
    priority_queue<int, vector<int>, greater<int>> que2;
    priority_queue<int, vector<int>, less<int>> que1;
    for (int i = 0; i < n; i++)
    {
        int a;
        cin >> a;
        if (a == 1)
        {
            ll b, c;
            cin >> b >> c;
            tmp += c;
            que1.push(b);
            que2.push(b);
            if (que1.top() > que2.top())
            {
                int x = que1.top();
                int y = que2.top();
                que1.pop();
                que2.pop();
                que2.push(x);
                que1.push(y);
                ans += abs(x - y);
            }
        }
        else
        {
            cout << que1.top() << " " << ans + tmp << endl;
        }
    }

    return 0;
}


Measured memory_bytes: 3828
#include<vector>
#include <iostream>
#include<string>
#include <complex>
#include <algorithm>
#include<string>

using namespace std;

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

    char s[n];
    char c;
    for(int i = 0; i< n; i++){
        cin >> c;
        if(i+1 == k){
            c += 32;
        }
        cout << c;
    }

    cout << endl;
}

Measured memory_bytes: 3604
#include<bits/stdc++.h>
using namespace std;
int main(){
  string s, t, u;
  cin >> s >> t;
  int a, b;
  cin >> a >> b;
  cin >> u;
  if(u == s)	a--;
  if(u == t)	b--;
  cout << a << "  " << b;
  
  return 0;
}

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

using namespace std;

using ll = long long;
using P = pair<ll, ll>;
using Graph = vector<vector<ll>>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int ddx[8] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll MOD = 1000000007;
const ll INF = 1000000000000000000L;
#ifdef __DEBUG

/**
 * For DEBUG
 * https://github.com/ta7uw/cpp-pyprint
 */
#include "cpp-pyprint/pyprint.h"

#endif

void Main() {
    ll N, K, C;
    cin >> N >> K >> C;
    string S;
    cin >> S;
    vector<ll> l, r;
    ll idx = 0;
    while (idx < N) {
        ll s = S[idx];
        if (s == 'o') {
            l.push_back(idx);
            idx += C + 1;
        } else {
            idx++;
        }
    }
    idx = N - 1;
    while (idx >= 0) {
        ll s = S[idx];
        if (s == 'o') {
            r.push_back(idx);
            idx -= C + 1;
        } else {
            idx--;
        }
    }
    reverse(r.begin(), r.end());
    if (l.size() > K) {
        return;
    } else {
        rep(i, l.size()) {
            if (l[i] == r[i]) {
                cout << l[i] + 1 << '\n';
            }
        }
    }
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    Main();
    return 0;
}


Measured memory_bytes: 5128
import math

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

        total = 0

        for a in range(1,K+1):
                if a==1:
                        total += 1*K*K
                else:
                        for b in range(1,K+1):
                                if b==1:
                                        total += 1*K
                                else:
                                        for c in range(1,K+1):
                                                total += math.gcd(math.gcd(a,b),c)

        print("{}".format(total))

if __name__=="__main__":
        main()

Measured memory_bytes: 9208
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(ll i = 0, i##_len = (n); i < i##_len; i++)
#define reps(i, s, n) for(ll i = (s), i##_len = (n); i < i##_len; i++)
#define rrep(i, n) for(ll i = (n) - 1; i >= 0; i--)
#define rreps(i, e, n) for(ll i = (n) - 1; i >= (e); i--)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((ll)(x).size())
#define len(x) ((ll)(x).length())

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    // ifstream in("input.txt");
    // cin.rdbuf(in.rdbuf());
    string s;
    ll k;
    cin >> s >> k;
    ll n = len(s);
    // dp[pos][smaller][cnt]
    vector<vector<vector<ll>>> dp(n + 1, vector<vector<ll>>(2, vector<ll>(k + 1, 0)));
    dp[0][0][0] = 1;
    rep(i, n) {
        ll v = (s[i] != '0') ? 1 : 0;
        reps(j, v, k + 1) {
            dp[i + 1][0][j] = dp[i][0][j - v];
        }
        v = s[i] - '0';
        rep(j, k + 1) {
            if (j == 0) {
                dp[i + 1][1][j] += dp[i][1][j];
                if (v > 0) dp[i + 1][1][j] += dp[i][0][j];
            }
            else {
                dp[i + 1][1][j] += dp[i][1][j] + dp[i][1][j - 1] * 9;
                if (v > 0) dp[i + 1][1][j] += dp[i][0][j] + dp[i][0][j - 1] * (v - 1);
            }
        }
    }
    cout << (dp[n][0][k] + dp[n][1][k]) << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<numeric>
#define int long long
#define ld long double
#define all(x) x.begin(),x.end()
const int maxn=1000000;
#define what_is(x) cerr << #x << " is " << x << endl;
const int MOD = 1e9 + 7;
using namespace std;
string abc="abcdefghijklmnopqrstuvwxyz";
int powmod(int a, int b, int MOD = MOD){
    if(!a and !b)    return 1ll;
    if(!a)    return a;
    int res = 1ll;
    b %= (MOD - 1ll), a %= MOD;
    while(b){
        if(b%2 == 1)    res = (res * a) % MOD;
        a = (a * a) % MOD;
        b /= 2;
    }
    return res;
}
int popcount(uint32_t n)
{
    n = n - ((n >> 1) & 0x55555555);
    n = (n & 0x33333333) + ((n >> 2) & 0x33333333);
    return ((n + (n >> 4) & 0xF0F0F0F) * 0x1010101) >> 24;
}
bool check(int n) {return (((double)sqrt(n)-floor((double)sqrt(n)))==0);}
vector<bool> sieve(maxn + 1, true);
void fillprime() {
    sieve[0] = sieve[1] = false;
    for (int i = 2; i <= maxn; ++i) {
        if (sieve[i] && (int) i * i <= maxn) {
            for (int j = i * i; j <= maxn; j += i) {
                sieve[j] = false;
            }
        }
    }
}
const int nn=1e5+5;
void solve() {
        int n;
        cin>>n;
        string s1,s2;
        cin>>s1>>s2;
        for(int i=0;i<n;++i)
        {
            cout<<s1[i]<<s2[i];
        }
    
}
int32_t main() {
    ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);
    //fillprime();
    //int t;cin>>t;while(t--)
    solve();
}

Measured memory_bytes: 3692
#include "bits/stdc++.h"
using namespace std;
#define REP(i, n) for(ll i = 0;i < n;i++)
#define ll long long
#define MOD 1000000007
using vi = vector<ll>; // intの1次元の型に vi という別名をつける
using vvi = vector<vi>; // intの2次元の型に vvi という別名をつける

ll n,k,x,y;




int main(){
  /*
// エラトステネスのふるい
    int MAX = 100000;
    vector<int> is_prime(MAX, 1);
    is_prime[0] = 0, is_prime[1] = 0;
    for (int i = 2; i < MAX; ++i) {
        if (!is_prime[i]) continue;
        for (int j = i*2; j < MAX; j += i) is_prime[j] = 0;
    }
*/
  ll ans=2000000000000;
  cin >> n;

  for(int i=1;i<=1000000;i++){
    if (n%i==0){
      ans=min((i+(n/i))-2,ans);
    }
  }
  
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 384
N,X = map(int,input().split())

# a[i]: レベルiの総数
a = [1]
# p[i]: レベルiのパティの総数
p = [1]
for i in range(N):
    a.append(a[i] * 2 + 3)
    p.append(p[i] * 2 + 1)

def f(n,x):
    if n == 0:
        return 0 if x <= 0 else 1
    elif x <= 1 + a[n-1]:
        return f(n-1,x-1)
    else:
        return p[n-1] + 1 + f(n-1,x-2-a[n-1])

print(f(N,X))

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n)  for(long long i=0;i<(long long)(n);i++)
#define REP(i,k,n) for(long long i=k;i<(long long)(n);i++)
#define all(a) a.begin(),a.end()
#define pb push_back
#define eb emplace_back
#define lb(v,k) (lower_bound(all(v),k)-v.begin())
#define ub(v,k) (upper_bound(all(v),k)-v.begin())
#define fi first
#define se second
typedef long long ll;
typedef pair<ll,ll> P;
typedef tuple<ll,ll,ll> PP;
typedef multiset<ll> S;
typedef priority_queue<ll> PQ;
typedef priority_queue<P,vector<P>,greater<P>> SPQ;
using vi=vector<ll>;
using vvi=vector<vector<ll>>;
const ll inf=1001001001001001;
const int INF=1001001001;
const int mod=1000000007;
const double pi=3.14159265358979323846;
bool chmin(auto &a,auto b){if(a>b){a=b;return true;}return false;}
bool chmax(auto &a,auto b){if(a<b){a=b;return true;}return false;}
void outvi(vi v){rep(i,v.size()){if(i)cout<<' ';cout<<v[i];}cout<<endl;}
void outvvi(vvi v){rep(i,v.size()){rep(j,v[i].size()){if(j)cout<<' ';cout<<v[i][j];}cout<<endl;}}

ll modpow(ll a,ll b){  //aのb乗 計算量はO(logb) modが32bitに収まらないとオーバーフロー
  ll ans=1;
  while(b>0){
    a%=mod;
    if((b&1)==1){
      ans=ans*a%mod;
    }
    b>>=1;
    a*=a;
  }
  return ans;
}
int main(){
    //cout<<25*48+52*40+67*32+72*24+79*16<<endl;
    //cout<<8416*32<<endl;
    ll n,ans=0;cin>>n;
    vi v(n);
    rep(i,n)cin>>v[i];
    sort(all(v));
    ll k=modpow(2,n-1);
    ll t=modpow(2,n-2);
    reverse(all(v));
    rep(i,n){
        ans+=k*v[i];
        k+=t;
        k%=mod;
        ans%=mod;
    }
    ll u=modpow(2,n);
    cout<<ans*u%mod<<endl;
}

Measured memory_bytes: 1792
#include "bits/stdc++.h"
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000


int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    string S; cin >> S;
    rep(i, S.length()) cout << 'x';
    cout << endl;

    return 0;
}


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

int main() {
  long long n,k;
  long long a,b = 0;
  
  cin >> n >> k;
  
  a = n % k;
  b = k - (n % k);
  
  if(a <= b) cout << a;
  else cout << b;
  
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
#define ll long long
#define fw(p) for(int w=0;w<(p);w++)
#define fx(p) for(int x=0;x<(p);x++)
#define fy(p) for(int y=0;y<(p);y++)
#define fz(p) for(int z=0;z<(p);z++)
#define fyg(p,g) for(int y=(g);y<(p);y++)
#define fzg(p,g) for(int z=(g);z<(p);z++)
#define ce(d) cout<<d<<endl;
#define ces(d) cout<<" "<<endl;

int main() {

int N;
ll K;
int A[100000];
int B[100000];
vector<pair<int,int>> S;
cin>>N>>K;
fx(N){
	cin>>A[x]>>B[x];
S.push_back(make_pair(A[x],B[x]));
}

sort(S.begin(),S.end());
ll ind=0;
int i=0;
while(ind<K){
ind+=S[i++].second;
}

ce(S[i-1].first);

}

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

int main() {
  int N;
  cin>>N;
  int a=0;
  vector<int>l(2*N);
  for(int i=0;i<2*N;i++)cin>>l[i];
  sort(l.begin(),l.end());
  for(int i=0;i<N;i++){
    a+=l[2*i];
  }
  cout<<a<<endl;
}

Measured memory_bytes: 256
main = do
  as <- getLine
  bs <- getLine
  cs <- getLine
  putStrLn $ solve as bs cs 'a'

solve :: String -> String -> String -> Char -> String
solve [] _ _ 'a' = "A"
solve (x:xs) bs cs 'a' = solve xs bs cs x
solve _ [] _ 'b' = "B"
solve as (x:xs) cs 'b' = solve as xs cs x
solve _ _ [] 'c' = "C"
solve as bs (x:xs) 'c' = solve as bs xs x


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

using namespace std;

using ll = long long;
using ld = long double;
using vl = vector<ll>;
using vvl = vector<vl>;
using vb = vector<bool>;
using P = pair<ll, ll>;
template<typename T> using pq = priority_queue<T>;
template<typename T> using minpq = priority_queue<T, vector<T>, greater<T>>;
template<typename T, typename K> using ump = unordered_map<T, K>;
const ll dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
const ll mod = 1000000007;
const ll inf = ll(1e9);
const ll e5 = ll(1e5);
const ll ll_inf = ll(1e9) * ll(1e9);

#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define repr(i, n) for (ll i = ll(n - 1); i >= 0; i--)
#define each(i, mp) for (auto &i : mp)
#define eb emplace_back
#define F first
#define S second
#define all(obj) (obj).begin(), (obj).end()

template<class T>
ostream &operator<<(ostream &out, const vector<T> &list) {
    ll n = list.size();
    rep(i, n) out << list[i] << ' ';
    return out;
}

template<class T>
istream &operator>>(istream &in, vector<T> &list) {
    ll n = list.size();
    rep(i, n) in >> list[i];
    return in;
}

template<class T>
ostream &operator<<(ostream &out, const vector<vector<T>> &list) {
    ll n = list.size();
    rep(i, n) out << list[i] << '\n';
    return out;
}

/* ------------- ANSWER ------------- */
/* ---------------------------------- */

void solve() {
    string s, t;
    cin >> s >> t;
    ll n = s.size();
    ll ans = 0;
    rep(i, n) {
        if (s[i] != t[i]) ans++;
    }
    cout << ans << '\n';
}

int main() {
#ifdef MY_DEBUG
    while (true) {
#endif
        solve();
#ifdef MY_DEBUG
    }
#endif
    return 0;
}


Measured memory_bytes: 3912
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
#define AMAX 1000005
int main()
{
    int n; cin >> n;
    int value;
    int cnt[AMAX];
    for(int i=0; i<AMAX; i++) cnt[i]=0;
    vector<int> a(n);
    for(int i=0; i<n; i++){
        cin >> value;
        a[i] = value;
        if(cnt[value] != 0){
            cnt[value] = 2;
            continue;
        }
        for(int j=value; j<AMAX; j+=value){
            cnt[j]++;
        }
    } 


    int ans = 0;
    for(int i=0; i<n; i++){
        if(cnt[a[i]]==1) ans++;
    }

    cout << ans << endl;
    return 0;

}

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

main()
{
	string s; cin>>s>>s;
	int t1=0;
	for(int i=0;i<s.size();i++)
	{
		if(s[i]==')') t1++;
		else break;
	}
	string s2;
	for(int i=1;i<=t1;i++) s2+="(";
	s=s2+s;
	int t2=0;
	for(int i=s.size()-1;i>=0;i--)
	{
		if(s[i]=='(') t2++;
		else break;
	}
	string s3;
	for(int i=1;i<=t2;i++) s3+=")";
	s=s+s3;;
	
	bool ok=false;
	while(!ok)
	{
		ok=true;
		int t=0;
		for(int i=0;i<s.size();i++)
		{
			if(s[i]=='(') t++;
			else t--;
			if(t<0)
			{
				ok=false;
				s="("+s;
				break;
			}
		}
	}
	ok=false;
	while(!ok)
	{
		ok=true;
		int t=0;
		for(int i=s.size()-1;i>=0;i--)
		{
			if(s[i]=='(') t++;
			else t--;
			if(t>0)
			{
				ok=false;
				s=s+")";
				break;
			}
		}
	}
	cout<<s;
	return 0;
}


Measured memory_bytes: 256
n = input()

cnt = 0

if n.count(n[0]) == 2:
  cnt += 1
if n.count(n[1]) == 2:
  cnt += 1
if n.count(n[2]) == 2:
  cnt += 1
if n.count(n[3]) == 2:
  cnt += 1

if cnt == 4:
  print('Yes')
else:
  print('No')



Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define R cin>>
#define Z class
#define ll long long
#define ln cout<<'\n'
#define in(a) insert(a)
#define pb(a) push_back(a)
#define pd(a) printf("%.10f\n",a)
#define mem(a) memset(a,0,sizeof(a))
#define all(c) (c).begin(),(c).end()
#define iter(c) __typeof((c).begin())
#define rrep(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define rep(i,n) REP(i,0,n)
#define tr(it,c) for(iter(c) it=(c).begin();it!=(c).end();it++)
template<Z A>void pr(A a){cout<<a;ln;}
template<Z A,Z B>void pr(A a,B b){cout<<a<<' ';pr(b);}
template<Z A,Z B,Z C>void pr(A a,B b,C c){cout<<a<<' ';pr(b,c);}
template<Z A,Z B,Z C,Z D>void pr(A a,B b,C c,D d){cout<<a<<' ';pr(b,c,d);}
template<Z A>void PR(A a,ll n){rep(i,n){if(i)cout<<' ';cout<<a[i];}ln;}
ll check(ll n,ll m,ll x,ll y){return x>=0&&x<n&&y>=0&&y<m;}
const ll MAX=1e9+7,MAXL=1LL<<61,dx[4]={-1,0,1,0},dy[4]={0,1,0,-1};
typedef pair<ll,ll> P;

int days(int y,int m,int d){
  if(m<3)y--,m+=12;
  return 365*y+y/4-y/100+y/400+(153*m+8)/5+d;
}

void Main() {
  int y,m,d;
  scanf("%d/%d/%d",&y,&m,&d);
  if(days(y,m,d)<=days(2019,4,30)) pr("Heisei");
  else pr("TBD");
}

int main(){/*ios::sync_with_stdio(0);cin.tie(0);*/Main();return 0;}


Measured memory_bytes: 256
#include <stdio.h>


int fibot_s(int x){
  int i,in[44];
  
  in[0]=1;
  in[1]=1;
  if(x==0 || x==1) return in[x];
  else {
    for(i=2;i<=x;i++){
      in[i]=in[i-2]+in[i-1];
    }
    return in[x];
  }
}

int main(){
  int kou;
  scanf("%d",&kou);

  printf("%d\n",fibot_s(kou));

  return 0;
}



Measured memory_bytes: 2072
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <math.h>

using namespace std;

#define ll long long
#define ull unsigned long long
#define REP(i, n) for(int i=0; i<n; i++)

int main(){
    int N,M;
    cin >> N >> M;
    int x = N - M;
    ll cost = M*1900 + x*100;
    cout << cost*pow(2,M) << endl;
    return 0;
}


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


int main(void){
    int n, k;
    string s;
    cin >> n >> k;
    cin >> s;
    char out[n]={};
    for(int i=0;i<n;++i){
      if(i != k-1)
        cout << s[i];
      else{
        if (s[i] == 'A')
          cout << 'a';
        if (s[i] == 'B')
          cout << 'b';
        if (s[i] == 'C')
          cout << 'c';
      }   
    }   
    cout<<endl;
    return 0;

}

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

const ll MAXN = 200000;
const ll INF = 1001001001;
const ll MOD = 1000000007;

ll N, ans=0, tmp=0;
vector<vector<ll>> A;

signed main(){
    cin >> N;
    A.resize(N);
    for(int i=0;i<N;i++) {
        A[i].resize(N,0);
    }
    for(int i=0;pow(2,i)<N;i++) {
        for(int j=1;j<N;j++) {
            for(int l=1;j+l*pow(2,i)<=N;l++) {
                A[j-1][j+l*pow(2,i)-1] = i+1;
            }
        }
    }
    if(N%2==0) A[0][N-1] = 1;
    for(int i=0;i<N;i++) {
        for(int j=i+1;j<N;j++) {
            cout << A[i][j] << " ";
        }
        cout << endl;
    }
    return 0;
}

Measured memory_bytes: 5832
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define repb(i, a, b) for(int i = a; i >= b; i--)
#define all(a) a.begin(), a.end()
#define o(a) cout << a << endl
#define int long long
#define fi first
#define se second
using namespace std;
typedef pair<int, int> P;

signed main(){
    int R, W, c, r;
    while(1){
        cin >> R >> W >> c >> r;
        if(R + W + c + r == 0) break;
        for(int i = 0;;i++){
            if(R + r * i >= c * W){
                cout << i << endl;
                break;
            }
        }
    }
}

Measured memory_bytes: 3096
// ------------------
// author: MatsuTaku
// date  : 19/02/2020
// ------------------

#include <bits/stdc++.h>

using namespace std;
using ll = long long;

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

  int H,N; cin>>H>>N;
  int sum = 0;
  for (int i = 0; i < N; i++) {
    int a; cin>>a;
    sum += a;
  }
  cout << (sum >= H ? "Yes" : "No") << endl;

  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(){
        int N;

        scanf("%d", &N);

        if(N % 2 == 0) {
                printf("%f\n", (double)(N / 2) / N);
        }else {
                printf("%f\n", (double)(N / 2 + 1) / N);
        }
        return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
using namespace std;
typedef long long ll;
#define rep(i,n) for(ll i=0;i<n;++i)
#define rep1(i,n) for(ll i=1;i<=n;++i)
int main(){
  ll n,a,b;cin>>n>>a>>b;
  ll ans=0;
  if(a>b){
    ll tmp;
    tmp=a;
    a=b;
    b=tmp;
  }
  if((b-a)%2==0){
    ans=(b-a)/2;
  }
  else{
    ll tail,front;
    front=a-1;
    tail=n-b;
    if(front<tail){
      ans+=front;
      b-=front;
      a=1;
      b--;
      ans++;
      ans+=(b-1)/2;
    }
    else{
      ans+=tail;
      a+=tail;
      b=n;
      a++;
      ans++;
      ans+=(n-a)/2;
    }
  }
  cout<<ans<<endl;
  return 0;
}


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

using namespace std;

int main() {
	int N;
	cin >> N;
	vector<int> num(N);
	for (int i = 0; i < N; i++) {
		int x;
		cin >> x;
		num[i] = x;
	}
	for (int i = num.size() - 1; i >= 0; i--) {
		if (i != 0) {
			cout << num[i] << " ";
		}
		else {
			cout << num[i] << endl;
		}
	}
	return 0;
}


Measured memory_bytes: 3064
#include<iostream>

#define	mp	make_pair
#define	N	first
#define	E	second

using namespace std;

typedef	pair<int,int>	pii;

const int L=100000;
pii memo[100][100];

int main()
{
	for(int w,h;cin>>w>>h,w;){
		memo[0][0]=mp(1,1);
		for(int i=1;i<h;i++)	memo[i][0]=mp(memo[i-1][0].N,0);
		for(int j=1;j<w;j++)	memo[0][j]=mp(0,memo[0][j-1].E);

		memo[1][1]=mp(1,1);
		for(int i=2;i<h;i++)	memo[i][1]=mp(memo[i-1][1].N,memo[i][0].N);
		for(int j=2;j<w;j++)	memo[1][j]=mp(memo[0][j].E,memo[1][j-1].E);

		for(int i=2;i<h;i++)for(int j=2;j<w;j++){
			memo[i][j].N=(memo[i-1][j].N+memo[i-1][j-1].E)%L;
			memo[i][j].E=(memo[i][j-1].E+memo[i-1][j-1].N)%L;
		}

		cout<<(memo[h-1][w-1].N+memo[h-1][w-1].E)%L<<endl;
	}

	return 0;
}

Measured memory_bytes: 0
#include<stdio.h>
main(){
  int x,y,z;
  scanf("%d%d",&x,&y);
  if(x < y){
    z = y;
    y = x;
    x = z;
}
    while(y != 0){
      z = x % y;
      x = y;
      y = z;
    }
    printf("%d\n",x);
    return 0;
}

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

int main() {
  int a, b;
  cin >> a >> b;
  
  if (a==1 && b==2)
    cout << 3 << endl;
  if (a==2 && b==1)
    cout << 3 << endl;
  if (a==3 && b==2)
    cout << 1 << endl;
  if (a==2 && b==3)
    cout << 1 << endl;
  if (a==1 && b==3)
    cout << 2 << endl;
  if (a==3 && b==1)
    cout << 2 << endl;
}

Measured memory_bytes: 3596
object Main extends App {
  val sc = new java.util.Scanner(System.in)
  val n = sc.nextInt

  val ls = (1 to 100).map { i =>
    if (i % 2 != 0) 0 else {
      var j = i
      var c = 0
      while(j % 2 == 0) {
        j /= 2
        c += 1
      }
      c
    }
  }
  val lss = ls.take(n)
  val max = lss.max
  println(lss.indexWhere(_ == max) + 1)
}

Measured memory_bytes: 26048
from collections import deque

n = int(input())
n2 = n * n
p = list(map(int, input().split()))

costs = [0] * n2

for i in range(n2):
    costs[i] = min(i // n, n - i // n - 1, i % n, n - i % n - 1)

remains = [1] * n2

ans = 0
for i, pi in enumerate(p):
    ans += costs[pi-1]
    remains[pi-1] = 0

    d = deque()
    d.append((pi-1, costs[pi-1]))

    while d:
        pos, cost = d.popleft()

        for offset in [-1, -n, 1, n]:
            if 0 <= pos + offset < n2:
                next_cost = cost + remains[pos]

                if costs[pos+offset] > next_cost:
                    costs[pos+offset] = next_cost
                    d.append((pos+offset, next_cost))

print(ans)


Measured memory_bytes: 172172
#include <bits/stdc++.h>
using ll=long long;
using namespace std;
#define rep_i(i, n) for (int i = 0; i < (n); ++i)
#define rep_ll(i, n) for (long long i = 0; i < (n); ++i)
#define r_rep_i(i, start, end) for (int i = (start); i < (end); ++i)
#define r_rep_ll(i, start, end) for (long long i = (start); i < (end); ++i)
#define debug_vi(v) copy((v).begin(), (v).end(), ostream_iterator<int>(cout, " "));
#define debug_vll(v) copy((v).begin(), (v).end(), ostream_iterator<long long>(cout, " "));
#define debug_vd(v) copy((v).begin(), (v).end(), ostream_iterator<double>(cout, " "));
#define sort_v(v) sort((v).begin(), (v).end()); //昇順
#define d_sort_vi(v) sort((v).begin(), (v).end(), greater<int>()); //降
#define d_sort_vll(v) sort((v).begin(), (v).end(), greater<long long>()); //降
#define d_sort_vd(v) sort((v).begin(), (v).end(), greater<double>()); //昇順
#define say(t) cout << (t) << endl;
#define sum_vi(v) accumulate((v).begin(), (v).end(), 0);
#define sum_vll(v)accumulate((v).begin(), (v).end(), 0LL);

ll gcd(ll a, ll b) { return b?gcd(b, a%b):a;}
ll lcm(ll a, ll b) { return a/gcd(a, b)*b;}
const int IINF=(1<<30);
const ll LLINF = 1LL<<60;

int main(){
  cin.tie(0);
  ios::sync_with_stdio(0);
  string s;cin >> s;
  int start_idx = s.length()/2 - 1;
  for (int i = start_idx; i > 0; i--){
    bool f = true;
    for(int a = 0; a < i; a++){
      if(s[a] != s[i + a]){
        f = false;
      }
    }
    if(f){
      say(i*2);
      return 0;
    }
  }
}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <climits>
#include <cstdlib>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <vector>
#define DEBUG 1
using namespace std;
constexpr int kMod = 1000000007;
typedef long long LL;

int main() {
  string S; cin >> S;
  LL K; cin >> K;
  for (int i = 0; i < S.size(); ++i) {
    if (S[i] - '0' > 1) {
      cout << S[i] << endl;
      break;
    } else if (K == i + 1) {
      cout << S[i] << endl;
      break;
    }
  }
}


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

int main()
{
    int n;
    cin >> n;
    vector <int> v;
    v.push_back(0);
    int j = 0;
    for(int i = 0; i < n; i++)
    {
        int x;
        cin >> x;
        if((x == (v[j]+1)))
        {
          v.push_back(x);
          j++;
        }
    }
    int len = v.size()-1;
    if(len == 0)
        cout << "-1" << endl;
    else
        cout << n - len << endl;
    return 0;
}


Measured memory_bytes: 1400
#include <bits/stdc++.h>
using namespace std;
/* typedef */
typedef long long ll;
typedef pair<int, int> pii;
/* constant */
const int INF = 1 << 30;
const ll LINF = 1LL << 50;
const int NIL = -1;
const int MAX = 10000;
const int mod = 1000000007;
const double pi = 3.141592653589;
/* global variables */
/* function */
/* main */
int main(){
    string S = "ARC";
    string T;
    cin >> T;
    if (T != S) cout << "ARC" << '\n';
    else cout << "ABC" << '\n';
}


Measured memory_bytes: 3596
import java.util.Scanner;
 
/**
 *
 * @author kke2
 */
public class Main {
 
    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int weight  =sc.nextInt();
    int time    =sc.nextInt();
        int i = weight-time;
    if(weight<time){
    i =0;
    }
    System.out.println(i);
    }
}

Measured memory_bytes: 24020
#include<bits/stdc++.h> 
#define ll long long 
#define ld long double
using namespace std;
const int N = 1e5+5;

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	string s;cin>>s;

	int a = -1,z = 0;

	for(int i = 0; i < s.size(); i++)
	{
		if(s[i] == 'A')
		{
			if(a == -1)
				a = i;
		}
		else if(s[i] == 'Z')
			z = i;

	}

	cout<<z-a+1<<"\n";
	return 0;
}







Measured memory_bytes: 720
#include<stdio.h>
int main()
{
   int n,k=0,s=0;
   scanf("%d",&n);
   if((n%2==0)||(n%10==5)) k=-1;
   else
   {
       while(s<n)
       {
           s=s*10+7;
           k++;
       }
       while(1)
       {
           s %=n;
           if(s==0) break;
           s=s*10+7;
           k++;
       }
     }
   printf("%d",k);
  return 0;
}


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

int main() {
  int n;
  cin >> n;
  if (n == 25) {
    puts("Christmas");
  } else if (n == 24) {
    puts("Christmas Eve");
  } else if (n == 23) {
    puts("Christmas Eve Eve");
  } else {
    puts("Christmas Eve Eve Eve");
  }
  return 0;
}


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

#define REP(i, stop) for (int i = 0, i##_len = stop; i < i##_len; ++i)

int A[200000];
signed main() {
	int n;
	scanf("%d", &n);
	int m0 = 0;
	int m1 = 0;
	REP(i, n) {
		int a;
		scanf("%d", &a);
		if (a > m0) {
			m1 = m0;
			m0 = a;
		} else if (a > m1) {
			m1 = a;
		}
		A[i] = a;
	}
	REP(i, n) {
		int a = A[i];
		if (a == m0) {
			printf("%d\n", m1);
		} else {
			printf("%d\n", m0);
		}
	}
}


Measured memory_bytes: 2304
n, m = map(int, input().split())
PAIRS = [(a, 1) for a in map(int, input().split())]

for _ in range(m):
    b, c = map(int, input().split())
    PAIRS.append((c, b))
PAIRS.sort(reverse = True)

answer, count = 0, 0
for pair in PAIRS:
    answer += pair[0] * pair[1]
    count += pair[1]
    if count > n:
        answer -= pair[0] * (count - n)
        break

print(answer)


Measured memory_bytes: 28888
s=[0]*26
try:
    while True:
        n=str(input())
        n=n.lower()
        #print(n)
        for i in range(len(n)):
            if 97<=ord(n[i])<=122:
                s[ord(n[i])-97]+=1
except EOFError:pass
for j in range(26):
    print(chr(j+97),':',s[j])



Measured memory_bytes: 5564
import java.util.*;

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

  private void run() {
    while(sc.hasNext()) {
      final int w = sc.nextInt();
      final int h = sc.nextInt();
      sc.nextLine();

      if(w == 0 && h == 0) break;

      final Tiles map = new Tiles(w, h);
      int px = -1;
      int py = -1;

      for(int y = 0; y < h; y++) {
        String line = sc.nextLine();
        for(int x = 0; x < w; x++) {
          switch(line.charAt(x)) {
          case '.' : map.setBlack(x, y); break;
          case '#' : map.setRed(x, y);   break;
          case '@' : map.setBlack(x, y); px = x; py = y; break;
          }
        }
      }

      System.out.println(map.blackArea(px, py));
    }
  }

  private final Scanner sc = new Scanner(System.in);
}

class Tiles {
  public Tiles(int w, int h) {
    this.w = w;
    this.h = h;
    this.map = new int[w * h];

    for(int i = 0; i < w * h; i++) map[i] = -1;
  }

  public void setBlack(int x, int y) {
    final int pos = x + y * w;

    map[pos] = -1;

    if(x != 0 && map[pos - 1] != RED) union(pos, pos - 1);
    if(y != 0 && map[pos - w] != RED) union(pos, pos - w);
  }

  public void setRed(int x, int y) {
    map[x + y * w] = RED;
  }

  public int blackArea(int x, int y) {
    return - map[root(x + y * w)];
  }

  private void union(int a, int b) {
    a = root(a);
    b = root(b);

    if(a != b) {
      if(map[a] < map[b]) {
        map[a] += map[b];
        map[b] = a;
      }
      else {
        map[b] += map[a];
        map[a] = b;
      }
    }
  }

  private int root(int a) {
    if(map[a] < 0) return a;

    map[a] = root(map[a]);
    return map[a];
  }

  private final int w;
  private final int h;
  private final int[] map;

  private static final int RED = 10000000;
}

Measured memory_bytes: 12000
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <algorithm>
using namespace std;
int n, m;
int a[105];
int ans;

int main() {
	scanf("%d %d", &n, &m);
	for(int i = 1; i <= n; i++) scanf("%d", &a[i]);
	int sum = 0;
	for(int i = 1; i <= n; i++) sum += a[i];
	int t = m - sum;
	sort(a + 1, a + n + 1);
	int p = t / a[1];
	ans = p + n;
	printf("%d\n", ans);
}

Measured memory_bytes: 128
#include <iostream>
#include <cstdio>
#include <algorithm>
using namespace std;

int main(int argc, char* argv[]) {
	int W, H, x, y, r;
	cin >> W >> H >> x >> y >> r;
	
	int minX = x - r;
	int maxX = x + r;
	int minY = y - r;
	int maxY = y + r;
	
	if(minX < 0 || maxX > W || minY < 0 || maxY > H){
		cout << "No" << endl;
	}else{
		cout << "Yes" << endl;
	}
	

	return 0;
}

Measured memory_bytes: 1156
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <queue>
#include <vector>
#include <algorithm>
#include <math.h>
#include <map>
#include <list>
#include <iomanip>
#include <queue>
#include <cmath>
#include <numeric>
#define repl(i, l, r) for (ll i = l; i < r; i++)
#define rep(i, n) repl(i, 0, n)

using namespace std;
using ll = long long;
template<class T>bool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }

int main() {

	ll N, M;
	cin >> N >> M;
	vector<vector<ll>> s(M);
	vector<ll> p(M);
	rep(i, M){
	ll k;
		cin >> k;
		rep(j, k) {
			ll S;
			cin >> S;
			S--;
			s[i].push_back(S);
		}
	}
	rep(i, M) {
		cin >> p[i];
	}

	ll ans = 0;
	for (ll mask = 0; mask < 1 << N; mask++) {
		ll flag = 0;
		rep(i, M) {
			ll cnt = 0;
			rep(j, s[i].size()){
				ll sw = s[i][j];
				if (mask >> sw & 1) cnt++;
			}
			if (cnt % 2 == p[i]) continue;
			else {
				flag = 1;
				break;
			}
		}
		if (flag == 0) ans++;
	}

	cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3460
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    int h, w;
    int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
    string field[50];
    int miss = 0;
    cin >> h >> w;
    for (int i = 0; i < h; i++) cin >> field[i];
    
    for (int i = 0; i < h; i++) {
        for (int j = 0; j < w; j++) {
            if (field[i][j] == '.') continue;
            miss++;
            for (int k = 0; k < 4; k++) {
                int ni = dx[k] + i, nj = dy[k] + j;
                if (ni < 0 || ni >= h) continue;
                if (nj < 0 || nj >= w) continue;
                if (field[ni][nj] == '#') {
                    miss--;
                    break;
                }
            }
        }
    }
    if (miss == 0) cout << "Yes" << endl;
    else cout << "No" << endl;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main()
{
	int N;
	cin >> N;
	
	int answer = 0;
	for (int i = N; i < 1000 ; i++)
	{
		if (i % 111 == 0)
		{
			answer = i;
          	break;
		}
	}
	
	cout << answer << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <string>
#include <map>
#include <set>
#include <tuple>
#include <deque>
#include <numeric>
#include <bitset>
#include <iomanip>
#include <cassert>
#include <chrono>
#include <random>
#include <limits>
#include <iterator>
#include <functional>
#include <sstream>
using namespace std;

typedef long long ll;
typedef pair<int, int> P;
typedef pair<int, double> Pid;
typedef pair<double, int> Pdi;
typedef pair<ll, int> Pl;
typedef pair<int, pair<int, int>> PP;
const double PI = 3.1415926535897932;   // acos(-1)
const double EPS = 1e-15;
const ll mod = 1e+9 + 7;
const int INF = 1001001001;

#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define chadd(x, y) x = (x + y) % mod

vector<int> graph[200005];

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

    int n, m;
    cin >> n >> m;
    for(int i = 0; i < m; ++i){
        int a, b;
        cin >> a >> b;
        --a, --b;
        graph[a].push_back(b);
        graph[b].push_back(a);
    }
    set<int> stopping_point;
    for(int v : graph[n-1]) stopping_point.insert(v);
    int sz = stopping_point.size();
    if(sz == 0){
        cout << "IMPOSSIBLE\n";
        return 0;
    }
    for(int v : graph[0]){
        if(stopping_point.find(v) != stopping_point.end()){
            cout << "POSSIBLE\n";
            return 0;
        }
    }
    cout << "IMPOSSIBLE\n";
}

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

using namespace std;

int main() {
    int N;
    cin >> N;
    vector<int> A(N);
    vector<int> B(N - 1);
    for (auto& b : B) {
        cin >> b;
    }
    A.at(0) = B.at(0);
    A.at(N - 1) = B.at(N - 2);
    for (int i = 1; i < N - 1; i++) {
        A.at(i) = min(B.at(i - 1), B.at(i));
    }
    cout << accumulate(A.begin(), A.end(), 0) << endl;
    return 0;
}


Measured memory_bytes: 256
# https://atcoder.jp/contests/abc129/tasks/abc129_b



N = gets.to_i
Ws = gets.split.map(&:to_i)

total_w = Ws.inject(:+)

s1 = 0
ans = total_w
Ws.each do |w|
  s1 += w
  s2 = total_w - s1
  ans = (s1 - s2).abs if (s1 - s2).abs < ans
end
puts ans


Measured memory_bytes: 1788
import sys
from itertools import starmap
readline = sys.stdin.readline
class Segment(object):
    __slots__ = ('fi', 'se')
    def __init__(self, fi, se):
        self.fi = fi
        self.se = se
def cross(a, b):
    return a.real * b.imag - a.imag * b.real
def dot(a, b):
    return a.real * b.real + a.imag * b.imag
def norm(base):
    return abs(base) ** 2
def project(s, p2):
    base = s.fi - s.se
    r = dot(p2 - s.fi, base) / norm(base)
    return s.fi + base * r
def reflect(s, p):
    return p + (project(s, p) - p) * 2.0
s = Segment(*starmap(complex, zip(*[map(int, readline().split())] * 2)))
n = int(readline())
for _ in [0] * n:
    p1 = reflect(s, complex(*map(float, readline().split())))
    print("{0:.10f} {1:.10f}".format(p1.real, p1.imag))

Measured memory_bytes: 7904
#include <stdio.h>
#include <stdlib.h>

#define N 110

int main(){
  int n, u, v, k, i, j, a[N][N];

  scanf("%d", &n);
  if(n<1 || n>N) exit(1);

  for(i=0; i<N; i++)
    for(j=0; j<N; j++) a[i][j] = 0;

  for(i=0; i<n; i++){
    scanf("%d", &u);
    scanf("%d", &k);
    for(j=0; j<k; j++){
      scanf("%d", &v);
      a[u][v] = 1; 
    }
  }

  for(i=1; i<=n; i++){
    for(j=1; j<=n; j++){
      printf("%d", a[i][j]);
      if(j != n) printf(" ");
    }
    printf("\n");
  }

  return 0;
}



Measured memory_bytes: 2048
#include <iostream>
#include <numeric>
#include <math.h>
#include <algorithm>
#include <float.h>
#include <limits>
#include <vector> 
#include <string.h>

#define rep(i,a,n) for(ll int (i) = (a);(i) < (n);(i)++)
#define urep(i,a,n) for(ll int (i) = (a);(i) > (n);(i)--)
#define MOD 1000000007
#define ll long long
#define asort(a) sort(a.begin(),a.end());

using namespace::std;

int jo(ll int jxo, ll int jyo){//累乗
	ll int jhogeo = 1;
	rep(jinto,0,jyo) jhogeo=jhogeo*jxo;
	return jhogeo;
}
char tobig(char toxbig){//char大文字化
  return (toxbig-0x20);
}
char tolow(char toxlow){//char小文字化
  return (toxlow+0x20);
}
int ctoi(char cctoi){//char->int
  if('0' <= cctoi && cctoi <= '9') return (cctoi-'0');
  return -1;
}
int gcd(int gcad, int gcbd) {//最大公約数
  if(gcad < gcbd) return gcd(gcbd, gcad);
  int gcrd;
  while ((gcrd=gcad%gcbd)) {
    gcad = gcbd;
    gcbd = gcrd;
  }
  return gcbd;
}
int lcm(int lcam, int lcbm){//最小公倍数
 return (lcam*lcbm)/gcd(lcam,lcbm);
}


int main(){
  string a;
  cin>>a;
  int al[26];
  int ans=0;
  rep(i,0,26) al[i]=0;
  rep(i,0,a.length()){
    al[a[i]-'a']++;
  }
  rep(i,0,26) ans+=(al[i]==0?0:al[i]-1);
  cout<<(ans?"no":"yes");

}

// int *p = new int[N];

//  vector<int> 変数名(要素数);
//  sort(変数名.begin(),変数名.end());//昇順ソート

// vector<vector<int>> 変数名(左の個数, vector<int>(右の個数));

//


Measured memory_bytes: 256
// 2020-06-05 18:13
#include <bits/stdc++.h>
using namespace std;

int main() {
    int N, Q;
    cin >> N >> Q;
    vector<vector<int>> Tree(N);
    for (int i = 0; i < N - 1; ++i) {
        int a, b;
        cin >> a >> b;
        --a, --b;
        Tree[a].push_back(b);
        Tree[b].push_back(a);
    }
    vector<long long> ans(N, 0);
    while (Q--) {
        int p, x;
        cin >> p >> x;
        --p;
        ans[p] += x;
    }
    // 頂点0から根までBFSして漸化式で値を足していく
    vector<bool> visited(N, false);
    queue<int> Task;
    Task.push(0);
    while (!Task.empty()) {
        int f = Task.front();
        visited[f] = true;
        Task.pop();
        for (int t : Tree[f]) {
            if (visited[t]) continue;
            ans[t] += ans[f];
            Task.push(t);
        }
    }
    for (int i = 0; i < N; ++i) {
        cout << ans[i] << (i == N - 1 ? '\n' : ' ');
    }
    return 0;
}

Measured memory_bytes: 16372
#include<iostream>
using namespace std;
int main(){

  int x1,y1,x2,y2;
  cin>>x1>>y1>>x2>>y2;
  int xdis=(x2-x1);
  int ydis=(y2-y1);
  int x3=x2-ydis;
  int y3=y2+xdis;
  int x4=x1-ydis;
  int y4=y1+xdis;
  cout<<x3<<" "<<y3<<" "<<x4<<" "<<y4;
  return 0;
}

Measured memory_bytes: 3620