akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define REP(i,x,n) for(int i=x;i<(int)n;i++)
#define rep(i,n) REP(i,0,n)
#define sp(p) cout<<setprecision(16)<<fixed<<p<<endl;
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define SORT(a) sort(all(a))
#define RSORT(a) sort(rall(a))
#define UNIQ(a) unique(all(a))
#define UNIQNUM(a) UNIQ(a)-a.begin()
#define UNIQIT(a) a.erase(UNIQ(a), a.end());
#define VOUT(v,i) rep(i,v.size())cout<<v[i]<<(i==v.size()-1?"\n":" ");
#define vout(v) VOUT(v,z);
#define vdbg(v,i) cout<<#v<<": ";for(int i=0;i<(int)v.size();i++){cout<<v[i]<<" ";}cout<<"\n";
#define vmin(v) *min_element(all(v))
#define vmax(v) *max_element(all(v))
#define vsum(v) accumulate(all(v), 0LL)
#define MOUT(m,r,c) rep(i,r){rep(j,c){cout<<m[i][j]<<" ";}cout<<endl;}
#define mout(m) MOUT(m,m.size(),m[0].size())
#define debg(a) cout<<#a<<": "<<a<<endl;
#define show(a) for(cont &y:a){for(cont &x:y){cout<<x<<" ";}cout<<endl;}
#define digit(a) to_string(a).length();
template<class T>inline int out(const T &t){ print(t); putchar('\n'); return 0; }
// template<class T>inline T gcd(T a,T b){if(b==0)return a; return(gcd(b,a%b));}
// template<class T>inline T lcm(T a,T b){return a/gcd(a,b)*b;}
bool is_palindrome(string s){return s == string(s.rbegin(),s.rend());}
#define popcount __builtin_popcount
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> P;
typedef vector<ll> V;
typedef vector<vector<ll>> VV;
// const long long MOD=1000000007;
const long long INF = 1e18;
#define EPS (1e-7)
#define PI (acos(-1))
template<class T>
inline bool chmax(T &a, T b) {
    if(a < b) { a = b; return true; }
    return false;
}
template<class T>
inline bool chmin(T &a, T b) {
    if(a > b) { a = b; return true; }
    return false;
}

ll N;
ll K;
std::vector<long long> A;

bool check(ll mid){
    ll cnt=0;
    for (long long i = 0; i < N; i++) {
        if(A[i]<=mid) continue;
        cnt+=A[i]/mid;
    }
    return cnt<=K;
}

int main(){
    // long long N;
    scanf("%lld",&N);
    // long long K;
    scanf("%lld",&K);
    // std::vector<long long> A(N);
    A.resize(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&A[i]);
    }

    long long ng=0, ok=INF;
    while (abs(ok - ng) > 1) {
      long long mid = (ok + ng) / 2;
      if (check(mid)) {
        ok = mid;
      } else {
        ng = mid;
      }
    }
    cout << ok << endl;

    return 0;
}


Measured memory_bytes: 4792
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<math.h>
#include<queue>
#include<deque>
#include<stack>
#include<cstdio>
#include<utility>
#include<set>
#include<list>
#include<cmath>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
const int INF = 1e9;
int main() {
	int N, M;
	cin >> N >> M;
	int time = 1900 * M + 100 * (N - M);
	int x = 1;
	for (int i = 0; i < M; ++i) {
		x *= 2;
	}
	int ans = time * x;
	cout << ans << endl;
	return 0;
}

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

using namespace std;

int N;
int MAX_A = 55556;
bool A[55556];

int main() {
  scanf("%d", &N);
  for (int i=0; i<MAX_A; i++) A[i] = true;

  int ans = 0;
  int i=2;
  for (;;) {
    if (A[i] && i%5 == 1) {
      printf("%d ", i);
      ans++;
    }
    if (ans == N){
      printf("\n");
      return 0;
    }
    for (int j=i; j<MAX_A; j+=i) {
      A[j] = false;
    }
    i++;
  }
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
using namespace std;
bool isPossible(int a, int b, int x){
	if (a > x){
		return false;
	}
	if (a+b <x){
		return false;
	}
	return true;
}
int main() {
	// your code goes here
	int a=0; int b=0; int x=0;
	
	scanf("%d", &a);
	scanf("%d", &b);
	scanf("%d", &x);
	if (isPossible(a,b,x)){
		printf("YES");
	}else{
		printf("NO");
	}
	
}


Measured memory_bytes: 256
*A, = map(int, open(0).read().split())
N = A[9]
B = A[10:]
A = A[:9]

T = [False]*9

for b in B:
    if b in A:
        T[A.index(b)] = True

bingo = [(0, 1, 2), (3, 4, 5), (6, 7, 8), (0, 3, 6),
         (1, 4, 7), (2, 5, 8), (0, 4, 8), (2, 4, 6)]

for a, b, c in bingo:
    if T[a] and T[b] and T[c]:
        print('Yes')
        break
else:
    print('No')


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

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

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

int main(){
  int n;
  cin >> n;
  int a[n];
  rep(i,n)cin >> a[i];

  int ans=0;
  int tmp=0;
  int len=1;
  rep(i,n){
    if(tmp==a[i]){
      len++;
    }else {
      len=1;
    }
    tmp=a[i];

    if(len%2==0)ans++;
  }
  cout << ans << endl;
}

Measured memory_bytes: 3596
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using ll=long long;
using vi = vector<int>;
using vl = vector<ll>;
using Graph = vector<vi>;
using P = pair<int,int>;
const int MOD=(int)1e9+7;
const int INF=(int)1e9;
const ll LINF=(ll)1e18;
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(b<a)a=b;}

