akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define si size()
#define bk back()
#define popb pop_back()
#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define endl "\n"
#define lb lower_bound
#define ub upper_bound
#define emp empty()
#define beg begin()
#define en end()
#define ump unordered_map
#define forl(i,a,n) for(int i=a;i<n;i++)
#define rfor(i,n,a) for(int i=n;i>=a;i--)
#define fore(i,a,n) for(int i=a;i<=n;i++)
#define len length()
#define N 200000
int main()
{
	int n,k;
	cin>>n;
	int arr[n][3];
	forl(i,0,n)forl(j,0,3)cin>>arr[i][j];
	int dp[n][3];
	forl(i,1,n)forl(j,0,3)dp[i][j]=-1;
	dp[0][0]=arr[0][0];
	dp[0][1]=arr[0][1];
	dp[0][2]=arr[0][2];
	forl(i,1,n)
	{
		forl(j,0,3)
		{
			forl(k,0,3)
			{
				if(k!=j)
				{
					dp[i][j]=max(dp[i][j],arr[i][j]+dp[i-1][k]);
				}
			}
		}
	}
	cout<<max(dp[n-1][0],max(dp[n-1][1],dp[n-1][2]))<<endl;
	
	
}

Measured memory_bytes: 2688
#include <iostream>
#include <cstdio>
#include <sstream>
#include <vector>
using namespace std;

char decode(int a, int b, char c)
{
  return (a * (c - 'a') + b) % 26 + 'a';
}

int main()
{
  int N;
  string str;
  cin >> N;
  cin.ignore();
  //printf("N = %d\n", N);
  for (int i = 0; i < N; i++) {
    //if (i == 0) getline(cin, str);
    getline(cin, str);

    istringstream is(str);
    string tmp;
    vector<string> token;
    while (is >> tmp) {
      token.push_back(tmp);
    }
    /*for (int j = 0; j < token.size(); j++) {
      cout << token[j] << endl;
      }*/

    for (int a = 0; a < 26; a++) {
      for (int b = 0; b < 26; b++) {
	for (int j = 0; j < token.size(); j++) {
	  tmp = token[j];
	  for (int k = 0; k < token[j].size(); k++) {
	    tmp[k] = decode(a, b, tmp[k]);
	  }
	  if (tmp == "this" || tmp == "that") {
	    for (int k = 0; k < token.size(); k++) {
	      for (int l = 0; l < token[k].size(); l++) {
		cout << decode(a, b, token[k][l]);
	      }
	      if (k == token.size() - 1) {
		cout << endl;
		goto next;
	      } else {
		cout << " ";
	      }
	    }
	  }
	}
      }
    }
  next:;
  }
}

Measured memory_bytes: 0
#include <iostream>
#include <sstream>
#include <stack>
#include <iomanip>
#include <numeric>
#include <string>
#include <cstring>
#include <algorithm>
#include <functional>
#include <cstdlib>
#include <map>
#include <set>
#include <vector>
#include <utility>
#include <queue>
#include <cmath>

#define BEGIN(x) x.begin()
#define END(x) x.end()
#define ALL(x) BEGIN(x), END(x)
#define PAIR make_pair
#define VEC(type) vector<type >
#define endl '\n'

#define FOR(i, A, B) for(auto i = (A);i != (B); i++)
#define FORD(i, A, B) for(auto i = (A);i != (B); i--)

#define READRANGE(begin, end) FOR(it, begin, end) cin >> *it
#define READVEC(V) READRANGE(BEGIN(V), END(V))

using namespace std;

typedef long long lint;
typedef pair<int, int> Pii;
typedef pair<int, lint> Pil;
typedef pair<lint, lint> Pll;
typedef pair<lint, int> Pli;

template<class U, class V>
istream& operator >>(istream& in, pair<U, V>& pr) {
    return in >> pr.first >> pr.second;
}

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

template<class T>
ostream& operator <<(ostream& out, vector<T> vec) {
    for (T& e : vec)
        out << e << " ";
    return out << endl;
}

// ---- BEGIN LIBRARY CODE ----
// ---- END LIBRARY CODE ----
void io_init()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
};

int main(int argc, char **argv)
{
    io_init();

    // Actual program code starts here.
    int N;
    cin >> N;
    VEC(lint) A(N);
    READVEC(A);

    const lint _infinity = 1LL << 50;

    VEC(lint) Sums(N + 1, 0);
    FORD(i, N - 1, -1) {
        Sums[i] = A[i];
        if (i + 2 < N)
            Sums[i] += Sums[i + 2];
    }

    VEC(lint) dp(N + 1, -_infinity);
    dp[N] = 0;
    FORD(i, N - 1, -1) {
        int r = N - i;
        if (r % 2 == 0) {
            dp[i] = A[i] + dp[i + 2];
            dp[i] = max(dp[i], Sums[i + 1]);
        } else {
            if (i == N - 1) {
                dp[i] = 0;
                continue;
            }

            dp[i] = Sums[i + 2];
            dp[i] = max(dp[i], A[i] + dp[i + 2]);
            dp[i] = max(dp[i], dp[i + 1]);
        }
    }

    cout << dp[0] << endl;
    return 0;
};

Measured memory_bytes: 7876
#include<bits/stdc++.h>
#define ll long long int
#define M 1000000007
using namespace std;
ll n,t;

int main(){
      ios_base::sync_with_stdio(false); cin.tie(NULL);
      cin>>n;
      ll x,mx=0,ans=0;
      for(int i=0;i<n;i++){
        cin>>x;
        mx=max(mx,x);
        ans+=(mx-x);
      }
      cout<<ans;
}

Measured memory_bytes: 3652
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = ceil(log2(pow(10,9)));



int main()
{
  int n,k;
  string s;
  cin >> n >> k;
  cin >> s;
  k = k-1;
  s[k] = tolower(s[k]);
  cout << s << endl;
  return 0;
}


Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include <bits/stdc++.h>
using namespace std;
typedef vector<int> vi;
#define mp make_pair
#define MAX 20000
typedef long long ll;
typedef pair<int, int> ii;
typedef pair<ll, ll> pll;
typedef vector<long long> vll;
typedef vector<ii> vii;
#define EPS 1e-9
#define LSOne(S) (S & (-S))
#define INF 1000*1000*1000+889
const int N = 1e5+10;
int main(void)
{
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    int x;
    cin>>x;
    if(x == 7 || x == 5 || x == 3)
        puts("YES");
    else
        puts("NO");
}


Measured memory_bytes: 256
import           Control.Applicative
import           Control.Monad
import qualified Data.ByteString.Char8 as B
import           Text.Printf

readi :: B.ByteString -> Int
readi b | Just (n, _) <- B.readInt b = n

type Vector = (Double, Double)

add :: Vector -> Vector -> Vector
add (a, b) (c, d) = (a + c, b + d)

