akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(x) (x).begin(), (x).end()
using ll = long long;
using namespace std;

bool f(string s){
    string rs = s;
    reverse(all(rs));
    return s == rs;
}

int main() {
    string S;
    cin >> S;
    int N = S.size();
    string S2 = S.substr(0,(N-2)/2+1);
    string S3 = S.substr((N+3)/2-1);
    cout << ((f(S)&&f(S2)&&f(S3))?"Yes":"No") << endl;
}

Measured memory_bytes: 256
/*Lower_Rating*/
/*Comb*/
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<cstring>
#include<stack>
#include<vector>
#include<queue>
#include<bitset>
using namespace std;

#define LL long long
#define DB double
#define MOD 924844033
#define MAXN 4000
#define Pr pair<DB,int>
#define X first
#define Y second
#define INF 20000000000000000LL
#define mem(x,p) memset(x,p,sizeof(x))
#define P(x) ((x+1)*x/2)

LL read(){
  LL x=0,F=1;char c=getchar();
  while(c<'0'||c>'9'){if(c=='-')F=-1;c=getchar();}
  while(c>='0'&&c<='9'){x=(x<<3)+(x<<1)+c-'0';c=getchar();}
  return x*F;
}

int add(int a,int b){return (a+b>=MOD)?a+b-MOD:a+b;}
int dec(int a,int b){return (a-b<0)?a-b+MOD:a-b;}
int mul(int a,int b){return 1LL*a*b%MOD;}
int fst_pow(int a,int b){
    int res=1;
    while(b){
        if(b&1)res=mul(res,a);
        a=mul(a,a);
        b>>=1;
    }return res;
}

int n,k,istp[MAXN+5],cnt,fac[MAXN+5];
int f[MAXN+5][MAXN+5][2];
int ans;

int main()
{
    n=read(),k=read();
    fac[0]=1;
    for(int i=1;i<=n;i++)
    fac[i]=mul(fac[i-1],i);
    for(int i=1;i<=k;i++){
        istp[cnt+1]=1,cnt+=(n+k-i)/k;
        istp[cnt+1]=1,cnt+=(n+k-i)/k;
    }
    f[0][0][0]=1;
    for(int i=1;i<=(n*2);i++)
        for(int j=0;j<=i;j++){
            f[i][j][0]=add(f[i][j][0],add(f[i-1][j][0],f[i-1][j][1]));
            if(!istp[i]&&j)f[i][j][1]=add(f[i][j][1],f[i-1][j-1][0]);
        }
    for(int i=0;i<=n;i++){
        int s=add(f[n*2][i][0],f[n*2][i][1]);
        if(i&1)ans=dec(ans,mul(s,fac[n-i]));
        else ans=add(ans,mul(s,fac[n-i]));
    }
    printf("%d",ans);//
}


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

bool check(int a,int b,int n){
  string s=to_string(n);
  int m=0;
  for(int i=0;i<s.size();i++)
    m+=s.at(i)-48;
  if(a<=m&&b>=m)
    return true;
  return false;
}
int main(){
  int a,b,n;
  cin >> n >>a >> b;
  int ans=0;
  for(int i=1;i<=n;i++){
    if(check(a,b,i))
      ans+=i;
  }
  cout << ans << endl;
}

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


#define rep2(x,fr,to) for(int (x)=(fr);(x)<(to);(x)++)
#define rep(x,to) for(int (x)=0;(x)<(to);(x)++)
#define repr(x,fr,to) for(int (x)=(fr);(x)>=(to);(x)--)
#define all(c) (c).begin(),(c).end()
#define sz(v) (int)(v).size()

using namespace std;
typedef long long ll; typedef vector<int> VI; typedef pair<int,int> pii;
const int MD = (int)1e9 + 7; typedef vector<ll> VL;
void dbg(){ cerr << "\n"; }  template <class T, class ...T2>
void dbg(const T& fst, const T2&...rst){ cerr << fst << ": "; dbg(rst...); }
template <class T> void amax(T& a,T b){ a=max(a,b);}



int main(){
	cin.tie(0); ios_base::sync_with_stdio(false);
	int n, ans =0;
	cin >>n;
	VI p(n), z(n), w(n);
	rep(i, n){ cin >>p[i]; p[i]--;}
	
	z[0] = w[0] = p[0];
	rep2(i, 1, n){
		bool ok=true;
		
		if(z[i-1] > p[i]) ans++;
		z[i] = min(z[i-1], p[i]);
	}
	//for(auto x :z) cerr<<x<<" "; cerr<<"\n";
	cout <<ans + 1<<"\n";
	return 0;
}


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


int main(void){
	int n;
	cin >> n;
	for(int i = 0; i < n; i++){
		for(int j = 0; j < n; j++){
			if(i*7+j*4==n){
				cout << "Yes" << endl;
				return 0;
			}
		}
	}
	cout << "No" << endl;
	return 0;
}


Measured memory_bytes: 888
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		int A = scanner.nextInt();
		int B = scanner.nextInt();
		int C = scanner.nextInt();
		int count = B / A;
		System.out.println(C < count ? C : count);
		scanner.close();
	}
}

Measured memory_bytes: 23124
# -*- coding: utf-8 -*-
"""
Created on Wed Mar  4 00:20:28 2020

@author: Kanaru Sato
"""

A,B,K = list(map(int, input().split()))

if K-(A+B) >= 0:
    print(0,0)
else:
    if A<=K:
        print(0,B-K+A)
    if A>K:
        print(A-K,B)

Measured memory_bytes: 3064
#include<iostream>
#include<vector>
#include<algorithm>
#include<cstring>
#include<cstdio>
#include<cmath>
#include<cstdlib>
#include<ctime>
#include<queue>
#include<set>
#include<map>
#include<stack>
#include<bitset>

#define pb push_back
#define mp make_pair

using namespace std;

template<typename T>inline void upmin(T &x,T y) { y<x?x=y:0; }
template<typename T>inline void upmax(T &x,T y) { x<y?x=y:0; }

typedef unsigned int u32;
typedef long long LL;
typedef unsigned long long ULL;
typedef long double lod;
typedef pair<int,int> PR;
typedef vector<int> VI;

const int oo=1<<30;
const LL OO=1e18;

const int N=4e5+100;

int gi() {
	int w=0;bool q=1;char c=getchar();
	while ((c<'0'||c>'9') && c!='-') c=getchar();
	if (c=='-') q=0,c=getchar();
	while (c>='0'&&c <= '9') w=w*10+c-'0',c=getchar();
	return q? w:-w;
}

const int mod=1e9+7;
inline int qpow(int x,int y) {
	int ans=1;
	while (y) {
		ans=1LL*ans*x%mod;
		x=1LL*x*x%mod;y>>=1;
	}
	return ans;
}