int main(){
    int n;cin >> n;
    vi b(n);
    rep(i,n) cin >> b[i];
    vi ans;
    rep(i,n){
        for(int j=b.size()-1;j>=0;j--){
            if(b[j]==j+1){
                ans.push_back(j+1);
                b.erase(b.begin() + j);
                break;
            }
        }
    }
    reverse(ans.begin(),ans.end());
    if(ans.size()!=n){
        cout << -1 << endl;
    }else{
        rep(i,n) cout << ans[i] << endl;
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <map>
#include <vector>
#include <tuple>

using namespace std;

int main()
{
    int n;
    cin >> n;
    int okane = 0;
    okane = n/15;
    cout << (800*n)-(okane*200) << endl;
}

Measured memory_bytes: 256
# coding: utf-8
# Your code here!

from functools import cmp_to_key
s = input()
K = int(input())
 
e = set([])
 
def cmp(a, b):
    if a == b: return 0
    return -1 if a < b else 1
    
def substring_sort(a,b):
    if len(a) != len(b):
        return cmp(len(a), len(b))
    else:
        return cmp(a,b)
 
for i in range(1,K+1):
    for j in range(len(s)):
    #     if len(e) < 5:
    #         e.add(s[j:j+i])
    #     if len(e) == 5:
    #         break
    # else:
    #     continue
    # break
        e.add(s[j:j+i])
# print(e)
# result = sorted(e,key=cmp_to_key(substring_sort),reverse=True)
result = sorted(e)
# print(result)
print(result[K-1])

Measured memory_bytes: 5088
#include <stdio.h>
#include <math.h>
 
#define POW(x) ((x) * (x))
 
int main(){
  double x1, y1, x2, y2;
  scanf("%lf%lf%lf%lf", &x1, &y1, &x2, &y2);
  printf("%.8f\n", sqrt(POW(x2 - x1) + POW(y2 - y1)));
  return 0;
}


Measured memory_bytes: 2104
#include <bits/stdc++.h>
#define ll long long
#define MODV 1000000007
#define INF INT_MAX // 2147483647
#define INFLL LLONG_MAX // 9223372036854775807
#define rep(i, n) for(ll i=0, i##_len=(ll)(n); i<i##_len; i++)
#define repf(i, n) for(ll i=1, i##_len=(ll)(n+1); i<i##_len; i++)
#define per(i, n) for(ll i=((ll)(n))-1; i>=0; i--)
#define perf(i, n) for(ll i=((ll)(n)); i>0; i--)
#define all(v) v.begin(), v.end()
#define endl "\n"
#define vi vector<ll>
#define vvi vector<vector<ll>>
#define Yes() cout << "Yes" << endl
#define YES() cout << "YES" << endl
#define No() cout << "No" << endl
#define NO() cout << "NO" << endl
#define Init() std::ios::sync_with_stdio(false); std::cin.tie(0); std::cout<<fixed<<setprecision(15);
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; }
using namespace std;

int main(){
    Init();
    ll n; cin >> n;
    cout << ((n%2 == 0) ? n : n*2) << endl; 
}

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

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  string S;
  cin >> S;
  int ans = 0;
  int gsum = 0;
  int ksum = 0;
  int gcnt = 0;
  int kcnt = 0;
  for(int i = 0; i < S.size(); i += 2) {
    gsum += S[i] - 48;
    gcnt++;
    // cout << "gsum: " << gsum << "gcnt: " << gcnt << endl;
  }
  for(int i = 1; i < S.size(); i += 2) {
    ksum += S[i] - 48;
    kcnt++;
  }
  ans = min(gsum + kcnt - ksum, ksum + gcnt - gsum);
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 512
/******************************************************************************

                              Online C++ Compiler.
               Code, Compile, Run and Debug C++ program online.
Write your code in this editor and press "Run" button to compile and execute it.

*******************************************************************************/

#include <iostream>

using namespace std;

int main()
{
    int a[9],i,j,k,n;
    for(i=0;i<9;i++)
    {
        cin>>a[i];
    }
    cin>>n;
    for(i=0;i<n;i++)
    {
        cin>>j;
        for(k=0;k<9;k++)
        {
           if(a[k]==j)
            a[k]=0; 
        }
        
    }
    
    if(a[0]==0 && a[1]==0 && a[2]==0)
    cout<<"Yes";
    else if(a[3]==0 && a[4]==0 && a[5]==0)
    cout<<"Yes";
    else if(a[6]==0 && a[7]==0 && a[8]==0)
    cout<<"Yes";
    else if(a[0]==0 && a[3]==0 && a[6]==0)
    cout<<"Yes";
    else if(a[1]==0 && a[4]==0 && a[7]==0)
    cout<<"Yes";
    else if(a[2]==0 && a[5]==0 && a[8]==0)
    cout<<"Yes";
    else if(a[0]==0 && a[4]==0 && a[8]==0)
    cout<<"Yes";
    else if(a[2]==0 && a[4]==0 && a[6]==0)
    cout<<"Yes";
    else
    cout<<"No";

    return 0;
}


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

using namespace std;

using i64 = int64_t;
const i64 MOD = 1e9 + 7;
const i64 INF = i64(1e18) + 7;


signed main(){

    int m, f, b;
    cin >> m >> f >> b;
    int val = max(0, b - m);
    if(val > f){
        cout << "NA" << endl;
    }
    else{
        cout << val << endl;
    }

}



Measured memory_bytes: 3092
// finish date: 2018/01/23
#include <iostream>
#include <cmath>
#include <vector>
#include <bitset>
#include <algorithm>
#include <stack>
#include <map>
#include <climits>

using namespace std;

#define FOR(i, a, b) for(int (i)=a;(i)<(b);(i)++)
#define rep(i, n)  FOR(i,0,n)
#define ll long long
#define vi vector<int>
#define vl vector<ll>
#define bigmod 1000000007
#define INF 500000000


int main() {
    int N;
    cin >> N;
    int a;
    int count2 = 0, count4 = 0, counte = 0;
    rep(i, N) {
        cin >> a;
        if (a % 4 == 0) count4++;
        else if (a % 2 == 0) count2++;
        else counte++;
    }
    N -= count2;
    if (count4 >= counte) cout << "Yes" << endl;
    else if (count2 == 0 && count4 >= counte - 1) cout << "Yes" << endl;
    else cout << "No" << endl;

    return 0;
}



Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
using namespace std;
int main(){
  int n;
  int k;
  int h[100005];
  int dp[100005]={};
  
  cin>>n>>k;
  
  for(int i=0;i<n;i++){
    cin>>h[i];
  }
  
  
  for(int i=1;i<n;i++){
    int minimum=1000000000;
    for(int j=1;j<=k;j++){
      if(i-j>=0){
	minimum=min(minimum,dp[i-j]+abs(h[i-j]-h[i]));
      }
      dp[i]=minimum;
    }
  }
  cout<<dp[n-1]<<"\n";

  return 0;
}


Measured memory_bytes: 1024
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();
		
		int[] x = {a, b, c};
		
		Arrays.sort(x);
		
		System.out.println(x[0] + x[1]);
		
	}
}


Measured memory_bytes: 22996
# -*- coding:utf-8 -*-

n = input()
n = int(n)

w = []
for i in range(n):
    _w = input()
    w.append(_w)
ans = "Yes"
for i in range(0,len(w)-1):
    for j in range(i+1,len(w)):
        if w[i] == w[j]:
            ans = "No"
for i in range(0,len(w)-1):
    if w[i][-1] != w[i+1][0] :
        ans ="No"

print(ans)

Measured memory_bytes: 3064
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {

        Scanner scanner = new Scanner(System.in);
        int N = scanner.nextInt();
        int A = scanner.nextInt();
        int B = scanner.nextInt();
        if (N * A < B) {
            System.out.println(N*A);
        } else {
            System.out.println(B);
        }
    }
}

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

