akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<math.h>
#include<algorithm>
#include<string>
using namespace std;

int a,b,c;
int main(void){
 cin>>a>>b>>c;
 if(a==1){
  if(b==1){cout<<"Open"<<endl;}
  else{cout<<"Close"<<endl;}
 }
 else{
  if(c==1){cout<<"Open"<<endl;}
  else{cout<<"Close"<<endl;}
 }
 return 0;
}

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

using namespace std;

int main() {

    long long a,b,k;
    cin >> a >> b >> k;

    long long mn = min(a,k);
    a -= mn;
    k -= mn;

    mn = min(b,k);
    b -= mn;
    k -= mn;
    cout << a << " " << b << "\n";
    return 0;
}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-
"""
D - Knapsack 1
https://atcoder.jp/contests/dp/tasks/dp_d

"""
import sys


def solve(N, W, items):
    ans = {0: 0}
    for w, v in items:
        u = dict()
        for x, y in ans.items():
            if x+w <= W and ans.get(x+w, 0) < y+v:
                u[x+w] = y+v
        ans.update(u)
    return max([v for v in ans.values()])


def main(args):
    N, W = map(int, input().split())
    items = [[int(i) for i in input().split()] for _ in range(N)]
    ans = solve(N, W, items)
    print(ans)


if __name__ == '__main__':
    main(sys.argv[1:])

Measured memory_bytes: 121272
#include <bits/stdc++.h>
#define FOR(i, a, b) for(int i=(a); i<(b); i++)
#define REP(i, n) FOR(i, 0, n)
#define all(x) (x).begin(), (x).end()
#define bit(x) (1L << (x))
using ll = long long;
using namespace std;

constexpr int nlim = 1e2, klim = 1e5;
int dp[2][klim+1];

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

  memset(dp, -1, sizeof(dp));

  dp[0][0] = 0; dp[1][0] = 1;

  REP(rest, k+1)REP(turn, 2){
    dp[turn][rest] = 0;
    REP(i, n){
      if(rest - a[i] < 0) continue;
      dp[turn][rest] |= !dp[1-turn][rest-a[i]];
    }
  }
  
  string ans = (dp[0][k])? "First": "Second";
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 1024
#include<iostream>
using namespace std;
int main(){
    int a,b;
    cin >> a >> b;
    
    if(a < b){
        cout << "a < b" << endl;
    }else if(a == b){
        cout << "a == b" << endl;
    }else{
        cout << "a > b" << endl;
    }

    return 0;
}


Measured memory_bytes: 3084
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int y,m,d;
	scanf("%d/%d/%d",&y,&m,&d);
	if(y<=2019&&m<=4&&d<=30)
	{
		cout<<"Heisei";
		return 0;
	}
	cout<<"TBD";
	return 0;
}


Measured memory_bytes: 256
# include "bits/stdc++.h"
using namespace std;
using LL = long long;
using ULL = unsigned long long;
const double PI = acos(-1);
template<class T>constexpr T INF() { return ::std::numeric_limits<T>::max(); }
template<class T>constexpr T HINF() { return INF<T>() / 2; }
template <typename T_char>T_char TL(T_char cX) { return tolower(cX); };
template <typename T_char>T_char TU(T_char cX) { return toupper(cX); };
typedef pair<LL, LL> pii;
const int vy[] = { -1, -1, -1, 0, 1, 1, 1, 0 }, vx[] = { -1, 0, 1, 1, 1, 0, -1, -1 };
const int dx[4] = { 0,1,0,-1 }, dy[4] = { 1,0,-1,0 };
int popcnt(unsigned long long n) { int cnt = 0; for (int i = 0; i < 64; i++)if ((n >> i) & 1)cnt++; return cnt; }
int d_sum(LL n) { int ret = 0; while (n > 0) { ret += n % 10; n /= 10; }return ret; }
int d_cnt(LL n) { int ret = 0; while (n > 0) { ret++; n /= 10; }return ret; }
LL gcd(LL a, LL 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; };
# define ALL(qpqpq)           (qpqpq).begin(),(qpqpq).end()
# define UNIQUE(wpwpw)        sort(ALL((wpwpw)));(wpwpw).erase(unique(ALL((wpwpw))),(wpwpw).end())
# define LOWER(epepe)         transform(ALL((epepe)),(epepe).begin(),TL<char>)
# define UPPER(rprpr)         transform(ALL((rprpr)),(rprpr).begin(),TU<char>)
# define FOR(i,tptpt,ypypy)   for(LL i=(tptpt);i<(ypypy);i++)
# define REP(i,upupu)         FOR(i,0,upupu)
# define INIT                 std::ios::sync_with_stdio(false);std::cin.tie(0)

int n;
LL x[101], y[101], h[101];
int idx;
int main(){
    INIT;
    cin >> n;
    REP(i, n)cin >> x[i] >> y[i] >> h[i];
    REP(i, n)if(h[i] != 0)idx = i;
    REP(i, 101){
        REP(j, 101){
            LL hi = h[idx] + abs(j - x[idx]) + abs(i - y[idx]);
            if(hi <= 0LL)continue;
            bool isok = true;
            REP(k, n){
                if(max(hi - abs(j - x[k]) - abs(i - y[k]), 0LL) != h[k])isok = false;
            }
            if(isok){
                cout << j << " " << i << " " << hi << endl;
                return 0;
            }
        }
    }
}

Measured memory_bytes: 256
#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()
typedef long long int ll;
typedef pair<int, int> P;
const ll MOD = 1e9+7, INF = 1e9;

int main()
{
    ll x; cin >> x;
    ll ans = x / 11 * 2;
    x %= 11;
    if(x > 6)ans += 2;
    else if(x > 0)ans += 1;
    cout << ans << endl;
    system("pause");
}

Measured memory_bytes: 504
#include<bits/stdc++.h>
#define int long long
using namespace std;
int vis[300005],ans;
 main()
{
   int x;
   cin>>x;
   for(int i =0; i<=2000 ; i++){
        int cur = i*i*i*i*i;
        int ans = cur-x;
        for(int j =-2000; j*j*j*j*j <=ans; j++){
            int todo = j*j*j*j*j;
            if(todo == ans){
                cout<<i<<" "<<j<<endl;
                return 0;
            }
        }
   }
	return 0;
}


Measured memory_bytes: 3632
#include<stdio.h>
#include<string.h>
int main()
{
	char arr[15],str[15];
	scanf("%s",arr);
	scanf("%s",str);
	int ln=strlen(arr);
	char sur[15];
	str[ln]='\0';
	int res=strcmp(arr,str);
	if(res==0)
	{
		printf("Yes\n");
	}
	else

	{
		printf("No\n");
	}
}

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

