akhauriyash/Code-Regression huggingface dataset:
/*
─────────────────────
───────────████████──
──────────███▄███████
──────────███████████
──────────███████████
──────────██████─────
──────────█████████──
█───────███████──────
██────████████████───
███──██████████──█───
███████████████──────
███████████████──────
─█████████████───────
──███████████────────
────████████─────────
─────███──██─────────
─────██────█─────────
─────█─────█─────────
─────██────██────────
─────────────────────
*/
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>

#define int long long
#define read(a) int a; cin >> a;
#define readb(a, b) int a, b; cin >> a >> b;
#define readc(a, b, c) int a, b, c; cin >> a >> b >> c;
#define reads(s) string s; cin >> s;
#define readarr(a, n) int a[(n) + 1] = {}; fori (i, 1, (n)) {cin >> a[i];}
#define readmat(a, n, m) int a[n + 1][m + 1] = {}; fori (i, 1, n) {fori (j, 1, m) cin >> a[i][j];}

#define print(a) cout << a << endl;
#define printarr(a, n) fori (i, 1, n) cout << a[i] << " "; cout << endl;
#define printv(v) for (int i: v) cout << i << " "; cout << endl;
#define printmat(a, n, m) fori (i, 1, n) {fori (j, 1, m) cout << a[i][j] << " "; cout << endl;}
#define all(v) v.begin(), v.end()
#define sz(s) (int)(s.size())
#define pb push_back
#define fi first
#define se second
#define rz resize
#define fori(i, a, b) for (int i = (a); i <= (b); i++)
#define ford(i, a, b) for (int i = (a); i >= (b); i--)
#define endl '\n'
#define setprec(x) cout << fixed << setprecision(x);
 
using namespace std;
using namespace __gnu_pbds; 
 
typedef tree<long long,null_type,less<long long>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef vector<pair <int, int>> vpi;
typedef vector < vector <int> > vvi;
 
const int INF = 4e18;
const int mod = 1e9+7; 

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


    //start from here

    read(a) char c; cin >> c; read(b)

    if(c == '+') print(a+b) else print(a-b)

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long int
#define pb push_back
#define ss second
#define ff first
#define INF 30000000000001
#define ll_max 9000000000000000001
#define mod 1000000007
#define PI 3.14159265358979323846L
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
using namespace std;
typedef vector<pair<ll,ll> > vll;
typedef vector<pair<int,int> > vii ;
typedef pair<ll,ll> pll;

int main()
{
    fast;
    int _ = 1;
    //cin >> _;
    while(_--)
    {
        string s, r;
      	cin >> s >> r;
      	int ans = 0;
      	for(int i = 0; i < 3; i++) if(s[i] == r[i]) ans++;
        cout << ans << "\n";
    }
    return 0;
}


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

#define int long long

#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,a,b) for(int i=(a);i<(b);i++)
#define pb push_back
#define eb emplace_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second

using vint=vector<int>;
using pint=pair<int,int>;
using vpint=vector<pint>;

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

template<class A,class B>
ostream& operator<<(ostream& ost,const pair<A,B>&p){
	ost<<"{"<<p.first<<","<<p.second<<"}";
	return ost;
}

template<class T>
ostream& operator<<(ostream& ost,const vector<T>&v){
	ost<<"{";
	for(int i=0;i<v.size();i++){
		if(i)ost<<",";
		ost<<v[i];
	}
	ost<<"}";
	return ost;
}

signed main(){
	vint a(3);rep(i,3)cin>>a[i];
	if(accumulate(all(a),0ll)>=22)cout<<"bust"<<endl;
	else cout<<"win"<<endl;
	return 0;
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-
def main():
    S  = input()
    O_flag = 0
    E_flag = 0
    for i in range(0, len(S),2):
        if S[i]!="R" and S[i]!="U" and S[i]!="D":
            O_flag = 1
            break
    for i in range(1, len(S),2):
        if S[i]!="L" and S[i]!="U" and  S[i]!="D":
            E_flag = 1
            break
    if O_flag ==1 or E_flag ==1:
        print("No")
    else:
        print("Yes")

if __name__ == '__main__':
    main()

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

public class Main {

    public static void main(String[] args) throws IOException {
        Scanner sc = new Scanner(System.in);
        PrintWriter out = new PrintWriter(System.out);
        int n = sc.nextInt();
        int[] a = new int[n + 1];
        for (int i = 1; i <= n; i++)
            a[i] = sc.nextInt();
        int[] b = new int[n + 1];
        int m = 0;
        for (int i = n; i > 0; i--) {
            int need = a[i];
            int sum = 0;
            for (int j = i + i; j <= n; j+=i)
                sum += b[j];
            sum %= 2;
            if (need != sum) {
                b[i]++;
                m++;
            }
        }
        out.println(m);
        for (int i=1 ; i<=n ; i++)
            if (b[i]!=0) out.print(i+ " ");
        out.flush();
        out.close();
    }

    static class Scanner {

        StringTokenizer st;
        BufferedReader br;

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


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

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

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

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

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

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

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


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

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


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

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

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

    }
}

Measured memory_bytes: 43556
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define pb push_back
#define mp make_pair
#define ios ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
const int mod=1000000007;
int main()
{
	string a,b;
	int i;
	cin>>a>>b;
	for(i=0;i<a.length();i++)
	{
		if(a[i]!=b[i]) {
		cout<<"No"; break;}
	}
	if(i==a.length()) cout<<"Yes";
	return 0;
}

Measured memory_bytes: 3620
from math import gcd
# def gcd(a, b):
#     if a%b==0: return b
#     return gcd(b, a%b)
K=int(input())
sum=0
for a in range(1,K+1):
    for b in range(1,K+1):
        for c in range(1,K+1):
            sum+=gcd(gcd(a,b),c)
print(sum)

Measured memory_bytes: 9076
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int N = scanner.nextInt();
        int W = scanner.nextInt();
        int[] w = new int[N];
        int[] v = new int[N];
        for (int i = 0; i < N; i++) {
            w[i] = scanner.nextInt();
            v[i] = scanner.nextInt();
        }
        long res = knapsack(N, W, w, v);
        System.out.println(res);
    }

    private static long knapsack(int N, int W, int[] w, int[] v) {
        // f(i, j): max value of first i items with at most j weight
        // f(N, W)

        // f(i, j) = max:
        //         f(i-1, j)
        //         f(i-1, j-w) + v, if j-w >= 0
        // f(0, *) = 0
        // f(*, 0) = 0
        long[] dp = new long[W+1];
        for (int i = 1; i <= N; i++) {
            for (int j = W; j >= w[i-1]; j--) {
                dp[j] = Math.max(dp[j], dp[j-w[i-1]] + v[i-1]);
            }
        }
        return dp[W];
    }
}