int head[N],nxt[N];
int f[N],s[N],son[N];
int tot[N],p[N],dfn[N],up[N],dep[N],pi[N];
int cnt;
inline void dfs1(int k) {
	tot[dep[k]]++;up[k]=1;
	for (int i=head[k];i;i=nxt[i]) {
		dep[i]=dep[k]+1;dfs1(i);
		if (up[i]+1>up[k]) up[k]=up[i]+1,son[k]=i;
	}
}
inline void merge(int x,int y) {
	int o=(p[s[y]]-f[y]+mod)%mod;
	f[x]=(1LL*f[x]*o+1LL*pi[x]*f[y])%mod;
	s[x]+=s[y];pi[x]=1LL*pi[x]*o%mod;
}
inline void dfs2(int k) {
	int t,mx=0;
	f[cnt]=s[cnt]=1;
	dfn[k]=cnt++;
	if (son[k]) dfs2(son[k]);
	for (int i=head[k];i;i=nxt[i])
		if (i!=son[k])
			mx=max(mx,up[i]);
	for (int t=1;t<=mx;t++)
		pi[dfn[k]+t]=(p[s[dfn[k]+t]]-f[dfn[k]+t]+mod)%mod;
	for (int i=head[k];i;i=nxt[i])
		if (i!=son[k]) {
			dfs2(i);
			for (t=0;t<up[i];t++)
				merge(dfn[k]+t+1,dfn[i]+t);
		}
}
int main()
{
	int n=gi(),i,k,ans=0;
	for (i=1;i<=n;i++)
		nxt[i]=head[k=gi()],head[k]=i;
	for (i=p[0]=1;i<=n+1;i++)
		p[i]=(p[i-1]<<1)%mod;
	dfs1(0);
	dfs2(0);
	for (i=0;i<up[0];i++)
		ans=(ans+1LL*f[i]*p[n+1-tot[i]])%mod;
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 36992
ae = [int(input()) for _ in range(5)]
k = int(input())
flag = False
for i in range(4):
    for j in range(i+1, 5):
        if ae[j] - ae[i] > k:
            print(":(")
            flag = True
            break
    if flag:
        break
else:
    print("Yay!")


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

using namespace std;

int main(void)
{
	ios_base::sync_with_stdio(0);
	cin.tie(NULL);

	int a, b, h;
	cin >> a >> b >> h;
	cout << min(a, b) * h + abs(a - b) * h / 2 << '\n';

	return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main (){
    int N,ma,mi,a,b,c;
    cin >> N;
    cin >> a >> b;
    ma = max(a,b);
    mi = min(a,b);
    for(int i=2;i<N;i++){
        cin >> c;
        if(c > ma){
            ma = c;
        }
        if(c < mi){
            mi = c;
        }
    }
    cout << ma-mi << endl;
}

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

using namespace std;
#define all(x) (x).begin(),(x).end()
#define rep(i, n) for (int i = 0; i < (n); i++)
#define chmin(x, y) (x) = min((x), (y))
#define chmax(x, y) (x) = max((x), (y))
#define endl "\n"
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

template <typename T> ostream &operator<<(ostream &os, const vector<T> &vec) {os << "["; for (const auto &v : vec) {os << v << ","; } os << "]"; return os;}
template <typename T, typename U> ostream &operator<<(ostream &os, const pair<T, U> &p) {os << "(" << p.first << ", " << p.second << ")"; return os;}

void solve() {
    ll K, A, B;
    cin >> K >> A >> B;
    if (B - A <= 2) {
        cout << K + 1 << endl;
    } else {
        if (K - A + 1 < 0) {
            cout << K + 1 << endl;
            return;
        } else {
            K -= A - 1;
            ll now = A;
            if (K % 2) {
                now++;
                K--;
            }
            ll cnt = K / 2;
            now += (B - A) * cnt;
            cout << now << endl;
        }
    }
}

int main() {
    #ifdef LOCAL_ENV
    cin.exceptions(ios::failbit);
    #endif
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout.setf(ios::fixed);
    cout.precision(16);
    
    solve();
}

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

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

ll const mod = 1e9+7;

int main() {
  int n;
  cin >> n;
  ll a;
  map<ll,int> m;
  rep(i,n) {
    cin >> a;
    m[a] += 1;
  }
  int cnt = 0;
  for (auto ix=m.begin();ix!=m.end();ix++) {
    if (ix->second%2==1) cnt++;
  }
  cout << cnt << endl;
}

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

int main() {
  int n;
  string s;
  cin>>n>>s;
  int p=0;
  for(int i=0;i<n-2;i++){
    if(s.at(i)=='A' && s.at(i+1)=='B'  && s.at(i+2)=='C'){
      p++;
    }
  }
  cout<<p<<endl;
}


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

a1=[int(x) for x in input().split()]
a2=[int(x) for x in input().split()]
ans=[0 for i in range(n)]

c1=0
c2=0
for i in range(n):
  c1+=a1[i]
  c2+=a2[-1-i]
  ans[i]+=c1
  ans[-1-i]+=c2
  
print(max(ans))

Measured memory_bytes: 3064
def main():
    import sys
    input = sys.stdin.readline
    sys.setrecursionlimit(10**7)
    from collections import Counter, deque
    from collections import defaultdict
    from itertools import combinations, permutations, accumulate, groupby, product
    from bisect import bisect_left,bisect_right
    from heapq import heapify, heappop, heappush
    import math
    #from math import gcd

    #inf = 10**17
    #mod = 10**9 + 7

    d = defaultdict(int)
    res = 0
    n = int(input())
    a = list(map(int, input().split()))
    for i in range(n-1, -1, -1):
        res += d[i+a[i]]
        d[i-a[i]] += 1
    print(res)

if __name__ == '__main__':
    main()

Measured memory_bytes: 61472
import sys
import itertools
readline = sys.stdin.buffer.readline

s = readline().rstrip().decode('utf-8')
n = len(s)
dig = n-1 #桁数
bit_mask = list(itertools.product([0,1],repeat=dig))
ans = 0
for i in bit_mask:
    res = []
    p = s[0]
    for j,k in enumerate(i,1):
        if k == 0:
            p = p + s[j]
        else:
            res.append(p)
            p = s[j]
    res.append(p)
    for i in res:
        ans += int(i)

print(ans)

    
    


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

int main(){
  int h,w;
  cin >> h >> w;
  vector<string> s(h);
  vector<vector<int>> cnt(h,vector<int>(w));
  rep(i,h) cin >> s[i];
  
  rep(i,h){
    vector<int> done(w);
    rep(j,w){
      if(s[i][j]=='#')continue;
      if(done[j])continue;
      int l = 0;
      
      while(j+l<w){
        if(s[i][j+l]=='#')break;
        l++;
      }
      
      rep(k,l){
        cnt[i][j+k] += l;
        done[j+k] = 1;
      }
    }
  }
  
  rep(i,w){
    vector<int> done(h);
    rep(j,h){
      if(s[j][i]=='#')continue;
      if(done[j])continue;
      int l = 0;
      
      while(j+l<h){
        if(s[j+l][i]=='#')break;
        l++;
      }
      
      rep(k,l){
        cnt[j+k][i] += l;
        done[j+k] = 1;
      }
    }
  }
  int ans = 0;
  rep(i,h){
    rep(j,w){
      ans = max(ans,cnt[i][j]-1);
    }
  }
  cout << ans << endl;
}


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

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const int INF = (1<<30) - 1;
const ll LINF = (1LL<<60) - 1;

int dp[5010][5010];

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

    for (int i = n-1; i >= 0; --i) {
        for (int j = n-1; j >= i; --j) {
            if (s[i] == s[j]) {
                dp[i][j] = dp[i+1][j+1] + 1;
            }
        }
    }

    int res = 0;
    for (int i = 0; i < n; ++i) {
        for (int j = i; j < n; ++j) {
            if (dp[i][j] <= j - i) chmax(res, dp[i][j]);
        }
    }
    cout << res << endl;
}

Measured memory_bytes: 70376
import java.io.*;

public class Main{
 public static void main(String[] args){
	try{  
	 BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
  	 int x  = Integer.parseInt(br.readLine());
  	 String[] str = br.readLine().split(" ");

		for(int i = str.length-1;  i >= 0; i--){
			if(i != 0){
		 	 System.out.print(str[i] + " ");
			}else{
		 	 System.out.println(str[i]);
			}
		}
	}catch(IOException e){
	 System.out.println(e);
	}
}
}

Measured memory_bytes: 16912
#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()

int main()
{
	string s;
	cin >> s;
	int N = s.size();
	int p = 0;
	rep(i, N) {
		if (s[i] == 'p')
			p++;
	}
	auto ans = N/2 - p;
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 512
#include <iostream>
#include <algorithm>
#define flush fflush(stdout)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef pair<ll, ll> Pl;
const int mod = (int)1e9 + 7, INF = (int)1e9;
const int di[4] = { 1,0,-1,0 }, dj[4] = { 0,1,0,-1 };


int main(void) {
    int n, i;
    ll c[200003], bif[200003], ans, ml;

    scanf("%d", &n);
    for (i = 0; i < n; i++) {
        scanf("%lld", &c[i]);
    }

    sort(c, c + n, greater<ll>());

    bif[0] = 1;
    for (i = 1; i <= n; i++) {
        bif[i] = bif[i - 1] * 2 % mod;
    }

    ans = 0;
    for (i = 0; i < n; i++) {
        ml = c[i] * bif[n - i - 1] % mod * ((bif[max(0, i - 1)] * i % mod + bif[i]) % mod) % mod;
        ans = (ans + ml) % mod;
    }

    ans = ans * bif[n] % mod;

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

    return 0;
}

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

int main() {
  std::string s;
  std::cin >> s;
  int count;
  for (std::size_t i = 0; i < s.size(); i++) {
    if (s[i] == '1') count++;
  }
  std::cout << count;
  
  return 0;
}

Measured memory_bytes: 256
/* package whatever; // don't place package name! */

import java.util.*;
import java.lang.*;
import java.io.*;

/* Name of the class has to be "Main" only if the class is public. */
public class Main
{
	public static void main (String[] args) throws java.lang.Exception
	{
		Scanner in = new Scanner(System.in);
		int n = in.nextInt();
		int ac = 0,wa=0,tle=0,re=0;
		for(int i=0;i<n;i++){
			String temp = in.next();
			if(temp.equals("AC")){
				ac++;
			}else if(temp.equals("WA")){
				wa++;
			}else if(temp.equals("TLE")){
				tle++;
			}else{
				re++;
			}
		}
		System.out.println("AC x "+ac);
		System.out.println("WA x "+wa);
		System.out.println("TLE x "+tle);
		System.out.println("RE x "+ re);// your code goes here
	}
}

Measured memory_bytes: 58020
n = int(input())
cnt = [ [0]*10 for _ in range(10)]

for i in range(1, n+1):
  strI = str(i)

  t = strI[0]
  b = strI[-1]
  cnt[int(t)][int(b)] += 1

ans = 0
for j in range(10):
  for k in range(10):
    ans += cnt[j][k] * cnt[k][j]

print(ans)

Measured memory_bytes: 3060
#include <algorithm> 
#include <cstdio> 
#define SZ 1000009 
#define p 1000000007 
#define llg long long 
using namespace std; 

llg dp[20][SZ], ans = 0, lst[SZ], fac[SZ], Cc[20], ifac[SZ]; 
int n, m, a[SZ], allsta, Log[SZ], sn; 

int read(); 
bool cmp(int x, int y) {return x > y; } 
llg fsq(llg x, llg kn) {
	llg ret = 1; 
	while (kn) {
		if (kn & 1) (ret *= x) %= p; 
		(x *= x) %= p; kn >>= 1; 
	} 
	return ret; 
} 
llg C(llg x, llg y) {return fac[x] * ifac[y] % p * ifac[x - y] % p; } 
void get_C() { 
	Cc[0] = 1; for (int i = 1; i <= n; ++i) Cc[i] = Cc[i - 1] << 1; 
	for (int i = 1; i <= allsta; ++i) Log[i] = Log[i >> 1] + i & 1; 
	fac[0] = 1; for (int i = 1; i <= allsta + 1; ++i) fac[i] = fac[i - 1] * i % p; 
	ifac[allsta + 1] = fsq(fac[allsta + 1], p - 2); 
	for (int i = allsta; i >= 0; --i) ifac[i] = ifac[i + 1] * (i + 1) % p; 
	for (int i = 0; i <= allsta; ++i) {
		int lsti = sn - i - 1, ni = 0, sum = lsti; lst[i] = 1; 
		while (lsti) {
			if (lsti & 1) 
				(lst[i] *= C(sum, Cc[ni]) * fac[Cc[ni]] % p) %= p; 
			if (lsti & 1) sum -= Cc[ni]; ++ni; lsti >>= 1; 
		} 
	} 
} 

int main() {
	n = read(), m = read(); sn = 1 << n; allsta = sn - 1; 
	for (int i = 1; i <= m; ++i) a[i] = read(); 
	sort(a + 1, a + 1 + m, cmp); dp[0][0] = 1; get_C(); 
	for (int i = 0; i <= m; ++i) dp[i][0] = 1; 
	for (int i = 1; i <= m; ++i) {
		for (int j = 0; j <= allsta; ++j) dp[i][j] = dp[i - 1][j]; 
		for (int j = 0; j <= allsta; ++j) 
			for (int k = 1; k <= n; ++k) if (!((j >> k - 1) & 1)) 
				if (j + Cc[k - 1] <= sn - a[i] + 1) 
					(dp[i][j | (1 << k - 1)] += 	
		dp[i - 1][j] * C(sn - a[i] - j, Cc[k - 1] - 1) % p * fac[Cc[k - 1]] % p) %= p; 
	} 
	for (int j = 0; j <= allsta; ++j) { 
		llg now = dp[m][j] * lst[j] % p; 
		if (Log[j] & 1) (now *= (p - 1)) %= p; 
		(ans += now) %= p; 
	} 
	printf("%lld\n", ans * sn % p); 
	return 0; 
} 

int read() {
	int x = 0, f = 1; char c = getchar(); 
	while (c > '9' || c < '0') f = (c == '-') ? -1 : f, c = getchar(); 
	while (c >= '0' && c <= '9') x = x * 10 + c - '0', c = getchar(); 
	return x * f; 
} 

Measured memory_bytes: 11640
#include <iostream>
#include <math.h>

bool isPrim(int x){
    if(x==2){
        return true;
    }
    if(x<2||x%2==0){
        return false;
    }
    //x????????¶??°??????2??????sqrt(x)?????§???????????°??????
    for(int i=3;i<=sqrt(x);i++){
        if((x%i)==0){
            return false;
        }
        i++;
    }
    return true;
}

int main(){
    int x,n;
    int cnt=0;

    std::cin>>n;
    while(n--){
        std::cin>>x;
        if(isPrim(x)){
            cnt++;
        }
    }
    std::cout<<cnt<<std::endl;
    return 0;
}

Measured memory_bytes: 3084
#include<iostream>
#include<string>
#include<algorithm>
#include<math.h>
#include<queue>
#include<set>
#include<map>
#include<random>
#include<functional>
#include<utility>

typedef long long ll;

#define rep(i,n) for(int i=0; i<n; i++)
#define pb push_back
#define P pair<int, int>
#define PLI pair<ll, int>
#define PLL pair<ll, ll>
#define VI vector<int>
#define VII vector<VI>

using namespace std;



int N;
P A[100005], B[100005];
int p[100005];
int main() {
	cin >> N;
	rep(i, N) {
		cin >> A[i].first;
		A[i].second = i;
	}
	rep(i, N) {
		cin >> B[i].first;
		B[i].second = i;
	}
	sort(A, A + N);
	sort(B, B + N);

	rep(i, N) {
		if (A[i].first > B[i].first) {
			cout << "No" << endl;
			return 0;
		}
	}

	rep(i, N - 1) {
		if (B[i].first >= A[i + 1].first) {
			cout << "Yes" << endl;
			return 0;
		}
	}

	rep(i, N) {
		p[A[i].second] = B[i].second;
	}
	int cnt = 0;
	int x = 0;
	do
	{
		x = p[x];
		cnt++;
	} while (x != 0);
	if (cnt != N) {
		cout << "Yes" << endl;
		return 0;
	}
	cout << "No" << endl;

	return 0;
}


Measured memory_bytes: 2176
#include<stdio.h>
#include<algorithm>
using namespace std;
const int MAX=200001;
int a[MAX];
int main()
{

  int n;
  scanf("%d",&n);
  for(int i=0;i<n;i++)
    scanf("%d",&a[i]);
    int maxv=-2000000000;
    int minv=a[0];
    for(int i=1;i<n;i++)
    {
        maxv=max(maxv,a[i]-minv);
        minv=min(minv,a[i]);
    }
    printf("%d\n",maxv);
    return 0;

}

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

#define for_(i,a,b) for(int i=a;i<b;++i)

int r, n, H[50];

int main() {
	while (cin >> r >> n, r) {
		memset(H, 0, sizeof(H));
		
		for_(i,0,n) {
			int xl, xr, h; cin >> xl >> xr >> h;
			for_(j,xl+20,xr+20) H[j] = max(H[j], h);
		}
		
		double ans = 1e5;
		for_(x,-r,r) {
			double p = (x < 0 ? x + 1 : x);
			ans = min(ans, H[x+20] + r - sqrt(r * r - p * p));
		}
		
		printf("%.9lf\n", ans);
	}
	
	return 0;
}

Measured memory_bytes: 1196
N,Q=map(int,input().strip().split())
S=list(input())
lr=[list(map(int,input().strip().split())) for _ in range(Q)]

#累積和
dp=[0 for _ in range(N)]
for n in range(1,len(S)):
    if S[n]=="C" and S[n-1]=="A":
        dp[n]=dp[n-1]+1
    else:
        dp[n]=dp[n-1]

#部分和の算出
for q in range(Q):
    print(dp[lr[q][1]-1]-dp[lr[q][0]-1])

Measured memory_bytes: 30288
#include <iostream>

using namespace std;

int main(void){
  int n, i;
  float a[1000];
  double sum = 0;

  cin >> n;
  for(i = 0; i < n; i++){
    cin >> a[i];
    sum = sum + 1 / a[i];
  }
  sum = 1 / sum;
  printf("%lf",sum);
  return 0;
}


Measured memory_bytes: 384
//#include <bits/stdc++.h>
//#include <stdio.h>
#include<iostream>
#include<cstdio>
#include<bitset>
#include<algorithm>
#include<vector>
#include<list>
#include<queue>
#include<stack>
#include<string>
#include<string.h>
#include<cmath>
#include<utility>
#include<functional>
#include<map>
#include<set>
#include<cctype>
#include<fstream>


#define FOR(i, a, b) for( int i=(a);i<=(b);i++)
#define RFOR(i, a, b) for( int i=(a);i>=(b);i--)
#define LFOR(i, a, b) for( long long int i=(a);i<=(b);i++)
#define LRFOR(i, a, b) for(long long int i=(a);i>=(b);i--)
#define MOD 1000000007
#define INF 1000000000 //2000000000
#define LLINF 1000000000000000000 //9000000000000000000
#define PI 3.14159265358979
#define MAXI 7500000

using namespace std;
typedef long long int ll;
typedef pair< long long int, long long  int> P;

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

int main(void){
    int n,m,c;
    int b[21];
    int a[21][21];
    int count=0;
    int point=0;
    cin>>n>>m>>c;
    FOR(i,1,m){
        cin>>b[i];
    }
    FOR(i,1,n){
        FOR(j,1,m){
            cin>>a[i][j];
        }
    }
    FOR(i,1,n){
        point=0;
        point+=c;
        FOR(j,1,m){
            point+=a[i][j]*b[j];
        }
        if(point>0){
            count++;
        }
    }

cout<<count<<endl;
}

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

#define REP(i,num) for(int i=0;i<(num);++i)

using namespace std;
using ll = long long;

int hamming(string& a,string& b){
  int dist = 0;
  for(int i=0,ei=a.size();i<ei;i++){
    dist += (a[i]+b[i])%2;
  }
  return dist;
}

template<typename T=int>
T in(){T x; cin >> x; return (x);}

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

  string S=in<string>();
  int size = S.size();
  string Ap(size,'0'),An(size,'0');
  for(int i=0;i<size;i+=2) Ap[i] = '1';
  for(int i=1;i<size;i+=2) An[i] = '1';
  
  cout << min(hamming(S,Ap),hamming(S,An)) << endl;
  
  return 0;
}

Measured memory_bytes: 592
/*
[agc037] C - Numbers on a Circle
*/

#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;
typedef pair<ll, ll> pll;
#define ALL(c) (c).begin(), (c).end()

const int MAX_N = 2e5;

int N;
int A[MAX_N], B[MAX_N];

ll solve() {
    priority_queue<pii> q;
    for (int i = 0; i < N; i++) {
        q.push({B[i], i});
    }

    ll ans = 0;
    while (!q.empty()) {
        pii p = q.top();
        q.pop();
        int i = p.second;
        int d = B[(i + N - 1) % N] + B[(i + 1) % N];
        int m = (B[i] - A[i]) / d;
        if (m > 0) {
            ans += m;
            B[i] -= m * d;
            if (B[i] > A[i]) {
                q.push({B[i], i});
            }
        }
    }

    for (int i = 0; i < N; i++) {
        if (B[i] != A[i]) {
            return -1;
        }
    }

    return ans;
}

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

    cout << solve() << endl;

    return 0;
}


