akhauriyash/Code-Regression huggingface dataset:
//#pragma GCC optimize ("Ofast")
//#pragma GCC optimize ("unroll-loops")
//#pragma GCC target("avx,avx2,fma")

#include <bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//#include <ext/rope>
#define pb push_back
#define F first
#define S second
#define ins insert
#define mp make_pair
#define fo(i, n1, n, x) for(int i = n1; i <= n; i += x)
#define foo(i, n, n1, x) for(int i = n; i >= n1; i -= x)
#define bit __builtin_popcount
#define md (l + ((r - l) / 2))
#define all(x) x.begin(),x.end()
#define eb emplace_back
#define ub upper_bound
#define lb lower_bound
#define ios ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define file(s) if (fopen(s".in", "r")) freopen(s".in", "r", stdin), freopen(s".out", "w", stdout)

using namespace std;
//using namespace __gnu_pbds;
//using namespace __gnu_cxx;


using ll = long long;

//#define int ll

using pii = pair<int,int>;
using pll = pair<ll,ll>;
using vi = vector<int>;



const int N = 2e5 + 11, mod = 1e9 + 7, mod2 = 998244353;
const int MAX = 1e5 + 11;
const int INF1 = 2e9 + 11;
const ll INF2 = 6e18 + 11;
const double INF3 = 1e8 + 11;
const int base = 500;
const int P = 31;
const int dx[] = {1, -1, 0, 0, 1, 1, -1, -1};
const int dy[] = {0, 0, 1, -1, 1, -1, 1, -1};
const double EPS = 1e-4;
const double PI = acos(-1.0);


//template<typename T> using ordered_set = tree <T, null_type, less <T>, rb_tree_tag, tree_order_statistics_node_update>;
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; }


mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

int s, w;
main() {
  file("threesum");
  ios;
  int n;map<string,bool> us;
  cin >> n;
  int ans = 0;
  while (n--) {
    string s;
  cin >> s;
    if (!us[s]) ++ans;
    us[s] = 1;
  }
  cout << ans;
  return 0;
}
/**

*/


Measured memory_bytes: 19248
#include <bits/stdc++.h>
using namespace std;
bool a[1000005],b[1000005];
const int mod=1e9+7;
int main()
{
	int n,m;
	cin>>n>>m;
	long long sum=1;
	for(int i=0;i<n;i++)
	{
		int x;
		cin>>x;
		if(a[x])
		{
			cout<<"0";
			return 0;
		}
		a[x]=1;
	}
	for(int i=0;i<m;i++)
	{
		int y;
		cin>>y;
		if(b[y])
		{
			cout<<"0";
			return 0;
		}
		b[y]=1;
	}
	int k1=0,t1=0;
	for(int i=n*m;i>0;i--)
	{
		int k2=k1,t2=t1;
		if(b[i])
		{
			k2=1;
			k1++;
		}
		if(a[i])
		{
			t2=1;
			t1++;
		}
		if(a[i]||b[i])
			sum*=(k2*t2)%mod;
		else
			sum*=(k2*t2-(n*m-i))%mod;
		sum%=mod;
	}
	cout<<sum%mod;

	return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <algorithm>
#include <vector>
using namespace std;
const int Maxn = 100010;
const int inf = 0x7fffffff;
int po[Maxn];
int f[1<<15], bit[1<<15], n;
vector <int> vec[20];
void down(int &x, int y) { if(x > y) x = y; }
int main() {
	int i, j, k;
	scanf("%d", &n);
	for(i = 1; i < n; i++){
		int x, y, d;
		scanf("%d%d%d", &x, &y, &d);
		po[x] ^= d; po[y] ^= d;
	}
	for(i = 1; i < 1<<15; i++){ bit[i] = bit[i>>1]+(i&1); vec[bit[i]].push_back(i); }
	int p = 0, ans = 0;
	for(i = 0; i < 1<<15; i++) f[i] = inf;
	for(i = 0; i < n; i++){
		if(!po[i]) continue;
		if(p&(1<<po[i]-1)) ans++;
		p ^= (1<<po[i]-1);
	}
	f[p] = 0;
	for(i = 15; i >= 1; i--){
		for(j = 0; j < vec[i].size(); j++){
			int x = vec[i][j];
			if(f[x] == inf) continue;
			for(k = 0; k < 15; k++){
				if(x&(1<<k)){
					for(int u = 0; u < 15; u++){
						if(k != u && x&(1<<u)){
							int t = (k+1)^(u+1);
							if(x&(1<<t-1)) down(f[x^(1<<k)^(1<<u)^(1<<(t-1))], f[x]+2);
							else down(f[x^(1<<k)^(1<<u)^(1<<(t-1))], f[x]+1);
						}
					}
				}
			}
		}
	}
	printf("%d\n", f[0]+ans);
	return 0;
}

Measured memory_bytes: 1024
#include <stdio.h>
#include <stdlib.h>
#include <iostream>
#include <math.h>
#include <algorithm>
#include <string>
#include <string.h>
#include <vector>
#include <functional>
#include <queue>
#include <unordered_set>
#include <climits>
#include <set>
#include <list>
#include <cmath>
#include <map>

using namespace std;
typedef long long ll;

int main()
{
	int D, T, S;
	cin >> D >> T >> S;
	if(T * S >= D){
		cout << "Yes" << endl;
	}else{
		cout << "No" << endl;
	}
	return 0;
}


Measured memory_bytes: 3624
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define REPS(i,n) for(int i=1;i<=(int)(n);i++)
using namespace std;
using ll = long long;
using ld = long double;

int main(void) {
    int N, M;
    cin >> N >> M;

    int ans = 0;
    if (N >= 2) {
        ans += N*(N-1) / 2;
    }
    if (M >= 2) {
        ans += M*(M-1) / 2;
    }

    cout << ans << endl;
}

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

#define pb push_back
#define P pair<int, int>
#define fi first
#define se second
#define INF (1 << 30)
#define REP(i, n) for (int i = 0; i < n; i++)

const int MAX_V = 100000;
struct edge {
  int to, cost;
};
int V;
vector<edge> G[MAX_V];
int d[MAX_V];

void bfs01(int s) {
  deque<P> que;
  fill(d, d + V, INF);
  d[s] = 0;
  que.push_back(P(0, s));
  while (!que.empty()) {
    P p = que.front();
    que.pop_front();
    int v = p.se;
    if (d[v] < p.fi) continue;
    for (int i = 0; i < G[v].size(); i++) {
      edge e = G[v][i];
      if (d[e.to] > d[v] + e.cost) {
        d[e.to] = d[v] + e.cost;
        if (e.cost == 0)
          que.push_front(P(d[e.to], e.to));
        else
          que.push_back(P(d[e.to], e.to));
      }
    }
  }
}

int main() {
  cin >> V;
  REP(i, V) {
    edge t;
    t.to = (i + 1) % V;
    t.cost = 1;
    G[i].pb(t);
  }
  REP(i, V) {
    edge t;
    t.to = (i * 10) % V;
    t.cost = 0;
    G[i].pb(t);
  }
  bfs01(1);
  cout << d[0] + 1 << endl;
  return 0;
}


Measured memory_bytes: 6528
#include <iostream>
#include <vector>

using namespace std;

int minus_manzoku(int c[], int last[], int d)
{
    int sum = 0;
    int i;
    for (i = 0; i < 26; i++) {
        sum += c[i] * (d - last[i]);
    }
    return sum;
}

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

    int c[26];
    int last[26];
    int i;
    for (i = 0; i < 26; i++) {
        cin >> c[i];
        last[i] = 0;
    }

    int s[D][26];
    int j;
    for (i = 0; i < D; i++) {
        for (j = 0; j < 26; j++) cin >> s[i][j];
    }

    int t[D];
    for (i = 0; i < D; i++) cin >> t[i];

    long score = 0;
    for (i = 0; i < D; i++) {
        last[t[i] - 1] = i + 1;
        score += s[i][t[i] - 1] - minus_manzoku(c, last, i + 1);
        cout << score << endl;
    }

    return 0;
}

