akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <stdio.h>
#include <math.h>
#include <string.h>
#include <algorithm>
#include <stdlib.h>
#include <string>
#include <queue>
#include <vector>
#include <set>

using namespace std;

struct node
{
	int st,hp,len;
	node(){}
	node(int st,int hp,int len) :
		st(st),hp(hp),len(len) {}
};

int n,m,ind;
int HP_init,HP_mx;
char adj[205][205];
int T,hurt[30];
int S,route[1205];
int P,pi[20];
int dp[(1<<12)+10][1005];
bool vis[ (1<<12)+10 ][1005];

int dx(char chr)
{
	if(chr=='D') return 1;
	if(chr=='U') return -1;
	if(chr=='L') return 0;
	return 0;
}
int dy(char chr)
{
	if(chr=='D') return 0;
	if(chr=='U') return 0;
	if(chr=='L') return -1;
	return 1;
}
int fun(int x,int y)
{
	return hurt[ adj[x][y]-'A' ];
}
void getNxt(int hp,int len,int &hp_nxt,int &len_nxt)
{
	int lft=len,rht=ind;
	while(lft<=rht)
	{
		int mid=(lft+rht)>>1;

		int sum=route[mid]-route[len];
		if(sum<hp) lft=mid+1,len_nxt=mid,hp_nxt=hp-sum;
		else rht=mid-1;
	}
}

int main()
{
	//freopen("C.in","r",stdin);

	while(scanf("%d%d",&HP_init,&HP_mx)!=EOF)
	{
		if(HP_init==0&&HP_mx==0) break;

		ind=1;
		memset(hurt,0,sizeof(hurt));
		memset(vis,0,sizeof(vis));
		memset(dp,0,sizeof(dp));
		memset(route,0,sizeof(route));

		scanf("%d%d",&n,&m);
		for(int i=0;i<n;i++) scanf("%s",adj[i]);

		scanf("%d",&T);
		for(int i=0;i<T;i++)
		{
			char str[10]; int tmp;
			scanf("%s%d",str,&tmp);
			hurt[ str[0]-'A' ]=tmp;
		}

		//for(int i=0;i<30;i++) cout<<hurt[i]<<" ";cout<<endl;

		scanf("%d",&S);

		int x=0,y=0;
		for(int i=0;i<S;i++)
		{
			char str[10]; int tmp;
			scanf("%s%d",str,&tmp);
			for(int j=0;j<tmp;j++)
			{
				x+=dx(str[0]);
				y+=dy(str[0]);
				route[++ind]+=fun(x,y);
			//	cout<<str[0]<<" x="<<x<<" y="<<y<<" fun="<<fun(x,y)<<endl;
				route[ind]+=route[ind-1];
			}
		}

		//for(int i=1;i<=ind;i++) cout<<route[i]<<" ";cout<<endl;

		scanf("%d",&P);
		for(int i=0;i<P;i++) scanf("%d",&pi[i]);

		queue<node> que;

		int hp_nxt,len_nxt;
		getNxt(HP_init,1,hp_nxt,len_nxt);

		que.push(node( (1<<(P))-1,hp_nxt,len_nxt) );

		dp[ (1<<P)-1 ][ len_nxt ]=hp_nxt;
		vis[ (1<<P)-1 ][ len_nxt ]=1;

		bool flag=0;
		while(!que.empty())
		{
			int st=que.front().st;
			int hp=que.front().hp;

			int len=que.front().len;
			//cout<<"st="<<st<<" hp="<<hp<<" len="<<len<<endl;

			que.pop(); 		vis[st][len]=0;

			if(len==ind)
			{
				flag=1; break;
			}

			for(int i=0;i<P;i++) if(st&(1<<i))
			{
				int st_nxt=st^(1<<i),hp_nxt,len_nxt;

				getNxt(min(HP_mx,hp+pi[i]),len,hp_nxt,len_nxt);

				if(dp[st_nxt ][ len_nxt ]<hp_nxt)
				{
					dp[ st_nxt ][len_nxt]=hp_nxt;
					if(vis[ st_nxt ][len_nxt]==0)
					{
						que.push(node(st_nxt,hp_nxt,len_nxt));

						vis[ st_nxt ][len_nxt]=1;
					}
				}
			}
		}
		if(flag) puts("YES");
		else puts("NO");
	}
	return 0;
}

Measured memory_bytes: 21416
import java.util.*;
 
class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
      
      Set<Integer> hash_set = new HashSet<Integer>();
      int nam = 0;
      
      for(int i=0;i < n;i++){
        nam = sc.nextInt();
        if(hash_set.contains(nam)){
          hash_set.remove(nam);
        }else{
          hash_set.add(nam);
        }
      }
      
      System.out.print(hash_set.size());
      
    }
}

Measured memory_bytes: 62932
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
static const int INF (1<<30);

int main() {
  int N, K;
  cin >> N >> K;
  vector<int> x(N);

  rep(i, N) {
    cin >> x[i];
  }

  int ans = INF;

  rep(i, N) {
    int r = i + K - 1;
    if (r >= N) break;

    if ((long long)x[i]*x[r] < 0) {
      ans = min(ans, min(2*abs(x[i])+x[r], abs(x[i]) + 2*x[r]));
    } else {
      ans = min(ans, max(abs(x[i]), abs(x[r])));
    }
  }

  cout << ans << endl;

  return 0;
}

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

template<class Type> inline bool chmax(Type& a, Type b) { if (a < b) { a = b; return 1; } return 0; }
template<class Type> inline bool chmin(Type& a, Type b) { if (a > b) { a = b; return 1; } return 0; }

template<class Type>
Type modpow(Type a, Type n, Type mod)
{
	Type res = 1;
	while (0 < n)
	{
		if (n & 1)
		{
			res = res * a % mod;
		}
		a = a * a % mod;
		n >>= 1;
	}
	return res;
}

template<class Type>
Type gcd(Type x, Type y)
{
	Type r;
	if (x < y)
	{
		swap(x, y);
	}

	while (0 < y)
	{
		r = x % y;
		x = y;
		y = r;
	}
	return x;
}

template<class Type>
bool isPrime(Type x)
{
	if (x == 2) return true;
	if (x < 2 || x % 2 == 0) return false;

	for (Type i = 3; i <= sqrt(x); i += 2)
	{
		if (x % i == 0) return false;
	}
	return true;
}

template<class Type>
vector<bool> eratos(Type n)
{
	vector<bool> isPrime(n + 1, true);
	isPrime[0] = isPrime[1] = false;
	for (Type i = 2; i <= n; i++)
	{
		if (isPrime[i])
		{
			Type j = i + i;
			while (j <= n)
			{
				isPrime[j] = false;
				j = j + i;
			}
		}
	}
	return isPrime;
}

bool binarySearchJudge(vector<int> a, int index, int key)
{
	if (key <= a[index]) return true;
	else return false;
}

int binarySearch(vector<int> a, int key)
{
	int ng = -1;
	int ok = a.size();
	while (1 < abs(ng - ok))
	{
		int mid = (ng + ok) / 2;
		if (binarySearchJudge(a, mid, key)) ok = mid;
		else ng = mid;
	}
	return a[ok] == key;
}

