akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <vector>
#include <list>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <fstream>
#include <sstream>
#include <iomanip>

using namespace std;

long long MOD = 1000000007;

void cout_vec(vector<int> &vec){
    for(int i=0; i<vec.size(); i++){
        if (i!=0){
            cout << ' ';
        }
        cout << vec[i];
    }
    cout << endl;
}

int main(){
    int N, K;
    cin >> N >> K;
    string S;
    cin >> S;
    vector<int> vec(1,0);
    char c='0';
    for(int i=0; i<S.size(); i++){
        if(S[i]==c){
            continue;
        }else{
            c=S[i];
            vec.push_back(i);
        }
    }
    vec.push_back(N);
    vec.push_back(N);
    int ans=0;
    int a=vec.size()-2*K;
    if(a<=0){
        cout << N << endl;
        return 0;
    }
    for(int i=0; i<vec.size(); i++){
        if(2*K+i+(i%2)>=vec.size())break;
        ans=max(vec[2*K+i+(i%2)]-vec[i],ans);
    }
    //cout_vec(vec);
    cout << ans << endl;
}

Measured memory_bytes: 1020
#include <stdio.h>
#include <algorithm>
using namespace std;
int arr[2001];
int main(){
	int N,X,Y;
	scanf("%d %d %d",&N,&X,&Y);
	for(int i=1;i<=N;i++){
		for(int j=i+1;j<=N;j++){
			if(j<=X || Y<=i) arr[j-i]++;
			else if(i<=X&&Y<=j) arr[j-i-(Y-X-1)]++;
			else if(X<=i&&j<=Y) arr[min(j-i,i-j+Y-X+1)]++;
			else if(i<=X&&X<=j) arr[min(j-i,Y+X-j-i+1)]++;
			else arr[min(j-i,i+j-X-Y+1)]++;
		}
	}
	for(int i=1;i<N;i++) printf("%d\n",arr[i]);
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
#define ll long long
#define N 100000
#define M 3000
using namespace std;

int n,ans,p[M+5];
ll x;
vector<ll> pr;
map<ll,int> mp;

void init() {

  for(int i=2;i<=M;i++) {
    if(!p[i]) {
      pr.push_back(i);
      for(int j=i+i;j<=M;j+=i) {
        p[j]=1;
      }
    }
  }

}

ll ters(ll x) {

  for(int i=0;i<pr.size();i++) {
    ll bol=1ll*pr[i]*pr[i]*pr[i];
    while(x%bol==0) x/=bol;
  }
  return x;

}

ll pai(ll x) {

  ll pi=1;
  vector<ll> carp;
  for(int i=0;i<pr.size();i++) {
    int no=0;
    while(x%pr[i]==0) x/=pr[i],no++;
    if(no) {
      for(int j=1;j<=3-no;j++,carp.push_back(pr[i]));
    }
  }
  ll sq=sqrt(x);
  if(sq*sq==x) {
    carp.push_back(sq);
  }
  else {
    for(int i=0;i<2;i++,carp.push_back(x));
  }
  for(int i=0;i<carp.size();i++) {
    pi*=carp[i];
    if(pi>1ll*N*N) {
      return 0;
    }
  }
  return pi;

}

int main() {

  init();
  scanf("%d",&n);
  for(int i=1;i<=n;i++) {
    scanf("%lld",&x);
    x=ters(x);
    mp[x]++;
  }
  for(auto i:mp) {
    ll inv=pai(i.first);
    if(i.first==1 || !inv) {
      if(i.first==1) ans+=2;
      else ans+=i.second*2;
      continue ;
    }
    if(mp.find(inv)!=mp.end()) {
      ans+=max(mp[inv],i.second);
    }
    else {
      ans+=2*i.second;
    }
  }
  printf("%d",ans/2);

}


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

using namespace std;

int main(){
    int a, b, c, k;
    int ans = 0;
    cin >> a >> b >> c >> k;
    ans += min(a, k);
    k -= a;
    if(k > 0)
        k -= b;
    if(k > 0)
        ans -= min(c, k);
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 3588
//inlclude before define 
#define _USE_MATH_DEFINES

//include
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<cmath>
#include<type_traits>
#include<numeric>
#include<deque>
#include<iomanip>
#include<set>
#include<unordered_set>
#include<tuple>
#include<map>
#include<memory>

using namespace std;

//typedef
typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<char> VC;
typedef vector<double> VD;
typedef pair<int, int> P1;
typedef long long int ll;

//number
#define INF 1e9
#define NUM 1000000007

//itr
#define all(x) begin(x),end(x)

//repeat
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define REP(i,a,b) for(int i=int(a);i<int(b);i++)
#define RREPS(i,x) for(int i=((int)(x));i>=0;i--)

//max,min
#define chmin(a,b) a=min((a),(b))
#define chmax(a,b) a=max((a),(b))

//function

/*ll gcd(ll a, ll b) {
	if (b == 0) return a;
	else return gcd(b, a%b);
}*/

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

/*int dig(int a) {
	int sum = 0;
	while (a) {
		sum += a % 10;
		a /= 10;
	}
	return sum;
}*/

//grid template
int x[] = { -1, 0, 1, 0 };
int y[] = { 0,-1,0,1 };
int xx[] = { -1,-1,1,1 };
int yy[] = { 1,-1,1,-1 };

int main() {
	int n;
	cin >> n;
	VD x(n);
	VS u(n);

	rep(i, n) {
		cin >> x[i] >> u[i];
	}

	double sum=0;
	rep(i, n) {
		if (u[i] == "JPY") {
			sum += x[i];
		} else {
			sum += x[i] * 380000.0;
		}
	}

	cout << sum << endl;
}


 

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

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

		long a = sc.nextLong();
		long b = sc.nextLong();
		long c = sc.nextLong();
//
//		b = Math.max(c,b/c*c);
//		if(a > b){
//			System.out.println(0);
//			return;
//		}
//		a = Math.max(c, a/c*c);
		long n1;

		if(a % c == 0){
			n1 = Math.max(0, a/c - 1);
		}
		else {
			n1 = a/c;
		}

		long n2 = b/c;

		long geta = a == 0 ? 1 : 0;
//		System.out.println(b - a);
		System.out.println(n2 - n1 + geta);
    }
}

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

template<typename T, typename U>
using pv=vector<pair<T,U>>;
template<typename T>
using pque=priority_queue<T>;
template<typename T>
using lpque=priority_queue<T,vector<T>,greater<T>>;