mult :: Vector -> Double -> Vector
mult (a, b) k = (k * a, k * b)

dot :: Vector -> Vector -> Double
dot (a, b) (c, d) = a * c + b * d

norm :: Vector -> Double
norm (a, b) = a * a + b * b

project :: Vector -> Vector -> Vector -> Vector
project (a, b) (c, d) (e, f) = (a, b) `add` (base `mult` r)
  where
    base = (c - a, d - b)
    hypo = (e - a, f - b)
    r = (hypo `dot` base) / norm base

main :: IO ()
main = do
    [a,b,c,d] <- fmap (fromIntegral . readi) . B.words <$> B.getLine
    q <- readLn
    let p1 = (a, b)
    let p2 = (c, d)
    replicateM_ q $ do
        [x, y] <- fmap (fromIntegral . readi) . B.words <$> B.getLine
        let (ax, ay) = project p1 p2 (x, y)
        printf "%.8f %.8f\n" ax ay



Measured memory_bytes: 4428
def solve():
    N = int(input())
    Ps = list(map(float, input().split()))

    Qs = [1-P for P in Ps]

    dp = [0.0] * (N+2)
    dp[0] = 1.0
    for i, (P, Q) in enumerate(zip(Ps, Qs)):
        dp2 = [0.0] * (N+2)
        for j in range(i+1):
            dp2[j] += dp[j] * Q
            dp2[j+1] += dp[j] * P
        dp = dp2

    print(sum(dp[(N+1)//2:]))


solve()


Measured memory_bytes: 3316
array=[1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
k = input()
ki=int(k)-1
print(array[ki])

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

using namespace std;
typedef long long ll;
typedef vector<int> VI;
ll mm=1000000000;ll MM=mm+7;
#define rep(i, n) for(int i=0;i<n;i++)

int main(){
   ll a,b,c,k; 
  cin >> a >> b >> c >> k ;
  ll ans;
  if(k<=a) ans=k;
  else if(k<=a+b) ans=a;
  else{
    ll n=k-a-b;
    ans=a-n;
  }
  cout << ans << endl;
}


Measured memory_bytes: 3676
#include <cstdio>
#include <vector>
#include <utility>
#include <cstdlib>

using namespace std;

int n,m;


const int INF = 999999999;

vector< vector< pair<int,int> > > stones;
int dp[153][153][153];

int calcd(pair<int,int> a,pair<int,int> b){
	if(a.first == -1 || b.first == -1){return 0;}
	//printf("CALCD:(%d,%d) -> (%d,%d) : %d\n",a.first,a.second,b.first,b.second,(a.second + b.second) * abs(a.first - b.first));
	return (a.second + b.second) * abs(a.first - b.first);
}

void setvalue(int* begin,int* end,int value){
	int* pt = begin;
	while(pt != end){
		*pt = value; 
		pt++;
	}
}

int main(){
	int self;
	int a,b;
	int s,ss;
	int x,y;
	while(scanf("%d %d",&n,&m) && (n || m)){
		//printf("%d,%d\n",n,m);
		stones.clear();
		vector< pair<int,int> > vvv;
		vvv.push_back( pair<int,int>(-1,0) );
		
		stones.push_back(vvv);
		
		for(int i=0;i<n;i++){
			scanf("%d",&self);
			//printf("%d :",i);
			vector< pair<int,int> > vv(self);
			for(int j=0;j<self;j++){
				scanf("%d %d",&a,&b);
				//printf("(%d,%d) ",a,b);
				vv[j] = (pair<int,int>(a,b));
				
			}
			//printf("\n");
			stones.push_back(vv);
		}
		stones.push_back(vvv);
		
		setvalue(&dp[0][0][0],&dp[0][0][0] + 10 * 150 * 76,INF);
		
		
		for(int i=0;i<stones[0].size();i++){
			dp[m][i][0] = 0;
			
		}
		/*
		if(m > 0){
			for(int i=0;i<stones[1].size();i++){
				dp[m - 1][i][1] = 0;
			}
		}
		
		*/
		/*
		for(int k = m;k >= 0;k--){
			printf("[k:%d]\n",k);
			for(int j = 0;j < n;j++){
				for(int i = 0;i < stones[j].size();i++){
					printf("%d ",dp[k][i][j]);
				}
				printf("\n");
			}
			printf("\n");
		}
		*/
		for(int k = m;k >= 0;k--){
			for(int j = 0;j < n + 2;j++){
				for(int i = 0;i < stones[j].size();i++){
					//printf("%d %d %d\n",k,i,j);
								
					if(j > 0){
						self = INF;
						for(int l = 0;l < stones[j - 1].size();l++){
							if(dp[k][l][j - 1] >= INF){continue;}
							//printf("call (%d,%d) , (%d,%d)\n",i,j,j-1,l);
							s = calcd(stones[j][i],stones[j - 1][l]) + dp[k][l][j - 1];
							if(s < self){
								self = s;
							}
						}
						dp[k][i][j] = self;
					}
					if(j > 1 && k < m){
						self = INF;
						for(int l = 0;l < stones[j - 2].size();l++){
							if(dp[k + 1][l][j - 2] >= INF){continue;}
							//printf("call (%d,%d) , (%d,%d)\n",i,j,j-2,l);
							s = calcd(stones[j][i],stones[j - 2][l]) + dp[k + 1][l][j - 2];
							if(s < self){
								self = s;
							}
						}
						if(dp[k][i][j] > self){
							dp[k][i][j] = self;
						}
					}
				}
			}
		}
		int ans = INF;
		s = stones[n + 1].size();
		for(int i = 0;i <= m;i++){
			for(int j = 0;j < s;j++){
				if(dp[i][j][n + 1] < ans){
					ans = dp[i][j][n + 1];
				}
			}
		}
		
		/*
		for(int k = m;k >= 0;k--){
			printf("[k:%d]\n",k);
			for(int j = 0;j < n + 1;j++){
				for(int i = 0;i < stones[j].size();i++){
					printf("%d ",dp[k][i][j]);
				}
				printf("\n");
			}
			printf("\n");
		}
		*/
		printf("%d\n",ans);
	}
}

Measured memory_bytes: 1992
using System;
using System.Collections.Generic;

namespace _0013
{
    class Program
    {
        static void Main(string[] args)
        {
            Stack<int> train = new Stack<int>();
            while (true)
            {
                string s = Console.ReadLine();
                if (s == null)
                {
                    break;
                }
                int n = int.Parse(s);
                if (n == 0)
                {
                    Console.WriteLine(train.Pop());
                }
                else
                {
                    train.Push(n);
                }
            }
        }
    }
}

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

using namespace std; 

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef vector<PII> VPII;
typedef long long LL;
typedef vector<LL> VL;
typedef vector<VL> VVL;
typedef pair<LL, LL> PLL;
typedef vector<PLL> VPLL;
typedef priority_queue<int> PQ_DESC;
typedef priority_queue<int, vector<int>, greater<int>> PQ_ASC;
typedef priority_queue<PII> PQ_DESC_PII;
typedef priority_queue<PII, vector<PII>, greater<PII>> PQ_ASC_PII;

#define ALL(c) (c).begin(),(c).end()
#define PB push_back
#define MP make_pair
#define SORT_ASC(c) sort(ALL(c))
//#define SORT_DESC(c) sort(ALL(c), greater<typeof(*((c).begin()))>())
#define SORT_DESC(c) sort((c).rbegin(),(c).rend())
#define REV(c) reverse((c).begin(), (c).end())
#define SIZE(a) int((a).size())

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define ROF(i,a,b) for(int i=(b-1);i>=(a);--i)
#define REP(i,n) FOR(i,0,n)
#define PER(i,n) ROF(i,0,n)

const double EPS = 1e-10;
const double PI  = acos(-1.0);
const int LARGE_INT = 1e9+100;
const int INF = 2e9+100;
const LL INF_LL = (LL)INF * 300 * 300;
const int MOD = 1e9+7;

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

LL modpow(LL a, LL n) {
    LL res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % MOD;
        a = a * a % MOD;
        n >>= 1;
    }
    return res;
}

void Main()
{
    LL a,b;cin>>a>>b;

    if((a*b)%2 == 0){
        cout<<"Even"<<endl;
    }
    else{
        cout<<"Odd"<<endl;
    }
	return;
}

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

Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);

        int n = sc.nextInt();

        int[] a = new int[n];
        for (int i = 0; i < n; ++i) {
            a[i] = sc.nextInt();
        }

        Arrays.sort(a);

        int t = 0;
        for (int i = 0; i < n - 1; ++i) {
            t += a[i];
        }

        System.out.println(t > a[n-1] ? "Yes" : "No");
    }
}

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

