akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<vector>
#include<map>
#include<algorithm>
#include<math.h>
#include<string>
#include <iomanip>
#include<deque>

typedef long long ll;
typedef unsigned long long ull;
typedef int itn;
const ll LINF = 1e18;
const int INF = 1e8;

using namespace std;


//マクロ定義
#define vvint(vec,n,m,l) vector<vector<int>> vec(n, vector<int>(m,l));	// lで初期化
#define vvll(vec,n,m,l) vector<vector<ll>> vec(n,vector<ll>(m,l));
#define vint vector<int>
#define pint pair<int,int>
#define rep(i,a) for(int i=0;i<(a);i++)
#define all(x) (x).begin(),(x).end()
#define debug system("pause")				//デバッグ用


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

	vector<int> a(3);
	cin >> a[0] >> a[1] >> a[2];

	sort(a.begin(), a.end());

	cout << a[2] - a[0] << endl;

}

Measured memory_bytes: 256
import std.stdio, std.string, std.conv;

void main()
{
	auto n = readln.split.to!(int[]), a = n[0], b = n[1];
	int m;
	if((a + b) % 2 == 0){
		m = 0;
	} else {
		m = 1;
	}
	writeln((a + b) / 2 + m);
}

Measured memory_bytes: 256
x,y,a,b,c = map(int,input().split())
p = list(map(int,input().split()))
q = list(map(int,input().split()))
r = list(map(int,input().split()))
import heapq as hp
s = x+y
u = []
hp.heapify(u)
for i in range(a):
    hp.heappush(u,[-p[i],'r'])
for i in range(c):
    hp.heappush(u,[-r[i],'m'])
v = []
hp.heapify(v)
for i in range(b):
    hp.heappush(v,[-q[i],'g'])
for i in range(c):
    hp.heappush(v,[-r[i],'m'])
z = []
ans = 0
hp.heapify(z)
for i in range(a):
    hp.heappush(z,[-p[i],'r'])
for i in range(b):
    hp.heappush(z,[-q[i],'g'])
for i in range(c):
    hp.heappush(z,[-r[i],'m'])
while s and x and y:
    t = hp.heappop(z)
    ans += -t[0]
    if t[1] == 'r':
        x -= 1
        s -=1
    elif t[1] == 'g':
        y -= 1
        s -= 1
    else:
        s -= 1
if s > 0 and x > 0:
    while s:
        t = hp.heappop(z)
        if t[1] == 'g':
            continue
        else:
            ans += -t[0]
            s -= 1
elif s > 0 and y > 0:
    while s:
        t = hp.heappop(z)
        if t[1] == 'r':
            continue
        else:
            ans += -t[0]
            s -= 1
print(ans)

Measured memory_bytes: 189904
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <list>
#include <vector>
#include <queue>
#include <algorithm>
#include <climits>
#include <cstring>
#include <cmath>
#include <stack>
#include <iomanip>
#include <tuple>
#include <functional>
#include <cfloat>
#include <map>
#include <set>
#include <array>
#include <stdio.h>
#include <string.h>
using ll = long long;
using namespace std;
//LLONG_MAX = 90^18
#define int long long
#define CONTAINS(v,n) (find((v).begin(), (v).end(), (n)) != (v).end())
#define SORT(v) sort((v).begin(), (v).end())
#define RSORT(v) sort((v).rbegin(), (v).rend())
#define ARY_SORT(a, size) sort((a), (a)+(size))
#define REMOVE(v,a) (v.erase(remove((v).begin(), (v).end(), (a)), (v).end()))
#define REVERSE(v) (reverse((v).begin(), (v).end()))
#define ARY_REVERSE(v,a) (reverse((v), (v)+(a)))
#define LOWER_BOUND(v,a) (lower_bound((v).begin(), (v).end(), (a)))
#define UPPER_BOUND(v,a) (upper_bound((v).begin(), (v).end(), (a)))
#define REP(i, n) for (int (i)=0; (i) < (n); (i)++)
#define CONTAINS_MAP(m, a) (m).find((a)) != m.end()
void YesNo(bool b) { cout << (b ? "Yes" : "No"); }
void Yes() { cout << "Yes"; }
void No() { cout << "No"; }

int N, M;
int H[100010];
vector<int> link[100010];

int X;

signed main()
{
	cin >> X;

	for (int a = -1000; a <= 1000; a++)
	{
		for (int b = -1000; b <= 1000; b++)
		{
			if (a * a * a * a * a - b * b * b * b * b == X)
			{
				cout << a << " " << b << endl;
				return 0;
			}
		}
	}
}




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

namespace AtCoder2 {
	class Program {
		static void Main(string[] args) {

var inputArray = retreiveStringArray();
			var inputCount = 1;

			// 不正な入力は処理しない
			if (inputArray.Length != inputCount) {
				Console.WriteLine("invalid input");
				return;
			}
			var S = inputArray[0];
			var T = retreiveStringArray()[0];

			var count = 0;
			for (int i = 0; i < S.Length; i++) {
				if (S[i]!=T[i]) {
					count++;
				}
			}

			//答えの出力
			var ans = count;
			Console.WriteLine(ans);

		}

		/// <summary>
		/// スペースで区切られた文字列配列の入力を受け取る
		/// </summary>
		/// <returns></returns>
		private static string[] retreiveStringArray() {
			var inputArray = Console.ReadLine().Split(' ');
			return inputArray;
		}

		/// <summary>
		/// スペースで区切られた整数配列の入力を受け取る
		/// </summary>
		/// <returns></returns>
		private static long[] retreiveLongArray() {
			var inputArray = Console.ReadLine().Split(' ');
			var longArray = inputArray.Select(s => long.Parse(s));
			return longArray.ToArray();
		}


		/// <summary>
		/// 2組みずつの入力データ(数値)からTuppleListを作成する
		/// </summary>
		/// <param name="N"></param>
		/// <returns></returns>
		private static List<Tuple<long, long>> createLongTuppleList(long N) {
			var inpList = new List<Tuple<long, long>>();

			for (int i = 0; i < N; i++) {
				var inp = retreiveLongArray();
				var item1 = inp[0];
				var item2 = inp[1];
				inpList.Add(new Tuple<long, long>(item1, item2));
			}
			return inpList;
		}
	}
}


Measured memory_bytes: 27324
#include<stdio.h>
int main()
{
    int N;

    scanf("%d", &N);

    if(N<=9)
        printf("Yes\n");
    else if(N>9)
    {
        if(N/2<=9 && N%2==0)
        printf("Yes\n");
    else if(N/3<=9 && N%3==0)
        printf("Yes\n");
    else if(N/4<=9 && N%4==0)
        printf("Yes\n");
    else if(N/5<=9 && N%5==0)
        printf("Yes\n");
    else if(N/6<=9 && N%6==0)
        printf("Yes\n");
    else if(N/7<=9 && N%7==0)
        printf("Yes\n");
    else if(N/8<=9 && N%8==0)
        printf("Yes\n");
    else if(N/9<=9 && N%9==0)
        printf("Yes\n");
    else
         printf("No\n");
    }

    return 0;

}


