akhauriyash/Code-Regression huggingface dataset:
/*
 * Author: Anmol Choudhary
 */
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>
#include<bits/stdc++.h>
//using namespace __gnu_pbds;
using namespace std;
#define ll long long
#define pb push_back
#define vi vector<int>
#define rep0(a,b) for(int a=0;a<b;a++)
#define rep1(a,b) for(int a=1;a<=b;a++)
#define repp(a,b,c) for(int a=b;a<c;a++)
#define in insert
#define len length()
#define si size()
#define lb lower_bound
#define ub upper_bound
#define beg begin()
#define en end()
#define f first
#define s second
#define pr(a) cout<<a
#define pr2(a,b) cout<<a<<" "<<b<<"\n"
#define nx cout<<"\n"
#define int long long
const ll mod = 1000000007;
const ll maxn = 500005;
const ll mm = 1e+18;
void solve()
{
    string s;
    cin>>s;
    if(s[0]=='7'||s[1]=='7'||s[2]=='7') cout<<"Yes";
    else cout<<"No";
}
signed main()
{
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    int t=1;
    //cin>>t;
    while(t--){
        solve();
        //nx;
    }
    return 0;
}

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

int main() {
	string P;
	int i, c = 0;
	cin >> P;
	for (i = 0; i < 3; i++){
		if (P[i] == P[i + 1])
			c++;
}
	if(c>=1)
		cout << "Bad" << endl;
	else
		cout << "Good" << endl;
	return 0;
}


Measured memory_bytes: 256
import sys

def pokakito(num_line):
    if not num_line and flag == 1:
        result_lis.append(check_num)
        return True
    for num in num_line:
        if three(num, num_line): return True
        if two(num, num_line): return True
        if straight(num, num_line): return True
    
def three(num, num_line):
    count = 0
    for check in num_line[:3]:
        if check == num:
            count += 1
    else:
        if count == 3:
            if pokakito(num_line[3:]): return True

def two(num, num_line):
    global flag
    count = 0
    for check in num_line[:2]:
        if check == num:
            count += 1
    else:
        if count == 2:
            flag += 1
            if pokakito(num_line[2:]): return True
            flag -= 1

def straight(num, num_line):
    num_lis = [num,num+1,num+2]
    for i in range(3):
        for check in num_lis:
            if check < 0 or (not check in num_line):
                for i in range(3):
                    num_lis[i] = num_lis[i]-1
                break
        else:
            for n in num_lis:
                index = 0
                while num_line:
                    if num_line[index] == n:
                        del num_line[index]
                        break
                    index += 1
            else:
                if pokakito(num_line): return True
            
flag = 0
result_lis = []
check_num = 0
for input_line in sys.stdin:
    for i in range(9):
        check_num = i+1
        input_line = input_line.rstrip()
        line = sorted(input_line + str(check_num))
        line = ''.join(line)
        index = line.find(str(check_num))
        if line[index:index+5] == str(check_num)*5:
            continue
        pokakito([int(char) for char in line])
        result = sorted([str(num) for num in result_lis])
        flag = 0
    else:
        if result_lis:
            print ' '.join(result)
        else:
            print 0
    flag = 0
    result_lis = []
    check_num = 0

Measured memory_bytes: 4336
#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()
#define chmin(x,y) x = min(x,y)
#define chmax(x,y) x = max(x,y)
typedef pair<int, int> P;
typedef long long ll;
const int INF = 1001001001;
const ll LINF = 1001002003004005006ll;
const ll MOD = 1e9+7;

const int D = 80*160+10;    // -80*160:0, 0:D, 80*160:2D
const int D2 = D*2;

int main() {
	int H, W;
	cin >> H >> W;
    vector<vector<int>> A(H, vector<int>(W));
    rep(i, H) rep(j, W) {
        int x;
        cin >> x;
        A[i][j] =x;
    }
    rep(i, H) rep(j, W) {
        int x;
        cin >> x;
        A[i][j] = abs(x - A[i][j]);
    }
    vector<vector<bitset<D2>>> dp(H, vector<bitset<D2>>(W));
    dp[0][0][D-A[0][0]] = 1;
    dp[0][0][D+A[0][0]] = 1;
    rep(i, H) rep(j, W) {
        if (i) {
            dp[i][j] |= dp[i-1][j] << A[i][j];
            dp[i][j] |= dp[i-1][j] >> A[i][j];
        }
        if (j) {
            dp[i][j] |= dp[i][j-1] << A[i][j];
            dp[i][j] |= dp[i][j-1] >> A[i][j];
        }
    }

    int ans = D2;
    rep(i,D2) if (dp[H-1][W-1][i]) {
        ans = min(ans, abs(i-D));
    }
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 20736
#include <bits/stdc++.h>
#define rep(i,n)for(int i=0;i<(n);i++)
using namespace std;
 
int main(){
	vector<int>a(3),b(3);
	cin>>a[0]>>a[1]>>a[2]>>b[0]>>b[1]>>b[2];
	if(a<b)swap(a,b);
	if(vector<int>{a[1],a[2]}<=vector<int>{b[1],b[2]})cout<<a[0]-b[0]<<endl;
	else cout<<a[0]-b[0]+1<<endl;
}

Measured memory_bytes: 3132
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int num = Integer.parseInt(sc.next());
    int[] a = new int[num];
    String ans = "YES";
    for (int i = 0; i<num; i++){
      a[i] = Integer.parseInt(sc.next());
    }
    Arrays.sort(a);
    for (int j = 1;j<num; j++){
      if(a[j-1] == a[j]){
        ans = "NO";
        break;
      }
    }
    System.out.println(ans);
  }
}

Measured memory_bytes: 50940
//#include <climits>
#include <vector>
#include <iostream>
#include <algorithm>
//#include <sstream>
// #include <string>
using namespace std;




bool check(vector<int> &w, int k, long long P) {
    int truck = 0; //何台目のトラックか？
    int i = 0; //荷物の添字
    while(truck < k) {
        //1台のトラックに荷物を積む
        long long weight = 0;
        while(weight + w[i] <= P) { //最大積載量まで積み続ける
            weight += w[i];
            i++;

            //全ての荷物を積めたとき(最大積載量が多すぎる)
            if(i == (int)w.size()) {
                return true;
            }
        }

        //最大積載量を超えたら次のトラックへ
        truck++;
    }

    //全ての荷物を積めないとき(最大積載量が少なすぎる)
    return false;
}


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

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

    long long left = 0;               //最小の最大積載量
    long long right = 100000 * 10000; //最大の最大積載量
    while(left < right) {
        long long mid = (left + right) / 2;

        // cout << "---\n";
        // printf("left  : %d\n", left);
        // printf("right : %d\n", right);
        // printf("mid   : %d\n", mid);

        if(check(w, k, mid)) { //最大積載量が多い
            right = mid;
        } else {  //最大積載量が少ない
            left = mid+ 1;
        }
    }

    cout << left << endl;

    return 0;
}




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