Measured memory_bytes: 21972
#include<cmath>
#include<cstdio>
#include<cassert>
#include<cstring>
#include<algorithm>
#define MN 51
#define Cx 0.03
#define Cy 0.03
#define eps 1e-7
using namespace std;

int read_p,read_ca;
inline int read(){
    read_p=0;read_ca=getchar();
    while(read_ca<'0'||read_ca>'9') read_ca=getchar();
    while(read_ca>='0'&&read_ca<='9') read_p=read_p*10+read_ca-48,read_ca=getchar();
    return read_p;
}
int n,ma,mb,mmh[1000][1000],a,b,c,MMH;
int main(){
	register int i,j,k;
	memset(mmh,63,sizeof(mmh));
	n=read();ma=read();mb=read();mmh[0][0]=0;
	for (i=1;i<=n;i++){
		a=read();b=read();c=read();
		for (j=400;j>=0;j--)
		for (k=400;k>=0;k--)
		if (mmh[j+a][k+b]>mmh[j][k]+c) mmh[j+a][k+b]=mmh[j][k]+c;
	}
	MMH=1e7;
	for (j=1;ma*j<=400&&mb*j<=400;j++)
	if (MMH>mmh[ma*j][mb*j]) MMH=mmh[ma*j][mb*j];
	printf("%d\n",MMH==1e7?-1:MMH);
}

Measured memory_bytes: 4224
#include<iostream>
#include<vector>
using namespace std;
using ll = long long;

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

    vector<string> results(numTestCases);
    for (int i=0; i<numTestCases; ++i) {
        cin >> results[i];
    }

    int ac{0}, wa{0}, tle{0}, re{0};

    for (int i=0; i<numTestCases; ++i) {
        string currentResult = results[i];
        if (currentResult == "AC") ++ac;
        else if (currentResult == "WA") ++wa;
        else if (currentResult == "TLE") ++tle;
        else ++re;
    }

    cout << "AC x " << ac << endl;
    cout << "WA x " << wa << endl;
    cout << "TLE x " << tle << endl;
    cout << "RE x " << re << endl;
    return 0;
}

Measured memory_bytes: 6360
//  Twitter@KonoLv1 2020年春からエンジニア見習いデビュー！

//  標準入出力を扱うヘッダーファイルの読み込み
#include <stdio.h>
//  "atoi" "atof"などのキャスト、"rand" 疑似乱数を発生させるヘッダーファイルの読み込み
#include <stdlib.h>
//  "strcpy" "strcat"などの文字列操作や"strlen"文字列長さ取得などを行うヘッダーファイルの読み込み
#include <string.h>
//  "sqrtl" "fmax"などの数値操作を行うヘッダーファイルの読み込み
#include <math.h>


int main(void){

    unsigned long int a;
    unsigned long int b;
    unsigned long int n;
    unsigned long int ans1 = 0;
    unsigned long int ans2 = 0;
    unsigned long int ans3 = 0;

    scanf("%lu %lu %lu",&n,&a,&b);
    
    if ((b - a) % 2 == 0){
        printf("%lu",((b - a) / 2));
    }else{
        if (b - 1 <= n - a){
            ans1 = b - 1;

            ans2 = (((b - a) / 2) + 1) +  (a - 1);

                  //   printf("%lu  ",ans2);
        }else{
            ans1 = n - a;

            ans2 = (((b - a) / 2) + 1) + (n - b);
                  //   printf("%lu  ",ans2);
        }
            
       if (ans1 > ans2){
           printf("%lu",ans2);
       }else{
           printf("%lu",ans1);
       }
    }

  

}





Measured memory_bytes: 128
//#include <bits/stdc++.h>
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstdlib>
#include <string>
#include <vector>
#include <map>
#include <queue>

using namespace std;

typedef long long ll;
typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<n;++i)
#define mod (ll)(1e9+7)
#define FIX(a) ((a)%mod+mod)%mod
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define fi first
#define se second
#define pb push_back
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n,a,b;
    cin >> n >> a >> b;
    cout << min(b,n*a) << endl;

    return 0;
}

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

using namespace std;

#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define PI 3.141592653589793238
#define INF 1050000000

using vi = vector<int>;


