akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#include <math.h>
#include <string.h>
#include <stdlib.h>
#include <time.h>

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define s_pri(str) printf("%s\n",str);
#define PRINT(str) printf(#str "\n")
#define v_pri(val) printf("%d\n",val);
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define MIN(a, b) ((a) < (b) ? (a) : (b))
#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define pi acos(-1.0)
#define sca(x) scanf("%d",&x);

typedef long long int ll;

/*
puts("aa");
//*/
int cmp(const void* a, const void* b) {
	return *(int*)a - *(int*)b;
}


int main(void) {
	int N;
	scanf("%d", &N);
	int A[200000];
	rep(i, N) {
		scanf("%d", &A[i]);
	}
	int count = 0;
	qsort(A, N, sizeof(int), cmp);
	rep(i, N - 1) {
		if (A[i] == A[i + 1]) {
			count++;
		}
	}
	if (count == 0) {
		printf("YES\n");
	}
	else {
		printf("NO\n");
	}

	return 0;
}

Measured memory_bytes: 1788
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int t,i;
    cin>>t;
    int arr[t];
    string str[t];

    for(i=0; i<t; i++)
    {
        cin>> str[i] >> arr[i];
    }
     int sum=0,a=0;
     string btr;
    cin>>btr;
    for(i=0; i<t; i++)
    {

        if(btr==str[i])
            a=i+1;
    }
    for(i=a; i<t; i++)
    {
        sum+=arr[i];
    }
    cout<<sum<<endl;

}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define all(x) (x).begin(), (x).end()
using namespace std;
using VI = vector<int>;
using VB = vector<bool>;
using Graph = vector<vector<int>>;
using ll = long long;
using P = pair<int, int>;

const int mod = 1000000007;
int main()
{
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int n, m;
  cin >> n >> m;
  vector<int> a(m);
  rep(i, m) cin >> a[i];

  map<int, bool> mp;
  rep(i, m) mp[a[i] - 1] = true;

  ll dp[n];

  dp[0] = mp[0] ? 0 : 1;
  dp[1] = mp[1] ? 0 : dp[0] + 1;
  for (int i = 1; i < n; i++)
  {
    if (mp[i])
    {
      dp[i] = 0;
      dp[i + 1] = dp[i - 1] % mod;
    }
    else
    {
      dp[i + 1] = dp[i] % mod + dp[i - 1] % mod;
    }
  }

  cout << dp[n-1] % mod << endl;
}

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

int main(){
  int n;
  int small;
  int cnt = 0;
  int tmp;
  
  cin >> n;
  
  small = n+1;
  for(int i = 0; i < n; i++){
    cin >> tmp;
    small = min(small,tmp);
    if(small == tmp) cnt++;
  }
  
  cout << cnt;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using System.Text;
using System.Text.RegularExpressions;
using System.Diagnostics;
//var input = Console.ReadLine().Split().Select(int.Parse).ToArray();
namespace AtCoderSolve
{
    class Solve
    {
        const int mod = 1000000007;
        static void Main(string[] args)
        {

            //var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            //Console.SetOut(sw);

            //var p = Console.ReadLine().Split().Select(int.Parse).ToArray();
            int N = int.Parse(Console.ReadLine());
            int A = int.Parse(Console.ReadLine());
            Console.WriteLine(N % 500 <= A ? "Yes" : "No");

            //Console.Out.Flush();

        }
    }



    public class Calculation
    {

    }

    public class Graph
    {

    }
}


Measured memory_bytes: 11092
object Main extends App {

  import scala.io.StdIn._

  solve
  def solve:Unit = {
    val n = readInt
    if (n == 0) return
    val self = readLine.trim.split(' ').map(_.toInt).sorted.reverse
    val other = readLine.trim.split(' ').map(_.toInt).sorted.reverse
    self.indices.find{j ⇒
      val i = upperBound(other, self(j))
      j + 1 > 2 * i
    } match {
      case Some(i) if i + 1 < n ⇒ println(i + 1)
      case _ ⇒ println("NA")
    }
    solve
  }
  def upperBound(array: Array[Int], target: Int): Int = {
    var left = 0
    var right = array.length
    while(left < right){
      val mid = (left + right) / 2
      if (array(mid) >= target){
        left = mid + 1
      }else {
        right = mid
      }
    }
    right
  }
  implicit class Extension[T](val value :T) extends AnyVal {
    @inline
    def let[A](@inline func: T ⇒ A): A = func(value)
    @inline
    def also(@inline func: T ⇒ Unit): T = {func(value); value}
  }
}


Measured memory_bytes: 235216
#include <stdio.h>

int main(void)
{
    int t[101][101];
    int r, c, i, j;
    int s, m;

    scanf("%d %d", &r, &c);

    for (i = 1; i <= r; i++){
        for (j = 1; j <= c; j++){
            scanf("%d", &t[i][j]);
        }
    }

    for (i = 1; i <= r; i++){
        s = 0;
        for (j = 1; j <= c; j++){
            s += t[i][j];
        }

        t[i][0] = s;
    }

    m = 0;
    for (j = 1; j <= c; j++){
        s = 0;
        for (i = 1; i <= r; i++){
            s += t[i][j];
        }

        t[0][j] = s;
        m += s;
    }

    for (i = 1; i <= r; i++){
        for (j = 1; j <= c; j++){
            printf("%d ", t[i][j]);
        }

        printf("%d\n", t[i][0]);
    }

    for (j = 1; j <= c; j++){
        printf("%d ", t[0][j]);
    }

    printf("%d\n", m);

    return (0);
}


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

int main() {
	int A, B, C, D, E;
	int ans = 0;

	cin >> A >> B >> C;

	D = A + B;
	if (D < C) {
		ans = D + B + 1;
	}
	else {
		ans = B + C;
	}

	cout << ans << '\n';

	return 0;
}

Measured memory_bytes: 256
///A drunk man will find his way home, but a drunk bird may get lost forever...
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define f first
#define s second
#define int long long
#define sz(x) (int)x.size()
int b[2000 * 100 + 5], a[2000 * 100 + 5], n;
bool big(int x){
	for(int i = 1; i <= 2 * n - 1; i++)
		a[i] = (b[i] >= x);
	for(int i = 0; i < n - 1; i++){
		if((a[n - i] && a[n - i - 1]) || (a[n + i] && a[n + i + 1]))
			return 1;
		if((!a[n - i] && !a[n - i - 1]) || (!a[n + i] && !a[n + i + 1]))
			return 0;
	}
	return a[1];
}
int32_t main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
	int ans = -1;
	cin >> n;
	for(int i = 1; i <= 2 * n - 1; i++)
		cin >> b[i];
	int l = 1, r = 2 * n - 1, mid;
	while(l <= r){
		mid = (r + l) / 2;
	//	cout << mid << " " << big(mid) << endl;
		if(big(mid)){
			ans = mid;
			l = mid + 1;
		}
		else
			r = mid - 1;
	}
	cout << ans << endl;
	return 0;
}


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

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

	int S=0;
	for (size_t i = 0; i < N.length(); ++i)
		S += N[i]-'0';

	cout<< (stoll(N)%S==0 ? "Yes\n" :"No\n");

	return 0;
}
	

Measured memory_bytes: 3036
#include <iostream>
#include <vector>
#include <string>
#include <array>
#include <queue>
#include <deque>
#include <set>
#include <list>
#include <map>
#include <stack>
#include <utility>
#include <algorithm>
#include <numeric>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cctype>
#include <cstring>
#include <climits>
#include <bitset>
#include <random>
#include <functional>
#include <sstream>
#include <iomanip>