double dist(vector<int> x, vector<int> y, int i, int j)
{
	return sqrt(pow(x[i] - x[j], 2) + pow(y[i] - y[j], 2));
}

int main()
{
	ll x, y;
	cin >> x >> y;
	int ans = 1;
	while (x * 2 <= y)
	{
		x *= 2;
		ans++;
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <array>
#include <cassert>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <sstream>
#include <vector>
#include <queue>
#include <stack>
#include <list>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <complex>
#include <cmath>
#include <numeric>
#include <bitset>
#include <functional>
#include <random>
#include <ctime>

using namespace std;

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

typedef long long int64;
typedef pair<int, int> ii;
const int INF = 1 << 29;
const int MOD = 1e9 + 7;
mt19937 mrand(random_device{}());
int rnd(int x) { return mrand() % x; }

const int N = 2e5 + 10;
int64 p2[N];
vector<int> a[N];
int sz[N];
int n, ret;

void DFS(int u, int parent) {
  sz[u] = 1;
  for (auto& v : a[u]) {
    if (v == parent) continue;
    DFS(v, u);
    sz[u] += sz[v];
  }
  int cnt = (p2[sz[u] - 1] + MOD - 1) % MOD;
  for (auto& v : a[u]) {
    if (v == parent) continue;
    cnt = (cnt + MOD - (p2[sz[v]] + MOD - 1) % MOD) % MOD;
    // trace(cnt);
  }
  ret += cnt;
  ret %= MOD;
  ret += (p2[sz[u] - 1] + MOD - 1) * (p2[n - sz[u]] + MOD - 1) % MOD;
  ret %= MOD;
}

int64 power_mod(int64 a, int n) {
  int64 ret = 1;
  for (; n; n >>= 1) {
    if (n & 1) ret = ret * a % MOD;
    a = a * a % MOD;
  }
  return ret;
}

int main() {
  p2[0] = 1;
  for (int i = 1; i < N; ++i) p2[i] = p2[i - 1] * 2 % MOD;
  scanf("%d", &n);
  for (int i = 1; i < n; ++i) {
    int x, y;
    scanf("%d%d", &x, &y);
    --x; --y;
    a[x].push_back(y);
    a[y].push_back(x);
  }
  ret = 0;
  DFS(0, -1);
  // trace(ret);
  for (int i = 0; i < n; ++i) {
    if (ret % 2 == 0) {
      ret /= 2;
    } else {
      ret = (ret + MOD) / 2;
    }
  }
  // ret = ret * power_mod(power_mod(2, MOD - 2), n) % MOD;
  printf("%d\n", ret);
  return 0;
}


Measured memory_bytes: 24704
numbers = list(map(int,input().split()))
counter1 = 0
counter2 = 0
for i in numbers:
    if i == 5:
        counter1 += 1
    if i == 7:
        counter2 += 1

if counter1 == 2 and counter2 == 1:
    print("YES")
else:
    print("NO")


Measured memory_bytes: 2940
#include<stdio.h>
#define MAX 100005
#define NIL -1

struct Node{ int p, l, r;};
struct Node T[MAX];
int n, H, D[MAX];

int getDepth(int u){
  int d = 0;
  for(; T[u].p != NIL ;d++) u = T[u].p;
  return d;
}

void print(int u){
  int i, c;
  printf("node %d: ", u);
  printf("parent = %d, ", T[u].p);
  printf("depth = %d, ", D[u]);

  if (T[u].p == NIL) printf("root, ");
  else if (T[u].l == NIL) printf("leaf, ");
  else printf("internal node, ");

  printf("[");
  for(i = 0, c = T[u].l; c != NIL; i++, c = T[c].r){
    if (i) printf(", ");
    printf("%d", c);
  }
  printf("]\n");
}

int main(){
  int i, j, d, v, c, l;
  scanf("%d", &n);
  for (i = 0; i < n; i++) T[i].p = T[i].l = T[i].r = NIL;

  for (i = 0; i < n; i++){
    scanf("%d %d", &v, &d);
    for (j = 0; j < d; j++){
      scanf("%d", &c);
      if (j == 0) T[v].l = c;
      else T[l].r = c;
      l = c;
      T[c].p = v;
    }
  }
  H = 0;
  for (i = 0; i < n; i++){
    D[i] = getDepth(i);
    if ( D[i] > H ) H = D[i];
  }
  for (i = 0; i < n; i++) print(i);
  return 0;
}


Measured memory_bytes: 3268
fun main(args: Array<String>){
    val n = readLine()!!.toInt()
    val list = readLine()!!.split(" ").map{it.toInt()}.toMutableList()
    val count = bubbleSort(list, n)
    for(i in 0 until list.size) {
        print(list[i].toString())
        if(i != list.size-1) {
            print(" ")
        } else {
            println()
        }
    }
    println(count)
}

fun bubbleSort(A: MutableList<Int>, n: Int): Int {
    var count = 0
    var flag = 1
    while(flag != 0){
        flag  = 0
        for(i in n-1 downTo 1){
            if(A[i] < A[i-1]) {
                val temp = A[i]
                A[i] = A[i-1]
                A[i-1] = temp
                flag = 1
                count++
            }
        }
    }
    return count
}


Measured memory_bytes: 31996
#include <cstdio>
#include <cmath>
#include <iostream>
#include <vector>
#include <string>
#include <utility>
#include <algorithm>
#include <queue>
using namespace std;
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define REP(i,n) for(ll i=0;i<n;i++)
#define REPR(i,n) for(ll i=n-1;i>=0;i--)

typedef long long ll;
#define INF 1e18

int main(){
	ll n; cin>>n;
	printf("%lf\n",2*n*3.14159265358979);
	return 0;
}

Measured memory_bytes: 3760
import java.io._
import java.util.StringTokenizer
import scala.util.control.Breaks.{breakable,break}
import scala.collection.mutable.{Map, Stack, Queue, PriorityQueue, Set}

object Main extends App {
  val in = new InputReader(System.in)
  val pw = new PrintWriter(System.out)

  val hash = Map[String, Int]()
  val N = in.next().toInt
  for (_ <- 1 to N) {
    val s = in.next()
    if (!hash.contains(s)) {
      hash += (s -> -1)
    }
    else {
      hash(s) -= 1
    }
  }

  var hoge = 0
  val fuga = hash.toSeq.map {case (k, v) => (v, k)}.sorted
  for ((v, k) <- fuga) {
    if (hoge == 0 || hoge == v) {
      pw.println(k)
      hoge = v
    }
  }
  pw.flush()
}

object Sub {
  def print2DimArray[A](mat: Array[Array[A]]): Unit = {
    mat.foreach(lin => println(lin.toList))
  }
}

class InputReader(stream: InputStream) {
  private[this] val reader = new BufferedReader(new InputStreamReader(stream))
  private[this] var tokenizer: StringTokenizer = new StringTokenizer(reader.readLine())
  def next(): String = {
    while (!tokenizer.hasMoreTokens()) {
      tokenizer = new StringTokenizer(reader.readLine())
    }
    tokenizer.nextToken()
  }
}


Measured memory_bytes: 81820
from math import sqrt
n = int(input())
x = []
y = []
sum = 0
for i in range(n):
    X,Y = map(int,input().split())
    x.append(X)
    y.append(Y)
for i in range(n):
    for j in range(n):
        if j == i:
            continue
        sum += sqrt((x[i]-x[j])**2+((y[i]-y[j])**2))
def rank(s):
    if s != 1:
        return s * rank(s-1)
    else:
        return 1

print(sum * 2 * rank(n-1)/ rank(n)/2)

Measured memory_bytes: 3188
n = gets.to_i
h = gets.split.map(&:to_i)

dp = [0]
dp[1] = (h[0] - h[1]).abs

1.upto(n - 1) do |i|
  dp[i] = [(h[i] - h[i - 1]).abs + dp[i - 1], (h[i] - h[i - 2]).abs + dp[i - 2]].min
end

puts dp[n - 1]


Measured memory_bytes: 11524
#include <iostream>
#include <algorithm>
#define pq priority_queue
#define mp make_pair
#define cauto const auto&

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
#define SZ(x) ((int)(x).size())

#define clr(ar,val) memset(ar, val, sizeof(ar))

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

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

using namespace std;

typedef long long int64;
typedef long long lint;
typedef long long lli;
typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;
typedef pair<int, ll> pil;
typedef pair<ll, ll> pll;

const int iinf = 1 << 29;
const long long linf = 1ll << 61;


int main(){
    int n,a,b;
    cin>>n>>a>>b;
    cout<< min(a,b)<<' '<<max(min({a,b,a+b-n}),0)<<endl;
    return 0;
}




Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n;  cin >> n;
  int a[n];
  int sum = 0;
  for(int i=0 ; i<n ; i++){
    cin >> a[i];
    sum += a[i];
  }
  int ans = sum;
  if(sum%10 == 0){
    int cnt10 = 0;
    vector<int> v;
    for(int i=0 ; i<n ; i++){
      if(a[i]%10==0){
        cnt10++;
      }else{
        v.push_back(a[i]);
      }
    }
    sort(v.begin(),v.end());
    if(cnt10==n){
      ans = 0;
      cout << ans << endl;
      return 0;
    }
    ans -= v[0];
    if(cnt10==n) ans = 0;
  }
  cout << ans << endl;
  return 0;
}


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

using namespace std;

int main()
{
	int n,h;
	cin >> n >> h; 
	
	vector<int> a(n),b(n);
	for(int i=0;i<n;i++)
		cin >> a[i] >> b[i];
	
	sort(a.begin(),a.end(),greater<int>());
	sort(b.begin(),b.end(),greater<int>());

	int count=0;

	for(int i=0;i<n;i++)
	{
		if(b[i]<a[0])break;
		count++;
		h-=b[i];
		if(h<=0)
		{
			cout << count << endl;
			return 0;
		}
	}

	count+=((h-1)/a[0]+1);

	cout<< count << endl;
}



Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)