int main(void){
  string N;
  cin >> N;
  if(N[0] == N[1] && N[1] == N[2] ||N[1] == N[2] && N[2] == N[3] ){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
  return 0;
  
}


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


int N, M;


int main() {
    cin >> N >> M;
    vector<bool> AC(N, false);
    vector<int> WA(N, 0);
    int ac, wa;
    ac = wa = 0;
    rep(i, M) {
        int p;
        string s;
        cin >> p >> s;
        p--;
        if (AC[p]) continue;
        if (s == "AC") {
            AC[p] = true;
            ac++;
            wa += WA[p];
        }
        else WA[p]++;
    }
    cout << ac << " " << wa << endl;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
int gcd(int a,int b){
  if(a%b==0){
    return(b);
  }else{
    return(gcd(b,a%b));
  }
}
template<typename T>
vector<T> smallest_prime_factors(T n) {

    vector<T> spf(n + 1);
    for (int i = 0; i <= n; i++) spf[i] = i;


    for (T i = 2; i * i <= n; i++) {

        // 素数だったら
        if (spf[i] == i) {

            for (T j = i * i; j <= n; j += i) {

                // iを持つ整数かつまだ素数が決まっていないなら
                if (spf[j] == j) {
                    spf[j] = i;
                }
            }
        }
    }

    return spf;
}
int main(){
  int N;
  cin>>N;
  vector<int> A(N);
  for(int i=0;i<N;i++){
    cin>>A.at(i);
  }
  int G=A.at(0);
  for(int i=1;i<N;i++){
    G=gcd(G,A.at(i));
  }
  auto spf=smallest_prime_factors(1000000);
  unordered_map<int,int> mp;
  for(int i=0;i<N;i++){
    int R=A.at(i);
    unordered_map<int,int> C;
    while(R>1){
      //cout<<R<<" "<<spf[R]<<endl;
      if(C[spf[R]]==0)mp[spf[R]]++;
      C[spf[R]]++;
      R/=spf[R];
    }
  }
  int check=0;
  for(int i=2;i<=1000000;i++){
    if(mp[i]>=2){check++;}
  }
  if(check==0){cout<<"pairwise coprime"<<endl;}
  else if(G==1){cout<<"setwise coprime"<<endl;}
  else{cout<<"not coprime"<<endl;}
}

Measured memory_bytes: 50472
#include <iostream>
#include <string>
#include <cctype>
#define conv(c) ((c) - 'a')
#define Rconv(c) ((c) + 'a')
using namespace std;

int main(){
  int n;
  cin >> n;
  cin.ignore();
  while(n--){
    string s,t,ans; getline(cin,s);

    for(int i=0;i<=25;i++){
      for(int j=0;j<=25;j++){
	t = s; ans = "";
	for(int k=0;k<t.size();k++){
	  if(isalpha(t[k])) ans += Rconv((conv(t[k])*i+j) % 26);
	  else ans += t[k];
	}
	if(ans.find("that") != string::npos || ans.find("this") != string::npos) goto exit;
      }
    }
  exit:;
    cout << ans << endl;
  }
}

Measured memory_bytes: 1216
/*
このコード、と～おれ!
Be accepted!
∧＿∧　
（｡･ω･｡)つ━☆・*。
⊂　　 ノ 　　　・゜+.
　しーＪ　　　°。+ *´¨)
 　　　　　　　　　.· ´¸.·*´¨) ¸.·*¨)
		  　　　　　　　　　　(¸.·´ (¸.·'* ☆
					*/

#include <stdio.h>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstring>
#include <vector>
#include <numeric>
#include <iostream>
#include <random>
#include <map>
#include <unordered_map>
#include <queue>
#include <regex>

#pragma GCC optimize("Ofast")
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define rep1(i, n) for(int i = 1; i <= (n); ++i)
#define rep2(i, n) for(int i = 2; i < (n); ++i)
#define repr(i, n) for(int i = n; i >= 0; --i)
#define reprm(i, n) for(int i = n - 1; i >= 0; --i)
#define printynl(a) printf(a ? "yes\n" : "no\n")
#define printyn(a) printf(a ? "Yes\n" : "No\n")
#define printYN(a) printf(a ? "YES\n" : "NO\n")
#define printin(a) printf(a ? "possible\n" : "inposible\n")
#define printdb(a) printf("%.50lf\n", a)//少数出力
#define printdbd(a) printf("%.16lf\n", a)//少数出力(桁少なめ)
#define prints(s) printf("%s\n", s.c_str())//string出力
#define all(x) (x).begin(), (x).end()
#define allsum(a, b, c) ((a + b) * c / 2)//等差数列の和、初項,末項,項数
#define pb push_back
#define priq priority_queue
#define rpriq priq<int, vector<int>, greater<int>>
#define deg_to_rad(deg) (((deg)/360.0)*2.0*PI)
#define rad_to_deg(rad) (((rad)/2.0/PI)*360.0)
#define Please return
#define AC 0

using ll = long long;

constexpr int INF = 1073741823;
constexpr int MINF = -1073741823;
constexpr ll LINF = ll(4661686018427387903);
constexpr ll MOD = 1000000007;
const double PI = acos(-1);

using namespace std;

void scans(string& str) {
	char c;
	str = "";
	scanf("%c", &c);
	if (c == '\n')scanf("%c", &c);//最初の改行対策
	while (c != '\n' && c != -1) {
		str += c;
		scanf("%c", &c);
	}
}

void scanc(char& str) {
	char c;
	scanf("%c", &c);
	if (c == -1)return;
	while (c == '\n') {
		scanf("%c", &c);
	}
	str = c;
}

double acot(double x) {
	return PI / 2 - atan(x);
}

/*-----------------------------------------ここからコード-----------------------------------------*/


int main() {
	
	int a, b, c;
	scanf("%d%d%d", &a, &b, &c);
	printyn(min(a, b) <= c && c <= max(a, b));
	
	Please AC;
}


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



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

  char S[N]={ };
  for(int i=0; i<N; i++){
    char X;
    cin>>X;
    S[i]=X;

  }
  if(S[K-1]=='A')
  S[K-1]='a';
  else if(S[K-1]=='B')
  S[K-1]='b';
  else if(S[K-1]=='C') 
  S[K-1]='c';
  
  for(int i=0; i<N; i++)
  cout<<S[i];


  

}

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

#define rep(i,N) for(int i=0;i<N;i++)
#define rep2(i,N) for(int i=1;i<=N;i++)
using namespace std;
long long  INF=1e18;
long long mod=1e9+7;

struct UnionFind {
    vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2

    UnionFind(int N) : par(N) { //最初は全てが根であるとして初期化
        for(int i = 0; i < N; i++) par[i] = i;
    }

    int root(int x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
        if (par[x] == x) return x;
        return par[x] = root(par[x]);
    }

    void unite(int x, int y) { // xとyの木を併合
        int rx = root(x); //xの根をrx
        int ry = root(y); //yの根をry
        if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま
        par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
    }

    bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }
};