#define CH(N,A,B) (A<=N&&N<B)
#define REP(i,a,b) for(int i=a;i<b;i++)
#define RREP(i,a,b) for(int i=(b-1);a<=i;i--)

using namespace std;

const int INF = 1000000005;
int N, p[100005], dp[100005];

void dfs(int prevPos, int currentPos, int step){
  if(dp[currentPos] <= step) return;
  dp[currentPos] = step;
  if(currentPos == N-1) return;
  if(p[currentPos] > 0) dfs(currentPos, min(N - 1, currentPos + p[currentPos]), step);
  else if(p[currentPos] < 0) dfs(currentPos, max(0, currentPos + p[currentPos]), step);
  else{
    REP(i,1,7){
      dfs(currentPos, min(N-1, currentPos+i), step+1);
    }
  }
  return;
}

int main() {
  cin>>N;
  REP(i,0,N) cin>>p[i];
  REP(i,0,N) dp[i] = INF;
  dfs(-1,0,0);
  cout<<dp[N-1]<<endl;
  return 0;
}

Measured memory_bytes: 4652
#include <iostream>
#include <cassert>
#include <cstdlib>
#include <cstring>
#include <utility>
#include <sstream>
#include <limits>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <string>
#include <cctype>
#include <queue>
#include <deque>
#include <stack>
#include <cmath>
#include <ctime>
#include <list>
#include <map>
#include <set>
#define PI (acos(-1.0))
#define Abs(a) (((a)<0) ? (-(a)) :(a) )
#define rep(i,n) for((i)=0;(i)<(n);(i)++)
#define Rep(i,n) for(int i=0;i<(n);i++)
#define Rrep(i,n) for(int i=((n)-1);i>=0;i--)
#define rrep(i,n) for((i)=(n)-1;(i)>=0;(i)--)
#define Pii pair<int,int>
#define PB push_back
#define Size(x) ((int)(x.size()))
using namespace std;
typedef long long mint;
typedef unsigned long long umint;
Pii st[200], chk[200];
int nearestIdx(Pii pos, int m)
{
    int mn = Abs(pos.first - chk[0].first) + Abs(pos.second - chk[0].second);
    int idx = 0;
    for(int i = 1; i < m; i++)
    {
        int d = Abs(pos.first - chk[i].first) + Abs(pos.second - chk[i].second);
        if(d < mn)
        {
            mn = d;
            idx = i;
        }
    }
    return idx + 1;
}
int main()
{
    //freopen("in.txt","r",stdin);
    int n,m;
    cin >> n >> m;
    Rep(i,n)
    {
        cin >> st[i].first >> st[i].second;
    }
    Rep(i,m)
    {
        cin >> chk[i].first >> chk[i].second;
    }
    Rep(i,n)
    {
        cout << nearestIdx(st[i], m) << endl;
    }
    return 0;
}




Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
using namespace std;
int pr[50050];
int main() {
  int i,j,k=0,n;
  for (i=2;i<50050;i++) if (pr[i]==0) { pr[i]=1; for (j=i+i;j<50050;j+=i) pr[j]=2;}
  while(cin >> n) {
	  for (i=n-1;i>1;i--) if (pr[i]==1) { cout << i << ' '; break;}
	  for (i=n+1;i<50050;i++) if (pr[i]==1) { cout << i << endl; break;}
  }
  return 0;
}

Measured memory_bytes: 1352
import sys
sys.setrecursionlimit(10**6)

n = int(input())
#b = list(map(int, input().split()))
#n, m = map(int, input().split())
#s = input()
#s,t = input().split()
#a = [int(input()) for _ in range(n)]
#
#readline = sys.stdin.readline
#n,m = [int(i) for i in readline().split()]
#ab = [[int(i) for i in readline().split()] for _ in range(n)]

if n%1000 == 0:
    print(0)
else:
    print(1000-n%1000)

Measured memory_bytes: 9156
import java.util.Arrays;
import java.util.Scanner;


class Main{

	public static void main(String[] args) {

		Scanner scan = new Scanner(System.in);
		int N = scan.nextInt();
		int X = scan.nextInt();
		int[] data = new int[N];
		for(int i=0;i < N;i++){
			data[i] = scan.nextInt();
		}

		int key = Math.abs(data[0] - X);
		
		for(int i = 1;i < N;i++){
			key = gcd(key, Math.abs(data[i] - X));
		}
		System.out.println(key);

	}
	
	static int gcd(int p,int q){
		if(q == 0){
			return p;
		}else{
			return gcd(q, p%q);
		}
	}
}


Measured memory_bytes: 49024
use std::cmp::min;
use proconio::input;

fn main() {
    input! {
        a: i64,
        b: i64,
        n: i64,
    }
 
   let (af, bf) = (a as f64, b as f64);

    let f = |x: f64| f64::floor(af / bf * x) - af * f64::floor(x / bf);

    println!("{}", f(min(b-1, n) as f64));
}