using namespace std;

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

    char ch[200000],c;
    int N,i,ans=0;
    unordered_map<string, int> hash;
    cin>>N;

    unordered_map<string, int>:: iterator p;
    for(i=0;i<N;i++)
    {
        cin>>ch;
        hash[ch]++;
    }
    for (p = hash.begin(); p != hash.end(); p++)
    {
        if(p->second != 0)
            ans++;
    } 
    cout<<ans;
  
   
    return 0;   
}   


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


void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i : x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}

#define fo(i, n) for(int i=0; i<n; i++)
#define Fo(i, k, n) for(int i=k; i<n; i++)
#define w(x)  int x; cin>>x; while(x--)
#define watch(x) cout << (#x) << " is " << (x) << "\n"
#define watch2(x,y) cout <<(#x)<<" is "<<(x)<<" and "<<(#y)<<" is "<<(y)<<"\n"
#define watch3(x,y,z) cout <<(#x)<<" is "<<(x)<<" and "<<(#y)<<" is "<<(y)<<" and "<<(#z)<<" is "<<(z)<<"\n"
#define watch4(x,y,z,q) cout <<(#x)<<" is "<<(x)<<" and "<<(#y)<<" is "<<(y)<<" and "<<(#z)<<" is "<<(z)<<" and "<<(#q)<<" is "<<(q)<<"\n"
#define MOD 1000000007
#define INF 1000000007;
#define F first
#define S second
#define pb(x) push_back(x);


#define ll  long long
#define all(c) (c).begin(),(c).end()
#define endl "\n"

typedef vector<int> vl;
typedef vector< vl > vvl;
typedef pair< int, int> pll;
typedef map< int, int> mll;


#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif





void c_p_c()
{
#ifndef ONLINE_JUDGE
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
}
void parray(int a[], int n) {
	for (int i = 0; i < n; i++) {
		cout << a[i] << " ";
	}
	cout << endl;
}



int check(int n) {

	int temp = n + 9;

	temp = temp / 10;
	return temp * 10;



}

bool comp(int a, int b) {


	return a % 10 > b % 10;

}

int main() {
	int i, n, m, k, c = 0;
	c_p_c();
	cin >> n;
	int a[n];
	fo(i, n) cin >> a[i];
	int b[n];
	fo(i, n) cin >> b[i];



	int sum = 0;
	for (int i = 0; i < n; ++i)
	{
		/* code */
		int val = a[i] - b[i];
		if (val > 0)
			sum += val;
	}
	cout << sum << endl;

	return 0;
}



Measured memory_bytes: 3584
#include <bits/stdc++.h>
using namespace std;
int main() {
  int N,A,answer = INT_MAX;
  cin >> N;
  for (int n = 0; N; N--, n = 0) {
    for (cin >> A; !(A%2); n++, A /= 2);
    answer = min(answer,n);
  }
  cout << answer;
}

Measured memory_bytes: 3508
n, k = map(int, input().split())
d=list(map(int, input().split()))
l = [i for i in range(10) if i not in d]
for i in range(n,100000):
    flag=True
    for j in str(i):
        if int(j) in (d):
            flag = False
    if flag:
        print(i)
        break

Measured memory_bytes: 3060
n, k = map(int, input().split())
h = list(map(int, input().split()))

dp = [10**10] * n
dp[0] = 0
for i in range(n):
  for j in range(1, k+1):
    if i - j >= 0:
      dp[i] = min(dp[i], dp[i-j] + abs(h[i] - h[i-j]))
print(dp[n-1])

Measured memory_bytes: 55416
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); i++)
#define repf(i,a,b) for (int i = (a); i < (b); i++)
#define repi(i,a,b) for (int i = (a); i <= (b); i++)
#define repr(i,a,b) for (int i = (a); i >= (b); i--)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define debug(x)  cout << #x << " = " << (x) << endl;
#define SORT(x) sort(all(x));
#define RSORT(x) sort(rall(x));
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vd = vector<double>;
using vb = vector<bool>;
using pii = pair<int, int>;
using vc = vector<char>;
using vvc = vector<vc>;
using vs = vector<string>;
using tiii = tuple<int, int, int>;
const ll inf = 1ll<<29;
const ll mod = 1000000007;
const double eps = 1e-9;
const int dx[4] = {1,0,-1,0};
const int dy[4] = {0,1,0,-1};

int main() {
  int N; cin >> N;
  vector<tuple<string,int,int>> data(N);
  rep(i,N) {
    string S;
    int P;
    cin >> S >> P;
    data.at(i) = make_tuple(S,-P,i+1);
  }

  SORT(data);

  rep(i,N) {
    int number;
    tie(ignore,ignore,number) = data.at(i);
    cout << number << endl;
  }
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <stdlib.h>
#include <string.h>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <set>
#include <stdio.h>
#include <tuple>
#include <bitset>
#include <cfloat>
#include <fstream>
#include <limits.h>
#include <list>
#include <math.h>
#include <random>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <numeric>
#include <utility>
#include <sstream>
#define int long long
#define rep(i, n) for (int i = 0; i < (n); i++)
#define P pair<int, int>
#define sz(x) x.size()
#define all(x) (x).begin(),(x).end()
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;
}

using namespace std;
typedef long long ll;
using Graph = vector<vector<int>>;
ll gcd(ll a, ll b) {
	if (a < b)swap(a, b);
	if (b == 0) return a;
	return gcd(b, a % b);
}
ll lcm(ll a, ll b) {
	ll g = gcd(a, b);
	return a / g * b;
}
bool prime(int n) {
	for (int i = 2; i <= sqrt(n); i++) {
		if (n%i == 0)return false;
	}
	return n != 1;
}


const long long MOD = 1000000007;
const long long INF = 1LL << 60;

// pair -> vector<pair<int,int>> 
//		   AandB.push_back(make_pair(a[i],b[i]))


