akhauriyash/Code-Regression huggingface dataset:
#include <iostream>

using namespace std;

const int INF = 100000000;
int c[10][10] = {0};
int d[10] = {0};

void bellman_ford(int s) {
    d[s] = 0;
    for (int i = 0; i < 10; i++) {
        for (int j = 0; j < 10; j++) {
            for (int k = 0; k < 10; k++) {
                if (j == k) continue;
                int cost = c[k][j];
                if (d[j] != INF && d[k] > d[j] + cost) {
                    d[k] = d[j] + cost;
                }
            }
        }
    }
}

int main() {
    int H, W;
    int t, ans = 0;

    cin >> H >> W;

    for (int i = 0; i < 10; i++) {
        for (int j = 0; j < 10; j++) {
            cin >> c[i][j];
        }
    }
    for (int i = 0; i < 10; i++) {
        d[i] = INF;
    }

    bellman_ford(1);

    for (int i = 0; i < W; i++) {
        for (int j = 0; j < H; j++) {
            cin >> t;
            if (t != -1) {
                ans += d[t];
            }
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>

int integrateX2(int d) {
	static const int iBegin = 0, iEnd = 600;
	int sum = 0;
	for (int x = iBegin; x < iEnd; x += d) {
		sum += x * x * d;
	}
	return sum;
}

int main() {
	int d;
	while (std::cin >> d) {
		std::cout << integrateX2(d) << '\n';
	}
	return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
#include <math.h>
#define _GLIBCXX_DEBUG
using namespace std;
int main() {
  
  vector<int> vec(3);
  cin>>vec[0]>>vec[1]>>vec[2];
  
  sort(vec.begin(),vec.end());
  
  cout<<vec[2]-vec[0]<<endl;
}

Measured memory_bytes: 3556
#include"bits/stdc++.h"
using namespace std;
typedef long long ll;

int main(void) {
	int n, p;
	int Min = 200001, ans = 0;
	cin >> n;
	for (int i = 0; i < n; ++i) {
		cin>>p;
		Min = min(Min, p);
		if (p <= Min) {
			++ans;
		}
	}
	cout << ans;
}
/*
0 1 2 3 4 5
    1   1  
*/

Measured memory_bytes: 256
// In the name of Allah the Most Merciful.

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

typedef long long ll;

vector<int>v[26];

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

    string ar , br;
    cin >> ar >> br;
    for(int i=0;i<ar.size();i++){
        v[ar[i]-'a'].push_back(i+1);
    }
    bool check = true;
    for(int i=0;i<br.size();i++){
        if(v[br[i]-'a'].size()==0)check = false;
    }
    if(check){
        ll ans = 0 , now = -1;
        for(int i=0;i<br.size();i++){
            int ch = br[i]-'a';
            if(upper_bound(v[ch].begin() , v[ch].end() , now)==v[ch].end()){
                now = -1;
                ans++;
            }
            now = *upper_bound(v[ch].begin() , v[ch].end() , now);
        }
        cout << ans*(ll)ar.size()+now << endl;
    }
    else{
        cout << -1 << endl;
    }

    return 0;
}


Measured memory_bytes: 1228
# ΣnCiが高速に計算できればいいがNがでかい -> なんかΣncrでググったら高速化できるらしい?
# なんかi=0 -> i=nで2^nになるらしい。これは繰り返し二乗法でいけそう

# 最終的にΣnCi(i=1, i<=n) - nCa - nCaができればいい

# なぜか手持ちのライブラリがことごとくダメ

n, a, b = map(int, input().split())
mod = 10**9 + 7


def rep(i, n):
    if n == 0:
        return 1
    if n % 2 == 0:
        tmp = rep(i, n // 2) % mod
        return tmp * tmp % mod
    else:
        return i * rep(i, n - 1) % mod


# なぜかうまくいかない
# def ncr(n, r):
#     res = 1
#     for i in range(1, r + 1):
#         res = res * (n - i + 1) // i
#         res %= mod
#     for i in range(2, r + 1):
#         res *= rep(i, mod - 2)
#         res %= mod
#     return res

# なぜかうまくいかない
# def cmb(n, r, mod):
#     if (r < 0 or r > n):
#         return 0
#     g1 = [1, 1]  # 元テーブル
#     g2 = [1, 1]  #逆元テーブル
#     inverse = [0, 1]  #逆元テーブル計算用テーブル
#     N = 10**6  # なんでだろうね
#     for i in range(2, N + 1):
#         g1.append((g1[-1] * i) % mod)
#         inverse.append((-inverse[mod % i] * (mod // i)) % mod)
#         g2.append((g2[-1] * inverse[-1]) % mod)
#     return g1[n] * g2[r] * g2[n - r] % mod


# なぜかうまくいく
def nCrMod(n, r, p):
    ret = 1
    # 分子
    for i in range(n - r + 1, n + 1):
        ret *= i
        ret %= p
    # 分母
    for i in range(2, r + 1):
        # ret //= i なんかこれがおかしい（なんでだろうね）
        ret *= rep(i, p - 2)  # なぜかここでやらないと駄目だった
        ret %= p
    # ret = repMod(ret, p - 2, p) # なぜかここでやると駄目だった
    return ret % p


ans = (rep(2, n) - 1 - nCrMod(n, a, mod) - nCrMod(n, b, mod)) % mod  # なぜかうまくいく
# ans = (rep(2, n) - 1 - ncr(n, a) - ncr(n, b)) % mod なぜかうまくいかない
# ans = (rep(2, n) - 1 - cmb(n, a, mod) - cmb(n, b, mod)) % mod なぜかうまくいかない
while ans < 0:
    ans += mod
print(ans)


Measured memory_bytes: 82892
#include <iostream>
#include <stdio.h>
#include <memory.h>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <string>
#include <algorithm>
#include <set>
#include <cmath>
using namespace std;
typedef long long ll;
const int oo=1000000000;
vector<int> v;
int n,a,b;
int ans=1e9,x;
bool check(ll d){
	ll cur=0;
	for(int i=0;i<v.size();i++)
		if(v[i]>d*b)
			cur+=(v[i]-d*b+a-b-1)	/(a-b);
	if(cur>d)
		return 0;
	return 1;
}
int main(){

	cin>>n>>a>>b;
	for(int i=0;i<n;i++){
		scanf("%d",&x);
		v.push_back(x);
	}
	int l=0,r=1000000000,m;
	while(l<=r){
		m=(l+r)/2;
		bool ch=check((ll)m);
		if(ch){
			ans=min(ans,m);
			r=m-1;
		}
		else 
			l=m+1;
	}
	printf("%d",ans);
	return 0;
}	


Measured memory_bytes: 892
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep2(i, x, n) for(int i = x; i <= n; i++)
#define rep3(i, x, n) for(int i = x; i >= n; i--)
#define elif else if
#define sp(x) fixed << setprecision(x)
#define pb(x) push_back(x)
#define all(x) x.begin(), x.end()
using ll = long long;
using ld = long double;
using pii = pair<int, int>;
using pil = pair<int, ll>;
using pli = pair<ll, int>;
using pll = pair<ll, ll>;
const ll MOD = 1e9+7;
//const ll MOD = 998244353;
const int inf = 1e9;
const ll INF = 1e18;
const ld EPS = 1e-10;

int main(){
    int N;
    cin >> N;
    pll p[N];
    ll M[N+1], m[N+1];
    M[0] = 0, m[0] = INF;
    rep(i, N){
        cin >> p[i].first >> p[i].second;
        if(p[i].second < p[i].first) swap(p[i].first, p[i].second);
    }
    sort(p, p+N);
    rep(i, N){
        M[i+1] = max(M[i], p[i].second);
        m[i+1] = min(m[i], p[i].second);
        //cout << M[i+1] << ' ' << m[i+1] << endl;
    }
    ll ans = (p[N-1].first-p[0].first)*(M[N]-m[N]);
    //要素の最大と最小の差
    ll x = M[N]-p[0].first;
    rep(i, N-1){
        ll t = max(M[i+1], p[N-1].first);
        ll s = min(p[i+1].first, m[i+1]);
        ans = min(ans, (t-s)*x);
    }
    cout << ans << endl;
}

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

 using namespace std;
 typedef long long ll;

 int main() {
   int N, sum_a = 0;
   double average;
   cin >> N;
   vector<int> a(N);
   for (int i = 0; i < N; i++) {
     cin >> a.at(i);
     sum_a += a.at(i);
   }
   average = (sum_a * 1.0) / (N * 1.0);

   double min_ave = 100;
   int ans;

   for (int i = 0; i < N; i++) {
     if (fabs(a.at(i) - average) < min_ave) {
       min_ave = fabs(a.at(i) - average);
       ans = i;
     }
   }
   cout << ans << endl;
 }


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, a, b) for (int i = a; i < b; i++)
int main()
{

    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);

    int n;
    cin >> n;
    vector<ll> a(n);
    rep(i, 0, n)
    {
        cin >> a[i];
    }
    sort(a.begin(), a.end());
    ll m = a[0];
    int idx = 0;
    while (true)
    {
        bool ok = true;
        ll tmpm = m;
        rep(i, 0, n)
        {
            if (a[i] == tmpm)
                continue;

            a[i] = a[i] % tmpm;
            if (a[i] != 0)
            {
                if (m > a[i])
                {
                    m = a[i];
                    ok = false;
                }
            }
        }
        if (ok)
        {
            break;
        }
        a.erase(remove(a.begin(), a.end(), 0), a.end());
    }

    cout << m << endl;
    return 0;
}


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

using namespace std;

#define FOR(i, N) for (int i = 0; i < (int)N; i++)
#define FORIN(i, a, b) for (int i = a; i < (int)b; i++)
#define ALL(x) (x).begin(), (x).end()
#define MOD 1000000007
#define INF (1 << 29)
#define LLINF (1LL << 60)
#define DEBUG(...) debug(__LINE__, ":" __VA_ARGS__)

using Pi = pair<int, int>;
using ll = long long;

string to_string(string s) { return s; }
template <class S>
string to_string(unordered_set<S> s);
template <class S>
string to_string(set<S> s);
template <class S, class T>
string to_string(map<S, T> m);
template <class T>
string to_string(vector<T> v);

template <class S, class T>
string to_string(pair<S, T> p) {
  return "{" + to_string(p.first) + "," + to_string(p.second) + "}";
}

template <class S>
string to_string(unordered_set<S> s) {
  string ret = "{";
  for (S x : s) ret += to_string(x) + ",";
  return ret + "}";
}

template <class S>
string to_string(set<S> s) {
  string ret = "{";
  for (S x : s) ret += to_string(x) + ",";
  return ret + "}";
}

template <class S, class T>
string to_string(map<S, T> m) {
  string ret = "{";
  for (pair<S, T> x : m) ret += to_string(x) + ",";
  return ret + "}";
}

template <class T>
string to_string(vector<T> v) {
  string ret = "{";
  for (int i = 0; i < (int)v.size() - 1; ++i) {
    ret += to_string(v[i]) + ",";
  }
  if (v.size() > 0) {
    ret += to_string(v.back());
  }
  ret += "}";
  return ret;
}

void debug() { cerr << endl; }

template <class Head, class... Tail>
void debug(Head head, Tail... tail) {
  cerr << to_string(head) << " ";
  debug(tail...);
}

void print() { cout << endl; }

template <class Head, class... Tail>
void print(Head head, Tail... tail) {
  cout << to_string(head);
  print(tail...);
}

ll euclidean_gcd(ll a, ll b) {
  if (a < b) return euclidean_gcd(b, a);
  ll r;
  while ((r = a % b)) {
    a = b;
    b = r;
  }
  return b;
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(0);
  int N;
  cin >> N;
  vector<int> a(N);
  FOR(i, N) cin >> a[i];
  int ans = 0;
  int pt = 1;
  FOR(i, N) {
    if (pt != a[i]) {
      ans++;
    } else {
      pt++;
    }
  }
  cout << (ans == N ? -1 : ans) << endl;
  return 0;
}

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

int main()
{
    long long N;
    cin >> N;
    vector<vector<long long>> score(N, vector<long long>(3));
    vector<vector<long long>> dp(N + 1, vector<long long>(3, 0));

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

    for (int i = 0; i < N; i++)
    {
        for (int j = 0; j < 3; j++)
        {
            for (int k = 0; k < 3; k++)
            {
                if (j == k)
                    continue;

                dp.at(i + 1).at(j) = max(dp.at(i + 1).at(j), dp.at(i).at(k) + score.at(i).at(j));
            }
        }
    }

    long long ans = 0;
    ans = max(dp.at(N).at(0), dp.at(N).at(1));
    ans = max(ans, dp.at(N).at(2));

    cout << ans << endl;
}


Measured memory_bytes: 11136
#include<stdio.h>

int main(){

int n,input,max=0,min=0,i;
long sum=0;

scanf("%d",&n);

if(n==0){
 printf("undefined\n");
}else{
for(i=0;i<n;i++){
 scanf("%d",&input);
 if(i==0){
  min = input;
  max = input;
  sum = input;
 }else{
  if(max < input) max=input;
  if(input < min) min=input;
  sum += input;
 }
}

printf("%d %d %ld\n",min,max,sum);
}
return 0;

}


Measured memory_bytes: 2108
//ITP 1_10_B

#include<iostream>
#include<cmath>
using namespace std;

int main(){
    int a, b, c;
    double S, L, h, pi, radc;
    cin >> a >> b >> c;

    pi = acos(-1);
    radc = c * pi/180;

    S = 1.0/2 * a * b * sin(radc);
    L = a + b + sqrt(a*a + b*b - 2.0*a*b*cos(radc));
    h = 2.0 * S / a; 
    
    cout << fixed << S << endl;
    cout << fixed << L << endl;
    cout << fixed << h << endl;

    return 0;
}


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

using namespace std;

int n;
vector<int> x[20], y[20];

int v[20];

int main() {
	cin >> n;

	for(int i = 0; i < n; i++) {
		int a;
		cin >> a;
		x[i].resize(a), y[i].resize(a);
		for(int j = 0; j < a; j++) {
			cin >> x[i][j] >> y[i][j];
			x[i][j]--;
		}
	}
	int ans = 0;

	for(int b = 1; b < (1 << n); b++){
		memset(v, -1, sizeof v);

		queue<int> q;
		for(int i = 0; i < n; i++) {
			if(b >> i & 1) {
				q.push(i);
				v[i] = 1;
			}
		}

		bool ok = true;
		while(!q.empty() and ok) {
			int i = q.front(); q.pop();
			for(int j = 0; j < (int)x[i].size(); j++) {
				if(y[i][j] == 0) {
					if(v[ x[i][j] ] == 1) ok = false;
					v[ x[i][j] ] = 0;
				}
				else {
					if(v[ x[i][j] ] == 0) ok = false;
					else if(v[ x[i][j] ] == -1) {
						v[ x[i][j] ] = 1;
						q.push(x[i][j]);
					}
				}
			}
		}
		if(ok) ans = max(ans, __builtin_popcount(b));
	}

	printf("%d\n", ans);
}


Measured memory_bytes: 256
#define _USE_NATH_DEFINES
#include<cstdio>
#include <iostream>
#include<sstream>
#include<fstream>
#include<iomanip>
#include<algorithm>
#include<cmath>
#include<complex>
#include <string>
#include<vector>
#include<list>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<bitset>
#include<numeric>
#include<limits>
#include<climits>
#include<cfloat>
#include<functional>
#include<iterator>
#define REP(i,m,n) for(int i=(int)m ; i < (int) n ; ++i )
#define rep(i,n) REP(i,0,n)
using namespace std;

int main() {
	int a, b, c, d;
	cin >> a >> b >> c >> d;
	int lower = max(a,c);
	int upper = min(b,d);
	cout << max(0,upper- lower) << endl;
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scn = new Scanner(System.in);
		String line = scn.nextLine();
		int length = line.length();
		String S[] = line.split("");
		String answer = S[0].equals("0") ? "1" : "0";
		int count = 0;

		for(int i = 1;i < length;i++) {
			if(!S[i].equals(answer)) {
				count++;
			}
			answer = answer.equals("0") ? "1" : "0";
		}

		System.out.println(count);
	}
}


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

class Katana implements Comparable<Katana>{
	long a, b;
	public Katana(long _a, long _b) {
		a = _a; b = _b;
	}
	public int compareTo(Katana k) {
		return (int)(k.b - b);
	}
}
public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		long H = sc.nextInt();
		long max_A = 0, sum_B = 0;
		Katana[] kt = new Katana[N];
		for(int i = 0; i < N; i++) {
			kt[i] = new Katana(sc.nextInt(), sc.nextInt());
			max_A = Math.max(max_A, kt[i].a);
		}
		long ans = (H + max_A - (long)1) / max_A; // 何も投げない
		Arrays.sort(kt);

		for(int i = 0; i < N; i++) {
			sum_B += kt[i].b;
			if(H - sum_B < 0) {
				ans = Math.min(ans, (i + 1));
				break;
			}
			ans = Math.min(ans, (H - sum_B + max_A - (long)1) / max_A + (long)(i + 1));
		}
		System.out.println(ans);
	}
}

