akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i=0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
using ll = long long;
using VI = vector<int>;
using VVI = vector<vector<int>>;

int main(){
  string s[3];
  cin >> s[0] >> s[1] >> s[2];
  
  int turn=0;
  VI num(3), ini(3);
  rep(i,3){
    ini[i] = s[i].length();
    num[i] = s[i].length();
  }
  
  while(1){
    if(num[turn] == 0) break;
    char x = s[turn][ini[turn] - num[turn]];
    num[turn]--;
    if(x=='a') turn = 0;
    else if(x=='b') turn = 1;
    else turn = 2;
  }
  
  if(turn==0) cout << 'A' << endl;
  else if(turn==1) cout << 'B' << endl;
  else cout << 'C' << endl;
  
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main()
{
	int n,m,a[10008],z=0;
	cin>>n>>m;
	for(int i=1;i<=m;i++)
	{
		cin>>a[i];
		z+=a[i];
	}
	if(z<=n) cout<<n-z<<endl;
	else
	cout<<-1<<endl;
	return 0;
 } 

Measured memory_bytes: 3628
#include "bits/stdc++.h"
using namespace std;

int main() {
  int a,b;
  string s;
  cin>>a>>b>>s;
  int ans=0;
  if(s.at(a)=='-') {
    ans++;
  }
  for(int i=0;i<a;i++) {
    if('0'<=s.at(i)&&s.at(i)<='9') {
      ans++;
    }
  }
  for(int i=a+1;i<a+b+1;i++) {
    if('0'<=s.at(i)&&s.at(i)<='9') {
      ans++;
    }
  }
  if(ans==a+b+1) {
    cout<<"Yes"<<endl;
  }
  else {
    cout<<"No"<<endl;
  }
}

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

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VL;
typedef vector<VL> VVL;

__attribute__((constructor))
void initial(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed <<setprecision(15);
}


int main(void){
	ll H,W;
    cin >> H >> W;
    ll h = (H+1)/2;
    ll w = (W+1)/2;
    ll ans = h*w + (H/2)*(W/2);
    if(H == 1){
        ans = 1;
    }
    if (W == 1) ans = 1;
    cout << ans << endl;
    return 0;
}


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

int s[105][105];

int main(){
  int w,h,n;
  int x[105];
  int y[105];
  int a[105];

  int i,j,k;


  scanf("%d %d %d", &w, &h, &n);

  int sum = 0;
  for(i = 1;i <= h;i++){
    for(j = 1;j <= w;j++){
      s[i][j] = 1;
      sum += s[i][j];
    }
  }

//  printf("%d\n", sum);


  for(i = 0;i < n;i++) scanf("%d %d %d", &x[i], &y[i], &a[i]);

  for(i = 0;i < n;i++){
    if(a[i] == 1){
      for(j = 1;j <= h;j++){
        for(k = 1;k <= x[i];k++) s[j][k] = 0;
      }
    }

    else if(a[i] == 2){
      for(j = 1;j <= h;j++){
        for(k = x[i] + 1;k <= w;k++) s[j][k] = 0;
      }
    }

    else if(a[i] == 3){
      for(j = 1;j <= y[i];j++){
        for(k = 1;k <= w;k++) s[j][k] = 0;
      }
    }

    else {
      for(j = y[i] + 1;j <= h;j++){
        for(k = 1;k <= w;k++) s[j][k] = 0;
      }
    }
  }

  int ans = 0;
  for(i = 1;i <= h;i++){
    for(j = 1;j <= w;j++) ans += s[i][j];
  }

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

  return 0;
}

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

#define ll long long

int n,f[1000010],add;

int main()
{
    scanf("%d",&n);
    f[n]=n;
    f[n-1]=(ll)n*n%1000000007;
    for(int i=n-2;i>=1;--i)
    {
        add=(add+f[i+3])%1000000007;
        f[i]=f[i+1];
        f[i]=(f[i]+(ll)(n-1)*(n-1)%1000000007)%1000000007;
        f[i]=(f[i]+add)%1000000007;
        f[i]=(f[i]+i+1)%1000000007;
    }
    printf("%d\n",f[1]);
    return 0;
}

Measured memory_bytes: 4096
import java.util.Scanner;

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

        int a = scanner.nextInt();
        int b = scanner.nextInt();

        if (a == b) {
            System.out.println("a == b");
        } else if (a > b) {
            System.out.println("a > b");
        } else {
            System.out.println("a < b");
        }

    }
}


Measured memory_bytes: 26116
#include<stdio.h>
#include<algorithm>
#include<vector>
#define BEGIN_STACK_EXTEND(size) void * stack_extend_memory_ = malloc(size);void * stack_extend_origin_memory_;char * stack_extend_dummy_memory_ = (char*)alloca((1+(int)(((long long)stack_extend_memory_)&127))*16);*stack_extend_dummy_memory_ = 0;asm volatile("mov %%rsp, %%rbx\nmov %%rax, %%rsp":"=b"(stack_extend_origin_memory_):"a"((char*)stack_extend_memory_+(size)-1024));
 
#define END_STACK_EXTEND asm volatile("mov %%rax, %%rsp"::"a"(stack_extend_origin_memory_));free(stack_extend_memory_);

using namespace std;
vector<pair<int,long long> >g[210000];
long long val[410000];
long long kt[410000];
int v[410000];
int sz;
void dfs(int a,int b){
	v[a]=1;
	for(int i=0;i<g[a].size();i++){
		if(g[a][i].first==b)continue;
		if(!v[g[a][i].first]){
			val[g[a][i].first]=(val[a]^g[a][i].second);
			dfs(g[a][i].first,a);
		}else{
			kt[sz++]=(val[a]^val[g[a][i].first]^g[a][i].second);
		}
	}
}
int main(){
	BEGIN_STACK_EXTEND(120*1024*1024);
	int a,b,c;
	scanf("%d%d%d",&a,&b,&c);
	for(int i=0;i<b;i++){
		int p,q;
		long long r;
		scanf("%d%d%lld",&p,&q,&r);
		g[p].push_back(make_pair(q,r));
		g[q].push_back(make_pair(p,r));
	}
	sz=0;
	dfs(0,-1);
	int now=0;
	for(int i=59;i>=0;i--){
		int at=-1;
		for(int j=now;j<sz;j++){
			if(kt[j]&(1LL<<i)){
				at=j;break;
			}
		}
		if(!~at)continue;
		if(at!=now)swap(kt[at],kt[now]);
		for(int j=0;j<sz;j++){
			if(now==j)continue;
			if(kt[j]&(1LL<<i))kt[j]^=kt[now];
		}
		now++;
	}
	//for(int i=0;i<a;i++)printf("%lld\n",val[i]);
	//for(int i=0;i<now;i++)printf("%lld\n",kt[i]);
	for(int i=0;i<c;i++){
		int p,q;scanf("%d%d",&p,&q);
		long long ret=(val[p]^val[q]);
		for(int j=0;j<now;j++){
			if(ret<(ret^kt[j]))ret^=kt[j];
		}
		printf("%lld\n",ret);
	}
	END_STACK_EXTEND;
}

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

