akhauriyash/Code-Regression huggingface dataset:
#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 pb emplace_back
typedef long long ll;
typedef pair<int,int> pint;

const int max_n=1000010;
bool is_prime[max_n];
int prime[max_n];
int sieve(int n){
    int p=0;
    rep(i,n+1) is_prime[i]=true;
    is_prime[0]=is_prime[1]=false;
    FOR(i,2,n+1){
        if(is_prime[i]){
            prime[p++]=i;
            for(int j=2*i;j<=n;j+=i) is_prime[j]=false;
        }
    }
    return p;
}
int g[1005][1005];
pint dp[1005][1005];
pint id[1000010];
const int dx[]={1,0,-1,0},dy[]={0,-1,0,1};
const int dx2[]={-1,0,1},dy2[]={1,1,1};
int m,n;
pint dfs(int cur){
    int x=id[cur].first,y=id[cur].second;
    if(dp[y][x].first!=-1) return dp[y][x];
    pint ret={0,0};
    if(is_prime[cur]) ret={0,cur};
    rep(i,3){
        int tx=x+dx2[i],ty=y+dy2[i];
        if(ty>=0&&tx>=0&&g[ty][tx]!=0&&g[ty][tx]<=m){
            pint r=dfs(g[ty][tx]);
            if(is_prime[g[ty][tx]])r.first+=1;
            ret=max(ret,r);
        }
    }
    return dp[y][x]=ret;
}
int main(){
    sieve(1000009);
    int cnt=1,cur=-1;
    int cx=500,cy=500;
    while(cnt!=1000001){
        id[cnt]={cx,cy};
        g[cy][cx]=cnt++;
        if(g[cy+dy[(cur+1)%4]][cx+dx[(cur+1)%4]]==0) cur=(cur+1)%4;
        cx+=dx[cur],cy+=dy[cur];
    }
    /*FOR(i,490,510){
        FOR(j,490,510) cout<<g[i][j]<<" ";
        cout<<endl;
    }*/
    while(cin>>m>>n,m|n){
        rep(i,1001)rep(j,1001) dp[i][j]={-1,-1};
        pint ans=dfs(n);
        cout<<ans.first+is_prime[n]<<" "<<ans.second<<endl;
    }
    return 0;
}


Measured memory_bytes: 24084
import sys


def input(): return sys.stdin.readline().strip()
def I(): return int(input())
def LI(): return list(map(int, input().split()))


# 条件を満たすかどうか
def is_ok(l, i, key):
    # ここが条件
    if l[i] >= key:
        return True


def binary_seach(l, key) -> int:
    left = -1
    right = len(l)

    while right - left > 1:
        mid = left + (right - left) // 2
        if is_ok(l, mid, key):
            right = mid
        else:
            left = mid

    return right


n = I()
l = LI()
l = sorted(l)
ans = 0
for i in range(n - 2):
    # 三角形のうち一番短い辺
    a = l[i]
    for j in range(i + 1, n - 1):
        # 三角形のうち二番目に短い辺
        b = l[j]
        # 三角形の中で一番大きい辺 かつ
        # a + b より小さい辺 を二分探索で探す
        # a + b 以上の要素の初めのindexを取得
        ind = binary_seach(l, a + b)
        # b 以上の辺のうち、a + b より小さい要素の数を足す
        ans += ind - j - 1
print(ans)


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

using namespace std;

int main() {
    int N, W;
    cin >> N >> W;
    vector<int> dp(W+2000);
    for (int i = 0; i < N; i++) {
        int v, w;
        cin >> v >> w;
        for (int j = W-1; j >= 0; j--) {
            dp[j+w] = max(dp[j+w], dp[j]+v);
        }
    }
    cout << dp[W] << endl;
}


Measured memory_bytes: 3168
from collections import Counter

N = int(raw_input())

points = [map(int, raw_input().split()) for _ in xrange(N)]

if N == 1:
    print 1
else:
    dist = lambda p1, p2: (p1[0]-p2[0], p1[1]-p2[1])

    vecs = []
    for i in xrange(N):
        for j in xrange(N):
            if j == i:
                continue
            vecs.append(dist(points[i], points[j]))

    vecs_cnt = Counter(vecs)
    # print Counter(vecs)
    ans = max(vecs_cnt.values())

    print N-ans

Measured memory_bytes: 3320
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define deb(x)	cout <<#x <<" = "<< x <<"\n"
#define ff              first
#define ss              second
#define ll             	long long
#define pb              push_back
#define mp              make_pair
#define pii             pair<int,int>
#define vi              vector<int>
#define mii             map<int,int>
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define mod             1000000007
#define inf             1e18
#define mk(arr,n,type)  type *arr=new type[n];
#define w(x)            int x; cin>>x; while(x--)


int main()
{
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    int arr[5];
    for(int i = 0 ; i < 5 ; i++){
		cin >> arr[i];
		if(arr[i] == 0){
			cout << i+1 <<endl;
		}
	}    
    return 0;
}


Measured memory_bytes: 3592
#include<iostream>
#include<algorithm>
#include<cmath>
#include<cstring>
#include<set>
#include<map>
#include<vector>
#include<queue>
#include<deque>
#define ll long long
#define mp make_pair
using namespace std;
int main(){
	string s;
	cin>>s;
	sort(s.begin(),s.end());
	if(s[0]==s[1] and s[2]==s[3] and s[1]!=s[2]) cout<<"Yes";
	else cout<<"No";
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define Rep(i,s,n) for(int i=s;i<n;i++)
#define fi first
#define se second
#define all(c) c.begin(),c.end()
typedef long long int ll;
typedef pair<int, int> P;
typedef long double ld;
void Ans(bool x){if(x) cout<<"Yes"<<endl;else cout<<"No"<<endl;}

const ll INF=1001001001;
const ll mod=1000000007;

int main(){
  ll n;
  cin>>n;
  
  ll a[n+1];
  
  ll s=0;
  
  ll now=1;
  int c=0;
  
  rep(i,n+1){
    cin>>a[i];
    s+=a[i];
  }
  s--;

    
    ll ans=0;
    rep(i,n+1){
      ans+=now;
      //cout<<ans<<" "<<s<<endl;
      now-=a[i];
      if(now<0) c++;
      
      if(s>0){
      if(s>=now){
        s-=now;
        now*=2;
      }
      else if(s<=now){
        now+=s;
        s=0;
      }
      }
      
    }
    if(c!=0||s>0){
    cout<<-1<<endl;
  }
  else cout<<ans<<endl;
}
  
  
  

Measured memory_bytes: 4420
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
template<class T, class U> inline bool chmax(T& a,U b) { if (a < b) { a = b; return 1; } return 0; }
template<class T, class U> inline bool chmin(T& a,U b) { if (a > b) { a = b; return 1; } return 0; }

int main() {
    long long a;
    cin >> a;
    long long ans = (a / 500) * 1000;
    a %= 500;
    ans += (a / 5) * 5;
    cout << ans << endl;
    return 0;
}

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

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

using namespace std;
using ll = long long;

const double PI = 3.14159265358979;

void solve()
{
  string s, t;
  cin >> s >> t;
  sort(ALL(s));
  sort(RALL(t));
  cout << (s < t ? "Yes" : "No");
}

int main()
{
  fastio;
  solve();

  return 0;
}

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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)