using ll=long long;
using intpair=pair<int,int>;
using llpair=pair<ll,ll>;
using ilpair=pair<int,ll>;
using lipair=pair<ll,int>;
using intvec=vector<int>;
using llvec=vector<ll>;
using intq=queue<int>;
using llq=queue<ll>;
using intmat=vector<intvec>;
using llmat=vector<llvec>;

#define PI 3.141592653589793
#define INTINF ((1<<30)-1)
#define LLINF ((1LL<<62)-1)
#define MPRIME 1000000007
#define MPRIME9 998244353
#define MMPRIME ((1ll<<61)-1)

#define len length()
#define pushb push_back
#define fi first
#define se second

#define setpr fixed<<setprecision(15)
#define all(name) name.begin(),name.end()
#define rall(name) name.rbegin(),name.rend()
#define gsort(vbeg,vend) sort(vbeg,vend,greater<>())

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

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

template<class T>
inline void init(T& v) {
	for(auto &a: v) cin>>a;
}
template<class T, class U>
inline void init(vector<pair<T,U>>& v) {
	for(auto &a: v) cin>>a.first>>a.second;
}
template<class T, class N>
inline void init(T& v, N n) {
	v.resize(n);
	for(auto &a: v) cin>>a;
}
template<class T, class U, class N>
inline void init(vector<pair<T,U>>& v, N n) {
	v.resize(n);
	for(auto &a: v) cin>>a.first>>a.second;
}

inline void out() {
	cout<<endl;
}
template<class T, class... U>
inline void out(T a, U... alist) {
	cout<<a<<" ";
	out(forward<U>(alist)...);
}

template<class N>
void resiz(N n) {
	//empty
}
template<class N, class T, class... U>
void resiz(N n, T&& hd, U&&... tl) {
	hd.resize(n);
	resiz(n,forward<U>(tl)...);
}

bool isout(int h, int w, int H, int W) {
	return ( h<0 || h>=H || w<0 || w>=W );
}

ll binpow(ll a, ll ex, ll p) {
	ll result=1;
	while(ex>0) {
		if(ex&1) result=result*a%p;
		ex>>=1;
		a=a*a%p;
	}
	return result;
}


ll K,A,B,ans;

void input() {
	cin>>K>>A>>B;
}

void solve() {
	K++;
	if(B-A<=2 || K-A-2<0) {
		cout<<K<<endl;
		return;
	}
	cout<<A+(K-A)/2*(B-A)+(K-A)%2<<endl;
}

int main() {
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout<<fixed<<setprecision(15);
	int t=1;
	while(t) {
		input();
		solve();
		t--;
	}
}


Measured memory_bytes: 3656
s = list(input())
N = len(s)
res = True


