akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <numeric>
#include <cmath>

using namespace std;

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

#define all(x) x.begin(),x.end()

const ll mod = 1e9+7;
const ll INF = 1e9;
const ll MAXN = 1e9;

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

    vector<P> v;
    int cnt=0;
    for(int i = 0; i < n; i++){
        cnt++;
        if(i+1>=n || s[i]!=s[i+1]){
            v.push_back(P(s[i],cnt));
            cnt=0;
        }
    }

    // for(int i = 0; i < v.size(); i++){
    //     cout<<v[i].second<< " ";
    // }
    // printf("\n");

    vector<int> sum(v.size()+1,0);
    for(int i = 0; i < v.size(); i++){
        sum[i+1] = sum[i] + v[i].second;
    }

    // for(int i = 1; i <= v.size(); i++){
    //     cout<<sum[i] - sum[i-1]<<" ";
    // }
    // printf("\n");
    // for(int i = 1; i <= v.size(); i++){
    //     cout<<sum[i]<<" ";
    // }
    // printf("\n");


    int l=1,r=1;
    if(v[0].first=='1') l=2;

    r = l + 2*(k-1);

    if(r>=v.size()){
        cout<<n<<endl;
        return 0;
    }

    int ans=0;
    while(r<=v.size()){
        // cout<< (r==v.size()?sum[r]:sum[r+1]) << " - "<<(l-2<0?0:sum[l-2])<< " = "<<(r==v.size()?sum[r]:sum[r+1])-(l-2<0?0:sum[l-2])<<endl;
        ans = max(ans,(r==v.size()?sum[r]:sum[r+1])-(l-2<0?0:sum[l-2]));
        l+=2;
        r+=2;
    }

    cout<<ans<<endl;


    return 0;
}

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