int main(){
/*クラスカル法

1.グラフの各頂点がそれぞれの木に属するように木の集合を生成
    =>頂点1個のみからなる木が頂点の個数だけ存在する状態

2.グラフのすべての辺を含む集合Eを生成

3.Eが空になるまで以下を繰り返す
    Eから重みが最小の辺eを取り出し、削除。
    その辺eがつながっている2つの頂点u,vが別々の木に属しているならば、
    辺eを森Fに加え、二つの木を連結しひとつの木にまとめる

4.最終的には森Fが最小全域木となる

*/
    int v_size;
    int e_size;
    cin>>v_size>>e_size;

    UnionFind uf(v_size);
    multimap<long long ,pair<int,int>>edge;
    rep(i,e_size){
        int s,t;
        long long w;
        cin>>s>>t>>w;
        edge.emplace(make_pair(w,make_pair(s,t)));
    }
    auto it=edge.begin();
    long long ans=0;

    while(it!=edge.end()){
        int one=it->second.first;
        int two=it->second.second;
        if(!uf.same(one,two)){
            ans+=it->first;
        }
        uf.unite(one,two);
        it++;
    }

    cout<<ans<<endl;
    return 0;

}
/*


*/



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

int main (){
    /*
    int N, K;
    cin >> N >> K;
    vector <int> a(N);
    for (int i=0; i<N; ++i) cin >> a[i];
    if(K-N==0){
        cout << 1 << endl;
    }else if((K-N)%(K-1) == 0){
        cout << (N-K)/(K-1)+1 << endl;
    }else{
        cout << (N-K)/(K-1)+2 << endl;
    }
    */
   int n,k; cin >> n >> k;
   vector<int> a(n); 
   if((n-k)%(k-1) == 0){
       cout << (n-k)/(k-1)+1 << endl;
   }else{
       cout << (n-k)/(k-1)+2 << endl;
   }
}

Measured memory_bytes: 3784
#include <iostream>
#include <cstdio>
#include <vector>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <cassert>
#include <utility>
#include <cmath>

using namespace std;

using lli = long long;

#ifdef DEBUG
#define debug(var) cout << (#var) << ": " << (var) << endl;
template<class T> void dump_array_impl(const T& a) {
  bool first = true;
  for (auto&& x : a) {
    if (!first) { cout << ", "; first = false; }
    cout << x;
  }
}
#define debug_array(a) cout<<(#a)<<": ";dump_array_impl(a);cout<<endl
#else
#define debug(var) ()
#define debug_array(a) ()
#endif

int main() {
  int x, y;
  cin >> x >> y;
  cout << (x + y/2) << endl;
  return 0;
}


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

using namespace std;

void Main() {
    int N;
    cin >> N;
    map<int, int> A;
    for (int i = 0; i < N; ++i) {
        int a;
        cin >> a;
        if (A.count(a) == 0) {
            A.insert(make_pair(a, 0));
        }
        A[a] += 1;
    }

    int nSingle = 0;
    int nPair = 0;
    for (auto e : A) {
        if (e.second % 2 == 0) {
            ++nPair;
        }
        else {
            ++nSingle;
        }
    }

    int ans = nSingle;
    if (nPair % 2 == 0) {
        ans += nPair;
    }
    else {
        ans += nPair - 1;
    }
    cout << ans << endl;
}

int main() {
    std::cout << std::fixed << std::setprecision(15);
    Main();
    return 0;
}


Measured memory_bytes: 8212
#include <bits/stdc++.h>
using namespace std;
#define IOS ios_base::sync_with_stdio(false);cin.tie(0)
#define endl "\n"
#define pb push_back
#define ff first
#define ss second
#define all(a) a.begin(),a.end()
#define int long long
const int MOD=1e9+7;
const int N=3e5+10;
int32_t main()
{
    IOS;
    int n;
    cin>>n;
    string s="";
    while(n>0)
    {
        n--;
        s+=char(n%26+'a');
        n/=26;
    }
    reverse(all(s));
    cout<<s<<endl;

    

}

