akhauriyash/Code-Regression huggingface dataset:
import bisect, collections, copy, heapq, itertools, math, string
import sys
def I(): return int(sys.stdin.readline().rstrip())
def MI(): return map(int, sys.stdin.readline().rstrip().split())
def LI(): return list(map(int, sys.stdin.readline().rstrip().split()))
def S(): return sys.stdin.readline().rstrip()
def LS(): return list(sys.stdin.readline().rstrip().split())

from  collections import defaultdict
from collections import Counter
import bisect
def main():
    H, W, K = MI()
    C = []
    for i in range(H):
        c = S()
        C.append(c)
    A = []
    for i in range(2 ** (H + W)):
        A_bit = []
        for j in range(H + W):
            # 二進数表記でj回右にシフトして0桁目（一番下の桁）が1であればTrue
            if ((i >> j) & 1):
                A_bit.append(j)
        A.append(A_bit)
    Ans_list = []
    for a in A:
        cnt = 0
        for i in range(H):
            if i in a:
                continue
            else:
                for j in range(H, W + H):
                    if j not in a and C[i][j - H] == '#':
                        cnt += 1
        Ans_list.append(cnt)
    ans = Counter(Ans_list)[K]
    print(ans)


if __name__ == "__main__":
    main()



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

int main(){
    int N, M;
    cin >> N >> M;
    vector<int> A(2*N);
    for(int i=0; i<2*N; i++) cin >> A[i];
    sort(A.rbegin(), A.rend());

    int ok = 0, ng = N+1;
    while(ng-ok>1){
        int mid = (ok+ng)/2;
        bool over = true;
        for(int i=0; i<mid; i++) if(A[i] + A[2*mid-1-i] < M) over = false;
        (over ? ok : ng) = mid;
    }
    int ans = 0;
    for(int i=0; i<ok; i++) ans = max(ans, A[i] + A[2*ok-1-i] - M);
    for(int i=0; i<N-ok; i++) ans = max(ans, A[2*ok+i] + A[2*N-1-i]);
    cout << ans << endl;
    return 0;
}


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

using namespace std;

long long ans[123456][3];
int N, a[123456], b[123456], c[123456];

int main(int argc, char *argv[])
{
  cin >> N;
  for (int i = 0; i < N; i++) {
    cin >> a[i] >> b[i] >> c[i];
  }

  ans[0][0] = a[0];
  ans[0][1] = b[0];
  ans[0][2] = c[0];

  for (int i = 1; i < N; i++) {
    ans[i][0] = a[i] + max(ans[i-1][1], ans[i-1][2]);
    ans[i][1] = b[i] + max(ans[i-1][0], ans[i-1][2]);
    ans[i][2] = c[i] + max(ans[i-1][1], ans[i-1][0]);
  }

  cout << max(max(ans[N-1][0], ans[N-1][1]), ans[N-1][2]) << endl;
  return 0;
}


Measured memory_bytes: 4096
S=input()
T=input()

dict_S={}
dict_T={}

for x, y in zip(S, T):
    if x not in dict_S:
        dict_S[x] = y
    else:
        if dict_S[x] != y:
            print("No")
            exit()

    if y not in dict_T:
        dict_T[y] = x
    else:
        if dict_T[y] != x:
            print("No")
            exit()


print("Yes")

Measured memory_bytes: 9168
#include <stdio.h>
#include <string.h>
#include <stdbool.h>
#include <stdint.h>
#include <stdlib.h>
#include <limits.h>
#include <math.h>
int acs(const void *a, const void *b){return *(int*)a - *(int*)b;} /* 1,2,3,4.. */
int des(const void *a, const void *b){return *(int*)b - *(int*)a;} /* 8,7,6,5.. */
int cmp_char(const void *a, const void *b){return *(char*)a - *(char*)b;} /* a,b,c,d.. */
int cmp_str(const void *a, const void *b){return strcmp(*(const char **)a, *(const char **)b);} /* aaa,aab.. */
#define min(a,b) (a < b ? a: b)
#define max(a,b) (a > b ? a: b)
#define rep(i, l, r) for (int i = l; i < r; i++)
#define MAX 100001
#define MOD 1000000007

typedef long long int lli;

int main(void) {
  int a, b, c;
  scanf("%d %d %d",&a, &b, &c);
  int max = max(max(a, b), c);
  int ans = a + b + c;
  ans = ans - max + max * 10;
  printf("%d\n", ans);
  return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <cstdio>
#include <fstream>
#include <algorithm>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <utility>
#include <stack>
#include <queue>
#include <sstream>
#include <fstream>

using namespace std;

int main()
{
	string S;cin >> S;
	int cnt[26] = {};
	for (int i = 0; i < S.size(); ++i) cnt[S[i] - 'a']++;
	for (int i = 0; i < 26; ++i) if (cnt[i] % 2) {
		cout << "No\n";
		return 0;
	}
	cout << "Yes\n";
}

Measured memory_bytes: 256
#include<stdio.h>
#define MAX_ELEMENTS 100001
#define INFTY  1000000001

typedef struct {
  char m;
  int n;
} Card;

Card L[50000],R[50000];
int n;

void swap(Card *A,Card *B){
  Card t;
  t=*A;
  *A=*B;
  *B=t;
}

void merge(Card *A,int left,int mid,int right){
  
    int n1, n2,i,j,k;

    n1 = mid - left;
    n2 = right - mid;

    for(i=0; i<=n1-1; i++)  L[i] = A[left + i];
    for(i=0; i<=n2-1; i++)  R[i] = A[mid + i];
    
    L[n1].n = INFTY;
    R[n2].n = INFTY;

    i = 0;
    j = 0;

    for(k=left; k<=right-1; k++){
        if(L[i].n<=R[j].n) A[k] = L[i++];
        else               A[k] = R[j++];
    }
}

void mergeSort(Card *A,int left,int right){
    int mid;
    if(left+1 < right){
        mid = left+(right-left)/2;
        mergeSort(A, left, mid);
        mergeSort(A, mid, right);
        merge(A, left, mid, right);
    }
}

int partition(Card *A,int p,int r){

int pivot, i, j;

//右端の要素を枢軸に

pivot=A[r].n;
i=p-1;

    for(j=p;j<r;j++){
        if(A[j].n<=pivot){
        i=i+1;
        swap(&A[i],&A[j]);
        }
    }
    swap(&A[i+1],&A[r]);
    return i+1;
}

void quicksort(Card *A,int p,int r){
    int q;
    if(p < r){
        q = partition(A, p, r);
        quicksort(A, p, q-1);
        quicksort(A, q+1, r);
    }
}

int main(void){

    int i,flag=0;
    char S[10];
    Card A[MAX_ELEMENTS],B[MAX_ELEMENTS];

    scanf("%d", &n);
    for(i=0; i<n; i++){
    scanf("%s %d", &S, &A[i].n);
    B[i].m = A[i].m = S[0];
    B[i].n = A[i].n;
    }

    quicksort(A, 0, n-1);
    mergeSort(B, 0, n);

    for(i=0;i<n;i++){
        if(A[i].m!=B[i].m) flag=1;
    }
    if(flag==1) printf("Not stable\n");
    else        printf("Stable\n");
    for(i=0;i<n;i++) printf("%c %d\n", A[i].m, A[i].n);
    return 0;
}


Measured memory_bytes: 4044
n = int(input())
a = list(map(int,input().split()))
a = sorted(a)
#print(a)
if a[0]==0 :
  print(0)
  exit()

res = 1

lim = 10**18

for i in(a):
  res *= i
  if res > lim :
    print(-1)
    exit()
  
print(res)

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

using namespace std;

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

  int ans = 0;
  while(n > 0){
    if(n%10 == 2){
      ans++;
    }
    n /= 10;
  }

  cout << ans << endl;

  return 0;
}

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