for i in range((N - 1) // 2):
    if s[i] != s[N - i - 1]:
        res = False

N = (N - 1) // 2

if N % 2 != 0:
    for i in range((N - 1) // 2):
        if s[i] != s[N - i - 1]:
            res = False
        if s[i + N + 1] != s[N - i - 1 + N + 1]:
            res = False
else:
    for i in range(N // 2):
        if s[i] != s[N - i - 1]:
            res = False
        if s[i + N + 1] != s[N - i - 1 + N + 1]:
            res = False

if res:
    print("Yes")
else:
    print("No")

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

#include <math.h>
#include <stdlib.h>


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

ll table[10][10];

void addTableNum(ll _num){
    ll top, bottom;
    bottom = _num%10;
    while(_num>9)_num /= 10;
    top = _num;
    table[top][bottom]++;
}


int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    
    ll n; cin >> n;
    
    ll num = 1;
    while(num <= n){
        addTableNum(num);
        num++;
    }

    ll ans = 0;
    for(int i = 0; i < 10; i++){
        for(int j = 0; j < 10; j++){
            ans += table[i][j] * table[j][i];
        }
    }
    cout << ans << endl;

    return 0;
}


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

int main(){
    double x1,x2,y1,y2;

	scanf("%lf %lf %lf %lf",&x1,&y1,&x2,&y2);


	double ans=sqrt((fabs(x1-x2)*fabs(x1-x2))+(fabs(y1-y2)*fabs(y1-y2)));
	
	printf("%f\n",ans);

	return 0;
}


Measured memory_bytes: 2048
import sys
sys.setrecursionlimit(10**7) #再帰関数の上限,10**5以上の場合python
import math
from copy import copy, deepcopy
from copy import deepcopy as dcp
from operator import itemgetter
from bisect import bisect_left, bisect, bisect_right#2分探索
#bisect_left(l,x), bisect(l,x)#aはソート済みである必要あり。aの中からx未満の要素数を返す。rightだと以下
from collections import deque, defaultdict
#deque(l), pop(), append(x), popleft(), appendleft(x)
#q.rotate(n)で → にn回ローテート
from collections import Counter#文字列を個数カウント辞書に、
#S=Counter(l),S.most_common(x),S.keys(),S.values(),S.items()
from itertools import accumulate,combinations,permutations,product#累積和
#list(accumulate(l))
from heapq import heapify,heappop,heappush
#heapify(q),heappush(q,a),heappop(q) #q=heapify(q)としないこと、返り値はNone
from functools import reduce,lru_cache#pypyでもうごく
#@lru_cache(maxsize = None)#maxsizeは保存するデータ数の最大値、2**nが最も高効率
from decimal import Decimal
from argparse import ArgumentParser

args=ArgumentParser()
args.add_argument('-loc', '--local', type=bool,default=False)
LOCAL=args.parse_args().local

def input(): 
    x=sys.stdin.readline(); 
    if x[-1]=="\n": 
        return x.rstrip() 
    return x
    
def printe(*x):_=print("## ",*x,file=sys.stderr) if LOCAL else 0
def printl(li): _=print(*li, sep="\n") if li else None
def argsort(s, return_sorted=False): 
    inds=sorted(range(len(s)), key=lambda k: s[k])
    if return_sorted: return inds, [s[i] for i in inds]
    return inds
def alp2num(c,cap=False): return ord(c)-97 if not cap else ord(c)-65
def num2alp(i,cap=False): return chr(i+97) if not cap else chr(i+65)
def matmat(A,B):
    K,N,M=len(B),len(A),len(B[0])
    return [[sum([(A[i][k]*B[k][j]) for k in range(K)]) for j in range(M)] for i in range(N)]
def matvec(M,v):
    N,size=len(v),len(M)
    return [sum([M[i][j]*v[j] for j in range(N)]) for i in range(size)]
def T(M):
    n,m=len(M),len(M[0])
    return [[M[j][i] for j in range(n)] for i in range(m)]
def binr(x): return bin(x)[2:]
def bitcount(x): #xは64bit整数
    x= x - ((x >> 1) & 0x5555555555555555)
    x= (x & 0x3333333333333333) + ((x >> 2) & 0x3333333333333333)
    x= (x + (x >> 4)) & 0x0f0f0f0f0f0f0f0f 
    x+= (x >> 8); x+= (x >> 16); x+= (x >> 32) 
    return x & 0x7f

def main():
    mod = 1000000007
    #w.sort(key=itemgetter(1),reverse=True)  #二個目の要素で降順並び替え

    #N = int(input())
    #N, K = map(int, input().split())
    #A = tuple(map(int, input().split())) #1行ベクトル
    #L = tuple(int(input()) for i in range(N)) #改行ベクトル
    #S = tuple(tuple(map(int, input().split())) for i in range(N)) #改行行列


    s=input()
    if (s[-1]=="s"):
        print(s+"es")
    else:
        print(s+"s")

if __name__ == "__main__":
    main()

Measured memory_bytes: 77432
#include <iostream>
#include <cstdio>
#include <algorithm>
using namespace std;
#define INF 50
int a[INF];
bool compare (int a,int b){
	return a>b;
}
int main()
{
	int k,n,i;
	int sum=0;
	cin>>n>>k;
	for(i=0;i<n;i++)
		cin>>a[i];
		for(i=0;i<k;i++)
			sort(a,a+n,compare);
			for(i=0;i<k;i++)
				sum+=a[i];
				printf("%d\n",sum);
			return 0;
	}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <string>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <stack>

using std::cin;
using std::cout;
using std::endl;
using std::setprecision;
using std::fixed;
using std::pair;
using std::make_pair;
using std::string;
using std::vector;
using std::list;
using std::map;
using std::set;
using std::queue;
using std::priority_queue;
using std::stack;

typedef vector<int> VI;
typedef vector<vector<int> > VII;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<int, bool> PIB;

struct SCORE {
    vector<PIB> time;
    int total_time;
    int solve;
    SCORE() {
        total_time = 0; 
        solve = 0; 
    }
};

int main(void) {
    int m; // time
    int t; // number of team
    int p; // number of problems
    int r; // number of post records
    while (1) {
        cin >> m >> t >> p >> r;
        if (m == 0 && t == 0 && p == 0 && r == 0) {
            break; 
        }
        vector<SCORE> rec(t);

        // constructor????????????????????????????????????????????????
        vector<PIB> temp(p, make_pair(0, false));
        for (int i = 0; i < t; i++) {
            rec[i].time = temp;
        }

        for (int loop = 0; loop < r; loop++) {
            int m2;
            int t2;
            int p;
            int j;
            cin >> m2 >> t2 >> p >> j;
            t2--;
            p--;
            if (j == 0) {
                rec[t2].solve++; 
                rec[t2].time[p].first += (m - m2);
                rec[t2].time[p].second = true;
                rec[t2].total_time += rec[t2].time[p].first;
            } else {
                rec[t2].time[p].first -= 20;
            }
        }
        priority_queue<pair<int, pair<int, int> > > pq;
        for (int i = 0; i < t; i++) {
           pq.push(make_pair(rec[i].solve, make_pair(rec[i].total_time, i + 1))); 
        }

        /*
        priority_queue<pair<int, pair<int, int> > > pq2 = pq;
        while (!pq2.empty()) {
            cout << pq2.top().first << " " << pq2.top().second.first << " " << pq2.top().second.second << endl;
            pq2.pop();
        }
        */
        int first = pq.top().first;
        int second = pq.top().second.first;
        cout << pq.top().second.second;
        pq.pop();
        for (int i = 1; i < t; i++) {
            if (first == pq.top().first && second == pq.top().second.first) {
                cout << "=" << pq.top().second.second;
            } else {
                first = pq.top().first;
                second = pq.top().second.first;
                cout << "," << pq.top().second.second;
            }
            pq.pop();
        }
        cout << endl;
    }
    return 0;
}

Measured memory_bytes: 3096
#include <stdio.h>
int main(void){
	int N, K, X, Y;

	scanf("%d\n%d\n%d\n%d", &N, &K, &X, &Y);

	if(N<=K)
		printf("%d\n", N*X);

	else
		printf("%d\n", K*X+(N-K)*Y);


	return 0;
}

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

int n,m; ll a[N],b[N],ans[N];
int main(){
	scanf("%d%d",&n,&m);
	int i,x,y; scanf("%d",&y);
	ll sum=0;
	for (i=1; i<n; i++){
		x=(y>m?y-m:y); scanf("%d",&y);
		if (x>y) y+=m;
		a[x+1]++; a[y+1]--;
		b[x+1]-=x; b[y+1]+=x;
		sum+=y-x;
	}
	for (i=1; i<=(m<<1); i++){
		a[i]+=a[i-1]; b[i]+=b[i-1];
		ans[i>m?i-m:i]+=a[i]*(i-1)+b[i]; 
	}
	ll mn=1ll<<60;
	for (i=1; i<=m; i++) mn=min(mn,sum-ans[i]);
	printf("%lld\n",mn);
	return 0;
}


Measured memory_bytes: 4096
import math

# import time


def get_primes(n):
    primes = []
    checks = [True for _ in range(int(math.sqrt(n)) + 1)]
    checks[0] = checks[1] = False
    for i in range(2, len(checks)):
        if checks[i]:
            primes.append(i)
            tmp = 0
            while i + tmp * i < len(checks):
                checks[i + tmp * i] = False
                tmp += 1
    return primes


def combination(a, b):
    i = 1
    for _i in range(a - b + 1, a + 1):
        i *= _i
    return i // math.factorial(b)


n, m = map(int, input().split())
# start = time.time()
primes = get_primes(m)
elems = []
m_copy = m
divides = dict()
for _p in primes:
    while m_copy % _p == 0:
        m_copy = m_copy // _p
        if str(_p) in divides.keys():
            divides[str(_p)] += 1
        else:
            divides[str(_p)] = 1
if m_copy > 1:
    divides[str(m_copy)] = 1
# print(primes)

# print(time.time() - start)
ans = 1
for i in divides.values():
    ans *= combination(i + n - 1, i)
print(ans % (1000000007))
# print(time.time() - start)


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


Measured memory_bytes: 1152
import java.util.*;

    public class Main{
        public static void main(String[] args) {
            Scanner scn = new Scanner(System.in);
            int n = scn.nextInt();
            int[] arr = new int[n];
            int min = Integer.MAX_VALUE;
            int updatedMin = 0;
            for(int i = 0 ; i < n ; i++){
                arr[i] = scn.nextInt();
                if(arr[i] <min){
                    updatedMin++;
                    min = arr[i];
                }
            }
            System.out.println(updatedMin);

        }
    }

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

#define CIN_ONLY if(1)
struct cww{cww(){
    CIN_ONLY{
        ios::sync_with_stdio(false);cin.tie(0);
    }
}}star;
#define fin "\n"
#define FOR(i,bg,ed) for(int i=(bg);i<(ed);i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
#define fi first
#define se second
#define pb push_back
#define DEBUG if(0)
#define REC(ret, ...) std::function<ret (__VA_ARGS__)>
template <typename T>inline bool chmin(T &l,T r)
{bool a=l>r;if(a)l=r;return a;}
template <typename T>inline bool chmax(T &l,T r)
{bool a=l<r;if(a)l=r;return a;}
template <typename T>
istream& operator>>(istream &is,vector<T> &v){
    for(auto &it:v)is>>it;
    return is;
}

int main(){
    LL A,B;
    cin>>A>>B;
    if(A==B){
        cout<<1<<endl;
        return 0;
    }
    int M=63-__builtin_clzll(A^B);
    LL all=1ll<<M;
    A=A&(all-1);
    B=B&(all-1);
    //cout<<M<<endl;
    //cout<<A<<" "<<B<<endl;
    if(A<=B){
        LL res=all*2-A;
        cout<<res<<endl;
    }
    else{
        int m;
        LL bb;
        if(B==0)bb=1;
        else{
            m=63-__builtin_clzll(B);
            bb=1ll<<(m+1);
        }
        if(bb>A){
            LL res=all*2-A;
            cout<<res<<endl;
        }
        else{
            LL res=all*2-A*2+bb;
            cout<<res<<endl;

        }
        

    }
    return 0;
}


Measured memory_bytes: 256
N, K, S = map(int, input().split())

result = []
for i in range(K):
    result.append(S)

if S != 1000000000:
    for i in range(N - len(result)):
        result.append(S + 1)
else:
    for i in range(N - len(result)):
        result.append(S - 1)

output = ' '.join(list(map(str, result)))
print(output)

Measured memory_bytes: 15128
from collections import defaultdict
n = int(input())
f = defaultdict(int)


def fact(n, d):
    div = 2
    while n > 1 and div * div <= n:
        if n % div == 0:
            n //= div
            d[div] += 1
        else:
            div += 1
    if n > 1:
        d[n] += 1


for i in range(2, n+1):
    fact(i, f)
ans = 1
mod = 10**9 + 7
for k,v in f.items():
  ans = (ans * (v+1)) % mod
print(ans)

Measured memory_bytes: 3316
#include<stdio.h>

int main()
{
	char buffer[3];
	int i,j;
	
	i = 0;
	scanf("%s",buffer);
	if(buffer[0] == 'o') ++i;
	if(buffer[1] == 'o') ++i;
	if(buffer[2] == 'o') ++i;
	
	
	
	j = 700 + i*100;
	
	printf("%d\n",j);
	
	return 0;
}

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

char winner;
char game(deque<char> a,deque<char> b,deque<char> c, char player){
  char next_player;
  if(player == 'a'){
    if(a.empty()){
      winner =  'A';
    }else{
      next_player = a.front();
      a.pop_front();
      game(a,b,c,next_player);
    }
  }
  if(player == 'b'){
    if(b.empty()){
      winner =  'B';
    }else{
      next_player = b.front();
      b.pop_front();
      game(a,b,c,next_player);
    }
  }
  if(player == 'c'){
    if(c.empty()){
      winner =  'C';
    }else{
      next_player = c.front();
      c.pop_front();
      game(a,b,c,next_player);
    }
  }
}
  

int main() {
  deque<char> A, B, C;
  string aa, bb, cc;
  cin >> aa >> bb >> cc;
  for(int i = 0; i < aa.size(); i++){
    A.push_back(aa.at(i));
  }
  for(int i = 0; i < bb.size(); i++){
    B.push_back(bb.at(i));
  }
  for(int i = 0; i < cc.size(); i++){
    C.push_back(cc.at(i));
  }
  game(A,B,C,'a');
  cout << winner <<endl;
}

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

#define cel(n, k) ((n-1)/k+1)
#define sets(a) memset(a, -1, sizeof(a))
#define clr(a) memset(a, 0, sizeof(a))
#define dbg(x) cout << "Line " << __LINE__ <<": " << x << nl
#define nl "\n"
#define sp " "

#define fastio() ios::sync_with_stdio(0), cin.tie(0), cout.tie(0)
#define file() freopen("in.txt", "r", stdin), freopen("out.txt", "w", stdout)

typedef long long ll;
typedef pair<int,int> pii;

const int N = 2e5+5;

int tc = 1;

int n, cnt, ara[N];

int exist[10*N];

bool get_divs(int n){

	bool ret = 1;
	for(int i = 2; i*i <= n; i++){

		if(!ret)
			break;

		if(n%i == 0){
			if(i*i==n){

				if(exist[i]){

					ret = 0;
					break;
				}
				
			}
			else{
				
				if(exist[i] or exist[n/i]){

					ret = 0;
					break;
				}
			}
		}
	}

	return ret;
}

int main(){

   	//file();

    fastio();

    //cin >> tc;

    while(tc--){

    	cin >> n;

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

    		cin >> ara[i];

    		exist[ara[i]]++;
    	}

    	cnt = 0;

    	if(exist[1]){

    		if(exist[1] == 1)
    			cout << 1 << nl;
    		else
    			cout << 0 << nl;
    		continue;
    	}

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

    		if(exist[ara[i]] > 1)
    			continue;
    		if(get_divs(ara[i]))
    			cnt++;

    	}
    	
    	cout << cnt << nl;
    	
    }

    return 0;
}


