akhauriyash/Code-Regression huggingface dataset:
n = int(input())
red = [tuple(int(x) for x in input().split()) for _ in range(n)]
blue = [tuple(int(x) for x in input().split()) for _ in range(n)]

red = sorted(red)
blue = sorted(blue)

ans = 0
for x, y in blue:
    if x == 0:
        continue
    else:
        temp = [-1, -1]
        for a, b in red:
            if a > x:
                break
            elif y > b > temp[1]:
                temp = [a, b]
        if temp[1] >= 0:
            ans += 1
            red.remove((temp[0], temp[1]))

print(ans)

Measured memory_bytes: 3064
import java.util.*;

public class Main {
	public static void main(String[] args) throws Exception{
		Scanner scn = new Scanner(System.in);
		int n = scn.nextInt();
		int[] a = new int[n];
		for(int i=0; i<a.length; i++){
			a[i] = scn.nextInt();
		}
      	Arrays.sort(a);
      	String ans = "YES";
      	for(int i=1; i<a.length; i++){
			if(a[i]==a[i-1]) ans = "NO";
		}
      	System.out.println(ans);
	}
}


Measured memory_bytes: 60860
import re
import sys
import math
import itertools
import bisect
from copy import copy
from collections import deque,Counter
from decimal import Decimal
import functools
def v(): return input()
def k(): return int(input())
def S(): return input().split()
def I(): return map(int,input().split())
def X(): return list(input())
def L(): return list(input().split())
def l(): return list(map(int,input().split()))
def lcm(a,b): return a*b//math.gcd(a,b)
sys.setrecursionlimit(10 ** 9)
mod = 10**9+7
cnt = 0
ans = 0
inf = float("inf")

n,k=I()
a = l()
town = []
num = [0]*(n+1)
cnt = 1
num[0]=1

for i in range(n):
    num[a[cnt-1]] += 1
    if num[a[cnt-1]] == 2:
        ans = a[cnt-1]
        p = town.index(ans)
        b = town[p:]
        x = len(town)
        y = len(b)
        q = k-x+y
        if y == 0:
            print(town[n-1])
            sys.exit()
        if q < 0:
            print(town[k-1])
            sys.exit()
        z = q%y
        print(b[z-1])
        sys.exit()
        break
    town.append(a[cnt-1])
    cnt = a[cnt-1]


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

int main()
{
    int n, m; cin>>n>>m;
    int c[n]={}, a[n]={};
    for(int& e: c) e=1;
    a[0]=1;
    while (m--) {
        int x, y; cin>>x>>y;
        --c[--x], ++c[--y];
        if (a[x]) a[y]=1;
        if (!c[x]) a[x]=0;
    }
    int res=0;
    for(int e: a) res+=e;
    cout<<res<<endl;
}


Measured memory_bytes: 1024
#pragma region header
#define _GLIBCXX_DEBUG 
#include <bitset>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <cctype>
#include <assert.h>
#include <stdlib.h>
#include <stdio.h>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <limits>
#include <map>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
#include <math.h>
using namespace std;
#define int long long
signed main() {
    int K,X;
    cin>>K>>X;

    for(int i=X-K+1;i<=X+K-1;i++){
        cout<<i<<" ";
    }
}

Measured memory_bytes: 3620
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n - 1; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i <= n; i++)
#define FORR(i, m, n) for(int i = m; i >= n; i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
 
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<ll, ll>;

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

    ll h, w, d;
    cin >> h >> w >> d;
    ll a;
    vector<P> p(h * w);
    REP(i, h){
        REP(j, w){
            cin >> a;
            a--;
            p[a] = P(i, j);
        }
    }
    ll t = w * h + 1, flg = 0;
    vll dist(t);
    REP(j, t){
        REP(i, d){
            if((j + 1) * d + i == h * w){
                flg = 1;
                break;
            }
            ll cy = p[j * d + i].first, cx = p[j * d + i].second;
            ll ny = p[(j + 1) * d + i].first, nx = p[(j + 1) * d + i].second;
            dist[(j + 1) * d + i] = dist[j * d + i] + abs(ny - cy) + abs(nx - cx);
        }
        if(flg) break;
    }
    ll q, l, r;
    cin >> q;
    REP(i, q){
        cin >> l >> r;
        l--;
        r--;
        ll res = dist[r] - dist[l];
        cout << res << endl;
    }
}

Measured memory_bytes: 3200
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cmath>

using namespace std;

int main() {
    int n, m;
    cin >> n >> m;
    vector<int> a(m), b(m);
    for (int i = 0; i < m; i++) {
        cin >> a.at(i) >> b.at(i);
    }

    vector<int> cnt(n, 0);
    for (int i = 0; i < m; i++) {
        cnt.at(a.at(i)-1)++;
        cnt.at(b.at(i)-1)++;
    }

    for (int i = 0; i < n; i++) {
        cout << cnt.at(i) << endl;
    }
}


Measured memory_bytes: 256
#include <stdio.h>

int main() {
    int a[10];
    int b;
    int i;
    int j;
    
    for(i=0;i<10;i++){
        scanf("%d", &a[i]);
    }
    
    for(i=0; i<10; i++){
        for(j=i+1; j<10; j++){
            if(a[i] < a[j]){
                b = a[i];
                a[i] = a[j];
                a[j] = b;
            }
        }
    }
    
    for(i=0;i<3;i++){
        printf("%d", a[i]);
        printf("\n");
    }

    return 0;
}

Measured memory_bytes: 604
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>

using namespace std;

int main(void) {
	int N;
	cin >> N;
	vector< pair<int,int> > X(N);
	for (int i = 0; i < N; ++i) {
		int temp;
		cin >> temp;
		X[i] = {temp,i};
	}
	sort(X.begin(),X.end());

	int med = N/2;
	vector<int> res(N);
	for (int i = 0; i < N; ++i) {
		if (i < med) {
			res[X[i].second] = X[N-med].first;
		}
		else {
			res[X[i].second] = X[N-med-1].first;
		}
	}

	for (int i = 0; i < N; ++i) {
		cout << res[i] << endl;
	}
	return 0;
}


Measured memory_bytes: 4480
#!/usr/bin/perl

sub main() {
  my($A,$B,$C)=split(/ /,<>);
  chomp($C);
  my $ans = prob($A,$B,$C);
  print $ans;
}

