akhauriyash/Code-Regression huggingface dataset:
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Scanner;

public class Main {
	public static int max;
	public static int[] a;
	public static int result;
	public static boolean end;
	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int min = Integer.MAX_VALUE;
		int pmin = Integer.MAX_VALUE;
		a = new int[n];
		max = 0;
		for (int i = 0; i < n; i++) {
			a[i] = sc.nextInt();
			if (a[i] > max) {
				max = a[i];
			}
			if (a[i] < min) {
				min = a[i];
			} else if (pmin > a[i]) {
				pmin = a[i];
			}
		}
		if (pmin >= (int)10E11) {
			pmin = min;
		}
		result = 1;
		end = false;
		calc(0, 0, pmin);
		System.out.println(result);
	}
	
	public static int calc(int i, int count, int num) {
		if (num < 1) {
			end = true;
			return count;
		} else {
			if (end) {
				return count;
			} else if (i >= a.length && count <= 1) {
				if (result < num) {
					result = num;
				}
				end = true;
				return calc(0, 0, --num);
			} else {
				if (a[i] % num != 0 && ++count >= 2) {
					return calc(0, 0, --num);
				} else {
					return calc(++i, count, num);
				}
			}
		}
	}
}

Measured memory_bytes: 70356
def main():
    N, L = (int(i) for i in input().split())
    s = sum(L + i for i in range(N))
    ans = 10**9
    for i in range(N):
        eat = L + i
        if abs(eat) < abs(ans):
            ans = eat
    print(s - ans)


if __name__ == '__main__':
    main()


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

int main()
{
    int n, m;
    long long int k;
    cin >> n >> m >> k;
    vector<int> A(n+1);
    vector<int> B(m+1);
    vector<long long int> a(n+1);
    vector<long long int> b(m+1);
    for(int i=1; i<=n; i++) cin >> A[i];
    for(int j=1; j<=m; j++) cin >> B[j];
    a[0] = b[0] = 0;
    for(int i=1; i<=n; i++) a[i] = a[i-1] + A[i];
    for(int j=1; j<=m; j++) b[j] = b[j-1] + B[j];
    

    int best_j = m;
    int ans = 0;
    for(int i=0; i<=n; i++){
        if(a[i] > k) break;
        for(int j=best_j; j>=0; j--){
            if(b[j] <= k - a[i]){ 
                best_j = j; 
                ans = max(ans, i+j);
                break;
                }
        }
    }

    cout << ans << endl;

    return 0;
}

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

#define repd(i,a,b) for (int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repd(i,0,n)
#define mp(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<pii, int> ppi;

#define INF 1000000000

bool sorter(const ppi p1, const ppi p2){
  return p1.second<p2.second;
}

int main(){
  while(true){
    ppi bar[1000]; //<<p,q>,h>
    int n,m,a;
    cin>>n>>m>>a;
    if(n==0&&m==0&&a==0) break;

    rep(i,m){
      int h,p,q;
      scanf("%d %d %d", &h,&p,&q);
      bar[i] = mp(mp(p,q),h);
    }

    sort(bar,bar+m,sorter);

    int res[100];
    rep(i,n) res[i]=i+1;

    rep(i,m){
      swap(res[bar[i].first.first-1], 
	   res[bar[i].first.second-1]);
    }

    cout << res[a-1] << endl;

  }
}

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

#define mp make_pair
#define pb push_back

#define int int64_t
#define ld long double

const int MOD = 1e9+7;
const int N = 2e5+5;

vector<int> adj[N];
vector<int> vis(N);
vector<int> vert(N);

int k;
int ans;
void dfs(int x, int p) {
    if(vis[x]|| p==k+1) {
        if(p==k+1) {
            ans = x;
            return;
        }
        k-=(vis[x]-1);
        k%=(p-vis[x]);
        ans=vert[vis[x]+k];
        return;
    }
    vis[x]=p;
    vert[p]=x;
    p++;
    for(int i: adj[x])
        dfs(i, p);
}

int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    int n;
    cin>>n>>k;   

    int u;
    for(int i=1;i<=n;i++) {
        cin>>u;
        adj[i].pb(u);
    }

    dfs(1, 1);

    cout<<ans;

    return 0;
}

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

int main() {
  int N, M, X;
  cin >> N >> M >> X;
  int cnt_l = 0, cnt_h; 
  for (int i = 0; i < M; ++i) {
    int ai;
    cin >> ai;
    if (X < ai) {
      ++cnt_h;
    } else {
      ++cnt_l;
    }
  }
  cout << min(cnt_h, cnt_l) << endl;
}


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

int main() {
	std::string s;
	std::cin >> s;

	int flip = 0;
	for (int i = 1; i < s.size(); ++i)
		if (s[i] != s[i - 1])
			++flip;

	std::cout << flip << std::endl;
}

Measured memory_bytes: 512
import java.util.Scanner;
public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int kei = 100000;
		for(int i=1; i<=n; i++){
			kei *= 1.05;
			if(kei%1000 > 0){
				kei = ((kei - kei%1000)+ 1000);
			}
		}
		System.out.println(kei);
	}
}

