akhauriyash/Code-Regression huggingface dataset:
from itertools import combinations
n, m, q = map(int, input().split())
L = []
for _ in range(q):
    a, b, c, d = map(int, input().split())
    a -= 1
    b -= 1
    L.append((a, b, c, d))

def calc(A):
  score = 0
  for a, b, c, d in L:
    if A[b] - A[a] == c:
      score += d
  return score

N = list(range(1, n+m))
P = list(combinations(N, n))
ans = 0
for c in P:
  A = [c[i]-i for i in range(n)]
  g = calc(A)
  if g > ans:
    ans = g
print(ans)


Measured memory_bytes: 21444
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int main(int argc,char *argv[])
{
    char str[101];
    int count=0;
    gets(str);
    for(int i=0; i<strlen(str)/2; i++)
    {
        if(str[i]!=str[strlen(str)-1-i])
            count++;
    }
    printf("%d",count);
}


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

int main()
{
	int N, Q, T, C = 0;
	vector<int> S;
	
	cin >> N;
	for(int i = 0; i < N; ++i)
	{
		int temp;
		cin >> temp;
		S.push_back(temp);
	}
	
	sort(S.begin(), S.end());
	
	cin >> Q;
	for(int i = 0; i < Q; ++i)
	{
		cin >> T;
		vector<int>::iterator t = lower_bound(S.begin(), S.end(), T);
		if(t != S.end() && (*t) == T)
		{
			++C;
		}
	}
	
	cout << C << endl;

    return 0;
}



Measured memory_bytes: 3448
#include<iostream>
#include<algorithm>
using namespace std;
int main(){
  while(1){
    int n,m,i,a;cin>>n>>m>>a;if(n==0)break;
    pair<int,int>w[1000];
    for(i=0;i<m;i++)cin>>w[i].first>>w[i].second>>n;
    sort(w,w+m);
    for(i=m-1;i>=0;i--){
      n=w[i].second;
      if(n==a)a++;
      else if(n+1==a)a--;
    }
    cout<<a<<endl;
  }
  return 0;
}

Measured memory_bytes: 1172
#!/usr/bin/env python
# encoding: utf-8

from __future__ import print_function


class Solution:
    """
    @param prices: Given an integer array
    @return: Maximum profit
    """

    @staticmethod
    def insertion_sort():
        # write your code here
        array_length = int(input())
        unsorted_array = [int(x) for x in input().split()]

        for i in range(array_length):
            v = unsorted_array[i]
            j = i - 1
            while j >= 0 and unsorted_array[j] > v:
                unsorted_array[j + 1] = unsorted_array[j]
                j -= 1
            unsorted_array[j + 1] = v
            print(" ".join(map(str, unsorted_array)))


if __name__ == '__main__':
    solution = Solution()
    solution.insertion_sort()

Measured memory_bytes: 7704
#include<bits/stdc++.h>
using namespace std;
int main()
{
   int a[6];
   for(int i=1;i<=5;i++)
   {
       cin>>a[i];
   }
   for(int i=1;i<=5;i++)
   {
       if(a[i]==0)
       {
           cout<<i<<endl;
        
       }
   }

   return 0;
}


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

int main(){
    int n;
    cin >> n;
    vector<int> v(n);
    vector<int> c(n);
    int ans = 0;
    for (int i = 0; i<n; i++){
        cin >> v[i];
    }
    for (int i=0; i<n; i++){
        cin >> c[i];
    }
    for (int i=0; i<n; i++){
        if (v[i]-c[i]>0) ans += v[i]-c[i];
    }
    cout << ans << endl;
}



Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		
		String s = scan.nextLine();
		int cntA = 0;
		int cntB = 0;
		for (int i = 0; i < s.length(); i++) {
			if (s.charAt(i)=='A') {
				cntA++;
			} else {
				cntB++;
			}
		}
		
		if (cntA == 2 || cntB == 2) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}

	}

}

Measured memory_bytes: 23252
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scn = new Scanner(System.in);
		int n = scn.nextInt();
		int m = scn.nextInt();
		int max = n;
		int min = 0;
		int l;
		int r;
		for(;0<m;m--) {
			l = scn.nextInt();
			r = scn.nextInt();
			if(min<l) {
				min = l;
			}
			if(r<max) {
				max = r;
			}
		}
		if(max-min<0) {
			System.out.println(0);
		}else {
			System.out.println(max-min + 1);
		}
	}
}

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

using ll = int64_t;
#define int ll

#define FOR(i, a, b) for (int i = int(a); i < int(b); i++)
#define REP(i, b) FOR(i, 0, b)
#define MP make_pair
#define PB push_back
#define EB emplace_back
#define ALL(x) x.begin(), x.end()

using pi = pair<int, int>;
using vi = vector<int>;
using ld = long double;

template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
  os << "(" << p.first << "," << p.second << ")";
  return os;
}

template <class T> ostream &operator<<(ostream &os, const vector<T> &v) {
  os << "{";
  REP(i, (int)v.size()) {
    if (i)
      os << ",";
    os << v[i];
  }
  os << "}";
  return os;
}

ll read() {
  ll i;
  scanf("%" SCNd64, &i);
  return i;
}

void printSpace() { printf(" "); }

void printEoln() { printf("\n"); }

void print(ll x, int suc = 1) {
  printf("%" PRId64, x);
  if (suc == 1)
    printEoln();
  if (suc == 2)
    printSpace();
}

string readString() {
  static char buf[3341000];
  scanf("%s", buf);
  return string(buf);
}

char *readCharArray() {
  static char buf[3341000];
  static int bufUsed = 0;
  char *ret = buf + bufUsed;
  scanf("%s", ret);
  bufUsed += strlen(ret) + 1;
  return ret;
}

template <class T, class U> void chmax(T &a, U b) {
  if (a < b)
    a = b;
}

template <class T, class U> void chmin(T &a, U b) {
  if (b < a)
    a = b;
}

template <class T> T Sq(const T &t) { return t * t; }

const int mod = 1e9 + 7;

signed main() {
  int n, a, b;
  std::cin >> n >> a >> b;
  print(min(a * n, b));
}


Measured memory_bytes: 256
x, n = map(int, input().split())
ls = list(map(int, input().split()))
if n == 0:
    print(x)
else:
    i, j = 0, 0
    while True:
        if x + i not in ls:
            num1 = x + i
            break
        else:
            i += 1

    while True:
        if x - j not in ls:
            num2 = x - j
            break
        else:
            j += 1

    if abs(x - num1) > abs(x - num2):
        print(num2)
    elif abs(x - num1) < abs(x - num2):
        print(num1)
    else:
        print(min(num1, num2))


Measured memory_bytes: 9208
import java.util.Scanner

fun main(args: Array<String>) {
  val S = Scanner(System.`in`).next()
  var maxAns = 0
  var nowAns = 0
  for (c in S.toCharArray()) {
    if (c == 'A' || c == 'C' || c == 'G' || c == 'T') {
      nowAns++
      maxAns = if (maxAns > nowAns) maxAns else nowAns
    } else {
      nowAns = 0
    }
  }
  print(maxAns)
}