sub prob() {
  my($A,$B,$C) = @_;
  my $al = (split(//,$A))[-1];
  my $bf = (split(//,$B))[0];
  my $bl = (split(//,$B))[-1];
  my $cf = (split(//,$C))[0];
  if($al eq $bf and $bl eq $cf){
    return "YES";
  } else {
    return "NO";
  }
}

&main();

Measured memory_bytes: 384
import java.util.Scanner;

class Main{

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);			//文字の入力
		long[] data = new long[5];
		long n = sc.nextLong();
		for(int i = 0;i < 5;i++){
			data[i] = sc.nextLong();
		}
		
		long ans = 0;
		long min = Long.MAX_VALUE;
		for(int i = 0;i < 5;i++){
			min = Math.min(min, data[i]);
		}
		ans = (n/min) + 5;
		if(n % min == 0){
			ans--;
		}
		
		System.out.println(ans);
		
	}
	


}


class Pair implements Comparable{
	int from;
	int end;
	@Override
	public int compareTo(Object other) {
		Pair otherpair = (Pair)other;

		return from - otherpair.from;
	}
}




Measured memory_bytes: 23892
#include<bits/stdc++.h>
using namespace std;
const int N=2e3+10;
const int mod=1e9+7;
int n,m,k,f[N*2][N][2],sum[N],ans=0;
int main() {
    cin>>n>>m>>k;m--;k--;
    int up=(n+m)/k;
    f[0][0][0]=1;
    for(int i=1;i<=up;i++) {
        for(int j=0;j<=n;j++) sum[j]=(((j-1>=0?sum[j-1]:0)+f[i-1][j][0])%mod+f[i-1][j][1])%mod;
        for(int j=0;j<=n;j++) {
            f[i][j][0]=(f[i-1][j][0]+f[i-1][j][1])%mod;
            int t=max(0,j-k);
            f[i][j][1]=(sum[j-1]-(t-1>=0?sum[t-1]:0)+mod)%mod;
        }
        for(int j=0;j<=n;j++) if((j%k==n%k)&&((i*k-j)%k==m%k)&&i*k-j<=m) ans=(ans+f[i][j][1])%mod;
    }
    printf("%d\n",ans);
    return 0;
}
//orzgzy
//鸡贼明年进队超稳


Measured memory_bytes: 63104
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int M = sc.nextInt();
		int a[] = new int[N];
		int penality = 0;
		for (int i=0;i<M;i++) {
			int temp = sc.nextInt();
			String result = sc.next();
			if (result.equals("WA")) {
				if (a[temp-1]<=0) {
					a[temp-1]--;
				}
			} else {
				if (a[temp-1]<0) {
					penality +=-a[temp-1];
				}
				a[temp-1]=1;
			}
		}
		int correct=0;
		for (int i=0;i<N;i++) {
			if (a[i]>0) {
				correct++;
			}
		}
		System.out.println(correct+" "+penality);
	}
}


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

int main()
{
    int n;
    scanf("%d",&n);
    int cnt=0;
    for (int i=0;i<n;++i){
        int x;
        scanf("%d",&x);
        if (x%2)
            cnt++;
    }
    if (cnt%2)
        printf("NO\n");
    else
        printf("YES\n");
    return 0;
}


Measured memory_bytes: 384
N = int(input())
l = [list(map(int, input().split())) for l in range(N)]


check_list=[]

for i in range(N):
    check_list.append(l[i][0]==l[i][1])

a=0

for j in range(N-2):
    if check_list[j]==True and check_list[j] == check_list[j+1] and check_list[j]==check_list[j+2]:
            print('Yes')
            a=1
            break
    else:
        continue

if a == 0 :
    print('No')


Measured memory_bytes: 9184
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const ll INF = 1LL << 60;
const int MAX = 1000000010;
const ll MOD = 1000000007;

int main() {
    int N; cin >> N;
    vector<int> A(4);
    for (int i = 0; i < N; i++) {
        string s; cin >> s;
        if (s == "AC") A[0]++;
        if (s == "WA") A[1]++;
        if (s == "TLE") A[2]++;
        if (s == "RE") A[3]++;
    }

    cout << "AC x " << A[0] << endl;
    cout << "WA x " << A[1] << endl;
    cout << "TLE x " << A[2] << endl;
    cout << "RE x " << A[3] << endl;
    return 0;
}

Measured memory_bytes: 3628
#include<iostream>
#include<cmath>
using namespace std;
int main() {
	int n;
	cin >> n;
	if (n == 1){
		cout << 1;
		return 0;
	}
	for (int i = 0; i < n; i++) {
		if (pow(2, i) > n) {
			cout << pow(2, i - 1);
			return 0;
		}
	}
}

Measured memory_bytes: 4216
def solve():
    H, W = map(int, input().split())
    field = [list(input()) for i in range(H)]
    H_table = [[0] * W for i in range(H)]
    W_table = [[0] * W for i in range(H)]
    
    for h in range(H):
        for w in range(W):
            if field[h][w] == '#':
                continue
            if w == 0:
                H_table[h][w] = 1
            else:
                H_table[h][w] = H_table[h][w-1] + 1

    for h in range(H-1, -1, -1):
        mx = 0
        for w in range(W-1,-1,-1):
            if field[h][w] == '#':
                continue
            if w == W-1 or field[h][w+1] == '#':
                mx = H_table[h][w]
            else:
                H_table[h][w] = mx
    
    for w in range(W):
        for h in range(H):
            if field[h][w] == '#':
                continue
            if h == 0:
                W_table[h][w] = 1
            else:
                W_table[h][w] = W_table[h-1][w] + 1

    for w in range(W-1, -1, -1):
        mx = 0
        for h in range(H-1,-1,-1):
            if field[h][w] == '#':
                continue
            if h == H-1 or field[h+1][w] == '#':
                mx = W_table[h][w]
            else:
                W_table[h][w] = mx
    
    mx = 0
    for h in range(H):
        for w in range(W):
            if field[h][w] == '#':
                continue
            mx = max(mx, W_table[h][w] + H_table[h][w] - 1)
    
    print(mx)

if __name__ == '__main__':
    solve()

Measured memory_bytes: 246536
#include<cstdio>
#include<algorithm>
#define ll long long
using namespace std;
ll mod = 1e9 + 7;
ll n;
ll dp[100010];
ll a[100010];
ll fac[100010];
ll len[100010];
ll mypow(ll x, ll y){
	if (y == 0)return 1;
	if (y % 2){
		return (x*mypow((x*x) % mod, y / 2)) % mod;
	}
	else return mypow((x*x) % mod, y / 2);
}
ll sub(ll x, ll y){
	return (x - y + mod*mod) % mod;
}
ll add(ll x, ll y){
	return (x + y) % mod;
}
ll mul(ll x, ll y){
	return (x*y) % mod;
}
ll C(ll x, ll y){
	ll gap = fac[x];
	gap = mul(gap, mypow(fac[y], mod - 2));
	gap = mul(gap, mypow(fac[x - y], mod - 2));
	return gap;
}
ll H(ll x, ll y){
	if (x == 0)return 1;
	return C(x + y - 1, y);
}

int main()
{
	fac[0] = 1;
	for (int i = 1; i <= 100000; i++)
		fac[i] = (fac[i - 1] * i) % mod;
	scanf("%lld", &n);
	len[1] = fac[n];
	for (int i = 2; i <= n; i++){
		len[i] = (len[i - 1] + mul(mul(H(i+1,n-i),fac[i-1]),fac[n-i]))%mod;
	}
	for (int i = 1; i <= n; i++)
		scanf("%lld", &a[i]);
	ll dap = 0;
	for (int i = 1; i <= n; i++){
		dap += mul(a[i], len[n - i + 1]);
		dap%=mod;
		dap += mul(a[i], len[i]);
		dap %= mod;
		dap = sub(dap, mul(fac[n], a[i]));
	}
	printf("%lld", dap);
}

Measured memory_bytes: 2560
#include <bits/stdc++.h>
#define rep(i, n) for(ll i = 0; i < n; i++)
#define repr(i, n) for(ll i = n; i >= 0; i--)
#define inf LLONG_MAX
#define all(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;


int main()
{
    ll n; cin >> n;
    vector<ll> a(n);
    rep(i, n) cin >> a[i];
    a.insert(a.begin(), 0);
    a.push_back(0);
    // for (auto elem : a) cout << elem << " "; cout << endl;

    vector<ll> ls(n+1);
    rep(i, n+1) {
        ls[i] = abs(a[i+1] - a[i]);
        if (i != 0) ls[i] += ls[i-1];
    }
    ls.insert(ls.begin(), 0);
    // for (auto elem : ls) cout << elem << " "; cout << endl;

    rep (i, n) {
        ll num = ls[i];
        num += abs(a[i+2] - a[i]);
        num += ls[ls.size()-1] - ls[i+2];

        cout << num << endl;
    }
/*     vector<ll> b(a.begin(), a.end());
    sort(all(b));
    ll max_num = b[b.size()-1], min_num = b[0];

    rep(i, n) {
        ll num = a[i];
        if (num == min_num) {
            cout << max(0LL, -b[1]) * 2 + max_num * 2 << endl;
        } else if (num == max_num) {
            cout << -min_num * 2 + max(0LL, b[b.size()-2]) * 2 << endl;
        } else {
            cout << (max_num - min_num) * 2 << endl;
        }
    }
 */
    return 0;
}

Measured memory_bytes: 3568
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define rep2(i, a, n) for(ll i = a; i < (ll)(n); i++)
#define memi cout << endl
#define kono(n) cout << fixed << setprecision(n)
#define all(c) (c).begin(), (c).end()
#define pb push_back
#define hina cout << ' '
#define in(n) cin >> n
#define in2(n, m) cin >> n >> m
#define in3(n, m, l) cin >> n >> m >> l
#define out(n) cout << n
const ll mei = (ll)1e9 + 7;

int main(){
  ll n;
  in(n);
  if(n < 105)
    out(0);
  else if(n < 135)
    out(1);
  else if(n < 165)
    out(2);
  else if(n < 189)
    out(3);
  else if(n < 195)
    out(4);
  else
    out(5);
  memi;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main(){
    int D,N;
    cin >>D >>N;
  int mul=1,order;
  for (int i=0;i<D;i++){mul*=100;}
  order=N+(N-1)/99;	
  cout << order*mul <<endl;
    return 0;
}

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

int main(){
  int n, m;
  cin >> n >> m;
  int v[n+1];
  for (int i = 0; i < n; i++) {
    int a; cin >> a;
    v[a] = i+1;
  }
  vector<int> e[n+1];
  for (int i = 0; i < m; i++) {
    int x, y; cin >> x >> y;
    e[x].push_back(y);
    e[y].push_back(x);
  }
  int k = 1;
  vector<int> c(n+1, -1);
  for (int i = 1; i <= n; i++) {
    if (c[i] != -1) continue;
    queue<int> q;
    q.push(i);
    c[i] = k;
    while(!q.empty()) {
      int u = q.front(); q.pop();
      for (int j = 0; j < e[u].size(); j++) {
        if (c[e[u][j]] == -1) {
          c[e[u][j]] = k;
          q.push(e[u][j]);
        }
      }
    }
    k++;
  }
  int count = 0;
  for (int i = 1; i <= n; i++) {
    if (c[i] == c[v[i]]) count++;
  }
  cout << count << endl;
  return 0;
}


Measured memory_bytes: 6528
#include<bits/stdc++.h>
using namespace std;
#define ll  long long
#define endl '\n'
#define FASTINOUT ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
const ll mod = 1000000007;
const double PI = 3.141592653589793238463;
const int N=1e6+10;
int main()
{
    FASTINOUT;
    int r,c;
    cin>>r>>c;
    int a[r+1][c+1];
    for (int i=1;i<=r;i++){
        for (int j=1;j<=c;j++){
            cin>>a[i][j];
            a[i][j]%=2;
        }
    }
    vector<pair<pair<int,int>,pair<int,int>>>v;
    for (int i=1;i<=r;i++){
        for (int j=1;j<=c;j++){
            if (a[i][j]&1){
                if (j<c)
                {
                    a[i][j+1]=(a[i][j+1]+1)%2;
                    a[i][j]=0;
                    v.push_back({{i,j},{i,j+1}});
                }
                else{
                    if (i<r){
                    a[i+1][j]=(a[i+1][j]+1)%2;
                    a[i][j]=0;
                        v.push_back({{i,j},{i+1,j}});
                    }
                }
            }
        }
    }
    cout<<v.size()<<endl;
    for (int i=0;i<v.size();i++)
        cout<<v[i].first.first<<" "<<v[i].first.second<<" "<<v[i].second.first<<" "<<v[i].second.second<<endl;
    return 0;
}


Measured memory_bytes: 5232
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll INF = 1LL << 60;

int main(){
  ll N, W;
  cin >> N >> W;
  vector<ll> v(N + 1), w(N + 1);
  for(int i = 1; i <= N; i++){
    cin >> w[i] >> v[i];
  }
  int MAX_J = 100100;
  vector<vector<ll>> dp(N + 1, vector<ll> (MAX_J, INF));
  dp[0][0] = 0;
  for(int i = 0; i < N; i++){
    for(int j = 0; j <= MAX_J; j++){
      if(j - v[i + 1] < 0){
        dp[i + 1][j] = dp[i][j];
      }
      else{
        dp[i + 1][j] = min(dp[i][j], dp[i][j - v[i + 1]] + w[i + 1]);
      }
    }
  }
  int ans = 0;
  for(int j = 0; j < MAX_J; j++){
    if(dp[N][j] <= W) ans = j;
  }
  cout << ans << endl;
}

Measured memory_bytes: 80256
package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
	"strconv"
)

func out(x ...interface{}) {
	fmt.Println(x...)
}

var sc = bufio.NewScanner(os.Stdin)

func getInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func getInts(N int) []int {
	ret := make([]int, N)
	for i := 0; i < N; i++ {
		ret[i] = getInt()
	}
	return ret
}

func getString() string {
	sc.Scan()
	return sc.Text()
}

// min, max, asub, absなど基本関数
func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func asub(a, b int) int {
	if a > b {
		return a - b
	}
	return b - a
}

func abs(a int) int {
	if a >= 0 {
		return a
	}
	return -a
}

func lowerBound(a []int, x int) int {
	idx := sort.Search(len(a), func(i int) bool {
		return a[i] >= x
	})
	return idx
}

func upperBound(a []int, x int) int {
	idx := sort.Search(len(a), func(i int) bool {
		return a[i] > x
	})
	return idx
}

func main() {
	sc.Split(bufio.ScanWords)
	sc.Buffer([]byte{}, 1000000)
	N := getInt()
	for i := 1; i < 10; i++ {
		for j := 1; j < 10; j++ {
			if i*j == N {
				out("Yes")
				return
			}
		}
	}
	out("No")
}


Measured memory_bytes: 1772
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n,m,i,b=0;
	float sum;
	cin>>n>>m;
	int a[n+1];
	for(i=1;i<=n;i++)
	{
	cin>>a[i];
	sum=sum+a[i];
}
    sum=sum*0.25/m;
    for(i=1;i<=n;i++)
    if(a[i]>=sum)
    b++;
    if(b>=m)
    cout<<"Yes"<<endl;
    else
    cout<<"No"<<endl;
    return 0;
 } 

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <cmath>
#include <tuple>
#include <cstdio>
#include <bitset>
#include <sstream>
#include <iterator>
#include <numeric>
#include <map>
#include <cstring>
#include <set>

using namespace std;

#define DEBUG_ //!!提出時にコメントアウト!!
#ifdef DEBUG_
	#define dump(x)  cerr << #x << " = " << (x) << endl;
#else
	#define dump(x)  ; //何もしない文
#endif

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define SZ(x) ((int)(x).size()) //unsignedのサイズをint型に変換
#define pb push_back
#define eb emplace_back

//#define int long long

typedef long long LL;
typedef vector<int> VI;
typedef vector<LL> VL;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<LL, LL> PLL;

template <typename T>
std::string printVector(const std::vector<T> &data)
{
    std::stringstream ss;
    std::ostream_iterator<T> out_it(ss, ", ");
    ss << "[";
    std::copy(data.begin(), data.end() - 1, out_it);
    ss << data.back() << "]";
    return ss.str();
}

const int MOD = 1e9+7;
const LL LINF = 1001002003004005006ll;
const int INF = 1001001001;

signed main(int argc, char const *argv[])
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    string S; cin >> S;
    int cntg = 0;
    int cntp = 0;
    int ans = 0;
    REP(i,S.length()){
        if(S[i] == 'g'){
            if(cntp < cntg) {
                ans++;
                cntp++;
            }
            else{
                cntg++;
            }
        }
        else{
            if(cntp < cntg){
                cntp++;
            }
            else
            {
                cntg++;
                ans--;
            }
            }
        }
    cout << ans << endl;

}

Measured memory_bytes: 512
// CppPractice.cpp : このファイルには 'main' 関数が含まれています。プログラム実行の開始と終了がそこで行われます。
//
#include <iostream>
#include <vector>

using namespace std;

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

	vector<int> d(n);
	for (int i = 0; i < n; i++) {
		cin >> d.at(i);
	}
	int sum = 0;
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < n; j++) {
			if (i < j) sum += d.at(i) * d.at(j);
		}
	}
	cout << sum << endl;
}