Measured memory_bytes: 89936
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define ALL(x) (x).begin(),(x).end()
#define LL long long

using namespace std;

int main(){

    LL a[7];
    REP(i,7)cin>>a[i];

    LL K=0;
    K+=a[1];

    LL Km =0;

    Km=(a[0]/2)*2+(a[3]/2)*2+(a[4]/2)*2;
    if(a[0]&&a[3]&&a[4]){
        a[0]--;a[3]--;a[4]--;
        Km = max(Km , 3+(a[0]/2)*2+(a[3]/2)*2+(a[4]/2)*2);
    }
    K+=Km;


    cout<<K<<endl;

    return 0;
}

Measured memory_bytes: 256
//Jai Bhole Ki
#include <bits/stdc++.h>
using namespace std;
#define fast static int fastline = []() { std::ios::sync_with_stdio(false); cin.tie(NULL); return 0; }();
#define ll long long
#define LL unsigned ll
#define pb push_back
#define pi pair<ll,ll>
#define debug(x) cout<<x<<"\n";
#define debug cout<<"debugged\n";
#define minval -2e9
#define maxval 2e9
long double PI =3.14159265358979323846;
 
const ll M=1e9+7;
const ll inf=1e18;
const ll ms=2e5+5;
fast;
ll ans,temp;
void solve()
{
    string s;cin>>s;
    for(int i=0;i<3;i++)
    {
        temp*=10;
        temp+=s[i]-'0';
    }ans=abs(753ll-temp);
    for(int i=3;i<s.size();i++)
    {
        temp=(temp%100)*10+s[i]-'0';
        
        ans=min(abs(753ll-temp),ans);
    }
    cout<<ans<<endl;
}
int main()
{
 // freopen("input.txt","r",stdin);
//  freopen("output.txt","w",stdout);
    //int t;cin>>t;while(t--)
    {
        solve();
    }
    return 0;
}

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