int main(){
  string S,T;
  cin >> S;
  T=S;
  reverse(T.begin(),T.end());
  int count=0;
  for(int i=0;i<S.size();i++){
    if(S.at(i)!=T.at(i)){
      count++;
    }
  }
  cout << count/2 << endl;
}

Measured memory_bytes: 3620
#include <bits/stdc++.h>
#define rep(i, n) for (int i=0; i<n; ++i)
#define rep1(i, n) for (int i=1; i<=n; ++i)
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
using namespace std;
typedef long long ll;
constexpr ll  MOD = (1e9+7);
constexpr int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
constexpr int lcm(int a, int b) { return a / gcd(a, b) * b; }

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;
}
ll factorial(ll n, ll m=2) {
    // calculate n!
    m = max(2LL, m);
    ll rtn = 1;
    for (ll i=m; i<=n; i++) {
        rtn = (rtn * i);
    }
    return rtn;
}
ll modinv(ll a, ll m) {
    ll b = m, u = 1, v = 0;
    while (b) {
        ll t = a / b;
        a -= t * b;
        swap(a, b);
        u -= t * v;
        swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}
ll modpow(ll a, ll n) {
    ll res = 1;
    while (n > 0) {
        if (n & 1)
            res = res * a % MOD;
        a = a * a % MOD;
        n >>= 1;
    }
    return res;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    double n, k; cin >> n >> k;
    cout << setprecision(10) << k * pow(k-1, n-1) << endl;
    return 0;
}

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

int main() {
	
	int a, b, c, n;
	
	cin >> a >> b;
	/*
	cin >> n

	cin >> a >> b >> c;
	
	*/
	
	
	cout << max(a+b, max(a - b, a * b)) << endl;
	return 0;
}

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

// 型定義
typedef long long ll;
typedef pair<ll, ll> P;

// forループ
#define REP(i,n) for(ll i=0; i<(ll)(n); ++i)

// 定数宣言
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

// グラフ表現
using Graph = vector<vector<int>>;

// グラフの辺表現
using Edge = map<pair<int,int>,int>;

// n次元配列の初期化。第２引数の型のサイズごとに初期化していく。
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

// 最大公約数
ll gcd(ll a,ll b){
   if (a%b == 0) return(b);
   else return(gcd(b, a%b));
}

// 最小公倍数
ll lcm(ll a, ll b){
    return a*b/gcd(a, b);
}

int main()
{
    cout << fixed << setprecision(15);
    ll N;
    string A, B, C;

    cin >> N;
    cin >> A;
    cin >> B;
    cin >> C;

    ll count = 0;
    REP(i, N){
        if((A[i] != B[i]) && (B[i] != C[i]) && (C[i] != A[i])){
            count += 2;
            continue;
        }
        if((A[i] == B[i]) && (B[i] != C[i]) && (C[i] != A[i])){
            count++;
            continue;
        }
        if((A[i] != B[i]) && (B[i] == C[i]) && (C[i] != A[i])){
            count++;
            continue;
        }
        if((A[i] != B[i]) && (B[i] != C[i]) && (C[i] == A[i])){
            count++;
            continue;
        }
    }

    cout << count << endl;
    return 0;
}

Measured memory_bytes: 256
import Control.Applicative
import Control.Monad

main = do
    [n, m, x] <- map read . words <$> getLine
    as <- map read . words <$> getLine
    putStrLn $ show $ ans n m x as

ans :: Int -> Int -> Int -> [Int] -> Int
ans n m x as = min left right
    where
        left = length $ takeWhile (< x) as
        right = length $ dropWhile (< x) as


Measured memory_bytes: 892
#include<iostream>
#include<vector>
#include<algorithm>
#include<iomanip>
#include<utility>
#include<iomanip>
#include<map>
#include<queue>
#include<cmath>
#include<cstdio>

#define rep(i,n) for(int i=0; i<(n); ++i)
#define pai 3.1415926535897932384

using namespace std;
using ll =long long;
using P = pair<int,int>;

int main(int argc, const char * argv[]) {
    
    ll a, b, c, d;
    cin >> a >> b >> c >> d;
    
    ll Ans = -9223372036854775808;
    
    Ans = max(a*c, Ans);
    Ans = max(a*d, Ans);
    Ans = max(b*c, Ans);
    Ans = max(b*d, Ans);
    
    cout << Ans << endl;
    
    return 0;
}


Measured memory_bytes: 3192
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double db;
typedef pair<ll,ll> P;
#define pb push_back
#define mp make_pair
#define fr(i,n) for(int i=0;i<n;i++)
#define Fr(i,n) for(int i=0;i++<n;)
#define ifr(i,n) for(int i=n-1;i>=0;i--)
#define iFr(i,n) for(int i=n;i>0;i--)

int main(){
  ll n,t,a[100010],m[100010]={(ll)1e10},M=0,ans=0;
  cin>>n>>t;
  Fr(i,n){
    cin>>a[i];
    m[i]=min(m[i-1],a[i]);
    M=max(M,a[i]-m[i]);
  }
  Fr(i,n) if(M==a[i]-m[i]) ans++;
  cout<<ans<<endl;
}

Measured memory_bytes: 1792
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
import sys

input = sys.stdin.readline
a = input().split()
ans = []

a = ','.join(a)
for i in range(3):
    if a[i] == '1':
        ans.append(9)
    else:
        ans.append(1)

print(str(ans[0]) + str(ans[1]) + str(ans[2]))


Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
#define ALL(x) x.begin(),x.end()
#define rep(i,n) for(int i=0;i<n;i++)
#define debug(v) cout<<#v<<":";for(auto x:v){cout<<x<<' ';}cout<<endl; 
#define INF 1000000000
#define mod 1000000007
typedef long long ll;
const ll LINF = 1001002003004005006ll;
int dx[]={1,0,-1,0};
int dy[]={0,1,0,-1};
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
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; }

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

    int a,b;cin>>a>>b;
    if(a>b) swap(a,b);
    if(a==1 and b==2) cout<<3<<endl;
    if(a==1 and b==3) cout<<2<<endl;
    if(a==2 and b==3) cout<<1<<endl;
    return 0;
}


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

int main() {
	int n;
	cin >> n;
	int v[n], c[n], result = 0;
	for (int i = 0; i < n; i++) {
		cin >> v[i];
	}
	for (int i = 0; i < n; i++) {
		cin >> c[i];
	}
	for (int i = 0; i < n; i++) {
		result += max(0, v[i] - c[i]);
	}
	cout << result << endl;

}



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

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

int N, W;
int v[110], w[110];

int dp[110][10100];

int main() {

    cin >> N >> W;

    rep(i, N) {
        cin >> v[i] >> w[i];
    }
    rep(i, W+1) {
        dp[0][i] = 0;
    }

    rep(i, N) {
        rep(k, W+1) {
            if (k >= w[i]) dp[i + 1][k] = max(dp[i][k - w[i]] + v[i],dp[i][k]);
            else dp[i + 1][k] = dp[i][k];
        }
    }
    cout << dp[N][W] << "\n";
}