Measured memory_bytes: 1620
import sys
input = sys.stdin.readline
N = int(input())
cx, cy, ct = 0, 0, 0
for _ in range(N):
  t, x, y = map(int, input().split())
  if abs(x - cx) + abs(y - cy) <= t - ct and ((t - ct - (abs(x - cx) + abs(y - cy))) % 2 == 0):
    continue
  print("No")
  exit(0)
print("Yes")

Measured memory_bytes: 40684
#include<stdio.h>
#define INFTY 2000000000

void merge(int *,int,int,int);
void mergeSort(int *,int,int);
 
int S[100000000];
int L[1000000],R[1000000];
long long int cnv=0; 

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

  mergeSort(S,0,n);

  printf("%lld\n",cnv);
  return 0;
}

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

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

  for(i=0;i<n1;i++){
    L[i]=A[left+i];
  }

  for(i=0;i<n2;i++){
    R[i]=A[mid+i];
  }

  L[n1]=INFTY;
  R[n2]=INFTY;

  i=0;
  j=0;

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

void mergeSort(int *A,int left, int right){
  int mid;
  int v1,v2,v3;

  if(left+1<right){
    mid=(left+right)/2;
    mergeSort(A,left,mid);
    mergeSort(A,mid,right);
    merge(A,left,mid,right);
  }
}

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

int main()
{
    cin.tie(0);
    int n, m;
    cin >> n >> m;

    vector<bool> r1(n, false), rn(n, false);

    for (int i = 0; i < m; i++) {
        int a, b;
        cin >> a >> b;
        a--, b--;
        if (a > b)
            swap(a, b);

        if (a == 0) {
            r1[b] = true;
        }
        if (b == n - 1) {
            rn[a] = true;
        }
    }

    bool ok = false;
    for (int i = 1; i < n - 1; i++) {
        if (r1[i] && rn[i]) {
            ok = true;
            break;
        }
    }

    cout << (ok ? "POSSIBLE" : "IMPOSSIBLE") << endl;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
using namespace std;
#define REP(i,n) for (int i=0;i<(n);++i)
#define rep(i,a,b) for(int i=a;i<(b);++i)
template<class T> inline bool chmin(T &a, T b){ if(a > b) { a = b; return true;} return false;}
template<class T> inline bool chmax(T &a, T b){ if(a < b) { a = b; return true;} return false;}
typedef long long ll;
const ll INF = 1LL << 60;
const ll MOD = 1e9 + 7;

ll A,B,C;

int main() {
    cin.tie(0); ios_base::sync_with_stdio(false);
    cin >> A >> B >> C;
    vector<ll> check(3);
    if(A & 1 && B & 1 && C & 1){
        check[0] = A; check[1] = B; check[2] = C;
        sort(check.begin(),check.end());
        cout << check[0] * check[1] << endl;
    } else {
        cout << 0 << endl;
    }
    return 0;
}

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

using namespace std;

/*  テンプレここから */
typedef long long ll;

#define rep(i, n) for(int i = 0; i < n; ++i)
#define repi(i, start, end) for(int i = start; i < end; ++i)
#define all(x) (x).begin(), (x).end()
#define INF (1e9)
#define INFL (1e18)
#define add_mod(a, b, x) ( (ll)(a) + (ll)(b) ) % (ll)(x)
#define mul_mod(a, b, x) ( ((ll)(a) % (ll)(x)) * ((ll)(b) % (ll)(x)) ) % (ll)(x)
#define out(x) cout << (x) << endl;
#define outyes(bool_val) cout << (bool_val ? "yes" : "no") << endl;
#define outYes(bool_val) cout << (bool_val ? "Yes" : "No") << endl;
#define outYES(bool_val) cout << (bool_val ? "YES" : "NO") << endl;
#define outPossible(bool_val) cout << (bool_val ? "Possible" : "Impossible") << endl;
#define outPOSSIBLE(bool_val) cout << (bool_val ? "POSSIBLE" : "IMPOSSIBLE") << endl;

template<typename A, size_t N, typename T>
void array_fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

ll sub_mod(ll a, ll b, ll x){
    ll tmp = (a - b) % x;
    if(tmp < 0) tmp += x;
    return tmp;
}
ll gcd(ll a, ll b){
    if(b == 0) return a;
    else return gcd(b, a % b);
}

int dx[] = {0, 1, 0, -1};
int dy[] = {-1, 0, 1, 0};
/*  テンプレここまで */

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

    int n, q;
    cin >> n >> q;

    string s;
    cin >> s;

    vector<int> cnt(n + 10, 0);
    rep(i, n){
        cnt[i + 1] += cnt[i] + (s[i] == 'A' && s[i + 1] == 'C');
    }

    rep(i, q){
        int l, r;
        cin >> l >> r;
        cout << cnt[r - 1] - cnt[l - 1] << endl;
    }
}

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

int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
#ifdef _DEBUG
	freopen("input.txt", "r", stdin);
#endif
	long double n;
	cin>>n;
	long double ans = 3.14159265 * 2.0 * n;
	cout<<ans<<"\n";
	return 0;
}

Measured memory_bytes: 3812
#include<algorithm>
#include<iostream>
#include<cstring>
#include<cstdlib>
#include<cstdio>
#include<vector>
#include<cmath>
#include<ctime>
#include<queue>
#include<map>
#include<set>
#define LL __int128
#define db double

using namespace std;
const int N=2e5+10;
int rd()
{
    int x=0,w=1;char ch=0;
    while(ch<'0'||ch>'9'){if(ch=='-') w=-1;ch=getchar();}
    while(ch>='0'&&ch<='9'){x=x*10+(ch^48);ch=getchar();}
    return x*w;
}
int m0[N<<2],m1[N<<2];
#define mid ((l+r)>>1)
void psup(int o){m0[o]=max(m0[o<<1],m0[o<<1|1]),m1[o]=max(m1[o<<1],m1[o<<1|1]);}
void modif(int o,int l,int r,int x,int y,bool oo)
{
	if(l==r){!oo?m0[o]=y:m1[o]=y;return;}
	if(x<=mid) modif(o<<1,l,mid,x,y,oo);
	else modif(o<<1|1,mid+1,r,x,y,oo);
	psup(o);
}
int quer(int o,int l,int r,int ll,int rr,bool oo)
{
	if(ll<=l&&r<=rr) return !oo?m0[o]:m1[o];
	int an=-(1<<20);
	if(ll<=mid) an=max(an,quer(o<<1,l,mid,ll,rr,oo));
	if(rr>mid) an=max(an,quer(o<<1|1,mid+1,r,ll,rr,oo));
	return an;
}
int n,a[N],f[N][2],sm;
bool b[N],an[N];