#include "boost/multiprecision/cpp_int.hpp"
#include "boost/multiprecision/cpp_dec_float.hpp"
namespace mp = boost::multiprecision;
typedef mp::cpp_int LL;
typedef mp::number<mp::cpp_dec_float<1024>> DD;// 仮数部が1024ビットの浮動小数点数型(TLEしたら小さくする)

 
typedef long double dd;
#define i_7 (ll)(1E9+7)
//#define i_7 998244353
#define i_5 i_7-2
ll mod(ll a){
    ll c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
typedef pair<ll,ll> l_l;
typedef pair<dd,dd> d_d;
ll inf=(ll)1E16;
#define rep(i,l,r) for(ll i=l;i<=r;i++)
#define rrep(i,r,l) for(ll i=r;i>=l;i--)
#define pb push_back
ll max(ll a,ll b){if(a<b)return b;else return a;}
ll min(ll a,ll b){if(a>b)return b;else return a;}
void Max(ll &pos,ll val){pos=max(pos,val);}//Max(dp[n],dp[n-1]);
void Min(ll &pos,ll val){pos=min(pos,val);}
void Add(ll &pos,ll val){pos=mod(pos+val);}
dd EPS=1E-9;
#define fastio ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define fi first
#define se second
#define endl "\n"  //インタラクティブで消す！！！！！！！！！！！！！！！！！！！！！
#define SORT(v) sort(v.begin(),v.end())
#define ERASE(v) v.erase(unique(v.begin(),v.end()),v.end())
#define POSL(v,x) (lower_bound(v.begin(),v.end(),x)-v.begin())
#define POSU(v,x) (upper_bound(v.begin(),v.end(),x)-v.begin())
template<class T,class S>
inline bool chmax(T &a, S b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}
template<class T,class S>
inline bool chmin(T &a, S b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
}

void mod_print(ll k){
    ll P=1000;
    rep(y,1,P){
        ll x=mod(y*k);
        if(x+P>=i_7){
            x-=i_7;
        }
        if(abs(x)<=P){
            //cout<<x<<"/"<<y;
            cout<<setprecision(5)<<(dd)x/(dd)y;
            return;
        }
    }
    cout<<"nun"<<endl;
}
#define all(c) c.begin(),c.end()
//////////////////////////



int main(){fastio
    string s,t;cin>>s>>t;
    ll ans=0;
    rep(i,0,s.size()-1){
        if(s[i]!=t[i])ans++;
    }
    cout<<ans;
    
    return 0;
}


Measured memory_bytes: 3800
while True:
    h, w = map(int, input().split())

    if h == 0 and w == 0:
        break

    for y in range(h):
        isOddLine = True
        if y % 2 == 0:
            isOddLine = False
        else:
            isOddLine = True

        for x in range(w):
            if isOddLine:
                if x % 2 == 0:
                    print('.', end='')
                else:
                    print('#', end='')
            else:
                if x % 2 == 0:
                    print('#', end='')
                else:
                    print('.', end='')
        print('')
    print('')

Measured memory_bytes: 9096
x = int(input())

if x == 2:
    print(2)
    quit()
li = [2]
for i in range(3, 10 ** 6, 2):
    for j in li:
        if i % j == 0:
            break
    else:
        if i >= x:
            print(i)
            quit()
        li.append(i)

Measured memory_bytes: 41980
#include<bits/stdc++.h>
using namespace std;
#define arep(i,x,n) for(int i=int(x);i<(int)(n);i++)
#define rep(i,n) for(long long i = 0;i < n;++i)
#define pi 3.141592653589793
#define eps 0.00000001
#define INF 1e9+7  
using ll = long long; 
using P=pair<int,int>;
using lP=pair<ll,ll>;
using fP=pair<double,double>;
ll const mod=998244353;
const ll MAX=300000;
using vi=vector<int>;
using vc=vector<char>;
using vs=vector<string>;
using vvi =vector<vector<int>>;
using vvc=vector<vector<char>>;
using vvp =vector<vector<P>>;
int main(){
    int k,x;
    cin>>k>>x;
    if(k*500>=x)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Scanner;
import java.util.Spliterator;
import java.util.Spliterators;
import java.util.concurrent.ThreadLocalRandom;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.stream.IntStream;
import java.util.stream.Stream;
import java.util.stream.StreamSupport;

public class Main {
	static final Scanner s = new Scanner(System.in);

	static final long[] fal_rnd(int size, boolean parallel) {
		AtomicInteger l = new AtomicInteger(-1), r = new AtomicInteger(size);
		long[] res = new long[size];
		(parallel ? INS(size).parallel() : INS(size)).unordered().mapToLong(Long::parseLong).forEach(
				v -> res[ThreadLocalRandom.current().nextBoolean() ? l.incrementAndGet() : r.decrementAndGet()] = v);
		return res;
	}

	static final IntStream REPS(int v) {
		return IntStream.range(0, v);
	}

	static final Stream<String> INS(long size) {
		return StreamSupport
				.stream(Spliterators.spliterator(s, size, Spliterator.NONNULL & Spliterator.IMMUTABLE), false)
				.limit(size);
	}

	static HashMap<Integer, ArrayList<String>> map = new HashMap<>();

	public static void main(String __[]) {
		for (int n = s.nextInt(); n > 0; n--) {
			String in = s.next();
			HashSet<String> r=new HashSet<>(114514);
			for (int i = 1; i <= in.length(); i++) {
				String
				left=in.substring(0, i),
				right=in.substring(i, in.length()),
				lrev=String.valueOf(reverse(left.toCharArray())),
				rrev=String.valueOf(reverse(right.toCharArray()));
				r.add(left+right);
				r.add(right+left);

				r.add(left+rrev);
				r.add(right+lrev);

				r.add(lrev+right);
				r.add(rrev+left);

				r.add(lrev+rrev);
				r.add(rrev+lrev);
			}
			System.out.println(r.size());
		}
	}
	public static void swap(char[] l, int a, int b) {
		char x = l[b];
		l[b] = l[a];
		l[a] = x;
	}
	public static char[] reverse(char[] b) {
		for (int c = 0; c < b.length / 2; c++) {
			swap(b, c, b.length - 1 - c);
		}
		return b;
	}
}

Measured memory_bytes: 66264
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author tatsumack
 */

#include <iostream>
#include <fstream>

#include <iostream>
#include <limits.h>
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>

#include <list>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <queue>
#include <unordered_map>
#include <unordered_set>

#define int long long
#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define REPS(i, n) for (int i = 1, i##_len = (n); i <= i##_len; ++i)
#define FOR(i, a, b) for (int i = (a), i##_len = (b); i <= i##_len; ++i)
#define REV(i, a, b) for (int i = (a); i >= (b); --i)
#define CLR(a, b) memset((a), (b), sizeof(a))
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define INF 1001001001001001001ll
#define fcout cout << fixed << setprecision(12)

using namespace std;

template<typename T>
vector <T> make_v(size_t a) { return vector<T>(a); }

template<typename T, typename... Ts>
auto make_v(size_t a, Ts... ts) {
    return vector<decltype(make_v<T>(ts...))>(a, make_v<T>(ts...));
}

template<typename T, typename V>
typename enable_if<is_class<T>::value == 0>::type
fill_v(T& t, const V& v) { t = v; }

template<typename T, typename V>
typename enable_if<is_class<T>::value != 0>::type
fill_v(T& t, const V& v) {
    for (auto& e:t) fill_v(e, v);
}

typedef pair<int, int> P;

class AFerrisWheel {
public:
    void solve(std::istream& cin, std::ostream& cout) {
        int A, B;
        cin >> A >> B;

        int res = 0;
        if (A >= 13) {
            res = B;
        }
        else if (A >= 6) {
            res = B / 2;
        }
        cout << res << endl;

    }
};


signed main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    std::istream& in(std::cin);
    std::ostream& out(std::cout);

    AFerrisWheel solver;
    solver.solve(in, out);
    return 0;
}


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

int main() {
	int n;
	cin >> n;
	vector<int> a(n);
	vector<int> b(n);
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	for (int j = 0; j < n; j++) {
		b[j] = a[n - j - 1];
	}
	cout << b[0];
	for (int k = 1; k < n; k++) {
		cout << " " << b[k];
	}
cout << endl;
}


Measured memory_bytes: 3080
#include<bits/stdc++.h>
using namespace std;
const int N=2005;
int n,L[N],R[N],f[N];
char s[N],t[N];
vector<pair<int,int> > a;
inline bool inseg(int x,int l,int r)
{
	if(l<=r)return x>=l&&x<=r;
	return x>=l||x<=r;
}
inline int getR(int x,int y)
{
	if(x<=y)return y-x;
	return y+n-x;
}
inline int getL(int x,int y)
{
	if(y<=x)return x-y;
	return x+n-y;
}
int main()
{
	memset(L,-1,sizeof(L));
	memset(R,-1,sizeof(R));
	scanf("%s%s",s,t);
	n=strlen(s);
	int S=1,T=1;
	for(int i=0;i<n;i++)
	{
		if(s[i]=='1')S=0;
		if(t[i]=='1')T=0;
	}
	if(S&&T)return puts("0"),0;
	if(T)return puts("-1"),0;
	int pos=0;
	for(int i=0;i<n;i++)if(t[i]=='1')pos=i;
	for(int i=pos;L[i]<0;i=(i+1)%n)L[i]=(t[i]=='1'?i:L[(i+n-1)%n]);
	for(int i=pos;R[i]<0;i=(i+n-1)%n)R[i]=(t[i]=='1'?i:R[(i+1)%n]);
	int ans=1e9;
	for(int i=0;i<n;i++)
	{
		a.clear();
		int num=i;
		for(int j=0;j<n;j++)num+=(s[(i+j)%n]!=t[j]);
		for(int j=0;j<n;j++)if(s[(i+j)%n]!=t[j]&&!inseg(L[(i+j)%n],j,(i+j)%n))
			a.push_back(make_pair(getL(j,L[(j+n-1)%n]),getR((i+j)%n,R[(i+j+1)%n])));
		if(a.size())
		{
			sort(a.begin(),a.end());
			for(int i=a.size()-2;i>=0;i--)a[i].second=max(a[i].second,a[i+1].second);
			int mn=min(a[0].second,a[a.size()-1].first);
			for(int i=0;i<a.size()-1;i++)mn=min(mn,a[i].first+a[i+1].second);
			num+=2*mn;
		}
		if(num<ans)ans=num;
	}
	for(int i=0;i<n;i++)
	{
		a.clear();
		int num=i;
		for(int j=0;j<n;j++)num+=(s[(j-i+n)%n]!=t[j]);
		for(int j=0;j<n;j++)if(s[(j-i+n)%n]!=t[j]&&!inseg(L[j],(j-i+n)%n,j))
			a.push_back(make_pair(getL((j-i+n)%n,L[(j-i-1+n)%n]),getR(j,R[(j+1)%n])));
		if(a.size())
		{
			sort(a.begin(),a.end());
			for(int i=a.size()-2;i>=0;i--)a[i].second=max(a[i].second,a[i+1].second);
			int mn=min(a[0].second,a[a.size()-1].first);
			for(int i=0;i<a.size()-1;i++)mn=min(mn,a[i].first+a[i+1].second);
			num+=2*mn;
		}
		if(num<ans)ans=num;
	}
	printf("%d\n",ans);
	return 0;
}

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

int64_t calcGCD(int64_t a,int64_t b){
    int64_t p = a;
    int64_t q = b;
    int64_t c = a%b;
    while(c != 0){
        p = q;
        q = c;
        c = p%q;
    }
    return q;
}

int main(){
 int64_t k,x;
  cin >> k >> x;
  if(500*k >= x){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }   
}

Measured memory_bytes: 256
import sys
sys.setrecursionlimit(100000000)


def main():
    N, K, C = map(int, input().split())
    S = input()

    def forward(k):
        i = 0
        day = 0
        days = [-1] * k
        l = len(S)
        while day < k and i < l:
            while S[i] == 'x':
                i += 1
                if i >= l:
                    return None
            days[day] = i
            day += 1
            i += 1 + C
        if day < k:
            return None
        return days

    def backward(k):
        day = k
        days = [-1] * k
        l = len(S)
        i = l - 1
        while day > 0 and i >= 0:
            while S[i] == 'x':
                i -= 1
                if i < 0:
                    return None
            day -= 1
            days[day] = i
            i -= (1 + C)
        if day > 0:
            return None
        return days

    left = forward(K)
    if left is None:
        return

    right = backward(K)
    for i, j in zip(left, right):
        if i == j:
            print(i + 1)

main()


Measured memory_bytes: 20596
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, from, to) for (int i = from; i < (to); ++i)
#define mp(x,y) make_pair(x,y)
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()
using ll = long long;
using vin=vector<int>;
using vll=vector<ll>;
using P = pair<int, int>;
const int inf=1e9+7;
const ll INF=1e18;
template <typename T> void chmin(T &a, T b) { a = min(a, b); }
template <typename T> void chmax(T &a, T b) { a = max(a, b); }