Measured memory_bytes: 3624
#include<bits/stdc++.h>
using namespace std;
main()
{
    long long n;
    while(scanf("%lld",&n)==1){
        long long a=1;
        while(n>0){
            n=floor(n/2);
            a*=2;
        }
        printf("%lld\n",a-1);
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vll = vector<ll>;
#define all(x) (x).begin(), (x).end()
#define fsp(x) cout << fixed << setprecision(x)
const ll inf = LLONG_MAX;
const long double pi = acos(-1);
void Yes() {cout << "Yes" << endl;}
void No() {cout << "No" << endl;}
void YES() {cout << "YES" << endl;}
void NO() {cout << "NO" << endl;}

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

	ll n, t;
	cin >> n >> t;
	vll a(n), b(n);
	for (ll i = 0; i < n; i++) cin >> a[i] >> b[i];

	vector<vll> dp1(n - 1, vll(t, 0));
	if (a[0] < t) {
		dp1[0][a[0]] = b[0];
		for (ll i = a[0] + 1; i < t; i++) dp1[0][i] = dp1[0][i - 1];
	}
	for (ll i = 1; i < n - 1; i++) {
		dp1[i] = dp1[i - 1];
		for (ll j = a[i]; j < t; j++) {
			dp1[i][j] = max(dp1[i][j], dp1[i - 1][j - a[i]] + b[i]);
		}
	}

	vector<vll> dp2(n, vll(t, 0));
	if (a[n - 1] < t) {
		dp2[n - 1][a[n - 1]] = b[n - 1];
		for (ll i = a[n - 1] + 1; i < t; i++) dp2[n - 1][i] = dp2[n - 1][i - 1];
	}
	for (ll i = n - 2; i > 0; i--) {
		dp2[i] = dp2[i + 1];
		for (ll j = a[i]; j < t; j++) {
			dp2[i][j] = max(dp2[i][j], dp2[i + 1][j - a[i]] + b[i]);
		}
	}

	priority_queue<ll> ans;
	ans.push(dp2[1][t - 1] + b[0]);
	ans.push(dp1[n - 2][t - 1] + b[n - 1]);

	for (ll i = 1; i < n - 1; i++) {
		ll x = 0;
		for (ll j = 0; j < t; j++) {
			x = max(x, dp1[i - 1][j] + dp2[i + 1][t - 1 - j]);
		}
		ans.push(x + b[i]);
	}

	cout << ans.top() << endl;
}


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

int H, W;
vector<string> grid;
int dp[105][105];
const int inf = 1 << 30;


int main(void){
    // Your code here!
    cin >> H >> W;
    grid.resize(H);
    for (int i=0; i<H; i++) cin >> grid[i];
    
    for (int i=0; i<105; i++){
        for (int j=0; j<105; j++){
            dp[i][j] = inf;
        }
    }
    
    dp[0][0] = (grid[0][0] == '#') ? 1 : 0;
    
    for(int i=0; i<H; i++){
        for (int j=0; j<W; j++){
            int p=0;
            if(i+1  < H && grid[i][j] == '.' && grid[i+1][j] == '#') p = 1;
            dp[i+1][j] = min(dp[i+1][j], dp[i][j] + p);
            p = 0;
            if(j+1 < W && grid[i][j] == '.' && grid[i][j+1] == '#')p = 1;
            dp[i][j+1] = min(dp[i][j+1], dp[i][j] + p);
        }
    }
    // cout << dfs(0, 0) << endl;
    cout << dp[H-1][W-1] << endl;

}


Measured memory_bytes: 3704
#include <iostream>
#include <string>
#include <vector>

using namespace std;

static inline int charToInt(char c) {
  switch(c) {
  case 'A':
    return 1;
  case 'C':
    return 2;
  case 'G':
    return 3;
  case 'T':
    return 4;
  default:
    return 0;
  }  
}

static inline uint64_t getKey(const string& str) {
  uint64_t total = 0, p = 1;
  for (int i = 0; i < str.length(); i++) {
    total += p * (charToInt(str[i]));
    p *= 5;
  }  
  return total;
}

static const int M = 1046527;
static const int NUL = -1;
static const int L = 14;

static inline int h1(int key) {
  return key % M;
}

static inline int h2(int key) {
  return 1 + (key % (M - 1));
}

static vector<string> H(M);

static inline bool find(const string& str) {
  uint64_t key, h;
  key = getKey(str);
  for (int i = 0;; i++) {
    h = (h1(key) + i * h2(key)) % M;
    if (H[h] == str) {
      return true;
    }
    else if (H[h].size() == 0) {
      return false;
    }
  }
  return false;
}

static inline bool insert(const string& str) {
  uint64_t key, h;
  key = getKey(str);
  for (int i = 0;; i++) {
    h = (h1(key) + i * h2(key)) % M;
    if (H[h] == str) {
      return true;
    }
    else if (H[h].size() == 0) {
      H[h] = str;
      return false;
    }
  }
  return false;
}

int main() {
  int n, h;

  cin >> n;

  string str, com;
  for (int i = 0; i < n; i++) {
    cin >> com >> str;
    if (com[0] == 'i') {
      insert(str);
    } else {
        cout << (find(str) ? "yes" : "no") << endl;
    }
  }
  return 0;
}



Measured memory_bytes: 27460
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define all(x) (x).begin(), (x).end()
#define INF 1000000007
#define mod 1005
#define ll long long int
const double mx = 2e6 + 5 ;

void solve()
{
	int n;
	cin>>n;
	vector<pair<int, int>> vect(n);
	REP(i,n)
	{
		cin>>vect[i].first;
		vect[i].second = i+1;
	}
	sort(all(vect));
	REP(i,n)
	{
		cout<<vect[i].second<<" ";
	}
}
int main()
{
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
	int t = 1;
//	cin>>t;
	while(t--)
	{
		solve();
	}
	return 0;
}

Measured memory_bytes: 3992
import sys
sys.setrecursionlimit(10**6) #再帰関数の上限
import math
from copy import copy, deepcopy
from operator import itemgetter
from bisect import bisect_left, bisect, bisect_right#2分探索
#bisect_left(l,x), bisect(l,x)#aはソート済みである必要あり。aの中からx未満の要素数を返す。rightだと以下
from collections import deque 
#deque(l), pop(), append(x), popleft(), appendleft(x)
##listでqueの代用をするとO(N)の計算量がかかってしまうので注意
from collections import Counter#文字列を個数カウント辞書に、
#S=Counter(l),S.most_common(x),S.keys(),S.values(),S.items()
from itertools import accumulate#累積和
#list(accumulate(l))
from heapq import heapify,heappop,heappush
#heapify(q),heappush(q,a),heappop(q) #q=heapify(q)としないこと、返り値はNone
#import fractions#古いatcoderコンテストの場合GCDなどはここからimportする


def input(): return sys.stdin.readline()[:-1]
def printl(li): print(*li, sep="\n")
def argsort(s, return_sorted=False): 
    inds=sorted(range(len(s)), key=lambda k: s[k])
    if return_sorted: return inds, [s[i] for i in inds]
    return inds
def alp2num(c,cap=False): return ord(c)-97 if not cap else ord(c)-65
def num2alp(i,cap=False): return chr(i+97) if not cap else chr(i+65)
def matmat(A,B):
    K,N,M=len(B),len(A),len(B[0])
    return [[sum([(A[i][k]*B[k][j]) for k in range(K)]) for j in range(M)] for i in range(N)]
def matvec(M,v):
    N=len(v)
    size=len(M)
    return [sum([M[i][j]*v[j] for j in range(N)]) for i in range(size)]
def main():
    mod = 10**9+7
    #w.sort(key=itemgetter(1),reversed=True)  #二個目の要素で降順並び替え

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

    l=[(s[i][0]+s[i][1],s[i][0]-s[i][1]) for i in range(N)]
    l.sort()

    cur=l[0][0]
    ans=1
    for rob in l[1:]:
        if cur>rob[1]:
            continue
        ans+=1
        cur=rob[0]
    print(ans)


if __name__ == "__main__":
    main()

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

using namespace std;

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

    int cnt=1;
    int a=s;
    map<int,int> check;
    while(check[a]!=1){
        check[a]=1;
        if(a%2==0) a=a/2;
        else a=3*a+1;
        cnt++;
    }
    cout << cnt << endl;
}


Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <ctime>
#include <cmath>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <random>
#include <unordered_set>
#include <unordered_map>
#include <string>
#include <cstring>
#include <iomanip>
using namespace std;

#define double long double
#define int long long
#define mp make_pair
#define debug(x) cerr << #x << ": " << x << '\n';
#define fi first
#define se second
#define pb push_back
typedef long long ll;
typedef pair<int, int> pii;
template <typename T1, typename T2> bool chkmin(T1 &x, T2 y) { return y < x ? (x = y, true) : false; };
template <typename T1, typename T2> bool chkmax(T1 &x, T2 y) { return y > x ? (x = y, true) : false; };

void fast() {
    ios_base::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);
}

int ans = 0;
int n;

void check(int x) {
	int tn = n;
	while (tn % x == 0) tn /= x;
	if (tn % x == 1) ans++;
}

signed main() {
	cin >> n;
	if (n > 2) {
		ans++;
		int i = 2;
		for (; i * i < n - 1; i++) {
			if ((n - 1) % i == 0) ans += 2;
		}
		if (i * i == n - 1) ans++;
	}
	check(n);
	int i = 2;
	for (; i * i < n; i++) {
		if (n % i == 0) {
			check(i);
			check(n / i);
		}
	}
	if (i * i == n) check(i);
	cout << ans << '\n';
	return 0;
}

Measured memory_bytes: 256
x_1, y_1, x_2, y_2 = map(int, input().split())

x_4 = x_1 - (y_2 - y_1)
y_4 = y_1 + (x_2 - x_1)
x_3 = x_4 - (y_1 - y_4)
y_3 = y_4 + (x_1 - x_4)
 
print(x_3, y_3, x_4, y_4)

