akhauriyash/Code-Regression huggingface dataset:
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/multiprecision/cpp_int.hpp>
#include <boost/numeric/interval.hpp>
#include <boost/numeric/interval/io.hpp>
using namespace::std;
namespace mp = boost::multiprecision;
typedef mp::number<mp::cpp_dec_float<32,int64_t>> cfloat;
typedef mp::cpp_int cint;
typedef long long lint;
typedef long long ll;
typedef long double ldouble;
typedef vector<lint> vec;
typedef vector<vector<lint>> mat;
typedef vector<vector<vector<lint>>> mat3;
typedef vector<double> dvec;
typedef vector<vector<double>> dmat;
typedef vector<vector<vector<double>>> dmat3;
typedef vector<string> svec;
typedef vector<vector<string>> smat;
typedef vector<vector<vector<string>>> smat3;
typedef vector<pair<lint,lint>> pvec;
typedef vector<vector<pair<lint,lint>>> pmat;
typedef vector<vector<vector<pair<lint,lint>>>> pmat3;
#define rep(i, n) for(lint i = 0; i < (lint)(n); i++)
#define irep(i) for(lint i = 0;; i++)
#define irep1(i) for(lint i = 1;; i++)
#define irep2(i) for(lint i = 2;; i++)
#define rrep(i, n) for(lint i = (lint)(n-1); i >-1; i--)
#define rrepi(i,a,b) for(lint i = (lint)(b-1); i >a-1; i--)
#define repi(i,a,b) for(lint i=lint(a);i<lint(b);i++)
#define rep2(i,a,b,c) for(lint i=lint(a);i>lint(b);i+=c)
#define all(x) (x).begin(),(x).end()
#define PI 3.141592653589793
#define cout (cout<<fixed<<setprecision(15))
#define dist(x1,y1,x2,y2) (pow(pow(x2-x1,2)+pow(y2-y1,2),0.5))
#define out(v) do{bool f=0;for(auto i:v){cout<<(f?" ":"")<<i;f=1;}cout<<"\n";}while(0)
#define out2(v) for(auto i:v)output(i);
#define input(a,n) lint n;cin>>n;vector<lint>a(n);rep(i,n)cin>>a[i];
#define sum(v) accumulate(all(v),0LL)
#define INF (1LL<<60)
#define IINF (1<<30)
#define LINF 9223372036854775807
#define MOD 1000000007
vector<lint> dx={-1,1,0,0,1,1,-1,-1};
vector<lint> dy={0,0,-1,1,1,-1,1,-1};
inline lint gcd(lint a,lint b){return b?gcd(b,a%b):a;}
inline lint lcm(lint a,lint b){return a*b/gcd(a,b);}
int main(){
    input(a,n);
    lint cnt=0,cnt2=0;
    lint now=0;
    rep(i,n){
        now+=a[i];
        if(i%2==0&&now<1){
            cnt+=1-now;
            now=1;
        }
        if(i%2==1&&now>-1){
            cnt+=now+1;
            now=-1;
        }
    }
    now=0;
    rep(i,n){
        now+=a[i];
        if(i%2==1&&now<1){
            cnt2+=1-now;
            now=1;
        }
        if(i%2==0&&now>-1){
            cnt2+=now+1;
            now=-1;
        }
    }
    cout<<min(cnt,cnt2);
}

Measured memory_bytes: 1024
def partition(A, p, r):
    x = A[r]
    i = p - 1

    for j in range(p, r):
        if A[j] <= x:
            i += 1
            A[i], A[j] = A[j], A[i]

    A[i + 1], A[r] = A[r], A[i + 1]

    return i + 1


n = int(input())
A = list(map(int, input().split()))

index = partition(A, 0, len(A) - 1)
A[index] = "[{}]".format(A[index])
print(*A)


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

using namespace std;

typedef long long ll;

#define rep(i, n) for(int i = 0; i < n; i++)
#define repi(i, start, end) for(int i = start; i < end; i++)
#define all(x) (x).begin(), (x).end()
#define debug(x) cout << (x) << endl;
#define INF (1e9)
#define add_mod(a, b, x) ( (ll)(a) + (ll)(b) ) % (ll)(x)
#define mul_mod(a, b, x) ( ((ll)(a) % (ll)(x)) * ((ll)(b) % (ll)(x)) ) % (ll)(x)

ll sub_mod(ll a, ll b, ll x){
    ll tmp = (a - b) % x;
    if(tmp < 0) tmp += x;
    return tmp;
}

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

vector<vector<int>> line(5, vector<int>());
int visited[5] = {0};

void search(int pos){
    for(auto itr = line[pos].begin(); itr != line[pos].end(); itr++){
        if(visited[*itr] == 0){
            visited[pos] = 1;
            search(*itr);
        }
    }
}

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

    rep(i, 3){
        int a, b;
        cin >> a >> b;
        line[a].push_back(b);
        line[b].push_back(a);
    }

    bool flag = false;
    repi(i, 1, 5){
        search(i);
        int sum = 1;
        repi(i, 1, 5){
            sum += visited[i];
            visited[i] = 0;
        }

        if(sum == 4) flag = true;
    }

    if(flag) cout << "YES" << endl;
    else cout << "NO" << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define endl "\n"
#define F first
#define S second
#define pb push_back
#define mp make_pair

const int MOD = 1000000007;
const int N = 1e5 + 18;


int32_t main()
{
    ios_base::sync_with_stdio(false); cin.tie(0);
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout);
#endif
    int t = 1;
    //cin >> t;
    while (t--) {
        //for (int tt = 1; tt <= t; tt++) {
        int n, x, t;
        cin >> n >> x >> t;
        int cnt = 0;
        int x1 = n;
        while (x1 > 0) {
            cnt += t;
            x1 -= x;
        }
        cout << cnt << endl;


    }
    return 0;

}




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

class Magatro
{
    private int N;
    private int[] A, B, C;

    private void Scan()
    {
        N = int.Parse(Console.ReadLine());
        A = new int[N];
        B = new int[N];
        C = new int[N];
        var l = Console.ReadLine().Split(' ');
        for (int i = 0; i < N; i++)
        {
            A[i] = int.Parse(l[i]);
        }
        l = Console.ReadLine().Split(' ');
        for (int i = 0; i < N; i++)
        {
            B[i] = int.Parse(l[i]);
        }
        l = Console.ReadLine().Split(' ');
        for (int i = 0; i < N; i++)
        {
            C[i] = int.Parse(l[i]);
        }
    }

    private int SearchA(int n)//nより小さいやつの個数
    {
        int l = -1;
        int r = N;
        while (r - l > 1)
        {
            int mid = (l + r) / 2;
            if (A[mid] >= n)
            {
                r = mid;
            }
            else
            {
                l = mid;
            }
        }
        return l + 1;
    }