using namespace std;
const int INF = 1e7;
typedef pair<int,int> P;
int main(){
  int n;
  while(cin >> n, n){
    vector<vector<P>> dp(n+1,vector<P>(55000,P(0,-INF)));
    dp[0][0]=P(0,0);
    for(int i=0;i<n;i++){
      int p;
      cin >> p;
      for(int j=0;j<=50000;j++){
	if(dp[i][j].second<=-INF)
	  continue;
	dp[i+1][j]=max(dp[i+1][j], dp[i][j]);
	int fee=(p+999)/1000*1000;
	int back=fee-p;
	int get= back+j>=500 ? 1 : 0;
	int rest=(back+j)-get*500;
	//cout << fee << " " << back << " " << get << " " << rest << endl;
	dp[i+1][rest]=max(dp[i+1][rest], P(dp[i][j].first+get,dp[i][j].second-p));
      }
    }
    P ans=P(0,-INF);
    for(int i=0;i<50000;i++)
      ans=max(ans,dp[n][i]);
    cout << ans.first << " " << -ans.second << endl;
  }
  return 0;
}

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

struct  card {
	char suit;
	int value;
};
void bubbleSort(card *A, int n)
{
	card t;
	for (int i = 0; i<n; i++)
		for (int j = n-1; j >= i + 1; j--)
		{
			if (A[j].value <A[j - 1].value)
			{
				t = A[j]; A[j] = A[j - 1]; A[j - 1] = t;
			}
		}
}

void selectSort(card *A, int n)
{
	card t;
	int i, j;
	for (i = 0; i<n; i++)
	{
		int mini = i;
		for (j = i; j<n; j++)
		{
			if (A[j].value<A[mini].value)
				mini = j;
		}
		t = A[i]; A[i] = A[mini]; A[mini] = t;
	}
}

bool cmp(card *A, card *B, int n)
{
	for (int i = 0; i< n; i++)
	{
		if (A[i].suit != B[i].suit) return false;
	}
	return true;
}



int main()
{
	card A[100], B[100];
	int n;
	cin >> n;

	//char suit;
	//int value;
	for (int i = 0; i< n; i++)
	{
		//cin >> suit >> value;
		//A[i].suit = suit;
		cin >> A[i].suit >> A[i].value;
		B[i] = A[i];
	}
	
	bubbleSort(A, n);
	selectSort(B, n);

	for (int i = 0; i < n; i++)
	{
		if (i) cout << " ";
		cout << A[i].suit << A[i].value;
	}
	cout << endl;
	cout << "Stable" << endl;


	for (int i = 0; i < n; i++)
	{
		if (i) cout << " ";
		cout << B[i].suit << B[i].value;
	}
	cout << endl;
	if(cmp(A,B,n))
		cout <<"Stable"<<endl;
	else
		cout << "Not stable"<<endl;

}

Measured memory_bytes: 3068
a = {}

for s in [input() for _ in range(int(input()))]:
  if s in a: a[s] += 1
  else: a[s] = 1

a = sorted(a.items(), key=lambda x:x[1], reverse=True)
n = a[0][1]
i = 1
while i < len(a) and a[i][1] == n: i += 1
a = a[:i]
a = sorted(a, key=lambda x:x[0])

for s,t in a:
  print(s)

Measured memory_bytes: 43120
/// In The Name Of God

#include <bits/stdc++.h>

#define f first
#define s second

#define pb push_back
#define pp pop_back
#define mp make_pair

#define sz(x) (int)x.size()
#define sqr(x) ((x) * 1ll * (x))
#define all(x) x.begin(), x.end()

#define rep(i, l, r) for (int i = (l); i <= (r); i++)
#define per(i, l, r) for (int i = (l); i >= (r); i--)

#define Kazakhstan ios_base :: sync_with_stdio(0), cin.tie(0), cout.tie(0);

#define nl '\n'
#define ioi exit(0);

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;

const int N = (int)5e5 + 7;
const int inf = (int)1e9 + 7;
const int mod = (int)1e9 + 7;
const ll linf = (ll)1e18 + 7;

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