int main() {
	int n; cin >> n;
	vector<int>a(n + 2, 0); for (int i = 1; i <= n; i++)cin >> a[i];
	int sum = 0; for (int i = 1; i < a.size(); i++)sum += abs(a[i] - a[i - 1]);
	
	int ans = 0;
	for (int i = 1; i <= n; i++) {
		ans = sum + abs(a[i + 1] - a[i - 1]) - (abs(a[i - 1] - a[i]) + abs(a[i] - a[i + 1]));
		cout << ans << endl;
	}

	return 0;
}

Measured memory_bytes: 1664
N,K = map(int,input().split())
A = int((N-1)*(N-2)//2)
if K > A:
    print(-1)
else:
    R = A - K
    Edge = []
    M = N-1+R
    for i in range(N-1):
        Edge.append([i+1,N])
    count = 0
    c = 0
    while(count < R):
        a = int(c//N + 1)
        b = c % N +1
        c += 1
        if a <= b:
            continue
        Edge.append([a,b])
        count += 1
    print(M)
    for edge in Edge:
        print(edge[0],edge[1])

Measured memory_bytes: 4148
#include <iostream>
using namespace std;
int main() {
    int W, H, x, y, r;
    cin >> W >> H >> x >> y >> r;
    if(x <= (W-r) && x >= r && y >= r && y <= (H-r) ){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 1156
// ABC_107_A
#include <bits/stdc++.h>
using namespace std;
using ll = long long;

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

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

	cout << n - i +1 << "\n";

	return 0;
}

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

typedef struct {
	long long key, id, pref, city;
} data;

void merge_sort(data x[], int n)
{
	static data y[200001] = {};
	if (n == 1) return;
	merge_sort(&(x[0]), n/2);
	merge_sort(&(x[n/2]), (n+1)/2);
	
	int i, p, q;
	for (i = 0, p = 0, q = n/2; i < n; i++) {
		if (p >= n/2) y[i] = x[q++];
		else if (q >= n) y[i] = x[p++];
		else y[i] = (x[p].key < x[q].key)? x[p++]: x[q++];
	}
	for (i = 0; i < n; i++) x[i] = y[i];
}

int main()
{
	int i, N, M;
	long long P[100001], Y[100001];
	scanf("%d %d", &N, &M);
	for (i = 0; i < M; i++) scanf("%lld %lld", &(P[i]), &(Y[i]));
	
	data X[100001];
	for (i = 0; i < M; i++) {
		X[i].key = Y[i];
		X[i].pref = P[i];
		X[i].city = i;
	}
	merge_sort(X, M);
	
	int p[100001] = {};
	for (i = 0; i < M; i++) {
		X[i].id = X[i].pref * 1000000 + (++p[X[i].pref]);
		X[i].key = X[i].city;
	}	
	merge_sort(X, M);
	
	for (i = 0; i < M; i++) printf("%012lld\n", X[i].id);
	fflush(stdout);
	return 0;
}

Measured memory_bytes: 10624
n,x,y = map(int, input().split())
 
dis = [0]*n
 
for i in range(n):
    for j in range(i+1, n):
        kyori = min(j-i, abs(x - (i+1)) + 1 + abs(y - (j+1)))
        dis[kyori] += 1
 
for k in range(1, n):
    print(dis[k])

Measured memory_bytes: 3444
x1,y1,x2,y2 = map(int,input().split())
vec = [x2-x1,y2-y1]

x3,y3 = x2-vec[1] ,y2+vec[0]
x4,y4 = x1-vec[1], y1+vec[0]

print("{} {} {} {}".format(x3,y3,x4,y4))

Measured memory_bytes: 3060
using System;
using System.Linq;
using System.Collections.Generic;
namespace Solution
{
    class Solution
    {
        static void Main(string[] args)
        {
                bool b = true;
                string[] input = System.Console.ReadLine().Split(' ');
                int h = int.Parse(input[0]), w = int.Parse(input[1]);
                char[][] c = new char[h][];
                for (int i = 0; i < h; i++)
                {
                    c[i] = System.Console.ReadLine().ToCharArray();
                }
                for(int i = 1; i < h-1; i++)
            {
                for(int j = 1; j < w-1; j++)
                {
                    if (c[i][j] == '#')
                    {
                        if (c[i][j + 1] == '.' && c[i][j - 1] == '.' && c[i + 1][j] == '.' && c[i - 1][j] == '.') b = false;
                    }
                }
            }
            for(int i = 1; i < h-1; i++)
            {
                if (c[i][0] == '#' && c[i][1] == '.' && c[i - 1][0] == '.' && c[i + 1][0] == '.') b = false;
                if (c[i][w-1] == '#' && c[i][w-2] == '.' && c[i - 1][w-1] == '.' && c[i + 1][w-1] == '.') b = false;
            }
            for (int i = 1; i < w - 1; i++)
            {
                if (c[0][i] == '#' && c[1][i] == '.' && c[0][i-1] == '.' && c[0][i+1] == '.') b = false;
                if (c[h-1][i] == '#' && c[h-2][i] == '.' && c[h - 1][i - 1] == '.' && c[h - 1][i + 1] == '.') b = false;
            }
            if (c[0][0] == '#' && c[0][1] == '.' && c[1][0] == '.') b = false;
            if (c[0][w-1] == '#' && c[0][w-2] == '.' && c[1][w-1] == '.') b = false;
            if (c[h-1][0] == '#' && c[h-1][1] == '.' && c[h-2][0] == '.') b = false;
            if (c[h-1][w-1] == '#' && c[h-2][w-1] == '.' && c[h-1][w-2] == '.') b = false;
            if (b==true) System.Console.WriteLine("Yes");
            else System.Console.WriteLine("No");
          
        }

    }
}


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

int main(){
    int n;
    cin >> n;
    
    vector<int> a;
    for(int i = 0; i < n; i++){
        int z;
        cin >> z;
        z--;
        a.push_back(z);
    }
    
    int now = 0, c = 0;
    for(;;){
        if(now == 1){
            cout << c;
            break;
        }
        if(c >= n){
            cout << -1;
            break;
        }
        c++;
        now = a[now];
    }
    
    
}


Measured memory_bytes: 892
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,l,r) for(long long i=(l);i<(r);++i)
#define REP(i,n) FOR(i,0,n)
#define REPS(i,n) FOR(i,1,n+1)
#define RFOR(i,l,r) for(long long i=(l);i>=(r);--i)
#define RREP(i,n) RFOR(i,n-1,0)
#define RREPS(i,n) RFOR(i,n,1)
#define int long long
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define SZ(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b; return true; }return false; }
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b; return true; }return false; }
const int INF = 1e18;
const long double PI = acos(-1.0);