D = []
for i in range(M):
    P, Y = map(int, input().split())
    D.append((i, P, Y))
D.sort(key=lambda x: x[2])

X = [1 for _ in range(N+1)]
A = []
for i, p, y in D:
    A.append((i, "{0:06d}{1:06d}".format(p, X[p])))
    X[p] += 1
A.sort()
for i, x in A:
    print(x)


Measured memory_bytes: 36732
#include <bits/stdc++.h>
#define REP(i, a, n) for(ll i = ((ll) a); i < ((ll) n); i++)
#define INF (1LL << 60)
#define MOD 100000007LL
using namespace std;
typedef long long ll;
typedef pair<ll, ll> pll;
typedef vector<ll> vll;
typedef pair<vll, vll> pvll;

struct state {
  ll d, v;

public:
  bool operator<(const state s) const { return d > s.d; }
};

const ll S = 0, G = 1;
ll N, M, A[100000], B[100000], C[100000];
vector< vector<pll> > E1(100000), E2(100000);

pvll dijkstra(vector< vector<pll> > &E, ll s) {
  vll dist(N, INF), cnt(N, 0);
  dist[s] = 0;
  cnt[s] = 1;

  priority_queue<state> q;
  q.push((state) { 0, s });

  while(q.size()) {
    ll d = q.top().d, v = q.top().v;
    q.pop();

    if(dist[v] < d) continue;

    REP(i, 0, E[v].size()) {
      ll u = E[v][i].first, c = E[v][i].second;
      if(dist[u] == d + c) {
        (cnt[u] += cnt[v]) %= MOD;
      } else if(dist[u] > d + c) {
        dist[u] = d + c;
        cnt[u] = cnt[v];
        q.push((state) { d + c, u });
      }
    }
  }

  return pvll(dist, cnt);
}

int main(void) {
  cin >> N >> M;
  REP(i, 0, M) {
    cin >> A[i] >> B[i] >> C[i]; A[i]--; B[i]--;
    E1[A[i]].push_back(pll(B[i], C[i]));
    E2[B[i]].push_back(pll(A[i], C[i]));
  }

  pvll d1 = dijkstra(E1, S), d2 = dijkstra(E2, G);
  vll dist1 = d1.first, dist2 = d2.first, cnt1 = d1.second, cnt2 = d2.second;

  ll orgd = dist1[G];
  ll orgc = cnt1[G];

  REP(i, 0, M) {
    ll u = A[i], v = B[i], cost = C[i];
    if(dist1[v] + cost + dist2[u] < orgd) cout << "HAPPY" << endl;
    else if(dist1[u] + cost + dist2[v] == orgd && (cnt1[u] * cnt2[v]) % MOD == orgc) cout << "SAD" << endl;
    else cout << "SOSO" << endl;
  }
}

Measured memory_bytes: 22304
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<queue>
#include<map>
#include<set>
using namespace std;
#define LL long long 
#define LD long double
int n,u,v,dis1[100005],dis2[100005];
vector<int>to[100005];
void bfs1(int st)
{
	queue<int>q;
	memset(dis1,0x3f,sizeof(dis1));
	dis1[st]=0;
	q.push(st);
	while(!q.empty())
	{
		int now=q.front();q.pop();
		int len=to[now].size();
		for(int i=0;i<len;i++)
		{
			int v=to[now][i];
			if(dis1[v]==0x3f3f3f3f)
			{
				dis1[v]=dis1[now]+1;
				q.push(v);
			}
		}
	}
}

