akhauriyash/Code-Regression huggingface dataset:
N, M = map(int, input().split())

s = []
c = []

for i in range(M):
    s_e, c_e = map(int, input().split())
    s.append(s_e)
    c.append(c_e)

ans = -1

for i in range(1000):
    str_i = str(i)
    len_str_i = len(str_i)
    if len_str_i != N:
        continue
    else:
        for k in range(M):
            if str_i[s[k]-1] != str(c[k]):
                break
        else:
            ans = i
            break

print(ans)


Measured memory_bytes: 3064
n,x=map(int, input().split())
a=list(map(int, input().split()))
b=a[::]
if a[0]>x:
    a[0]=x
for i in range(n-1):
    if a[i]+a[i+1]>x:
        a[i+1]=x-a[i]
ans=0
for i in range(n):
    ans+=b[i]-a[i]
print(ans)

Measured memory_bytes: 14252
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
using namespace std;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;

int main()
{
    ll a, b, n;
    cin >> a >> b;
    n = 1;
    for (ll i = 2; i <= a || i <= b; i++)
    {
        while (a % i == 0 || b % i == 0)
        {
            n *= i;
            if (a % i == 0)
            {
                a /= i;
            }
            if (b % i == 0)
            {
                b /= i;
            }
        }
    }
    cout << n << endl;

    return 0;
}

Measured memory_bytes: 256
import java.util.*;
public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int k = sc.nextInt();
		int[] x = new int[n];
		int plus = 0;
		int minus = 0;
		int zero = 0;
		int z = 0;
		for(int i=0; i<n; i++){
			x[i] = sc.nextInt();
		}
		int dist = Math.abs(x[0])+x[n-1]-x[0];
		for(int i=0; i<=n-k; i++){
			dist = Math.min(dist, Math.min(Math.abs(x[i]),Math.abs(x[i+k-1]))+x[i+k-1]-x[i]);
		}
		System.out.println(dist);
	}
}

Measured memory_bytes: 50256
al = 'abcdefghijklmnopqrstuvwxyz'
AL = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
a, b = map(int,input().split())
s = input()
ans = ''
for i in range(a):
    if i == b-1:
        ans += al[AL.index(s[i])]
    else:
        ans += s[i]
print(ans)

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

using namespace std;

inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

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

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

#define MP make_pair
#define EACH(i,c) for(auto i: c)
#define SORT(c) sort((c).begin(),(c).end())

#define ALL(a)  (a).begin(),(a).end()

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	int H, W, K;
	cin >> H >> W >> K;

	vector<string> S(H);
	REP(i, H) cin >> S[i];

	int ret = 0;

	REP(i, 1 << (W + H))
	{
		vector<string> A = S;
		int count = 0;
		REP(j, H){
			if((i >> j) & 0x01){
				REP(k, W) A[j][k] = '*';
			}
		}
		REP(j, W){
			if((i >> (H + j) & 0x01)){
				REP(k, H) A[k][j] = '*';
			}
		}
		REP(r, H){
			REP(c, W) if(A[r][c] == '#') count++;
		}
		if(count == K) ret++;
	}

	cout << ret << endl;


	return 0;
}


Measured memory_bytes: 3192
#include <stdio.h>
#include <iostream>
#include <algorithm>
using namespace std;
#define N (int)1e5
#define mod (int)(1e9 + 7)
typedef long long LL;
LL n, a, b, c, d, s;
LL dp[1001][1001], inv[3333], fact[1001];
int extgcd(int a, int b, int& x, int& y)
{
	int d = a;
	if (b != 0)
	{
		d = extgcd(b, a % b, y, x);
		y -= (a / b) * x;
	}
	else
	{
		x = 1; y = 0;
	}
	return d;
}
int mod_inverse(int a, int m)
{
	int x, y;
	extgcd(a, m, x, y);
	return (m + x % m) % m;
}
int main()
{
	cin >> n >> a >> b >> c >> d;
	fact[0] = 1;
	inv[0] = 1;
	inv[1] = 1;
	for (int i = 1; i <= n; i++)
	{
		fact[i] = i;
		if (fact[i - 1]) {
			fact[i] *= fact[i - 1];
			fact[i] %= mod;
			inv[i] = mod_inverse(fact[i], mod);
		}
	}

	dp[a - 1][0] = 1;
	for (int i = a; i <= b; i++)
	{

		for (int k = 0; k <= n; k++)
		{
			s = 1;
			LL l = 0;
			for (int j = c; j <= d; j++)
			{

				if (i * j + k <= n)
				{
					for (l; l < j; l++)
					{
						s *= (fact[n - k - l * i] * inv[n - k - i - l * i]) % mod * inv[i] % mod;
						s %= mod;
					}
					s *= inv[j];
					s %= mod;
					dp[i][i * j + k] += (dp[i - 1][k] * s) % mod;
					dp[i][i * j + k] %= mod;
					s *= fact[j];
					s %= mod;
				}
				else
				{
					break;
				}
			}
		}
		for (int k = 0; k <= n; k++)
		{
			dp[i][k] += dp[i - 1][k];
			dp[i][k] %= mod;
		}
	}

	cout << dp[b][n] % mod << endl;
}

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

#define fst(t) std::get<0>(t)
#define snd(t) std::get<1>(t)
#define thd(t) std::get<2>(t)
#define unless(p) if(!(p))
#define until(p) while(!(p))

using ll = std::int64_t;
using P = std::tuple<int,int>;

constexpr ll MOD = 1'000'000'007;
int N;
int dp[110][4][4][4];

bool isAGC(int a, int b, int c){
    return a == 0 && b == 1 && c == 2;
}

ll rec(int i, int a, int b, int c){
    if(i == N){
        return 1;
    }

    if(dp[i][a][b][c] != -1){
        return dp[i][a][b][c];
    }

    ll cnt = 0;

    for(int j=0;j<4;++j){
        if(!isAGC(b, c, j) &&
           !isAGC(a, b, j) &&
           !isAGC(b, j, c) &&
           !isAGC(c, b, j) &&
           !isAGC(a, c, j)){
            cnt = (cnt + rec(i + 1, b, c, j)) % MOD;
        }
    }

    return dp[i][a][b][c] = cnt;
}

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

    std::cin >> N;

    memset(dp, -1, sizeof(dp));

    ll cnt = 0;

    for(int i=0;i<4;++i){
        for(int j=0;j<4;++j){
            for(int k=0;k<4;++k){
                if(!isAGC(i, j, k) &&
                   !isAGC(j, i, k) &&
                   !isAGC(i, k, j)){
                    cnt = (cnt + rec(3, i, j, k)) % MOD;
                }
            }
        }
    }

    std::cout << cnt << std::endl;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void) {
    
    unsigned int s;
    unsigned int m;
    unsigned int h;
    scanf("%d", &s);

    m = s / 60;
    h = m / 60;
    m = m % 60;
    s = s % 60;

    printf("%d:%d:%d\n", h, m, s);
}

