akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
int main() {
  int A,B,C ;
    cin >> A >> B >> C ;
  if (A==B && B==C){
    cout << "No" << endl;
    
  }
  else if  (A!=B && B!=C && C!=A){
    cout << "No" << endl;
   
  }
  else{
    cout << "Yes" << endl;
  }
    
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <cctype>
#include <cmath>
#include <map>
#include <set>
#define rep(i, m, n) for(int i = m;i < n;i++)
#define repr(i, n) for(int i = n;i >= 0;i--)
#define ll long long
#define ull unsigned long long
#define push(a) push_back(a)
#define pop(a) pop_back(a)
#define debug(x) cout<<#x<<": "<<x<<endl
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define INF 999999999
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

int dy[]={0, 0, 1, -1, 0};
int dx[]={1, -1, 0, 0, 0};

int main(){
  ull a,b,c,cnt=0,tmp1=0,tmp2=0;
  cin>>a>>b>>c;
  while(a%2==0&&b%2==0&&c%2==0){
    if(a==b&&b==c){
      cout<<-1<<endl;
      return 0;
    }
    a/=2;b/=2;c/=2;
    tmp1=a;
    tmp2=b;
    a=tmp2+c;
    b=tmp1+c;
    c=tmp1+tmp2;
    cnt++;
  }
  cout<<cnt<<endl;
}


Measured memory_bytes: 256
def next_line():
    return input()


def next_int():
    return int(input())


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


def next_int_array_multi_lines(size):
    return [int(input()) for _ in range(size)]


def next_str_array(size):
    return [input() for _ in range(size)]


def main():
    r, c, k = map(int, input().split())
    dp = [[[0] * (c+1) for i in range(r+1)] for i in range(4)]
    v = [[0] * (c+1) for i in range(r+1)]
    for i in range(k):
        row, col, val = map(int, input().split())
        v[row][col] = val

    for row in range(1, r + 1):
        for col in range(1, c + 1):
            for num in range(0, 4):
                if num == 0:
                    dp[num][row][col] = dp[3][row-1][col]  # simple down
                else:
                    dp[num][row][col] = max(dp[num-1][row][col],  # str
                                            dp[num][row][col-1],  # right x
                                            dp[3][row-1][col] + \
                                            v[row][col],  # down o
                                            dp[num-1][row][col-1] + \
                                            v[row][col],  # right o
                                            )
    print(dp[3][r][c])


if __name__ == '__main__':
    main()

Measured memory_bytes: 430256
import java.util.*;

public class Main {

    public static void main(String[] args) {
        // write your code here
        Scanner sc = new Scanner(System.in);
        long a = sc.nextInt();
        long b = sc.nextInt();

        System.out.println(a * b / gcd(a, b));
    }

        private static long gcd (long a, long b) {
        long temp;
        while((temp = a%b)!=0) {
            a = b;
            b = temp;
        }
        return b;
    }
}

Measured memory_bytes: 21844
s=input()
lst = list(s)
l=[]
for i in range(len(lst)):
    l.append(int(lst[i]))

cnt=0

if l[0]==0:
    for i in range(len(l)):
        if i%2==0:
            if l[i]==1:
                cnt+=1
        else:
            if l[i]==0:
                cnt+=1
else:
    for i in range(len(l)):
        if i%2==0:
            if l[i]==0:
                cnt+=1
        else:
            if l[i]==1:
                cnt+=1

print(cnt)

Measured memory_bytes: 4852
#include <iostream>
#include <algorithm>
#include <cctype>
#include <cstdio>
#include <math.h>
using namespace std;

int main(){
	
	while(1){
	int a=0,b,c,d,e,x;
	scanf("%d,%d,%d,%d,%d",&a,&b,&c,&d,&e);
	for(int i=0;i<5;i++){
		if(a>b){x=a;a=b;b=x;}
		if(b>c){x=b;b=c;c=x;}
		if(c>d){x=c;c=d;d=x;}
		if(d>e){x=d;d=e;e=x;}
	}
	if(a==0)return 0;
	if(b==c&&c==d&&(a==b||d==e))cout<<"four card"<<endl;
	else if(a==b&&d==e&&(b==c||c==d))cout<<"full house"<<endl;
	else if(a==b&&b==c||b==c&&c==d||c==d&&d==e)cout<<"three card"<<endl;
	else if(a==b&&(c==d||d==e)||b==c&&d==e)cout<<"two pair"<<endl;
	else if(a==b||b==c||c==d||d==e)cout<<"one pair"<<endl;
	else if((b==a+1||b==a+9)&&c==b+1&&d==c+1&&e==d+1)cout<<"straight"<<endl;
	else cout<<"null"<<endl;
	}
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
using Int = long long;
int main()
{
    int N; cin >> N;
    string s, t; cin >> s >> t;
    int overlap = N;
    while (overlap > 0) {
        bool ok = true;
        for (int i = 0; i < overlap; i++) {
            if (s[N-overlap+i] != t[i]) {
                ok = false;
                break;
            }
        }
        if (ok) break;
        overlap--;
    }
    cout << 2 * N - overlap << endl;
    return 0;
}

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

int n,total=0,minv=2138475648;
int a[200005];

int main()
{
	cin>>n;
	for (int i=1;i<=n;i++)  cin>>a[i];
	for (int i=1;i<=n;i++)
	{
		if (a[i]<=minv)
		{
			minv=a[i];
			total++;
		}
	}
	cout<<total<<endl;
	return 0;
}

Measured memory_bytes: 1024
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<utility>
#include<map>
#include<set>
#include <sstream>
#include<queue>
#include<stack>
#include<functional>
#include<math.h>
#include <iomanip>
#include <numeric>
using namespace std;


int main(void){
    string N;
    cin >> N;
    cout << N.substr(0,3) << endl;
}

Measured memory_bytes: 3596
N=int(input())
s=input()
a,b,c,d='SS','SW','WW','WS'
def f(a,N):
  for i in range(N-2):
    if a[-1]=='S' and s[i+1]=='o':
      if a[-2]=='S':
        a=a+'S'
      else:
        a=a+'W'
    elif a[-1]=='S' and s[i+1]=='x':
      if a[-2]=='S':
        a=a+'W'
      else:
        a=a+'S'
    elif a[-1]=='W' and s[i+1]=='o':
      if a[-2]=='S':
        a=a+'W'
      else:
        a=a+'S'
    else:
      if a[-2]=='S':
        a=a+'S'
      else:
        a=a+'W'
  return a

A,B,C,D=f(a,N),f(b,N),f(c,N),f(d,N)    
def g(s,A):
  a=True
  if A[-1]=='S'and s[-1]=='o':
    if A[-2]!=A[0]:
      a=False
  elif A[-1]=='S'and s[-1]=='x':
    if A[-2]==A[0]:
      a=False
  elif A[-1]=='W'and s[-1]=='o':
    if A[-2]==A[0]:
      a=False    
  elif A[-1]=='W'and s[-1]=='x':
    if A[-2]!=A[0]:
      a=False  
  
  if A[0]=='S'and s[0]=='o':
    if A[-1]!=A[1]:
      a=False
  elif A[0]=='S'and s[0]=='x':
    if A[-1]==A[1]:
      a=False
  elif A[0]=='W'and s[0]=='o':
    if A[-1]==A[1]:
      a=False    
  elif A[0]=='W'and s[0]=='x':
    if A[-1]!=A[1]:
      a=False
  return a
      
if g(s,A):
  print(A)
  exit()
if g(s,B):
  print(B)
  exit()      
if g(s,C):
  print(C)
  exit()
if g(s,D):
  print(D)
  exit() 
print(-1)    

Measured memory_bytes: 3828
#include <iostream>

using namespace std;

int main() {
    int a,b,c,k;
    cin>>a>>b>>c>>k;
    while(k--){
        if(b<=a)
        b*=2;
        else c*=2;
    }
    if(a<b && b<c)
    cout<<"Yes";
    else cout<<"No";
}

Measured memory_bytes: 3628
import java.util.Scanner;

public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        String target = sc.next();
        int num = sc.nextInt();
        for(int i = 0; i < num; i++){
            String command = sc.next();
            int a = sc.nextInt();
            int b = sc.nextInt() + 1;
            String c = "";
            if(command.equals("replace")){
                c = sc.next();
            }

            if(command.equals("print")){
                System.out.println(target.substring(a, b));
            }else if(command.equals("reverse")){
                char[] charArray = target.substring(a, b).toCharArray();
                String str = "";
                for(int j = charArray.length - 1; j >= 0; j--){
                    str += charArray[j];
                }
                target = target.substring(0, a) + str + target.substring(b);
            }else if(command.equals("replace")){
                target = target.substring(0, a) + c + target.substring(b);
            }
        }
    }
}


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

