akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h> 
using namespace std;
using ll=long long;
using P=pair<ll,ll>;
template<class T> using V=vector<T>; 
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
const ll inf=(1e18);
//const ll mod=998244353;
const ll mod=1000000007;
int GCD(ll a,ll b) {return b ? GCD(b,a%b):a;}
ll LCM(ll c,ll d){return c/GCD(c,d)*d;}
struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}} __init;
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
int main(){
  string s;
  cin>>s;
  if(s=="ABC")cout<<"ARC"<<"\n";
  else cout<<"ABC"<<"\n";
}



Measured memory_bytes: 3652
#include<stdio.h>

int main(void){
	long n,max,min,sum,i;
	scanf("%d",&n);

	long a[n];
	scanf("%ld",&a[0]);
	max = a[0];
	min = a[0];
	sum = a[0];
	
	for(i=1;i<n;i++){
		scanf("%ld",&a[i]);
		if(max < a[i]){
			max = a[i];
		}
		if(min > a[i]){
			min = a[i];
		}
		sum += a[i];
	}
	printf("%ld %ld %ld\n",min,max,sum);
	return 0;
}



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

long long int split(long long int a, long long int b) {
  long long int diff = a*b;
  
  for (int i = 1; i < a; i++) {
    long long int diff_temp;
    long long int split1[3] = {i*b, (a-i) * (b - b/2), (a-i) * (b/2)};
    long long int split2[3] = {i*b, (a-i)/2 * b, (a-i-(a-i)/2) * b};
    
    sort(split1, split1+3);
    sort(split2, split2+3);
    
    diff_temp = min(split1[2]-split1[0], split2[2]-split2[0]);
    if (diff_temp < diff) diff = diff_temp;
  }
  return diff;
}


int main() {
  long long int h, w;
  cin >> h >> w;
    
  cout << min(split(h,w), split(w,h)) << endl;
}

Measured memory_bytes: 256
from collections import defaultdict


def readln():
    return list(map(int, input().split()))


N = readln()[0]
S = input()


dic = defaultdict(lambda: 0)
for s in S:
    dic[s] += 1
ans = 1
for count in dic.values():
    # print(count)
    ans *= count + 1

# print(ans)
print((ans-1) % (10**9+7))


Measured memory_bytes: 3444
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<vector>
#include<map>
#include<set>
#include<string>
#include<queue>
#include<stack>
#include <cassert>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
#define INF ((1<<30)-1)
#define LINF (1LL<<60)
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
typedef long long ll;
typedef pair<int,int> P;

int main(){
    int x,a;
    cin >> x >> a;
    if(x<a)cout << 0 << endl;
    else cout << 10 << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n=sc.nextInt();
		String s="";
		for(int i=0;i<n;i++) {
			s=sc.next();
			if(s.charAt(0)=='Y'){
				System.out.println("Four");
				return;
			}
		}
		System.out.println("Three");
		}
}


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

#define M 5*5*5*5*5*5*5*5*5*5*5
#define L 13

int get_char(char ch){
    if(ch == 'A') return 1;
    else if(ch == 'C') return 2;
    else if(ch == 'G') return 3;
    else if(ch == 'T') return 4;
    return 0;
}

int get_key(char str[]){
    int sum = 0, p = 1, i;
    for(i = 0; i < strlen(str); ++i){
        sum += p * (get_char(str[i]));
        p *= 5;
    }
    return sum;
}

int main(void){
    bool *hash = new bool[M];
    int n;
    char str[L], com[9];
    for(int i = 0; i < M; i++) hash[i] = false;

    cin >> n;
    for(int i = 0; i < n; ++i){
        cin >> com >> str;
        if(com[0] == 'i'){
            hash[get_key(str)] = true;
        }else{
            cout << ((hash[get_key(str)])? "yes" : "no") << endl; 
        }
    }
}


Measured memory_bytes: 50764
using Atcoder;
using System;
using System.Collections.Generic;
using System.ComponentModel.Design;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Atcoder
{
    class Program
    {
        static void Main(string[] args)
        {
            var first = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
            var N = first[0];
            var D = first[1];

            List<int[]> inputList = new List<int[]>();
            for (int i = 0; i < N; i++)
            {
                var tmp = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
                inputList.Add(tmp);
            }

            int result = 0;
            
            for (int i = 0; i < N; i++)
            {
                for (int k = i+1; k < N; k++)
                {
                    double tmpR = 0;
                    for (int j = 0; j < D; j++)
                    {
                        tmpR += Math.Pow(Math.Abs(inputList[i][j] - inputList[k][j]), 2);
                    }
                    tmpR = Math.Sqrt(tmpR);
                    if ((int)tmpR == tmpR)
                    {
                        result++;
                    }
                }

            }
            Console.WriteLine(result);
        }
        //static void Main(string[] args)
        //{
        //    var temp = new Atcoder.ABC130.D();
        //    temp.Run();
        //}

    }
}

Measured memory_bytes: 13396
#include<stdio.h>

int main(){
	long long int input;
	char otp[50];
	int index=1;
	scanf("%lld",&input);
	while(input!=0){
		input--;
		char temp = char(input%26) + 'a';
		otp[index] = temp;
		index++;
		input /=26;
	}
	for(int i = index-1;i>=1;i--) printf("%c",otp[i]);
	printf("\n");
	
	return 0;
}

Measured memory_bytes: 1660
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.LinkedList;

public class Main {
    public static void main(String[] args) throws Exception {
        
        LinkedList<Integer> list = new LinkedList<Integer>();
        String line;
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        br.readLine();
        while((line = br.readLine()) != null){
            String[] order = line.split(" ");
            switch(order[0]){
                case "insert" : list.addFirst(Integer.valueOf(order[1]));
                    break;
                case "delete" : list.remove(Integer.valueOf(order[1]));
                    break;
                case "deleteFirst" : list.removeFirst();
                    break;
                case "deleteLast" : list.removeLast();
                    break;
                default:
            }
        }

        Integer m;
        if((m = list.pollLast()) != null){
            StringBuilder sb = new StringBuilder();
            for(int j : list)
                sb.append(j).append(" ");
            System.out.println(sb.append(m));
        }
    }
}


Measured memory_bytes: 203608
using System;

public class ITP1_10_A{
    public static void Main(){
        var items = Console.ReadLine().Split(' ');
        
        var x1 = double.Parse(items[0]);
        var y1 = double.Parse(items[1]);
        var x2 = double.Parse(items[2]);
        var y2 = double.Parse(items[3]);
        
        var ans = Math.Sqrt(Math.Pow(x2 - x1, 2) + Math.Pow(y2 - y1, 2));
        Console.WriteLine(ans);
    }
}