void bfs2(int st)
{
	queue<int>q;
	memset(dis2,0x3f,sizeof(dis2));
	dis2[st]=0;
	q.push(st);
	while(!q.empty())
	{
		int now=q.front();q.pop();
		int len=to[now].size();
		for(int i=0;i<len;i++)
		{
			int v=to[now][i];
			if(dis2[v]==0x3f3f3f3f)
			{
				dis2[v]=dis2[now]+1;
				q.push(v);
			}
		}
	}
}
int main()
{
	scanf("%d%d%d",&n,&u,&v);
	for(int i=1,x,y;i<n;i++)
	{
		scanf("%d%d",&x,&y);
		to[x].push_back(y);
		to[y].push_back(x);
	}
	bfs1(u);
	bfs2(v);
	int ans=0;
	for(int i=1;i<=n;i++)
	{
		if(dis1[i]<dis2[i])
		{
			ans=max(ans,dis2[i]-1);
		}
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 6656
#include<bits/stdc++.h>
using namespace std;
const int N = 1e6 + 5;

int cnt[N];
int n;
void solve(){
    int i = 0, j = 0;
    for(i = 1; i < N; i++){
        for(j = i; j < N; j += i){
            if(i < sqrt(j))
                cnt[j] += 2;
            else if(i == sqrt(j))
                cnt[j]++;
        }
    }
    int sum = 0;
    for(i = 1; i <= n - 1; i++){
        sum += cnt[n - i];
    }
    cout << sum << "\n";
}
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int t = 1;
    while(t--) {
        cin >> n;
        solve();
    }
    return 0;
}

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

class Main {
  public static void main(String[] args) {
    Scanner scanner = new Scanner(System.in);
    
    int[] a = new int[3];
    for (int i = 0; i < 3; i++) {
      a[i] = scanner.nextInt();
    }
    Arrays.sort(a);
    System.out.println(a[0] + a[1]);
    
    
}
}

Measured memory_bytes: 22996
#include <iostream>

using namespace std;
int main(void){
    // Here your code !
string c;
getline(cin,c);

for(int i=0;i<c.size();i++){
    if('a'<=c[i]&&c[i]<='z') c[i]=c[i]-'a'+'A';
    cout<<c[i];
}
cout<<endl;
}

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

using namespace std;

#define FOR(i,a,b) for(int i = (a); i < (b); ++i)
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()

inline int toInt(string s) {int v; istringstream sin(s);sin>>v; return v;}

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector< vector<int> > Mat;
typedef tuple<int, int, int, int> T;

const int MOD = (int)1e9+7;
const int INF = (int)1e9;
const int dx[] = {0, 1, 0, -1};
const int dy[] = {1, 0, -1, 0};
const int ddx[] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[] = {1, 1, 0, -1, -1, -1, 0, 1};

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

    double ave = 0;
    rep(i, N){
        ave += a[i];
    }
    ave /= N;
    //cout << "ave = " << ave << endl;

    double dist = (double)1e9;
    int ans = 0;
    rep(i, N){
        double tmp = abs(ave - a[i]);

        if(tmp < dist){
            dist = tmp;
            ans = i;
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
import java.util.*;
import java.lang.*;

public class Main{
        public static void main(String[] args){
                Scanner scanCnt = new Scanner(System.in);
                int cnt = scanCnt.nextInt();

                double arrayA[] = new double[cnt];
                String arrayB[] = new String[cnt];

                double res=0;


                for(int i =0; i< arrayA.length ; i++){
                        double scanA = scanCnt.nextDouble();
                        String scanB = scanCnt.next();
                        arrayA[i] = scanA;
                        arrayB[i] = scanB;
                }

                for(int i =0; i< arrayA.length ; i++){
                        if(arrayB[i].equals("JPY")){
                                res += arrayA[i];
                        }else{
                                res += arrayA[i]*380000;
                        }
                }

                System.out.println(res);
        }
}

Measured memory_bytes: 23124
#include <cstdio>
#include <string.h>
#include <algorithm>
using namespace std;

#define N 1100000
#define P 1000000007

int dp[N], sum[N];
int n;

int main() {
	scanf("%d", &n);
	dp[0] = 1;
	dp[1] = n;
	sum[0] = 1;
	sum[1] = n + 1;
	for (int i = 2; i <= n; i++) {
		dp[i] = dp[i - 1];
		dp[i] = (dp[i] + 1LL * (i - 2) * (n - 1)) % P;
		if (i >= 3)
			dp[i] = (dp[i] + sum[i - 3]) % P;
		// for (int j = 2; j <= i - 1; j++)
		// 	dp[i] = (dp[i] + dp[i - j - 1] + (n - 1)) % P;
		dp[i] = (dp[i] + 1LL * (n - i + 1) * n) % P;
		sum[i] = (dp[i] + sum[i - 1]) % P;
	}
	printf("%d\n", dp[n]);
}


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

#define fastio ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL)
#define lli long long int
#define rep(i,n,z) for(int i=z;i<n;i++)
#define rrep(i,z) for(int i=z;i>=0;i--)
#define nl cout<<endl
#define vi vector<int>
#define vlli vector<long long int>
#define umap unordered_map
#define pb push_back
#define mp make_pair
#define ss second
#define ff first
#define ipair pair <int,int>
#define llipair pair <lli,lli>
#define pq priority_queue
#define displaymatrix(a,m,n) for(int i=0;i<m;i++){for(int j=0;j<n;j++)cout<<a[i][j]<<" ";cout<<endl;}
#define printarray(a,n) for(int i=0;i<n;i++){cout<<a[i]<<" ";}nl;
#define vinput(a,n) vlli a(n);rep(i,n,0)cin>>a[i]
#define ainput(a,n) rep(i,n,0)cin>>a[i]
#define SO(a) sort(a.begin(),a.end())
#define all(x) (x).begin(),(x).end()
#define SOP(a,comp) sort(a.begin(),a.end(),comp)
#define inf INT_MAX
#define endl '\n'

int main()
{
    fastio;
    int a,b,c,d;
    cin>>a>>b>>c>>d;
    int turn  = 1;
    while(1){
        if(turn&1){
            c -= b;
            if(c <= 0){
                cout<<"Yes"<<endl;
                return 0;
            }
        }
        else{
            a -= d;
            if(a <= 0){
                cout<<"No"<<endl;
                return 0;
            }
        }
        turn ^= 1;
    }
}

Measured memory_bytes: 3632
#include<cstdio>
#include<iostream>
#include<vector>
#include<tuple>
#include<queue>
#include <set>
#include<algorithm>
#include<string.h>
#include<math.h>

using namespace std;

int main(int argc, char* argv[]){
  int n;
  scanf("%d",&n);
  int odd;
  int even;
  int ans;
  set<int>oddst;
  multiset<int>oddmst;
  set<int>evenst;
  multiset<int>evenmst;
  for(int i=0;i<n;i++){
      if(i%2==0){
        scanf("%d",&odd);
        oddst.insert(odd);
        oddmst.insert(odd);
      }else{
        scanf("%d",&even);
        evenst.insert(even);
        evenmst.insert(even);
      }
  }
  int numo = oddst.size();
  int max1onum=0;
  int max1oidx;
  int max2onum=0;
  int max2oidx;
  int num;
  for(auto itr = oddst.begin(); itr != oddst.end(); ++itr) {
    num = oddmst.count(*itr);
    if(num > max1onum){
      max1onum = num;
      max1oidx = *itr;
    }else if(num >= max2onum){
      max2onum = num;
      max2oidx = *itr;
    }  
  }
  for(auto itr = oddst.begin(); itr != oddst.end(); ++itr) {
    num = oddmst.count(*itr);
    if(num >= max2onum && num < max1onum){
      max2onum = num;
      max2oidx = *itr;
    }  
  }
  int nume = evenst.size();
  int max1enum=0;
  int max1eidx;
  int max2enum=0;
  int max2eidx;
  for(auto itr = evenst.begin(); itr != evenst.end(); ++itr) {
    num = evenmst.count(*itr);
    if(num > max1enum){
      max1enum = num;
      max1eidx = *itr;
    }else if(num >= max2enum){
      max2enum = num;
      max2eidx = *itr;
    }  
  }
  for(auto itr = evenst.begin(); itr != evenst.end(); ++itr) {
    num = evenmst.count(*itr);
    if(num >= max2enum && num < max1enum){
      max2enum = num;
      max2eidx = *itr;
    }  
  }
  if(max1oidx != max1eidx){
    ans = (n/2 - max1onum)+(n/2 -max1enum);
  }else{
    int ans1 = (n/2 - max1onum)+(n/2 - max2enum);
    int ans2 = (n/2 - max2onum)+(n/2 - max1enum);
    ans = min(ans1,ans2);
  }
  printf("%d\n",ans);
  return 0;
}

Measured memory_bytes: 9600
#pragma GCC optimize("Ofast")
#include <cstring>
#include <iostream>
#include <bits/stdc++.h>
#include <algorithm>
#include <vector>
#include <math.h>
using namespace std;
typedef long long ll;

int main() {
    ll N, n=0;
    int i;
    string same;

    cin >> N;

    vector <string> S(N); 
    set <string> ans;

    for(i=0; i<N; i++) {        
        cin >> S[i];
        ans.insert(S[i]);
    }

    cout << ans.size() << endl;

}

Measured memory_bytes: 25104
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
#include<cmath>
using namespace std;
int main(){
	int A,B,C,D;
		while(~scanf("%d%d%d%d",&A,&B,&C,&D)){
		if(A+B>C+D)
			printf("Left\n");
		else if(A+B==C+D)
			printf("Balanced\n");
		else if(A+B<C+D)
			printf("Right\n");
		}
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <math.h>
#include <algorithm>
#include <string>
#include <map>
#include <iomanip>
#define rep(i,N) for(int i=0; i<N;i++)
using namespace std;
long int gcd(long int a, long int b)
{
   if (a%b == 0)
   {
       return(b);
   }
   else
   {
       return(gcd(b, a%b));
   }
}

long int lcm(long int a, long int b)
{
   return a * b / gcd(a, b);
}

int main(){
    long int A,B,ans;
    cin >> A >> B;
    cout << lcm(A,B)<<endl;

    return 0;
}

Measured memory_bytes: 256
import java.util.*;
import java.lang.*;
import java.io.*;

class Main
{
	public static void main (String[] args) throws java.lang.Exception
	{
		String nl = System.getProperty("line.separator");
		StringBuilder p = new StringBuilder(1000);
		StringBuilder d = new StringBuilder(".");
		StringBuilder s = new StringBuilder("#");
		StringBuilder k = new StringBuilder(50);
		Scanner r = new Scanner(System.in);
		int h, w, i, ww;
		String t, u;
		for (i = 0; i < 4; ++i) {
			d.append(d);
			s.append(s);
		}
		ww = d.length();
		while ((h = r.nextInt()) + (w = r.nextInt()) != 0) {
			while (w > ww) {
				d.append(d);
				s.append(s);
				ww += ww;
			}
			p.append(u = s.substring(0,w));
			p.append(nl);
			k.setLength(0);
			k.append('#');
			k.append(d.substring(2, w));
			k.append('#');
			k.append(nl);
			for (i = h - 2; i > 0; --i) {
				p.append(k);
			}
			p.append(u);
			p.append(nl);
			p.append(nl);
		}
		System.out.print(p);
	}
}

Measured memory_bytes: 18388
#include <iostream>
#include <sstream>
#include <vector>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <utility>
#include <map>
#include <list>
#include <climits>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <iomanip>
#include <bitset>

// #define cerr if(false)cerr
#define watch(x) cerr << "> " << #x << ": " << x << "\n";

using namespace std;

template <typename T>
std::ostream &operator <<(std::ostream &out, vector<T> &v) {
	for (typename vector<T>::size_type i = 0; i < v.size(); ++i)
		out << v[i] << " ";
	out << "\n";
    return out;
}
template <typename T, typename N>
std::ostream &operator <<(std::ostream &out, vector<pair<T, N> > &v) {
	for (size_t i = 0; i < v.size(); ++i)
		out << "(" << v[i].first << ", " << v[i].second << ") ";
	out << "\n";
    return out;
}
template <typename T>
std::ostream &operator <<(std::ostream &out, vector<vector<T> > &v) {
	for (size_t i = 0; i < v.size(); ++i) {
		for (size_t j = 0; j < v[i].size(); ++j) {
			out << v[i][j] << " ";
		}
		out << "\n";
	}
   	return out;
}

int main() {

	std::ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);

	int n;
	cin >> n;

	vector<vector<pair<int, int> > > testimonies(n + 1, vector<pair<int, int> > ());
	int a;
	for (int i = 0; i < n; ++i) {
		cin >> a;	
		int x, y;
		while (a--) {
			cin >> x >> y;
			testimonies[i + 1].push_back({x, y});
		}	
	}

	int ans = 0;
	for (int i = 0; i < (1 << n); ++i) {
		vector<int> is_honest(n + 1);
		int count = 0;
		for (int j = 0; j < n; ++j) {
			if (i & (1 << j)) {
				is_honest[j + 1] = 1;
				++count;
			}
		}

		bool contradiction = false;
		for (int j = 1; j <= n; ++j) {
			for (int k = 0; k < (int) testimonies[j].size(); ++k) {
				if (is_honest[j] && is_honest[testimonies[j][k].first] != testimonies[j][k].second) {
					contradiction = true;
					break;
				}
			}
		}

		if (!contradiction) {
			ans = max(ans, count);
		}
	}

	cout << ans << "\n";

	return 0;

}

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

int N,M;
vector<int> dp;
vector<bool> visited;

int dfs(int v,vector<vector<int> > &G){
    if(visited[v])return dp[v];
    visited[v] = true;
    dp[v] = 0;
    for(auto u : G[v]){
        int res = dfs(u,G);
        dp[v] = max(dp[v],res+1);
    }
    return dp[v];
}

int main(){
    cin >> N >> M;
    dp.resize(N,0);
    visited.resize(N,false);
    vector<vector<int> > G(N);
    rep(i,M){
        int u,v;cin >> u >> v;
        u--;v--;
        G[u].push_back(v);
    }

    int ans = 0;

    rep(i,N){
        int res = dfs(i,G);
        ans = max(ans,res);
    }
    cout << ans << endl;
    return 0;
}

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

#define ll long long int
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define phi 3.1415926535
#define fastio() ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define endl '\n'
 
using namespace std;

const ll mod = 1000000007;    

ll tc, cnt = 0, number, many, total = 0, query;
// vector <vector <int> > adjList;
int rmove[8] = {-1, 0, 1, 0, -1, 1, -1, 1};
int cmove[8] = {0, 1, 0, -1, 1, -1, -1, 1};

ll power(ll x, ll y, ll mod)
{
    if(y == 0)
        return 1;
    else if(y % 2 == 0)
        return (power(x, y / 2, mod) % mod * power(x, y / 2, mod) % mod) % mod;
    else
        return x * (power(x, y / 2, mod) % mod * power(x, y / 2, mod) % mod) % mod;
}

struct Info
{
    int a, b, c;
};

int main()
{
    fastio();
        
    // freopen("input.txt","r", stdin);
    // freopen("output.txt","w", stdout);
    // g++ -std=c++11 Default.cpp  -o test
    // g++ -Wl,--stack=268435456 -std=c++11 Default.cpp  -o test

    cin >> many;

    Info arr[many];
    for(int i = 0; i < many; i++)
        cin >> arr[i].a >> arr[i].b >> arr[i].c;

    int dp[many + 1][3];
    memset(dp, 0, sizeof(dp));

    for(int i = 1; i <= many; i++)
    {
        for(int j = 0; j < 3; j++)
        {
            if(j == 0)
                dp[i][j] = max(dp[i - 1][1], dp[i - 1][2]) + arr[i - 1].a;
            else if(j == 1)
                dp[i][j] = max(dp[i - 1][0], dp[i - 1][2]) + arr[i - 1].b;
            else
                dp[i][j] = max(dp[i - 1][1], dp[i - 1][0]) + arr[i - 1].c;
        }
    }

    cout << max(dp[many][0], max(dp[many][1], dp[many][2])) << endl;

    //
    return 0;
}

Measured memory_bytes: 5912
A, B, C, K = map(int, input().split())
ans = 0

if A < K and K > 0:
    ans += A
    K -= A
elif A >= K and K > 0:
    ans += K
    K = 0

if B < K and K > 0:
    K -= B
elif B >= K and K > 0:
    K = 0

if C < K and K > 0:
    ans -= C
    K -= C
elif C >= K and K > 0:
    ans -= K
    K = 0

print(ans)

Measured memory_bytes: 9188
import java.util.*;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
  int H = sc.nextInt();
  int W = sc.nextInt();
  String[] s = new String[H];
  for(int i = 0;i < W+2;i++)System.out.print("#");
  System.out.println("");
  for(int i = 0;i < H;i++){
    s[i] = sc.next();
    System.out.println("#" + s[i] + "#");
  }
  for(int i = 0;i < W+2;i++)System.out.print("#");
  System.out.println("");
}}

Measured memory_bytes: 21844
#include <stdio.h>

int main() {
  int number, number_upper, number_bottom, flag = 0;
  scanf("%d", &number);
  number_bottom = number % 100;
  number_upper = (number - number_bottom) / 100;
  if((1 <= number_bottom && number_bottom <= 12) && !(1 <= number_upper && number_upper <= 12)) {
    printf("YYMM\n");
  } else if((1 <= number_upper && number_upper <= 12) && !(1 <= number_bottom && number_bottom <= 12)) {
    printf("MMYY\n");
  } else if((1 <= number_upper && number_upper <= 12) && (1 <= number_bottom && number_bottom <= 12)) {
    printf("AMBIGUOUS\n");
  } else {
    printf("NA\n");
  }
  return 0;
}


Measured memory_bytes: 128
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);
		int n = Integer.parseInt(sc.next());
		int d = Integer.parseInt(sc.next());
		int n1 = Integer.parseInt(sc.next());
		int d1 = Integer.parseInt(sc.next());
		if(n==n1) {
			System.out.print(0);
		}
		else {
			System.out.print(1);
		}
	}
}