int f(int x){
    int c = x;
    int k = 1;
    while(x>=2){
        x /= 2;
        k++;
    }
    return pow(2,k) - c;
}

signed main(){
    int n; cin >> n;
    vector<int> a(n);
    map<int,int> mp;
    REP(i,n){ 
        cin >> a[i];
        mp[a[i]]++;
    }
    sort(rall(a));
    int ans = 0;
    REP(i,n)if(mp[f(a[i])] and mp[a[i]]){
        if(f(a[i]) == a[i] and mp[a[i]] == 1) continue;
        ans++; mp[f(a[i])]--; mp[a[i]]--;
    }
    cout << ans <<'\n';
}

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

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

    int x;
    cin >> x;

    vector<int> A;
    A.emplace_back(1);
    REP(i, 40){
        if(i <= 1) continue;
        int tmp = i;
        while(tmp < x){
            tmp *= i;
            A.push_back(tmp);
        }
    }
    
    sort(A.begin(), A.end());
    
    set<int> st;
    for(auto hoge : A) st.insert(hoge);
    vector<int> B;
    for(auto hoge : st) B.push_back(hoge);

    sort(B.begin(), B.end());

    int maxi = -1e9;
    for(int i = 0; i < B.size(); i++){
        if(B[i] > x) break;
        maxi = max(maxi, B[i]);
    }
    cout << maxi << endl; 

    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>

#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>

#include <functional>
#include <cassert>

typedef long long ll;
using namespace std;

#define debug(x) cerr << #x << " = " << x << endl;


#define mod 1000000007 //1e9+7(prime number)
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define SIZE 100010

const int MAX_P = 4010; //max
bool prime[MAX_P+1];

void Eratosthenes(void){
  for(int i=2;i<=MAX_P;i++)
    prime[i]=true;
  
  for(int i=2;i*i<=MAX_P;i++)
    if(prime[i])  
      for(int j=i;i*j<=MAX_P;j++)
        prime[i*j]=false;
}

int main(){
  int n;
  ll in;
  vector<ll> s;
  vector<ll> prime_v,prime_v3;
  map<ll,int> mm;
  map<ll,ll> sq;
  
  Eratosthenes();

  for(ll i=2;i<=100010;i++){
    sq[i*i] = i;
  }

  for(ll i=2;i<4010;i++){
    if(prime[i]) prime_v.push_back(i);
    if(prime[i]) prime_v3.push_back(i*i*i);
  }
  
  scanf("%d",&n);
  
  for(int i=0;i<n;i++){
    scanf("%lld",&in);
    s.push_back(in);
  }
  
  for(int i=0;i<n;i++){
    ll t = s[i];

    for(int j=0;j<prime_v3.size();j++){
      if(t < prime_v3[j]) break;
      
      while(t%prime_v3[j]==0){
        t /= prime_v3[j];
      }
    }

    s[i] = t;
  }

  for(int i=0;i<n;i++){
    mm[s[i]]++;
  }

  sort(s.begin(),s.end());
  s.erase(unique(s.begin(),s.end()),s.end());

  n = s.size();

  int ans = 0;
  
  for(int i=0;i<n;i++){
    int f[1000] = {};

    ll t = s[i];
    
    for(int j=0;j<prime_v.size();j++){
      if(t%(prime_v[j]*prime_v[j])==0){
        t/=(prime_v[j]*prime_v[j]);
        f[j] = 2;
      }else if(t%prime_v[j]==0){
        t /= prime_v[j];
        f[j] = 1;
      }else{
        f[j] = 0;
      }
    }

    ll q = 1;

    auto it = sq.find(t);
    
    if(it != sq.end()){
      q = it->second; 
    }else if(t > 1){
      if(t > 100000){
        ans += mm[s[i]];
        continue;
      }
      
      q = t*t;
    }
    
    for(int j=0;j<prime_v.size();j++){
      if(f[j]==1)
        q *= (ll) prime_v[j] * prime_v[j];
      else if(f[j]==2)
        q *= prime_v[j];
    }
    
    if(mm[q]==0){
      ans += mm[s[i]];
    }else if(s[i] > q){
      ans += max(mm[s[i]],mm[q]);
    }
    
  }

  if(mm[1] > 0) ans ++;
  
  printf("%d\n",ans);
  
  return 0;
}


Measured memory_bytes: 17532
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define db long double
int main(){
  ll i,n,j;
  cin>>n;
  db p[n+1],dp[n+1][n+1];
  
  for(i=1;i<=n;i++)cin>>p[i];
  memset(dp,0,sizeof(dp));
  dp[0][0]=1;
  for(i=1;i<=n;i++)
   for(j=0;j<=n;j++)
    if(j==0)dp[i][j]=dp[i-1][j]*(1-p[i]);
    else dp[i][j]=dp[i-1][j]*(1-p[i])+dp[i-1][j-1]*p[i];
  db ans=0.0;
  for(i=n/2+1;i<=n;i++)
   ans+=dp[n][i];
  cout<<fixed<<setprecision(10)<<ans;
}

Measured memory_bytes: 140928
#include <iostream>
using namespace std;
int main(void){
    int n,i,j,b,ans=0;
    int o;
    cin>>n;
    o=1000000;
    for(i=1;i<n;i++){
        cin>>b;
        ans+=min(o,b);
        o=b;
    }
    cout<<ans+o;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using lint     = long long;
const lint inf = 1LL << 60;
const lint mod = 1000000007;

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    lint n;
    cin >> n;
    vector<lint> a(n);
    map<lint, int> cnt;
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
        cnt[a[i]]++;
    }
    lint ret = 0;
    lint l1  = 0;
    for (auto it = cnt.rbegin(); it != cnt.rend(); it = next(it)) {
        if (l1 != 0 && it->second >= 2) {
            ret = l1 * it->first;
            break;
        } else if (it->second >= 4) {
            ret = it->first * it->first;
            break;
        } else if (it->second >= 2) {
            l1 = it->first;
        }
    }
    cout << ret << "\n";
    return 0;
}

Measured memory_bytes: 7296
#include<bits/stdc++.h>
using namespace std;
#define debug(x) cout << '[' << #x << " is: " << x << "] " <<"\n";

int main(){

    ios_base::sync_with_stdio(0);
    cin.tie(NULL);
    cout.tie(NULL);
    long long  a ,s ;
    cin >> a >>s ;
    cout <<a*s;

    return 0;
}


Measured memory_bytes: 3648
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Numerics;
using System.Text;
using System.Threading.Tasks;