Measured memory_bytes: 2708
//it was hard to write
//so it should be hard to read
#include <bits/stdc++.h>
#define sz size
#define pb push_back
#define ll long long
#define F first
#define S second
#define all(x) (x).begin(), (x).end()
#define last(x) (x).size() - 1
#define mp make_pair

using namespace std;

typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef double ld;

const int MAXN = 1e5 + 5;
const ll INF = 1e18 + 7;
const int inf = 1e9 + 7;
const double EPS = 1e-9;

int n, h[25], mx, res;

int main() {
    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
    cin >> n;
    for (int i = 1; i <= n; i++) {
        cin >> h[i];
    }
    for (int i = 1; i <= n; i++) {
        if (mx <= h[i]) res++;
        mx = max(mx, h[i]);
    }
    cout << res;
    return 0;
}


Measured memory_bytes: 256
//NAME-DEEPESH BHATT
//Institute-IIT Dhanbad
//MOTTO-THINK FIRST,CODE LATER

#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
ll MOD = 1000000007  ;
#define pb push_back
#define mp make_pair

//Check for signed int overflow

ll gcd(ll a,ll b)
{
    if(b==0)
        return a;
    else
        return gcd(b,a%b);
}
ll lcm(ll a ,ll b)
{
    return a/gcd(a,b)*b;
}
ll power(ll a,ll n)
{
    if (n == 0)
        return 1;
    ll p = power(a, n / 2);
    p = (p * p);
    if (n % 2)
        return (p * a);
    else
        return p;
}
/*vector<bool>is_prime(1000001,true);
void sieve(){
    is_prime[0]=is_prime[1]=false;
    is_prime[2]=true;
    for(int i=2;i*i<=1000000;i++){
        if(is_prime[i]){
            for(int j=i*i;j<=1000000;j+=i){
                is_prime[j]=false;
            }
        }
    }
}*/

/*bool is_sorted(int *arr,int n){
    for(int i=0;i<n-1;i++){
        if(arr[i+1]<arr[i]){
            return false;
        }
    }
    return true;
}*/

void solve(){
    int x,y;
    cin>>x>>y;
    if((y-2*x)>=0&&(y-2*x)%2==0){
        if((y-2*x)<=2*x){
            cout<<"Yes";
        } else
            cout<<"No";
    }
    else{
        cout<<"No";
    }
}

int32_t main()
{
    ios_base::sync_with_stdio(false);    //for fast I/O operation
    cin.tie(NULL);
    ll test=1;
    /*cin>>test;*/
    while(test--) {
        solve();
    }
    return 0;
}


Measured memory_bytes: 3608
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author NikuKyabe
 */

#include "bits/stdc++.h"

using namespace std;
#define int long long
#define FOR(i, a, b) for(int i=(int)(a);i<(int)(b);++i)
#define REP(i, n)  FOR(i,0,(n))
typedef pair<int, int> P;


class BRobotArms {
public:
    void solve(std::istream &in, std::ostream &out) {
      int n;
      in >> n;
      vector<P> xl(n);
      REP(i, n) {
        int x, y;
        in >> x >> y;
        xl[i] = P(x, y);
      }
      sort(xl.begin(), xl.end(), [](P a, P b) {
          return a.first + a.second < b.first + b.second;
      });
      P t = xl[0];
      int ans = 1;
      FOR(i, 1, n) {
        if (t.first + t.second <= xl[i].first - xl[i].second) {
          ans++;
          t = xl[i];
        }
      }
      out << ans << endl;
    }
};


signed main() {
  ios::sync_with_stdio(false);
  cout.tie(0);
  cout << fixed;
  BRobotArms solver;
  std::istream &in(std::cin);
  std::ostream &out(std::cout);
  solver.solve(in, out);
  return 0;
}


Measured memory_bytes: 1792
#include "bits/stdc++.h"
#include <boost/multi_array.hpp>
#include <boost/optional.hpp>
#include <boost/range/irange.hpp>
#include <boost/range/algorithm.hpp>
#include <boost/range/adaptors.hpp>
#include <boost/operators.hpp>
#include <boost/dynamic_bitset.hpp>
namespace adaptor = boost::adaptors;
using index_t = std::size_t;

namespace lib
{
	struct max_t
	{
		template<class T>T operator()(T&& lhs, T&& rhs)const
		{
			return std::max(lhs, rhs);
		}
	};
	struct min_t
	{
		template<class T>T operator()(T&& lhs, T&& rhs)const
		{
			return std::min(lhs, rhs);
		}
	};

	template<class T>auto order_by(T func)
	{
		return [=](auto&& lhs, auto&& rhs)
		{
			return func(lhs) < func(rhs);
		};
	}
}

void Main()
{
	int N;
	std::cin >> N;
	std::set<std::string> set;
	for (auto i : boost::irange(N))
	{
		std::string str;
		std::cin >> str;
		set.emplace(str);
	}
	std::cout << set.size() << std::endl;
}

int main()
{
	std::cin.tie(nullptr);
	std::ios_base::sync_with_stdio(false);
	std::cout << std::fixed << std::setprecision(15);
	Main();
}

Measured memory_bytes: 19256
a, b = map(int, input().split())
x1 = []
y1 = []
x2 = []
y2 = []
for i in range(a):
    x, y = map(int, input().split())
    x1.append(x)
    y1.append(y)


for j in range(b):
    x, y = map(int, input().split())
    x2.append(x)
    y2.append(y)
ans = -1
min=1000000000000
for i in range(a):
    for j in range(b):
        xx = x1[i] - x2[j]
        yy = y1[i] - y2[j]
        if(xx<0):
            xx= -xx
        if(yy<0):
            yy = -yy
        if(xx+yy<min):
            min=xx+yy
            ans=j+1
    print(ans)
    min = 100000000000
    ans=-1
    

Measured memory_bytes: 3064
#include <iostream>
#include <cstdio>
#include <string>
#include <cstring>
using namespace std;

int n, m, g, d;

int check(int line[30][10])
{
    int now = m-1;
    for (int i = 0; i < d; i++) {
        now += line[i][now];
    }
    return (now == g - 1) ? 1 : 0;
}

int main()
{
    while (1) {
        int line[30][10] = { 0 };
        string s;
        int flag = 0;
        // ??\???
        cin >> n;
        if (n == 0) break;
        cin >> m >> g >> d;
        memset(line, 0, sizeof(line));
        for (int i = 0; i < d; i++) {
            cin >> s;
            for (int j = 0; j < s.size(); j++) {
                if (line[i][j] != 0) continue;
                line[i][j] = s[j] - '0';
                line[i][j+1] = -(s[j] - '0');
            }
        }
        // ??????????????????
        if (check(line)) {
            puts("0");
            continue;
        }
        // ????????????
        for (int i = 0; i < d; i++) {
            for (int j = 0; j < n; j++) {
                if (line[i][j] != 0) continue;
                if (j > 0 && line[i][j - 1] == 1) continue;
                if (line[i][j + 1] != 0) continue;
                // ??????
                line[i][j + 1] = -1;
                line[i][j] = 1;
                // ?????????
                if (check(line)) {
                    printf("%d %d\n", i + 1, j + 1);
                    flag = 1;
                    break;
                }
                // ??????
                line[i][j + 1] = 0;
                line[i][j] = 0;
            }
            if (flag) break;
        }
        if (flag == 0) {
            puts("1");
        }
    }
    return 0;
}