using namespace std;

void go(int a, int b, int c, int k) {
	if (b > a && c > b) cout << "Yes", ioi
	if (k) {
		go(a * 2, b, c, k - 1);
		go(a, b * 2, c, k - 1);
		go(a, b, c * 2, k - 1);
	}
}
int main() {
	#ifdef wws
		freopen ("in.txt", "r", stdin);
	#endif
	int a,  b, c, k;;
	cin >> a >> b >> c >> k;
	go(a, b, c, k);
	cout << "No";
	ioi
}


Measured memory_bytes: 3632
a = [[[0] * 10 for _ in range(3)] for _ in range(4)]
for _ in range(int(input())):
    b, f, r, v = [int(i) for i in input().split()]
    a[b - 1][f - 1][r - 1] += v
for i in a:
    for j in i:
        print("", *j)
    if i is a[-1]:
        break
    print("#" * 20)



Measured memory_bytes: 5624
#include<iostream>
#include<algorithm>
#include<cmath>
#include<vector>
#include<map>
#include<queue>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep1(i, n) for (int i = 1; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;
const int INF = 1001001001;

int res[3][3];

int main() {
  int A[3][3];
  rep(i,3)rep(j,3) cin >> A[i][j];
  int N;
  cin >> N;
  int b[N];
  rep(i,N) cin >> b[i];

  if (N < 3) {
    cout << "No" << endl;
    return 0;
  }
  rep(i,N)rep(j,3)rep(k,3) {
    if (b[i] == A[j][k]) res[j][k] = 1;
  }
  if ((res[0][0] == 1 && res[1][1] == 1 && res[2][2] == 1) || (res[0][2] == 1 && res[1][1] == 1 && res[2][0] == 1)) {
    cout << "Yes" << endl;
    return 0;
  }
  rep(i,3) {
    if ((res[i][0] == 1 && res[i][1] == 1 && res[i][2] == 1) || (res[0][i] == 1 && res[1][i] == 1 && res[2][i] == 1)) {
      cout << "Yes" << endl;
      return 0;
    }
  }
  cout << "No" << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <array>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <algorithm>
#include <iomanip>
#include <cmath>
#include <limits>

using namespace std;

typedef long long ll;

void add_mod(ll& val, ll add_val) {
	val = (val + add_val) % 100000007;
}

int main (int argc, char* argv[]) {
	int n;
	cin >> n;
	unordered_set<string> hist;
	string prev;
	for (int i = 0; i < n; i++) {
		string current;
		cin >> current;
		if (i == 0) {
			hist.insert(current);
			prev = current;
			continue;
		}
		if (hist.count(current) > 0 || prev.back() != current.front()) {
			cout << "No" << endl;
			return 0;
		}
		hist.insert(current);
		prev = current;
	}
	cout << "Yes" << endl;
}


Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
using namespace std;
 
int main(void) {
  string str, st, sr;
  cin >> str;
  for (int i = 2; i < str.length(); i += 2) {
    st = str.substr(0, (str.length() - i) / 2);
    sr = str.substr((str.length()-i )/ 2, (str.length() - i) / 2);
    if (st == sr) {
      cout <<  str.length()-i<< endl;
      break;
    }
  }
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#include <unordered_map>
#include <set>
#include <climits>
using namespace std;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N;
    cin >> N;
    vector<pair<int, int>> v1(N), v2(N);
    for(int i=0; i<N; i++){
        v1[i].second = i;
        v2[i].second = i;
    }
    for(int i=0; i<N; i++){
        int x, y;
        cin >> x >> y;
        v1[i].first = x;
        v2[i].first = y;
    }
    sort(v1.begin(), v1.end());
    sort(v2.begin(), v2.end());

    vector<vector<pair<int, int>>> G(N);
    for(int i=0; i<N-1; i++){
        int id1 = v1[i].second, id2 = v1[i+1].second;
        int cost = abs(v1[i].first - v1[i+1].first);
        G[id1].push_back(make_pair(cost, id2));
        G[id2].push_back(make_pair(cost, id1));
    }
    for(int i=0; i<N-1; i++){
        int id1 = v2[i].second, id2 = v2[i+1].second;
        int cost = abs(v2[i].first - v2[i+1].first);
        G[id1].push_back(make_pair(cost, id2));
        G[id2].push_back(make_pair(cost, id1));
    }

    int cnt = 0;
    long long ans = 0;
    vector<int> isVisited(N, false);
    priority_queue<pair<int, int>, vector<pair<int, int>>, greater<pair<int, int>>> pq;
    pq.push(make_pair(0, 0));
    while(cnt < N){
        pair<int, int> tp = pq.top();
        pq.pop();
        if(isVisited[tp.second]) continue;
        cnt++;
        isVisited[tp.second] = true;
        ans += tp.first;
        for(auto edge : G[tp.second])
            pq.push(edge);
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 12408
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<map>
#include<set>
#include<cstdio>
#include<cmath>
#include<deque>
#include<numeric>
#include<queue>
#include<stack>
#include<cstring>
#include<limits>
#include<functional>
#include<unordered_set>
#include<iomanip>
#include<cassert>
#include<regex>
#include<bitset>
#include<complex>
#include<chrono>
#define rep(i,a) for(int i=(int)0;i<(int)a;++i)
#define pb push_back
#define eb emplace_back
#define all(x) x.begin(),x.end()
using ll=long long;
constexpr ll mod = 1e9 + 7;
constexpr ll INF = 1LL << 60;

ll gcd(ll n, ll m) {
	ll tmp;
	while (m!=0) {
		tmp = n % m;
		n = m;
		m = tmp;
	}
	return n;
}

ll lcm(ll n, ll m) {
	return abs(n * m) / gcd(n, m);//gl=xy
}
 
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;
}
 
using namespace std;

//ここから

void solve(){
  int n,r;
  cin>>n>>r;
  if(n>=10)cout<<r;
  else cout<<r+100*(10-n);
}

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


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args){
        Scanner scanner = new Scanner(System.in);
        try{
            int a = scanner.nextInt();
            int b = scanner.nextInt();
            System.out.print(a*b+" ");
            System.out.println(2*(a+b));
            scanner.close();
        }catch(NumberFormatException e){
            System.out.println(e);
        }finally{
            scanner.close();
        }
        }
    }


Measured memory_bytes: 26180
import numpy as np
from scipy.sparse.csgraph import floyd_warshall

N, M, L = map(int, input().split())
Map = np.full((N, N), 10**12, dtype='int64')
for _ in range(M):
    a, b, c = map(int, input().split())
    a -= 1
    b -= 1
    Map[a][b] = c
    Map[b][a] = c
Q = int(input())
Query = [tuple(map(int, input().split())) for _ in range(Q)]
graph = floyd_warshall(Map).astype('int64')
graph[graph <= L] = 1
graph[graph > L] = 10**12
A = floyd_warshall(graph).astype('int64')
for s, t in Query:
    if A[s - 1][t - 1] >= 10**12:
        print(-1)
    else:
        print(int(A[s - 1][t - 1] - 1))