Measured memory_bytes: 15980
N, A, B, C, D = map(int, input().split())
# N, A, B, C, D = 48792, 105960835, 681218449, 90629745, 90632170
# N, A, B, C, D = 491995, 412925347, 825318103, 59999126, 59999339


succeed = False
for m in range(N):
    if C * (N - 1 - m) - D * m <= B - A <= -C * m + (N - 1 - m) * D:
        succeed = True
        break

if succeed:
    print("YES")
else:
    print("NO")


Measured memory_bytes: 2940
s = input()
len_s = len(s)
if s[:int((len_s-1) /2)] != s[int((len_s-1) / 2 +1):]:
    print('No')
else:
    tmp = s[:int((len_s -1 ) /2)]
    if len(tmp) == 1:
        print('Yes')
    else:
        if len(tmp ) %2 == 1:
            if tmp[:int((len(tmp) - 1) / 2)] == tmp[int((len(tmp) - 1) / 2 + 1):][::-1]:
                print('Yes')
            else:
                print('No')
        else:
            if tmp[:int(len(tmp) / 2)] == tmp[int(len(tmp) / 2):][::-1]:
                print('Yes')
            else:
                print('No')


Measured memory_bytes: 3064
from collections import defaultdict
from heapq import heappop, heappush,heapify
import sys
input = sys.stdin.readline

N,M,S = map(int,input().split())
UVAB = [list(map(int,input().split())) for i in range(M)]
U,V,A,B = zip(*UVAB)

'''
from itertools import combinations 
N = 14
M = N*(N-1)//2
S = 0
UVAB = [[x,y,50,10**9] for x,y in combinations(range(1,N+1),2)] 
U,V,A,B = zip(*UVAB)
'''

mc = max(A)* M
g = defaultdict(list)

for u,v,a,b in UVAB:
    for i in range(a,mc+1):
        g[(u,i)].append(((v,i-a),b))
        g[(v,i)].append(((u,i-a),b))

CD = [[0,0]] + [list(map(int,input().split())) for i in range(N)]
#CD = [[0,0]] + [[10**9,10**9] for i in range(N)]
C,D = zip(*CD)
C = [min(c,mc) for c in C]

for i in range(1,N+1):
    for c in range(mc+1-C[i]):
        g[(i,c)].append(((i,c+C[i]),D[i]))

S = min(S,mc)
dq = [(0,S,1)]

ans = [[10**15 for j in range(mc+1)] for i in range(N+1)]
while dq:
    t, w, v = heappop(dq)
    if ans[v][w] <= t:
        continue
    for i in range(w+1):
        ans[v][i] = min(t, ans[v][i])
    for (nv,nw), nt in g[(v,w)]:
        if ans[nv][nw] > t + nt:
            heappush(dq,(t+nt,nw,nv))

for i in range(2,N+1):
    print(min(ans[i]))





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

import sys
input = sys.stdin.buffer.readline
sys.setrecursionlimit(10**6)
INF = float("inf")

import math

def main():
    A,B,X = map(int,input().split())

    # 2次元で考える
    X /= A

    # 水位が, 断面の対角線より上
    if X > A*B/2:
        ans = math.atan(2*(A*B-X)/(A**2))
    # 水位が, 断面の対角線より下
    else:
        ans = math.atan(B**2/(X*2))
    
    print(ans * 180 / math.pi)

if __name__ == "__main__":
    main()

Measured memory_bytes: 9436
#include <algorithm>
#include <climits>
#include <iostream>
#include <string>
#include <utility>
#include <vector>
#include <map>
#include <queue>
using namespace std;
using ll = long long int;

template <class T> ostream &operator<<(ostream &os, vector<T> &v) {
  for (auto i = v.begin(); i != v.end(); i++) {
    os << *i << " ";
  }
  return os;
}

ll gcd(ll a, ll b) {
  ll tmp;
  if ( b > a) {
    tmp = a;
    a = b;
    b = tmp;
  }
  while (a % b !=0) {
    tmp = b;
    b = a % b;
    a = tmp;
  }
  return b;
}

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