long long int calc(long long int n)
{
     return n * (n-1) / 2;
}

int main() {
    int n;
    cin >> n;
    vector<int> a(n);
    rep(i, n) cin >> a[i];

    map<int,int> m;
    vector<int> num;

    rep(i, n){
        if(m.find(a[i]) == m.end()){
            m.insert(make_pair(a[i], m.size()));
            num.push_back(1);
        }else{
            ++num[m[a[i]]];
        }
    }
    long long int base_answer = 0;
    for(std::map<int,int>::iterator itr = m.begin(); itr != m.end(); ++itr){
        base_answer += calc(num[itr->second]);
    }
    cerr << base_answer << endl;

    rep(i, n){
        long long int ans = base_answer;
        ans -= calc(num[m[a[i]]]);
        ans += calc(num[m[a[i]]]-1);
        cout << ans << endl;
    }
    return 0;    
}


Measured memory_bytes: 8824
#include <bits/stdc++.h>
#define ll long long int
#define ld long double
#define pb push_back
#define pll pair<ll, ll> 
#define vi vector<int>
#define vl vector<ll> 
#define vvl vector< vector<ll> > 
#define vvi vector< vector<int> >
#define vlp vector< pair<ll, ll> >
#define vllp vector<pair<ll, ll>, ll > 
#define mll map<ll, ll> 
#define rep(i,a)  for(ll i=0; i< a; i++)
#define rep1(i,a)   for(ll i = 1; i< a; i++)
#define foi(i, a, b)    for(ll i = a; i<b ; i++)
#define fod(i, a, b)    for(ll i = a; i>=b ; i--)
#define mp make_pair
#define fst first
#define sec second
#define ff first.first
#define fs first.second
#define pi pair<int, int>
#define ppi pair<pair<int, int>, int>
#define max3(a, b, c)   max(max(a, b), c)
#define min3(a, b, c)   min(min(a, b), c)
#define MAX 1000001
#define MOD 1000000007
#define INF (ll)1e18
#define s(v) v.size()
#define e(v) v.empty()

using namespace std;

ll gcd(ll a, ll b){if(b==0)return a;return gcd(b, a%b);}
ll lcm(ll a, ll b){return a*b/gcd(a, b);}
ll fexp(ll a, ll b){ll ans = 1;while(b){if(b&1) ans = ans*a%MOD; b/=2;a=a*a%MOD;}return ans;}
ll inverse(ll a, ll p){return fexp(a, p-2);}
// bool sortbysec(const pll &a, const pll &b){return (a.second < b.second);} 
void ingraph(vvl& graph, ll m){ll x, y;rep(i, m){cin>>x>>y;x--, y--;graph[x].pb(y);graph[y].pb(x);}}

int main(){
    // #ifndef ONLINE_JUDGE
    //     freopen("../input.txt", "r", stdin);
    //     freopen("../output.txt", "w", stdout);
    // #endif
    ios::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    ll t;
    // cin>>t;
    t = 1;
    while(t--){
        ll n;
        cin>>n;
        ll cnt = 0;
        ll x;
        rep(i, n){
            cin>>x;
            if(x != i+1)    cnt++;
        }
        if(cnt > 2) cout<<"NO";
        else cout<<"YES";
    }
}

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

int N;
int H[101];
int Max[101];

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

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

    Max[0] = H[0];
    for (int i = 1; i < N; i++) {
        Max[i] = Max[i-1];
        if (Max[i-1] < H[i]) Max[i] = H[i];
    }

    int ans = 1;
    for (int i = 1; i < N; i++) {
        if (Max[i] <= H[i]) ans++;
    }

    cout << ans << endl;
}

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

int main(){
	long long int n;
	cin >> n;
	vector<long long int> v(n);
	
	long long int sum =0;
	long long int even_sum = 0;
	for(int i=0;i<n;++i){
		cin >> v[i];
		sum += v[i];
		if(i%2 == 1) even_sum += v[i];
	}
	
	
	long long int a = sum - 2 * even_sum;
	vector<long long> res(n);
	res[0] = a;
	for(int i=1;i<n;++i){
		res[i] = 2*v[i-1] - res[i-1];
	}
	
	cout << res[0];
	for(int i=1;i<n;++i){
		cout << " " << res[i];
	}
	cout << endl;
	
	return 0;
}



Measured memory_bytes: 2944
if True:
    N = int(input())
    As = list(map(int, input().split()))

    maxA = 10**6 + 6
    c = [0] * (maxA+1)
    for A in As:
        c[A] += 1
    isPrime = True
    cnt = 0
    for i in range(2, maxA+1):
        cnt = sum(c[i::i])
        if cnt == N:
            # Asはすべてiの約数
            print("not coprime")
            break
        if cnt >= 2:
            isPrime = False
        
    else:
        if isPrime:
            print("pairwise coprime")
        else:
            print("setwise coprime")





Measured memory_bytes: 212808
#include <stdio.h>
int main()
{
int a,b;

scanf("%d %d",&a,&b);

if(a<b){
  printf("a < b\n");
}else if(a>b){
  printf("a > b\n");
}else if(a==b){
  printf("a == b\n");
}

  return 0;
}


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

using namespace std;