using namespace std;

#define _CRT_SECURE_NO_WARNINGS
#define REP(i, n) for(LL i=0; i<(n); i++)
#define FOR(i, m, n) for(LL i=(m);i<(n);i++)
#define SZ(x) ((int)(x).size())
#define SORT(x) sort((x).begin(),(x).end())
#define REVE(x) reverse((x).begin(),(x).end())
#define MP make_pair
#define PB push_back
#define INF INT_MAX

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

int main() {
	LL n;
	cin >> n;
	VS s(n);
	vector<LL> m(6);
	REP(i, n) {
		cin >> s[i];
		if (s[i][0] == 'M')m[0]++;
		if (s[i][0] == 'A')m[1]++;
		if (s[i][0] == 'R')m[2]++;
		if (s[i][0] == 'C')m[3]++;
		if (s[i][0] == 'H')m[4]++;
	}
	vector<LL> a1 = { 0,0,0,0,0,0,1,1,1,2 },
		a2 = { 1,1,1,2,2,3,2,2,3,3 },
		a3 = { 2,3,4,3,4,4,3,4,4,4 };
	LL ans = 0;
	REP(i, 10)ans += m[a1[i]] * m[a2[i]] * m[a3[i]];
	cout << ans << endl;
}

Measured memory_bytes: 6144
/*
 *
 *   Author     : Amit Kumar
 *   Date    	: June 1 2019
 * 
 */

#include <bits/stdc++.h>

//#define FAST_INPUT_OUTPUT
//#define MORE_THAN_ONE_TESTCASE // COMMENT IT

#define vi vector<int>
#define vl vector<long long>
#define mii map<int , int>
#define mll map<long long , long long>
#define msi map<string , i>
#define msl map<string , long long>
#define umii unordered_map<int,int>
#define umll unordered_map<long long ,long long>
#define umsi unordered_map<string , int>
#define umsl map<string , long long> 
#define si set<int>
#define sl set<long long>
#define pii pair<int , int >
#define psi pair<string,int>
#define psl pair<string , long > 
#define pll pair<long long , long long>
#define vpii vector<pii>
#define vpll vector<pll>
#define vpsi vector<psi>
#define vpsl vector<psl>
#define pqi priority_queue<int>
#define pql priority_queue<long long>
#define ub upper_bound
#define lb lower_bound
#define bint long long int
#define ff first
#define ss second
#define all(x) x.begin(),x.end()
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define iv(v) for(auto &i:v){cin>>i;}
#define ov(v) for(auto i:v){cout<<i<<" ";}cout<<endl;
#define ovn(v) for(auto i:v){cout<<i<<endl;}
#define euv(v) for(auto i:v){cerr<<i<<" ";}cerr<<endl;
#define eovn(v) for(auto i:v){cerr<<i<<endl;}
#define os(s) for(auto itr:s){cout<<itr<<" ";}cout<<endl;
#define osn(s) for(auto itr:s){cout<<itr<<endl;}
#define eos(s) for(auto itr:s){cerr<<itr<<" ";}cerr<<endl;
#define eosn(s) for(auto itr:s){cerr<<itr<<endl;}
#define rep(x) for(auto i=0 ; i<(x); ++i)
#define _rep(a,b) for(auto i=(a); i<(b); ++i)
#define endl '\n'
using namespace std;

bool compare(pll x , pll y){
    return x.ss > y.ss;
}



auto SOLUTION_FUNCTION( void ) ->void {

    // your solution goes here 


    int n , m;

    cin>>n>>m;

    vl v(n);

    iv(v);

    sort(all(v));

    vpll b(m);

    rep(m){
        bint bi , ci;

        cin>>bi>>ci;

        b[i].ff = bi;
        b[i].ss = ci;

    }

    sort(all(b),compare);

    int counter = 0;

    rep(m){
        while(b[i].ff && b[i].ss > v[counter] && counter < n){
            v[counter] = b[i].ss;
            b[i].ff--;
            counter++;
        }
        if(counter >= n){
            break;
        }
    }

    bint sum=0;

    for(int l : v)
        sum+=l;

    cout<<sum<<endl;


    return ;
}




int main(void){
#ifdef FAST_INPUT_OUTPUT
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    cout<<setprecision(10);
    cout<<fixed;
    cout<<boolalpha;
#endif
#ifdef MY_LOCAL_PROJECT
    freopen("din","r",stdin);
    freopen("dout","w",stdout);
#endif
    int testcase = 1;


#ifdef MORE_THAN_ONE_TESTCASE
    cin>>testcase;
#endif
    
    while(testcase--){
        SOLUTION_FUNCTION();
    }

#ifdef MY_LOCAL_PROJECT
    cout<<"Time : "<<1.0*(double)clock()/CLOCKS_PER_SEC<<endl;
#endif
    return 0;
}


Measured memory_bytes: 2560
#include<bits/stdc++.h>
using namespace std;
int main()
{
    double a,b,c,d,e,f;
    double x,y;
    while(cin >> a >> b >> c >> d >> e >> f){
        x = (e*c - b*f) / (a*e - d*b);
        y = (a*f - c*d) / (a*e - d*b);
        if(x == -0){
            x = 0;
        }
        if(y == -0){
            y = 0;
        }
        printf("%.3lf %.3lf\n", x, y);
    }
}

Measured memory_bytes: 3100
#include <bits/stdc++.h>
#define fst first
#define snd second
#define pb push_back
#define eb emplace_back
#define mt make_tuple
using namespace std;

const int N = 100005;

int n, m;
int cnt[N];

int main() {
	scanf("%d%d", &n, &m);
	for (int i = 0; i < m; i++) {
		int a, b; scanf("%d%d", &a, &b); a--, b--;
		cnt[a]++, cnt[b]++;
	}
	for (int i = 0; i < N; i++) if (cnt[i] & 1) return printf("NO\n"), 0;
	printf("YES\n");
	return 0;
}

Measured memory_bytes: 640
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <memory.h>
#include <math.h>
#include <assert.h>
#include <queue>
#include <map>
#include <set>
#include <string>
#include <algorithm>
#include <iostream>
#include <functional>
#include <unordered_map>
#include <unordered_set>
#include <list>
#include <bitset>

using namespace std;
typedef pair<int, int> Pi;
typedef long long ll;
#define Fi first
#define Se second
#define pb(x) push_back(x)
#define sz(x) (int)x.size()
#define rep(i, n) for(int i=0;i<n;i++)
#define all(x) x.begin(), x.end()
typedef tuple<int, int, int> t3;
typedef pair<ll, ll> PL;

int A[100010];
ll B[100010];
ll sum;

void solve(){
	int n; scanf("%d", &n);
	rep(i, n)scanf("%d", A+i), sum += A[i];
	ll p = (ll)n * (n+1) / 2;
	if(sum % p != 0){
		puts("NO");
		return;
	}
	ll X = sum / p;
	rep(i, n){
		int j = (i + n - 1) % n;
		ll Y = A[i] - A[j];
		if((X-Y) % n != 0){
			puts("NO");
			return;
		}
		B[i] = (X-Y) / n;
		if(B[i] < 0){
			puts("NO");
			return;
		}
	}
	puts("YES");
}

int main(){
	int Tc = 1; //scanf("%d", &Tc);
	for(int tc=1;tc<=Tc;tc++){
		solve();
	}
	return 0;
}

Measured memory_bytes: 1408
# -*- coding: utf-8 -*-
from sys import stdin
# import numpy as np

