akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (n); i++)
using namespace std;
using ll = long long;
using pii = pair<int, int>;

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

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

const int INF = 1 << 30;

int main() {
	int n, m;
	cin >> n >> m;
	vector<int> c(m);
	rep(i, m) cin >> c[i];
	vector<int> dp(n + 1, INF);
	dp[0] = 0;
	for (int i = 0; i <= n; i++) {
		for (int j = 0; j < m; j++) {
			if (i >= c[j]) chmin(dp[i], dp[i - c[j]] + 1);
		}
	}
	cout << dp[n] << endl;
	return 0;
}


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

#define fi first
#define se second
#define pb push_back
#define mod(n,k) ( ( ((n) % (k)) + (k) ) % (k))
#define forn(i,a,b) for(int i = a; i < b; i++)
#define forr(i,a,b) for(int i = a; i >= b; i--)
#define all(x) (x).begin(), (x).end()

typedef long long ll;
typedef long double ld;
typedef pair<int,int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;

#define si cout << "Yes\n";
#define no cout << "No\n";
int solve(int r,int g,int b,int k){
	if(g > r && b > g)return 1;
	if(!k)return 0;
	int res = 0;
	res |= solve(r*2,g,b,k-1);
	res |= solve(r,g*2,b,k-1);
	res |= solve(r,g,b*2,k-1);
	return res;
}
int main(){
	ios_base::sync_with_stdio(0); cin.tie(0);
	int r,g,b,k; cin >> r >> g >> b >> k;
	int res = solve(r,g,b,k);
	if(res){
		si;
		return 0;
	}
	no;
	return 0;
}
/*
__builtin_mul_overflow(x,y,&x)
-fsplit-stack
*/


Measured memory_bytes: 3656
fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}

fn read_vec2<T: std::str::FromStr>(n: usize) -> Vec<Vec<T>> {
    (0..n).map(|_| read_vec()).collect()
}

fn read_col<T: std::str::FromStr>(n: usize) -> Vec<T> {
    (0..n).map(|_| read()).collect()
}

use std::cmp::max;

fn main() {
    let n: usize = read();
    let mut a: Vec<u64> = read_col(n);
    let mut mx = 0;
    let mut id = 0;
    for i in 0..a.len() {
        if a[i] > mx {
            mx = a[i];
            id = i;
        }
    }
    a[id] = 0;
    let mut mx2 = 0;
    for i in 0..a.len() {
        if a[i] > mx2 {
            mx2 = a[i];
        }
    }
    for i in 0..a.len() {
        if i == id {
            println!("{}", mx2);
        } else {
            println!("{}", mx);
        }
    }
}