// プログラムの実行: Ctrl + F5 または [デバッグ] > [デバッグなしで開始] メニュー
// プログラムのデバッグ: F5 または [デバッグ] > [デバッグの開始] メニュー

// 作業を開始するためのヒント: 
//    1. ソリューション エクスプローラー ウィンドウを使用してファイルを追加/管理します 
//   2. チーム エクスプローラー ウィンドウを使用してソース管理に接続します
//   3. 出力ウィンドウを使用して、ビルド出力とその他のメッセージを表示します
//   4. エラー一覧ウィンドウを使用してエラーを表示します
//   5. [プロジェクト] > [新しい項目の追加] と移動して新しいコード ファイルを作成するか、[プロジェクト] > [既存の項目の追加] と移動して既存のコード ファイルをプロジェクトに追加します
//   6. 後ほどこのプロジェクトを再び開く場合、[ファイル] > [開く] > [プロジェクト] と移動して .sln ファイルを選択します


Measured memory_bytes: 256
#include<stdio.h>
typedef long long LL;
int N,i,j,x,y=0,A[200000],town[200000];LL K;
int main(void)
{
  i=scanf("%d %lld",&N,&K);
  for(i=0;i<N;i++)town[i]=-scanf("%d",&A[i]);
  for(i=0,j=0;;i=A[i]-1,j++)if(town[i]<0)town[i]=j;else{x=town[i];break;}
  while(K>0){if(i==y){K%=x-j;if(!K)return printf("%d",i+1),0;}y=A[y]-1,K--;}
  return printf("%d\n",y+1),0;
}