int main()
{
	memset(m1,-0x3f3f3f,sizeof(m1));
	n=rd();
	for(int i=1,ma=0;i<=n;++i)
	{
		a[i]=rd();
		if(ma<a[i]) ma=a[i],b[i]=1,++sm;
	}
	for(int i=n;i;--i)
	{
		f[i][1]=-(1<<20);
		int xx=b[i]+1+max(0,quer(1,1,n,a[i],n,0)),yy=b[i]+1+max(0,quer(1,1,n,a[i],n,1));
		f[i][xx&1]=max(f[i][xx&1],xx);
		f[i][yy&1]=max(f[i][yy&1],yy);
		modif(1,1,n,a[i],f[i][0],0);
		modif(1,1,n,a[i],f[i][1],1);
	}
	int c0=0,c1=0,mi0=0,mi1=0;
	for(int i=1,j=sm;i<=n;++i)
	{
		j-=b[i];
		modif(1,1,n,a[i],0,0);
		modif(1,1,n,a[i],-(1<<20),1);
		int x=c0+(a[i]>=mi0)-c1+j;
		bool o=0;
		if(quer(1,1,n,max(mi1,1),n,x&1)<x)
		{
			x=c1-(c0+(a[i]>=mi0))+j;
			o=x<0||quer(1,1,n,max(mi0,a[i]),n,x&1)<x;
		}
		if(o) an[i]=1,c1+=a[i]>=mi1,mi1=max(mi1,a[i]);
		else c0+=a[i]>=mi0,mi0=max(mi0,a[i]);
	}
	c0=c1=0;
	for(int i=1,mm0=0,mm1=0;i<=n;++i)
	{
		if(!an[i])
		{
			if(mm0<a[i]) mm0=a[i],++c0;
		}
		else
		{
			if(mm1<a[i]) mm1=a[i],++c1;
		}
	}
	if(c0!=c1) puts("-1");
	else for(int i=1;i<=n;++i) printf("%d",an[i]);
    return 0;
}


Measured memory_bytes: 8576
/*Remember: The Struggle is Important*/

//CF,CC,AtC,SPOJ: hp1999
//HE: hemant269
//HR: hemant2132

#include<bits/stdc++.h>
using namespace std;

#define     int          long long int
#define     ld           long double
#define     fast()       ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define     all(x)       x.begin(),x.end()
#define     mem(a,b)     memset(a,b,sizeof(a))
#define     gcd(a,b)     (__gcd((a),(b)))
#define     lcm(a,b)     (((a)*(b))/gcd((a),(b)))
#define     pb           push_back
#define     ins          insert
#define     pii          pair<int,int>
#define     F            first
#define     S            second
#define     show(x)      for(auto c:x)cout<<c<<" ";cout<<"\n";
#define     show2(x)     for(auto c:x)cout<<c.F<<" "<<c.S<<"\n";

const int inf=1e18,M=1e9+7;
const int N=1;

void solve()
{
    int a[3];
    cin>>a[0]>>a[1]>>a[2];

    sort(a,a+3);

    if((a[0]==a[1] && a[0]!=a[2]) || (a[2]==a[1] && a[0]!=a[2]))
        cout<<"Yes";
    else
        cout<<"No";
}

int32_t main()
{
    fast();

    int t=1;
    //cin>>t;
    while(t--)
    {
        solve();
        //cout<<"\n";
    }

    return 0;
}




Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, s, e) for(int i = s; i < e; i++)
#define rrep(i, s, e) for(int i = s; i > (s)-(e); i--)
#define pr(s) std::cout << s << std::endl
#define prb(s) std::cout << s
using namespace std;



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


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

  if (a == b) pr(c);
  if (b == c) pr(a);
  if (c == a) pr(b);


  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

void bubblesort(int[],int);

int main(){
  int a[100],i,n;

    scanf("%d",&n);

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

    bubblesort(a,n);

    return 0;
}

void bubblesort(int a[],int n){
  int key=0,flag=1;
  int i,j,status;
    
    for(i=0;flag;i++){
      flag=0;
      for(j=n-1;j>=i+1;j--){
	if(a[j]<a[j-1]){
	  status=a[j];
	  a[j]=a[j-1];
	  a[j-1]=status;
	  flag=1;
	  key++;
	}
      }
    }

    for(i=0;i<n;i++){
      if(i>0) printf(" ");
      printf("%d",a[i]);
    }
    printf("\n%d\n",key);
}



Measured memory_bytes: 2080
/* package whatever; // don't place package name! */

import java.util.*;
import java.lang.*;
import java.io.*;

import java.util.ArrayList;
import java.util.List;

/* Name of the class has to be "Main" only if the class is public. */
class Main
{
	public static void main (String[] args) throws java.lang.Exception
	{
		//文字列読込み
		Scanner sc = new Scanner(System.in);
		//取得
		String scline  = sc.nextLine();	//1行取得
		int len = scline.length();

		String scChar;
		String result = "";

		for (int i = 0; i < len; i++) {
			scChar = String.valueOf(scline.charAt(i));
			if(Character.isUpperCase(scline.charAt(i))) {
				//大文字
				result = result + scChar.toLowerCase();
			} else {
				//小文字
				result = result + scChar.toUpperCase();
			}
		}
		System.out.println(result);
	}
}


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

using namespace std;
int main() {
	string s;
	cin >> s;
	if (s[2]==s[3]&&s[4]==s[5]) cout << "Yes" << endl;
	else cout << "No" << endl;

}


Measured memory_bytes: 256
import sys

read = sys.stdin.buffer.read
input = sys.stdin.buffer.readline
inputs = sys.stdin.buffer.readlines


# mod=10**9+7
# rstrip().decode('utf-8')
# map(int,input().split())
# import numpy as np

def main():
	h, w = map(int, input().split())
	
	G = [[0] * w for i in range(h)]
	A = [0]*h
	B = [0]*h
	
	for i in range(h):
		A[i] = list(map(int, input().split()))
	for i in range(h):
		B[i] = list(map(int, input().split()))
	
	for i in range(h):
		for j in range(w):
			G[i][j]=abs(A[i][j]-B[i][j])

	M = (h + w) * 80

	li = [[[0] * M for i in range(w)] for j in range(h)]
	
	li[0][0][G[0][0]] = 1
	for i in range(h):
		for j in range(w):
			for k in range(M):
				
				if li[i][j][k] == 1:
					if i < h - 1:
						li[i + 1][j][abs(k - G[i+1][j])] = 1
						li[i + 1][j][abs(k + G[i+1][j])] = 1
					if j < w - 1:
						li[i][j + 1][abs(k - G[i][j+1])] = 1
						li[i][j + 1][abs(k + G[i][j+1])] = 1

	for i in range(M):
		if li[h-1][w - 1][i] == 1:
			print(i)
			exit(0)