Measured memory_bytes: 47864
#n = int(input())
#l = list(map(int, input().split()))

'''
A=[]
B=[]
for i in range():
    a, b = map(int, input().split())
    A.append(a)
    B.append(b)'''

l = list(map(int, input().split()))

if l[0]<10:
    print(l[1]+100*(10-l[0]))
else:
    print(l[1])

Measured memory_bytes: 2940
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define ll long long
#define forin(x,y) for(ll i=x;i<y;i++)
#define vii vector<ll>
#define pii  pair<ll,ll>
#define pb push_back
#define mp make_pair
using namespace __gnu_pbds;
using namespace std;

template <typename T>
using ordered_set =
    tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

string s,t;
vector<vii> dp;
ll evaluate(ll a,ll b)
{
    if(a<0 || b<0 )    return 0;
    if(dp[a][b] != -1)   return dp[a][b];
    if(s[a] == t[b]){
        dp[a][b] = 1+evaluate(a-1,b-1);
    }
    else
    {
       dp[a][b] = max(evaluate(a,b-1),evaluate(a-1,b));
    }
    return dp[a][b];
}
    
int main()
{
    ios::sync_with_stdio(false);    cin.tie(0);     cout.tie(0);
    cin>>s>>t;  
    dp.resize(s.length());
    for(auto &i:dp) i.resize(t.length(),-1);
    
    evaluate(s.length()-1,t.length()-1);
        
    ll i=s.length()-1;
    ll j = t.length()-1;
    string ans;
    while(i>=0 && j>=0)
    {
        if(s[i] == t[j])
        {
            ans +=s[i]; --i;    --j;
        }
        else if(i>0 &&  dp[i-1][j]>=dp[i][j-1])
        {
            --i;
        }
        else
        {
            --j;
        }
    }
    reverse(ans.begin(),ans.end());
    cout<<ans<<endl;
}


Measured memory_bytes: 71040
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int N;
const int MAX3N=3e5+10;
const ll INF = 1e18;

int a[MAX3N];
ll pref[MAX3N], suff[MAX3N];

void precompute() {
    priority_queue<int, vector<int>, greater<int> > min_heap;
    ll sum=0;
    for(int i=1;i<=N;i++) {
        min_heap.push(a[i]);
        sum += a[i];
    }
    pref[N] = sum;
    for(int i=N+1;i<=2*N;i++) {
        sum += a[i];
        min_heap.push(a[i]);
        sum -= min_heap.top();
        min_heap.pop();
        pref[i] = sum;
    }

    priority_queue<int> max_heap;
    sum=0;
    for(int i=3*N;i>2*N;i--) {
        max_heap.push(a[i]);
        sum += a[i];
    }
    suff[2*N+1] = sum;
    for(int i=2*N;i>N;i--) {
        sum += a[i];
        max_heap.push(a[i]);
        sum -= max_heap.top();
        max_heap.pop();
        suff[i] = sum;
    }
}

int main() {
    scanf("%d", &N);
    for(int i=1;i<=3*N;i++) scanf("%d", &a[i]);
    precompute();

    ll ans = -INF;
    for(int i=N;i<=2*N;i++) {
        ans = max(ans, pref[i]-suff[i+1]);
    }

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

}



Measured memory_bytes: 5112
#include<bits/stdc++.h>
using namespace std;
int main(){
	string s;
	string ans = "";
	map <string ,int> mp;
	while(cin >> s){
		if(ans.size() < s.size())
			ans = s;
		mp[s]++;
	}
	int va = 0;
	string asdf;
	for(auto itr = mp.begin() ; itr != mp.end() ; itr++)
		if((*itr).second > va){
			asdf = (*itr).first;
			va = (*itr).second;
		}
	cout << asdf << " " << ans << endl;
}

Measured memory_bytes: 2996
#include <cstdio>
#include <vector>
#include <utility>
using namespace std;

#define INF 10000000

int n,r,k,t,p,s,d,v;
vector<pair<int,vector<int> > > vec;

int find(int num){
	for(int i = 0; i < n; i++){
		if(vec[i].first == num){
			return i;
		}
	}
	return -1;
}

int sch(int st, int ed){
	int from = find(st);
	int to = find(ed);
	vector<int> vv = vector<int>(n,INF);
	vv[from] = 0;
	for(int i = 1; i <= n; i++){
		for(int vi = 0; vi < n; vi++){
			if(vv[vi] == i - 1){
				for(int j = 0; j < vec[vi].second.size(); j++){
					int tmp = find(vec[vi].second[j]);
					if(vv[tmp] == INF){
						vv[tmp] = i;
					}
				}
			}
		}
	}
	return vv[to];
}

int main(){
	scanf("%d",&n);
	vec = vector<pair<int,vector<int> > >(n);
	for(int i = 0; i < n; i++){
		scanf("%d%d",&r,&k);
		vec[i].first = r;
		vec[i].second = vector<int>(k);
		for(int j = 0; j < k; j++){
			scanf("%d",&t);
			vec[i].second[j] = t;
		}
	}
	scanf("%d",&p);
	for(int i = 0; i < p; i++){
		scanf("%d%d%d",&s,&d,&v);
		int l = sch(s,d);
		l += 1;
		if(l <= v){
			printf("%d\n",l);
		}
		else{
			printf("NA\n");
		}
	}
	return 0;
}

Measured memory_bytes: 2748
import java.util.*;
class Main{
	public static void main(String args[]){
		Scanner s = new Scanner(System.in);
		String indata;
		indata = s.next();
		int wide = Integer.parseInt(indata);
		indata = s.next();
		int hight = Integer.parseInt(indata);
		indata = s.next();
		int x = Integer.parseInt(indata);
		indata = s.next();
		int y = Integer.parseInt(indata);
		indata = s.next();
		int r = Integer.parseInt(indata);
		
		if(x>=r&&y>=r&&(wide-x)>=r&&(hight-y)>=r)System.out.println("Yes");
		else System.out.println("No");
		
				
	}
}

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

#define pb push_back
#define mp make_pair
#define mt make_tuple
#define ll long long unsigned
#define pii pair<int,int>
#define tii tuple <int,int,int>
#define N 1000005
#define mod 2000003
#define X first
#define Y second
#define eps 0.0000000001
#define all(x) x.begin(),x.end()
#define tot(x) x+1,x+n+1
using namespace std;
char c;
int main()
{
    cin.sync_with_stdio(0);
    cout.sync_with_stdio(0);
    cin>>c;
    if(strchr("aeiou",c))
        cout<<"vowel";
    else
        cout<<"consonant";
    return 0;
}




Measured memory_bytes: 764
#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
#include<set>
#include<string>
#include<stdio.h>
#include<cmath>
#include<map>
#include<bitset>

using namespace std;

#define rep(i, n) for(int i = 0; i < n; i++)
#define repn(i, n) for(int i = 1; i <= n; i++)
#define repr(i, n) for(int i = n-1; i >= 0; i--)
#define all(x) (x).begin(), (x).end()
#define lint long long