Measured memory_bytes: 8340
#include<stdio.h>
#include<string.h>
#define LEN 100005

typedef struct pp{
  char name[100];
  int t;
}P;

P Q[LEN+1];
int k,head,tail;

void enqueue(P);
P dequeue(void);


int main(){
  int elaps = 0,i,q;
  P u;
  scanf("%d %d", &k, &q);

  for (i=1;i<=k;i++){
    scanf("%s", Q[i].name);
    scanf("%d", &Q[i].t);
  }

  head=1;
  tail=k+1;

  while(head!=tail){
    if(Q[head].t<=q){
      elaps+=Q[head].t;
      u=dequeue();
      printf("%s %d\n",u.name,elaps);
    }else{
      elaps+=q;
      Q[head].t-=q;
      enqueue(Q[head]);
      dequeue();
    }
  }


  return 0;

}

void enqueue(P x){
  Q[tail]=x;
  if(tail==LEN){
    tail = 1;
  }
  else{
    tail++;
  }
}

P dequeue(){
  P x;
  x = Q[head];

  if(head == LEN){
    head = 1;
  }
  else{
    head++;
  }
  return x;
}

Measured memory_bytes: 10756
#!/usr/bin/env python3
import functools
import operator

def solve(m, k):
    if k >= 2 ** m:
        return [-1]
    if m == 1 and k == 0:
        return [0, 1, 1, 0]
    b = list(range(2 ** m))
    b.remove(k)
    if functools.reduce(operator.xor, b, 0) != k:
        return [-1]
    a = b + [k] + list(reversed(b)) + [k]
    return a