int main(void) {
  int h, w;
  cin>>h>>w;
  vector<string> v;
  for(int i=0; i<h; i++) {
    string s;
    cin>>s;
    v.push_back(s);
  }
  int cnt=0;
  for(int i=0; i<h; i++) {
    for(auto it = v[i].begin(); it!=v[i].end(); ++it) {
      if(*it == '.')
	cnt++;
    }
  }
  queue<pair<int, pair<int, int>>> q;
  q.push(make_pair(0, make_pair(0, 0)));
  v[0][0] = '#';
  int d[4][2] = {{0, 1}, {0, -1}, {1, 0}, {-1, 0}};
  while(!q.empty()) {
    pair<int, pair<int, int>> p = q.front();
    q.pop();
    if(p.second.first == h-1 and p.second.second == w-1) {
      std::cout << cnt-p.first-1 << std::endl;
      return 0;
    }
    for(int i=0; i<4; i++) {
      int ny = p.second.first + d[i][0];
      int nx = p.second.second + d[i][1];
      if(0<=ny and ny<h and 0<=nx and nx<w and v[ny][nx] == '.') {
	v[ny][nx] = '#';
	q.push(make_pair(p.first + 1, make_pair(ny, nx)));
      }
    }
  }
  std::cout << -1 << std::endl;
  return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <list>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <fstream>
#include <sstream>
#include <iomanip>

using namespace std;

long long MOD = 1000000007;

void dfs(int now, int d, vector<int> &dist, vector<vector<int> > &edges, vector<int> &cut){
    if(dist[now]!=MOD || cut[now]>0){
        if(cut[now]==1){
            dist[now]=d;
        }
        return;
    }

    dist[now]=d;
    for(int i=0; i<(int) edges[now].size(); i++){
        int next_=edges[now][i];
        dfs(next_, d+1, dist, edges, cut);
    }
}

template<typename T>
void cout_vec(vector<T> &vec){
    for(int i=0; i<vec.size(); i++){
        if (i!=0){
            cout << ' ';
        }
        cout << vec[i];
    }
    cout << endl;
}

int main(){
    int N, u, v;
    cin >> N >> u >> v;
    u--;v--;

    vector<vector<int> > edges(N,vector<int>(0));
    for(int i=0; i<N-1; i++){
        int A, B;
        cin >> A >> B;
        A--;B--;

        edges[A].push_back(B);
        edges[B].push_back(A);
    }

    vector<int> t_dist(N,MOD);
    vector<int> a_dist(N,MOD);
    vector<int> cut(N,0);

    dfs(u, 0, t_dist, edges, cut);
    dfs(v, 0, a_dist, edges, cut);

    
    for(int i=0; i<N; i++){
        if(t_dist[i]>a_dist[i]){
            cut[i]=2;
        }else if(t_dist[i]==a_dist[i]){
            cut[i]=1;
        }
    }

    t_dist = vector<int>(N,MOD);
    dfs(u, 0, t_dist, edges, cut);

    int ans=0;
    for(int i=0; i<N; i++){
        if(t_dist[i]==MOD)continue;

        if(ans<a_dist[i]){
            int diff=t_dist[i]-a_dist[i];
            if(diff==0){
                ans=a_dist[i];
            }else{
                ans=a_dist[i]-1;
            }
        }
    }

    //cout_vec(t_dist);
    //cout_vec(a_dist);
    cout << ans << endl;

}

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

int main() {
  string s;
  const string t[] = {"apple", "peach"};
  while(getline(cin, s)) {
    for(int i = 0; i < s.size(); ++i) {
      bool flag = false;
      for(int j = 0; j < 2; ++j) {
        if(s.substr(i, t[j].size()) == t[j]) {
          flag = true;
          cout << t[1-j];
          i += t[j].size()-1;
          break;
        }
      }
      if(!flag) cout << s[i];
    }
    cout << endl;
  }
  return 0;
}

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

int main() {
    int n;
    cin >> n;
    vector<int> d(n);
    rep(i,n) cin >> d[i];
    sort(d.begin(),d.end());
    if(n%2){
        cout << 0 << endl;
        return 0;
    }
    cout << d[n/2]-d[n/2-1] << endl;
}

Measured memory_bytes: 3752
#include <iostream>
#include <cmath>
#include <algorithm>
#include <string>
#include <vector>
#include <set>
#include <map>

typedef unsigned int u32;
typedef int i32;
typedef unsigned long long int u64;
//typedef long long int i64;
typedef int i64;
typedef uint16_t u16;
typedef int16_t i16;
typedef uint8_t u8;
typedef int8_t i8;

const double PI = 3.141592653589793238463;

using namespace std;

const int MAXN = 1000500;
const int MAXVALUE = 1000000500;
//const long double EPS = 1e-7;

i64 mod = 1e9 + 7;

i64 T, n, m, k, q;

vector <i64> h;
vector <set<i64>> d;

int main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.precision(16);


	cin >> n >> m;	

	h.resize(n + 1);
	d.assign(n + 1, {});

	for (int i = 1; i <= n; ++i) {
		cin >> h[i];
	}

	i64 x, y;
	for (int i = 1; i <= m; ++i) {
		cin >> x >> y;
		d[x].insert(h[y]);
		d[y].insert(h[x]);
	}

	i64 res = 0;
	for (int i = 1; i <= n; ++i) {
		set <int>::iterator it;
		bool fl = true;
		for (it = d[i].begin(); it != d[i].end(); ++it) {
			if (h[i] <= *it) {
				fl = false;
				break;
			}
		}

		if (fl) {
			res += 1;
		}
	}

	cout << res << endl;



	return 0;
}

Measured memory_bytes: 15068
#include <iostream>
#include <queue>
#include <cstdint>
using namespace std;

int main() {
    int n, m; cin >> n >> m;
    uint64_t sum = 0;
    priority_queue<int> que;
    for (int i = 0; i < n; ++i) {
        int a; cin >> a;
        sum += a;
        que.push(a);
    }

    for (int i = 0; i < m; ++i) {
        int c = que.top(); que.pop();
        sum -= c;
        c /= 2;
        sum += c;
        que.push(c);
    }

    cout << sum << endl;
}



Measured memory_bytes: 3924
#include <bits/stdc++.h>
#define SORT(x) sort(x.begin(),x.end())
#define ALL(x) x.begin(),x.end()
#define rep(i, n) for(int i = 0; i < n; i++)
#define reps(i, m, n) for(int i = m; i < n; i++)
#define repr(i, m, n) for(int i = m; i >= n; i--)
#define INF (1e9)
#define PI (acos(-1))
#define MOD 1000000007
using namespace std;
typedef long long ll;

void Main(){

  ll N;
  cin >> N;

  ll dp[63][3]={}; //[上位i桁まで][Nとの差(どれだけ低いか)]=(vの通り).jは2以上は2に。

  dp[62][0]=1;

  repr(i,61,0){ //桁dp
    rep(j,3){ //012
      rep(k,3){ //(00)(01)(11) a,bの組。01は必ず可換で,00と11はvが必ず異なる。
        ll j2 = min((ll)2,2*j+(N>>i &1)-k);
        if(j2>=0) {
          dp[i][j2]+=dp[i+1][j];
          dp[i][j2]%=MOD;
        }
      }
    }
  }

  cout << ((dp[0][0]+dp[0][1]+dp[0][2])%MOD) <<"\n";
}
//-----------------------------------
int main(){
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(15);
  Main();
}
//-----------------------------------


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define L 3001
int tag[L][L];
string a,b;
void solve()
{
    int i,j,la=a.length(),lb=b.length(),x[la+1][lb+1];
    string ans;
    for (i=0;i<=la;i++)
        for (j=0;j<=lb;j++)
            x[i][j]=0;
    for (i=1;i<=la;i++)
        for (j=1;j<=lb;j++)
            if (a[i-1]==b[j-1])
            {
                x[i][j]=x[i-1][j-1]+1;
                tag[i][j]=1;
            }
            else if (x[i][j-1]>x[i-1][j])
            {
                x[i][j]=x[i][j-1];
                tag[i][j]=2;
            }
            else
            {
                x[i][j]=x[i-1][j];
                tag[i][j]=3;
            }
    while(la>0&&lb>0)
    {
        if (tag[la][lb]==1)
        {
            ans.push_back(a[la-1]);
            la--;
            lb--;
        }
        else if (tag[la][lb]==2) lb--;
        else la--;
    }
    for (i=ans.size()-1;i>=0;i--)
        cout<<ans[i];
    cout<<endl;
}
int main()
{
    while(cin>>a>>b)
        solve();
}

Measured memory_bytes: 70656
S = input()
N = len(S)

S_s= S[:int((N-1)/2)]
S_e= S[int((N+3)/2)-1:]