Measured memory_bytes: 7676
#include <iostream>
using namespace std;
typedef long long ll;
ll n,s[100001],a,ans=1,MOD=1e9+7;
int main(void){
    cin>>n;
    s[0]=3;
    for(int i=0;i<n;i++){
        cin>>a;
        ans*=s[a];
        ans%=MOD;
        s[a]--;
        s[a+1]++;
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 1024
import java.util.Scanner;

public class Main{

	public static void main(String args[]){
		new Main().mainrun();
	}

	private Scanner scan;

	private void mainrun() {
		scan = new Scanner(System.in);

		call(scan.nextInt());

		scan.close();
	}

	private void call(int n) {
		int i = 1;
		boolean f;

		f = false;

		while(true) {
			int x = i;
			f = false;

			if(x % 3 == 0) {
				System.out.print(" " + i);
				f = true;
			}

			if(!f) {
				while(true) {
					if(x % 10 == 3) {
						System.out.print(" " + i);
						break;
					}
					x /= 10;

					if(x == 0) {
						break;
					}
				}
			}

			if(++i > n) {
				break;
			}
		}
		System.out.println();
	}
}


Measured memory_bytes: 28728
import sys
input = sys.stdin.readline

def main():
    N, K = map(int, input().split())
    A = list(map(lambda n: int(n)-1, input().split()))

    visited = [False] * N
    visited[0] = True

    index = 0
    visited_index = [0]

    while K:
        index = A[index]
        if visited[index]:
            K -= 1
            start = visited_index.index(index)
            loop_index = visited_index[start:]
            print(loop_index[K % len(loop_index)] + 1)
            sys.exit()
        visited_index.append(index)
        visited[index] = True
        K -= 1
    print(index + 1)
    
main()

Measured memory_bytes: 31424
N,C = map(int,input().split())
ch = {}
for _ in range(N):
    s,t,c = map(int,input().split())
    if c not in ch:
        ch[c] = [0 for _ in range(2*10**5+2)]
    for i in range(2*s-1,2*t):
        ch[c][i]=1
cmax = 0
for i in range(2*10**5+2):
    cnt = 0
    for c in ch:
        if ch[c][i]==1:
            cnt += 1
    cmax = max(cmax,cnt)
print(cmax)

Measured memory_bytes: 134060
#include<bits/stdc++.h>
using namespace std;
const int mx=500000;
#define ll long long
#define p push_back
#define ff first
#define ss second
ll n ;
int main(){
    string s;
    cin>>s;
    cin>>n;
    for(int i=0;i<s.size();i++){
        if(i%n==0){
            cout<<s[i];
        }
    }
    return 0;
}


Measured memory_bytes: 384
// Problem : A - Takahashikun, The Strider
// Contest : AtCoder - AtCoder Grand Contest 046
// URL : https://atcoder.jp/contests/agc046/tasks/agc046_a
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

/*⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⣠⣶⡾⠏⠉⠙⠳⢦⡀⠀⠀⠀
⠀⠀⠀⣴⠿⠏⠀⠀⠀⠀⠀⠀⢳⡀⠀
⠀⠀⢠⣟⣋⡀⢀⣀⣀⡀⠀⣀⡀⣧⠀
⠀⠀⢸⣯⡭⠁⠸⣛⣟⠆⡴⣻⡲⣿⠀
⠀⠀⣟⣿⡭⠀⠀⠀⠀⠀⢱⠀⠀⣿⠀
⠀⠀⠙⢿⣯⠄⠀⠀⠀⢀⡀⠀⠀⡿⠀⠀
⠀⠀⠀⠀⠹⣶⠆⠀⠀⠀⠀⠀⡴⠃⠀⠀
⠀⠀⠀⠀⠀⢸⣷⡦⢤⡤⢤⣞⣁⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⢀⣤⣴⣿⣏⠁⠀⠀⠸⣏⢯⣷⣖⣦⡀⠀⠀⠀⠀⠀⠀
⢀⣾⣽⣿⣿⣿⣿⠛⢲⣶⣾⢉⡷⣿⣿⠵⣿⠀⠀⠀⠀⠀⠀
⣼⣿⠍⠉⣿⡭⠉⠙⢺⣇⣼⡏⠀⠀⠀⣄⢸⠀⠀⠀⠀⠀⠀
⣿⣿⣧⣀⣿.........⣀⣰⣏⣘⣆⣀⠀
*/
#include <bits/stdc++.h> 
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
 
#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
 
 
using namespace std;
using namespace __gnu_pbds;
 
typedef long long ll;
typedef long double ld;
typedef complex<ld> cd;
 
typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;
 
typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<cd> vcd;
 
#define l00p(i, a, b) for (int i=a; i<(b); i++)
#define loop(i, a) for (int i=0; i<(a); i++)
#define rep1(i,a,b) for (int i = (b)-1; i >= a; i--)
#define rep(i,a) for (int i = (a)-1; i >= 0; i--)
#define trav(a,x) for (auto& a : x)
#define uid(a, b) uniform_int_distribution<int>(a, b)(rng)

#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
#define ins insert
#define imax INT_MAX
#define imin INT_MIN
//#define MOD 998244353
 
template<class T> bool ckmin(T& a, const T& b) { return b < a ? a = b, 1 : 0; }
template<class T> bool ckmax(T& a, const T& b) { return a < b ? a = b, 1 : 0; }

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

 
const int MOD = 1000000007;
const char nl = '\n';
const ll INF = 1e18;
const int MX = 100001; //check the limits, dummy

int main() {
	 
	ios_base::sync_with_stdio(0); cin.tie(0); 
	int k;
	scanf("%d",&k);
	int t=1;
	while(k*t%360!=0)
	t++;
	printf("%d",t);
	return 0;
}
// read the question correctly (ll vs int)
// template by bqi343

Measured memory_bytes: 3792
import java.io.*;
public class Main{
	public static void main(String [] args) throws NumberFormatException, IOException{
		BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
		while(true){
		String[] st=br.readLine().split(" ");
		int a=Integer.parseInt(st[0]);
		int b=Integer.parseInt(st[1]);
		if(a==0&&b==0)break;
		System.out.println(Math.min(a, b)+" "+Math.max(a, b));
		}
	}}

Measured memory_bytes: 24392
import sys, math
from functools import lru_cache
sys.setrecursionlimit(500000)
MOD = 10**9+7

def input():
    return sys.stdin.readline()[:-1]

def mi():
    return map(int, input().split())

def ii():
    return int(input())

def i2(n):
    tmp = [list(mi()) for i in range(n)]
    return [list(i) for i in zip(*tmp)]

def main():
    X, Y = mi()
    pt = 0
    if X == 1:
        pt += 300000
    if X == 2:
        pt += 200000
    if X == 3:
        pt += 100000
    if Y == 1:
        pt += 300000
    if Y == 2:
        pt += 200000
    if Y == 3:
        pt += 100000
    if X == Y == 1:
        pt += 400000

    print(pt)

if __name__ == '__main__':
    main()

Measured memory_bytes: 9584
//template code, C343, 2019
import java.util.LinkedList;
import java.util.PriorityQueue;
import java.util.Queue;
import java.util.Scanner;
import java.util.ArrayList;
import java.util.Iterator;

class GraphRe {
	private int totalVertex;
	private LinkedList<LinkedList<Integer>> adjList;

	// adjacency list of edges
	public GraphRe() {
		totalVertex = 0;
	}

	public void loadAdjList() {
		Scanner in = new Scanner(System.in);
		totalVertex = in.nextInt();
		adjList = new LinkedList<LinkedList<Integer>>();
		for (int i = 0; i < totalVertex; i++) {
			LinkedList<Integer> tmp = new LinkedList<Integer>();
			// System.out.println("mark idx1 = " + idx1 + " degree = " + degree);
			for (int j = 0; j < totalVertex; j++) {
				int weight = in.nextInt();
				if (weight != -1) {
					tmp.add(j);
					tmp.add(weight);
				}
			}
			adjList.add(tmp);
		}
		in.close();
	}

	public void runDijkstra() {
		Pair[] paths = new Pair[totalVertex];
		paths[0] = new Pair(0);

		for (int i = 1; i < totalVertex; i++) {
			paths[i] = new Pair(Integer.MAX_VALUE);
		}

		int min = 0;

		while (min != -1) {
			Pair minPair = paths[min];
			minPair.setDone(true);
			LinkedList<Integer> neighbors = adjList.get(min);
			Iterator<Integer> it = neighbors.iterator();

			while (it.hasNext()) {
				int n = it.next();
				int w = it.next();
				Pair neighbor = paths[n];
				if(!neighbor.isDone()) {
				neighbor.setDistFromStart(Math.min(neighbor.getDistFromStart(), w));
				}
			}

			min = findMinVertex(paths);
		}

		int sum = 0; 
		
		for (int i = 0; i < totalVertex; i++) {
			sum+=paths[i].getDistFromStart();
		}
		
		System.out.println(sum);
	}

	private int findMinVertex(Pair[] paths) {
		int min = -1;
		int minDist = Integer.MAX_VALUE;

		for (int i = 0; i < totalVertex; i++) {
			Pair p = paths[i];
			if (p.getDistFromStart() < minDist && !p.isDone()) {
				minDist = p.getDistFromStart();
				min = i;
			}
		}

		return min;
	}
}

class Pair implements Comparable<Pair> {
	private int distFromStart;
	private boolean isDone;

	public Pair(int distFromStart) {
		this.distFromStart = distFromStart;
		this.isDone = false;
	}

	public boolean isDone() {
		return isDone;
	}

	public void setDone(boolean isDone) {
		this.isDone = isDone;
	}

	public int getDistFromStart() {
		return distFromStart;
	}

	public void setDistFromStart(int distFromStart) {
		this.distFromStart = distFromStart;
	}

	public int compareTo(Pair other) {
		return this.distFromStart - other.distFromStart;
	}
}

//change class name GraphRepresentation to Main() for submission to AIZU
public class Main {
	public static void main(String argv[]) {
		GraphRe g = new GraphRe();
		g.loadAdjList();
		// g.updateTimes();
		// g.printTimeStamps();
		// g.printAdjMatrix();
		// g.printShortestPaths();
		g.runDijkstra();
	}
}


Measured memory_bytes: 41472
#include <bits/stdc++.h>
#define rep(i, N) for (int i=0; i<(int)N; i++)
#define rep1(i, N) for (int i=1; i<(int)N; i++)

using namespace std;

int a, b;

int main() {
  cin >> a >> b;
  /*
  string s = "";
  string t = "";
  rep(i, b) s.push_back(to_string(a));
  rep(i, a) t.push_back(to_string(b));
  if(s < t) cout << s;
  else cout << t;
  */
  if (a < b) {
    rep(i, b) {
      cout << a;
    }
  } else {
    rep(i, a) {
      cout << b;
    }
  }
    
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>

int main() {
    int input[5];
    int cost = 10;
    int num = 0;
    int time = 0;

    for (int i = 0; i < 5; i++) {
        scanf("%d",&input[i]);
        if ((input[i] - 1)%10< cost) {
            cost = (input[i]-1) % 10;
            num = i;
        }
    }
    for (int i = 0; i < 5; i++) {
        if (i != num ) {
            if (input[i]%10 == 0){
                time += (input[i] / 10) * 10;
            }
            else {
                time += ((input[i] / 10) + 1) * 10;
            }
        }
        else {
            time += input[i];
        }
    }
    printf("%d\n",time);
    return 0;
}

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

using namespace std;

using ll = long long;
#define pb push_back
#define dbg(x) cerr << #x << " " << x << "\n"

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

    int x, y;
    cin >> x >> y;
    for (int a = 0; a <= x; a++) {
        if (a * 2 + (x - a) * 4 == y) {
            cout << "Yes\n";
            return 0;
        }
    }
    cout << "No\n";
    return 0;
}


Measured memory_bytes: 3636
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <cstdio>
#include <cmath>
#include <tuple>
#include <iomanip>
#include <numeric>
#include <unordered_map>
#include <sstream>   
#include<limits.h>
#include<float.h>
#include<list>
#include <array>
#include <complex>
#include<stdio.h>
#include<string.h>
#include <bitset>

using namespace std;
#define int  long long
 
#define I32_MAX 2147483647
#define I64_MAX 9223372036854775807LL
#define I64_MAX2 1223372036854775807LL
#define INF I64_MAX2
#define MOD 1000000007
#define MEM_SIZE 10000
#define DEBUG_OUT true
#define ALL(x) (x).begin(),(x).end()

template<typename T> void DEBUG(T e){if(DEBUG_OUT == false)return; std::cout << e <<" ";}
template<typename T> void DEBUG(const std::vector<T>& v){if(DEBUG_OUT == false)return;for(const auto& e : v){std::cout<< e << " "; } std::cout << std::endl;}
template<typename T> void DEBUG(const std::vector<std::vector<T> >& vv){if(DEBUG_OUT == false)return;for(const auto& v : vv){ DEBUG(v); } }
template<class T,class... Ts> void DEBUG(T d, Ts... e){if(DEBUG_OUT == false)return;DEBUG(d);DEBUG(e...);}
template <class T> void corner(bool flg, T hoge) {if (flg) {cout << hoge << endl; exit(0);}}
template< typename T1, typename T2 > inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template< typename T1, typename T2 > inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }

//solve

//FUNCTION
//solve

void solve(void)
{
  int N; cin>>N;
  int ANS = 0;
  for (int i = 0; i < N; i++)
  {
     int X; cin>>X;
     while(X%2 == 0)
     {
       ANS++;
       X /= 2;
     }
  }
  cout<<ANS<<endl;
  return;
}

int32_t main(int32_t argc, const char *argv[])
{
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);

  std::cout << std::fixed;
  std::cout << std::setprecision(9);
  solve();

  return 0;
}


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