signed main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int n; cin >> n;
	vector<int>b(n-1); rep(i, n-1)cin >> b[i];
	vector<int>a(n);
	a[0] = b[0];
	a[n - 1] = b[n - 2];
	for (int i = 1; i < n - 1;i++) {
		a[i] = min(b[i - 1], b[i]);
	}
	int ans = 0;
	rep(i, n) {
		ans += a[i];
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstring>
#include <algorithm>
#include <vector>
#include <string>
#include <math.h>
#include <iomanip>
#include <limits>
#include <list>
#include <queue>
#include <tuple>
#include <map>
using namespace std;
#define MOD (long long int)(1e9+7)
#define ll long long int
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define reps(i,n) for(int i=1; i<=(int)(n); i++)
#define REP(i,n) for(int i=n-1; i>=0; i--)
#define REPS(i,n) for(int i=n; i>0; i--)
#define INF (int)(1123456789)
#define LINF (long long int)(112345678901234567)
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
#define all(v) v.begin(), v.end()



int main(void){
	int N;
    cin >> N;
    int p[N];
    rep(i,N){
        cin >> p[i];
    }

    string ans = "YES";
    int a = 0;

    rep(i,N){
        if(p[i] != i+1){
            if(p[p[i]-1] != i+1){
                ans = "NO";
            }
            a++;
        }
    
    }
    if(a > 2){
        ans = "NO";
    }

    cout << ans << endl;

    return 0;
}



Measured memory_bytes: 256
import sys
import decimal # 10進法に変換，正確な計算

def input():
    return sys.stdin.readline().strip()

def main():
    a, b =  input().split()
    if int(a) <= int(b):
        for i in range(int(b)):
            print(a, end="")
        return
    for i in range(int(a)):
            print(b, end="")
    

main()


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

int main(){
  int n,k;
  int h[100001];
  int dp[100001];
  int mini;

  cin >> n >> k;
  for(int i=1;i<=n;i++){
    cin >> h[i];
  }

  memset(dp,0,sizeof(dp));

  for(int i=2;i<=n;i++){
    mini=1<<30;
    for(int j=1;j<=min(i-1,k);j++){
      mini=min(mini,dp[i-j]+abs(h[i]-h[i-j]));
    }
    dp[i]=mini;
  }
  cout << dp[n] << '\n';

  return 0;
}


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

int main() {
    int n, d;
    cin >>n >>d;
    vector<vector<int>> x(n, vector<int>(d));
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < d; j++) {
            cin >> x[i][j];
        }
    }
    int ret = 0, norm;
    for (int i = 0; i < n; i++) {
        for (int j = i+1; j < n; j++) {
            norm = 0;
            for (int k = 0; k < d; k++) {
                int diff = x[i][k] - x[j][k];
                norm += diff * diff;
            }
            bool flag = false;
            for (int k = 0; k <= norm; k++) {
                if (k*k == norm) {flag=true; break;}
            }
            if (flag) ret++;
        }
    }
    cout << ret << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i= 0;i<(n);++i)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
const long long INF = 1LL << 60;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int main(){

    int n,m;cin>>n>>m;
    vector<int> x(m),y(m);
    vector<int> ball(n+1);//個数
    vector<bool>red(n+1,false);//赤がある可能性

    for(int i =1;i<=n;i++){
        ball[i]=1;
        red[i]=0;
    }
    red[1]=true;
    rep(i,m){
        cin>>x[i]>>y[i];
    }
    rep(i,m){
        if(ball[x[i]]==0)break;
        ball[x[i]]-=1;
        ball[y[i]]+=1;
        if(red[x[i]])red[y[i]]=true;
        if(ball[x[i]]==0){
            red[x[i]]=false;
        }


    }
    int count =0;
    for(int i=1;i<=n;i++){
        if(red[i])count++;
    }
    cout<<count<<endl;
}

Measured memory_bytes: 4500
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
int a[3];
bool contains(string s, char c){
  return s[0] == c || s[1] == c;
}
int main()
{
  int n;
  cin >> n >> a[0] >> a[1] >> a[2];
  vector<string> qs(n);
  for(auto& el : qs)
    cin >> el;
//  return 0;

  vector<int> nxt(n);
  nxt[n - 1] = n;
  for(int i = n - 2;i >= 0;i--){
    if(qs[i] == qs[i + 1])
      nxt[i] = nxt[i + 1];
    else
      nxt[i] = i + 1;
  }
  vector<char> ans;
  for(int i = 0;i < n;i++){
    string q = qs[i];
    char x = q[0], y = q[1];
    int &f = a[x - 'A'], &s = a[y - 'A'];
    if(f == s && f == 0){
      cout << "No";
      return 0;
    }
    if(f < s || (f == s && (nxt[i] == n || contains(qs[nxt[i]], x)))){
      f++, s--;
      ans.push_back(x);
    }else{
      f--, s++;
      ans.push_back(y);
    }
  }
  cout << "Yes\n";
  for(auto el : ans)
    cout << el << endl;
  return 0;
}


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

#define ll long long
#define INF 1e9
#define Inf 1e18
#define rep(i,n) for(int (i)=0;(i)<n;i++)
#define REP(i,n) for(int (i)=1;(i)<=n;i++)
#define mp make_pair
#define pb push_back
#define pii pair<int,int>
inline void Fail(){
	printf("0");
	exit(0);
}

const int maxn=100005;
int n,ans;
int cnt[maxn];

int main(){
	scanf("%d",&n);
	rep(i,n){
		int x;
		scanf("%d",&x);
		cnt[x]++;
		if(cnt[x]==1)ans++;
	}
	int cur=n-ans;
	if(cur%2)ans--;
	printf("%d",ans);
	return 0;
}

/*
Input:
-----------------
Output:
*/

Measured memory_bytes: 640
n,m = [int(i) for i in input().split()]

cakes = []
ranking = [[] for i in range(8)]
ranking2 = []

for i in range(n):
    cakes.append(list(map(int,input().split())))

a = 0
for i in range(2):
    for j in range(2):
        for k in range(2):
            for x in range(n):
                kirei = cakes[x][0]
                oisii = cakes[x][1]
                ninki = cakes[x][2]
                if i ==1:
                    kirei = (-1)*kirei
                if j ==1:
                    oisii = (-1) * oisii
                if k==1:
                    ninki = (-1)*ninki
                sum = kirei + oisii + ninki
                ranking[a].append(sum)
            a += 1

for i in ranking:
    i = sorted(i)
    i = i[::-1]
    ranking2.append(i)

ans = 0

maxi = 0

for x in ranking2:
    ans = 0
    for i in range(m):
        ans += x[i]
    maxi = max(maxi,ans)
print(maxi)

Measured memory_bytes: 3700
#include <iostream>
#include <algorithm>
#include <array>
#include <cstdint>
#include <functional>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stdlib.h>
#include <string>
#include <utility>
#include <vector>

#define INF 1000000000
#define MOD 1000000007
#define rep(i,a,b) for(uint32 i = (a); i < (b); ++i)
#define bitget(a,b) (((a) >> (b)) & 1)
#define ALL(x) (x).begin(),(x).end()
#define C(x) std::cout << #x << " : " << x << std::endl
#define scanf scanf_s

using int32 = std::int_fast32_t;
using int64 = std::int_fast64_t;
using uint32 = std::uint_fast32_t;
using uint64 = std::uint_fast64_t;