int main() {

	int N;

	cin >> N;

	string S;

	cin >> S;

	long long int ans = 0;
	long long int r=0, g=0, b=0;

	for (int i = 0; i < N; i++)
	{
		if (S[i] == 'R') {
			r++;
		}
		else if (S[i] == 'G') {
			g++;
		}
		else {
			b++;
		}
	}

	long long int ex=0;

	for (int i = 0; i < N-2; i++)
	{
		for (int j = i+1; j < N-1; j++)
		{	
			
			int k = j + (j - i);
			if (k > N - 1) {
				continue;
			}
			
			if (S[i] != S[j] && S[j] != S[k] && S[i] != S[k]) {
				ex++;
			}
		}
	}


	ans = r * g * b - ex;

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
string change_max(string x){
  sort(x.begin(), x.end(), greater<char>());
  return x;
}
string change_min(string x){
  sort(x.begin(), x.end());
  return x;
}
int main() {
  string s, t;
  cin >> s >> t;
  string min_s=change_min(s);
  string max_t=change_max(t);
  if(min_s<max_t){
    cout << "Yes" << endl;
    return 0;
  }
  cout << "No" << endl;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;
#define N 105
int num1[N], num2[N];
int main()
{
	int n, m, x, y;
	while(~scanf("%d%d%d%d", &n, &m, &x, &y))
	{
		memset(num1, 0, sizeof(num1));
		memset(num2, 0, sizeof(num2));
		for(int i = 0; i < n; i++) scanf("%d", &num1[i]);
		for(int i = 0; i < m; i++) scanf("%d", &num2[i]);
		sort(num1, num1+n);
		sort(num2, num2+m);
		if(num1[n-1] < num2[0])
		{
			if(x <= num1[n-1] && y >= num2[0])
			    printf("No War\n");
			else
			    printf("War\n");
		}
		else printf("War\n");
	}
	return 0;
}

Measured memory_bytes: 128
import sys
sys.setrecursionlimit(10**9)

n,q=map(int,input().split())
G=[[] for _ in range(n+1)]
for _ in range(n-1):
  a,b=map(int,input().split())
  G[a].append(b)
  G[b].append(a)

S=[0]*(n+1)
for _ in range(q):
  p,x=map(int,input().split())
  S[p]+=x

def dfs(now,prev=-1):
  for next in G[now]:
    if next==prev:
      continue
    S[next]+=S[now]
    dfs(next,now)

dfs(1)
print(*S[1:])

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

const int INF = 1e9;

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

  int sorted[n];
  for(int i=0;i<n;i++)sorted[i]=x[i];
  sort(sorted,sorted+n);
  for(int i=0;i<n;i++){
    auto it=lower_bound(sorted,sorted+n,x[i]);
    if(it-sorted<n/2){
      cout<<sorted[n/2]<<endl;
    }else{
      cout<<sorted[n/2-1]<<endl;
    }
  }
}

Measured memory_bytes: 3712
n, k = map(int, input().split())
A = [[] for _ in range(k)]

for i in range(k):
	d = int(input())
	A[i] = list(map(int, input().split()))

target = list(range(1, n + 1))

lst = []
for v in A:
	for j in range(len(v)):
		lst.append(v[j])

lst = set(lst)

print(n - len(lst))

Measured memory_bytes: 67608
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int, int> P;
typedef pair<int, P> P1;

#define fr first
#define sc second
#define mp make_pair
#define pb push_back
#define rep(i, x) for (int i = 0; i < x; i++)
#define rep1(i, x) for (int i = 1; i <= x; i++)
#define rrep(i, x) for (int i = x - 1; i >= 0; i--)
#define rrep1(i, x) for (int i = x; i > 0; i--)
#define sor(v) sort(v.begin(), v.end())
#define rev(s) reverse(s.begin(), s.end())
#define lb(vec, a) lower_bound(vec.begin(), vec.end(), a)
#define ub(vec, a) upper_bound(vec.begin(), vec.end(), a)
#define uniq(vec) vec.erase(unique(vec.begin(), vec.end()), vec.end())
#define mp1(a, b, c) P1(a, P(b, c))

const int INF = 1000000000;
const ll M = 1000000000;
const int dir_4[4][2] = {{1, 0}, {0, 1}, {-1, 0}, {0, -1}};
const int dir_8[8][2] = {{1, 0},  {1, 1},   {0, 1},  {-1, 1},
                         {-1, 0}, {-1, -1}, {0, -1}, {1, -1}};

/*----------------------------------------------/
/- char         : %c  | char *       : %s  | short        : %hd
/- int          : %d  | long         : %ld | long long    : %lld
/- unsigned short:%hu | unsigned int : %u  | unsigned long: %lu
/- u_long long  : %llu| (octal)      : %o  | (hexadecimal): %x
/- float        : %f  | double       : %lf |
/----------------------------------------------*/

/*----------------------------------------------/
/- INT_MAX, LONG_MAX   : 1<<15 = 2.1*pow(10, 9)       (= 2147483647)
/- UINT_MAX, ULONG_MAX : 1<<16 = 4.2*pow(10, 9)       (= 4294967295)
/- LLONG_MAX           : 1<<63 = 9.2*pow(10, 18)      (= 9223372036854775807)
/- ULLONG_MAX          : 1<<64 = 1.8*pow(10, 19)      (= 18446744073709551615)
/----------------------------------------------*/

int main() {
    int n, h[105];
    scanf("%d", &n);
    rep1(i, n) scanf("%d", &h[i]);
    /* ====================================== */
    bool loop = true;
    int count = 0;
    h[n + 1] = 0;
    while (loop) {
        int ph = 0;
        int keep = 0;
        rep1(i, n + 1) {
            if (i == n + 1 && h[i - 1] == 0) {
                loop = false;
                break;
            }
            if (h[i] > ph) {
                keep = 0;
            } else if (h[i] == ph) {
                keep++;
            } else {
                for (int j = i - keep; j <= i; j++) {
                    h[j - 1]--;
                }
                break;
            }
            ph = h[i];
            continue;
        }
        count++;
    }

    cout << count - 1;
    /* ====================================== */
    cout << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <array>
#include <algorithm>
#include <cstring>

int main(int argc, char *argv[])
{
    int n;
    int a[20];

    std::cin >> n;

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

    int ans = 0;
    for (int i = 1; i < n - 1; i++) {
        if (((a[i - 1] < a[i]) && (a[i] < a[i + 1])) ||
            ((a[i - 1] > a[i]) && (a[i] > a[i + 1])))
        {
            ans++;
        }
    }

    std::cout << ans << std::endl;

    return 0;
}

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

using namespace std;

vector<int> lft[100005];
vector<int> rgt[100005];
int a[100005];
signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    
    int n;
    cin>>n;
    for (int i = 1; i <=n ; ++i) {
        cin>>a[i];
    }

    set<int>s;
    vector<int>temp;
    for (int i = 1; i <=n ; ++i) {
        auto z=s.lower_bound(a[i]);
         while (!s.empty())
         {
             if(z!=s.begin())
             {
                 z--;
                 rgt[*z].push_back(i);
                 if(rgt[*z].size()==2)
                 {
                     temp.push_back(*z);
                 }
             }
             else
                 break;
         }
         for(auto j:temp)
             s.erase(j);
         temp.clear();
         s.insert(a[i]);
    }

    for(auto i:s)
    {
        while (rgt[i].size()<2)
            rgt[i].push_back(n+1);
    }

    temp.clear();
    s.clear();
    for (int i = n; i >=1 ; --i) {
        auto z=s.lower_bound(a[i]);
        while (!s.empty())
        {
            if(z!=s.begin())
            {
                z--;
                lft[*z].push_back(i);
                if(lft[*z].size()==2)
                {
                    temp.push_back(*z);
                }
            }
            else
                break;
        }
        for(auto j:temp)
            s.erase(j);
        temp.clear();
        s.insert(a[i]);
    }

    for(auto i:s)
    {
        while (lft[i].size()<2)
            lft[i].push_back(0);
    }

    int ans=0;
    for (int i = 1; i <=n ; ++i) {
        int zz=rgt[a[i]][1]-rgt[a[i]][0];
        zz*=(i-lft[a[i]][0]);
        ans+=zz*a[i];

        zz=lft[a[i]][0]-lft[a[i]][1];
        zz*=(rgt[a[i]][0]-i);
        ans+=zz*a[i];
    }

    cout<<ans;
}

Measured memory_bytes: 16256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;


namespace _20180502_pra
{
    class Program
    {
        static void Main(string[] args)
        {

           var S = Console.ReadLine().ToArray();
            Array.Sort(S);
            char[] charS = S.ToArray();

            for (int i = 'a'; i <= 'z'; i++)
            {
                var contains = S.Contains((char)i);
                if (!contains)
                {
                    Console.WriteLine((char)i);
                    return;
                }
               
            }
            Console.WriteLine("None");

        }
    }
}

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

// 基本テンプレート
#pragma region MACRO
#define P(x) cout << (x) << endl
#define p(x) cout << (x)
#define PED cout << "\n"
#define rep(i,n) for(int i=0; i<(int)n; ++i)
#define REP(i,x,n) for(int i=x; i<(int)n; ++i)
#define repi(i,n) for(int i=0; i<=(int)n; ++i)
#define REPI(i,x,n) for(int i=x; i<=(int)n; ++i)
#define ILP while(true)
#define FOR(i,c) for(__typeof((c).begin())!=(c).begin(); i!=(c).end(); ++i)
#define ALL(c) (c).begin(), (c).end()
#define mp make_pair
#pragma endregion

// 型
#pragma region TYPE_DEF
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<string, string> pss;
typedef pair<string, int> psi;
typedef pair<int, string> pis;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<long double> vld;
typedef vector<long> vl;
typedef vector<long long> vll;
typedef vector<string> vs;
#pragma endregion

// Effective std
#pragma region ESTD
template<typename C, typename T> int count(C& c, T t) { return count(ALL(c), t); }
template<typename C, typename F> int count_if(C& c, F f) { return count_if(ALL(c), f); }
template<typename C, typename T> void erase(C& c, T t) { remove(ALL(c), t), c.end(); }
template<typename C> void remove(vector<C>& c, unsigned int index) { c.erase(c.begin()+index); }
template<typename C, typename T, typename U> void replace(C& c, T t, U u) { replace(ALL(c), t, u); }
template<typename C, typename F, typename U> void replace_if(C& c, F f, U u) { (ALL(c), f, u); }
template<typename C> void reverse(C& c) { reverse(ALL(c)); }
template<typename C> void sort(C& c) { sort(ALL(c)); }
template<typename C, typename Pred> void sort(C& c, Pred p) { sort(ALL(c), p); }
#pragma endregion

// 定数
#pragma region CONST_VAL
constexpr int PI = (2*acos(0.0));
constexpr int EPS = (1e-9);
constexpr int MOD = (int)(1e9+7);
constexpr int INF = 100000000;
#pragma endregion


int main()
{
    int n, m;
    cin >> n >> m;
    vector<pair<int, int> > v(n);
    rep(i, n) {
        int a, b;
        cin >> a >> b;
        v[i] = make_pair(a, b);
    }
    vector<pair<int, int> > u(m);
    rep(i, m) {
        int c, d;
        cin >> c >> d;
        u[i] = make_pair(c, d);
    }

    rep(i, n) {
        int a = v[i].first;
        int b = v[i].second;

        int res = 0;
        int mind = MOD;
        rep(j, m) {
            if(mind>abs(a-u[j].first)+abs(b-u[j].second)) {
                mind = abs(a-u[j].first) + abs(b-u[j].second);
                res = j;
            }
        }
        cout << res+1 << endl;
    }
    return 0;
}



Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		
		
		int a = scan.nextInt();
		int lst[] = new int[a];
		
		for(int i = 0; i < a; i++) {
			lst[i] = scan.nextInt();
		}
		
		int minimum = lst[0];
		int maximum = lst[1]-lst[0];
		
		for(int i = 1; i < a; i++) {
			maximum = Math.max(maximum, lst[i] - minimum);
			minimum = Math.min(minimum, lst[i]);

		}
		System.out.println(maximum);
		
	}

}



