akhauriyash/Code-Regression huggingface dataset:
/* ****Ragnar7 -SHINIGAMI- _Lawliet_**** */
/* First, solve the problem.Then write the code. */
#include<bits/stdc++.h>
#define ll          long long
#define ld 			long double
#define hell        1000000007
#define time        cerr << "\nTime elapsed: " << 1000 * clock() / CLOCKS_PER_SEC << "ms\n";
std::mt19937_64 rng(std::chrono::steady_clock::now().time_since_epoch().count());
using namespace std;

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	#ifndef ONLINE_JUDGE
	freopen ("input.txt","r",stdin);
	// freopen ("output.txt","w",stdout);
	#endif
	ll t = 1;
	// cin>>t;
	while(t--)
	{
		ll n,w;
		cin>>n>>w;
		vector<pair<ll,ll> > v;
		ll x,y;
		v.push_back({0,0});
		for(ll i=1;i<=n;i++)
		{
			cin>>x>>y;
			v.push_back({x,y});
		}
		sort(v.begin(), v.end());
		ll maxVal = 100000;
		ll dp[n+5][maxVal+5];
		ll inf = 1LL<<60LL;
		for(ll i=1;i<=maxVal;i++)
			for(ll j=0;j<=n;j++)
				dp[j][i] = inf;
		for(ll i=0;i<=n;i++)
			dp[i][0] = 0;
		ll ans = 0;
		for(ll i=1;i<=maxVal;i++)
		{
			for(ll j=1;j<=n;j++)
			{
				if(i-v[j].second>=0)
					dp[j][i] = min(dp[j][i],dp[j-1][i-v[j].second]+v[j].first);
				dp[j][i] = min(dp[j][i],dp[j-1][i]);
				if(dp[j][i]<=w)
					ans = max(ans,i);
			}	
		}
		cout<<ans;
	}
	time
	return 0;
}

Measured memory_bytes: 82576
#include<bits/stdc++.h>
#define mk make_pair
#define scd second
#define fst first

using namespace std;

typedef long long LL;
typedef pair<int,int> pii;
const LL MOD=1e9+7;
const LL MAXN=4096;
const LL MAXK=2e5+10;
LL h,w,n;
pii poi[MAXN];
LL dp[MAXN][4];
LL mul[MAXK],inv[MAXK];

LL pow(LL x,LL k){
	LL ret=1;
	while(k){
		if(k&1) ret*=x,ret%=MOD;
		x*=x,x%=MOD;
		k>>=1;
	}
	return ret;
}

void init(){
	mul[0]=1;
	for(int i=1;i<MAXK;i++){
		mul[i]=mul[i-1]*i%MOD;
	}
	inv[MAXK-1]=pow(mul[MAXK-1],MOD-2)%MOD;
	inv[0]=1;
	for(int i=MAXK-2;i>=1;i--){
		inv[i]=inv[i+1]*(i+1)%MOD;
	}
}

LL cal(LL x,LL y){
	return mul[y]*inv[x]%MOD*inv[y-x]%MOD;
}

int main(){
	init();
	cin>>h>>w>>n;
	for(int i=1;i<=n;i++){
		cin>>poi[i].fst>>poi[i].scd;
	}
	poi[n+1]=mk(1,1);
	poi[n+2]=mk(h,w);
	sort(poi+1,poi+n+3);
	
	dp[1][1]=1;
	for(int i=1;i<=n+2;i++){
		for(int j=1;j<i;j++){
			LL dx=poi[i].fst-poi[j].fst;
			LL dy=poi[i].scd-poi[j].scd;
			if(dx<0||dy<0) continue;
			LL cn=cal(dx,dx+dy);
			dp[i][0]+=dp[j][1]*cn%MOD,dp[i][0]%=MOD;
			dp[i][1]+=dp[j][0]*cn%MOD,dp[i][1]%=MOD;
		}
	}
	cout<<(dp[n+2][0]-dp[n+2][1]+MOD)%MOD<<endl;
	return 0;
}


Measured memory_bytes: 3456
/*input
6
0 153 10 10 23
*/
/**
    Author: Kristopher Paul
    Date Created: 07-09-2019
    Contest Name:
                _/    _/   _/_/_/_/   _/   _/_/_/_/
               _/  _/     _/    _/   _/   _/
              _/_/       _/_/_/_/   _/   _/_/_/_/
             _/  _/     _/  _/     _/         _/
            _/    _/   _/    _/   _/   _/_/_/_/
**/
#include<bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
#define ll long long
#define int ll
#define pb push_back
#define INF 1e18
#define MOD 1000000007
#define mp make_pair
const double PI=3.141592653589793238462643383279502884197169399375105820974944;
#define REP(i,n) for (int i = 0; i < n; i++)
#define FOR(i,a,b) for (int i = a; i < b; i++)
#define REPD(i,n) for (int i = n-1; i >= 0; i--)
#define FORD(i,a,b) for (int i = a; i >= b; i--)
#define remax(a,b) a = max(a,b)
#define remin(a,b) a = min(a,b)
#define umap unordered_map
#define pii pair<int,int>
#define F first
#define S second
#define mii map<int,int>
#define vi vector<int>
#define vvi vector<vi>
#define itr :: iterator it
#define all(v) v.begin(),v.end()
#define WL(t) while(t--)
#define gcd(a,b) __gcd((a),(b))
#define lcm(a,b) ((a)*(b))/gcd((a),(b))
#define out(x) cout << #x << " is " << x << endl
#define FastIO ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
using namespace std;
//using namespace __gnu_pbds;

//typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> pbds; // set
//typedef tree<int,null_type,less_equal<int>,rb_tree_tag,tree_order_statistics_node_update> pbds; // multiset

int ModExp(int x,int y,int m){
    int res = 1;
    x = x % m;
    while (y > 0)
    {
        if (y & 1)
            res = (res*x) % m;

        y = y>>1;
        x = (x*x) % m;
    }
    return res;
}

void solve(){
    int n;
    cin >> n;
    int b[n];
    FOR(i,0,n-1){
        cin >> b[i];
    }
    int a[n];
    a[0] = b[0];
    FOR(i,1,n-1){
        a[i] = min(b[i],b[i-1]);
    }
    a[n-1] = b[n-2];
    int ans = 0;
    FOR(i,0,n){
        ans += a[i];
    }
    cout << ans << endl;
}

signed main(){
    FastIO;
    int t = 1;
//    cin >> t;
    WL(t){
        solve();
    }
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
    int N;
    char c;
    
    
    scanf("%d%c", &N, &c);
    
    
    if(N < 10)
        printf("%d\n", N);
    else if(N < 100)
        printf("9\n");
    else if(N < 1000)
        printf("%d\n", 9+N-100+1);
    else if(N < 10000)
        printf("909\n");
    else if(N < 100000)
        printf("%d\n", 9+900+N-10000+1);
    else
        printf("90909\n");
    
    
    //system("pause");
    
    return 0;
}
/*
1-9		     9
100-999		 900
10000-99999	 90000
*/

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

