akhauriyash/Code-Regression huggingface dataset:
//
//  main.cpp
//  20190810homework
//
//  Created by Priscilla Leang on 8/11/19.
//  Copyright © 2019 Priscilla Leang. All rights reserved.
//

#include <iostream>
using namespace std;
int main(int argc, const char * argv[]) {
    int a, b, m, x, f, y;
    bool b1 = false;
    string s, t;
    
    //first problem
    /*
    cin>> a>>b;
    m = a* b;
    m = m - a - b+1;
    cout << m;
    */
    //second problem
    
    m = 0;
    cin>> x>>a>>b;
    for (int i = 1; i<= x; i++){
        
        f = 0;
//        f = f+i/10;
//        f = f + i% 10;
        int n = i;
        while (n>9){
            f = f + n%10;
            n = n/10;
        }
        f+=n;
        
        
        
        if (a<=f && f<=b ){
            m+=i;
        }
        
    }
    cout << m;
    /*
    //third porblem
    b1 = true;
    cin>> s;
    for (int i = 1; i<s.length(); i++){
        f = 0;
        for (int j = 65; j<= 90; j++){
            if ( s[i] == j){
                f++;
            }
        }
        if (f != 1){
            b1 = false;
            break;
        }
    }
    if (b1 == true){
        if (s[0]<=90){
            a = s[0] + 32;
        }
        else {
            a = s[0] - 32;
        }
        cout <<  char(a);
        for (int i = 1; i< s.length(); i++){
            cout <<char(s[i] + 32);
        }
    }
    else if (b1 == false) {
        cout << s;
    }*/
    return 0;
}


Measured memory_bytes: 256
macro_rules! l {
    () => {{
        let mut buf = String::new();
        std::io::stdin().read_line(&mut buf).unwrap();
        buf.trim()
            .split_whitespace()
            .map(|x| x.parse().unwrap())
            .collect::<Vec<i32>>()
    }};
}

struct A<'a> {
    m: i32,
    v: Vec<i32>,
    check: Box<dyn FnMut(&Vec<i32>) + 'a>,
}

impl A<'_> {
    fn dfs(&mut self, i: usize, cm: i32) {
        if self.v.len() == i {
            (self.check)(&self.v);
            return;
        }
        for x in cm..(self.m + 1) {
            self.v[i] = x;
            self.dfs(i + 1, x);
        }
    }
}

fn main() {
    let (n, m, q) = match &l!()[..] {
        &[n, m, q] => (n, m, q),
        _ => panic!(),
    };

    let reqs = (0..q).into_iter().map(|_| l!()).collect::<Vec<_>>();

    let mut ans = -1;
    {
        let mut a = A {
            m: m,
            v: vec![-1; (1 + n) as usize],
            check: Box::new(|v| {
                let mut sum = 0;
                for r in &reqs {
                    if v[r[1] as usize] - v[r[0] as usize] == r[2] {
                        sum += r[3];
                    }
                }
                ans = std::cmp::max(sum, ans);
            }),
        };
        a.dfs(1, 1);
    }

    println!("{}", ans);
}


Measured memory_bytes: 2096
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
      int a = n/100;
      int b = n%100/10;
      int c = n%100%10;
      
        if(a==1) System.out.print(9);
        else if(a==9) System.out.print(1);
        else System.out.print(a);
      
      if(b==1) System.out.print(9);
        else if(b==9) System.out.print(1);
        else System.out.print(b);
      
      if(c==1) System.out.print(9);
        else if(c==9) System.out.print(1);
        else System.out.print(c);
      
	}
}

Measured memory_bytes: 21716
import java.util.Scanner;

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


Measured memory_bytes: 23252
#include<iostream>
#include<string>
#include<set>
#include<math.h>
using namespace std;

int digit_table[10],number[10];
set<int> set2,set3,set4;

void digit(int n,int s){
  int dgt=1;
  while(s/10!=0){
    s/=10;
    dgt+=1;
  }
  digit_table[n]=dgt;
}

int main(){
  int n,k,tmp,a,b;
  cin>>n>>k;

  while(n!=0&&k!=0){
  set<int> set2,set3,set4;
  for(int i=0;i<n;i++){
    cin>>tmp;
    number[i]=tmp;
    digit(i,tmp);
  //  cout<<"tmp="<<tmp<<" digit="<<digit_table[i]<<endl;
  }
  for(int i=0;i<n;i++){
    for(int j=0;j<n;j++){
        if(i!=j){
      //    cout<<number[i]*pow(10,digit_table[j])+number[j]<<endl;
          set2.insert(number[i]*pow(10,digit_table[j])+number[j]);
        }
    }
  }

  for(int i=0;i<n;i++){
    for(int j=0;j<n;j++){
      for(int l=0;l<n;l++){
        if(i!=j&&j!=l&&l!=i){
          set3.insert(number[i]*pow(10,digit_table[j]+digit_table[l])+number[j]*pow(10,digit_table[l])+number[l]);
        }
      }
    }
  }

  for(int i=0;i<n;i++){
    for(int j=0;j<n;j++){
      for(int l=0;l<n;l++){
        for(int m=0;m<n;m++){
          if(i!=j && i!=l && i!=m && j!=l && j!=m && l!=m){
            set4.insert(number[i]*pow(10,digit_table[j]+digit_table[l]+digit_table[m])+number[j]*pow(10,digit_table[l]+digit_table[m])+number[l]*pow(10,digit_table[m])+number[m]);
          }
        }
      }
    }
  }
//cout<<"answer=";
  if(k==2) cout<<set2.size()<<endl;
  if(k==3) cout<<set3.size()<<endl;
  if(k==4) cout<<set4.size()<<endl;
  cin>>n>>k;
}
  return 0;
}

Measured memory_bytes: 3356
import math
## test

n,a,b=map(int, input().split())
cnt = 0
mode = 0
if a == 0:
    cnt = 0
elif a+b == n:
    cnt = a
else:
    roop = math.floor(n / (a+b))
    anc_a = a*roop
    n_b = n-(roop*(a+b))
    while True:
        if n_b >= a and mode == 0:
            n_b = n_b - a
            cnt += a
            mode = 1
        elif mode == 1:
            n_b = n_b-b
            mode = 0
        elif n_b < a and mode == 0:
            cnt += n_b
            n_b = n_b -a
        if n_b <= 0:
            break
    cnt += anc_a 
print(cnt)
    
    


Measured memory_bytes: 3064
#include<iostream>
#include<cmath>
#define LEN 6378.1
#define PI 3.141592653589793238
using namespace std;
double a, b, c, d, BC, CA, C;
int main() {
    while (true) {
        cin >> a >> b >> c >> d;
        if (a == -1) { break; }
        BC = PI / 180 * (90.0 - a);
        CA = PI / 180 * (90.0 - c);
        C = PI*(d - b) / 180;
        cout << (int)(0.5 + LEN*acos(cos(BC)*cos(CA) + sin(BC)*sin(CA)*cos(C)))<< endl;
    }
}

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