int main() {
 bool ok=true;
  string s;
  cin>>s;
  ok= s[0]=='A';
  int cnt=0;
  int n=s.size();
  for(int i=2;i<=s.size()-2;i++){
    if(s[i]=='C')cnt++;
    else if(s[i]<'a') ok=false;
  }
  if(cnt!=1) ok=false;
  if(s[1]<'a') ok=false;
  if(s[n-1]<'a') ok=false;
  
  if(ok) cout<<"AC"<<endl;
  else cout<<"WA"<<endl;
}










Measured memory_bytes: 256
#include<iostream>

using namespace std;

int main(void){
  long long x,emp[4001],val[4001];
  long long emp1,val1,con,flag;

  while(1){
    cin >> x;
    if(x==0)break;

    for(int i=0;i<4001;i++){
      emp[i]=0;
      val[i]=0;
    }
    for(int i=0;i<x;i++){
      cin >> emp1 >> val1 >> con;

      flag=0;
      for(int j=0;j<x;j++){
	if(emp[j]==emp1){
	  flag=1;
	  val[j]+=val1*con;
	  break;
	}
      }
      if(flag==0){
	for(int j=0;j<4001;j++){
	  if(emp[j]==0){
	    emp[j]=emp1;
	    val[j]=val1*con;
	    break;
	  }  
	}
      }
    }
      flag=0;
    for(int j=0;j<4001;j++){
      if(val[j]>=1000000){
	cout << emp[j] << endl;
	flag=1;
      }
    }
    if(flag==0)cout << "NA" << endl;
  }
  return 0;
}

Measured memory_bytes: 0
object Main {
  def main(args:Array[String]) = {
    val sc = new java.util.Scanner(System.in)
    val a = sc.nextInt //最初の整数が読み込まれる
    val b = sc.nextInt //2番目に出てきた整数が読み込まれる
    println(a*a-b)
  }
}

Measured memory_bytes: 25672
#include<bits/stdc++.h>
#define REP(i,n) for(int (i)=0 ;(i)<(n);(i)++)
#define REPR(i,n) for(int (i)=(n);(i)>=0;(i)--)
#define FOR(i,m,n) for(int (i)=(m);(i)<(n);(i)++)
#define ALL(x) x.begin(),x.end()
#define REVERSE(x) reverse(x.begin(),x.end())
#define SORT(x,n) sort(x,x)
#define P pair<int,int>
typedef long long LL;
const int INF=1000000007;
using namespace std;
int main(){
    int N;
    int K;
    int Q;
    int nankai[100000]={};
    int A[100000];
    cin>>N>>K>>Q;
    FOR(i,1,Q+1){
        cin>>A[i];
    }
    FOR(i,1,Q+1){
        nankai[A[i]]++;
    }
    int point[100000];
    FOR(i,1,N+1){
        point[i]=K-Q+nankai[i];
    }
    FOR(i,1,N+1){
        if(point[i]>0){
            cout<<"Yes"<<endl;
        }
        else{
            cout<<"No"<<endl;
        }
    }
}

Measured memory_bytes: 1792
//Link : https://atcoder.jp/contests/arc066/tasks/arc066_c

#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define N 200005

int A[N],op[N];
ll dp[N][4];

int getValue(int o,int bit,int v) {
  bit^=o;
  if(bit&1) {
    return -v;
  }
  return v;
}
ll solveDp(int ind,int bit,int n) {
  if(ind>n) {
    return 0;
  }
  ll &ret = dp[ind][bit];
  if( ret!=-1) {
    return ret;
  }
  for(int i=0;i<bit;++i) {
    ret = max(ret, solveDp(ind,i,n));
  }

  ret = max(ret,solveDp(ind+1,bit,n) + getValue(op[ind-1],bit,A[ind]));
  if(op[ind-1]) {
    if(bit!=3) {
      ret = max(ret,getValue(op[ind-1],bit,A[ind]) + solveDp(ind+1,bit+1,n));
    }
  }

  return ret;
}
void solve() {
  int n;scanf("%d ",&n);
  for(int i=1;i<=n;++i) {
    scanf("%d ", &A[i]);
    char c;
    if(i!=n) {
      scanf(" %c ", &c);
      if(c=='-') {
        op[i] = 1;
      }
    }
  }
  memset(dp,-1,sizeof(dp));
  printf("%lld\n", solveDp(1,0,n));
}
int main() {
    //freopen("input.txt","r",stdin);
    solve();
    return 0;
}


Measured memory_bytes: 15104
n = int(input())
a = list(map(int,input().split()))

ans = 0
min = 1000000

for i in range(n):
	while (a[i]>>1 != 0) and (a[i]%2 == 0):
		a[i]=a[i]>>1
		ans+=1
	if ans<min:
		min = ans
	ans = 0
print(min)


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

int dp[100005];

int min(int a,int b);

int main(void){
  int N,h[100005],i;
  char str[1000000],*p;
  
  fgets(str,sizeof(str),stdin);
  N=atoi(str);
  
  fgets(str,sizeof(str),stdin);
  p=strtok(str," \n");
  h[1]=atoi(p);
  for(i=2;i<N+1;i++){
    p=strtok(NULL," \n");
    h[i]=atoi(p);
  }
  
  for(i=3,dp[2]=abs(h[2]-h[1]);i<N+1;i++){
    dp[i]=min(dp[i-1]+abs(h[i]-h[i-1]),dp[i-2]+abs(h[i]-h[i-2]));
  }
  
  printf("%d\n",dp[N]);
  
  return 0;
}