namespace AtCorder
{
	public class Program
	{
		static void Main(string[] args)
		{
			int n = int.Parse(Console.ReadLine());
			long[] a = Console.ReadLine().Split(' ').Select(long.Parse).ToArray();

			long[] sums = new long[n];
			sums[0] = a[0];
			for (int i = 1; i < n; i++) {
				sums[i] += a[i] + sums[i - 1];
			}

			long sum = sums[n - 1];

			long ans = long.MaxValue;
			for (int i = 0; i < n - 1; i++) {
				long dif = Math.Abs(sum - sums[i] - sums[i]);
				ans = Math.Min(ans, dif);
			}

			Console.WriteLine(ans);
		}
	}
}

Measured memory_bytes: 33988
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

//AtCoder Beginner Contest 134
//C	Exception Handling
public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		List<Integer> aList = new ArrayList<>();
		for (int i = 0; i < N; i++) {
			aList.add(sc.nextInt());
		}
		sc.close();

		int max1 = 0;
		int max2 = 0;
		for (Integer a : aList) {
			
			if (max1 < a) {
				max1 = a;
			} else {
				if (max2 < a) {
					max2 = a;
				}
			}
		}

		for (Integer a : aList) {
			if (a == max1) {
				System.out.println(max2);
			} else {
				System.out.println(max1);
			}
		}
	}
}


Measured memory_bytes: 106580
#include<iostream>
using namespace std;
	int a[6];
	int b[6];
int main()
{
	
	for(int i=0;i<6;i++)
	{
		cin>>a[i];
		b[a[i]]++;
		if(b[a[i]]==3)
		{
			cout<<"NO";
			return 0;
		}
	}
	for(int i=1;i<=4;i++)
		if(b[i]==0)
		{
			cout<<"NO";
			return 0;
		}
	cout<<"YES";
	
	return 0;
}

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

#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define endl "\n"
#define ALL(a) (a).begin(),(a).end()

using namespace std;
using ll = long long;

const double PI = 3.14159265358979;

void solve()
{
  ll n, k;
  cin >> n >> k;
  ll ans = 0;

  for(ll i = k + 1; i <= n; ++i)
  {
    // a % b >= k
    // a % i >= k
    ans += n / i * (i - k) + max(n % i - k + 1, 0LL);
  }
  if (k == 0) ans -= n;
  cout << ans;
}

int main()
{
  fastio;
  solve();

  return 0;
}

Measured memory_bytes: 3552
#include<bits/stdc++.h>
using namespace std;
#define int long
using pi=pair<int,int>;
signed main(){
    int n;
    cin >> n;
    int r = n * (n + 1) / 2;
    int three = n / 3, five = n / 5, tf = n / 15;
    cout << r - 3 * three * (three + 1) / 2 - 5 * five * (five + 1) / 2 + 15 * tf * (tf + 1) / 2;
}

Measured memory_bytes: 3596
import java.util.*;
public class Main{
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int a = sc.nextInt();
    int b = sc.nextInt();
    int c = sc.nextInt();
    if(a==b && b==c){
      System.out.println("No");
    }else{
      if(a==b || b==c || c==a){
        System.out.println("Yes");
      }else{
        System.out.println("No");
      }
    }
  }
}


Measured memory_bytes: 23636
#include <stdio.h>

int main(void){
  long long n ,a[2005],k,count=0;
  scanf("%lld %lld",&n,&k);
  for(int j=0;j<n;j++){
    scanf("%lld",&a[j]);
  }
  for(int i=0;i<n;i++){
    for(int j=0;j<n;j++){
      if(a[i]>a[j]){
        if(i<j) count+=k*(k+1)/2;
        else count+=k*(k-1)/2;
      }
      count%=1000000007;
    }
  }
  k=k%1000000007;
  count=count%1000000007;
  printf("%lld\n",count);
  return 0;
}

Measured memory_bytes: 1740
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
#include <queue>
#include <deque>
#include <string>
#include <stack>
#include <unordered_set>
#include <cmath>
#include <climits>
#include <cstdlib>
#include <cstring>
#include <map>
#include <ctime>
#include <set>
#define endl '\n'
#define ll long long
#define mod 1000000007
#define NCONS 100001
#define MACRO(a) for(int a = 1; a < 1001; a++)

using namespace std;

vector<string> vec;
string str; int K;
set<string> st;

int main(void)
{
	cin.tie(NULL); ios_base::sync_with_stdio(false);
	cin >> str >> K;

	for (int i = 0; i < str.length(); i++)
	{
		for (int j = 1; j <= K; j++)
		{
			st.insert(str.substr(i, j));
//			cout << str.substr(i, j) << endl;
		}
	}
	for (auto ptr = st.begin(); ptr != st.end(); ptr++)
	{
		vec.push_back(*ptr);
	}

	sort(vec.begin(), vec.end());
	cout << vec[K-1] << endl;

	return 0;
}

Measured memory_bytes: 1728
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Numerics; 

class _Class
{
  void _Do()
  {
    int N = Split.ints()[0];
    int min = int.MaxValue;
    for(int i=1;i<=N-1 ;i++ )
    {
      var A = i;
      var B = N - i;

      var aa = 0;
      while (A > 0) {
        aa += (A % 10);
        A = A / 10;
      }

      var bb = 0;
      while (B > 0)
      {
        bb += (B % 10);
        B = B / 10;
      }

      if (min > aa + bb)
        min = aa + bb; ;
    }
    Console.WriteLine(min);
  }


  //
  static void Main(string[] args)
  {
    _(args);
    new _Class()._Do();
  }

  [Conditional("DEBUG")]
  static void _(string[] args)
  {
    if (args.Length != 0 && File.Exists(args[0]))
      Console.SetIn(new StreamReader(args[0]));
    else
      Console.Error.WriteLine("in");
  }
}

static class Split
{


  // 1
  public static string[] strings()
  {
    return Console.ReadLine().Split();
  }


  // [2.1] -2,147,483,648 ~ +2,147,483,647
  public static int[] ints()
  {
    var _s = Console.ReadLine().Split();

    var x = new int[_s.Length];
    for (var i = 0; i < _s.Length; i++)
      x[i] = int.Parse(_s[i]);

    return x;
  }

  // [2.2] 
  // -9,223,372,036,854,775,808 ~ 
  // +9,223,372,036,854,775,807
  public static long[] longs()
  {
    var _s = Console.ReadLine().Split();

    var x = new long[_s.Length];
    for (var i = 0; i < _s.Length; i++)
      x[i] = long.Parse(_s[i]);

    return x;
  }

  public static double[] doubles()
  {
    var _s = Console.ReadLine().Split();

    var x = new double[_s.Length];
    for (var i = 0; i < _s.Length; i++)
      x[i] = double.Parse(_s[i]);

    return x;
  }