Measured memory_bytes: 31264
program Project1;

{$APPTYPE CONSOLE}

uses
  SysUtils;
var
  a,h,w,i,j,count,x,y,sw,m,n,b,c,soeji,sum,max,k,min:Integer;
  l:array of Integer;
  s,s123,s1,s2,s3:string;
  al:string = 'abcdefghijklmnopqrstuvwxyz';
  tf,tfl,tfr:Boolean;
begin
  try
    { TODO -oUser -cConsole メイン : ここにコードを記述してください }
    Read(a);
    Readln(b);
    count:=0;
    max  :=0;
    min  :=100;

    if a mod b =0 then
      Writeln('0')
    else
      Writeln('1');
    Readln;
  except
    on E: Exception do
      Writeln(E.ClassName, ': ', E.Message);
  end;
end.

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

// ABC127 C - Prison
// 2020.07.04

int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  int N, M; cin >> N >> M;
  vector<int> V(N+1, 0);
  vector<int> VV(N+1, 0);
  REP(i, M){
    int l, r; cin >> l >> r; l--; r--;
    V[l]++;
    V[r+1]--;
  }
  REP(i, N){
    if(i != 0){
      VV[i] = VV[i-1] + V[i];
    }else{
      VV[i] = V[i];
    }
  }
  int ans = 0;
  REP(i, N){
    if(VV[i] == M){
      ans++;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 3948
///*
#include<iostream>
using namespace std;

int main() {

	int a, b, k;
	int bigger;
	int counter = 0;
	int *kouyakusu;

	cin >> a >> b >> k;
	
	if (a > b) {
		kouyakusu = new int[a];
		bigger = a;
	}else{ 
		kouyakusu = new int[b];
		bigger = b;
	}

	for (int i = 1; i <= a&&i <= b; i++) {
		if (a%i == 0 && b%i == 0) {
			kouyakusu[counter] = i;
			counter++;
			//cout << i << " ";
		}
	}
	//cout << endl;

	cout << kouyakusu[counter - k] << endl;
	
	delete[] kouyakusu;

	return 0;
}
//*/

Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
const int N=1e5+50;
char s[N];
int len,x,y,ans;
int main(){
	scanf("%s",s);
	len=strlen(s);
	for(int i=0;i<len;i++){
		if(s[i]==s[i+1]){printf("%d %d\n",i+1,i+2);return 0;}
		else if(s[i]==s[i+2]){printf("%d %d\n",i+1,i+3);return 0;}
	}
	printf("-1 -1\n");
}

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

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

    std::vector<int> v(N);

    for (int k = 0; k < K; k++)
    {
        // k番目のお菓子をもらった人の数を取得
        int okashi_num;
        std::cin >> okashi_num;

        // k番目のお菓子をもらった人のインデックスを取得
        for (int i = 0; i < okashi_num; i++)
        {
            int num;
            std::cin >> num;
            v[--num]++;
        }
    }

    int cnt = 0;
    for (int i = 0; i < v.size(); i++)
    {
        // お菓子を持っていなければカウント
        if (v[i] == 0)
            cnt++;
    }

    std::cout << cnt << std::endl;

    return 0;
}

Measured memory_bytes: 3632
#include <stdio.h>
#include <string.h>
char s[100000];
int main(){
  scanf("%s",s);
  int len=strlen(s);
  int c=0;
  char t=s[0];
  for(int i=0;i<len;i++){
    if(s[i]!=t){
      c++;
      t=s[i];
    }
  }
  printf("%d\n",c);
  return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for (int i=0;i<(n);++i)
#define rep(i,a,b) for(int i=a;i<(b);++i)
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;}
typedef long long ll;
const ll INF = 1LL << 60;
const ll MOD = 1e9 + 7;

int N,K;
vector<ll> V;

ll check(int l, int r){
    vector<int> tmp;
    for(int i=0; i<=l;++i) tmp.push_back(V[i]);
    for(int i=r; i< N;++i) tmp.push_back(V[i]);
    sort(tmp.begin(),tmp.end());
    ll n = K - tmp.size(); // 捨てることができる数
    if(n < 0) return 0;
    ll sum = 0;
    REP(i,tmp.size()){
        if(n > 0 && tmp[i] < 0) --n;
        else sum += tmp[i];
    }
    return sum;
}
int main() {
    cin >> N >> K;
    V.resize(N);
    REP(i,N) cin >> V[i];

    ll ans = 0;
    for(int i = -1; i < N;++i){
        for(int j = i+1; j <= N; ++j){
            ans = max(ans,check(i,j));
        }
    }
    cout << ans << endl;
    return 0;
}

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

int n, m;
map<int,vector<int>> p;
int dp[100010];
int f(int x){
    if ( dp[x] >= 0 ) {
        return dp[x];
    }
    int ans = 0;
    if (p.count(x) != 0) {
        for ( int y : p[x] ) {
            ans = max( ans, f(y) + 1 );
        }
    }
    return dp[x] = ans;
}
int main() {
    cin >> n >> m;
    rep(i,n+1){
        dp[i] = -1;
    }
    rep(i,m){
        int x, y;
        cin >> x >> y;
        p[x].push_back(y);
    }

    int ans = 1;
    rep(i,n){
        ans = max( ans, f(i+1) );
    }
    cout << ans << endl;
}


Measured memory_bytes: 13696
#include<iostream>
using namespace std;
#define MAX_P 20000
int n; int dp[5010][MAX_P];
void fact(int n) {
	dp[0][0] = 1;
	for (int i = 1; i <= n; i++) {
		for (int j = 0; j < MAX_P; j++) {
			dp[i][j] += dp[i - 1][j] * i;
			if (dp[i][j] >= 10) {
				dp[i][j + 1] += dp[i][j] / 10; dp[i][j] %= 10;
			}
		}
	}
	dp[n][0] += 2;
	for (int j = 0; j < MAX_P; j++) {
		if (dp[n][j] >= 10) { dp[n][j + 1] += dp[n][j] / 10; dp[n][j] %= 10; }
	}
}
int main() {
	cin >> n; fact(n + 1); int ok = 0;
	for (int i = MAX_P - 1; i >= 0; i--) {
		if (dp[n + 1][i] >= 1) { ok = 1; }
		if (ok == 1) { cout << dp[n + 1][i]; }
	}
	cout << endl;
	for (int i = 2; i < n + 2; i++) { cout << i << endl; }
	return 0;
}

Measured memory_bytes: 119868
#include "bits/stdc++.h"
 
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
#define int ll
typedef pair<int,int> pii;
#define fi first
#define se second
#define Sort(a) sort(a.begin(),a.end())
#define rep(i,n) for(int i = 0;i < (n) ; i++) 
#define REP(i,n) for(int i = 0;i < (n) ; i++) 
#define MP(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define INF LLONG_MAX/4
#define INTINF INT_MAX/2
#define all(x) (x).begin(),(x).end()
#define debug(x) cerr<<#x<<": "<<x<<endl
#define debug_vec(v) cerr<<#v<<":";rep(i,v.size())cerr<<" "<<v[i];cerr<<endl
template<class T> inline bool chmax(T &a, T b){if(a < b){a = b;return true;}return false;}
template<class T> inline bool chmin(T &a, T b){if(a > b){a = b;return true;}return false;}
/*----------------------------------------------------------------*/
const int MOD = 998244353;
// const int MOD = 1000000007;

/*----------------------------------------------------------------*/
signed main(){

	
	int h,w;
	cin >> h >> w;
	char c[101][101];
	rep(i,h)rep(j,w)cin >> c[i][j];
	rep(i,h){
		rep(j,w)cout << c[i][j];cout << endl;
		rep(j,w)cout << c[i][j];cout << endl;
	}


	

	return 0;
}
/*----------------------------------------------------------------*/

// g++ -std=gnu++17 code1.cpp
// sudo pip3 install --upgrade online-judge-tools
// rm -r -f test;oj dl https://code-festival-2018-quala.contest.atcoder.jp/tasks/code_festival_2018_quala_c
// rm -r -f test;oj dl https://abc049.contest.atcoder.jp/tasks/abc049_b

Measured memory_bytes: 3648
d=list(map(int,input().split()))
for i in range(int(input())):
	o=list(map(int,input().split()))
	if o[0]==d[0]:
		if o[1]==d[1]:
			print(d[2])
		elif o[1]==d[2]:
			print(d[4])
		elif o[1]==d[4]:
			print(d[3])
		elif o[1]==d[3]:
			print(d[1])
			
	elif o[0]==d[1]:
		d[0],d[1],d[4],d[5]=d[1],d[5],d[0],d[4]
		if o[1]==d[1]:
			print(d[2])
		elif o[1]==d[2]:
			print(d[4])
		elif o[1]==d[4]:
			print(d[3])
		elif o[1]==d[3]:
			print(d[1])
			
	elif o[0]==d[2]:
		d[0],d[2],d[3],d[5]=d[2],d[5],d[0],d[3]
		if o[1]==d[1]:
			print(d[2])
		elif o[1]==d[2]:
			print(d[4])
		elif o[1]==d[4]:
			print(d[3])
		elif o[1]==d[3]:
			print(d[1])
		
	elif o[0]==d[3]:
		d[0],d[2],d[3],d[5]=d[3],d[0],d[5],d[2]
		if o[1]==d[1]:
			print(d[2])
		elif o[1]==d[2]:
			print(d[4])
		elif o[1]==d[4]:
			print(d[3])
		elif o[1]==d[3]:
			print(d[1])
		
	elif o[0]==d[4]:
		d[0],d[1],d[4],d[5]=d[4],d[0],d[5],d[1]
		if o[1]==d[1]:
			print(d[2])
		elif o[1]==d[2]:
			print(d[4])
		elif o[1]==d[4]:
			print(d[3])
		elif o[1]==d[3]:
			print(d[1])
			
	elif o[0]==d[5]:
		d[0],d[1],d[4],d[5]=d[5],d[4],d[1],d[0]
		if o[1]==d[1]:
			print(d[2])
		elif o[1]==d[2]:
			print(d[4])
		elif o[1]==d[4]:
			print(d[3])
		elif o[1]==d[3]:
			print(d[1])
	


Measured memory_bytes: 5632
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <bitset>
#include <algorithm>
#include <complex>
#include <array>
#include <iomanip>
using namespace std;

#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<long double> VD;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef vector<VD> VVD;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

template<typename T> void chmin(T &a, T b) { if (a > b) a = b; }
template<typename T> void chmax(T &a, T b) { if (a < b) a = b; }

int in() { int x; scanf("%d", &x); return x; }
ll lin() { ll x; scanf("%lld", &x); return x; }
#define INF 1LL<<60

int main() {
    int K;
    string S;
    cin >> K >> S;
    int l = S.length();
    if(l <= K) cout << S << endl;
    else cout << S.substr(0, K) + "..." << endl;
    return 0;
}

Measured memory_bytes: 3608
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <math.h>
using namespace std;
const int INF = 2000000000;
int main() {
	int n, m;
	cin >> n >> m;
	int c[21];
	int mini[50001];
	for (int i = 1; i <= m; i++) {
		cin >> c[i];
	}
	sort(c + 1, c + 1 + m);
	for (int i = 1; i <= n; i++) mini[i] = INF;
	for (int i = 1; i <= m; i++) {
		for (int j = 0; j <= n - c[i]; j++) {
			mini[j + c[i]] = min(mini[j] + 1, mini[j + c[i]]);
		}
	}
	cout << mini[n] << endl;
	return 0;
}

Measured memory_bytes: 3344
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int INF=0x3f3f3f3f;
const int MAXN=100009;

int main()
{
	//freopen("in.txt","r",stdin);
	//freopen("out.txt","w",stdout);
 
	char ch[5];
	while(scanf("%s",ch)!=EOF){
		int flag=0;
		if(ch[0]==ch[1]&&ch[0]==ch[2]) flag=1;
		if(ch[1]==ch[2]&&ch[1]==ch[3]) flag=1;
		if(flag) puts("Yes");
		else puts("No");
	}
	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
 
#if 1
#define gc() getchar_unlocked()
#else
#define gc() getchar()
#endif
int in()
{
    int n = 0, c = gc();
    do n = 10*n + (c & 0xf), c = gc(); while (c >= '0');
    return n;
}
 
int rot[24][7] = {
    { 0,1,2,3,4,5,6 },{ 0,1,3,5,2,4,6 },{ 0,1,4,2,5,3,6 },{ 0,1,5,4,3,2,6 },
    { 0,2,6,3,4,1,5 },{ 0,2,3,1,6,4,5 },{ 0,2,1,4,3,6,5 },{ 0,2,4,6,1,3,5 },
    { 0,3,1,2,5,6,4 },{ 0,3,2,6,1,5,4 },{ 0,3,5,1,6,2,4 },{ 0,3,6,5,2,1,4 },
    { 0,4,1,5,2,6,3 },{ 0,4,2,1,6,5,3 },{ 0,4,5,6,1,2,3 },{ 0,4,6,2,5,1,3 },
    { 0,5,1,3,4,6,2 },{ 0,5,3,6,1,4,2 },{ 0,5,4,1,6,3,2 },{ 0,5,6,4,3,1,2 },
    { 0,6,2,4,3,5,1 },{ 0,6,3,2,5,4,1 },{ 0,6,5,3,4,2,1 },{ 0,6,4,5,2,3,1 } };
 
int  a[102][7];
char f[102];
 
int identical(int *a, int *b)
{
    int i, j;
    memset(f, 0, sizeof(f));
    for (i = 1; i <= 6; i++) f[a[i]]++;
    for (i = 1; i <= 6; i++) f[b[i]]--;
    for (i = 1; i <= 6; i++) if (f[b[i]]) return 0;
 
    for (j = 0; j < 24; j++) {
        if (b[1] == a[rot[j][1]]) {
            for (i = 2; ; i++) {
                if (i > 6) return 1;
                if (b[i] != a[rot[j][i]]) break;
            }
        }
    }
    return 0;
}
 
int main()
{
    int n, i, j, f;
 
    n = in();
    for (i = 0; i < n; i++) {
        for (j = 1; j <= 6; j++) a[i][j] = in();
    }
    f = 1;
    for (i = 0; i < n; i++) for (j = i+1; j < n; j++) {
        if (identical(a[i], a[j])) { f = 0; goto done; }
    }
done:
    puts(f? "Yes": "No");
    return 0;
}


		




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

const double PI = acos(-1);

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
using P = pair<ll, ll>;
using V = vector<ll>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep1(i, n) for(ll i=1;i<=(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
#define ALL(obj) (obj).begin(), (obj).end()
#define RALL(obj) (obj).rbegin(), (obj).rend()
#define MOD 1000000007
#define INF 1000000000
#define LLINF 1e18

#define MAX_V 200005
struct edge {
	int to;
	int cost;
};
vector<edge> G[MAX_V];
int d[MAX_V];

void dijkstra(int s) {
	priority_queue<P, vector<P>, greater<P> > que;
	fill(d, d + MAX_V, INF);
	d[s] = 0;
	que.push(P(0, s));

	while (!que.empty()) {
		P p = que.top();
		que.pop();
		int v = p.second;
		if (d[v] < p.first) continue;

		for (int i = 0; i < G[v].size(); ++i) {
			edge e = G[v][i];
			if (d[e.to] > d[v] + e.cost) {
				d[e.to] = d[v] + e.cost;
				que.push(P(d[e.to], e.to));
			}
		}
	}
}

void solve_abc_c() {
	ll n, m;
	ll k;
	ll h, w;
	//ll x;
	//ll a;
	string s;
	string s_ans;
	ll l_ans = 0;
	double d_ans = 0;

	cin >> n;

	vector<P> a(n);
	rep(i, n) {
		cin >> a[i].first;
		a[i].second = i+1;
	}

	sort(ALL(a));

	rep(i, n) {
		cout << a[i].second << " ";
	}
}

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

	solve_abc_c();

	return 0;
}


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

double Area(double x0, double y0, double x1, double y1, double x2, double y2) {
    double a, b, c, z;
    a = sqrt((x1-x0) * (x1-x0) + (y1-y0) * (y1-y0));    //(x0,y0),(x1,y1)間の距離
    b = sqrt((x2-x0) * (x2-x0) + (y2-y0) * (y2-y0));    //(x0,y0),(x2,y2)間の距離
    c = sqrt((x2-x1) * (x2-x1) + (y2-y1) * (y2-y1));    //(x1,y1),(x2,y2)間の距離
    z = (a+b+c) / 2.0;
    return sqrt(z * (z-a) * (z-b) * (z-c));
}

int main(void){
    double x0, y0, x1, y1, x2, y2;
    double area=0.0;
    
    scanf("%lf,%lf", &x0, &y0);
    scanf("%lf,%lf", &x1, &y1);
    while(scanf("%lf,%lf", &x2, &y2) != EOF) {
        area += Area(x0, y0, x1, y1, x2, y2);
        x1=x2; y1=y2;
    }    
    printf("%.6lf\n", area);
    
    return 0;
}


Measured memory_bytes: 1988
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
#define mp make_pair
#define PI pair<int,int>
#define poly vector<ll>
#define For(i,l,r) for(int i=(int)(l);i<=(int)(r);i++)
#define Rep(i,r,l) for(int i=(int)(r);i>=(int)(l);i--)
#define pb push_back
#define fi first
#define se second
inline char gc(){
    static char buf[100000],*p1=buf,*p2=buf;
    return p1==p2&&(p2=(p1=buf)+fread(buf,1,100000,stdin),p1==p2)?EOF:*p1++;
}
#define gc getchar
inline ll read(){
	ll x = 0; char ch = gc(); bool positive = 1;
	for (; !isdigit(ch); ch = gc())	if (ch == '-')	positive = 0;
	for (; isdigit(ch); ch = gc())	x = x * 10 + ch - '0';
	return positive ? x : -x;
}
inline void write(ll a){
    if(a<0){
    	a=-a; putchar('-');
	}
    if(a>=10)write(a/10);
    putchar('0'+a%10);
}
inline void writeln(ll a){write(a); puts("");}
inline void wri(ll a){write(a); putchar(' ');}
inline ull rnd(){
	return ((ull)rand()<<30^rand())<<4|rand()%4;
}
const int N=405,mod=998244353;
const ll mod2=(ll)mod*mod*8;
int b[N],sa,sb,n;
ll a[N],A[N],fac[N],ni[N],dp[2][N][N],yc[N],xs[N][N],inv[N];
ll ksm(ll a,int b){
	int ans=1;
	for(;b;b>>=1){
		if(b&1)ans=ans*a%mod;
		a=a*a%mod;
	}
	return ans;
}
int main(){
	For(i,fac[0]=ni[0]=1,N-1){
		fac[i]=fac[i-1]*i%mod; ni[i]=ksm(fac[i],mod-2);
	}
	n=read(); ll s=0;
	For(i,1,n){s+=(a[i]=read());b[i]=read(); }
	inv[1]=1; For(i,2,n)inv[i]=mod-mod/i*inv[mod%i]%mod;
	s=ksm(s%mod,mod-2);
	For(i,1,n){
		A[i]=a[i]*s%mod;
	}
	dp[0][0][0]=1;
	For(i,1,n){
		int t=i&1,s=t^1;
		For(j,yc[0]=1,b[i]-1)yc[j]=yc[j-1]*A[i]%mod;
		For(j,0,b[i]-1)yc[j]=yc[j]*(mod-ni[j])%mod;
		sa+=a[i]; sb+=b[i]-1;
		For(j,0,sa)For(k,0,sb){
			dp[t][j][k]=j>=a[i]?dp[s][j-a[i]][k]:0;
			int meiju=min(k,b[i]-1);
			For(l,0,meiju){dp[t][j][k]+=dp[s][j][k-l]*yc[l]; if(dp[t][j][k]>=mod2)dp[t][j][k]-=mod2;}
			dp[t][j][k]%=mod;
		} 
	}
	For(i,0,sa-1){
		xs[i][0]=ksm((1-i*s)%mod,mod-2);
		For(j,1,sb){
			xs[i][j]=xs[i][j-1]*j%mod*xs[i][0]%mod;
		}
	}
	ll ans=0;
	For(i,0,sa-1)For(j,0,sb)ans=(ans+xs[i][j]*dp[n&1][i][j])%mod;
	cout<<(-ans%mod+mod)%mod<<endl;
}

Measured memory_bytes: 4096
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <utility>
#include <tuple>
#include <algorithm>
#include <numeric>
#include <cstdio>
#include <cmath>
#define rep(i, n) for(int i = 0; i < (n); i++)
using namespace std;
using ll = long long;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

int main(){
  int N;
  cin >> N;
  cout << (int)pow(N, 3) << endl;
}

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

using namespace std;

#define S scanf
#define P printf
#define G getline
#define SZ size()
#define C clear()
#define B begin()
#define F front()
#define T top()
#define E end()
#define EM empty()
#define V vector
#define Q queue
#define DQ deque
#define PQ priority_queue
#define ST stack
#define FI first
#define SE second
#define PI acos(-1)
#define PS push
#define PP pop()
#define PSF push_front
#define PSB push_back
#define PPF pop_front()
#define PPB pop_back()
#define MP make_pair
#define LL long long int
#define ULL unsigned long long int
#define PII pair<int,int>
#define PSI pair<string,int>
#define PIS pair<int,string>
#define PLI pair<long long int,int>
#define PLL pair<long long int,long long int>
#define MII map<int,int>
#define MSI map<string,int>
#define MIS map<int,string>
#define MLI map<long long int,int>
#define FAST() ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)





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






int main()
{
    FAST();

//    freopen("input.txt","r",stdin);
//    freopen("input.txt","w",stdout);

    int ans=0;
    string s1,s2;
    cin >> s1 >> s2;
    for(int i=0;i<3;i++)
    {
        if(s1[i] == s2[i])
        {
            ans++;
        }
    }
    cout << ans;
    return 0;
}


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

using namespace std;

void solve() {
    int N;
    cin >> N;
    int C[N], S[N], F[N];
    for(int i = 0; i < N - 1; i++) cin >> C[i] >> S[i] >> F[i];
    int ans[N];
    for(int i = 0; i < N; i++) ans[i] = 0;

    for(int i = 0; i < N-1; i++){
        int time = S[i] + C[i];
        for(int j = i+1; j < N-1; j++){
            int k = 0;
            while (time > S[j]+F[j]*k)
            {
                /* code */
                k++;
            }
            time = S[j]+F[j]*k + C[j];
        }
        ans[i] = time;
    }
    for(int i = 0; i < N; i++) cout << ans[i] << endl;
    return;
}

int main() {
    solve();
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<math.h>
#include<cstdio>
#include<ctype.h>
#include<stdio.h>
#include<set>
#include<vector>
#include<map>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<numeric>
#include<string>
using namespace std;
typedef long long ll;
ll dx[] = { 1,1,0,-1,-1,-1,0,1 };
ll dy[] = { 0,1,1,1,0,-1,-1,-1 };
ll prime(ll x) {
	ll i;
	if (x < 2)return 0;
	else if (x == 2) return 1;
	if (x % 2 == 0) return 0;
	for (i = 3; i*i <= x; i += 2) {
		if (x%i == 0) return 0;
	}
	return 1;
}
ll gcd(ll a, ll b) {
	if (a<b) { return gcd(b, a); }
	else if (a%b) { return gcd(b, a%b); }
	else { return b; }
}

ll MOD = 1000000007;
int main() {
	string s, t;
	cin >> s;
	cin >> t;
	sort(s.begin(), s.end());
	sort(t.rbegin(), t.rend());
	if (s<t)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;
}


Measured memory_bytes: 256
import std;

alias sread = () => readln.chomp();
alias lread = () => readln.chomp.to!long();
alias aryread(T = long) = () => readln.split.to!(T[]);
//aryread!string();
//auto PS = new Tuple!(long,string)[](M);
//x[]=1;でlong[]全要素1に初期化
void main()
{
    long n, x, t;
    scan(n, x, t);
    // writeln(n, x, t);
    long cnt;
    long time;
    foreach (_; 0 .. 10 ^^ 7)
    {
        cnt += x;
        time += t;
        // writeln(cnt);
        if (cnt >= n)
        {
            writeln(time);
            return;
        }
    }
}

void scan(L...)(ref L A)
{
    auto l = readln.split;
    foreach (i, T; L)
    {
        A[i] = l[i].to!T;
    }
}

void arywrite(T)(T a)
{
    a.map!text.join(' ').writeln;
}


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

int main() {

  double PI = 3.14159265358979323846264338327950L;

  double A, B, H, M;
  cin >> A >> B >> H >> M;

  double angleH = 360 * H / 12;
  double angleM = 360 * M / 60;

  angleH += 30 * M / 60;

  double angle = angleH - angleM;

  double radian = angle * PI / 180.0;
  double answer =(double) A * A + B * B - ((double) 2 * A * B * cosl(radian));

  printf("%.20f\n", sqrt(answer));

  return 0;

}

Measured memory_bytes: 4156
#include<iostream>
#include<algorithm>
using namespace std;
static const int MAX = 200000;
int main(){
    int R[MAX], n;
    
    cin >> n;
    for ( int i = 0; i < n; i++ ) {cin >> R[i];}
    
    int maxv = -2000000000;
    int minv = R[0];
    
    for ( int i = 1; i < n; i++ ){
        maxv = max(maxv, R[i] - minv);
        minv = min(minv, R[i]);
    }
    
    cout << maxv << endl;
    
    return 0;
}


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

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;}
template<class T> inline T gcd(T a,T b){T c;while(b!=0){c=a%b;a=b;b=c;}return a;}
template<class T> inline T lcm(T a,T b){return a*b/gcd(a,b);}

const int INF=1e9;
const double eps=0.0000000001;


int main(){
    int n,k;
    cin >> n >> k;
    int a[1000000];
    FOR(i,n){
      cin >> a[i];
    }

    sort(a,a+n);

    int cnt=1;
    vector<int> v;
    FOR(i,n-1){
      if(a[i]!=a[i+1]){
        v.push_back(cnt);
        cnt=1;
      }else{
        cnt++;
      }
    }
    v.push_back(cnt);

    sort(v.begin(),v.end());
    int ans=0;
    if(v.size()<k){
      cout << 0 << endl;
      return 0;
    }
    FOR(i,v.size()-k){
      ans+=v[i];
    }
    cout << ans << endl;
}


Measured memory_bytes: 2944
h,w=map(int,input().split())
L=[input() for i in range(h)]

L2=[]
for i in range(h):
      if "#" in L[i]:
            L2.append(list(L[i]))
            
flag=[]
for i in range(w):
      for j in range(len(L2)):
            if L2[j][i]=="#":
                  flag.append(i)
                  break
ans=[]
ans2=[]
for i in range(len(L2)):
      for j in flag:
            ans2.append(L2[i][j])
      ans.append(ans2)
      ans2=[]

for i in range(len(ans)):
      print("".join(ans[i]))
            

Measured memory_bytes: 3188
h1,h2=map(int,input().split())
k1,k2=map(int,input().split())
a,b,c,d=map(int,input().split())
hiro=a*h1+b*h2+(h1//10)*c+(h2//20)*d
kenji=a*k1+b*k2+(k1//10)*c+(k2//20)*d
if hiro>kenji:
    print("hiroshi")
elif hiro<kenji:
    print("kenjiro")
else:
    print("even")



Measured memory_bytes: 5596
P = [11, 31, 41, 61, 71, 101, 131,
     151, 181, 191, 211, 241, 251,
     271, 281, 311, 331, 401, 421,
     431, 461, 491, 521, 541, 571,
     601, 631, 641, 661, 691, 701,
     751, 761, 811, 821, 881, 911,
     941, 971, 991, 1021, 1031, 1051,
     1061, 1091, 1151, 1171, 1181,
     1201, 1231, 1291, 1301, 1321,
     1361, 1381]

print " ".join(map(str, P[:input()]))

Measured memory_bytes: 2568
#include <iostream>
#include <string>
#include <stdio.h>
#include <algorithm>
#define MAX 1000


int lcs(std::string X, std::string Y) {
    int c[MAX+1][MAX+1];
    int maxl = 0;
    int m = X.size();
    int n = Y.size();
    for (int i = 1; i <= m; i++) {
        c[i][0] = 0;
    }
    for (int i = 1; i <= n; i++) {
        c[0][i] = 0;
    }
    X = ' ' + X;
    Y = ' ' + Y;
    for (int i = 1; i <= m; i++) {
        for (int j = 1; j <= n; j++) {
            if (X[i] == Y[j]) {
                c[i][j] = c[i-1][j-1] + 1;
            } else {
                c[i][j] = std::max(c[i-1][j], c[i][j-1]);
            }
            maxl = std::max(maxl, c[i][j]);
        }
    }
    return maxl;
}

int main() {
    std::string s1, s2;
    int n;
    scanf("%d", &n);
    for (int i = 0; i < n; i++) {
        std::cin >> s1 >> s2;
        int a = lcs(s1, s2);
        printf("%d\n", lcs(s1, s2));
    }
    
    return 0;
}



Measured memory_bytes: 7136
using System;

namespace ABC076B
{
    class Program
    {
        static void Main(string[] args)
        {
            int N = int.Parse(Console.ReadLine());
            int K = int.Parse(Console.ReadLine());

            int res = 1;
            for (int i = 0; i < N; i++)
            {
                if (res < K)
                {
                    res <<= 1;
                }
                else
                {
                    res += K;
                }
            }

            Console.WriteLine(res);
        }
    }
}


Measured memory_bytes: 11092
/* ***********************************************
Author        :yang12138
Created Time  :2017年04月17日 星期一 01时40分45秒
File Name     :B.cpp
************************************************ */
#include <iostream>
#include <stdio.h>
#include <cstring>
#include <algorithm>
#include <string>
#include <math.h>
#include <cstdlib>
#include <vector>
#include <queue>
#include <set>
#include <map>
using namespace std;
#define mem(a,b) memset(a,b,sizeof(a))
typedef long long ll;
typedef pair<int,int>pii;
#define lson (root<<1)
#define rson (root<<1|1)

const int N=1e5+10;

struct Edg{
	int to,nex;
}e[N<<1];

int head[N],cnt;
void add_edge(int u,int v){
	e[cnt].to=v,e[cnt].nex=head[u],head[u]=cnt++;
}
bool vis[N];
int s,t;

void dfs(int u,vector<int>& ve){
	vis[u]=1,ve.push_back(u);
	int flag=-1;
	for(int i=head[u];~i;i=e[i].nex){
		int v=e[i].to;
		if(!vis[v]) {flag=v;break;}
	}
	if(flag==-1) return ;
	dfs(flag,ve);
}

vector<int>ans;
int main(){
    //freopen("in.txt","r",stdin);
    //freopen("out.txt","w",stdout);
   	int n,m;
	scanf("%d%d",&n,&m);

	mem(head,-1);
	for(int i=1;i<=m;i++){
		int u,v;
		scanf("%d%d",&u,&v);
		add_edge(u,v);
		add_edge(v,u);
		s=u,t=v;
	}

	vis[s]=vis[t]=1;
	dfs(s,ans);
	reverse(ans.begin(),ans.end());
	dfs(t,ans);

	printf("%d\n",(int)ans.size());
	for(int i=0;i<ans.size()-1;i++){
		printf("%d ",ans[i]);
	}
	printf("%d\n",ans[ans.size()-1]);



    return 0;
}


Measured memory_bytes: 5624
#include<iostream>
#include<stdio.h>
#include<algorithm>
#include<cmath>
#include<vector>
#include<map>
#include<set>
#include<string>
using namespace std;
#define mod int(1e9+7)
#define rep(i,n) for(int i=0;i<n;i++)
#define reps(i,a,b) for(int i=a;i<=b;i++)
#define repn(i,a,b) for(int i=b-1;i>=a;i--)
#define F first
#define S second
#define pb push_back
#define mk make_pair
typedef long long int ll;

int main()
{ ios_base::sync_with_stdio(false); cin.tie(0);
  ll n; cin>>n;
  ll a; cin>>a;
  ll ans=a-1,i=1;
  reps(j,1,n-1) {
    cin>>a;
    if(i+1==a) i++;
    else if(a>i+1) { ans+=(a-1)/(i+1); }
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 256
var result = Int.max
let S = Array(readLine()!)
let T = Array(readLine()!)

for sIndex in 0..<S.count {
    if S.count - sIndex >= T.count {
        var tmpMin = 0
        for tIndex in 0..<T.count {
            if S[sIndex+tIndex] != T[tIndex] {
                tmpMin += 1
            }
        }
        result = min(result, tmpMin)
    }
}

print(result)


Measured memory_bytes: 7764
#include <bits/stdc++.h>
const long long INF = 1LL << 60;
using namespace std;
using ll = long long;
using P = pair<int, int>;

ll cho2(ll n) {
    return n*(n-1)/2;
}

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

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

    vector<int> cnt(N);
    for (int i = 0; i < N; ++i) cnt[A[i]]++;

    ll total = 0;
    for (int i = 1; i < N+1; ++i) total += cho2(cnt[i]);

    for (int i = 0; i < N; ++i) {
        ll ans = total;
        ans -= cho2(cnt[A[i]]);
        cnt[A[i]]--;
        ans += cho2(cnt[A[i]]);
        cout << ans << endl;
        cnt[A[i]]++;
    }
    return 0;
}

Measured memory_bytes: 4096
a, v = map(int, input().split())
b, w = map(int, input().split())
t = input()
T = int(t)

d = b - a
d = int(d)
dv = v - w
dv = int(dv)
d = abs(d)
if dv > 0 and abs(d) <= abs(dv) * T:
    print('YES')
else:
    print('NO')

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

int main(){
	int n,k;
	cin>>n>>k;
	vector<char> a(k);
	for(int i=0;i<k;i++){
		cin>>a[i];
	}
	
	bool flag;
	
	while(1){
		string s=to_string(n);
		flag=true;
		for(int i=0;i<s.size();i++){
			for(int j=0;j<a.size();j++){
				if(s[i]==a[j]){
					flag=false;
				}
			}
		}
		if(flag){
			cout<<n<<endl;
			return 0;
		}
		n++;
	}
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void) {
    int n, y;
    scanf("%d %d", &n, &y);
    n += 1;


    for (int i = 0; i < n; ++i) {
        int o, check;
        o = n - i;
        for (int j = 0; j < o; ++j) {
            int k;
            k = n -1 - i - j;
            check = (10000 * i) + (5000 * j) + (1000 * k);
            if (check == y){
                printf("%d %d %d",i,j,k);
                return 0;
            }
        }
    }
    printf("-1 -1 -1");
    return 0;
}


Measured memory_bytes: 1728
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
#define INT(...) int __VA_ARGS__;in(__VA_ARGS__)
#define LL(...) ll __VA_ARGS__;in(__VA_ARGS__)
#define ULL(...) ull __VA_ARGS__;in(__VA_ARGS__)
#define STR(...) string __VA_ARGS__;in(__VA_ARGS__)
#define CHR(...) char __VA_ARGS__;in(__VA_ARGS__)
#define DBL(...) double __VA_ARGS__;in(__VA_ARGS__)
#define vec(type,name,...) vector<type> name(__VA_ARGS__)
#define VEC(type,name,size) vector<type> name(size);in(name)
#define vv(type,name,h,...) vector<vector<type>>name(h,vector<type>(__VA_ARGS__))
#define VV(type,name,h,...) vector<vector<type>>name(h,vector<type>(__VA_ARGS__));in(name)
#define vvv(type,name,h,w,...) vector<vector<vector<type>>>name(h,vector<vector<type>>(w,vector<type>(__VA_ARGS__)))
inline int scan(){ return getchar(); }
inline void scan(int &a){ scanf("%d", &a); }
inline void scan(unsigned &a){ scanf("%u", &a); }
inline void scan(long &a){ scanf("%ld", &a); }
inline void scan(long long &a){ scanf("%lld", &a); }
inline void scan(unsigned long long &a){ scanf("%llu", &a); }
inline void scan(char &a){ cin >> a; }
inline void scan(float &a){ scanf("%f", &a); }
inline void scan(double &a){ scanf("%lf", &a); }
inline void scan(long double &a){ scanf("%Lf", &a); }
inline void scan(vector<bool> &vec){ for(unsigned i = 0; i < vec.size(); i++) { int a; scan(a); vec[i] = a; } }
inline void scan(string &a){ cin >> a; }
template<class T> inline void scan(vector<T> &vec);
template<class T, size_t size> inline void scan(array<T, size> &vec);
template<class T, class L> inline void scan(pair<T, L> &p);
template<class T, size_t size> inline void scan(T (&vec)[size]);
template<class T> inline void scan(vector<T> &vec){ for(auto &i : vec) scan(i); }
template<class T, size_t size> inline void scan(array<T, size> &vec){ for(auto &i : vec) scan(i); }
template<class T, class L> inline void scan(pair<T, L> &p){ scan(p.first); scan(p.second); }
template<class T, size_t size> inline void scan(T (&vec)[size]){ for(auto &i : vec) scan(i); }
template<class T> inline void scan(T &a){ cin>>a; }
inline void in(){}
template <class Head, class... Tail> inline void in(Head &head, Tail&... tail){ scan(head); in(tail...); }
inline constexpr ll gcd(ll a,ll b){if(!a||!b)return 0;while(b){ll c=b;b=a%b;a=c;}return a;}
inline constexpr ll lcm(ll a,ll b){if(!a||!b)return 0;return a*b/gcd(a,b);}
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; }
using Graph = vector<vector<int>>;
/* 4方向への隣接頂点への移動を表すベクトル */
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

const long long INF = 1LL << 60;
int main(){
    LL(N);
    if(N%2 == 0){
        cout<< 0.5 << endl;
    } else if(N == 1){
        cout << 1 << endl;
    } else {
        cout<< (float)(1.0+N/2)/N << endl;
    }
}

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

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

    vector<pair<int,int>> problem(n);
    multiset<int> used;
    multiset<int> remaining;

    for(int i=0; i<n; i++){
        cin >> problem[i].first >> problem[i].second;
        remaining.insert(problem[i].second);
    }
    sort(problem.begin(), problem.end());
    reverse(problem.begin(), problem.end());

    int l2 = problem[0].first;
    int r2 = problem[0].second;

    int ans = 0;
    for(int i=1; i<n; i++){// first problem to be in different group with problem[0]
        remaining.erase(remaining.find(problem[i-1].second));
        used.insert(problem[i-1].second);

        r2 = min(r2, *used.begin());
        int l1 = problem[i].first;
        int r1 = problem[i].second;

        int test1 = max(0, min(r1,*remaining.begin()) - l1 + 1) + max(0,     r2                     - l2 + 1);
        int test2 = max(0,     r1                     - l1 + 1) + max(0, min(r2,*remaining.begin()) - l2 + 1);
        ans = max({ans, test1, test2});
    }
    cout << ans << endl;
    return 0;
}

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

#define rep(i, n) for (int i = 0; i < n; ++i)
#define ALL(a) (a).begin(), (a).end()

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

using ll = long long;
using ld = long double;
using P = pair<int, int>;
using DoP = pair<double, double>;
using edge = struct { int to; double cost;}; // edge x = {to, cost}

const int di[] = {0, 1, 0, -1, 1, 1, -1, -1};
const int dj[] = {1, 0, -1, 0, 1, -1, 1, -1};
const int INF = 1<<29;
const ll INF64 = 1ll << 45;
const int mod = 1000000007;

struct mint
{
  ll x; // typedef long long ll;
  mint(ll x = 0) : x((x % mod + mod) % mod) {}
  mint operator-() const { return mint(-x); }
  mint &operator+=(const mint a)
  {
    if ((x += a.x) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator-=(const mint a)
  {
    if ((x += mod - a.x) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator*=(const mint a)
  {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const
  {
    mint res(*this);
    return res += a;
  }
  mint operator-(const mint a) const
  {
    mint res(*this);
    return res -= a;
  }
  mint operator*(const mint a) const
  {
    mint res(*this);
    return res *= a;
  }
  mint pow(ll t) const
  {
    if (!t)
      return 1;
    mint a = pow(t >> 1);
    a *= a;
    if (t & 1)
      a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const
  {
    return pow(mod - 2);
  }
  mint &operator/=(const mint a)
  {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const
  {
    mint res(*this);
    return res /= a;
  }
};
// h(n, r) = c(n+r-1, r)
struct combination
{
  vector<mint> fact, ifact;
  combination(int n) : fact(n + 1), ifact(n + 1)
  {
    assert(n < mod);
    fact[0] = 1;
    for (int i = 1; i <= n; ++i)
      fact[i] = fact[i - 1] * i;
    ifact[n] = fact[n].inv();
    for (int i = n; i >= 1; --i)
      ifact[i - 1] = ifact[i] * i;
  }
  mint operator()(int n, int k)
  {
    if (k < 0 || k > n)
      return 0;
    return fact[n] * ifact[k] * ifact[n - k];
  }
};

int main(){
  string s; cin >> s;
  if(s == "ABC") cout << "ARC" << endl;
  else cout << "ABC" << endl;
}

Measured memory_bytes: 3596
#include <iostream>
using namespace std;
int main(){
  int N;
  cin>>N;
  int t[N],x[N],y[N];
  t[0]=x[0]=y[0]=0;
  for(int i=0; i<N; i++) cin>>t[i+1]>>x[i+1]>>y[i+1];
    bool chinko=true;
  for (int i=0; i<N; i++) {
    int dt=t[i+1]-t[i];
    int dint=abs(x[i+1]-x[i])+abs(y[i+1]-y[i]);
    if (dt<dint){
      chinko=false;}
    if (dint % 2 != dt % 2){
      chinko=false;}
  }
  if(chinko) cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
}
    
    

Measured memory_bytes: 1408
#include <iostream>

int main() {
    while( true ) {
        int h , w ;
        std::cin >> h >> w ;
        if( h == 0 && w == 0 ) {
            break ;
        } else {
            for( int i = 0 ; i < h ; i++ ) {
                for( int ii = 0 ; ii < w ; ii++ ) {
                    if( i != 0 && i != h - 1 && ii != 0 && ii != w - 1 ) {
                        std::cout << "." ;
                    } else {
                        std::cout << "#" ;
                    }
                }
                std::cout << std::endl ;
            }
            std::cout << std::endl ;
        }
    }
}



Measured memory_bytes: 3080
#include<stdio.h>
#include<algorithm>
using namespace std;
long long bit[2][524288];
void add(int a,int b,int c){
	for(;a<524288;a|=a+1)bit[c][a]+=b;
}
long long sum(int a,int b,int c){
	if(a)return sum(0,b,c)-sum(0,a-1,c);
	long long ret=0;
	for(;b>=0;b=(b&(b+1))-1)ret+=bit[c][b];
	return ret;
}
int p[300000];
int q[300000];
pair<int,int> dat[300000];
pair<int,int> val[300000];
int main(){
	int a;
	scanf("%d",&a);
	for(int i=0;i<a;i++)scanf("%d%d",p+i,q+i);
	for(int i=0;i<a;i++)val[i]=make_pair(p[i],q[i]);
	std::sort(val,val+a);
	for(int i=0;i<a;i++)dat[i]=make_pair(-val[i].second,i);
	std::sort(dat,dat+a);
	int ret=0;
	for(int i=0;i<a;i++){
		add(dat[i].second,val[dat[i].second].first,0);
		add(dat[i].second,1,1);
		int left=-1;
		int right=300000;
		while(left+1<right){
			int M=(left+right)/2;
			long long s=sum(0,M,0);
			long long t=sum(0,M,1);
		//	printf("%lld\n",(long long)dat[i].first*t+s);
			if((long long)dat[i].first*t+s<=0)left=M;
			else right=M;
		}
	//	printf("%d %d\n",left,sum(0,left,1));
		ret=max(ret,(int)sum(0,left,1));
	}
	printf("%d\n",ret);
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int n;
  cin>>n;
  vector<int> v;
  for(int i=0;i<n;i++)
  {
    int a;
    cin>>a;
    v.push_back(a);
  }
  float f=0;
  sort(v.begin(),v.end());
  
  f=v[0];
  for(int i=1;i<n;i++)
  { f=(f+v[i])/2;
  }
  cout<<f;
}
    
  

Measured memory_bytes: 256
#!/usr/bin/env python3
import sys, math, itertools, collections, bisect
input = lambda: sys.stdin.buffer.readline().rstrip().decode('utf-8')
inf = float('inf') ;mod = 10**9+7
mans = inf ;ans = 0 ;count = 0 ;pro = 1

while True:
  mans = inf
  n=int(input())
  if n == 0: exit()
  A=list(map(int,input().split()))
  for i in range(n-1):
    for j in range(i+1,n):
      mans = min(mans,abs(A[i]-A[j]))
  print(mans)


Measured memory_bytes: 6156
#include <stdio.h>
 
void Judge(int F_W, int F_H, int F_x, int F_y, int F_r)
{
    if( (F_x+F_r<=F_W) && (F_x-F_r>=0) && (F_y+F_r<=F_H) && (F_y-F_r>=0) ){
        printf("Yes\n");
    }
    else{
        printf("No\n");
    }
} 
 
int main()
{
    int W, H, x, y, r;
    scanf("%d", &W);
    scanf("%d", &H);
    scanf("%d", &x);
    scanf("%d", &y);
    scanf("%d", &r);
    
    Judge(W,H,x,y,r);
    
    return 0;
}


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

int main()
{
    int N;
    long map[10][10] = {0};
    cin >> N;
    for (int i = 1; i < N + 1; i++)
    {
        string s = to_string(i);
        char s_first = s[0];
        char s_last = s[s.size() - 1];
        if (s_first != '0' && s_last != '0')
        {
            map[s_last - '0'][s_first - '0']++;
        }
    }
    long sum = 0;
    for (int i = 1; i < 10; i++)
    {
        for (int j = 1; j < 10; j++)
        {
            sum += map[i][j] * map[j][i];
        }
    }
    cout << sum << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int func(int i,int n,int a[],int b[],int c[],int prev,int dp[][4])
{
	if(i==n)
		return 0;
	if(dp[i][prev]!=-1)
		return dp[i][prev];
	int pos1=0,pos2=0,pos3=0;
	if(prev!=1)
		pos1=a[i]+func(i+1,n,a,b,c,1,dp);
	if(prev!=2)
		pos2=b[i]+func(i+1,n,a,b,c,2,dp);
	if(prev!=3)
		pos3=c[i]+func(i+1,n,a,b,c,3,dp);
	return dp[i][prev] = max(pos1,max(pos2,pos3));
}
int main()
{
	int n;
	cin>>n;
	int a[n],b[n],c[n];
	for(int i=0;i<n;i++)
		cin>>a[i]>>b[i]>>c[i];
	int dp[n+1][4];
	memset(dp,-1,sizeof(dp));
	cout<<func(0,n,a,b,c,0,dp);
}


Measured memory_bytes: 17240
#include<iostream>
#include<string>
#include<cstring>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
using ll = long long;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;
#define PI 3.141592653589793

int main(){
  int N; cin >> N; ll a[N];
  rep(i, N){
    cin >> a[i];
  }
  ll dp[N+1][N+1];
  rep(i, N+1){
    dp[i][i]=0;
  }
  for(int len=1; len<=N; len++){
    for(int i=0; i+len<=N; i++){
      int j = i+len;
      if((N-(j-i))%2) dp[i][j] = min(dp[i][j-1]-a[j-1], dp[i+1][j]-a[i]);
      else dp[i][j] = max(dp[i][j-1]+a[j-1], dp[i+1][j]+a[i]);
    }
  }
  cout << dp[0][N] << endl;
}

Measured memory_bytes: 70400