int main(){
    lint n; cin >> n;
    if(n % 2 == 1){
        cout << 0 << endl;
        return 0;
    }

    lint ans = 0;
    n /= 2;
    while(n >= 1){
        ans += (n / 5);
        n /= 5;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <unistd.h>
#include <sys/time.h>
#include <stdlib.h>
 
using namespace std;
 
typedef long long ll;
typedef pair<ll,ll> P;
typedef pair<P, ll> T;
 
long long int INF = 2e18;
const ll fact_table = 1200008;
double Pi = 3.1415926535897932384626;

priority_queue <ll> pql;
priority_queue <P> pqp;
priority_queue <P> bag;
//big priority queue
priority_queue <ll,vector<ll>,greater<ll> > pqls;
priority_queue <P,vector<P>,greater<P> > pqps;
//small priority queue
//top pop
 
ll dx[8]={1,0,-1,0,1,1,-1,-1};
ll dy[8]={0,1,0,-1,1,-1,-1,1};
char dir[] = "DRUL";
//↓,→,↑,←

#define endl "\n"
#ifdef ENJAPMA
    #undef endl
#endif
#define p(x) cout<<x<<endl;
#define el cout<<endl;
#define pe(x) cout<<x<<" ";
#define ps(x) cout<<fixed<<setprecision(25)<<x<<endl;
#define pu(x) cout<<(x);
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define CLEAR(a) a = decltype(a)(); 
#define pc(x) cout << x << ",";
 
const ll mod = 998244353ll;
// const ll mod = 1000000007ll;
  
ll mypow(ll number1,ll number2, ll mod){
    if(number2 == 0){
        return 1ll;
    }else{
        ll number3 = mypow(number1,number2 / 2, mod);
        number3 *= number3;
        number3 %= mod;
        if(number2%2==1){
            number3 *= number1;
            number3 %= mod;
        }
        return number3;
    }
}
void YES(bool condition){
    if(condition){
        p("YES");
    }else{
        p("NO");
    }
    return;
}
void Yes(bool condition){
    if(condition){
        p("Yes");
    }else{
        p("No");
    }
    return;
}


ll fact[fact_table + 5],rfact[fact_table + 5]; 
 
void c3_init(){
    fact[0] = rfact[0] = 1;
    for(ll i=1; i<=fact_table; i++){
        fact[i] = (fact[i-1]*i) % mod;
    }
    rfact[fact_table] = mypow(fact[fact_table],mod - 2, mod);
    for(ll i=fact_table; i>=1; i--){
       rfact[i-1] = rfact[i] * i;
       rfact[i-1] %= mod;
    }
    return;}
ll c3(ll n,ll r){
    assert(n >= r);
    assert(n >= 0);
    assert(r >= 0);
    return (((fact[n] * rfact[r]) % mod ) * rfact[n-r]) % mod;}

bool multicase = false;

ll n,m,num,a,b,c,d,e,q;

ll x[200005], y[100005], z[100005];
ll k, ans;
ll dp[1005][1005];
ll before[200005];

void solve(){
    c3_init();
    cin >> n >> m >> k;
    for(ll i=n-k;i<=n;i++){
        ll kosuu = i;
        ll tmp = c3(n - 1, i - 1);
        tmp *= m;
        tmp %= mod;
        tmp *= mypow(m - 1, i - 1, mod);
        tmp %= mod;
        ans += tmp;
        ans %= mod;
    }
    p(ans);
    return;
}

int main(){
    // init();
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    ll q, testcase = 1;
    if(multicase){
        cin >> q;
    }else{
        q = 1; 
    }
    while(q--){
        // pu("Case ");pu("#");pu(testcase);pu(": ");
        solve();
        testcase++;
    }
    // solve();
    return 0;
}
















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

#define int long long
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

map<string, int> mp;

void f(string s){
	cout << s << " x " << mp[s] << endl;
}
signed main(){
	int n;
	cin >> n;

	for(int i = 0;i < n;i++){
		string s;
		cin >> s;
		mp[s]++;
	}


	f("AC");
	f("WA");
	f("TLE");
	f("RE");

	return 0;
}


Measured memory_bytes: 3604
#include<cstdio>
using namespace std;
const int maxn = 1e5;
int a[maxn];

int main(){
	int N,f,cnt;
	while(scanf("%d",&N)==1){
		f = 0; cnt = 1;
		for(int i=1;i<=N;i++){
			scanf("%d",&a[i]);		
		}
		int i=a[1];
		while(i!=2){
			i=a[i];
			cnt++;
			if(cnt>=1e5){
				f=1;
				break;
			}
		}
		if(f==1) printf("-1\n");
		else printf("%d\n",cnt);
	}
	return 0;
}

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

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(0);
    
    int k;
    string s;
    cin >> k;
    cin >> s;
    if(k >= s.length()){
    	cout << s;
    }
    else{
    	for(int i = 0; i < k; i++){
    		cout << s[i];
    	}
    	cout << "...";
    }

    return 0;
}

Measured memory_bytes: 3528
#include<cstdlib>
#include<iostream>
#include<algorithm>
#include<vector>
#include<stack>
#include<queue>
#include<string>
#include<cstring>
using namespace std;
typedef long long lng;
typedef unsigned long long ulng;

#define pb push_back
#define SZ(a) int((a).size())
#define ALL(aA) (a).begin(), (a).end()
#define FOR(i,a,b) for(int i=(a); i<=(b); ++i)
#define FORD(i,b,a) for(int i=(b); i>=(a); --i)
#define REP(i,n) FOR(i,0,n-1)
#define UNIQUE(a) a.erase(unique(ALL(a)), a.end())

lng power(lng b, lng e) {lng sol=1; while(e>0) {if(e&1) {sol=sol*b;} e>>=1; b*= b;} return sol;}

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

    int N, M;
    string sb[100], sr[100];
    cin >> N;
    REP(i, N) cin >> sb[i];
    cin >> M;
    REP(i, M) cin >> sr[i];

    int ans = 0;
    REP(i, N) {
        int tmp = 0;
        string s = sb[i];
        REP(j, N) {
            if(sb[j] == s) tmp++;
        }
        REP(j, M) {
            if(sr[j] == s) tmp--;
        }
        ans = max(ans, tmp);
    }

    cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <tuple>
#include <map>
#include <vector>
#include <algorithm>
#include <cmath>
#include <limits>
using namespace std;
void init();
#define MAX_OF(type) numeric_limits<type>::max()
#define MIN_OF(type) numeric_limits<type>::min()
#define REP(var, num) for(sll var = 0; var < num; var++)
typedef signed long long sll;
typedef unsigned long long ull;

int main() {
    init();
    sll n;
    cin >> n;
    double t, a;
    cin >> t >> a;

    int d_i = -1;
    double d_min = MAX_OF(sll);
    REP(i, n) {
        sll h;
        cin >> h;
        double temp = t - h * 0.006;
        double d = abs(a - temp);
        if (d < d_min) {
            d_i = i;
            d_min = d;
        }
    }

    cout << d_i + 1 << endl;
    return 0;
}

void init() {
    cin.tie(0);
    ios::sync_with_stdio(false);
}

Measured memory_bytes: 256
import math
import copy
import sys
import fractions
# import numpy as np
# import statistics
import decimal
import heapq
import collections
import itertools
import bisect


# from operator import mul

sys.setrecursionlimit(100001)


# input = sys.stdin.readline
# sys.setrecursionlimit(10**6)

# ===FUNCTION===

def getInputIntList():
    outputDataList = []
    inputData = input().split()
    outputDataList = [int(n) for n in inputData]

    return outputDataList


def getSomeInputInt(n):
    outputDataList = []
    for i in range(n):
        inputData = int(input())
        outputDataList.append(inputData)

    return outputDataList


def getSomeInputListInt(n):
    inputDataList = []
    outputDataList = []
    for i in range(n):
        inputData = input().split()
        inputDataList = [int(n) for n in inputData]
        outputDataList.append(inputDataList)

    return outputDataList


# ===CODE===

def dfs(x, y):
    flg = False
    if data[x][y] == 0 or table[x][y] == 1:
        return False
    else:
        table[x][y] = 1
        flg = True


    for i in range(x - 1, x + 2):
        if i < 0 or i > h-1:
            continue
        for j in range(y - 1, y + 2):
            if j < 0 or j > w-1:
                continue
            if not(x == i and y == j):
                tmp = dfs(i, j)

    return flg


while True:
    w, h = map(int, input().split())
    if w == 0 and h == 0:
        break

    data = getSomeInputListInt(h)
    table = [[0 for _ in range(w)] for _ in range(h)]

    ans = 0
    for i in range(h):
        for j in range(w):
            if dfs(i, j):
                ans += 1

    print(ans)



Measured memory_bytes: 9372
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		long x = sc.nextLong();
		long y = sc.nextLong();

		System.out.println(Math.abs((x - 2) * (y - 2)));
		sc.close();
	}
}