Measured memory_bytes: 26096
#include<iostream>
#include<algorithm>
#include<cmath>
#include<vector>
#include<string>
#include<queue>
#include<set>
#include<map>
using namespace std;
typedef long long int ll;
typedef vector<pair<ll,ll> > Q;
typedef pair<int,int> P;
#define rep(i,j,n) for(int i=(int)(j);i<(int)(n);i++)
const ll inf=1e9+7;
ll gcd(ll a, ll b) { return (b ? gcd(b, a % b) : a); }
ll lcm(ll a, ll b) { return a / (gcd(a, b)) * b; }

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

  ll tmp=sqrt(n);
  for(int i=tmp;i>=1;i--){
    if(n%i==0){
      tmp=i;
      cout<<n/i+i-2<<endl;
      break;
    }
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define mod 1000000007
#define pb push_back
#define ll long long
#define mp make_pair
using namespace std;
int main(){
	ll n;
	cin>>n;
	vector<long double> a;
	for(int i=0;i<n;i++){
		ll x;
		cin>>x;
		a.pb(x*1.0);
	}
	ll negm = 0, posm = 0, negi = -1, posi = -1;
	for(int i=0;i<n;i++){
		if( a[i] < 0){
			if(abs(a[i])>negm){
				negm=abs(a[i]);
				negi = i;
			}
		}
		if( a[i] > 0){
			if(abs(a[i])>posm){
				posm=abs(a[i]);
				posi = i;
			}
		}
	}
	if(posm == 0 && negm == 0){
		cout<<0<<endl;
		return 0;
	}
	else if(posm >= negm){
		cout<<2*n-1<<endl;
		for(int i=0;i<n;i++){
			cout<<posi+1<<" "<<i+1<<endl;
		}
		for(int i=0;i<n-1;i++){
			cout<<i+1<<" "<<i+2<<endl;
		}
	}
	else{
		cout<<2*n-1<<endl;
		for(int i=0;i<n;i++){
			cout<<negi+1<<" "<<i+1<<endl;
		}
		for(int i=n;i>=2;i--){
			cout<<i<<" "<<i-1<<endl;
		}
	}
	return 0;
}

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

int main() {
	int a, b, c, d;
	int ab, ac, bc;
	std::cin >> a;
	std::cin >> b;
	std::cin >> c;
	std::cin >> d;

	ab = abs(b - a);
	ac = abs(c - a);
	bc = abs(c - b);

	if (ac <= d) {
		std::cout << "Yes";
		return 0;
	}
	else if ((ab <= d)&(bc <=d)) {
		std::cout << "Yes";
		return 0;
	}
	else {
		std::cout << "No";
		return 0;
	}


	return 0;
}

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

int main (){
  int sum = 0;
  int N, M;
  cin >> N >> M;
  
  vector<int> vec(N);
  for( int i= 0; i < N ;i++){
    cin >> vec.at(i);
  }
  //cout << sum << N << M ;
  vector<bool> evaluation(N,true);
  for(int i = 0;  i < M; i++){
    int A, B;
    cin >> A >> B;
    int ha, hb;
    ha = vec.at(A-1);
    hb = vec.at(B-1);
    
    if(ha < hb){
      evaluation.at(A-1) = false;
    }
    
    else if(ha > hb){
      evaluation.at(B-1) = false;
    }
    else {
      evaluation.at(A-1) = false;
      evaluation.at(B-1) = false;
    }
    
  }
  
  for( int i = 0; i < N;i++){
    if(evaluation.at(i))
      sum++;
  }
  
  cout << sum << endl;
  
  
}

Measured memory_bytes: 3784
#include<iostream>
#include<algorithm>
#include<cmath>
#include<map>
#include<queue>
#include<string>
#include<set>
#include<utility>
#include<vector>

using namespace std;
typedef long long ll;
#define rep(i, n) for(int i=0; i<n; i++)
#define per(i, n) for(int i=n-1; i>=0; i--)
#define reps(i, n) for(int i=1; i<n; i++)
#define pers(i, n)  for(int i=n-1; i>=1; i--)

const int INF = 1001001001;

void solve(){
  int n, x, y;  cin >> n >> x >> y;
  x--;  y--;
  vector<vector<int>> vec(n, vector<int>(n, 0));
  vector<int> ans(n, 0);
  for(int i=0; i<n; i++){
    bool isForked = i==x;
    for(int j=i+1; j<n; j++){
      vec[i][j]=vec[i][j-1]+1;
      if(j==x)  isForked=true;
      if(isForked && j==y)  vec[i][j]=vec[i][x]+1;
    }
    if(i>x){
      vec[i][y] = min(vec[i][y], i-x+1);
    }
    for(int j=y-1; j>max(i, x); j--){
      vec[i][j] = min(vec[i][j], vec[i][j+1]+1);
    }
    for(int j=y+1; j<n; j++){
      vec[i][j] = min(vec[i][j], vec[i][j-1]+1);
    }

    for(int j=i+1; j<n; j++){
      ans[vec[i][j]]++;
    }
  }

  reps(i, n){
    cout << ans[i] << endl;
  }
}

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


Measured memory_bytes: 16000
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define all(a)  (a).begin(),(a).end()
#define pb emplace_back
#define INF (1e9+1)
//#define INF (1LL<<59)

int main(){
    int n;
    while(cin>>n&&n){
        vector<string> vs(n);
        rep(i,n)cin>>vs[i];
        
        rep(i,n){
            int count;
            int pos = i;

            count = 0;
            while(count<5 && pos<n) count+=vs[pos++].size();
            if(count!=5)continue;

            count = 0;
            while(count<7 && pos<n) count+=vs[pos++].size();
            if(count!=7)continue;

            count = 0;
            while(count<5 && pos<n) count+=vs[pos++].size();
            if(count!=5)continue;

            count = 0;
            while(count<7 && pos<n) count+=vs[pos++].size();
            if(count!=7)continue;

            count = 0;
            while(count<7 && pos<n) count+=vs[pos++].size();
            if(count!=7)continue;

            cout<<i+1<<endl;
            break;
        }
    }
}

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


/// File input & output /////
#define fRead(x)        freopen("x.txt","r",stdin)
#define fWrite(x)       freopen ("x.txt","w",stdout)

#define mt              make_tuple
#define ld              long double
#define ll              long long
#define ull             unsigned long long
#define ff              first
#define ss              second
#define pb              push_back
#define INF             2e16
#define PI              acos(-1.0)
#define mp              make_pair
#define pii             pair<int,int>
#define pll             pair<LL,LL>


#define min3(a,b,c)     min(a,min(b,c))
#define max3(a,b,c)     max(a,max(b,c))
#define min4(a,b,c,d)   min(a,min(b,min(c,d)))
#define max4(a,b,c,d)   max(a,max(b,max(c,d)))
#define SQR(a)          ((a)*(a))
#define FOR(i,a,b)      for(int i=a;i<=b;i++)
#define ROF(i,a,b)      for(int i=a;i>=b;i--)
#define REP(i,b)        for(int i=0;i<b;i++)
#define MEM(a,x)        memset(a,x,sizeof(a))
#define ABS(x)          ((x)<0?-(x):(x))

#define SORT(v)         sort(v.begin(),v.end())
#define REV(v)          reverse(v.begin(),v.end())


#define FASTIO        ios_base::sync_with_stdio(0);cin.tie(nullptr);




///..................Sort by second element in a pair in decending order............. ///
bool SortbySecDesc(const pair<long long,long long > &a, const pair<long long,long long > &b)
{
    return a.second>b.second;
}

///.........................first element of pair in descending order..........................//////
bool sortinrev(const pair<int,int> &a,
               const pair<int,int> &b)
{
       return (a.first > b.first);
}



///.............................................................TEMPLATE................................................./////

int main()
{
    FASTIO;
    ll s , w;

    cin >> s >> w;

    if(w>=s)
    {
        cout << "unsafe" << endl;
    }
    else
    {
        cout << "safe" << endl;
    }





    return 0;
}



Measured memory_bytes: 3652
#include <iostream>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <iomanip> // cout<<setprecision(n)
#include <functional> // std::function<void(long long)>
using namespace std;
#define All(v) (v).begin(),(v).end()
const long long mod = 1000000007;
const long long inf = mod*mod;
const long long MAXS = 114514;
const double EPS=1e-10;
const double INF=1e+10;
const double PI=acos(-1.0);
string s,x;
long long n;
long long res=0;
void dfs(string x, long long i){
    if(i==n){
        //構文解析
        x += '+';//最後の処理が面倒なので＋を加えておく
        int l = x.size();
        long long a = 0;
        for(int k=0;k<l;k++){
            //+がきたらそれまでたまっていたのを答えに加える
            if(x[k]=='+'){
                res+=a;
                a=0;
            }
            //＋以外は末尾に加えていく
            else a=a*10+(x[k]-'0');
        }
        return;
    }
    dfs(x+'+'+s[i],i+1);//+をつかう
    dfs(x+s[i],i+1);//＋をつかわない
}

signed main() {
    cin>>s;
    n=s.size();
    string x = {s[0]};
    dfs(x,1);
    cout<<res<<endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define M 1000000007
#define INF ((1LL<<62LL) - 1)

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

    int n,k,c; cin >> n >> k >> c;
    string s; cin >> s;

    vector<int> ans;

    int l[k+1],r[k+1];

    int cur = 1;
    int i = 0;
    while(i<n){
        if(cur>k) break;
        if(s[i] == 'x'){
            i++;
            continue;
        }
        l[cur] = i;
        i += (c+1);
        cur++;
    }

    cur = k;
    int j = n-1;
    while(j>=0){
        if(cur == 0) break;
        if(s[j] == 'x'){
            j--;
            continue;
        }
        r[cur] = j;
        j -= (c+1);
        cur--;
    }

    for(int i=1;i<=k;i++){
        if(l[i] == r[i]){
            cout << l[i]+1 << "\n";
        }
    }



}


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

using namespace std;

int main(int argc, char *argv[]) {
	int N;
	cin >> N;

	string answer;
	if (N >= 1000) {
		answer = "ABD";
	} else {
		answer = "ABC";
	}

	cout << answer << endl;
	return 0;
}


Measured memory_bytes: 256
from operator import mul
from functools import reduce

def cmb(n,r):
    r = min(n-r,r)
    if r == 0: return 1
    over = reduce(mul, range(n, n - r, -1))
    under = reduce(mul, range(1,r + 1))
    return over // under


n,p=map(int,input().split())
a=list(map(int,input().split()))
guu=0
ki=0
for i in range(n):
  if a[i]%2==0:
    guu+=1
  else:
    ki+=1
ans=0
if p==0:
  i=0
  while i<=ki:
    ans+=cmb(ki,i)
    i+=2
  print((2**guu)*ans)
  
else:
  i=1
  while i<=ki:
    ans+=cmb(ki,i)
    i+=2
  print((2**guu)*ans)

Measured memory_bytes: 3572
#include <algorithm>  
#include <iostream>  
#include <sstream>  
#include <string>  
#include <cstring>
#include <vector>  
#include <queue>  
#include <set>  
#include <map>  
#include <cstdio>  
#include <cstdlib>  
#include <cctype>  
#include <cmath>  
#include <list>  
#include <cassert>
#include <ctime>
#include <climits>
using namespace std;  

#define PB push_back  
#define MP make_pair  
#define SZ(v) ((int)(v).size())  
#define FOR(i,a,b) for(int i=(a);i<(b);++i)  
#define REP(i,n) FOR(i,0,n)  
#define FORE(i,a,b) for(int i=(a);i<=(b);++i)  
#define REPE(i,n) FORE(i,0,n)  
#define FORSZ(i,a,v) FOR(i,a,SZ(v))  
#define REPSZ(i,v) REP(i,SZ(v))  
typedef long long ll;
typedef unsigned long long ull;
ll gcd(ll a,ll b) { return b==0?a:gcd(b,a%b); }

const int MAXN=200000;

int n;
int a[MAXN],b[MAXN];

void run() {
	scanf("%d",&n); REP(i,n) scanf("%d%d",&a[i],&b[i]);

	ll sum=0; REP(i,n) sum+=a[i];
	ll mn=LLONG_MAX; REP(i,n) if(b[i]<a[i]) mn=min(mn,(ll)b[i]);
	if(mn==LLONG_MAX) { printf("0\n"); return; }
	printf("%lld\n",sum-mn);
}

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


Measured memory_bytes: 384
import math
import collections
import bisect
from collections import deque
from copy import copy, deepcopy


def main():
    A, B, C = map(int, input().split())
    K = int(input())
    ans = 0
    tmp1 = math.ceil(math.log2((A + 0.1) / B))
    if tmp1 > 0:
        B = B * (2**tmp1)
        ans += tmp1
    tmp2 = math.ceil(math.log2((B + 0.1) / C))
    if tmp2 > 0:
        ans += tmp2
    #print(tmp1, tmp2)
    if ans <= K:
        print("Yes")
    else:
        print("No")


if __name__ == '__main__':
    main()


Measured memory_bytes: 9736
import math

a,b,h,m=map(int,input().split())
deg1=h*30+m*0.5
x1,y1=0,0
if deg1<=90:
  x1=a*math.sin(2*math.pi*(deg1/360))
  y1=a*math.cos(2*math.pi*(deg1/360))
elif deg1<=180:
  x1=a*math.sin(2*math.pi*((180-deg1)/360))
  y1=-a*math.cos(2*math.pi*((180-deg1)/360))
elif deg1<=270:
  x1=-a*math.sin(2*math.pi*((deg1-180)/360))
  y1=-a*math.cos(2*math.pi*((deg1-180)/360))
elif deg1<=360:
  x1=-a*math.sin(2*math.pi*((360-deg1)/360))
  y1=a*math.cos(2*math.pi*((360-deg1)/360))
deg2=m*6
x2,y2=0,0
if deg2<=90:
  x2=b*math.sin(2*math.pi*(deg2/360))
  y2=b*math.cos(2*math.pi*(deg2/360))
elif deg2<=180:
  x2=b*math.sin(2*math.pi*((180-deg2)/360))
  y2=-b*math.cos(2*math.pi*((180-deg2)/360))
elif deg2<=270:
  x2=-b*math.sin(2*math.pi*((deg2-180)/360))
  y2=-b*math.cos(2*math.pi*((deg2-180)/360))
elif deg2<=360:
  x2=-b*math.sin(2*math.pi*((360-deg2)/360))
  y2=b*math.cos(2*math.pi*((360-deg2)/360))
ans=math.sqrt((x1-x2)**2+(y1-y2)**2)
print(ans)

Measured memory_bytes: 9596
#include <iostream>

using namespace std;

int main()
{

      
float age,the_cost,b;
cin>>age;

cin>>b;
the_cost=b;
if(age>=13){
    cout<<the_cost<<endl;}
else if(age>=6){
    cout<<the_cost*0.5<<endl;}
else{cout<<"0"<<endl;}
    return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		String s = sc.next();
		for(int i=0;i<s.length();i+=2){
			System.out.print(s.charAt(i));
		}
		System.out.println();
		
	}

}