template<typename T>
class hashmap64 {
	std::vector<std::pair<uint64, T>> map;
	uint64 mask, count, temp;
	uint64 hash64(uint64 key) {
		key = ~key;
		key ^= key << 13;
		key ^= key >> 19;
		return key ^ (key << 17);
	}
public:
	hashmap64() :map(8192, std::make_pair(~static_cast<std::uint_fast64_t>(0), T())) {
		mask = 8191; count = 0;
	}
	hashmap64(size_t s) {
		s |= s << 1;
		s |= s >> 2;
		s |= s >> 4;
		s |= s >> 8;
		s |= s >> 16;
		s |= s >> 32;
		mask = s;
		count = 0;
		map.resize(s + 1, std::make_pair(~static_cast<std::uint_fast64_t>(0), T()));
	}
	T &operator[](uint64 suf) {
		temp = mask&hash64(suf);
		while (map[temp].first != suf) {
			temp = mask&(temp + 1);
		}
		return map[temp].second;
	}
	void insert(uint64 key, const T &value) {
		temp = mask&hash64(key);
		while (~map[temp].first) {
			if (map[temp].first == key) {
				map[temp].second = value;
				return;
			}
			temp = mask&(temp + 1);
		}
		map[temp] = std::make_pair(key, value);
		++count;
		if ((count << 1) > mask) {
			std::pair<uint64, T> mkey;
			mask = mask << 1 | 1;
			map.resize(mask + 1, std::make_pair(~static_cast<std::uint_fast64_t>(0), T()));
			for (uint64 t = 0;t <= mask >> 1;++t) {
				if (!~map[t].first) {
					mkey = map[t];
					map[t].first = ~0;
					temp = mask&hash64(mkey.first);
					while (~map[temp].first) {
						temp = mask&(temp + 1);
					}
					map[temp] = mkey;
				}
			}
		}
		return;
	}
	bool find(uint64 key) {
		temp = mask&hash64(key);
		while (~map[temp].first) {
			if (map[temp].first == key) {
				return true;
			}
			temp = mask&(temp + 1);
		}
		return false;
	}
	bool empty(void) {
		return !count;
	}
	size_t size(void) {
		return count;
	}
};

int main(void) {
	std::ios::sync_with_stdio(false);
	std::cin.tie(0);
	hashmap64<uint32> map(30000);
	uint32 n;
	std::cin >> n;
	int64 a, sum = 1e15;
	uint32 ans = 0;
	map.insert(sum, 0);
	rep(i, 0, n) {
		std::cin >> a;
		sum += a;
		if (map.find(sum)) {
			ans = std::max(ans, i + 1 - map[sum]);
		}
		else {
			map.insert(sum, i + 1);
		}
	}
	std::cout << ans << "\n";
	return 0;
}

Measured memory_bytes: 15176
import java.io.*;
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		double x = sc.nextDouble();
		long y = Math.round(Math.ceil((Math.sqrt(2*x + .25) - .5)));
		System.out.println(y);
	}
}

Measured memory_bytes: 22996
#include<stdio.h>

#define NIL 10000000


int main(){
  int n,i,j,k;
  scanf("%d",&n);
  int row[n];
  int column[n];
  for(i=0;i<n;i++)
    scanf("%d %d",&row[i],&column[i]);
  
  int dp[n][n];
  
  for(i=0;i<n;i++)
    {
      for(j=0;j<n;j++){
	dp[i][j]=NIL;
      }
    }
  
  for(i=0;i<n;i++){
    dp[i][i]=0;
  }

  for(j=0;j<n;j++){
    for(i=0;i<n-j;i++){
      for(k=i+1;k<=i+j;k++){
	dp[i][i+j]=min(dp[i][i+j],dp[i][k-1]+dp[k][i+j]+row[i]*column[k-1]*column[i+j]);
      }
    }
  }
  printf("%d\n", dp[0][n-1]);

  return 0;
}

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

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

using namespace std;

int main()
{
    ios_base::sync_with_stdio( false ), cin.tie( nullptr ), cout.tie( nullptr );

    int D, G, m = INT_MAX, s_max; cin >> D >> G, s_max = 100 * D; pair< int, int > p[ D ];

    for( int i = 0; i < D; i++ )
        cin >> p[ i ].first >> p[ i ].second;

    for( int x = 1, y = 1 << D; x < y; x++ )
    {
        int g = G, q = 0;

        for( int i = D - 1, s = s_max, z = x; g > 0 and i >= 0 and z > 0; i--, s -= 100, z >>= 1 )
            if ( z & 1 )
            {
                int n = min( g / s, p[ i ].first ); g -= n * s, q += n;

                if ( n == p[ i ].first )
                    g -= p[ i ].second;
            }

        if ( g <= 0 )
            m = min( m, q );
    }

    cout << m;
}


Measured memory_bytes: 256
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<iostream>
using namespace std;
int N,x,syu=0,xmax=0,xmin=2000;
int main(void)
{
	cin>>N;
	for(int i=0;i<N;i++){
		cin>>x;
		if(x<xmin){
			xmin=x;
		}
		if(x>xmax){
			xmax=x;
		}
	}
	syu+=(double)0.5+(xmax-xmin)/2.0;
	cout<<syu<<endl;
}


Measured memory_bytes: 3092
s = gets.chomp.split("")
t = gets.chomp.split("")

result = t.length
s.each_cons(t.length) do |arr|
  tmp = t.length
  (0..t.length-1).each do |i|
    tmp -= 1 if arr[i] == t[i]
  end
  result = tmp if tmp < result
end

puts result


Measured memory_bytes: 16128
#define _USE_MATH_DEFINES
#include <cassert>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <sstream>
#include <vector>
#include <queue>
#include <stack>
#include <list>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <complex>
#include <cmath>
#include <numeric>
#include <bitset>
#include <functional>
#include <random>
#include <ctime>

using namespace std;

#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cerr << name << ": " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
  const char* comma = strchr(names + 1, ',');
  cerr.write(names, comma - names) << ": " << arg1 << " |";
  __f(comma + 1, args...);
}

typedef long long int64;
typedef pair<int, int> ii;
const int INF = 1 << 29;
const int MOD = 1e9 + 7;

struct Node {
  int s, t, x;
  bool operator <(const Node& rhs) const {
    return s < rhs.s;
  }
};

int main() {
  int n, m;
  scanf("%d%d", &n, &m);
  vector<Node> a(n);
  vector<ii> A;
  for (int i = 0; i < n; ++i) {
    scanf("%d%d%d", &a[i].s, &a[i].t, &a[i].x);
    a[i].s -= a[i].x;
    a[i].t -= a[i].x;
    A.push_back({a[i].s, a[i].x});
    A.push_back({a[i].t, -a[i].x});
  }
  vector<int> t(m), ret(m, -1);
  for (int i = 0; i < m; ++i) {
    scanf("%d", &t[i]);
  }
  sort(A.begin(), A.end());
  int len = A.size();
  set<int> S;
  int k = 0;
  for (int i = 0, j; i < len; ++i) {
    for (j = i; j < len && A[j].first == A[i].first; ++j) {
      if (A[j].second > 0) {
        S.insert(A[j].second);
      } else {
        S.erase(-A[j].second);
      }
    }
    // trace(k, i, j, A[i].first);
    // for (auto& it : S) cout << it << " ";
    // cout << endl;
    while (k < m && t[k] < A[i].first) ++k;
    while (k < m && j < len && t[k] < A[j].first) {
      ret[k] = S.size() ? *S.begin() : -1;
      ++k;
    }
  }
  for (int i = 0; i < m; ++i) {
    printf("%d\n", ret[i]);
  }
  return 0;
}