int main()
{
	string s;
	cin>>s;
	int a=(s[0]%48);
	int b=(a*10)+(s[1]%48);
	int c=((s[2]%48)*10)+(s[3]%48);
	
	 if(((b>=1)&&(b<=12))&&((c>=1)&&(c<=12)))
    {
        cout<<"AMBIGUOUS";
    }
    else if((b>=1)&&(b<=12))
        {
            cout<<"MMYY";
        }
    else if((c>=1)&&(c<=12))

        {
            cout<<"YYMM";
        }
        else
        {
            cout<<"NA";
        }
}

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

using namespace std;
typedef long long ll;

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

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

  if (a == b && b == c) cout << 1 << "\n";
  else if (a == b || a == c || b == c) cout << 2 << "\n";
  else cout << 3 << "\n";
}


Measured memory_bytes: 3628
#include <stdio.h>
#include <string.h>
#define max(a,b) ((a) > (b) ? (a) : (b))

int lcs(char *X, char *Y){
  int i, j;
  int c[1000 + 1][1000 + 1];
  int m, n;
  int maxl = 0;
  m = strlen(X) - 1;
  n = strlen(Y) - 1;
  //X--;  //Xのアドレスを左に一つずらす。
  //Y--;  //Yのアドレスを左に一つずらす。
  //(X+0) = ' ';  //Xの先頭アドレスには何もはいっていないから、空白を入れられる。
  // Y = ' ';  //Yの先頭アドレスには何もはいっていないから、空白を入れられる。
  for(i = 0; i <= m; i++) c[i][0] = 0;
  for(j = 1; j <= n; j++) c[0][j] = 0;
  //printf("%s",X);
  //X = strcat("0",X);//X = ' ' + X;
  //Y = strcat("0",Y);//Y = ' ' + Y;
  for(i = 1; i <= m; i++){
    for(j = 1; j <= n; j++){
      if(X[i] == Y[j]) c[i][j] = c[i - 1][j - 1] + 1;
      else c[i][j] = max(c[i - 1][j], c[i][j - 1]);

      maxl = max(maxl, c[i][j]);
    }
    }
  
  
  return maxl;
}