void exc( int& a, int& b ) {
    int buf;
    buf = a;
    a = b;
    b = buf;
}

int main() {
    int ns[10];
    int fst, scd = 0, trd = 0;
    for( int i = 0; i < 10; ++i ) {
        cin >> ns[i];
        if( i == 0 ) {
            fst = ns[ i ];
            continue;
        }
        if( ns[ i ] >= trd ) {
            trd = ns[ i ];
            if( trd > scd ) {
                exc( trd, scd );
                if( scd > fst ) {
                    exc( scd, fst );
                }
            }
        }
    }
    cout << fst << endl
         << scd << endl
         << trd << endl;
}

Measured memory_bytes: 3072
#include <stdio.h>
main(){
  double a;
  while(scanf("%lf",&a) !=EOF){
    if(a<=48) printf("light fly\n");
    else if(a>48&&a<=51) printf("fly\n");
    else if(a>51&&a<=54) printf("bantam\n");
    else if(a>54&&a<=57) printf("feather\n");
    else if(a>57&&a<=60) printf("light\n");
    else if(a>60&&a<=64) printf("light welter\n");
    else if(a>64&&a<=69) printf("welter\n");
    else if(a>69&&a<=75) printf("light middle\n");
    else if(a>75&&a<=81) printf("middle\n");
    else if(a>81&&a<=91) printf("light heavy\n");
    else printf("heavy\n");
  }
 
  return 0; 
}

Measured memory_bytes: 0
//Relive your past life.
//Face your demons.
//The past is never dead,it is not even past.
//The memories are not only the key to the past but...also to the future.
//coded in Rusty Lake
#include<cmath>
#include<math.h>
#include<ctype.h>
#include<algorithm>
#include<bitset>
#include<cassert>
#include<cctype>
#include<cerrno>
#include<cfloat>
#include<ciso646>
#include<climits>
#include<clocale>
#include<complex>
#include<csetjmp>
#include<csignal>
#include<cstdarg>
#include<cstddef>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<ctime>
#include<cwchar>
#include<cwctype>
#include<deque>
#include<exception>
#include<fstream>
#include<functional>
#include<iomanip>
#include<ios>
#include<iosfwd>
#include<iostream>
#include<istream>
#include<iterator>
#include<limits>
#include<list>
#include<locale>
#include<map>
#include<memory>
#include<new>
#include<numeric>
#include<ostream>
#include<queue>
#include<set>
#include<sstream>
#include<stack>
#include<stdexcept>
#include<streambuf>
#include<string>
#include<typeinfo>
#include<utility>
#include<valarray>
#include<vector>
#include<string.h>
#include<stdlib.h>
#include<stdio.h>
#define ll   long long
#define pb   push_back
#define mp   make_pair
#define orz  1000000007
using namespace std;
int n,h[100005],f[100005];
void u(int &x,int y){
    if(y<x)x=y;
}
int main(){
    scanf("%d",&n);
    for(int i=1;i<=n;++i)scanf("%d",h+i);
    for(int i=2;i<=n;++i){
        f[i]=f[i-1]+abs(h[i]-h[i-1]);
        if(i>2)u(f[i],f[i-2]+abs(h[i]-h[i-2]));
    }
    printf("%d\n",f[n]);
	//system("pause");
	return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using pull = pair<ull, ll>;
using pis = pair<int, string>;
#define all(x) (x).begin(), (x).end()
#define INF 1000000000
#define LLINF 10000000000000000ll
#define MOD 1000000007LL

struct UnionFind {
  vector<int> d;
  UnionFind(int n=0): d(n, -1) {}

  //functions
  void init_tree() {
    for (int i = 0; i < d.size(); i++) {
      d[i] = -1;
    }
  }
  
  int find(int x) {
    if (d[x] < 0) return x;
    return d[x] = find(d[x]);
  }

  bool unite(int x, int y) {
    x = find(x);
    y = find(y);
    if (x == y) return false;
    if (d[x] > d[y]) swap(x, y);
    d[x] += d[y];
    d[y] = x;
    return true;
  }

  bool same(int x, int y) {
    return find(x) == find(y);
  }

  int size(int x) {
    return -d[find(x)];
  }
};

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

  ll n, m;
  cin >> n >> m;
  UnionFind uf(n);
  for (int i = 0; i < m; i++) {
    int a, b;
    cin >> a >> b;
    a--, b--;
    uf.unite(a, b);
  }
  int ans = -1;
  for (int i = 0; i < n; i++) {
    ans = max(ans, uf.size(i));
  }
  cout << ans << endl;
}


Measured memory_bytes: 3968
#include <stdio.h>
#include <math.h>

int main(void) {
	int n, d, ans = 0;
	int x[10][20];

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

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

	for (int i = 0; i < n; ++i) {
		for (int j = 0; j < i; ++j) {
			int memo = 0;
			for (int k = 0; k < d; ++k) {
				memo += (x[i][k] - x[j][k]) * (x[i][k] - x[j][k]);
			}
			if (sqrt(memo) - (int)sqrt(memo) == 0) {
				++ans;
			}

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


	return 0;
}


Measured memory_bytes: 128
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
       
        Scanner sc = new Scanner(System.in);
        int hoge = sc.nextInt();
        char array[] = new char[hoge];
        String a = sc.next();
        int flag = 0;
        for(int i = 0; i < hoge; i++){
            array[i] = a.charAt(i);
        }
        if (hoge % 2 != 0){
            flag = 1;
        }else{
            for(int i = 0; i < hoge/2; i++){
                if(array[i] != array[hoge/2+i]){
                    flag = 1;
                }
            }
        }
        if(flag == 1){
            System.out.println("No");
        }else{
            System.out.println("Yes");
        }    
    }     
}

Measured memory_bytes: 21844
dbflag=""

def debug(*args):
  if ""!=dbflag: print(*args)

if ""!=dbflag: _INDATA=open(dbflag)

def readline():
  if ""!=dbflag:return _INDATA.readline()
  else: return input()


result = -1

N = int(readline())



import numpy as np

A1 = [int(i) for i in readline().split(' ')]
A2 = [int(i) for i in readline().split(' ')]
data = np.zeros((2,N),dtype=int)
data[0,0:N]=A1
data[1,0:N]=A2

#np.reshape(data,[2,N])

memo = np.zeros((2,N), dtype=int)
score = np.zeros((2,N), dtype=int)