const long long MOD = 1e9+7;
map<long long,long long> dp;
long long ans(long long x){
    if(dp[x]){
        return dp[x];
    }
    
    return dp[x] = ((ans(x/2)+ans((x-1)/2))%MOD+ans((x-2)/2))%MOD;
}
int main()
{
    long long n;
    cin>>n;
    dp[0] = 1;
    dp[1] = 2;
    cout<<ans(n)<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
using P = pair<int,int>;


int main(void){
    ll n, k; cin >> n >> k;
    vector<ll> a(n);

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

    vector<int> num0(dig);
    vector<int> num1(dig);

    for(int d = 0; d < dig; d++){
        for(int i = 0; i < n; i++){
            if((a[i] >> d) & 1LL) num1[d]++;
            else num0[d]++;
        }
    }

    ll x = 0;
    for(int d = dig; d >= 0; d--){
        if((num1[d] < num0[d]) && (x + (1LL << d) <= k)){
            x += (1LL << d);
        }
    }

    ll ans = 0;
    for(int i = 0; i < n; i++){
        ans += (x ^ a[i]);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 4052
import java.util.Scanner;


public class Main {

	final int DAY_MONTH[]={0, 31, 28, 31, 30, 31, 30, 31, 31, 30 ,31, 30 ,31};
	
	Scanner sc;
	
	int isLeap(int y){
		if(y%4==0){
			if(y%100==0){
				if(y%400==0){
					return 1;
				}
				else{
					return 0;
				}
			}
			else{
				return 1;
			}
		}
		else{
			return 0;
		}
	}
	
	int dayCount(int y, int m1, int d1, int m2, int d2){
		int days=-d1;
		for(int m=m1;m<=m2;++m){
			days+=DAY_MONTH[m];
			if(m==2) days+=isLeap(y);
		}
		days-=DAY_MONTH[m2]+(m2==2?isLeap(y):0)-d2;
		return days;
	}
	
	int solve(int y1, int m1, int d1, int y2, int m2, int d2){
		int days=0;
		if(y2-y1>=2){
			for(int y=y1+1;y<y2;++y){
				days+=365+isLeap(y);
			}
		}
		if(y2-y1>=1){
			days+=dayCount(y1, m1, d1, 12, 31)+dayCount(y2, 1, 1, m2, d2)+1;
		}
		else{
			days=dayCount(y1, m1, d1, m2, d2);
		}
		return days;
	}
	
	int ni(){
		return sc.nextInt();
	}
	
	void io(){
		sc=new Scanner(System.in);
		
		while(true){
			int y1=ni(), m1=ni(), d1=ni(), y2=ni(), m2=ni(), d2=ni();
			if(y1<0||m1<0||d1<0||y2<0||m2<0||d2<0) break;
			
			System.out.println(solve(y1, m1, d1, y2, m2, d2));
		}
		
		sc.close();
	}
	
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		new Main().io();
	}

}

Measured memory_bytes: 19864
//ｺｯwwｺｯwwｺｹｯwwwｺｯwwｺｹｯwwwｺｹｯｺｯwwwｺｯwwｺｯwwｺｹｯwwwｺｯwwｺｹｯwwwｺｹｯｺｯwwwｺｹｰｰｰｰｯ!!!wwwwwｺｯwwｺｯwwｺｹｯwwwｺｯwwｺｹｯwwwｺｹｯｺｯwwwｺｯwwｺｯwwｺｹｯwwwｺｯwwwｺｹｯwwwｺｹｯｺｯwwwｺｹｰｰｰｰｯ!!!wwwwwｺｹｯｺｯｯｺｰｰｰｰ!!!!!!wwwwwwwwwww
import java.util.*;
public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int m = sc.nextInt();
        int[][] a = new int[2][n];
        int[][] c = new int[2][m];
        for(int i = 0 ; i < n ; i++){
            for(int j = 0 ; j < 2 ; j++){
                a[j][i] = sc.nextInt();
            }
        }
        for(int i = 0 ; i < m ; i++){
            for(int j = 0 ; j < 2 ; j++){
                c[j][i] = sc.nextInt();
            }
        }
        for(int i = 0 ; i < n ; i++){
            int yono = 0;
            for(int j = 0 ; j < m ; j++){
                if(Math.abs(c[0][yono] - a[0][i]) + Math.abs(c[1][yono] - a[1][i]) > Math.abs(c[0][j] - a[0][i]) + Math.abs(c[1][j] - a[1][i])){
                    yono = j;
                }
            }
            System.out.println(yono + 1);
        }
    }
}
//ｺｯwwｺｯwwｺｹｯwwwｺｯwwｺｹｯwwwｺｹｯｺｯwwwｺｯwwｺｯwwｺｹｯwwwｺｯwwｺｹｯwwwｺｹｯｺｯwwwｺｹｰｰｰｰｯ!!!wwwwwｺｯwwｺｯwwｺｹｯwwwｺｯwwｺｹｯwwwｺｹｯｺｯwwwｺｯwwｺｯwwｺｹｯwwwｺｯwwwｺｹｯwwwｺｹｯｺｯwwwｺｹｰｰｰｰｯ!!!wwwwwｺｹｯｺｯｯｺｰｰｰｰ!!!!!!wwwwwwwwwww

Measured memory_bytes: 35864
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		int l=sc.nextInt(),r=sc.nextInt();
		sc.close();
		if(r-l>=2018) System.out.println(0);
		else {
			long min=2018;
			for(int i=l;i<r;i++) {
				for(int j=i+1;j<=r;j++) {
					long temp =(long)i*j;
					long mod = temp%2019;
					if(mod<min) min=mod;
				}
			}
			System.out.println(min);
		}
	}
}

Measured memory_bytes: 23764
#include <iostream>
#include <queue>
#include <algorithm>
#include <string>
#include <utility>
#include <vector>
#include <map>
#include <stack>
#include <iomanip>
#include <set>
#include <sstream>
#include <cmath>
#include <deque>
#include <list>
#include <bitset>
using namespace  std;
typedef pair<long long , long long> P;
typedef long long int64;
typedef long long lint;
#define REP(i, n) for(long long (i)=0; (i)<(n); ++i)
#define FOR(i, a, b) for(long long (i)=(a); (i)<(b); ++i)
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define FST first
#define SND second