Measured memory_bytes: 1020
#include <bits/stdc++.h>
  using namespace std;
#define ll long long
#define fw(p) for(int w=0;w<(p);w++)
#define fx(p) for(int x=0;x<(p);x++)
#define fy(p) for(int y=0;y<(p);y++)
#define fz(p) for(int z=0;z<(p);z++)
#define fyg(p,g) for(int y=(g);y<(p);y++)
#define fzg(p,g) for(int z=(g);z<(p);z++)
#define ce(d) cout<<d<<endl;
#define vecp(p) int aa;cin>>aa;(p).push_back(aa);
#define vecpl(p) long long aa;cin>>aa;(p).push_back(aa);
#define vecps(p) string aa;cin>>aa;(p).push_back(aa);
#define vecp2(p) cin>>aa;(p).push_back(aa);
#define vecpl2(p) long long ab;cin>>ab;(p).push_back(ab);
#define vecps2(p) string ab;cin>>ab;(p).push_back(ab);
#define set0(k,n) for(int nn=0;nn<(n);nn++){ (k).push_back(0); }
#define sorts(c) sort((c).begin(),(c).end());
#define reverses(c) reverse((c).begin(),(c).end());
#define vec(b) vector<int> (b);
#define vecl(b) vector<long long> (b);
#define vecs(b) vector<string> (b);
#define vecsize(b,size) vector<int> (b)((size));
#define pb(b,a) (b).push_back((a));
#define doublece(a,b) cout<<(a)<<' '<<(b)<<endl;
#define pairs(s) vector<pair<int,int>> (s);
#define pairsl(s) vector<pair<ll,ll>> (s);
#define pairss(s) vector<pair<string,string>> (s);
#define pairsp(s) int aa,bb;cin>>aa>>bb;(s).push_back(make_pair(aa,bb));
#define pairspl(s) int aa,bb;cin>>aa>>bb;(s).push_back(make_pair(aa,bb));
#define pairsps(s) int aa,bb;cin>>aa>>bb;(s).push_back(make_pair(aa,bb));
#define pairsREV(s) (s).push_back(make_pair(bb,aa));
#define pairslREV(s) (s).push_back(make_pair(bb,aa));
#define pairssREV(s) (s).push_back(make_pair(bb,aa));
#define MOD 1000000007

int gcd(int x,int y){
	
	if(x%y==0){
		return y;
	}else{
		return gcd(y,x%y);
	}
	
}

int main() {
	
	double T,X;
	cin>>T>>X;
	
	cout << fixed << setprecision(5) << T/X << endl; 
	
}

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

int main(){
	string s;
	int ans = 0;
	cin >> s;
	vector<int> n(s.size());
	rep(i, s.size()) n.at(i) = s[i] - '0';
	bool flag = false;
	if(s.size() > 1){
		for(int i = s.size()-1; i >= 0; i--){
			if(i == 0){
				ans += n.at(i) - 1;
				if(flag == false) ans++;
			}
			else ans += 9;
			if(n.at(i) != 9) flag = true;
		}
	}else{
		ans = n.at(0);
	}
	
	cout << ans << endl;
	
	return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
#include <iostream>
#include <set>
#include <cmath>
 
using namespace std;
int main(){
    long long int a,b;
    int n;
    cin>>n;
    for(int i=0; i<n;i++){
      long long  int aa, bb;
        cin>>aa>>bb;
        if(!i){
            a=aa;
            b=bb;
            continue;
        }
       long long int ka=a/aa+!!(a%aa);
        long long int kb=b/bb+!!(b%bb);
        long long int k=max(ka, kb);
        a=k*aa;
        b=k*bb;
    }
    cout<<a+b<<endl;
    return 0;
}

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

using namespace std;

int main() {

    int N, D;
    cin >> N >> D;
    
    int width = D * 2 + 1;
    
    int result = 0;

    while (N > 0)
    {
        N = N - width;
        result++;
    }
    
    cout << result;

    return 0;

}

Measured memory_bytes: 256
//#include "pch.h"
#include <stdio.h>
#include <math.h>
#include <string.h>
#include <stdlib.h>
#include <time.h>

#include <vector>
#include <set>
#include <map>
#include <iostream>
#include <utility>
#include <queue>
#include <algorithm>
#include <functional>
#include <string>
#include <bitset>

#define ll long long
#define fri(n) for(i=0;i<(n);i++)
#define frj(n) for(j=0;j<(n);i++)
#define min(p,q) ((p)<(q)?(p):(q))
#define max(p,q) ((p)>(q)?(p):(q))
#define INF 1000000000000000000//10^18
#define INFINT 2000000001//2*10^9+1
#define MOD 1000000007
#define MODANOTHER 998244353
#define PI acos(-1)

//#define int ll

using namespace std;



signed main(void)
{
	//変数の宣言
	int n,m;
	int h,w;
	static char s[20];

	//よく使う変数
	int i,j,k,l;
	int flag=0;
	int ans=0;
	int count=0;
	int temp=0;
	int temp1=0;
	int temp2=0;
	int temp3=0;
	static int vec[1010];
	int max=0;
	int min=INFINT;
	int len=0;
	int sum=0;
	int ok=0;
	int ng=0;
	char dummy;
	static char stemp[100010];
	
	//データの読み込み


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


//	scanf("%s",&s);
//	scanf_s("%s",&s,20);




/*	//scanf("%c",&dummy);
	scanf_s("%c",&dummy);
	for(i=0;i<n;i++){
//		scanf("%c",&s[i]);
		scanf_s("%c",&s[i]);
	}*/


/*	for(i=0;i<h;i++){
//		scanf("%s",&s[i]);
		scanf_s("%s",&s[i],1010);
	}*/


	//	printf("nは%dです\n", n);
	//	printf("データの読み込み終了\n");
	//実際の処理

//	clock_t start=clock();

	ans=0;
	temp=n/500;
	ans=ans+temp*1000;
	n=n-temp*500;
	
	temp=n/5;
	ans=ans+temp*5;

	printf("%d",ans);

	


//	clock_t end=clock();

	//	printf("計算部分終了\n");

	//出力
	
	//printf("%d",(d[i-1][j-1]+1)/2);

//	printf("time=%lf",(double)(end-start)/CLOCKS_PER_SEC);
	//	printf("結果の出力終了\n");

	return 0;
}



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

template<class T> inline void chmin(T& a, T b) {
    if (a > b) {
        a = b;
    }
}

template<class T> inline void chmax(T& a, T b) {
    if (a < b) {
        a = b;
    }
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N;
    cin >> N;
    vector<ll> H(N);
    REP(i,N)cin >> H[i];
    bool ng = 0;
    ll before = 0;
    REP(i,N){
        if(H[i] < before){
            ng = 1;
            before = H[i] - 1;
        }else if(H[i] > before){
            H[i]--;
            before = H[i];
        }
    }
    if(ng){
        cout << "No" << "\n";
    }else{
        cout << "Yes" << "\n";
    }
}

Measured memory_bytes: 1024
import numpy as np
from scipy.sparse.csgraph import csgraph_from_dense, floyd_warshall

N, M, L = [int(_) for _ in input().split()]
ABC = [[int(_) for _ in input().split()] for _ in range(M)]
Q = int(input())
ST = [[int(_) for _ in input().split()] for _ in range(Q)]
edge = np.full((N, N), 10**10, dtype=int)
for a, b, c in ABC:
    if c <= L:
        edge[a - 1][b - 1] = edge[b - 1][a - 1] = c
G = csgraph_from_dense(edge, null_value=10**10)
D = floyd_warshall(G)
D = D <= L
E = floyd_warshall(D)
INF = float('inf')
for s, t in ST:
    d = E[s - 1][t - 1]
    if d == INF:
        d = 0
    print(int(d) - 1)


Measured memory_bytes: 36184
// #pragma GCC optimize("O3")
#include <bits/stdc++.h>
#define ll long long
#define rep2(i,a,b) for(ll i=a;i<=b;++i)
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep3(i,a,b) for(ll i=a;i>=b;i--)
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pq priority_queue
#define pb push_back
#define eb emplace_back
#define vec vector<int>
#define vecll vector<ll>
#define vecpii vector<pii>
#define vec2(a,b) vector<vec>(a,vec(b))
#define vec2ll(a,b) vector<vecll>(a,vecll(b))
#define vec3(a,b,c) vector<vector<vec>>(a,vec2(b,c))
#define vec3ll(a,b,c) vector<vector<vecll>>(a,vec2ll(b,c))
#define fi first
#define se second
#define endl "\n"
#define all(c) begin(c),end(c)
#define ios ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define lb(c,x) distance(c.begin(),lower_bound(all(c),x))
#define ub(c,x) distance(c.begin(),upper_bound(all(c),x))
#define MM " "
using namespace std;
int in() {int x;cin>>x;return x;}
ll lin() {ll x;cin>>x;return x;}
template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
template<class T> inline void print(pair<T,T> p){cout<<"("<<p.first<<","<<p.second<<") ";}
template<class T> inline void print(vector<pair<T,T>> v){for(auto e:v)print(e); cout<<endl;}
template<class T> inline void print(T v){for(auto e:v)cout<<e<<" ";cout<<endl;}



main(){
    ios
    int a=in(),b=in();
    cout<<max(0,a-b*2)<<endl;
}



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

using namespace std;

#if __has_include("print.hpp")
  #include "print.hpp"
#endif

typedef long long ll;
typedef pair<ll,ll> p;

vector<ll> dp = {0, 1};

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

ll lcm(ll a, ll b)
{
  ll g = gcd(a, b);
  return a / g * b;
}

map<int, int> mp;

// O(root(n))
void count_divisor(int n){
  for (int i = 2; n > 1;)
  {
    if(n % i == 0){
      mp[i]++;
      n /= i;
    } else i++;
  }
}


int main()
{
  int n;
  cin >> n;
  vector<int> v(n-1, 0);

  for (int i = 2; i <= n; i++)
  {
    count_divisor(i);
  }

  ll res = 1;

  for(auto a : mp){
    res *= a.second + 1;
    res %= 1000000007;
  }

  cout << res << endl;
}


Measured memory_bytes: 256
#include <iostream>
#define REP(i, n) for (int i = 0; i < (n); i++)
using namespace std;

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

    int n;
    string s;
    cin >> n >> s;

    int count = 0;
    REP(i, n - 2) {
        if (s.substr(i, 3) == "ABC")
            count++;
    }

    cout << count << '\n';
    return 0;
}

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