Measured memory_bytes: 3956
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
#define fi first
#define se second
template<typename A, typename B> inline bool chmax(A &a, B b) { if (a<b) { a=b; return 1; } return 0; }
template<typename A, typename B> inline bool chmin(A &a, B b) { if (a>b) { a=b; return 1; } return 0; }
typedef long long ll;
typedef pair<int, int> pii;
const ll INF = 1e9+100;
const ll INFL = 1e18+100;
const ll MOD = 1e9+7;
const bool debug = 0;
//-----------------------------------------------//

int N, Z, W;
int a[2000];
int dp[2000][2];

int dfs(int idx, int turn) {
	if (~dp[idx][turn]) return dp[idx][turn];
	
	int cur;
	if (idx == 0) cur = !turn ? W : Z;
	else cur = a[idx - 1];
	
	int res;
	if (turn == 0) {
		res = 0;
		FOR(i, idx, N - 1) chmax(res, dfs(i + 1, turn^1));
		chmax(res, abs(cur - a[N - 1]));
	}	
	else {
		res = INF;
		FOR(i, idx, N - 1) chmin(res, dfs(i + 1, turn^1));
		chmin(res, abs(cur - a[N - 1]));
	}
	
	return dp[idx][turn] = res;
}

int main() {
	cin >> N >> Z >> W;
	REP(i, N) scanf("%d", a + i);
	
	memset(dp, -1, sizeof(dp));
	cout << dfs(0, 0) << endl;
	
	return 0;
}


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