Measured memory_bytes: 3260
import numpy as np
import math
import sys
sys.setrecursionlimit(10000000)

def main():
    N = int(input())
    W = [int(c) for c in input().split()]
    dis = 100000000000
    for i in range(1, N):
        S1 = W[:i]
        S2 = W[i:]
        # print(S1, S2)
        dis = min(dis, abs(sum(S1)-sum(S2)))
    print(dis)


if __name__ == '__main__':
    main()

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

int main() {
    int a, b;
    cin >> a >> b;
    if(a <= 8 && b <= 8) cout << "Yay!" << endl;
    else cout << ":(" << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<math.h>
int main(void)
{
	int x,h;
	double a,b,c,S;
	scanf("%d",&x);
	scanf("%d",&h);
	while(x!=0 && h!=0) {
		0<=x && x<=100;
		0<=h && h<=100;
		a=(double)x/2.0;
		b=sqrt((double)a*a+(double)h*h);
		c=(double)x*b/2.0;
		S=(double)x*x+4.0*c;
	printf("%lf\n",S);
	scanf("%d %d",&x,&h);
	}
	return 0;
}

Measured memory_bytes: 628
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp15
{
    class Class313
    {
        static int N;
        static List<int>[] G2;
        static int[] Ans;

        static void Main()
        {
            var NQ = Console.ReadLine().Split().Select(int.Parse).ToArray();
            N = NQ[0];
            int Q = NQ[1];
            List<int>[] G = new List<int>[N];
            for (int i = 0; i < N; i++) G[i] = new List<int>();
            for(int i = 0; i < N-1; i++)
            {
                var r = Console.ReadLine().Split().Select(x=>int.Parse(x)-1).ToArray();
                G[r[0]].Add(r[1]);
                G[r[1]].Add(r[0]);
            }
            G2 = new List<int>[N];
            for (int i = 0; i < N; i++) G2[i] = new List<int>();
            bool[] frag = new bool[N];
            Queue<int> que = new Queue<int>();
            que.Enqueue(0);
            while (que.Count > 0)
            {
                int m = que.Dequeue();
                frag[m] = true;
                foreach(int i in G[m])
                {
                    if (frag[i]) continue;
                    G2[m].Add(i);
                    que.Enqueue(i);
                }
            }

            Ans = new int[N];
            for(int i = 0; i < Q; i++)
            {
                var r = Console.ReadLine().Split().Select(int.Parse).ToArray();
                Ans[r[0] - 1] += r[1];
            }
            DFS(0);
            Console.WriteLine(string.Join(" ",Ans));
        }

        static void DFS(int now)
        {
            int r = Ans[now];
            foreach(int i in G2[now])
            {
                Ans[i] += r;
                DFS(i);
            }
            
        }
    }
}


Measured memory_bytes: 91632
#include<bits/stdc++.h>
using namespace std;
int n,m;
std::vector<vector<bool>> edge;
std::vector<bool> flag;

int dfs(int node=0,int num=1){
	if(flag[node]) return 0;
	if(num==n){
		return 1;
	}
	int ans=0; flag[node]=true;
	for(int i=0;i<n;i++) {
		if(edge[node][i]){
			ans+=dfs(i,num+1);
		}
	}
	flag[node]=false;
	return ans;
}

int main()
{
	cin>>n>>m;
	flag=vector<bool>(n,false);
	edge.resize(n);
	for (int i = 0; i < n; ++i)
	{
		edge[i].resize(n);
	}
	for (int i = 0; i < m; ++i)
	{
		int a,b;
		cin>>a>>b;
		a--;b--;
		edge[a][b]=edge[b][a]=true;
	}
	cout<<dfs();
}

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

#ifndef LOCAL
#define cerr dolor_sit_amet
#endif

#define mp make_pair
#define sz(x) ((int)((x).size()))
#define X first
#define Y second

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair < int , int > ipair;
typedef pair < ll , ll > lpair;
const int IINF = 0x3f3f3f3f;
const ll LINF = 0x3f3f3f3f3f3f3f3fll;
const double DINF = numeric_limits<double>::infinity();
const int MOD = 1000000007;
const double EPS = 1e-9;
const int DX[] = { 1,  0, -1,  0,  1, -1,  1, -1};
const int DY[] = { 0,  1,  0, -1,  1, -1, -1,  1};
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll sqr(ll x) { return x*x; } ll sqr(int x) { return (ll)x*x; }
double sqr(double x) { return x*x; } ld sqr(ld x) { return x*x; }
mt19937 mmtw(960172);
ll rnd(ll x, ll y) { static uniform_int_distribution<ll> d; return d(mmtw) % (y - x + 1) + x; }

// ========================================================================= //

const int N = 100179;

int main() {
    ios::sync_with_stdio(false);

    string s;
    cin >> s;
    if (sz(s) >= 4 && s.substr(0, 4) == "YAKI")
        cout << "Yes\n";
    else
        cout << "No\n";

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <string>
using namespace std;
using ll=long long;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define inf 1001001001
typedef pair<int,int> P;
#define mod 1000000007



int main(){
    int a,b;
    cin >> a >>b;
    if(a%3==0||b%3==0||(a+b)%3==0) cout << "Possible" << endl;
    else cout << "Impossible" << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
#define gcd            __gcd
#define setbits(x)     __builtin_popcountll(x)
#define zrobits(x)     __builtin_ctzll(x)
#define mod            1000000007
#define mod2           998244353
#define maxe           *max_element
#define mine           *min_element
#define inf            1e18
#define deci(x,y)      fixed<<setprecision(y)<<x
#define w(t)           int t; cin>>t; while(t--)
#define nitin          ios_base::sync_with_stdio(false); cin.tie(NULL)
using namespace std;

int power(int x, int y, int p)
{
    int res = 1;
    x = x % p;
    while (y > 0)
    {
        if (y & 1)
            res = (res * x) % p;
        y = y >> 1;
        x = (x * x) % p;
    }
    return res;
}
int modi(int a, int m)
{
    return power(a, m - 2, m);
}
int32_t main()
{
    int n,k;
    cin>>n>>k;
    vector<int>v(n);
    for(int i=0;i<n;i++)
    {
        cin>>v[i];
    }
    sort(v.begin(),v.end());
    int sum=0;
    for(int i=0;i<k;i++)
    {
        sum+=v[i];
    }
    cout<<sum<<endl;
}

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

int main() {
	int k,n,ma;
	cin >> k >> n;
	if(n == 1) {
		cout << k - 1 << endl;
		return 0;
	}
	for(int i = 0;i < n;i++){
		cin >> ma;
		if((k + 1) / 2 < ma){
			cout << k - 2 * (k - ma) - 1 << endl;
			return 0;
		}
	}
	cout << 0 << endl;
	return 0;
}

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

int main() {
  int n;
  cin >> n;
  vector<int> num(100001,0);
  for (int i=0; i<n; i++) {
    int tmp;
    cin >> tmp;
    num[tmp]++;
    num[tmp+1]++;
    if (tmp>0) {
      num[tmp-1]++;      
    }
  }

  int ans=0;
  for (int i=0; i<(int)num.size(); i++) {
    //printf("%d:%d\n", i, num[i]);
    if (ans < num[i]) {
      ans = num[i];
    }
  }
  cout << ans << endl;
  return 0;
}


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

using namespace std;

vector<long> frac(long N)
{
  vector<bool> primes(99992, true);
  primes[0] = primes[1] = false;
  for (int i = 2; i < primes.size(); ++i) {
    if (primes[i]) {
      for (int j = i + i; j < primes.size(); j += i) {
        primes[j] = false;
      }
    }
  }

  vector<long> results;
  for (int prime = 0; prime < primes.size(); ++prime) {
    if (!primes[prime]) continue;
    if (prime > N) break;
    while (N % prime == 0) {
      results.push_back(prime);
      N = N / prime;
    }
  }
  if (N > 1) results.push_back(N);
  return results;
}

int digit(long N)
{
  return floor(log10(N)) + 1;
}

int trace(const vector<long>& results, int i, long a, long b)
{
  if (i == results.size()) return max(digit(a), digit(b));
  const auto result = results[i];
  return min(
    trace(results, i + 1, a * result, b),
    trace(results, i + 1, a, b * result)
  );
}

int main()
{
  long N;
  cin >> N;
  auto results = frac(N);
  if (results.size() == 1) {
    cout << digit(results[0]) << endl;
    return 0;
  }
  // for (auto r: results) cout << r << endl;
  // cout << base << " " << a << " " << b << endl;
  // cout << max(digit(a), digit(b)) << endl;
  cout << trace(results, 0, 1, 1) << endl;
  return 0;
}

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

char s1[10000];
char s2[10000];

int n1[10000];
int n2[10000];

int no[100];
char so[100];

int main()
{
	int n;
	scanf("%d",&n);
	for(int i = 0; i < n; i++)
	{
		scanf("%s",s1);
		scanf("%s",s2);
		int l = strlen(s1);
		if(l > 80)
		{
			printf("overflow\n");
			continue;
		}
		for(int i = 0; i < l; i++)
		{
			n1[i] = s1[l - 1 - i] - '0';
		}
		for(int i = l; i < 80; i++)
		{
			n1[i] = 0;
		}
		l = strlen(s2);
		if(l > 80)
		{
			printf("overflow\n");
			continue;
		}
		for(int i = 0; i < l; i++)
		{
			n2[i] = s2[l - 1 - i] - '0';
		}
		for(int i = l; i < 80; i++)
		{
			n2[i] = 0;
		}
		int keta = 0;
		for(int i = 0; i < 80; i++)
		{
			int w = n1[i] + n2[i] + keta;
			no[i] = w % 10;
			keta = w / 10;
		}
		if(keta != 0)
		{
			printf("overflow\n");
		}
		else
		{
			int b = 0;
			for(int i = 80 - 1; i >= 0; i--)
			{
				if(b != 0 || no[i] != 0)
				{
					so[b] = no[i] + '0';
					b++;
				}
			}
			if(b == 0)
			{
				printf("0\n");
			}
			else
			{
				so[b] = '\0';
				printf("%s\n",so);
			}
		}
	}
	return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
#include<iostream>
using namespace std;
int main(){
  int n=0,k=0;
  scanf("%d %d", &n, &k);
  vector<int>d(n);
  for(int i=0;i<n;i++)
    scanf("%d",&d[i]);
  
  vector<int>dp(n, INT_MAX);
  dp[0]=0;
  for(int i=1;i<n;i++){
    for(int j=i-1;j>=i-k;j--){
      if(j>=0){
        dp[i]=min(dp[i], dp[j]+abs(d[j]-d[i]));
      }
    }
  }
  printf("%d\n", dp[n-1]);
  return 0;
}

Measured memory_bytes: 1024
N, Y = gets.split.map(&:to_i)
0.upto(N) do |n3|
    0.upto(N-n3) do |n2|
        n1 = N-n3-n2
        sum = 10000 * n1 + 5000 * n2 + 1000 * n3
        if sum > Y
            next
        elsif sum == Y
            print("#{n1} #{n2} #{n3}")
            exit
        end
    end
end
print("-1 -1 -1")

Measured memory_bytes: 1788
A, B, C = map(int, input().split())
D, E, F = map(int, input().split())
G, H, I = map(int, input().split())
N = int(input())

card = [A, B, C, D, E, F, G, H, I]
count = []

for i in range(N):
    num = int(input())
    if num in card:
        count.append(num)

if A in count and B in count and C in count:
    print("Yes")
elif D in count and E in count and F in count:
    print("Yes")
elif G in count and H in count and I in count:
    print("Yes")
elif A in count and D in count and G in count:
    print("Yes")
elif B in count and E in count and H in count:
    print("Yes")
elif C in count and F in count and I in count:
    print("Yes")
elif A in count and E in count and I in count:
    print("Yes")
elif C in count and E in count and G in count:
    print("Yes")
else:
    print("No")


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

    a = [0] * (N + 1)
    for i in range(1, N+1):
        a[i] = a[i-1]
        if S[i-2:i] == "AC":
            a[i] += 1

    # print(a)
    ans = 0
    for l, r in lr:
        ans = a[r] - a[l]
        print(ans)


if __name__ == '__main__':
    main()


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

#define ll long long

#define rep(i,a,b) for(ll i=a;i<b;i++)
#define repb(i,a,b) for(ll i=a;i>=b;i--)
#define repA(i,A)   for(auto i:A)

#define err() cout<<"=================================="<<endl;
#define errA(A) for(auto i:A)   cout<<i<<" ";cout<<endl;
#define err1(a) cout<<#a<<" "<<a<<endl
#define err2(a,b) cout<<#a<<" "<<a<<" "<<#b<<" "<<b<<endl
#define err3(a,b,c) cout<<#a<<" "<<a<<" "<<#b<<" "<<b<<" "<<#c<<" "<<c<<endl
#define err4(a,b,c,d) cout<<#a<<" "<<a<<" "<<#b<<" "<<b<<" "<<#c<<" "<<c<<" "<<#d<<" "<<d<<endl

#define mp make_pair
#define pb push_back
#define all(A)  A.begin(),A.end()
#define ft first
#define sd second

#define pll pair<ll,ll>
#define V vector<ll>
#define S set<ll>
#define VV vector<V>

#define endl "\n"

const ll logN = 20;
const ll N = 100005;
const ll M = 1000000007;
#define PI 3.14159265

int main(){
  ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
  int n, k;
  cin>>n>>k;
  vector<int> a(n);
  rep(i, 0, n) cin>>a[i];
  vector<bool> dp(k+1);
  rep(i, 0, k+1){
//        cout<<"x";
    for(int j = 0; j < n; j++){
//            cout<<a[j]<<" ";
      if(i >= a[j] && !dp[i-a[j]]){
//                  cout<<"y";
            dp[i] = true;
            break;
      }
    }
  }
  puts(dp[k] ? "First" : "Second");
  return 0;
}


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

struct edge { int to, cost; };
vector<edge> graph[(int)1e5];
long long x[(int)1e5];
bool used[(int)1e5];
bool ok = true;

void dfs(int cur) {
  used[cur] = true;
  for (edge e: graph[cur]) {
    if (used[e.to]) {
      if (x[e.to] != x[cur] + e.cost) {
        ok = false;
        break;
      }
    } else {
      used[e.to] = true;
      x[e.to] = x[cur] + e.cost;
      dfs(e.to);
    }
  }
}
int main() {
  int n, m;
  cin>>n>>m;

  for (int i=0; i<m; i++) {
    int l, r, d;
    cin>>l>>r>>d;
    --l;
    --r;
    graph[l].push_back({r, d});
    graph[r].push_back({l, -d});
  }

  for (int i=0; i<n; i++) used[i] = false;

  for (int i=0; i<n; i++) {
    if (!used[i]) {
      x[i] = 0;
      dfs(i);
      if (!ok) {
        cout<<"No"<<endl;
        return 0;
      }
    }
  }
  long long max_x = -1e12;
  long long min_x = 1e12;
  for (int i=0; i<n; i++) {
    if (used[i]) {
      max_x = max(x[i], max_x);
      min_x = min(x[i], min_x);
    }
  }
  if (max_x - min_x <= 1e9) {
    cout<<"Yes"<<endl;
  } else {
    cout<<"No"<<endl;
  }
}

Measured memory_bytes: 11520
# Euclidean Algorithm
def gcd(m, n):
    r = m % n
    return gcd(n, r) if r else n

# lcm (least common multiple)
def lcm(m, n):
    return m//gcd(m, n)*n

a, b, c, d = map(int, input().split())
lcm = lcm(c,d)

x = b - a + 1
y = b//c - (a-1)//c 
z = b//d - (a-1)//d
w = b//lcm - (a-1)//lcm

print(x - y - z + w)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define FORR(i, m, n) for (int i = m; i >= n; i--)
#define INF 1e9;
using namespace std;
typedef long long ll;
int main() {
  ll N;
  cin >> N;
  ll A[N + 2];
  A[0] = 0;
  A[N + 1] = 0;
  FOR(i, 1, N + 1) { cin >> A[i]; }
  ll sum = 0;
  REP(i, N + 1) { sum += abs(A[i + 1] - A[i]); }
  FOR(i, 1, N + 1) {
    if (A[i - 1] <= A[i] && A[i + 1] <= A[i] ||
        A[i - 1] >= A[i] && A[i + 1] >= A[i]) {
      ll c = abs(A[i + 1] - A[i - 1]) - abs(A[i] - A[i - 1]) -
             abs(A[i + 1] - A[i]);
      cout << sum + c << endl;
    } else {
      cout << sum << endl;
    }
  }
  return 0;
}

Measured memory_bytes: 2048
#include<iostream>
#include<queue>
#include<string>
#include<utility>
#include<array>

#define h first
#define w second 

using namespace std;

string map[1002];
int cost[1002][1002] {};


int main()
{
    int H{ 0 };
    int W{ 0 };
    int N{ 0 };

    int nowH{ 0 };
    int nowW{ 0 };

    queue< pair<int, int> > path; //????????? (h, w)

    cin >> H >> W >> N;

    for(int i = 0; i < H; i++)
    {
        //??\???
        cin >> map[i];
        for(int j = 0; j < W; j++)
        {
            //??????????????°????????¢?´¢
            if(map[i][j] == 'S')
            {
                nowH = i;
                nowW = j;
            }
        }
    }

    //???????????§??\???



    //?????????????§£???
    path.push(make_pair(nowH, nowW));

    int nowHP{ 1 };
    while(nowHP <= N)
    {
        pair<int, int> now = path.front();
        path.pop();

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

        for(int i = 0; i < 4; i++)
        {
            int nextH = now.h + dy[i];
            int nextW = now.w + dx[i];

            if(0 <= nextH && nextH < H && 0 <= nextW && nextW < W)
            {
                //?§????????????§???????????\??????????????£??????
                if(map[nextH][nextW] != 'X' && cost[nextH][nextW] == 0)
                {
                    cost[nextH][nextW] = cost[now.h][now.w] + 1;
                    path.push(make_pair(nextH, nextW));
                }
                //????????????????????\??´??????
                if(map[nextH][nextW] == char(nowHP + 48))
                {
                    if(nowHP == N)
                    {
                        cout << cost[nextH][nextW] << endl;
                        return 0;
                    }
                    else
                    {
                        nowHP++;
                        while(!path.empty())path.pop();
                        path.push(make_pair(nextH, nextW));

                        int tmp = cost[nextH][nextW];

                        for(int x = 0; x < W; x++)
                            for(int y = 0; y < H; y++)
                                cost[y][x] = 0;

                        cost[nextH][nextW] = tmp;
                        i = 10;
                    }
                    
                }
//                cout << map[nextH][nextW] << " / h : " << nextH << " w : " << nextW << " :: " << cost[nextH][nextW] << endl;
            }
        }

    }



    return 0;
}

Measured memory_bytes: 8000
#include<bits/stdc++.h>
#define MAX 1e9 + 7
#define ll long long int
#define fo(i,n) for(int i=0;i<n;i++)
#define ull unsigned long long int
#define pb push_back
#define eb emplace_back
using namespace std;

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
//    int t;
//    cin>>t;
//    int x=1;
//    while(t--) {
//
//    }
    int a,b,c,d;
    cin>>a>>b>>c>>d;
    int flg=0;
    while(true){
        if(!flg){
            c-=b;
            if(c<=0){
                cout<<"Yes"<<endl;
                return 0;
            }
            flg=1;
        }
        else{
            a-=d;
            if(a<=0){
                cout<<"No"<<endl;
                return 0;
            }
            flg=0;
        }
    }
    return 0;
}

Measured memory_bytes: 3612
#include<stdio.h>
int main(void)
{
	int a,b,c,d,i,s,x[100];
	char w[10];
	scanf("%d %d",&a,&b);
	for(i=0;i<a;i++){
		x[i]=0;
		x[i]=i+1;
	}
	s=0;
	for(i=0;i<b;i++){
		scanf("%d %c %d",&c,w,&d);
		s=x[c-1];
		x[c-1]=x[d-1];
		x[d-1]=s;
	}
	for(i=0;i<a;i++){
		printf("%d\n",x[i]);
	}
	return 0;
}

Measured memory_bytes: 596
#include <iostream>
#include <cstdio>
#include <cmath>
#include <ctime>
#include <cstdlib>
#include <cassert>
#include <vector>
#include <list>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <string>
#include <algorithm>
#include <utility>
#define llint long long
#define inf 1e18
#define rep(x, s, t) for(llint (x) = (s); (x) < (t); (x)++)
#define Rep(x, s, t) for(llint (x) = (s); (x) <= (t); (x)++)
#define chmin(x, y) (x) = min((x), (y))
#define chmax(x, y) (x) = max((x), (y))

using namespace std;
typedef pair<llint, llint> P;

llint x;

int main(void)
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	cin >> x;
	cout << 10-x/200 << endl;
	
	return 0;
}

Measured memory_bytes: 3664
#include<iostream>
#include<string>
#include<algorithm>
using namespace std;
int main(){
int v,n=0,i=0,z=0; char x; string s,d; cin>>s>>d;
v = s.size();
if(s ==d){cout<<"Yes";}
    else if(s != d){
for(int i=0; i<v+1; i++){
x = s[v-1];
s = s.erase(v-1,1);
s = x+s;
if (s == d){
    cout<<"Yes";
    break;
}}
if(s != d){cout<<"No";}
}}




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

    # divisors.sort()
    return divisors



mm0 = make_divisors(m0)
mm1 = make_divisors(m1)
mm = mm0 + mm1
mm.sort()
si = 0
candi = 0
for g in mm:
    si = 0
    for i in range(n):
        if a[i] % g != 0:
            si += 1
            if si == 2:
                break
    else:
        candi = g
print(candi)

Measured memory_bytes: 63984
#include <bits/stdc++.h>
 
using namespace std;
 
#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cerr<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" "<<v[i]; cerr<<endl;
#define DEBUG_MAT(v) cerr<<#v<<endl;for(int i=0;i<v.size();i++){for(int j=0;j<v[i].size();j++) {cerr<<v[i][j]<<" ";}cerr<<endl;}
typedef long long ll;
#define int ll
 
#define vi vector<int>
#define vl vector<ll>
#define vii vector< vector<int> >
#define vll vector< vector<ll> >
#define vs vector<string>
#define pii pair<int,int>
#define pis pair<int,string>
#define psi pair<string,int>
#define pll pair<ll,ll>
template<class S, class T> pair<S, T> operator+(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first + t.first, s.second + t.second); }
template<class S, class T> pair<S, T> operator-(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first - t.first, s.second - t.second); }
template<class S, class T> ostream& operator<<(ostream& os, pair<S, T> p) { os << "(" << p.first << ", " << p.second << ")"; return os; }
#define X first
#define Y second
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define rrep(i,n) for(int i=(int)(n)-1;i>=0;i--)
#define rrep1(i,n) for(int i=(int)(n);i>0;i--)
#define REP(i,a,b) for(int i=a;i<b;i++)
#define in(x, a, b) (a <= x && x < b)
#define all(c) c.begin(),c.end()
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 (a>b) { a = b; return 1; } return 0; }
#define UNIQUE(v) v.erase(std::unique(v.begin(), v.end()), v.end());
const ll inf = 1000000001;
const ll INF = (ll)1e18 + 1;
const long double pi = 3.1415926535897932384626433832795028841971L;
#define Sp(p) cout<<setprecision(25)<< fixed<<p<<endl;
//int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
//int dx2[8] = { 1,1,0,-1,-1,-1,0,1 }, dy2[8] = { 0,1,1,1,0,-1,-1,-1 };
vi dx = {1, 0, -1, 0}, dy = {0, 1, 0, -1};
vi dx2 = { 1,1,0,-1,-1,-1,0,1 }, dy2 = { 0,1,1,1,0,-1,-1,-1 };
#define fio() cin.tie(0); ios::sync_with_stdio(false);
const ll MOD = 1000000007;
//const ll MOD = 998244353;
// #define mp make_pair
//#define endl '\n'