s_in = lambda: stdin.readline()[:-1]  # s = s_in()
d_in = lambda: int(stdin.readline())  # N = d_in()
ds_in = lambda: list(map(int, stdin.readline().split()))  # List = ds_in()


N, M = ds_in()

all_loved = set([i for i in range(1, M+1)])
for _ in range(N):
    loved = set(ds_in()[1:])
    all_loved = all_loved.intersection(loved)

print(len(all_loved))


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

int main() {
    int n, sum = 1, m;
    cin >> n;
    vector<int> a(n);
    for(int i = 0; i < n; i++) {
        cin >> a[i];
    }
    m = a[0];
    for(int i = 1; i < n; i++) {
        m = min(m, a[i]);
        if(m == a[i]) sum++;
    }
    cout << sum << endl;

    return 0;
}

Measured memory_bytes: 1024
N = int(input())
H = int(input())
W = int(input())
if N > H and N > W:
    print((N-H+1)*(N-W+1))
elif N > H and N == W:
    print(N-H+1)
elif N == H and N > W:
    print(N-W+1)
elif N == H and N == W:
    print(1)


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

struct point{
    double x, y;
};

void koch(int n, point a, point b){
    if (n==0) return;
    point s, t, u;
    double th = M_PI/3;
    
    s.x = (2.0*a.x + 1.0*b.x)/3.0;
    s.y = (2.0*a.y + 1.0*b.y)/3.0;
    t.x = (1.0*a.x + 2.0*b.x)/3.0;
    t.y = (1.0*a.y + 2.0*b.y)/3.0;
    u.x = (t.x-s.x)*cos(th) - (t.y-s.y)*sin(th) + s.x;
    u.y = (t.x-s.x)*sin(th) + (t.y-s.y)*cos(th) + s.y;
    
    koch(n-1, a, s);
    cout << s.x << " " << s.y << endl;
    koch(n-1, s, u);
    cout << u.x << " " << u.y << endl;
    koch(n-1, u, t);
    cout << t.x << " " << t.y << endl;
    koch(n-1, t, b);
}

int main(){
    int n;
    cin >> n;
    point a, b;
    a.x = 0;
    a.y = 0;
    b.x = 100;
    b.y = 0;
    
    cout << fixed << a.x << " " << a.y << endl;
    koch(n, a, b);
    cout << b.x << " "  << b.y << endl;   
}

Measured memory_bytes: 1248
#include <bits/stdc++.h>
#define IOS std::ios::sync_with_stdio(false),cin.tie(0),cout.tie(0);
typedef long long ll;	
using namespace std;
int main()
{    
    IOS;
    ll n,s;
    while(cin>>s>>n){
    int a[n+2];
    for(int i=1;i<=n;i++)
       cin>>a[i];
    sort(a+1,a+1+n);
    a[n+1]=a[1];
    int x,y,max=0;
    for(int i=1;i<=n;i++)
    if ( max<abs(a[i+1]-a[i])&&i!=n ) {   x=i;y=i+1;max=a[i+1]-a[i]; }
    else  if( (max<(s-(a[n]-a[1]))&&i==n  )){     {   x=i;y=i+1;max=a[i+1]-a[i]; }   }
    ll ans=0;
    for(int i=1;i<=n;i++)
    {
        if(i!=x&&i!=n) ans+= abs(a[i+1]-a[i]);
        else if(i!=x&&i==n){   ans+=  s-(a[n]-a[1]);  }
    }
    cout<< ans <<endl;
    }

    return 0;
}

Measured memory_bytes: 1152
#include "bits/stdc++.h"
using namespace std;
// #define endl '\n'
// #define double long double
#define int long long
// int MOD = 1000 * 1000 * 1000 + 7;
// int MOD = 998244353;

signed main() {

	int n, k, c;
	cin >> n >> k >> c;
	
	bool can[n];
	string s;
	cin >> s;
	for (int i=0; i<n; i++) can[i] = (s[i] == 'o');
	
	int l_aft[n];
	int mx = 0; // if i take this, what more can i go?
	for (int i=n-1; i>=0; i--) {
		if (i + c + 1 < n) mx = max(mx, l_aft[i+c+1]);
		if (!can[i]) {
			l_aft[i] = 0;
			continue;
		}
		l_aft[i] = mx + 1;
	}
	
	int l_bef[n];
	mx = 0;
	for (int i=0; i<n; i++) {
		if (i - c - 1 >= 0) mx = max(mx, l_bef[i-c-1]);
		if (!can[i]) {
			l_bef[i] = 0;
			continue;
		}
		l_bef[i] = mx + 1;
	}
	
	int pfmax[n];
	pfmax[0] = l_bef[0];
	for (int i=1; i<n; i++) pfmax[i] = max(pfmax[i-1], l_bef[i]);
	int sfmax[n];
	sfmax[n-1] = l_aft[n-1];
	for (int i=n-2; i>=0; i--) sfmax[i] = max(sfmax[i+1], l_aft[i]);
	
	for (int i=0; i<n; i++) {
		if (can[i]) {
			int sm = 0;
			if (i > 0) {
				sm += pfmax[i-1];
			}
			if (i < n-1) {
				sm += sfmax[i+1];
			}
			if (sm < k) {
				cout << i + 1 << endl;
			}
		}
	}
	
	
}


Measured memory_bytes: 8324
#include<stdio.h>
#define N 500000

int A[N],B[N],count=0;

void mergeSort(int*,int,int);
    
int main(){
    int i,n;
    scanf("%d",&n);
    for(i=0;i<n;i++)
        scanf("%d",&A[i]);
    mergeSort(A,0,n-1);
    for(i=0;i<n-1;i++)
        printf("%d ",A[i]);
    printf("%d\n%d\n",A[n-1],count);
    return 0;
}

void mergeSort(int *a,int l,int r){
    int i,j,k,m;
    if(r>l){
        m=(r+l)/2;
        mergeSort(a,l,m);
        mergeSort(a,m+1,r);
        for(i=m+1;i>l;i--)
            B[i-1]=A[i-1];
        for(j=m;j<r;j++)
            B[r+m-j]=A[j+1];
        for(k=l;k<=r;k++){
            A[k]=(B[i]<B[j])?B[i++]:B[j--];
            count++;
        }
    }
}



Measured memory_bytes: 5592
using System;
using System.Linq;

class Test
{
    static void Main()
    {
        string[] mm;
        int a, b;
        string op;
        string ss;

        while (!(ss = Console.ReadLine()).Contains("?"))
        {
            mm = ss.Split();
            a = int.Parse(mm[0]);
            b = int.Parse(mm[2]);
            op = mm[1];

            switch (op)
            {
                case "+": Console.WriteLine(a + b);
                    break;
                case "-": Console.WriteLine(a - b);
                    break;
                case "*": Console.WriteLine(a * b);
                    break;
                case "/": Console.WriteLine(a / b);
                    break;
            }
        }
    }
}


Measured memory_bytes: 18048
#include<bits/stdc++.h>
using namespace std;
int main()
{
    string a;
    cin>>a;
    for(int i=0;i<a.size();i++)
    {
        if(a[i]>='a' && a[i]<='z')
        {
            cout<<'x';
        }
    }
}


Measured memory_bytes: 256
n, m = map(int, input().split())
ab = [list(map(int, input().split())) for _ in range(m)]

ab.sort()

l = ab[0][0]
r = ab[0][1]
ans = 1

for i in range(1,m):
    if r<=ab[i][0]:
        ans += 1
        l = ab[i][0]
        r = ab[i][1]
    else:
        r = min(r, ab[i][1])