def getScore(i,j):
	debug(i,j,data[i,j])
	if i < 0 or j < 0 : return 0

	
	if memo[i,j]: return score[i,j]
	
	return data[i,j] + max(getScore(i-1,j) ,  getScore(i,j-1))

result = getScore(1,N-1)
print(result)

Measured memory_bytes: 12444
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1LL<<62
#define inf 1000000007

vector<ll>a;
int main() {
	ll n;
	cin>>n;
	for(int i=0;i<n;i++){
		ll x;
		cin>>x;
		x-=(i+1);
		a.push_back(x);
	}
	sort(a.begin(),a.end());
	ll m;
	if(n%2!=0){
		m=a[(n+2-1)/2-1];
	}
	else{
		m=(a[n/2-1]+a[n/2])/2;
	}
	ll ans=0;
	for(int i=0;i<a.size();i++){
		ll now=abs(a[i]-m);
		ans+=now;
	}
	cout << ans;
	return 0;
}

Measured memory_bytes: 2420
#include <bits/stdc++.h>
    using namespace std;
    int main()
    {
        //std::ios::sync_with_stdio(false);
        int T=1;
        //cin>>T;
        // cin.ignore(); must be there when using getline(cin, s)
        while(T--)
        {
            int n;
            cin>>n;
            double a[n];
            for(int i=0;i<n;i++)
                cin>>a[i];
            double dp[n+2][n+2]={0};
            dp[0][0]=1;
            for(int i=0;i<n;i++)
            {
                for(int j=0;j<n;j++)
                {
                    dp[i+1][j+1]+=dp[i][j]*a[i];
                    dp[i+1][j]+=dp[i][j]*(1.0-a[i]);
                }
            }
            double ans=0;
            //int i=n/2;
            //i++;
            for(int i=n/2+1;i<=n;i++)
                ans+=dp[n][i];
             printf("%.15lf\n", ans);
        }
        return 0;
    }


Measured memory_bytes: 70656
#include <bits/stdc++.h>
//#define int long long

using namespace std;
using LL = long long;
using P = pair<int, int>;

#define FOR(i, a, n) for(int i = (int)(a); i < (int)(n); ++i)
#define REP(i, n) FOR(i, 0, n)

#define pb(a) push_back(a)
#define all(x) (x).begin(),(x).end()

template<typename T>
vector<T> make_v(size_t a){return vector<T>(a);}
template<typename T,typename... Ts>
auto make_v(size_t a, Ts... ts) {return vector<decltype(make_v<T>(ts...))>(a, make_v<T>(ts...)); }

template<typename T,typename V>
typename enable_if<is_class<T>::value == 0>::type
fill_v(T &t, const V &v){ t = v; }

template<typename T,typename V>
typename enable_if<is_class<T>::value != 0>::type
fill_v(T &t, const V &v){ for(auto &e : t) fill_v(e, v); }

const int INF = (int)1e9;
const LL INFL = (LL)1e18;
const int MOD = 1e9 + 7;

signed main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int n, d;
    cin >> n >> d;
    
    int ans = 0;
    while(n > 0)
    {
        ans++;
        n -= d*2+1;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
mod = int(1e9+7)
def add(a, b):
    c = a + b
    if c >= mod:
        c -= mod
    return c

def main():
    INF = 1e9+7
    
    x, n = map(int,raw_input().split())
    
    arr = map(int,raw_input().split())
    
    s = set(arr)
    
    ret = INF
    
    for num in range(102):
        if num not in s:
            diff = abs(num - x)
            ret_diff = abs(ret - x)
            if diff < ret_diff:
                ret = num
            elif diff == ret_diff and num < ret:
                ret = num
    
    print(ret)
    

main()

Measured memory_bytes: 85032
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;

public class Main {
    static final FS sc = new FS();  // 封装输入类
    static final PrintWriter pw = new PrintWriter(System.out);

    public static void main(String[] args) {
        int n = sc.nextInt();
        int[] a = sc.nextArray(n);
        int res = 0;
        for(int i = 0;i < n;i++) {
            for(int j = i + 1;j < n;j++) {
                if (a[i] == a[j]) {
                    continue;
                }
                int sum = a[i] + a[j];
                int diff = a[i] - a[j];
                for(int k = j + 1;k < n;k++) {
                    if (a[i] == a[k] || a[j] == a[k]) {
                        continue;
                    }
                    if (sum > a[k] && diff + a[k] > 0
                        && a[k] > diff) {
                        res++;
                    }
                }
            }
        }
        pw.println(res);
        pw.flush();
    }

    static class FS {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        StringTokenizer st = new StringTokenizer("");
        String next() {
            while(!st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch(Exception ignored) {}
            }
            return st.nextToken();
        }
        int[] nextArray(int n) {
            int[] a = new int[n];
            for(int i = 0;i < n;i++) {
                a[i] = nextInt();
            }
            return a;
        }
        int nextInt() {
            return Integer.parseInt(next());
        }
        long nextLong() {
            return Long.parseLong(next());
        }
    }
}

Measured memory_bytes: 33492
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int a = sc.nextInt();
        int b = sc.nextInt();
        int[] h = new int[n];

        for (int i = 0; i < n; i++) {
            h[i] = sc.nextInt();
        }

        long ans = solve(n, a, b, h);
        System.out.println(ans);
    }

    static long solve(int n, int a, int b, int[] h) {

        // 最大HP / b を求めることで最大攻撃回数の上限を決めておく
        long maxHp = 0L;
        for (int i = 0; i < n; i++) {
            maxHp = Math.max(h[i], maxHp);
        }

        long L = 0;
        long R = (maxHp / b);
        while (L <= R) {
            long t = (L + R) / 2;

            if (isEnough(t, h, a, b)) {
                L = t + 1;
            } else {
                R = t - 1;
            }
        }

        return L;
    }

    private static boolean isEnough(long t, int[] h, int a, int b) {
        long atackTimes = 0;
        for (int hp : h) {
            if (hp > b * t) {
                double remain = (double) hp - b * t;
                double addDamage = (double) (a - b);
                atackTimes += (int) Math.ceil(remain / addDamage);
            }
        }
        return atackTimes > t;
    }
}


Measured memory_bytes: 49016
#include <stdio.h>

int main() {

  int a,b,c;
  scanf("%d %d %d",&a,&b,&c);

  if(((a<c)&&(c<b))||((a>c)&&(c>b))){
    printf("Yes\n");
  } else {
    printf("No\n");
  }

  return 0;

}  