Measured memory_bytes: 1204
import java.util.*;
public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int A = sc.nextInt();
        int B = sc.nextInt();
        int C = sc.nextInt();
        int[] num = new int[]{A,B,C};
        Arrays.sort(num);
        int ans = 0;
        if((num[1]-num[0])%2==0){
            ans+=(num[1]-num[0])/2;
            ans+=num[2]-num[1];
        }
        else{
            ans++;
            ans+=(num[1]-num[0]-1)/2;
            ans+=num[2]+1-num[1];
        }
        System.out.println(ans);
    }
}

Measured memory_bytes: 21844
import sys
reader = (s.rstrip() for s in sys.stdin)
input = reader.__next__

def unable():
    print(-1)
    exit()

n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))

from heapq import heappush, heappop
h = []
base = 10**6
for i in range(n):
    if a[i]>b[i]:
        unable()
    else:
        heappush(h, -(b[i]*base+i))

ans = 0
while h:
    k = heappop(h)
    i = -k%base
    cnt, mod = divmod(b[i]-a[i],b[i-1]+b[(i+1)%n])
    if cnt == 0:
        if mod != 0:
            unable()
    else:
        ans += cnt
        b[i] = a[i]+mod
        heappush(h, -(b[i]*base+i))
print(ans)


Measured memory_bytes: 121720
# -*- coding: utf-8 -*-
N = int(input())

import collections
s_frq_dict = collections.defaultdict(int)
for _ in range(N):
    s = [c for c in input()]
    s.sort()
    s_frq_dict[tuple(s)] += 1

ret = 0
for frq in s_frq_dict.values():
    ret += int(frq * (frq-1) * 0.5)

print(ret)

Measured memory_bytes: 118276
#include <stdio.h>
int main(){
  int H , W;
  while(1){
    scanf("%d %d",&H,&W);
    if(H == 0&& W == 0)break;
    for(int i = 0; i < H; i++){
      for(int k = 0;k < W; k++){
        printf("#");
      }
    printf("\n");
    }
    printf("\n");
  }
  return 0;
}

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

int main () {
    int h, w;
    cin >> h >> w;

    for (int i = 0; i < w + 2; i++) cout << "#";
    cout << endl;

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

    for (int i = 0; i < w + 2; i++) cout << "#";
    cout << endl;

    return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<cstdlib>
#include<cstring>
using namespace std;
inline int read()
{
	int x=0,f=1;char ch=getchar();
	while(ch<'0' || ch>'9'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0' && ch<='9')x=x*10+ch-'0',ch=getchar();
	return x*f;
}
int stack[20];
inline void write(int x)
{
	if(x<0){putchar('-');x=-x;}
	if(!x){putchar('0');return;}
	int top=0;
	while(x)stack[++top]=x%10,x/=10;
	while(top)putchar(stack[top--]+'0');
}
inline void pr1(int x){write(x),putchar(' ');}
inline void pr2(int x){write(x),puts("");}
const int mod=1000000007;
inline int ad(int x){return x>=mod?x-mod:x;}
inline int dec(int x){return x<0?x+mod:x;}
inline int power(int a,int b)
{
	int ans=1;
	while(b)
	{
		if(b&1)ans=1LL*ans*a%mod;
		a=1LL*a*a%mod;
		b>>=1;
	}return ans;
}
int fac[100010],inv[100010],f[100010];
inline int C(int n,int m){return 1LL*fac[n]*inv[m]%mod*inv[n-m]%mod;}
int main()
{
	//freopen("a.in","r",stdin);
	//freopen("a.out","w",stdout);
	fac[0]=1;
	for(int i=1;i<=100000;i++)fac[i]=1LL*fac[i-1]*i%mod;inv[100000]=power(fac[100000],mod-2);
	for(int i=100000;i>=1;i--)inv[i-1]=1LL*inv[i]*i%mod;
	for(int i=1;i<=100000;i++)f[i]=ad(f[i-1]+1LL*inv[i]*fac[i-1]%mod);
	int n=read(),ans=0,lt;
	for(int i=1;i<=n;i++)
	{
		int now=read();
		if(i>1)ans=ad(ans+1LL*(now-lt)*C(n-1,i-1)%mod*fac[n-i]%mod*f[i-1]%mod*fac[i-1]%mod);
		lt=now;
	}
	pr2(ans);
	return 0;
}

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

typedef long long ll;
typedef pair<int, int> P;
#define MOD 1e9+7;
#define INF (1 << 30)
#define REP(i,m,n) for(int i=(int)m; i < (int)n; ++i)
#define rep(i,n) REP(i,0,n)


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

    int n, a, b; cin >> n >> a >> b;
    cout << (n-a+1)*(n-b+1) << '\n';
    return 0;
}

Measured memory_bytes: 256
AKIBA = 'AKIHABARA'
s = input()

if s.replace('A', '') != 'KIHBR':
    print('NO')
    exit()
    
t = len(AKIBA)-len(s)
for i in range(len(AKIBA)):
    if i>len(s)-1 or s[i]!=AKIBA[i]:
        s = s[:i]+'A'+s[i:]
    
if s == AKIBA:
    print('YES')
else:
    print('NO')


Measured memory_bytes: 3060
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <numeric>
//#include <function>
using namespace std;
typedef long long unsigned int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

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


int main() {

  int N, M;
  cin >> N >> M;
  vector<pair<ll, ll>> A(N);
  REP(i, N) cin >> A[i].first >> A[i].second;

  sort(A.begin(), A.end(), [](pair<ll, ll> x, pair<ll, ll> y) { return x.first < y.first;});

  int res = M;
  ll price = 0LL;
  ll tmp;
  REP(i, N){
    if (res > A[i].second){
      res -= A[i].second;
      price += A[i].first * A[i].second;
    }else {
      price += res * A[i].first;
      break;
    }
  }
  //REP(i, N) cout << A[i].first << ":" <<A[i].second << endl;
  cout << price << endl;
  return 0;
}


Measured memory_bytes: 1792
const int N = 400005;
const int LG = 21;
const long long MOD = 1e9 + 7;
const long long INF = 1e9;
const long long INFLL = 1e18;

#include <iostream>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <algorithm>
#include <cmath>
#include <time.h>
#include <unordered_set>
#include <bitset>
#include <deque>

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<ll> vi;

#define forn(i, n) for (int (i) = 0; (i) != (n); (i)++)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define popcount(x) __builtin_popcount(x)
#define popcountll(x) __builtin_popcountll(x)
#define fi first
#define se second
#define re return
#define uniq(x) sort(all(x)); (x).resize(unique(all(x)) - (x).begin())

#ifdef LOCAL
#define dbg(x) cerr << __LINE__ << " " << #x << " " << x << endl
#define ln cerr << __LINE__ << endl
#else
#define dbg(x) void(0)
#define ln void(0)
#endif // LOCAL

int cx[4] = {-1, 0, 1, 0};
int cy[4] = {0, -1, 0, 1};

ll inq(ll x, ll y)
{
    if (!y) re 1 % MOD;
    ll l = inq(x, y / 2);
    if (y % 2) re l * l % MOD * x % MOD;
    re l * l % MOD;
}

ll rev(ll x)
{
    return inq(x, MOD - 2);
}

bool __precomputed_combinatorics = 0;
vector<ll> __fact, __ufact, __rev;

void __precompute_combinatorics()
{
    __precomputed_combinatorics = 1;
    __fact.resize(N);
    __ufact.resize(N);
    __rev.resize(N);
    __rev[1] = 1;
    for (int i = 2; i < N; i++) __rev[i] = MOD - __rev[MOD % i] * (MOD / i) % MOD;
    __fact[0] = 1, __ufact[0] = 1;
    for (int i = 1; i < N; i++) __fact[i] = __fact[i - 1] * i % MOD, __ufact[i] = __ufact[i - 1] * __rev[i] % MOD;
}

ll fact(int x)
{
    if (!__precomputed_combinatorics) __precompute_combinatorics();
    return __fact[x];
}

ll cnk(int n, int k)
{
    if (!__precomputed_combinatorics) __precompute_combinatorics();
    return __fact[n] * __ufact[n - k] % MOD * __ufact[k] % MOD;
}

signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    ll n;
    cin >> n;
    vector<ll> a(n);
    forn(i, n) cin >> a[i];
    sort(all(a));
    ll c = 0, d = 0;
    for (int i = 0; i + 1 < n; i++)
    {
        if (a[i] == a[i + 1])
        {
            if (c < d) c = a[i];
            else d = a[i];
            i++;
        }
    }
    cout << c * d;
}