Measured memory_bytes: 22992
#include<stdio.h>
#include<math.h>
int main()
{
  int a;
  int i,j[101];
  j[0]=1;
	  while(scanf("%d",&a)!=EOF)
	  {
	    int b=0;
		for(i=1;i<=a;i++)
		{
		  j[i]=pow(2,i);
		  if(j[i]>a)
		  {
		    b=j[i-1];
			break;
		  }
		}
		printf("%d\n",b);
	  }
	  return 0;
}




Measured memory_bytes: 128
//
//  9_C.cpp
//  
//
//  Created by 杵鞭俊 on 2018/07/13.
//

#include <cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
#define MAX 2000000
#define INFTY (1<<30)

int H, A[MAX+1];

void maxHeapify(int i){
    int l,r,largest;
    l = 2 * i;
    r = 2 * i + 1;
    
    if(l <= H && A[l] > A[i] ) largest = l;
    else largest = i;
    
    if(r <= H && A[r] > A[largest] ) largest = r;
    
    if(largest != i){
        swap( A[i],A[largest]);
        maxHeapify(largest);
    }
}

int extract(){
    int maxv;
    if(H < 1) return -INFTY;
    maxv = A[1];
    A[1] = A[H--];
    maxHeapify(1);
    return maxv;
}


void increaseKey(int i,int key){
    if(key < A[i]) return;
    A[i] = key;
    while(i > 1 && A[i / 2] < A[i]) {
        swap(A[i],A[i / 2]);
        i = i / 2;
    }
}