int min(int a,int b){
  if(a<=b){
    return a;
  }else{
    return b;
  }
}

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

int main() {
  long double pi = 3.14159265358979323846264338327950;
  int A, B, H, M;
  cin >> A >> B >> H >> M;
  long double a = pi*2*((long double)H/12.0+((long double)M/60.0)/12.0-(long double)M/60.0); // cos(360-t)=cos(t)よりabsは取らなくて良い
  long double x = (long double)(A*A + B*B) - (long double)(2*A*B)*cosl(a);
  printf("%.20Lf", sqrt(x));
}


Measured memory_bytes: 4112
#include<bits/stdc++.h>
#define rep(i,a,n) for (int i = a;i < n;i++)
#define per(i,n,a) for (int i = n-1;i >= a;i--)
using namespace std;

int main () {
    int w, a, b; cin >> w >> a >> b;
    cout << max(0, abs(b - a) - w) << endl;
}

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

#define REP(i, s, n) for (int i = s; i < n; ++i)
#define rep(i, n) REP(i, 0, n)
#define SORT(c) sort((c).begin(), (c).end())
#define SORT_INV(c) sort((c).begin(), (c).end(), greater<int>())

#define IINF INT_MAX
#define LLINF LLONG_MAX
#define DEBUG false
#define LL long long
#define MOD 1000000007

//cout << (c)?"Yay!":":(" << endl;

// sort(a.begin(), a.end(), std::greater<int>());
using namespace std;

int main()
{
int a,b;
cin>>a>>b;
if(a<b) cout<<0<<endl;
else cout<<10<<endl;
return 0;
}


Measured memory_bytes: 256
package main

import "fmt"

func main() {
	var N, K int
	fmt.Scanf("%d", &N)
	fmt.Scanf("%d", &K)

	var S string
	fmt.Scanf("%s", &S)

	var groupCount int
	var current rune
	for _, s := range S {
		if current == 0 || current != s {
			current = s
			groupCount++
		}
	}

	for i := 0; i < K; i++ {
		if groupCount == 1 {
			break
		} else if groupCount == 2 {
			groupCount--
		} else {
			groupCount -= 2
		}
	}

	fmt.Println(N - groupCount)
}


Measured memory_bytes: 1280
#include <algorithm>
#include <array>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <vector>

#define REP(X, Y, Z) for (ll(X) = (Y); (X) < (Z); (X)++)
#define REV(X, Y, Z) for (ll(X) = (Y); (X) > (Z); (X)--)

using namespace std;
using ll = long long;
using dll = deque<ll>;
using pll = pair<ll, ll>;
using qll = queue<ll>;
using usll = unordered_set<ll>;
using umll = unordered_map<ll, ll>;
using sll = stack<int>;
using vll = vector<ll>;
using vvll = vector<vll>;

constexpr ll kMod = 1e9 + 7;

ll gcd(ll a, ll b) {
  if (a < b) {
    return gcd(b, a);
  }
  ll c = a % b;
  while (c != 0) {
    a = b;
    b = c;
    c = a % b;
  }
  return b;
}

ll lcm(ll a, ll b) {
  return a / gcd(a, b) * b;
}

void init() {
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(15);
}

int main() {
  init();

  ll N, M;
  string S, T;
  cin >> N >> M >> S >> T;

  ll g = gcd(N, M);
  ll l = lcm(N, M);
  REP(i, 0, N) {
    if (i % (N / g) == 0 && S[i] != T[i * M / N]) {
      cout << -1 << endl;
      return 0;
    }
  }
  cout << l << endl;

  return 0;
}


Measured memory_bytes: 640
// ABC079B - 

#include <bits/stdc++.h>
using namespace std;

typedef unsigned long long int ull;
typedef long long int ll;

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

	ull L[N+1];

	L[0] = 2;
	L[1] = 1;

	for (int i = 2; i <= N; i++) {
		L[i] = L[i-1] + L[i-2];
	}

	cout << L[N] << endl;

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define snuke srand((unsigned)clock()+(unsigned)time(NULL));
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
inline int in() { int x; scanf("%d",&x); return x;}
template<typename T>inline istream& operator>>(istream&i,v(T)&v)
{rep(j,sz(v))i>>v[j];return i;}
template<typename T>string join(const v(T)&v)
{stringstream s;rep(i,sz(v))s<<' '<<v[i];return s.str().substr(1);}
template<typename T>inline ostream& operator<<(ostream&o,const v(T)&v)
{if(sz(v))o<<join(v);return o;}
template<typename T1,typename T2>inline istream& operator>>(istream&i,pair<T1,T2>&v)
{return i>>v.fi>>v.se;}
template<typename T1,typename T2>inline ostream& operator<<(ostream&o,const pair<T1,T2>&v)
{return o<<v.fi<<","<<v.se;}
template<typename T>inline ll suma(const v(T)& a) { ll res(0); for (auto&& x : a) res += x; return res;}
const double eps = 1e-10;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
#define dame { puts("-1"); return 0;}
#define yn {puts("Yes");}else{puts("No");}
const int MX = 200005;

    // 整数スキャン（複数）
    /*
    int x;
    scanf("%d",&x);
    int y;
    scanf("%d",&y);
    int z;
    scanf("%d",&z);

    // n個の整数のスキャン
    /*
    ll a[n] = {};
    rep(i,n){
        scanf("%lld",&a[i]);
    }
    */

    // 文字列スキャン
    /*
    string s;
    cin >> s;
    */

    // n個の文字列スキャン
    /*
    vector<string> slist;
    rep(i,n){
        string s;
        cin >> s;
        slist.push_back(s);
    }
    */

int main() {
    int x;
    scanf("%d",&x);
    int y;
    scanf("%d",&y);
    int z;
    scanf("%d",&z);


    ll ans = 0;
    
    cout << (x*y)/2 << endl;
    return 0;
}
 
 


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a) for(int i = 0; i < (a); i++)
#define ALL(a) (a).begin(),(a).end()
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1e9;
const int MOD = 1e9 + 7;

int main(){
	int n,m;
	cin >> n >> m;
	vector<int> p(m),y(m);
	vector<vector<int>> tmp(n);
	REP(i,m){
		cin >> p[i] >> y[i];
		tmp[p[i] - 1].push_back(y[i]);
	}
	REP(i,n) sort(ALL(tmp[i]));
	vector<int> res(m);
	REP(i,m) res[i] = lower_bound(ALL(tmp[p[i] - 1]), y[i]) - tmp[p[i] - 1].begin() + 1;
	REP(i,m) printf("%06d%06d\n", p[i], res[i]);
}