template<typename T>
void test(T a){
    return ;
}

signed main(){
    int h, w; cin >> h >> w;
    if( h == 1 || w == 1 ) cout << 1 << endl;
    else cout << (h * w + 1) / 2 << endl;

}

Measured memory_bytes: 256
n,q = map(int,input().split())
s = input()

geta = []
acam = [0]*n
c = 0

for i in range(1,n):
    if s[i-1] == 'A' and s[i] == 'C':
        c += 1
        geta.append(i-1)
    acam[i] = c
    
for i in range(q):
    l , r = map(int,input().split())
    l -= 1
    r -= 1
    print(acam[r] - acam[l])

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

#define int long long
typedef pair<int, int> P;
#define mod 1000000007
#define INF (1LL<<60)
 
#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define repi(itr, ds) for (auto itr = ds.begin(); itr != ds.end(); itr++)
#define YES puts("YES")
#define Yes puts("Yes")
#define NO  puts("NO")
#define No  puts("No")
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
 
const int dx[4] = { 1, 0, -1, 0 };
const int dy[4] = { 0, 1, 0, -1 };
 
 
#if 1
//-------------
// DUMPマクロ
// https://www.creativ.xyz/dump-cpp-652/
 
// vector
template <typename T>
istream& operator>>(istream& is, vector<T>& vec) {
    for (T& x : vec) is >> x;
    return is;
}
// pair
template <typename T, typename U>
ostream& operator<<(ostream& os, pair<T, U>& pair_var) {
    os << "(" << pair_var.first << ", " << pair_var.second << ")";
    return os;
}
// vector
template <typename T>
ostream& operator<<(ostream& os, const vector<T>& vec) {
    os << "{";
    for (int i = 0; i < vec.size(); i++) {
        os << vec[i] << (i + 1 == vec.size() ? "" : ", ");
    }
    os << "}";
    return os;
}
// map
template <typename T, typename U>
ostream& operator<<(ostream& os, map<T, U>& map_var) {
    os << "{";
    repi(itr, map_var) {
        os << *itr;
        itr++;
        if (itr != map_var.end()) os << ", ";
        itr--;
    }
    os << "}";
    return os;
}
// set
template <typename T>
ostream& operator<<(ostream& os, set<T>& set_var) {
    os << "{";
    repi(itr, set_var) {
        os << *itr;
        itr++;
        if (itr != set_var.end()) os << ", ";
        itr--;
    }
    os << "}";
    return os;
}
 