Measured memory_bytes: 31336
#include<bits/stdc++.h>
 
using namespace std;
#define ff first
#define ss second
#define pii pair<int, int>
#define pll pair<long long , long long>
#define pb push_back
#define ll long long
#define ld long double
#define precision(x,d) cout<<fixed<<setprecision(d)<<x
#define fill(a,b) memset((a),(b),sizeof((a)))
#define FAST ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);srand(time(NULL));
ll power(ll x,ll y,ll m){ll r=1;for(;y;y>>=1){if(y&1)r=r*x%m;x=x*x%m;}return r;}
const ll mod = 1e9 + 7;
const ld pi = 3.14159265358979;
 
int run_test(){
      ll n, k;
      cin >> n >> k;
      ll ans = 0;
      for(ll i=k; i<=n; i++){
            ans += (-1 * ((i * (i - 1))/2) + (n*(n + 1))/2 - ((n-i)*(n-i+1))/2) % mod;
            ans += 1;
      }
      ans += 1;
      cout << ans % mod;
      return 0;
}
 
int main(){
    FAST;
    ll t;
    t = 1;
 
    while(t--){
        run_test();
    }
}

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

int main() {
  int h, w;
  cin >> h >> w;
  
  for (int i=0;i<w+2;i++) { cout << "#"; }
  cout << endl;
  
  for (int i=0;i<h;i++) {
    string s;
    cin >> s;
    cout << "#" << s << "#" << endl;
  }
  
  for (int i=0;i<w+2;i++) { cout << "#"; }
  cout << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define repone(i,n) for(int i=1;i<(int)(n);++i)
#define repo(i,o,n) for(int i=o;i<(int)(n);++i)
#define Rep(j,n) for(int j=0;j<(int)(n);++j)
#define Repo(j,o,n) for(int j=o;j<(int)(n);++j)
#define Repone(j,n) for(int j=1;j<(int)(n);++j)
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define int long long
#define pb(a) push_back(a)
#define eraser(v,i) (v).erase(v.begin()+(i))
#define pbpair(a,b) push_back(make_pair(a,b))
#define Little 1
const long long INF = 1LL<<60;
#define pairint pair<int,int>
signed main(){
  int x=0,y=0,z=0,w=0,n=0,m=0,o=0;
std::cin >> x>>y;
std::vector<int> v(x);
std::vector<int> vv(x,0);
rep(i,x)std::cin >> v[i];
rep(i,y){
  std::cin >> z>>w;
  if(v[z-1]>v[w-1])vv[w-1]++;
  else if(v[z-1]==v[w-1]){
    vv[z-1]++;
    vv[w-1]++;
  }else vv[z-1]++;
}
rep(i,x){
  if(vv[i]==0)n++;
}
std::cout << n << '\n';
}


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


int main() {
  int n, x, y;
  cin >> n >> x >> y;
  if(x>y) swap(x,y);
  vector<int> ans(n);
  for(int i=1; i<n; i++) {
    for(int j=i+1; j<=n; j++) {
      int dis = min(j-i,abs(j-y)+abs(i-x)+1);
      ans[dis-1]++;
    }
  }
  rep(i,n-1) cout << ans[i] << endl;
  return 0;
}

Measured memory_bytes: 3608
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int Nsc = sc.nextInt();
		int anscnt = 0;
		for(int j = 1; j <= Nsc; j++) {
		int N = j;

		int cnt = 0;
		for(int i = 1; i <= N; i++) {
			if(N % i == 0) {
				cnt ++;
			}
		}
		//int ans = 0;
		if(N % 2 ==1) {
		if(cnt == 8) {
			//ans = 1;
			anscnt ++;
			//System.out.println(j+":"+ans);
		}
		}
		}
		System.out.println(anscnt);
		sc.close();

	}

}