print(ans)

Measured memory_bytes: 27876
n, q = map(int, input().split())
link = dict()
counter = list([0]*n)
for i in range(n-1):
    a,b = map(int, input().split())
    link[b-1] = a-1
        
for i in range(q):
  p,pp = map(int, input().split())
  counter[p-1] += pp

for i in range(n):
    if i in link:
        counter[i] += counter[link[i]]

counter = map(str, counter)
ans = " ".join(counter)
print(ans)

Measured memory_bytes: 53024
a = int(input())
b = int(input())
c = int(input())
d = int(input())
e = int(input())
li = [a, b, c, d, e]
li_2 = []
d = 10
count = 0
adr = 0
for i in li:
    li_2.append(i % 10)
for i in li_2:
    if i < d and i != 0:
        d = i
        ans = adr
    adr += 1
if d == 10:
    d = 0
    ans = 0
for i in range(5):
    if i != ans and li_2[i] != 0:
        count += (li[i] - li_2[i] + 10)
    elif i != ans and li_2[i] == 0:
        count += li[i]
count += li[ans]
print(count)


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

int main() {
    string str;
    cin >> str;
    int n;
    cin >> n;
    string cmd;
    float a, b;
    string c;
    char tmp;
    for (int i = 0; i < n; i++) {
        cin >> cmd >> a >> b;
        if (cmd == "print") {
            cout << str.substr(a, b - a + 1) << endl;
        }
        else if (cmd == "reverse") {
            string tmp = str.substr(a, b - a + 1);
            reverse(tmp.begin(), tmp.end());
            str = str.substr(0, a) + tmp + str.substr(b + 1, str.size() - a - 1);
        }
        else if (cmd == "replace") {
            cin >> c;
            str = str.substr(0, a) + c + str.substr(b + 1, str.size() - a - 1);
        }
    }
}


Measured memory_bytes: 3296
/*

*/
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<map>
#include<vector>
#include<set>
#include<queue>
#include<cmath>
//#include<ext/pb_ds/assoc_container.hpp>
//#include<ext/pb_ds/hash_policy.hpp>
#define Pair pair<int, int>
#define MP(x, y) make_pair(x, y)
#define fi first
#define se second
#define int long long 
#define LL long long 
#define ull unsigned long long 
#define rg register 
#define pt(x) printf("%d ", x);
//#define getchar() (p1 == p2 && (p2 = (p1 = buf) + fread(buf, 1, 1<<22, stdin), p1 == p2) ? EOF : *p1++)
//char buf[(1 << 22)], *p1 = buf, *p2 = buf;
//char obuf[1<<24], *O = obuf;
//void print(int x) {if(x > 9) print(x / 10); *O++ = x % 10 + '0';}
//#define OS  *O++ = ' ';
using namespace std;
//using namespace __gnu_pbds;
const int MAXN = 1e6 + 10, INF = 1e9 + 10, mod = 1e9 + 7;
const double eps = 1e-9;
inline int read() {
    char c = getchar(); int x = 0, f = 1;
    while(c < '0' || c > '9') {if(c == '-') f = -1; c = getchar();}
    while(c >= '0' && c <= '9') x = x * 10 + c - '0', c = getchar();
    return x * f;
}
int N, a[MAXN];
main() {
	int N = read(), X = read();
	for(int i = 1; i <= N; i++) a[i] = read();
	int g = abs(X - a[1]);
	for(int i = 2; i <= N; i++) {
		int dis = abs(X - a[i]);
		g = __gcd(g, dis);
	}
	printf("%d", g);
    return 0;
}
/*
2 2 1
1 1
2 1 1
*/

Measured memory_bytes: 1024
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int N = scan.nextInt();
		long K = scan.nextLong();
		int[] a = new int[N];
		int[] b = new int[N];
		long[] c = new long[100000];
		for(int i = 0; i < N; i++) {
			a[i] = scan.nextInt();
			b[i] = scan.nextInt();
		}
		for(int i = 0; i < N; i++) {
			c[a[i] - 1] += b[i];
		}
		for(int i = 0; i < c.length; i++) {
			if(c[i] >= K) {
				System.out.println(i + 1);
				break;
			} else {
				K -= c[i];
			}
		}
		scan.close();
	}

}


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

int main(){
	long long int N, K;
	cin >> N >> K;
	
	long long int ans = 10^18;
	if(N%K==0)	ans = 0;
	else if(N>K){
		ans = N-N/K*K;
		if(K-ans<ans)	ans = K-ans;
	}
	else{
		ans = K-N;
		if(N<K/2)	ans = N;
	}
	
	cout << ans << endl;
	
	return 0;
}


Measured memory_bytes: 256
use v5.18;
use warnings;
sub read_line { chomp(my $s = <>); $s }
sub splited_read_line { split / /, read_line }

my ($n, $m) = splited_read_line;
my @light_conditions  = map { my @line = splited_read_line; shift @line; \@line } 0 .. $m - 1;
my @light_switch_nums = splited_read_line;

my @ans =
  grep {
    my $pattern = $_;
    my @lighted = grep {
      my $i = $_;
      my $switch_nums    = $light_conditions[$i];
      my @on_switch_nums = grep { $pattern->[$_ - 1] } @$switch_nums;
      $light_switch_nums[$i] == @on_switch_nums % 2;
    } 0 .. $#light_conditions;
    @lighted == $m;
  }
  sub {
    my ($pattern, $i) = @_;
    return $pattern if $i == $n;
    map { __SUB__->(do { my $p = [ @$pattern ]; $p->[$i] = $_; $p }, $i + 1) } 0, 1;
  }->([], 0);

say scalar @ans;


Measured memory_bytes: 1152
#include <bits/stdc++.h>
#define inf 100000000
using namespace std;

int main(){
  int simen[200]={};
  for(int i=0;i<200;i++)simen[i] = (i+1) * (i+2) * (i+3) / 6;
  int dp[1000005], kisudp[1000005];
  for(int i=0;i<1000005;i++){dp[i] = inf; kisudp[i] = inf;}
  dp[0]=0;kisudp[0]=0;
  for(int k=0;k<200;k++)for(int i=1;i<1000005;i++){
    if(i >= simen[k])dp[i] = min(dp[i], dp[i-simen[k]] + 1);
  }
  for(int k=0;k<200;k++)for(int i=1;i<1000005;i++){
    if(i >= simen[k] && simen[k]%2 == 1)kisudp[i] = min(kisudp[i], kisudp[i-simen[k]] + 1);
  }

  while(1){
    int N;
    scanf("%d", &N);
    if(N==0)break;
    else printf("%d %d\n", dp[N], kisudp[N]);
  }
  return 0;
}



Measured memory_bytes: 11000
n = int(input())
an = list(map(int, input().split()))

c1 = 0
c2 = 0
sum1 = 0 # 偶数番目が正
sum2 = 0 # 奇数番目が正
for i in range(n):
    sum1 += an[i]
    sum2 += an[i]
    if i%2 == 0:
        if sum1 <= 0:
            p = abs(sum1) + 1
            c1 += p
            sum1 += p
        if sum2 >= 0:
            p = abs(sum2) + 1
            c2 += p
            sum2 -= p
    else:
        if sum1 >= 0:
            p = abs(sum1) + 1
            c1 += p
            sum1 -= p
        if sum2 <= 0:
            p = abs(sum2) + 1
            c2 += p
            sum2 += p

print(min(c1, c2))


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