    private int SearchC(int n)
    {
        int l = -1;
        int r = N;
        while (r - l > 1)
        {
            int mid = (l + r) / 2;
            if (C[mid] > n)
            {
                r = mid;
            }
            else
            {
                l = mid;
            }
        }
        return N - r;
    }

    public void Solve()
    {
        Scan();
        Array.Sort(A);
        Array.Sort(B);
        Array.Sort(C);
        long ans = 0;
        foreach (int n in B)
        {
            ans += (long)SearchA(n) * SearchC(n);
        }
        Console.WriteLine(ans);
    }
    static void Main(string[] args)
    {
        new Magatro().Solve();
    }
}

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

int search(int a[], int n, int key) {
	int i = 0;
	a[n] = key;
	while(a[i] != key) i++;
	return i != n;
}
int main() {
	int i, n, a[10001], q, key, sum = 0;
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}

	cin >> q;
	for (int i = 0; i < q; i++) {
		cin >> key;
		if (search(a, n, key)) sum++;
	}
	cout << sum << endl;
	return 0;

}


Measured memory_bytes: 3140
N, M = list(map(int, input().split()))
S = list(map(int, input().split()))
T = list(map(int, input().split()))
MOD = 10 ** 9 + 7

DP = [[0] * M for _ in range(N)]

t = 0
for i in range(M):
  if S[0] == T[i]:
    t += 1
  DP[0][i] = t

for i in range(1, N):
  cnt = 0
  while cnt < M:
    if cnt == 0:
      DP[i][0] = DP[i - 1][0]
      if S[i] == T[0]:
        DP[i][0] += 1
    else:
      if S[i] == T[cnt]:
        DP[i][cnt] = (DP[i - 1][cnt] + 1 + DP[i][cnt - 1]) % MOD
      else:
        DP[i][cnt] = (DP[i - 1][cnt] + DP[i][cnt - 1] - DP[i - 1][cnt - 1]) % MOD
      while DP[i][cnt] < MOD:
        DP[i][cnt] += MOD
    cnt += 1

print((DP[-1][-1] + 1) % MOD)

Measured memory_bytes: 73052
import java.util.Scanner;

public class Main {
    private static int ALL_ALPHABET_NUMBER = 26;

    public static void main(final String[] args) {
        final Scanner scanner = new Scanner(System.in);
        final String s = scanner.nextLine();

        if (s.length() == 26) {
            final boolean[] isNotExisting = new boolean[ALL_ALPHABET_NUMBER];
            for (int i = s.length() - 1; i >= 0; i--) {
                for (int j = 0; j < isNotExisting.length; j++) {
                    if (isNotExisting[j] && s.charAt(i) < 'a' + j) {
                        System.out.println(s.substring(0, i) + (char) ('a' + j));
                        return;
                    }
                }
                isNotExisting[s.charAt(i) - 'a'] = true;
            }
            System.out.println(-1);
            return;
        }

        final boolean[] isExisting = new boolean[ALL_ALPHABET_NUMBER];

        for (int i = 0; i < s.length(); i++) {
            isExisting[s.charAt(i) - 'a'] = true;
        }

        for (int i = 0; i < isExisting.length; i++) {
            if (!isExisting[i]) {
                System.out.println(s + (char) ('a' + i));
                return;
            }
        }
    }
}


Measured memory_bytes: 21844
N, A, B, C = map(int, raw_input().split())
l = [input() for _ in range(N)]

def cost(X, x):
  t = 0
  c = 0
  for i in range(N):
    if x>>i&1:
      t += l[i]
      c += 1
  return (c-1)*10 + abs(X-t)

ans = 10000
for a in range(1, 1<<N):
  ac = cost(A, a)
  for b in range(1, 1<<N):
    if (a&b)==0:
      bc = cost(B, b)
      for c in range(1, 1<<N):
        if ((a|b)&c)==0:
          cc = cost(C, c)
          ans = min(ans, ac+bc+cc)
print ans


Measured memory_bytes: 2692
#include "bits/stdc++.h"
#define LF '\n'
#define ALL(x) x.begin(), x.end()
#define iostreamBooster() { cin.tie(nullptr); ios_base::sync_with_stdio(false); }
using namespace std;
typedef int64_t i64;
typedef pair<int,int> pii;
template<class A, class B>inline bool chmax(A &a, const B &b){return b>a ? a=b,1 : 0;}
template<class A, class B>inline bool chmin(A &a, const B &b){return b<a ? a=b,1 : 0;}
constexpr int INF = 0x3f3f3f3f;
template<class Itr> void dump(Itr begin, Itr end) { for (;begin != end; ++begin) clog << *begin << LF; }

signed main()
{
  long r, g;
  cin >> r >> g;

  cout << 2*g - r << LF;

  return 0;
}



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