signed main() {
    int n, k;
    cin >> n >> k;
    set<int> st;
    rep (i, k) {
        int d;
        cin >> d;
        rep (j, d) {
            int x;
            cin >> x;
            st.insert(x);
        }
    }
    cout << n - (int)st.size() << endl;

}

Measured memory_bytes: 3636
n, m = map(int, input().split())
if n == 1 and m == 1:
    ans = 0
elif n >= 2 and m == 0:
    ans = 1/2 * n * (n-1)

elif n == 0 and m >= 2:
    ans = 1/2 * m * (m-1)

else:
    ans =1/2*(n*(n-1)+m*(m-1))

print(int(ans))

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep2(i,m,n) for(int (i)=(m);(i)<(n);(i)++)
const ll INF = 1LL<<60;
const ll MOD = 1e9+7;

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n; cin>>n;
    vector<int> l(n);rep(i,n)cin>>l[i];
    sort(l.begin(),l.end());
    ll ans = 0;
    for(int i=0; i<n; i++){
        for(int j=i+1; j<n; j++){
            int a = l[i],b=l[j];
            int d = abs(a-b)+1;
            int u = a+b;
            int U = lower_bound(l.begin(),l.end(),u)-l.begin()-1;
            int D = lower_bound(l.begin(),l.end(),d)-l.begin();
            ans+=U-max(j+1,D)+1;
        }
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
//forループ関係
//引数は、(ループ内変数,動く範囲)か(ループ内変数,始めの数,終わりの数)、のどちらか
//Dがついてないものはループ変数は1ずつインクリメントされ、Dがついてるものはループ変数は1ずつデクリメントされる
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
//xにはvectorなどのコンテナ
#define ALL(x) (x).begin(),(x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x)) //最大値を求める
#define MIN(x) *min_element(ALL(x)) //最小値を求める
//定数
#define INF 1000000000000 //10^12:極めて大きい値,∞
#define MOD 1000000007 //10^9+7:合同式の法
#define MAXR 100000 //10^5:配列の最大のrange(素数列挙などで使用)
//略記
#define PB push_back //vectorヘの挿入
#define MP make_pair //pairのコンストラクタ
#define F first //pairの一つ目の要素
#define S second //pairの二つ目の要素

int main(void)
{
  int a, b, c;
  int cnt = 0;
  cin >> a >> b >> c;
  FOR(i, a, b)  if (0 == c % i)  cnt++;
  cout << cnt << endl;
  return 0;
}



Measured memory_bytes: 3104
fun main(args: Array<String>) {
    val s = readLine()!!.toString()
    val t = readLine()!!.toString()

    var ans = Int.MAX_VALUE
    for (i in s.indices) {
        if (t.length + i > s.length) break
        var temp = 0
        for (j in t.indices) {
            if (s[i + j] == t[j]) {
                continue
            } else {
                temp++
            }
        }
        ans = minOf(ans, temp)
    }
    println(ans)
}

Measured memory_bytes: 35976
N = int(raw_input())
A = sorted(map(int, raw_input().split()))

def check(i):
    x = A[i]
    for j, a in enumerate(A):
        if j == i:
            continue
        if a > x * 2:
            return False
        else:
            x += a
    return True

if check(0) == True:
    print N
    exit()
if check(N-1) == False:
    print 0
    exit()

low = 0
high = N - 1
t = (low + high) / 2
while high - low > 1:
    v = check(t)
    if v:
        high = t
    else:
        low = t
    t = (low + high) / 2
print N - t - 1


Measured memory_bytes: 11320