#define N 100000

int main(void){
    ios::sync_with_stdio(false);
    vector<bool> prime(N+1,true);
    prime[0]=prime[1]=false;
    for (size_t i = 0; i <= sqrt(N); i++)
    {
        if (prime[i])
        {
            for (size_t j = 2; i*j <= N; j++)
            {
                prime[i*j]=false;
            }
        }
    }
    vector<int> likeCnt(N);
    for (size_t i = 1; i <= N; i++)
    {
        likeCnt[i]=likeCnt[i-1];
        if (i%2==1&&prime[i]&&prime[(i+1)/2])
        {
            likeCnt[i]++;
        }
    }
    /**************************************/
    int q;
    cin >> q;
    int l,r;
    for (size_t i = 0; i < q; i++)
    {
        cin >> l >> r;
        cout << likeCnt[r] - likeCnt[l-1] << "\n";
    }
    return 0;
}

Measured memory_bytes: 1152
#include <iostream>
#include <string>
#include <algorithm>

using namespace std;

int main() {
  int x1,y1,x2,y2;
  cin >> x1 >> y1 >> x2 >> y2;
  int x3,y3,x4,y4;
  x3 = x2 - y2 + y1;
  y3 = y2 + x2 - x1;
  x4 = x3 - x2 + x1;
  y4 = y3 - y2 + y1;
  cout << x3 << " " << y3 << " " << x4 << " " << y4 << endl;
  return 0;
}

Measured memory_bytes: 256
import bisect
import collections
import copy
import functools
import heapq
import math
import sys
from collections import deque
from collections import defaultdict
input = sys.stdin.readline
MOD = 10**9+7

N,M,P = map(int,(input().split()))
line = []
for i in range(M):
    a,b,c = map(int,(input().split()))
    line.append([a-1,b-1,-c+P])

min_distance = [float("inf")]*N # min_distance[i] は始点から街iまでの最短距離
min_distance[0] = 0 # 始点から始点への最短距離は0とする

flag = 0
for _ in range(N):
        update = False
        for s,g,d in line: # [s,g,d] = [道路の始点,道路の終点,道路の長さ] について、すべての道路を見る
            if min_distance[s] != float("inf") and min_distance[s] + d < min_distance[g]: # 最短経路が確立されている街から伸びる道路を通ることで、距離を短くできるならば、
                min_distance[g] = min_distance[s] + d # 最短距離を上書きする
                update = True
        if not update:
            flag = 1
            break

if flag == 1:
    ans = min_distance[N-1]
    print(max(-ans,0))
else:
    for _ in range(N):
        for s,g,d in line: # [s,g,d] = [道路の始点,道路の終点,道路の長さ] について、すべての道路を見る
            if min_distance[s] != float("inf") and min_distance[s] + d < min_distance[g]: # 最短経路が確立されている街から伸びる道路を通ることで、距離を短くできるならば、
                min_distance[g] = -float("inf")
                if g == N-1:
                    break
        else:
            continue
        break
    ans = min_distance[N-1]
    if ans == -float("inf"):
        print(-1)
    else:
        print(max(-ans,0))