Measured memory_bytes: 17644
#include<bits/stdc++.h>
#define int long long
using namespace std;
struct trees{
	int l,r,maxv;
}tree[2400005];
int a[300005],dp[300005];
void build(int L,int R,int i){
	tree[i].l=L;
	tree[i].r=R;
	tree[i].maxv=0;
	if(L==R){
		return;
	}
	int mid=(L+R)>>1;
	build(L,mid,i<<1);
	build(mid+1,R,i<<1|1);
}
void change(int X,int K,int i){
	if(tree[i].l==tree[i].r){
		tree[i].maxv=max(tree[i].maxv,K);
		return;
	}
	if(tree[i<<1].r>=X){
		change(X,K,i<<1);
	}
	else{
		change(X,K,i<<1|1);
	} 
	tree[i].maxv=max(tree[i<<1].maxv,tree[i<<1|1].maxv);
}
int ask(int L,int R,int i){
	if(L<=tree[i].l&&tree[i].r<=R)
		return tree[i].maxv;
	int cnt=0;
	if(tree[i<<1].r>=L)
		cnt=ask(L,R,i<<1);
	if(tree[i<<1|1].l<=R)
		cnt=max(cnt,ask(L,R,i<<1|1));
	return cnt;
}
signed main(){
	int n,k,i,ans=1;
	cin>>n>>k;
	for(i=1;i<=n;i++){
		cin>>a[i];
	}
	build(1,300002,1);
	for(i=1;i<=n;i++){
		dp[i]=max(1ll,ask(max(0ll,a[i]-k)+1,min(300000ll,a[i]+k)+1,1)+1);
		change(a[i]+1,dp[i],1);
		ans=max(ans,dp[i]);
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 32856
#include<iostream>
#include<vector>
#include<queue>
#include<stack>
#include<string>
#include<cmath>
#include<algorithm>
#include<bitset>
#include<map>
#include<functional>
#include<set>

#pragma region
using namespace std;
#define FOR(i,r,n) for(ll i = (ll)(r); i < (ll)(n); i++)
#define RFOR(i,r,n) for(ll i=(ll)(n-1);i>=r;i--)
#define ALL(x) x.begin(),x.end()
#define RALL(x) x.rbegin(),x.rend()
#define PB(a,n) FOR(i,0,n){ll buf; scanf("%lld",&buf); a.pb(buf); }
#define LOWER(a,x) lower_bound(ALL(a), x) - a.begin() - 1;
#define COUNT(a,x)  upper_bound(ALL(a), x) - lower_bound(ALL(a), x);
#define MCOUNT(a,x,y) upper_bound(ALL(a), y) - lower_bound(ALL(a), x);
#define INF 111111111111111111
#define MOD 1000000007
#define pb push_back
#define F first
#define S second
typedef long long int ll;
typedef long double ld;
typedef vector<ll> vll;
typedef pair<ll, ll> pll;
ll n = 0, m = 0, ans = 0, sum = 0, cnt = 0, tmp = 0, ma = 0, mi = 0;
string s;
bool flag, ok;
ll dx[4] = { 1,-1,0,0 }, dy[4] = { 0,0,1,-1 };
ll ddx[8] = { 1,-1,0,0,1,1,-1,-1 }, ddy[8] = { 0,0,1,-1,1,-1,1,-1 };
#pragma endregion
#define MAX 111111


int main(void) {
  cin >> s;
  n = s.length();
  if (s[0] == s[n - 1]) {
	if (n % 2 == 0) {
	  cout << "First" << endl;
	}
	else {
	  cout << "Second" << endl;
	}
  }
  else {
	if (n % 2 == 0) {
	  cout << "Second" << endl;
	}
	else {
	  cout << "First" << endl;
	}
  }

  return 0;
}


Measured memory_bytes: 512
#include<stdio.h>

int main(void)
{
	int i,d,E;
	
	while(scanf("%d",&d)!=EOF)
	{
    E=0;
	for(i=d;i<=600-d;i+=d)
	{
	    E+=d*i*i;
	}
	printf("%d\n",E);
	}
	return 0;
}

Measured memory_bytes: 596
#include<bits/stdc++.h>
#define endl "\n";
using namespace std;
int main()
{
    int N;
    set<string> s;
    cin>>N;
    for(int i=0;i<N;i++)
    {
        string t;
        cin>>t;
        s.insert(t);
    }
    cout<<s.size()<<endl;
}


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

int main() {
	int n;cin>>n;
	string s,t;cin >>s>>t;
	string out = "";
	for(int i=0;i<n;++i){
		out += s.substr(i,1);
		out += t.substr(i,1);
	}
	cout << out << endl;
	return 0;
}

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


#define	SIZE	64


void Init(int *box)
{
	int i;

	for(i = 0; i < SIZE; i++)
		box[i]  = 0;
}


void Test(int *box, int x)
{
	if(box[x])
		printf("1\n");
	else
		printf("0\n");
}


void Set(int *box, int x)
{
	box[x] = 1;
}


void Clear(int *box, int x)
{
	box[x] = 0;
}


void Flip(int *box, int x)
{
	if(box[x])
		box[x] = 0;
	else
		box[x] = 1;
}


void All(int *box)
{
	int i;

	for(i = 0; i < SIZE; i++){
		if(box[i] == 0){
			printf("0\n");
			return;
		}
	}

	printf("1\n");
}


void Any(int *box)
{
	int i;

	for(i = 0; i < SIZE; i++){
		if(box[i]){
			printf("1\n");
			return;
		}
	}

	printf("0\n");
}


void None(int *box)
{
	int i;

	for(i = 0; i < SIZE; i++){
		if(box[i]){
			printf("0\n");
			return;
		}
	}

	printf("1\n");
}


void Count(int *box)
{
	int count = 0;
	int i;

	for(i = 0; i < SIZE; i++)
		if(box[i])
			count++;

	printf("%d\n", count);
}


void Val(int *box)
{
	unsigned long long int sum = 0;
	int i;

	for(i = 0; i < SIZE; i++)
		sum += (unsigned long long int)(pow(2, i) * box[i]);

	printf("%llu\n", sum);
}


int main()
{
	int q, command, x;
	int bit_box[SIZE];
	int i;

	scanf("%d", &q);

	Init(bit_box);

	for(i = 0; i < q; i++){
		scanf("%d", &command);

		switch(command){
			case 0:
			// test
				scanf("%d", &x);
				Test(bit_box, x);
				break;
			case 1:
			//set
				scanf("%d", &x);
				Set(bit_box, x);
				break;
			case 2:
			// clear
				scanf("%d", &x);
				Clear(bit_box, x);
				break;
			case 3:
			// flip
				scanf("%d", &x);
				Flip(bit_box, x);
				break;
			case 4:
			// all
				All(bit_box);
				break;
			case 5:
			// any
				Any(bit_box);
				break;
			case 6:
			// none
				None(bit_box);
				break;
			case 7:
			// count
				Count(bit_box);
				break;
			case 8:
			// val
				Val(bit_box);
				break;
		}
	}

	return 0;
}


Measured memory_bytes: 2084
#include<bits/stdc++.h>
#define N 20
using namespace std;
int n,A[N],q,m;
bool ans;

void dfs(int x,int s){
  if(x==n){
    if(s==m)ans=true;
    return;
  }
  dfs(x+1,s+A[x]);
  dfs(x+1,s);
}

int main(){
  cin>>n;
  for(int i=0;i<n;i++)cin>>A[i];
  cin>>q;
  while(q--){
    cin>>m;
    ans=0;
    dfs(0,0);
    if(ans)cout<<"yes"<<endl;
    else cout<<"no"<<endl;
  }
  return 0;
}

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

#define fast_io() ios_base :: sync_with_stdio(0); cin.tie(0); cout.tie(0)

const ll LINF = LLONG_MAX, MOD = 1e9 + 7, N = 1e5 + 5, LG = 20;
const int INF = INT_MAX;
const db PI = acos(-1), EPS = 1 / db(1e6);

void test() {
    int n; cin >> n;
    int a[n + 1];
    for(int i = 1; i <= n; ++i) cin >> a[i];
    vector<int> b;
    for (int i = 1; i <= n; i += 2) {
        int k = (a[i] ^ a[i + 1]);
        b.push_back(k);
    }
    int k = 0;
    for (int i = 0; i < b.size(); ++i) {
        k = (k ^ b[i]);

    }
    for (int i = 1; i <= n; ++i) {
        a[i] = k ^ a[i];
    }
    for (int i = 1; i <= n; ++i) cout << a[i] << "\n";
}

int main() {
      fast_io();
      #ifdef HOME
            freopen("input.txt", "r", stdin);
            freopen("output.txt", "w", stdout);
      #endif
      cout << fixed << setprecision(15);
      int t = 1;
      // cin >> t;
      for (int i = 1; i <= t; ++i) {
          test();
      }
      #ifdef HOME
          cout << "Time: " << (int)(clock() * 1000. / CLOCKS_PER_SEC) << "ms";
      #endif
      return 0;
}


Measured memory_bytes: 4540
#include <iostream>
#include <map>
#include <vector>
#include <algorithm>
#include <cmath>

using namespace std;

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

    vector<int64_t> a(N), b(N);
    for(int i = 0; i < N; ++i) cin >> a[i];
    for(int i = 0; i < N; ++i) cin >> b[i];

    int64_t ans = 0;
    for(int i = 0; i <= 29; ++i){
        vector<int64_t> a2(N);
        vector<int64_t> b2(N);
        int64_t T = 1 << i;
        for(int j = 0; j < N; ++j){
            a2[j] = a[j] % (2 * T);
            b2[j] = b[j] % (2 * T);
        }
        sort(b2.begin(), b2.end());
        bool res = false;
        for(int j = 0; j < N; ++j){
            auto l = lower_bound(b2.begin(), b2.end(), T * 2 - a2[j]);
            auto r = lower_bound(b2.begin(), b2.end(), T - a2[j]);
            auto l2 = lower_bound(b2.begin(), b2.end(), T * 4 - a2[j]);
            auto r2 = lower_bound(b2.begin(), b2.end(), T * 3 - a2[j]);
            res ^= (l - r + l2 - r2) & 1;
        }
        ans |= res << i;
    }
    cout << ans << endl;
}

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

int main(){
    int M, D; cin >> M >> D;
    
    int cnt = 0;
    for(int i = 1; i <= M; ++i) {
        for(int k = 20; k <= D; ++k) {
            int ten = k / 10;
            int one = k - (ten * 10);
            if(ten * one == i && ten >= 2 && one >= 2) {
                cnt++;
            }
        }
    }

    cout << cnt << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string S;
  cin >> S;

  int cnt = 0; int temp = 0;
  for(int i=0;i<S.length() ;i++){
    if(S[i] == 'A' || S[i] == 'C' || S[i] == 'T' || S[i] == 'G'){
      temp++;
    }else{
      temp = 0;
    }

    cnt = max(cnt,temp);
  }

  cout << std::setprecision(20);
  cout << cnt << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int n;
  cin>>n;set<int> s;int x;
  for(int i=0;i<n;i++){cin>>x;s.insert(x);}
  if(s.size()==n)cout<<"YES";
  else cout<<"NO";
  
}

Measured memory_bytes: 9600
#include<bits//stdc++.h>
using namespace std;
int main(){
  int n;
  while(cin>>n){
    vector<int> v;
    for(int i=10;i>=0;i--){
      if(n>=(1<<i)){
	     n-=(1<<i);
	     v.push_back(1<<i);
      }
    }sort(v.begin(),v.end());
    cout << v[0];
    for(int i=1;i<v.size();i++) cout << " " << v[i];
    cout << endl;
  }
}


Measured memory_bytes: 3056
// Undone
#include <bits/stdc++.h>
#define int long long
#define double long double
#define INF 1e18
#define MOD 1000000007
using namespace std;
signed main() {
  int N; cin >> N;
  vector<int> A(N+1), B(N);
  for (int i = 0; i < N+1; i++) cin >> A[i];
  for (int i = 0; i < N; i++) cin >> B[i];
  
  int ans = 0;
  for (int i = 0; i < N; i++) {
    if (B[i] > A[i]) {
      ans += A[i];
      B[i] -= A[i];
      if (B[i] > A[i+1]) {
        ans += A[i+1];
        A[i+1] = 0;
      } else {
        ans += B[i];
        A[i+1] -= B[i];
      }
    } else {
      ans += B[i];
    }
  }
  cout << ans << endl;
}



Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define RFOR(i,a,b) for (int i = (b)-1; i >= (a); --i)
#define rep(i,n) FOR(i,0,(n))
#define REPS(i,n) FOR(i,1,(n)+1)
#define RREP(i,n) RFOR(i,0,(n))
#define rng(x) (x).begin(),(x).end()
#define rrng(x) (x).rbegin(),(x).rend()
#define debug(x) cout << #x << " = " << (x) << endl;
#define SORT(x) sort(rng(x))
#define RSORT(x) sort(rrng(x))
#define SUM(x) accumulate(rng(x),0)
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define uni(x) x.erase(unique(rng(x)),x.end())
#define SP << " " <<
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using pii = pair<int, int>;
using tiii = tuple<int, int, int>;
const int mod = 1000000007;
const double EPS = 1e-9;
const int INF = (1<<30)-1;
const ll INFLL = (1LL<<62)-1;
const int dx[4] = {1,0,-1,0};
const int dy[4] = {0,1,0,-1};
//cout << fixed << setprecision(10);

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

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

// 素因数分解
// 12 -> [(2,2), (3,1)] (2^2*3^1)

vector<pair<ll,int>> factorize(ll n) {
  vector<pair<ll,int>> res;
  for (ll i = 2; i*i <= n; ++i) {
    if (n%i) continue;
    res.emplace_back(i,0);
    while (n%i == 0) {
      n /= i;
      res.back().second++;
    }
  }
  if (n != 1) res.emplace_back(n,1);
  return res;
}

int main () {
  ll a, b;
  cin >> a >> b;
  ll g = gcd(a,b);
  auto f = factorize(g);
  cout << f.size()+1 << endl;

  return 0;
}

Measured memory_bytes: 256
/*
 *        ~Botay~
 *    code by kazalika
 */

#include <bits/stdc++.h>

using namespace std;

typedef pair<int, int> pii;
typedef long long ll;
typedef pair<ll, ll> pll;
typedef long double ldb;
typedef double db;
typedef vector<int> vint;
typedef vector<ll> vll;
#define forn(a, i, n) for (int i = (a); i < (n); ++i)
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define sz(x) int(x.size())
const int N = 3e6 + 6;



int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  cout.precision(20);

  int a, b;
  cin >> a >> b;
  cout << a * b;

}