void insert(int key){
    H++;
    A[H] = -INFTY;
    increaseKey(H,key);
}


int main(){
    int key;
    char com[10];
    
    while (1) {
        scanf("%s",com);
        if (com[0] == 'e' && com[1] == 'n') break;
        if (com[0] == 'i') {
            scanf("%d",&key);
            insert(key);
        } else {
            printf("%d\n",extract());
        }
        
    }
    return 0;
}



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

int main() {
    int N, M;
    cin >> N >> M;
    vector<set<int>> graph(N+1);
    vector<int>A(M);
    vector<int>B(M);
    for (int i = 0; i < M; ++i) {
        cin >> A[i] >> B[i];
        graph[A[i]].insert(B[i]);
        graph[B[i]].insert(A[i]);
    }
    if(M % 2 == 1){
        cout << "-1";
        return 0;
    }

    // 全域木を求める
    vector<set<int>> spTree(N+1);
    stack<int> s1;
    vector<int>flag1(N+1, 0);
    s1.push(1);
    flag1[1] = 1;
    while (! s1.empty()){
        int t = s1.top();
        s1.pop();
        for (auto x : graph[t]) {
            if(flag1[x] == 0){
                flag1[x] = 1;
                spTree[t].insert(x);
                spTree[x].insert(t);
                s1.push(x);
            }
        }
    }

    // 頂点から出る辺の本数
    vector<int>degree(N+1, 0);

    // 木以外の辺の向きを適当に決める
    for (int i = 0; i < M; ++i) {
        if(spTree[A[i]].count(B[i]) == 0) {
            degree[A[i]]++;
            cout << A[i] << " " << B[i] << endl;
        }
    }

    // 確定済みでない辺の個数が1の頂点をstackに入れて探索
    stack<int> s2;
    for (int i = 1; i < N+1; ++i) {
        if(spTree[i].size() == 1){
            s2.push(i);
        }
    }
    while (! s2.empty()) {
        int t = s2.top();
        s2.pop();
        auto itr = spTree[t].begin();
        if(degree[t] % 2 == 0){
            cout << *itr << " " << t << endl;
            degree[*itr]++;
        } else {
            cout << t << " " << *itr << endl;
            degree[t]++;
        }
        spTree[*itr].erase(t);
        if(spTree[*itr].size() == 1){
            s2.push(*itr);
        } else if(spTree[*itr].size() == 0){
            break;
        }
    }
    return 0;
}

Measured memory_bytes: 31232
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=(a);i<=(b);i++)
#define per(i,a,b) for(int i=(a);i>=(b);i--)
#define ms(s,x) memset(s,x,sizeof(s))
#define ls rt<<1
#define rs rt<<1|1
#define pb push_back
#define inf 0x3f3f3f3f
typedef long long ll;
using namespace std;

const double PI = acos(-1.0);
const double eps = 1e-8;
const int MAXN = 1e5+5;
const ll MOD = 1e9+7;

int main()
{
    bool flag = 1;
    int e[10]; ms(e, -1);
    int n, m, s, c, ans = 0;
    cin >> n >> m;
    rep(i, 1, m){
        cin >> s >> c;
        if (e[s] != -1 && e[s] != c) flag = 0;
        e[s] = c;
    }
    if (!flag){
        cout << "-1\n";
        return 0;
    }
    if (n == 1){
        if (e[1] != -1) cout << e[1] << endl;
        else cout << "0\n";
    }
    else{
        if (!e[1]){
            cout << "-1\n";
            return 0;
        }
        else if (e[1] == -1) ans = 1;
        else ans = e[1];
        rep(i, 2, n){
            if (e[i] != -1)
                ans = ans * 10 + e[i];
            else ans *= 10;
        }
        cout << ans << endl;
    }

    return 0;
}


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