Measured memory_bytes: 22868
#include<bits/stdc++.h>
typedef long long int ll;
#define optimization() ios_base::sync_with_stdio(0);
#define FOR(V,lim) for(ll V=0;V<lim;V++)
#define endl '\n'
using namespace std;
int main()
{
    ll a,b;
    cin>>a>>b;
    if(a==b)
        cout<<"Draw"<<endl;
    else if((a==1 || a>b) && b>1)
        cout<<"Alice"<<endl;
    else
        cout<<"Bob"<<endl;
return 0;
}
//Vanquisher_10


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

#define CIN2(a,b) long long a,b;cin >> a >> b;
#define CIN3(a,b,c) long long a,b,c;cin >> a >> b >> c;
#define rep(i,n) for(int i=0,i##_len=(n); i<i##_len; ++i)

int main(){
    int n;cin >> n;
    string s;cin >> s;
    vector<int> v;

    int tmp = 0;
    rep(i,n){
        tmp++;
        if(i==n-1) v.push_back(tmp);
        else if(s[i]!=s[i+1]){
            v.push_back(tmp);
            tmp = 0;
        }
    }

    if(s[0]=='.') v.erase(v.begin());
    if(s[n-1]=='#') v.pop_back();

    //rep(i,v.size()) cout << v[i] << ",";

    int ans = 0;
    for(int i=1,len=v.size(); len>i;i+=2){
        ans += v[i];
    }
    //cout << ans << endl; 

    int score = ans;
    for(int i=0,len=v.size(); len>i;i+=2){
        score = score +v[i] -v[i+1];
        ans = min(ans,score);
    }
    cout << ans << endl;
}


Measured memory_bytes: 1532
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const ll MOD = 1e9+7;
const ll INF = 1e18;
#define rep(i,m,n) for(ll i = (m); i <= (n); i++)
#define zep(i,m,n) for(ll i = (m); i < (n); i++)
#define rrep(i,m,n) for(ll i = (m); i >= (n); i--)
#define print(x) cout << (x) << endl;
#define printa(x,m,n) for(ll i = (m); i <= n; i++){cout << (x[i]) << " ";} cout<<endl;

int main(){
	cin.tie(0); ios::sync_with_stdio(false);
	
	ll n, a, b;
	cin >> n >> a >> b;
	ll ans = (n/(a+b))*a+min(n%(a+b), a);
	print(ans)
	return 0;
}

Measured memory_bytes: 256
my $shopsCount = <STDIN> - 0;
my $shops = [];
for(my $i = 0; $i < $shopsCount; $i++) {
    my @s = map{$_-0}split / /, <STDIN>;
    $shops->[$i] = \@s;
}
my $earn = [];
for(my $i = 0; $i < $shopsCount; $i++) {
    my @s = map{$_-0}split / /, <STDIN>;
    $earn->[$i] = \@s;
}

my $earnMax;
sub attempt {
    my @arr = @_;
    if(scalar(@arr) == 10) {
        return unless grep { $_ == 1 } @arr;
        #print @arr;
        my $er = 0;
        for(my $i = 0; $i < $shopsCount; $i++) {
            my $dup = 0;
            for(my $l = 0; $l < 10; $l++){
                $dup++ if $arr[$l] && $shops->[$i]->[$l];
            }
            #print join('',$earn[$i]),"\n";
            $er += $earn->[$i]->[$dup];
        }
        #print $er;
        $earnMax = $er if $earnMax < $er || !$earnMax;
    } else {
        attempt(@arr, 1);
        attempt(@arr, 0);
    }
}
attempt();
print $earnMax;

Measured memory_bytes: 512
# -*- coding: utf-8 -*-
import math

N = int(input())
As = list(map(int, input().split()))

if As[-1] != 2:
    print(-1)
    exit()
if N == 1:
    print(2, 3)
    exit()

p_min = As[-1]
p_max = As[-1] + 1

for i in range(N-2,-1,-1):
    p_min = As[i] * math.ceil(p_min/As[i])
    p_max = As[i] * math.floor(p_max/As[i])
    if p_min > p_max:
        print(-1)
        exit()

    p_max = p_max + As[i] - 1


print(p_min, p_max)

Measured memory_bytes: 15020
#include<stdio.h>

int main(void){
  int n,k,i,j,total=0,tmp;

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

  int p[n];

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

  for(i=0; i<n; i++){
    for(j=i+1; j<n; j++){
      if(p[i]>p[j]){
        tmp=p[i];
        p[i]=p[j];
        p[j]=tmp;
      }
    }
  }

  for(i=0; i<k; i++){
    total+=p[i];
  }

  printf("%d", total);

  return 0;
}


Measured memory_bytes: 1728
#include <algorithm>
#include <iostream>
#include <vector>

using namespace std;
using ll = long long;

int main() {
  ll N, S{}, ans{1};
  cin >> N;
  vector<ll> A(N);
  for (ll &a : A) cin >> a, S += a;
  sort(rbegin(A), rend(A));
  for (int i = 0; i < N - 1; ++i) {
    S -= A[i];
    if (A[i] <= 2 * S) ++ans;
    else break;
  }
  cout << ans << endl;
}