/* Note:
Check constants at the beginning of the code.
    N is set to 4e5 but be careful in problems with large constant factor.
Check corner cases.
    N = 1
No def int long long for now.
Add something here.
*/


Measured memory_bytes: 1024
# -*- coding: utf-8 -*-


def count_rewrite_times(n, v, even, odd):
    ans = 0

    for x in range(n):
        if x % 2 == 0:
            if v[x] != even:
                ans += 1
        else:
            if v[x] != odd:
                ans += 1

    return ans


def main():
    from collections import Counter

    n = int(input())
    v = list(map(int, input().split()))

    if len(set(v)) == 1:
        print(n // 2)
        exit()
    else:
        even = Counter(v[::2]).most_common(1)[0][0]
        odd = Counter(v[1::2]).most_common(1)[0][0]

        if even == odd:
            even2 = Counter(v[::2]).most_common(2)[1][0]
            odd2 = Counter(v[1::2]).most_common(2)[1][0]

            print(min(count_rewrite_times(n, v, even, odd2),
                      count_rewrite_times(n, v, even2, odd)))
            exit()

        print(count_rewrite_times(n, v, even, odd))


if __name__ == '__main__':
    main()


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

int main() {
  int h, w, k;
  vector<vector<char>> c;
  vector<string> d;
  int counter;
  cin >> h >> w >> k;

  for (int i = 0; i < h; i++) {
    vector<char> tmp_v;
    string tmp;
    cin >> tmp;
    for (int j = 0; j < w; j++) {
      tmp_v.push_back(tmp[j]);
    }
    c.push_back(tmp_v);
  }

  int gcounter = 0;
  int h_pat = 1 << h;
  int w_pat = 1 << w;
  for (int i = 0; i < h_pat; i++) {
    for (int j = 0; j < w_pat; j++) {
      counter = 0;
      for (int k = 0; k < h; k++) {
        int pos_h = ((i >> k) & 0x1);
        for (int l = 0; l < w; l++) {
          int pos_w = ((j >> l) & 0x1);
          if (pos_h == 1 || pos_w == 1) {
            // no count
          } else {
            // count
            if (c[k][l] == '#') {
              counter++;
            }
          }
        }
      }
      if (counter == k) {
        gcounter++;
      }
    }
  }
  cout << gcounter << endl;
  return 0;
}

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

const int N = 500 + 10;
const int INF = int(1e9);

int n, c, a[N][N], d[N][N];
int num[N];
int cost[N][N];

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);

    cin >> n >> c;
    for (int i = 1; i <= c; i++)
        for (int j = 1; j <= c; j++) cin >> d[i][j];
    for (int i = 1; i <= n; i++)
        for (int j = 1; j <= n; j++) cin >> a[i][j];

    int ans = INF;
    for (int mod = 0; mod < 3; mod++) {
        memset(num, 0, sizeof(num));
        for (int i = 1; i <= n; i++)
            for (int j = 1; j <= n; j++)
                if ((i + j) % 3 == mod) num[a[i][j]]++;
        for (int i = 1; i <= c; i++) {
            int sum = 0;
            for (int j = 1; j <= c; j++)
                if (i != j) {
                    sum += num[j] * d[j][i];
                }
            cost[mod][i] = sum;
        }
    }

    for (int i = 1; i <= c; i++)
        for (int j = 1; j <= c; j++)
            for (int k = 1; k <= c; k++) {
                if (i == j || i == k || j == k) continue;
                ans = min(ans, cost[0][i] + cost[1][j] + cost[2][k]);
            }
    cout << ans << '\n';
    return 0;
}

Measured memory_bytes: 1280
#pragma GCC optimize(3, "Ofast", "inline")
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn = 100000 + 5;

int n;

int main() {	
    ios::sync_with_stdio(false);
    cin.tie(nullptr), cout.tie(nullptr);
    int x;
    cin >> x;
    if(x >= 30) cout << "Yes";
    else cout << "No";
    return 0;
}

Measured memory_bytes: 3612
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <string>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <list>
using namespace std;

typedef long long ll;

#define main() main(){
#define MOD 1000000007
#define p(x); cout << x << endl;
#define el cout << endl;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

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

    int a, b, c;
    cin >> a >> b >> c;

    if(b - a == c - b){
        p("YES")
    }else{
        p("NO")
    }
}


Measured memory_bytes: 256
#include<stdio.h>