signed main(){
    int r, g, b, n;
    cin >> r >> g >>b >>n;
    int res = 0;
    REP(i, n/r+1){
        REP(j, n/g+1){
            int tmp = i*r + j*g;
            if(tmp>n) break;
            if((n-tmp) % b == 0 ) res++;
        }
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
long double spi=3.1415926535898*5.00;
int x[200005],y[200005];
int u[200005],t[200005];
struct node
{int x,y;
}p[200005];
int cnt=0;
inline int min(int a,int b){return a<b?a:b;}
inline int max(int a,int b){return a>b?a:b;}
inline bool cmp(node a,node b)
{return a.x<b.x;}
int main (){
	int n,xs,xt,ys,yt,p1=1,p2=1,i,j;
	scanf ("%d%d%d%d",&xs,&ys,&xt,&yt);
	if (xs>xt) {xs*=(-1);xt*=(-1);p1=-1;}
        if (ys>yt) {ys*=(-1);yt*=(-1);p2=-1;}
	scanf ("%d",&n);
	for (i=1;i<=n;i++)
	{scanf ("%d%d",&x[i],&y[i]);x[i]*=p1;y[i]*=p2;}
	for (i=1;i<=n;i++)
	{if (x[i]>=xs&&x[i]<=xt&&y[i]>=ys&&y[i]<=yt)
	{p[++cnt].x=x[i];p[cnt].y=y[i];u[cnt]=y[i];}
	}
	sort(p+1,p+cnt+1,cmp);
	sort(u+1,u+cnt+1);
	for (i=1;i<=cnt;i++)
	{p[i].y=lower_bound(u+1,u+cnt+1,p[i].y)-u;}
	int ans=0;
	for (i=1;i<=cnt;i++)
	{int tp=0;
        for (j=p[i].y;j;j-=(j&(-j))) tp=max(tp,t[j]);
        tp++;
	if (tp>ans) {ans=tp;}
	for (j=p[i].y;j<=cnt;j+=(j&(-j))) t[j]=max(tp,t[j]);
	}
	long double res=(yt-ys+xt-xs)*100.00+ans*(spi-20.0);
	if (ans==min(yt-ys,xt-xs)+1) {res+=spi;}
	printf ("%.15Lf\n",res);
	return 0;
}

Measured memory_bytes: 4992
import Data.Array

main :: IO ()
main = do
  (n:k:_) <- fmap (map read . words) getLine :: IO [Int]
  hs <- fmap (map read . words) getLine :: IO [Int]
  print $ solve n k hs

solve :: Int -> Int -> [Int] -> Int
solve n k hs = dp ! n
  where
    harr = listArray (1, n) hs
    dp = listArray (1, n) $ map f [1..n]
    f :: Int -> Int
    f 1 = 0
    f i = minimum $ map g [(max 1 (i - k))..(i - 1)]
      where g j = dp!j + cost i j
    cost i j = abs (harr!i - harr!j)


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

int main(){
    ll N; cin >> N;
    vector<string> S[5];
    for(int i = 0; i < N; i++){
        string tmps; cin >> tmps;
        if(tmps[0] == 'M') S[0].push_back(tmps);
        else if(tmps[0] == 'A') S[1].push_back(tmps);
        else if(tmps[0] == 'R') S[2].push_back(tmps);
        else if(tmps[0] == 'C') S[3].push_back(tmps);
        else if(tmps[0] == 'H') S[4].push_back(tmps);
    }
    ll num[5];
    for(int i = 0; i < 5; i++) num[i] = S[i].size();

    ll ans = 0;
    for(int i = 0; i < 5; i++){
        for(int j = i + 1; j < 5; j++){
            for(int k = j + 1; k < 5; k++){
                ans += num[i] * num[j] * num[k];
            }
        }
    }
    cout << ans << endl;

}


Measured memory_bytes: 5748
#include<bits/stdc++.h>
using namespace std;
using Int = long long;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}

//INSERT ABOVE HERE
signed main(){
  Int n,k;
  string s;
  cin>>n>>k>>s;
  k--;
  s[k]=tolower(s[k]);
  cout<<s<<endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <math.h>
#include <string>
#include <numeric>
#include <queue>
#include <cstdio>
#include <cstring>
#define ll long long
#define rep(i,n) for(ll i=0;i<n;++i)
#define rep1(i,n) for(ll i=1;i<n;++i)
#define mrep(i,n) for(ll i=n;i>=0;--i)
#define all(a) (a).begin(),(a).end()
#define vl vector<ll>
#define vvl vector<vector<ll> >
#define vb vector<bool>
#define vvb vector<vector<bool> >
#define pl pair<ll,ll>
#define inf 1001001001001001000
//#define mod 1000000007
#define mod 2
#define pi 3.1415926535
using namespace std;
struct __INIT{
    __INIT(){
        cin.tie(0);
        ios::sync_with_stdio(false);
        cout<<fixed<<setprecision(15);
    }
}__init;

// index が条件を満たすかどうか
bool isOK(vector<pl> &a,ll index, ll key) {
    if (a[index].first >= key) return true;
    else return false;
}

// 汎用的な二分探索のテンプレ
ll binary_search(vector<pl> &a,ll key) {
    ll ng = -1; //「index = 0」が条件を満たすこともあるので、初期値は -1
    ll ok = (ll)a.size(); // 「index = a.size()-1」が条件を満たさないこともあるので、初期値は a.size()

    /* ok と ng のどちらが大きいかわからないことを考慮 */
    while (abs(ok - ng) > 1) {
        ll mid = (ok + ng) / 2;

        if (isOK(a,mid, key)) ok = mid;
        else ng = mid;
    }
    return ok;
}

// index が条件を満たすかどうか
bool isOK2(vector<pl> &a,ll index, ll key) {
    if (a[index].first > key) return true;
    else return false;
}

// 汎用的な二分探索のテンプレ
ll binary_search2(vector<pl> &a,ll key) {
    ll ng = -1; //「index = 0」が条件を満たすこともあるので、初期値は -1
    ll ok = (ll)a.size(); // 「index = a.size()-1」が条件を満たさないこともあるので、初期値は a.size()

    /* ok と ng のどちらが大きいかわからないことを考慮 */
    while (abs(ok - ng) > 1) {
        ll mid = (ok + ng) / 2;

        if (isOK2(a,mid, key)) ok = mid;
        else ng = mid;
    }
    return ok;
}

int main(void){
    ll n;
    cin>>n;
    vl a(n);
    vector<pl> pitsu(n);
    rep(i,n){
        cin>>a[i];
        pitsu[i].first = a[i]+i+1;
        pitsu[i].second = 1;
    }
    sort(all(pitsu));
    ll ans = 0;
    rep(i,n){
        if(i+1-a[i] <= 0) continue;
        ll sa = i+1-a[i];
        ll lind = binary_search(pitsu,sa);
        if(lind == n) continue;
        if(pitsu[lind].first == sa){
            ll rind = binary_search2(pitsu,sa);
            if(pitsu[rind].first == sa){
                ans += rind-lind+1;
            }
            else{
                ans += rind-lind;
            }
        }
    }
    cout<<ans<<endl;
}

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

#define lli long long int
#define REP(i,s,n) for(int i=s;i<n;i++)
#define NUM 2520
#define INF (1LL<<50)
#define DEBUG 0
#define mp(a,b) make_pair(a,b)
#define SORT(V) sort(V.begin(),V.end())
#define PI (3.141592653589794)
#define TO_STRING(VariableName) # VariableName
#define LOG(x) if(DEBUG)cout<<TO_STRING(x)<<"="<<x<<" "<<endl;
#define LOG2(x,y) if(DEBUG)cout<<TO_STRING(x)<<"="<<x<<" "<<TO_STRING(y)<<"="<<y<<endl;
#define LOG3(x,y,z) if(DEBUG)cout<<TO_STRING(x)<<"="<<x<<" "<<TO_STRING(y)<<"="<<y<<" "<<TO_STRING(z)<<"="<<z<<endl;
#define LOG4(w,x,y,z) if(DEBUG)cout<<TO_STRING(w)<<"="<<w<<" "<<TO_STRING(x)<<"="<<x<<" "<<TO_STRING(y)<<"="<<y<<" "<<TO_STRING(z)<<"="<<z<<endl;

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

lli cnt[10000100];

void func(long long N){

    REP(i,1,N+1){
        for(lli j=1;i*j <=10000010;j++){
            cnt[i*j]++;
        }
    }

    lli ans = 0;
    REP(i,1,N+1){
        ans += i*cnt[i];
    }

    cout<<ans<<endl;

}

int main(){
    // cout << fixed << setprecision(5);

    long long N;
    scanf("%lld",&N);
    func(N);
    return 0;
}


Measured memory_bytes: 81812
let nil = -1

type node = {
  mutable parent : int;
  mutable left : int;
  mutable right : int;
  mutable depth : int;
  mutable height : int;
}

let make () = {
  parent = nil;
  left = nil;
  right = nil;
  depth = nil;
  height = nil
}

let search_root t n =
  let rec doit i =
    if i = n then nil
    else if t.(i).parent = nil then i
    else doit (i + 1)
  in doit 0

let set_depth t n =
  let rec doit i d =
    t.(i).depth <- d;
    if t.(i).left <> nil then doit t.(i).left (d + 1);
    if t.(i).right <> nil then doit t.(i).right (d + 1);
  in doit (search_root t n) 0

let set_height t n =
  let rec doit i =
    let hl = ref 0 in
    let hr = ref 0 in
    if t.(i).left <> nil then (doit t.(i).left; hl := t.(t.(i).left).height + 1);
    if t.(i).right <> nil then (doit t.(i).right; hr := t.(t.(i).right).height + 1);
    t.(i).height <- (max !hl !hr)
  in doit (search_root t n)

let print t =
  let sibling i =
    if t.(i).parent = nil then nil
    else if t.(t.(i).parent).left <> i && t.(t.(i).parent).left <> nil then t.(t.(i).parent).left
    else if t.(t.(i).parent).right <> i && t.(t.(i).parent).right <> nil then t.(t.(i).parent).right
    else nil
  in
  let degree i = 0 + (if t.(i).left <> nil then 1 else 0) + (if t.(i).right <> nil then 1 else 0) in
  let (p, q) = (print_string, print_int) in
  let print_node i =
    p "node "; q i;
    p ": parent = "; q t.(i).parent;
    p ", sibling = "; q (sibling i);
    p ", degree = "; q (degree i);
    p ", depth = "; q t.(i).depth;
    p ", height = "; q t.(i).height;
    p (if t.(i).parent = nil then ", root" else if t.(i).left = nil && t.(i).right = nil then ", leaf" else ", internal node");
    p "\n"
  in Array.iteri (fun i _ -> print_node i) t

let () =
  let n = read_int () in
  let t = Array.init n (fun _ -> make ()) in
  let rec read i =
    if i < n then begin
      let (id, l, r) = Scanf.scanf "%d %d %d\n" (fun id l r -> (id, l, r)) in
      t.(id).left <- l;
      t.(id).right <- r;
      if l <> nil then t.(l).parent <- id;
      if r <> nil then t.(r).parent <- id;
      read (i + 1)
    end in
  read 0;
  set_depth t n;
  set_height t n;
  print t

Measured memory_bytes: 2276
#include <iostream>
#include <algorithm>
using namespace std;
int main(void){
    int k,c=0;
    cin>>k;
    for(int i=1;i<=k;i++){
        for(int j=1;j<=k;j++){
            if(i%2==0&&j%2!=0)c++;
        }
    }
cout<<c<<endl;
}


Measured memory_bytes: 256
def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    divisors.sort()
    return divisors

n=int(input())
s=make_divisors(n)

if len(s)%2==0:
    k=int(len(s)/2) 
    ans=max((n/s[k]+s[k])-2,0)
    print(int(ans))
else:
    k=int(len(s)/2) 
    ans=min(n/s[k]+s[k]-2,n/s[k+1]+s[k+1]-2)
    print(int(ans))
    

Measured memory_bytes: 3268
#include<stdio.h>
int main()
{
  int a,b[10000],c,d,s,i;
  scanf("%d",&a);
  for(i=0;i<a;i++){
    scanf("%d",&b[i]);
  }
  d=a-1;
  for(i=d;i>=0;i--){
    if (i>0)printf("%d ",b[i]);
    else printf("%d",b[i]);
  }
  printf("\n");
  return 0;
}


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

int main(){
    unsigned long N, M;
    cin >> N >> M;
    deque<deque<bool>> edges(N, deque<bool>(N, true));
    for(unsigned long i = 0, a, b; i < M; ++i){
        cin >> a >> b;
        --a;
        --b;
        edges[a][b] = edges[b][a] = false;
    }
    vector<unsigned long> v(N);
    iota(v.begin(), v.end(), 0);
    unsigned long ans{1};
    for(unsigned long i = 2; i < N; ++i)ans *= i;
    ++ans;
    do for(unsigned long i = 1; i < N; ++i)if(edges[v[i - 1]][v[i]] && --ans)break;
    while(next_permutation(v.begin() + 1, v.end()));
    cout << ans - 1 << endl;
    return 0;
}

Measured memory_bytes: 256
S = input()
head = 0
end = 0

for i in range(len(S)):
    if S[i] == "A":
        head = i
        break

for i in range(len(S) - 1, -1, -1):
    if S[i] == "Z":
        end = i + 1
        break

print(end - head)

Measured memory_bytes: 3516
import sys
def main():
    input = sys.stdin.readline
    N,A,B,C=map(int, input().split())
    S=[input().rstrip() for _ in range(N)]

    MX=2
    dp=[[[[None]*(MX+1) for _ in range(MX+1)] for __ in range(MX+1)] for ___ in range(N+4)]
    dp[0][min(MX,A)][min(MX,B)][min(MX,C)]=1
    for i,s in enumerate(S):
        ni=i+1
        for a in range(MX+1):
            for b in range(MX+1):
                for c in range(MX+1):
                    for j in range(2):
                        na,nb,nc=a,b,c
                        sel=None
                        if s=='AB':
                            if j==0:
                                if b==0: continue
                                na,nb=min(MX,na+1),nb-1
                                sel='A'
                            else:
                                if a==0: continue
                                na,nb=na-1,min(MX,nb+1)
                                sel='B'
                        elif s=='AC':
                            if j==0:
                                if c==0: continue
                                na,nc=min(MX,na+1),nc-1
                                sel='A'
                            else:
                                if a==0: continue
                                na,nc=na-1,min(MX,nc+1)
                                sel='C'
                        elif s=='BC':
                            if j==0:
                                if c==0: continue
                                nb,nc=min(MX,nb+1),nc-1
                                sel='B'
                            else:
                                if b==0: continue
                                nb,nc=nb-1,min(MX,nc+1)
                                sel='C'
                        if dp[i][a][b][c]: dp[ni][na][nb][nc]=(a,b,c,sel)

    flag=False
    ga,gb,gc=0,0,0
    for a in range(MX+1):
        for b in range(MX+1):
            for c in range(MX+1):
                if dp[N][a][b][c]:
                    flag=True
                    ga,gb,gc=a,b,c
    if flag==False:
        print('No')
        return
    print('Yes')
    ans=[]
    for i in range(N,0,-1):
        ga,gb,gc,sel=dp[i][ga][gb][gc]
        ans.append(sel)
    for a in reversed(ans):
        print(a)

if __name__ == '__main__':
    main()

Measured memory_bytes: 342508
import sys
from io import StringIO
import unittest


def resolve():
    # ★get input
    n, m = map(int, input().split())

    demands = [[int(i) for i in input().split()] for j in range(m)]

    # 要望を[1]の昇順で並べ替え(後述する[1]-1の場所に橋を作る、という方法の効率を最大化するため、らしい。
    # 右側から徐々に橋を取り除くイメージ。
    demands = sorted(demands,key=lambda x:x[1])

    # 最後に取り除いた橋
    new_remove_bridge = 0
    # 取り除いた橋の数
    remove_bridge_count = 0

    for demand in demands:

        # 最後に取り除いた橋では分断できない島に対する要望を受けた場合
        # 例
        # 島1-除-島2-除-島3----島4 <= 2-3間の橋を取り除いた状態で・・3-4間の橋を取り除いてほしい、と言われた場合。
        if new_remove_bridge  < demand[0]:
            new_remove_bridge = demand[1] -1
            remove_bridge_count += 1

    print(str(remove_bridge_count))



class TestClass(unittest.TestCase):
    def assertIO(self, input, output):
        stdout, stdin = sys.stdout, sys.stdin
        sys.stdout, sys.stdin = StringIO(), StringIO(input)
        resolve()
        sys.stdout.seek(0)
        out = sys.stdout.read()[:-1]
        sys.stdout, sys.stdin = stdout, stdin
        self.assertEqual(out, output)
    def test_入力例_1(self):
        input = """5 2
1 4
2 5"""
        output = """1"""
        self.assertIO(input, output)
    def test_入力例_2(self):
        input = """9 5
1 8
2 7
3 5
4 6
7 9"""
        output = """2"""
        self.assertIO(input, output)
    def test_入力例_3(self):
        input = """5 10
1 2
1 3
1 4
1 5
2 3
2 4
2 5
3 4
3 5
4 5"""
        output = """4"""
        self.assertIO(input, output)

if __name__ == "__main__":
    # unittest.main()
    resolve()

Measured memory_bytes: 76756
// abc044_a
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

#if __cplusplus >= 201103L
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <type_traits>
#include <typeindex>
#include <unordered_map>
#include <unordered_set>
#endif

template <typename A, typename B> bool cmin(A &a, const B &b) {
  return a > b ? (a = b, true) : false;
}
template <typename A, typename B> bool cmax(A &a, const B &b) {
  return a < b ? (a = b, true) : false;
}
const double PI = acos(-1);
const double EPS = 1e-9;
int inf = sizeof(int) == sizeof(long long) ? 2e18 : 1e9 + 10;
int dx[] = {0, 1, 0, -1};
int dy[] = {1, 0, -1, 0};
#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 N, K, X, Y;
  cin >> N >> K >> X >> Y;
  if (N > K) {
    cout << K * X + (N - K) * Y << endl;
  } else {
    cout << X * N << endl;
  }
  return 0;
}


Measured memory_bytes: 3592
#!/usr/bin/env python3
import sys
# import math
# import numpy as np
# from functools import lru_cache

args = sys.argv
if len(args) == 2:
  from IPython import embed
  em = True
else:
  em = False

# sys.setrecursionlimit(10000)

#### input
S = input()
T = input()


# a, b, c, d = map(int, input().split())
# a = list(map(int, input().split()))
# a = list(map(lambda x: int(x)*(-1), a))  # 各要素を-1倍


# n = int(input())
# t = [int(input()) for i in range(n)]
if em: sys.stdin = open('/dev/tty')

#### function
# @lru_cache(maxsize=10000)

#### process
# if em: embed()
score = 0
for i in range(0, len(S)):
  if S[i] == T[i]:
    score = score + 1

print(score)

## heapsort, O(logN)
# import heapq
# heapq.heapify(A)
# min = heapq.heappop(A)
# heapq.heappush(A, new_element)


Measured memory_bytes: 3060
#include <iostream>
#include <cstring>
#include <string>

using namespace std;

string Upper(string str)
{
    string strx = str;
    
    for(int i = 0; i < (str.size()); i++)
    {
        
        if(islower(str[i]))
        {
            strx[i] = toupper(str[i]);
        }
    }
    
    return strx;
}

int main()
{
   string str1;    
   string str2[2000];
   int count = 0;
   
   cin >> str1;
   
   while(1)
   {
       int n = 0;
     
       
       cin >> str2[n];
       
       if(str2[n] == "END_OF_TEXT"){break;}
       
       if(Upper(str1) == Upper(str2[n]))
       {
           count++;
       }
       
       n++;
   }
   
   cout << count << endl;
   
   return 0;
}


Measured memory_bytes: 3168
#![allow(non_snake_case)]
#![allow(unused_variables)]
#![allow(dead_code)]

fn main() {
    let (A, B): (i64, i64) = {
        let mut line: String = String::new();
        std::io::stdin().read_line(&mut line).unwrap();
        let mut iter = line.split_whitespace();
        (
            iter.next().unwrap().parse().unwrap(),
            iter.next().unwrap().parse().unwrap()
        )
    };

    let ans = std::cmp::max(A - 2 * B, 0);

    println!("{}", ans);
}

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

using namespace std;
typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VL;
typedef vector<VL> VVL;
typedef pair<int, int> PII;

#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
#define MOD 1000000007
#define INF (1LL<<25)     //33554432
#define PI 3.14159265359
#define EPS 1e-12
//#define int ll

int t[100010];
signed main(void)
{
  int n, c, k;
  cin >> n >> c >> k;
  REP(i, n) cin >> t[i];

  sort(t, t+n);
  ll ret = 0;
  int l = 0, r = 0;
  while(r < n) {
    while(r < n && r-l+1 <= c && t[r] - t[l] <= k) r++;
    ret++;
    //cout << l << " " << r << endl;
    l = r;
  }

  cout << ret << endl;
  return 0;
}


Measured memory_bytes: 640
/******************************************************************************

Welcome to GDB Online.
GDB online is an online compiler and debugger tool for C, C++, Python, Java, PHP, Ruby, Perl,
Pascal, Fortran, Haskell, Objective-C, Assembly, HTML, CSS, JS.
Code, Compile, Run and Debug online from anywhere in world.

*******************************************************************************/
#include <stdio.h>
#include <iostream>
using namespace std;
char c;
int main()
{
    for(int i=0; i<3; i++){
        for(int j=0; j<3; j++){
            cin>>c;
            if(j==i)
                cout<<c;
        }
    }
    cout<<endl;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
 
int main(){
  int a,b,c,max=0; cin>>a>>b>>c;
  if(10*a+b+c>a+10*b+c){
    max=10*a+b+c;}
  else {
    max=10*b+a+c;}
  if(max<10*c+b+a){
    max=10*c+b+a;}
  cout<<max<<endl;
   return 0;
}

Measured memory_bytes: 256
import sys, bisect, math, itertools, string, queue, copy
# import numpy as np
# import scipy
# from collections import Counter,defaultdict,deque
# from itertools import permutations, combinations
# from heapq import heappop, heappush
# # input = sys.stdin.readline
# sys.setrecursionlimit(10**8)
mod = 10**9+7
def inp(): return int(input())
def inpm(): return map(int,input().split())
def inpl(): return list(map(int, input().split()))
def inpls(): return list(input().split())
def inplm(n): return list(int(input()) for _ in range(n))
def inplL(n): return [list(input()) for _ in range(n)]
def inplT(n): return [tuple(input()) for _ in range(n)]
def inpll(n): return [list(map(int, input().split())) for _ in range(n)]
def inplls(n): return sorted([list(map(int, input().split())) for _ in range(n)])

n,k = inpm()
A = sorted(inpl())

f=[1]
for i in range(1,n+1):
  f.append(f[-1]*i % mod)

#nCr
def comb(n,r):
    if n <= 0 or r <= 0:
        return 0
    x = f[n] % mod
    y = f[r] * f[n-r] % mod
    return (x * pow(y, mod-2, mod) % mod)

ans = 0
for i in range(n):
    c = comb(n-i-1,k-1)
    ans += A[n-1-i] * c - A[i] * c
    ans %= mod
    if c == 1:
        break

print(ans)


Measured memory_bytes: 21388
def LI():return map(int,input().split())
def I(): return input().split()

n=int(input())
lst=[]
ans=float("inf")
for i in range(1,int(n**0.5)+1):
    if n % i==0:
        lst.append((i,n//i))
# print(lst)
for j,k in lst:
    ans=min(ans,max(len(str(j)),len(str(k))))
print(ans)

Measured memory_bytes: 9368
# 3 .. 6 N=4とすると真ん中2つは(3, 3)~(6, 6)までで、1ずつインクリメントして全種類網羅できる
# 3+3 ~ 6+6までの12-6+1種類
# n>1 a<bが条件になってないっていう非本質的な小賢しい罠

n, a, b = map(int, input().split())
if a == b and n == 1:
    print(1)
elif b < a or n == 1:
    print(0)
elif n == 2 and a <= b:
    print(1)
else:
    minn = (n - 2) * a
    maxn = (n - 2) * b
    print(maxn - minn + 1)


Measured memory_bytes: 2940
#include<stdio.h>
int main()
{
  int A,B,C;

  scanf("%d %d %d", &A, &B, &C);

  if(((A==B) && (B!=C))||((B==C) && (C!=A))||((C==A) && (A!=B))){
  printf("Yes\n");
  }
  else{
  printf("No\n");  
  }
  return 0;
}


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

using namespace std;

struct Card{
	char mark;
	int number;
};

int main(){
  int n,min;
  char buf[3];
  scanf("%d",&n);
  
  Card selectArray[n],bubbleArray[n];
  
  for(int i = 0; i < n; i++){
    scanf("%s",buf);
    selectArray[i].mark = buf[0];
    selectArray[i].number = buf[1] - '0';
    bubbleArray[i] = selectArray[i];
  }
  
  for(int i = n-1; i >= 0; i--){
    for(int j = 0; j < i; j++){
      if(bubbleArray[j].number > bubbleArray[j+1].number) swap(bubbleArray[j], bubbleArray[j+1]);
    }
  }
  
  for(int i = 0; i < n-1; i++){
    min = i;
    for(int j = i+1; j < n; j++){
      if(selectArray[j].number < selectArray[min].number){
	min = j;
      }
    }
    if(i != min){
      swap(selectArray[i],selectArray[min]);
    }
  }
  
  for(int i = 0; i < n-1; i++) printf("%c%d ",bubbleArray[i].mark,bubbleArray[i].number);
  printf("%c%d\n",bubbleArray[n-1].mark,bubbleArray[n-1].number);
  printf("Stable\n");
  for(int i = 0; i < n-1; i++) printf("%c%d ",selectArray[i].mark,selectArray[i].number);
  printf("%c%d\n",selectArray[n-1].mark,selectArray[n-1].number);
  
  int p;
  for(p=0; p < n; p++){
    if(selectArray[p].number != bubbleArray[p].number || selectArray[p].mark != bubbleArray[p].mark)
      break;
  }
  if(p == n){
    printf("Stable\n");
  }else{
    printf("Not stable\n");
  }
  
  return 0;
}



Measured memory_bytes: 3172
L, R = map(int, input().split())
def mod(L, R):
    ans = []
    for i in range(L, R):
        for j in range(L+1, R+1):
            if (i*j)%2019 == 0:
                return 0
            ans.append((i*j)%2019)
    return min(ans)
print(mod(L, R))


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

using namespace std;
int main(){
  int A, B, C;
  cin >> A >> B >> C;
  int D = A * B * C;
  if (D == 175){
    cout << "YES" << endl;
  }
  else{
    cout << "NO" << endl;
    }
  }


Measured memory_bytes: 256
from functools import reduce
read = input
n = int(read())
A = list(map(int, read().split()))
if any(map(lambda x:x==0, A)):
    A = map(abs, A)
    print(sum(A))
else:
    cnt = reduce(lambda ac,x:ac + 1 if x < 0 else ac, A, 0)
    if cnt % 2 == 0:
        A = list(map(abs, A))
        print(sum(A))
    else :
        A = list(map(abs, A))
        print(sum(A) - 2*min(A))

Measured memory_bytes: 14908
#include<iostream>
#include<bits/stdc++.h>
#include<cmath>
using namespace std;
int main()
{
   int n;
   cin>>n;
   int a[n][3],f[n][3]={0},ac[3]={0};
   int i,j;
   for(i=0;i<n;i++)
   {
       for(j=0;j<3;j++)
       {
           cin>>a[i][j];
       }
   }
   int m=0,g=0,k=0;
   f[0][0]=a[0][0];
   f[0][1]=a[0][1];
   f[0][2]=a[0][2];
   for(i=1;i<n;i++)
   {
       f[i][0]=a[i][0]+max(f[i-1][1],f[i-1][2]);
       f[i][1]=a[i][1]+max(f[i-1][0],f[i-1][2]);
       f[i][2]=a[i][2]+max(f[i-1][0],f[i-1][1]);
   }
   g=0;
  for(j=0;j<3;j++)
       {
           if(f[n-1][j]>g)
           {
               g=f[n-1][j];
           }
       }
       cout<<g;
   return 0;
}


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

int n;
using ll = long long;
int x;
int ans[4];

int main()
{
    ios::sync_with_stdio(false);
    cin>>n;
    for (int i=1;i<=n;i++)
    {
    	cin>>x;
    	if (x%4==0) ans[3]++;
		else if (x%2==0) ans[2]++;
		else ans[1]++;
	} 
	if (ans[1]-1>ans[3] || (ans[1]-1==ans[3] && ans[2]>0)) return 0*puts("No");else return 0*puts("Yes");
}

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

int gcd(int a,int b){
    while(1){
        if(a<b) swap(a,b);
        if(b==0) break;
        a%=b;
    }
    return a;
}

int main(){
    int N,ans;cin>>N;
    int A[N]; 
    for(int i=0;i<N;i++){
        cin>>A[i];
    }
    ans = A[0];
    for(int j=1;j<N;j++){
        ans = gcd(ans,A[j]);
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 640
use proconio::{input, fastout};
use proconio::marker::{Chars};
#[fastout]
fn main() {
    input!{
        n: usize,
        o: [(f64, Chars); n],
    }
    let mut ans = 0.0;
    for i in 0..n {
        let unit: String = o[i].1.iter().collect();
        if unit=="JPY" {
            ans += o[i].0;
        } else {
            ans += o[i].0*380000.0;
        }
    }
    println!("{}", ans);
}


Measured memory_bytes: 2228
# -*- coding: utf-8 -*-
"""
Created on Sun Feb 16 20:59:44 2020

@author: W_Indicate
"""

A, B, C = (int(x) for x in input().split())



if A == B == C:
    print("No")
elif (A != B)  and (C != B) and (A != C):
    print("No")
else:
    print("Yes")

Measured memory_bytes: 3060
#include <algorithm>
#include <iostream>
#include <map>
#include <set>
#include <vector>
using namespace std;

template <class K, class V>
ostream &operator<<(ostream &out, const map<K, V> m) {
    out << "Dict(size=" << m.size() << ", ";
    out << "{ ";
    for (auto &[k, v] : m) {
        out << k << ": " << v << ", ";
    }
    out << "})";
    return out;
}

template <class T> ostream &operator<<(ostream &out, const multiset<T> s) {
    out << "Set(size=" << s.size() << ", ";
    out << "{ ";
    for (auto it = s.begin(); it != s.end(); ++it) {
        out << *it << " ";
    }
    out << "})";
    return out;
}

void solve() {
    int H, W;
    cin >> H >> W;

    multiset<int> steps;
    map<int, int> end2start;
    for (int c = 0; c < W; c++) {
        end2start[c] = c;
        steps.insert(0);
    }

    for (int r = 1; r <= H; r++) {
        int a, b;
        cin >> a >> b;
        a--;
        b--;

        // Erase pairs (e, s) that a <= e <= b + 1
        auto lb = end2start.lower_bound(a);
        auto ub = end2start.upper_bound(b + 1);
        auto max_start = -1;
        for (auto it = lb; it != ub; ++it) {
            int end = it->first;
            int start = it->second;
            steps.erase(steps.find(end - start));
            max_start = max(max_start, start);
        }
        end2start.erase(lb, ub);

        // Update pair (b + 1, s)
        if (b != W - 1 and max_start != -1) {
            end2start[b + 1] = max_start;
            steps.insert(b + 1 - end2start[b + 1]);
        }

        if (steps.size() > 0) {
            cout << *steps.begin() + r << endl;
        } else {
            cout << "-1" << endl;
        }
    }
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    solve();
    return 0;
}

Measured memory_bytes: 22376
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args) throws NumberFormatException, IOException {
		// TODO Auto-generated method stub
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String[] ah = br.readLine().split(" ");
		int a = Integer.parseInt(ah[1]);
		int h = Integer.parseInt(ah[0]);
		if(h % a == 0 ) {
			System.out.println(h/a);
		}else {
			System.out.println(h/a+1);
		}
	}

}


Measured memory_bytes: 21204
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    int N;
    cin >> N;
    string S;
    cin >> S;

    int count = 0;
    for(int i=0; i<N-2; i++){
        if(S.at(i)=='A' && S.at(i+1)=='B' && S.at(i+2)=='C'){
            count++;
        }
    }
    cout << count << endl;
}

Measured memory_bytes: 256
#include <cstdio>

int main() {
  char S[128];
  scanf("%*d %s", S);
  int res=0, cur=0;
  for (int i=0; S[i]; ++i) {
    if (S[i] == 'I') {
      ++cur;
    } else {
      --cur;
    }

    if (res < cur)
      res = cur;
  }

  printf("%d\n", res);
  return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <tuple>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <cmath>
#include <iomanip>
#define rep(i, n) for(int i = 0; i < (int)(n); ++i)
using namespace std;

int main() {
    int N, K;
    cin >> N >> K;
    int X = (N - 1) * (N - 2) / 2;
    if (K > X) {
        cout << -1 << "\n";
        return 0;
    }
    cout << N - 1 + X - K << "\n";
    rep(i, N - 1) cout << 1 << " " << 2 + i << "\n";
    int n = 2, m = 3;
    rep(i, X - K) {
        cout << n << " " << m << "\n";
        ++m;
        if (m > N) {
            ++n;
            m = n + 1;
        }
    }
    return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main()
{
  int a,b,c;
  int x;
  int cnt = 0;

  cin >> a >> b >> c >> x;

  for ( int i = 0; i <= a; ++i ) {
    for ( int j = 0; j <= b; ++j ) {
      for ( int k = 0; k <= c; ++k ) {
        if ( i*500+j*100+k*50 == x ) ++cnt;
      }
    }
  }

  cout << cnt << "\n";
}


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

void printArray(int A[], int N) {
    for (int i = 0; i < N; i++) {
        if (i) cout << " ";
        cout << A[i];
    }
    cout << endl;
    return;
}

void insertionSort(int A[], int N) {
    for (int i = 1; i < N; i++) {
        printArray(A, N);
        int v = A[i];
        int j = i - 1;
        while (j >= 0 && A[j] > v) {
            A[j + 1] = A[j];
            j--;
        }
        A[j + 1] = v;
    }
    printArray(A, N);
    return;
}

int main() {
    int N, A[110];
    cin >> N;
    for (int i = 0; i < N; i++) cin >> A[i];
    insertionSort(A, N);
    return 0;
}


Measured memory_bytes: 3096
#include <stdio.h>
#include <string.h>
#include <iostream>
using namespace std;
#define rep(i, n) for(int i=0; i<(int)(n); i++)
typedef long long Int;

#define MOD (1000000009LL)
#define MAXN (200000)
#define MAXE (500000)

int N, M;
int dig[MAXN], is[MAXN];
int E, u[MAXE], v[MAXE], next[MAXE], head[MAXN];

int main() {
    memset(head, -1, sizeof(head));
    scanf("%d%d", &N, &M);
    rep(_, M) {
        int x, y;
        scanf("%d%d", &x, &y);
        x--, y--;
        dig[x]++, dig[y]++;
        u[E]=x; v[E]=y; next[E]=head[u[E]]; head[u[E]]=E; E++;
        u[E]=y; v[E]=x; next[E]=head[u[E]]; head[u[E]]=E; E++;
    }
    rep(i, N) {
        is[i] = 1;
        for(int x=head[i]; x!=-1; x=next[x]) if(dig[v[x]]<dig[i]) {
            is[i] = 0;
            break;
        }
    }
    Int ansm = 0, answ = 1;
    rep(i, N) if(is[i]) {
        int c = 0;
        for(int x=head[i]; x!=-1; x=next[x]) if(dig[v[x]]==dig[i]) {
            is[v[x]] = 0;
            c++;
        }
        ansm += 1;
        answ = answ*(c+1)%MOD;
    }
    cout << ansm << endl;
    cout << answ << endl;
    return 0;
}

Measured memory_bytes: 0