if __name__ == "__main__":
	main()


Measured memory_bytes: 676488
N, M, X = map(int, input().split())
C = [None for _ in range(N)]
A = [[] for _ in range(N)]
for i in range(N):
    C[i], *A[i] = list(map(int, input().split()))

ans = float('inf')
for i in range(1 << N):
    smart = [0 for _ in range(M)]
    cost = 0
    for j in range(N):
        if (i >> j) & 1:
            cost += C[j]
            for k in range(M):
                smart[k] += A[j][k]
    ok = True
    for j in range(M):
        if smart[j] < X:
            ok = False
    if ok:
        ans = min(ans, cost)

if ans != float('inf'):
    print(ans)
else:
    print(-1)


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

int main(void){
	int n;
	unsigned long long L[86];
	cin >> n;
	L[0] = 2;
	L[1] = 1;
	for (int i = 2; i <= n; ++i){
		L[i] = L[i-1] + L[i-2];
	}
	cout << L[n] << endl;
	return 0;
}

Measured memory_bytes: 256
import sys
from itertools import accumulate

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60
MOD = 1000000007


def main():
    N, *A = map(int, read().split())

    csum = [0]
    csum.extend(accumulate(reversed(A)))

    ans = 0
    for i, a in enumerate(A):
        ans = (ans + a * csum[N - i - 1] % MOD) % MOD

    print(ans)
    return


if __name__ == '__main__':
    main()


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

int main() {
  int N;
  cin >> N;
  vector<int> vec(N);
  for (int i=0;i<N;i++){
    cin >> vec.at(i);
  }
  int sum=1;
  for (int i=1;i<N;i++){
    for (int j=i-1;j>=0;j--){
      if(vec.at(i)==vec.at(j)){
        break;
      }
      if (j==0){
        sum++;
      }
    }
  }
  cout << sum << endl;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
 
public class Main {
 
    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String line = "";
        while (!(line = br.readLine().trim()).equals("0") && !line.isEmpty()) {
 
            int goal = Integer.parseInt(line);
            int times = Integer.parseInt(br.readLine().trim());
            int sum = 0;
            for (int i = 0; i < times; i++) {
                line = br.readLine().trim();
                int s = Integer.parseInt(line.substring(0, line.indexOf(' ')));
                int f = Integer.parseInt(line.substring(line.indexOf(' ') + 1));
                sum += f - s;
            }
            System.out.println(sum >= goal ? "OK" : goal - sum);
        }
    }
}



Measured memory_bytes: 24616
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#include <limits.h>

int main(void) {
	int n, y;
	int flag = 0;
	int cnt_nogu = 0, cnt_higu = 0, cnt_fuku = 0;

	scanf("%d %d", &n, &y);

	for (int i = 0; i <= n; i++) {
		for (int j = 0; j <= n - i; j++) {
			if (10000 * i + 5000 * j + 1000*(n - i - j) == y) {
				printf("%d %d %d", i, j, n - i - j);
				flag = 1;
				break;
			}
			if (flag)break;
		}
		if (flag) break;
		else if(i==n) printf("-1 -1 -1");
	}
	return 0;
}


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

map <ll,int> mp;
ll num[200010];
ll ans;
int n;

int main()
{
    ll sum;
    int i;
    scanf("%d",&n);
    for(i=1;i<=n;i++)
    {
        scanf("%lld",&num[i]);
    }
    mp.clear();
    sum=0,ans=0;
    for(i=1;i<=n;i++)
    {
        sum+=num[i];
        ans+=mp[sum];
        if(sum==0) ans++;
        mp[sum]++;
        //printf("*%lld %d*\n",sum,mp[sum]);
    }
    printf("%lld\n",ans);
    return 0;
}


Measured memory_bytes: 14336
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConsoleApplication1
{
    class Program
    {
        static readonly double EPS = 1E-10;

        static void Main(string[] args)
        {
            double[] input;

            input = Array.ConvertAll(Console.ReadLine().Split(' '), double.Parse);
            Point3D p = new Point3D(input[0], input[1], input[2]);

            input = Array.ConvertAll(Console.ReadLine().Split(' '), double.Parse);
            Point3D e = new Point3D(input[0], input[1], input[2]);

            Point3D[] b = new Point3D[3];

            for (int i = 0; i < 3; i++)
            {
                input = Array.ConvertAll(Console.ReadLine().Split(' '), double.Parse);
                b[i] = new Point3D(input[0], input[1], input[2]);
            }

            Point3D vb = (b[1] - b[0]).Cross(b[2] - b[0]);
            Point3D pb = p - b[0];
            Point3D eb = e - b[0];

            if (vb.Dot(pb) * vb.Dot(eb) > 0)
            {
                Console.WriteLine("HIT");
            }
            else
            {
                Point3D vr = p + (e - p) * Math.Abs(vb.Dot(pb)) / (Math.Abs(vb.Dot(pb)) + Math.Abs(vb.Dot(eb)));

                if ((b[1] - b[0]).Cross(vr - b[1]).Dot((b[2] - b[1]).Cross(vr - b[2])) > -EPS &&
                    (b[1] - b[0]).Cross(vr - b[1]).Dot((b[0] - b[2]).Cross(vr - b[0])) > -EPS)
                {
                    Console.WriteLine("MISS");
                }
                else
                {
                    Console.WriteLine("HIT");
                }
            }
        }
    }

    struct Point3D
    {
        internal double x, y, z;

        public Point3D(double x, double y, double z)
        {
            this.x = x;
            this.y = y;
            this.z = z;
        }

        public Point3D Cross(Point3D other)
        {
            Point3D ret;
            ret.x = y * other.z - z * other.y;
            ret.y = z * other.x - x * other.z;
            ret.z = x * other.y - y * other.x;
            return ret;
        }

        public double Dot(Point3D other)
        {
            return x * other.x + y * other.y + z * other.z;
        }

        public static Point3D operator +(Point3D a, Point3D b)
        {
            return new Point3D(a.x + b.x, a.y + b.y, a.z + b.z);
        }

        public static Point3D operator -(Point3D a, Point3D b)
        {
            return new Point3D(a.x - b.x, a.y - b.y, a.z - b.z);
        }

        public static Point3D operator *(Point3D p, double m)
        {
            return new Point3D(p.x * m, p.y * m, p.z * m);
        }

        public static Point3D operator /(Point3D p, double m)
        {
            return new Point3D(p.x / m, p.y / m, p.z / m);
        }
    }
}

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

using namespace std;

#define DUMP(x) std::cerr << (#x) << " = " << (x) << "\n"
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define REP(i, k, n) for (int i = (k); i < (int)(n); ++i)
#define ALL(r) r.begin(), r.end()
#define YES puts("YES")
#define Yes puts("Yes")
#define NO puts("NO")
#define No puts("No")
#define IMP puts("IMPOSSIBLE")
#define Imp puts("Impossible")
#define imp puts("impossible")
#define M1 puts("-1")
#define pb push_back