using namespace std;


#define MAXN 510
int n, c[MAXN], s[MAXN], f[MAXN];

int solve(int station) {
  int time = 0;
  while (station<n) {
    while(time<s[station]) time++;
    while (time%f[station]) time++;
    time += c[station];
    station++;
  }
  return time;
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cin >> n;
  for (int i = 1; i <= n; ++i) {
    cin >> c[i] >> s[i] >> f[i];
  }
  for (int i = 1; i <= n; ++i) {
    cout << solve(i) << endl;
  }
  return 0;
}


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

int main(){
  int N;string s;
  cin >> N >> s;
  
  int64_t R = 0, G = 0, B = 0;
  for(int i = 0; i < N; i++){
    if(s.at(i) == 'R'){
      R++;
    }else if(s.at(i) == 'G'){
      G++;
    }else{
      B++;
    }
  }
  
  int count = 0;
  for(int i = 0; i < N-2; i++){
    for(int j = i + 1; j < (N - i + 1)/2 + i; j++){
      if(s.at(i) != s.at(j) && s.at(j) != s.at(2*j - i) && s.at(i) != s.at(2*j - i)){
        count++;
      }
    }
  }
  
  cout << R * G * B - count << endl;
}


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

#define REP(i,s,n) for(int i=s;i<n;++i)
#define rep(i,n) REP(i,0,n)

using namespace std;

#define MAX 100100

typedef long long ll;
ll T;
int N;
ll s[MAX], t[MAX];
ll sum[MAX*2];

void compute() {
  vector<ll> event;
  rep(i,N) {
    event.push_back(s[i]);
    event.push_back(t[i]);
  }

  // koko de sum wo tsukuru
  sum[0] = 0;
  REP(i,1,(int)event.size()) {
    sum[i] = sum[i-1];
    if( i & 1 ) {
      sum[i] += ( event[i] - event[i-1] );
    }
  }

  /*
  cout << "sum = ";
  rep(i,(int)event.size()) {
    cout << sum[i] << " ";
  } puts("");
  */

  ll maxi = 0;
  rep(i,(int)event.size()) {
    int sp = i;
    ll next = event[sp] + T;
    int ptr = lower_bound(event.begin(),event.end(),next) - event.begin();

    if( ptr >= (int)event.size() ) {
      ptr = (int)event.size()-1;
    } else {
      if( event[ptr] != next ) --ptr;
    }
    
    ll cost = 0;
    if( ptr & 1 ) {
      assert( ptr >= sp );
      cost = sum[ptr] - sum[sp];
    } else {
      assert( ptr >= sp );
      cost = sum[ptr] - sum[sp];
      cost += ( next - event[ptr] );
    }
    maxi = max(maxi,cost);
  }
  cout << maxi << endl;
}

int main() {
  cin >> T;
  cin >> N;
  rep(i,N) cin >> s[i] >> t[i];
  compute();
  return 0;
}

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

#define ll long long
#define ar array

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;

template <typename T> using oset = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define all(c) (c).begin(), (c).end()
#define sz(x) (int)(x).size()

#define F_OR(i, a, b, s) for (int i = (a); ((s) > 0 ? i < (b) : i > (b)); i += (s))
#define F_OR1(e) F_OR(i, 0, e, 1)
#define F_OR2(i, e) F_OR(i, 0, e, 1)
#define F_OR3(i, b, e) F_OR(i, b, e, 1)
#define F_OR4(i, b, e, s) F_OR(i, b, e, s)
#define GET5(a, b, c, d, e, ...) e
#define F_ORC(...) GET5(__VA_ARGS__, F_OR4, F_OR3, F_OR2, F_OR1)
#define FOR(...) F_ORC(__VA_ARGS__)(__VA_ARGS__)

#define E_ACH2(x, a) for (auto& x: a)
#define E_ACH3(x, y, a) for (auto& [x, y]: a)
#define E_ACH4(x, y, z, a) for (auto& [x, y, z]: a)
#define E_ACHC(...) GET5(__VA_ARGS__, E_ACH4, E_ACH3, E_ACH2)
#define EACH(...) E_ACHC(__VA_ARGS__)(__VA_ARGS__)

const int mxN=2e5, M=1e9+7;
int n, k, c0;
vector<ll> ap, an;

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

	cin >> n >> k;
	FOR(n) {
		ll a;
		cin >> a;
		if(a>0)
			ap.push_back(a);
		else if(a<0)
			an.push_back(-a);
		else
			++c0;
	}
	sort(all(ap));
	sort(all(an));
	if(k+c0>n) {
		cout << 0;
		return 0;
	}
	if(k==n-c0?an.size()%2==0:ap.size()||k%2==0) {
		reverse(all(ap));
		reverse(all(an));
		ll ans=1;
		int i=0, j=0;
		for(; k; --k) {
			if(i<ap.size()&&(j>=an.size()||ap[i]>an[j])) {
				ans=ans*ap[i]%M;
				++i;
			} else {
				ans=ans*an[j]%M;
				++j;
			}
		}
		if(j&1) {
			//i j-2
			//i-2 j
			ans=1;
			if(i<ap.size()&&j-1>=0&&(j>=an.size()||i-1<0||ap[i]*ap[i-1]>an[j]*an[j-1])) {
				FOR(k, i+1)
					ans=ans*ap[k]%M;
				FOR(k, j-1)
					ans=ans*an[k]%M;
				//ans=ans*a[i]%M;
				//ans=ans*a[i+1]%M;
			} else {
				FOR(k, i-1)
					ans=ans*ap[k]%M;
				FOR(k, j+1)
					ans=ans*an[k]%M;
				//ans=ans*a[i]%M;
				//ans=ans*a[i+1]%M;
			}
		}
		cout << ans;
		return 0;
	}
	if(c0) {
		cout << 0;
		return 0;
	}
	ll ans=1;
	for(int i=0, j=0; k; --k) {
		if(i<ap.size()&&(j>=an.size()||ap[i]<an[j])) {
			ans=ans*ap[i]%M;
			++i;
		} else {
			ans=ans*an[j]%M;
			++j;
		}
	}
	cout << M-ans;
}


Measured memory_bytes: 5552
#include <iostream>
#include <set>
#include <map>
#include <cmath>
#include <vector>
#include <string>
#include <algorithm>
#include <iomanip>
#include <queue>
#include <deque>
#include <stack>
#include <climits>
#include <math.h>
#include <cassert>
#include <unordered_map>
#include <chrono>
#include <random>
#include <ctime>
using namespace std;
#pragma warning(disable : 4996)
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;

const ld PI = 3.14159265358979323846;
const ll MOD = 998244353;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());


int main() {
#ifdef _DEBUG
	freopen("input1.txt", "r", stdin);
	freopen("output2.txt", "w", stdout);
#endif
	srand(time(0));
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	int n, k;
	cin >> n >> k;
	map<int, vector<int>> m;
	ll ans = 0;
	m[0].push_back(0);
	ll sum = 0;
	for (int i = 0; i < n; i++) {
		ll x;
		cin >> x;
		sum = (sum + x) % k;
		ll ind = ((sum - i - 1) % k + k) % k; 
		auto it = lower_bound(m[ind].begin(), m[ind].end(), i - k + 2);
		ans += m[ind].end() - it;
		m[ind].push_back(i + 1);
	}
	cout << ans;
}

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