print(*solve(*map(int, input().split())))


Measured memory_bytes: 13720
#include <bits/stdc++.h>
using namespace std;
int n;
string s,pre;
int main() 
{
    cin>>n;
    int a=0,b=n,c=n/2;
    cout<<0<<endl;
    cin>>pre;
    s=pre;
    while(s!="Vacant") 
	{
        cout<<c<<endl;
        cin>>s;
        if((pre==s)^(a%2==c%2)) 
		{
            b=a; 
			a=c;
        } 
		else{
			a=c;
		}
        c=(a+b)/2;
        pre=s;
    }
}

Measured memory_bytes: 852
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
 
using namespace std;
typedef long long ll;
 
const ll MOD = 1000000007;
 
ll fact[100005];
 
int N, K;
ll A[100005];
 
void init_fact() {
    ll f = 1;
    fact[0] = 1;
    for (int i = 1; i <= 100004; i ++) {
        f = (f * i) % MOD;
        fact[i] = f;
    }
}
 
ll Power(ll base , ll e)
{
    if(e == 0) return 1;
    ll ans = base; e--;
    while(e)
	{
        if(e & 1) ans = (ans * base) %MOD;
        base = (base * base) %MOD;
        e >>= 1;
	}
	return ans % MOD;
}
 
ll inv(ll a) {
    ll x;
    x=Power(a,MOD-2);
    x=x%MOD;
    
    return (x + MOD) % MOD;
}
 
ll combination(int n, int r) {
    return (fact[n] * inv(fact[r]) % MOD * inv(fact[n - r]) % MOD)%MOD;
}
 