if S == S[::-1] and S_s == S_s[::-1] and S_e == S_e[::-1]:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 3060
function MainB(input){
    const [N, ...Arr] = input.split('\n');
    let zoroCount = 0;
    const Darr = Arr.map(a => a.split(' '))
    for(let i=0; i< Darr.length; i++){
        if(Darr[i][0] == Darr[i][1]){
            zoroCount++;
        } else{
            zoroCount = 0;
        }
        if(zoroCount === 3) break; 
    }
    console.log(zoroCount === 3 ? "Yes" : "No");
}
MainB(require("fs").readFileSync("/dev/stdin", "utf8").trim());


Measured memory_bytes: 29688
N,K = map(int,input().split())
P = list(map(int,input().split()))
Q = [(p+1)/2 for p in P]
c = [0]
for q in Q:
    c.append(c[-1] + q)

ans = 0
for i in range(K,N+1):
    ans = max(ans, c[i] - c[i-K])
print(ans)

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

#define rep(i, l, r) for (ll i = (l); i <= (r); i++)
#define irep(i, r, l) for (ll i = (r); i >= (l); i--)
#define vec(t) vector<t>

using namespace std;
using ll = long long;
using vecint = vec(int);
using vecll = vec(ll);

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    int a,b, c;

    cin >> a >> b >> c;

    if (a==5 && b==7 && c==5) { cout << "YES\n"; return 0;}
    if (a==7 && b==5 && c==5) { cout << "YES\n"; return 0;}
    if (a==5 && b==5 && c==7) { cout << "YES\n"; return 0;}

    cout << "NO\n";

}

Measured memory_bytes: 256
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, [ $t:tt ]) => {
        {
            let len = read_value!($next, usize);
            (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
        }
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
        n: usize,
        m: usize,
        c: i64,
        b: [i64; m],
        a: [[i64; m]; n],
    }
    let mut result = 0;
    for i in 0..n {
        let mut s = c;
        for j in 0..m {
            s += b[j] * a[i][j];
        }
        if s > 0 {
            result += 1;
        }
    }
    println!("{}", result);
}


Measured memory_bytes: 4352
n = int(input())
ans = 1;
tem = 0
ok = 1
s = input().split()
for i in s:
    if(int(i) == 0):
        tem = 1
        break
    if(ok == 1):
        ans *= int(i) 
        if(ans > 10**18):
            ok = 0
if(tem):
    print(0)
elif(ok):
    print(ans)
else:
    print("-1")


Measured memory_bytes: 19532
#include <iostream>
#include <bitset>
#include <string>
#include <vector>
#include <climits>

#define inf INT_MIN

int main(int argc, char *argv[]) {  
	std::bitset<10> f[109];
	int p[109][12];
	int n;
	std::cin >> n;
	for(int k = 0; k < n; k++) {
		for(int i = 0; i < 10; i++) {
			int temp;
			std::cin >> temp;
			f[k][i] = temp;
		}
	}
	for(int i = 0; i < n; i++) {
		for(int j = 0; j < 11; j++) {
			std::cin >> p[i][j]; 
		}
	}
	int ans = inf;
	for(unsigned i = 1; i <= 1023; i++) {
		std::bitset<10> pa(i);
		int now = 0, tot = 0;
		for(int k = 0; k < n; k++) {
			now = 0;
			for(int j = 0; j < 10; j++) {
				if(f[k][j]&pa[j]) {
					now++;
				}
			}
			tot += p[k][now];
		}
		ans = std::max(tot, ans);
	}
	std::cout << ans << std::endl;
	return 0;
}

Measured memory_bytes: 256
N = int(input())
A = list(map(int, input().split()))
mn_count = len([0 for i in A if i < 0])
AA = [abs(i) for i in A]
mn = min(AA) if mn_count % 2 else 0
#print(AA, mn, mn_count)
print(sum(AA) - mn*2)

Measured memory_bytes: 14412
#include <bits/stdc++.h>
typedef long long int ll;
typedef long double ld;
using namespace std;
const long long int INF = 1e18;
const long long int mod = 1e9+7;
typedef pair<ll,ll> pairs;
typedef vector<pairs> p;


ll gcd(ll A,ll B){
    if (A%B==0)return(B);
    else return(gcd(B,A%B));
}

ll keta(ll N){
    int tmp{};
    while( N > 0 ){
        tmp += ( N % 10 );
        N /= 10;
    }
    N = tmp;
    return N;
}

vector<vector<ll>> combination(ll n, ll r){
    vector<vector<ll>> v(n + 1, vector<ll>(n + 1, 0));
    for(ll i=0;i<v.size();++i){
        v[i][0] = 1;
        v[i][i] = 1;
    }
    for(ll i=1;i<v.size();++i){
        for(ll j=0;j<i;++j){
            v[i][j] = (v[i - 1][j - 1] + v[i - 1][j]);
        }
    }
    return v;
}

bool kai(string S){
    bool flag = true;
    for(ll i=0;i<S.size()/2;++i){
        if(S[i] != S[S.size()-i-1]){
            flag = false;
            break;
        }
    }
    return flag;
}
// ---------------------------------------------

int main(){
    ll n;
    cin>>n;
    vector<ll> a(n);
    ld ave = 0;
    for(ll i=0;i<n;++i){
        cin>>a[i];
        ave += a[i];
    }
    ave /= n;
    ll flag = INF;
    ll ans;
    for(ll i=0;i<n;++i){
        if(abs(flag-ave) > abs(a[i]-ave)){
            flag = a[i];
            ans = i;
        }
    }
    cout<<ans<<endl;

    return 0;
}

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

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

int main() {
  int N;
  int64_t K;
  cin >> N >> K;
  int A[N];
  rep(i,N)
    cin >> A[i];
  
  int d[N];
  rep(i,N)
    d[i] = -1;
  
  int nA = 0;
  int nt = 0;
  while (true){
    if (d[nA] != -1){
      nt -= d[nA];
      break;
    }
    d[nA] = nt;
    nA = A[nA]-1;
    nt++;
  }
  
  int rest = -1;
  int res = -1;
  rep(i,N){
    if (d[i] == -1)
      continue;
    if ((K-d[i])%nt == 0 && d[i] > rest && K>=d[i]){
      rest = d[i];
      res = i+1;
    }
  }
  
  cout << res << endl;
}

Measured memory_bytes: 5168
#include <stdio.h>

char const* get_result(unsigned state)
{
	switch (state){
	  case 3: return "120";
	  case 5: return "201";
	  case 6: return "012";
	  default:return "333";
	}
}