Measured memory_bytes: 128
W,H,N=map(int,input().split(' '))
info = [[0],[W],[0],[H]] #min_x,max_x,min_y,max_y
for i in range(N):
  x,y,a=map(int,input().split(' '))
  info[a-1].append([x,y][(a-1)//2])
print(max(min(info[1])-max(info[0]),0)*max(min(info[3])-max(info[2]),0))

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

using lint = long long int;
using pint = pair<int, int>;
using plint = pair<lint, lint>;
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((lint)(x).size())
#define POW2(n) (1LL << (n))
#define FOR(i, begin, end) for (int i = (begin), i##_end_ = (end); i < i##_end_; i++)
#define IFOR(i, begin, end) for (int i = (end)-1, i##_begin_ = (begin); i >= i##_begin_; i--)
#define REP(i, n) FOR(i, 0, n)
#define IREP(i, n) IFOR(i, 0, n)
#ifdef LOCAL
#define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
#define eprintf(...) 42
#endif

int main()
{

    lint m, d;
    cin >> m >> d;
    lint d1, d10;

    lint ans=0, tmp;

    FOR(i, 1, m+1){
        FOR(j, 1, d + 1)
        {
            d10 = j / 10;
            d1 = j - d10 * 10;
            if(d10<2 || d1<2)
                continue;
            if (d1 * d10 == i)
                ans += 1;
        }
    }
    
    cout << ans <<"\n";

    return 0;
}

Measured memory_bytes: 256
using System;
using System.Linq;
using System.Collections.Generic;

namespace Algorithm
{
    class Program
    {
        static void Main(string[] args)
        {
            var S = Console.ReadLine();
            
            var left = 0;
            var right = S.Length-1;
            var ans = 0;
            while (left < right) {
                if (S[left] == S[right]) {
                   left++;
                   right--; 
                } else if (S[left] == 'x') {
                   ans++;
                   left++; 
                } else if (S[right] == 'x') {
                   ans++;
                   right--; 
                } else {
                   Console.WriteLine(-1);
                   return;
                }
            }
            
            Console.WriteLine(ans);
        }
    }
}


Measured memory_bytes: 13280
#include <bits/stdc++.h>
#define rep(i, a, n) for (int i = a; i < n; i++)
#define repr(i, a, n) for (int i = n - 1; i >= a; i--)
using namespace std;
using ll = long long;
using P = pair<int, int>;
template <typename T> void chmin(T &a, T b) { a = min(a, b); }
template <typename T> void chmax(T &a, T b) { a = max(a, b); }

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

  int n;
  cin >> n;
  vector<int> v(n), diff(n);
  rep(i, 0, n) {
    cin >> v[i];
    diff[i] = v[i] - i;
  }

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

  int c = diff[n / 2];
  ll ans = 0;
  rep(i, 0, n) ans += abs(v[i] - (c + i));

  cout << ans << endl;
}


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

typedef complex<double> P;

#define EPS (1e-10)

double cross(P a,P b){
	return (a.real() * b.imag() - a.imag() * b.real());
}

int is_intersected_ls(P a1,P a2,P b1,P b2){
	return ((cross(a2-a1,b1-a1) * cross(a2-a1,b2-a1) < EPS) &&
					(cross(b2-b1,a1-b1) * cross(b2-b1,a2-b1) < EPS));
}

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

	while(n--){
		P p[3],k,s;

		for(int i=0;i<3;i++){
			cin>>p[i].real()>>p[i].imag();
		}
		cin>>k.real()>>k.imag();
		cin>>s.real()>>s.imag();

		int count = 0;
		count += is_intersected_ls(k,s,p[0],p[1]);
		count += is_intersected_ls(k,s,p[1],p[2]);
		count += is_intersected_ls(k,s,p[2],p[0]);

		if(count == 1){
			cout<<"OK\n";
		}
		else{
			cout<<"NG\n";
		}
	}

	return 0;
}

Measured memory_bytes: 944
#include <bits/stdc++.h>
using namespace std;
vector<int>v[100009];
int x,y,n,m,i,ans,d[100009];
int dp(int i){
    if(d[i]!=-1) return d[i];
    d[i]=0;
    for(int j=0;j<v[i].size();j++)
        d[i]=max(d[i],1+dp(v[i][j]));
    return d[i];
}
int main()
{
    cin>>n>>m;
    memset(d,-1,sizeof d);
    for(i=0;i<m;i++) {
        cin>>x>>y;
        v[x].push_back(y);
    }
    for(i=1;i<=n;i++) ans=max(ans,dp(i));
    cout<<ans;
    return 0;
}


Measured memory_bytes: 8192
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)
#define INF (long long)1 << 61
#define MOD 1000000007
using namespace std;

typedef pair<int, int> P;
typedef pair<llong, llong> LP;
typedef pair<int, P> PP;
typedef pair<llong, LP> LPP;
typedef vector<llong> LV;

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

int main() {
	string s;cin >> s;
    cout << ((s=="ABC") ? "ARC": "ABC" )<< endl;
    return 0;
}


Measured memory_bytes: 3564
import sys

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

mod = 10 ** 9 + 7


def p(n, r):
    if n < r:
        return 0
    return fact[n] * invs[n - r] % mod


def dfs(v, bf):
    global ans
    if v == 0:
        ans *= p(k, len(es[v]) + 1)
        ans %= mod
    else:
        ans *= p(k - 2, len(es[v]) - 1)
        ans %= mod

    for nv in es[v]:
        if nv == bf: continue
        dfs(nv, v)


n, k = map(int, input().split())

es = [[] for _ in range(n)]
for _ in range(n - 1):
    a, b = map(int, input().split())
    a -= 1
    b -= 1
    es[a].append(b)
    es[b].append(a)

fact = [1]
for i in range(1, k + 1):
    fact.append(fact[-1] * i % mod)

invs = [None] * (k + 1)
invs[k] = pow(fact[-1], mod - 2, mod)
for i in range(k - 1, -1, -1):
    invs[i] = invs[i + 1] * (i + 1) % mod

ans = 1
dfs(0, -1)
print(ans)


Measured memory_bytes: 87276
#include <bits/stdc++.h>
#ifdef DEMETRIO
#define deb(...) fprintf(stderr,__VA_ARGS__)
#define deb1(x) cerr << #x << " = " << x << endl
#else
#define deb(...) 0
#define deb1(x) 0
#endif
#define pb push_back
#define mp make_pair
#define fst first
#define snd second
#define fore(i,a,b) for(int i=a,ThxDem=b;i<ThxDem;++i)
#define SZ(x) ((int)(x).size())
#define mset(a,v) memset(a,v,sizeof(a))
#define mcpy(a,b) memcpy(a,b,sizeof(a))
using namespace std;
typedef long long ll;

int n,k,a[128];
bool f[100005];