Measured memory_bytes: 3060
//#pragma GCC optimize("O3")
//#pragma GCC optimize("unroll-loops")

#include <bits/stdc++.h>

using namespace std;

int main() {
   // freopen("test.in", "r", stdin);
    //  freopen("ac.txt", "w", stdout);
    map<pair<int, int>, int> mp;
    int n;
    scanf("%d", &n);
    double x;
    long long v;
    for (int i = 0; i < n; ++i) {
        scanf("%lf", &x);
        v = (x * 1e9) + 1e-3;
       // printf("%lld\n", v);
        int t = 0, f = 0;
        while (v % 2 == 0) {
            v /= 2;
            ++t;
        }
        while (v % 5 == 0) {
            v /= 5;
            ++f;
        }
        mp[{t, f}]++;
    }
    vector<pair<int, int>> vec;
    for (auto p:mp) {
        vec.push_back(p.first);
    }
    long long ans = 0;
    for (int i = 0; i < vec.size(); ++i) {
        for (int j = i + 1; j < vec.size(); ++j) {
            pair<int, int> sm = vec[i];
            sm.first += vec[j].first;
            sm.second += vec[j].second;
            int v = min(sm.first, sm.second);
            if (v >= 18) {
                ans += (1ll * mp[vec[i]] * mp[vec[j]]);
            }
        }
        int v = min(vec[i].first, vec[i].second) * 2;
        if (v >= 18) {
            long long z = mp[vec[i]];
            ans += (z * (z - 1)) / 2;
        }
    }
    printf("%lld", ans);
}


Measured memory_bytes: 3724
#include <stdio.h>
#include <stdlib.h>

typedef long long ll;

int cmp(const void *a,const void *b)
{
  return (*(ll *)b) - (*(ll *)a);
}

int main()
{
  ll n,k,i, ans=0;
  ll *h;

  scanf("%lld %lld",&n,&k );
  h = calloc(n,sizeof(ll));

  for(i=0; i<n; i++)
    scanf("%lld", &h[i]);

  qsort(h,n,sizeof(ll),cmp);

  if(k<n){
    for(i=0; i<k; i++)
    h[i] = 0;
    for(i=k; i<n; i++)
    ans += (ll)h[i];
  }
  else
    ans = 0;

  printf("%lld", ans);

  free(h);
  return 0;
}


Measured memory_bytes: 4684
#!/usr/bin python3
# -*- coding: utf-8 -*-

r, c, k = map(int, input().split())
itm = [[0]*(c) for _ in range(r)]
for i in range(k):
    ri, ci, vi = map(int, input().split())
    itm[ri-1][ci-1] = vi

dp0 = [[0]*4 for c_ in range(3005)]
dp1 = [[0]*4 for c_ in range(3005)]

for i in range(r):
    for j in range(c):
        nowv = itm[i][j]
        dp0[j][3] = max(dp0[j][3], dp0[j][2] + nowv)
        dp0[j][2] = max(dp0[j][2], dp0[j][1] + nowv)
        dp0[j][1] = max(dp0[j][1], dp0[j][0] + nowv)

        dp0[j+1][0] = max(dp0[j+1][0], dp0[j][0])
        dp0[j+1][1] = max(dp0[j+1][1], dp0[j][1])
        dp0[j+1][2] = max(dp0[j+1][2], dp0[j][2])
        dp0[j+1][3] = max(dp0[j+1][3], dp0[j][3])

        dp1[j][0] = max(dp1[j][0], max(dp0[j]))
    dp0 = dp1.copy()

print(max(dp1[c-1]))


Measured memory_bytes: 153544
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		boolean[] p = new boolean[50001];
		p[0] = false;
		p[1] = false;
		for(int i=2;i<=50000;i++) {
			p[i] = true;
		}
		for(int i=2;i<=Math.sqrt(50000);i++) {
			if(p[i] == true) {
				for(int j=i*2;j<=50000;j+=i) {
					p[j] = false;
				}
			}
		}
		while(true) {
			int n = sc.nextInt();
			if(n==0) break;
			int count = 0;
			for(int i=2;i<=n/2;i++) {
				if(p[i] == true && p[n-i] == true) {
					count++;
//					System.out.println(i + " " + (n-i));
				}
			}
			System.out.println(count);
		}
	}
}





Measured memory_bytes: 43080
import Data.List
--import Data.Vector
{-
f :: Int -> [Int] -> Int -> Int -> Int
f a x m n 
    | n >= (length x) = 0
    | (a + (x !! m) > (x !! n)) = n - m + (f a x m (n + 1))
    | m + 1  == n = (f a x m (n + 1))
    | otherwise = f a x (m + 1) n

g :: [Int] -> Int
g [] = 0
g (a:x) = (f a x 0 1) + (g x)

main = do
    getLine
    x <- getLine >>= return . sort . (map (read :: String -> Int)) . words
    putStrLn $ show $ g x
-}
f :: Int -> [Int] -> [Int] -> Int -> Int -> Int
f a [] _ _ _ = 0
f a _ [] _ _ = 0
f a (x:xs) (y:ys) m n 
    | (a + x) > y = n - m + (f a (x:xs) ys m (n + 1))
    | m + 1  == n = (f a (x:xs) ys m (n + 1))
    | otherwise = f a xs (y:ys) (m + 1) n

g :: [Int] -> Int
g (a:(x:xs)) = (f a (x:xs) xs 0 1) + (g (x:xs))
g _ = 0

main = do
    getLine
    x <- getLine >>= return . sort . (map (read :: String -> Int)) . words
    putStrLn $ show $ g x

Measured memory_bytes: 2300
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin>>n;
  int ans=0;
  int now=0;
  for(int i=0;i<n;i++){
     int a;
     cin>>a;
    ans+=!!(now<=a);
    now=max(now,a);
  }
  cout<< ans<<endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main() {
	int n, team[101] = { 0 }, a, b, c, d, rank;
	cin >> n;

	for (int i = 0; i < n * (n - 1) / 2; i++) {
		cin >> a >> b >> c >> d;
		c == d ? team[a]++, team[b]++ : (c > d ? team[a] += 3 : team[b] += 3);
	}

	for (int i = 1; i <= n; i++) {
		rank = 1;
		for (int j = 1; j <= n; j++) {
			team[i] < team[j] ? rank++ : NULL;
		}
		cout << rank << endl;
	}

	return 0;
}

Measured memory_bytes: 1164
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define ALL(x) (x).begin(), (x).end()
typedef long long ll;
typedef pair<int, int> P;
typedef vector<vector<int>> Matrix;
static const int INF = 2000000000;



int main(){
  int n, a;
  cin >> n >> a;
  cout << n*n - a << endl;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void){
    long long N,i,a,b;
    cin>>N;
    long long h[N],c[N];
    for(i=0;i<N;i++){
        cin>>h[i];
    }
    c[0]=0;c[1]=abs(h[1]-h[0]);
    for(i=2;i<N;i++){
        a=c[i-2]+abs(h[i]-h[i-2]);
        b=c[i-1]+abs(h[i]-h[i-1]);
        c[i]=min(a,b);
    }
    cout<<c[N-1]<<endl;
}


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