#print(min_distance)


Measured memory_bytes: 75856
#include<iostream>
#include<cmath>
using namespace std;
int main(){
    int n;
    cin >> n;
    while(n--){
        double x1,x2,y1,y2,r1,r2;
        cin >> x1 >> y1 >> r1 >> x2 >> y2 >> r2;
        double dist = sqrt((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2));
        if(r1>r2){
            if(dist<(r1-r2))    cout << "2\n";
            else if(dist>=(r1-r2)&&dist<=(r1+r2))   cout << "1\n";
            else    cout << "0\n";
        }
        else{
            if(dist<(r2-r1)) cout << "-2\n";
            else if(dist>=(r2-r1)&&dist<=(r2+r1))   cout << "1\n";
            else    cout << "0\n";
        }
    }
    return 0;
}


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

int main(){
	int n,q,time;
	string name;
	queue< pair<string,int> > Q;
	cin>>n>>q;
	while(n--){
		cin>>name>>time;
		Q.push(make_pair(name,time)); 
	}
	int process = 0,cost;pair<string,int> m;
	while(!Q.empty()){
		m = Q.front(); Q.pop() ;
		cost = min(m.second ,q);
		m.second -= cost;
		process += cost;
		if(m.second > 0){
			Q.push(m);
		}
		else{
			cout<<m.first<<" "<<process<<endl;
		}
	}
	return 0;
} 


Measured memory_bytes: 6328
#include<bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()
using namespace std;

int main(){
  string s;
  int k;
  cin>>s>>k;
  int q;
  
  rep(i,s.size()){
    q = s.at(i)-'0';
    if(q!=1){
      cout <<q;
      return 0;
    }
    else if(i+1==k)break;
  }
  cout << 1;
}
    
      

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

int main(){
  string s;
  cin>>s;
  if(s=="A") cout<<"T"<<endl;
  else if(s=="T") cout<<"A"<<endl;
  else if(s=="C") cout<<"G"<<endl;
  else cout<<"C"<<endl;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

struct Item
{
  long long w;
  int v;
};

const long long PINF = 1000LL*1000LL*1000LL*1000LL;

int main()
{
  int n;
  long long W;
  cin >> n >> W;
  Item items[n];
  for (int i = 0; i < n; ++i)
    cin >> items[i].w >> items[i].v;
  int nbV = n*1000;
  long long dp[n+1][nbV+1];
  for (int i = 0; i < nbV + 1; ++i)
    dp[0][i] = PINF;
  dp[0][0] = 0;
  for (int i = 1; i < n + 1; ++i)
    for (int j = nbV; j >= 0; --j)
      dp[i][j] = min(dp[i-1][j], (j >= items[i-1].v) ? dp[i-1][j-items[i-1].v] + items[i-1].w :
		     (j < nbV) ? dp[i][j+1] : dp[i-1][j]);

  for (int i = nbV; i >= 0; --i)
    if (dp[n][i] <= W)
    {
      cout << i << '\n';
      return 0;
    }
}


Measured memory_bytes: 79104
S = input()
s = S.split("a")
H = S.split("a",1)
h=H[0]
B = S.rsplit("a",1)
b=B[1]
X = set(s)
if h in ["dre","er"]:
  if b in ["m","mer","se","ser"]:
    if X <= {"dre","er","m","mer","se","ser","mdre","merdre","mer","merer","sedre","serdre","seer","serer"}:
      print("YES")
    else:
      print("NO")  
  else:
    print("NO")
else:
  print("NO")
    

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

int main() {
  int n, C;
  cin >> n >> C;
  
  vector<vector<int>> d(C, vector<int>(C)), c(n, vector<int>(n)), x(3, vector<int>(C));
  for(int i = 0; i < C; i++){
    for(int j = 0; j < C; j++){
      cin >> d.at(i).at(j);
    }
  }
  for(int i = 0; i < n; i++){
    for(int j = 0; j < n; j++){
      cin >> c.at(i).at(j);
      x.at((i + j) % 3).at(c.at(i).at(j) - 1)++;
    }
  }
  
  int keep, ans = 1e9;
  for(int i = 0; i < C; i++){
    for(int j = 0; j < C; j++){
      if(i == j) continue;
      for(int k = 0; k < C; k++){
        if(i == k || j == k) continue;
        
        keep = 0;
        for(int l = 0; l < C; l++){
          keep += x.at(0).at(l) * d.at(l).at(i);
          keep += x.at(1).at(l) * d.at(l).at(j);
          keep += x.at(2).at(l) * d.at(l).at(k);
        }
        ans = min(ans, keep);
      }
    }
  }
  
  cout << ans << endl;
}

Measured memory_bytes: 1280
object Main {
  def main(args: Array[String]): Unit = {
    val Array(a, b, d, _*) = io.StdIn.readLine().split(" ").map(_.toDouble)

    val rad = d / 180 * Math.PI
    val h = b * Math.sin(rad)
    val s = a * h / 2
    val c = {
      val c2 = a * a + b * b - 2 * a * b * Math.cos(rad)
      Math.sqrt(c2)
    }

    println(f"$s%.8f")
    println(f"${a + b + c}%.8f")
    println(f"$h%.8f")
  }
}

Measured memory_bytes: 44004
#pragma region header
#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i <= (int)(n); i++)
#define rev(i, n) for(int i = (int)(n - 1); i >= 0; i--)
#define rev1(i, n) for(int i = (int)(n); i > 0; i--)
#define pb push_back
#define all(v) (v).begin(), (v).end()
#define resort(v) sort((v).rbegin(), (v).rend())
#define vi vector<int>
#define vvi vector<vector<int>>
#define vc vector<char>
#define vvc vector<vector<char>>
#define vb vector<bool>
#define vvb vector<vector<bool>>
using ll = long long;
using P = pair<int, int>;

int dx[] = {1,0,-1,0};
int dy[] = {0,1,0,-1};
constexpr ll mod = 1e9+7;
constexpr ll inf = INT32_MAX/2;
constexpr ll INF = LLONG_MAX/2;
constexpr long double eps = DBL_EPSILON;
constexpr long double pi = 3.141592653589793238462643383279;



template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}

ll fact(int i) {       
    if (i == 0) return 1;
    return (fact(i - 1)) * i % mod;
}
ll gcd(ll a, ll b) {        
    if(b == 0) return a;
    return gcd(b, a % b); 
}
ll lcm(ll a, ll b) {      
    return a / gcd(a, b) * b ;
}
int keta(ll n) {       
    if(n == 0) return 1;
    int count = 0;
    while(n != 0) {
        n /= 10;
        count++;
    }
    return count;
}
ll ketasum(ll n) {   
    ll sum = 0;
    while(n != 0) {
        sum += n % 10;
        n /= 10;
    }
    return sum;
}