using namespace std;
using ll = long long;

const int MOD = 1e9 + 7;
#define REP(i, n)  for(int i = 0; i < n; ++i)
#define FOR(i, t, n)  for(ll i = t; i <= (ll)n; ++i)
struct edge {
    int from, to;
    ll cost;
};


class Eratosthenes {
public:
    vector<bool> prime;

    Eratosthenes(ll size) {
        size = max((int) sqrt(size) + 1, 101010);
        prime.resize(size, 1);
        prime[0] = 0;
        prime[1] = 0;
        for (size_t i = 2; i * i <= size; ++i)
            if (prime[i]) {
                for (size_t j = 2; i * j <= size; ++j)prime[i * j] = false;
            }
    }
};


class Combination {
    vector<ll> fac; //n!(mod M)
    vector<ll> ifac; //k!^{M-2} (mod M)
public:
    Combination(ll size) {
        fac.resize(size);
        ifac.resize(size);
        fac[0] = 1;
        ifac[0] = 1;
        for (ll i = 0; i < size; i++) {
            fac[i + 1] = fac[i] * (i + 1) % MOD;
            ifac[i + 1] = ifac[i] * mpow(i + 1, MOD - 2) % MOD;
        }
    }

    ll mpow(ll x, ll n) {
        ll ans = 1;
        while (n != 0) {
            if (n & 1) ans = ans * x % MOD;
            x = x * x % MOD;
            n = n >> 1;
        }
        return ans;
    }

    ll comb(ll a, ll b) {
        if (a == 0 && b == 0)return 1;
        if (a < b || a < 0)return 0;
        ll tmp = ifac[a - b] * ifac[b] % MOD;
        return tmp * fac[a] % MOD;
    }
};


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

ll LCM(ll a, ll b) {
    ll gcd = GCD(a, b);
    return a / gcd * b;
}

ll N, P;