int main(){
	scanf("%d%d",&n,&k);
	fore(i,0,n)scanf("%d",a+i);
	fore(i,1,k+1)fore(j,0,n)if(a[j]<=i&&!f[i-a[j]])f[i]=true;
	puts(f[k]?"First":"Second");
	return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cstdlib>
#include <string>
#include <cstring>
#include <cmath>
#include <climits>
#include <ctime>
#define endl '\n'
#define ll long long
#define mod 1000000007
#define NCONS 1000000000
//#define NCONS 100001
//#define NCONS 1001
//#define NCONS 101
#define MCONS 2001
#define LIMIT 1000000000
#define TRUE 1
#define FALSE 0

using namespace std;

int h, w;
struct Point{int x; int y; int depth;};
vector<string> grid;
bool visited[1000][1000];
queue<Point> quu;
int dx[] = {0, 1, 0, -1};
int dy[] = {1, 0, -1, 0};
int ret = 0;

void bfs()
{
    while(!quu.empty())
    {
        auto cur = quu.front(); quu.pop();
        ret = max(ret, cur.depth);
        
        for(int i = 0; i < 4; i++)
        {
            auto nx = cur.x + dx[i], ny = cur.y + dy[i];
            if(min(nx, ny) < 0 || nx >= h || ny >= w) continue;
            if(visited[nx][ny]) continue;
            
            visited[nx][ny] = true;
            quu.push(Point{nx, ny, cur.depth + 1});
        }
    }
}


int main(void)
{
    cin.tie(NULL); ios_base::sync_with_stdio(false);
    cin >> h >> w;
    for(int i = 0; i < h; i++) { string t; cin >> t; grid.push_back(t); }
    
    for(int i = 0; i < h; i++)
        for(int j = 0; j < w; j++)
            if(grid[i][j] == '#')
            {
                visited[i][j] = true;
                quu.push(Point{i, j, 0});
            }
    
    bfs();
    
    cout << ret << endl;
   
    return 0;
}


Measured memory_bytes: 14352
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <string>
#include <cmath>
#include <vector>
#include <queue>
typedef long long ll;
using namespace std;

int main(void){
  int n,i,sum=0;
  int b[100];

  cin>>n;
  for(i=0;i<n-1;i++){
    cin>>b[i];
  }

  sum+=b[0];
  for(i=1;i<n-1;i++){
    sum+=min(b[i-1],b[i]);
  }
  sum+=b[n-2];

  cout<<sum<<endl;

  return 0;
}


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

int main() {
	int N,M;
	cin >> N >> M;
	int t=1900*M + 100*(N-M);
	
	for(int i=0; i<M; i++){
		t*=2;
	}
	cout << t << endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<algorithm>
#include<vector>
#include<functional>
#include<iomanip>
#include<queue>
#include<cassert>
#include<tuple>
#include<set>
#include<map>
#include<list>
#include<bitset>
#include<utility>
#include<numeric>

#define PB push_back
#define all(a)  (a).begin(),(a).end()
#define ALL(v) begin(v), end(v)
#define DWN(a)  (a).begin(),(a).end(), greater<int>()
#define rep(i, m) for (int i = 0; i < m; i++)
#define REP(i, n, m) for (int i = n; i < m; i++)
#define V vector<int>
#define VV vector<V>
#define VVV vector<VV>

using namespace std;

typedef long long ll;
typedef pair<int, int> P;

const int dx[4] = { 1, 0, -1, 0 };
const int dy[4] = { 0, 1, 0, -1 };
const int INF = (int)1e9;
const ll inf = (ll)1e18;
const ll MOD{ (ll)1e9 + 7 };
const long double EPS = 1e-10;

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

	int minus = 1;
	for (int i = 0; i < n; i++) {
		if (a[i] % 2 == 0) {
			minus *= 2;
		}
	}

	cout << pow(3, n) - minus << endl;
	return 0;
}

Measured memory_bytes: 512
$N=<>;$C=1e9;
push@a,[/./g]for<>;
for$x(0..$N-1){
	for$y(0..$N-1){
		$s[$x]+=$a[$y][$x]eq'#'
	}
	$A+=$s[$x]==$N;
	$e|=$s[$x]
}
for$y(0..$N-1){
	$c=!$s[$y];
	for$x(0..$N-1){
		$c+=$a[$y][$x]eq'.'
	}
	$C-=$-=$C-$c
}
print$e?$C+$N-$A:-1,$/


Measured memory_bytes: 20480
#include <stdio.h>

int main() {
    long long n;
    scanf("%lld", &n);

    long long sum = 0;
    for (long long i = 1; i <= n; i++) {
        // if (!(n % 3 == 0 || n % 5 == 0))
        if (i % 3 != 0 && i % 5 != 0)
            sum = sum + i;
    }

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

    return 0;
}

Measured memory_bytes: 1700
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define int long long
#define mod 1000000007
int n,m;
int a[114514],b[114514],c,d;
signed main(){
	cin>>n>>m;
	rep(i,n){
		cin>>a[i];
		if(i)c+=(a[i]-a[i-1])*i*(n-i);
		c%=mod;
	}
	rep(i,m){
		cin>>b[i];
		if(i)d+=(b[i]-b[i-1])*i*(m-i);
		d%=mod;
	}
	cout<<c*d%mod<<endl;
	return 0;
}


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

using namespace std;
#define DBG(x)                         \
    (void)(cout << "L" << __LINE__     \
                << ": " << #x << " = " \
                << (x) << '\n')

typedef long long ll;
using pii = pair<int, int>;
using pli = pair<ll, int>;
using pll = pair<ll, ll>;
const int INF = 0x3f3f3f3f;
const int maxn = 110000;
double calc(double sx, double sy, double nx, double ny)
{
    return sqrt((sx - nx) * (sx - nx) + (sy - ny) * (sy - ny));
}
int main()
{
    //检查有没有特判0,有没有越界限.
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << setiosflags(ios::fixed) << setprecision(12);
    int n;
    cin >> n;
    vector<int> cnt(n);
    for (int i = 0; i < n; i++)
    {
        cnt[i] = i;
    }
    vector<double> x(n), y(n);
    for (int i = 0; i < n; i++)
    {
        cin >> x[i] >> y[i];
    }
    double sum = 0.0;
    do
    {
        for (int i = 0; i < n - 1; i++)
        {
            int pos1 = cnt[i], pos2 = cnt[i + 1];
            sum += calc(x[pos1], y[pos1], x[pos2], y[pos2]);
        }
    } while (next_permutation(cnt.begin(), cnt.end()));
    int num = 1;
    for (int i = n; i >= 2; i--)
    {
        num *= i;
    }
    cout << sum / num << "\n";
    return 0;
}

Measured memory_bytes: 3800
#define F first
#define S second
#define EPS 1E-10
using namespace std;
#define pb push_back
#define mp make_pair
#define inf 0x3f3f3f3f
#include <bits/stdc++.h>
#define int64 long long int
#define infl 0x3f3f3f3f3f3f3f3fll
#define uint64 unsigned long long int
#define BLACK 1
#define WHITE 2


const int N = 100010;
vector <int> G[N];
int n, f, col[N], pa[N];

void dfs (int u, int p, int color, int god)
{
	if (u == god) f = 1;
	if (f) col[u] = color;
	for (int v : G[u]) if (v != p) {
		dfs (v, u, color, god);
	}
	if (u == god) f = 0;
}

void dfss (int u, int p)
{
	pa[u] = p;
	for (int v : G[u]) if (v != p) {
		dfss (v, u);
	}
}

void dfsss (int u, int p, int color)
{
	for (int v : G[u]) if (v != p) {
		if (col[v]) continue;
		col[v] = color;
		dfsss (v, u, color);
	}
}
int main ()
{
	scanf ("%d", &n);
	for (int i = 0; i < n - 1; i++) {
		int x, y;
		scanf ("%d %d", &x, &y);
		G[x].pb (y);
		G[y].pb (x);
	}
	dfs (1, 0, WHITE, n);
	dfs (n, 0, BLACK, 1);
	dfss (1, 0);
	vector <int> v;
	int xy = pa[n];
	while (xy != 1) {
		v.pb (xy);
		xy = pa[xy];
	}
	reverse (v.begin (), v.end ());
	int xyy = (v.size () + 1) / 2;
	for (int i = 0; i < v.size (); i++) {
		if (i < xyy) col[v[i]] = BLACK;
		else col[v[i]] = WHITE;
	}
	for (int i = 0; i < N; i++) {
		if (!col[i]) continue;
		dfsss (i, 0, col[i]);
	}
	int white = 0, black = 0;
	for (int i = 0; i < N; i++) {
		white += col[i] == 2;
		black += col[i] == 1;
	}
	if (black > white) puts ("Fennec");
	else puts ("Snuke");
	return 0;
}

Measured memory_bytes: 13304
#include <cstdio>
using namespace std;

int const MAXN = 999999;

int n;
bool is_prime[MAXN+1];

void check_prime()
{
    for (int i = 0; i <= MAXN; i++) is_prime[i] = true;
    is_prime[0] = is_prime[1] = false;
    for (int i = 2; i <= MAXN; i++) {
        if (!is_prime[i]) continue;
        for (long long j = i * 2; j <= MAXN; j += i)
            is_prime[j] = false;
    }
}

int main()
{
    check_prime();
    while (scanf("%d", &n) != EOF) {
        int res = 0;
        for (int i = 0; i <= n; i++)
            if (is_prime[i]) res++;
        printf("%d\n", res);
    }
    return 0;
}

Measured memory_bytes: 3560
#include <stdio.h>

int main(void) {
  int i, n, c, ans = 0, a;
  scanf("%d%d", &n, &c);
  for(i = 0; i < c; ++i) {
    scanf("%d", &a);
    ans += a;
  }
  printf("%d\n", (ans + n) / (n + 1));
  return 0;
}



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

using namespace std;
using ll = long long;
using ii = pair<ll, ll>;

const int MAX { 3010 };
const ll MOD { 1000000007 }, oo { 1LL << 62 };

ll st[MAX][MAX][5];

ll dp(int r, int c, int q, int R, int C, map<ii, ll>& ks)
{
    if (r == R and c == C)
        return q < 3 ? ks[ii(r, c)] : 0LL;

    if (st[r][c][q] != -1)
        return st[r][c][q];

    ll res = 0;

    if (r < R)
    {
        res = dp(r + 1, c, 0, R, C, ks);

        auto it = ks.find(ii(r, c));

        if (it != ks.end() and q < 3)
            res = max(res, dp(r + 1, c, 0, R, C, ks) + it->second);
    }

    if (c < C)
    {
        res = max(res, dp(r, c + 1, q, R, C, ks));

        auto it = ks.find(ii(r, c));

        if (it != ks.end() and q < 3)
            res = max(res, dp(r, c + 1, q + 1, R, C, ks) + it->second);
    }

    st[r][c][q] = res;

    return res;
}

ll solve(int R, int C, map<ii, ll>& ks)
{
    memset(st, -1, sizeof st);

    return dp(1, 1, 0, R, C, ks);
}

int main()
{
    ios::sync_with_stdio(false);

    int R, C, K;
    cin >> R >> C >> K;

    map<ii, ll> ks;

    while (K--)
    {
        ll r, c, v;
        cin >> r >> c >> v;

        ks[ii(r, c)] = v;
    }

    auto ans = solve(R, C, ks);

    cout << ans << '\n';

    return 0;
}


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

using namespace std;
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef pair<int, int> P;
typedef pair<ll, ll> PL;
#define FOR(i, a, b) for(int i = (a); i < (b); ++i)
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define debug(x) cout << #x << ": " << x << endl
#define out(x) cout << x << endl
//#define int long long int
const int MOD = 1000000007;
const ll LINF = (ll)1e18 - 1;
const int INF = 1e9 - 1;
const double EPS = 0.000000001;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

void print(const vector<int> &v) {
  for(auto x : v) {
    cout << x << " ";
  }
  cout << endl;
}

signed main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n;
  cin >> n;
  vector<P> a;
  rep(i, n) {
    int b;
    cin >> b;
    a.emplace_back(b, i);
  }
  sort(all(a));
  rep(i, n) {
    cout << a[i].second + 1 << ' ';
  }
  cout << endl;
  return 0;
}


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