int main(void)
{
	unsigned state;
	int hand[8];

	while (scanf("%d", hand), *hand){
		int i;
		
		for (i = 1; i < 5; i++){
			scanf("%d", hand + i);
		}
		state = 0;
		for (i = 0; i < 5; i++){
			state |= 1 << hand[i];
		}
		state >>= 1;

		do {
			char const* result = get_result(state);
			for (i = 0; i < 5; i++){
				printf("%c\n", result[hand[i] - 1]);
			}
		} while (0);
	}
	return (0);
}

Measured memory_bytes: 600
let () =
  let i = 1000000007 in
  let fact a =
    let rec fact_aux x tmp =
      if x = 1 then tmp mod i else fact_aux (x - 1) (tmp * x mod i)
    in
    fact_aux a 1
  in
  let f n m = fact n mod i * fact m mod i in
  let dogs, monkeys = Scanf.scanf "%d %d" (fun x y -> (x, y)) in
  ( match abs (dogs - monkeys) with
    | 0 -> f dogs monkeys * 2 mod i
    | 1 -> f dogs monkeys mod i
    | _ -> 0 )
  |> Printf.printf "%d\n"

Measured memory_bytes: 2432
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
      
      Scanner sc = new Scanner(System.in);
      
      int a = sc.nextInt();
      int b = sc.nextInt();
      int c = sc.nextInt();
      
      int x;
      
      if(a*c <= b){
        x = c;
      } else {
        x = b/a;
      }
      
      System.out.println(x);
      
     
    }
}

Measured memory_bytes: 22996
#include<iostream>
#include<ctime>
#include<cstdlib>
#include<cstdio>
#include<cmath>
#include<climits>
#include<cstring>
#include<iomanip>
#include<string>
#include<bitset>
#include<set>
#include<vector>
#include<map>
#include<queue>
#include<stack>
#include<deque>
#include<algorithm>
#include<functional>
#include<chrono>
#include<random>

#define y0 asdahsdlkahsdad
#define y1 aasdfasdfasdf
#define yn askfhwqriuperikldjk
#define j1 assdgsdgasghsf
#define taskname "E"
#define BeztDonkey

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

using namespace std;

const int nAlpha = 'z' - 'a' + 1, maxN = 2e5 + 1;

deque<int> pos[nAlpha];
static int p[maxN], lab[maxN], n, mid;
ll ans = 0;
string s;

inline void Update(int i, int val) { for (; i <= n; i += i & -i) lab[i] += val; }
inline int Get(int i) { int res = 0; for (; i > 0; i &= i - 1) res += lab[i]; return res; }

int main()
{
    #ifdef BeztDonkey
    auto start = chrono::steady_clock::now();
    #endif
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    //freopen(taskname".inp", "r", stdin);
    //freopen(taskname".out", "w", stdout);

    cin >> s;
    n = s.size();
    for (int i = 0; i < n; ++i) pos[s[i] -= 'a'].push_back(i + 1);
    int dem = 0;
    for (int c = 0; c < nAlpha; ++c)
        if (pos[c].size() & 1) ++dem, mid = pos[c][pos[c].size() >> 1];
    if (dem > 1) return cout << -1, 0;
    for (int i = 1; i <= n; ++i) lab[i] = i & -i;
    for (int dem = n; dem > 1; dem -= 2)
    {
        int _c, _cost = maxN;
        for (int c = 0; c < nAlpha; ++c)
        {
            auto &v = pos[c];
            if (v.size() <= 1) continue;
            int cost = dem - (Get(v.back()) - Get(v.front() - 1));
            if (cost < _cost) _cost = cost, _c = c;
        }
        ans += _cost;
        auto &v = pos[_c];
        Update(v.front(), -1); v.pop_front();
        Update(v.back(), -1); v.pop_back();
    }
    /*for (int i = 1; i <= n; ++i)
        if (i != mid) Update(i, 1);
    for (int i = 1; i <= n; ++i)
    {
        auto &v = pos[s[i - 1]];
        if (v.back() <= i) continue;
        p[i] = v.back();
        ans += Get(n) - Get(v.back());
        Update(i, -1);
        Update(v.back(), -1);
        v.pop_back();
    }
    if (n & 1)
        for (int i = 1; i <= n; ++i)
            ans += p[i] && (i < mid && p[i] < mid || i > mid && p[i] > mid);*/
    cout << ans;

    #ifdef BeztDonkey
    auto end = chrono::steady_clock::now();
    cerr << "In milliseconds : "
         << chrono::duration_cast<chrono::milliseconds>(end - start).count();
    cerr << '\n' << "In seconds : "
         << chrono::duration_cast<chrono::seconds>(end - start).count() << '\n';
    #endif
    return 0;

}


Measured memory_bytes: 2068
#include <bits/stdc++.h>
#define rep(i,a,b) for(ll i=ll(a);i<ll(b);i++)
#define irep(i,a,b) for(ll i=ll(a);i>=ll(b);i--)
using ll = long long;
using namespace std;
ll LR[2200][2200]={0},RL[2200][2200]={0},UD[2200][2200]={0},DU[2200][2200]={0};
int main(){
    ll h,w,ans=0,tmp=0;
    cin>>h>>w;
    string s[h];
    rep(i,0,h)cin>>s[i];

    rep(i,0,h)if(s[i][0]=='.')LR[i][0]=1;
    rep(i,0,w)if(s[0][i]=='.')UD[0][i]=1;
    
    rep(i,0,h){
        rep(j,1,w){
            if(s[i][j]=='.')LR[i][j]=LR[i][j-1]+1;
            else LR[i][j]=0;
        }
        irep(j,w-1,0){
            if(s[i][j]=='.')RL[i][j]=RL[i][j+1]+1;
            else RL[i][j]=0;
        }
    }

    rep(i,0,w){
        rep(j,1,h){
            if(s[j][i]=='.')UD[j][i]=UD[j-1][i]+1;
            else UD[j][i]=0;
        }
        irep(j,h-1,0){
            if(s[j][i]=='.')DU[j][i]=DU[j+1][i]+1;
            else DU[j][i]=0;
        }
    }

     rep(i,0,h){
        rep(j,0,w){
            tmp=0;
            if(s[i][j]=='.')tmp=LR[i][j]+RL[i][j]+UD[i][j]+DU[i][j]-3;
            ans=max(ans,tmp);
        }
    }
    cout<<ans;
}


Measured memory_bytes: 149760
#include<stdio.h>
 
int c;
int sub(int n,int x,int s,int sum){
   int i;
   if(n==0){
if(s==sum){
      c++;
}
      return 0;
   }
   for(i=x;i<=10-n;i++){
      sub(n-1,i+1,s,sum+i);
   }
}
 