int main() {
    int N; cin >> N;
    vector<int> a(N); for (int i = 0; i < N; i++) cin >> a[i];
    int mini = a[0], minind = 0;
    int maxi = a[0], maxind = 0;
    int neg = 0, posi = 0;

    for (int i = 0; i < N; i++) {
        if (a[i] < mini) {
            mini = a[i]; minind = i;
        }
        if (a[i] > maxi) {
            maxi = a[i]; maxind = i;
        }
    }
    bool f = abs(mini) > abs(maxi);
    int ind = maxind;
    if (f) ind = minind;
    ind++;
    printf("%d\n", 2*N-1);
    for (int i = 1; i <= N; i++) {
        printf("%d %d\n", ind, i);
    }
    if (f) {
        for (int i = N-1; 1 <= i; i--) {
            printf("%d %d\n", i+1, i);
        }
    } else {
        for (int i = 2; i <= N; i++) {
            printf("%d %d\n", i-1, i);
        }
    }
}


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

using namespace std;

#define pb push_back
#define mk make_pair
#define mod 1000000007
#define ff first
#define ss second

typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

int nxt[20][100010];
int inp[100010];
int pre[20][100010];
int main(){
    ios::sync_with_stdio(0);
    int n;
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>inp[i];
    }
    int l;
    cin>>l;
    for(int j=0;j<20;j++){
        for(int i=0;i<100010;i++){
            nxt[j][i]=100005;
            pre[j][i]=-1;
        }
    }
    int lst = n-1;
    for(int i=n-2;i>=0;i--){
        while(inp[lst]-inp[i]>l){
            lst--;
        }
        nxt[0][i]=lst;
    }

    lst=0;

    for(int i=1;i<n;i++){
        while(inp[i]-inp[lst]>l){
            lst++;
        }
        pre[0][i]=lst;
    }

    for(int j=1;j<20;j++){
        for(int i=0;i<n;i++){
            nxt[j][i]=nxt[j-1][nxt[j-1][i]];
            if(pre[j-1][i]!=-1)
            pre[j][i]=pre[j-1][pre[j-1][i]];
            else pre[j][i]=-1;
        }
    }

    int q;
    cin>>q;
    while(q--){
        int a,b;
        cin>>a>>b;
        a--;b--;
        if(a==b){
            cout<<0<<endl;
            continue;
        }
        int ans = 0;
        int j;
        if(a<b){
            for(j=19;j>=0;j--){
                if(nxt[j][a]<b){
                    a=nxt[j][a];
                    ans+=(1<<j);
                }
                else if(nxt[j][a]==b){
                    ans+=(1<<j);
                    break;
                }
            }
            if(j==-1) ans++;
        }
        else{
            for(j=19;j>=0;j--){
                if(pre[j][a]>b){
                    a=pre[j][a];
                    ans+=(1<<j);
                }
                else if(pre[j][a]==b){
                    ans+=(1<<j);
                    break;
                }
            }
            if(j==-1) ans++;
        }
        cout<<ans<<endl;
    }


}