Measured memory_bytes: 3668
#include <stdio.h>

int main(void){
  int n, i;
  int flg=1;
  int count=0;
  int ans=0;
  long a[200];


  scanf("%d", &n);
  for (i=0; i<n; i++){
    scanf("%ld",&a[i]);
  }
  /*
  for (i=0; i<n; i++){
    printf("a[%d]=%ld\n",i,a[i]);
  }
  */
  while(flg==1){
    count=0;
    for (i=0; i<n;i++){
      if (a[i]%2==0){
        count++;
        //printf("OK: a[%d]=%ld, count = %d\n",i,a[i], count);
      }
    }
    if (count==n){
      for (i=0; i<n;i++){
        a[i]=a[i]/2;
        //printf("OK: a'[%d]=%ld\n",i,a[i]);
      }
      ans++;
    }
    else{
      flg=0;
    }
  }

  printf("%d\n",ans);
  return(0);
}



Measured memory_bytes: 1728
n, m = map(int, input().split())
l_lst = list()
for i in range(m):
    l_lst.append(input().split())

for i in range(0, len(l_lst)):
    for j in range(0, len(l_lst[i])):
        l_lst[i][j] = int(l_lst[i][j])

max_lst = list()
min_lst = list()
for i in range(0, len(l_lst)):
    max_lst.append(l_lst[i][0])
    min_lst.append(l_lst[i][1])