Measured memory_bytes: 8192
import itertools
import math
n = int(input())
dis = [[0] * 2 for i in range(n)]
for i in range(n):
    dis[i][0],dis[i][1] = list(map(int,input().split()))
b= [0] * n
for i in range(n):
    b[i] = i + 1
p = list(itertools.combinations(b,2))
ans =0
for i in range(len(p)):
    dist = (dis[p[i][0]-1][0]-dis[p[i][1]-1][0])**2 + (dis[p[i][0]-1][1]-dis[p[i][1]-1][1])**2
    ans += math.sqrt(dist)

print(ans/n * 2)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
#define INF 9003372036854775807LL
#define mod 1000000007
#define fixed fixed<<setprecision(12)
#define abs(x,y) (max(x,y)-min(x,y))
#define lol long long
#define mp make_pair
#define fi first
#define se second
using namespace std;
using pii=pair<int, int > ;
lol a[300010];
signed main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  string s;
  lol n,m,k,r,x,y;
  cin >>n;
  lol ans=1;
  while(ans*2<=n) ans*=2;
  cout <<ans<<'\n';
  return (0);
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <algorithm>
using namespace std;

int main() {
  int a, b, c;
  cin >> a >> b >> c;
  cout << a + b + c << endl;
}




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



int main() {
    vector<int> n(3);
    vector<int> j(3);


    for(int i=0;i<3;i++){
        cin>>n.at(i);
    }




    sort(n.begin(),n.end(),greater<int>());


    int co=0;
    cin>>n.at(0)>>n.at(1)>>n.at(2);
    for(int i=0;i<3;i++){
        if(n.at(i)%2==0){
            co++;
            j.at(i)=1;
            //0->even 1-> odd
        }
    }


    if(co==0||co==3){
        cout<<(2*n.at(0)-n.at(1)-n.at(2))/2<<endl;
    }else if(co==1){
        for(int i=0;i<3;i++){
            if(j.at(i)==0){
                n.at(i)++;
            }
        }
        cout<<((2*n.at(0)-n.at(1)-n.at(2))/2)+1<<endl;
    }else if(co==2){
        for(int i=0;i<3;i++){
            if(j.at(i)==1){
                n.at(i)++;
            }
        }
        cout<<((2*n.at(0)-n.at(1)-n.at(2))/2)+1<<endl;
    }
}

Measured memory_bytes: 256
import math

n, k = list(map(int, input().split()))
mod = 10 ** 9 + 7

def comb(n, r):
	return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

def solve(n, k, i):
	n_b = comb(k - 1, i - 1) % mod
	if i == 1:
		n_r = (n - k + 1) % mod
	else:
		if n - k < i - 1:
			n_r = 0
		elif n - k == i - 1:
			n_r = 1
		elif n - k == i:
			n_r = comb(n - k - 1, i - 2) + comb(n - k - 1, i - 1) * 2
		else:
			n_r = (comb(n - k - 1, i - 2) + comb(n - k - 1, i - 1) * 2 + comb(n - k - 1, i)) % mod
	#print(n_b, n_r, (n_b * n_r) % mod)
	print((n_b * n_r) % mod)

for i in range(1, k + 1):
	solve(n, k, i)

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

using namespace std;

typedef long long ll;

int a[100005][3],n;
ll dp[100005][4];
ll vacation(int i,int idx)
{
    if(i>=n)
        return 0;

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

    ll temp=0;
    for(int j=1;j<=3;j++)
    {
        if(idx==j)
            continue;

       temp = max(temp,a[i][j]+vacation(i+1,j));
    }
    dp[i][idx]=temp;
    return dp[i][idx];
}


int main()
{
    memset(dp,-1,sizeof(dp));
    cin>>n;
    for(int i=0;i<n;i++)
    {
        for(int j=1;j<=3;j++)
        {
            cin>>a[i][j];
        }
    }
    cout<<vacation(0,0);


    return 0;
}


Measured memory_bytes: 15664
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define F first
#define S second
#define pii pair<int, int>
#define pli pair<ll, int>
#define pil pair<int, ll>
#define pll pair<ll, ll>
#define eb emplace_back
#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep3(i, l, n) for (int i = l; i < (n); ++i)
#define sz(v) (int)v.size()
#define endl '\n'
const int inf = 1000000007;
const ll INF = 1e18;
// int mod = 998244353;
int mod = 1000000007;
const double eps = 1e-8;
#define abs(x) (x >= 0 ? x : -(x))
#define lb(v, x) (int)(lower_bound(all(v), x) - v.begin())
#define ub(v, x) (int)(upper_bound(all(v), x) - v.begin())
template<typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { if (a > b) { a = b; return 1; } return 0; }
template<typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { if (a < b) { a = b; return 1; } return 0; }
ll gcd(ll a, ll b) { if (b == 0) return a; return gcd(b, a % b); }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
template<typename T, typename U> T pow_(T a, U b) { return b ? pow_(a * a, b / 2) * (b % 2 ? a : 1) : 1; }
ll modpow(ll a, ll b, ll _mod) { return b ? modpow(a * a % _mod, b / 2, _mod) * (b % 2 ? a : 1) % _mod : 1; }
template<class T, class U> ostream& operator << (ostream& os, const pair<T, U>& p) { os << p.F << " " << p.S; return os; }
template<class T> ostream& operator << (ostream& os, const vector<T>& vec) { rep(i, sz(vec)) { if (i) os << " "; os << vec[i]; } return os; }
template<class T> ostream& operator << (ostream& os, const set<T>& s) { for (auto si : s) os << si << " "; return os; }
template<typename T> inline istream& operator >> (istream& is, vector<T>& v) { rep(j, sz(v)) is >> v[j]; return is; }
template<class T, class T2> inline void add(T &a, T2 b) { (a += (b % mod + mod)) %= mod; }
template<class T> void operator += (vector<T>& v, vector<T> v2) { rep(i, sz(v2)) v.eb(v2[i]); }

void solve();

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cout << fixed << setprecision(12); // debuged
    int T;
    T = 1;
    while (T--) solve();
}

void solve() {
    int n;
    cin >> n;
    vector<int> a(n), b(n);
    cin >> a >> b;
    vector<int> c = a;
    sort(all(c));
    int ai = -1, bi = -1;
    
    int cnt = 0;
    do {
        if (c == a) ai = cnt;
        if (c == b) bi = cnt;
        ++cnt;
    } while (next_permutation(all(c)));
    cout << abs(ai - bi) << endl;
}


Measured memory_bytes: 3556
#include<bits/stdc++.h>
using namespace std;
int main()
{
  string s;
  cin>>s;
  if(s=="SUN")
    cout<<"7";
  if(s=="MON")
    cout<<"6";
  if(s=="TUE")
    cout<<"5";
  if(s=="WED")
    cout<<"4";
  if(s=="THU")
    cout<<"3";
  if(s=="FRI")
    cout<<"2";
  if(s=="SAT")
    cout<<"1";
  return 0;
}

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