Measured memory_bytes: 3588
import sys
import math
import copy
import random
from heapq import heappush, heappop, heapify
from functools import cmp_to_key
from bisect import bisect_left, bisect_right
from collections import defaultdict, deque, Counter
# sys.setrecursionlimit(1000000)

# input aliases
input = sys.stdin.readline
getS = lambda: input().strip()
getN = lambda: int(input())
getList = lambda: list(map(int, input().split()))
getZList = lambda: [int(x) - 1 for x in input().split()]

INF = float("inf")
MOD = 10**9 + 7
divide = lambda x: pow(x, MOD-2, MOD)

def nck(n, k, kaijyo):
    return (npk(n, k, kaijyo) * divide(kaijyo[k])) % MOD

def npk(n, k, kaijyo):
    if k == 0 or k == n:
        return n % MOD
    return (kaijyo[n] * divide(kaijyo[n-k])) % MOD

def fact_and_inv(SIZE):
    inv = [0] * SIZE  # inv[j] = j^{-1} mod MOD
    fac = [0] * SIZE  # fac[j] = j! mod MOD
    finv = [0] * SIZE  # finv[j] = (j!)^{-1} mod MOD
    inv[1] = 1
    fac[0] = fac[1] = 1
    finv[0] = finv[1] = 1
    for i in range(2, SIZE):
        inv[i] = MOD - (MOD // i) * inv[MOD % i] % MOD
        fac[i] = fac[i - 1] * i % MOD
        finv[i] = finv[i - 1] * inv[i] % MOD

    return fac, finv

def renritsu(A, Y):
    # example 2x + y = 3, x + 3y = 4
    # A = [[2,1], [1,3]])
    # Y = [[3],[4]] または [3,4]
    A = np.matrix(A)
    Y = np.matrix(Y)
    Y = np.reshape(Y, (-1, 1))
    X = np.linalg.solve(A, Y)

    # [1.0, 1.0]
    return X.flatten().tolist()[0]


class BIT():
    # A1 ... AnのBIT(1-indexed)
    def __init__(self, n):
        self.n = n
        self.BIT = [0] * (n + 2)

    # A1 ~ Aiまでの和 O(logN)
    def query(self, idx):
        res_sum = 0
        while idx > 0:
            res_sum += self.BIT[idx]
            idx -= idx & (-idx)
        return res_sum

    # Ai += x O(logN)
    def update(self, idx, x):
        # print(idx)
        while idx <= self.n:
            # print(idx)
            self.BIT[idx] += x
            idx += idx & (-idx)
        return

    def show(self):
        print(self.BIT)


def solve():
    n = getN()
    li = []
    for i in range(n):
        li.append(getN())

    slis = [0 for i in range(n+10)]

    for num in li:
        slis[num] = slis[num-1] + 1

    print(n - max(slis))


def main():
    n = getN()
    for _ in range(n):
        s = "".join([random.choice(["F", "T"]) for i in range(20)])
        print(s)
        solve(s, 1, 0)

    return
if __name__ == "__main__":
    # main()
    solve()

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

int main() {
  int64_t t1,t2,a1,a2,b1,b2;
  cin >> t1>>t2>>a1>>a2>>b1>>b2;
  a1 -= b1; a2 -= b2;
  int64_t l1 = a1*t1; int64_t l2 = a2*t2;
  if(l1+l2 == 0){
      cout << "infinity" << endl;
  }
  else{
      if(l1+l2 < 0){
          l1 *= -1; l2*= -1;
      }
      if(l1 == 0) cout << 1 << endl;
      else if(l1 > 0) cout << 0 << endl;
      else{
          int64_t k = l2/(l1+l2);
          if(l2%(l1+l2)==0) cout << 2*k-2 << endl;
          else cout << 2*k-1 << endl;
      }
  }
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;

public class Prog
{
    public static void Main()
    {
        //var input = Console.ReadLine().Split();
        //int[] X = Array.ConvertAll(input, int.Parse);
        string S = Console.ReadLine();
        int number = int.Parse(S);
        int back = number % 100;
        int front = (number - back) / 100;
        bool YYMM = true;
        bool MMYY = true;
        if(back > 0 && back < 13)
        {
            YYMM = true;
        }
        else
        {
            YYMM = false;
        }
        if(front > 0 && front < 13)
        {
            MMYY = true;
        }
        else
        {
            MMYY = false;
        }
        if(YYMM == true && MMYY == true)
        {
            Console.WriteLine("AMBIGUOUS");
        }else if(YYMM == false && MMYY == true)
        {
            Console.WriteLine("MMYY");
        }else if(YYMM == true && MMYY == false)
        {
            Console.WriteLine("YYMM");
        }
        else
        {
            Console.WriteLine("NA");
        }
    }
}

//Array.ConvertAll(int.Parse)

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

template <typename T> void chmin(T&x,const T &y)
{
	if(x>y)x=y;
}
template <typename T> void chmax(T &x,const T &y)
{
	if(x<y)x=y;
}
typedef long long s64;
typedef unsigned long long u64;
typedef unsigned int u32;
typedef pair<int,int> pii;
#define rep(i,l,r) for(int i=l;i<=r;++i)
#define per(i,r,l) for(int i=r;i>=l;--i)
#define rep0(i,l,r) for(int i=l;i<r;++i)
#define gc (c=getchar())
int read()
{
	char c;
	while(gc<'-');
	if(c=='-')
	{
		int x=gc-'0';
		while(gc>='0')x=x*10+c-'0';
		return -x;
	}
	int x=c-'0';
	while(gc>='0')x=x*10+c-'0';
	return x;
}
#undef gc

const int N=2e5+5;
int a[N],b[N],q[N];s64 s[N];

int main()
{
#ifdef kcz
	freopen("1.in","r",stdin);//freopen("1.out","w",stdout);
#endif
	int n;
	cin>>n;
	s64 sa=0,sb=0;
	rep(i,1,n)
	{
		scanf("%d%d",a+i,b+i);
		sa+=a[i];
		sb+=b[i];
		q[i*2-1]=a[i];q[i*2]=b[i];
	}
	sort(q+1,q+n*2+1);
	rep(i,1,n*2)s[i]=s[i-1]+q[i];
	s64 ans=min(sa,sb);
	rep(i,1,n)
	{
		int x=a[i],y=b[i];
		if(x>y)swap(x,y);
		int ax=lower_bound(q+1,q+n*2+1,x)-q,ay=lower_bound(q+ax+1,q+n*2+1,y)-q;
		chmin(ans,x+y+(ax>n-2?s[n-2]:(ay>n-1?s[n-1]-x:s[n]-x-y)));
	}
	cout<<ans;
}


Measured memory_bytes: 3328
#include<stdio.h>
#include<stdbool.h>
#define N 8
#define FREE -1
#define NOT_FREE 1

int row[N],col[N],dpos[2*N-1],dneg[2*N-1];
int X[N][N];

void initialize(){
  int i,j;
  for(i=0;i<N;i++){ row[i]=FREE, col[i]=FREE;}
  for(i=0;i<2*N-1;i++){ dpos[i]=FREE; dneg[i]=FREE;}
}
void printBoard(){
  int i,j;
  for(i=0;i<N;i++){
    for(j=0;j<N;j++){
      if(X[i][j]){
	if(row[i]!=j) return;
      }
    }
  }
  for(i=0;i<N;i++){
    for(j=0;j<N;j++){
      if(row[i]==j) printf("Q");
      else printf(".");
    }
    printf("\n");
  }
}

void recursive(int i){
  int j;
  if(i==N){
    printBoard(); return;
  }
  for(j=0;j<N;j++){
    if(NOT_FREE == col[j] || NOT_FREE == dpos[i+j] || NOT_FREE == dneg[i-j+N-1]) continue;
    row[i]=j;
    col[j]=dpos[i+j]=dneg[i-j+N-1]=NOT_FREE;
    recursive(i+1);
    row[i]=col[j]=dpos[i+j]=dneg[i-j+N-1]=FREE;
  }
}

int main(){
  int i,j,k,r,c;
  initialize();

  for(i=0;i<N;i++){
    for(j=0;j<N;j++){
      X[i][j]=0;
    }
  }
  scanf("%d",&k);
  for(i=0;i<k;i++){
    scanf("%d%d",&r,&c);
    X[r][c]=1;
  }

  recursive(0);

  return 0;
}



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

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

int main(void){
  int n, k;
  cin >> n >> k;

  vector<ll> s(n+1);
  s[0] = 0;
  rep(i, n){
    ll a;
    cin >> a;
    s[i+1] = (s[i] + a - 1) % k;
  }

  map<ll, ll> mp;
  queue<ll> q;
  ll ans = 0;
  rep(j, n+1){
    ans += mp[s[j]];
    mp[s[j]]++;
    q.push(s[j]);
    if(q.size() == k){
      mp[q.front()]--;
      q.pop();
    }
  }

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

Measured memory_bytes: 16000
import java.io.IOException;
import java.io.InputStream;
import java.util.*;
public class Main{
    public static void main(String[] args)throws Exception{
        FastScanner sc = new FastScanner();

        int n = sc.nextInt();

        int dp[][] = new int[n][3];

        for(int i = 0;i < 3;i++){
            dp[0][i] = sc.nextInt();
        }

        for(int i = 1;i < n;i ++){
            for(int j = 0;j < 3;j ++){
                switch (j){
                    case 0 :
                        dp[i][0] = sc.nextInt() + Math.max(dp[i-1][1],dp[i-1][2]);
                        break;
                    case 1 :
                        dp[i][1] = sc.nextInt() + Math.max(dp[i-1][0],dp[i-1][2]);
                        break;
                    case 2 :
                        dp[i][2] = sc.nextInt() + Math.max(dp[i-1][1],dp[i-1][0]);
                        break;
                }
            }
        }

        System.out.println(Math.max(dp[n-1][0],Math.max(dp[n-1][1],dp[n-1][2])));




    }
}

class FastScanner {
    private final InputStream in = System.in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;
    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        }else{
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }
    private int readByte() { if (hasNextByte()) return buffer[ptr++]; else return -1;}
    private static boolean isPrintableChar(int c) { return 33 <= c && c <= 126;}
    public boolean hasNext() { while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++; return hasNextByte();}
    public String next() {
        if (!hasNext()) throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while(isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }
    public long nextLong() {
        if (!hasNext()) throw new NoSuchElementException();
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while(true){
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            }else if(b == -1 || !isPrintableChar(b)){
                return minus ? -n : n;
            }else{
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }
    public int nextInt() {
        long nl = nextLong();
        if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) throw new NumberFormatException();
        return (int) nl;
    }
    public double nextDouble() { return Double.parseDouble(next());}
}

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

template <typename T>
void print(const T &v);

int main()
{
    int n;
    cin >> n;
    n %= 1000;
    if (n == 0)
    {
        cout << 0 << endl;
        return 0;
    }
    else
    {
        cout << 1000 - n << endl;
        return 0;
    }
}

// Use For Debug
template <typename T>
void print(T const &v)
{
    for (int i = 0; i < v.size(); i++)
    {
        if (i)
            cout << " ";
        cout << v[i];
    }
    cout << endl;
}

Measured memory_bytes: 3652
#include <bits/stdc++.h>
#define rep(X,N) for(ll X = 0; X < (N); X++)
#define PI (acos(-1.0))
#define pback push_back
#define mpair make_pair
#define divceil(A, B) ((A + (B - 1)) / B)
#define MODN 1000000007
#define ALL(V) (V).begin(),(V).end()
#define CERR if(false) cerr

typedef long long ll;

using namespace std;

int point2num(int y, int x, int width){
    return width * y + x;
}

int main(){

    int h,w;
    cin >> h >> w;

    vector<string> field;

    vector<vector<int>> d(h * w, vector<int>(h * w, INT_MAX / 2));

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

    rep(i,h){
        string tmp;
        cin >> tmp;

        field.pback(tmp);
    }

    rep(i, h){
        rep(j, w){

            if(field[i][j] == '.'){

                //cerr << point2num(i, j, w) << endl;
                d[point2num(i, j, w)][point2num(i, j, w)] = 0;

                rep(k, 4){
                    int tmpy = i + dy[k];
                    int tmpx = j + dx[k];

                    if(tmpx >= 0 && tmpx < w && tmpy >= 0 && tmpy < h && field[tmpy][tmpx] == '.'){
                        d[point2num(i, j, w)][point2num(tmpy, tmpx, w)] = 1;
                    }
                }
            }
        }
    }

    for(int k = 0; k < h * w; k++){
        for(int i = 0; i < h * w; i++){
            for(int j = 0; j < h * w; j++){
                d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
            }
        }
    }

    int ans = 0;

    for(int i = 0; i < h * w; i++){
        for(int j = 0; j < h * w; j++){
            //cerr << d[i][j] << " ";
            if(d[i][j] != INT_MAX/ 2){
                ans = max(ans, d[i][j]);
            }
        }
        cerr << endl;
    }

    cout << ans << endl;
    






    return 0;
}


Measured memory_bytes: 896
import operator


class SegmentTree:
    __slots__ = ('n', 'op', 'tree')

    def __init__(self, seq, op=operator.add):
        self.n = len(seq)
        self.op = op
        self.tree = [-1] * self.n + seq
        for i in reversed(range(1, self.n)):
            self.tree[i] = op(self.tree[2*i], self.tree[2*i+1])

    def modify(self, pos, val):
        assert pos < self.n
        pos += self.n
        self.tree[pos] = val
        while pos > 1:
            self.tree[pos//2] = self.op(self.tree[pos], self.tree[pos ^ 1])
            pos //= 2

    def query(self, L, R):
        assert L <= R and L >= 0 and R <= self.n
        res = 0
        L += self.n
        R += self.n
        while L < R:
            if L % 2 == 1:
                res = self.op(res, self.tree[L])
                L += 1
            if R % 2 == 1:
                R -= 1
                res = self.op(res, self.tree[R])

            L //= 2
            R //= 2

        return res


def solve(n, heights, beauty):
    dp = [0] * (n+1)
    st = SegmentTree(dp, op=max)

    for flower in range(n):
        pos = heights[flower]
        val = st.query(0, heights[flower]) + beauty[flower]
        st.modify(pos, val)

    return st.tree[1]


def main():
    n = int(input())
    heights = [int(c) for c in input().split()]
    beauty = [int(c) for c in input().split()]
    ans = solve(n, heights, beauty)
    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 121852
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD = 1000000007;
 
int main(){
    int N, K;
    cin >> N >> K;
    
    int count = 0;
    for(int i=1;i<=N;i+=2){
        count++;
        if(count == K){
            cout << "YES" << endl;
            return 0;
        } 
    }
        
    cout << "NO" << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#define _USE_MATH_DEFINES
#include<math.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);++i)
vector<vector<int>> path;
vector<bool> isvisited;

int dfs(int v, int p = -1) {
	bool visitall = true;
	for (bool u : isvisited) {
		if (!u)visitall = false;
	}
	if (visitall) {
		return 1;
	}
	int ret = 0;
	for(int u : path[v]) {
		if (u == p)continue;
		if (isvisited[u])continue;
		isvisited[u] = true;
		ret += dfs(u, v);
		isvisited[u] = false;
	}
	return ret;
}
int main() {
	int n,m;
	cin >> n >> m;
	path.resize(n);
	isvisited.resize(n);
	rep(i, n) {
		isvisited[i] = false;
	}
	int a, b;
	rep(i, m) {
		cin >> a >> b;
		--a; --b;
		path[a].push_back(b);
		path[b].push_back(a);
	}
	isvisited[0] = true;
	cout << dfs(0) << endl;
	return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
	Scanner sc = new Scanner(System.in);

	public static void main(String[] args) {
		new Main();
	}

	public Main() {
		new aoj0297().doIt();
	}
	class aoj0297 {
		void doIt() {
			int n  = sc.nextInt();
			for(int i = 0;i < n;i++){
				int a = sc.nextInt();
				int b = sc.nextInt();
				if(a % b == 0)System.out.println(b);
				else System.out.println((a % b));
			}
		}
	}
}

Measured memory_bytes: 20352
#include <stdio.h>

int main(void)
{
    int a, b, c;
    
    scanf("%d %d %d", &a, &b, &c);
    
    if ((a < b) && (b < c)) {
        printf("Yes\n");
    } else {
        printf("No\n");
    }

    return 0;
}


Measured memory_bytes: 2040
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <map>
#include <cmath>
#include <iomanip>
#include <queue>
#include <stack>
#include <functional>

using namespace std;
int main() {
	int ans = 700;
	string S;
	cin >> S;
	if (S[0] == 'o')ans += 100;
	if (S[1] == 'o')ans += 100;
	if (S[2] == 'o')ans += 100;
	cout << ans << endl;
	return 0;
}

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

#define rep(i, n) for(int i = 0; i < (n); ++i)
typedef long long ll;

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

  int n; cin >> n;
  vector<ll> a(3*n);
  rep(i, 3*n) cin >> a[i];
  sort(a.begin(), a.end());
  reverse(a.begin(), a.end());

  ll ans = 0;
  ll tmp = 1;
  for(int i = 1; ; i += 2) {
    if(tmp > n) break;
    ans += a[i];
    tmp++;
  }
  cout << ans << '\n';
  return 0;
}


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

int main(){
    int N,rs = 1,ans = 0;
    cin >> N;
    bool flag = false;
    bool son = false;
    vector<int> A(N);

    for(int i = 0;i < N;i++){
        cin >> A.at(i);
    }

    int i = 0;

        while(i < N){
            if(rs == A.at(i)){
                son = true;
                rs++;
            }else{
                ans++;
            }
            i++;
        }
        

    if(!son)
        cout << -1 << endl;
    else
        cout << ans << endl;
}

Measured memory_bytes: 1152
#include <cstdio>
#include <cstdint>
#include <iostream>
#include <iomanip>
#include <string>
#include <queue>
#include <stack>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <algorithm>
#include <utility>
#include <functional>
#include <cmath>
#include <climits>
#include <bitset>

#define ll long long int
#define pb push_back
#define mk make_pair
#define pq priority_queue

using namespace std;
typedef pair<int, int> P;
typedef pair<ll, int> Pl;
typedef pair<ll, ll> Pll;
const int inf = 1e9;
const ll linf = 1LL << 50;
const double EPS = 1e-10;

int main(int argc, char const* argv[])
{
  int n, l;
  cin >> n >> l;
  vector<ll> a;
  int at = -1;
  for(int i = 0; i < n; i++){
    ll x;
    cin >> x;
    a.pb(x);
  }
  for(int i = n - 1; i > 0; i--){
    if(a[i] + a[i - 1] >= l){
      at = i - 1;
      break;
    }
  }
  if(at == -1){
    cout << "Impossible" << endl;
    return 0;
  }
  cout << "Possible" << endl;
  for(int i = 0; i < at; i++){
    cout << i + 1 << endl;
  }
  for(int i = n - 2; i > at; i--){
    cout << i + 1 << endl;
  }
  cout << at + 1 << endl;
	return 0;
}


Measured memory_bytes: 1780
import sys
n=int(input())
px=0
py=0
pt=0
for i in range(n):
    t,x,y=map(int,input().split())
    if abs(x-px)+abs(y-py)>t-pt or (abs(x-px)+abs(y-py))%2!=(t-pt)%2:
        print('No')
        sys.exit()
    else:
        px=x
        py=y
        pt=t
print('Yes')

Measured memory_bytes: 3064
#!/mnt/c/Users/moiki/bash/env/bin/python
s = input()

i_t = 0
text="keyence"
continue_ = False

def check1(s, text):
    if s.find(text) == 0:
        return True
    else:
        return False
def check3(s, text):
    rev_text = text[::-1]
    rev_s    =    s[::-1]

    if rev_s.find(rev_text) == 0:
        return True
    else:
        return False

def check2(s, text):
    is_ok = False
    for i in range(1, 7): # 1 to 6
        first  = text[:i]
        second = text[i:]
        # print("first: ", first)
        # print("second: ", second)
        if check1(s, first) and check3(s,second):
            is_ok = True
            break
    if is_ok:
        return True
    else:
        return False

    
    
# print(check1(s, text) , check2(s, text) , check3(s, text))

if check1(s, text) or check2(s, text) or check3(s, text):
    print("YES")
else:
    print("NO")


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

int main(){
  int n;
  cin>>n;
  set<string>st;
  for(int i=0;i<n;i++){
    string s;
    cin>>s;
    st.insert(s);
    
  }
  cout<<st.size()<<endl;
}
  
 


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

#define int long long
#define endl "\n"
#define REP(i,a,n) for(int i=a;i<n;++i)
#define REPR(i,a,n) for(int i=a;i>n;--i)
#define RUP(a,b) ((a+b-1)/(b))
#define ALL(v) (v).begin(),(v).end()
#define pb push_back
#define mp make_pair
#define mt make_tuple
//#define MOD 1000000007
#define INF LLONG_MAX/2

typedef long long ll;
typedef pair<int,int> Pii;
typedef tuple<int,int,int> Tiii;
typedef vector<int> Vi;
typedef vector<Vi> VVi;
typedef vector<Pii> VPii;
typedef vector<string> Vs;

template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
template<class T> void YesNo(T a) {cout<<(a?"Yes":"No")<<endl;}
template<class T> void YESNO(T a) {cout<<(a?"YES":"NO")<<endl;}
void vin(Vi &v){REP(i,0,(v).size()) cin>>v[i];}
void vin(Vi &v,Vi &v2){REP(i,0,(v).size()) cin>>v[i]>>v2[i];}
void vout(Vi &v){for(int i=0;i<(v).size();i++) cout<<v[i]<<" ";cout<<endl;}
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int lcm(int a,int b){return a/gcd(a,b)*b;}
void uniq(Vi &v){sort(v.begin(),v.end()); v.erase(unique(v.begin(),v.end()),v.end());}
int ctoi(char c){if(c>='0'&&c<='9'){return c-'0';}return 0;}
void accum(Vi &v){REP(i,1,(v).size()) v[i]+=v[i-1];}
bool comp(Pii a,Pii b){
    if(a.second != b.second) return a.second<b.second;
    else return a.first<b.first;
}


void solve(std::string s){
    string t=s;
    reverse(ALL(t));
    int ans=0;
    REP(i,0,s.size()) if(s[i]!=t[i]) ans++;
    cout<<ans/2<<endl;
}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
signed main(){
    std::string S;
    std::cin >> S;
    solve(S);
    return 0;
}


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

int n, cnt;

void dfs(ll x, int f) {
    if(x > n) return;
    if(f == 7) cnt++;
    dfs(x * 10 + 3, f | 1);
    dfs(x * 10 + 5, f | 2);
    dfs(x * 10 + 7, f | 4);
}

int main() {
    cin >> n;
    dfs(0, 0);
    cout << cnt << endl;
}

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

#define ll long long
#define sd(x) scanf("%d", &(x))
#define pii pair<int, int>
#define F first
#define S second

#define TRACE

#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
	cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
	const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...)
#endif

int sdig(int n){
	int ret = 0;
	for(; n; n /= 10) ret += n % 10; return ret;
}
int main(){
	int n;
	cin >> n;
	int ans = 1e9;
	for(int a = 1; a <= n - 1; a++)
		ans= min(ans, sdig(a) + sdig(n-a));
	cout <<ans;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define sqr(x) ((x)*(x))
#define ll long long
#define ull unsigned long long
#define ui unsigned int
#define ld long double
#define vi vector<int>
#define pii pair<int,int>
#define pb push_back
#define mp make_pair
#define debuge cerr<<"isok"<<endl
#define debug(x) cerr<<#x<<"="<<x<<endl
#define SS second
#define FF first
#define ls (k<<1)
#define rs (k<<1|1)
#define inf 0x3f3f3f3f
#define clr(a,x) memset(a,x,sizeof(a))
#define cpy(a,x) memcpy(a,x,sizeof(a))
#define file(x) freopen(x".in","r",stdin),freopen(x".out","w",stdout);
using namespace std;

const int N=300005,M=100005,mod=1e9+7;
template<class T> inline void gmin(T &x,const T &y){if(x>y) x=y;}
template<class T> inline void gmax(T &x,const T &y){if(x<y) x=y;}
inline void ch(int &x,int y){x=(x+y)%mod;}
inline void read(int &x){
	x=0;char ch=getchar(),rev=0;
	while(ch>'9'||ch<'0') rev=(ch=='-'),ch=getchar();
	while(ch>='0'&&ch<='9') x=x*10+ch-'0',ch=getchar();
	x=rev?-x:x;
}
inline int exp(int x,int y){
	int ans=1;
	while(y){
		if(y&1) ans=(ll)ans*x%mod;
		x=(ll)x*x%mod;y>>=1;
	}return ans;
}
int w,h,n,cnt,ans,x[N],y[N],yy[N],sta[N][2],g[N][2],top[2];
int p[N<<2],flag[N<<2];

inline int get(int y){return lower_bound(yy+1,yy+cnt+1,y)-yy;}
inline void add(int k,int b){p[k]+=b;flag[k]+=b;}
inline void push(int k){
	if(!flag[k]) return;
	add(ls,flag[k]);add(rs,flag[k]);
	flag[k]=0;
}
inline void ch(int l,int r,int x,int y,int k,int b){
	if(x<=l&&r<=y){add(k,b);return;}
	push(k);
	int mid=l+r>>1;
	if(x<=mid) ch(l,mid,x,y,ls,b);
	if(y>mid) ch(mid+1,r,x,y,rs,b);
	p[k]=max(p[ls],p[rs]);
}
inline void build(int l,int r,int k){
	flag[k]=0;
	if(l==r){p[k]=-yy[l-1];return;}
	int mid=l+r>>1;
	build(l,mid,ls);build(mid+1,r,rs);
	p[k]=max(p[ls],p[rs]);
}
inline void solve(int mid){
	clr(flag,0);clr(top,0);
	for(int i=1;i<=n;i++)
		yy[i]=y[i];
	sort(yy+1,yy+n+1);
	cnt=n;
	yy[0]=0;yy[cnt+1]=h;
	for(int i=1;i<=cnt+1;i++) gmax(ans,(w+yy[i]-yy[i-1])*2);
	build(1,cnt,1);
	for(int i=1;i<=cnt;i++)
		g[i][0]=mid,g[i][1]=w-mid;
	for(int i=1;i<=n;i++)
		if(x[i]<=mid) gmin(g[get(y[i])][0],mid-x[i]); else gmin(g[get(y[i])][1],x[i]-mid);
	cerr<<clock()*1000/CLOCKS_PER_SEC<<endl;
	for(int i=1;i<=cnt;i++){
		for(int x=0;x<2;x++){
			int last=i;
			ch(1,cnt,i,i,1,g[i][x]);
			while(top[x]&&g[sta[top[x]][x]][x]>g[i][x]){
				int l=sta[top[x]-1][x]+1,r=sta[top[x]][x];
				ch(1,cnt,l,r,1,g[i][x]-g[r][x]);
				top[x]--;
			}
			sta[++top[x]][x]=i;
		}
		gmax(ans,(p[1]+yy[i+1])*2);
	}
	cerr<<clock()*1000/CLOCKS_PER_SEC<<endl;
}

int main(){
#ifdef rqgao2014
	freopen("input.txt","r",stdin);
#endif
	scanf("%d%d%d",&w,&h,&n);
	int m=0;
	for(int i=1;i<=n;i++){
		scanf("%d%d",&x[i],&y[i]);
		if(x[i]>0&&x[i]<w&&y[i]>0&&y[i]<h) x[++m]=x[i],y[m]=y[i];
	}n=m;
	if(!n){printf("%d\n",(w+h)*2);return 0;}
//	for(int i=1;i<=n;i++) printf("%d %d\n",x[i],y[i]);
	solve(w/2);
	for(int i=1;i<=n;i++)
		swap(x[i],y[i]);
	swap(w,h);solve(w/2);
	printf("%d\n",ans);
	return 0;
}	

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

using namespace std;

int main() {

	// freopen("input.txt", "r", stdin);
	// freopen("output.txt", "w", stdout);

	int a, b;
	cin >> a >> b;
	int c;
	c = max(a + b, a - b);
	cout << max(c, a * b) << "\n";
	return 0;
}

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

using namespace std;

typedef long long ll;
typedef vector<int> pi;
typedef pair<int,int> vi;

#define F first
#define S second
#define PB push_back
#define MK make_pair
#define REP(i, a, b) for (int i=a; i < b; i++)


bool sort_by(vi c, vi d){
	return c.S < d.S;
}

int main() {
	int s, w; 
	cin >> s >> w;
	
	if(s <= w) cout << "unsafe";
	else cout << "safe";

}


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


int main() {
    int k, s;

    std::cin >> k >> s;

    std::map<int, int> m;

    for (int i = 0; i <= k; i++) {
        for (int j = 0; j <= k; j++) {
            m[i + j]++;
        }
    }

    long long sum = 0;
    for (auto it = m.begin(); it != m.end(); it++) {
        if (s - it->first >= 0 && s - it->first <= k) {
            sum += it->second;
        }
    }

    std::cout << sum << std::endl;
    return 0;
}

Measured memory_bytes: 512
n = input()
s = raw_input()
cnt = 0
for i in range(n):
    judge = False
    p = raw_input()
    for j in range(1, len(p)):
        for k in range(len(p)):
            for l in range(len(s)):
                if k+l*j < len(p) and p[k+l*j] == s[l]:
                    if l+1 >= len(s): judge = True
                    continue
                break
    if judge == True: cnt += 1
print cnt

Measured memory_bytes: 6464
import java.io.IOException;
import java.io.InputStream;
import java.util.*;
import java.lang.Math;

public class Main {
    public static void main(String[] args) {
        FS reader = new FS();
        // write reader
        int N = reader.nextInt();
        int W = reader.nextInt();
        long[] w = new long[N];
        long[] v = new long[N];
        for (int i=0; i<N; i++) {
            w[i] = reader.nextLong();
            v[i] = reader.nextLong();
        }

        // dp[i][j] : max value till use ith item and weight is j
        long[][] dp = new long[N+1][W+1];
        for (int i=0; i<N; i++) {
            for (int j=0; j<=W; j++) {
                dp[i+1][j] = dp[i][j];
                if (0 <= j-w[i]) dp[i+1][j] = Math.max(dp[i+1][j], dp[i][j-(int)w[i]]+v[i]);
            }
        }
        System.out.println(dp[N][W]);
    }

    // Read Class
    static class FS {
        private final InputStream in = System.in;
        private final byte[] buffer = new byte[1024];
        private int ptr = 0;
        private int buflen = 0;
        private boolean hasNextByte() {
            if (ptr < buflen) {
                return true;
            } else {
                ptr = 0;
                try {
                    buflen = in.read(buffer);
                } catch (IOException e) {
                    e.printStackTrace();
                }
                if (buflen <= 0) {
                    return false;
                }
            }
            return true;
        }
    
        private int readByte() { return hasNextByte() ? buffer[ptr++] : -1;}
        private boolean isPrintableChar(int c) {return 33 <= c && c <= 126;}
        private void skipUnprintable() {while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++;}
    
        public boolean hasNext() { skipUnprintable(); return hasNextByte();}
        public String next() {
            if (!hasNext()) throw new NoSuchElementException();
            StringBuilder sb = new StringBuilder();
            int b = readByte();
            while(isPrintableChar(b)) {
                sb.appendCodePoint(b);
                b = readByte();
            }
            return sb.toString();
        }
        public int nextInt() {
            return (int)nextLong();
        }
        public long nextLong() {
            if (!hasNext()) throw new NoSuchElementException();
            long n = 0;
            boolean minus = false;
            int b = readByte();
            if (b == '-') {
                minus = true;
                b = readByte();
            }
            if (b < '0' || '9' < b) {
                throw new NumberFormatException();
            }
            while(true) {
                if ('0' <= b && b <= '9') {
                    n *= 10;
                    n += b - '0';
                } else if(b == -1 || !isPrintableChar(b)) {
                    return minus ? -n : n;
                } else {
                    throw new NumberFormatException();
                }
                b = readByte();
            }
        }
    }
}



Measured memory_bytes: 127060
#include <bits/stdc++.h>
#define rep(i,N) for(int i=0;i<N;i++)
#define rep2(i,N) for(int i=1;i<=N;i++)
using namespace std;
long long  INF=1000000000000000000;
long long mod=1000000007;
using namespace std;


int main(){


long long ans=0;

int N;
cin>>N;
long long x;
cin>>x;
long long A[N];

rep(i,N){
    cin>>A[i];
}
long long zero=0;
for(int i=1;i<N;i++){
    long long sum=A[i-1]+A[i];
    if(sum>x){
        ans+=sum-x;
        A[i]=max(zero,A[i]-(sum-x));
    }
    
}

//rep(i,N)cout<<A[i]<<" ";
cout<<ans<<endl;

return 0;
}
/*
3 3
2 2 2

1

6 1
1 6 1 2 0 4

11

5 9
3 1 4 1 5

0

2 0
5 5

10

*/


Measured memory_bytes: 1024
#include <cstdio>

int main() {
	int n; scanf("%d", &n);
	int maxv = 0;
	long long ans = 0;
	while (n--) {
		int x; scanf("%d", &x);
		if (x >= maxv)
			maxv = x;
		else
			ans += maxv - x;
	}
	printf("%lld\n", ans);
	return 0;
}



Measured memory_bytes: 1728
N, M, Q = map(int, input().split())

X = []
for _ in range(Q):
    X.append(list(map(int, input().split())))

from itertools import combinations_with_replacement
C = combinations_with_replacement(range(1, M + 1), N)

ans = -1
for c in C:
    score = 0
    for x in X:
        if (c[x[1] - 1] - c[x[0] - 1]) == x[2]:
            score += x[3]
    if ans < score:
        ans = score

print(ans)




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

int main() {
  string s; cin >> s;
  
  int w_cnt = 0, b_cnt = 0;
  for (int i = 0; i < s.size(); ++i) {
    char color = s[i];
    if (i % 2 == 0) {
      if (color == '1') ++b_cnt;
      else if (color == '0') ++w_cnt;
    }
    else {
      if (color == '1') ++w_cnt;
      else if (color == '0') ++b_cnt;
    }
  }
  cout << min(w_cnt, b_cnt) << endl;
  
  return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
typedef long long LL;
#define SORT(c) sort((c).begin(),(c).end())

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

using namespace std;
int main(void)
{
  for(;;){
    int n;
    cin >> n;
    if(!n) return 0;
    vector<string> vs(n);
    REP(i,n) cin >> vs[i];
    vector<int> dots(n,0);
    REP(i,n) for(auto c:vs[i]) if(c=='.') ++dots[i];
    REP(i,n) for(int j=i-1;j>=0;--j){
      if(dots[i]>=dots[j]) break;
      vs[j][dots[i]-1]='|';
    }
    REP(i,n) vs[i][dots[i]-1]='+';
    REP(i,n) for(auto &c:vs[i]) if(c=='.') c=' ';
    REP(i,n) cout << vs[i] << endl;
  }
}

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

#define int long long
#define vvi vector<vector<int>>
#define vec vector
#define pq priority_queue
#define all(v) (v).begin(), (v).end()
#define uniqueV(x) sort(x.begin(), x.end()); x.erase(unique(x.begin(), x.end()), x.end());
#define rep(i, n) for (int (i) = (0); (i) < (n); ++(i))
#define repp(i, m, n) for (int (i) = (m); (i) < (n); ++(i))
#define dbg(x) cerr << #x << ": " << x << endl;
#define dbg2(x, y) cerr<<"("<<#x<<", "<<#y<<") = "<<"("<<x<<", "<<y<<")"<<endl;
#define dbg3(x, y, z) cerr<<"("<<#x<<", "<<#y<<", "<<#z<<") = "<<"("<<x<<", "<<y<<", "<<z<<")"<<endl;
#define dbgB(value, size) cerr<<#value<<": "<<bitset<size>(value) << endl;
#define line() cerr << "---------------" << endl;

const int dx[] = {1, -1, 0, 0};
const int dy[] = {0, 0, -1, 1};
const double PI = 3.14159265358979323846;

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

template<typename T>
void print1(T begin, T end) {
  while (begin != end) {
    cout << (*begin) << " ";
    *begin++;
  }
  cout << endl;
}

template<typename T>
void print2(T Array, int height, int width) {
  for (int i = 0; i < height; i++) {
    for (int j = 0; j < width; j++) {
      cout << " " << Array[i][j];
    }
    cout << endl;
  }
}

void print() { std::cerr << endl; }
template <class Head, class... Tail>
void print(Head&& head, Tail&&... tail) {
  std::cerr << head << " ";
  print(std::forward<Tail>(tail)...);
}

template<class T>
void Add(T &a, const T &b, const T &mod=1000000007) {
  int val = ((a % mod) + (b % mod)) % mod;
  if (val < 0) { val += mod; }
  a = val;
}

template <typename X, typename T> auto vectors(X x, T a) { return vector<T>(x, a); }
template <typename X, typename Y, typename Z, typename... Zs> auto vectors(X x, Y y, Z z, Zs... zs) { auto cont = vectors(y, z, zs...); return vector<decltype(cont)>(x, cont); }

// ------------------------------------------------------------------------------------------

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

  vec<pair<int, int>> ans;
  if (n % 2 == 0) {
    for (int i = 1; i <= n; i++) {
      for (int j = i+1; j <= n; j++) {
        if (i + j == n+1) continue;
        ans.push_back({i, j});
      }
    }
  } else {
    for (int i = 1; i <= n; i++) {
      for (int j = i+1; j <= n; j++) {
        if (i + j == n) continue;
        ans.push_back({i, j});
      }
    }
  }

  cout << ans.size() << endl;
  for (auto x : ans) {
    cout << x.first << " " << x.second << endl;
  }

  return 0;
}

Measured memory_bytes: 512
#include<stdio.h>
int main()
{
  char S[200001]={0},T[200001]={0};
  scanf("%s %s",&S,&T);
  int count=0;
  for(int i=0;i<200001;i++){
    if(S[i]!=T[i]) count++;
  }  
  printf("%d",count);
}

Measured memory_bytes: 2088
N,M=map(int,input().split())
L=[]
R=[]
for i in range(M):
  l,r=map(int,input().split())
  L.append(l)
  R.append(r)
count=0
if max(L)>min(R):
  print(0)
else:
  print(min(R)-max(L)+1)

Measured memory_bytes: 10996
#include<bits/stdc++.h>
#define ll long long
const int INF = 1e9 + 5;
using namespace std;

int main()
{
    ios_base::sync_with_stdio(false) ;
    cin.tie(NULL) ;
    cout.tie(NULL) ;
    
    int n, w;
    scanf("%d%d", &n, &w);
    vector<ll> dp(w + 1); 
    
    for(int i1 = 0; i1 < n; i1++) 
    {
        int weight, value;
        scanf("%d%d", &weight, &value);

        for(int i = w - weight; i >= 0; i--) 
        {
            dp[i + weight] = max(dp[i + weight], dp[i] + value);
        }
    }

    ll answer = 0;
    for(int i = 0; i <= w; ++i) 
        answer = max(answer, dp[i]);

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

    return 0;
}

Measured memory_bytes: 1024
#include<stdio.h>
#include<string.h>

int main(void) {
	int n,c = 0;
	int t[256];
	char s[256][256] , x[256];
	
	scanf("%d",&n);
	
	for (int i = 0; i < n; i++) {
		scanf("%s", s[i]);
		scanf("%d", &t[i]);
	}
	scanf("%s", x);

	for (int i = 0; i < n; i++) {
		if (strcmp(x,s[i]) == 0) {
			for (int j = i + 1; j < n; j++) {
				c += t[j];
			}
			break;
		}
	}
	printf("%d\n", c);
	
	return 0;
}

Measured memory_bytes: 128
#include<stdio.h>
int main(){
int a,b,plus,minus,into;
scanf("%d %d",&a,&b);
plus=a+b;
minus=a-b;
into=a*b;
if(plus>=minus&&plus>=into){printf("%d\n",plus);}

else if(minus>=plus&&minus>=into){printf("%d\n",minus);}

else if(into>=plus&&into>=minus){printf("%d\n",into);}

return 0;
}


Measured memory_bytes: 128
using System;
using System.Linq;

namespace _003_IsitaRightTriangle
{
	class Program
	{
		static void Main ( string[] args )
		{
			int inputCount = int.Parse (Console.ReadLine ());

			for (int lp = 0; lp < inputCount; lp++)
			{
				int[] inputNum = Console.ReadLine ().Split (' ').Select (str => int.Parse (str)).ToArray ();
				Array.Sort (inputNum);

				bool isTriangle = inputNum[0] * inputNum[0] + inputNum[1] * inputNum[1] == inputNum[2] * inputNum[2];

				if (isTriangle)
					Console.WriteLine ("YES");
				else
					Console.WriteLine ("NO");
			}
		}
	}
}

Measured memory_bytes: 9560
while True:
    a,b,c=map(int,input().split())
    if a==-1 and b==-1 and c==-1:
        break
    elif a==-1 or b==-1:
        print("F")
    elif a+b>=80:
        print("A")
    elif a+b>=65:
        print("B")
    elif a+b>=50:
        print("C")
    elif a+b>=30 and c<50:
        print("D")
    elif a+b>=30 and c>=50:
        print("C")
    elif a+b<30:
        print("F")


Measured memory_bytes: 5592
def gcd(a, b)
    if(b == 0) then
      return a.to_i;
    end
    return gcd(b, a%b);
end

def lcm(a, b) 
    return a/gcd(a,b)*b;
end

def main()
  _n= gets.to_i
  a= gets.chomp.split(" ").map(&:to_i)
  mod=10**9+7
  lcmNum=1
  
  a.each do |i|
    lcmNum=lcm(lcmNum, i);
  end
  ans=0
  a.each do |i|
    ans+=(lcmNum.to_i/i.to_i)
  end
  puts ans%mod
end
main()


Measured memory_bytes: 63520
public class Main{
    public static void main(String[] args) {
        java.util.Scanner sc = new java.util.Scanner(System.in);
        long D = sc.nextLong();
        long N = sc.nextLong();
        if(D == 0){
            if(N < 100){
                System.out.println(N);
            }else{
                System.out.println(100+1);
            }
        }else if(D == 1){
            if(N < 100){
                System.out.println(N*100);
            }else{
                System.out.println(100*100+100);
            }
        }else{
            if(N < 100){
                System.out.println(N*100*100);
            }else{
                System.out.println(100*100*100+10000);
            }
        }
         
    }
}

Measured memory_bytes: 21844
#include<bits/stdc++.h>
using namespace std;
#define inf 0x3f3f3f3f
#define ll long long
const int N=200005;
const int mod=1e9+7;
const double eps=1e-8;
const double PI = acos(-1.0);
#define lowbit(x) (x&(-x))
ll gcd(ll a,ll b){return b==0?a:gcd(b,a%b);}
ll qpow(ll a,ll b){ll res=1;while(b){if(b&1) res=res*a%mod;a=a*a%mod;b>>=1;}return res;}
ll inv(ll a,ll p){return qpow(a,p-2);}
int main()
{
    std::ios::sync_with_stdio(false);
    string s;
    while(cin>>s)
    {
        map<char,int> m;
        int l=s.length();
        for(int i=0;i<l;i++)
        {
            m[s[i]]++;
        }
        int flag=0;
        for(map<char,int>::iterator it=m.begin();it!=m.end();it++)
        {
            if((*it).second&1)
            {
                flag=1;
                break;
            }
        }
        if(!flag)
            cout<<"Yes"<<endl;
        else
            cout<<"No"<<endl;
    }
    return 0;
}


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

ll solve() {
    string S;
    cin >> S;
    ll ans = 0;
    for ( char c : S ) {
        ans += (ll)(c-'0');
    }
    return ans;
}

int main() {
    auto ans = solve();
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 256
import math
n,k = map(int,input().split())
for i in range(1,k+1):
    if n-k-i+1 < 0:
        print(0)
        continue
    c = math.factorial(n-k+1)//(math.factorial(i)*math.factorial(n-k+1-i))
    h = math.factorial(k-1)//(math.factorial(k-i)*math.factorial(i-1))
    print((c*h)%(10**9+7))


Measured memory_bytes: 3316