  public static BigInteger[] bigs()
  {
    var _s = Console.ReadLine().Split();

    var x = new BigInteger[_s.Length];
    for (var i = 0; i < _s.Length; i++)
      x[i] = BigInteger.Parse(_s[i]);

    return x;
  }
}




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

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

    int a[] = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
    cout << a[k-1] << endl;
}

Measured memory_bytes: 3548
#include <bits/stdc++.h>
#define ll long long
#define PI 3.141592653589
#define IO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define EPS 1e-9
#define f first
#define s second
using namespace std;
int n, k;
int arr[100005];
ll memo[100005];
ll solve(int idx){
    if (idx >= n-1)
        return 0;
    ll &res = memo[idx];
    if(res != -1)
        return res;
    res = 1e18;
    for (int i = 1; i<=k && (idx+i<=n-1); ++i)
        res = min(res, abs(arr[idx+i]-arr[idx])+solve(idx+i));
    return res;
}
int main(){
    IO;
    cin >> n >> k;
    memset(memo, -1, sizeof memo);
    for(int i = 0; i < n; ++i)
        cin >> arr[i];
    cout << solve(0);

    return 0;
}


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

#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n - 1; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i <= n; i++)
#define FORR(i, m, n) for(int i = m; i >= n; i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define VSORTR(v) sort(v.rbegin(), v.rend());
#define ALL(v) (v).begin(),(v).end()

using namespace std;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<ll, ll>;