using namespace std;

vector <int> g[MAXN + 1];
bool viz[2][MAXN + 1];
int dist[2][MAXN + 1];
int cnt[2];

void dfs(int nod, bool t) {
   // cnt[t]++;
    viz[t][nod] = 1;
    for(auto it : g[nod])
      if(viz[t][it] == 0) {
          dist[t][it] = dist[t][nod] + 1;
          dfs(it, t);
      }
}

int main() {
    //fstream cin("A.in");
    //ofstream cout("A.out");
    int i, n, a, b;
    //ios::sync_with_stdio(false);
    cin >> n;
    for(i = 1; i < n; i++) {
        cin >> a >> b;
        g[a].push_back(b);
        g[b].push_back(a);
    }
    viz[0][n] = 1;
    dist[0][1] = 1;
    dfs(1, 0);
    viz[1][1] = 1;
    dist[1][n] = 1;
    dfs(n, 1);
    for(i = 1; i <= n; i++)
        if(viz[0][i] == 0)
           cnt[1]++;
        else if(viz[1][i] == 0)
           cnt[0]++;
        else if(dist[0][i] <= dist[1][i])
            cnt[0]++;
        else
            cnt[1]++;
    if(cnt[0] > cnt[1])
        cout << "Fennec";
    else
        cout << "Snuke";
    //cin.close();
    // cout.close();
    return 0;
}


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

unordered_map<int, int> factor;
int main()
{
    int n;
    cin >> n;
    for(int i = 2;i <= n;++i)
    {
        int t = i;
        for(int j = 2;j <= t;++j)
        {
            while(t % j == 0)
            {
                ++factor[j];
                t /= j;
            }
        }
        if(t != 1)
            ++factor[t];
    }
    long long ans = 1;
    for(auto ele : factor)
        ans = (ans * (ele.second + 1)) % MOD;
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
import itertools as it
for i in range(10**9):
    cnt=0
    n,x=map(int,input().split())
    if n==0 and x==0:
        exit()
    comb=it.combinations(range(1,n+1),3)
    for i in comb:
        if sum(i)==x:
            cnt+=1
    print(cnt)


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


int main() {
    char op;
    int a, b;
    cin >> a >> op >> b;
    if (op == '+')cout << a + b << endl;
    else cout << a - b << endl;
    
    return 0;
}

Measured memory_bytes: 256
/**
class cfmaster {
 public:
  struct code {
  	see the details down there !
  };
};
**/
#include <bits/stdc++.h>
 
using namespace std;
 
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n, k;
  cin >> n >> k;
  int ans = 0;
  while (n) {
    n /= k;
    ++ans;
  }
  cout << max(ans, 1) << '\n';
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<algorithm>
using namespace std;
int main(){
//	freopen(".in","r",stdin);
//	freopen(".out","w",stdout);
	int n;
	cin>>n;
	int a[n+1];
	for(int i=1;i<=n;i++){
		cin>>a[i];
	}
	sort(a+1,a+n+1);
	for(int i=1;i<=n-1;i++){
		if(a[i]==a[i+1]){
			cout<<"NO"<<endl;
			return 0;
		}
	}
	cout<<"YES"<<endl;
	return 0;
}

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

// #include <ext/pb_ds/assoc_container.hpp> 
// #include <ext/pb_ds/tree_policy.hpp> 
// using namespace __gnu_pbds; 
  
// #define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> 
 
#define FS              ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ll              long long int
#define ld              long double
#define pb              push_back
#define bp              __builtin_popcount
#define sz              size()
#define ff              first
#define ss              second
#define vll             vector<ll>
#define vbool           vector<bool>
#define vpll            vector<pair<ll,ll>>
#define pll             pair<ll,ll>
#define vllv            vector<vector<ll>>
#define setpri(x)       cout<<setprecision(x)<<fixed;
#define all(v)          v.begin(),v.end()
#define allr(v)         v.rbegin(),v.rend()
#define yesr {cout<<"YES"<<endl;return;}
#define nor {cout<<"NO"<<endl;return;}
// getline (std::cin,name);
ll MOD=1e9+7;
ll ceil1(ll n,ll x){return (n-1)/x+(n>0);}

ll gcd(ll a,ll b){return __gcd(a,b);}
ll lcm(ll a,ll b){return (max(a,b)/gcd(a,b))*min(a,b);}

ll pow1(ll n,ll m ,ll mod=MOD );
ll pow2(ll n,ll k);

ll modinv(ll n,ll mod=MOD){  return pow1(n,mod-2,mod);}

bool func(pair<ll,ll> &a,pair<ll,ll> &b ){
        if(a.ff != b.ff)return a.ff < b.ff;
        return a.ss > b.ss;
}

ll const N=(ll)2e5+11;
ll const LG=(ll)log2(N)+1;


void solve(){
        ll i,j,k,l,n,m,x,y,z,r;
       
       cin>>n>>m;
       ll ans=max({n+n-1,m+m-1,n+m});
       cout<<ans<<endl;
       
        
}       
int main(){
        FS;
        
        ll i,j,k,n,m,x,y,z,q;
        q=1;
        // cin>>q;
        for(ll tc=1;tc<=q;tc++){
                // cout<<"Case #"<<tc<<": ";
                solve();
        }
        return 0;
}


ll pow1(ll n,ll m,ll mod){
        if(m==0)return 1;
        
        if(m%2==0)return pow1((n*n)%mod,m/2,mod);
    	
    	return (pow1((n*n)%mod,m/2,mod)*n)%mod;
}

ll pow2(ll n,ll k){
        ll ans=1;
            while(k>0){
                if(k%2==1)ans=ans*n;
                n=n*n;
                k/=2;
            }
            return ans;
}


Measured memory_bytes: 3608
#include<stdio.h>

struct Card{
  char suit;
  char value;
};

void bubble(struct Card A[], int n){
  int i, j;
  struct Card t;
  for ( i = 0; i < n; i++ ){
    for ( j = n-1; j >= i+1; j-- ){
      if ( A[j].value < A[j-1].value ){
	t = A[j]; A[j] = A[j-1]; A[j-1] = t;
      }
    }
  }
}

void selection(struct Card A[], int n){
  int i, j, mini;
  struct Card t;
  for ( i = 0; i < n; i++ ){
    mini = i;
    for ( j = i; j < n; j++ ){
      if ( A[j].value < A[mini].value ) mini = j;
    }
    t = A[i]; A[i] = A[mini]; A[mini] = t;
  }
}

void print(struct Card A[], int n){
  int i;
  for ( i = 0; i < n; i++ ){
    if ( i ) printf(" ");
    printf("%c%c", A[i].suit, A[i].value);
  }
  printf("\n");
}

int isStable(struct Card C1[], struct Card C2[], int n){
  int i;
  for ( i = 0; i < n; i++ ){
    if ( C1[i].suit != C2[i].suit ) return 0;
  }
  return 1;
}

int main(){
  struct Card C1[101], C2[101];
  int n, i;
  char ch;

  scanf("%d%c", &n, &ch);
  //scanf("%d\n", &n);
  for ( i = 0; i < n; i++ ){
    //scanf("%c%c ", &C1[i].suit, &C1[i].value);
    scanf("%c%c%c", &C1[i].suit, &C1[i].value, &ch);
  }

  for ( i = 0; i < n; i++ ) C2[i] = C1[i];

  bubble(C1, n);
  selection(C2, n);

  print(C1, n);
  printf("Stable\n");
  print(C2, n);
  if ( isStable(C1, C2, n) ){
    printf("Stable\n");
  } else {
    printf("Not stable\n");
  }

  return 0;
}



Measured memory_bytes: 2124
// Author: Mrigank
/* Science is what we understand well enough to explain to a computer, 
    Art is everything else we do - Donald E. Knuth */

#include <bits/stdc++.h>
#include <iostream>
#include <unordered_map>
#include <map>
#include <queue>
#include <stack>
#include <unordered_set>
#include <set>
#include <string> 
#include <vector>
#include <algorithm>
#include <numeric>

using namespace std;

typedef long long int ll;
typedef long double ld;
typedef pair<ll, int> PLI;
typedef pair<int, int> PII;
typedef vector < ll > vl;
typedef vector < int > vi;
typedef vector < bool > vb;
typedef vector < pair < ll , ll > > vpl;
typedef vector < pair < ll , bool > > vpb;
typedef vector < vector < int > > vvi;
typedef vector < vector < ll > > vvl;


#define fo(i,n) for(i=0;i<n;i++)
#define Fo(i,k,n) for(i=k;i<n;i++)
#define pi pair < ll , ll >
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define clr(x , val) memset(x , val , sizeof(x))
#define deb(x) cout<<#x<<" :: "<<x<<"\n"
#define deb2(x,y) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<"\n"
#define deb3(x,y,z) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<"\t"<<#z<<" :: "<<z<<"\n"
#define all(x) x.begin() , x.end()
#define alls(x , y) x.begin() , x.end() , y
#define fastIO ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define endl "\n"

const ll mxsize = 5e6 + 5;
const ll linf = 1e9;
const ld inf = 10000000000.0;
const ll mod = 1e9 + 7;
 
/******************************************** CODE STARTS FROM HERE *************************************************/ 

int main()
{
    fastIO;
    ll n , m;
    cin >> n >> m;
    vl arr(m);
    ll i;
    fo(i , m)
    {
        cin >> arr[i];
    }
    ll sum = accumulate(alls(arr , 0));
    if(sum <= n)
    {
        cout << n - sum << endl;
    }
    else
    {
        cout << -1 << endl;
    }
}

Measured memory_bytes: 3640
#include <bits/stdc++.h>
using namespace std;
using Int = long long int;
template<typename T> void swap(T *t1, T *t2){ T* tmp=t1; t1=t2; t2=tmp;}
Int tmpi = 0;
double tmpd = 0.0;


class Edge {
    public:
    Int to, weight;
    Edge(Int t, Int w) : to(t), weight(w) {}
};

vector<vector<Edge>> graph(100001);

void dfs(Int u, int color[], Int n, int visit[]){
    visit[u] = 1;
    for(Edge const& e : graph[u]){
        if(visit[e.to] != 0) continue;
        if(e.weight%2 == 0){
            color[e.to] = color[u];
        }else{
            color[e.to] = color[u]==0 ? 1 : 0;
        }
        dfs(e.to, color, n, visit);
    }
}

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

    Int n;
    Int u, v, w;
    int color[100001];
    int visit[100001];
    cin >> n;
    for(Int i=0; i<n-1; i++){
        cin >> u >> v >> w;
        graph[u].push_back(Edge(v, w));
        graph[v].push_back(Edge(u, w));
    }
    for(Int i=1; i<=n; i++){
        color[i] = 0;
        visit[i] = 0;
    }
    
    dfs(1, color, n, visit);

    for(Int i=1; i<=n; i++){
        cout << color[i] << endl;
    }
    return 0;
}