Measured memory_bytes: 16896
#include<iostream>
#include<vector>
#include<algorithm>
#include<cmath>
#include<string>
#include<tuple>
#include<utility>
#include<stack>
#include<queue>
#include<deque>
#include<set>
#include<iomanip>
#include<map>
using namespace std;
typedef long long int ll;          
typedef pair<int, int> P;
const int INF = 1e9 + 7;
int dx[8] = { 1,0,-1,0,1,1,-1,-1 };
int dy[8] = { 0,1,0,-1,1,-1,1,-1 };



int main() {

	int n, d;
	cin >> n >> d;

	double x[15][15];

	for (int i = 0; i < n; i++) {
		for (int j = 0; j < d; j++) {
			cin >> x[i][j];
		}
	}

	int cnt = 0;

	vector<double> a;

	for (int i = 0; i < n-1; i++) {
		for (int j = i+1; j < n; j++) {
			double dis = 0;
			for (int k = 0; k < d; k++) {
				
				 dis += pow(abs(x[i][k] - x[j][k]),2);
				 
			}
			
			a.push_back(dis);
		}
	}
	for (int j = 0; j < a.size(); j++) {
		for (double i = 0; i * i <= 17000; i++) {
			if (i * i == a[j]) {
				cnt++;
			}
		}
	}
	

	cout << cnt << endl;
	
	return 0;
}

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! {
        s: String,
    }
    let s :&str = &s;
    println!("{}", match s {
        "SUN" => 7,
        "MON" => 6,
        "TUE" => 5,
        "WED" => 4,
        "THU" => 3,
        "FRI" => 2,
        "SAT" => 1,
        _ => 0,
    });
}


Measured memory_bytes: 4352
#include <iostream>
using namespace std;
int N,M,C,A[30],B[30];

int main(void)
{
  int i,j,s,cnt=0;
  cin >> N >> M >> C;
  for(i=0;i<M;i++) {
    cin >> B[i];
  }
  for(j=0;j<N;j++) {
    s=C;
    for(i=0;i<M;i++) {
      cin >> A[i];
      s+=A[i]*B[i];
    }
    cnt+=s>0?1:0;
  }
  cout << cnt;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long int
#define mk make_pair
#define pb push_back
#define pf push_front
#define fi first
#define se second
#define mod 1000000007
using namespace std;

void fast(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);cout.tie(0);
}

int main(){
    fast();
	ll a,b;
//	double b;
	cin>>a>>b;
//	double ans=a*b;
	cout<<a*b;
}

Measured memory_bytes: 3648
use std::cmp;

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)*}
    };
}

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)*}
    };
}

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, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

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

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

pub struct Graph(Vec<Vec<usize>>);

impl Graph {
    pub fn from_pairs(n: i32, pairs: Vec<(usize, usize)>) -> Self {
        let mut g = Vec::new();
        for _ in 0..n {
            g.push(Vec::new());
        }

        for (x,y) in pairs {
            g[x].push(y);
        }

        Graph(g)
    }

    fn search_internal(&self, current: usize, answer: &mut Vec<usize>, checked: &mut Vec<bool>) {
        let branches = self.0[current].clone();

        for b in branches {
            if !checked[b] {
                self.search_internal(b, answer, checked);
            }
            answer[current] = cmp::max(answer[b] + 1, answer[current]);
        }

        checked[current] = true;
    }

    pub fn search(self, n: i32) -> usize {
        let mut ans = vec![];
        for _ in 0..n {
            ans.push(0);
        }

        let mut checked = vec![];
        for _ in 0..n {
            checked.push(false);
        }

        for i in 0..n {
            if ans[i as usize] != 0 {
                continue;
            }

            self.search_internal(i as usize, &mut ans, &mut checked);
        }

        ans.into_iter().max().unwrap()
    }
}

fn main() {
    input!{
        n: i32,
        m: i32,
        xys: [(usize, usize); m],
    }

    let graph = Graph::from_pairs(n, xys.into_iter().map(|(x,y)| (x-1,y-1)).collect::<Vec<_>>());

    println!("{:?}", graph.search(n));
}



Measured memory_bytes: 15868
//url:
//problem name: Brick Break

#include <bits/stdc++.h>
#define REP(i,n) for (int i = 0; i < (n); ++i)
template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b;return true;}return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b;return true;}return false;}
using namespace std;
using ll = long long;
using P = pair<int,int>;
using Pl = pair<long long,long long>;
using veci = vector<int>;
using vecl = vector<long>;
using vecveci = vector<vector<int>>;
using vecvecl = vector<vector<long long>>;

int main() {
    int N,K,R,S,P;
    cin >> N >> K >> R >> S >> P;
    string T; cin >> T;
    string U = "";
    ll ans = 0;

    vector<char> res;

    REP(i,N) {
        ll score;
        char t;
        if(i-K < 0) {
            if(T[i] == 'r') {
                ans += P;
                U += 'p';
            }
            else if(T[i] == 's') {
                ans += R;
                U += 'r';
            }
            else {
                ans += S;
                U += 's';
            }
        } else {
                if(T[i] == 'r' && U[i-K] != 'p') {
                    ans += P;
                    U += 'p';
                }
                else if(T[i] == 's' && U[i-K] != 'r') {
                    ans += R;
                    U += 'r';
                 }
                    else if(T[i] == 'p' && U[i-K] != 's') {
                     ans += S;
                    U += 's';
                } else {
                    U += 'x';
                }
            }
    }

    cout << ans << endl;
}

Measured memory_bytes: 640
//自称高知能系Vtuberの高井茅乃です。
//Twitter: https://twitter.com/takaichino
//YouTube: https://www.youtube.com/channel/UCTOxnI3eOI_o1HRgzq-LEZw

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

#define INF 1999999999
#define REP(i,n) for(int i=0;i<n;i++)
#define REP1(i,n) for(int i=1;i<=n;i++)
#define MODA 1000000007 

int main() {
    int ans = 0;
	int a, b, c;
	cin >> a >> b >> c;

    cout << 9*max(a, max(b,c)) + a + b + c << endl;
}

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

using namespace std;

string s[109];