const ll mod = 1e9+7;

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

    ll a,b; cin>>a>>b;
    ll mx = min(a+2020,b);
    ll ans=2019;
    for(ll i=a;i<mx;i++){
        for(ll j=i+1;j<=mx;j++){
            if (i*j%2019==0){
                cout<< 0 <<endl;
                return 0;
            }
            ans = min(i*j%2019, ans);

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

Measured memory_bytes: 256
N = int(input())
book= []
for i in range(N):
    a = input().split()
    city = a[0]
    score = (100-int(a[1]))
    book.append((city, score))
b=sorted(book)

for i in b:
    ans =  1
    for j in book:
        if i == j:
            print(ans)
        else:
            ans += 1

Measured memory_bytes: 3060
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
#define repr(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define invrepr(i,a,b) for(int i=b-1;i>=a;i--)
#define invrep(i,n) invrepr(i,0,n)
#define repitr(itr,a) for(auto itr=a.begin();itr!=a.end();++itr)
#define P pair<int,int>
const int MOD=1e9+7;
const int INF=1e9;
const double PI=acos(-1);

vector<int> vectorCnt(vector<char> a) {
    sort(a.begin(),a.end());
    int n=a.size();
    vector<int> b;
    int cnt=1;
    rep(i,n-1) {
            if (a[i+1]!=a[i]) {
                b.push_back(cnt);
                cnt=1;
            } else {
                ++cnt;
            }
    }
    b.push_back(cnt);
    return b;
}

int main() {
    ios_base::sync_with_stdio(false); 

    int h,w;
    cin >> h >> w;
    vector<char> a(h*w);
    rep(i,h) {
        rep(j,w) cin >> a[w*i+j];
    } 
    vector<int> b=vectorCnt(a);
    int m=b.size();
    vector<int> c(3);
    rep(i,m) { 
        if (b[i]%2==1) ++c[0];
        else if (b[i]%4==2) ++c[1];
        else ++c[2];
    }
    bool flag=1;
    if (h%2==0 && w%2==0) {
        if (c[0]>0 || c[1]>0) flag=0;
    } else if (h%2==0) {
        if (c[0]>0 || c[1]*2>h) flag=0;
    } else if (w%2==0) {
        if (c[0]>0 || c[1]*2>w) flag=0; 
    } else {
        if (c[0]>1 || c[1]*2>w-1+h-1) flag=0;
    }
    if (flag) cout << "Yes" << endl;
    else cout << "No" << endl;
    
    
    

    return 0;
}


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

#define ll long long
ll MAX = 1000000000+7;

using namespace std;

ll modF(ll a) {
    if (a<0) return modF((a%MAX)+MAX);
    else return (a%MAX);
}

int main() {

        ll n, k, i, a, po=0, ni=0, ans=1;
        vector<ll> vcp, vcn;
        cin >> n >> k;
        for (i=0;i<n;i++) {
            cin >> a;
            if (a<0) {
                a=-a;
                ni++; vcn.push_back(a);
            }
            else {
                po++; vcp.push_back(a);
            }
        }
        if (po>0) sort(vcp.begin(),vcp.end());
        if (ni>0) sort(vcn.begin(),vcn.end());

        if (po==0) {
            if (k%2==0) {
                for (i=0;i<k;i++) {
                    ans = ans * (-vcn[ni-1]);
                    ans = modF(ans);
                    ni--;
                }
            }
            else {
                for (i=0;i<k;i++) {
                    ans = ans * (-vcn[i]);
                    ans = modF(ans);
                }
            }
        }
        else if (ni==0) {
            for (i=0;i<k;i++) {
                ans = ans * vcp[po-1];
                ans = modF(ans);
                po--;
            }
        }
        else {
            if (k%2==1) {
                ans = vcp[po-1];
                po--; k--;
            }
            while (k>1 && (po>=2 || ni>=2)) {
                ll propo = 0;
                if (po>=2) propo = vcp[po-1]*vcp[po-2];
                ll proni = 0;
                if (ni>=2) proni = vcn[ni-1]*vcn[ni-2];

                if (propo>proni) {
                    propo = modF(propo);
                    ans = ans*propo;
                    ans = modF(ans);
                    po = po-2;
                }
                else {
                    proni = modF(proni);
                    ans = ans*proni;
                    ans = modF(ans);
                    ni = ni-2;
                }
                k=k-2;
            }
            while (k>0) {
                if (po>0) {
                    ans = ans*vcp[po-1];
                    ans = modF(ans);
                    po--; k--;
                }
                else if (ni>0) {
                    ans = ans*(-vcn[ni-1]);
                    ans = modF(ans);
                    ni--; k--;
                }
            }
        }
        cout << ans << endl;

    return 0;
}


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

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  ll n;
  string s;
  cin >> n >> s;
  
  /*
  vector<int> a(n);
  rep(i, n) cin >> a.at(i);
  */
  
  rep (i, s.size()) {
    if (s.at(i) +n >90)
      s.at(i) += (n - 26);
    else
      s.at(i) += n;
  }
  cout << s << "\n";

}


Measured memory_bytes: 256
N,M = map(int,input().split())
A = [0]*M
B = [0]*M
for i in range(M):
    A[i],B[i] = map(int,input().split())

from collections import deque
links = [[] for _ in range(N+1)]
for i in range(M):
    links[A[i]].append(B[i])
    links[B[i]].append(A[i])

result = [-1]*(N+1)
q  = deque([1])
while q:
    i = q.popleft()
    for j in links[i]:
        if result[j] == -1:
            result[j] = i
            q.append(j)
        
        
print('Yes')
print('\n'.join(str(i) for i in result[2:]))

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

using namespace std;

int main()
{
    set<string> seen;
    int n;
    cin >> n;
    for (int i = 0; i < n; i++)
    {
        string s;
        cin >> s;
        seen.insert(s);
    }
    cout << (int) seen.size() << endl;
    return 0;
}


Measured memory_bytes: 19256
#include <bits/stdc++.h>
#define base 1000000007LL
#define ll long long
#define X first
#define Y second
#define pb push_back
#define MAXN 21010
#define Scan(a) scanf("%I64d", &a)
#define CLR(a) memset(a,0,sizeof(a))
#define FOR(i,a,b) for(int i=(a),_b=(b); i<=_b; i++)
#define FORE(i,a,b) for(int i=(a),_b=(b); i>=_b; i--)

using namespace std;

typedef pair<int, int> II;
typedef vector<II> vi;

int n;
string s;
char res[100010];

bool solve()
{
    char ch = res[n];
    FOR(i,2,n-1)
        if (res[i] == 'W') {
            if (s[i] == 'o') {
                if (res[i-1] == 'W') res[i+1] = 'S';
                else res[i+1] = 'W';
            }
            else res[i+1] = res[i-1];
        }
        else {
            if (s[i] == 'o') res[i+1] = res[i-1];
            else {
                if (res[i-1] == 'W') res[i+1] = 'S';
                else res[i+1] = 'W';
            }
        }
    if (ch != res[n]) return false;
    if (res[n] == 'W') {
        if (s[n] == 'o') {
            if (res[1] != res[n-1]) return true;
        }
        else {
            if (res[1] == res[n-1]) return true;
        }
    }
    else {
        if (s[n] == 'x') {
            if (res[1] != res[n-1]) return true;
        }
        else {
            if (res[1] == res[n-1]) return true;
        }
    }
    return false;
}

int main()
{
    ios::sync_with_stdio(0);
    //freopen("inp.txt", "r", stdin);
    //freopen("out.txt", "w", stdout);
    cin >> n >> s;
    s = " " + s;
    res[1] = 'S';
    if (s[1] == 'o') {
        res[n] = res[2] = 'W';
        if (solve()) {
            FOR(i,1,n) cout << res[i];
            return 0;
        }
        res[n] = res[2] = 'S';
        if (solve()) {
            FOR(i,1,n) cout << res[i];
            return 0;
        }
    }
    else {
        res[n] = 'W'; res[2] = 'S';
        if (solve()) {
            FOR(i,1,n) cout << res[i];
            return 0;
        }
        res[n] = 'S'; res[2] = 'W';
        if (solve()) {
            FOR(i,1,n) cout << res[i];
            return 0;
        }
    }
    res[1] = 'W';
    if (s[1] == 'x') {
        res[n] = res[2] = 'W';
        if (solve()) {
            FOR(i,1,n) cout << res[i];
            return 0;
        }
        res[n] = res[2] = 'S';
        if (solve()) {
            FOR(i,1,n) cout << res[i];
            return 0;
        }
    }
    else {
        res[n] = 'W'; res[2] = 'S';
        if (solve()) {
            FOR(i,1,n) cout << res[i];
            return 0;
        }
        res[n] = 'S'; res[2] = 'W';
        if (solve()) {
            FOR(i,1,n) cout << res[i];
            return 0;
        }
    }
    cout << -1;
    return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <utility>
#include <cmath>
typedef long long ll;
using namespace std;

ll ManhattanDistance(pair<ll, ll> a, pair<ll, ll> b) {
    return abs(a.first-b.first) + abs(a.second-b.second);
}

int main() {
    int n, m;
    cin >> n >> m;
    ll x, y;
    pair<ll, ll> student[n], check[m];
    for(int i=0; i<n; i++) {
        cin >> x >> y;
        student[i] = make_pair(x, y);
    }
    for(int i=0; i<m; i++) {
        cin >> x >> y;
        check[i] = make_pair(x, y);
    }
    
    for(int i=0; i<n; i++) {
        ll min=1e9;
        ll num=1;
        for(int j=0; j<m; j++) {
            x = ManhattanDistance(student[i], check[j]);
            if(min>x) {
                min = x;
                num = j+1;
            }
        }
        cout << num << endl;
    }

    return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <sstream>
#include <cstdio>
using namespace std;
int main()
{
	int n;
	while(cin>>n&&n)
	{
		vector<long long> a;
		for(int i=0;i<n;i++)
		{
			int x;
			cin>>x;
			a.push_back(x);
		}
		sort(a.begin(),a.end());
		long long ans=0;
		a.back()=0;
		for(int i=1;i<n;i++)
		{
			ans+=a[i-1];
			a[i]+=a[i-1];
			
		}
		cout<<ans<<endl;
	}
}

Measured memory_bytes: 1340
import java.util.Scanner;

/*
 * ABC086A - Product
 */
public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        if ((a*b)%2 ==0){
            System.out.println("Even");
        } else {
            System.out.println("Odd");
        }

        sc.close();
    }

}


Measured memory_bytes: 23124
from bisect import bisect_left
from collections import defaultdict
n, m = map(int, input().split())
m = [tuple(map(int, input().split())) for _ in range(m)]

d = defaultdict(list)
for p, y in sorted(m):
    d[p].append(y)

for p, y in m:
    print('{:06}{:06}'.format(p, bisect_left(d[p], y)+1))

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

#define int long long

string s;
int s1, s2;

int32_t main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	cin >> s;
	for (int i = 0; i < s.size(); i++) {
		s1 += ((s[i] - '0') != (i & 1));
		s2 += ((s[i] - '0') == (i & 1));
	}
	cout << min(s1, s2) << endl;
}