Measured memory_bytes: 11008
#!/usr/bin/env python3
def main():
    N = int(input())
    if N == 1:print(1);exit();
    x = [None] * N
    y = [None] * N
    for i in range(N):
        x[i], y[i] = map(int, input().split())
    
    diff = []
    nums = []
    for i in range(N):
        for j in range(N):
            if i == j:
                continue
            if (x[j]-x[i],y[j]-y[i]) in diff:
                nums[diff.index((x[j]-x[i],y[j]-y[i]))] += 1
            else:
                diff.append((x[j]-x[i],y[j]-y[i]))
                nums.append(1)
    # print(diff)
    # print(nums)
    print(N-max(nums))

if __name__ == "__main__":
    main()


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


int main() {
    int n;
    cin >> n;
    vector<int> vec(n);
    for (int i = 0; i < n; i++) {
        cin >> vec.at(i);
    }

    cout << *max_element(vec.begin(), vec.end()) - *min_element(vec.begin(), vec.end()) << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <string>
#include <cmath>
using namespace std;
#define ll long long
const int N=10005;
const int mod=1e9+7;
const int maxn=1e7;
ll a[101];
ll gcd(ll x,ll y)
{
    ll c;
    ll m=x,n=y;
    while(y!=0){
        c=x%y;//x-2 y-3 ,c-2,x=3,y=2\\c=1,x=2,y=1\\c=0,x=1,y=0
        x=y;
        y=c;
    }
    return m/x*n;// 2/1*3
}
int main()
{
    int n;
    cin>>n;
    ll m,s,l;
    cin>>m;
    if(n==1) cout<<m<<endl;
    else if(n>1){
        cin>>l;
        s=gcd(l,m);
        for(int i=0;i<n-2;i++){
            cin>>m;
            s=gcd(s,m);
        }
        cout<<s<<endl;
    }
    return 0;
}

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

#define rep(i,x,y) for(ll i=(x);i<(y);i++)
#define rrep(i,x,y) for(ll i=(ll)(y)-1;i>=(x);i--)
#define all(x) (x).begin(),(x).end()
#ifdef LOCAL
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl
#define itrdebug(x) cerr << #x << " "; for (auto & el : (x)) {cerr << (el) << " ";} cerr << endl
#define dassert(...) assert(__VA_ARGS__)
#else
#define debug(x)
#define itrdebug(x)
#define dassert(...)
#endif
//#define int long long

typedef long long ll;
const ll MOD = 1e9 + 7;
const long double EPS = 1e-8;

struct RL {
    int R = 0, L = 0;
    pair<int, int> cost;

    bool operator< (const RL & a) {
        return cost < a.cost;
    }
};

void solve(long long N, std::vector<std::string> S){
    rep(i,0,N) {
        vector<int> left;
        rep(j,0,S[i].size()) {
            if (S[i][j] == '(') {
                left.push_back(j);
            } else if (!left.empty() && S[i][j] == ')') {
                S[i][left.back()] = 'o';
                S[i][j] = 'o';
                left.pop_back();
            }
        }
        left.clear();
    }
    vector<RL> rl(N);
    rep(i,0,N) {
        rep(j,0,S[i].size()) {
            if (S[i][j] == ')') {
                assert(rl[i].L == 0);
                rl[i].R++;
            } else if (S[i][j] == '(') {
                rl[i].L++;
            }
        }
    }
    rep(i,0,N) {
        if (rl[i].L - rl[i].R >= 0) {
            rl[i].cost.first = 0;
            rl[i].cost.second = rl[i].R;
        } else {
            rl[i].cost.first = 1;
            rl[i].cost.second = -rl[i].L;
        }
    }
    sort(all(rl));
    bool isValid = true;
    int current = 0;
    rep(i,0,N) {
        current -= rl[i].R;
        if (current < 0) {
            isValid = false;
            break;
        }
        current += rl[i].L;
    }
    if (current != 0) isValid = false;
    cout << (isValid ? "Yes" : "No") << endl;
}

signed main(){
    cin.tie(NULL);
    ios_base::sync_with_stdio(false);
    long long N;
    cin >> N;
    std::vector<std::string> S(N);
    for(int i = 0 ; i < N ; i++){
        std::cin >> S[i];
    }
    solve(N, std::move(S));
    return 0;
}


Measured memory_bytes: 50132
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,s,n) for(ll i = (s); i < (n); i++)
#define all(v) v.begin(), v.end()
#define allr(v) v.rbegin(), v.rend()