int hantei(int *,int,int,int,int);
int main()
{
  int n,k,i;
  
  scanf("%d",&n);

  int a[n];

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

  scanf("%d",&k);

  int b[k];

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

  for(i = 0 ; i < k ; i++)
    {
      if(hantei(&a[0],b[i],0,n,0)==0) printf("no\n");
      else printf("yes\n");
    }
  
  return 0;
}

int hantei(int *a,int b,int i,int n,int res)
{
  if(b == 0) return 1;

  if(i >= n) return 0;

  res = hantei(&a[0],b,i + 1,n,res) || hantei(&a[0],b - a[i],i + 1,n,res);
  
    return res;
  
}



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

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

  ll ans=10000000000000;
  for (ll i=1; i*i<=n; i++) {
    if (n%i==0) {
      ans=min(ans, n/i+i-2);
    }
  }
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <cmath>
#include <numeric>
using namespace std;
#define rep(i,a,b) for(int64_t i=(a); i<(b); ++i) // a ≦ i < b 
#define Rrep(i,a,b) for(int64_t i=(a);i>=(b);--i) // reverse repeat. a から b まで減少．
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend() //逆イテレータ
#define RANGE(a,b,c) (a).begin()+b,(a).begin()+c // コンテナ a の 要素 b から c へのイテレータ
#define MOD 1000000007
#define INF 1000000000
typedef pair<int64_t, int64_t> PII;
typedef vector<int64_t> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef vector<PII> VP;

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

int64_t A, B, C, K; cin >> A >> B >> C >> K;

if (abs(A - B) > 1e18) cout << "Unfair\n";
else if (K % 2)  cout << B - A << endl;
else cout << A - B << endl;

}

// 書いて考える
// 境界，出力文字列 チェック
// 可読性優先．高速化次点．
// まずは全探索，分割統治，次にDP
// 制限を見る．境界に注意．求めたい量の変域．
// 偶奇，逆から，ソート，出現回数，出現位置，DP， 余事象，包除
// データ構造． 問題の特徴量．単調性，二分探索
// 存在判定：構成方法，入力の特徴
// gcd, lcm ,素因数分解．
// 例外を十分に含む一般化．想像力の限界
// 小さい系から例示
// 代数的処理
// 始めは過剰に例示・場合分けしてもいい．各場合を確実に対処．
// 自明な例から処理，除外．
// 小数のときは，精度の設定する．doubel 変数に数値を入力するときは 123. とする．
// テストケース作成は数表あり



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

using namespace std;

#define INF 1000000007
#define LINF (1LL << 62)
#define PI 3.14159265358979

typedef long long i64;
typedef pair<i64,i64> P;

inline i64 mod(i64 a, i64 m) { return (a % m + m) % m; }

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; }



int a,b;
void solve(){
	cin >> a >> b;
	if(a <= b) cout << "unsafe" << endl;
	else cout << "safe" << endl;
}

int main(){
	std::cin.tie(0);
	std::ios::sync_with_stdio(false);
	int t = 1;
	//cin >> t;
	while(t--){
		solve();
	}
	
	return 0;
}

Measured memory_bytes: 3608
def main():
    while True:
        pc, sdt = map(int, input().split())
        if pc == 0: break
        
        rec = int(input())
        log = [[] for i in range(sdt)]
        login = []
        
        for i in range(rec):
            # 時刻　PC　生徒　ログインアウト
            t,n,m,s = map(int, input().split())

            # ログイン情報の時
            if s == 1:
                login.append([t,n,m])

            else:
                for j in range(len(login)):
                    if login[j][1] == n:
                        log[m - 1].append([login[j][0], t])
                        del login[j]
                        break

        for i in range(len(log)):
            log[i] = sorted(log[i], key = lambda x:x[0])
            log[i] = flatter(log[i], 0)

        #print("")
        #print("log::")         
        #print(log)

        qtn = int(input())

        for i in range(qtn):
            # 始まり　終わり　生徒
            ts, te, mm = map(int, input().split())
            #print("question::")
            #print(ts,te,mm)
            summ = 0

            for item in log[mm - 1]:
                #print(log[mm - 1])
                summ += usetime(item, [ts, te])

            print(summ)
            #print("")
                

def flatter(listt, fromm):
    for i in range(len(listt) - 1):
        a = listt[i]
        b = listt[i + 1]
        if b[0] <= a[1]:
            if a[1] < b[1]: a[1] = b[1]
            del listt[i + 1]
            return flatter(listt, i)

    return listt

def usetime(log,qtn):
    logs = log[0]
    loge = log[1]
    fr = qtn[0]
    to = qtn[1]

    if fr <= logs and loge <= to:
        #print("case1")
        return loge - logs
    elif logs <= fr and to <= loge:
        #print("case2")
        return to - fr
    elif logs <= fr and fr <= loge and loge <= to:
        #print("case3")
        return loge - fr
    elif fr <= logs and logs <= to and to <= loge:
        #print("case4")
        return to - logs
    else:
        #print("case0")
        return 0
main()



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

char m[500][501], an1[500][501], an2[500][501];
bool r[500];
int h, w;

int main() {
	scanf("%d%d", &h, &w);
	f(i, 0, h) {
		scanf("%s", m[i]);
		f(j, 0, w) {
			if (i & 1)an2[i][j] = '#', an1[i][j] = '.';
			else an1[i][j] = '#', an2[i][j] = '.';
			if (m[i][j] == '#')an1[i][j] = an2[i][j] = '#', r[i] = true;
		}
	}
	f(i, 0, h)an1[i][0] = '#', an2[i][0] = '.', an1[i][w - 1] = '#', an2[i][w - 1] = '.';
	for (int i = 2; i < h; i += 2) {
		if (r[i])continue;
		f(j, 1, w - 1)if (m[i][j] == '.') {
			an1[i][j] = '.';
			an2[i][j] = '#';
			break;
		}
	}
	f(i, 0, h) {
		f(j, 0, w)printf("%c", an1[i][j]);
		printf("\n");
	}
	f(i, 0, h) {
		printf("\n");
		f(j, 0, w)printf("%c", an2[i][j]);
	}
}

Measured memory_bytes: 1408
#include <bits/stdc++.h>
using namespace std;
int main(){
    bool T=false;
    int K,A,B;cin>>K>>A>>B;
    for (int i = A; i <= B; i++)
    {
        if(i%K==0)T=true;
    }
    if(T)cout<<"OK";
    else cout<<"NG";
}

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

int main() {
  int N;
  int Y = 0;
  cin >> N;
  for (int i=0;i<N;i++){
    string S;
    cin >> S;
    if (S == "Y")
      Y++;
  }
  if (Y==0)
    cout << "Three"<< endl;
  else
    cout << "Four"<< endl;
}


Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<algorithm>

using namespace std;

const int MX=100111;
typedef long long LL;

int n,m,c[MX];
struct Edge{
	int t,w,nxt;
	Edge(int _t=0,int _w=0,int _nxt=0):t(_t),w(_w),nxt(_nxt){}
}e[MX<<1];
int ec,hed[MX];