Measured memory_bytes: 21712
#include <iostream>
#include <cmath>
#include <vector>
#include <string>
#include <algorithm>

using namespace std;

#define INF 1e9
#define ll long long
#define vi vector<int>
#define vll vector<long long>
#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)

string S;

void solve(){
    int N = S.size();
    cout << S[0] << N-2 << S[N-1] << endl;
}

int main(){
    cin >> S;

    solve();
}


Measured memory_bytes: 256
#include"bits/stdc++.h"
//#include<bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(int i=a;i<b;i++)
#define print(x) cout<<x<<endl;
typedef long long ll;

int main() {
	int n, m, t[102], p[102], x[102];
	int sum = 0;
	cin >> n;
	rep(i, 0, n)cin >> t[i];
	cin >> m;
	rep(i, 0, m) { cin >> p[i] >> x[i]; p[i]--; }

	rep(j, 0, m) {
		sum = 0;
		rep(i, 0, n) {
			if (i == p[j]) { sum += x[j]; }
			else { sum += t[i]; }
		}
		print(sum);
	}
	return 0;
}

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

using namespace std;

int main(){
int a,b,d,r;
double f;
cin >> a >> b;
d = a/b;
r = a%b;
f = (double)(a)/b;
//cout << d << " " << r << " " << f << endl;
printf("%d %d %.8lf\n",d,r,f);
return 0;
}

Measured memory_bytes: 3220
#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() {
  int k;
  string s;
  cin >> k >> s;
  if(s.length() <= k) {
    cout << s << endl;
    return 0;
  }
  cout << s.substr(0, k) << "..." << endl;
  return 0; 
}

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

int main(){
  int n, q, query, t, x;
  cin >> n >> q;
  vector<stack<int>> S(n);
  for(int i = 0; i < q; i++){
    cin >> query;
    if(query == 0){
      cin >> t >> x;
      S[t].push(x);
    }else if(query == 1){
      cin >> t;
      if(!S[t].empty()){
        cout << S[t].top() << endl;
      }
    }else{
      cin >> t;
      if(!S[t].empty()){
        S[t].pop();
      }
    }
  }
  return 0;
}


Measured memory_bytes: 4324
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<stack>
#include<string>
#include<map>
#include<set>
#include<tuple>
#include<cmath>
#include<iomanip>


#define MOD 1000000007
#define INF 1001001001
#define MIN -1001001001
#define rep(i,k,N) for(int i=k;i<N;i++)
#define MP make_pair
#define MT make_tuple //tie,make_tuple は別物
#define PB push_back
#define PF push_front
#define all(x) (x).begin(),(x).end()