int main(){
 
  int N;
    int t[110000], x[110000], y[110000];
    cin >> N;
    t[0] = x[0] = y[0] = 0; 
    for (int i = 0; i < N; ++i) cin >> t[i+1] >> x[i+1] >> y[i+1];
  
  bool can = true;
  for(int i=0; i<N; i++){
       
       bool flg2 = 0;
       
  		int dt = t[i+1] - t[i];
    	int dist = abs(x[i+1]-x[i]) + abs(y[i+1]-y[i]);
     	if(dt < dist) can = false;
      	if(dist % 2 != dt % 2) can = false;
  }
      
  if(can){
  	cout << "Yes" << endl; 
  }
  else cout << "No" << endl;
  
}

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

int main() {
    int n;
    std::cin >> n;

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

    auto end = std::unique(A.begin(), A.end());
    for (auto it = A.begin(); it < end; it++) {
        std::cout << *it;
        if (it < end - 1) {
            std::cout << " ";
        }
    }
    std::cout << std::endl;
}



Measured memory_bytes: 3124
import java.util.Scanner;
import java.util.stream.IntStream;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner scanner = new Scanner(System.in);
        long cnt = IntStream.range(0, 3)
                .map(e -> scanner.nextInt())
                .distinct()
                .count();
        System.out.println(cnt == 2 ? "Yes" : "No");
    }
}

Measured memory_bytes: 27348
import java.util.Scanner;

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

		while(true){
			int candidates = sc.nextInt();
			int first_num = sc.nextInt();
			if(candidates==0 && first_num==0) break;

			int[] stone = new int[candidates];
			stone[0]++;
			int bowl = first_num - 1;
			int i = 0;

			while(first_num!=bowl){
				i = (i+1)%candidates;
				if(bowl>0){
					stone[i]++;
					bowl--;
				}else{
					bowl = stone[i];
					stone[i] = 0;
				}
			}
			System.out.println(i);
		}
	}
}

Measured memory_bytes: 26660
import collections
n = int(input())
s = [input() for _ in range(n)]
m = int(input())
t = [input() for _ in range(m)]

ctr_s = collections.Counter(s)
ctr_t = collections.Counter(t)
ans = 0
for k,v in ctr_s.items():
    if ctr_s[k]:
        ans = max(ans, v - ctr_t[k])
    else:
        ans = max(ans, v)
print(ans)

Measured memory_bytes: 3316
function Main(input) {
    "use strict";
    const els = input.split(' ');
    let i = parseInt(els[0],10);
    let sum = 0;

    while(i <= els[2]){
        sum += parseInt(els[1],10);
        i += parseInt(els[0],10);
    }
    console.log(sum);
}

Main(require('fs').readFileSync('/dev/stdin', 'utf-8'));

Measured memory_bytes: 7372
#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);

    ll x;
    cin >> x;

    ll ans = x / (6 + 5) * 2;
    ll div = x % (6 + 5);
    if (div) {
        if (div <= 6) ans += 1;
        else ans += 2;
    }

    cout << ans << '\n';
    return 0;
}


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

int main()
{
   int n,m,i,j,k;cin>>n>>m;
   vector<pair<int,int>> v;
   for(i=0;i<m;i++)
   {
       int a,b;cin>>a>>b;
       v.push_back(make_pair(a,b));
   }
   sort(v.begin(),v.end());
   int l,r,res=0;
   for(i=0;i<m;i++)
   {
       if(i==0) {l=v[i].first;r=v[i].second;res++;}

       else
       {
           if(v[i].first>=r) {l=v[i].first;r=v[i].second;res++;}

           else if(v[i].second<r) {r=v[i].second;}
       }
   }
   cout<<res<<endl;
}


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

#define boost ios::sync_with_stdio(false);cin.tie(NULL)
#define ll long long
#define pll pair<ll,ll>
#define pb push_back
#define mp make_pair
#define F first
#define S second

ll n,a;