Measured memory_bytes: 512
#pragma GCC optimize(2,3,"Ofast")
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define db double
#define in inline
namespace fast_io
{
    char buf[1<<12],*p1=buf,*p2=buf,sr[1<<23],z[23],nc;int C=-1,Z=0,Bi=0,ny;
    in char gc() {return p1==p2&&(p2=(p1=buf)+fread(buf,1,1<<12,stdin),p1==p2)?EOF:*p1++;}
    in ll read()
    {
        ll x=0;ny=1;while(nc=gc(),(nc<48||nc>57)&&nc!=EOF)if(nc==45)ny=-1;Bi=1;if(nc<0)return nc;
        x=nc-48;while(nc=gc(),47<nc&&nc<58&&nc!=EOF)x=(x<<3)+(x<<1)+(nc^48),Bi++;return x*ny;
    }
    in db gf() {int a=read(),y=ny,b=(nc!='.')?0:read();return (b?a+(db)b/pow(10,Bi)*y:a);}
    in int gs(char *s) {char c,*t=s;while(c=gc(),c<32);*s++=c;while(c=gc(),c>32)*s++=c;return s-t;}
    in void ot() {fwrite(sr,1,C+1,stdout);C=-1;}
    in void flush() {if(C>1<<22) ot();}
    template <typename T>
    in void write(T x,char t)
    {
        int y=0;if(x<0)y=1,x=-x;while(z[++Z]=x%10+48,x/=10);
        if(y)z[++Z]='-';while(sr[++C]=z[Z],--Z);sr[++C]=t;flush();
    }
    in void write(char *s) {int l=strlen(s);for(int i=0;i<l;i++)sr[++C]=*s++;sr[++C]='\n';flush();}
};
using namespace fast_io;
const int N=3e5+5,p=998244353;
int n;
ll a[N],ans,mx;
int main()
{
	n=read();for(int i=1;i<=n;i++) a[i]=read(),mx=max(mx,a[i]);
	for(int i=0;i<=ceil(log2(mx));i++)
	{
		ll c0=0,c1=0;
		for(int j=1,k;j<=n;j++) k=bool(a[j]&(1ll<<i)),c0+=(k==0),c1+=(k==1);
		ans+=c0*c1%1000000007*((1ll<<i)%1000000007)%1000000007;ans%=1000000007;
	}
	write(ans,'\n');
	return ot(),0;
}
//Author: disangan233
//In my dream's scene,I can see the everything that in Cyaegha.

Measured memory_bytes: 4352
import java.util.Scanner;
class Main
{
    public static void main(String args[])
    {
	int n;
	Scanner scan=new Scanner(System.in);
	n=scan.nextInt();
	int a[]=new int[n];
	for(int i=0;i<n;i++)
	    {
		a[i]=scan.nextInt();
	    }
	int j=0,k=n-1,tmp;
	while(true)
	    {		
		if((j==k) || (j>k))break;
		tmp=a[j];
		a[j]=a[k];
		a[k]=tmp;
		j++;
		k--;
	    }
	for(int i=0;i<n;i++)
	    {
	if(i==n-1)
	    {
		System.out.println(a[i]);
		break;
	    }
		System.out.print(a[i]+" ");
	
	    }
    }
}

Measured memory_bytes: 18996
#include <bits/stdc++.h>
#define all(a) (a).begin(), (a).end()
#define rep(i, n) for(int i = 0, i##_len = (n); i < i##_len; ++i)
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl
using namespace std;
using ll = long long;

int main() {
    int A, B, C;
    cin >> A >> B >> C;
    cout << C << " " << A << " " << B << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long i64;
const i64 INF = 1LL << 50;

template<typename T> struct Edge {
	int to;
	T cost;
};

template<typename T> class WeightedGraph {
	vector<vector<Edge<T> > > data;
public:
	WeightedGraph(int size) {
		data.resize(size);
	}
	
	inline vector<Edge<T> > operator[](int index) const { return data[index]; }
	inline vector<Edge<T> >& operator[](int index) { return data[index]; }
	
	size_t size() {
		return data.size();
	}
};

template<typename T> vector<T> dijkstra(WeightedGraph<T> &g, int s) {
	vector<T> dist(g.size(), INF); 
	priority_queue<pair<T, int>, vector<pair<T, int> >, greater<pair<T, int> > > q;
	
	dist[s] = 0;
	q.push({0, s});
	
	while (!q.empty()) {
		pair<T, int> p = q.top(); q.pop();
		int v = p.second;
		if (dist[v] < p.first) continue;
		for (int i = 0; i < g[v].size(); i++) {
			Edge<T> e = g[v][i];
			if (dist[e.to] > dist[v] + e.cost) {
				dist[e.to] = dist[v] + e.cost;
				q.push({dist[e.to], e.to});
			}
		}
	}
	
	return dist;
}

int main(void) {
  int v, e, r;
  cin >> v >> e >> r;
  WeightedGraph<i64> g(v);
  for (int i = 0; i < e; i++) {
    int s, t, d;
    cin >> s >> t >> d;
    g[s].push_back({t, d});
  }
  vector<i64> dists = dijkstra(g, r);
  for (int i = 0; i < v; i++) {
    if (dists[i] < INF) cout << dists[i] << endl;
    else cout << "INF" << endl;
  }
}



Measured memory_bytes: 19460
from bisect import bisect_right
def inpl(): return input().split()

n = int(input())
a = list(map(int, inpl()))
b = [1, 400, 800, 1200, 1600, 2000, 2400, 2800, 3200]

d = dict()
for i in range(n):
    pos = bisect_right(b, a[i])#1->pos=1, 3200->pos=9
    d[pos] = d.get(pos, 0) + 1
ans = 0
for pos in range(bisect_right(b, 1), bisect_right(b, 3200)):
    if (d.get(pos, 0) > 0):
        ans += 1
cnt_colorful = d.get(bisect_right(b, 3200), 0)

if ans == 0:
    #3200以上のみの場合
    print(1, cnt_colorful)
else:
    print(ans, ans + cnt_colorful) 


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

using namespace std;


#define uniq(x)  x.erase(unique(x.begin(),x.end()), x.end()) //Unique value find from vector
#define upper(arr,n,fixed) upper_bound(arr,arr+n,fixed)-arr  //Upper value search  >
#define lower(arr,n,fixed) lower_bound(arr,arr+n,fixed)-arr  //Lower value search  >=
#define FOR(i,a,n) for(int i=a; i<(int)n; i++)
#define FORI(i,a,n) for(int i=a; i>=(int)n; i--)
#define pii pair<int,int>
#define vpii vector<pii>
#define mp make_pair
#define fi first
#define se second
#define pb push_back
#define sz(a) int((a).size())
#define fastIO() ios_base::sync_with_stdio(0); cin.tie(0)
#define endl "\n"
#define all(a) a.begin(), a.end()
#define MEMSET(p,i) memset(p,i,sizeof(p))

typedef long long LL;


template<class T>T Lcm(T a,T b){T tmp=__gcd(a,b);return (a/tmp)*b;}


// int solve(string v, string s)
// {
// 	int cnt = 1;
// 	int i = 0;
// 	while(i < sz(s))
// 	{
// 		cout << v << " " << s << endl;
// 		if(sz(v) != 1 || v[0] != s[i]){
// 			v = s.substr(i,1);
// 			cnt++;
// 			i++;
// 		}
// 		else{
// 			if(i+1 < sz(s)){
// 				v = s.substr(i,2);
// 				cnt ++;
// 				i += 2;
// 			}
// 			else{

// 				return 0;
// 			}
// 		}


// 	}
// 	return cnt;
// }

string s;
int memo[200010];
// aaaccacabaababcc

int dp(int i, string &v)
{

	if(i >= sz(s))
		return 0;
	if(memo[i] != -1){
		cout << i << " " << v << " " << memo[i] << endl;
		return memo[i];
	}

	string p = s.substr(i,1);
	if(p != v){
		memo[i] = max(memo[i], dp(i+1, p) + 1);
	}
	if(i+1 < sz(s)){
		p = s.substr(i,2);
		if(p != v){
			memo[i] = max(memo[i], dp(i+2, p) + 1);
		}
	}
	
	return memo[i];
}


// aaaaa
int main(void)
{
	// fastIO();
	
	cin >> s;

	int n = sz(s);

	int A1[200010];
	int A2[200010];
	MEMSET(A1,-1);
	MEMSET(A2,-1);
	
	A1[n-1] = 1;
	A2[n-1] = -1;

	if(n-2 >= 0)
	{
		if(s[n-2] != s[n-1])
			A1[n-2] = 2;
		A2[n-2] = 1;
	}


	FORI(i,n-3,0)
	{
		if(A2[i+1] != -1)
			A1[i] = A2[i+1] + 1;
		if(s[i] != s[i+1] && A1[i+1] != -1){
			A1[i] = max(A1[i], A1[i+1] + 1);
		}


		if(i+2 < n)
		{
			if(A1[i+2] != -1)
				A2[i] = A1[i+2] + 1;
			
			if(i+4 < n){
				string a = s.substr(i,2);
				string b = s.substr(i+2,2);
				if(a != b && A2[i+2] != -1)
					A2[i] = max(A2[i], A2[i+2] + 1);
			}
		}

	}

	// FOR(i,0,n) cout << A1[i] << " "; cout << endl;
	// FOR(i,0,n) cout << A2[i] << " "; cout << endl;

	int ans = 0;
	FOR(i,0,n)
		ans = max({ans, A1[i], A2[i]});
	cout << ans << endl;

		
	


	
}



Measured memory_bytes: 2180
class Bubble_sort:
    def __init__(self):
        self.swap_num=0
    
    def sort(self,n,list):
        for i in range(n):
            for j in range(i+1,n)[::-1]:
                if(list[j] < list[j-1]):
                    list[j],list[j-1]=list[j-1],list[j]
                    self.swap_num+=1
        return list




n=int(input())
data=list(map(int,input().split()))
bubble_sort=Bubble_sort()
print(" ".join(list(map(str,bubble_sort.sort(n,data)))))
print(bubble_sort.swap_num)


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

int main() {
  string alphabet;
  cin >> alphabet;
  if(alphabet == "a" || alphabet == "i"
    || alphabet == "u" || alphabet == "e"
    || alphabet == "o") {
    cout << "vowel" <<endl;
  }
  
  else {
    cout << "consonant" << endl;
  }

  // ここにプログラムを追記
}


Measured memory_bytes: 3628
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int m = sc.nextInt();
		List<Integer>[] path = new ArrayList[n + 1];
		for(int i = 1; i < n + 1; i++) {
			path[i] = new ArrayList<>();
		}
		for(int i = 0; i < m; i++) {
			int s = sc.nextInt();
			int t = sc.nextInt();
			path[s].add(t);
		}
		double[] dp = new double[n + 1];
		double ans = Double.MAX_VALUE;
		for(int i = 1; i < n + 1; i++) {
			for(int j = n; j > 0; j--) {
				dp[j] = 0;
				double max = 0;
				if(j == n) {
					dp[j] = 0;
				} else {
					for(Integer to : path[j]) {
						dp[j] += dp[to] + 1;
						max = Math.max(max, dp[to] + 1);
					}
					if(i == j) {
						dp[j] -= max;
						if(path[j].size() - 1 != 0)
							dp[j] /= (path[j].size() - 1);
						else
							dp[j] = Double.MAX_VALUE;
					} else {
						dp[j] /= path[j].size();
					}
				}
			}

			ans = Math.min(ans, dp[1]);
		}
		System.out.println(ans);
	}

}