typedef long long ll;
#define REP(i, n, m) for(int i = n; i < m; i++)
#define REPR(i, n, m) for(int i = n; i >= m; i--)
#define LREP(i, n, m) for(ll i = n; i < m; i++)
#define LREPR(i, n, m) for(ll i = n; i >= m; i--)

#define P pair<int, int >


const ll INF = 1e12 + 1;
const int MOD = 1e9 + 7;



//---functions---//
int gcd(int a, int b){
    if(a < b) swap(a, b);
    return b?gcd(b, a%b):a;
}

int s2i(string num){stringstream ss; ss << num << flush; int n; ss >> n; return n;}
string i2s(int n){stringstream ss; ss << n << flush; return ss.str();}

bool firstCompare(const P& firstElof, const P& secondElof){
    return firstElof.first < secondElof.first;
}
bool secondCompare(const P& firstElof, const P& secondElof){
    return firstElof.second < secondElof.second;
}
//---------------//
//-----class-----//
class UnionFind{
    public:
        vector<ll> par; //parents
        vector<ll> siz; // sizes of set
        vector<ll> rank; // rank of each element 
    UnionFind(ll n): par(n), siz(n, 1LL), rank(n){
        LREP(i, 0, n) par[i] = i;
    }
    //initialization
    /*
    void init(ll n){
        par.assign(n);
        siz.assign(n, 1LL);
        rank.assign(n);
        LREP(i, 0, n) par[i] = i;
    }
    */