int main(void){
int i,j,k,n,s,sum;
while(1){
scanf("%d %d",&n,&s);
if(n==0&&s==0){break;}
   c=0;
   sub(n,0,s,0);
   printf("%d\n",c);
}
return 0;
}

Measured memory_bytes: 1748
#include <iostream>
#include <algorithm>
#include <vector>
#include <cstdio>
using namespace std;
typedef vector<int> vi;
typedef vector< vi > vvi;
int main() {
	int m, f, r, S;
	while (cin >> m >> f >> r) {
		S = m + f;
		if(m == -1 && f == -1 && r == -1){
			break;
		}
		else {
			if (m == -1 || f == -1 || S < 30) {
				cout << 'F' << endl;
			}
			else {
				if (S >= 80) {
					cout << 'A' << endl;
				}
				else if (S < 80 && S >= 65) {
					cout << 'B' << endl;
				}
				else if(S < 65 && S >= 50){
					cout << 'C' << endl;
				}
				else if (S < 50 && S >= 30) {
					if(r >= 50){
						cout << 'C' << endl;
					}
					else {
						cout << 'D' << endl;
					}
				}
			}
		}
	}
}

Measured memory_bytes: 1152
def main():
    from builtins import int, map, list, float, print
    import sys
    sys.setrecursionlimit(10 ** 6)

    input = sys.stdin.readline
    input_list = (lambda: input().rstrip().split())
    input_number = (lambda: int(input()))
    input_number_list = (lambda: list(map(int, input_list())))

    N = input_number()
    T,A = input_number_list()
    H = input_number_list()
    m = float('inf')
    idx = -1
    for i in range(N):
        if m > abs(A-(T-H[i]*0.006)):
            m = abs(A-(T-H[i]*0.006))
            idx = i
    print(idx+1)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
from collections import deque
n = int(input())
g = [[] for _ in range(n)]
for i in range(n-1):
  u, v, w = map(int, input().split())
  g[u-1].append((v-1,w))
  g[v-1].append((u-1,w))
ds = [-1]*n
dq = deque([0])
ds[0] = 0
while dq:
  t = dq.popleft()
  for i in g[t]:
    if ds[i[0]] == -1:
      ds[i[0]] = ds[t] + i[1]
      dq.append((i[0]))
for i in ds:
  if i%2 == 0:
    print(0)
  else:
    print(1)

Measured memory_bytes: 47844
#include <iostream>
#include <cstdio>
#include <algorithm> // sort
#include <cmath>
#include <vector>
#include <stack>
#include <queue>
#include <string>
#include <set>
#include <utility>

using namespace std;

typedef long long int lli;
typedef pair<lli,lli> p_ii;

#define IOS ios_base::sync_with_stdio(false); cin.tie(NULL);
#define debug(x) cout << #x ": " << x << endl
int bug = 1;

vector<lli> bar;

int main(){
	IOS
	lli i;
	lli n;
	lli total = 0, left = 0;
	lli ans = -1;

	cin >> n;
	bar.resize(n);
	for(i = 0; i < n; i++){
		cin >> bar[i];
		total += bar[i];
	}

	for(i = 0; i < n; i++){
		left += bar[i];
		lli right = total - left;
		if(ans == -1){
			ans = abs(right - left);
		}
		else{
			ans = min(abs(right - left), ans);
		}
	}

	cout << ans << endl;
	
	return 0;
}


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