template <typename T>
T dup(T x, T y)
{
    return (x + y - 1) / y;
};
template <typename A, size_t N, typename T>
inline void arrayFill(A (&array)[N], const T &val) { std::fill((T *)array, (T *)(array + N), val); }

using ll = int64_t;
using vint = vector<int32_t>;
using vvint = vector<vint>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vstr = vector<string>;
using pint = pair<int32_t, int32_t>;
using pll = pair<ll, ll>;
using setint = set<int32_t>;
using setstr = set<string>;
using qint = queue<int32_t>;
using qpint = queue<pint>;

constexpr std::int32_t INF = 1001001001;
constexpr std::int64_t LINF = 1001001001001001001;

void Main()
{
    int n;
    cin >> n;
    vint x(n), y(n);
    rep(i, n) cin >> x[i] >> y[i];

    double sum = 0;
    rep(i, n) REP(j, i + 1, n)
    {
        double a = x[i] - x[j];
        double b = y[i] - y[j];
        sum += sqrt(a * a + b * b);
    }

    cout << sum * 2 / n << endl;
}

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


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define For(i,n,k) for(ll i=(n);i<(k);i++)
#define ALL(a)  (a).begin(),(a).end()
ll ans=0;
void Main(){
    int card[3][3];
    For(i,0,3){
        For(j,0,3){
            cin>>card[i][j];
        }
    }
    ll n;cin>>n;
    vector<int> num(n);
    For(i,0,n){
        cin>>num[i];
    }
    For(t,0,n){
        For(i,0,3){
            For(j,0,3){
                if(num[t]==card[i][j]) card[i][j]=-1;
            }
        }
    }
    bool flag=false;
    For(i,0,3){
        bool r=true;
        For(j,0,3){
            if(card[i][j]>-1) r=false;
        }
        flag|=r;
    }
    For(j,0,3){
        bool r=true;
        For(i,0,3){
            if(card[i][j]>-1) r=false;
        }
        flag|=r;
    }
    bool r=true;
    For(i,0,3){
        if(card[i][i]>-1) r=false;
    }
    flag|=r;
    r=true;
    For(i,0,3){
        if(card[2-i][i]>-1) r=false;
    }
    flag|=r;
    cout<<(flag?"Yes":"No")<<endl;
}
int main(){
    Main();
    return 0;
}

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