int main(){
  ll N;
  cin>>N;
  vector<P>Sup;
  vector<P>Sdown;
  rep(i,N){
  	string s;
  	cin>>s;
    ll total=0,mini=0;
    rep(j,s.size()){
      if(s[j]=='('){total++;}
      else{total--;}
      mini=min(mini,total);
    }
    if(total>=0){Sup.push_back(P(mini,total));}
    else{Sdown.push_back(P(mini-total,-total));}
  }
  sort(Sup.begin(),Sup.end());
  reverse(Sup.begin(),Sup.end());
  
  sort(Sdown.begin(),Sdown.end());
  reverse(Sdown.begin(),Sdown.end());
  
  int flag=0;
  ll sum1=0;
  ll sum2=0;
  rep(i,Sup.size()){
  	if(Sup[i].first<0&&sum1+Sup[i].first<0){flag=1;}
  	else{sum1+=Sup[i].second;}
    if(sum1<0){flag=1;}
  }
  rep(i,Sdown.size()){
  	if(Sdown[i].first<0&&sum2+Sdown[i].first<0){flag=1;}
  	else{sum2+=Sdown[i].second;}
    if(sum2<0){flag=1;}
  }
  if(sum1!=sum2){flag=1;}
  if(flag==1){cout<<"No";}
  if(flag==0){cout<<"Yes";}
}


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

#define double long double

const int EPS = 1e-9;
int n;
vector<double> A;