#define DUMPOUT cerr
 
void dump_func() {
    DUMPOUT << endl;
}
template <class Head, class... Tail>
void dump_func(Head&& head, Tail&& ... tail) {
    DUMPOUT << head;
    if (sizeof...(Tail) > 0) {
        DUMPOUT << ", ";
    }
    dump_func(std::move(tail)...);
}
#ifdef _DEBUG
#define DEB
#define dump(...)                                                              \
    DUMPOUT << "  " << string(#__VA_ARGS__) << ": "                            \
            << "[" << to_string(__LINE__) << ":" << __FUNCTION__ << "]"        \
            << endl                                                            \
            << "    ",                                                         \
        dump_func(__VA_ARGS__)
#else
#define DEB if (false)
#define dump(...)
#endif
#endif



signed main() {

    string S;
    cin >> S;

    int ans = 0;
    for(int i=1; i<S.length()/2;i++){
        string t = S.substr(0,i);
        t = t+t;
        if(S.find(t)!=S.npos){
            
            ans=max(ans,i*2);
            cerr << t << endl;
        }
        
    }
    cout << ans << endl;
    
    return 0;
}


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

ll gcd(ll a, ll b){return b!=0 ? gcd(b, a%b) : a;}
ll lcm(ll a, ll b){return a / gcd(a, b) * b;}

int main(){
	int a, b;
  cin >> a >> b;

  if(a > 0 && b > 0){
    cout << "Positive" << endl;
  }
  else if(a < 0 && b < 0){
    ll ans = abs(a - b) + 1;
    if(ans % 2 == 0){
      cout << "Positive" << endl;
    }
    else{
      cout << "Negative" << endl;
    }
  }
  else{
    cout << "Zero" << endl;
  }
	return 0;
}



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

// 型定義
typedef long long ll;
typedef pair<ll, ll> P;

// forループ
#define REP(i,n) for(ll i=0; i<(ll)(n); ++i)

// 定数宣言
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

// グラフ表現
using Graph = vector<vector<int>>;

// グラフの辺表現
using Edge = map<pair<int,int>,int>;

// n次元配列の初期化。第２引数の型のサイズごとに初期化していく。
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

// 最大公約数
ll gcd(ll a,ll b){
   if (a%b == 0) return(b);
   else return(gcd(b, a%b));
}

// 最小公倍数
ll lcm(ll a, ll b){
    return a*b/gcd(a, b);
}

int main()
{
    cout << fixed << setprecision(15);
    string a, b;
    cin >> a >> b;

    ll N = stoi(a+b);

    for(ll i=1; i<=ll(sqrt(N)); i++){
        if(N%i == 0){
            if(i == N/i){
                cout << "Yes" << endl;
                return 0;
            }
        }
    }
    cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
open System.Collections.Generic

type Scanner() = class
    let mutable hold = [||]
    let mutable index = 0
    member public this.Next() =
        if hold.Length > index
        then 
            index <- index + 1
            hold.[index - 1]
        else
            let mutable st = stdin.ReadLine()
            while st = "" do st <- stdin.ReadLine()
            hold <- st.Split(' ')
            if hold.Length = 0
            then
                this.Next()
            else
                index <- 1
                hold.[index - 1]
            
    member public this.NextI32() =
        this.Next() |> int

    member public this.ArrayI32(n: int) =
        [|for _ in 0 .. n - 1 -> this.NextI32()|]

    member public this.IArrayI32(n: int) =
        [|for i in 0 .. n - 1 -> this.NextI32(), i|]

    member public this.NextI64() =
        this.Next() |> int64
    
    member public this.ArrayI64(n: int) =
        [|for _ in 0 .. n - 1 -> this.NextI64()|]

    member public this.IArrayI64(n: int) =
        [|for i in 0 .. n - 1 -> this.NextI64(), i|]

    member public this.NextF32() =
        this.Next() |> float32
    
    member public this.ArrayF32(n: int) =
        [|for _ in 0 .. n - 1 -> this.NextF32()|]

    member public this.IArrayF32(n: int) =
        [|for i in 0 .. n - 1 -> this.NextF32(), i|]

    member public this.NextF64() =
        this.Next() |> double
    
    member public this.ArrayF64(n: int) =
        [|for _ in 0 .. n - 1 -> this.NextF64()|]

    member public this.IArrayF64(n: int) =
        [|for i in 0 .. n - 1 -> this.NextF64(), i|]

    member public __.Tuple2Array n (f : int -> 'a list) =
        [|for _ in 0 .. n - 1 -> f 2 |> fun x -> x.[0], x.[1]|]
    
    member public __.Tuple3Array n (f : int -> 'a list) =
        [|for _ in 0 .. n - 1 -> f 3 |> fun x -> x.[0], x.[1], x.[2]|]

    member public __.CountDic n (f : unit -> 'a) =
        let seqs = seq {for _ in 0 .. n - 1 -> f()}
        let dic = new Dictionary<'a, int64>();
        for i in seqs do
            if dic.ContainsKey(i)
            then dic.[i] <- dic.[i] + 1L
            else dic.Add(i, 1L)
        dic

end

[<EntryPoint>]
let main _ =
#if DEBUG
    printfn "debuged"
#endif

    let scanner = Scanner()
    let n = scanner.NextI32()
    let csf = [|for _ in 0..n-2 -> scanner.NextI64(), scanner.NextI64(), scanner.NextI64()|]
    let func1 i (arr: (int64 * int64 * int64) array) =
        let (c, s, _) = arr.[i]
        let next = c + s
        let rec func2 ns =
            function
            | x when x = n - 1 -> ns
            | x ->
                let (cc, ss, ff) = arr.[x]
                let iss = if ss > ns then ss else ns
                let iff = if iss % ff = 0L then iss else iss + ff - iss % ff
                func2 (iff + cc) (x + 1)
        func2 next (i + 1)

    if n <> 1 then
        [|for i in 0..n-2 -> func1 i csf|]
        |> Array.iter (printfn "%i")

    printfn "0"

    0


Measured memory_bytes: 14172
#include<bits/stdc++.h>
using namespace std;
int main()
{
    double w, h, x, y;
    cin >> w >> h;
	cin >> x >> y;
	int num = (x == w / 2 && y == h / 2) ? 1 : 0;
    double ans;
	ans = (double)w * h / 2.0;
	printf("%.10f %d\n", ans, num);
	return 0;
}


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

using namespace std;


int main() {
 long long int a,b[100010],c,d;
  
  cin >> a;
  
  for(int i=0;i<a;i++)
    cin >> b[i];
  
  
  for(int i=0;i<a-1;i++){
    
    if(b[i] >=b[i+1]){
      c++;
    }
    
    else if(b[i] < b[i+1]){
     
      c =0;
    }
    d = max(c,d);
  }
  
  cout << d << endl;
  
}
    


Measured memory_bytes: 1024
import qualified Data.ByteString.Char8 as BS

main = do
    ss <- BS.getLine
    let m = BS.length ss `div` 2
    let (a,b) = BS.splitAt m ss
    let c = if even $ BS.length ss then b else BS.tail b
    print $ sum $ BS.zipWith eq2n a $ BS.reverse c

eq2n a b = 1 - fromEnum (a == b)

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

typedef long long ll;
#define IO ios_base::sync_with_stdio(0);cin.tie(0); cout.tie(0);
#define endl '\n'
const int N = 1e5 + 5;
using namespace std;

int main() {
    IO;
    ll n, sum = 0, t;
    map<ll, ll> cnt;
    cin >> n;
    for (int i = 0; i < n; ++i) {
        ll x;
        cin >> x;
        cnt[x]++;
        sum += x;
    }
    cin >> t;
    while (t--) {
        ll i, x;
        cin >> i >> x;
        auto it = cnt.find(i);
        if (it == cnt.end()) {
            cout<<sum<<endl;
            continue;
        }
        sum -= (it->first * it->second);
        sum += (x * it->second);
        cnt[x] += it->second;
        cnt[i] = 0;
        cout << sum << endl;
    }


}

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

using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef pair<int, int> Pii;
typedef pair<int, ll> Pil;
typedef pair<ll, ll> Pll;
typedef pair<ll, int> Pli;

#define fi first
#define se second

const ll MOD = 1e9 + 7;
const ll MOD2 = 998244353;
const ll MOD3 = 1812447359;
const ll INF = 1ll << 62;
const double PI = 2 * asin(1);

void yes() {printf("yes\n");}
void no() {printf("no\n");}
void Yes() {printf("Yes\n");}
void No() {printf("No\n");}
void YES() {printf("YES\n");}
void NO() {printf("NO\n");}

int main(){
  int A, B; char C;
  cin >> A >> C >> B;
  if (C == '+') cout << A + B << endl;
  else cout << A - B << endl;
  
  return 0;
}


Measured memory_bytes: 3624
# include <iostream>
# include <cmath>
# include <algorithm>
# include <stdio.h>
# include <cstdint>
# include <cstring>
# include <string>
# include <cstdlib>
# include <vector>
# include <bitset>
# include <map>
# include <queue>
# include <ctime>
# include <stack>
# include <set>
# include <list>
# include <random>
# include <deque>
# include <functional>
# include <iomanip>
# include <sstream>
# include <fstream>
# include <complex>
# include <numeric>
# include <immintrin.h>
# include <cassert>
# include <array>
# include <tuple>
# include <unordered_set>
# include <unordered_map>
using namespace std;


int n;
string s;
int dp[200005][2];


int main(int argc, const char * argv[]) {
#ifdef __APPLE__
    freopen("/Users/danya.smelskiy/Documents/Danya/Resources/input.txt","r",stdin);
#endif
    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    cin >> n;
    cin >> s;
    for (int i = 1; i <= n; ++i) {
        dp[i][0] = dp[i - 1][0];
        dp[i][1] = dp[i - 1][1];
        if (s[i - 1] == '#') ++dp[i][0];
        else ++dp[i][1];
    }
    int ans = min(dp[n][0], dp[n][1]);
    for (int i = n - 1; i > 0; --i) {
        int cur = dp[i][0] + dp[n][1] - dp[i][1];
        ans = min(ans, cur);
    }
    cout << ans << '\n';
}



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

int n;
string s;

int main(void){
    cin >> n;
    cin >> s;
    int res = 0;
    for(int i = 0; i < s.size(); i++){
        string x, y;
        x = s.substr(0, i);
        y = s.substr(i);
        unordered_map<char, int> mx, my;
        for(auto j : x) mx[j] = 1;
        for(auto j : y) my[j] = 1;
        int tmp = 0;
        for(char c = 97; c <= 122; c++){
            tmp += mx[c]*my[c];
        }
        res = max(res, tmp);
    }
    cout << res << endl;
    return 0;
}


Measured memory_bytes: 3604
use proconio::input;

fn main() {
    input! {
        n: usize,
        a: i32,
        b: i32,
        p: [i32; n],
    }

    let mut count = [0; 3];
    for p in p {
        if p <= a {
            count[0] += 1;
        } else if p <= b {
            count[1] += 1;
        } else {
            count[2] += 1;
        }
    }

    if let Some(ans) = count.iter().min() {
        println!("{}", ans);
    }
}


Measured memory_bytes: 2152
#include<stdio.h>
#include<algorithm>
#include<functional>
#include<cmath>
using namespace std;
long long  mod = 1000000007;
int main()
{
	long long L, R;
	int an = 2019;
	scanf("%lld%lld", &L, &R);
	if (R - L >= 2019) {
		printf("0");
		return 0;
	}
	L = L % 2019;
	R = R % 2019;
	if (L > R) {
		printf("0");
	}
	else {
		for (int i = L; i < R; i++) {
			for (int j = i + 1; j <= R; j++) {
				if (i * j % 2019 < an) {
					an = i * j % 2019;
				}
				if (an == 0) {
					printf("0");
					return 0;
				}
			}
		}
		printf("%d", an);
	}
	return 0;
}


Measured memory_bytes: 128
#include <stdio.h>
#include <iostream>
#include <vector>
#include <cstdlib> 
#include <cmath>
#include <algorithm>
#include <sstream>
#include <string>
using namespace std;

int main() {
	int a, b, x;
	cin >> a >> b >> x;
	
	if ((a + b >= x) && (a <= x)) {
		cout << "YES" << endl;
		return 0;
	}
	cout << "NO" << endl;
}

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

using namespace std;

#define F first
#define S second
#define modulo ll (1e9 + 7)

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

void init(){
    cin.tie(0);
    cin.sync_with_stdio(0);
}

const int N = 5e3 + 9, M = 5e3 + 9, OO = 0x3f3f3f3f;
const ll llOO = 0x3f3f3f3f3f3f3f3f;



int main(){
    init();

    int n, m;   cin >> n >> m;
    pii a[n], b[m];
    for(int i = 0;i < n;i++)    cin >> a[i].F >> a[i].S;
    for(int i = 0;i < m;i++)    cin >> b[i].F >> b[i].S;

    for(int i = 0;i < n;i++){
        int idx, x = a[i].F, y = a[i].S, dist = OO;
        for(int i = 0;i < m;i++){
            int d = abs(x - b[i].F) + abs(y - b[i].S);
            if(d < dist){
                dist = d;
                idx = i;
            }
        }
        cout << idx + 1 << '\n';
    }



}

Measured memory_bytes: 256
n = int(input())
lis = [list(map(int,input().split())) for i in range(n)]
li = []
for i in range(n):
  if lis[i][-1] != 0:li.append(lis[i])
ans = []
for i in range(101):
  for j in range(101):
    H = abs(li[0][0]-i)+abs(li[0][1]-j)+li[0][2]
    key = 0
    for x,y,h in lis:
      if max(0,H- abs(x-i)-abs(y-j)) != h:
        key = 1
    if key == 0:ans.append([i,j,H])
if len(ans) == 1:
  print(ans[0][0],ans[0][1],ans[0][2])


Measured memory_bytes: 3064
#include <iostream>

using namespace std;

int main(void)
{
	while(1){
		int n;
		cin >> n;
		if (n == 0){
			break;
		}
		int s, sum=0, maxi, mini;
		cin >> s;
		maxi = s;
		mini = s;
		sum += s;
		for(int i=1;i<n;i++){
			cin >> s;
			maxi = max(maxi, s);
			mini = min(mini, s);
			sum += s;
		}
		sum -= (maxi + mini);
		cout << sum/(n-2) << endl;
	}
	return 0;
}


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

using namespace std;

int n,m;
vector <int> adj[10007];
int in[10007];
queue <int> q;

int main()
{
    cin>>n>>m;
    for(int i=0;i<m;i++)
    {
        int x,y;
        cin>>x>>y;
        in[y]++;
        adj[x].push_back(y);
    }

    for(int i=0;i<n;i++)
        if(in[i]==0)
            q.push(i);

    while(q.size()>0)
    {
        int x=q.front();
        q.pop();
        in[x]=-1;
        cout<<x<<" ";
        for(int i=0;i<adj[x].size();i++)
        {
            in[adj[x][i]]--;
            if(in[adj[x][i]]==0)
                q.push(adj[x][i]);
        }
    }
}

Measured memory_bytes: 1892
#include <iostream>
    using namespace std;
     
    int main() {
    	int D, N; cin >> D >> N;
     
    	int S = 1; for (int i = 0; i < D; i++) S *= 100;
    	if (N <= 99) {
    		cout << S * N << endl;
    	}
    	else {
    		cout << S * 101 << endl;
    	}
    	return 0;
    }

Measured memory_bytes: 256
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
typedef long long ll;
// #include<C:\Users\J\Desktop\AC\athead.h>
#define showa(v) for(int iii = 0; iii < v.size(); iii++){ cout << v[iii] << " ";} cout << endl;
#define show(iiii) cout << iiii << endl; 
#define shows(iiiii) cout << iiiii << " ";
#include<iostream>
#include<string>
#include<vector>
#include<stdio.h>
#include <cmath>
#include <cstdlib>
#include <cassert>
#include <algorithm>
#include <set>
#include <deque>
#include <numeric>
#include<tuple>
#include <utility>
#include <map>
#include <cassert>
using namespace std;
 
int main(){
    long long int a, b, k;
    cin >> a >> b >> k;
    // cout << k << endl;
    if(a <= k){
        
        k -= a;
        a = 0;
        if(b <= k){
            b = 0;
        }
        else{
            b -= k;
        }
    }
    else{
        a -= k;
    }
    cout << a << " " << b << endl;
 }

Measured memory_bytes: 256
#include<stdio.h>
#include<math.h>
int main(){
	int h,w,x;
	char c[99];
	scanf("%d %d",&h, &w);
	for(int i=0; i<h; i++){
	scanf("%s", c);
	printf("%s\n%s\n", c, c);
	}	
}



Measured memory_bytes: 128
using System;
using System.Collections.Generic;
using System.Linq;
using static Input;

public class Prog
{
    private const int INF = 1000000007;
    private const long INFINITY = 100000000000007;
    public static void Main()
    {
        int N = NextInt();
        int M = NextInt();
        //辺の重みを逆転させれば実質的な最大なのでは...？
        int[] a = new int[M];
        int[] b = new int[M];
        long[] c = new long[M];
        for (int i = 0; i < M; i++)
        {
            a[i] = NextInt() - 1;
            b[i] = NextInt() - 1;
            c[i] = -NextInt();
        }

        long[] cost = Enumerable.Repeat<long>(INFINITY, N).ToArray();
        cost[0] = 0;
        BellmanFord(cost, a, b, c);
        long ans = -cost[N - 1];
        BellmanFord(cost, a, b, c);
        if (ans == -cost[N - 1]) { Console.WriteLine(ans); }
        else Console.WriteLine("inf");
    }
    private static void BellmanFord(long[] cost, int[] s, int[] g, long[] c)
    {
        for (int i = 0; i < cost.Length; i++)
        {
            for (int j = 0; j < s.Length; j++)
            {
                cost[g[j]] = Math.Min(cost[g[j]], cost[s[j]] + c[j]);
            }
        }
    }
}

public class Input
{
    private static Queue<string> q = new Queue<string>();
    private static void Confirm() { if (q.Count == 0) foreach (var s in Console.ReadLine().Split(' ')) q.Enqueue(s); }
    public static int NextInt() { Confirm(); return int.Parse(q.Dequeue()); }
    public static long NextLong() { Confirm(); return long.Parse(q.Dequeue()); }
    public static string NextString() { Confirm(); return q.Dequeue(); }
    public static double NextDouble() { Confirm(); return double.Parse(q.Dequeue()); }
    public static int[] LineInt() { return Console.ReadLine().Split(' ').Select(int.Parse).ToArray(); }
    public static long[] LineLong() { return Console.ReadLine().Split(' ').Select(long.Parse).ToArray(); }
    public static string[] LineString() { return Console.ReadLine().Split(' ').ToArray(); }
    public static double[] LineDouble() { return Console.ReadLine().Split(' ').Select(double.Parse).ToArray(); }
}

Measured memory_bytes: 13396
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define Rep(i, m,n) for (int i = m; i < (int)(n); i++)
int main(){
  int A,B,C;
  cin>>A>>B>>C;
  cout<<C;
  cout<<' ';
  cout<<A;
  cout<<' ';
  cout<<B<<endl;






}

Measured memory_bytes: 256
s=input()
k=int(input())
if s[0]!='1':
  print(s[0])
else:
  cnt=0
  idx=0
  for i in range(len(s)):
    if s[i]=='1':
      cnt+=1 
    else:
      idx=i
      break
  if cnt>k-1:
    print('1')
  else:
    print(s[idx])
    
    
  
    
    

    


Measured memory_bytes: 2940
#include <iostream>
#include <string>
#include <vector>
#include <cstdlib>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <map>
#include <stack>
#include <queue>
#include <set>
#include <cstring>

using namespace std;
// ascending order
#define vsort(v) sort(v.begin(), v.end())
// descending order
#define vsort_r(v) sort(v.begin(), v.end(), greater<int>())
// ascending order
#define asort(array, N) sort(array, array + N)
// descending order
#define asort_r(array, N) sort(array, array + N, greater<int>())
#define vunique(v) v.erase(unique(v.begin(), v.end()), v.end())
#define mp make_pair
#define ts(x) to_string(x)
typedef long long ll;
typedef pair<int, int> P;
const ll INF = 1e18;

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int N, K;
	cin >> N >> K;
	if(N == 1) {
		cout << K << endl;
		return 0;
	}
	int rslt = K * pow(K - 1, N - 1);
	cout << rslt << endl;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
using namespace std;
typedef long long int64;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const int INF = 1<<29;
const long long  INFL = 1e18;
const int MOD = 1000000007;
const int MAX = 210000;
const int MAX_NUM = 999999999;
void solve() {
	int n; cin >> n;
	vector<int> a(n);
	for (int i = 0; i < n; ++i) {
		cin >> a[i];
	}
	while(a.size() != 1) {
		sort(all(a));
		for (int i = 1; i < a.size(); ++i) {
			a[i] %= a[0];
		}
		a.erase(remove(all(a), 0), a.end());
	}
	cout << a[0] << endl;
	return;
}
int main() {
	solve();
	return 0;
}

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

using namespace std;

int main(){
	int n,l;
	cin >> n;
	l = n % 10;
	if(l == 3) cout << "bon" << '\n';
	else if(l == 0 || l ==1|| l ==6 || l == 8) cout << "pon" << '\n';
	else cout << "hon" << '\n';
	return 0;
}

Measured memory_bytes: 3624
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {


		Scanner sc = new Scanner(System.in);
		long n = sc.nextLong();
		long a = sc.nextLong();
		long b = sc.nextLong();
		long answer = 0;
		long warizan = n /(a + b);
		answer += (warizan * a);
		long amari = n % (a + b);
		if(amari >= a) {
			answer += a;
		}else {
			answer += amari;
		}
		System.out.println(answer);
	}
}

Measured memory_bytes: 21844