struct node{
  struct node *right;
  struct node *left;
  struct node *parent;
  int key;
};
typedef struct node * Node;
#define NIL NULL

Node root;

Node treeMinimum(Node x){
  while(x->left!=NIL){
    x=x->left;
  }
  return x;

}

Node treeMaximum(Node x){
  while(x->right!=NIL){
    x=x->right;
  }
  return x;

}

Node treeSearch(Node u, int k){
  if(u==NIL || k==u->key){
    return u;
}
  if(k<u->key){
    return treeSearch(u->left,k);
  }
  else{
    return treeSearch(u->right,k);
  }

}

Node treeSuccessor(Node x){
   Node y;
  if(x->right!=NIL){
    return treeMinimum(x->right);
  }
  y=x->parent;
  while(y!=NIL && x==y->right){
    x=y;
    y=y->parent;
  }
  return y;

}

void treeDelete(Node z){
  Node y; // node to be deleted
  Node x; // child of y
  if(z->left==NIL || z->right==NIL){
    y=z;
  }
  else{
    y=treeSuccessor(z);
  }
  if(y->left!=NIL){
    x=y->left;
  }
  else{
    x=y->right;
  }
  if(x!=NIL){
    x->parent=y->parent;
  }
  if(y->parent==NIL){
    root=x;
  }
  else if(y==y->parent->left){
    y->parent->left=x;
  }
  else{
    y->parent->right=x;
  }
  if(y!=z){
    z->key=y->key;
  }
}

void insert(int k){
  Node y = NIL;
  Node x = root;
  Node z;

  z = malloc(sizeof(struct node));
  z->key = k;
  z->left = NIL;
  z->right = NIL;

  while(x!=NIL){
    y=x;
    if(z->key<x->key){
      x=x->left;
    }
    else{
      x=x->right;
    }
  }
  z->parent=y;
  if(y==NIL){
    root=z;
  }
  else if(z->key<y->key){
    y->left=z;
  }
  else{
    y->right=z;
  }
}

void inorder(Node u){
  if(u == NIL)return;
    inorder(u->left);
    printf(" %d",u->key);
    inorder(u->right);
}
void preorder(Node u){
  if(u == NIL)return;
    printf(" %d",u->key);
    preorder(u->left);
    preorder(u->right);
}


int main(){
  int n, i, x;
  char com[20];
  scanf("%d", &n);

  for ( i = 0; i < n; i++ ){
    scanf("%s", com);
    if ( com[0] == 'f' ){
      scanf("%d", &x);
      Node t = treeSearch(root, x);
      if ( t != NIL ) printf("yes\n");
      else printf("no\n");
    } else if ( com[0] == 'i' ){
      scanf("%d", &x);
      insert(x);
    } else if ( com[0] == 'p' ){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    } else if ( com[0] == 'd' ){
      scanf("%d", &x);
      treeDelete(treeSearch(root, x));
    }
  }

  return 0;
}



Measured memory_bytes: 20432
use proconio::{input, fastout};
use proconio::marker::{Chars};
use proconio::marker::Usize1;
use std::cmp::*;

macro_rules! debug {
      ($($a:expr),*) => {
          eprintln!(concat!($(stringify!($a), " = {:?}, "),*), $($a),*);
      }
  }
  fn gcd(mut a: usize, mut b: usize) -> usize {
    if a<b {
        let mut tmp = a;
        a = b;
        b = tmp;
    } 
    let mut r = a % b;
    while r!=0 {
        a = b;
        b = r;
        r = a % b;
    }
    b
}

  #[fastout]
fn main() {
    input!{
        n: usize,
    }

    if n%2==0 {
        println!("{}", n);
    } else {
        println!("{}", n*2);
    }

}


Measured memory_bytes: 2172
#include<bits/stdc++.h>
using namespace std;
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define ll long long
#define db double
#define ld long double
#define rep(i,n) for(ll i=0;i<n;i++)
#define rev(i,n) for(ll i=n;i>=0;i--)
#define rep_a(i,a,n) for(ll i=a;i<n;i++)
#define pb push_back
#define sz(v) ((int)(v).size())
#define all(v) (v).begin(), (v).end()
#define debug(x) do { std::cerr << #x << ": " << x << std::endl; } while (0);
#define debugg(x,y) do { std::cerr << #x << ": " << x << "  "<< #y << ": " << y << std::endl; } while (0);
#define debugggg(i,j,k,ans) std::cerr << #i << ": " << i << "  "<< #j << ": " << j <<#k << ": " << k <<#ans << ": " << ans << std::endl;
const long long mod = 998244353;
const long long MOD = 1000000007;
typedef vector<ll>              vll;
typedef vector<string>          vstr;
typedef vector<char>            vchar;
typedef vector<pair<ll,ll> >    vpll;
typedef set<ll>                 sll;
typedef set<string>             sstr;
typedef set<pair<ll,ll> >       spll;
typedef map<ll,ll>              mllll;
typedef map<string,ll>          mstrll;
typedef queue<ll>               qll;
map<ll,ll>mp; 
int solve()
{
  int n;cin>>n;vll h(n);
  rep(i,n)cin>>h[i];
  vll dp(n+1,0);
  dp[0] = 0;
  dp[1] = 0;
  dp[2] = abs(h[0] - h[1]);
  rep_a(i,3,n+1)
  {
    dp[i] = min(dp[i-2] + abs(h[i-3] - h[i - 1]) , dp[i-1] + abs(h[i-2] - h[i -1]));
  }
  cout<<dp[n]<<endl;
  return 0;
}
 
int main()
{
  fast;
	/* #ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
	#else
	#endif */
	solve();
	/* #ifndef ONLINE_JUDGE
	cout<<"\nTime Elapsed: "<<1.0*clock()/ CLOCKS_PER_SEC <<" Sec\n";
	#endif */
	return 0;
}

Measured memory_bytes: 4736
#include<bits/stdc++.h>
using namespace std;
int main(){
	int h,w,n;
	cin >> h >> w >> n;
	if(n%max(h,w)==0)
	cout << n/max(h,w) << endl;
	else
	cout << n/max(h,w)+1 << endl;
	return 0;
} 

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <stdio.h>
#include <complex>
#include <math.h>
#include <assert.h>

using namespace std;
typedef complex<double> Complex;

static const double E = 0.000001;

inline bool collide_circle_circle(const Complex p1, const double r1, const Complex p2, const double r2) {
  assert(r1 >= 0.0 && r2 >= 0.0);
  Complex dif = p1 - p2;
  return dif.real() * dif.real() + dif.imag() * dif.imag() <= (r1 + r2) * (r1 + r2) + E;
}

// include circle inside
inline bool collide_circle_point(const Complex p1, const double r1, const Complex p2) {
  return collide_circle_circle(p1, r1, p2, 0.0);
}