using namespace std;
typedef long long ll;
typedef vector<ll> v;
typedef vector<vector<ll>> vv;

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

int main(){
    ll N;
    cin>>N;
    v A(N);
    vector<pair<ll,ll>> A2(N);
    rep(i,0,N){
        cin>>A[i];
        A2[i] = MP(A[i],i);
    }
    vv dp(N+1,v(N+1));
    ll ans = 0;
    sort(all(A2), greater<pair<ll,ll>>());

    rep(l,0,N)rep(r,0,N){
        if(l+r == N){
            ans = max(ans,dp[l][r]);
            continue;
        }
        ll activeness = A2[l+r].first, ind = A2[l+r].second;
        dp[l+1][r] = max(dp[l+1][r],dp[l][r] + activeness*abs(ind-l));
        dp[l][r+1] = max(dp[l][r+1],dp[l][r] + activeness*abs((N-1-r)-ind));
    }
    
    cout<<ans;
    return 0;
}

Measured memory_bytes: 34588
#include <bits/stdc++.h>
#include <algorithm>
using namespace std;
struct Fast { Fast() { cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20);} } fast;
 
 
int main() {
    long long n, max1 = 0, max2 = 0, ans = 0;
    cin >> n;
//    vector<long> as(n);
  //  for (int i = 0; i < n; i++){
    //    cin >> as[i];
   // }
   cout << n * n * n << endl;
}

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

using namespace std;

typedef long long ll;

int main(){
	int n;
	cin >> n;
	int a[n+2];
	a[0] = 0;
	a[n+1] = 0;
	ll sum = 0;
	for(int i = 1; i <= n+1; i++){
		if(i != n+1)cin >> a[i];
	   	sum += abs(a[i]-a[i-1]);
	}
	for(int i = 1; i <= n; i++){
		cout << sum - abs(a[i]-a[i-1]) - abs(a[i+1]-a[i]) + abs(a[i+1]-a[i-1]) << endl;
	}
    return 0;
}

Measured memory_bytes: 1664
using System;
using System.Collections.Generic;
using System.Collections;
using System.Collections.Specialized;
using System.Linq;
using System.Text;
using System.IO;
using System.Reflection;
using static System.Math;
using System.Numerics;
static class Program{
	const int mod=(int)1e9+7;
	static void Main(){
		Sc sc=new Sc();
		var s=sc.Sa;
		Console.WriteLine("{0}",s[1]+s[0]);
	}
}

public class Sc{
	public int I{get{return int.Parse(Console.ReadLine());}}
	public long L{get{return long.Parse(Console.ReadLine());}}
	public double D{get{return double.Parse(Console.ReadLine());}}
	public string S{get{return Console.ReadLine();}}
	public int[] Ia{get{return Array.ConvertAll(Console.ReadLine().Split(),int.Parse);}}
	public long[] La{get{return Array.ConvertAll(Console.ReadLine().Split(),long.Parse);}}
	public double[] Da{get{return Array.ConvertAll(Console.ReadLine().Split(),double.Parse);}}
	public string[] Sa{get{return Console.ReadLine().Split();}}
	public object[] Oa{get{return Console.ReadLine().Split();}}
	public int[] Ia2{get{return Array.ConvertAll(("0 "+Console.ReadLine()+" 0").Split(),int.Parse);}}
	public int[] Ia3(int a){return Array.ConvertAll((a.ToString()+" "+Console.ReadLine()).Split(),int.Parse);}
	public int[] Ia3(bool a,int b,bool c,int d){return Array.ConvertAll(((a?b.ToString()+" ":"")+Console.ReadLine()+(c?" "+d.ToString():"")).Split(),int.Parse);}
	public long[] La2{get{return Array.ConvertAll(("0 "+Console.ReadLine()+" 0").Split(),long.Parse);}}
	public long[] La3(int a){return Array.ConvertAll((a.ToString()+" "+Console.ReadLine()).Split(),long.Parse);}
	public long[] La3(bool a,int b,bool c,int d){return Array.ConvertAll(((a?b.ToString()+" ":"")+Console.ReadLine()+(c?" "+d.ToString():"")).Split(),long.Parse);}
	public T[] Arr<T>(int n,Func<T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f();}return a;}
	public T[] Arr<T>(int n,Func<int,T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f(i);}return a;}
	public T[] Arr<T>(int n,Func<string[],T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f(Console.ReadLine().Split());}return a;}
	public T[] Arr<T>(int n,Func<int,string[],T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f(i,Console.ReadLine().Split());}return a;}
}

Measured memory_bytes: 13140
import sys
import math as mt
input=sys.stdin.buffer.readline  
t=1
#t=int(input())
for _ in range(t):
    n=int(input())
    #a,b,c=map(int,input().split())
    #l=list(map(int,input().split()))
    print(n+n**2+n**3)

Measured memory_bytes: 61716
#include <cstdio>
#include <vector>

typedef std::pair<int, int> Info;

const int N = 100000 + 10;

int n, m, q, a[N], b[N];
Info f[11][N];

int main() {
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= m; ++i) scanf("%d%d", &a[i], &b[i]);
  scanf("%d", &q);
  for (int i = 1; i <= q; ++i) {
    int v, d, c;
    scanf("%d%d%d", &v, &d, &c);
    f[d][v] = Info(i, c);
  }
  for (int i = 10; i > 0; --i) {
    for (int j = 1; j <= n; ++j) f[i - 1][j] = std::max(f[i - 1][j], f[i][j]);
    for (int j = 1; j <= m; ++j) {
      int x = a[j], y = b[j];
      f[i - 1][x] = std::max(f[i - 1][x], f[i][y]);
      f[i - 1][y] = std::max(f[i - 1][y], f[i][x]);
    }
  }
  for (int i = 1; i <= n; ++i) printf("%d\n", f[0][i].second);
  return 0;
}


Measured memory_bytes: 9984
#include<iostream>
#include <algorithm>
using namespace std;
int main(){
    int h,w;
    while(1){
        cin >> h >> w;
        
        for(int i=0; i<h; i++){//width
            for(int j=0; j<w; j++){//height
                cout << "#";
            }
            cout << endl;
        }
        if(h==0&&w==0){
            return 0;
        }
        cout << endl;
        
    }
    return 0;
}

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#pragma GCC optimize("unroll-loops,no-stack-protector")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
using namespace std;
typedef long long ll;
typedef long double ld;

int main(){
	vector <ll> arr(3);
	cin >> arr[0] >> arr[1] >> arr[2];
	sort(arr.begin(),arr.end());
	cout << arr[0]*arr[1]/2 << endl;
	cin >> arr[0];
}
 