inline void ade(int f,int t){
	e[++ec]=Edge(t,1,hed[f]),hed[f]=ec;
	e[++ec]=Edge(f,-1,hed[t]),hed[t]=ec;
}
int stk[MX],stc,E;
bool dfs(int k,int _c){
	bool r=false;
	c[k]=_c;stk[++stc]=k;
	for(int i=hed[k];i;i=e[i].nxt){
		E+=(e[i].w==1);
		if(c[e[i].t]==-1)r=dfs(e[i].t,(_c+e[i].w+3)%3)||r;
		else r=r||(c[e[i].t]!=(_c+e[i].w+3)%3);
	}
	return r;
}
int main(){
	scanf("%d%d",&n,&m);
	for(int i=1;i<=m;i++){
		static int a,b;
		scanf("%d%d",&a,&b);
		ade(a,b);
	}
	memset(c+1,-1,sizeof(int)*n);
	LL ans=0LL;
	for(int i=1;i<=n;i++)if(c[i]==-1){
		stc=0;E=0;
		bool flg=dfs(i,0);
		if(flg)ans+=(LL)stc*stc;
		else{
			int C[3]={0};
			for(int &i=stc;i;i--)C[c[stk[i]]]++;
			if(!C[0]||!C[1]||!C[2])ans+=E;
			else ans+=(LL)C[0]*C[1]+(LL)C[1]*C[2]+(LL)C[2]*C[0];
		}
	}
	printf("%lld\n",ans);
	return 0;
}


Measured memory_bytes: 8320
#include<bits/stdc++.h>
#define MOD (long long)(1e9+7)
using namespace std;
int n;
pair<int,int> a[105],b[105];
int main()
{
	cin >> n;
	for(int i=0; i<n; i++) cin >> a[i].first >> a[i].second;
	for(int i=0; i<n; i++) cin >> b[i].first >> b[i].second;
	sort(a,a+n);
	sort(b,b+n);
	int ans=0,vis[105]={0};
	for(int i=0; i<n; i++)
	{
		int maxd=-1,id=-1;
		for(int j=0; j<n; j++)
			if(!vis[j] && b[i].first>a[j].first && b[i].second>a[j].second && a[j].second>maxd)
			{
				
				maxd=a[j].second; id=j;
			}
		if(id>=0) vis[id]=1,ans++;
	}
	cout << ans;
	return 0;
}


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

int main(){
  string s,t, out = "No";
  cin >> s >> t;
  for(int i=0;i<s.length();++i){
    if(s == t){
      out = "Yes";
      break;
    } else {
      s.insert(0,s,s.size()-1,s.size());
      s.erase(s.size()-1);
    }
  }
  cout << out << endl;

  return 0;
}

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

int main() {
	int D;
	long long G;
	cin >> D >> G;
	vector<long long>P(D);
	vector<long long>C(D);
	for (int i = 0;i<D; ++i) {
		cin >> P[i] >> C[i];
	}
	long long Ans = 1e18;
	for (int i = 0;i<(1<<D);++i) {
		long long ans = 0;
		long long g = 0;
		for (int j = 0; j < D; ++j) {
			if (0 != ((i >> j) & 1)) {
				ans += P[j];
				g += P[j] * 100 * (j + 1) +C[j];
			}
		}		
		for (int j = D - 1; j >= 0; --j) {
			if (g < G) {
				if (0 == ((i >> j) & 1)) {
					long long count = (G - g) / (100 * (j + 1)); 
					if (0 != (G - g) % (100 * (j + 1))) {
						count++;
					}
					count = min(P[j]-1,count);
					ans += count;
					g += count * 100 * (j + 1);
				}
			}
		}	
		if (g >= G) {
			Ans = min(ans ,Ans);
		}
	}
	cout << Ans << endl;
}


Measured memory_bytes: 3616
#include <iostream>
#include <vector>
#include <math.h>

using namespace std;

int main(){
  int n,d;cin>>n>>d;
  vector<vector<int>> vec(n,vector<int>(d));
  for(int i=0;i<n;++i){
    for(int j=0;j<d;++j){
      cin>>vec[i][j];
    }
  }
  double dt = 0;
  int ans = 0;
  for(int i=0;i<n;++i){
    for(int j=0;j<n;++j){
      if(i==j) continue;
      if(i>j) continue;
      for(int k=0;k<d;++k){
        dt += pow(fabs(vec[i][k] - vec[j][k]),2);
      }
      dt = sqrt(dt);
      dt = dt - (int)dt;
      if(dt == 0) ++ans;
      dt = 0;
    }
  }

  cout << ans << endl;
  return 0;
}

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

using namespace std;

int main()
{
  int N, M, C; cin >> N >> M >> C;
  vector<int> B(M);
  for (int i = 0; i < M; ++i) {
    cin >> B[i];
  }

  vector<vector<int>> A(N, vector<int>(M));
  for (int i = 0; i < N; ++i) {
    for (int j = 0; j < M; ++j) {
      cin >> A[i][j];
    }
  }

  int result = 0;
  for (int i = 0; i < N; ++i) {
    int sum = 0;
    for (int j = 0; j < M; ++j) {
      sum += A[i][j] * B[j];
    }
    if (sum > -C) {
      result++;
    }
  }

  cout << result << endl;
}

Measured memory_bytes: 256
def bubbleSort(A,N):
    for i in range(0,N):
        for j in range(N-1,i,-1):
            if A[j][1] < A[j-1][1]:
                v = A[j]
                A[j] = A[j-1]
                A[j-1] = v
    return A

def selectionSort(A,N):
    for i in range(0,N):
        minj = i
        for j in range(i,N):
            if A[j][1] < A[minj][1]:
                minj = j
        v = A[i]
        A[i] = A[minj]
        A[minj] = v
    return A

if __name__ == '__main__':
    N = (int)(input())
    A1 = [[x[0],(int)(x[1])] for x in [list(x) for x in input().split()] ]
    A2 = A1.copy()

    resultA1 = bubbleSort(A1,N)
    resultA2 = selectionSort(A2,N)

    outputA1 = ' '.join( [x[0]+(str)(x[1]) for x in resultA1])
    outputA2 = ' '.join( [x[0]+(str)(x[1]) for x in resultA2])

    print(outputA1)
    print("Stable")
    print(outputA2)
    if outputA1 == outputA2 :
        print("Stable")
    else:
        print("Not stable")

Measured memory_bytes: 7852
n = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
k = int(input())
print(n[k-1])

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

int main(){
  char c;
  cin >> c;
  if((c=='a')+(c=='i')+(c=='e')+(c=='o')+(c=='u')){
      cout << "vowel" << endl;
      }
  else{
    cout << "consonant" << endl;
  }


}


Measured memory_bytes: 256