int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(18);
  
  string s;
  ll a, b;
  cin >> a >> b;
  
  //vector<ll> a(n);  rep(i, 0, n) cin >> a[i];
  
  if(a*b==15)
    cout << "*" << "\n";
  else if(a+b==15)
    cout << "+" << "\n";
  else
    cout << "x" << "\n";

}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double db;
typedef long double ldb;
#define pi acos(-1)
const int N=100005;
const ll mod=1e9+9;
inline ll read(){
    ll x=0,f=1;char ch=getchar();
    while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
    while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
    return f*x;
}
char ch[5]; 
int main()
{
	int ans=700;
	scanf("%s",ch+1);
	for(int i=1;i<=3;i++)
		if(ch[i]=='o')
			ans+=100;
	cout<<ans;
	return 0;
}

Measured memory_bytes: 256
<?php
$f = fopen( 'php://stdin', 'r' );

function whatTriangle($three_seg) {
    sort($three_seg);
    if ($three_seg[0]+$three_seg[1] <= $three_seg[2]) {
        return false;
    } elseif (pow($three_seg[0], 2)+pow($three_seg[1], 2) === pow($three_seg[2], 2)) {
        return 'RT';
    } elseif (pow($three_seg[0], 2)+pow($three_seg[1], 2) > pow($three_seg[2], 2)) {
        return 'AT';
    } elseif (pow($three_seg[0], 2)+pow($three_seg[1], 2) < pow($three_seg[2], 2)) {
        return 'OT';
    }
}

$result_array = [0, 0, 0, 0];
while( $line = fgets( $f ) ) {
    $three_seg = array_map('intval', explode(' ', $line));
    $test = whatTriangle($three_seg);
    switch ($test) {
        case 'RT':
            $result_array[0]++;
            $result_array[1]++;
            break;
        case 'AT':
            $result_array[0]++;
            $result_array[2]++;
            break;
        case 'OT':
            $result_array[0]++;
            $result_array[3]++;
            break;
        case false:
            break 2;
    }
}
$result = implode(' ', $result_array);
echo $result;

fclose( $f );
?>



Measured memory_bytes: 9312
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		String S = in.nextLine();
		String T = in.nextLine();
		in.close();
		Map<Character, Character> charMap = new HashMap<>();

		boolean result = true;
		for (int i = 0; i < S.length(); ++i) {
			Character s = S.charAt(i);
			Character t = T.charAt(i);
			if (!charMap.containsKey(s) && !charMap.containsValue(t)) {
				charMap.put(s, t);
			} else {
				if (!t.equals(charMap.get(s))) {
					result = false;
					break;
				}
			}
		}
		if (result) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}
	}
}

Measured memory_bytes: 30036
#include<cstdio>
#define ll long long
using namespace std;
int read()
{
	int x=0;char ch=getchar();
	while (ch<'0'||ch>'9')ch=getchar();
	while (ch>='0'&&ch<='9')x=x*10+(ch^48),ch=getchar();
	return x;
}
const ll inf=1e15;
int n,a[505][505];
ll f[505][505],p[505][505],q[505][505];
ll min(ll a,ll b){return a<b?a:b;}
int main()
{
	n=read();
	for (int i=0;i<n;++i)
	for (int j=0;j<n;++j)
	if (i!=j)
	{
		a[i][j]=read();
		if (i<j)
		f[i][j]=inf;
	}
	for (int i=n-1;i>=0;--i)
	{
		for (int j=i+1;j<=n;++j)
		p[i][j]=p[i][j-1]+a[i][j];
		for (int j=i+1;j<=n;++j)
		p[i][j]+=p[i+1][j];
	}
	for (int i=0;i<n;++i)
	{
		for (int j=n-1;j>i;--j)
		q[i][j]=q[i][j+1]+a[j][i];
		if (i)
		for (int j=n-1;j>i;--j)
		q[i][j]+=q[i-1][j];
	}
	for (int i=1;i<=n;++i)
		for (int j=i+1;j<=n+1;++j)
		f[i][j]=p[0][i-1]+p[i][j-1]+q[i-1][j];
	for (int i=1;i<n;++i)
	for (int j=i+1;j<=n;++j)
	for (int k=j+1;k<=n+1;++k)
	f[j][k]=min(f[j][k],f[i][j]+
	p[j][k-1]+q[j-1][k]-q[i-1][k]);
	printf("%lld\n",f[n][n+1]);
	return 0;
}

Measured memory_bytes: 8516
from sys import stdin

n = stdin.readline().rstrip()
a = [int(x) for x in stdin.readline().rstrip().split()]

minc = 10**9

for b in a:
    count = 0
    while True:
        if b % 2 == 1: break
        b = b//2
        count = count + 1

    minc = min([minc, count])

print(minc)

Measured memory_bytes: 8868