Measured memory_bytes: 256
import java.util.*;
import java.awt.geom.*;
import java.io.*;
public class Main{
    int [][] dp;
    int MAX = 1120;
    int K= 14;
    boolean [] isprime;
     
    private void doit(){
        Scanner sc = new Scanner(System.in);
         
        isprime = new boolean[MAX + 1];
        eratos();
         
        dp = new int[K + 1][MAX + 1];
        dp();
        while(true){
            int n = sc.nextInt();
            int k = sc.nextInt();
            if((n|k) == 0) break;
            int ans = dp[k][n];
            System.out.println(ans);
        }
    }
 
    private void dp() {
        for(int i = 1; i <= MAX; i++){
            dp[1][i] = isprime[i] ? 1 : 0;
        }
         
        for(int i = MAX; i >= 2; i--){
            if(! isprime[i]) continue;
            for(int j = MAX; j >= i; j--){
                for(int k = K - 1; k  >= 1; k--){
                    if(k == 1 && j == i) continue;
                    if(j + i > MAX) continue;
                    dp[k+1][j + i] += dp[k][j];
                }
            }
        }
    }
 
    private void eratos() {
        Arrays.fill(isprime, true);
        isprime[0] = false;
        isprime[1] = false;
        for(int i = 2; i * i <= MAX; i++){
            if(isprime[i]){
                for(int j = i * 2; j <= MAX; j+= i){
                    isprime[j] = false;
                }
            }
        }
         
    }
 
    public static void main(String [] args){
        new Main().doit();
    }
}

Measured memory_bytes: 12000
import math
import sys


def main():
    sx, sy, tx, ty = map(int, input().split())
    dx = tx - sx
    dy = ty - sy
    ax11 = [("R" if dx >= 0 else "L")] * abs(dx)
    ay11 = [("U" if dy >= 0 else "D")] * abs(dy)
    ax12 = [("L" if dx >= 0 else "R")] * abs(dx)
    ay12 = [("D" if dy >= 0 else "U")] * abs(dy)
    ax21 = [("D" if dy >= 0 else "U")] * 1 + \
        [("R" if dx >= 0 else "L")] * (abs(dx) + 1)
    ay21 = [("U" if dy >= 0 else "D")] * (abs(dy) + 1) + \
        [("L" if dx >= 0 else "R")] * 1
    ax22 = [("U" if dy >= 0 else "D")] * 1 + \
        [("L" if dx >= 0 else "R")] * (abs(dx) + 1)
    ay22 = [("D" if dy >= 0 else "U")] * (abs(dy) + 1) + \
        [("R" if dx >= 0 else "L")] * 1
    a1 = "".join(ax11 + ay11 + ax12 + ay12)
    a2 = "".join(ax21 + ay21 + ax22 + ay22)
    print(a1 + a2)


if __name__ == '__main__':
    main()


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

int main(){
    int N;
    cin >> N;
    vector<int> A(N);
    vector<int> B(N);
    vector<int> C(N);
    int num=0;
    int i;
    for(i=0;i<N;i++) cin >> A[i];
    for(i=0;i<N;i++) cin >> B[i];
    for(i=0;i<N-1;i++) cin >> C[i];

    for(i=0;i<N;i++){
        num += B[i];
        if(A[i]+1 == A[i+1])
            num += C[A[i]-1];
    }
    cout << num << endl;
    return 0;

}

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

void startup()
{
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
}

int32_t main()
{
    startup();
	
		 int n;
		 cin>>n;
		 string s;
		 cin>>s;

		 int cntw=0;
		 int cntr=0;
		 for(int i=0 ; i<n ; ++i)
		 {
		 	if(s[i]=='W')
		 		cntw++;
		 	else
		 		cntr++;
		 }
		 if(cntw==cntr)
		 {
		 	int mid=n/2-1;
		 	int ans=0;
		 	for(int i=mid ; i>=0 ; --i)
		 	{
		 		if(s[i]=='W')
		 			++ans;
		 	}
		 	cout<<ans;
		 }
		 else if(cntr>cntw) 
		 {
		 	int ans=0;
		 	for(int i=cntr-1 ; i>=0 ; --i)
		 	{
		 		if(s[i]=='W')
		 			++ans;
		 	}
		 	cout<<ans;
		 }
		 else
		 {
		 	int ans=0;
		 	for(int i=cntr-1 ; i>=0 ; --i)
		 	{
		 		if(s[i]=='W')
		 			++ans;
		 	}
		 	cout<<ans;
		 }

    return 0;
}