int main() {
    cin >> N >> P;
    Eratosthenes era(P);
    ll cnt = 0;
    map<ll, ll> m;
    for (ll i = 0; i <= era.prime.size(); i++) {
        if (!era.prime[i])continue;
        while (P % i == 0)P /= i, m[i]++, cnt++;
    }
    if (P > 1)m[P]++;
    if (cnt < N) {
        cout << 1 << endl;
        return 0;
    }
    priority_queue<ll, vector<ll>, greater<>> q;
    REP(i, N)q.push(1);
    for (auto v:m) {
        while (m[v.first] > 0) {
            ll k = q.top();
            q.pop();
            q.push(k * v.first);
            m[v.first]--;
        }
    }
    ll res = q.top();
    q.pop();
    while (!q.empty()) {
        res = GCD(res, q.top());
        q.pop();
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 384
/*
ID: wangjun30
TASK:
LANG: C++
*/
#include<iostream>
#include<queue>
#include<algorithm>
#include<tuple>
using namespace std;
int main(){
	int n,m;
	cin>>n>>m;
	tuple<int,int,int> p;
	queue<tuple<int,int,int> > rp[n+1];
	tuple<int,int,int> pa[m];
	for(int i=0;i<m;i++){
		int b,c;
		cin>>b>>c;
		pa[i]=make_tuple(b,c,i);
	}
	sort(pa,pa+m);
	for(int i=0;i<m;i++)
		rp[get<0>(pa[i])].push(make_tuple(get<2>(pa[i]),get<0>(pa[i]),rp[get<0>(pa[i])].size()+1));
	int pp=0;
	for(auto i:rp){
		while(!i.empty()){
			const auto j=i.front();
			pa[pp]=j;
			pp++;
			i.pop();
		}
	}
	sort(pa,pa+m);
	for(int i=0;i<m;i++){
		cout.fill('0');
		cout.width(6);
		cout<<get<1>(pa[i]);
		cout.fill('0');
		cout.width(6);
		cout<<get<2>(pa[i]);
		cout<<endl;
	}
	return 0;
}

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

int main(){
	int n;
	while(cin >> n){
		int a = n;
		if(n>1000) a = 1000;
		long s = 0;
		for(int i=0;i<=a;i++){
			int b = n-i;
			if(b>1000) b = 1000;
			for(int j=0;j<=b;j++){
				int c = n-i-j;
				if(c<=1000) s += c+1;
				else if(c<=2000) s += 2001-c;
			}
		}
		cout << s << endl;
	}
}

Measured memory_bytes: 1164
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef map<int,int> mii;
typedef vector<int> vi;
typedef vector<vector<int>> vii;
typedef vector<long long> vl;
typedef vector<vector<ll>> vll;
typedef vector<bool> vb;
typedef set<int> si; 
typedef queue<int> qi;
typedef stack<int> sti;
typedef priority_queue<int> pqi;
#define fori(i,a,b) for(int i = (a); i < (b); ++i)
#define rep(i,b,a) for(int i = (b); i >= (a); --i)
#define all(a) (a).begin(), (a).end()
//#define __builtin_popcountll bitCountLL
//#define __builtin_popcount bitCount
//__builtin_ctz 末尾0的个数, __builtin_clz 前导0的个数
//__builtin_ffs 最后一个1的位置
mt19937 mt_rand(chrono::high_resolution_clock::now().time_since_epoch().count());
//std::uniform_int_distribution<long long> rg(1,1e18);
#define maxn 100005
#define Mod 1000000007
const int INF = 2e9;
const ll ML = 4e18;
    
void solve() {
    int n;
    cin >> n;
    fori(i,0,n) cout << "ACL";
}

int main() {
    ios_base::sync_with_stdio(0); cin.tie(0);
	//cout.precision(30); cout << fixed;
	//freopen("D:\\data_in.txt", "r", stdin);
   
    solve();
   
    /*
    clock_t start,finish;
    start = clock();
    
    finish = clock();
    cout << "\n" << (double)(finish - start) / (double)(CLOCKS_PER_SEC) * 1000 << "ms" << endl;
    */
    return 0;
}

/***************************************************************
 question:
 idea:
 tag:
 record:
 ***************************************************************/


Measured memory_bytes: 3644
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, srt, end) for (long long i = (srt); i < (long long)(end); i++)
#define INF 100000000
int main(){
    string S;
    cin>>S;
    sort(S.begin(),S.end());
    if(S[0]==S[1]&&S[1]!=S[2]&&S[2]==S[3])cout<<"Yes";
    else cout<<"No";
}


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

int main()
{
	int a, b, c;
	cin >> a >> b >> c;
	
	if (a == b)
	{
		if (b == c)
		{
			cout << "No" << endl;
		}
		else
		{
			cout << "Yes" << endl;
		}
	}
	else if (b == c)
	{
		if (c == a)
		{
			cout << "No" << endl;
		}
		else
		{
			cout << "Yes" << endl;
		}
	}
	else if (c == a)
	{
		if (a == b)
		{
			cout << "No" << endl;
		}
		else
		{
			cout << "Yes" << endl;
		}
	}
	else
	{
		cout << "No" << 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 jAll = sc.nextInt();
        int mAll = sc.nextInt();
        int jEach = sc.nextInt();
        int mEach = sc.nextInt();
        System.out.println(n - Math.max((jAll + jEach - 1) / jEach, (mAll + mEach - 1) / mEach));
    }
}



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

int main(){
  int n ; cin >> n ;
  string a,b ;
  cin >> a >> b ;
  string ans ;
  for(int i=0;i<n;i++){
    ans += a.at(i) ;
    ans += b.at(i) ;
  }
  cout << ans << endl ;
}

Measured memory_bytes: 256
import sys
input = lambda: sys.stdin.readline().rstrip()
input_nums = lambda: list(map(int, input().split()))

def main():
    N = int(input())
    S = input()
    if N % 2 != 0:
        print('No')
    else:
        if S[:N//2] == S[N//2:]:
            print('Yes')
        else:
            print('No')

if __name__ == '__main__':
    main()

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

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

# define int(x) int x; scanf("%d",&x);
# define vint(v,n) vector<int> v(n); REP(i,n) scanf("%d", &v[i]);
# define string(x) string x; cin >> x;

using namespace std;

namespace utils{
  template <typename T> void print(vector<vector<T>> mat) {
    REP (i, mat.size()) {
      REP (j, mat[0].size()) cout << mat[i][j] << ' ';
      cout << endl;
    }
  }

  template <typename T> void print(vector<T> v) {
    REP (i, v.size())
      if (i >= v.size()-1)
	cout << v[i];
      else
	cout << v[i] << ' ';
    
    cout << endl;
  }

  template <typename T> pair<T, T> shape(vector<vector<T>> mat) {
    int d1, d2;

    d1 = mat.size();
    if (d1 > 0) d2 = mat[0].size();
    else int d2 = 0;
    cout << "(" << d1 << ", " << d2 << ")" << endl;
    return make_pair(0, 0);
  }

  template <typename T> vector<vector<T>> empty(int n, int m) {
    vector<vector<T>> mat(n, vector<T>(m));
    return mat;
  }
}


int main() {
  int a,b;
  cin >> a >> b;

  if(a%3 ==0) cout << "Possible" << endl;
  else if(b%3 ==0) cout << "Possible" << endl;
  else if((a+b)%3 ==0) cout << "Possible" << endl;
  else cout << "Impossible" << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define rep(i, a, b) for (int i = (a); i < (b); i++)
#define per(i, a, b) for (int i = (b) - 1; i >= (a); i--)
#ifdef LOCAL
#define debug(x) cerr << '[' << #x << " = " << (x) << "]\n"
#else
#define debug(x)
#endif
const int maxn=1e5;
int a[maxn],b[maxn],c[maxn],dp[maxn][3];
int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	int n;cin>>n;
	rep(i,0,n){
		cin>>a[i]>>b[i]>>c[i];
	}
	dp[0][0]=a[0];
	dp[0][1]=b[0];
	dp[0][2]=c[0];
	rep(i,1,n){
		dp[i][0]=a[i]+max(dp[i-1][1],dp[i-1][2]);
		dp[i][1]=b[i]+max(dp[i-1][0],dp[i-1][2]);
		dp[i][2]=c[i]+max(dp[i-1][1],dp[i-1][0]);
	}
	cout<<max({dp[n-1][0],dp[n-1][1],dp[n-1][2]});
}

Measured memory_bytes: 5968
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define all(x) (x).begin(),(x).end()
using namespace std;
const int INF=1145141919,MOD=1e9+7;
const long long LINF=8931145141919364364,LMOD=998244353;
// const int dx[]={1,0,-1,0,1,1,-1,-1},dy[]={0,-1,0,1,1,-1,-1,1};


int main(){
    int n,k; cin>>n>>k;
    long long a[n+1]={};
    rep(i,n){
        cin>>a[i+1];
        a[i+1]+=a[i];
    }
    vector<long long> sum;
    for(int i=0;i<n+1;i++){
        for(int j=i;j<n+1;j++){
            if(a[j]-a[i]!=0){
                sum.push_back(a[j]-a[i]);
            }
        }
    }
    sort(all(sum)); reverse(all(sum));
    // for(auto i:sum) cout<<i<<endl;
    // long long st=0,ss=sum[0];
    // while(ss>>=1){
    //     st++;
    // }
    long long ans=0;
    for(long long i=50;i>=0;i--){
        vector<long long> next;
        long long tmp=(1ll<<50)-1;
        for(long long j:sum){
            // if(i<=5)cout<<j<<endl;
            if((j>>i)&1){
                // cout<<j<<endl;
                next.push_back(j);
                tmp&=j;
            }
        }
        long long m=next.size();
        if(m>=k){
            ans=max(ans,tmp);
            sum=next;
        }
        // cout<<ans<<endl;
        // cout<<next.size()<<endl;
    }
    // for(int i=0;i<n*(n+1)/2;i++){
    //     for(int j=0;j<n*(n+1)/2;j++){
    //         if(i==j) continue;
    //         ans=max(ans,sum[i]&sum[j]);
    //     }
    // }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 6384
#include <iostream>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <limits>
#include <string>
#include <bitset>
#include <functional>

using namespace std;
using lint = long long;
using vi = vector<int>;
using vl = vector<int>;
using pii = pair<int, int>;
using pll = pair<lint, lint>;
using pqi = priority_queue<int>;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repr(i, n) for (int i = (n); i > 0; i--)
#define rep1(i, n) for (int i = 1; i <= (n); i++)
#define mp(x, y) make_pair((x), (y))
#define all(x) (x).begin(), (x).end()
#define foreach(it, x) for (auto it = (x).begin(); it != (x).end(); it++)
#define space (char)0x20

constexpr lint MOD = 1e9 + 7;
lint A, B, C, F, H, I, J, K, L, M, N, P, Q, R, S, T, U, V, W, X, Y;
// int ans;
// string ans;

struct Edge {
    lint to;
    lint yen;
    lint snuke;
};

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

	cin >> N >> M >> S >> T;
    vector<vector<Edge>> edge(N + 1);
    rep(i, M) {
        int a, b, c, d;
        cin >> a >> b >> c >> d;
        edge[a].push_back({ b, c, d });
        edge[b].push_back({ a, c, d });
    }

    priority_queue<pll, vector<pll>, greater<pll>> pq;

    vector<lint> y(N + 1, INT64_MAX);
    y[S] = 0;
    pq.push({ 0, S });
    while (!pq.empty()) {
        auto c = pq.top(); pq.pop();
        if (y[c.second] < c.first) {
            continue;
        }
        for (auto i : edge[c.second]) {
            if (y[i.to] > y[c.second] + i.yen) {
                y[i.to] = y[c.second] + i.yen;
                pq.push({ y[i.to], i.to});
            }
        }
    }

    vector<lint> s(N + 1, INT64_MAX);
    s[T] = 0;
    pq.push({ 0, T });
    while (!pq.empty()) {
        auto c = pq.top(); pq.pop();
        if (s[c.second] < c.first) {
            continue;
        }
        for (auto i : edge[c.second]) {
            if (s[i.to] > s[c.second] + i.snuke) {
                s[i.to] = s[c.second] + i.snuke;
                pq.push({ s[i.to], i.to});
            }
        }
    }

    priority_queue<pll, vector<pll>, greater<pll>> ans;
    rep1(i, N) {
        ans.push({ y[i] + s[i], i });
    }
    rep1(i, N) {
        while (ans.top().second < i) {
            ans.pop();
        }
        std::cout << (lint)1e15 - ans.top().first << endl;
    }

	return 0;
}

Measured memory_bytes: 14324
#include<iostream>
#include<algorithm>
#include<math.h>
#include<string>
#include<vector>
#include<queue>
#include<deque>
using namespace std;
typedef pair<int, int>P;
typedef pair<string, pair<int, int>>PP;
typedef long long ll;

int main() {
	int a, b; cin >> a >> b;
	int ans = a-1;
	if (a <= b) {
		ans++;
	}
	cout << ans << endl;
	return 0;
}

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

n = int(input())
ans = 0
table = [0] * (n + 1)

for i in range(1, n + 1):
    for j in range(i, n + 1, i):
        table[j] += 1
    ans += i*table[i]

print(ans)

Measured memory_bytes: 146052
#include <stdio.h>

#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <climits>
#include <cmath>
#include <deque>
#include <fstream>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>

using namespace std;

typedef long long ll;
typedef long double ld;

vector<ll> t;
vector<pair<ll, ll>> monsters;

void update(ll i, ll x) {
  for (++i; i < (ll)t.size(); i += i & -i) {
    t[i] += x;
  }
}
void rupdate(ll l, ll r, ll x) {
  update(l, x);
  update(r + 1, -x);
}
ll query(ll i) {
  ll r = 0;
  for (++i; i > 0; i -= i & -i) {
    r += t[i];
  }
  return r;
}

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

  ll n, d, a;
  cin >> n >> d >> a;
  monsters = vector<pair<ll, ll>>(n);
  t = vector<ll>(n + 1);
  for (auto &x : monsters) {
    cin >> x.first >> x.second;
    x.second = (x.second + a - 1) / a;
  }
  sort(monsters.begin(), monsters.end());

  for (ll i = 0; i < n; ++i) {
    rupdate(i, i, monsters[i].second);
  }

  ll res = 0;
  for (ll i = 0; i < n; ++i) {
    ll h = query(i);
    if (h <= 0) continue;

    ll lo = i, hi = n - 1;
    ll ans = -1;
    while (lo <= hi) {
      ll mid = lo + (hi - lo) / 2;
      if (monsters[mid].first <= monsters[i].first + d * 2) {
        ans = mid;
        lo = mid + 1;
      } else {
        hi = mid - 1;
      }
    }
    rupdate(i, ans, -h);
    res += h;
  }

  cout << res;
}


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

using namespace std;

#define _for(i,j,N) for(int i = (j); i < (N);i++)

int get_int(){int x;scanf("%d",&x);return x;}

int main()
{
    vector<int> vi1;
    vector<int> vi2;
    int n;
    cin >> n;
    _for(i,0,n){
        int h = get_int();
        vi1.push_back(h);
    }
    _for(i,0,n){
        int h = get_int();
        vi2.push_back(h);
    }
    for(int i = n-2;i>=0;i--){
        vi2[i]+=vi2[i+1];
    }

    int s = 0;
    int max_a = 0;
    _for(i,0,n){
        s+=vi1[i];
        max_a = max(max_a,s+vi2[i]);
    }
    cout << max_a << endl;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
int main(){
int n;
scanf("%d",&n);
char judge[n]={};
int ac=0,tle=0,wa=0,re=0;
for(int i=0;i<n;i++){
	scanf("%s",judge);
	if(strcmp(judge,"AC")==0){
		ac++;
	}
	else if(strcmp(judge,"TLE")==0){
		tle++;
	}
	else if(strcmp(judge,"WA")==0){
		wa++;
	}
	else if(strcmp(judge,"RE")==0){
		re++;
	}
}

printf("AC x %d\n",ac);
printf("WA x %d\n",wa);
printf("TLE x %d\n",tle);
printf("RE x %d\n",re);
return 0;
}

Measured memory_bytes: 1828
#include <bits/stdc++.h>
#include <cstdlib> //abs(x-y)
#include <iomanip> //出力の桁数指定

using namespace std;

int main() {
  string sa, sb, sc;
  cin >> sa >> sb >> sc;
  char x = sa.front();
  
  while(1){    
    if(x == 'a'){
      if(sa.empty()){
        cout << 'A' << endl;
        break;
      }
      x = sa.front();
      sa.erase(0, 1);
    }
    else if(x == 'b'){
      if(sb.empty()){
        cout << 'B' << endl;
        break;
      }
      x = sb.front();
      sb.erase(0, 1);
    }
    else{
      if(sc.empty()){
        cout << 'C' << endl;
        break;
      }
      x = sc.front();
      sc.erase(0, 1);
    }
  }
}

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

set<string> zet; //unique string
string s;
int k;

int main(){
  cin >> s >> k;
  int N = s.size(); // length of
  for (int i=0;i<N;i++){
    string ss = "";
    for (int j=i;j<i+k;j++){
      if (j >= N){
        break;
      }
      ss += s[j];
      zet.insert(ss);//all substring of size <= k
    }
  }
  
  //converting zet into an array
  
  
  //Access element by index
  set<string>::iterator it = zet.begin();
  for (int j=0;j<k-1;j++){
    it++;
  }
  cout << *it; 
  
  return 0;
}



Measured memory_bytes: 1664
#include<stdio.h>
#include<string.h>
int main(void){
    int A,B,C;
    scanf("%d %d %d",&A,&B,&C);
    if(A+B<C){
        printf("NO");
    }else if(A>C){
        printf("NO");
    }else{
        printf("YES");
    }
    return 0;
}

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

int main() {	
	
		int a,b,c,d; cin>>a>>b>>c>>d;
		bool k=false;
		for(int i=0;i<=20000;i++)
		{
			c-=b;
			if(c<=0){k=true; break;}
			a-=d;
			if(a<=0){break;}
		}
		cout<<(k?"Yes":"No");
}

Measured memory_bytes: 3636
#include "bits/stdc++.h"
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
typedef long long ll;

using namespace std;

// init {{{
struct ProconInit {
    static constexpr int IOS_PREC = 15;
    static constexpr bool AUTOFLUSH = false;

    ProconInit() {
        cin.tie(nullptr);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(IOS_PREC);
        if (AUTOFLUSH)
            cout << unitbuf;
    }
} PROCON_INIT;


const int NM = 201001;//ここを問題の制約を見ながらいじる．配列の確保に使う．
//ll P[NM];//あまり褒められたことではないが関数の外側に配列を確保すると怒られにくい．
//ll dp[NM];//あまり褒められたことではないが関数の外側に配列を確保すると怒られにくい．
ll P[NM];//あまり褒められたことではないが関数の外側に配列を確保すると怒られにくい．
double kitai[NM];//あまり褒められたことではないが関数の外側に配列を確保すると怒られにくい．
double dp[NM];//あまり褒められたことではないが関数の外側に配列を確保すると怒られにくい．


ll MOD = 1000000007;
int digit_length(int num)
{
    int count = 0;
    while (num) {
        num = num / 10;
        ++count;
    }
    return count;
}


ll gcd(ll a, ll b) {
    ll v0 = a, v1 = b, v2 = a % b;
    while (v2 != 0) {
        v0 = v1;
        v1 = v2;
        v2 = v0 % v1;
    };
    return v1;
}


// mod. m での a の逆元 a^{-1} を計算する
long long modinv(long long a, long long m) {
    long long b = m, u = 1, v = 0;
    while (b) {
        long long t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}

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

ll lcm(ll a, ll b) {
    return( (a % MOD) *modinv(gcd(a, b), MOD) * (b % MOD)) % MOD;
}
       // Main program
void solve() {
    ll N,K;
    cin >> N;
    cin >> K;


    for(ll i=0;i<N;i++){
        cin >> P[i];
      	kitai[i] = (double)P[i]*(double)(P[i]+1)/2.0/(double)P[i];      
      	//cout << kitai[i];
    }

  
  	for(ll j=0;j<0+K;j++){
        dp[0] += kitai[j];
    }
     //     cout << dp[0];



    for(ll i=1;i<N;i++){
      dp[i] = dp[i-1] + kitai[i+K-1] - kitai[i-1];
     // cout << dp[i];
    }
      //cout << dp[i];
    //}
    double max = 0;
    for(ll i=0;i<N;i++){
        if(max<dp[i]){
            max=dp[i];
        }  
    }
    cout << max;
    return;
}


int main() {
    solve();
    return 0;
}








Measured memory_bytes: 4992
#include <iostream>
#include <string>
using namespace std;
int main( void )
{
	double a, b;
	while ( cin >> a >> b )
	{
		double check_a[] = {
			35.5,
			37.5,
			40.0,
			43.0,
			50.0,
			55.0,
			70.0
		};

		double check_b[] = {
			71.0,
			77.0,
			83.0,
			89.0,
			105.0,
			116.0,
			148.0
		};

		int i;
		for ( i = 0; i < 7; i++ )
		{
			if ( a < check_a[i] && b < check_b[i] )
				break;
		}

		string rank[] = {
			"AAA",
			"AA",
			"A",
			"B",
			"C",
			"D",
			"E",
			"NA"
		};

		cout << rank[i] << endl;

	}

	return 0;
}

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

using namespace std;

int main () {
    int i, n, taro=0, hanako=0;
    string t, h;
    cin >> n;
    for(i=0;i<n;i++) {
        cin >> t >> h;
        if(t.compare(h) > 0) taro+=3;
        else if(t.compare(h) < 0) hanako+=3;
        else {taro++; hanako++;}
    }
    cout << taro << " " << hanako <<endl;
}

Measured memory_bytes: 1208
#include<stdio.h>

int main(void)
{
	int i, j, k;   //くり返し用
	int total;   //最初に入力する合計
	int number;   //1からnumberまでの組み合わせ
	int get_total;   //totalと一致する合計を見つけるために使う
	int count;   //totalと一致する合計を見つけたらカウントする

	while (1)
	{
		count = 0;
		scanf("%d %d", &number, &total);
		/*0 0が入力されたらプログラム終*/
		if (number == 0 && total == 0)
		{
			break;
		}
		/*重複なしで3つの数を選び合計を求める*/
		for (i = 1; i <= number; i++)
		{
			for (j = i + 1; j <= number; j++)
			{
				for (k = j + 1; k <= number; k++)
				{
					get_total = i + j + k;
					/*求めた合計と入力した合計が一致したらカウントする*/
					if (get_total == total)
					{
						count++;
					}
				}
			}
		}
		printf("%d\n", count);
	}
	return 0;
}


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

int main(){
  ll N; cin >> N;
  vector<vector<ll> > g(N);
  
  for(ll i = 0; i < N; i++){
    for(ll j = 0; j < N; j++){
      char c; cin >> c;
      if(c == '1'){
        g[i].push_back(j);
      }
    }
  }
  
  ll ans = -1;
  
  for(ll i = 0; i < N; i++){
    vector<ll> dist(N, -1);
    queue<ll> que;
    dist[i] = 1;
    que.push(i);
    ll tmp = 0;
    while(!que.empty()){
      ll now = que.front(); que.pop();
      for(auto e: g[now]){
        if(dist[e] == -1){
          dist[e] = dist[now] + 1;
          que.push(e);
        }else if(abs(dist[e] - dist[now]) != 1){
          tmp = -1;
          break;
        }
      }
    }
    if(tmp == -1) continue;
    else{
      for(ll j = 0; j < N; j++){
        tmp = max(tmp, dist[j]);
      }
      ans = max(ans, tmp);
    }
  }
  
  cout << ans << endl;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define pb push_back
#define REP(i, n) for (signed long long i = 0; i < (n); i++)
#define MOD 998244353
#define INF 93193111451418101
#define bitcnt(a) (ll) __builtin_popcount((a))
#define lb(a, b) lower_bound((a).begin(), (a).end(), (b))
#define ub(a, b) upper_bound((a).begin(), (a).end(), (b))
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;

ll gcd(ll a, ll b) {
  if (a == 0 || b == 0) {
    return 0;
  }
  while (a % b) {
    a = a % b;
    swap(a, b);
  }
  return b;
}
int main() {
  ll a, b;
  cin >> a >> b;
  cout << (a + b + 2) - gcd(a, b) - 1 << endl;
}



Measured memory_bytes: 3092
#include <bits/stdc++.h>
using namespace std;
int main(){
  int A,B,C,D,n;
  cin >> A >> B >> C >> D;
  n = A + B - C - D;
  if ( n > 0)
    cout << "Left" << endl;
  else if ( n == 0)
    cout << "Balanced" << endl;
  else
    cout << "Right" << endl;
}

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

const ll VMAX = 50;
const ll SMAX = VMAX * 50;
const ll INF = 1LL<<60;

struct Edge {
    ll to, a, b;
    Edge(ll to, ll a, ll b) : to(to), a(a), b(b) {}
};

struct Node {
    ll v;    // ノード
    ll t, s;  // 時間 , 所持金
    Node(ll v, ll t, ll s) : v(v), t(t), s(s) {}

    bool operator<(const Node& x) const {
        return (t > x.t);
    }
};

vector<Edge> V[VMAX];
vector<pair<ll,ll>> C;
ll dp[VMAX][SMAX]; // dp[i][j] : 頂点iで所持金jのときの最短時間

int main()
{
    ll n, m, s;
    cin >> n >> m >> s;
    s = min(s, SMAX-1);

    rep(i,m) {
        ll u, v, a, b;
        cin >> u >> v >> a >> b;
        u--; v--;        
        V[u].push_back(Edge(v, a, b));
        V[v].push_back(Edge(u, a, b));
    }
    C.resize(n);
    rep(i,n) {
        ll c, d;
        cin >> c >> d;
        C[i] = make_pair(c, d);
    }

    priority_queue<Node> Q;
    auto push = [&](ll v, ll t, ll s) {
        if (s < 0) return; // お金が足りないとreturn
        if (dp[v][s] <= t) return; // 既に他の最適経路があればreturn
        dp[v][s] = t;
        Q.emplace(v, t, s);
    };

    rep(i,VMAX)rep(j, SMAX) dp[i][j] = INF;
    push(0, 0, s);
    while(!Q.empty()) {
        auto node = Q.top();Q.pop();
        ll v = node.v;
        ll t = node.t;
        ll s = node.s;
        if (dp[v][s] != t) continue;

        // 換金するパターン
        ll c = C[v].first;
        ll d = C[v].second;
        push(v, t+d, min(s+c,SMAX-1));

        // 別のノードにいくパターン
        for (Edge x : V[v]) {
            ll a = x.a;
            ll b = x.b;
            ll to = x.to;
            push(to, t+b, s-a);
        }
    }
    
    for (int i=1; i<n; i++) {
        ll ans = INF;
        rep(j, SMAX) {
            ans = min(ans, dp[i][j]);
        }
        cout << ans << endl;
    }


    return 0;
}

Measured memory_bytes: 7360
#include <stdio.h>

#include <algorithm>
#include <cmath>
#include <iostream>
#include <numeric>
#include <queue>
#include <stack>
#include <string>
#include <vector>
typedef long long ll;
const ll BIGMOD = 1e9 + 7;
using namespace std;

int main() {
  int k, n;
  cin >> k >> n;
  vector<int> arr(n);
  for (int i = 0; i < n; ++i) scanf("%d", &arr[i]);
  vector<int> diff(n);
  for (int i = 0; i < n - 1; ++i) diff[i] = arr[i + 1] - arr[i];
  diff[n - 1] = k - arr[n - 1] + arr[0];
  int max = -1;
  int index = -1;
  for (int i = 0; i < n; ++i) {
    if (diff[i] > max) {
      max = diff[i];
      index = i;
    }
  }
  index = index == n - 1 ? 0 : index + 1;
  cout << k - max << endl;

  return 0;
}

Measured memory_bytes: 1920
n = int(input())
A = sorted(list(map(int, input().split())))

from collections import Counter
c = Counter(A)

NMAX = 10 ** 6 + 1000
dp = [True] * (NMAX + 1)

for x in A:
    if not dp[x]:
        continue
    for i in range(x * 2, NMAX + 1, x):
        dp[i] = False
    if c[x] > 1:
        dp[x] = False
    
count = 0
for x in A:
    if dp[x]:
        count += 1

print(count)


Measured memory_bytes: 129896
#include <iostream>
#include <queue>
using namespace std;
struct edge
{
	int v,n;
	long long w;
}e[2000005];
int head[500005],cnt;
long long dis[500005],ans[5005];
int vis[500005];
inline void add(int u,int v,long long w)
{
	e[++cnt]={v,head[u],w};
	head[u]=cnt;
}
priority_queue <pair<long long,int>,vector <pair<long long,int> >,greater <pair<long long,int> > > q;
inline int id(int x,int y)
{
	return x*5001+y;
}
int main(int argc, char** argv) {
	int n,m,st;
	cin >> n >> m >> st;
	for(int i=1;i<=m;i++)
	{
		int u,v,a,b;
		cin >> u >> v >> a >> b;
		for(int j=a;j<=5000;j++)
			add(id(u,j),id(v,j-a),b),add(id(v,j),id(u,j-a),b);
	}
	for(int i=1;i<=n;i++)
	{
		int c,d;
		cin >> c >> d;
		for(int j=0;j<=5000;j++)
			add(id(i,j),id(i,min(5000,j+c)),d);
	}
	int s=id(1,min(st,5000));
	q.push({0,s});
	for(int i=1;i<=500000;i++)
		dis[i]=1e18;
	dis[s]=0;
	while(!q.empty())
	{
		int x=q.top().second;
		q.pop();
		if(vis[x]) continue;
		vis[x]=1;
		for(int i=head[x];i;i=e[i].n)
		{
			if(dis[e[i].v]>dis[x]+e[i].w)
			{
				dis[e[i].v]=dis[x]+e[i].w;
				q.push({dis[e[i].v],e[i].v});
			}
		}
	}
	for(int i=2;i<=n;i++)
	{
		ans[i]=1e18;
		for(int j=0;j<=5000;j++)
			ans[i]=min(ans[i],dis[id(i,j)]);
		cout << ans[i] << "\n";
	}
//	for(int i=1;i<=n;i++)
//		cout << dis[i] << " ";
	return 0;
}

Measured memory_bytes: 31904
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> l_l;
typedef pair<int , int> i_i;
typedef vector<ll> vel;
typedef vector<int> vei;
typedef vector<char> vec;
typedef vector<bool> veb;
typedef vector<string> ves;
typedef vector<vector<ll>> ve_vel;
typedef vector<vector<int>> ve_vei;
typedef vector<vector<char>> ve_vec;
typedef vector<vector<bool>> ve_veb;
typedef vector<vector<string>> ve_ves;
#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 rep2(i,n) for(int i=2;i<(int)(n);i++)
#define repk(i,k,n) for(int i=k;i<(int)(n);i++)
#define fs first
#define sc second
#define pub push_back
#define pob pop_back
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define maxel(a) *max_element(all(a))
#define minel(a) *min_element(all(a))
#define acc accumulate
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define mod (1000000007)
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(){
	cin.tie(0);
	ios::sync_with_stdio(false);

	int a,b; cin >> a >> b;
    if(a > 0) {cout << "Positive" << endl; return 0;}
    if(a <= 0 and b >= 0) {cout << "Zero" << endl; return 0;}
    if(b < 0) {
        if((b-a) % 2 == 0){cout << "Negative" << endl; return 0;}
        else {cout << "Positive" << endl; return 0;}
    }
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<stdio.h>
#include<string>
#include<vector>
using namespace std;



int main(){
    int n, cnt = 0; 
    cin >> n;
    int h[n];
    int max = 0;
    for(int i = 0; i < n; i++){
        cin >> h[i];
        if(h[i] >= max){
            max = h[i];
            cnt++;
        }
    }
    cout << cnt << endl;

}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
using datas=pair<ll,ll>;
using tdata=pair<ll,datas>;
using vec=vector<ll>;
using mat=vector<vec>;
using pvec=vector<datas>;
using pmat=vector<pvec>;
#define For(i,a,b) for(i=a;i<b;i++)
#define bFor(i,a,b) for(i=a;i>=b;i--)
#define rep(i,N) For(i,0,N)
#define rep1(i,N) For(i,1,N)
#define brep(i,N) bFor(i,N-1,0)
#define all(v) (v).begin(),(v).end()
#define allr(v) (v).rbegin(),(v).rend()
#define vsort(v) sort(all(v))
#define vrsort(v) sort(allr(v))
#define mod 1000000007
#define endl "\n"
#define output(v) do{bool f=0;for(auto i:v){cout<<(f?" ":"")<<i;f=1;}cout<<endl;}while(0)

long mmid(long a,long b,long c){return a<b?(b<c?b:max(a,c)):(b>c?b:min(a,c));}

ll modinv(ll a) {
  ll b=mod,u=1,v=0,t;
  while(b){
    t=a/b;
    a-=t*b; swap(a,b);
    u-=t*v; swap(u,v);
  }
  return (u+mod)%mod;
}

ll moddevide(ll a,ll b){return (a*modinv(b))%mod;}

ll modncr(ll n,ll r){
  ll i,plus=1;
  rep(i,r){
    plus=(plus*(n-i))%mod;
    plus=moddevide(plus,i+1);
  }
  return plus;
}

ll modncrlistp[200000],modncrlistm[200000];

ll modncrs(ll n,ll r){
  ll i,j;
  if(modncrlistp[n]==0){
    for(i=n;i>=0;i--){
      if(modncrlistp[i])break;
    }
    if(i<0){
      modncrlistp[0]=1;
      rep1(i,n+1){
        modncrlistp[i]=(modncrlistp[i-1]*i)%mod;
      }
    }else{
      For(j,i+1,n+1){
        modncrlistp[j]=(modncrlistp[j-1]*j)%mod;
      }
    }
  }
  if(modncrlistm[n]==0){
    for(i=n;i>=0;i--){
      if(modncrlistm[i])break;
    }
    if(i<0){
      modncrlistm[0]=1;
      rep1(i,n+1){
        modncrlistm[i]=(modncrlistm[i-1]*modinv(i))%mod;
      }
    }else{
      For(j,i+1,n+1)modncrlistm[j]=(modncrlistm[j-1]*modinv(j))%mod;
    }
  }
  return (((modncrlistp[n]*modncrlistm[r])%mod)*modncrlistm[n-r])%mod;
}

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

ll countdigits(ll n){
  ll ans=0;
  while(n){n/=10;ans++;}
  return ans;
}

ll sumdigits(ll n){
  ll ans=0;
  while(n){ans+=n%10;n/=10;}
  return ans;
}

vec eratosthenes(ll N){
  ll i;
  vec ch(N+1,1),p;
  ch[0]=ch[1]=0;
  rep(i,N+1){
    if(ch[i]){
      p.push_back(i);
      for(ll j=2;i*j<=N;j++){
        ch[i*j]=0;
      }
    }
  }
  return ch;
}
int main(){
  ll i,j,k,N,M,a,b,c,ans=0;
  cin>>N>>M;
  mat v(N,vec(N,1LL<<60)),x(N,vec(N,0));
  rep(i,M){
    cin>>a>>b>>c;
    a--;b--;
    v[a][b]=c;
    v[b][a]=c;
    x[a][b]=c;
  }
  rep(k,N){
    rep(i,N){
      rep(j,N){
        v[i][j]=min(v[i][j],v[i][k]+v[k][j]);
      }
    }
  }
  rep(i,N){
    rep(j,N){
      if(x[i][j]&&(x[i][j]!=v[i][j]))ans++;
    }
  }
  cout<<ans<<endl;
  return 0;
}

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

using namespace std;


int main() {
    int n;
    cin >> n;
    vector<int> x(n),y(n),h(n);
    for(int i = 0; i < n; i++) {
        cin >> x[i] >> y[i] >> h[i];
    }
    for(int i = 0; i <= 100; i++) {
        for(int j = 0; j <= 100; j++) {
            int H = -1;
            for(int k = 0; k < n; k++) {
                if(h[k] > 0) {
                    int R = h[k] + abs(i - x[k]) + abs(j - y[k]);
                    if(H == -1) {
                        H = R;
                    } else if(H != R) {
                        H = -2;
                        break;
                    }
                }
            }
            if(H == -2) {
                continue;
            }
            for(int k = 0; k < n; k++) {
                if(h[k] == 0) {
                    int d = h[k] + abs(i - x[k]) + abs(j - y[k]);
                    if(H > d) {
                        H = -2;
                        break;
                    }
                }
            }
            if(H == -2) {
                continue;
            }
            cout << i << " " << j << " " << H << "\n";
            return 0;
        }
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
    int n,m,max=0;
    string tmp;
    cin >> n;
    map<string,int> nss;
    for(int i=0;i<n;i++){
        cin >> tmp;
        nss[tmp]++;
    }
    cin >> m;
    for(int i=0;i<m;i++){
        cin >> tmp;
        nss[tmp]--;
    }
    for (auto iter = nss.begin(); iter != nss.end(); iter++)
        if(max<iter->second)
            max = iter->second;
    cout << max <<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i,n) for (int i = 0; i < (n); i++)
#define ALL(a) a.begin(), a.end()
#define RALL(a) a.rbegin(), a.rend()
using namespace std;
using ll = long long;
const ll MOD = 1000000007;
const ll INF = MOD * MOD;

int main() {

    int a, b, c, d;
    cin >> a >> b >> c >> d;
    
    cout << (a*b >= c*d ? a*b : c*d) << endl;
    
    return 0;
}

Measured memory_bytes: 256
#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 a	b;cin>>ab;(p).push_back(ab);
#define vecps2(p) string ab;cin>>ab;(p).push_back(ab);
#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 pb(b,a) (b).push_back((a));
#define doublece(a,b) cout<<(a)<<' '<<(b)<<endl;
#define pairs(s) vector<pair<int,int>> (s);
#define pairsp(s) int aa,bb;cin>>aa>>bb;(s).push_back(make_pair(aa,bb));
#define MOD 1000000007
#define cey ce("Yes")
#define cen ce("No")
#define ceY ce("YES")
#define ceN ce("NO")

int sum[210000];
int main()
{
	int N;
	cin >> N;
	fx(N-1) {
		int a;
		cin >> a;
		sum[a]++;
	}

	fyg(N+1,1) {
		ce(sum[y])
	}
    return 0;
}



Measured memory_bytes: 4376
import numpy as np
def q48(n, m, c, b, a):
    return (np.count_nonzero(np.dot(a, b) + c > 0))

N, M, C = [int(i) for i in input().split()]
B= [int(i) for i in input().split()]
A = []
for i in range(N):
    A.append([int(i) for i in input().split()])

print(q48(N, M, C, B, A))

Measured memory_bytes: 12564