Measured memory_bytes: 7104
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define all(obj) (obj).begin(),(obj).end()
typedef pair<int,int> P;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n,m;cin>>n>>m;
    priority_queue<int> pq;
    priority_queue<P,vector<P>,greater<P>> pqmini;
    rep(i,n){
        int a,b;cin>>a>>b;
        pqmini.push(make_pair(a,b));
    }
    int tot=0;
    for(int i=1;i<=m;i++){
        while(1){
            P k=pqmini.top();
            if(k.first!=i)break;
            pq.push(k.second);
            pqmini.pop();
        if(pqmini.empty())break;            
        }
        if(pq.empty())continue;
        tot+=pq.top();pq.pop();
    }
    cout<<tot<<endl;
    return 0;
}


Measured memory_bytes: 1908
#include <iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<math.h>
using namespace std;
typedef long long ll;
#define int long long
typedef vector<int> VI;
#define REP(i,n) for(int i=0;i<n;i++)
#define eREP(i,n) for(int i=0;i<=n;i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define eFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define SORT(c) sort((c).begin(),(c).end())
#define rSORT(c) sort((c).rbegin(),(c).rend())
#define LB(x,a) lower_bound((x).begin(),(x).end(),(a))
#define UB(x,a) upper_bound((x).begin(),(x).end(),(a))
#define INF 1000000000
#define LLINF 9223372036854775807
#define mod 1000000007
//vector<vector<int> > dp;
//vector<vector<vector<int> > > vvvi;
//dp=vector<vector<int> >(N, vector<int>(M,0));
//vector<pair<int,int> > v;
//v.push_back(make_pair(x,y));



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

	int H, W;
	cin >> H >> W;
	vector<string> S(H);
	REP(i, H)
		cin >> S[i];

	int cnt[26] = { 0 };
	REP(i, H) {
		REP(j, W) {
			cnt[S[i][j] - 'a']++;
		}
	}
	int g1, g2, g4;
	if (H % 2 == 0 && W % 2 == 0)
		g1 = 0, g2 = 0, g4 = (H / 2) * (W / 2);
	else if (H % 2 == 0)
		g1 = 0, g2 = H / 2, g4 = (H / 2) * (W / 2);
	else if (W % 2 == 0)
		g1 = 0, g2 = W / 2, g4 = (H / 2) * (W / 2);
	else
		g1=1,g2=W/2+H/2,g4= (H / 2) * (W / 2);

	
	
	REP(j, g4) {
		REP(i, 26) {
			if (cnt[i]>=4) {//cnt[i] % 4 == 0 && 
				//cout << i <<" "<<"K"<< endl;
				cnt[i] -= 4;
				continue;
			}
		}
	}
	REP(j, g2) {
		REP(i, 26) {
			if (cnt[i]>=2) {//cnt[i] % 4 == 2 && 
				cnt[i] -= 2;
				break;
			}
		}
	}
	REP(j,g1){
		REP(i, 26) {
			if ( cnt[i]>=1) {//(cnt[i] % 4 == 1 || cnt[i] % 4 == 3) &&
				cnt[i]--;
				break;
			}
		}
	}

	
	REP(i, 26) {
		if (cnt[i] > 0) {
			cout << "No" << endl;
			return 0;
		}
	}
	cout << "Yes" << endl;

	return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
//#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
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; }
//---------------------------------------------------------------------------------------------------
/*---------------------------------------------------------------------------------------------------
　　　　　　　　　　　 ∧＿∧  
　　　　　 ∧＿∧ 　（´<_｀ ）　 Welcome to My Coding Space!
　　　　 （ ´_ゝ`）　/　 ⌒i     @hamayanhamayan
　　　　／　　　＼　 　  |　|     
　　　 /　　 /￣￣￣￣/　　|  
　 ＿_(__ﾆつ/　    ＿/ .| .|＿＿＿＿  
　 　　　＼/＿＿＿＿/　（u　⊃  
---------------------------------------------------------------------------------------------------*/














int N, A, B;
//---------------------------------------------------------------------------------------------------
void _main() {
	cin >> N >> A >> B;
	int ans = min(N * A, B);
	cout << ans << endl;
}







Measured memory_bytes: 256
/*********************************************JMD**********************************************/
//                                  |\  |     | |   |   /\                                   //
    //                              | \ |     | |---|  /--\                              //
        //                          |  \| |___| |   | /    \1999                     //
/*******************************************************************************************/
#include <bits/stdc++.h>
using namespace std;

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

#define mp make_pair
#define pb push_back
#define pf push_front
#define ss second
#define ff first
#define mem(x,val) memset(x,val,sizeof(x))
#define forr(i,a,b) for(ll i=a;i<b;i++)
#define f(i,n) forr(i,0,n)
#define sz(x) ll((x).size())
#define all(x) ((x).begin(),(x).end())
#define asc(x) ((int)(x))
#define precision(x) cout<<fixed<<setprecision((x));

const ll mod=1e9 + 7;

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

void solve()
{
    ll n,m;
    cin>>n>>m;


    ll a[100001];
   mem(a,0);
   ll d[100007];
   d[0]=0;
    mem(d,0);
    f(i,m)
    {
        ll x,y;
        cin>>x>>y;
        x--;
        d[x]+=1;
        d[y]-=1;
    }

    a[0]=d[0];

    for(ll i=1;i<n;i++)
    {
        a[i]=d[i]+a[i-1];
    }


   ll ans=0;
   f(i,n) if(a[i]==m) ans++;
   cout<<ans<<endl;


    return;
}

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

    ll t=1;
    //cin>>t;
    clock_t launch=clock();

    while(t--)
    {
        solve();
    }

    clog<<((long double)(clock()-launch)/CLOCKS_PER_SEC)<<"\n";
}


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

#define ll          long long
#define pb          push_back
#define endl        '\n'
#define mii         map<ll,ll>
#define pii         pair<ll,ll>
#define vi          vector<ll>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (ll)x.size()
#define hell        1000000007
#define INF         (1ll<<60)
#define rep(i,a,b)  for(ll i=a;i<=b;i++)
#define rrep(i,a,b)  for(ll i=a;i>=b;i--)
#define ios ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define time        cerr << "\nTime elapsed: " << 1000 * clock() / CLOCKS_PER_SEC << "ms\n";
ll gcd(ll a, ll b) { return b == 0 ? a : gcd(b, a % b); }
ll lcm(ll a, ll b) { return a * (b / gcd(a, b)); }
const int N=100005;
void solve(){
    ll n;
    cin>>n;
    ll temp=n/500;
    ll ans=temp*1000;
    n-=temp*500;
    temp=n/5;
    ans+=temp*5;
    cout<<ans;
}
signed main()
{
    ios
    int TESTS=1;
    //cin>>TESTS;
    while(TESTS--){
        solve();
    }
    time
    return 0;
}