int main(){
  int n, i;
  char s1[1000], s2[1000];
  
  scanf("%d", &n);
  for(i = 0; i < n; i++){
  scanf("%s", s1+1);
  scanf("%s", s2+1);
  s1[0] = ' ';
  s2[0] = ' ';
  printf("%d\n", lcs(s1, s2));
  }
  
  return 0;
}



Measured memory_bytes: 5628
n, k = map(int, input().split())
v = list(map(int, input().split()))
u = v[::-1]
ans = 0

m = min(n, k)
for l in range(m + 1):
    for r in range(m - l + 1):
        s = v[:l] + u[:r]
        s.sort()
        for i in range(k - l - r + 1):
            ans = max(ans, sum(s[i:]))

print(ans)

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

using namespace std;

typedef long long ll;

const int N=1e5+5;

vector<int> a[N];

int main()
{

    char c;
    cin >> c;
    if(c=='A') printf("T\n");
    if(c=='G') printf("C\n");
    if(c=='C') printf("G\n");
    if(c=='T') printf("A\n");
    return 0;
}


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

int n, S[100010], q, key, cnt=0;

int search(){
  int left = 0, right = n, med;
  while(left < right){
    med = (left + right) / 2;
    if (S[med] == key) return 1;
    else if (S[med] < key) left = med + 1;
    else right = med;
  }
  return 0;
}

int main(){
  cin>>n;
  for(int i=0;i<n;i++) cin>>S[i];
  cin>>q;
  for(int i=0;i<q;i++){
    cin>>key;
    cnt += search();
  }
  cout<<cnt<<endl;
  return 0;
}



Measured memory_bytes: 3456
# -*- coding: utf-8 -*-

N, M = map(int, input().split())
k = [None] * N
a = [None] * N
for i in range(N):
    ka = list(map(int, input().split()))
    k[i] = ka[0]
    a[i] = ka[1:]

ans = 0
for i in range(1, M+1):
    count = 0
    for j in range(N):
        if i in a[j]:
            count += 1

    if count >= N:
        ans += 1

print(ans)


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

using namespace std;
LL p = 1000000007ll;

int main(void)
{
  LL a,b;
  cin >> a >> b;
  cout << max(max(a+b,a-b),a*b) << endl;
  return 0;
}


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

using namespace std;

typedef pair<string,string> P;
int ans;
map<string,bool> M;


void solve(string a, string b){
  vector<string> v1,v2;

  v1.push_back(a);
  v2.push_back(b);
  reverse(a.begin(),a.end());
  reverse(b.begin(),b.end());
  v1.push_back(a);
  v2.push_back(b);

  for(int i = 0; i < v1.size(); i++)
    for(int j = 0; j < v2.size(); j++)
      if(M[v1[i]+v2[j]] == false){
	//	cout << v1[i] << " " << v2[j] << endl;
	M[v1[i]+v2[j]] = true;
	ans++;
      }
  
  
  for(int i = 0; i < v2.size(); i++)
    for(int j = 0; j < v1.size(); j++)
	if(M[v2[i]+v1[j]] == false){
	  //cout << v2[i] << " " << v1[j] << endl;
	  M[v2[i]+v1[j]] = true;
	  ans++;
	}

}

void init(){
  ans = 0;
  M.clear();
}

int main(){

  int n;
  cin >> n;
  while(n--){
    init();
    string s;
    cin >> s;
    for(int i = 1; i < s.length(); i++){
      solve(s.substr(0,i),s.substr(i));
    }
    cout << ans << endl;
  }
  return 0;
}

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

int main(){
  
  int a[3], ans = 0;
  
  cin >> a[0] >> a[1] >> a[2];
  
  sort(a, a + 3);
  for(int i = 1;i < 3;i++) ans += a[i] - a[i - 1];
  
  cout << ans << endl;
  
  return 0;
}

Measured memory_bytes: 256
n, m = [int(x) for x in input().split()]

matrix = []
for i in range(n):
    l = [int(x) for x in input().split()]
    matrix.append(l)

vector = []
for i in range(m):
    t = int(input())
    vector.append(t)


for i in range(n):
    c = 0
    for j in range(m):
        c += matrix[i][j] * vector[j]
    print(c)

    
    


Measured memory_bytes: 6008
using System;
using System.Collections.Generic;
using System.Text;
using System.Numerics;
using System.IO;

namespace SolutionCS
{
    class Program
    {
        static void Main(string[] args)
        {
            string s = Console.ReadLine();
            int ans = 0;
            switch(s)
            {
                case "SUN": ans = 7; break;
                case "MON": ans = 6; break;
                case "TUE": ans = 5; break;
                case "WED": ans = 4; break;
                case "THU": ans = 3; break;
                case "FRI": ans = 2; break;
                case "SAT": ans = 1; break;
            }

            Console.WriteLine(ans);
        }
    }
}



Measured memory_bytes: 13152
#map(int, input().split())

from math import pi
from math import sqrt
from math import cos
A, B, H, M = map(int, input().split())

m_degree = M * (pi / 30)

real_h  = H + M/60
h_degree = real_h * (pi / 6)

l = sqrt(A**2 + B**2 - 2*A*B*cos(abs(m_degree-h_degree)))
print(l)

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

int main() {
	
	int n;
	cin >> n;
	vector<int> d(n);
	rep(i, n) cin >> d[i];
	
	int ans = 0;
	for(int i = 0; i < n - 1; i++){
		for(int j = i + 1; j < n; j++){
			ans += d[i] * d[j];
		}
	}
	cout << ans << endl;
	return 0;
}

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

int main() {
  int n;
  cin>>n;
  ll a[n];
  int count=0,b[100001]={0};
  rep(i,n){
    cin>>a[i];
    if(a[i]>100000) count++;
    else b[a[i]]++;
  }
  rep(i,100001){
    if(i<b[i]) count+=(b[i]-i);
    else if(i>b[i]) count+=b[i];
  } 
  
  cout<<count<<endl;

}

Measured memory_bytes: 1408
#include<stdio.h>
#include<string.h>
#include<queue>
using namespace std;
int a[11000];
int s[110][110];
int h,w,n;

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

queue<int>v;
void dfs(){
	int i=0,j=0;
	int k=0;int p=0;
	while(!v.empty()){
		s[i][j]=v.front();
		v.pop();
		if(i==h-1&&j==w-1){
			//printf("##%d ",p);
			p++;
		}
		else if(i==0&&j==w-1){
			//printf("##%d ",p);
			p++;
		}
		else if(i==h-1&&h!=1&&j==0){
			//printf("##%d ",p);
			p++;
		}
		else if(s[i+dx[p]][j+dy[p]]!=0){
			//printf("##%d ",p);
			p++;
		}
		p%=4;
		
		i=i+dx[p],j=j+dy[p];
	}
	
}