int main() {
  int n;
  cin >> n;
  set<string> ss;
  for (int i = 0; i < n; ++i) {
    cin >> s[i];
    ss.insert(s[i]);
  }
  if ((int)ss.size() != n) {
    cout << "No" << endl;
    return 0;
  }
  for (int i = 1; i < n; ++i) {
    if (s[i][0] != s[i - 1].back()) {
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;
}


Measured memory_bytes: 384
from collections import OrderedDict as od
a = {n for n in range(1,14)}
dic = od({"S":[],"H":[], "C":[], "D":[]})
N = int(input())
for n in range(N):
    card, num = tuple(input().split())
    dic[card].append(int(num))

dic["S"] = list(a - set(dic["S"]))
dic["H"] = list(a - set(dic["H"]))
dic["C"] = list(a - set(dic["C"]))
dic["D"] = list(a - set(dic["D"]))

for card,num in dic.items():
    num.sort()
    for n in num:
        print("{0} {1}".format(card,n))


Measured memory_bytes: 6000
#pragma GCC optimize("Ofast")
#pragma GCC target("avx")
#include <bits/stdc++.h>
using namespace std;

#define INIT std::cin.tie(0);std::ios::sync_with_stdio(false);
#define ALL(c) (c).begin(), (c).end()
#define CALL(c) (c).cbegin(), (c).cend()
#define RALL(c) (c).rbegin(), (c).rend()
#define CRALL(c) (c).crbegin(), (c).crend()
#define REP(i, n) for (int i = 0; i < static_cast<int>(n); i++)
#define FOR(i, s, n) for (int i = s; i < static_cast<int>(n); i++)
#define ASC(t) [](t& x, t& y){ return x < y; }
#define DESC(t) [](t& x, t& y){ return x > y; }
#define PSORT(s,p,e) partial_sort((s), next((s), (p)), (e))
#define VIEW(v,t) for_each((v).begin(), (v).end(), [](t& a) { cout << a << " "; }); cout << endl;

#define IN(a, x, b) (a<=x && x<b)
template<class T> inline T CHMAX(T& x, const T y){return x=(x<y)?y:x;}
template<class T> inline T CHMIN(T& x, const T y){return x=(x>y)?y:x;}
#define OUT(dist) std::cout<<(dist);
#define WS std::cout<<" ";
#define NL std::cout<<"\n"

using PII = pair<int, int>;
using PLL = pair<long long, long long>;
using LL = long long;
using ULL = unsigned long long;
template<class T> using V = vector<T>;
template<class T> using V2 = vector<vector<T>>;
template<class T, int W=255> using A = array<T, W>;
template<class T, int W=255, int H=255> using A2 = array<array<T, W>, W>;

LL N;

std::set<LL> s;


int main(){
    INIT;
    cin >> N;
    LL ans = (2 < N) ? N-1 : 0;
    s.insert(N-1);
    for(LL c = 2; c <= std::sqrt(N); c++) {
        LL x = N/c;
        while(x-1 > 0) {
            if(N % (x-1) == N / (x-1)) {
                if(s.find(x-1) == s.end()) {
                    ans += x-1;
                    s.insert(x-1);
                }
            }
            x /= c;
        }
    }
    cout << ans << "\n";
}

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


string func(ll n){
    if(n==0) return "";
    n--;
    return func(n/26) + string(1,'a'+n%26);
}

int main(void){
    ll n;
    cin >> n;
    cout << func(n) << endl;
    return 0;
}

Measured memory_bytes: 3600
a = int(input())
b = int(input())
c = int(input())
X = int(input())
count = 0
for i in range(a+1):
  for j in range(b+1):
    for k in range(c+1):
      total  = 500*i + 100*j + k*50
      if total == X:
        count +=1
        
print(count)


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

using namespace std;

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

using ll = long long;

const int Inf = 1e9;

int main() {
    int h, n;
    cin >> h >> n;
    vector<int> a(n), b(n);
    rep (i, n) cin >> a[i] >> b[i];
    vector<int> dp(h + 10, Inf);
    dp[0] = 0;
    rep (i, h + 1) {
        if (dp[i] == Inf) continue;
        rep (j, n) {
            int t = i + a[j];
            if (t >= h) t = h;
            dp[t] = min(dp[t], dp[i] + b[j]);
        } 
    }
    cout << dp[h] << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define endl '\n'
#define fast ios::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define zy -2147382637
#define bql 2147483647
#define ll long long
#define ull unsigned long long
#define ld long double
#define il inline
#define sz(x) x.size()
#define maxn 100010
#define rp(i, l, r) for (int i = l; i <= r; i++)
#define rb(i, r, l) for (int i = r; i >= l; i--)
#define fi first
#define se second
#define pb push_back
#define mp make_pair

using namespace std;
ll max(ll a,ll b){if(a>b)return a;else return b;}
ll min(ll a,ll b){if(a<b)return a;else return b;}
ll lowbit(ll x){return x&(-x);}
ll prime(ll x){
   if(x<=1)return false;
   for(int i=2;i<=int(sqrt(x));i++){
	   if(x%i==0)return false;
   }return true;
}
bool cmp(ll a,ll b){return a>b;}
ll gcd(ll a,ll b){ll r;while(b>0){r=a%b;a=b;b=r;}return a;}
ll powmod(ll a,ll b,ll mod) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
inline ll read() {
	char c = getchar(); ll w = 1; ll x = 0;
	while (!isdigit(c))
		(c == '-') && (w = -w), c = getchar();
	while (isdigit(c))
		x = (x << 1) + (x << 3) + (c ^ '0'), c = getchar();
	x *= w;
}
void fl(string name){
	freopen((name+".in").c_str(),"r",stdin);
	freopen((name+".out").c_str(),"w",stdout);
}
const int dx[8] = {-1, 1, 0, 0, -1, 1, -1, 1},
		  dy[8] = {0, 0, -1, 1, -1, -1, 1, 1};
int main(){
	fast;
	ll a,b;
	cin>> a>>b;
	if(a%b==0)cout<<a/b<<endl;
	else cout<<a/b+1<<endl;
	return 0;
}/*『你强归你强，Siyuan比你强』*/





Measured memory_bytes: 256
use std::cmp::*;
use std::f64::consts::PI;
use std::io::*;
use std::str::FromStr;
//portable utility
#[allow(dead_code)]
fn switch<T>(flag: bool, true_value: T, false_value: T) -> T {
    if flag {
        true_value
    } else {
        false_value
    }
}
#[allow(dead_code)]
fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}
#[allow(dead_code)]
fn read_string() -> Vec<char> {
    read::<String>().chars().collect()
}
#[allow(dead_code)]
fn read_vector<T: FromStr>(number: usize) -> Vec<T> {
    (0..number).map(|_| read()).collect()
}

fn main() {
    let a: f64 = read();
    let b: f64 = read();
    let h: f64 = read();
    let m: f64 = read();

    let arad = (h + m / 60.0) / 12.0 * 2.0 * PI;
    let ax = a * arad.cos();
    let ay = a * arad.sin();

    let brad = m / 60.0 * 2.0 * PI;
    let bx = b * brad.cos();
    let by = b * brad.sin();

    let dx = ax - bx;
    let dy = ay - by;
    let d = (dx * dx + dy * dy).sqrt();
    //println!("{},{},{},{}", arad, brad, ax, bx);
    println!("{}", d);
}


Measured memory_bytes: 2896
#include<bits/stdc++.h>
#define rep(i,n)for(int i=0;i<(n);i++)
using namespace std;
typedef pair<int,int>P;
#define mygc(c) (c)=getchar_unlocked()
#define mypc(c) putchar_unlocked(c)
void reader(int& x) { int k, m = 0; x = 0; for (;;) { mygc(k); if (k == '-') { m = 1; break; }if ('0' <= k&&k <= '9') { x = k - '0'; break; } }for (;;) { mygc(k); if (k<'0' || k>'9')break; x = x * 10 + k - '0'; }if (m) x = -x; }
void writer(int x, char c) { int s = 0, m = 0; char f[10]; if (x<0)m = 1, x = -x; while (x)f[s++] = x % 10, x /= 10; if (!s)f[s++] = 0; if (m)mypc('-'); while (s--)mypc(f[s] + '0'); mypc(c); }

vector<P>E[100000];
int d[100000],b[100000],cnt[200001],u[200000],v[200000],r[200000];
int main(){
	int n,m,q;reader(n);reader(m);reader(q);
	rep(i,m){
		reader(u[i]);reader(v[i]);u[i]--;v[i]--;r[i]=q;
	}
	rep(i,q){
		int a;reader(a);r[a-1]=i;
	}
	rep(i,m){
		E[u[i]].emplace_back(P(v[i],r[i]));E[v[i]].emplace_back(P(u[i],r[i]));
	}
	d[0]=1;b[0]=q;
	queue<int>que;que.emplace(0);
	while(!que.empty()){
		int p=que.front();que.pop();
		for(P&v:E[p]){
			if(d[v.first]==0){
				d[v.first]=d[p]+1;que.emplace(v.first);
			}
			if(d[v.first]==d[p]+1)
				b[v.first]=max(b[v.first],min(b[p],v.second));
		}
	}
	rep(i,n)cnt[b[i]]++;
	int ans=0;
	rep(i,q){
		ans+=cnt[i];
		writer(ans,'\n');
	}
}

Measured memory_bytes: 15460
N,K,*A=map(int,open(0).read().split())
for _ in range(K):
  B=[0]*(N+1)
  for i,j in enumerate(A):
    B[max(0,i-j)]+=1
    B[min(N,i+j+1)]-=1
  for i in range(N):B[i+1]+=B[i]
  if A==B:break
  A=B
print(*A[:-1])

Measured memory_bytes: 162488
#include<iostream>
#include<string>
#include<algorithm>
#include<bits/stdc++.h>
using namespace std;

int main(){
	long long N, sum=1;
	cin >> N;
  long long T[N+10];
  for(int j=0; j<N; j++){
    cin >> T[j];
    sum = T[j]/__gcd(T[j],sum)*sum;
  }cout << sum << endl;
}

Measured memory_bytes: 256
# coding: utf-8
n = int(input().rstrip())
taro = 0
hanako = 0
for i in range(n):
    t, h = input().rstrip().split()
    if t > h:
        taro += 3
    elif t < h:
        hanako +=3
    else:
        taro += 1
        hanako += 1

print(str(taro) + " " + str(hanako))


Measured memory_bytes: 5604
/*#include<iostream>
#include<algorithm>
#include<cstdio>
#define _USE_MATH_DEFINES
#include<math.h>
using namespace std;
int a[50], n;

int solve(int i, int m) {
	if (m == 0)return 1;
	if (i >= n)return 0;
	int res = solve(i + 1, m) || solve(i + 1, m - a[i]);
	return res;
}
int main() {
	int q, m, i;

	scanf("%d", &n);
	for (i = 0; i < n; i++) scanf("%d", &a[i]);
	scanf("%d", &q);
	for (i = 0; i < q; i++) {
		scanf("%d", &m);
		if (solve(0, m))printf("yes\n");
		else printf("no\n");
	}
	return 0;
}

struct point { double x, y; };

void koch(int n, point a, point b) {
	if (n == 0)return;
	point s, t, u;
	double th = M_PI *  60/ 180.0;

	s.x = (2.0*a.x + 1.0*b.x) / 3;
	s.y = (2.0*a.y + 1.0*b.y) / 3;
	t.x = (1.0*a.x + 2.0*b.x) / 3;
	t.y = (1.0*a.y + 2.0*b.y) / 3;
	u.x = (t.x - s.x)*cos(th) - (t.y - s.y)*sin(th) + s.x;
	u.y = (t.x - s.x)*sin(th) + (t.y - s.y)*cos(th) + s.y;

	koch(n - 1, a, s);
	printf("%.8f %.8f\n", s.x, s.y);
	koch(n - 1, s, u);
	printf("%.8f %.8f\n", u.x, u.y);
	koch(n - 1, u, t);
	printf("%.8f %.8f\n", t.x, t.y);
	koch(n - 1, t, b);
}

int main() {
	point a, b;
	int n;

	scanf("%d", &n);

	a.x = 0;
	a.y = 0;
	b.x = 100;
	b.y = 0;

	printf("%.8f %.8f\n", a.x, a.y);
	koch(n,a, b);
	printf("%.8f %.8f\n", b.x, b.y);
	return 0;
}

#include<iostream>
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<string.h>
using namespace std;
int main() {
	int n, m;
	int c[50001];
	int c1[21];
	cin >> n >> m;
	memset(c, 0x3f, sizeof(c));
	for (int i = 0; i < m; i++) {
		cin >> c1[i];
		c[c1[i]] = 1;
	}
	for (int i = 1; i < n; i++) {
		for (int j = 0; j < m; j++) {
			if(i+c1[j]<=50000)
				c[i + c1[j]] = min(c[i+c1[j]],c[i] + 1);
		}
	}
	cout << c[n] << endl;
	return 0;
}
*/
#include<iostream>
#include<cstdio>
#include<cmath>
#include<algorithm>
using namespace std;

int dp[101][10001];
int main() {
	int n,W;
	cin >> n >> W;
	for (int i = 1; i <= n; i++) {
		int v, w;
		cin >> v >> w;
		for (int j = W; j >=0; j--) {
			if (j - w >= 0)
				dp[i][j] = max(dp[i - 1][j - w] + v, dp[i - 1][j]);
			else
				dp[i][j] = dp[i - 1][j];
		}
	}
	cout << dp[n][W] << endl;

	return 0;
}


Measured memory_bytes: 7000
#include "bits/stdc++.h"
using namespace std;
#define REP(i, n) for(ll i = 0;i < n;i++)
#define ll long long
#define MOD 1000000007
using vi = vector<int>; // intの1次元の型に vi という別名をつける
using vvi = vector<vi>; // intの2次元の型に vvi という別名をつける

int n,k,x,y;

int main(){
  int ans=0;
  cin >> n;
  string s;cin>>s;
  if (n<3200){
    cout<<"red"<<endl;
  }else{
    cout<<s<<endl;
  }
  
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
class solve{ 
    public:
        void qq(){ 
            for(int i=1;i<10;i++){ 
                for(int j=1;j<10;j++){ 
                    cout<<i<<"x"<<j<<"="<<i*j<<endl;
                }
            }
        }
};
int main(){
    solve ans;
    ans.qq();
    return 0;
}

Measured memory_bytes: 2996
X, N = map(int, input().split())
p = list(map(int, input().split()))
ans, min_value = 0, 200

for i in range(102):
    if i in p:
        pass
    else:
        if abs(i-X) < min_value:
            ans = i
            min_value = abs(i-X)
print(ans)


Measured memory_bytes: 9172
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
using namespace std;
#define REP(i,m,n) for(int i=(int)m ; i < (int) n ; ++i )
#define rep(i,n) REP(i,0,n)
typedef long long ll;
typedef pair<int,int> pint;
typedef pair<ll,int> pli;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;
    using namespace std;
 
    int main(){
      int a,b,c;
      cin >> a >> b >>c;
      if(a+b>=c) cout << "Yes" << endl;
      else cout << "No" << endl;
      return 0;}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <climits>

using namespace std;

int gcd(int x, int y) {
    if (x < y) {
        int tmp = x;
        x = y;
        y = tmp;
    }
    int r = -1;

    while(r != 0) {
        r = x % y;
        x = y;
        y = r;
    }
    return x;
}

int check(vector<int> skip) {
    int ans = gcd(skip[0], skip[1]);
    for (int i = 1; i < skip.size() - 1; i++) {
        ans = gcd(ans, skip[i + 1]);
    }
    return ans;
}

int main()
{
    int n, x; cin >> n >> x;
    vector<int> skip;

    for (int i = 0; i < n; i++) {
        int cp; cin >> cp;
        skip.push_back(abs(cp - x));
    }

    if (skip.size() == 1) {
        cout << skip[0] << endl;
    } else {
        cout << check(skip) << endl;
    }

    return 0;
}

Measured memory_bytes: 1144
//#define _GLIBCXX_DEBUG

#include<bits/stdc++.h>
#define PI 3.14159265359
using namespace std;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
const int INF= 1e9+5;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll> >vvl;
typedef pair<ll,ll> P;
typedef tuple<ll,ll,ll> T;
const ll MOD=1000000007LL;
string abc="abcdefghijklmnopqrstuvwxyz";
string ABC="ABCDEFGHIJKLMNOPQRSTUVWXYZ";
int main(){
  ll n,m;cin>>n>>m;
  ll ans;
  if(2*n>m)ans=m/2;
  else {
    ans+=n;
    m-=2*n;
    ans+=m/4;
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 256
<?php

fscanf(STDIN, "%d", $n);
$A = array_map('intval', explode(' ', trim(fgets(STDIN))));

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

$gcd = gcd($A[0], $A[1]);
for ($i = 2; $i < $n; ++$i) {
    $gcd = gcd($gcd, $A[$i]);
}
echo $gcd;


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


//using ll = long long;
int ASC( void *a,  void *b) {
	return strcmp(*(const char **)a, *(const char **)b);//降順
}
int GCD(int a, int b) {
	if (b == 0) return a;
	else return GCD(b, a % b);
}

int main(void)
{
	char s[11], sx[11];
	scanf("%s%s",s,sx);
	for (int i = 0; i < strlen(s); i++) {
		if (s[i] != sx[i]) {
			printf("No");
			return 0;
		}
	}
	printf("Yes");

	return 0;
}

Measured memory_bytes: 1732
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> pii;
typedef pair<pii,ll> piii;
typedef pair<ll,pii> ipii;
#define MOD 998244353 
#define mod(a) ((a)%MOD)
#define pb push_back
#define ft first
#define sd second
#define mp make_pair
#define dbg(x) cout<<#x<<" = "<<x<<"\n"
#define dbg2(x,y) cout<<#x<<" = "<<x<<" , "<<#y<<" = "<<y<<"\n"
#define dbg3(x,y,z) cout<<#x<<" = "<<x<<" , "<<#y<<" = "<<y<<" , "<<#z<<" = "<<z<<"\n"
#define INF (1LL<<60)
/*#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;*/
#define sync ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define all(v) v.begin(),v.end()
#define endl '\n'
ll gcd(ll a,ll b){if(a==0) return b; return gcd(b%a,a);}
ll powm(ll base,ll exp,ll mod=MOD) {base%=mod;ll ans=1;while(exp){if(exp&1LL) ans=(ans*base)%mod;exp>>=1LL,base=(base*base)%mod;}return ans;}

vector<ll> ed[100005];
ll dp[100005];
ll p[100005];
ll d[100005];
ll v[100005];
ll ans=0;
void dfs(int x){
    if(v[x]) return;
    if(d[x]!=p[x]) return;
    v[x]=1;
    dp[x]++;
    ans=max(ans,dp[x]);
    for(auto it:ed[x]){
    	 d[it]++;
    	 dp[it]=max(dp[it],dp[x]);
    	 dfs(it);
    }  

}
int main(){
     sync;
     ll n,m;
     cin>>n;
     cin>>m;
     for(ll i=0; i<m; i++){
           ll x,y;
           cin>>x>>y;
           ed[x].pb(y);
           p[y]++;
     }
     queue<ll> q;
     for(int i=1;i<=n;i++){
     	 dfs(i);
     }

      cout<<ans-1<<endl;
} 



Measured memory_bytes: 12032
import sys
import math
import sys


##参考 https://qiita.com/hukuhuku11111a1/items/1bbf67d90630552eb512

class UnionFind:
    # 負の値はルートで集合の個数
    # 正の値は次の要素を返す
    def __init__(self, size):
        self.table = [-1 for _ in range(size)]
        self.size = [1 for _ in range(size)]

    # 集合の代表と集合の個数を求める
    def find(self, x):
        while self.table[x] >= 0:
            # 根に来た時,self.table[根のindex]は負の値なのでx = 根のindexで値が返される。
            x = self.table[x]
        return x, self.size[x]

    # 併合
    def union(self, x, y):
        s1, size1 = self.find(x)  # 根のindex,table[s1]がグラフの高さ
        s2, size2 = self.find(y)
        sumsize = size1 + size2
        if s1 != s2:  # 根が異なる場合
            if self.table[s1] != self.table[s2]:  # グラフの高さが異なる場合
                if self.table[s1] < self.table[s2]:
                    self.table[s2] = s1
                    self.size[s1] = sumsize
                else:
                    self.table[s1] = s2
                    self.size[s2] = sumsize
            else:
                # グラフの長さが同じ場合,どちらを根にしても変わらない
                # その際,グラフが1長くなることを考慮する
                self.table[s1] += -1
                self.table[s2] = s1
                self.size[s1] = sumsize
        return


input = sys.stdin.readline

# 1整数
# n = int(input())

# 空白区切り2整数
n, m = list(map(int, input().split()))
edge = [[0]] * m
for i in range(m):
    #print(m - i - 1)
    #print(edge)
    a, b = list(map(int, input().split()))
    edge[m - i - 1] = [a - 1, b - 1]

huben = 0
for i in range(n):
    huben += i

##不便さ
hubenlist = [0] * m

uf = UnionFind(n)

##橋を立てていく
for i in range(m):
    hubenlist[m - i - 1] = huben
   # print(str(i) + ' ' + str(huben))
    a, b = edge[i]
    s1, size1 = uf.find(a)
    s2, size2 = uf.find(b)
    if s1 != s2:
        huben -= size1 * size2

    uf.union(a, b)

for i in range(m):
    print(hubenlist[i])


Measured memory_bytes: 26864
import sys
input = sys.stdin.readline

from heapq import heappop, heappush
from collections import defaultdict

N, Q = map(int, input().split())

lst = []
l_append = lst.append
for i in range(N):
    s, t, x = map(int, input().split())
    l_append((t - x, 0, x)) #xで止まらなくなる
    l_append((s - x, 1, x)) #xで止まる

for i in range(Q):
    l_append((int(input()), 2, i))

lst.sort()
ans = [-1] * Q

#引っかかっている場所の管理
se = set()
se_hp = [] #heapで最小値を先頭に保つ

#小さい時刻から順に見ていく
s_remove = se.remove
s_add = se.add
for a, b, c in lst:
    if b == 0:
        s_remove(c)
    elif b == 1:
        s_add(c)
        heappush(se_hp, c)
    else:
        while se_hp and se_hp[0] not in se:
            heappop(se_hp)
        ans[c] = se_hp[0] if se_hp else -1

print ('\n'.join(map(str, ans)))

Measured memory_bytes: 106028
#include<cstdio>
#include<algorithm>
#include<vector>
using namespace std;
char p[201000];
int PV[26], n;
vector<int>E[26];
int w[201000], BIT[201000];
void Add(int a) {
	while (a <= n) {
		BIT[a]++;
		a += (a&-a);
	}
}
int Sum(int a) {
	int r = 0;
	while (a) {
		r += BIT[a];
		a -= (a&-a);
	}
	return r;
}
int main() {
	int i, j;
	scanf("%s", p);
	for (i = 0; p[i]; i++) {
		E[p[i] - 'a'].push_back(i);
	}
	n = i;
	for (i = 1; i <= n / 2; i++) {
		int Mx = -1, pv = -1;
		for (j = 0; j < 26; j++) {
			if ((PV[j] + 1) * 2 <= E[j].size()) {
				int d = E[j][E[j].size() - 1 - PV[j]] - E[j][PV[j]];
				if (Mx < d)Mx = d, pv = j;
			}
		}
		if (pv == -1) {
			printf("-1\n");
			return 0;
		}
		w[i] = E[pv][PV[pv]] + 1;
		w[n + 1 - i] = E[pv][E[pv].size() - 1 - PV[pv]] + 1;
		PV[pv]++;
	}
	if (n % 2) {
		for (i = 0; i < 26; i++)if (E[i].size() % 2)w[n/2+1] = E[i][PV[i]] + 1;
	}
	long long res = 0;
	for (i = n; i >= 1; i--) {
		res += Sum(w[i]);
		Add(w[i]);
	}
	printf("%lld\n", res);
}

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
typedef long long ll;
int main() {
    // ifstream in("data1.txt");
    // cin.rdbuf(in.rdbuf());
    int A, P;
    cin >> A >> P;
    int ans = 0;

    ans = (A * 3 + P) / 2;
    cout << ans << endl;
}


Measured memory_bytes: 256
n,k = map(int,input().split())
mod = 10**9+7

ans = 0

s = n*(n+1)//2 #0からnまでの総和

for i in range(k,n+2): #kからn+1まで
    mi = (i-1)*i//2
    ma = s - (n-i)*(n-i+1)//2
    ans += (ma-mi+1)%mod
print(ans%mod)

Measured memory_bytes: 9200
#include "bits/stdc++.h"

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

using namespace std;

int main() {
	int N;
	cin >> N;
	vector<int> d(N);
	
	rep(i, N)cin >> d[i];

	long long ans = 0;
	rep(i, N) {
		rep2(j, i + 1, N) {
			ans += (long long)d[i] * d[j];
		}
	}
	cout << ans;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstring>
#include <chrono>
#include <complex>
#define endl "\n"
#define ll long long int
#define vi vector<int>
#define vll vector<ll>
#define vvi vector < vi >
#define pii pair<int,int>
#define pll pair<long long, long long>
#define mod 1000000007
#define inf 1000000000000000001;
#define all(c) c.begin(),c.end()
#define mp(x,y) make_pair(x,y)
#define mem(a,val) memset(a,val,sizeof(a))
#define eb emplace_back
#define f first
#define s second

using namespace std;
int main()
{
  string s;
	cin>>s;
	if(s=="ABC")
	{
		cout<<"ARC\n";
	}
	else
	{
		cout<<"ABC\n";
	}
	return 0;
}


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

int main(){
  int n[6];
  for (int i = 1; i < 6; i++) {
    int a;
    std::cin >> a;
    if(a!=i)std::cout << i << '\n';
  }

  return 0;
}


Measured memory_bytes: 3632