Measured memory_bytes: 3656
#include<iostream>
#include<algorithm>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
ll inf = 1000000007;
string rev(string s) {
	reverse(s.begin(),s.end());
	return s;
}
int main() {
	string s;
	cin >> s;
	string t;
	t = rev(s);
	if (t != s) {
		cout << "No" << endl;
		return 0;
	}
	int x = (s.size() - 1) / 2;
	int y = (s.size() + 3) / 2;
	y--;
	ll check = 0;
	string a = s.substr(0, x);
	string b = rev(a);
	
	if (a == b) {
		check++;
	}
	string c = s.substr(y, x);
	string d = rev(c);
	
	if (c == d) { 
		check++; 
	}
	if (check == 2) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstring>
#include <algorithm>
using namespace std;
const int MAX = 4001;

int dp[MAX][MAX];

int main(){
  string s1,s2;

  while(cin >> s1 >> s2){
    memset(dp,0,sizeof(dp));

    int n = s1.size() ,m = s2.size();
    int ans = 0; 
    for(int i = 0 ; i < n ; i++){
      for(int j = 0 ; j < m ; j++){
	if(s1[i] == s2[j]){
	  dp[i+1][j+1] = dp[i][j] + 1;
	}
	ans = max(ans,dp[i+1][j+1]);
      }
    }

    cout << ans << endl;
  }

  return 0;
}

Measured memory_bytes: 63748
a = int(input())
b = int(input())
c = int(input())
x = int(input())

ans = 0
for i in range(a+1):
    for j in range(b+1):
        for k in range(c+1):
            if x == 500*i+100*j+50*k:
                ans += 1

print(ans)


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

using namespace std;

int main()
{
#ifdef CraZYali
	freopen("c.in", "r", stdin);
	freopen("c.out", "w", stdout);
#endif
	int A, B, C, X, Y;
	cin >> A >> B >> C >> X >> Y;
	C *= 2;
	if (A + B > C)
		if (X > Y)
			if (A < C) printf("%d", C * Y + (X - Y) * A);
			else printf("%d", C * X);
		else
			if (B < C) printf("%d", C * X + (Y - X) * B);
			else printf("%d", C * Y);
	else printf("%d", A * X + B * Y);
	return 0;
}


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

using namespace std;

int main()
{
	int K, T, A, ans;
	int max_v;
	cin >> K >> T;

	cin >> max_v;
	for (int i = 1; i < T; i++)
	{
		cin >> A;

		if (max_v < A)
			max_v = A;
	}
	
	ans = max_v - 1 - (K - max_v);
	cout << ((ans >= 0) ? ans : 0) << endl;

	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main() {
	int x;
	cin >> x;
	if (x >= 1800)
		cout << 1;
	else if (x >= 1600)
		cout << 2;
	else if (x >= 1400)
		cout << 3;
	else if (x >= 1200)
		cout << 4;
	else if (x >= 1000)
		cout << 5;
	else if (x >= 800)
		cout << 6;
	else if (x >= 600)
		cout << 7;
	else if (x >= 400)
		cout << 8;
	return 0;
}

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

void inv(vector<int>& v) {
    int length = v.size();
    for (int i = 0; i < length; i++) {
        cin >> v[i];
    }
}
void inv(vector<int>& v, int length) {
    for (int i = 0; i < length; i++) {
        cin >> v[i];
    }
}

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

    if (x <= 599) {
        cout << 8 << endl;
    } else if (x <= 799) {
        cout << 7 << endl;
    } else if (x <= 999) {
        cout << 6 << endl;
    } else if (x <= 1199) {
        cout << 5 << endl;
    } else if (x <= 1399) {
        cout << 4 << endl;
    } else if (x <= 1599) {
        cout << 3 << endl;
    } else if (x <= 1799) {
        cout << 2 << endl;
    } else if (x <= 1999) {
        cout << 1 << endl;
    }

    return 0;
}


Measured memory_bytes: 3628
#include <iostream>
#include <algorithm>
#include <string>
using namespace std;
int main(void){
    int n,m,x,a[105]={},b,ans1=0,ans2=0;
    cin>>n>>m>>x;
    for(int i=0;i<m;i++){cin>>b;a[b]++;}
    for(int i=x;i>0;i--){
        ans1+=a[i];
    }
    for(int i=x;i<n;i++){
        ans2+=a[i];
    }
    
    cout<<min(ans1,ans2)<<endl;
}


Measured memory_bytes: 384
#include <iostream>
#include <array>
#include <algorithm>
#include <map>
#include <vector>
#include <list>
#include <cmath>
#include <stack>
#include <queue>
#include <climits>
#include <string.h>
#include <cctype>
#include <set>

#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;
using namespace std;

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

// a と b の最大公約数を返す関数
long long GCD(long long a, long long b) {
	if (b == 0) return a;
	else return GCD(b, a % b);
}

long long gcd(long long a, long long b)
{
	if (a % b == 0)
	{
		return(b);
	}
	else
	{
		return(gcd(b, a % b));
	}
}

long long lcm(long long a, long long b)
{
	return a * b / gcd(a, b);
}

// auto mod int
// https://youtu.be/L8grWxBlIZ4?t=9858
// https://youtu.be/ERZuLAxZffQ?t=4807 : optimize
// https://youtu.be/8uowVvQ_-Mo?t=1329 : division
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 { return mint(*this) += a; }
	mint operator-(const mint a) const { return mint(*this) -= a; }
	mint operator*(const mint a) const { return mint(*this) *= 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 { return mint(*this) /= a; }
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x; }
ostream& operator<<(ostream& os, const mint& a) { return os << a.x; }

struct combination {
	vector<mint> fact, ifact;
	combination(int n) :fact(n + 1), ifact(n + 1) {
		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];
	}
} comb(2000005);

mint g(int r, int c) {
	return comb(r + c + 2, r + 1) - 1;
}

bool comp(int i, int j) {
	return i > j;
}

bool compare_by_b(pair<int, int> a, pair<int, int> b) {
	return a.second < b.second;
}
vector<vector<int>> dd;

int main()
{
	bool isNext = false;
	int n, m;
	cin >> n >> m;
	int ll = (m % 2 == 1) ? (m / 2 + 1) : m / 2;
	int lr = ll + 1;
	int rl = n - m / 2 - 1;
	int rr = rl + 2;
	for (int i = 0; i < m; i++)
	{
		if (i % 2 == 0)
		{
			cout << ll << " " << lr << endl;
			ll--;
			lr++;
		}
		else
		{
			cout << rl << " " << rr << endl;
			rl--;
			rr++;
		}
	}
}



Measured memory_bytes: 34200
N,Q = map(int,input().split())
S = list(input())
ac = [0 for i in range(N)]
for i in range(1,N):
    ac[i] = ac[i-1]
    if S[i-1] == "A" and S[i] == "C": ac[i] += 1

quest = [[] for i in range(Q)]
for i in range(Q): quest[i] = list(map(int,input().split()))

for i in range(Q):
    l,r = quest[i]
    print(ac[r-1]-ac[l-1])

Measured memory_bytes: 31392
/*
Submitted With (^^) by -> Hossam ^_^
_____________________
|     ___     ___     |
|    (^_^)   (^_^)    |
|   /( | )\_/( | )\   |
|_____|_|_____|_|_____|
*/

#include <bits/stdc++.h>

using namespace std;

inline void prep()
{
    cin.tie(0);
    cin.sync_with_stdio(0);
};

#define X first
#define Y second
#define endl '\n'
#define ll long long
#define inf (0x7fffffffffffffff)
#define all(x) x.begin(), x.end()
#define debug(x) cerr << #x << " = " << (x) << "\n";
#define ZXC cerr << clock() * 1.0 / CLOCKS_PER_SEC << endl;

const int mod = (int)1e9 + 7;
// const int mod = 998244353;
const int MX = (int)2e4 + 10;

int main()
{
    prep();
    srand(time(0));

    int n, k;
    cin >> n >> k;

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

    int res = (int)2e9;
    for(int i = 0; i + k - 1 < n; ++i){
        int lf = i;
        int rg = i + k - 1;

        if(a[lf] <= 0 && a[rg] >= 0){
            int lx = -a[lf];
            int rx = a[rg]; 
            res = min({res, lx * 2 + rx, rx * 2 + lx});
        }
        else if(a[rg] > 0 && a[lf] > 0){
            res = min(res, a[rg]);
        }
        else if(a[lf] < 0 && a[rg] < 0){
            res = min(res, -a[lf]);
        }
    }

    cout << res << endl;

    // ZXC
    return 0;
}

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

typedef long long ll;
int N;

int main() {
    cin >> N;

    vector<ll> A;
    A.push_back(0);
    for (int i = 0; i < N; i++) { 
        ll a;
        scanf("%lld", &a);
        A.push_back(a);
    }

    for (int i = 1; i <= N+1; i++) {
        A[i] += A[i-1];
    }

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

    A.push_back(-1000000008);

    ll ans = 0;
    ll temp = -10000000000008;
    ll cnt = 1;
    for (int i = 0; i <= N+1; i++) {
        if (A[i] == temp) cnt++;
        else {
            ans += cnt * (cnt-1) / 2;
            cnt = 1;
            temp = A[i];
        }
    }

    cout << ans << '\n';

}