int main(){
	int t;
	
	scanf("%d %d",&h,&w);
	scanf("%d",&n);
	while(!v.empty())v.pop();
	for(int i=0;i<n;i++){
		scanf("%d",&t);
		while(t>0){
			v.push(i+1);
			t--;
		}
	}
	memset(s,0,sizeof(s));
	
	dfs();
	
	for(int i=0;i<h;i++){
		for(int j=0;j<w;j++){
			if(j)printf(" ");
			printf("%d",s[i][j]);
		}
		printf("\n");
	}
	
}

Measured memory_bytes: 384
import sys
input = sys.stdin.readline

a,b,c,d = map(int,list(input())[:4])


def add(x, y):
    return x+y

def sub(x, y):
    return x-y

def printans(a,b,c,d,op):
    ansstr = str(a)
    ansstr += '+' if op[0] == 0 else '-'
    ansstr += str(b)
    ansstr += '+' if op[1] == 0 else '-'
    ansstr += str(c)
    ansstr += '+' if op[2] == 0 else '-'
    ansstr += str(d)
    ansstr += '=7'

    print(ansstr)

ops = []
for i in range(2):
    for j in range(2):
        for k in range(2):
            ops.append((i, j, k))


for op in ops:
    ans = a
    for i,x in enumerate(op):
        if x == 0:
            if i == 0:
                ans = add(ans, b)
            if i == 1:
                ans = add(ans, c)
            if i == 2:
                ans = add(ans, d)
        else:
            if i == 0:
                ans = sub(ans, b)
            if i == 1:
                ans = sub(ans, c)
            if i == 2:
                ans = sub(ans, d)
    

    if ans == 7:
        printans(a,b,c,d,op)
        break



Measured memory_bytes: 3064
n = input()
p = [0 for row in range(101)]
m = [[0 for col in range(n+1)] for row in range(n+1)]
for i in range(1, n+1):
  p[i-1], p[i] = map(int, raw_input().split())

for l in range(2, n+1):
  for i in range(1, n-l+2):
    j = i + l - 1
    m[i][j] = 10000000000000000
    for k in range(i, j):
      if m[i][j]>m[i][k]+m[k+1][j]+p[i-1]*p[k]*p[j]:
        m[i][j] = m[i][k]+m[k+1][j]+p[i-1]*p[k]*p[j]

print m[1][n]

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

int main() {
    string S; 
    cin>>S;
    if(S=="AAA" || S=="BBB"){
        cout<<"No"<<endl;
    }else{
        cout<<"Yes"<<endl;
    }
    return 0;
};


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000
#define int long long
typedef pair<int, int> P;
int H, W;
string S[100];
int d[100][100];
int dx[4] = {0, 1, 0, -1};
int dy[4] = {1, 0, -1, 0};
int bfs() {
    queue<P> q;
    q.push({0, 0});
    rep(i, 100) rep(j, 100) d[i][j] = INF;
    d[0][0] = 1;
    while(q.size()) {
        P dot = q.front();
        q.pop();
        int x = dot.first;
        int y = dot.second;
        if (x == H - 1 && y == W - 1) return d[x][y];
        rep(i, 4) {
            int xx = x + dx[i];
            int yy = y + dy[i];
            if (xx < 0 || xx >= H) continue;
            if (yy < 0 || yy >= W) continue;
            if (S[xx][yy] == '#') continue;
            if (d[xx][yy] != INF) continue;
            d[xx][yy] = d[x][y] + 1;
            q.push({xx, yy});
        }
    }
    return INF;
}

signed main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> H >> W;
    int sharp = 0;
    rep(i, H) {
        cin >> S[i];
    }
    rep(i, H) rep(j, W) if (S[i][j] == '#') sharp++;
    if(bfs() == INF) {
        cout << -1 << endl;
        return 0;
    }
    cout << H * W - bfs() - sharp << endl;


    return 0;
}


Measured memory_bytes: 384
#include <cstdio>
#include <iostream>
#include <iomanip>
#include <string>
#include <queue>
#include <stack>
#include <vector>
#include <set>
#include <map>
#include <algorithm>
#include <utility>
#include <cmath>

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

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

int main(int argc, char const* argv[])
{
  string s, t;
  cin >> s >> t;
  sort(s.begin(), s.end());
  sort(t.begin(), t.end());
  reverse(t.begin(), t.end());
  if(s < t)cout << "Yes" << endl;
  else cout << "No" << endl;
	return 0;
}


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

ll gcd(ll a, ll b) {
	return(a % b == 0 ? b : gcd(b, a % b));
}

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

	int K;
	cin >> K;
	ll s = 0;
	for (int i = 1; i <= K; i++) {
		for (int j = 1; j <= K; j++) {
			for (int k = 1; k <= K; k++) {
				s += gcd(gcd(i, j), k);
			}
		}
	}
	cout << s << endl;
}


Measured memory_bytes: 3648
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <stdio.h>
#include <sstream>
#include <math.h>
#include <queue>
#include <map>
#include <set>
#include <ios>     // std::left, std::right
#include <iomanip> // std::setw(int), std::setfill(char)
using namespace std;


int main(){
int M1;
int M2;
int D1;
int D2;
cin>>M1>>D1;
cin>>M2>>D2;
if(M1!=M2){
  cout<<1<<"\n";
}
else{
  cout<<0<<"\n";
}
return 0;
}


Measured memory_bytes: 256
#define _DEBUG
#include "bits/stdc++.h"
#define CHOOSE(a) CHOOSE2 a
#define CHOOSE2(a0,a1,a2,a3,a4,x,...) x
#define debug_1(x1) cout<<#x1<<": "<<x1<<endl
#define debug_2(x1,x2) cout<<#x1<<": "<<x1<<", "#x2<<": "<<x2<<endl
#define debug_3(x1,x2,x3) cout<<#x1<<": "<<x1<<", "#x2<<": "<<x2<<", "#x3<<": "<<x3<<endl
#define debug_4(x1,x2,x3,x4) cout<<#x1<<": "<<x1<<", "#x2<<": "<<x2<<", "#x3<<": "<<x3<<", "#x4<<": "<<x4<<endl
#define debug_5(x1,x2,x3,x4,x5) cout<<#x1<<": "<<x1<<", "#x2<<": "<<x2<<", "#x3<<": "<<x3<<", "#x4<<": "<<x4<<", "#x5<<": "<<x5<<endl
#ifdef _DEBUG
#define debug(...) CHOOSE((__VA_ARGS__,debug_5,debug_4,debug_3,debug_2,debug_1,~))(__VA_ARGS__)
#else
#define debug(...)
#endif
#define rep(index,num) for(int index=0;index<(int)num;index++)
#define rep1(index,num) for(int index=1;index<=(int)num;index++)
#define brep(index,num) for(int index=(int)num-1;index>=0;index--)
#define brep1(index,num) for(int index=(int)num;index>0;index--)
#define scan(argument) cin>>argument
#define prin(argument) cout<<argument<<endl
#define kaigyo cout<<endl
#define eps 1e-7
#define mp(a1,a2) make_pair(a1,a2)
#define ALL(a) (a).begin(),(a).end()
#define rALL(a) (a).rbegin(),(a).rend()
typedef long long ll;
typedef long double ld;
using namespace std;
typedef pair<ll,ll> pll;
typedef pair<int,int> pint;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<pint> vpint;
typedef vector<pll> vpll;
ll INFl=(ll)1e+18+1;
int INF=1e+9+1;
int N,M;
ll K,A[200001],B[200001];
ll Asum[200001]={},Bsum[200001]={};
int main(){

	scan(N>>M>>K);
	rep(i,N) scan(A[i]);
	rep(i,M) scan(B[i]);
	rep(i,N) Asum[i+1]=Asum[i]+A[i];
	rep(i,M) Bsum[i+1]=Bsum[i]+B[i];
	int ans=0;
	rep(i,N+1){
		int anum=i;
		if(Asum[i]>K) continue;
		int bnum=upper_bound(Bsum,Bsum+M+1,K-Asum[i])-Bsum-1;
		ans=max(ans,anum+bnum);
	}
	prin(ans);
	return 0;
}