Measured memory_bytes: 256
program main
	implicit none
	integer :: n
	integer, allocatable :: v(:)
	integer :: i, baketu(1:2,1:100010),baketu_num(1:2,1:100010), ans
	
	read(*, *) n
	allocate(v(1:n))
	read(*, *) v
	
	baketu = 0
	do i = 1, n, 2
		baketu(1,v(i)) = baketu(1,v(i)) + 1
	end do
	do i = 2, n, 2
		baketu(2,v(i)) = baketu(2,v(i)) + 1
	end do
	
	call heapsort2(100010,baketu(1,:),baketu_num(1,:))
	call heapsort2(100010,baketu(2,:),baketu_num(2,:))
	
	if(baketu_num(1,100010) /= baketu_num(2,100010)) then
		ans = n - (baketu(1,100010) + baketu(2,100010))
	else
		ans = n - max(baketu(1,100010)+baketu(2,100009),baketu(1,100009)+baketu(2,100010))
	end if
	
	write(*, *) ans
	
	contains
	subroutine heapsort2(n,array,turn)
		implicit none
		integer,intent(in)::n
		integer,intent(out)::turn(1:n)
		integer,intent(inout)::array(1:n)

		integer::i,k,j,l,m
		double precision::t
  
		if(n.le.0)then
			write(6,*)"Error, at heapsort"; stop
		endif
		if(n.eq.1)return

		do i=1,N
			turn(i)=i
		enddo

		l=n/2+1
		k=n
		do while(k.ne.1)
			if(l.gt.1)then
				l=l-1
				t=array(l)
				m=turn(l)
			else
				t=array(k)
				m=turn(k)
				array(k)=array(1)
				turn(k)=turn(1)
				k=k-1
				if(k.eq.1) then
					array(1)=t
					turn(1)=m
					exit
				endif
			endif
			i=l
			j=l+l
			do while(j.le.k)
				if(j.lt.k)then
					if(array(j).lt.array(j+1))j=j+1
				endif
				if (t.lt.array(j))then
					array(i)=array(j)
					turn(i)=turn(j)
					i=j
					j=j+j
				else
					j=k+1
				endif
			enddo
			array(i)=t
			turn(i)=m
		enddo
		
		return
	end subroutine heapsort2
end program main

Measured memory_bytes: 3696
#include<bits/stdc++.h>
using namespace std;
void func(int nn);
int n,m,x;
int kin[12],rk[12][12];
int sum,box[12],MIN;
int main(void){
	int i,j;
	cin>>n>>m>>x;
	for(i=0;i<n;i++){
		cin>>kin[i];
		for(j=0;j<m;j++){
			cin>>rk[i][j];
		}
	}
	// for(i=0;i<n;i++){
		// cout<<kin[i];
		// for(j=0;j<m;j++){
			// cout<<" "<<rk[i][j];
		// }
		// cout<<endl;
	// }
	sum=0;
	for(i=0;i<n;i++)	box[i]=0;
	MIN=INT_MAX;
	func(0);
	if(MIN==INT_MAX)	cout<<-1<<endl;
	else				cout<<MIN<<endl;
	return 0;
}
void func(int nn){
	int i,flg;
	// cout<<"nn="<<nn<<endl;
	// for(i=0;i<n;i++)	cout<<box[i]<<" ";
	// cout<<endl;
	if(nn==12){
		flg=1;
		for(i=0;i<m;i++){
			if(x>box[i])	flg=0;
		}
		if(flg==1)	MIN=min(MIN,sum);
	}
	else{
		func(nn+1);
		sum+=kin[nn];
		for(i=0;i<m;i++)	box[i]+=rk[nn][i];
		func(nn+1);
		sum-=kin[nn];
		for(i=0;i<m;i++)	box[i]-=rk[nn][i];
	}
}
		
	


Measured memory_bytes: 3624
import sys; input = sys.stdin.buffer.readline
sys.setrecursionlimit(10**7)
from collections import defaultdict
mod = 10 ** 9 + 7; INF = float("inf")

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

class SegmentTree(object):
	#N:処理する区間の長さ
	def __init__(self, N):
		self.N = N
		self.N0 = 2 ** (N - 1).bit_length()
		self.initVal = 0
		self.data = [self.initVal] * (2 * self.N0)

	# 区間クエリの種類
	def calc(self, a, b):
		return a + b

	# セグメント木の中身をリストAで初期化
	def initialize(self, A):
		for i in range(self.N):
			self.data[self.N0 - 1 + i] = A[i]
		for i in range(self.N0 - 2, -1, -1):
			self.data[i] = self.calc(self.data[2 * i + 1], self.data[2 * i + 2])

	#k番目の値をxに更新
	def update(self, k, x):
		k += self.N0 - 1
		self.data[k] = x
		while k > 0:
			k = (k - 1) // 2
			self.data[k] = self.calc(self.data[2 * k + 1], self.data[2 * k + 2])

	# k番目の値を取得
	def pointQuery(self, k):
		return self.data[k + self.N0 - 1]

	# k番目の値にxを加算
	def add(self, k, x):
		k += self.N0 - 1
		self.data[k] += x
		while k > 0:
			k = (k - 1) // 2
			self.data[k] = self.calc(self.data[2 * k + 1], self.data[2 * k + 2])

	#区間[l, r]の演算値
	def query(self, l, r):
		L = l + self.N0; R = r + self.N0 + 1
		m = self.initVal
		while L < R:
			if R & 1:
				R -= 1
				m = self.calc(m, self.data[R - 1])
			if L & 1:
				m = self.calc(m, self.data[L - 1])
				L += 1
			L >>= 1; R >>= 1

		return m

def main():
	N, Q = getlist()
	A = getlist()
	Seg = SegmentTree(N)
	Seg.initialize(A)
	for i in range(Q):
		q, a, b = getlist()
		if q == 0:
			Seg.add(a, b)
		else:
			res = Seg.query(a, b - 1)
			print(res)

if __name__ == '__main__':
	main()

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

#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;
typedef long double ld;
const ll INF = 1e18;

int main() {
  ll a;
  string b;
  cin >> a >> b;
  int nb = (b[0] - '0') * 100 + (b[2] - '0') * 10 + (b[3] - '0');
  cout << a * nb / 100 << endl;
  return 0;
}


Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
 
int main() {
 string a;
  cin>>a;
  int c=1000;
  for(int i=0;i<a.size()-2;i++){
    if(c>abs((a.at(i)-'0')*100+(a.at(i+1)-'0')*10+(a.at(i+2)-'0')-753))
    c=abs((a.at(i)-'0')*100+(a.at(i+1)-'0')*10+(a.at(i+2)-'0')-753);
}
cout<<c;
}