int main()
{
    boost;
    if(fopen("inp.txt", "r")) {
      freopen("inp.txt", "r", stdin);
      freopen("outp.txt", "w", stdout);
    }

    cin>>n>>a;

    cout<<n*n-a<<endl;

    return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.InteropServices;
using System.Text;
using System.Threading.Tasks;
using static System.Console;
using static System.Math;

namespace Project
{
    class Program
    {
        public static void Main(string[] args)
        {
            new Program().Solve(new ConsoleInput(Console.In, ' '));
        }

        public void Solve(ConsoleInput cin)
        {
            var a =cin.ReadInt;
            var ans = a + a * a + a * a * a;
            WriteLine(ans);

        }
    }

    public class ConsoleInput
    {
        private readonly System.IO.TextReader _stream;
        private char _separator = ' ';
        private Queue<string> inputStream;
        public ConsoleInput(System.IO.TextReader stream, char separator = ' ')
        {
            this._separator = separator;
            this._stream = stream;
            inputStream = new Queue<string>();
        }

        public string Read
        {
            get
            {
                if (inputStream.Count != 0) return inputStream.Dequeue();
                string[] tmp = _stream.ReadLine().Split(_separator);
                for (int i = 0; i < tmp.Length; ++i)
                    inputStream.Enqueue(tmp[i]);
                return inputStream.Dequeue();
            }
        }
        public string ReadLine { get { return _stream.ReadLine(); } }
        public int ReadInt { get { return int.Parse(Read); } } // intの範囲は-2147483648～2147483648
        public long ReadLong { get { return long.Parse(Read); } }
        public double ReadDouble { get { return double.Parse(Read); } }
        public string[] ReadStrArray(long N)
        { var ret = new string[N]; for (long i = 0; i < N; ++i) ret[i] = Read; return ret; }
        public int[] ReadIntArray(long N)
        { var ret = new int[N]; for (long i = 0; i < N; ++i) ret[i] = ReadInt; return ret; }
        public long[] ReadLongArray(long N)
        { var ret = new long[N]; for (long i = 0; i < N; ++i) ret[i] = ReadLong; return ret; }

    }
}


Measured memory_bytes: 27840
#include<bits/stdc++.h>
#define rep(i,x,y) for(int i=x;i<y;i++)
#define rept(i,x,y) for(int i=x;i<=y;i++)
#define per(i,x,y) for(int i=y;i>=x;i--)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(x) x.begin(),x.end()
#define pii pair<int,int>
//	ios::sync_with_stdio(false);
//	cin.tie(0);
const int maxx = 2e5+7;
const int maxn = 1e9+7;
typedef long long ll;
using namespace std;
inline int read(){
   int s=0,w=1;
   char ch=getchar();
   while(ch<'0'||ch>'9'){if(ch=='-')w=-1;ch=getchar();}
   while(ch>='0'&&ch<='9') s=s*10+ch-'0',ch=getchar();
   return s*w;
}
ll n,m,op,op1,op2,sum;
int a[105];
int main(){
		ios::sync_with_stdio(false);
	cin.tie(0);
	cin>>n>>m;
	rept(i,1,m){
		cin>>op;
		rept(i,1,op){
			cin>>op1;
			a[op1]++;
		} 
	}
	rept(i,1,n){
		if(a[i]==0)sum++;
	}
	cout<<sum<<endl;
	return 0;
}


Measured memory_bytes: 3652
#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  for(int i=0;i<(n);++i)
#define FORq(i, m, n) for(int i = (m);i <= (n);++i)
#define SCD(n) scanf("%d",&n)
#define SCD2(m,n) scanf("%d%d",&m,&n)
#define SCD3(m,n,k) scanf("%d%d%d",&m,&n,&k)
#define PB push_back
#define MP make_pair
#define ARSCD(A,N) REP(i,N){SCD(A[i]);}
#define ARSCD1(A,N) FORq(i,1,N){SCD(A[i]);}
#define PRINTD(n) printf("%d\n",n)
#define PRINTLLD(n) printf("%lld\n",n)
#define DEBUG printf("%s\n","debug")
#define fst first
#define snd second
#define IN(x,S) (S.count(x) != 0)
using namespace std;
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef long long ll;
//////////////////////////////////////////////////////
int main(){
	int N,M;
	SCD2(N,M);
	ll xyz[10][1002];
	
	REP(i,N){
		ll x,y,z;
		scanf("%lld%lld%lld",&x,&y,&z);
		xyz[1][i] = x+y+z;
		xyz[2][i] = x+y-z;
		xyz[3][i] = x-y+z;
		xyz[4][i] = x-y-z;
		xyz[5][i] = -x-y-z;
		xyz[6][i] = -x-y+z;
		xyz[7][i] = -x+y-z;
		xyz[8][i] = -x+y+z;
	}
	
	ll ans = 0;
	
	FORq(i,1,8){
		ll nans = 0;
		sort(xyz[i],xyz[i]+N);
		for(int j = N-1; N-M-1 < j ; j--){
			nans += xyz[i][j];
		}
		
		ans = max(nans,ans);
		
	}
	
	PRINTLLD(ans);
	
	return 0;
}



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

using namespace std;


int main()
{

	int n, k, s;

	cin >> n >> k >> s;


	for (int i = 0; i < n; i++) {
		if (i < k) {
			cout << s;
		}
		else {
          	if(s == 1000000000){
              cout << 1;
            } else {
			  cout << s + 1;
            }
        }
		cout << " ";
	}


	cout << endl;


}

Measured memory_bytes: 1280
import java.io.*;
import java.util.StringTokenizer;


public class Main {
    public static void main(String[] args) throws IOException {
        Scanner sc = new Scanner(System.in);
        PrintWriter out = new PrintWriter(System.out);
        int n = sc.nextInt();
        int[] a = new int[n + 1];
        for (int i = 1; i <= n; i++)
            a[i] = sc.nextInt();
        boolean found = false;
        for (int i = 1; i <= n; i++) {
            if (a[i] == i) continue;
            if (found || a[a[i]] != i) {
                System.out.println("NO");
                return;
            }
            found = true;
            a[a[i]] = a[i];
        }
        out.println("YES");
        out.flush();
        out.close();
    }


    static class Scanner {

        StringTokenizer st;
        BufferedReader br;

        public Scanner(InputStream system) {
            br = new BufferedReader(new InputStreamReader(system));
        }


        public String next() throws IOException {
            while (st == null || !st.hasMoreTokens()) st = new StringTokenizer(br.readLine());
            return st.nextToken();
        }

        public String nextLine() throws IOException {
            return br.readLine();
        }

        public int nextInt() throws IOException {
            return Integer.parseInt(next());
        }

        public double nextDouble() throws IOException {
            return Double.parseDouble(next());
        }

        public char nextChar() throws IOException {
            return next().charAt(0);
        }

        public Long nextLong() throws IOException {
            return Long.parseLong(next());
        }

        public boolean ready() throws IOException {
            return br.ready();
        }


        public int[] nextIntArray(int n) throws IOException {
            int[] a = new int[n];
            for (int i = 0; i < n; i++)
                a[i] = nextInt();
            return a;
        }

        public long[] nextLongArray(int n) throws IOException {
            long[] a = new long[n];
            for (int i = 0; i < n; i++)
                a[i] = nextLong();
            return a;
        }


        public Integer[] nextIntegerArray(int n) throws IOException {
            Integer[] a = new Integer[n];
            for (int i = 0; i < n; i++)
                a[i] = nextInt();
            return a;
        }

        public double[] nextDoubleArray(int n) throws IOException {
            double[] ans = new double[n];
            for (int i = 0; i < n; i++)
                ans[i] = nextDouble();
            return ans;
        }

        public short nextShort() throws IOException {
            return Short.parseShort(next());
        }

    }
}

Measured memory_bytes: 22612
#include <iostream>
#include <cstring>
#include <cmath>
#include <vector>
#include <algorithm>
#include <stdio.h>
#include <math.h>
#include <stdlib.h>
#include <set>
#include <map>
#include <iterator>
#include <stack>
#include <string.h>
#include <cstdlib>
#include <queue>
#include <list>

using namespace std;

int main()
{
    int n;
    int a[15];
    pair<int[15],bool[15]> P[15];
    int ans = 0;
    bool h[15];
    
    cin >> n;
    for (int i = 0;i < n;i++){
        cin >> a[i];
        for (int j = 0;j < a[i];j++){
            cin >> P[i].first[j] >> P[i].second[j];
        }
    }
    for (int i = 0;i < 1<<n;i++){
        int num = 0;
        for (int j = 0;j < n;j++){
            if (i&1<<j){
                h[j] = 1;
                num++;
            }
            else {
                h[j] = 0;
            }
        }
    
        for (int j = 0;j < n;j++){
            for (int k = 0;k < a[j];k++){
                if (h[j] == 1 && h[P[j].first[k]-1] != P[j].second[k]){
                    num = 0;
                    goto EXIT;
                 }
            }
        }
        EXIT:
        ans = max(ans,num);
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
import math
num = int(input())
words = {}

for i in range(num):
  a = str(sorted(list(input())))
  
  if a in words:
    words[a] += 1
  else:
  	words[a] = 1

points = list(words.values())
sum = 0
def combinations_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))
for i in range(len(points)):
  if points[i] > 1:
  	sum += combinations_count(points[i], 2)
print(sum)



Measured memory_bytes: 21984
#入力:N,M(int:整数)
def input2():
	return map(int,input().split())

N,M=input2()
L,R=[],[]
for i in range(M):
	l,r=input2()
	L.append(l)
	R.append(r)

MIN=0
MAX=N

for j in range(M):
	if L[j]>MIN:
		MIN=L[j]
	if R[j]<MAX:
		MAX=R[j]

if MAX<MIN:
	print(0)
else:
	print((MAX-MIN)+1)


Measured memory_bytes: 16808
#include <stdio.h>

int lucky(int n)
{
  if(n%10==7){
    return 1;
  }else{
    if(n>=10){
      lucky(n/10);
    }else{
      return 0;
    }
  }
    
}
int main()
{
  int n,flg=0;
  scanf("%d",&n);
  flg=lucky(n);
  if(flg==0)
    printf("No");
  else
    printf("Yes");
  
  return 0;
  
}


Measured memory_bytes: 1736
#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>
#include <cmath>

using namespace std;

int main(void) {
    int N;
    cin >> N;
    vector<int64_t> a(N);
    for(int i=0; i<N; i++) {
        cin >> a[i];
    }

    partial_sum(a.begin(), a.end(), a.begin());

    int64_t ans = numeric_limits<int64_t>::max();
    for(int i=0; i<N-1; i++) {
        ans = min(ans, abs(a[i] - (a[N-1]-a[i])));
    }

    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
//解説AC
int main() {
  long long n,a,b,c,d;
  cin >>n>>a>>b>>c>>d;
  string s;
  cin>>s;
  if(c==d){
    cout<<"No1"<<endl;
    return 0;
  }
  bool hantei=true;
  if(c<d){
    for(long long i=a-1;i<d-1;i++){
      if(s[i]=='#'&&s[i+1]=='#'){
        hantei=false;
        break;
      }
    }
  }else{
    hantei=false;
    for(long long i=b-2;i<d-1;i++){
      if(s[i]=='.'&&s[i+1]=='.'&&s[i+2]=='.'){
        hantei=true;
        //cout<<i<<endl;
      }
    }
    for(long long i=a-1;i<c-1;i++){
      if(s[i]=='#'&&s[i+1]=='#'){
        //cout<<i<<endl;
        hantei=false;
        break;
      }
    }
  }
  if(hantei)cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
  return 0;
}

Measured memory_bytes: 3720
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
// ll inf=(ll)1e18;
ll seg[800000]={0},h[200000],b[200000];

ll ans(ll l,ll r,ll tl,ll tr,ll v){
  if(l>r)return 0;
  if(tl==l&&tr==r)return seg[v];
  ll tm=tl+(tr-tl)/2;
  return max(ans(l,min(tm,r),tl,tm,2*v) ,ans(max(tm+1,l),r,tm+1,tr,2*v+1) );
}

void update(ll v,ll tl,ll tr,ll pos,ll val){
  if(tl==tr) {seg[v]=max(seg[v],val); return ;}
  ll tm= tl+(tr-tl)/2;
  if(pos<=tm) update(2*v,tl , tm, pos,val);
  else  update(2*v+1, tm+1,tr, pos,val);
  seg[v]= max({seg[v],seg[2*v] , seg[2*v+1]});
}

int main(){
  ll i,n,x,y;
  cin>>n;
  for(i=0;i<n;i++)cin>>h[i];
  for(i=0;i<n;i++)cin>>b[i];
  ll answer=0;
  for(i=0;i<n;i++){
    ll k=ans( 0,h[i]-1,0,n-1,1);
    answer=max(answer,k+b[i]);
    update(1,0,n-1,h[i]-1, k+b[i]);
  }
   cout<<answer;
}

Measured memory_bytes: 8448
#include<bits/stdc++.h>
using namespace std;
string s;
set<string> p;
set<string> :: iterator it; 
int n,l,cnt=1;
int main()
{
	cin >> s;
	scanf("%d",&n);
	for(int i=1;i<=s.size();i++)
	{
		for(int j=0;j<=s.size()-i;j++)
		{
			l=j;
			p.insert(s.substr(l,i));
			if(p.size()==6)
			{
				p.erase(*p.rbegin());
			}
		}
	}
	for(it=p.begin();it!=p.end();it++)
	{
		if(cnt==n)
		{
			cout << *it << endl;
			break;
		}
		++cnt;
	}
}

Measured memory_bytes: 3692
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cassert>
#include <string>
#include <algorithm>
#include <vector>
#include <valarray>
#include <queue>
#include <stack>
#include <functional>
#include <iostream>
#include <iomanip>
#include <map>
#include <set>
#include <list>
#include <limits>
#include <numeric>
#include <utility>
#include <deque>
#include <unordered_set>
#include <unordered_map>
#include <regex>
#include <array>
#include <bitset>
#include <complex>
#include <tuple>
#include <random>

using namespace std;
using ll = long long;
const int INF = 1e9;
const ll MOD = 1e9 + 7;

int main()
{
  int n;
  while (cin >> n, n)
  {
    int sum = 0;
    int l = 0, r = 0;
    int pre = 0;
    for (int i = 0; i < n; ++i)
    {
      string f;
      cin >> f;
      if (f[0] == 'l')
      {
        if (f[1] == 'u')
        {
          if (l == 0)
          {
            l = 1;
            if (l == r && pre == 0)
              sum++, pre = 1;
          }
        }
        else
        {
          if (l == 1)
          {
            l = 0;
            if (l == r && pre == 1)
              sum++, pre = 0;
          }
        }
      }
      else
      {
        if (f[1] == 'u')
        {
          if (r == 0)
          {
            r = 1;
            if (l == r && pre == 0)
              sum++, pre = 1;
          }
        }
        else
        {
          if (r == 1)
          {
            r = 0;
            if (l == r && pre == 1)
              sum++, pre = 0;
          }
        }
      }
    }
    cout << sum << endl;
  }

  return 0;
}



Measured memory_bytes: 3160
#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  vector<long int> a(n+1);
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  sort(a.begin(), a.end());
  for (int i = 0; i < n-1; i++) {
    if(a[i+1]==a[i+2]){
      cout << "NO" << endl;
      exit (0);
    }
  }
  cout << "YES" << endl;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(i,n) for (int i = 0; i < (n); ++i)
int main() {
    int n;
    string s;
    cin >> n;
    cin >> s;
    int ans = 0;
    vector<char> sl;
    vector<char> sr;
    rep(i, n) {
        sl.clear();
        rep(j, i) {
            bool flg = false;
            rep(k, sl.size()) {
                if ( s[j] == sl[k] ) {
                    flg = true;
                }
            }
            if ( !flg ) {
                sl.push_back(s[j]);
            }
        }
        int tmp_cnt = 0;
        sr.clear();
        for ( int j = i; j < s.length(); j++ ) {
            bool continue_flg = false;
            rep(k, sr.size()) {
                if ( s[j] == sr[k] ) {
                    continue_flg = true;
                    break;
                }
            }
            if ( continue_flg ) continue;
            rep(k, sl.size()) {
                if ( s[j] == sl[k] ) {
                    tmp_cnt++;
                    sr.push_back(s[j]);
                }
            }
        }
        ans = max(ans, tmp_cnt);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256