int main(){
  int N; cin >> N;
  vector<int> H(N);
  for(int i = 0; i < N; i++){
    cin >> H[i];
  }
  string ans = "Yes";
  for(int i = N-1; i>0; i--){
    if(H[i]-H[i-1]==-1) H[i-1]--;
    else if(H[i]-H[i-1]<-1){
      ans ="No";
      break;
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
int zeta(int t){
  if(t<0)t*=-1;
  return t;
}
 
int main() {
  int a,b,c,d;
  cin >>a>>b>>c>>d;
  
  bool s=0,t=0;
  if(zeta(c-a)<=d)s=1;
  if(zeta(b-c)<=d&&zeta(a-b)<=d)t=1;
  
  if(s||t)cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
}

Measured memory_bytes: 256
#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 N;
	cin >> N;

	VI A(2);
	A[0] = 1e9 + 10;
	cin >> A[1];

	FOR(i, 1, N){
		int a;
		cin >> a;

		int l = 0, r = A.size(), m;
		while(l + 1 < r){
			m = (l + r) / 2;
			if(a <= A[m]) l = m;
			else r = m;
			// cerr << a << " " << A[m] << " " << l << " " << r << endl;
		}
		m = (l + r) / 2 + 1;
		// cerr << m << endl;
		if(m < A.size()) A[m] = a;
		else A.push_back(a);
	}

	cout << A.size() - 1 << endl;

	return 0;
}


Measured memory_bytes: 892
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define db double
#define pii pair<int,int>
#define pli pair<ll,int>
#define pil pair<int,ll>
#define pll pair<ll,ll>
#define mat vector<vector<int>>
const int inf = 1 << 30;
const ll linf = 1e18;
const db EPS = 1e-7;
template<class T> void chmin(T& x, T y){if(x > y) x = y;}
template<class T> void chmax(T& x, T y){if(x < y) x = y;}

int N, M;
vector<int> G[100010];
int H[100010];
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin >> N >> M;
    for(int i = 1; i <= N; i++) cin >> H[i];
    for(int i = 0; i < M; i++){
        int a, b;
        cin >> a >> b;
        G[a].push_back(b);
        G[b].push_back(a);
    }
    int res = 0;
    for(int i = 1; i <= N; i++){
        bool flag = true;
        for(auto u : G[i]){
            if(H[u] >= H[i]) flag = false;
        }
        res += flag;
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 9140
#include <algorithm>
#include <cassert>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
//#include <regex>

/* g++ -g -std=c++0x */
/* g++ -g -std=c++11 */

using namespace std;

// freopen("input.txt", "rt", stdin);
// freopen("output.txt", "wt", stdout);

#define ALL(c)          (c).begin(), (c).end()
#define ALLR(c)         (c).rbegin(), (c).rend()
#define FOR(i,a,b)      for (int i=(a); i < (b); ++i)
#define FORR(i,a,b)     for (int i=(a); i > (b); --i)
#define FOR_ALL(i,c)    for (__typeof((c).begin()) i=(c).begin();   \
                             i != (c).end(); ++i)
#define FOR_ALLR(i,c)   for (__typeof((c).rbegin()) i=(c).rbegin(); \
                             i != (c).rend(); ++i)
#define SZ(array)       (sizeof(array)/sizeof(array[0]))
#define lc(x)           (x<<1)     /* 2*x */
#define rc(x)           (x<<1 | 1) /* 2*x+1 */
#define lowbit(x)       (x & (-x)) /* 0b10100 -> 0b100 */

typedef long long       LL;
typedef map<int,int>    MII;
typedef pair<int,int>   PII;
typedef set<int>        SI;
typedef vector<bool>    VB;
typedef vector<double>  VD;
typedef vector<int>     VI;
typedef vector<string>  VS;

/* check if a key is in container C */
template <class C>
inline bool in_(const typename C::key_type& k, const C& A)
{ return A.find(k) != A.end(); }
inline bool in_(const string& s, const string& S)
{ return S.find(s) != string::npos; }

const int maxn = 100100;
int n,m;
vector<int> G[maxn];
int dp[maxn];

int dfs(const int i)
{
    int& ans = dp[i];
    if (-1 == ans) {
        ans = 0;
        for (int j = 0; j < G[i].size(); j++) {
            int result = dfs(G[i][j]) + 1;
            ans = max(ans,result);
        }
    }
    return ans;
}
    
int main()
{
/* #ifndef ONLINE_JUDGE */
/*     freopen("foo", "rt", stdin); */
/* #endif */
    std::ios::sync_with_stdio(false);
    while (cin >> n >> m) {
        memset(dp,-1,sizeof(dp));
        FOR(i,1,n+1)
            G[i].clear();
        FOR(i,0,m) {
            int u,v; cin >> u >> v;
            G[u].push_back(v);
        }
        int ans = 0;
        FOR(u,1,n+1) {
            ans = max(ans,dfs(u));
        }
        cout << ans << endl;
    }
    return 0;
}


Measured memory_bytes: 8192
using System;class P{static void Main(string[] args){bool a=false;int b,c,d,e;int[] f,g=new int[4],h=new int[4],i=new int[]{10,50,100,500};while(true){b=int.Parse(Console.ReadLine());if(b==0){break;}if(!a){a=!a;}else{Console.WriteLine();}c=0;f=Array.ConvertAll(Console.ReadLine().Split(' '),int.Parse);for(e=3;e>=0;e--){c+=f[e]*i[e];}d=c-b;for(e=3;e>=0;e--){g[e]=d/i[e];d=d%i[e];h[e]=f[e]-g[e];}for(e=0;e<4;e++){if(h[e]>0){Console.WriteLine("{0} {1}",i[e],h[e]);}}}}}


Measured memory_bytes: 9368
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double ld;
const ll N = 100005;
char en = '\n';
ll inf = 1e16;
ll mod = 1e9 + 7;
ll power(ll x, ll n, ll mod) {
  ll res = 1;
  x %= mod;
  while (n) {
    if (n & 1)
      res = (res * x) % mod;
    x = (x * x) % mod;
    n >>= 1;
  }
  return res;
}

ll f(ll x, ll a, ll b) {
  if (x == 0)
    return 0;

  ll lcm = (a * b) / (__gcd(a, b));

  return (x / b) + (x / a) - (x / lcm);
}

int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);

  ll a, b, c, d;
  cin >> a >> b >> c >> d;

  cout << (b - a + 1 - (f(b, c, d) - f(a - 1, c, d))) << en;

  return 0;
}

Measured memory_bytes: 256
#define SUBMIT

#include <bits/stdc++.h>

using namespace std;

int main() {
#ifdef SUBMIT
    auto& in = cin;
#else
    stringstream in(R"(123456789012345678901234567890
234567890123456789012345678901
)");
#endif
    string a, b;
    in >> a >> b;
    string {5, '0'};
    if (a.length() > b.length()) b.insert(0, string(a.length() - b.length(), '0'));
    else if (a.length() < b.length()) a.insert(0, string(b.length() - a.length(), '0'));
//    cout << a << endl << b << endl;

    for (int i = 0; i < a.length(); ++i) {
        auto a_i = stoi(a.substr(i, 1));
        auto b_i = stoi(b.substr(i, 1));
        if (a_i > b_i) {
            cout << "GREATER" << endl;
            exit(0);
        } else if (a_i < b_i) {
            cout << "LESS" << endl;
            exit(0);
        }
    }
    cout << "EQUAL" << endl;
    return 0;
}

Measured memory_bytes: 256
while True :
    a, o ,b =map( str, input().split())
    a = int(a)
    b = int(b)
    if o == '?' :
        break
    elif o == '+' :
        print(a + b) 
    elif o == '-' :
        print(a - b)
    elif o =='*' :
        print(a*b)
    elif o =='/' :
        print(int(a/b))


Measured memory_bytes: 5596
N,Y=map(int,input().split())
for i in range(N+1):
    for j in range(N-i+1):
            if Y==i*10000+j*5000+1000*(N-j-i) :
                print(i,j,N-j-i)
                exit()
            elif i==N:
                print(-1,-1,-1)
                exit()

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define FASTIO ios::sync_with_stdio(false);cin.tie(0);
#define ADD +
#define SUBTRACT -
#define MULTIPLY *
#define DIVIDE /
#define MOD %
#define INCREMENT(x) ++x
#define DECREMENT(x) --x
#define in(a,b) cin>>a>>b;
#define out(a,b) cout<<a<<endl<<b<<endl;
#define scan(a) scanf("%d",&a);
#define print(a) printf("%d\n",a);
#define scanii(a,b) scanf("%d %d",&a,&b);
#define printii(a,b) printf("%d\n%d\n",a,b);
#define scaniii(a,b,c) scanf("%d %d %d",&a,&b,&c);
#define pub push_back
#define pob pop_back
#define puf push_front
#define pof pop_front
#define ll long long
#define ull unsigned long long
#define sll signed long long
#define pi acos(-1)
#define mod 1000000007
#define TRUE 1
#define FALSE 0
#define ZERO 0
#define MP make_pair
#define F first
#define S second
#define f1(i,a) for(int i=0;i<a;++i)
#define f2(i,a) for(int i=a-1;i>=0;--i)
#define en puts("");
#define elif else if
typedef ll int lli;
typedef sll int slli;
typedef ull int ulli;
const int sz=10000;
using namespace std;

int clue();
int result();
void show();
bool check(int n) {
    for(int i=2;i*i<=n;++i) {
        if(n%i==0)
        return false;
    }
    return true;
}


// bool cmp(pair<int,int>p,pair<int,int>q) {
//     // return p.first>q.first;//descending by first
//     // return p.first<q.first;//ascending by first
//     // return p.second>q.second;//descending by second
//     return p.second<q.second;//ascending by second
// }