using ll = long long;
using ull = unsigned long long;
using ld = long double;

#define MOD 1000000007LL

#define rep(i, n) for(ll (i) = 0LL;(i) < (ll)(n);(i)++)
#define rep2(i, s, e) for(ll (i) = (ll)(s);(i) < (ll)(e);(i)++)
#define repi(i, n) for(ll (i) = 0LL;(i) <= (ll)(n);(i)++)
#define repi2(i, s, e) for(ll (i) = (ll)(s);(i) <= (ll)(e);(i)++)
#define per(i, n) for(ll (i) = (ll)(n) - 1LL;(i) >= 0LL;(i)--)
#define per2(i, s, e) for(ll (i) = (ll)(s) - 1LL;(i) >= (ll)(e);(i)--)
#define peri(i, n) for(ll (i) = (ll)(n);(i) >= 0LL;(i)--)
#define peri2(i, s, e) for(ll (i) = (ll)(s);(i) >= (ll)(e);(i)--)
#define iter(i, it) for(auto &(i): (it))

template<typename T, typename U> ostream& operator<<(ostream &s, const pair<T, U> m) {
    cout << "(" << m.first << ", " << m.second << ")";
    return s;
}
template<typename T, typename U> ostream& operator<<(ostream &s, const map<T, U> m) {
    ll c = 0;
    cout << "{ ";
    iter(i, m) cout << i << (c++ == m.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}
template<typename T> ostream& operator<<(ostream &s, const vector<T> &v) {
    cout << "{ ";
    rep(i, v.size()) cout << v[i] << (i == v.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}
template<typename T> ostream& operator<<(ostream &s, const list<T> &v) {
    ll c = 0;
    cout << "{ ";
    iter(i, v) cout << i << (c++ == v.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}

int main(void) {
    ll N;
    ll money = 1000;
    ll kabu = 0;
    cin >> N;
    vector<ll> A(N);
    rep(i, N) cin >> A[i];
    A.erase(unique(A.begin(), A.end()), A.end());
    rep(i, A.size()) {
        ll temp = i;
        ll temp2 = i;
        rep2(j, i + 1, A.size()) {
            if(A[i] > A[j]) temp = j;
            else break;
        }
        rep2(j, i + 1, A.size()) {
            if(A[i] < A[j]) temp2 = j;
            else break;
        }
        if(i == temp2) {
            money += A[i] * kabu;
            kabu = 0;
        } else if(i == temp) {
            ll temp = money / A[i];
            kabu += temp;
            money -= temp * A[i];
        }
    }
    cout << money << endl;
    return 0;
}


Measured memory_bytes: 3616
#include <cstdio>
#include <algorithm>
#include <vector>
#include <string>
#include <iostream>
#include <cmath>
#include <climits>
#include <unordered_map>

using namespace std;

#define size_t int

int main(int argc, char const *argv[]) {
  int N, H, W;
  scanf("%d %d %d", &N, &H, &W);
  int A[N];
  int B[N];
  for (size_t i = 0; i < N; i++) {
    scanf("%d %d", &A[i], &B[i]);
  }
  int r = 0;
  for (size_t i = 0; i < N; i++) {
    if (A[i] >= H && B[i] >= W) {
      r++;
    }
  }
  printf("%d\n", r);
}


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

using namespace std;

int main()
{
    long long n,k,h,x,sum=0;
    priority_queue<long long>pq;
    cin >> n >> k ;
    for(int i=0;i<n;i++){
        cin >> x;
        pq.push(x);
        sum +=x;
    }
    for(int i=0;i<k;i++){
        sum-=pq.top();
        pq.pop();
    }

    if(sum<0)
        cout << 0;
        else
            cout << sum ;
    return 0;
}

Measured memory_bytes: 2420
#include <bits/stdc++.h>
#define all(a) (a).begin(), (a).end()
#define REP(i, n) for(int (i)=0; (i)<(n); (i)++)
#define RREP(i, n) for(int (i)=(n)-1; (i)>=0; (i)--)
#define ios() cin.tie(0), ios::sync_with_stdio(false)
typedef long long ll;
typedef unsigned long long ull;
ll const MOD = 1e9+7;
ll const INF = 1e18;
using namespace std;

int main(){
    ios();
    int n;
    cin >> n;

    vector<int> p(n), a(n), b(n);
    for(int& i : p){
        cin >> i;
    }

    REP(i, n){
        a[i] = 1 + 20010 * i;
        b[n-i-1] = 1 + 20010 * i;
    }

    REP(i, n){
        a[p[i]-1] += i;
    }

    for(int i : a){
        cout << i << " ";
    }
    cout << endl;
    for(int i : b){
        cout << i << " ";
    }
    cout << endl;

    return 0;
}

Measured memory_bytes: 896
#include <iostream>
#include <cmath>
#include <vector>
#include <algorithm>
 
int main(){
  std::string s;
  std::cin >> s;
  if(s.size()<3) {
    std::cout << 0 << std::endl;
    return 0;
  }
  long int j=0;
  while( j < s.size()-1 ){
    if(s[j]=='B' && s[j+1]=='C') {
      s[j]='D';
      s.erase(s.begin()+j+1);
    }
    if(s[j]=='C' && s[j+1]=='B') {
      s[j]='G';
      s.erase(s.begin()+j+1);
    }
    if(s[j]=='C' && s[j+1]=='C') {
      s[j]='G';
      s.erase(s.begin()+j+1);
    }
    if(s[j]=='B' && s[j+1]=='B') {
      s[j]='G';
      s.erase(s.begin()+j+1);
    }
    ++j;
  }
  long int count=0;
  long int i=0;
//  while( i < s.size()-2 ){
/*  while( i < s.size()-1 ){
    if(s[i]=='A') {
//      if(s[i+1]=='B' && s[i+2]=='C'){
//        s[i]='B';
//        s[i+1]='C';
//        s[i+2]='A';
      if( s[i]=='A' && s[i+1]=='D' ){
      s[i]='D';
      s[i+1]='A';
        count++;
        if(i>=1) i--;
      }
      else { i++; }
    }
    else { i++; }
  }*/
  int acount=0;
  for( int i=0; i < s.size(); ++i){
    if(s[i]=='A') acount++;
    else if(s[i]=='D') count += acount;
    else acount = 0;
  }
  std::cout << count <<std::endl;
  return 0;
}


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

int main() {
    int N,K;
    cin >> N >> K;
    int X[N];
    for(int i=0;i<N;i++){
        cin >> X[i];
    }
    int sum=0;
    for(int i=0;i<N;i++){
        sum+=min(2*X[i],abs(X[i]-K)*2);
    }
    cout << sum <<endl;
}

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

int main()
{
    int n,q;
    int s[10000],t[10000];
    int cnt=0;
    cin>>n;
    for(int i=0;i<n;i++) cin>>s[i];
    cin>>q;
    for(int i=0;i<q;i++) cin>>t[i];
    
    for(int i=0;i<q;i++){
    for(int j=0;j<n;j++){
    if(t[i]==s[j]) {
    cnt++;
    break;
    }
    }
    }
    cout<<cnt<<endl;
    
}



Measured memory_bytes: 3104
n=int(input())
hoge=list(map(int,input().split()))
kei=sum(hoge)
now=0
ans=-1
for i in range(n):
  now+=hoge[i]
  if(abs(now-kei/2)<=ans or ans==-1):
    ans=abs(now-kei/2)
    
print(int(ans*2))

Measured memory_bytes: 26224
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0;i<(int)(n);++i)
#define REPR(i,n) for (int i=(int)(n)-1;i>=0;--i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
#define valid(y,x,h,w) (0<=y&&y<h&&0<=x&&x<w)
#define tpl(...) make_tuple(__VA_ARGS__)
const int INF = 0x3f3f3f3f;
const double EPS = 1e-8;
const double PI = acos(-1);
const int dy[] = {-1,0,1,0};
const int dx[] = {0,1,0,-1};
typedef long long ll;
typedef pair<int,int> pii;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
template<typename Ch,typename Tr,typename C,typename=decltype(begin(C()))>basic_ostream<Ch,Tr>& operator<<(basic_ostream<Ch,Tr>&os,
const C& c){os<<'[';for(auto i=begin(c);i!=end(c);++i)os<<(i==begin(c)?"":" ")<<*i;return os<<']';}
template<class S,class T>ostream&operator<<(ostream &o,const pair<S,T>&t){return o<<'('<<t.first<<','<<t.second<<')';}
template<int N,class Tp>void output(ostream&,const Tp&){}
template<int N,class Tp,class,class ...Ts>void output(ostream &o,const Tp&t){if(N)o<<',';o<<get<N>(t);output<N+1,Tp,Ts...>(o,t);}
template<class ...Ts>ostream&operator<<(ostream&o,const tuple<Ts...>&t){o<<'(';output<0,tuple<Ts...>,Ts...>(o,t);return o<<')';}
template<class T>void output(T t,char z=10){if(t<0)t=-t,putchar(45);int c[20];
int k=0;while(t)c[k++]=t%10,t/=10;for(k||(c[k++]=0);k;)putchar(c[--k]^48);putchar(z);}
template<class T>void outputs(T t){output(t);}
template<class S,class ...T>void outputs(S a,T...t){output(a,32);outputs(t...);}
template<class T>void output(T *a,int n){REP(i,n)cout<<a[i]<<(i!=n-1?',':'\n');}
template<class T>void output(T *a,int n,int m){REP(i,n)output(a[i],m);}
template<class T>bool input(T &t){int n=1,c;for(t=0;!isdigit(c=getchar())&&~c&&c-45;);
if(!~c)return 0;for(c-45&&(n=0,t=c^48);isdigit(c=getchar());)t=10*t+c-48;t=n?-t:t;return 1;}
template<class S,class ...T>bool input(S&a,T&...t){input(a);return input(t...);}
template<class T>bool inputs(T *a, int n) { REP(i,n) if(!input(a[i])) return 0; return 1;}

int A[100000];
int B[100000];
int C[100000];

int main() {
  int n;
  while(cin>>n) {
    inputs(A,n); sort(A,A+n);
    inputs(B,n); sort(B,B+n);
    inputs(C,n); sort(C,C+n);
    int ai = 0, ci = 0;
    ll ans = 0;
    REP(i,n) {
      while(ai<n&&A[ai]<B[i])ai++;
      while(ci<n&&C[ci]<=B[i])ci++;
      ans += (ll)ai*(n-ci);
    }
    cout << ans << endl;
  }
}


Measured memory_bytes: 1536
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define REP(i,n) for(long long i=0;i<n;++i)
#define REPP(i,m,n) for(long long i=m;i<n;++i)
#define rep(i,n) for(long long i = n-1;i>=0;--i)
#define repp(i,n,m) for(long long i = n-1; i >= m; --i)
#define ALL(N) (N.begin(),N.end())
#define de cout << "line : " << __LINE__ << " debug" << endl;
#define pb push_back
#define pq priority_queue
#define Dcout(N) cout << setprecision(20) << N << endl
constexpr int INF = 2147483647;
constexpr long long INFF = 9223372036854775807;

int N,M;
signed main() {
    cin.tie(0);
	ios::sync_with_stdio(false);
    cin >> N >> M;
    vector<int> V;
    for(int i = 1;i*i <= M;++i){
        if(M % i == 0){
            V.pb(i);
            V.pb(M/i);
        }
    }
    sort ALL(V);
    int ans = 0;
    for(int i = 0;i < V.size();++i){
        if(V[i] > M/N) break;
        ans = V[i];
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
a,b,c,d=map(int,input().split())
print("R"*(c-a)+"U"*(d-b)+"L"*(c-a)+"D"*(d-b)+"L"+"U"*(d-b+1)+"R"*(c-a+1)+"D"+"R"+"D"*(d-b+1)+"L"*(c-a+1)+"U")

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

struct UnionFind
{
	vector<int> uni;

	UnionFind(int n) : uni(n, -1){}

	int root(int a)
	{
		if (uni[a] < 0) return a;	
		return uni[a] = root(uni[a]);
	}

	bool connect(int a, int b)
	{
		a = root(a);
		b = root(b);
		if (a == b) return false;
		if (uni[a] > uni[b])
		{
			a ^= b;
			b ^= a;
			a ^= b;
		}
		uni[a] = uni[a] + uni[b];
		uni[b] = a;
		return true;
	}

	bool isConnect(int a, int b)
	{
		return root(a) == root(b);
	}

	int size(int a)
	{
		return -uni[root(a)];
	}
};

signed main(void)
{
	int n, m, cnt;
	cin >> n >> m;
	vector<bool> check(n, false);
	UnionFind uf(n);
	rep(i, m)
	{
		int x, y, z;
		cin >> x >> y >> z;
		x--; y--;
		if (!uf.isConnect(x, y)) uf.connect(x, y);
	}
	cnt = 0;
	rep(i, n)
	{
		int p = uf.root(i);
		if (!check[p])
		{
			cnt++;
			check[p] = true;
		}
	}
	cout << cnt << endl;
	return 0;
}


Measured memory_bytes: 640
import math

s = input()
n = len(s)
ans = [0 for x in range(n)]

index = 0

for i in range(n) :
  index_i = index
  if index >= n :
    break
  for j in range(n) :
    if s[index:index+2] == 'RL' :
      index_RL = index + 1
    index += 1
    if s[index:index+2] == 'LR' or index == n - 1 :
      index += 1
      break
  R = math.ceil((index_RL-index_i)/2) + math.floor((index-index_RL)/2)
  L = math.floor((index_RL-index_i)/2) + math.ceil((index-index_RL)/2)
  ans[index_RL-1] = R
  ans[index_RL] = L

print(*ans)

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

using VI = vector<long>;

long TMP[5] = {5, 7, 5, 7, 7};

int main() {
  int n;
  while (1) {
    cin >> n;
    if (n) {
      VI ps;
      for (int i = 0; i < n; i++) {
        string s;
        cin >> s;
        ps.push_back(s.size());
      }
      for (int first = 0; first < n; first++) {
        int diff = 0;
        bool legal = true;
        for (int k = 0; k < 5; k++) {
          int acc = 0;
          while (acc < TMP[k]) {
            acc += ps[first + diff];
            diff++;
          }
          if (acc > TMP[k]) {
            legal = false;
            break;
          }
        }
        if (legal) {
          cout << first+1 << endl;
          break;
        }
      }
    } else {
      return 0;
    }
  }
}



Measured memory_bytes: 3192
n=int(input())
h=list(map(int,input().split()))
dp=[10**7]*n
dp[0]=0
dp[1]=abs(h[1]-h[0])
for i in range(n-2):
    dp[i+2]=min(dp[i+1]+abs(h[i+2]-h[i+1]),dp[i]+abs(h[i+2]-h[i]))
print(dp[n-1])

Measured memory_bytes: 20548
#include "bits/stdc++.h"
using namespace std;
const int MAX = 700000;
const int MOD = 1000000007;

long long  fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAX; i++) {
		fac[i] = fac[i - 1] * i % MOD;
		inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
		finv[i] = finv[i - 1] * inv[i] % MOD;
	}
}

// 二項係数計算
long long COM(int n, int k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
/*第二引数で第一引数を割ったときの切り上げの計算*/
long long int maxtime(long long int x, long long int y){
	return(x + y - 1) / y;

}
/*最大公約数*/
long long int lcm(long long int number1, long long int number2) {
	long long int m = number1;
	long long int n = number2;

	if (number2 > number1) {
		m = number2;
		n = number1;
	}
	long long int s = -1;
	while (s != 0) {
		s = m % n;
		m = n;
		n = s;
	}
	return m;
}
/*最大公倍数*/
long long int gcd(long long int number1, long long int number2) {
	long long int m = number1;
	long long int n = number2;
	return m / lcm(m, n) * n;
}
/*逆元計算*/
long long int  modinv(long long a, long long m) {
	long long int b = m, u = 1, v = 0;
	while (b) {
		long long int t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}
// index が条件を満たすかどうか
vector<long long int >meguru;
bool isOK(int index, int key) {
	if (meguru[index] >= key) return true;
	else return false;
}
// 汎用的な二分探索のテンプレ
int binary_search(int key) {
	int left = -1; //「index = 0」が条件を満たすこともあるので、初期値は -1
	int right = (int)meguru.size(); // 「index = a.size()-1」が条件を満たさないこともあるので、初期値は a.size()
	/* どんな二分探索でもここの書き方を変えずにできる！ */
	while (right - left > 1) {
		int mid = left + (right - left) / 2;

		if (isOK(mid, key)) right = mid;
		else left = mid;
	}
	/* left は条件を満たさない最大の値、right は条件を満たす最小の値になっている */
	return right;
}
long long modpow(long long a, long long n, long long mod) {
	long long res = 1;
	while (n > 0) {
		if (n & 1) res = res * a % mod;
		a = a * a % mod;
		n >>= 1;
	}
	return res;
}

int main() {
	int a, b, c;
	cin >> a >> b >> c;
	int kara = 0;
	kara = a;
	a = b;
	b = kara;
	kara = c;
	c = a;
	a = kara;
	cout << a << " " << b << " " << c;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define LL long long int
int main() {
	ios::sync_with_stdio(false);
	cin.tie(NULL);cout.tie(NULL);
	int n, x, ans = 0, i;
	cin >> n;
	for (i=0;i<n;i++) {
		cin >> x;
		ans = __gcd(ans, x);
	}
	cout << ans;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp> // Common file
//#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update

using namespace std;
//using namespace __gnu_pbds;
//typedef tree< pair<int, int>, null_type, less<pair<int, int>>, rb_tree_tag, tree_order_statistics_node_update>
//ordered_set;
int dx[] = {0, 1, 0, -1};
int dy[] = {-1, 0, 1, 0};
#define X first
#define Y second
#define int long long int 
const int N = (int)1e6 + 10;
const int MOD = 1000000007;


void solve(){
    int n, m;
    cin >> n >> m;
    vector<int> a(n);
    int sum = 0;
    for(auto & x: a)
        cin >> x, sum += x;
    int total = 0;
    int rest = (sum + 4 * m - 1)/(4 * m);
    for(auto & x: a){
        if( x >= rest)
            total++;
    }
    if(total >= m)
        cout << "Yes\n";
    else 
        cout << "No\n";

}   

int32_t main(){
    ios_base::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr); 
    //int t; cin >> t;
    //while(t--)
        solve();
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<queue>
#include<algorithm>
#include<map>
#include<set>
#include<vector>
#include<math.h>

using namespace std;

#define INF 1000000007
#define LINF (1LL << 62)

typedef long long i64;
typedef pair<i64,i64> P;


int n, a[1010];

int main(){
	cin >> n;
	for(int i = 0; i < n; i++){
		cin >> a[i];
	}
	
	priority_queue<double, vector<double>, greater<double>> pq;
	for(int i = 0; i < n; i++){
		pq.push(a[i]);
	}
	
	while(pq.size() > 1){
		double x = pq.top(); pq.pop();
		double y = pq.top(); pq.pop();
		pq.push((x+y)/2.0);
	}
	printf("%.10f\n", pq.top());
	
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define MOD 1000000007
#define INF 2000000000
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define reprev(i,n) for(int (i)=(n-1);(i)>=0;(i)--)
#define Flag(x) (1<<(x))
#define Flagcount(x) __builtin_popcount(x)
#define pint pair<int,int>
#define pdouble pair<double,double>
typedef unsigned long long int ull;
typedef long long lint;
 
using namespace std;
 
int main(void){
  string S;
  cin >> S;
  int L=S.length();
  int check=0;
  int ccheck=0;
  if(S[0]!='A') check=1;
  else{
    for(int i=1;i<L;i++){
      if(S[i]-'a'<0 && S[i]=='C' && i>=2 && i<=L-2) ccheck++;
      else if(S[i]-'a'<0) check=1;
    }
  }
  if(check==0 && ccheck==1) cout << "AC" << endl;
  else cout << "WA" << endl;
}

Measured memory_bytes: 256
#!/usr/bin/env python3
import sys
input = sys.stdin.readline
def INT(): return int(input())
def MAP(): return map(int,input().split())
def LI(): return list(map(int,input().split()))

def main():
    N,M = MAP()
    a = LI()

    b = [0]*N

    for i in range(N):
        aa = a[i]
        cnt = 0
        while aa%2==0:
            aa //= 2
            cnt +=1
        b[i] = cnt
    
    if b.count(b[0]) != N:
        print(0)
        return
    
    # 2で割れる回数が同じ
    import fractions
    from functools import reduce
    def lcm(x, y):
        return (x * y) // fractions.gcd(x, y)
    def lcm_list(numbers):
        return reduce(lcm, numbers)

    LCM = lcm_list([aa//2 for aa in a])
    c = M//LCM
    if c&1:
        c += 1
    
    print(c//2)
    return

if __name__ == '__main__':
    main()


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

typedef long long ll;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef vector<vector<vector<ll>>> vvvll;
typedef vector<bool> vb;
typedef vector<vector<bool>> vvb;
typedef vector<vector<vector<bool>>> vvvb;
typedef pair<ll, ll> pll;
typedef vector<pll> vpll;
typedef vector<vpll> vvpll;
typedef vector<double> vd;
typedef vector<vd> vdd;

#define FOR(i,x,y) for(ll i=(ll)x; i<(ll)y; ++i)
#define REP(i,y) FOR(i, 0, y)
#define RFOR(i,x,y) for(ll i=(ll)x; i>=(ll)y; --i)
#define RREP(i,x) RFOR(i, x, 0)
#define ALL(a) a.begin(), a.end()
#define pb push_back
#define debug_print(x...) cerr << "line " << __LINE__ << " : "; debug_print_in(x);

template <typename First>
void debug_print_in(First first){
  cerr << first << endl;
  return;
}

template <typename First, typename... Rest>
void debug_print_in(First first, Rest... rest){
  cerr << first << " ";
  debug_print_in(rest...);
  return;
}

void IN(void){
  return;
}

template <typename First, typename... Rest>
void IN(First& first, Rest&... rest){
  cin >> first;
  IN(rest...);
  return;
}

template <typename First>
void OUT(First first){
  cout << first << endl;
  return;
}

template <typename First, typename... Rest>
void OUT(First first, Rest... rest){
  cout << first << " ";
  OUT(rest...);
  return;
}

template<class t, class u> void chmax(t&a,u b){if(a<b)a=b;};
template<class t, class u> void chmin(t&a,u b){if(a>b)a=b;};
int popcount(int t){return __builtin_popcount(t);} //GCC
int popcount(ll t){return __builtin_popcountll(t);} //GCC

template <typename T>
void vec_print(vector<T> VEC){
  REP(i, VEC.size()){
    cerr << VEC[i] << " ";
  }
  cerr << endl;
};

template <typename T>
void mat_print(vector<vector<T> > MAT){
  REP(i,MAT.size()){
    REP(j,MAT[i].size()){
      cerr << MAT[i][j] << " ";
    }
    cerr << endl;
  }
};

constexpr int INF = (1<<30);
constexpr ll INFLL = 1LL<<62;
constexpr long double EPS = 1e-12;
constexpr ll MOD = (ll)((1E+9)+7);

vvll dp;
ll N;
string S;

void search(ll index){
  if(index>=N) return;
  if(S[index]=='?'){
    REP(num,10){
      REP(i,13){
        dp[index+1][(i*10+num)%13] += dp[index][i];
        dp[index+1][(i*10+num)%13] %= MOD;
      }
    }
  }else{
    ll num = (S[index]-'0');
    REP(i,13){
      dp[index+1][(i*10+num)%13] += dp[index][i];
      dp[index+1][(i*10+num)%13] %= MOD;
    }
  }
  search(index+1);
  return;
}

int main(){
  cin.tie(0); // cut the cin and cout (default, std::flush is performed after std::cin)
  ios::sync_with_stdio(false); // cut the iostream and stdio (DON'T endl; BUT "\n";)

  IN(S);
  N = S.size();

  dp.resize(N+1, vll(13, 0));
  dp[0][0] = 1;

  search(0);

  //mat_print(dp);

  OUT(dp[N][5]%MOD);

  return 0;
}

Measured memory_bytes: 13648
fun _gen753List(digit: Int): List<String> {
    if (digit <= 1) return listOf("3", "5", "7")

    return _gen753List(digit-1).flatMap { p -> listOf("3", "5", "7").map { p + it } }
}

fun gen753List(digit: Int): List<String> {
    return (1..digit).flatMap {_gen753List(it)}
}

fun main(args: Array<String>) {
    val S = readLine()!!
    val n = S.toInt()
    val list = gen753List(S.length).map { it.toInt() }.sorted()

    println(list.takeWhile { it <= n }.count { i -> val s = i.toString(); ("3" in s && "5" in s && "7" in s) })
}

Measured memory_bytes: 44880
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll MA=4294967295;
const int mod=1000000007;

int main(){
	int h,w;
	cin>>h>>w;
	string s[h];
	for(int i=0;i<h;i++){
		cin>>s[i];
	}
	int ans=h*w;
	int prevw[h][w],prevh[h][w];
	int nextw[h][w],nexth[h][w];
	for(int i=0;i<h;i++){
		int l=-1;
		for(int j=0;j<w;j++){
			if(s[i][j]=='#'){
				prevw[i][j]=j;
				l=j;
			}
			else{
				prevw[i][j]=l;
			}
		}
		int n=w;
		for(int j=w-1;j>=0;j--){
			if(s[i][j]=='#'){
				nextw[i][j]=j;
				n=j;
			}
			else{
				nextw[i][j]=n;
			}
		}
	}
	for(int j=0;j<w;j++){
		int l=-1;
		for(int i=0;i<h;i++){
			if(s[i][j]=='#'){
				prevh[i][j]=i;
				l=i;
			}
			else{
				prevh[i][j]=l;
			}
		}
		int n=h;
		for(int i=h-1;i>=0;i--){
			if(s[i][j]=='#'){
				nexth[i][j]=i;
				n=i;
			}
			else{
				nexth[i][j]=n;
			}
		}
	}
	int t=0;
	for(int i=0;i<h;i++){
		for(int j=0;j<w;j++){
			int temp=(nexth[i][j]-prevh[i][j])+(nextw[i][j]-prevw[i][j])-3;
			t=max(t,temp);
			// cout<<temp<<" ";
		}
		// cout<<endl;
	}
	cout<<t;
	return 0;
}

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

using namespace std;

using ll = long long;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    string a, b, c;
    cin >> n >> a >> b >> c;
    int ans = 0;
    for (int i = 0; i < n; i++) {
        if (a[i] == b[i] && b[i] == c[i]) continue;
        if (a[i] == b[i] || b[i] == c[i] || c[i] == a[i]) ans++;
        else ans += 2;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

        int L = 0;
        int R = 0;
        int ans = 2018;
        int c = 0;
         
        int main(void){
          if(scanf("%d%d",&L,&R) == 1);
          if((R-L) >= 2019){
            printf("0\n");
            return 0;
          }
          for(int i = L;i < R;i++){
            for(int j = i + 1;j <= R;j++){
              c = (i%2019) *(j%2019) % 2019;
              if(c < ans){
                if(c == 0){
                  printf("0\n");
                  return 0;
                }
                ans = c;
              }
            }
          }
          printf("%d\n",ans);
          return 0;
        }

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

int p,q;

int main(){
  while( cin >> p >> q ){
    map<int,int> M;
    string res="";
    int pos = -1;
    int cnt = 0;
    M[p] = cnt++;
    while( p != 0 ){
      p*=10;
      res += ('0'+p/q);
      p%=q;
      if( M.count( p ) != 0 ) {
        pos = M[p];
        break;      
      }
      M[p] = cnt++;
    }
    cout << res << endl;
    if( pos != -1 ){
      for(int i=0;i<(int)res.size();i++){
        if( i >= pos ) cout << "^";
        else cout << " ";
      }
      cout << endl;
    }
  }
}

Measured memory_bytes: 3200
#include <bits/stdc++.h>
#define ll long long
#define double long double
#define rep(i,n) for(int i=0;i<(n);i++)
#define REP(i,n) for(int i=1;i<=(n);i++)
#define mod (ll)(1e9+7)
#define inf (ll)(3e18+7)
#define pi (double) acos(-1)
#define P pair<int,int>
#define PiP pair<int,pair<int,int>>
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
using namespace std;

int main() {
    string s;
    cin >> s;
    int now = 0, ans = 0, a = 1;
    reverse(all(s));
    map<int, int> mp;
    mp[0]++;
    rep(i, s.size()){
        now = (now + (s[i]-'0') * a % 2019) % 2019;
        a = a * 10 % 2019;
        mp[now]++;
    }
    for(auto x : mp)ans += x.second * (x.second-1) / 2;
    cout << ans << endl;
}


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

using namespace std;

int INF = 1145141919;

int main() {
    int n;
    cin >> n;
    vector<int> v(n);
    for (int i = 0; i < n; i++)cin >> v[i];

    vector<int> ret(n);
    for (int i = n; i > 0; i--) {
        int count = 0;
        for (int j = i; j <= n; j += i) count += ret[j - 1];
        if (count % 2 != v[i - 1])
            ret[i - 1]++;
    }

    vector<int> ans;
    for (int i = 0; i < n; i++) {
        if (ret[i] == 1)ans.push_back(i + 1);
    }

    cout << ans.size() << endl;
    for (int i = 0; i < ans.size(); i++) {
        if (i > 0)cout << " ";
        cout << ans[i];
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin >> N;
  vector<int> Ws(N);
  for (int i = 0; i < N; i++) { cin >> Ws.at(i); }
  int min_abs = 10000000000;
  for (int i = 0; i < N; i++) {
    int sum_a = 0;
    int sum_b = 0;
    for (int j = 0; j < i; j++) { sum_a += Ws.at(j); }
    for (int j = i; j < N; j++) { sum_b += Ws.at(j); }
    if (abs(sum_a - sum_b) < min_abs) { min_abs = abs(sum_a - sum_b); }
  }
  cout << min_abs << endl;
}

Measured memory_bytes: 256
import sys
input=lambda: sys.stdin.readline().rstrip()
n=int(input())

def f(x):
  A=[]
  for _ in range(n):
    A.append(x%10)
    x//=10
  return A[::-1]

def g(X):
  cur=X[0]
  ret=-1
  for i in range(1,n):
    if X[i]+1<=cur+1 and X[i]+1<=i:
      ret=i
    cur=max(cur,X[i])
  return ret
Ans=[0]

a=f(0)
b=g(a)
while b>=0:
  next=0
  for i in range(n):
    if i<b:
      next+=a[i]*(10**(n-1-i))
    elif i==b:
      next+=(a[i]+1)*(10**(n-1-i))
  Ans.append(next)
  a=f(next)
  b=g(a)
for a in Ans:
  ans=""
  for x in f(a):
    ans+=chr(97+x)
  print(ans)







Measured memory_bytes: 9028
using System;
using System.Collections.Generic;
using System.Linq;

class Procon {
    public Procon () { }
    static void Main (string[] agrs) {
        new Procon ().Do ();
    }

    Scanner cin;

    public void Do () {
        cin = new Scanner ();
        int K = cin.nextInt ();
        int X = cin.nextInt ();
        for (int i = X - K + 1; i <= X + K - 1; i++) {
            if ((-1000000 <= i) && (i <= 1000000)) {
                Console.Write ("{0} ", i);
            }
        }
        Console.WriteLine ("");
    }
}

class Scanner {
    string[] s;
    int i;
    int max_i;

    public Scanner () {
        s = new string[0];
        max_i = 0;
        i = 0;
    }

    public string nextString () {
        if (i >= s.Length) {
            s = Console.ReadLine ().Split (' ');
            max_i = s.Length;
            i = 0;
            if (max_i == 0) {
                return "";
            }
            return s[i++];
        } else {
            return s[i++];
        }
    }

    public int nextInt () {
        return int.Parse (nextString ());
    }

    public long nextLong () {
        return long.Parse (nextString ());
    }

    public double nextDouble () {
        return double.Parse (nextString ());
    }

    public string[] arrayString () {
        return Console.ReadLine ().Split (' ');
    }

    public int[] arrayInt () {
        string[] str = Console.ReadLine ().Split (' ');
        int[] array = new int[str.Length];
        for (int i = 0; i < str.Length; i++) {
            array[i] = int.Parse (str[i]);
        }
        return array;
    }

    public long[] arrayLong () {
        string[] str = Console.ReadLine ().Split (' ');
        long[] array = new long[str.Length];
        for (int i = 0; i < str.Length; i++) {
            array[i] = long.Parse (str[i]);
        }
        return array;
    }

    public double[] arrayDouble () {
        string[] str = Console.ReadLine ().Split (' ');
        double[] array = new double[str.Length];
        for (int i = 0; i < str.Length; i++) {
            array[i] = double.Parse (str[i]);
        }
        return array;
    }
}

Measured memory_bytes: 13268
import java.io.BufferedReader;
import java.io.InputStreamReader;


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

    public void solve(String[] args) {
        MyScanner scanner = new MyScanner();

        // ビジネスロジックここから
        
        
        int R = scanner.nextInt();
        
         
        if (R < 1200) {
        	System.out.println("ABC");
        }
        else if (1200 <= R && R < 2800) {
        	System.out.println("ARC");
        }
        else if (R >= 2800) {
        	System.out.println("AGC");
        }
        
        // ビジネスロジックここまで

    }

    private class MyScanner {
        String[] s;
        int i;
        BufferedReader br;
        String reg = " ";
        MyScanner () {
            s = new String[0];
            i = 0;
            br = new BufferedReader(new InputStreamReader(System.in));
        }
        public String next() {
            try {
                if (i < s.length) return s[i++];
                String line = br.readLine();
                while (line.equals("")) {line = br.readLine();}
                s = line.split(reg, 0);
                i = 0;return s[i++];
            } catch (Exception e) {e.printStackTrace();}
            return null;
        }
        public int nextInt() {
            try {return Integer.parseInt(next());} catch (Exception e) {e.printStackTrace();}
            return -1;
        }
        public double nextDouble() {
            try {return Double.parseDouble(next());} catch (Exception e) {e.printStackTrace();}
            return -1;
        }
        public long nextLong()  {
            try {return Long.parseLong(next());} catch (Exception e) {e.printStackTrace();}
            return -1;
        }
    }
}


Measured memory_bytes: 20948
fun main(args: Array<String>) {
    val (N, K) = listOfInt()
    val A = listOfInt()
    val ans = if (N == K) 1 else (N - 1 + (K - 2)) / (K - 1)
    println(ans)
}
fun next() = readLine()!!
fun nextInt() = Integer.parseInt(next())
fun listOfString() = next().split(" ")
fun listOfInt() = listOfString().map { Integer.parseInt(it) }
fun listOfLong() = listOfString().map { java.lang.Long.parseLong(it) }


Measured memory_bytes: 48800
// -*- mode:c++; coding:utf-8; c-basic-offset:2; -*-
// ALDS1_4-C: Dictionary

#include <cstdio>
#include <cstring>

#define NDEBUG
#include <cassert>

template <unsigned int N>
class Dictionary {
  char** data_;
  unsigned int size_ = 0; // for assert
public:
  Dictionary()
  {
    data_ = new char*[N];
    for (auto i = 0u; i < N; ++i) {
      data_[i] = nullptr;
    }
  }

  ~Dictionary()
  {
    for (auto i = 0u; i < N; ++i) {
      delete data_[i]; // delete nullptr is ok!
    }
    delete[] data_;
  }

  void insert(const char* cp)
  {
    assert(size_ < N-1); // at least one vacancy entry needed for not found
    auto i = find_index(cp);
    if (data_[i]) return; // cp was already inserted
    auto buf = new char[std::strlen(cp)+1];
    std::strcpy(buf, cp);
    data_[i] = buf;
    ++size_;
  }

  bool find(const char* cp) const
  {
    auto i = find_index(cp);
    return data_[i] ? true : false;
  }
private:
  unsigned int find_index(const char* cp) const
  {
    auto h1 = hash1(cp), h2 = hash2(h1);
    auto h = h1 % N;
    for (auto i = 0U; ; ++i) {
      if (data_[h] == nullptr || std::strcmp(data_[h], cp) == 0) {
        return h;
      }
      h = (h+h2) % N; // (h + i*h2(h)) % N;
    }
  }

  unsigned int hash1(const char* cp) const
  {
    auto h = 0U;
    for (; *cp; ++cp) {
      h = 31*h + *cp;
    }
    return h % N;
  }

  unsigned int hash2(int h1) const
  {
    return h1 ? (N-h1) : 1;
  }
};

int main()
{
  const unsigned int M = 1250437; // (prime number) * 0.8 > 1000000
  Dictionary<M> dict;

  int n;
  std::scanf("%d", &n);
  
  for (auto i = 0; i < n; ++i) {
    char buf1[6+1]; // "insert".size() + 1('\0')
    char buf2[12+1]; // 12(max)+1('\0')
    std::scanf("%6s %12s", buf1, buf2);
    if (buf1[0] == 'i') { // insert ...
      dict.insert(buf2);
    } else { // find ...
      bool found = dict.find(buf2);
      puts(found ? "yes" : "no");
    }
  }
}

// eof

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

#define all(a) a.begin(), a.end()
#define allr(a) a.rbegin(), a.rend()
#define rev(v) reverse(v.begin(), v.end());
#define io() ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); srand(time(NULL));

using namespace std;

using ll = long long;
using ld = long double;
using ull = unsigned long long;

signed main(){
    io();
    int n; cin >> n;
    int curmn = 2e5 + 1, ans = 0;
    for(int i = 0, x; i < n; ++i){
        cin >> x;
        ans += (x < curmn);
        curmn = min(curmn, x);
    }
    cout << ans << '\n';
    return 0;
}

Measured memory_bytes: 3612
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep2(i, x, n) for(int i = x; i <= n; i++)
#define rep3(i, x, n) for(int i = x; i >= n; i--)
#define elif else if
typedef long long ll;
typedef pair<ll, ll> P;
const ll MOD = 1e9+7;
const ll MOD2 = 998244353;
const ll INF = 1e18;

int main(){
    int M;
    ll K;
    cin >> M >> K;
    ll e[M+1];
    e[0] = 1;
    rep(i, M) e[i+1] = 2*e[i];
    if(M == 0){
        if(K == 0) cout << 0 << ' ' << 0 << endl;
        else cout << -1 << endl;
    }
    elif(M == 1){
        if(K == 0) cout << 0 << ' ' << 0 << ' ' << 1 << ' ' << 1 << endl;
        else cout << -1 << endl;
    }
    else{
        if(K < e[M]){
            cout << K << ' ';
            rep(i, e[M]){
                if(i != K) cout << i << ' ';
            }
            cout << K << ' ';
            rep3(i, e[M]-1, 0){
                if(i != K) cout << i << ' ';
            }
            cout << endl;
        }
        else cout << -1 << endl;
    }
}

Measured memory_bytes: 1792
package main

import (
	"fmt"
)

func max(a, b int64) int64 {
	if a > b {
		return a
	}
	return b
}
func min(a, b int64) int64 {
	if a < b {
		return a
	}
	return b
}
func main() {
	var n int64
	fmt.Scan(&n)

	if n%2 == 0 {
		fmt.Println(n)
	} else {
		fmt.Println(2 * n)
	}
}


Measured memory_bytes: 1768
#include<iostream>
#include<cstdio>
#include<vector>
#include<cmath>
#include<string>
#include<cstring>
#include<algorithm>
#include<queue>
#include<map>
#include<set>
#define  endl '\n'
#define all(s) s.begin(),s.end()
#define lowbit(x) (x&-x)
#define rep(i,a,n) for (int i=a;i<=n;i++)
#define IOS ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define mem(a,b) memset(a,b,sizeof(a))
#define fi first
#define se second
#define pb push_back
#define pi acos(-1.0)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
const int mod=1e9+7;
const double eps=1e-8;
const int inf=0x3f3f3f3f;
const int N=2e5+10;
int main()
{
	int n,m,q,k;
	cin>>n;
	map<string,int>mp;
	while(n--){
		string s;
		cin>>s;
		mp[s]++;
	}
	cout<<"AC x "<<mp["AC"]<<endl;
	cout<<"WA x "<<mp["WA"]<<endl;
	cout<<"TLE x "<<mp["TLE"]<<endl;
	cout<<"RE x "<<mp["RE"]<<endl;
}



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

int main(){
	int n, k;
	scanf("%d %d",&n,&k);
	if (k * 2 > n + 1){
		printf("-1\n");
		return 0;
	}
	for (int i = 0; i < (n + 1) / 2; i++)
		printf("%d %d %d\n", k + i, k + n + n / 2 + i, k + n * 2 + i * 2);
	for (int i = 0; i < n - (n + 1) / 2; i++)
		printf("%d %d %d\n", k + (n + 1) / 2 + i, k + n + i, k + n * 2 + i * 2 + 1);
	return 0;
}

Measured memory_bytes: 2304
// Package main provides
//
// File:  d.go
// Author: ymiyamoto
//
// Created on Mon Dec 17 15:23:05 2018
//
package main

import "fmt"

func nums(slice []int, f func(n int) bool) int {
	count := 0
	for _, s := range slice {
		if f(s) {
			count++
		}
	}
	return count
}

func gTE(n int) func(n int) bool {
	return func(m int) bool { return m >= n-1 }
}

func main() {
	var N int
	fmt.Scan(&N)

	m := map[int]int{}
	for i := 2; i <= N; i++ {
		n := i
		for j := 2; j <= i; j++ {
			for n%j == 0 {
				m[j]++
				n /= j
			}
		}
	}

	arr := make([]int, 0)
	for _, v := range m {
		arr = append(arr, v)
	}

	ans := nums(arr, gTE(75)) + nums(arr, gTE(25))*(nums(arr, gTE(3))-1) + nums(arr, gTE(15))*(nums(arr, gTE(5))-1) + nums(arr, gTE(5))*(nums(arr, gTE(5))-1)*(nums(arr, gTE(3))-2)/2
	fmt.Println(ans)
}


Measured memory_bytes: 512
n, p = map(int, input().split())
w, b = [], []
for _ in range(n):
    ww, bb = map(int, input().split())
    w.append(ww)
    b.append(bb)

s = []
for ww, bb in zip(w, b):
    s.append((100 - p) * ww + p * bb)
s.sort(reverse=True)

score = -sum(b) * p

cnt = 0
while score < 0:
    score += s[cnt]
    cnt += 1
print(cnt)

# (100-p)*w-p*b>=0


Measured memory_bytes: 15864
using System;
using System.Text;
using System.Linq;
using System.Collections;
using System.Collections.Generic;


class Program {

	static long mod = 998244353;
	static int[] ans;
	static void Main(string[] args) {

		char[] cs = new char[] { ' ' };
		//char[] cs = new char[] { ' ', ',' };

		//int n = int.Parse(Console.ReadLine());
		//int val = int.Parse(Console.ReadLine());
		//int[] vals = parseAry(Console.ReadLine().Split(cs));
		//string str = Console.ReadLine();
		//string[] strs = Console.ReadLine().Split(cs);


		string res = "No";
		//int[] vals = parseAry(Console.ReadLine().Split(cs));


		string str = Console.ReadLine();
		string[] ss=strAry(str);
		Array.Sort(ss);
		if ( ss[0] == ss[1] && ss[2] == ss[3] ) {
			res = "Yes";
		}

		if ( ss[1] == ss[2] ) {
			res = "No";
		
		}

			Console.WriteLine(res);
				return;

	}



	//	文字列strをindex番目からdで上書き
	static string strOverWrite(string str, int i, string s) {
		return str.Remove(i, s.Length).Insert(i, s);
	}

	//　String[]  ----->  int[]
	static int[] parseAry(string[] str) {
		int[] nums = new int[str.Length];
		for ( int i = 0; i < str.Length; i++ ) { nums[i] = int.Parse(str[i]); }
		return nums;
	}
	//　String[]  ----->  long[]
	static long[] parseAryL(string[] str) {
		long[] nums = new long[str.Length];
		for ( int i = 0; i < str.Length; i++ ) { nums[i] = long.Parse(str[i]); }
		return nums;
	}

	//文字列を1文字ずつString[]に入れる
	static string[] strAry(String str) {
		string[] re = new string[str.Length];
		for ( int i = 0; i < str.Length; i++ ) { re[i] = str[i].ToString(); }
		return re;
	}


}

Measured memory_bytes: 13408