Measured memory_bytes: 2420
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using vi = vector<int>;    using vvi = vector<vi>;
using vb = vector<bool>;   using vvb = vector<vb>;
using vl = vector<ll>;     using vvl = vector<vl>;
using vd = vector<double>; using vvd = vector<vd>;

#define REP(i,n) for(ll i=0, i##_len=(ll)(n); i<i##_len; ++i)
#define ALL(c) (c).begin(), (c).end()
#define FOR(i,s,n) for(ll i=s, i##_len=(ll)(n); i<i##_len; ++i)
#define TEN(x) ((ll)1e##x)
const ll mod = TEN(9) + 7;

int main() {
#ifdef INPUT_FROM_FILE
	ifstream cin("sample.in");
	ofstream cout("sample.out");
#endif
	cin.tie(0);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(50);
	ll h, w, n; cin >> h >> w >> n;
	vl a(n), b(n);
	REP(i, n) cin >> a[i] >> b[i];
	set<pair<ll, ll>> exist;
	REP(i, n) exist.insert({a[i], b[i]});


	vl ans(10, 0);

	set<pair<ll, ll>> visited;
	vl dx = { -2, -2, -2, -1, -1, -1,  0,  0, 0 };
	vl dy = { -2, -1,  0, -2, -1,  0, -2, -1, 0 };

	vl dx2 = { 0, 0, 0, 1, 1, 1, 2, 2, 2 };
	vl dy2 = { 0, 1, 2, 0, 1, 2, 0, 1, 2 };

	REP(i, n) {
		REP(d, 9) {
			ll nx = dx[d] + a[i];
			ll ny = dy[d] + b[i];
			if (nx < 1 || ny < 1) continue;
			if (nx + 2 > h || ny + 2 > w) continue;
			if (visited.find({ nx, ny }) != visited.end()) continue;
			ll cnt = 0;
			REP(d2, 9) {
				ll nnx = dx2[d2] + nx;
				ll nny = dy2[d2] + ny;
				if (exist.find({ nnx, nny }) != exist.end()) cnt++;
			}
			ans[cnt]++;
			visited.insert({nx, ny});
		}
	}
	ans[0] = (h-2) * (w-2);
	FOR(i, 1, 10) ans[0] -= ans[i];

	REP(i, 10) cout << ans[i] << endl;

	return 0;
}


Measured memory_bytes: 64384
#include <cstdio>
#include <iostream>
#include <vector>
#include <string>
#define rep(i, n) for(int i = 0; i < n; i++)
using namespace std;

typedef long long ll;

int main(void)
{
    int n;
    cin >> n;
    double sum = 0;

    rep(i, n){
        double a;
        cin >> a;
        sum += 1.0 / a; 
    }

    double ans = 1.0 / sum;
    printf("%.10f\n", ans);
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
int main(void){
  int n,a,b,p,i,x[3]={},min=100;
  scanf("%d%d%d",&n,&a,&b);
  for (i=0;i<n;i++){
    scanf("%d",&p);
    if (p<=a) x[0]++;
    else if (p<=b) x[1]++;
    else x[2]++;
  }
  for (i=0;i<3;i++){
    if (min>x[i]) min=x[i];
  }
  printf("%d\n",min);
  return 0;
}


Measured memory_bytes: 128
import java.util.*;
public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		// 整数の入力
		double W = sc.nextInt(); //X
		double H = sc.nextInt(); //Y
    double x = sc.nextInt();
    double y = sc.nextInt();

    double rectangle = W*H/2.0;
    System.out.printf("%f ", rectangle);
    if(W/2.0 == x && H/2.0 == y)
      System.out.println("1");
    else
      System.out.println("0");
	}
}

Measured memory_bytes: 21844
#include <cstdio>
#include <algorithm>
#include <iostream>
#include <vector>
#include <cstring>
#include <set>
#include <utility>
#include <cstdlib>
#include <cmath>
#include <queue>
#include <stack>
#include <string>
#include <map>
#include <cmath>
#include <deque>
#include <bitset>
#define ll long long
#define PI 3.1415926535897932384626433832795
#define read(x) scanf("%d",&x);
#define readll(x) cin>>x;
#define FOR(x,a,b) for(int x=a;x<b;x++)
#define MP make_pair
#define PB push_back
#define pii pair<int,int>
#define readN(N,X) for(int i=0;i<N;i++) cin>>X[i];
#define pff pair<double,double>
using namespace std;



long long fastpow(int a, int b, int MOD)
{
    long long x=1,y=a; 
    while(b > 0)
    {
        if(b%2 == 1)
        {
            x=(x*y) % MOD;
        }
        y = (y*y) % MOD;
        b /= 2;
    }
    return x;
}

long long InverseEuler(int n, int MOD)
{
    return fastpow(n,MOD-2,MOD);
}
 
long long f[300000];
bool init;
long long C(int n, int r, int MOD)
{
    if (!init){
        init=1;
        f[0]=1;
        for (int i=1; i<300000;i++)
            f[i]= (f[i-1]*i) % MOD;
        
    }
    return (f[n]*((InverseEuler(f[r], MOD) * InverseEuler(f[n-r], MOD)) % MOD)) % MOD;
}


int a[300005];
vector<int> loc[300005];
int N;
int main(){
   std::ios::sync_with_stdio(false); 
   cin>>N;
   N++;
   readN(N, a);
   FOR(i,0,N) {
   	loc[a[i]].push_back(i);
   }

   int cari = 0;
   FOR(i,0,N){
   		if (loc[i].size()==2) cari=i;
   }
   int A=loc[cari][0];
   int B=loc[cari][1];
   //cout<<cari<<endl;
   int jeda = N - (B-A) - 1;
   //cout<<jeda<<endl;
   for (int i=1;i<=N;i++){
   	ll base = C(N,i, 1000000007);
   	ll kur = 0;
   	if (jeda >= i-1)
   		kur = C(jeda, i-1, 1000000007);
   	cout<<(base - kur + 1000000007) % 1000000007<<endl;
   }





}

Measured memory_bytes: 14848
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int length = scanner.nextInt();
        String input = scanner.next();
        if (length % 2 != 0) {
            System.out.println("No");
        } else {
            if (input.substring(0, length / 2).equals(input.substring(length / 2))) {
                System.out.println("Yes");
            } else {
                System.out.println("No");
            }
        }
    }
}

Measured memory_bytes: 22996