max_int = max(max_lst)
min_int = min(min_lst)

cnt = 0
for i in range(1, n+1):
    if max_int <= i and i <= min_int:
        cnt += 1

print(cnt)

Measured memory_bytes: 33836
#include<bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int (i)=0;(i) < (N); (i)++)
#define all(V) V.begin(), V.end()
using i64 = int_fast64_t;
using P = pair<int,int>;

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

    int N, M;
    cin >> N >> M;
    vector<vector<int>> G(N);
    vector<vector<int>> visited(N, vector<int>(3, -1));

    int u, v;
    rep(i, M){
        cin >> u >> v; u--, v--;
        G[u].emplace_back(v);
    }
    int S ,T;
    cin >> S >> T; S--, T--;

    queue<pair<int,int>> que;
    que.emplace(make_pair(S, 0));
    visited[S][0] = 0;
    while(!que.empty() && visited[T][0] == -1){
        int v, md;
        tie(v, md) = que.front(); que.pop();
        const int nd = (md+1) % 3;
        for(int nxt : G[v]){
            if(visited[nxt][nd] != -1) continue;
            visited[nxt][nd] = visited[v][md] + 1;
            que.emplace(make_pair(nxt, nd));
        }
    }

    int ans = visited[T][0];
    if(ans != -1) ans /= 3;
    cout << ans << endl;
}


Measured memory_bytes: 11264
/* C++14 (Clang 3.8.0) for AtCoder */

#include <iostream>
#include <vector>
#include <string>
// #include <cmath>
// #include <math.h>
// #include <algorithm>
// #include "./Debug.h"

namespace AtCoder {
	using Input = std::vector<std::string>;
	using Num = std::vector<int>;

	Input input(void) {
		Input result;
		{
			std::string buf = "", row = "";
			std::getline(std::cin, buf);
			for (unsigned int i = 0; i < buf.size(); i++) {
				if (' ' == buf[i]) {
					result.push_back(row);
					row = "";
				} else {
					row += buf[i];
				}
			}
			result.push_back(row);
		}
		return result;
	}

	Num replaceToInteger(Input original = { "" }) {
		Num result;
		for (unsigned int i = 0; i < original.size(); i++) {
			result.push_back(atoi(original[i].c_str()));
		}
		return result;
	}
}

int main(void) {

	AtCoder::Num s = AtCoder::replaceToInteger(AtCoder::input());

	const int a = s[0], b = s[1];

	int ans = 0;

	if ((a + b) < (a - b)) {
		if ((a - b) < (a * b)) {
			ans = a * b;
		} else {
			ans = a - b;
		}
	} else {
		if ((a + b) < (a * b)) {
			ans = a * b;
		} else {
			ans = a + b;
		}
	}

	printf("%d\n", ans);

	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
typedef long long ll;
const int N=100100;
int s[N],n;
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
		scanf("%d",s+i);
	std::sort(s+1,s+n+1);
	int max=-1,dmax=-1;
	for(int i=n,j;i;i=j-1)
	{
		for(j=i;s[j-1]==s[i];j--);
		if(i==j)continue;
		if(max<0)max=s[i];
		else if(dmax<0){dmax=s[i];break;}
		if(i-j+1>=4){dmax=s[i];break;}
	}
	if(max>0 && dmax>0)printf("%lld\n",(ll)max*dmax);
	else printf("0\n");
	return 0;
}


Measured memory_bytes: 640