    // find the root of x
    ll find(ll x){
        if(par[x] == x) return x;
        else return par[x] = find(par[x]);
    }

    //Unite two set including x or y
    void unite(ll x, ll y){
        x = find(x);
        y = find(y);
        if(x == y) return;
        if(rank[x] < rank[y]){
            par[x] = y;
            siz[y] += siz[x];
        }else{
            par[y] = x;
            siz[x] += siz[y];
            if(rank[x] == rank[y]) rank[x]++;
        }
    }

    //Do x and y belong to the same set?
    bool issame(ll x, ll y){
        return find(x) == find(y);
    }

};

ll N;
int main(){
    cin.tie(0);
    cout.tie(0);
    ios::sync_with_stdio(false);
    cin >> N;
    ll ans = INF;
    LREP(i, 1, (ll) sqrt(N) + 1){
        if(N % i == 0){
            ans = min(ans, i + N / i - 2);
        }
    }

    cout << ans << '\n';
}


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

using namespace std;

int main(){
    int N, M;
    cin >> N >> M;
    int min = 0, max = 100001;
    for (int i = 0; i < M;i++){
        int l, r;
        cin >> l >> r;
        if(min < l)
            min = l;
        if(r < max)
            max = r;
    }
    int ans = max - min + 1;
    if(ans < 0)
        ans = 0;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
#include<string>

using namespace std;

signed main()
{
    string s; cin >> s;
    string t1,t2;
    int ret = 0, n = s.size(), index = n / 2 + 1;
    /* if( n == 1 ){
        printf( "%d\n", 0 );
        return 0;
    } */

    while( index > 0 ){
        t1 += "01";
        t2 += "10";
        index--;
    }
    if( s[0] == '0' )
    {

        for( int i = 0; i < n; i+= 2 ){
            if( s[i]  != t1[i] ) ret++;
        }
        for( int i = 1; i < n; i+= 2 ){
            if( s[i]  != t1[i] ) ret++;
        }
    }
    else
    {
        for( int i = 0; i < n; i+= 2 ){
            if( s[i]  != t2[i] ) ret++;
        }
        for( int i = 1; i < n; i+= 2 ){
            if( s[i]  != t2[i] ) ret++;
        }
    }
    printf( "%d\n", ret );
    return 0;
}

Measured memory_bytes: 768
import java.io.PrintWriter;
import java.util.Scanner;
import java.util.TreeSet;

public final class Main {

	private static final Scanner sc = new Scanner(System.in);
	static PrintWriter writer = new PrintWriter(System.out);

	public static void main(String[] args) {
		int Q = sc.nextInt();
		TreeSet<Long> set = new TreeSet<>();
		sc.next();
		long minima = sc.nextLong() << 32;
		set.add(minima);
		long upperSum = 0;
		long lowerSum = 0;
		long sumB = sc.nextInt();
		for (int i = 1; i < Q; i++) {
			int type = sc.nextInt();
			if (type == 1) {
				long a = (sc.nextLong() << 32) + i;
				sumB += sc.nextInt();
				set.add(a);
				if (a < minima) {
					lowerSum += a >> 32;
					if (set.size() % 2 == 0) {
						upperSum += minima >> 32;
						minima = set.lower(minima);
						lowerSum -= minima >> 32;
					}
				} else {
					upperSum += a >> 32;
					if (set.size() % 2 != 0) {
						lowerSum += minima >> 32;
						minima = set.higher(minima);
						upperSum -= minima >> 32;
					}
				}
			} else {
				int countU = set.size() / 2;
				int countL = (set.size() - 1) - countU;
				long ans = minima >> 32;
				long v = upperSum - ans * countU;
				v += ans * countL - lowerSum;
				v += sumB;
				writer.println(ans + " " + v);
			}
		}
		writer.flush();
	}

}

Measured memory_bytes: 165324
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
void p(vector<char> A){rep(i,A.size()){cout << A[i];}cout << endl;}
int f(int x){
    int cnt = 0;
    while(x%2 == 0){
        x /= 2;
        cnt++;
    }
    return cnt;
}

int main(){
    int n;
    cin >> n;
    vector<int> a(n);
    rep(i,n) cin >> a[i];
    int ans = 0;
    rep(i,n){
        ans += f(a[i]);
    }
    cout << ans << endl;
}

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

using namespace std;


int main() {

    int N;
    cin >> N;
    vector<int> A;
    vector<int> B;
    int res = 0;
    for(int i = 0; i < N-1; ++i)
    {
        int a;
        cin >> a;
        A.push_back(a);
    }

    B.push_back(A[0]);

    for(int i = 1 ; i < N-1; ++i)
    {
        B.push_back(min(A[i],A[i-1]));
    }
//
//    if(N <= 3)
//    {
//        B.push_back(A[0]);
//    }

    B.push_back(A[N-2]);

    for(auto x : B)
    {
        //cout << x << endl;
        res += x;
    }
    cout << res << endl;

    return 0;
}


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

using namespace std;
#define ll long long


int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int a, b, c;
    cin >> a >> b >> c;
    swap(a, b);
    swap(a, c);
    cout << a << " " << b << " " << c;
    return 0;
}

Measured memory_bytes: 256
n, Y = [int(s) for s in input().split(' ')]
 
max_x = int(Y/10000)
for x in range(min(n, max_x), -1, -1):
    if Y < x * 10000 or n < x:
        continue
    
    max_y = int((Y-x*10000)/5000)
    for y in range(min(n-x, max_y), -1, -1):
        if Y < x*10000+y*5000 or n < x+y:
            continue
            
        z = int((Y-x*10000-y*5000)/1000)
        if (Y-x*10000-y*5000) % 1000 == 0 and n == x+y+z:
            print('{} {} {}'.format(x, y, z))
            exit()
            
print('-1 -1 -1')

Measured memory_bytes: 3064
#include <iostream>
#include <algorithm>
using namespace std;
int main(){
	string s,a,b;
	int ret = 0;
	while(cin >> s){
		a = s.substr(0,s.length()/2+s.length()%2);
		b = s.substr(s.length()/2,s.length()/2+s.length()%2);
		reverse(b.begin(),b.end());
		if(a==b)ret++;
	}
	cout << ret << endl;
}

Measured memory_bytes: 0
n = gets.to_i
arr = gets.chomp.split(" ")

def bubble_sort(n, arr)
  flag = true
  i = 0
  sort_num = 0
  while flag do
    flag = false
    ((i+1)..(n-1)).reverse_each do |j|
      if arr[j][1] < arr[j-1][1]
        org_arr_j = arr[j]
        arr[j] = arr[j-1]
        arr[j-1] = org_arr_j
        sort_num += 1
        flag = true
      end
    end
    i += 1
  end
  arr