bool cmp(int p,int q) {
    return p>q;//descending
    // return p<q;//ascending
}


int main() {

    int t;
    // cin>>t;
    t=1;
    while(t-->0) {
        clue();
    }

    return 0;
}
int clue() {

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

    (a+b+c>=22)?cout<<"bust"<<endl:cout<<"win"<<endl;
    
    return 0;
}

Measured memory_bytes: 3596
# ちょうど、なので引いていって0になったらbreak
a, b, c, x = int(input()), int(input()), int(input()), int(input())
cnt = 0
for i in range(0, a+1):
    if 500*i>x:
        break
    for j in range(0, b+1): 
        if 500*i+100*j>x:
            break
        for k in range(0, c+1):
            if 500*i+100*j+50*k>x:
                break
            elif 500*i+100*j+50*k==x:
                cnt+=1
print(cnt)


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

using namespace std;

using ll = long long;
using Pi = pair<int, int>;
using Pl = pair<ll, ll>;
using Ti = tuple<int, int, int>;
using Tl = tuple<ll, ll, ll>;

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define mt make_tuple
#define F first
#define S second
#define Get(t, i) get<(i)>((t))
#define all(v) (v).begin(), (v).end()
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define reps(i, f, n) for(int i = (int)(f); i < (int)(n); i++)
#define each(a, b) for(auto& a : b)

const int inf = 1 << 25;
const ll INF = 1LL << 55;

struct UnionFind
{
  vector<int> data;
  UnionFind(int sz):data(sz, -1){}
  int find(int x)
  {
    return (data[x] < 0 ? x : data[x] = find(data[x]));
  }
  bool same(int x, int y)
  {
    return (find(x) == find(y));
  }
  int unite(int x, int y)
  {
    x = find(x), y = find(y);
    if(x != y) {
      if(data[x] < data[y]) swap(x, y);
      data[x] += data[y]; data[y] = x;
    }
    return -data[x];
  }
  int size(int x)
  {
    return -data[find(x)];
  }
};

int main()
{
  int N, W, H;
  cin >> N >> W >> H;
  UnionFind uf(N);
  vector<int> xx(W, -1), yy(H, -1);
  int hashi = 0;
  rep(i, N) {
    int x, y; cin >> x >> y;
    x--, y--;
    if(x == 0 || x == W-1 || y == 0 || y == H-1) hashi = 1;
    if(~xx[x]) uf.unite(i, xx[x]);
    else xx[x] = i;
    if(~yy[y]) uf.unite(i, yy[y]);
    else yy[y] = i;
  }
  set<int> st;
  rep(i, N) st.insert(uf.find(i));
  if((int)st.size() == 1) cout << N-1 << endl;
  else cout << N+(int)st.size()-1-hashi << endl;
  return 0;
}

Measured memory_bytes: 4940
#include <iostream>
#include <algorithm>
#include <stdio.h>
#include <vector>
#include <iomanip>
#include <stdlib.h>

using namespace std;

#define LL long long
#define FOR(i,l,r) for(int i = l; i <= r; ++i)
#define REP(i,l,r) for(int i = l; i < r; ++i)
#define pi pair<int,int>
#define mp make_pair

const int maxN = 1e5 + 11;
const LL oo = 1e17 + 11;

int N,K;
int A[maxN],C[maxN];
bool cmp(int i,int j){
    return A[i] < A[j];
}

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie();
    cout.tie();
    //

    cin >> N;
    FOR(i,1,N){
        cin >> A[i];
        C[i] = i;
    }
    sort(C + 1,C + 1 + N,cmp);
    //
    FOR(i,1,N) cout << C[i] << " ";

    return 0;
}

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

#define ll  long long int
#define ld  long double
#define MAX 1000001
#define MOD 1000000007
#define pi  3.14159265358979323846264338
#define mp  make_pair
#define pb  push_back
#define pll pair<ll,ll>
#define vl  vector<ll>
#define vi  vector<int>
#define vs  vector<string>
#define vc  vector<char>
#define fst first
#define sec second
#define foi(i, a, b)   for(ll i = a; i<b;i++)
#define fod(i, a, b)   for(ll i = a;i>=b;i--)
#define all(v)         (v).begin(), (v).end()
#define max3(a, b, c)  max(max(a,b), c)
#define min3(a, b, c)  min(min(a,b), c)
#define ump  unordered_map<ll,ll>
#define us   unordered_set<ll>
#define nl  "\n"
#define INF  (ll)1e18
#define s(v) (ll)(v).size()
#define e(v) (v).empty

using namespace std;

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


void solve(){
    int n,w;
    cin>>n>>w;
    vector<int> wt(n);
    vector<int> val(n);

    foi(i,0,n){
        cin>>wt[i]>>val[i];
    }

    ll dp[n+1][w+1];
    for(int i=0;i<n+1;i++){
        for(int j=0;j<w+1;j++){
            if(i==0 || j==0){
                dp[i][j] = 0;
            }else{
                if(wt[i-1]<=j){
                    dp[i][j] = max(dp[i-1][j],val[i-1] + dp[i-1][j-wt[i-1]]);
                }else{
                    dp[i][j] = dp[i-1][j];
                }
            }
        }
    }
    cout<<dp[n][w]<<"\n";
}

int main(){
    // #ifndef ONLINE_JUDGE
    //     freopen("../input.txt", "r", stdin);
    //     freopen("../output.txt", "w", stdout);
    // #endif
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    ll t;
    t = 1;
    //cin>>t;
    while(t--){
        solve();
    }

    cerr << "Time : " << 1000 * ((double)clock()) / (double)CLOCKS_PER_SEC << "ms\n";
}

Measured memory_bytes: 82664
#include<stdio.h>
#include<stdlib.h>
#include<math.h>

typedef long long int int64;

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

void run(void){
  int n,m;
  scanf("%d%d",&n,&m);
  int *oneTo=(int *)calloc(n+1,sizeof(int));
  int *toN=(int *)calloc(n+1,sizeof(int));
  int i;
  for(i=0;i<m;i++){
    int a,b;
    scanf("%d%d",&a,&b);
    if(a==1) oneTo[b]=1;
    if(b==n) toN[a]=1;
  }
  for(i=1;i<=n;i++){
    if(oneTo[i] && toN[i]){
      printf("POSSIBLE\n");
      return;
    }
  }
  printf("IMPOSSIBLE\n");
  return;
}

int main(void){
  run();
  return 0;
}


Measured memory_bytes: 1664