inline void intersection_circle_circle(const Complex p1, const double r1, const Complex p2, const double r2, int *size, Complex *ret1, Complex *ret2) {
  assert(p1 != p2);
  assert(ret1 != NULL && ret2 != NULL);
  if (!collide_circle_circle(p1, r1, p2, r2)) {
    if (size != NULL) { *size = 0; }
    *ret1 = *ret2 = Complex(NAN, NAN);
    return;
  }
  Complex center = (p1 * r2 + p2 * r1) / (r1 + r2);
  Complex vect = (center - p1) * Complex(0.0, 1.0);
  if (abs(vect) < E) {
    *ret1 = *ret2 = center;
    if (size != NULL) { *size = 1; }
    return;
  }
  vect *= sqrt(r1 * r1 - norm(vect)) / abs(vect);
  *ret1 = center + vect;
  *ret2 = center + vect * Complex(-1.0, 0.0);
  if (size != NULL) { *size = 2; }
}

Complex point[301];

int main() {
  int n;
  while (scanf("%d", &n), n != 0) {
    for (int i = 0; i < n; i++) {
      double a, b;
      scanf("%lf %lf", &a, &b);
      point[i] = Complex(a, b);
    }
    int max_ans = 1;
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < i; j++) {
        if (!collide_circle_circle(point[i], 1.0, point[j], 1.0)) { continue; }
        int size;
        Complex m[2];
        intersection_circle_circle(point[i], 1.0, point[j], 1.0, &size, &m[0], &m[1]);
        for (int s = 0; s < size; s++) {
          int ans = 0;
          for (int k = 0; k < n; k++) {
            if (collide_circle_point(m[s], 1.0, point[k])) {
              ans++; }
          }
          max_ans = max(max_ans, ans);
        }
      }
    }
    printf("%d\n", max_ans);
  }
}

Measured memory_bytes: 936
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n, m, x,tmp1, tmp2,cost0=0,costn=0;
    int a[110];
    cin >> n >> m >> x;
    for(int i=0; i<m ;i++){
        cin >> a[i];
    }
    
    for(int i=0; i<=x; i++){
        for(int j=0; j<=n;j++){
            if(i == a[j]){
                cost0++;
                break;
            }
            if(a[j]>=x){
                break;
            }
        }
    }
    for(int i=x; i<=n; i++){
        for(int j=0; j<=n;j++){
            if(i == a[j]){
                costn++;
                break;
            }
        }
    }
    
    cout << ((cost0<costn)?cost0:costn) << endl;
    
    return 0;
    
}

Measured memory_bytes: 256
h,w,a,b = [int(x) for x in input().split()]
for i in range(h):
  if i<h-b:
    z = "0"*a
    o = "1"*(w-a)
    print(z+o)
  else:
    z = "0"*(w-a)
    o = "1"*a
    print(o+z)

Measured memory_bytes: 3956
#include <bits/stdc++.h> //C++の機能を「全て」読み込むための命令
#define rep(i,n) for(int i=0; i<(n); ++i)
#define cout(x) cout<<x<<endl
#define all(v) v.begin(), v.end()
using namespace std;
//型エイリアス
using vi = vector<int>;
using ll = long long;
using P = pair<int,int>;
using Mat = vector<vector<int>>;
const ll inf = 1e18;
const int N = 2e5+10;

int main(){
    int n;
    cin >> n;
    vector<string> s(n);
    vi p(n);
    vector<tuple<string, int, int>> res(n);
    rep(i,n){
        cin >> s[i] >> p[i];
        res[i] = make_tuple(s[i],-p[i],i+1);
    }
    sort(all(res));
    for(auto x : res){
        get<1>(x) = -get<1>(x);
        cout(get<2>(x));
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i=0; i<(n); ++i)
#define repr(i, a, b) for (int i=a; i<(b); ++i)
#define reprev(i, n) for (int i=n-1; i>=0; --i)
#define reprrev(i, a, b) for (int i=b-1; i>=(a); --i)
using namespace std;
using ll = long long;
using P = pair<int, int>;

int main() {
    cout << fixed << setprecision(10);
    
    int n, m; cin >> n >> m;
    cout << n*(n-1)/2 + m*(m-1)/2 << endl;
    return 0;
}

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

const long long MOD = 1e9 + 7;

int n, x;
stack<int> s;

int main() {

    scanf("%d", &n);
    
    long long ans = 1;
    for (int i = 0; i < n; i++) {
        scanf("%d", &x);

        s.push(x);

        if (x < 2 * s.size() - 1) {
            ans = (ans * s.size()) % MOD;

            s.pop();
        }
    }

    while (!s.empty()) {
        ans = (ans * s.size()) % MOD;
        s.pop();
    }

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

    return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define int long long
#define double long double
#define rep(i,s,n) for(int i = (s); i < (n); i++)
#define all(v) begin(v), end(v)
#define allg(v) begin(v), end(v), greater<int>()



signed main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  
  string s;
  int n, t, a;
  
  cin >> n >> t >> a;
  
  vector<double> h(n);  
  
  rep(i, 0, n) {
    double hg;
    cin >> hg;
    h[i] = t - hg*0.006;
  }
  
  double dif = 1e9+7;
  int ans = 0;
  rep(i, 0, n) {
    if(abs(h[i] -a) < dif) {
      dif = abs(h[i] -a);
      ans = i+1;
    }
  }
  cout << ans << "\n";

}


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

using namespace std;

int main(){
    int N;
    long H,W;
    cin>>N;
    cin>>H>>W;

    vector<long> A(N),B(N);
    long ans=0;

    for(long i=0;i<N;i++){
        cin>>A[i]>>B[i];
        if(A[i]>=H&&B[i]>=W){
            ans++;
        }
    }

    cout<<ans<<endl;
}

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

typedef long long ll;
//const int INF = 2e9;
//const ll INF = 9e18;


int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    string X;
    cin >> X;
    stack<char> st;
    for (int i=0;i<X.size();i++){
        if (st.empty()) {
            st.push(X[i]);
            continue;
        }
        if (st.top() == 'S' && X[i] == 'T') {
            st.pop();
        } else {
            st.push(X[i]);
        }
    }
    cout << st.size() << "\n";
}

Measured memory_bytes: 720
#include <algorithm>
#include <cassert>
#include <cctype>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstring>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <vector>
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define show(x) cout << #x << " = " << (x) << endl;
using namespace std;
using ll = long long;
using pii = pair<int,int>;
vector<int>g[123456];
vector<int>rg[123456];
int cnt[123456];
bool used[123456];
int dp[123456];
int  dist[123456];
int ans[123456];
int dfs(int s){
    if(dp[s] != -1)return dp[s];
    int id = 0,ma = -1;
    for(int x:rg[s]){
        dfs(x);
        if(ma < dp[x]+1){
            ma = dp[x]+1;
            id = x;
        }
    }
    ans[s] = id;
    return dp[s] = ma;
}
int main(){
    int n,m;
    cin >> n >> m;
    rep(i,n-1+m){
        int a,b;
        cin >>a >> b;
        a--,b--;
        g[a].push_back(b);
        rg[b].push_back(a);
        cnt[b]++;
    }
    int root = 0;
    rep(i,n){
        if(cnt[i] == 0){
            root = i;
            break;
        }
    }
    rep(i,n){
        ans[i] = -1;
        dp[i] = -1;
    }
    dp[root] = 0;
    rep(i,n){
        dfs(i);
//        show(dp[i]);
    }
    rep(i,n){
        cout << ans[i] + 1 << "\n";
    }
}