end

def selection_sort(n, arr)
  n.times do |i|
    minj = i
    for j in i..(n-1)
      if arr[j][1] < arr[minj][1]
        minj = j
      end
    end
    if arr[i] != arr[minj]
      org_arr_i = arr[i]
      arr[i] = arr[minj]
      arr[minj] = org_arr_i
    end
  end
  arr
end

bubble_result = bubble_sort(n, arr.dup)
puts bubble_result.join(' ')
puts "Stable"

selection_result = selection_sort(n ,arr.dup)
puts selection_result.join(' ')
if selection_result == bubble_result
  puts "Stable"
else
  puts "Not stable"
end


Measured memory_bytes: 6880
#include<stdio.h>

int main(){
  int n,i,j,k,v,a[1000];

  scanf("%d",&n);
  for(k = 0;k < n;k++){
    scanf("%d",&a[k]);
    if(k<n-1){
      printf("%d ",a[k]);
    }
    else if(k==n-1){
      printf("%d",a[k]);
    }
    
  }
  printf("\n");
  for(i = 1;i < n;i++){
    v = a[i];
    j = i-1;
    while(j >= 0 && a[j] > v){
      a[j+1] = a[j];
      j--;
      a[j+1] = v;
    }
    for(k = 0;k < n;k++){
      if(k<n-1){
	printf("%d ",a[k]);
      }
      else if(k==n-1){
	printf("%d",a[k]);
      }
    }
    
    printf("\n");
  }
  
  return 0;
}

Measured memory_bytes: 608
#include <iostream>
#include <vector>
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];
	ll ret=a[0]/2;	a[0]%=2;
	for(int i=1;i<n;i++){
		if(a[i-1]&&a[i]){
			ret++;	a[i-1]--;	a[i]--;
		}
		ret+=a[i]/2;
		a[i]%=2;
	}
	cout<<ret<<endl;
	return 0;
}


Measured memory_bytes: 1024
#include <stdio.h>

int main()
{
    int r;
    scanf("%d",&r);    
    if(r < 1200)
    {
        printf("ABC");
    }
    else if (r < 2800)
    {
        printf("ARC");
    }
    else
    {
        printf("AGC");
    }
    
    
}

Measured memory_bytes: 128
var
	N,i,j,c,a,b,p,q:Longint;
	F:Array[0..8]of Longint=(1,1,2,6,24,120,720,5040,40320);
	Pe,Qe:Array[1..8]of Boolean;
begin
	read(N);
	for i:=1 to N do begin
		read(p);
		c:=0;
		for j:=1 to p-1 do if not Pe[j]then inc(c);
		inc(a,c*F[N-i]);
		Pe[p]:=True;
	end;
	for i:=1 to N do begin
		read(q);
		c:=0;
		for j:=1 to q-1 do if not Qe[j]then inc(c);
		inc(b,c*F[N-i]);
		Qe[q]:=True;
	end;
	if a<b then writeln(b-a)else writeln(a-b);
end.

Measured memory_bytes: 128
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**7)

n, q = map(int, input().split())
edges = [[] for _ in range(n)]

for _ in range(n-1):
    a, b = map(int, input().split())
    a -= 1
    b -= 1
    edges[a].append(b)
    edges[b].append(a)

count = [0]*n
for i in range(q):
    p, x = map(int, input().split())
    count[p-1] += x


def dfs(v, parent):
    for v2 in edges[v]:
        if v2 == parent:
            continue
        count[v2] += count[v]
        dfs(v2, v)


dfs(0, None)
print(*count)


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

int a, b, c, x;

int main() {
  cin >> a >> b >> c >> x;
  int ans = 0;
  for (int i = 0; i <= a; i++) {
    for (int j = 0; j <= b; j++) {
      for (int k = 0; k <= c; k++) {
        if (500 * i + 100 * j + 50 * k == x) {
          ans++;
        }
      }
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
/*																													   
 Templatka c++ Kacper Fis																							   																											   //
*/																													  
																								   
#include <bits/stdc++.h>																							   
																													   
using namespace std; 																								   
																													   
const int INF = 1000000001;																						   
const float PI = 3.14;																								   
typedef long long LL;																								   
																													   
typedef vector<int> vi;																								   
typedef list<int> li;																								   
typedef queue<int> qi; 																								   
typedef pair<int,int> ii; 																							   
typedef map<string,int> msi; //np msi['nazwa'] = 'liczba'															   
typedef vector<ii> vii; //vector par<int>, do tworzenia tablicy dla grafów wagowych #dijkstra #Bellman_Ford			   
typedef priority_queue< ii, vector<ii>, greater<ii> > pq; //kolejka priorytetowa vectorów par(top()=min) #dijkstra	   
																													   																				   
vector<ii>::iterator iter;																							   
																													   																				   
#define print_list(x) for(it = (x).begin(); it != (x).end(); it++) {cout << *it << " ";}							   
#define print_vector(x) for(it2 = (x).begin(); it2 != (x).end(); it2++) {cout << *it2 << " ";}						   
#define search_list(x) for(it = (x).begin(); it != (x).end(); it++)													   
#define search_vector(x) for(it2 = (x).begin(); it2 != (x).end(); it2++);											   
#define pb(x) push_back(x) 																							   
#define pf(x) push_front(x)																							   
#define mp(x, y) make_pair(x, y)                                                                                       
///////////////////////////////////////////////GLOBAL DEFINITIONS////////////////////////////////////////////////////////

bool tab[1000005];
int dp[1000005];

///////////////////////////////////////////////////FUNCTIONS/////////////////////////////////////////////////////////////


/////////////////////////////////////////////////////MAIN////////////////////////////////////////////////////////////////
int main(int argc, char* argv[])																					 
{ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);                  												       
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
    
    fill(tab, tab+1000001, 0);
    
	int n, m;
	cin >> n >> m;
	for(int i = 0; i < m; i++){
		int x;
		cin >> x;
		tab[x] = true;
	}
	
	dp[0] = 1;
	for(int i = 1; i <= n; i++){
		if(tab[i-1] == true && tab[i-2] == true){
			cout << "0" << "\n";
			return 0;
		}
		if(tab[i-1]){
			dp[i] = (dp[i-2] % 1000000007);
		}
		else if(tab[i-2]){
			dp[i] = (dp[i-1] % 1000000007);
		}
		else dp[i] = ((dp[i-1] + dp[i-2]) % 1000000007);
	}
	
	cout << dp[n] << endl;
	
	
	
	
	
	
	return 0;
}


Measured memory_bytes: 3456