Measured memory_bytes: 4008
/* ex4_1
    fmuacshai */

#include<stdio.h>
#include<math.h>
int main (void){
    //木の本数をtree_numとして、見える範囲をtree_distaceとする
    double tree_num,tree_distace;
    //必要な人の数をpeople_numとする
    int people_num;
    //tree_numを入力
    scanf("%lf",&tree_num);
    //tree_distaceを入力
    scanf("%lf",&tree_distace);
    //people_numの計算（1人(tree_distace*2+1)本の木を見れる）余った木はもう1人//
    people_num=ceil(tree_num/(tree_distace*2+1));
    //people_numを出力
    printf("%d\n",people_num);
    return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <stack>
#include <queue>
#include <algorithm>
#include <string>
#include <bitset>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <sstream>
#include <fstream>
#include <string.h>

#define X first
#define Y second
#define MP make_pair
#define FOR(i, n) for(int i = 0; i < n; i++)
typedef long long ll;
using namespace std;
const int MAX = 101;

template<class T, class U>
void convert(T &t, U &u){
    stringstream ss;
    ss << t;
    ss >> u;
}

double compute(double a, double b){
	double s    = ((a*2)+(b*2))/2;
	double tmp1 = (a*a+b*b)*(a*b+a*b)*(a*b+a*b);
	double tmp2 = (s-a)*(s-b)*(s-a)*(s-b);
	double res  = sqrt(tmp1/tmp2)/4;
	return res;
}

int main(){
	int t, y, h;
	while(cin >> t >> y >> h && t|y|h){
		int n;
		cin >> n;
		FOR(i, n){
			int  cir = 0;
			bool f   = false;
			cin >> cir;
			if(compute(t, y)<cir) f = true;
			if(compute(t, h)<cir) f = true;
			if(compute(y, h)<cir) f = true;

			if(f) cout << "OK" << endl;
			else cout << "NA" << endl;
		}
	}

	return 0;
}

Measured memory_bytes: 1156
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Numerics;
using static System.Console;
using static System.Math;
using static System.Array;

class Program
{
    public static void Main()
    {
        var n = ReadLine().Split().Select(int.Parse).ToArray();
        var a = ReadLine().Split().Select(int.Parse).ToArray();
        for(int i = 0; i < n[0] - n[1]; i++)
        {
            if(a[i] < a[i + n[1]])
                WriteLine("Yes");
            else
                WriteLine("No");
        }
        ReadLine();
    }
}


Measured memory_bytes: 44536
#include <map>
#include <string>
#include <iostream>

using namespace std;

int main()
{
	map<char, char> converse;

	for (char i = 'A'; i <= 'Z'; i++)
	{
		converse[i] = i - 3;
	}

	converse['A'] = 'X';
	converse['B'] = 'Y';
	converse['C'] = 'Z';

	string S;

	cin >> S;

	for (int i = 0; i < S.size(); i++)
	{
		cout << converse[S[i]];
	}

	cout << endl;
}

Measured memory_bytes: 3160
#include<iostream>
#include<string>
#include<vector>
#include<queue>
#include<algorithm>
#include<map>
#include<set>
#include<cmath>
typedef long long ll;
#define rep(i,n) for(int i=0;i<(n);i++)
using namespace std;

int main() {
	int n;
	ll x;
	cin >> n >> x;
	vector<ll> a(n);
	rep(i, n) cin >> a[i];
	ll ans = 0;
	rep(i, n - 1) {
		ll cnt = (a[i] + a[i + 1]) - x;
		if (cnt <= 0) continue;
		if (a[i + 1] >= cnt) {
			ans += cnt;
			a[i + 1] -= cnt;
		}
		else {
			a[i + 1] = 0;
			ans += cnt;
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 1024
#include "bits/stdc++.h"
using namespace std;
#define Rep(i,n) for(int i=0;i<(int)(n);i++)
#define For(i,n1,n2) for(int i=(int)(n1);i<(int)(n2);i++)
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define RREP(i,n) for(ll i=((ll)(n)-1);i>=0;i--)
#define FOR(i,n1,n2) for(ll i=(ll)(n1);i<(ll)(n2);i++)
#define RFOR(i,n1,n2) for(ll i=((ll)(n1)-1);i>=(ll)(n2);i--)
#define all(a)  (a).begin(),(a).end()
#define SORT(a) sort((a).begin(),(a).end())
#define oorret 0
#define oor(x) [&](){try{x;} catch(const out_of_range& oor){return oorret;} return x;}()
#define IOS cin.tie(0),ios::sync_with_stdio(false)
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
template<typename T1, typename T2> inline bool chmin(T1& a, T2 b) { if (a > b) { a = b; return 1; }return 0; }
template<typename T1, typename T2> inline bool chmax(T1& a, T2 b) { if (a < b) { a = b; return 1; }return 0; }
template<class Type>struct is_vector : std::false_type {};
template<class ValueType, class Alloc>struct is_vector<std::vector<ValueType, Alloc>> : std::true_type {};
template <typename T> inline ostream& operator << (ostream& out, const vector<T>& v) {
    if (v.empty())return out;
    constexpr bool is_vector_v = is_vector<T>::value;
    if (is_vector_v)for (auto itr = v.begin(); itr != v.end();)out << (*itr), out << ((++itr != v.end()) ? "\n" : "");
    else for (auto itr = v.begin(); itr != v.end();)out << (*itr), out << ((++itr != v.end()) ? " " : "");
    return out;
}
inline void put() {}
template<class T> inline void put(const T& first) { std::cout << first<<"\n"; }
template<class T, class... N> inline void put(const T& first, const N& ... rest) { std::cout << first << " "; put(rest...); }
inline void putn() {}
template<class T, class... N> inline void putn(const T& first, const N& ... rest) { std::cout << first << "\n"; putn(rest...); }


int main(){
    int n,k;
    cin >> n >> k;
    string s;
    cin >> s;
    int c = 0;
    REP(i,n-1){
        if(s[i]!=s[i+1]){
            c++;
        }
    }
    if(c<=k*2){
        put(n-1);
    }else{
        int t = c-k*2;
        put(n-t-1);
    }
    return 0;
}


Measured memory_bytes: 768
#include <iostream>
#include <algorithm>
#include <cmath>
using namespace std;

int main() {
	int N;
	cin >> N;
	double T, A, min_dif;
	cin >> T >> A;
	int point;
	for (int i = 0; i < N; i++) {
		double tmp;
		cin >> tmp;
		if (i == 0) {
			min_dif = fabs(A - (T - tmp * 0.006));
			point = i + 1;
		}
		double pre = min_dif;
		min_dif = min(min_dif, fabs(A - (T - tmp * 0.006)));
		if (min_dif != pre) point = i + 1;
	}

	cout << point << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
	int t;
	//cin>>t;
	t=1;
	while(t--)
	{
        int n;
        cin>>n;
        int x=1000-n%1000;
        if(x==1000)
        cout<<0<<endl;
        else cout<<x<<endl;
	}
	
}

Measured memory_bytes: 3604