Measured memory_bytes: 95748
#include <iostream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <algorithm>
#include <set>
#include <map>
#include <bitset>
#include <cmath>
#include <functional>
#define vv(a, b, c, d) vector<vector<d> >(a, vector<d>(b, c))
#define vvi vector<vector<int> >
#define vvl vector<vector<ll> >
#define vll vector<ll>
#define rep(c, a, b) for(ll c=a;c<b;c++)
#define re(c, b) for(ll c=0;c<b;c++)
#define all(obj) (obj).begin(), (obj).end()
typedef long long int ll;
typedef long double ld;
using namespace std;
int main(int argc, char const *argv[]) {
  ll l, r, ans = 0, n;std::cin >> n;
  re(i, n){
    std::cin >> l >> r;
    ans += r - l + 1;
  }
  std::cout << ans << '\n';
  return 0;
}


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

signed main(void)
{
	int n, cnt;
	cin >> n;
	int a[n];
	rep(i, n) cin >> a[i];
	cnt = 0;
	for (int i = 0; i < n; i+=2)
	{
		if (a[i] % 2 == 1)
			cnt++;
	}
	cout << cnt << endl;
	return 0;
}


Measured memory_bytes: 3624
#pragma GCC optimize("O2")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("avx,avx2,sse,sse2,fma,tune=native")
#include<bits/stdc++.h>
#define rall(x) x.rbegin(), x.rend()
#define all(x) x.begin(), x.end()
#define pb push_back
#include <x86intrin.h>
#define pb push_back
using namespace std;
using ll = long long;
using pi = pair<int, int>;
using vi = vector<ll>;
using vpi = vector<pi>;
using ld = long double;
const int maxn = 1e5 + 55, mod = 1e9 + 7;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#define prev asdjfasj
ll n, m;
int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	cin >> n >> m;
	if(n>=2&&m>=2) {
		cout << (n-2)*(m-2);
	} else {
		if(m==1) swap(n, m);
		if(m==1) cout << 1;
		else cout <<m-2;
	}
}


Measured memory_bytes: 256
import Control.Monad (replicateM)
import Data.List (sortBy)
import Data.Ord (comparing)

main = do
    [n,t] <- map read.words<$>getLine
    roots <- replicateM n getRoot
    let result = minimumCost t roots
    maybe (putStrLn "TLE") print result

getRoot :: IO (Int,Int)
getRoot = do
    [c,t] <- map read.words<$>getLine
    return (c,t)

minimumCost :: Int -> [(Int,Int)] -> Maybe Int
minimumCost rimit = safeHead.map fst.sortBy (comparing fst).filter (\(c,t) -> t <= rimit)

safeHead xs
  | null xs = Nothing
  | otherwise = Just $ head xs


Measured memory_bytes: 1020