int main() {
    init_fact();
    cin >> N >> K;
    rep(i, N) cin >> A[i];
    sort(A, A + N);
    ll ans = 0;
    for (int i = K - 1; i < N; i ++) {
        ll c = combination(i, K - 1);
        ans = (ans + c * A[i] % MOD) % MOD;
    }
    for (int i = 0; i <= N - K; i ++) {
        ll c = combination(N - 1 - i, K - 1);
        ans = (ans + MOD - (c%MOD * A[i]%MOD) % MOD) % MOD;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1792
#include<cstdio>
#include<cstring>
#include<cmath>
#include<map>
#include<algorithm>
using namespace std;

int main()
{
    char n[70];
    long long a,i;
    while(~scanf("%lld",&a))
    {
        i=a%500;
        a/=500;
        a*=1000;
        i/=5;
        i*=5;
        printf("%lld\n",a+i);
    }
}


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

using namespace std;
const static int N = 100005;
int hashed[N], Pow[N];
class Solution {
public:

    const static int base = 37;
    const static int md = 1021312637;
    int getHash (int i, int j) {
        return (hashed[j] - 1ll * hashed[i - 1] * Pow[j - i + 1] + 1ll * md * md) % md;
    }
    bool check(int len, string &s) {
        if (len == 0) {
            return true;
        }
        unordered_map <int, int> my_map_min, my_map_max;
        set <int> myset;
        for (int i = 1; i <= s.length() - len + 1; i++) {
            int hashed_value = getHash(i, i + len - 1);
            int map_min = my_map_min[hashed_value];
            if (map_min) {
                my_map_min[hashed_value] = min(map_min, i);
            } else {
                my_map_min[hashed_value] = i;
            }
            int map_max = my_map_max[hashed_value];
            my_map_max[hashed_value] = max(map_max, i);
            myset.insert(hashed_value);
        }
        for (auto x: myset) {
            int mn = my_map_min[x];
            int mx = my_map_max[x];
            if (mn + len <= mx) {
                return true;
            }
        }
        return false;
    }
    int longestDupSubstring(string &S) {
        int m = S.length();
        Pow[0] = 1;
        for (int i = 1; i <= m; i++) {
            Pow[i] = (1ll * Pow[i - 1] * base) % md;
        }
        for (int i = 1; i <= m; i++) {
            hashed[i] = (1ll * hashed[i - 1] * base + S[i - 1] - 'a') % md;
        }
        int l = 0, h = m;
        while (l <= h) {
            int mid = (l + h) >> 1;
            if (check(mid, S)) {
                l = mid + 1;
            } else {
                h = mid - 1;
            }
        }
        return l - 1;
    }
};
int main() {

    int n;
    cin >> n;
    string s;
    cin >> s;

    Solution solution;
    cout << solution.longestDupSubstring(s);
    return 0;
}


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

int main() {
  int N, K, y;
  cin >> N >> K;
  y = 0;
  for (int i = 0; i < N; i++) {
    int x;
    cin >> x;
    if (K-x >= x) y += 2*x;
    else y += 2*(K-x);
  }
  cout << y <<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <iterator>
#include <string>
#include <vector>
#include <map>
#include <stack>
#include <queue>
#include <functional>
#include <cctype>
#include <climits> // INT_MAX ...
#include <cstring> // 

using namespace std;

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

    string s, t, u;
    cin >> s >> t;
    map<string, int> mp;
    cin >> mp[s] >> mp[t];
    cin >> u;
    mp[u]--;
    cout << mp[s] << " " << mp[t] << endl;

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0;i<((int)(n));i++)
#define reg(i,a,b) for(int i = ((int)(a));i<=((int)(b));i++)
#define irep(i,n) for(int i = ((int)(n)-1);i>=0;i--)
#define ireg(i,a,b) for(int i = ((int)(b));i>=((int)(a));i--)
typedef long long ll;

/*
*/


string s;
void init(){
	cin>>s;
}

int main(void){
	init();
	bool ok=false;
	rep(i,3)if(s[i]==s[i+1])ok=true;
	cout<<(ok?"Bad":"Good")<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)   FOR(i,0,n)
#define pb emplace_back
typedef long long ll;
typedef pair<int,int> pint;

bool br[100001];
int n,m;
ll dp[100005];
const int mod=1000000007;
int main(){
    cin>>n>>m;
    int ai;
    rep(i,m){
        cin>>ai;
        br[ai]=true;
    }
    dp[0]=1;
    rep(i,n){
        if(!br[i+1])dp[i+1]+=dp[i],dp[i+1]%=mod;
        if(!br[i+2])dp[i+2]+=dp[i],dp[i+2]%=mod;
    }
    cout<<dp[n]<<endl;
    return 0;
}


Measured memory_bytes: 1152
#include <bits/stdc++.h>
#define PI 3.14159265358979323846
#define MAXINF (1e18L)
#define INF (1e9L)
#define EPS (1e-9)
#define MOD ((ll)(1e9+7))
#define REP(i, n) for(int i=0;i<int(n);++i)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define ALL(v) v.begin(),v.end()
#define FIND(v,x) (binary_search(ALL(v),(x)))
#define SORT(v) sort(ALL(v))
#define RSORT(v) sort(ALL(v));reverse(ALL(v))
#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cerr<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" "<<v[i]; cerr<<endl
#define Yes(n) cout<<((n)?"Yes":"No")<<endl
#define YES(n) cout<<((n)?"YES":"NO")<<endl
#define pb push_back
#define fi first
#define se second
using namespace std;
template<class A>void pr(A a){cout << (a) << endl;}
template<class A,class B>void pr(A a,B b){cout << a << " "  ;pr(b);}
template<class A,class B,class C>void pr(A a,B b,C c){cout << a << " " ;pr(b,c);}
template<class A,class B,class C,class D>void pr(A a,B b,C c,D d){cout << a << " " ;pr(b,c,d);}
template<class T> inline bool chmin(T& a, T b){return a>b ? a=b, true : false;}
template<class T> inline bool chmax(T& a, T b){return a<b ? a=b, true : false;}
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll,ll> pll;

int main(void)
{
    int N,M;
    cin >> N >> M;
    vector<vector<ll>> V(N, vector<ll>(3));

    REP(i, N) cin >> V[i][0] >> V[i][1] >> V[i][2];
    ll ans = 0;
    REP(i, 1<<3){
        vector<ll> T(N);
        REP(j, N){
            REP(k, 3){
                if(i&(1<<k)) T[j] -= V[j][k];
                else T[j] += V[j][k];
            }
        }
        SORT(T);
        ll tmp = 0;
        REP(j, M) tmp += T[j];
        chmax(ans, abs(tmp));
        RSORT(T);
        tmp = 0;
        REP(j, M) tmp += T[j];
        chmax(ans, abs(tmp));
    }
    pr(ans);
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void){
	unsigned long long int a,b,c;
	unsigned long long int l,m,s;
	scanf("%llu%llu%llu",&a,&b,&c);
	if(a>=b && a>=c){
		l=a;
		m=b;
		s=c;
	}else if(b>=c && b>=a){
		l=b;
		m=a;
		s=c;
	}else if(c>=b && c>=a){
		l=c;
		m=b;
		s=a;
	}

	if(l%2==0||m%2==0||s%2==0){
		puts("0");
	}else{
		printf("%llu\n",m*s);
	}
return 0;
}


Measured memory_bytes: 128
C = [0]
N = int(input())
A = [int(x) for x in input().split()]
B = [int(x) for x in input().split()]
C += [int(x) for x in input().split()]

ans = sum(B)

for i in range(N-1):
    if A[i+1]==A[i]+1:
        ans += C[A[i]]

print(ans)        

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#include <stdlib.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;
typedef pair<ll,ll> P;
typedef priority_queue<P,vector<P>,greater<P>> P_queue;

#define REP(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)
#define pb push_back
#define mp make_pair
#define ALL(a) a.begin(),a.end()
#define SORT(a) sort(ALL(a))
#define U_ERASE(V) V.erase(unique(ALL(V)), V.end());

const ll MOD=998244353;
const ll mod=1000000007;
const ll INF=1e15;
vec dx={1,0,-1,0};
vec dy={0,1,0,-1};

const ll MAXN=1e9;

long long ruijou(ll n, ll k){
    if(k==0) return 1;
    ll x=k/2;
    long long t=ruijou(n,x);
    
    if(k%2==1) return n*t*t;
    else return t*t;
}

bool ask(ll N){
    cout<<"? "<<N<<endl;
    char x; cin>>x;
    if(x=='Y') return true;
    else return false;
}

int main(){
    ll ans;
    if(ask(ruijou(10,10))){
        ll OK=-1,NG=10;
        while(NG>OK+1){
            ll MID=(OK+NG)/2;
            if(ask(2*ruijou(10,MID))) NG=MID;
            else OK=MID;
        }
        ans=ruijou(10,NG);
    }

    else{
        ll NG=10, OK=-1;
        while(NG>OK+1){
            ll MID=(OK+NG)/2;
            if(ask(ruijou(10,MID))) OK=MID;
            else NG=MID;
        }
        
        ll x=OK;
        NG=ruijou(10,x);
        OK=NG*10-1;
        while(OK>NG+1){
            ll MID=(OK+NG)/2;
            ll A=MID*10;
            if(ask(A)) OK=MID;
            else NG=MID;
        }
        ans=OK;
    }
    cout<<"! "<<ans<<endl;
}

Measured memory_bytes: 596
#include <iostream>
#include <algorithm>
using namespace std;
int main()
{
    int n,m,ans=0;
    int a[100005],b[100005];

	cin >> n >> m;
	for(int i=0;i<m;i++)
        cin >> a[i];
	sort(a,a+m);
	for(int i=0;i<m-1;i++)
		b[i]=a[i+1]-a[i];
	sort(b,b+m-1);
	for(int i=0;i<m-n;i++)
	ans+=b[i];
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 1024
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ARC092_ {
    class Program {
        static void Main(string[] args) {
            int N = int.Parse(Console.ReadLine());
            int[,] APos = new int[2, N];
            int[,] BPos = new int[2, N];
            int[] posRank = new int[2 * N];
            bool[] AMarked = new bool[N];
            for (int i = 0; i < N; i++) {
                int[] input = Console.ReadLine().Split(' ').Select(s => int.Parse(s)).ToArray();
                APos[0, i] = input[0];
                APos[1, i] = input[1];
                posRank[input[0]] = i;
            }
            for (int i = 0; i < N; i++) {
                int[] input = Console.ReadLine().Split(' ').Select(s => int.Parse(s)).ToArray();
                BPos[0, i] = input[0];
                BPos[1, i] = input[1];
                posRank[input[0]] = i + N;
            }
            int ans = 0;
            List<int> smallAList = new List<int>();
            for (int i = 0; i < 2 * N; i++) {
                if (posRank[i] < N) {
                    smallAList.Add(posRank[i]);
                } else {
                    int BNum = posRank[i] - N;
                    int max = 3 * N;
                    for (int j = 0; j < smallAList.Count(); j++) {
                        int pos = APos[1, smallAList[j]];
                        bool go = true;
                        if (max != 3 * N) {
                            if (pos < APos[1, max]) {
                                go = false;
                            }
                        }
                        if (go && pos < BPos[1, BNum] && !AMarked[smallAList[j]]) {
                            max = smallAList[j];
                        }
                    }
                    if(max != 3 * N) {
                        ans++;
                        AMarked[max] = true;
                    }
                }
            }
            Console.WriteLine(ans);
        }
    }
}


Measured memory_bytes: 13396
#include<iostream>
using namespace std;
int main(){
    
    while(true){
        int h, w;
        cin >> h >> w;
        
        if(h == 0 && w == 0){
            break;
        }
        
        for(int i = 0; i < h; i++){
            if(i == 0 || i == h-1){
                for(int j1 = 0; j1 < w; j1++){
                    cout << "#";
                }
                cout << endl;
            } else {
                for(int j2 = 0; j2 < w; j2++){
                    if(j2 == 0 || j2 == w-1){
                        cout << "#";
                    } else {
                        cout << ".";
                    }
                }
                cout << endl;
            }
        }
        cout << endl;
    }
    
    return 0;
}


Measured memory_bytes: 3072
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace abc160_c
{
  class Program
  {
    static void Main(string[] args)
    {
      var K = CIn.ReadInt();
      var N = CIn.ReadInt();
      var A = CIn.ReadIntArray(N);

      var max = 0;

      for (int i = 0; i < N; i++)
      {
        if (i < N - 1)
        {
          max = Math.Max(A[i + 1] - A[i], max);
        }
        else
        {
          max = Math.Max(A[0] + K - A[i], max);
        }
      }

      Console.WriteLine(K - max);
    }
  }

  static class CIn
  {
    private static readonly Queue<string> fieldBuffer = new Queue<string>();

    public static string Read()
    {
      if (fieldBuffer.Count == 0)
      {
        foreach (var field in Console.ReadLine().Split())
        {
          fieldBuffer.Enqueue(field);
        }
      }
      return fieldBuffer.Dequeue();
    }

    public static int ReadInt() => int.Parse(Read());
    public static long ReadLong() => long.Parse(Read());
    public static double ReadDouble() => double.Parse(Read());

    public static string[] ReadStringArray(int n)
    {
      var array = new string[n];
      for (var i = 0; i < n; i++)
      {
        array[i] = Read();
      }
      return array;
    }

    public static int[] ReadIntArray(int n)
    {
      var array = new int[n];
      for (var i = 0; i < n; i++)
      {
        array[i] = ReadInt();
      }
      return array;
    }

    public static long[] ReadLongArray(int n)
    {
      var array = new long[n];
      for (var i = 0; i < n; i++)
      {
        array[i] = ReadLong();
      }
      return array;
    }

    public static double[] ReadDoubleArray(int n)
    {
      var array = new double[n];
      for (var i = 0; i < n; i++)
      {
        array[i] = ReadDouble();
      }
      return array;
    }

    public static char[,] ReadCharMatrix(int h, int w)
    {
      var array = new char[h, w];
      for (var i = 0; i < h; i++)
      {
        var l = Console.ReadLine().ToCharArray();
        for (var j = 0; j < w; j++)
        {
          array[i, j] = l[j];
        }
      }
      return array;
    }
  }
}

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

using namespace std;

#define eb emplace_back
#define ii pair<int, int>
#define OK (cerr << "OK" << endl)
#define debug(x) cerr << #x " = " << (x) << endl
#define ff first
#define ss second
#define int long long
#define tt tuple<int, int, int>
#define all(x) x.begin(), x.end()
#define vvi vector<vector<int>>
#define vvii vector<vector<pair<int, int>>>
#define Mat(n, m, v) vector<vector<int>>(n, vector<int>(m, v))
#define endl '\n'

constexpr int INF = 2e18;
constexpr int MOD = 1e9 + 7;
constexpr int MAXN = 2e5 + 3;

vvi adj(MAXN);
int vis[MAXN];

int dfs(int u) {
  if (vis[u])
    return 0;

  vis[u] = true;
  int ret = 1;
  for (int v : adj[u]) {
    ret += dfs(v);
  }

  return ret;
}

// #define MULTIPLE_TEST_CASES
void solve() {

  int n;
  cin >> n;

  int m;
  cin >> m;

  while (m--) {
    int u, v;
    cin >> u >> v;
    adj[u].eb(v);
    adj[v].eb(u);
  }

  int ans = 0;
  for (int i = 1; i <= n; ++i) {
    ans = max(ans, dfs(i));
  }
  cout << ans << endl;
}

signed main() {
  // freopen(".in", "r", stdin);
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr), cout.tie(nullptr);

  int t = 1;
#ifdef MULTIPLE_TEST_CASES
  cin >> t;
#endif
  while (t--)
    solve();
}

Measured memory_bytes: 21980
//C
#ifndef _GLIBCXX_NO_ASSERT
#include <cassert>
#endif
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#if __cplusplus >= 201103L
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdalign>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
#endif

// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

#if __cplusplus >= 201103L
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#endif

//ここまで毎回include
//以下プログラム

using namespace std;

long gcd(long a, long b) {
	if (a < b) {
		swap(a, b);
	}
	long r = 1;
	do {
		r = a % b;
		if (r == 0) {
			return b;
		}
		else {
			a = b;
			b = r;
		}
	}while (r != 0);
}
long lcm(long a, long b) {
	return (a * b) / gcd(a, b);
}

int main() {
	long N, M;
	cin >> N >> M;
	string S, T;
	cin >> S >> T;
	long g = gcd(N, M);
	long L = lcm(N, M);
	long n = N / g;
	long m = M / g;
	for (int i = 0; i < g; i++) {
		if (S.substr(i * n, 1) != T.substr(i * m, 1)) {
			cout << -1 << endl;
			return 0;
		}
	}
	cout << L << endl;
}



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

int isMon(string s){
  if(s[0]=='0'){
    if(s[1]=='0')return 0;
    return 1;
  }
  if(s[0]=='1'){
    if(s[1]=='0' || s[1]=='1' || s[1]=='2')return 1;
    return 0;
  }
  return 0;
}

int main(){
  string s;
  cin>>s;
  if(isMon(s.substr(0,2)) && isMon(s.substr(2))){
    cout<<"AMBIGUOUS";
    return 0;
  }
  if(!isMon(s.substr(0,2)) && isMon(s.substr(2))){
    cout<<"YYMM";
    return 0;
  }
  if(isMon(s.substr(0,2)) && !isMon(s.substr(2))){
    cout<<"MMYY";
    return 0;
  }
  cout<<"NA";
}

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

long long max(long long n1, long long n2);

int main()
{
    long long a, b, c, d;
    cin >> a >> b >> c >> d;
    cout << max(a * c, max(a * d, max(b * c, b * d)));
    return 0;
}

long long max(long long  n1,long long n2)
{
    if(n1>=n2)
        return n1;
    else
        return n2;
}

Measured memory_bytes: 3596
package main

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

func getScanner(fp *os.File) *bufio.Scanner {
	scanner := bufio.NewScanner(fp)
	scanner.Split(bufio.ScanWords)
	scanner.Buffer(make([]byte, 1000005), 1000005)
	return scanner
}

func getNextString(scanner *bufio.Scanner) string {
	scanner.Scan()
	return scanner.Text()
}

func getNextInt(scanner *bufio.Scanner) int {
	i, _ := strconv.Atoi(getNextString(scanner))
	return i
}

func getNextInt64(scanner *bufio.Scanner) int64 {
	i, _ := strconv.ParseInt(getNextString(scanner), 10, 64)
	return i
}

func getNextUint64(scanner *bufio.Scanner) uint64 {
	i, _ := strconv.ParseUint(getNextString(scanner), 10, 64)
	return i
}

func getNextFloat64(scanner *bufio.Scanner) float64 {
	i, _ := strconv.ParseFloat(getNextString(scanner), 64)
	return i
}

func main() {
	fp := os.Stdin
	wfp := os.Stdout
	cnt := 0

	if os.Getenv("MASPY") == "ますピ" {
		fp, _ = os.Open(os.Getenv("BEET_THE_HARMONY_OF_PERFECT"))
		cnt = 3
	}
	if os.Getenv("MASPYPY") == "ますピッピ" {
		wfp, _ = os.Create(os.Getenv("NGTKANA_IS_GENIUS10"))
	}

	scanner := getScanner(fp)
	writer := bufio.NewWriter(wfp)
	solve(scanner, writer)
	for i := 0; i < cnt; i++ {
		fmt.Fprintln(writer, "-----------------------------------")
		solve(scanner, writer)
	}
	writer.Flush()
}

func solve(scanner *bufio.Scanner, writer *bufio.Writer) {
	n := getNextInt(scanner)
	aa := make([]int64, n)
	for i := 0; i < n; i++ {
		aa[i] = getNextInt64(scanner)
	}

	m := make([]map[int]int64, n+1)
	for i := 0; i < n+1; i++ {
		m[i] = map[int]int64{}
	}
	fmt.Fprintln(writer, dfs(n>>1, n, aa, m))
}

func dfs(c, n int, aa []int64, m []map[int]int64) int64 {
	if c == 0 || n == 0 {
		return 0
	}
	if m[n][c] != 0 {
		return m[n][c]
	}
	ans := dfs(c-1, n-2, aa, m) + aa[n-1]
	for i := n - 2; i >= (c-1)*2; i-- {
		ans = maxint64(ans, dfs(c-1, i-1, aa, m)+aa[i])
	}

	m[n][c] = ans
	return ans
}

func maxint64(a, b int64) int64 {
	if a < b {
		return b
	}
	return a
}


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

using namespace std;

int main()
{
	for (;;)
	{
		int h, w;
		cin >> h >> w;

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

		string s[] = {"#", "."};
		for (int i = 0; i < h; i++)
		{
			int cnt = (i % 2 == 0) ? 0 : 1;

			for (int j = 0; j < w; j++)
			{
				cout << s[cnt++ % 2];
			}
			cout << endl;
		}
		cout << endl;
	}
}


Measured memory_bytes: 3140
#include <iostream>
#include <string>
#include <stddef.h>
#include <stack>
#include <queue>

using namespace std;

int main() {
	int h, w;
	while (1) {
		cin >> h >> w;
		if (h == 0 && w == 0) break;
		for (int i = 0; i < h; i++) {
			for (int j = 0; j < w; j++) {
				if ((i + j) % 2 == 0) cout << '#';
				else cout<<'.';
			}
			cout << endl;
		}
		cout << endl;
	}
}

Measured memory_bytes: 1156
#include <iostream>
#include <vector>
#include <algorithm>

#define REP(i, n) for(int i = 0;i < n;i++)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define ALL(a) (a).begin(), (a).end()

using namespace std;

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

    n--;
    m--;

    cout << n * m << endl;
    
    return 0;
}

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

using namespace std;

int main()
{
	int n, m;
	int l[100000] = { 0 }, r[100000] = { 0 };
	int i;

	cin >> n >> m;
	for (i = 0; i < m; i++)
		cin >> l[i] >> r[i];

	int lmax = l[0], rmin = r[0];

	for (i = 1; i < m; i++) {
		lmax = max(lmax, l[i]);
		rmin = min(rmin, r[i]);
	}

	if (rmin - lmax >= 0)
		cout << rmin - lmax + 1 << endl;
	else
		cout << 0 << endl;

}

Measured memory_bytes: 1152
n, m = map(int, input().split())
h = list(map(int, input().split()))

edge = [[] for _ in range(n)]

## 接している各頂点をまとめる
for i in range(m):
    a, b = map(int, input().split())
    a -= 1
    b -= 1
    edge[a].append(b)
    edge[b].append(a)

cnt = 0

for node in range(n):
    good = True 
    for neighbor in edge[node]:
        if h[node] <= h[neighbor]:
            good = False
            
    if good:
        cnt += 1

print(cnt)

Measured memory_bytes: 29504