Measured memory_bytes: 100960
#include<math.h>
#include <bits/stdc++.h>
#include <algorithm>
#define rep(i, n) for (int i = 0; i < (int)n; i++)
#define ll long long int
#define ull unsigned long long
#define py printf("Yes\n")
#define pn printf("No\n")
#define in cin>>
using namespace std;
int INF = 1001001001;
const int MOD=1e9+7;

int main()
{
    int n;
    in n;
    vector<int>l(n);
    vector<int>r(n);
    int ans=0;
    rep(i,n)
    {
        in l[i];
        in r[i];
        ans+=r[i]-l[i]+1;
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 256
#!/usr/bin/perl
#abc087_d.pl
#Sun Jan 28 20:20:32 2018
#

use warnings;
use strict;

my $temp = <STDIN>;
chomp $temp;
my @temps = split(" ",$temp);

my $n = $temps[0];
my $m = $temps[1];


my $loopnum = $m;

my @l;
my @r;
my @d;

while ($loopnum > 0){
	my $stdin = <STDIN>;
	chomp $stdin;
	my @temps = split(" ",$stdin);
	push (@l, $temps[0]);
	push (@r, $temps[1]);
	push (@d, $temps[2]);
	$loopnum--;
}

my %dist;
my @position;
my $num = 0;
my %mem;

while ($num <= $#l){
	my $start = $l[$num];
	my $end = $r[$num];
	my $distance = $d[$num];
	$dist{$start}{$end} = $distance;
	$dist{$end}{$start} = $distance * (-1);
	$num++;
}

$num = 1;

my $flag = 0;

while ($num <= $n){
	if (!exists $dist{$num}){
		$num++;
		next;
	}
#	print "dist",$num,"\n";
	$flag = &distsearch($num);
	if ($flag == 1){
		last;
	}
	$num++;
}

if ($flag == 0){
	print "Yes\n";
}else{
	print "No\n";
}

sub distsearch{
	my $p = $_[0];
	if (exists $mem{$p}){
		return 0;
	}
	if (!exists $position[$p]){
		$position[$p] = 0;
	}

	$mem{$p} = 1;

	foreach(keys %{$dist{$p}}){
#		if (exists $mem{$_}){
#			next;
#		}
#		print $p,"\t",$_,"\t",$dist{$p}{$_},"\n";
		if (exists $position[$_]){
			if ($position[$_] != $position[$p] + $dist{$p}{$_}){
				return 1;
			}
		}else{
			$position[$_] = $position[$p] + $dist{$p}{$_};
		}

		if (!exists $mem{$_}){
			if (&distsearch($_)){
				$mem{$_} = 1;
				return 1;
			}
		}

	}
	return 0;
}

Measured memory_bytes: 201344
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>
#include<limits.h>

int max(int a, int b){
  return a >= b ? a : b;
}
int min(int a, int b){
  return b >= a ? a : b;
}
int sei(int a){
  return a>0 ? a : 0;
}
int factorial(int n) {
    if (n > 0) return n*factorial(n - 1);
		else return 1;
}
int compare_up_int(const void *a, const void *b){
   return *(int*)a - *(int*)b;
}
int compare_down_int(const void *a, const void *b){
   return *(int*)b - *(int*)a;
}
int euclid(int a, int b){
  if(a < b){int tmp = a;a = b;b = tmp;}
  int r = a % b;
  if(r < 0) r += b;
  while(r != 0){
    a = b;b = r;r = a % b;
    if(r < 0) r += b;
  }
  return b;
}

int main(){
  int N,Y;
  scanf("%d %d",&N,&Y);
  for(int i=0;i<=N;i++){
    for(int j=0;j<=N-i;j++){
      if(10000*i + 5000*j + 1000*(N-i-j) == Y){
        printf("%d %d %d",i,j,N-i-j);return 0;
      }
    }
  }
  printf("-1 -1 -1");
  return 0;
}


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

using namespace std;

int main()
{
	char flag = 1;
	string S;
	cin >> S;
	for (int count = 0; count < S.length(); count++)
	{
		if (count % 2 == 0)
		{
			if (S.at(count) == 'L')
			{
				flag = 0;
			}
		}
		else
		{
			if (S.at(count) == 'R')
			{
				flag = 0;
			}
		}
	}
	if (flag)
	{
		cout << "Yes" << endl;
	}
	else
	{
		cout << "No" << endl;
	}
}

Measured memory_bytes: 256
import java.util.*;
import java.io.*;
import java.nio.charset.StandardCharsets;

public class Main {
	long N;
	long result = 0;

	public static void main(String[] args) throws IOException {
		InputStreamReader reader = new InputStreamReader(System.in, StandardCharsets.UTF_8);
		BufferedReader in = new BufferedReader(reader);
		Main ins = new Main(in);
		ins.calc();
		ins.showResult();
	}

	Main(BufferedReader in) throws IOException {
		N = Long.parseLong(in.readLine());
	}

	void calc() {
		if (N % 2 == 1) {
			// 0のまま
			return;
		}
		for(long div = 10; div <= N; div = div*5) {
			result += N/div;
		}
	}


	void showResult() {
		System.out.println(result);
	}
}


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

int main() {
    ll k;
    cin>>k;
    ll rem;
    rem=7%k;
    rep(i,k){
        if(rem==0){
            cout<<i+1<<endl;
            return 0;
        }
        rem=(rem*10+7)%k;
    }
    cout<<-1<<endl;
    return 0;
}



Measured memory_bytes: 3596
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    int N;
    int a;
    cin >> N;
    a =  N%10;
    if(a==3){
        cout<<"bon"<<endl;
    }
    else if(a==0||a==1||a==6||a==8){
        cout<<"pon"<<endl;
    }
    else{
        cout<<"hon"<<endl;
    }
}

Measured memory_bytes: 3632
fn main() {
    let (n,m) = {
        let s = rv::<usize>();
        (s[0],s[1])
    };
    let mut g=vec![vec![];n];
    for i in 0..m {
        let s = rv::<usize>();
        let (a,b,c) = (s[0]-1,s[1]-1,s[2]as i32);
        g[a].push((b,c,i));
        g[b].push((a,c,i));
    }
    let mut e=vec![1;m+1];
    let mut q=std::collections::BinaryHeap::new();
    let mut d=vec![INF;n];
    for i in 0..n {
        for v in d.iter_mut() {*v=INF}
        q.push((INF-0, i, m));
        while let Some((s,v,i))=q.pop() {
            let s=-s;
            if d[v]>=s {
                e[i]=0;
            }
            if d[v]<=s {
                continue;
            }
            d[v]=s;
            for &(u,c,i) in &g[v] {
                let s=s+c;
                if d[u]>=s {
                    q.push((-s,u,i));
                }
            }
        }
    }
    println!("{}",e.into_iter().sum::<i32>());
}
const INF: i32=std::i32::MAX;
fn rl() -> String {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s
}
fn rv<T>() -> Vec<T>
  where T: std::str::FromStr, T::Err: std::fmt::Debug, {
    rl().split_whitespace().map(|x|x.parse::<T>().unwrap()).collect()
}

Measured memory_bytes: 4352
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0,i##_len=(n);i<i##_len;++i)
#define rep(i,a,b) for(int i=int(a);i<int(b);++i)
#define All(x) (x).begin(),(x).end()
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
int main(){
    int N,M;cin>>N>>M;
    vector<int> A(N);
    vector<P> v(M);
    REP(i, N){
        cin >> A[i];
        v.push_back(P(A[i],1));
    }
    REP(i,M){
        cin>>v[i].second>>v[i].first;
    }
    sort(rbegin(v),rend(v));
    ll ans=0;
    int now=0,pos=0;
    REP(i,N){
        ans+=v[now].first;
        pos++;
        if(pos==v[now].second){
            now++;
            pos=0;
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 8068
#include<bits/stdc++.h>
using namespace std;
int main(){
  int count=0;
  string S;
  cin >> S;
  int c = S.length();
  for(int i=0; i<c;i++){
    if(S[i] != S[c-1-i]){
      S[c-1-i] = S[i];
      count ++;
    }
  }
  cout << count << endl;
}


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


vector<ll> a(0);
vector<ll> b(0);
vector<pair<ll,ll>> res(0);
bool cmp(ll p1, ll p2) {return p2<p1;}
bool ok(ll m, ull k, ll n){
    ull summ=0;
    for(int i=0;i<n;i++){
        if(res[i].first>m){
            summ+=(res[i].first-m+res[i].second-1)/res[i].second;
        }
    }
    return summ<=k;
}
int main() {
    int n;
    ull k;
    cin>>n>>k;
    for(int i=0;i<n;i++) {
        ll c;
        cin>>c;
        a.push_back(c);
    }
    for(int i=0;i<n;i++) {
        ll c;
        cin>>c;
        b.push_back(c);
    }
    sort(a.begin(), a.end());
    sort(b.begin(), b.end(), cmp);
    for(int i=0;i<n;i++) res.push_back({b[i]*a[i], b[i]});
    sort(res.begin(), res.end());
    ll r=1e12+1;
    ll l=-1;
    while(r-l>1){
        ll m=(r+l)/2;
        if(ok(m,k,n)){
            r=m;
        }
        else l=m;
    }
    cout<<r;
    return 0;
}

Measured memory_bytes: 9328
#include <bits/stdc++.h>
#define INF INT_MAX
#define ll  long long
#define ull unsigned long long
#define rep(i,n) for(int i=0; i<n; ++i)
#define FOR(i, s, e) for(ll i=s; i<e; ++i)
#define MOD 1000000007
using namespace std;
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;}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int N; cin >> N;
  string S; cin >> S;
  int ans = 0;
  rep(i,10) {
    rep(j,10) {
      rep(k,10) {
        char a[] = {'0'+i, '0'+j, '0'+k};
        int l=0;
        for(auto c:S) {
          if(c == a[l]) ++l;
          if(l==3) {
            ++ans;
            break;
          }
        }
      }
    }
  }
  cout << ans << endl;
}

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

int main() {
	int a, b, c, d;

	cin >> a >> b >> c >> d;

	if (abs(a - c) <= d)
		cout << "Yes";
	else if (abs(a - b) <= d && abs(b - c) <= d)
		cout << "Yes";
	else
		cout << "No";

	return 0;

}

Measured memory_bytes: 256
#include <string>
#include <vector>
#include <map>
#include <set>
#include <deque>
#include <iostream>
#include <functional>
#include <algorithm>
#include <sstream>
#include <iterator>
#include <cmath>
#include <limits>
#include <tuple>
#include <queue>
#include <stack>

using namespace std;
typedef long long ll;

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define all(c) c.begin(),c.end()

/*
opt    = {} # opt[t] は t円の最適な払い方。これから求めるよ！
opt[0] = [] # 0円 はコイン0枚で最適に(?)払えます
1.upto(T) do |t|
  opt[t] =                       # t円の最適な払い方は
	 C.select{|c| opt[t-c]}.
		  map{|c| opt[t-c]+[c]}. #   t-c円の最適な払い方 + c円玉
	   min_by{|p| p.size}        #   … のうち一番枚数少ないヤツ
end
p opt[T]
*/

bool comp(const vector<int>& lhs, const vector<int>& rhs)
{
	if (lhs.size() < rhs.size())
		return true;
	else if (lhs.size() == rhs.size()) {
		for (int i = 0; i < (int)lhs.size(); i++)
			if (lhs[i] < rhs[i])
				return true;
	}
	return false;
}

int main()
{
	const int cost[] = { 0,2,5,5,4,5,6,3,7,6 };
	int N, M;
	cin >> N >> M;
	set<int> A;
	rep(i, M) {
		int a;
		cin >> a;
		A.insert(a);
	}
	vector<vector<int>> dp(N+1);	//dp[i]: i本マッチで作れる最大の数
	dp[0] = {};
	rep1(i, N) {
		for (auto rit = A.rbegin(); rit != A.rend(); ++rit) {
			const auto& a = *rit;
			int j = i - cost[a];
			if (j == 0 && dp[j].size() == 0 || j > 0 && dp[j].size() != 0) {
				auto x = dp[j];
				x.push_back(a);
				if (comp(dp[i], x)) {
					dp[i] = x;
				}
			}
		}
	}
	for (auto i : dp[N])
		cout << i;
	cout << endl;
	return 0;
}


Measured memory_bytes: 115200
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(ll i = 0; i < (ll)(n); i++)
#define repi(i,a,b) for(ll i = (ll)(a); i < (ll)(b); i++)
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const ll INF = 1LL << 60;
int main(){
    int n;
    string s;
    cin >> n >> s;
    int ans = 0;
    rep(i,n-2){
        if (s[i]=='A' && s[i+1]=='B' && s[i+2]=='C') ans++;
    }
    cout << ans <<endl;
    return 0;
}

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

using namespace std;

int main(void) {
	int num, k, i = 0, ans;
	cin >> num >> k;
	vector<int> d(num);
	for (; i < num; i++)
		scanf("%d", &d[i]);
	ans = (d[num - 1] - d[0]) * 2;
	for (i = 0; i <= num - k; i++)
		ans = min(ans, abs(d[i]) + d[i + k - 1] - d[i]);
	for (i = num - 1; i >= k - 1; i--)
		ans = min(ans, abs(d[i]) + d[i] - d[i - k + 1]);
	printf("%d\n", ans);
	return 0;
}

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

int main(){
    long long a,b,c;
    cin >> a >> b >> c;
    long long ans;
    if(a%2==0||b%2==0||c%2==0) ans=0;
    else ans=min(a*b,min(b*c,c*a));
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define F first
#define S second
using namespace std;
using ll = long long;
typedef pair<int, int> P;
ll Mod = 1000000007;
int main() {
  string s;
  cin >> s;
  int cnt = 0;
  for (int i = 0; i < 3; i++) {
    if (s[i] == '1') {
      cnt++;
    }
  }
  cout << cnt << endl;
  return 0;
}

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

int main() {
  int N;
  cin >> N;
  if(N%10==3){
  cout << "bon" << endl;
  }else if((N%10==0)||(N%10==1)||(N%10==6)||(N%10==8)){
    cout << "pon" <<endl;
  }else{
    cout << "hon" <<endl;
  }
}


Measured memory_bytes: 3636
#define _USE_MATH_DEFINES
#include "bits/stdc++.h"
using namespace std;
#define FOR(i,j,k) for(int (i)=(j);(i)<(int)(k);++(i))
#define rep(i,j) FOR(i,0,j)
#define each(x,y) for(auto &(x):(y))
#define mp make_pair
#define MT make_tuple
#define all(x) (x).begin(),(x).end()
#define debug(x) cout<<#x<<": "<<(x)<<endl
#define smax(x,y) (x)=max((x),(y))
#define smin(x,y) (x)=min((x),(y))
#define MEM(x,y) memset((x),(y),sizeof (x))
#define sz(x) (int)(x).size()
#define RT return
using ll = long long;
using pii = pair<int, int>;
using vi = vector<int>;
using vll = vector<ll>;

/*
セグメント木

int _query(int a, int b, int k, int l, int r)
[a,b)
l,rは今見ている範囲
内部で呼ぶだけ
コンストラクタ
要素数、初期値, 隣接要素を引数とする関数
query(int a, int b)
クエリ[a,b), 0Origin
int cal(int a, int b)
*/
template<class Value>
class SegmentTree {
    int n;
    Value e;
    vector<Value> dat;
    function<Value(Value, Value)> f;

    inline Value query(int a, int b, int k, int l, int r) {
        if (r <= a || b <= l) return e;
        if (a <= l && r <= b) return dat[k];
        else {
            Value vl, vr;
            vl = query(a, b, k << 1, l, (l + r) >> 1);
            vr = query(a, b, (k << 1) | 1, (l + r) >> 1, r);
            return f(vl, vr);
        }
    }

public:
    SegmentTree() {}

    SegmentTree(int n_, Value init_, function<Value(Value, Value)> f_)
        :n(1), e(init_), f(f_) {
        for (; n<n_; n <<= 1);
        dat = vector<Value>(n << 1, e);
    }

    void update(int k, Value a) {
        k += n;
        dat[k] = a;
        while (k>1) {
            k >>= 1;
            dat[k] = f(dat[k << 1], dat[(k << 1) | 1]);
        }
    }

    Value query(int a, int b) {
        return query(a, b, 1, 0, n);
    }
};

using P = array<ll, 2>;
P f(P p, P q) {
    P r;
    r[0] = max(p[0] + q[0], p[1] + q[1]);
    r[1] = max(p[0] + q[1], p[1] + q[0]);
    return r;
}
const ll MI = LLONG_MIN / 3;
using ST = SegmentTree<P>;

void solve() {
    int N, Q;
    cin >> N >> Q;

    vi A(2*N), B(2*N);
    rep(i, 2 * N) cin >> A[i];
    rep(i, 2 * N) cin >> B[i];

    P e{ 0, MI};
    ST st(2 * N, e, f);

    rep(i, 2 * N) {
        st.update(i, P{ A[i], B[i] });
    }
    rep(i, Q) {
        int p, x, y;
        cin >> p >> x >> y;
        p--;
        A[p] = x;
        B[p] = y;
        st.update(p, P{ x, y });
        ll ans = A[0] + A[2 * N - 1] + st.query(1, 2 * N - 1)[0];
        cout<<ans<<endl;
    }
}

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

Measured memory_bytes: 11520
import java.util.*;

public class Main {
	public static void main(String[] args) {
		
		Scanner sc = new Scanner(System.in);
		int[] A;
		int n,time;
		int i;
		
		while(true) {
			n = sc.nextInt();
			A = new int[n];
			for (i=0 ; i<n ; i++) {
				A[i] = n-i;
			}
			time = sc.nextInt();
			
			if (n==0 && time==0) {
				break;
			}
			
			for (i=0 ; i<time ; i++) {
				int a = sc.nextInt();
				int b = sc.nextInt();
				int[] A2;
				int j;
				A2 = new int[n];
				for (j =0 ; j<b ; j++) {
					A2[j] = A[a+j-1];
				}
				for (j=b ; j<a+b-1 ; j++) {
					A2[j] = A[j-b];
				}
				for (j = a+b-1 ; j<n ; j++) {
					A2[j] = A[j];
				}
				
				for (j=0 ; j<n ; j++) {
					A[j] = A2[j];
				}
			}
			
			
			System.out.println(""+A[0]);
			
		}
	}
}


Measured memory_bytes: 38544
#include <iostream>
int main()
{
  int n;
  std::cin >> n;
  for (int i = 1;i <= n; i++) {
    if (i % 3 == 0) {
      std::cout << " " << i;
    }
    else {
      int x = i;
      do {
        if (x % 10 == 3) {
          std::cout << " " << i;
          break;
        }
      } while (x /= 10);
    }
  }
  std::cout << std::endl;
  return 0;
}

Measured memory_bytes: 1160
#include <iostream>
#include <sstream>
#include <math.h>

using namespace std;

int isPrime(int n);

int main()
{
	string str;
	getline(cin, str);
	int num;
	stringstream num_ss(str);
	num_ss >> num;

	int counter = 0;

	for (int i = 0; i < num; i++) {
		getline(cin, str);
		stringstream tmp_ss(str);
		int n;
		tmp_ss >> n;
		n = isPrime(n);
		if (n != -1) {
			counter++;
		}
	}
	cout << counter << endl;
	return 0;
}

// if the param is a prime number, then return param. Else return -1.
int isPrime(int n) {
	int rtn = n;
	int end_num = (int) sqrt(n) + 1;

	if (n % 2 == 0) {
		if (n == 2) {
			return n;
		} else {
			return -1;
		}
	}

	for (int i = 3; i < end_num; i+=2) {
		if (n % i == 0) {
			rtn = -1;
			break;
		}
	}
	return rtn;
}

Measured memory_bytes: 3152
#include<stdio.h>
#include<string.h>
#include<stdlib.h>

struct Node {
	int a;
	Node *prev, *next;
};

Node* NIL;

void insert(int key)
{
	Node* x;
	x = (Node*)malloc(sizeof(Node));
	x->a = key;
	NIL->next->prev = x;
	x->next = NIL->next;
	NIL->next = x;
	x->prev = NIL;
}
Node* lineSearch(int key)
{
	Node *p;
	p = NIL->next;
	while (p != NIL&& p->a != key)
	{
		p = p->next;
	}
	return p;
}
void deleteNode(Node *p)
{
	if (p == NIL)
	    return;
	p->next->prev = p->prev;
	p->prev->next = p->next;
	free(p);
}
void deleteFirst()
{
	deleteNode(NIL->next);
}
void deleteLast()
{
	deleteNode(NIL->prev);
}
void delete1(int key)
{
	deleteNode(lineSearch(key));
}
void init()
{
	NIL = (Node*)malloc(sizeof(Node));
	NIL->next = NIL;
	NIL->prev = NIL;
}
void print()
{
	Node*p;
	p = NIL->next;
        if(p!=NIL)
          printf("%d",p->a);

        p = p->next;
	while (p != NIL)
	{       
		printf(" %d",p->a);
		p = p->next;
	}
	printf("\n");
}
int main()
{
	char cmd[15];
	int n,a;

	init();
	scanf("%d", &n);
	for (int i = 0; i < n; i++)
	{
		scanf("%s", cmd, 15);
		if (cmd[0] == 'i')
		{
			scanf("%d", &a);
			insert(a);
		}
		else if (strlen(cmd) > 6)
		{
			if (cmd[6] == 'F')
				deleteFirst();
			else
				deleteLast();
		}
		else
		{
			scanf("%d", &a);
			delete1(a);
		}
	}
	print();
	return 0;
}


Measured memory_bytes: 33928
#include<stdio.h>
int main()
{
    int n, i, j, minj, temp, count=0;
    int a[100];

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

    for(i=0;i<n-1;i++)
    {
        minj=i;
        for(j=i;j<n;j++)
            if(a[j]<a[minj]) minj=j;
        if(minj!=i)
        {
            temp=a[i];
            a[i]=a[minj];
            a[minj]=temp;
            count++;
        }
    }

    for(i=0;i<n-1;i++)
        printf("%d ", a[i]);
    printf("%d\n", a[i]);
    printf("%d\n", count);

    return 0;
}

Measured memory_bytes: 600
n = int(input())

s = list(map(str, input()))
count = 0
smax = 0

for i in range(len(s)):
    if s[i] == "I":
        count += 1
        if count > 0 and count > smax:
            smax += 1
    else:
        count -= 1
print(smax)


Measured memory_bytes: 2940
#include "bits/stdc++.h"
using namespace std;
#define OUT(x)                cout << #x << " = " << x << endl; 
#define rep(i, n)             for (int (i) = 0; (i) < (int)(n); (i)++)
#define rer(i, l, r)          for (int (i) = (int)(l); (i) <= (int)(r); (i)++)
#define reu(i, l, r)          for (int (i) = (int)(l); (i) < (int)(r); (i)++)
#define each(i, v)            for (auto i : v)
#define all(x)                (x).begin(), (x).end()
#define rall(x)               (x).rbegin(), (x).rend()
#define pb(x)                 push_back(x)
#define bp(x)                 __builtin_popcount(x)
#define mp(x, y)              make_pair((x), (y))
#define fi                    first
#define se                    second
#define setp(x)               setprecision(x)
#define mset(m, v)            memset(m, v, sizeof(m))
#define sz(x)                 (int)(x.size())
static const int INF        = 0x3f3f3f3f;
static const long long INFL = 0x3f3f3f3f3f3f3f3fLL;
static const int MOD        = 1000000007;
static const double PI      = 3.14159265358979;

#define int                   long long

typedef vector<double>        vd;
typedef vector<string>        vs;
typedef vector<bool>          vb;
typedef vector<int>           vi;
typedef pair<int, int>        pii;
typedef vector<pii>           vpii;

template<typename T> void pv(T a, T b) { for (T i = a; i != b; i ++) cout << *i << " "; cout << endl; }
template<typename T, typename U> inline void amin(T &x, U y) { if (y < x) x = y; }
template<typename T, typename U> inline void amax(T &x, U y) { if (x < y) x = y; }
int in() { int _x; scanf("%d", &_x); return _x; }
long long lin() {long long _x; scanf("%lld", &_x); return _x; };

int aa[101010];

signed main() { 
        int n;
        cin >> n;
        rep(i, n) {
                int a;
                cin >> a;
                aa[a] ++;
                if (aa[a] > 2) aa[a] -= 2;
        }
        int cnt1 = 0, cnt2 = 0;
        rep(i, 101010) {
                if (aa[i] == 1) cnt1 ++;
                else if (aa[i] == 2) cnt2 ++;
        }
        if (cnt2 % 2 == 1) cnt2 --;
        cout << cnt1 + cnt2 << endl;
        return 0;
}               



Measured memory_bytes: 1024
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws IOException {
		Scanner sc = new Scanner(System.in);
		//BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		
		boolean S = false;
		boolean W = false;
		boolean N = false;
		boolean E = false;
		String str = sc.next();
		for(char c : str.toCharArray()){
			if(c == 'S') S = true;
			else if(c == 'W') W = true;
			else if(c == 'N') N = true;
			else if(c == 'E') E = true;
		}
		
		if((S && !N) || (!S && N) || (E && !W) || (!E && W)) System.out.println("No");
		else System.out.println("Yes");
	}
}

Measured memory_bytes: 9940
#include<stdio.h>
#define N 2000001

int *A,*B;

void CountingSort(int);


main(){
  int i,k;
  scanf("%d",&k);
  A = malloc(sizeof(int)*k+1);
  B = malloc(sizeof(int)*k+1);

  for(i=0; k>i; i++){
    scanf("%d",&A[i]);
  }

  CountingSort(k);
 for(i=1; i<=k; i++){printf("%d",B[i]);
    if(i<k)printf(" ");
  }
printf("\n");
 return 0;
}

void CountingSort(int k){

  int i, C[N];

  for(i=0; i<k; i++){
    C[i] = 0;
  }

  for(i=0; i<k; i++){
    C[A[i]]++;

  }


  for(i=0; i<N; i++){

    C[i] = C[i]+C[i-1];

    if(C[i] == k) break;
  }

  for(i=k-1; i>=0; i--){

    B[C[A[i]]] = A[i];
C[A[i]]--;
}
}

Measured memory_bytes: 24044
#include <iostream>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <vector>
#include <iomanip>
typedef long long ll;
const ll MOD = (ll)1e9 + 7LL;
using namespace std;

ll T[100002], A[100002];

int main () {
	ll N;
	cin >> N;
	for(int i = 1; i <= N; i++)
	{
		cin >> T[i];
	}
	for(int i = 1; i <= N; i++)
	{
		cin >> A[i];
	}
	ll ans = 1;
	for(int i = 1; i <= N; i++)
	{
		bool upd_T = (T[i-1] != T[i]);
		bool upd_A = (A[i+1] != A[i]);
		if(upd_A && upd_T) {
			if(A[i] != T[i]) {
				cout << 0 << endl;
				return 0;
			}
		}
		if(upd_A && !upd_T) {
			if(A[i] > T[i]) {
				cout << 0 << endl;
				return 0;
			}
		}
		if(!upd_A && upd_T) {
			if(A[i] < T[i]) {
				cout << 0 << endl;
				return 0;
			}
		}
		if(!upd_A && !upd_T) {
			ans *= min(A[i], T[i]);
			ans %= MOD;
		}
	}
	cout << ans << endl;
}


Measured memory_bytes: 1792
# -*- coding: utf-8 -*-
n = int(input())
a = [int(input()) for _ in range(n)]
a_unique = list(sorted(set(a), reverse=True))
max_value = a_unique[0]
max_value_count = a.count(max_value)

if max_value_count == 1:
    for i in range(n):
        if a[i] == max_value:
            print(a_unique[1])
        else:
            print(max_value)
else:
    for i in range(n):
        print(max_value)


Measured memory_bytes: 17188