int main(){
  int n;
  cin >> n;
  int l[110];
  for(int i = 0;i < n;i++){
    cin >> l[i];
  }

  sort(l, l+n);

  int rui = 0;
  for(int i = 0;i < n-1;i++){
    rui += l[i];
  }


  if(rui > l[n-1]){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using i64 = long long;

int main() {
    int n;
    constexpr i64 mod = 1000000007;
    std::string s;
    std::cin >> n >> s;

    std::vector<std::vector<i64>> dp(n, std::vector<i64>(n + 1));
    std::vector<i64> ps(n + 1);
    for (int i = 1; i <= n; i++) dp[0][i] = 1;
    for (int i = 1; i < n; i++) {
        for (int j = 1; j <= n; j++) ps[j] = (ps[j - 1] + dp[i - 1][j]) % mod;
        for (int j = 1; j <= n - i; j++) {
            if (s[i - 1] == '>') dp[i][j] = (mod + ps[n] - ps[j]) % mod;
            else dp[i][j] = ps[j];
        }
    }
    std::cout << dp[n - 1][1] << std::endl;

    return 0;
}


Measured memory_bytes: 70656
#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 ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
const ll INF = (1LL<<60);

ll x,y;

ll cal(int b1, int b2)
{
  ll xx = (b1 ? -x : x);
  ll yy = (b2 ? -y : y);
  if(xx<=yy) return yy-xx+b1+b2;
  else return INF;
}

int main()
{
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  cin >> x >> y;
  ll ans = cal(0,0);
  ans = min(ans, cal(0,1));
  ans = min(ans, cal(1,0));
  ans = min(ans, cal(1,1));
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<queue>
#include<algorithm>
#include<map>
#include<set>
#include<cmath>
typedef long long ll;
#define rep(i,n) for(int i=0;i<(n);i++)
using namespace std;
int INF = 1e9;

int main() {
	int n, k;
	cin >> n >> k;
	vector<int> h(n);
	rep(i, n) cin >> h[i];
	vector<int> dp(n, INF);
	dp[0] = 0;
	rep(i, n - 1) {
		for (int j = 1; j <= k; j++) {
			if (i + j >= n) continue;
			dp[i + j] = min(dp[i + j], dp[i] + abs(h[i] - h[i + j]));
		}
	}
	cout << dp[n - 1] << endl;
}

Measured memory_bytes: 1024
N = int(input())
A = list(map(int, input().split()))
ans = 1


def gcd(x, y):
    if y > x:
        x, y = y, x
    while y:
        x, y = y, x % y
    return x


X = [0]*N
Y = [0]*N

for i in range(1, N):
    X[i] = gcd(X[i-1], A[i-1])
for i in range(N-1)[::-1]:
    Y[i] = gcd(Y[i+1], A[i+1])
for i in range(N):
    if gcd(X[i], Y[i]) > ans:
        ans = gcd(X[i], Y[i])

print(ans)


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

// #define int long long
#define rep(i, n) for (long long i = (long long)(0); i < (long long)(n); ++i)
#define reps(i, n) for (long long i = (long long)(1); i <= (long long)(n); ++i)
#define rrep(i, n) for (long long i = ((long long)(n)-1); i >= 0; i--)
#define rreps(i, n) for (long long i = ((long long)(n)); i > 0; i--)
#define irep(i, m, n) for (long long i = (long long)(m); i < (long long)(n); ++i)
#define ireps(i, m, n) for (long long i = (long long)(m); i <= (long long)(n); ++i)
#define SORT(v, n) sort(v, v + n);
#define REVERSE(v, n) reverse(v, v+n);
#define vsort(v) sort(v.begin(), v.end());
#define all(v) v.begin(), v.end()
#define mp(n, m) make_pair(n, m);
#define cout(d) cout<<d<<endl;
#define coutd(d) cout<<std::setprecision(10)<<d<<endl;
#define cinline(n) getline(cin,n);
#define replace_all(s, b, a) replace(s.begin(),s.end(), b, a);
#define PI (acos(-1))
#define FILL(v, n, x) fill(v, v + n, x);
#define sz(x) long long(x.size())

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vs = vector<string>;
using vpll = vector<pair<ll, ll>>;
using vtp = vector<tuple<ll,ll,ll>>;
using vb = vector<bool>;

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

const ll INF = 1e9;
const ll MOD = 1e9+7;
const ll LINF = 1e18;



signed main()
{
  cin.tie( 0 ); ios::sync_with_stdio( false );
  ll a,b,c,d; cin>>a>>b>>c>>d;
  while(true){
    c-=b;
    if(c<=0){
      cout<<"Yes"<<endl;
      return 0;
    }
    a-=d;
    if(a<=0){
      cout<<"No"<<endl;
      return 0;
    }
  }
}

Measured memory_bytes: 3640
N, M = map(int, raw_input().split())
A = map(int, raw_input().split())

v = sum(A) / 4.0 / M

c = 0
for i in range(N):
    if A[i] >= v:
        c += 1

if c >= M:
    print "Yes"
else:
    print "No"


Measured memory_bytes: 2568
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <deque>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#define p(s) cout<<(s)<<endl
#define REP(i,n,N) for(int i=n;i<N;i++)
#define RREP(i,n,N) for(int i=N-1;i>=n;i--)
#define CK(n,a,b) ((a)<=(n)&&(n)<(b))
#define F first
#define S second
typedef long long ll;
using namespace std;
const int inf = 1e9+7;

string s;
int ansl,ansr;
int main() {
    cin>>s;
    ansl=-1;
    ansr=-1;
    REP(i,0,s.size()){
        if(s[i]==s[i+1]) {
            ansl = i + 1;
            ansr = i + 2;
        }else if(s[i]==s[i+2]) {
            ansl = i + 1;
            ansr = i + 3;
        }
    }
    cout<<ansl<<" "<<ansr<<endl;
    return 0;
}

Measured memory_bytes: 512
#include<iostream>
#include<vector>
#include<string>
#include<cmath>
#include<algorithm>
#include <numeric>
#include<map>
#include<unordered_map>
#include <queue>
 
using namespace std;
using ll=long long;
#define rep(i,n)  for(ll i=0;i<n;++i)
#define all_map(itr,mp) for(auto itr=mp.begin();itr!=mp.end();itr++)
#define ALL(a) (a).begin(),(a).end()
 
int main(){
    string s;
    cin >> s;
    ll ans = s.size();
    ll scnt = 0;
    rep(i, s.size()){
        if(s[i]=='S')scnt++;
        else if(scnt > 0)scnt--, ans-=2;
    }
    cout << ans << endl;
}

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

void call(int n){
    int i = 1;
    while (true) {
        int x = i;
        if ( x % 3 == 0 ){
            cout << " " << i;
            if ( ++i <= n ) continue;
            else break;
        }

        bool flag = false;
        while (true){
            if ( x % 10 == 3 ){
                cout << " " << i;
                if ( ++i <= n ) flag = true;
                else break;
            }
            if (flag) break;
            x /= 10;
            if ( x ) continue;
            break;
        }
        if (flag) continue;
        if ( ++i <= n ) continue;

        break;
    }
        cout << endl;
}

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

    return 0;
}

Measured memory_bytes: 3092
#pragma GCC target("avx2")
#pragma GCC optimize ("O3")
#pragma GCC optimize ("unroll-loops")
#include<bits/stdc++.h>

#define f			first
#define sz(a)       ((int)(a).size())
#define s			second
#define all(v)		v.begin(),v.end()
#define pii 		pair<int,int>
#define vpii 		vector<pii>
#define eb			emplace_back
#define pb			push_back
#define fo(i,n)		for(int i=0;i<n;i++)
#define Fo(i,k,n)	for(int i=k;i<n;i++)
#define vi			vector<int>

using namespace std;
using ll  = long long;
using lld = long double;

const int oo = 0x3f3f3f3f;
const ll MOD = 1000000007;



signed main(){

#ifndef ONLINE_JUDGE
	//freopen("in.txt" , "r" , stdin);
#endif
	ios_base::sync_with_stdio(0);cin.tie(0);

    int n , ans = 0;
    cin >> n;
    vi ar(n);
    for(int i =0 ; i < n ;i++) cin >> ar[i];
    fo(i , n)
        Fo(j , i + 1 , n)
            Fo(k , j + 1 , n){
                if(i == j || j == k || i == k)
                    continue;
                int a = ar[i];
                int b = ar[j];
                int c = ar[k];
                if(a == b || b == c || a == c)
                    continue;
                if(a + b > c && a + c > b && b + c > a)
                    ans++;
            }
            
    cout << ans << '\n';
    return 0;

}



Measured memory_bytes: 3632
#include<map>
#include<queue>
#include<string>
#include<cstdlib>
#include<iostream>

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

using namespace std;

const int INF=1<<29;
const int dx[]={1,0,-1,0},dy[]={0,1,0,-1};

struct edge{ int v,cost; };

int sgn(int a){ return a==0?0:a>0?1:-1; }

int main(){
	for(int n,m;cin>>n>>m,n;){
		map<string,int> f;
		int x[1000],y[1000];
		rep(u,n){
			string s; cin>>s>>x[u]>>y[u];
			f[s]=u;
		}

		vector<edge> G[1000];
		rep(i,m){
			string s,t; cin>>s>>t;
			int u=f[s],v=f[t],cost=abs(x[u]-x[v])+abs(y[u]-y[v]);
			G[u].push_back((edge){v,cost});
			G[v].push_back((edge){u,cost});
		}
		int s,t;
		{
			string a,b; cin>>a>>b;
			s=f[a];
			t=f[b];
		}

		int d[1000][4],crs[1000][4]; // 最短距離, 通過した交差点の最小個数
		rep(u,n) rep(k,4) d[u][k]=crs[u][k]=INF;
		rep(k,4){
			d[s][k]=0;
			crs[s][k]=1;
		}

		priority_queue< pair< int,pair<int,int> > > Q;
		rep(k,4) Q.push(make_pair(0,make_pair(s,k)));
		while(!Q.empty()){
			int d_now=-Q.top().first,u=Q.top().second.first,k=Q.top().second.second;
			Q.pop();

			if(d[u][k]<d_now) continue;

			rep(i,G[u].size()){
				int v=G[u][i].v,cost=G[u][i].cost;

				// 直進 or 左折のみ
				int k2=-1;
				if(sgn(x[v]-x[u])==sgn(dx[k])
				&& sgn(y[v]-y[u])==sgn(dy[k])) k2=k;
				if(sgn(x[v]-x[u])==sgn(dx[(k+1)%4])
				&& sgn(y[v]-y[u])==sgn(dy[(k+1)%4])) k2=(k+1)%4;
				if(k2==-1) continue;

				int d2=d[u][k]+cost,crs2=crs[u][k]+1;
				if(d[v][k2]==d2){
					crs[v][k2]=min(crs[v][k2],crs2);
				}
				else if(d[v][k2]>d2){
					d[v][k2]=d2;
					crs[v][k2]=crs2;
					Q.push(make_pair(-d[v][k2],make_pair(v,k2)));
				}
			}
		}

		int ans=-1;
		rep(k,4) if(d[t][k]<INF) {
			if(ans==-1 || make_pair(d[t][k],crs[t][k])<make_pair(d[t][ans],crs[t][ans]))
				ans=k;
		}
		if(ans==-1) cout<<"impossible"<<endl;
		else        cout<<crs[t][ans]<<endl;
	}

	return 0;
}

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

using namespace std;

int main()
{
  string A;
  cin >> A;

  long long hist[30] = { };

  long long cnt = 0;
  for (int i = 0; i < A.size(); i++) {
    for (int j = 0; j < 26; j++) {
      if (j != A[i] - 'a') cnt += hist[j];
    }
    hist[A[i] - 'a']++;
  }
  
  cout << (cnt + 1) << endl;

  return 0;
}


Measured memory_bytes: 640
D = gets.to_i
C = gets.chomp.split.map(&:to_i)
s = D.times.map{gets.split.map(&:to_i)}
c = Array.new(26, 0)
t = []

(0..D-1).each do |i|

  (0..25).each do |l|
    c[l] += C[l]
  end
ans = 0
boder = s[i][0]+c[0]

  (1..25).each do |e|
    if s[i][e]+c[e] >= boder
      ans = e
      boder = s[i][e]+c[e]
    end
  end
c[ans] = 0
puts ans+1
end


  



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

ll n, x, ans;

ll gcd (ll a, ll b) {
	ans += a / b * 2 * b;
	if (a%b) gcd(b, a%b); else ans -= b;
}
int main () {
	cin >> n >> x;
	ans = n;
	gcd(n - x, x);
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ull long long
 
using namespace std ;
long long fac[100005]; 
long long infact[100005];   

ull mul(ull a,ull b,ull c){
   return ((a%c) * (b%c)) % c;
}
ull exp(ull a,ull b,ull c){
   if(b==0)return 1;
   ull dev=exp(a,b>>1,c);
   dev=mul(dev,dev,c);
   if(b&1)dev=mul(dev,a,c);
   return dev;
}
 

  
// Returns n^(-1) mod p 
int modInverse(int n, int p) 
{ 
    return exp(n, p-2, p); 
} 
  
// Returns nCr % p using Fermat's little 
// theorem. 
int nCrModP(int n, int r, int p) 
{ 
   // Base case 
   if (r==0) 
      return 1; 
  
    return mul( fac[n], mul( infact[r], infact[n-r], p), p);
} 

int main(){
   int p = 1000000007;
   fac[0] = 1; 
   infact[0] = 1;
   for (int i=1 ; i<=100001; i++){
        fac[i] = (fac[i-1]*i)%p; 
        infact[i] = modInverse(fac[i], p);
   }  
  int n, k; cin>>n>>k;
  
  vector<int>a(n);
  
  for(int & i : a) cin>>i;
  
  sort(a.begin(), a.end());
  
  long long ans = 0;
  
  for(int i = 0; i<n; i++){
     
    if(i >= k - 1 ){
  		ans += mul( nCrModP(i, k - 1, p), a[i], p) ;
    }
    
   ans %= p;
   
    if(n - i - 1 >= k - 1){
   		ans -=  mul( nCrModP(n - i - 1, k - 1, p), a[i], p);
    }
    
    ans %= p;

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


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

using namespace std;

int main() {
//        freopen("input.txt", "r", stdin);
//        freopen("output.txt", "w", stdout);
        int n;
        scanf("%d", &n);
        vector<vector<int>> dp(n, vector<int>(3, 0));
        auto a = dp;
        for (int i = 0; i < n; i++) {
                for (int j = 0; j < 3; j++) {
                        scanf("%d", &a[i][j]);
                }
        }
        for (int i = 0; i < 3; i++) {
                dp[0][i] = a[0][i];
        }
        for (int i = 0; i + 1 < n; i++) {
                for (int j = 0; j < 3; j++) {
                        for (int k = 0; k < 3; k++) {
                                if (j != k) {
                                        dp[i + 1][k] = max(dp[i + 1][k], dp[i][j] + a[i + 1][k]);
                                }
                        }
                }
        }
        int mx = 0;
        for (int i = 0; i < 3; i++) {
                mx = max(mx, dp[n - 1][i]);
        }
        printf("%d\n", mx);
        return 0;
}


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


int main(){
string a,b,c,s;
a = "Sunny";
b = "Cloudy";
c = "Rainy";

cin >> s;

if (s == a) cout << b << endl;
if (s == b) cout << c << endl;
if (s == c) cout << a << endl;
} 

Measured memory_bytes: 256
import java.util.*;

public class Main{
  public static void main(String[] args) {
    Scanner sc=new Scanner(System.in);
    int x=sc.nextInt();
    int a=sc.nextInt();
    int b=sc.nextInt();
    int ad=Math.abs(x-a);
    int bd=Math.abs(x-b);
    if (ad>bd) {
      System.out.println("B");
    }else{
      System.out.println("A");
    }
  }
}


Measured memory_bytes: 21460
#include <stdio.h>

int main(void){
    int i,flag,temp;
    char mo[3];
    for(i=0;i<3;i++){
        scanf("%c",&mo[i]);
    }
    for(i=0;i<3;i++){
        if(mo[i]=='A'){
            temp=0;
        }
        else{
            temp=1;
        }
    if(i!=0 && temp !=flag){
        printf("Yes");
        return 0;
    }
    flag =temp;
    }
    printf("No");
    return 0;
}

Measured memory_bytes: 128
#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <iostream>
#include <math.h>
#include <assert.h>
#include <vector>

using namespace std;
typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
static const double EPS = 1e-9;
static const double PI = acos(-1.0);

#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, s, n) for (int i = (s); i < (int)(n); i++)
#define FOREQ(i, s, n) for (int i = (s); i <= (int)(n); i++)
#define FORIT(it, c) for (__typeof((c).begin())it = (c).begin(); it != (c).end(); it++)
#define MEMSET(v, h) memset((v), h, sizeof(v))

int te[5];
int main() {
  while (true) {
    vector<int> cnt(3, 0);
    REP(i, 5) {
      int v;
      if (scanf("%d", &v), v == 0) { return 0; }
      v--;
      te[i] = v;
      cnt[v]++;
    }
    REP(i, 5) {
      int win = 2;
      if (cnt[te[i]] == 5 || (cnt[0] > 0 && cnt[1] > 0 && cnt[2] > 0)) {
        win = 3;
      } else if (cnt[(te[i] + 2) % 3] == 0) {
        win = 1;
      }
      printf("%d\n", win);
    }
  }
}

Measured memory_bytes: 0
object Main extends App{
  import scala.io.StdIn._
  @scala.annotation.tailrec
  def gcd(a: Long, b: Long): Long = {
    if(b == 0L) a
    else gcd(b, a%b)
  }
  val n=readLong()
  var ans:Long=0L
  for{i <- (1L to n);j<- (1L to n);k <-(1L to n)}{
    ans+=gcd(k,gcd(i,j))
  }
  println(ans)
}

Measured memory_bytes: 57168
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <map>
#include <vector>
#include <queue>
#include <algorithm>

using namespace std;

//typedef pair<int,int> P;



int main(){
	map<string, int> mp;

	string s;
	char str[5001];
	int K;
	scanf("%s", str);
	scanf("%d", &K);

	s = str;

	for(int i=0;i<s.length();i++){
		for(int j=1;j<=K;j++){
			string sub = s.substr(i, j);
			auto itr = mp.find(sub);
			if(itr == mp.end()){
				mp[sub] = i*s.length() + j;
				//printf("%s\n", sub.c_str());
			}
		}
	}

	auto iter = mp.begin();
	iter = next(iter, K-1);
	printf("%s\n", iter->first.c_str());

	return 0;
}


Measured memory_bytes: 1920
#include <bits/stdc++.h>
using namespace std;
#define int         long long
#define endl        "\n"
#define P           pair<int, int>

const int mod = 1e9+7;

inline int add(int a, int b) { int res = a + b; if(res >= mod) res -= mod;  return res; }
inline int sub(int a, int b) { int res = a - b; if(res < 0) res += mod; return res;}
inline int mul(int a, int b) { return (a * b)%mod; }

int modpow(int a, int b) {
    int ans = 1;
    while(b) {
        if(b%2) ans = mul(ans, a);    
        b /= 2; a = mul(a, a);
    }   return ans;
}

const int N = 1e5+5;
vector<P> g[N];
int n;

bool cmp1(pair<int, P> a, pair<int, P> b) {
    return a.second.first < b.second.first;
}

bool cmp2(pair<int, P> a, pair<int, P> b) {
    return a.second.second < b.second.second;
}

int MST() {
    priority_queue<P, vector<P>, greater<P>> q;
    int cost = 0;
    q.push({0, 0});
    bool mark[N]; memset(mark, 0, sizeof mark);
    while(!q.empty()) {
        P tp = q.top(); q.pop();
        int cur = tp.second;
        if(mark[cur]) continue;
        cost += tp.first;
        mark[cur] = 1;
        for(auto ne : g[cur]) {
            int node = ne.second;
            if(mark[node] == false) q.push(ne);
        }
    }
    return cost;
}

void solve() {
    cin >> n;
    pair<int, P> a[n];
    for(int i=0; i<n; i++) {
        P p; cin >> p.first >> p.second;
        a[i] = make_pair(i, p);
    }
    sort(a, a+n, cmp1);
    for(int i=1; i<n; i++) {
        int d = a[i].second.first - a[i-1].second.first;
        int u = a[i-1].first, v = a[i].first;
        g[v].push_back({d, u});
        g[u].push_back({d, v});
    }
    sort(a, a+n, cmp2);
    for(int i=1; i<n; i++) {
        int d = a[i].second.second - a[i-1].second.second;
        int u = a[i-1].first, v = a[i].first;
        g[u].push_back({d, v});
        g[v].push_back({d, u});
    }

    cout << MST() << endl;
}

signed main() {

    ios_base::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);
    cout << fixed << setprecision(12);

    int T = 1;
    //cin >> T;

    while(T--) {
        solve();
    }
    return 0;
}

Measured memory_bytes: 16244
#include<bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define pii pair<int,int>
#define pp pair<pair<ll, ll>,pair<ll, ll>>
#define pll pair<ll,ll>
#define pdd pair<double,double>
#define vii vector<int>
#define vll vector<ll>
#define mat vector<vector<ll>>
#define lb lower_bound
#define ub upper_bound
#define pb push_back
#define eb emplace_back
#define fi first
#define sc second
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep2(i,a,b) for(ll i=a;i<b;i++)
#define repr(i,n) for(ll i=n-1;i>=0;i--)
#define all(x) x.begin(),x.end()
#define sz(x) (ll) (x).size()
#define pq priority_queue<ll>
#define pqg priority_queue<ll,vector<ll>,greater<ll>>
#define LB(v,x) (lower_bound(v.begin(),v.end(),x)-v.begin())
#define UB(v,x) (upper_bound(v.begin(),v.end(),x)-v.begin())
#define ERASE(v) sort(v.begin(),v.end());v.erase(unique(v.begin(),v.end()),v.end())
#define int ll
// #define ll int
using namespace std;
const ll INF = (1 << 30 ) - 1;
const ll LLINF = (1LL << 60LL);
const ll MOD = 1000000007;
// const ll mod = 998244353;
const ll MAX = 2100000;
const double pi = acos(-1);
const double eps = 1e-10;
ll dx[8] ={1,0,-1,0,1,-1,1,-1};
ll dy[8] ={0,1,0,-1,1,-1,-1,1};
 
template<class T> 
inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> 
inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }







void solve(){
    ll k;
    cin>>k;
    ll a=7;
    a%=k;
    rep(i,50000000){
        if(a==0){
            cout<<i+1<<endl;
            return;
        }
        a*=10;a%=k;
        a+=7;a%=k;
    }
    cout<<-1<<endl;
}

signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);


    solve(); 


    return 0;
}


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

int main() {
  string s;cin>>s;
  if (s == "Sunny") cout << "Cloudy" << endl;
  else if (s == "Cloudy") cout << "Rainy" << endl;
  if (s == "Rainy") cout << "Sunny" << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
using namespace std;
int main(void){
    
    // 正解した問題の数を「　positiveNumber　」と置く
    int positiveNumber;
    cin >> positiveNumber;
    
    // 各、問題の得点を「　score　」と配列で置く
    vector<int> score( positiveNumber );
    
    // 各、問題の得点を入力する
    for(int i = 0; i < positiveNumber; i++) cin >> score[i];
    
    // 得点の最大値を「　maxScore = positiveNumber　」と置く。
    // 何故：maxScore = positiveNumber　を代入したか　maxScore は 答えが 1 ～ positiveNumber の間にあるから
    int maxScore = positiveNumber;
    
    // 今回のスコア算出の計算と条件
    while(1){
        
        // 正解が A 問以上の個数を「 count 」と置く
        int count = 0;
        
        // 得点が A 以上である個数を求める
        for(int i = 0; i < positiveNumber; i++){
            if(maxScore <= score[i]) count++;
        }
        
        // 問題の条件：得点が A 以上であるものが A 問以上あることを満たすような最大の A そのチームのスコア
        if(maxScore <= count){
            cout << maxScore << endl;
            break;
        }
        
        // 次の最大値 maxScore になるように　-1する
        maxScore--;
    }
    
}



Measured memory_bytes: 3116
#include<bits/stdc++.h>
                using namespace std;
                #define lli long long int
                #define fr(i,a,b) for(int i=a;i<b;i++)
                #define bfr(i,a,b) for(int i=a;i>=b;i--)
                #define fio ios_base::sync_with_stdio(false); cin.tie(NULL),cout.tie(NULL);
                #define tc int t;cin>>t;while(t--)
                #define mod 1000000007 
                #define all(vec) vec.begin(),vec.end()  
                #define ld long double


                   

               
        int main()
                {
                       
                    
                     fio


                     lli a,b,c;
                     cin>>a>>b>>c;

                    
                     if(a>=c || b>=c)cout<<"No";
                     else if(2*sqrtl(a*b)<c-b-a)cout<<"Yes";
                     else cout<<"No";


                     


                     



                     

                     

                     

                     





                     


                     







                     


                     

                     

                     


return 0;}

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

#define _CRT_SECURE_NO_WARNINGS
#define TLong long long
#define TBMod 1000000007

int main(int argc, char const *argv[])
{
	int h,w;
	char a[107][107] = { '\0' };
	scanf("%d%d",&h,&w);
	for (int i = -1; i <= h; ++i)
	{
		if(i == -1 || i == h){
			for (int i = 0; i < w + 2; ++i)	printf("#");
			puts("");
		}
		else{
			scanf(" %s",a[i]);
			printf("#%s#\n",a[i]);
		}
	}
	return 0;
}


Measured memory_bytes: 128
#include "bits/stdc++.h"
using namespace std;
#define Rep(i,n) for(int i=0;i<n;i++)
#define For(i,n1,n2) for(int i=n1;i<n2;i++)
#define REP(i,n) for(ll i=0;i<n;i++)
#define RREP(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,n1,n2) for(ll i=n1;i<n2;i++)
#define put(a) cout<<a<<"\n"
#define all(a)  (a).begin(),(a).end()
#define SORT(a) sort((a).begin(),(a).end())
#define oorret 0
#define oor(x) [&](){try{x;} catch(const out_of_range& oor){return oorret;} return x;}()
typedef long long ll;
typedef pair<int, int> P;
template<typename T1,typename T2> inline bool chmin(T1 &a,T2 b){if(a>b){a=b;return 1;}return 0;}
template<typename T1,typename T2> inline bool chmax(T1 &a,T2 b){if(a<b){a=b;return 1;}return 0;}

const int MAXN = 50;
bool visited[MAXN];


int main(){
    int n,k;
    cin >> n >> k;
    vector<int> l(n);
    REP(i,n){
        cin >> l[i];
    }
    sort(all(l),greater<>());
    int res = 0;
    REP(i,k){
        res += l[i];
    }
    put(res);
    return 0;
}


Measured memory_bytes: 256
// 課題3_4 AtCoder Beginner Contest 144 B - 81
// nk777
 
#include <stdio.h>
 
int main(void){
    // 整数Nを格納num,カウンタi_count, 結果格納result
    int num, i_count, result = 0;
 
    // nを受け取る
    scanf("%d", &num);
 
    for (i_count = 1; i_count < 10; i_count++)
    {
        // iの段を調べる
        // num/iの商が整数で1以上9以下
        if (num % i_count == 0 && 0 < num / i_count && num / i_count < 10)
        {
            result = 1;
            break;
        }
    }
    if (result == 1)
    {
        printf("Yes\n");
    }
    else
    {
        printf("No\n");
    }
    
    return 0;
}

Measured memory_bytes: 128
#include <cstdio>
#include <climits>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <list>
#include <set>
#include <bitset>
#include <iterator>
#define rep(i, n) for(long long i = 0; i < (long long)(n); i++)
using namespace std;
typedef long long int LL;
typedef unsigned long long int ULL;
LL f(LL n) {
    if (n % 2 == 0) {
        return n / 2;
    } else {
        return 3 * n + 1;
    }
}
int main() {
    LL s;
    cin >> s;
    vector<LL> v;
    v.push_back(-1);
    for (int i = 1; ; i++) {
        if (i == 1) {
            v.push_back(s);
        } else {
            v.push_back(f(v[i-1]));
        }
        for (int j = 1; j <=i - 1; j++) {
            for (int k = j + 1; k <= i; k++) {
                if (v[j] == v[k]) {
                    cout << k << endl;
                    return 0;
                }
            }
        }
    }

    return 0;
}


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

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

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

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

using namespace std;

typedef long long ll;

#define sz(x) ((int)(x).size())
#define in(x) int x;cin>>x
#define in2(x, y) int x,y;cin>>x>>y
#define bit(n) (1<<(n))

#define out(x) cout<<(x)<<endl;
#define err(x) cerr<<(x)<<endl;
#define errr(x,y) cerr<<(x)<<" "<<(y)<<endl;

#define rep(i,n) for (int i=0;i<(n);i++)
#define repp(i,n) for (int i=1;i<=(n);i++)

#define lim5 100002
#define lim9 1000000002

int main(){
	in(n);
	string s, ans = "";
	cin >> s;
	char b = '0';

	rep(i, n){
		if (b != s[i]) {
			ans += s[i];
			b = s[i];
		}
	}

	cout << ans.length() << endl;

	return 0;
}


Measured memory_bytes: 640
N = int(input())
A = list(map(int,input().split()))

swapcnt = 0

def bubbleSort(A):
  global N,swapcnt
  for i in range(N):
    for j in  range(N-1,i,-1):
      if A[j] < A[j-1]:
        x = A[j]
        A[j] = A[j-1]
        A[j-1] = x
        swapcnt += 1

def selectionSort(A):
  global N,swapcnt
  for i in range(N):
    minj = i
    for j in range(i,N):
      if A[j] < A[minj]:
        minj = j
    if minj != i :
      x = A[minj]
      A[minj] = A[i]
      A[i] = x
      swapcnt += 1

#bubbleSort(A)
selectionSort(A)
strA = [str(a) for a in A]
print(" ".join(strA))
print(swapcnt)


Measured memory_bytes: 5604
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,m,n) for(int i=(m);i<(n);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
using ll = long long;
const int INF = 0x3f3f3f3f;
const ll LINF = 0x3f3f3f3f3f3f3f3fLL;
const double EPS = 1e-8;
const int MOD = 1000000007;
// const int MOD = 998244353;
const int dy[] = {1, 0, -1, 0}, dx[] = {0, -1, 0, 1};
const int dy8[] = {1, 1, 0, -1, -1, -1, 0, 1}, dx8[] = {0, -1, -1, -1, 0, 1, 1, 1};
template <typename T, typename U> inline bool chmax(T &a, U b) { return a < b ? (a = b, true) : false; }
template <typename T, typename U> inline bool chmin(T &a, U b) { return a > b ? (a = b, true) : false; }
struct IOSetup {
  IOSetup() {
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(20);
  }
} iosetup;

int main() {
  int h, w; cin >> h >> w;
  vector<string> s(h); REP(i, h) cin >> s[i];
  vector<vector<int> > dist(h, vector<int>(w, INF));
  dist[0][0] = s[0][0] == '#';
  REP(i, h) REP(j, w) {
    if (i > 0) chmin(dist[i][j], dist[i - 1][j] + (s[i - 1][j] == '.' && s[i][j] == '#'));
    if (j > 0) chmin(dist[i][j], dist[i][j - 1] + (s[i][j - 1] == '.' && s[i][j] == '#'));
  }
  cout << dist[h - 1][w - 1] << '\n';
  return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define In_The_Name_Of_Allah_The_Merciful ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define Alhamdulillah return 0;
#define all(v) v.begin(),v.end()
#define debug(n) cerr << "[" << #n << " = " << n << "]" << endl 

void Suhaib_Sawalha (){

    int n , m , c;
    cin >> n >> m >> c;
    cout << min ({n+m , c+m , c+n});

}

int main(){
                                In_The_Name_Of_Allah_The_Merciful   /* بسم الله الرحمن الرحيم  */
#ifndef ONLINE_JUDGE
    freopen("SuhaibSawalha1.txt","r",stdin);
#endif
//int _;for(cin>>_;_;--_,cout<<'\n')
        Suhaib_Sawalha();
                                         Alhamdulillah                    /* الحمد لله */
}

Measured memory_bytes: 3596
raw_input()
ls = map(int, raw_input().split(" "))
ls.sort()
ls.reverse()
i = 0
answer = []
while i < len(ls) - 1:
  if ls[i] == ls[i+1]:
    answer.append(ls[i])
    if len(answer) >= 2:
      break
    i += 1
  i += 1

if len(answer) == 2:
  print answer[0] * answer[1]
else:
  print 0

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

int num_sum(int x){
  int y = 1;
  int count = 0;
  int x_mirror = x;
  while(x >= y){
    x_mirror = x;
    x_mirror = x_mirror / y;
    count += x_mirror %10;
    y *= 10;
  }
  return count;
}
int main(){
  int N;
  cin >> N;
  int ans = 100000;
  for(int i=1; i<N; i++){
    int ans_a = num_sum(i) + num_sum(N-i);
    ans = min(ans,ans_a);
  }
  cout << ans << endl;
}

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

int main(){
	int n,i;
	cin >> n;
	int a[n], ans[n];
	for(i = 0; i < n; i++){
		cin >> a[i];
	}
	for(i = 0; i < n; i++){
		ans[a[i]-1] = i+1;
	}

	cout << ans[0];
	for(i = 1; i < n; i++){
		cout << " " << ans[i];
	}
	return 0;
}


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

int main()
{
    int N;
    int A[200000];
    cin >> N;
    for(int i=0; i<N; i++)
        cin >> A[i];

    bool res = false;

    sort(A,A+N);

    for(int j=0; j<N-1; j++)
    {
        if(A[j] == A[j+1])
        {
            res = true;
            break;
        }
    }

    if(res)
        cout << "NO";
    else
    {
        cout << "YES";
    }
    
    return 0;
}

Measured memory_bytes: 1024
#include<cstdio>
int main(){
	int n;
	scanf("%d",&n);
	int a[n];
	for(int i=0;i<n;i++){
		scanf("%d",&a[i]);
	}
	int x=0;
	int y=0;
	for(int i=0;i<n;i++){
		if(a[i]==i+1){
			y++;
		}
		else{
			x=x+(y+1)/2;
			y=0;
		}
	}
	x=x+(y+1)/2;
	printf("%d",x);
	return 0;
}

Measured memory_bytes: 512
<?php
$nl=(int)trim(fgets(STDIN));

$node=array($nl);

for($i=0;$i<$nl;$i++){
	$node[$i]=array('ca'=>-1,'cb'=>-1,'pa'=>-1);
}

for($i=0;$i<$nl;$i++){
	$ls=explode(' ',trim(fgets(STDIN)));#lines
	$id=(int)array_shift($ls);
	$ca=(int)array_shift($ls);
	$cb=(int)array_shift($ls);

	if($ca!=-1){
		$node[$id]['ca']=$ca;#left
		$node[$ca]['pa']=$id;#parent
	}
	if($cb!=-1){
		$node[$id]['cb']=$cb;#right
		$node[$cb]['pa']=$id;
	}
}

$root=-1;
for($i=0;$i<$nl;$i++){
	if($node[$i]['pa']==-1){
		$root=$i;
		break;
	}
}

printf("Preorder\n");
prtw($root);
printf("\nInorder\n");
intw($root);
printf("\nPostorder\n");
pstw($root);
printf("\n");

function pstw($id){
	global $node;
	$ni=$node[$id];
	if($ni['ca']!=-1){pstw($ni['ca']);}
	if($ni['cb']!=-1){pstw($ni['cb']);}
	printf(" %d",$id);
}

function intw($id){
	global $node;
	$ni=$node[$id];
	if($ni['ca']!=-1){intw($ni['ca']);}
	printf(" %d",$id);
	if($ni['cb']!=-1){intw($ni['cb']);}
}

function prtw($id){
	global $node;
	$ni=$node[$id];
	printf(" %d",$id);
	if($ni['ca']!=-1){prtw($ni['ca']);}
	if($ni['cb']!=-1){prtw($ni['cb']);}
}

Measured memory_bytes: 15448
#include <iostream>
#include <cstdio>

using namespace std;
 
int main(){
    int n;
     
    while(cin >> n,n){
        int h,m,dm,lcnt=0,dcnt=0,mcnt = 0,ll=0,dd=0,mm=0;
        for(int i = 0 ; i < n ; i++){
            scanf("%d:%d %d" ,&h ,&m ,&dm);
            if((2 <= h && h < 11) || (15 <= h && h < 18)) continue;
            if(h < 2) h += 24;
            int t = h*60+m,dt = h*60+dm;
            if(dt < t) dt += 60;
            int a = dt-t;
         
            if(11 <= h && h <= 14){
                lcnt++;
                if(a <= 8) ll++;
            }
            else if(18 <= h && h <= 20){
                dcnt++;
                if(a <= 8) dd++;
            }
            else if(21 <= h && h <= 25){
                mcnt++;
                if(a <= 8) mm++;
            }
        }
        if(!lcnt) cout << "lunch no guest" << endl;
        else cout << "lunch " << ll*100/lcnt << endl;
        if(!dcnt) cout << "dinner no guest" << endl;
        else cout << "dinner " << dd*100/dcnt << endl;
        if(!mcnt) cout << "midnight no guest" << endl;
        else cout << "midnight " << mm*100/mcnt << endl;
    } 
    return 0;             
}

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

int main(){
  int n;
  cin >> n;
  int ans = 0;
  for(int i = 1 ; i <= n ; i += 2){
    int cnt = 0;
    for(int j = 1 ; j * j <= i ; j += 2){
      if(i % j == 0){
        cnt += 2;
        if(j * j == i){
          cnt--;
        }
      }
    }
    if(cnt == 8){
      ans++;
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
// https://atcoder.jp/contests/abc148/tasks/abc148_b

#include "algorithm"
#include "bitset"
#include "cmath"
#include "functional"
#include "iomanip"
#include "iostream"
#include "map"
#include "numeric"
#include "queue"
#include "set"
#include "string"
#include "vector"
#define rep(i, to) for (ll i = 0; i < (to); ++i)
#define rep1(i, to) for (ll i = 1; i <= (to); ++i)
#define repf(i, from, to) for (ll i = from; i < (to); ++i)
#define repr(i, from) for (ll i = from - 1; i >= 0; --i)
#define all(vec) vec.begin(), vec.end()
#define unless(cond) if (!(cond))
#define fi first
#define se second
using namespace std;
typedef long long ll;
template <typename T>
using V = vector<T>;
using VL = V<ll>;
using VVL = V<VL>;
template <typename T, typename U>
using P = pair<T, U>;
using PL = P<ll, ll>;
using VPL = V<PL>;
template <typename T>
inline bool chmax(T& a, T b);
template <typename T>
inline bool chmin(T& a, T b);
void print_ints(vector<ll> v);
template <typename T>
void drop(T a);

const ll INF = 1e18;

void solve() {
  ll N;
  string S, T;
  cin >> N >> S >> T;

  string res;

  rep(i, N) {
    res.push_back(S[i]);
    res.push_back(T[i]);
  }

  cout << res << endl;
}

struct exit_exception : public std::exception {
  const char* what() const throw() { return "Exited"; }
};

#ifndef TEST
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);

  try {
    solve();
  } catch (exit_exception& e) {
  }

  return 0;
}
#endif

template <typename T>
inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}

template <typename T>
inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}

void print_ints(vector<ll> v) {
  rep(i, v.size()) {
    if (i > 0) {
      cout << " ";
    }

    cout << v[i];
  }

  cout << endl;
}

template <typename T>
void drop(T res) {
  cout << res << endl;
  throw exit_exception();
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vpii = vector<pair<int,int>>;
using vpll = vector<pair<ll,ll>>;
using vi = vector<int>;
#define rep(i,n) for(int i=0;i<(int) n;i++)
#define rep1(i,m,n) for(int i=(int) m;i<(int) n;i++)
#define fix(n) cout << fixed << setprecision((int)n)

void absll(ll &x) {
    if(x>=0) return ;
    else x=-x; return;
}

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

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

const ll INF = 1LL << 60;

int N;

//DPテーブル
vector<ll> dp(100010);

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

Measured memory_bytes: 3912
// AtCoder165 C

#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <math.h>
#include <assert.h>
#include <string.h>
#include <memory.h>
#include <malloc.h>
#include <stdlib.h>

// qsortで用いる比較用関数．*a<*bならaが先になる．
int compare(const void* a, const void* b) {
    return *(int*)a - *(int*)b;
}

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


int main() {
    int i,j;
    int n;
    int* d;
    int center_i;

    scanf("%d", &n);
    d = (int*)malloc(sizeof(int) * n);
    for(i=0;i<n;i++){
        scanf("%d", d + i);
    }

    qsort(d,n ,sizeof(int), compare);

    center_i = n/2 - 1;
    printf("%d", d[center_i+1]- d[center_i]);
    return 0;
}

Measured memory_bytes: 892
#include<iostream>
using namespace std; 
int main(){
    long long int n, m, k;
    scanf("%lld%lld%lld", &n, &m, &k);
    long long int a[200005], b[200005], i, j;
    for(i = 0; i < n; i++)
        scanf("%lld", &a[i+1]);
    
    for(i = 0; i < m; i++)
        scanf("%lld", &b[i+1]);
        
    
    a[0] = b[0] = 0;
    
    for(i = 0; i < n; i++)
        a[i+1] += a[i];
    
    for(i = 0; i < m; i++)
        b[i+1] += b[i];
    
    long long int ans = 0;
    j = m;
    for(i = 0; i <= n; i++){
       while(j >=0 && a[i] + b[j] > k)
           j--;
        if(j >= 0)
               if(ans < i + j)
                   ans = i + j; 
    }
    printf("%lld\n", ans);
    return 0;
}    


Measured memory_bytes: 6856