Measured memory_bytes: 9840
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, log2
from itertools import accumulate, permutations, combinations, product, groupby
from operator import itemgetter, mul
from copy import deepcopy, copy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
import numpy as np
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

boin = ["a", "e", "i", "o", "u"]
c = input()

if c in boin:
	print("vowel")
else:
	print("consonant")

Measured memory_bytes: 13680
#include <bits/stdc++.h>
using namespace std;
#define modulo 1000000007
#define mod(mod_x) ((((long long)mod_x+modulo))%modulo)
#define Inf 1000000000


int main(){
	
	int K,T;
	cin>>K>>T;
	
	int maxi = 0;
	for(int i=0;i<T;i++){
		int a;
		cin>>a;
		maxi = max(maxi,a);
	}
	
	vector<int> F(K,0);
	
	for(int i=0;i<K;i+=2){
		if(maxi==0)break;
		F[i] = 1;
		maxi--;
	}
	
	for(int i=((K%2==0)?K-1:K-2);i>=0;i-=2){
		if(maxi==0)break;
		F[i] = 1;
		maxi--;
	}
	int ans = 0;
	
	for(int i=1;i<K;i++){
		if(F[i]==1&&F[i-1]==1)ans++;
	}
	
	cout<<ans<<endl;
	
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
struct Fast {Fast() {std::cin.tie(0); ios::sync_with_stdio(false);}} fast;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using pii = pair<int, int>;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define mp make_pair
#define MOD 1000000007

int main() {
    int N, A, B; cin >> N >> A >> B;
    cout << min(N * A, B) << endl;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
typedef long long ll;
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;
#define ios ios_base::sync_with_stdio(0) ; cin.tie(0) ; cout.tie(0)
#define so sizeof
#define pb push_back
#define vl vector<ll>
#define el endl;cout.flush()
#define be begin()
#define fi first
#define se second
#define br break
#define sz size()
#define en end()
#define ro return 0
#define br break
#define con continue;
#define um unordered_map<ll,ll>
#define ms(x) memset(x , 0, so x)
#define all(x) (x).be , (x).en
#define rall(x) (x).rbegin() , (x).rend()
#define acc(x) accumulate((x).be , (x).en , 0ll)
#define forn(i,a,b) for(ll i=a;i<=b;++i)
#define forr(i,a,b) for(ll i=a;i<b;++i)
#define rng_58 mt19937 rng(chrono::steady_clock::now().time_since_epoch().count())
#define vll vector<pair<ll,ll> >
#define pll pair<ll,ll>
#define plll pair<ll,pair<ll,ll>>
#define plvl pair<pair<ll,ll> ,ll>
#define mp make_pair
int main()
{
    ios;
    ll n ;
    cin >> n ;
    vl v ;
    v.pb(0);
    forn(i ,  1,  n ){
       ll x ;
       cin >> x;
       v.pb(x);
    }
    v.pb(0);
    /// 0   1   3    2    4   0///
    ll left[n+2];
    ms(left) ;
    ll right[n+2];
    stack<pll > s ;
    s.push(make_pair(0 , 0));
    forn(i , 1 ,  n){
       ll curr = v[i] ;
       ll ind = -1 ;
       while(s.empty() == false){
        ll attop = s.top().second;
        if(attop > curr){
            s.pop();
        }
        else if(attop < curr){
            ind = s.top().first ;
            left[i] = ind ;
            s.push({i , curr});
            br;
        }
       }
    }
    forn(i  , 1 , n ){
       cerr << left[i] << " "  ;
    }
     ll diff[n+2];
     ms(diff) ;
     forn(i ,  1,  n ){
        diff[i] = i - left[i];
     }
     stack<pll > ss ;
     s = ss ;
     s.push({n+1  , 0 });
     for(ll i=n ;i>=1 ; --i){
        ll curr = v[i] ;
        ll ind = -1 ;
        while(s.empty() == false){
            ll attop = s.top().second ;
            if(attop > curr){
                s.pop();
            }
            else if(attop < curr){
                ind = s.top().first;
                right[i] = ind ;
                s.push({i , curr}) ;
                br ;
            }
        }
     }
     cerr << el ;
     forn(i , 1 , n ){
        cerr << right[i] << " " ;
     }
     cerr << el ;
     ll diff2[n+2];
     ms(diff2);
     forn(i , 1 , n ){
         diff2[i] = right[i] - i ;
     }
     ll res = 0 ;
     forn(i , 1 , n ){
       res = res + diff2[i] * diff[i] * v[i];
     }
     forn(i , 1 , n ){
        cerr << diff[i] << " " ;
     }
     cerr << el ;
     forn(i , 1 , n ){
        cerr << diff2[i] << " " ;
     }
     cerr << el ;
     cout << res << el ;
}























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

using namespace std;
#define pb push_back

typedef long long ll;


int n, k;
const int maxn = 16;
const ll MOD = 1e9+7;
ll a[maxn][maxn];
ll dp[1<<maxn];
ll val[1<<maxn];

//inline void add(ll& a, ll b){ a+=b; a%=MOD;};

int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0); cout.tie(0);
  cin >> n; int S = (1<<n)-1;
  for (int i = 0; i < n; i++)for (int j = 0; j < n; j++) cin >> a[i][j];

  for (int x = 0; x <= S; x++)
  {
    val[x] = 0ll;
    for(int i = 0; i < n; i++)for(int j = i+1; j < n; j++)
    if(((x>>i)&1) && ((x>>j)&1))  val[x] += a[i][j];
  }

  for (int x = 0; x <= S; x++)
  {
    dp[x] = val[x];
    for (int s = x; s; s=(s-1)&x)
    { //s = x'
        dp[x] = max(dp[x], dp[s]+dp[s^x]);
    }
  }
  //for (int x = 0; x <= S; x++) cout << dp[x] << endl;
  cout << dp[S] << endl;

  return 0;
}