int32_t main(){
	cin >> n;
	A = vector<double> (n);
	vector<double> dp(n+1);
	dp[0]=1.0;
	for(auto &a:A) cin >> a;
	for(int i=0;i<n;i++)
		for(int id = i+1;id>=0;id--)
			dp[id] = (id==0?0:dp[id-1]*A[i])+dp[id]*(1-A[i]);
	double ans=0;
	for(int heads=0;heads<=n;heads++){
		int tails = n - heads;
		if(heads>tails)
			ans+=dp[heads];
	}
	cout << fixed << setprecision(10) << ans << '\n';
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
#define in long long
signed main(){
  int n,k,ans=0;
  int p[10000];
  cin>>n>>k;
  for(int i=0;i<n;i++){
    cin>>p[i];
  }
  sort(p,p+n);  
  for(int i=0;i<k;i++){
    ans+=p[i];
  }
  cout<<ans<<"\n";
}

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

#define ll long long int
#define ld long double
#define pb push_back
#define mp make_pair
#define pii pair<int,int>
#define pll pair<ll,ll>
#define F first
#define S second
#define all(x) (x).begin(),(x).end()
#define SZ(x) ((int)(x).size())
#define MS(x,a) memset((x),(a),sizeof(x)) 
#define F0R(i,n) for(auto (i) = 0; (i) < (n); (i)++)
#define FOR(i,a,b) for(auto (i) = (a); (i) <= (b); (i)++)
#define ROF(i,a,b) for(auto (i) = (a); (i) >= (b); (i)--)

using namespace std;

const int MAXN = 1e5+5;
bool dp[MAXN];

int main() {
	int n,k; cin >> n >> k;
	int a[n]; F0R(i,n) cin >> a[i];
	F0R(i,k+1) {
		F0R(j,n) {
			if(i>=a[j]) if(!dp[i-a[j]]) dp[i] = true;
		}
	}
	cout << (dp[k]?"First":"Second");
}	


Measured memory_bytes: 384
#include<iostream>
#include<cstring>
#include<cstdio>
#include<vector>
#include<algorithm>
//#include<ctime>
//#include<cmath>
//#include<queue>

using namespace std;
#define LL long long

inline LL read(){
	LL x=0,f=1; char c=getchar();
	for(;!isdigit(c);c=getchar()) if(c=='-') f=-1;
	for(;isdigit(c);c=getchar()) x=x*10+c-'0';
	return x*f;
}
const LL INF = 2147483600;
const LL MAXN = 500010;

struct data{
	LL x,y;
}p[MAXN+1],a[MAXN+1],b[MAXN+1];
data make_data(LL xx,LL yy){
	data a; a.x=xx; a.y=yy; return a;
}
LL N,W,H;
LL tag[MAXN<<2],tr[MAXN<<2];
bool cmp(data a,data b){
	if(a.x!=b.x) return a.x<b.x;
	return a.y<b.y;
}
inline void tage_lazy(LL rt){
	if(!tag[rt]) return ;
	tag[rt<<1]+=tag[rt]; tag[rt<<1|1]+=tag[rt];
	tr[rt<<1]+=tag[rt]; tr[rt<<1|1]+=tag[rt];
	tag[rt]=0;
	return ;
}
inline void update(LL rt,LL l,LL r,LL L,LL R,LL k){
	if(L>R) return ;
	if(L<=l&&R>=r){tr[rt]+=k; tag[rt]+=k; return ;} tage_lazy(rt);
	LL mid=(l+r)>>1; if(L<=mid) update(rt<<1,l,mid,L,R,k);
	if(R>mid) update(rt<<1|1,mid+1,r,L,R,k);
	tr[rt]=max(tr[rt<<1],tr[rt<<1|1]); return ;
} LL ans=0;

inline void work(){
	sort(p+1,p+N+1,cmp);
	memset(tr,0,sizeof(tr));
	memset(tag,0,sizeof(tag));
	LL l=0,r=0; 
	for(LL i=1;i<=N;i++){
		if(p[i].y<=(H>>1)){
			LL lat=i-1;
			while(l&&a[l].y<p[i].y){
				update(1,1,N,a[l].x,lat,a[l].y-p[i].y);
				lat=a[l].x-1; --l;
			} if(lat!=i-1){
				a[++l]=make_data(lat+1,p[i].y);
			}
		} else{
			LL lat=i-1;
			while(r&&b[r].y>p[i].y){
				update(1,1,N,b[r].x,lat,p[i].y-b[r].y);
				lat=b[r].x-1; --r;
			} if(lat!=i-1){
				b[++r]=make_data(lat+1,p[i].y);
			}
		} a[++l]=make_data(i,0);
		b[++r]=make_data(i,H); update(1,1,N,i,i,H-p[i].x);
		ans=max(ans,tr[1]+p[i+1].x);
	} return ;
}

int main(){
	//freopen("a.in","r",stdin);
	//freopen(".out","w",stdout);
	W=read(),H=read(); N=read(); 
	for(LL i=1;i<=N;i++){
		p[i].x=read(),p[i].y=read();
	} p[++N].x=0; p[N].y=0; p[++N].x=W; p[N].y=H; work(); swap(W,H);
	for(LL i=1;i<=N;i++){
		swap(p[i].x,p[i].y);
	} work(); printf("%lld\n",ans*2);
	return 0;
}


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

int main()
{
    long long x, ans=0, y;
    cin>>x;
    y =(x/500);
    ans+=(y*1000);
    if(x>=500)
    x-=(y*500);
    y = x/5;
    ans+=(y*5);
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
//
//  main.cpp

#include <iostream>
using namespace std;

int main(){
	while(1){
		int a,b;
		cin >> a >> b;
		if(a == 0 && b == 0){
			return 0;
		}
		int n;
		cin >> n;
		bool canGo[17][17];
		for(int i=0;i<17;i++){
			for(int j = 0;j<17;j++){
				canGo[i][j] = true;
			}
		}
		for(int i=0;i<n;i++){
			int A,B;
			cin >> A >> B;
			canGo[A][B] = false;
		}
		
		int matrix[17][17];
		for(int i=0;i<17;i++){
			for(int j=0;j<17;j++){
				matrix[i][j] = 0;
			}
		}
		matrix[1][1] = 1;
		
		for(int i=1;i<=a;i++){
			for(int j=1;j<=b;j++){
				if(j == 1 && i == 1)continue;
				if(canGo[i][j]){
					matrix[i][j] = matrix[i-1][j] + matrix[i][j-1];
				}else{
					matrix[i][j] = 0;
				}
			}
		}
		cout << matrix[a][b] << endl;
	}
	return 0;
}

Measured memory_bytes: 2988
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int a,b,c,d,s=0;
	scanf("%d %d",&a,&b);
	if(a>b)
	{
		s+=b;
	}
	else
	{
		s+=a;
	}
	scanf("%d %d",&c,&d);
	if(c>d)
	{
		s+=d;
	}
	else
	{
		s+=c;
	}
	printf("%d",s);
	return 0;
}

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

#include <boost/range/adaptors.hpp>
#include <boost/range/irange.hpp>

using namespace std;
using namespace boost;
using namespace boost::adaptors;

main() {
  int64_t n, W;
  cin >> n >> W;

  int64_t offset;
  vector<pair<int64_t, int64_t>> wv(n);
  for (auto i : irange(0L, n)) {
    cin >> wv[i].first >> wv[i].second;
    if (i == 0) {
      offset = wv[i].first;
    }
    wv[i].first -= offset;
  }

  vector<vector<int64_t>> dp(n + 1, vector<int64_t>(3 * n + 1));
  for (auto i : irange(0L, n)) {
    auto w = wv[i].first;
    auto v = wv[i].second;
    for (auto j : irange(1L, n + 1) | reversed) {
      for (auto k : irange(w, 3 * n + 1) | reversed) {
        dp[j][k] = max(dp[j][k], dp[j - 1][k - w] + v);
      }
    }
  }

  int64_t ans = -1;
  for (auto i : irange(0L, n + 1)) {
    if (W >= offset * i) {
      ans = max(ans, dp[i][min(W - offset * i, 3 * n)]);
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>, rb_tree_tag,tree_order_statistics_node_update> ordered_set;

#define scan(x) do{while((x=getchar())<'0'); for(x-='0'; '0'<=(_=getchar()); x=(x<<3)+(x<<1)+_-'0');}while(0)
char _;
#define complete_unique(a) a.erase(unique(a.begin(),a.end()),a.end())
#define all(a) a.begin(),a.end()
#define println printf("\n");
#define readln(x) getline(cin,x);
#define pb push_back
#define endl "\n"
#define INT_INF 0x3f3f3f3f
#define LL_INF 0x3f3f3f3f3f3f3f3f
#define MOD 1000000007
#define MOD2 1494318097
#define SEED 131
#define mp make_pair
#define fastio cin.tie(0); cin.sync_with_stdio(0);

typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;
typedef unordered_map<int,int> umii;
typedef pair<int,int> pii;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef pair<int,pii> triple;
typedef int8_t byte;

mt19937 g1(time(0));

int randint(int a, int b){return uniform_int_distribution<int>(a, b)(g1);}
ull randlong(ull a,ull b){return uniform_int_distribution<unsigned long long>(a, b)(g1);}

ll gcd(ll a, ll b){return b == 0 ? a : gcd(b, a % b);}
ll lcm(ll a, ll b){return a*b/gcd(a,b);}
//ll fpow(ll  b, ll exp, ll mod){if(exp == 0) return 1;ll t = fpow(b,exp/2,mod);if(exp&1) return t*t%mod*b%mod;return t*t%mod;}
//ll divmod(ll i, ll j, ll mod){i%=mod,j%=mod;return i*fpow(j,mod-2,mod)%mod;}

//ll fmul(ll a, ll b, ll mod){ll res=0;while(a){if(a&1)res=(res+b)%mod;a>>=1;b=(b<<1)%mod;}return res;}
//ll fpowfast(ll b, ll exp, ll mod){ll res=1;while(exp){if(exp&1)res=fmul(res,b,mod);b=fmul(b,b,mod);exp>>=1;}return res;}
//inline bool rabbin_miller(ll x){if(x%2==0) return false;for(int i=0;i<5;i++){ll rd=randlong(2,x-2);if(fpowfast(rd,x-1,x)!=1)return false;}return true;}

ll A,B,res=1;

ull fmul(ull a, ull b, ull mod){
	ull res = 0;
	while(a){
		if(a&1) res = (res+b)%mod;
		a>>=1;
		b = (b<<1)%mod;
	}
	return res;
}

ull fpow(ull b, ull exp, ull mod){
	ull res = 1;
	while(exp){
		if(exp&1) res = fmul(res,b,mod);
		b = fmul(b,b,mod);
		exp>>=1;
	}
	return res;
}

//inline bool prim(ull x){
//	if(x == 2 || x == 3) return true;
////	if(x%2 == 0) return false;
//	for(int i=0; i<30; i++){
//		ull rd = randlong(2,x-2);
//		if(fpow(rd,x-1,x) != 1)
//			return false;
//	}
//	return true;
//}

inline bool prim(ull x){
	if(x == 2) return true;
	ull lim = sqrt(x);
	while(lim*lim < x) lim++;
	while(lim*lim > x) lim--;
	for(ull k=2; k<=lim; k++){
		if(x%k == 0) return false;
	}
	return true;
}

int main(){
	scanf("%lld %lld",&A,&B);
	ull gg = __gcd(A,B);
	ull lim = sqrt(gg);
	while(lim*lim < gg) lim++;
	while(lim*lim > gg) lim--;
	for(ull i=2; i<=lim; i++){
		if(gg%i == 0){
			if(prim(i))
				res++;
			if(i*i != gg && prim(gg/i))
				res++;
		}
	}
	if(prim(gg) && gg != 1) res++;
	printf("%lld\n",res);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
 
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  long long n;
  cin >> n;
  int res=0;
  for(int i=1;i<=9; i++)
  {
  long long x=i;
    int sum=x;
    if(x>n) break;
    while(x*10+9<=n)
    {
      x=x*10+9;
      sum+=9;
    }
    res=max(res,sum);
  }
  cout<<res<<'\n';
  return 0;
}


Measured memory_bytes: 256
def solve(i, m):
    global n
    global A
    if( m == 0 ):
        return True
    if( i >= n ):
        return False
    return solve(i + 1, m) or solve(i + 1, m - A[i])


n = int(input())
A = [int(i) for i in input().split()]

q = int(input())
M = [int(i) for i in input().split()]



for m in M:
    if(min(A) > m or m > sum(A)):
        print("no")
    else:
        if( solve(0, m) == True):
            print("yes")
        else:
            print("no")



Measured memory_bytes: 5624
s=list(input())
n=int(input())
for i in range(n):
    a=input().split()
    if a[0]=='print':print(''.join(s[int(a[1]):int(a[2])+1]))
    elif a[0]=='replace':s[int(a[1]):int(a[2])+1]=a[3]
    else:s[int(a[1]):int(a[2])+1]=s[int(a[1]):int(a[2])+1][::-1]


Measured memory_bytes: 5620
#include <iostream>
#define ll long long int
using namespace std;

int main()
{
    ll n;
    cin>>n;
    string s;
    cin>>s;
    ll count=0;
	if(n%2!=0)
    {
      cout<<"No"<<endl;
    }
  	else
    {
      for(ll i=0; i<n/2; i++)
    	{
        	if(s[i]==s[i+n/2])
        	{
            	count++;
        	}
    	}
    	if(count==n/2)
    	{
        	cout<<"Yes"<<endl;
    	}
    	else
    	{
        	cout<<"No"<<endl;
    	}
    }
    return 0;
}


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

using namespace std;

typedef long long ll;

int main(){
        int N;
        cin>>N;
        vector <ll> a(N);
        for(int i=0;i<N;i++){
                cin>>a[i];
        }
        vector <ll> S(N);
        S[0]=a[0];
        for(int i=1;i<N;i++){
                S[i]=S[i-1]+a[i];
        }
        ll res=0;
        map<ll, ll> mp;
        for(int i=N-1;i>=0;i--){
                res+=mp[S[i]];
                mp[S[i]]++;
        }
        cout<<res+mp[0]<<endl;
        return 0;
}


Measured memory_bytes: 15872
#include <stdio.h>

int i,j;
int n, cnt, a[1000000] = {0}, g[1000000] = {0};

void insertion_sort(int*, int, int);

int main(void)
{
	int k;
	int m;

	scanf("%d", &n);

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

	cnt = 0;
	g[0] = 1;
	m = 1;
	i = 0;

	while(3 * g[i] + 1 < n)
	{
		g[i+1] = 3 * g[i] + 1;
		m++;
		i++;
	}

	for(k = m-1; k >= 0; k--)
	{
		insertion_sort(a, n, g[k]);
	}

	printf("%d\n", m);

	for(i = m-1; i >=0; i--)
	{
		if (i != 0)
		{
			printf("%d ", g[i]);
		}else
		{
			printf("%d\n", g[i]);
		}
	}

	printf("%d\n", cnt);

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

	return 0;
}


void insertion_sort(int *a, int n, int g)
{
	int v;

	for(i = g; i < n; i++)
	{
		v = a[i];
		j = i - g;

		while(j >= 0 && a[j] > v)
		{
			a[j + g] = a[j];
			j = j - g;
			cnt++;
		}

		a[j + g] = v;
	}
}

Measured memory_bytes: 6368
#include<stdio.h>
#include<string.h>
#define MIN(a,b) ((a) < (b) ? (a) : (b))
#define MAX 100
#define INF 100000000

int adj[MAX][MAX];
int visited[MAX];
int v;

int dfs(int u,int t,int f){
	int i;

	if(u == t)return f;
	
	visited[u]=1;

	for(i=0;i<v;i++){
		if(visited[i]==0 && adj[u][i]>0){
			int d=dfs(i,t,MIN(f,adj[u][i]));
			if(d > 0){
				adj[u][i]-=d;
				adj[i][u]+=d;
				return d;
			}
		}
	}

	return 0;
}


int max_flow(int s,int t){
	int flow=0;
	
	while(1){
		memset(visited,0,sizeof(visited));
		int f=dfs(s,t,INF);
		if(f==0)return flow;
		flow+=f;
		
	}
	return 0;
	
}


int main(){
	int e;
	int x,y,z,i,j;
	
	scanf("%d %d",&v,&e);
	
	for(i=0;i<v;i++){
		for(j=0;j<v;j++){
			adj[i][j]=0;
		}
	}
	
	
	for(i=0;i<e;i++){
		scanf("%d %d %d",&x,&y,&z);
		adj[x][y]=z;
	}
	
	printf("%d\n",max_flow(0,v-1));
	

	
	return 0;
}


Measured memory_bytes: 2144
#include<bits/stdc++.h>
using namespace std;
#define rep(i,j,n) for(int i=(int)(j);i<(int)(n);i++)
#define REP(i,j,n) for(int i=(int)(j);i<=(int)(n);i++)
#define MOD 1000000007
#define int long long
#define ALL(a) (a).begin(),(a).end()
#define vi vector<int>
#define vii vector<vi>
#define pii pair<int,int>
#define priq priority_queue<int>
#define disup(A,key) distance(A.begin(),upper_bound(ALL(A),(int)(key)))
#define dislow(A,key) distance(A.begin(),lower_bound(ALL(A),(int)(key)))
#define tii tuple<int,int,int>
#define Priq priority_queue<int,vi,greater<int>>
#define pb push_back
#define mp make_pair
int N,A,B,C[100000];
int func(int X){
  int ret=0;
  rep(i,0,N) ret+=(max(0ll,(C[i]-B*X))+A-B-1)/(A-B);
  return ret;
}
signed main(){
  cin>>N>>A>>B;
  rep(i,0,N) cin>>C[i];
  int left=0,right=1000000000*N/B;
  while(left+1<right){
    int mid=(left+right)/2;
    if(func(mid)<=mid) right=mid;
    else left=mid;
  }
  int ans=right;
  if(func(left)<=left) ans=left;
  cout<<ans<<endl;
  }



Measured memory_bytes: 1024
#include<stdio.h>
#include<stdlib.h>
#include<string.h>

struct node{
  unsigned int key;
  struct node *next;
  struct node *prev;
};

typedef struct node * NodePointer;

NodePointer nil;

NodePointer listSearch(int key){
  /* your code */
  NodePointer x;
  x = nil->next;
  while(x != nil && x->key != key)
    x = x->next;
  return x;
  
}

void init(){
  nil = malloc(sizeof(struct node));
  nil->next = nil;
  nil->prev = nil;
}

void printList(){
  NodePointer cur = nil->next;
  int isf = 1;
  while(1){
    if ( cur == nil ) break;
    if ( isf == 0)  printf(" ");
    printf("%d", cur->key);
    cur = cur->next;
    isf = 0;
  }
  printf("\n");
}

void deleteNode(NodePointer t){
  /* your code */
  if(t == nil) return;
  t->prev->next = t->next;
  t->next->prev = t->prev;
  
}

void deleteFirst(){
  NodePointer t = nil->next;
  if ( t == nil ) return;
  deleteNode(t);
}

void deleteLast(){
  /* your code */
  NodePointer t = nil->prev;
  if(t == nil) return;
  deleteNode(t);
}

void delete(int key){
  /* your code */
  deleteNode(listSearch(key));
}


void insert(int key){
  NodePointer x;
  x = malloc(sizeof(struct node));
  x->key = key;
  x->next = nil->next;
  nil->next->prev = x;
  nil->next = x;
  x->prev = nil;

  /* 

   your code 


  */

}

int main(){
  int key, n, i;
  int size = 0;
  char com[20];
  int np = 0, nd = 0;
  scanf("%d", &n);
  init();
  for ( i = 0; i < n; i++ ){
    scanf("%s%d", com, &key);
    if ( com[0] == 'i' ) {insert(key); np++; size++;}
    else if ( com[0] == 'd' ) {
      if (strlen(com) > 6){
	if ( com[6] == 'F' ) deleteFirst();
	else if ( com[6] == 'L' ) deleteLast();
      } else {
	delete(key); nd++; 
      }
      size--;
    }
  }

  printList();
  return 0;
}



Measured memory_bytes: 36072
N = int(input())
# = map(int, input().split())
P = list(map(int, input().split()))
# = [int(input()) for i in range(N)]
# = [list(map(int, input().split())) for i in range(N)]

count = 0
minimum = 300000

for i in range(N):
    if P[i] == 1:
        count += 1
        break
    if P[i] < minimum:
        count += 1
        minimum = P[i]

print(count)


Measured memory_bytes: 24744
import math

abhm = [int(x) for x in input().split()]
a = abhm[0]
b = abhm[1]
h = abhm[2]
m = abhm[3]

angle = abs((6*m)-((h+(m/60))*30))
angle = angle/180*math.pi

print(math.sqrt((a*a)+(b*b)-(2*a*b*math.cos(angle))))



Measured memory_bytes: 9508
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using Pair = pair<int, int>;
using Vec = vector<int>;
using Graph = vector<Vec>;

int		main(void)
{
	int n;
	cin >> n;
	string s;
	cin >> s;
	int c = 1;
	for (auto it = s.begin() + 1; it != s.end(); it++)
	{
		if (*it != *(it - 1))
			c++;
	}
	cout << c << endl;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main () 
{
  ll n,q,x,y;cin>>n;
  ll a[n],sum=0;
  map<ll,ll>m;
  for (ll i=0;i<n;i++) {cin>>a[i];m[a[i]]++;sum+=a[i];}
  cin>>q;
  while (q--) {
      cin>>x>>y;
      sum+=(y-x)*m[x];
      m[y]+=m[x];m[x]=0;
      cout<<sum<<endl;
  }
}

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

using namespace std;
#define ll long long
#define FOR(i, a, b) for (ll i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define PRINT(item) cout << (item) << endl;
#define PRINT_VEC(V)                                                           \
    for (auto v : (V))                                                         \
        cout << v << ' ';
const int MOD = 1000000007;
/* cout << fixed << setprecision(10) << decimal << endl; */

int main() {
    /* code */
    int K, A, B;
    cin >> K >> A >> B;
    FOR(i, A, B + 1) {
        if (i % K == 0) {
            cout << "OK" << endl;
            return 0;
        }
    }
    cout << "NG" << endl;
    return 0;
}

Measured memory_bytes: 3592
#include<iostream>
#include<math.h>
#include<string>
#include<vector>
#include<algorithm>
#include<queue>
using namespace std;
#define INF 1<<20

struct edge{
	int to;
	int cost;
	edge() {};
	edge(int a, int b) {
		to = a;
		cost = b;
	}
};

struct Node {
	int pos;
	int cost;
	Node() {};
	Node(int a, int b) {
		pos = a;
		cost = b;
	}
	bool operator <(const Node& rhs) const {
		return cost > rhs.cost;
	}
};

void dijkistra(int st, int TO,int V,vector<vector<edge> > graph) {
	priority_queue<Node> q;
	vector<int> d(V);
	for (int i = 0;i < V;i++) {
		d[i] = INF;
	}
	d[st] = 0;
	q.push(Node(st, 0));
	while (!q.empty()) {
		Node s = q.top(); q.pop();
		int pos = s.pos;
		for (int i = 0;i < graph[pos].size();i++) {
			int to = graph[pos][i].to;
			int cost = graph[pos][i].cost;
			if (d[pos] + cost < d[to]) {
				d[to] = d[pos] + cost;
				q.push(Node(to, d[to]));
			}

		}
	}
	cout << d[TO] << endl;
}
int partition(int A[],int p, int r) {
	int x = A[r];
	int i = p - 1;
	for (int j = p;j < r;j++) {
		if (x >= A[j]) {
			i = i + 1;
			swap(A[i], A[j]);
		}
	}
		swap(A[i + 1], A[r]);
		return i + 1;
}
void quicksort(int A[], int p, int r) {
	if (p < r) {
		int q = partition(A, p, r);
		quicksort(A, p, q-1);
		quicksort(A, q + 1, r);
	}
}

int getNumberOfCoin(int C[],int n,int m) {
	int T[50000];
	for (int j = 0;j <= n;j++) {
		T[j] = INF;
	}
	T[0] = 0;
	for (int i = 0;i < m;i++) {
		for (int j = 0;j <= n;j++) {
			if (j - C[i] >=0  ) {
				T[j] = min(T[j], T[j - C[i]] + 1);
			}
		}
	}
	return T[n];
}
int knapsack(int w, int n,int* v,int* ww) {
	int W[101][10001];
		for (int j = 0;j <= w;j++) {
			W[0][j] = 0;
		}
	for (int i = 0;i < n;i++) {
		for (int k = 0;k < n;k++){
			for (int j = 0;j <= w;j++) {
				if (j - ww[k] < 0) {
					W[i + 1][j] = W[i][j];
				}
				if (j - ww[i] >= 0) {
					W[i + 1][j] = max(W[i][j], W[i][j - ww[k]] + v[k]);

				}
			}
		}
	}
	return W[n][w];
}
int main() {
	int point;
	cin >> point;
	vector<queue<int> >lis(point);
	for (int i = 0;i < point;i++) {
		int V,edges;
		cin >> V>>edges;
		for (int j = 0;j < edges;j++) {
			int h;
			cin >> h;
			lis[i].push(h-1);
		}
	}

	vector<vector<int> > v(point, vector<int>(point, 0));
	for (int i = 0;i < point;i++) {
		while (!lis[i].empty()) {
			int j = lis[i].front();
			lis[i].pop();
			v[i][j] = 1;
		}
	}
	for (int i = 0;i < point;i++) {
		for (int j = 0;j < point;j++) {
			if ( j == point - 1) {
				cout << v[i][j];
			}
			else
			cout << v[i][j]<<" ";
		}
		cout << endl;
	}

	return 0;
	
}

int isPrime(int x) {
	if (x <= 1) return false;
	if (x>2 && x % 2 == 0) return false;
	for (int i = 2;i <= sqrt(x);i++) {
		if (x%i == 0) {
			return false;
		}
	}
	if (x == 2) return true;
	return true;
}

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

#define REP(i, n) for(int i=0; i<(n); ++i)
#define FOR(i, a, b) for(int i=(a); i<(b); ++i)
#define FORR(i, a, b) for(int i=(b)-1; i>=(a); --i)

#define DEBUG(x) cout<<#x<<": "<<x<<'\n'
#define DEBUG_VEC(v) cout<<#v<<":";REP(i, v.size())cout<<' '<<v[i];cout<<'\n'
#define ALL(a) (a).begin(), (a).end()

#define CHMIN(a, b) a=min((a), (b))
#define CHMAX(a, b) a=max((a), (b))

const ll MOD=1000000007ll;
// const ll MOD=998244353ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

const double EPS=1e-11;
#define EQ0(x) (abs((x))<EPS)
#define EQ(a, b) (abs((a)-(b))<EPS)

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	int k;
	cin>>k;
	cout<<(k/2)*((k+1)/2)<<'\n';
	return 0;
}


Measured memory_bytes: 256
$|=1;
$N = <STDIN>;chomp $N;
for($i=0;$i<$N;$i++){
	$d = <STDIN>;chomp $d;
	push @D,$d;
}
for($i=0;$i<$N;$i++){
	$h{$D[$i]}=1;
}
print scalar(keys %h);


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

int main()
{
#ifndef ONLINE_JUDGE
	// for getting input from input.txt
	freopen("input1.txt", "r", stdin);
	// for writing output to output.txt
	freopen("output1.txt", "w", stdout);
#endif
	string ans = "";
	int k;
	cin >> k;
	while (k--)
	{
		ans += "ACL";
	}
	cout << ans;
}

Measured memory_bytes: 3040
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstdlib>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <set>
#include <string>
#include <utility>
#include <vector>
#define REP(i, n) for(int i = 0; i < (n); ++i)
typedef long long ll;
const ll MOD = 1000000007;
using namespace std;

int main(){
    int n; cin >> n;
    vector<int> a(n);
    REP(i, n){
        cin >> a[i]; --a[i];
    }
    for(int cnt=0, cur=0; cnt <= n; ++cnt){
        if(cur == 1){
            cout << cnt << "\n";
            return 0;
        }
        cur = a[cur];
    }
    cout << -1 << "\n";
    return 0;
}

Measured memory_bytes: 640