Measured memory_bytes: 256
def main():
    import sys
    input = sys.stdin.readline
    sys.setrecursionlimit(10**7)
    from collections import Counter, deque
    #from collections import defaultdict
    from itertools import combinations, permutations, accumulate, groupby
    #from itertools import product
    from bisect import bisect_left,bisect_right
    from heapq import heapify, heappop, heappush
    from math import floor, ceil
    #from operator import itemgetter

    #inf = 10**17
    #mod = 10**9 + 7

    n = int(input())
    a = list(map(int, input().split()))
    if len(set(a)) == len(a):
        print('YES')
    else:
        print('NO')

if __name__ == '__main__':
    main()

Measured memory_bytes: 92756
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1LL<<62
#define inf 1000000007

int main() {
	ll h,w;
	cin>>h>>w;
	ll a[502][502];
	for(ll i=0;i<h;i++){
		for(ll j=0;j<w;j++){
			cin>>a[i][j];
		}
	}
	vector<ll>sy,sx,ey,ex;
	for(ll i=0;i<h-1;i++){
		for(ll j=0;j<w;j++){
			if(a[i][j]%2!=0){
				a[i+1][j]++;
				sy.push_back(i);
				sx.push_back(j);
				ey.push_back(i+1);
				ex.push_back(j);
			}
		}
	}
	for(ll j=0;j<w-1;j++){
		if(a[h-1][j]%2!=0){
			a[h-1][j+1]++;
			sy.push_back(h-1);
			sx.push_back(j);
			ey.push_back(h-1);
			ex.push_back(j+1);
		}
	}
	cout << sy.size()<<endl;
	for(ll i=0;i<sy.size();i++){
		cout << sy[i]+1<<" "<<sx[i]+1<<" "<<ey[i]+1<<" "<<ex[i]+1<<endl;
	}
	// your code goes here
	return 0;
}

Measured memory_bytes: 8148
function Main(input){
  var N = input.split(" ")[0];
  var K = input.split(" ")[1];
  N = parseInt(N,10);
  K = parseInt(K,10);

  var jud = N%K === 0;
  if(jud){
    console.log(0);
  }else{
    console.log(1);
  }
}
  Main(require('fs').readFileSync('/dev/stdin','utf8'));



Measured memory_bytes: 22204
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define ll long long
#define pb(a) push_back(a)
#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(){
    string s;
    int w;
    cin >> s >> w;
    for (int i = 0;i < s.size() ;i += w) {
        cout << s[i];
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i,k,n)  for(int i = (k);i < (n);++i)
#define REP(i,n)    FOR(i,0,n)
#define ALL(x)      begin(x),end(x)

using namespace std;
using vecint = vector<int>;
using ll = int64_t;

bool ok(const vecint& a, const int th, vecint& v) {
  ll n = a.size();
  v.assign(n*4, 0);
  int offset = n*2;
  ll cnt = 0;
  ll sum = 0;
  REP(i,n) {
    v[offset] += 1;
    if (a[i] >= th) {
      offset -= 1;
      sum -= v[offset];
    } else {
      sum += v[offset];
      offset += 1;
    }
    cnt += sum;
  }
  ll m = n * (n+1) / 2;
  ll mid = m/2 + 1;
  return cnt >= mid;
}

int main()
{
  int n;
  scanf("%d", &n);
  vecint a(n);
  REP(i,n) scanf("%d", &a[i]);
  int hi = 1000000001;
  int lo = 0;
  vecint v(n*4);
  while ((hi - lo) > 1) {
    int mid = (hi + lo) / 2;
    if (ok(a, mid, v)) {
      hi = mid;
    } else {
      lo = mid;
    }
  }
  printf("%d\n", lo);
  return 0;
}


Measured memory_bytes: 2176
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <iomanip>
#include <map>
#include <set>
#include <tuple>
#include <unordered_map>
#include <iterator>
#include <string>
#include <limits>

using namespace std;

using i64 = int64_t;
using P = pair<i64, i64>;
i64 mod = 1000000007;
int int_max = 2147483647;
int max_n = 1e5;


int main(int argc, char **argv) {
    string s;
    cin >> s;
    int n = s.size();
    std::vector<int> v(2019, 0);
    v[0] = 1;
    int carry{0};
    int pw{1};
    for (int i=0; i<n; ++i) {
        int next = s[n-i-1] - '0';
        carry = carry + pw * next;
        carry %= 2019;

        pw = (pw * 10) % 2019;

        ++v[carry];
    }

    i64 ans{0};
    for (auto i : v) {
        ans += (i * (i-1) / 2);
    }

    cout << ans << endl;

    return 0;
}


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

int main(){
    
    while(1){
       int a,b;
       string op;
       cin >> a >> op >>b;
       if ( op == "?") break;
       

       int ans;
       if ( op == "+") ans = a+b;
       if ( op == "-") ans=a-b;
       if ( op == "*") ans = a*b;
       if ( op == "/") ans = a/b;

       cout << ans <<endl;

       }
}


Measured memory_bytes: 3128
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 h = sc.nextInt();
		int m = sc.nextInt();
		
		//0時からの分針の角度を求める
		double Mangle = (m*360.0)/60.0;
		//0時からの時針の角度を求める
		double Hangle = (h*60.0+m)*360.0/(12.0*60.0);
		
		//時針の角度-分針の角度で辺a,bの間の角度を求める
		double MHangle = 0;
		//180°を超えている場合は360からマイナスする
		//例：(9:00の場合0時からだと270°となるので引いて90°となる)
		if(Hangle-Mangle>180) {
			MHangle = 360-(Hangle-Mangle);
		}else {
			MHangle = Hangle-Mangle;
		}
		
		//求めた角度からcosを求める
		//(一度ラジアンに変換する必要があるため[角度*(Math.PI/180)]とする)
		double cosA = Math.cos(MHangle*(Math.PI/180.0));
		
		//余弦定理から答えを求める Math.sqrt√(平方根)で求める
		double answer = Math.sqrt((a*a)+(b*b)-(2*a*b*cosA));

		System.out.println(answer);

	}
}

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