int main(){
    int n;
    cin>>n;
    map<int,int> mp;
    rep(i,n){
        int a;
        cin>>a;
        mp[a]++;
    }
    int ans=0;
    for(auto p:mp){
        if(p.first<=p.second){
            ans+=p.second-p.first;
        }
        else{
            ans+=p.second;
        }
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 8112
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std ;

short N , M ;
char mp[55][55] ;

bool vis[55][55] ;
short dfs( short r , short c ){
	int rt = 1 ; vis[r][c] = true ;
	if( mp[r+1][c] == '#' && !vis[r+1][c] ) rt += dfs( r + 1 , c ) ;
	if( mp[r-1][c] == '#' && !vis[r-1][c] ) rt += dfs( r - 1 , c ) ;
	if( mp[r][c+1] == '#' && !vis[r][c+1] ) rt += dfs( r , c + 1 ) ;
	if( mp[r][c-1] == '#' && !vis[r][c-1] ) rt += dfs( r , c - 1 ) ;
	return rt ;
}

void solve(){
	for( short i = 1 ; i <= N ; i ++ )
		for( short j = 1 ; j <= M ; j ++ )
			if( mp[i][j] == '#' && !vis[i][j] )
				if( dfs( i , j ) == 1 ) puts( "No" ) , exit( 0 ) ;
	puts( "Yes" ) ;
}

int main(){
	scanf( "%hd%hd" , &N , &M ) ;
	for( short i = 1 ; i <= N ; i ++ )
		scanf( "%s" , mp[i] + 1 ) ;
	solve() ;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int max_n=55;
struct edge
{
    int u,v,next;int w;
}G[max_n*2];
int head[max_n];
int tot;
void add_edge(int u,int v,ll w=1)
{
    G[tot].u=u;
    G[tot].v=v;
    G[tot].w=w;
    G[tot].next=head[u];
    head[u]=tot++;
}
void init()
{
    memset(head,-1,sizeof(head));
    tot=0;
}
int par[max_n];
void dfs(int u,int fa){
    for(int i=head[u];~i;i=G[i].next){
        if(G[i].v==fa)continue;
        par[G[i].v]=i;
        dfs(G[i].v,u);
    }
}
int n,m;
vector<int> lim[max_n];
bool color[max_n];
int main(){
    scanf("%d",&n);
    init();
    for(int i=1;i<n;i++){
        int u,v;
        scanf("%d%d",&u,&v);
        add_edge(u,v);
        add_edge(v,u);
    }
    scanf("%d",&m);
    for(int i=0;i<m;i++){
        int u,v;scanf("%d%d",&u,&v);
        dfs(u,0);
        int now=v;
        while(now!=u){
            lim[i].push_back(par[now]/2);
            now=G[par[now]].u;
        }
        /*
        cout<<i<<endl;
        for(auto x:lim[i])cout<<G[x].u<<' '<<G[x].v<<endl;
        */
    }
    ll ans=0;
    for(int s=0;s<(1<<m);s++){
        for(int i=0;i<n-1;i++)color[i]=false;
        int c=0;
        for(int i=0;i<m;i++){
            if(s>>i&1){
                c++;
                for(auto x:lim[i]){
                    color[x]=true;
                }
            }
        }
        ll t=1;
        for(int i=0;i<n-1;i++){
            if(color[i]==false)t*=2;
        }
        if(c&1)ans-=t;
        else ans+=t;
    }
    printf("%lld\n",ans);
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
#define rep(i,s,e) for(int (i) = (s);(i) <= (e);(i)++)
#define all(x) x.begin(),x.end()

const i64 MOD = 998244353;

const int MAX = 202020;

long long fac[MAX], finv[MAX], inv[MAX];

void init() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}


i64 comp(i64 n, i64 k) {
  if (n < k) return 0;
  if (n < 0 || k < 0) return 0;
  return fac[n] * finv[k] % MOD * finv[n - k] % MOD;
}

int main() {
  init();
  i64 K, N;
  cin >> K >> N;

  for(int i = 2; i <= 2 * K;i++) {
    i64 p = i;
    if(i > K + 1) p = (K + 1) * 2 - p;
    p /= 2;

    i64 ans = 0;

    for(int j = 0;j <= p;j++) {
      auto res = comp(p, j) * comp(K + N - 2 * j - 1, N - 2 * j) % MOD;
      if(j & 1) ans = (ans - res % MOD + MOD) % MOD;
      else ans = (ans + res) % MOD;
    }
    cout << ans << endl;
  }
}


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

#define ll long long

using namespace std;

vector< pair<int, int> > A;

ll relaxed(int i, ll cap) {
    ll result = 0;
    while(i < A.size()) {
        if(A[i].first <= cap) {
            cap -= A[i].first;
            result += A[i].second;
            i++;
        } else {
            result += (A[i].second * cap + A[i].first - 1) / A[i].first;
            //result += A[i].second;
            break;
        }
    }
    return result;
}

ll backtrack(int i, ll cap) {
    if(i >= A.size()) return 0;
    if(A[i].first > cap) return backtrack(i + 1, cap);
    ll a = A[i].second + backtrack(i + 1, cap - A[i].first);
    ll b = relaxed(i + 1, cap);
    if(a >= b)
        return a;
    return max(a, backtrack(i + 1, cap));
}

int main() {
    std::ios::sync_with_stdio(false);
    ll n, w, a, b;
    cin >> n >> w;
    A.resize(n);
    for(int i = 0; i < n; i++)
        cin >> A[i].first >> A[i].second;
    sort(A.begin(), A.end(), [](const pair<ll, ll> & x,
                                const pair<ll, ll> & y) {
                if(x.second * y.first == y.second * x.first)
                    return x.first < y.first;
                return x.second * y.first > y.second * x.first;
            });
    cout << backtrack(0, w) << "\n";

    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
int main()
{   long long n,m,ans1=1,ans2=1,cnt=0;
    scanf("%lld%lld",&n,&m);
    if(llabs(n-m)>1){
        printf("0");
        return 0;
    }else{
    while (cnt<n){
        cnt++;
        ans1*=cnt;
        ans1%=1000000007;
    }
    cnt=0;
    while (cnt<m){
        cnt++;
        ans2*=cnt;
        ans2%=1000000007;
    }
    if(n==m)ans1*=2;
    printf("%lld",(ans1*ans2)%1000000007);
    }
    
    return 0;
}


Measured memory_bytes: 256
N=int(input())
A=list(map(int,input().split()))
mod=10**9+7
ans=pow(2,N//2,mod)
judge=[0]*N
if N%2==0:
  for a in A:
    if (a>=N)or(a%2==0)or(judge[a]>=2):
      ans=0
      break
    judge[a]+=1
    
else:
  if A.count(0)!=1:
    ans=0
    
  else:
    for a in A:
      if (a>=N)or(a%2==1)or(judge[a]>=2):
        ans=0
        break
      judge[a]+=1
      
print(ans)

Measured memory_bytes: 14008
m,d=map(int,input().split())
ans=0
for i in range(d+1):
    a=i//10
    b=i-a*10
    if a*b!=0  and a!=1 and b!=1:
        for j in range(m+1):
            if a*b==j:
                ans+=1
print(ans)

Measured memory_bytes: 3060
#include<iostream>
#include<cstdlib>
#include<vector>
using namespace std;
int main(){
    int n,m;
    int kasuga;
    cin>>n>>m;
    long long min;
    long long minyukkar;
    vector<long long> maiyanx(n);
    vector<long long> maiyany(n);
    vector<long long> yukkarx(m);
    vector<long long> yukkary(m);
    for(int i=0;i<n;i++){
        cin>>maiyanx[i]>>maiyany[i];
    }
    for(int i=0;i<m;i++){
        cin>>yukkarx[i]>>yukkary[i];
    }
    for(int i=0;i<n;i++){
        for(int k=0;k<m;k++){
            kasuga=abs(maiyanx[i]-yukkarx[k])+abs(maiyany[i]-yukkary[k]);
            if(k==0){
                min=kasuga;
                minyukkar=k+1;
            }else if(kasuga<min){
                min=kasuga;
                minyukkar=k+1;
            }
        }
        cout<<minyukkar<<endl;
    }
}

Measured memory_bytes: 3640
#define ENABLE_DEBUG 1
// Kana's kitchen {{{
#include<bits/stdc++.h>
#define ALL(v) std::begin(v),std::end(v)
#define LOOP(k) for(i64 ngtkana_is_a_genius=0; ngtkana_is_a_genius<(i64)k; ngtkana_is_a_genius++)

using i32 = std::int_least32_t;
using i64 = std::int_least64_t;
using u32 = std::uint_least32_t;
using u64 = std::uint_least64_t;
using usize = std::size_t;

template <class T, class U> using pair = std::pair<U, T>;
template <class T> using diag_pair = std::pair<T, T>;
template <class... Args> using tuple = std::tuple<Args...>;
template <class T> using vec = std::vector<T>;
template <class T> using numr = std::numeric_limits<T>;

#ifdef NGTKANA
#include<debug.hpp>
#else
#define DEBUG(...)(void)0
#endif
/*}}}*/

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

    usize n;
    std::cin >> n;
    i64 ans = 0;
    while (n--) {
        i64 x;
        std::cin >> x;
        ans = ans == 0 ? x : ans / std::__gcd(ans, x) * x;
    }
    std::cout << ans << '\n';
}


Measured memory_bytes: 256
N, M = map(int, input().split())
G = [[] for i in range(N)]
for i in range(M):
    a, b, c = map(int, input().split())
    G[a - 1].append((b - 1, -c))

INF = float("inf")
d = [INF] * N
d[0] = 0
for i in range(N):
    for a in range(N):
        for b, c in G[a]:
            if d[b] > d[a] + c:
                d[b] = d[a] + c

ne = [False] * N
ans = -d[N - 1]
for i in range(N):
    for a in range(N):
        for b, c in G[a]:
            if d[b] > d[a] + c:
                ne[b] = True
                d[b] = d[a] + c

            if ne[a]:
                ne[b] = True

if ne[N - 1]:
    print("inf")
else:
    print(ans)


Measured memory_bytes: 3316
#include <bits/stdc++.h>
#define ll long long
#define fr first
#define ii pair<int,int>
#define sc second
#define mp make_pair
#define All(v) v.begin(),v.end()
using namespace std;
int main()
{
 ll x,y;
 cin>>x>>y;
 ll minx = x*y;
 for(int i=1;i<x;i++)
 {
     ll temp = i*y;
     ll xx , yy;
     xx = x-i;
     yy = y;
     ll mx = -1 , mi = 1e18 , temp2;
     if(yy%2 == 0)
     {
         temp2 = yy/2;
         temp2 *=xx;
         minx = min(minx , abs(temp-temp2));
     }
     else
     {
         temp2 = yy/2;
         temp2 *=xx;
         temp2 = max(abs(temp2-temp),abs(temp2+xx-temp));
         minx = min(minx , temp2);
     }
     swap(xx,yy);
    if(yy%2 == 0)
     {
         temp2 = yy/2;
         temp2 *=xx;
         minx = min(minx , abs(temp-temp2));
     }
     else
     {
         temp2 = yy/2;
         temp2 *=xx;
         temp2 = max(abs(temp2-temp),abs(temp2+xx-temp));
         minx = min(minx , temp2);
     }
 }
 swap(x,y);
 for(int i=1;i<x;i++)
 {
     ll temp = i*y;
     ll xx , yy;
     xx = x-i;
     yy = y;
     ll mx = -1 , mi = 1e18 , temp2;
     if(yy%2 == 0)
     {
         temp2 = yy/2;
         temp2 *=xx;
         minx = min(minx , abs(temp-temp2));
     }
     else
     {
         temp2 = yy/2;
         temp2 *=xx;
         temp2 = max(abs(temp2-temp),abs(temp2+xx-temp));
         minx = min(minx , temp2);
     }
     swap(xx,yy);
     if(yy%2 == 0)
     {
         temp2 = yy/2;
         temp2 *=xx;
         minx = min(minx , abs(temp-temp2));
     }
     else
     {
         temp2 = yy/2;
         temp2 *=xx;
         temp2 = max(abs(temp2-temp),abs(temp2+xx-temp));
         minx = min(minx , temp2);
     }

 }
 cout<<minx;
}


Measured memory_bytes: 256
#include<stdio.h>
  
int main(void){
    /* 変数の宣言 */
  int A, B, tmp;
  //scanf("%d", &A);
  //scanf("%d", &B);
  scanf("%d%d" , &A , &B);

  tmp=0;
  for(int i=0;i<2;i++){
    if(A>B){
          tmp+=A;
          A=A-1;
    }else{
          tmp+=B;
          B=B-1;
    }
  }   
  printf("%d",tmp);
  return 0;
}

Measured memory_bytes: 128
#include <algorithm>
#include <climits>
#include <iostream>
#include <map>
#include <string>
#include <vector>

using namespace std;
using ll = long long int;

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

  vector<ll> size(N);
  for (ll i = 0; i < N; i++) {
    cin >> size[i];
  }

  sort(size.begin(), size.end());

  ll sum = 0;
  ll t = 0;

  for (ll i = 0; i < N - 1; i++) {
    sum += size[i];
    if (sum * 2 < size[i + 1]) {
      t = i + 1;
    }
  }
  cout << (N - t) << endl;
}

Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <string.h>
using namespace std;

const int INF = 1000100;
int h, w, n = 0;
int a[1002][1002], b[1002][1002];
bool f[1002][1002];
vector<pair <int, int> > p;

void climb(int i, int j) {
	f[i][j] = 1;
	b[i][j]++;

	if (i < h && a[i + 1][j] > a[i][j] && !f[i + 1][j])
		climb(i + 1, j);
	if (i > 1 && a[i - 1][j] > a[i][j] && !f[i - 1][j])
		climb(i - 1, j);
	if (j < w && a[i][j + 1] > a[i][j] && !f[i][j + 1])
		climb(i, j + 1);
	if (j > 1 && a[i][j - 1] > a[i][j] && !f[i][j - 1])
		climb(i, j - 1);
}

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

	for (int i = 0; i < 1002; i++)
		for (int j = 0; j < 1002; j++)
			a[i][j] = INF;

	for (int i = 1; i <= h; i++)
		for (int j = 1; j <= w; j++)
			cin >> a[i][j];

	for (int i = 1; i <= h; i++)
		for (int j = 1; j <= w; j++) {
			if (a[i + 1][j] > a[i][j] && a[i - 1][j] > a[i][j] &&
				a[i][j + 1] > a[i][j] && a[i][j - 1] > a[i][j])
				p.push_back({ i, j });
		}

	memset(b, 0, 1004004);

	for (int i = 0; i < (int)p.size(); i++) {
		memset(f, 0, 1004004);
		climb(p[i].first, p[i].second);
	}
		
	for (int i = 1; i <= h; i++)
		for (int j = 1; j <= w; j++)
			if (b[i][j] > 1)
				n++;

	cout << n << endl;

	return 0;
}


Measured memory_bytes: 50792
#include "bits/stdc++.h"
#include <set>

using namespace std;
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define RFOR(i, a, b) for (int i = (b)-1; i >= (a); i--)
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep1(i, n) for (int i = 1; i < (n); i++)
#define rrep(i, n) for (int i = (n)-1; i >= 0; i--)
#define all(i) (i).begin(), (i).end()
#define rall(i) (i).begin(), (i).end(), greater<int>()
#define int long long
#define elif else if
#define eb emplace_back
#define pb push_back
#define mp make_pair
#define fst first
#define sec second
#define mod 1000000007
#define INF 10e10
template <typename T>

void print(T x)
{
	std::cout << x << " ";
}

template <typename T>

void println(T x)
{
	std::cout << x << "\n";
}


signed main(void) {
	int n,k;
	cin >> n>>k;
	vector<pair<int,int>>ab(n);
	rep(i,n){
		int a,b;
		cin >> a>>b;
		ab[i]=make_pair(a,b);
	}
	sort(ab.begin(),ab.end());
	int index=0;
	int ret;
	rep(i,n){
		index+=ab[i].second;
		if(index>=k){
			ret = ab[i].first;
			print(ret);
			return 0;
		}
	}
}

Measured memory_bytes: 4780
import math
a,b,c=map(float,input().split())
print((a*b)*math.sin(math.radians(c))/2)
print(a+b+math.sqrt(pow(a,2)+pow(b,2)-2*a*b*math.cos(math.radians(c))))
print((a*b)*math.sin(math.radians(c))/a)

Measured memory_bytes: 6880
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintStream;
import java.util.Stack;

class Main {

    public static void main(String[] args) throws IOException {
        doit(args, System.in, System.out);
    }

    static void doit(String[] args, InputStream in, PrintStream out)
            throws IOException {
        BufferedReader reader = new BufferedReader(new InputStreamReader(in));
        while (true) {
            String[] values = reader.readLine().split(" ");
            int n = Integer.parseInt(values[0]);
            int s = Integer.parseInt(values[1]);
            if (n == 0 && s == 0) {
                break;
            }
            int count = countSum(s, n, new Stack<Integer>(), 0);
            out.println(count);
        }
    }

    static int countSum(int s, int n, Stack<Integer> numbers, int numbersSum) {
        if (n == 0) {
            return numbersSum == s ? 1 : 0;
        }

        int count = 0;
        for (int i = numbers.isEmpty() ? 0 : numbers.peek() + 1; i < 10; i++) {
            int nsi = numbersSum + i;
            if (nsi > s) {
                break;
            }
            numbers.push(i);
            count += countSum(s, n - 1, numbers, nsi);
            numbers.pop();
        }
        return count;
    }
}

Measured memory_bytes: 9724
#include <iostream>

using namespace std;

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

    bool yes_flag = false;
    int count = 0;
    for(int i = 0; i < N; i++){
        int dice1, dice2;
        cin >> dice1 >> dice2;
        if(dice1 == dice2){
            count++;
            if(count == 3){
                yes_flag = true;
            }
        }else{
            count = 0;
        }
    }

    cout << ((yes_flag) ? "Yes" : "No") << endl;

}


Measured memory_bytes: 3628
import java.util.*;

public class Main{
    public static void main(String[] args){
    //入力
        Scanner sc = new Scanner(System.in);
        int N =sc.nextInt();
        int a[] = new int[N+1];
        for(int i=1;i<=N;i++){
            a[sc.nextInt()]=i;
        }
        for(int i=1;i<=N;i++){
            System.out.print(a[i]+" ");
        }
    }
}


Measured memory_bytes: 68396
#include <iostream>
#include<algorithm>
using namespace std;
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);                                            
    int R[200000],n;

    cin>>n;
    for(int i=0;i<n;i++)
        cin>>R[i];
    int maxv = -2000000000;
    int minv = R[0];

    for(int i=1;i<n;i++){                                          
        maxv=max(maxv,R[i]-minv);
        minv=min(minv,R[i]);
    }       
    cout << maxv <<"\n";
    return 0;
}


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