Measured memory_bytes: 1280
#include <iostream>
#include <string>

using namespace std;
int main(){
    string s; cin >> s;
    int i;
    for(i=0;i<3;i++){
        if(s[i]=='7'){
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
}

Measured memory_bytes: 3592
#include <iostream>

using namespace std;

int main(){
	int n,T,i;
	cin >> n >> T;
	int b[n],a[n];
	long long ans=0;
	for(i=0;i<n;i++){
		cin >> b[i];
	}
	
	for(i=0;i<n-1;i++){
	a[i] = b[i+1]-b[i];
	}
	
	for(i=0;i<n-1;i++){
		if(a[i]>T){
			ans += T;
		}else{
			ans +=a[i];
		}
	}	
		ans += T;
	cout << ans << endl;
}

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

struct edge{
  int to;
  int cost;
};

using P = pair<int,int>;

const int MAX_N = 1e3;
const int INF = 1e9;
vector<edge> G[MAX_N];
vector<int> dist(MAX_N,INF);
vector<int> par(MAX_N,-1);

void dijkstra(int s){
  priority_queue<P,vector<P>,greater<P>> PQ;
  for(int i=0; i<MAX_N; i++){
    dist[i] = INF;
    par[i] = -1;
  }
  dist[s] = 0;
  PQ.push(P(0,s));
  
  while(PQ.size()){
    P p = PQ.top();
    PQ.pop();
    int v = p.second; //from
    if(dist[v] < p.first){ //現在わかっている距離が更新できない
      continue;
    }
    for(int i=0; i<G[v].size(); i++){
      edge e = G[v][i];
      if(dist[e.to] > dist[v] + e.cost){
        dist[e.to] = dist[v] + e.cost;
        par[e.to] = v;
        PQ.push(P(dist[e.to], e.to));
      }
    }
  }
}

vector<int> restore(int start, int end){
  int now = end;
  vector<int> use(0);
  use.push_back(end);
  while(par[now] != -1){
    use.push_back(par[now]);
    now = par[now];
  }
  //reverse(use.begin(),use.end());
  return use;
}


int main(){
  int N, M;
  cin >> N >> M;
  for(int i=0; i<M; i++){
    int a, b;
    cin >> a >> b;
    a--; b--;
    edge add;
    add.to = b;
    add.cost = 1;
    G[a].push_back(add);
  }
  
  bool flag = false;
  vector<int> ans(N+1);
  
  for(int i=0; i<N; i++){
    dijkstra(i);
    for(int j=0; j<N; j++){
      if(i == j){
        continue;
      }
      for(int k=0; k<G[j].size(); k++){
        if(G[j][k].to == i && dist[j] != INF){
          if(ans.size() > restore(i,j).size()){
            ans = restore(i,j);
            flag = true;
          }
        }
      }
    }
  }
  
  if(flag){
    cout << ans.size() << endl;
    for(int i=0; i<ans.size(); i++){
      cout << ans[i]+1 << endl;
    }
  }
  else{
    cout << -1 << endl;
  }
  
  
}



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

int main() {
	cout << fixed << setprecision(10);
	int n;
	cin >> n;
	if (n % 2 == 0)cout << 0.5 << endl;
	else cout << (double)(n/2+1)/n << endl;
}

Measured memory_bytes: 256
n = int(input())
csf=[]
for _ in range(n-1):
    csf.append(list(map(int,input().split())))
for i in range(n):
    t=0
    for j in range(i,n-1):
        if t<csf[j][1]:
            t = csf[j][1]
        elif t%csf[j][2]!=0:
            t = t+csf[j][2]-t%csf[j][2]
        t += csf[j][0]
    print(t)


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

using namespace std;
int main()
{
    int n,inR,disR;
    cin>>n>>disR;
    if(n>=10)
    {
        inR=disR;
    }
    else if(n<10)
    {

     inR=disR+100*(10-n);
    }
    cout<<inR<<endl;
    return 0;
}


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

#define MOD 998244353

#define MIN(a,b) ((a)<(b)?(a):(b))
#define MAX(a,b) ((a)>(b)?(a):(b))

int compare_int(const void *a,const void *b){
    return *(int*)b - *(int*)a;
}


typedef long long int64;

int main(void){
    int N;
    int ans=0;
    scanf("%d",&N);
    int V[N],C[N];
    for(int i=0;i<N;i++){
       scanf("%d",&V[i]);
     }
     for(int i=0;i<N;i++){
       scanf("%d",&C[i]);
     }
     int comp[N];
    for(int i=0;i<N;i++){
            comp[i]=V[i]-C[i];
    }

    qsort(comp,N,sizeof(int),compare_int);
  
     
    
    
    for(int i=0;comp[i]>0;i++){
        ans+=comp[i];
    }
    printf("%d",ans);
    return 0;
}

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

int n;
int w[100010];

int main () {

	cin >> n;
	string s;
	cout << "0\n";
	cin >> s;
	if (s == "Male") w[0] = 1;
	else if (s == "Female") {w[0] = 2;}
	else {return 0;}
	cout << n-1 << "\n";
	cin >> s;
	if (s == "Male") w[n-1] = 1;
	else if (s == "Female") {w[n-1] = 2;}
	else {return 0;}
	
	int l = 0, r = n-1;
	while (1) {
		int mid = (l + r + 1) / 2;
		cout << mid << "\n";
		cin >> s;
		if (s == "Vacant") return 0;
		else if (s == "Male") {
			w[mid] = 1;
		}
		else {
			w[mid] = 2;
		}
		
		if (( (mid - l) % 2 == 0 && w[mid] != w[l]) || ( (mid - l) % 2 == 1 && w[mid] == w[l])) {
			r = mid;
		}
		else {
			l = mid;
		}
	}

	return 0;
}

Measured memory_bytes: 852
#include <stdio.h>
#include <stdlib.h>
#define MAX 2000001
#define VMAX 10000

int main(){
  unsigned short *A, *B;
  int C[VMAX+1];
  int n, i, j,k = 0;

  scanf("%d", &n);

  A = malloc(sizeof(short)*n+1);
  B = malloc(sizeof(short)*n+1);

  for(i = 1;i <= n;i++)
    {
      scanf("%d",&A[i]);
    }
  /*for(i = 1;i <= n;i++)
    {
      printf("%d",A[i]);
      }*/

  for(i = 1;i <= n;i++)
    {
      if(k < A[i])
	{
	  k = A[i];
	}
    }

  /* your code */
  for(i = 0;i <= k;i++)
    {
      C[i]=0;
    }

  for(j = 1;j <= n;j++)
    {
      C[A[j]]++;
    }

  for(i = 1;i <= k;i++)
    {
      C[i] = C[i] + C[i - 1];
    }

  for(j = n;j >= 1;j--)
    {
      B[C[A[j]]] = A[j];
      C[A[j]]--;
    }

  for(i = 1;i <= n;i++)
    {
      printf("%d",B[i]);
      if(i != n)
	{
	  printf(" ");
	}
    }
  

  printf("\n");

  return 0;
}



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

int main(){
    int n,a;
    cin >> n;
    bool t=true;
    for(int i=0;i<n;i++){
        cin >> a;
        if(a%2==0){
            if(a%3==0||a%5==0){

            }else{
                t=false;
            }
        }
    }
    if(t){
        cout << "APPROVED" << endl;
    }else{
        cout << "DENIED" << endl;
    }
    
    
}

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

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

    int N, M; cin >> N >> M;
    int max = M / N;

    for (int i = max; i > 0; --i) {
        if (M % i == 0) {
            cout << i;
            return 0;
        }
    }
    cout << 1;
    return -1;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<stack>
#include<queue>
#include<cstdio>
#include<climits>
#include<cmath>
#include<cstring>
#include<string>
#include<complex>

#define EPS (1e-10)
using namespace std;
#define PI (3.1415926535)

int main(){
	double x[4], y[4];
	bool left, right;
	double ax, ay, px, py;

	while(1){
		for(int i = 0; i < 4; i++){
			if(!(cin >> x[i] >> y[i])){
				return 0;
			}
		}

		left = false;
		right = false;
		for(int i = 0; i < 3; i++){
			ax = x[(i+1)%3]-x[i];
			ay = y[(i+1)%3]-y[i];
			px = x[3] - x[i];
			py = y[3] - y[i];
			if( ax*py-px*ay < 0){
				right = true;
			}else{
				left = true;
			}
		}

		if(left^right){
			cout << "YES" << endl;
		}else{
			cout << "NO" << endl;
		}
	}

	return 0;
}

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

using namespace std;
typedef long long ll;

int main() {
    int n;
    cin >> n;
    string s[100];
    int p[100];
    int ans[100];
    for(int i=0;i<n;i++){
        cin >> s[i] >> p[i];
        ans[i] = i;
    }

    for(int i=0; i<n-1;i++){
        for(int j=i;j<n;j++){
            if(s[ans[i]]>s[ans[j]]){
                swap(ans[i],ans[j]);
            }
        }
    }
    for(int i=0; i<n-1;i++){
        for(int j=i;j<n;j++){
            if(s[ans[i]] == s[ans[j]] and p[ans[i]] < p[ans[j]] ){
                swap(ans[i],ans[j]);
            }
        }
    }

    for(int i=0;i<n;i++){
        cout << ans[i]+1 <<endl;
    }



  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#define MAX 999999
using namespace std;

int main(void){
  int num,cnt;
  bool is_prime[MAX];

  for( int i = 0 ; i <= MAX ; i++ ) is_prime[i] = true;
  is_prime[0] = is_prime[1] = false;

  for( int i = 2 ; i*i <= MAX ; i++ ){
    if( is_prime[i]){
      for( int j = 2*i ; j <= MAX ; j += i ){
	is_prime[j] = false;
      }
    }
  }

  while(scanf("%d" ,&num) != EOF){
    cnt = 0;
    for( int i = 2 ; i <= num ; i++ ){
      if( is_prime[i] ) cnt++;
    }
    cout << cnt << endl;

  }
  return 0;
}

Measured memory_bytes: 2184
#include<iostream>
using namespace std;
int main()
{
  int n;
  cin>>n;
  int a[n];
  for(int i=0;i<n;i++)
    cin>>a[i];
  int count=0;
  for(int i=1;i<=n;i++)
  {
    if((i%2!=0)&&(a[i-1]%2!=0))
      count++;
  }
  cout<<count;
}

Measured memory_bytes: 3632
A = []
for i in range(3):
  A.append([int(i) for i in input().split()])

N = int(input())
ans = "No"

for i in range(N):
  B = int(input())
  for j in range(len(A)):
    for k in range(len(A[0])):
      if A[j][k] == B:
        A[j][k] = -1

# tate
for i in range(3):
  if A[0][i] == -1 and A[1][i] == -1 and A[2][i] == -1:
    ans = "Yes"
# yoko
for i in range(3):
  if A[i][0] == -1 and A[i][1] == -1 and A[i][2] == -1:
    ans = "Yes"

# naname
if A[0][0] == -1 and A[1][1] == -1 and A[2][2] == -1:
  ans = "Yes"

if A[2][0] == -1 and A[1][1] == -1 and A[0][2] == -1:
  ans = "Yes"

print(ans)


Measured memory_bytes: 3064
import sys

while True:
    h, w = map(int, sys.stdin.readline().split(' '))
    if h == 0 and w == 0:
        break

    for i in range(h):
        for j in range(w):
            sys.stdout.write('#' if (i+j) % 2 == 0 else '.')
        print ''
    print ''

Measured memory_bytes: 6432
N_ko, M_hon = map(int, input().split())
Heights = list(map(int, input().split()))

indexs=[]

for i in range(M_hon):
    a, b = map(int, input().split())
    a -= 1
    b -= 1

    h_a = Heights[a]
    h_b = Heights[b]


    if (h_a > h_b):
        indexs.append(b)

    elif (h_b > h_a):
        indexs.append(a)
    
    else:
        indexs.append(a)
        indexs.append(b)

ans = N_ko - len(set(indexs))

print(ans)

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

#if DEBUG
template <typename T>
void debug(const T& value) {
  std::cerr << value;
}
template <typename T, typename... Ts>
void debug(const T& value, const Ts&... args) {
  std::cerr << value << ", ";
  debug(args...);
}
#define dbg(...)                        \
  do {                                  \
    cerr << #__VA_ARGS__ << ": ";       \
    debug(__VA_ARGS__);                 \
    cerr << " (L" << __LINE__ << ")\n"; \
  } while (0)
#else
#define dbg(...)
#endif

void read_from_cin() {}
template <typename T, typename... Ts>
void read_from_cin(T& value, Ts&... args) {
  std::cin >> value;
  read_from_cin(args...);
}
#define rd(type, ...) \
  type __VA_ARGS__;   \
  read_from_cin(__VA_ARGS__);

template <typename T>
void write_to_cout(const T& value) {
  std::cout << value << '\n';
}
template <typename T, typename... Ts>
void write_to_cout(const T& value, const Ts&... args) {
  std::cout << value << ' ';
  write_to_cout(args...);
}
#define wt(...) write_to_cout(__VA_ARGS__);

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

using ll = long long;

template <typename T>
using V = std::vector<T>;
template <typename T>
using VV = V<V<T>>;

using namespace std;

int main() {
  rd(int, a, b, x);
  wt(a <= x && x <= a + b ? "YES" : "NO");
}


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

const int array_max = 1000005;
int main(void) {
    int n;
    int a;
    int b;
    int c;

    int dp_a = 0;
    int dp_b = 0;
    int dp_c = 0;

    int i;
    cin >> n;

    for(i = 0; i < n; i++) {
        cin >> a >> b >> c;
        a += dp_a;
        b += dp_b;
        c += dp_c;
        dp_a = max(b, c);
        dp_b = max(a, c);
        dp_c = max(a, b);
    }

    cout << max(max(dp_a, dp_b), dp_c) << endl;
}

Measured memory_bytes: 256