int main() {
  long N,X;cin>>N>>X;
  vector<long> x(N);
  for(long i=0;i<N;i++){
    long t;cin>>t;
    x[i]=abs(t-X);
  }
  if(N==1){
    cout<<x[0]<<endl;
    return 0;
  }
  sort(x.begin(),x.end());
  long ans=1;
  for(long i=x[0];i>0;i--){
    bool p=true;
    for(long j=1;j<N;j++){
      if(x[j]%i!=0){
        p=false;
        break;
      }
    }
    if(p){
      ans=i;
      break;
    }
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 1024
#include<stdio.h>

#define N 10000
#define Q 500

int main(){
  int n,q;
  int s[N],t[Q];
  int i,j,count=0;

  scanf("%d",&n);
  for(i=0;i<n;i++)scanf("%d",&s[i]);
  scanf("%d",&q);
  for(i=0;i<q;i++)scanf("%d",&t[i]);

  for(i=0;i<q;i++){/*t*/
    for(j=0;j<n;j++){/*s*/
      if(t[i]==s[j]){
	count++;
	break;
      }
    }
  }
  printf("%d\n",count);
  return 0;
}


Measured memory_bytes: 2108
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>

using namespace std;

//----------------------- Print Function ----------------------//

inline void print() {
    cout << endl;
}
template <typename First, typename... Rest>
void print(const First &first, const Rest &... rest) {
    cout << first << ' ';
    print(rest...);
}

template <typename T>
void print(const vector<T> &v) {
    for (auto e : v) cout << e << ' ';
    cout << endl;
}

//------------------------- Libraries -------------------------//

vector<long long> sieve(long long N) {
    vector<long long> res;
    vector<long long> is_prime(N+1, true);
    is_prime[0] = is_prime[1] = false;
    for (long long i = 2; i <= N; i++) {
        if (is_prime[i]) {
            res.push_back(i);
            for (long long j = 2 * i; j <= N; j+=i) {
                is_prime[j] = false;
            }
        }
    }
    return res;
}

//--------------------------- Solve ---------------------------//

void solve() {
    int N; cin >> N;
    vector<long long> primes = sieve(55555);
    vector<long long> ans;
    int cnt = 0;
    for (long long prime : primes) {
        if (prime % 5 == 2) {
            ans.push_back(prime);
            cnt++;
        }
        if (cnt == N) break;
    }
    print(ans);
}

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

    solve();

    return 0;
}

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

using namespace std;

typedef long long ll;

#ifdef iq
  mt19937 rnd(228);
#else
  mt19937 rnd(chrono::high_resolution_clock::now().time_since_epoch().count());
#endif

int main() {
#ifdef iq
  freopen("a.in", "r", stdin);
#endif
  ios::sync_with_stdio(0);
  cin.tie(0);
  string s;
  cin >> s;
  string str = "";
  string was = "";
  int ans = 0;
  for (int i = 0; i < (int) s.size(); i++) {
    str += s[i];
    if (was.size() != str.size() || was[(int) str.size() - 1] != str.back()) {
      was = str;
      str = "";
      ans++;
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 720
N,M,C=map(int,input().split())
B=input()
a=[]
for j in range (N):
    a.append([])
    c=input()
    d=c.split()
    a[j]=d
    for k in range (M):
        a[j][k]=int(a[j][k])
B=B.split()
for i in range(len(B)):
    B[i]=int(B[i])
count=0
ans=0
for o in range (len(a)):     
    for l in range (len(B)):
        count=count+a[o][l]*B[l]
    if count+C>0:
        ans+=1
        count=0
    else:
        count=0
print(ans)

Measured memory_bytes: 3064
#include <iostream>
#include <cstring>
using namespace std;
int main(){
int n,len;
string a;
cin>>n;
getline(cin,a);
for(int i=0;i<n;i++){
getline(cin,a);
len=a.size();
for(int o=0;o<=len;o++)
if(a[o]=='H'){
if(a[o+1]=='o')
if(a[o+2]=='s')
if(a[o+3]=='h')
if(a[o+4]=='i')
if(a[o+5]=='n')
if(a[o+6]=='o')
a[o+6]='a';}
cout<<a<<endl;}
return 0;
}

Measured memory_bytes: 1200
#include <iostream>
using namespace std;
using ll = long long;
#define rep(i,n) for(int i=0,_i=(n);i<_i;++i)
#define rrep(i,n) for(long long i=(n);i>=0;--i)

int A[3000];
ll dp[3001][3001]; // dp[l][r] = 左からl個、右からr個とった状態からスタートしたときのX-Y
const ll INF = 1e15;
int main() {
  int N; cin >> N;
  rep(i, N) cin >> A[i];
  rep(i, N+1) rep(j, N+1) dp[i][j] = 0;

  rrep(l, N) rrep(r, N) {
    if (l + r >= N)
      continue;
    dp[l][r] = ((l+r) % 2 == 0)
      ? max(dp[l+1][r] + A[l], dp[l][r+1] + A[N-1-r])
      : min(dp[l+1][r] - A[l], dp[l][r+1] - A[N-1-r]);
  }

  cout << dp[0][0] << endl;
  return 0;
}


Measured memory_bytes: 70656
import java.util.*;

public class Main {
	static Scanner sc = new Scanner(System.in);
	public static void main(String[] args) {
		while (true) {
			StringBuilder sb = new StringBuilder(sc.next());
			if (sb.toString().equals("-")) {break;}
			else {
				int n = sc.nextInt();
				for (int i=0; i<n; i++) {
					int a = sc.nextInt();
					String s = sb.substring(0,a);
					sb.delete(0,a);
					sb.append(s);
				}
				System.out.println(sb);
			}
		}
	}
}


Measured memory_bytes: 26232
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int n;
  cin>>n;
  long long a[n];
  for(int i=0;i<n;i++)
    cin>>a[i];
  long long ans=0;
  for(int i=1;i<n;i++)
     {
       if(a[i]<a[i-1])
       {
       ans+=a[i-1]-a[i];
       a[i]=a[i-1];
       }
     }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 5140
#include<iostream>
#include<stdio.h>
#include<vector>
#include<algorithm>
#include<set>
#include<string>
#include<map>
#include<string.h>
#include<complex>
#include<math.h>
#include<queue>
#include<time.h>
using namespace std;
typedef long long int llint;
typedef pair<int, int> pint;
typedef vector<bool> vbool;
typedef vector<int> vint;
typedef vector<vint> vvint;
typedef vector<llint> vllint;
typedef vector<vllint> vvllint;
typedef vector<pair<int, int>> vpint;
typedef vector<pair<llint, llint>> vpllint;
#define rep(i,n) for(int i=0;i<n;i++)
#define drep(i,n) for(int i=n-1;0<=i;i--)
#define yes(ans) if(ans)cout<<"yes"<<endl;else cout<<"no"<<endl;
#define Yes(ans) if(ans)cout<<"Yes"<<endl;else cout<<"No"<<endl;
#define YES(ans) if(ans)cout<<"YES"<<endl;else cout<<"NO"<<endl;
#define POSSIBLE(ans) if(ans)cout<<"POSSIBLE"<<endl;else cout<<"IMPOSSIBLE"<<endl;
#define Pi 3.1415926535897932384626
#define coutans rep(i, ans.size())cout << ans[i] << endl;

class UnionFind {
public:
	//親の番号を格納する。親だった場合は-(その集合のサイズ)
	vector<int> Parent;

	//作るときはParentの値を全て-1にする
	//こうすると全てバラバラになる
	UnionFind(int N) {
		Parent = vector<int>(N, -1);
	}

	//Aがどのグループに属しているか調べる
	int root(int A) {
		if (Parent[A] < 0) return A;
		return Parent[A] = root(Parent[A]);
	}

	//自分のいるグループの頂点数を調べる
	int size(int A) {
		return -Parent[root(A)];//親をとってきたい
	}

	//AとBをくっ付ける
	bool connect(int A, int B) {
		//AとBを直接つなぐのではなく、root(A)にroot(B)をくっつける
		A = root(A);
		B = root(B);
		if (A == B) {
			//すでにくっついてるからくっ付けない
			return false;
		}

		//大きい方(A)に小さいほう(B)をくっ付けたい
		//大小が逆だったらひっくり返しちゃう。
		if (size(A) < size(B)) swap(A, B);

		//Aのサイズを更新する
		Parent[A] += Parent[B];
		//Bの親をAに変更する
		Parent[B] = A;

		return true;
	}
};

//aとbの最大公約数を求めるよ
long long GCD(long long a, long long b) {
	if (b == 0) return a;
	else return GCD(b, a % b);
}

// 返り値: a と b の最大公約数
// ax + by = gcd(a, b) を満たす (x, y) が格納される
long long extGCD(long long a, long long b, long long& x, long long& y) {
	if (b == 0) {
		x = 1;
		y = 0;
		return a;
	}
	long long d = extGCD(b, a % b, y, x);
	y -= a / b * x;
	return d;
}

bool check(int a, int b) {
	return a > b;
}

// mod. m での a の逆元 a^{-1} を計算する
long long modinv(long long a, long long m) {
	long long b = m, u = 1, v = 0;
	while (b) {
		long long t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}

//aCbを1000000007で割った余りを求める
llint convination(llint a, llint b) {
	llint ans = 1;
	for (llint i = 0; i < b; i++) {
		ans *= a - i;
		ans %= 1000000007;
	}
	for (llint i = 1; i <= b; i++) {
		ans *= modinv(i, 1000000007);
		ans %= 1000000007;
	}
	return ans;
}

int main() {
	int n, m, l;
	cin >> n >> m >> l;
	vvllint a(n, vllint(m));
	vvllint b(m, vllint(l));
	vvllint c(n, vllint(l, 0));
	rep(i, n)rep(j, m)cin >> a[i][j];
	rep(i, m)rep(j, l)cin >> b[i][j];
	rep(i, n) {
		rep(j, l) {
			rep(k, m) {
				c[i][j] += a[i][k] * b[k][j];
			}
		}
	}
	rep(i, n) {
		rep(j, l) {
			cout << c[i][j];
			if (j == l - 1)cout << endl;
			else cout << " ";
		}
	}
	return 0;
}


Measured memory_bytes: 3288
#include<stdio.h>
#include <iostream>
#include <string.h>

using namespace std;

typedef struct{
	char name[11];
	int time;
}Process;

class ProcessQueue{
public:
	ProcessQueue(int size):
		m_size(size),
		m_head(0),
		m_tail(0),
		number(0)
	{
		m_process = new Process[m_size];
	};

	~ProcessQueue(){
		delete[] m_process;
	};

	void enQueue(Process process){
		//strcpy(m_process[m_tail].name,process.name);
		//m_process[m_tail].time = process.time;

		m_process[m_tail] = process;	//=??§??£??\????

		number++;

		if(m_tail < m_size-1){
			m_tail++;
		}else{	//?????°?????????
			m_tail = 0;
		}
	};

	Process deQueue(){
		number--;
		if(m_head < m_size-1){
			m_head++;
			return m_process[m_head-1];
		}else{	//?????°?????????
			m_head = 0;
			return m_process[m_size-1];
		}
	};

	int getNumber(){
		return number;
	}

private:
	int m_head;
	int m_tail;
	int m_size;
	int number;
	Process* m_process;

};

int main(){

	int n,q,totaltime=0;
	scanf("%d%d",&n,&q);

	ProcessQueue queue(n);

	Process tmp;
	for(int i = 0; i < n; i++){
		scanf("%s%d",&tmp.name,&tmp.time);
		queue.enQueue(tmp);
	}

	while(queue.getNumber() != 0){
		tmp = queue.deQueue();
		if(tmp.time - q > 0){
			totaltime += q;
			tmp.time -= q;
			queue.enQueue(tmp);
		}else{
			totaltime += tmp.time;
			printf("%s %d\n",tmp.name,totaltime);
		}
	}

}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define FORR(i, m, n) for (int i = m; i >= n; i--)
#define pb(a) push_back(a)
using namespace std;
typedef long long ll;

int main()
{
    ll N;
    cin >> N;
    vector<vector<ll>> data(N, vector<ll>(3));

    int a = -1;
    REP(i, N)
    {
        cin >> data.at(i).at(0) >> data.at(i).at(1) >> data.at(i).at(2);
        if (data.at(i).at(2) > 0)
            a = i;
    }

    for (ll cx = 0; cx < 101; cx++)
    {
        for (ll cy = 0; cy < 101; cy++)
        {
            ll H = data.at(a).at(2) + abs(data.at(a).at(0) - cx) + abs(data.at(a).at(1) - cy);
            bool flag = true;
            REP(i, N)
            {
                ll h = H - abs(data.at(i).at(0) - cx) - abs(data.at(i).at(1) - cy);
                h = max(h, 0LL);
                if (data.at(i).at(2) != h)
                {
                    flag = false;
                    break;
                }
            }

            if (flag == true)
            {
                cout << cx << ' ' << cy << ' ' << H << endl;
                return 0;
            }
        }
    }
}

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

using db = long double;
using ll = long long;
using vi = vector <int>;
#define op operator
#define pb push_back

const db eps = 1e-12L;
int sgn(db a, db b = 0) {
	a -= b;
	return (a > eps) - (a < -eps);
}

struct poi {
	db x, y;
	auto& r() { return cin >> x >> y; }
};

int main() {
	cout << fixed << setprecision(9);
	ios :: sync_with_stdio(0);

	for(poi a, b, c, d; a.r(); ) {
		b.r(); c.r(); d.r();
		if(max(a.x, c.x) <= min(b.x, d.x) &&
			max(a.y, c.y) <= min(b.y, d.y))
			cout << "YES\n";
		else
			cout << "NO\n";
	}

	return 0;
}

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


int main(){
    int N, K;
    cin >> N >> K;
    vector<int> box(N);
    rep(i, N){
        cin >> box.at(i);
    }
    for(int i = K ; i < N; i++){
        if(box.at(i) > box.at(i-K)){
            cout << "Yes" << endl;
        } else {
            cout << "No" << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 4048
#include<stdio.h>
#include<iostream>
#include<iomanip>
#include<string>
#include<vector>
#include<queue>
#include<stack>
#include<map>
#include<set>
#include<algorithm>
#include<string>
#include<math.h>
using namespace std;

const int MAX = 100000;
 
int main(){
    int N,D;
    cin >> N >> D;
    cout << (N - 1) / (D * 2 + 1) + 1 << endl;
    return 0;
}

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

int main(void) {
  int N, sum = 0;
  cin >> N;
  int tmp = N;
  while (tmp > 0) {
    sum += tmp % 10;
    tmp /= 10;
  }
  cout << (N % sum == 0 ? "Yes" : "No") << endl;
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<math.h>
#include<vector>
#include<array>
#include<algorithm>
#include<numeric>
#include<map>
#include<queue>
#include<deque>
#include<set>
#include<cstdio>
#include<cstring>
#include<string>
using namespace std;
typedef long long ll;
typedef vector<int> vec;
typedef vector<vector<int>> mat;

int N;
int ans=pow(10,9);
set <int> S={0,1,2,3,4,5,6,7,8,9};
void func(int s){
    if(s>=N){
        ans=min(ans,s);
        return;
    }
    for(auto itr=S.begin();itr!=S.end();itr++){
        func(10*s+*itr);
    }
}

int main(){
    int K;cin>>N>>K;
    for(int i=0;i<K;i++){
        int d;cin>>d;
        S.erase(d);
    }
    //S:使える数
    for(auto itr=S.begin();itr!=S.end();itr++){
        if(*itr==0)continue;
        func(*itr);
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
/*
 * @Author: clorf 
 * @Date: 2020-08-31 20:27:12 
 * @Last Modified by: clorf
 * @Last Modified time: 2020-08-31 21:33:54
 */
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<cmath>
#include<algorithm>
#include<ctime>
#define INF 1e9
using namespace std;
const int maxn=200010;
const double Pi=acos(-1.0);
template<class T>void read(T &x)
{
    x=0;int f=0;char ch=getchar();
    while(ch<'0'||ch>'9') {f|=(ch=='-');ch=getchar();}
    while(ch>='0'&&ch<='9'){x=(x<<1)+(x<<3)+(ch^48);ch=getchar();}
    x=f?-x:x;
    return;
}
int n,q,cnt;
int fa[maxn];
long long p[maxn],ans;
struct edge
{
    int x;
    int y;
    long long z;
}s[maxn],e[maxn<<1];
inline bool cmp(edge a,edge b)
{
    return a.z<b.z;
}
inline int sub(int x)
{
    return (x+1)%n;
}
int getfa(int x)
{
    if(fa[x]==x)
        return x;
    return fa[x]=getfa(fa[x]);
}
int main()
{
    memset(p,0x3f,sizeof(p));
    scanf("%d%d",&n,&q);
    for(int i=1;i<=q;i++)
    {
        scanf("%d%d%lld",&s[i].x,&s[i].y,&s[i].z);
        e[++cnt]=(edge){s[i].x,s[i].y,s[i].z};
        p[s[i].x]=min(p[s[i].x],s[i].z+1);
        p[s[i].y]=min(p[s[i].y],s[i].z+2);
    }
    int now=s[1].x,tot=2*n;
    long long sum=p[now];
    while(tot)
    {
        if(sum<p[now])
            p[now]=sum;
        else
            sum=p[now];
        sum+=2;
        now=sub(now);
        tot--;
    }
    for(int i=0;i<n;i++)
        e[++cnt]=(edge){i,sub(i),p[i]};
    for(int i=0;i<=n;i++)
        fa[i]=i;
    sort(e+1,e+cnt+1,cmp);
    for(int i=1;i<=cnt;i++)
    {
        int x=getfa(e[i].x);
        int y=getfa(e[i].y);
        if(x!=y)
        {
            fa[x]=y;
            ans+=e[i].z;
        }
    }
    printf("%lld",ans);
    return 0;
}


Measured memory_bytes: 19580
//q086.cpp
//Sun Sep  6 16:35:59 2020

#include <iostream>
#include <string>
#include <queue>
#include <map>
#include <unordered_map>
#include <vector>
#include <algorithm>
#include <math.h>
#include <set>
#define INTINF 2147483647
#define LLINF 9223372036854775807
#define MOD 1000000007
#define rep(i,n) for (int i=0;i<(n);++i)

using namespace std;
using ll=long long;
typedef pair<int,int> P;

int par[60]; //親。1個上の親でしか無いことに注意。グループの根はfindで呼び出す。
int treesize[60]; //木の深さ

//n要素で初期化
void init(int n){
	for (int i=0;i<n;i++){
		par[i] = i;
		treesize[i] = 1;
	}
}

//木の根（親）を見つける。再帰することで、グループの根まで辿る。
int find (int x){
	if (par[x] == x){
		return x;
	} else {
		return par[x] = find(par[x]);
	}
}

//xとyの属する集合の併合
void unite(int x, int y){
	x = find(x);
	y = find(y);
	if (x == y) {
		return;
	} 

	if(treesize[x] > treesize[y]){
		par[y] = x;
		treesize[x] += treesize[y];
	}else {
		par[x] = y;
		treesize[y] += treesize[x];
	}
	// if (treerank[x] < treerank[y]){
	// 	par[x] = y;
	// } else {
	// 	par[y] = x;
	// 	if (treerank[x] == treerank[y]){
	// 		treerank[x]++;
	// 	}
	// }
}

//xとyが同じグループに属するか判定
bool same(int x, int y){
	return find(x) == find(y);
}

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

	vector<int> a(m,0);
	vector<int> b(m,0);
	rep(i,m){
		cin >> a[i] >> b[i];
		a[i]--;
		b[i]--;
	} 

	int count = 0;
	int ans = 0;
	while(count<m){
		init(n);
		rep(i,m){
			if(i==count)continue;
			unite(a[i],b[i]);
		}
		// set<int> st;
		// rep(i,n){
		// 	st.insert(find(i));
		// }
		int tmp = n;
		rep(i,n){
			tmp = min(tmp,treesize[find(i)]);
		}
		if (tmp!=n){
			ans++;
		}
		count++;
	}

	cout << ans << endl;
//	printf("%.4f\n",ans);
}

Measured memory_bytes: 3616
#include<bits/stdc++.h>
using namespace std;
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define pb push_back
#define ll long long


void test_case()
{
    ll dp[100001]={};
    ll n,k;
    cin>>n>>k;
    dp[0]=1;
    ll a[n];
    for(ll i=0;i<n;i++)
        cin>>a[i];
    for(ll i=0;i<n;i++)
    {
        if(a[i]<=k)
        dp[a[i]]=1;
    }
    for(ll i=0;i<=k;i++)
    {
        if(dp[i]==0)
        {
            for(ll j=0;j<n;j++)
            {
                if(i+a[j]<=k)
                    dp[i+a[j]]=1;
            }
        }
    }
    if(dp[k]==0)
    {
        cout<<"Second";
    }
    else
        cout<<"First";
}

int main()
{
    fastio
//    int t;
//    cin>>t;
//    while(t--)
    test_case();
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
            #define ll long long
            #define ld long double
            using namespace std; 
            int gcd(int a, int b){
              	if (a == 0) 
           			return b;  
        		return gcd(b % a, a); 
            }
        	int lcm (int a, int b){
             	return a*b/gcd(a,b);
            }
            int main(){
            	ll x;
              	cin >> x;
              	cout << lcm(x, 360)/x << endl;
            	return 0;
            }

Measured memory_bytes: 3604