Measured memory_bytes: 18048
import math
a,b = map(int, input().split())
out = 0
num = a*b
if a == 1 or b == 1:
  out = 1
else:
  if num%2 == 0:
    out = out + (num / 2)
  else:
    out = out + (num / 2) + 1


print(math.floor(out))

Measured memory_bytes: 3060
#include <iostream>
#include <string>
using namespace std;
#define REP(i, n) for(int i=0; i<(n); i++)
#define SZ(x) ((int)(x).size())

int main() {
	string s;
	cin >> s;
	int n = SZ(s), p = 0;
	REP(i, n)if (s[i] == 'p')p++;
	cout << n / 2 - p << endl;
}

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

int main() {
  int X, A, B;
  cin >> X >> A >> B;
  int C = A - B;
  if (C >= 0) cout << "delicious" << endl;
  else if (-C <= X) cout << "safe" << endl;
  else cout << "dangerous" << endl;
  return 0;
}

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

using namespace std;

int main() {
	int N;
	cin >> N;
	vector<int> rel_pos_list(N+1);
	int prev_pos = 0;
	int fee_sum = 0;
	for (int i = 0; i < N; ++i) {
		int A;
		cin >> A;
		rel_pos_list[i] = A - prev_pos;
		fee_sum += abs(A - prev_pos);
		prev_pos = A;
	}
	rel_pos_list[N] = -prev_pos;
	fee_sum += abs(prev_pos);
	for(int i=0; i<N; ++i){
		cout << fee_sum - (abs(rel_pos_list[i]) + abs(rel_pos_list[i+1])) + abs(rel_pos_list[i]+rel_pos_list[i+1]) << endl;
	}
}


Measured memory_bytes: 1664
import math

if __name__ == "__main__":
    a, b, h, m = map(int, input().split())

    p = math.pi
    alpha = (60 * h + m) * p / 360
    beta = p * m / 30
    theta = alpha - beta

    c2 = a ** 2 + b ** 2 - 2 * a * b * math.cos(theta)
    c = math.sqrt(c2)

    print(c)

Measured memory_bytes: 9508
n = int(input())
d = {}
ans = []
for i in range(n):
  s = input()
  if s not in d:
    d[s] = 1
  else:
    d[s] += 1
d = sorted(d.items(), key=lambda x:x[1])
score = d[-1][1]
ans = []
for i in range(len(d)):
  if d[i][1] == score:
    ans.append(d[i][0])
ans.sort()
for i in range(len(ans)):
  print(ans[i])

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

while (<>) {
    ($x) = split /\s/, $_;
}

$i = 0;
$d = 0;
while (1) {
    $i++;
    $d += $i;
    if ($x == $d) {
        print "$i\n";
        exit;
    } elsif ($x < $d) {
        print "$i\n";
        exit;
    }
}


Measured memory_bytes: 512
#include<stdio.h>
#include<stdlib.h>

int main(void)
{
    int i,k,x;
    scanf("%d %d",&k,&x);
    if(k>=1&&k<=100&&x>=0&&x<=100)
    {
        for(i=k-1;i>=1;i--)
    {
        printf("%d ",x-i);
    }
    printf("%d ",x);
    for(i=1;i<=k-1;i++)
    {
        printf("%d ",x+i);
    }
    }
    return 0;
}


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

using namespace std;

#define ll long long
#define ull unsigned long long
#define PI acos(-1.0)
#define eps 1e-12
#define fi first
#define se second
#define MEM(a,b) memset((a),(b),sizeof(a))
#define mod(x) ((x)%MOD)
#define pii pair<int,int>
#define wz cout<<"-----"<<endl;
const int INF_INT = 2147483647;
const ll INF_LL = 9223372036854775807LL;
const ull INF_ULL = 18446744073709551615Ull;
const ll P = 92540646808111039LL;

const ll maxn = 1e5 + 10, MOD = 1e9 + 7;
const int Move[4][2] = {-1,0,1,0,0,1,0,-1};
const int Move_[8][2] = {-1,-1,-1,0,-1,1,0,-1,0,1,1,-1,1,0,1,1};

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


void init() {

}



int main(){
//    freopen("C:\\Users\\Administrator\\Desktop\\in.txt","r",stdin);
//    freopen("C:\\Users\\Administrator\\Desktop\\out.txt","w",stdout);
//    ios_base::sync_with_stdio(0);
    init();
    string s = "keyence";
    string t; cin >>t;
    int l = 0;
    if (t == s) {
        puts("YES");
        return 0;
    }
    for (int i = 1; i <= t.size() - 7; i++) {
        for (int j = 0; j <= t.size() - i; j++) {
            string sb = t.substr(0, j) + t.substr(j + i, t.size() - j + i - 1);
            if (sb == s) {
                puts("YES");
                return 0;
            }
        }
    }
    puts("NO");
    return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <functional>
#include <algorithm>
#include <vector>
#include <limits>
#include <numeric>
#include <type_traits>
#include <iostream>
#include <queue>
#include <bits/stdc++.h>

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

ll calcNumOfCombination(ll n, ll r) {
    ll num = 1;
    for (ll i = 1; i <= r; i++) {
        num = num * (n - i + 1) / i;
    }
    return num;
}

int gcd(int x, int y) { return (x % y) ? gcd(y, x % y) : y; }

int findSumDigits(int s) {
    int num = 0;
    int temp = 0;
    while (s) {
        temp = s % 10;
        num += temp;
        s = s / 10;
    }
    return num;
}

int countDivisorNum(int n) {
    int count = 0;
    for (int i = 1; i <= n; i++) {
        if (n % i == 0) {
            count++;
        }
    }
    return count;
}


int main() {
    int n, m;
    cin >> n >> m;
    ll h[n];
    rep(i, n, 0) cin >> h[i];
    int ans[n];
    rep(k, n, 0) ans[k] = -1;

    int temp1 = 0;
    int temp2 = 0;
    rep(j, m, 0) {
        cin >> temp1 >> temp2;
        if (h[temp1 - 1] > h[temp2 - 1]) {
            ans[temp2 - 1]++;
        } else if (h[temp1 - 1] < h[temp2 - 1]) {
            ans[temp1 - 1]++;
        } else {
            ans[temp1 - 1]++;
            ans[temp2 - 1]++;
        }
    }

    int count=0;
    rep(l, n, 0) {
        if (ans[l] == -1) {
            count++;
        }
    }

    cout << count << endl;

    return 0;
}

Measured memory_bytes: 4712