int main() {
    string s;
    cin >> s;
    string ans = "No";
    if ((s == "hi") || (s == "hihi") || (s == "hihihi") || (s == "hihihihi") || (s == "hihihihihi")) ans = "Yes";
    cout << ans << endl;
}

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

int main() {
  char c;
  int flag = 0;
  string vo = "aeiou";
  cin >> c;
  
  for(int i=0; i<vo.size(); i++){
    if(vo.at(i)==c){
      flag = 1;
    }
  }
  if(flag==1){
  	cout << "vowel" << endl;
  }else{
  	cout << "consonant" << endl;
  }
    
}



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

int main() {
  int MOD = 1000000007;
  int N; cin >> N;
  string S; cin >> S;
  vector<long long> cnt(26, 0);
  for (int i = 0; i < N; i++) cnt.at(S.at(i) - 'a')++;
  long long ans = 1;
  for (long long c : cnt) {
    if (c == 0) continue;
    ans = (ans * (c + 1)) % MOD;
  }
  cout << ans - 1 << endl;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
const int N=100005;
pair<int,int>p[N];
int n,m,a[N],vis[N];
vector<pair<int,int>>e[N];
vector<int>ans;
inline int dfs(int x)
{
	vis[x]=1;
	int rt=a[x];
	for(auto v:e[x])
	{
		int y=v.first;
		if(vis[y])
			continue;
		int t=dfs(y);
		if(t)
			ans.push_back(v.second);
		rt^=t;
	}
	return rt;
}
int main()
{
	ios_base::sync_with_stdio(false);
	cin>>n>>m;
	for(int i=0;i<n;i++)
		cin>>p[i].first>>p[i].second;
	sort(p,p+n);
	a[0]=p[0].second;
	for(int i=1;i<n;++i)
		a[i]=p[i-1].second^p[i].second;
	a[n]=p[n-1].second;
	for(int i=0,l,r;i<m;i++)
	{
		cin>>l>>r;
		l=lower_bound(p,p+n,make_pair(l,0))-p;
		r=upper_bound(p,p+n,make_pair(r,1))-p;
		e[l].push_back({r,i+1});
		e[r].push_back({l,i+1});
	}
	for(int i=0;i<=n;i++)
	{
		if(!vis[i])
		{
			if(dfs(i))
			{
				cout<<"-1\n";
				return 0;
			}
		}
	}
	cout<<ans.size()<<endl;
	sort(ans.begin(),ans.end());
	for(int i:ans)
		cout<<i<<' ';
	return 0;
}


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

int main(void){
    int H,W;
    cin>>H>>W;
    string glaph[100];
    for(int i = 0; i<H; i++){
        cin>>glaph[i];
    }

    for(int i=0;i<H;i++){
        if(glaph[i].find('#')==string::npos){
            glaph[i]="hhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh";
        }
    }

    for(int i=0; i<W;i++){
        bool flag=true;
        for(int j=0; j<H; j++){
            if(glaph[j][i]=='#'){
                flag=false;
            }
        }
        if(flag==true){
            for(int k=0; k<H;k++){
                glaph[k][i]='b';
            }
        }
    }

    for(int i=0;i<H;i++){
        if(glaph[i].find('h')<100)continue;
        for(int j=0; j<W;j++){
            if(glaph[i][j]=='b')continue;
            cout<<glaph[i][j];
        }
        cout<<endl;
    }


    return 0;
}

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

using namespace std;

#define INF 1e9
#define MAXN 100005
#define MAXM 100005
#define ll long long
#define vi vector<int>
#define vll vector<long long>
#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define pii pair<int, int>

ll A, B, A_, B_, K;

void solve(){
    A_ = max(0ll, A-K);
    K -= min(A,K);
    B_ = max(0ll, B - K);

    cout << A_ << " " << B_ << endl;
}

int main(){
    cin >> A >> B >> K;

    solve();
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
long long n,k,ans=0;
inline long long cl(long long a,long long b){
    if (!a) {return -b;}
    return cl(b%a,a)+(b/a)*2*a;
}
int main(){
    cin>>n>>k;
    ans=n;ans+=cl(k,n-k);
    printf("%lld",ans);
    return 0;    
}

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

int main()
{
    int imax=0;
    int i=0, j=0;
    char ch;
    char AfterStr[1200]={0};
    
    while(1){
        scanf("%c", &ch);
        if(isalpha(ch)){
            if(islower(ch)){
                ch = toupper(ch);
            }else if(isupper(ch)){
                ch = tolower(ch);
            }
        }else{
            ch = ch;
        }

        printf("%c", ch);
        if(ch=='\n') break;
    }
    

    return 0;
}


Measured memory_bytes: 2036
#include <iostream>
#include <algorithm>
#include <cassert>
#include <cctype>
#include <complex>
#include <cstdio>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <string>
#include <vector>
using namespace std;

int n,m;

int main(){
	while(cin>>n){
		if(!n)return 0;
		for(int i=0;i<9;i++){
			cin>>m;
			n-=m;
		}
		cout<<n<<endl;
	}
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
using namespace std;
typedef  long long  ll;
typedef vector<ll> vll;
#define rall(s) s.rbegin(),s.rend()
typedef map<ll,ll> mll;
#define fr(n,x) for(ll n=0;n<x;n++)
#define pb push_back
#define EL cout<<'\n'
#define all(s) s.begin(),s.end()
int pr[10000000];
void sieve(){
    ll n,k;
    for(n=0;n<10000000;n++)pr[n]=1;
    for(n=2;n*n<10000000;n++){
        if(pr[n]){
            for(k=n*2;k<10000000;k+=n)pr[k]=0;
        }
    }
}

int main(){
    sieve();
    ll x,n;
    cin>>x;
    while(!pr[x])x++;
    cout<<x;
}


Measured memory_bytes: 39296