#pragma endregion

signed main() {
    string s,t;cin >> s >> t;
    vvi v(26);
    rep(i, t.size()) v[t[i]-'a'].pb(i);
    for(auto p:v) {
        if(p.size()>1) {
            char c = s[p[0]];
            for(auto q:p) {
                if(s[q]!=c) {
                    printf("No\n");
                    return 0;
                }
            }
        }
    }
    vvi vec(26);
    rep(i, s.size()) vec[s[i]-'a'].pb(i);
    for(auto p:vec) {
        if(p.size()>1) {
            char c = t[p[0]];
            for(auto q:p) {
                if(t[q]!=c) {
                    printf("No\n");
                    return 0;
                }
            }
        }
    }
    printf("Yes\n");
    return 0;
}

Measured memory_bytes: 8064
#include<cstdio>
#include<algorithm>
using namespace std;
#define MAXN 110
int x,n,mx,cnt[MAXN];
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
	{
		scanf("%d",&x);
		cnt[x]++;
		mx=max(mx,x);
	}
	bool f=1;
	int k=mx-mx/2;
	for(int i=0;i<k&&f;i++)
		if(cnt[i])
			f=0;
	if(cnt[k]!=1+(mx&1))
		f=0;
	for(int i=k+1;f&&i<=mx;i++)
		if(cnt[i]<2)
			f=0;
	if(f==0) printf("Impossible\n");
	else printf("Possible\n");
}

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

using namespace std;

const int N = 100 + 77 , M = 100000 + 77;
int n , W;
long long dp[M];
int main(){
   memset(dp , 63 , sizeof(dp));
   dp[0] = 0;
   ios::sync_with_stdio(0);cin.tie(0);
   cin >> n >> W;
   for(int w , c , i = 1;i <= n;++ i){
      cin >> w >> c;
      for(int j = M - 1;j >= c;-- j)
         dp[j] = min(dp[j] , dp[j - c] + w);
   }
   for(int i = M - 1;i >= 0;-- i)
      if(dp[i] <= W)
         return cout << i , 0;


   return 0;
}


Measured memory_bytes: 1024
import numpy as np

def main():
    A = np.loadtxt(open(0), np.int32, skiprows=1, ndmin=2)

    N = ans = len(A)

    while A.any():
        b = np.bincount(A[:, 0])
        A = np.reshape(A[A != np.argmax(b)], (N, -1))
        ans = min(ans, max(b))

    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 13508
#include <iostream>
#include <fstream>
#include <typeinfo>
#include <vector>
#include <stack>
#include <cmath>
#include <set>
#include <map>
#include <string>
#include <algorithm>
#include <cstdio>
#include <queue>
#include <iomanip>
#include <cctype>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<char> vc;
typedef vector<vc> vvc;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<int,P> pip;
typedef vector<pip> vip;
const int inf=1<<30;
const ll INF=1ll<<60;
const double pi=acos(-1);
const double eps=1e-6;
const ll mod=1e9+7;
const vi emp;
const int dx[4]={0,1,0,-1},dy[4]={1,0,-1,-0};
const int DX[8]={-1,-1,-1,0,0,1,1,1},DY[8]={1,0,-1,1,-1,1,0,-1};

int n;

int main(){
	cin>>n;
	if(n==2){
		cout<<-1<<endl;
		return 0;
	}
	vvi a(n,vi(n-1));
	a[0][0]=1;a[0][1]=2;
	a[1][0]=2;a[1][1]=0;
	a[2][0]=0;a[2][1]=1;
	for(int i=3;i<n;i++){
		a[0][i-1]=a[0][0];
		a[0][0]=i;
		for(int j=1;j<i;j++) a[j][i-1]=i;
		for(int j=0;j<i-1;j++) a[i][j]=i-j-1;
	}
	for(int i=0;i<n;i++){
		for(int j=0;j<n-1;j++){
			if(j) cout<<' ';
			cout<<a[i][j]+1;
		}
		cout<<endl;
	}
}

Measured memory_bytes: 384
#include <iostream>
#include <vector>
#include <algorithm>
using ll=long long;
using namespace std;
int main(int argc, char const *argv[]) {
  int n;
  cin>>n;
  std::vector<ll> v;
  for(int i=0;i<n;i++){
    ll tmp;
    cin>>tmp;
    v.push_back(tmp);
  }
  sort(v.begin(),v.end());

  ll count=0;
  while(1){
    if(v[0]%2==0){
      count++;
      v[0]=v[0]/2;
    }else{
      break;
    }
  }
  for(int i=1;i<n;i++){
    int tmp=0;
    while(1){
      if(v[i]%2==0){
        tmp++;
        v[i]=v[i]/2;
      }else{
        if(tmp>=count){
          break;
        }else{
          count=tmp;
          break;
        }
      }
      if(tmp>=count)  break;
    }
  }
  cout<<count<<endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define repl(i,l,r) for(ll i=(l);i<(r);i++)
#define per(i,n) for(ll i=n-1;i>=0;i--)
#define perl(i,r,l) for(ll i=r-1;i>=l;i--)
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define ins insert
#define pqueue(x) priority_queue<x,vector<x>,greater<x>>
#define all(x) (x).begin(),(x).end()
#define CST(x) cout<<fixed<<setprecision(x)
#define vtpl(x,y,z) vector<tuple<x,y,z>>
#define at(x,i) get<i>(x);
#define rev(x) reverse(x);
using ll=long long;
using vl=vector<ll>;
using vvl=vector<vector<ll>>;
using pl=pair<ll,ll>;
using vpl=vector<pl>;
using vvpl=vector<vpl>;
const ll MOD=1000000007;
const ll MOD9=998244353;
const int inf=1e9+10;
const ll INF=4e18;
const ll dy[8]={1,0,-1,0,1,1,-1,-1};
const ll dx[8]={0,-1,0,1,1,-1,1,-1};
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
int main(){
  ll k;cin >> k;
  vvl v(10);
  ll cnt=0;
  repl(i,1,10){v[0].pb(i);cnt++;if(cnt==k){cout << i <<endl; return 0;}}
  rep(i,9){
    for(auto x:v[i]){
      ll d=x%10;
      ll p=x*10;
      repl(j,-1,2){
        if(d+j<0)continue;
        if(d+j>9)continue;
        ll z=p+d+j;
        v[i+1].pb(z);
        cnt++;
        if(cnt==k){
          cout << z <<endl;
          return 0;
        }
      }
    }
  }
}


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

int d[107];
int n;
int a[107];
int res=0;
int main(){
	//freopen("in.txt", "r", stdin);
	scanf("%d", &n);
	for(int i=1;i<=n;i++){
		scanf("%d", &a[i]);
		if(d[a[i]]==0){
			d[a[i]]=1;
			res++;
			//cout<<a[i]<<endl;
		}
	}
	printf("%d", res);
	return 0;
}

Measured memory_bytes: 256
import heapq
from itertools import product
h, w = map(int, input().split())
si, sj = map(lambda x: int(x)-1, input().split())
gi, gj = map(lambda x: int(x)-1, input().split())
fld = ''.join([input()for _ in range(h)])
INF = 10**18


def to_v(i, j):
    return i*w+j


n = h*w
start = to_v(si, sj)
goal = to_v(gi, gj)


def generate_v2(v):
    i, j = divmod(v, w)
    it = [-2, -1, 0, 1, 2]
    for di, dj in product(it, repeat=2):
        x, y = i+di, j+dj
        if x < 0 or h <= x or y < 0 or w <= y:
            continue
        if (di, dj) in [(-1, 0), (1, 0), (0, -1), (0, 1), (0, 0)]:
            d = 0
        else:
            d = 1
        yield d, x*w+y


def dijkstra(init_v):
    next_v = [(0, init_v)]
    dist = [INF]*n
    dist[init_v] = 0
    while next_v:
        d, v = heapq.heappop(next_v)
        if dist[v] < d:
            continue
        for d, v2 in generate_v2(v):
            if fld[v2] == '#':
                continue
            if dist[v2] <= dist[v]+d:
                continue
            dist[v2] = dist[v]+d
            heapq.heappush(next_v, (dist[v2], v2))
    return dist


ans = dijkstra(start)[goal]
print(-1 if ans == INF else ans)


Measured memory_bytes: 101952
#!/usr/bin/env python

from collections import deque
import itertools as it
import sys
import math

sys.setrecursionlimit(1000000)

INF = 10 ** 18

N, M = map(int, raw_input().split())
c = [0,2,5,5,4,5,6,3,7,6]
A = sorted(map(int, raw_input().split()))

D = [0] + [-1] * N * 9
a = [0, 0] * N

for i in range(1, N + 1):
    for j in A:
        p = i - c[j]
        if min(p, D[p], D[p] + 1 - D[i]) >= 0:
            D[i], a[i] = D[p] + 1, j

S, p = "", N
while p:
 S+=str(a[p])
 p-=c[a[p]]
print S

Measured memory_bytes: 4344
#include <bits/stdc++.h>
#define YES(i) cout<<(i?"YES":"NO")<<endl
#define Yes(i) cout<<(i?"Yes":"No")<<endl
#define yes(i) cout<<(i?"yes":"no")<<endl
using namespace std;
int main(){
	int a,b,t;
	cin>>a>>b>>t;
	int ans=0;
	for(int i=1;i<=t;i++){
		if(i%a==0){
			ans+=b;
		}
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#pragma comment(linker, "/stack:16777216")
#include <string>
#include <vector>
#include <map>
#include <list>
#include <iterator>
#include <cassert>
#include <set>
#include <queue>
#include <iostream>
#include <sstream>
#include <stack>
#include <deque>
#include <cmath>
#include <memory.h>
#include <cstdlib>
#include <cstdio>
#include <cctype>
#include <algorithm>
#include <utility>
#include <time.h>
#include <complex>
#include <bitset>
using namespace std;

#define FOR(i, a, b) for(int i=(a);i<(b);i++)
#define RFOR(i, b, a) for(int i=(b)-1;i>=(a);--i)
#define FILL(A,value) memset(A,value,sizeof(A))

#define ALL(V) V.begin(), V.end()
#define SZ(V) (int)V.size()
#define PB push_back
#define MP make_pair
#define Pi 3.14159265358979
#define x0 ikjnrmthklmnt
#define y0 lkrjhkltr
#define y1 ewrgrg

typedef long long Int;
typedef unsigned long long UInt;
typedef vector<int> VI;
typedef pair<int, int> PII;
typedef pair<Int, Int> PLL;
typedef pair<double, double> PDD;
typedef complex<double> base;

const int INF = 1000000000;
const int BASE = 1000000007;
const int MAX = 100007;
const int MAXX = 1000000;
const int ADD = 1000000;
const int MOD = 1000000007;
const int CNT = 800;

Int bpow(Int a, int k)
{
    Int res = 1;
    while(k)
    {
        if (k & 1)
        {
            res *= a;
            res %= MOD;
        }
        a *= a;
        a %= MOD;
        k /= 2;
    }
    return res;
}

int main()
{
    //freopen("in.txt", "r", stdin);
    //freopen("distance.in",  "r", stdin);
    //freopen("distance.out", "w", stdout);
    //freopen("out.txt" , "w" , stdout);
    
    Int s;
    cin >> s;
    
    int cnt = 1;
    int nx = 10;
    int sum = 0;
    
    int valL = 1;
    int cntL = 1;
    int nxL = 10;
    
    Int res = 0;
    
    FOR(i,1,100000000)
    {
        if (i == nx)
        {
            ++ cnt;
            nx *= 10;
        }
        sum += cnt;
        while (sum > s)
        {
            if (valL == nxL)
            {
                cntL ++;
                nxL *= 10;
            }
            sum -= cntL;
            valL ++;
        }
        if (sum == s)
            ++ res;
    }
    FOR(i,9,s + 1)
    {
        if (s % i == 0)
        {
            Int r = (bpow(10 , i) - bpow(10 , i - 1) + MOD - s / i + 1 + MOD) % MOD;
            res += r;
            res %= MOD;
        }
    }
    FOR(k,8,s / 2 + 1)
    {
        RFOR(xy , (s - 1) / k + 1 , 2)
        {
            int y = s - xy * k;
            int x = xy - y;
            if (x <= 0) break;
            res ++;
            if (res >= MOD) res -= MOD;
        }
    }
    cout << res << endl;
    
    
    
    return 0;
}













Measured memory_bytes: 384
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0;i<n;i++)
#define REPP(i,n) for(int i=1;i<=n;i++)
const double PI = acos(-1);
const double EPS = 1e-15;
long long INF=(long long)1E17;
#define i_7 (long long)(1E9+7)
long mod(long a){
    long long c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
using namespace std;
bool prime(int n){
  if(n==1){
    return false;
  }else if(n==2){
    return true;
  }else{
    for(int i=2;i<=sqrt(n);i++){
      if(n%i==0){
        return false;
      }
    }
    return true;
  }
}

long long gcd(long long a, long long b){
  if(a<b){
    swap(a,b);
  }
  if(a%b==0){
    return b;
  }else{
    return gcd(b,a%b);
  }
}
 
long long lcm(long long x, long long y){
  return (x/gcd(x,y))*y;
}
 
class UnionFind {
    public:
    //各頂点の親の番号を格納する。その頂点自身が親だった場合は-(その集合のサイズ)を入れる。
    vector<int> Parent;
    
    //クラスを作るときは、Parentの値を全て-1にする。
    //以下のようにすると全てバラバラの頂点として解釈できる。
    UnionFind(int N) {
        Parent = vector<int>(N, -1);
    }
    
    //Aがどのグループに属しているか調べる
    int root(int A) {
        if (Parent[A] < 0) return A;
        return Parent[A] = root(Parent[A]);
    }
    
    //自分のいるグループの頂点数を調べる
    int size(int A) {
        return -Parent[root(A)];//先祖をrootで取っておきたい。
    }
    
    //AとBをくっ付ける
    bool connect(int A, int B) {
        //AとBを直接つなぐのではなく、root(A)にroot(B)をくっつける
        A = root(A);
        B = root(B);
        if (A == B) {
            //すでにくっついてるからくっ付けない
            return false;
        }
        
        //大きい方(A)に小さいほう(B)をくっ付けたい
        //大小が逆だったらAとBをひっくり返す。
        if (size(A) < size(B)) swap(A, B);
        
        //Aのサイズを更新する
        Parent[A] += Parent[B];
        //Bの親をAに変更する
        Parent[B] = A;
        
        return true;
    }
};

int main(){
  string s;
  cin>>s;
  bool flag=false;
  REP(i,3){
    if(s[i]==s[i+1]){
      flag = true;
      break;
    }
  }
  
  if(flag){
    cout<<"Bad"<<endl;
  }else{
    cout<<"Good"<<endl;
  }
  return 0;
}


Measured memory_bytes: 256
/////////////////////////   _LeMur_
#include <iostream>
#include <algorithm>
#include <time.h>
#include <stack>
#include <string>
#include <cstring>
#include <cassert>
#include <cstdio>
#include <cmath>
#include <vector>
#include <queue>
#include <map>
#include <set>

using namespace std;

const int N = 1005;
const int inf = 1000 * 1000 * 1000;
const int mod = 1000 * 1000 * 1000 + 7;

int n;
long long a[N] , mx;
vector <int> pat;
vector <int> g[3];

int main(){
    scanf("%d",&n);
    long long s1 = 0 , s2 = 0;
    for(int i=1;i<=n;i++){
        scanf("%lld",&a[i]);
        if(i == 1 || a[i] > mx){
            mx = a[i];
        }
        if(i % 2 == 0){
            if(a[i] >= 0){
                s2 += a[i];
                g[2].push_back(i);
            }
        }
        else{
            if(a[i] >= 0){
                s1 += a[i];
                g[1].push_back(i);
            }
        }
    }
    if(mx < 0){
        cout<<mx<<endl;
        cout<<n - 1<<endl;
        int id = n;
        for(int i=1;i<=n;i++){
            if(a[i] != mx){
                cout<<1<<endl;
                id--;
                continue;
            }
            break;
        }
        while(id > 1){
            cout<<id<<endl;
            --id;
        }
        return 0;
    }
    int z;
    if(s1 > s2){
        cout<<s1<<endl;
        z = 1;
    }
    else{
        cout<<s2<<endl;
        z = 2;
    }
    int ind = 1;
    while(ind < g[z][0]){
        pat.push_back(1);
        ind++;
    }
    int id = n - ind + 1;
    ind = n;
    while(ind > g[z].back()){
        pat.push_back(id);
        ind--;
        id--;
    }
    for(int i=1;i<(int)g[z].size();i++){
        int x = (g[z][i] - g[z][i - 1]) / 2 - 1;
        while(x--){
            pat.push_back(3);
        }
        pat.push_back(2);
    }
    cout<<(int)pat.size()<<endl;
    for(int i=0;i<(int)pat.size();i++){
        cout<<pat[i]<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
int main(void){
    double x1,y1,x2,y2,x3,y3,xp,yp;
    double s,t;
    double a,b,c,d,e,f,det;
    
    while(scanf("%lf %lf %lf %lf %lf %lf %lf %lf",&x1,&y1,&x2,&y2,&x3,&y3,&xp,&yp) != EOF){
        a=x2-x1;
        b=x3-x1;
        c=y2-y1;
        d=y3-y1;
        e=xp-x1;
        f=yp-y1;
        
        det=a*d-b*c;
        s=(d*e-b*f)/det;
        t=(a*f-c*e)/det;
        
        if(s>0 && t>0 && s+t>0 && s+t<1) printf("YES\n");
        else printf("NO\n");
        
        
    }
    return 0;
}

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

using namespace std;

#define ll					long long
#define vi					vector<int>
#define vii					vector<vi>
#define ALL(s)			(s).begin(),(s).end()
#define ALLn(s)			s,s+n
#define pii					pair<int, int>
#define pll					pair<ll, ll>
#define si					set<int>
#define mp					make_pair
#define F						first
#define S						second
#define pb					push_back
#define tc(t)				int t; cin >> t; while(t--)
#define _						ios_base::sync_with_stdio(false); cin.tie(NULL);

template <typename Iter>
size_t index_of(Iter first, Iter last, int x)
{
    size_t i = 0;
    while (first != last && *first != x) ++first, ++i;
    return i;
}

const ll MOD = 1e9 + 7;
const ll INF = 1<<29;
const ll MAX_N = 1e6 + 7;


void solve() {
	int a,b,c;
	cin >> a >> b >> c;
	cout << c << " " << a << " " << b << "\n";
}

int main() {_
	
		solve();
	

}


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

const int Maxn = 12;
const int Maxm = 1000;
const int INF = 0x3f3f3f3f;

int N, M;
struct Node {
	int A, C;
};
Node A[100000 + 5];

int f[Maxm + 5][(1 << Maxn) + 5];

int main() {
#ifdef LOACL
	freopen("in.txt", "r", stdin);
	freopen("out.txt", "w", stdout);
#endif
	scanf("%d %d" ,&N, &M);
	for(int i = 1; i <= M; i++) {
		int x;
		scanf("%d %d", &A[i].A, &x);
		int t = 0;
		for(int j = 1; j <= x; j++) {
			int tmp;
			scanf("%d", &tmp);
			t |= (1 << (tmp - 1));
		}
		A[i].C = t;
	}
	memset(f, 0x3f, sizeof f);
	f[0][0] = 0;
	for(int i = 1; i <= M; i++) {
		for(int s = 0; s < (1 << N); s++) {
			int s1 = s | A[i].C;
			f[i][s1] = min(f[i][s1], f[i - 1][s] + A[i].A);
			f[i][s] = min(f[i][s], f[i - 1][s]);
		}
	}
	if(f[M][(1 << N) - 1] != INF)printf("%d\n", f[M][(1 << N) - 1]);
	else puts("-1");
	return 0;
}


Measured memory_bytes: 17808
#define _USE_MATH_DEFINES
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <complex>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <limits>
#include <climits>
#include <cfloat>
#include <functional>
#include <iterator>
using namespace std;

void solve1(vector<long long> v, vector<pair<int, int> >& ans)
{
    int n = v.size();
    ans.clear();

    for(;;){
        int x = max_element(v.begin(), v.end()) - v.begin();
        int y = 1;
        while(y < n && v[y-1] <= v[y])
            ++ y;
        if(y == n)
            return;
        v[y] += v[x];
        ans.push_back(make_pair(x, y));
    }
}

void solve2(vector<long long> v, vector<pair<int, int> >& ans)
{
    int n = v.size();
    ans.clear();

    for(;;){
        int x = min_element(v.begin(), v.end()) - v.begin();
        int y = n - 2;
        while(y >= 0 && v[y] <= v[y+1])
            -- y;
        if(y == -1)
            return;
        v[y] += v[x];
        ans.push_back(make_pair(x, y));
    }
}

void solve(const vector<long long>& v, vector<pair<int, int> >& ans)
{
    if(-*min_element(v.begin(), v.end()) < *max_element(v.begin(), v.end()))
        solve1(v, ans);
    else
        solve2(v, ans);
}

int main()
{
    int n;
    cin >> n;
    vector<long long> a(n);
    for(int i=0; i<n; ++i)
        cin >> a[i];

    vector<pair<int, int> > ans;
    solve(a, ans);
    cout << ans.size() << endl;
    for(const auto& p : ans)
        cout << (p.first + 1) << ' ' << (p.second + 1) << endl;

    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <vector>
 
using namespace std;
 
struct Node{
    Node(){
        brother = parent = -1;
        height = depth = num_of_children = 0;
    }
    int parent,brother,depth,num_of_children,height;
    vector<int> children;
};
 
void calcDepth(Node nodes[],int root_id){
    for(int i = 0;i < nodes[root_id].num_of_children;i++){
        nodes[nodes[root_id].children[i]].depth = nodes[root_id].depth+1;
        calcDepth(nodes,nodes[root_id].children[i]);
    }
}
 
void calcHeight(Node nodes[],int height,int parent){
    nodes[parent].height = max(nodes[parent].height,height+1);
    if(nodes[parent].parent != -1) calcHeight(nodes,height+1,nodes[parent].parent);
}
 
int main(){
    int n,id,left_id,right_id,root_id;
    scanf("%d",&n);
    Node nodes[n];
 
    for(int i = 0; i < n; i++){
        scanf("%d %d %d",&id,&left_id,&right_id);
        if(left_id != -1){
            nodes[id].children.push_back(left_id);
            nodes[id].num_of_children++;
            nodes[left_id].parent = id;
        }
        if(right_id != -1){
            nodes[id].children.push_back(right_id);
            nodes[id].num_of_children++;
            nodes[right_id].parent = id;
        }
        if(left_id != -1 && right_id != -1){
            nodes[left_id].brother = right_id;
            nodes[right_id].brother = left_id;
        }
    }
 
    for(root_id = 0; root_id < n; root_id++){
        if(nodes[root_id].parent == -1) break;
    }
 
    if(n > 1){
        calcDepth(nodes,root_id);
 
        for(int i = 0; i < n; i++){
            if(nodes[i].num_of_children == 0) calcHeight(nodes,0,nodes[i].parent);
        }
    }
 
    for(int i = 0; i < n; i++){
        printf("node %d: parent = %d, sibling = %d, degree = %d, depth = %d, height = %d,"
                ,i,nodes[i].parent,nodes[i].brother,nodes[i].num_of_children,nodes[i].depth,nodes[i].height);
        if(nodes[i].parent == -1){
            printf(" root\n");
        }else if(nodes[i].num_of_children == 0){
            printf(" leaf\n");
        }else{
            printf(" internal node\n");
        }
 
    }
}



Measured memory_bytes: 2820
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <iomanip>
#include <bitset>
#include <cassert>
#include <cmath>
#include <cstring>
#include <climits>

using namespace std;

#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define REP(i, n) FOR(i, 0, n)
#define SORT(c) sort((c).begin(), (c).end())

typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> V;
typedef map<int, int> M;

constexpr ll INF = 1e18;
constexpr ll MOD = 1e9 + 7;
constexpr double PI = 3.14159265358979323846;
constexpr int di[] = {0, 0, 1, -1};
constexpr int dj[] = {1, -1, 0, 0};

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

    ll n, a, b;

    cin >> n >> a >> b;

    if ((b - a) % 2)
    {
        ll l = a + b - 2;
        ll r = (n - a) + (n - b);
        cout << min((l + 1) / 2, (r + 1) / 2) << endl;
    }
    else
    {
        cout << (b - a) / 2 << endl;
    }

    return 0;
}

Measured memory_bytes: 256
import math

inputList=[]
for i in range(6):
    inputNum = input()
    inputList.append(inputNum)
# inputa = input().split()

# inputb = input()

# a = int(inputa[0])
# b = int(inputa[1])
# c = int(inputa[2])

# inputList = list(inputb)
#
# inputList[b-1] = inputList[b-1].lower()
#
# ans = "".join(inputList)



# inputList.sort()
#
# list = [a+b, b+c ,c+a]
#
# ans = min(list)
# print(ans)



flg = 1

if int(inputList[4])-int(inputList[0]) > int(inputList[5]):
    flg = 0

if flg == 0:
    print(":(")
else:
    print("Yay!")


Measured memory_bytes: 38256
n, k = map(int,input().split())
A = [list(map(int,input().split())) for i in range(n)]

C = [0] * (10**5 + 5)

for i in range(n):
    C[A[i][0]] += A[i][1]

for i in range(len(C)):
    if k <= C[i]:
        print(i)
        break
    else:
        k -= C[i]

Measured memory_bytes: 30152
#include<stdio.h>
#include<iostream>

using namespace std;

int main(void){
  
  int a,p;

  cin>>a>>p;
  
  int sumapple = 3 * a + p;
  
  int fin = sumapple / 2;
  
  
  cout<<fin<<endl;
  
  return 0;
  
  
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

import static java.lang.Integer.parseInt;

/**
 * Curry Making
 */
public class Main {

	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String line;
		String[] words;

		while ((line = br.readLine()) != null && !line.isEmpty()) {

			words = line.split(" ");

			int R0, W0, C, R;
			R0 = parseInt(words[0]);
			W0 = parseInt(words[1]);
			C = parseInt(words[2]);
			R = parseInt(words[3]);
			if ((R0 | W0 | C | R) == 0) break;

			int X = 0;
			while (C > R0 / W0) {
				R0 += R;
				X++;
			}

			System.out.println(X);
		}

	} //end main
}

Measured memory_bytes: 24160