akhauriyash/Code-Regression huggingface dataset:
#include<cstdio>
#include <vector>
#include<utility>
#include <stack>
#include<algorithm>
using namespace std;

int main(){
	int N;
	scanf("%d", &N);
	int a[N-1], b[N-1];
	vector<pair<int, int> > edge[N];
	for (int i = 0; i < N-1; ++i){
		scanf("%d %d", a+i, b+i);
		a[i]--;b[i]--;
		edge[a[i]].push_back(make_pair(b[i], i));
		edge[b[i]].push_back(make_pair(a[i], i));
	}
	int color[N], kinshi[N], K = 0;
	kinshi[0] = 0;
	bool has_been_discovered[N];
	has_been_discovered[0] = true;
	for (int i = 1; i < N; ++i){
		has_been_discovered[i] = false;
	}
	stack<int> S;
	S.push(0);
	while(!S.empty()){
		int u = S.top(); S.pop();
		int clr_this = 1;
		for (int i = 0; i < edge[u].size(); ++i){
			int v = edge[u][i].first;
			if(!has_been_discovered[v]){
				has_been_discovered[v] = true;
				S.push(v);
				kinshi[v] = color[edge[u][i].second] = clr_this == kinshi[u] ? ++clr_this : clr_this;
				if(clr_this > K) K = clr_this;
				clr_this++;
			}
		}
	}
	printf("%d\n", K);
	for (int i = 0; i < N-1; ++i){
		printf("%d\n", color[i]);
	}
	return 0;
}

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

using namespace std;

int main() {
	long long n;
	long long d;
	
	cin >> n >> d;
	
	int count = 0;
	vector <pair<long long, long long>> points(n);
	for (int i = 0; i < n; i++) {
		cin >> points[i].first >> points[i].second;
		if ( (long long) ceil(sqrt( points[i].first * points[i].first + points[i].second * points[i].second )) <= d) {
			count++;
		}
	}
	
	cout << count;
	return 0;
}

Measured memory_bytes: 6428
N = int(input())
Alist = list(map(int,input().split()))

minabs = min(list(map(abs,Alist)))
sumabs = sum(list(map(abs,Alist)))

c_ne = 0
c_ze = 0
for i in range(N):
    if Alist[ i ] < 0:
        c_ne += 1
    if Alist[ i ] == 0:
        c_ze += 1

if c_ne % 2 == 0:
    print( sumabs )
elif c_ze > 0:
    print( sumabs )
else:
    print( sumabs - minabs * 2)

Measured memory_bytes: 14252
#include <iostream>
#include <string>
#include <cmath>

int ctoi(char c){
  return c - '0';
}

int main(void){
  std::string s;
  std::cin >> s;

  int num = 0;
  num = (num*10)%1000 + ctoi(s[0]);
  num = (num*10)%1000 + ctoi(s[1]);
  int min_diff = 1000;
  for(int i=2; i<s.size(); i++){
    num = (num*10)%1000 + ctoi(s[i]);
    int diff = std::abs(num-753);
    if(min_diff > diff) min_diff = diff;
  }
  std::cout << min_diff << std::endl;
  return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <string>
#include <vector>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <typeinfo>
#include <numeric>
#include <functional>
#include <unordered_map>
#include <bitset>


using namespace std;
using ll = long long;
using ull = unsigned long long;

const ll INF = 1e16;
const ll MOD = 1e9 + 7;

#define REP(i, n) for(ll i = 0; i < n; i++)





int main() {
    int n;
    scanf("%d",&n);
    if(n%2!=0){
        n=n*2;
    }
    printf("%d\n",n);
}

Measured memory_bytes: 256
#define _LIBCPP_DEBUG 0
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
ll MOD = 1e9+7;

int main(void) {

    int N; cin>>N;
    vector<int> L(N);
    for (int i = 0; i < N; ++i) cin>>L[i];
    int ans = 0;
    sort(L.begin(), L.end());

    for (int i = 0; i < N-2; ++i) {
        for (int j = i+1; j < N-1; ++j) {
            int wa = L[i]+L[j];
            auto pos = lower_bound(L.begin()+j,L.end(),L[i]+L[j]);
            int ng = distance(L.begin()+j, pos)-1;
            ans += ng;
        }
    }

    cout<<ans<<endl;

    return 0;
}

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

public class Main {
	public static void main(String[] args) throws IOException{
		InputReader in = new InputReader(System.in);
		
		while (true) {
			int height = in.readInt();
			int width = in.readInt();	
			if (height == 0 && width == 0) break;
			for (int i = 0; i < height; i++) {
				for (int j = 0; j < width; j++) {
					System.out.print("#");
				}
				System.out.println();
			}
			System.out.println();
		}
	}
}

class InputReader{
	private BufferedReader br;
	private StringTokenizer buffer = null;	
	
	public InputReader(InputStream in) {
		br = new BufferedReader(new InputStreamReader(in));				
	}

	public String read() throws IOException {
		while(buffer == null || !buffer.hasMoreTokens()) {
			buffer = new StringTokenizer(br.readLine());
		}
		return buffer.nextToken();
	}
	
	public int readInt() throws IOException {
		while(buffer == null || !buffer.hasMoreTokens()) {
			buffer = new StringTokenizer(br.readLine());
		}
		return Integer.parseInt(buffer.nextToken());
	}
}


Measured memory_bytes: 33452
#include<bits/stdc++.h>
using namespace std;
const long long INF = 1LL << 60;
long long dp[110][100100];
template<class T> inline bool chmax(T& a, T b){if(a<b){a=b;return 1;}return 0;}
template<class T> inline bool chmin(T& a, T b){if(a>b){a=b;return 1;}return 0;}
#define rep(i,n) for(int i=0;i<n;i++)

int main(){
  int N, W;
  cin >> N >> W;
  int w[N], v[N];
  rep(i,N){
    cin >> w[i] >> v[i];
  }
  rep(i,N){
    rep(j,W+1){
      if(j-w[i]>=0){
        chmax(dp[i+1][j],dp[i][j-w[i]]+v[i]);
      }
      chmax(dp[i+1][j],dp[i][j]);
    }
  }
  cout << dp[N][W] << endl;
}


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

using namespace std;

const int N = 1e5 + 5;

typedef long long ll;

typedef pair <int, ll> pll;

vector <pll> g[N];
int n;
ll d[N];
int a[N];

void dfs(int u, int p, ll dis) {
  d[u] = dis;
  if(d[u] & 1) {
    a[u] = 1;
  } else {
    a[u] = 0;
  }
  for(auto v : g[u]) {
    if(v.first == p) continue;
    dfs(v.first, u, dis + v.second);
  }
}

int main() {
  cin >> n;
  for(int i = 1; i < n; i++) {
    int u, v; cin >> u >> v;
    ll w; cin >> w;
    g[u].push_back({v, w});
    g[v].push_back({u, w});
  }
  dfs(1, 1, 0);
  for(int i = 1; i <= n; i++) {
    cout << a[i] << '\n';
  }
}

Measured memory_bytes: 10496
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define repi(i,a,n) for(int (i)=(a);(i)<(n);(i)++)
int main() {
  int n,d,ans=0;
  cin>>n>>d;
  vector<vector<int>> x(n+1,vector<int>(d+1));
  repi(i,1,n+1) repi(j,1,d+1) cin>>x[i][j];
  
  repi(i,1,n){
    repi(j,i+1,n+1){
      int diff=0;
      repi(k,1,d+1){
        diff+=(x[i][k]-x[j][k])*(x[i][k]-x[j][k]);
      }
      for(int k=1;k<=diff;k++){
        if(k*k==diff) ans++;
      }
    }
  }
  cout<<ans;
  return 0;
}

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

const int maxn = 1005; 
int dp[maxn][maxn];
char s[maxn][maxn];
long long mod = 1e9 + 7;

int main(int argc, char const *argv[])
{
//	freopen("in.txt", "r", stdin);
	int n, m;
	scanf("%d %d", &n, &m);
	for(int i=0; i<n; i++){
		scanf("%s", s[i]);
	}
	int x = 0;
	while(x < n && s[x][0] == '.'){
		dp[x][0] = 1;
		x += 1;
	}
	x = 0;
	while(x < m && s[0][x] == '.'){
		dp[0][x] = 1;
		x += 1;
	}
	for(int i=1; i<n; i++){
		for(int j=1; j<m; j++){
			if(s[i][j] == '#')continue;
			if(i-1 >= 0 && s[i-1][j] == '.'){
				dp[i][j] = dp[i-1][j];
				dp[i][j] %= mod;
			}
			if(j-1 >= 0 && s[i][j-1] == '.'){
				dp[i][j] += dp[i][j-1];
				dp[i][j] %= mod;
			}
		}
	}
	cout << dp[n-1][m-1]%mod <<endl;

	return 0;
}

Measured memory_bytes: 5120
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vb=vector<bool>;
using vvb=vector<vb>;
using vd=vector<double>;
using vvd=vector<vd>;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using pii=pair<int,int>;
using pll=pair<ll,ll>;
using tll=tuple<ll,ll>;
using tlll=tuple<ll,ll,ll>;
using vs=vector<string>;

#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rep(i,n) range(i,0,n)
#define rrep(i,n) for(ll i=(n)-1;i>=0;i--)
#define range(i,a,n) for(ll i=(a);i<(n);i++)

#define LINF ((ll)1ll<<60)
#define INF ((int)1<<30)
#define EPS (1e-9)
#define MOD (1000000007ll)
#define fcout(a) cout<<setprecision(a)<<fixed
#define fs first
#define sc second
#define PI 3.1415926535897932384

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

template<class T>bool chmax(T&a,T b){if(a<b){a=b; return true;}return false;}
template<class T>bool chmin(T&a,T b){if(a>b){a=b; return true;}return false;}
template<class S>S acm(vector<S>&a){return accumulate(all(a),S());}
template<class S>S max(vector<S>&a){return *max_element(all(a));}
template<class S>S min(vector<S>&a){return *min_element(all(a));}
void YN(bool b){cout<<(b?"YES":"NO")<<"\n";}
void Yn(bool b){cout<<(b?"Yes":"No")<<"\n";}
void yn(bool b){cout<<(b?"yes":"no")<<"\n";}
int sgn(const double&r){return (r>EPS)-(r<-EPS);} // a>0  : sgn(a)>0
int sgn(const double&a,const double&b){return sgn(a-b);} // b<=c : sgn(b,c)<=0

ll max(int a,ll b){return max((ll)a,b);} ll max(ll a,int b){return max(a,(ll)b);}
template<class T>void puta(T&&t){cout<<t<<"\n";}
template<class H,class...T>void puta(H&&h,T&&...t){cout<<h<<' ';puta(t...);}
template<class S,class T>ostream&operator<<(ostream&os,pair<S,T>p){os<<"["<<p.first<<", "<<p.second<<"]";return os;};
template<class S>auto&operator<<(ostream&os,vector<S>t){bool a=1; for(auto s:t){os<<(a?"":" ")<<s;a=0;} return os;}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll h,n;
	cin>>h>>n;
	vl a(n),b(n);
	rep(i,n)cin>>a[i]>>b[i];
	vl dp(h+1+10000,LINF);
	dp[0]=0;
	rep(i,n){
		rep(j,h+1+10000){
			if(j-a[i]>=0)chmin(dp[j],dp[j-a[i]]+b[i]);
		}
		rrep(j,h+10000){
			chmin(dp[j],dp[j+1]);
		}
	}
	//puta(dp);
	puta(dp[h]);
}


Measured memory_bytes: 384
S = list(input())
for i in range(len(S)//2):
    flag =0
    _ = S.pop(-1)
    _ = S.pop(-1)
    bf = S[:len(S)//2]
    af = S[len(S)//2:]
    for i in range(len(bf)):
        if bf[i] != af[i]:
            flag = 1
            break
    if flag ==0:
        break
print(len(S))


Measured memory_bytes: 8956
#include<bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define INF 1000000010
#define EPS 1e-9
#define fst first
#define scd second

#define debug(x) cout<<x<<endl;
#define repi(i,x,n) for(int i=x;i<n;i++)
#define rep(i,n) repi(i,0,n)
#define lp(i,n) repi(i,0,n)
#define repn(i,n) for(int i=n;i>=0;i--)
#define int long long
#define endl "\n"


signed main(){
  cin.tie(0);	
  ios::sync_with_stdio(false);
  while(1){
    int n,w,d;
    cin>>n>>w>>d;
    if(n==0 && w==0 && d==0) break;
    vector<pair<int,pair<int,int> > >cake;
    cake.push_back(make_pair(w*d,make_pair(w,d)));
    int p[100],s[100];
    rep(i,n){
      cin>>p[i]>>s[i];
      pair<int,pair<int,int> > now;
      now=cake[p[i]-1];
      int ww=now.scd.fst,dd=now.scd.scd;
      cake.erase(cake.begin()+p[i]-1);
      while(s[i]>(ww+dd)) s[i]-=ww+dd;
      if(s[i]>ww){
	s[i]-=ww;
	cake.push_back(make_pair(ww*min(dd-s[i],s[i]),make_pair(ww,min(dd-s[i],s[i]))));
	cake.push_back(make_pair(ww*max(dd-s[i],s[i]),make_pair(ww,max(dd-s[i],s[i]))));
      }else{
	cake.push_back(make_pair(dd*min(ww-s[i],s[i]),make_pair(min(ww-s[i],s[i]),dd)));
	cake.push_back(make_pair(dd*max(ww-s[i],s[i]),make_pair(max(ww-s[i],s[i]),dd)));
      }
    }
    sort(cake.begin(),cake.end() );
    rep(i,cake.size() ){
      cout<<cake[i].fst;
      if(i!=cake.size() -1) cout<<" ";
    }
    cout<<endl;
  }
	
    

  return 0;
}


Measured memory_bytes: 3020
#include<stdio.h>

int main(void)
{
  double N = 0,p = 0,max = -99999999999,sum = 0;
  scanf("%lf",&N);
  
  for(int i = 0;i < N;i++)
  {
    scanf("%lf",&p);
    if(max < p)
    {
      max = p;
    }
    sum += p;
  }
  
  printf("%d",(int)sum - (int)max / 2);
  return 0;
}

Measured memory_bytes: 128
//Name: Carry a Cheese
//Level: 2
//Category: 数学,幾何
//Note:

/**
 * 直方体のどれかの面をまっすぐ入口に押しこむように入れるのが最適。
 * このとき、入口に平行な面の対角線の長さが、入口の直径よりも小さければ運び込むことができる。
 * 浮動小数点数を使うと誤差が怖いので、長さを2乗して扱うことで整数で判定する。
 *
 * オーダーは O(N)。
 */
#include <iostream>
#include <algorithm>

using namespace std;

bool solve() {
    long long A, B, C;
    cin >> A >> B >> C;
    if(!A && !B && !C) return false;

    const long long diag = min({A*A+B*B, A*A+C*C, B*B+C*C});
    int N;
    cin >> N;
    while(N--) {
        long long R;
        cin >> R;
        cout << (4*R*R > diag ? "OK" : "NA") << endl;
    }
    return true;
}

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

    while(solve()) ;
    return 0;
}

Measured memory_bytes: 1192
import java.util.*;

class Main {
    public static void main(String[] args) {
        Scanner sc  = new Scanner(System.in);

        long a = sc.nextLong();
        long b = sc.nextLong();
        long x = sc.nextLong();

        if ( a % x == 0 ) {
            System.out.println( b / x - (a / x - 1) );
        } else {
            System.out.println( b / x - (a / x) );
        }
    }
}

Measured memory_bytes: 21844
#include <cassert>
#include <cstdio>
#include <cstring>
#include <vector>

std::vector<int> process(int a, int b, int f)
{
    std::vector<bool> visited(f + 1);
    for (int i = 0; i <= f; i += a) {
        for (int j = i; j <= f; j += b) {
            visited[j] = true;
        }
    }
    std::vector<int> result;
    for (int i = 0; i <= f; ++ i) {
        if (visited[i]) {
            result.push_back(i);
        }
    }
    return result;
}

int main()
{
#ifdef LOCAL_JUDGE
    freopen("C.in", "r", stdin);
#endif
    int a, b, c, d, e, f;
    while (scanf("%d%d%d%d%d%d", &a, &b, &c, &d, &e, &f) == 6) {
        auto xs = process(100 * a, 100 * b, f);
        auto ys = process(c, d, f);
        auto a = 0;
        auto b = 0;
        for (auto x : xs) {
            assert(x % 100 == 0);
            for (auto y : ys) {
                if (x + y <= f && y <= x / 100 * e && (a == 0 && b == 0 || y * (a + b) > b * (x + y))) {
                    a = x, b = y;
                }
            }
        }
        printf("%d %d\n", a + b, b);
    }
}


Measured memory_bytes: 256
use proconio::input;

fn main() {
    input! {
        x: i32,
        y: i32
    }
    // a + b = x
    // a * 2 + b * 4 = y
    //
    // a = x - b
    // 2 * x - 2 * b + 4 * b = y
    // 2x + 2b = y
    // b = (y - 2 * x) / 2

    let b = y - 2 * x;
    if b < 0 || (y - 2 * x) % 2 != 0 || x - b / 2 < 0 {
        println!("No")
    } else {
        println!("Yes")
    }
}


Measured memory_bytes: 2116
#include <stdio.h>
void Sharpdot(int W){
    int j;
    for(j=1; j<=(W/2); j++)
        printf("#.");
    if(W%2 == 1)
        printf("#");
    printf("\n");
}

void Dotsharp(int W){
    int j;
    for(j=1; j<=(W/2); j++)
        printf(".#");
    if(W%2 == 1)
        printf(".");
    printf("\n");
}

int main(void){
    int H, W, i;
    scanf("%d %d", &H, &W);
    while(H!=0 || W!=0){
    
        for(i=1; i<=(H/2); i++){
            Sharpdot(W);
            Dotsharp(W);
        }
        if(H%2 == 1)
            Sharpdot(W);
        printf("\n");
        scanf("%d %d", &H, &W);
    }
    return 0;
}



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

typedef pair<int, int> pii;
typedef long long ll;
typedef vector<int> vi;

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
#define rep(i,n) rep2(i,0,n)
#define rep2(i,m,n) for(int i=m;i<(n);i++)
#define ALL(c) (c).begin(),(c).end()
#define dump(x) cout << #x << " = " << (x) << endl
constexpr ll TEN(int n) { return (n == 0) ? 1 : 10 * TEN(n-1); }

template<class T, class U>
ostream& operator<<(ostream& os, const pair<T, U>& p) {
	os<<"("<<p.first<<","<<p.second<<")";
	return os;
}

template<class T>
ostream& operator<<(ostream& os, const vector<T>& v) {
	os<<"{";
	rep(i, v.size()) {
		if (i) os<<",";
		os<<v[i];
	}
	os<<"}";
	return os;
}

map<int, int> M;

int main() {
	int N; cin >> N;
	vi a(N);

	bool allzero = true;
	bool zero = false;

	rep(i, N) {
		cin >> a[i];
		++M[a[i]];

		if (a[i] != 0) {
			allzero = false;
		} else {
			zero = true;
		}
	}

	bool ok = false;

	if (allzero) {
		puts("Yes");
		return 0;
	}

	if (N % 3 == 0) {
		int num = N / 3;

		if (zero) {
			int x = -1;
			rep(i, N) {
				if (a[i] != 0) {
					x = a[i];
				}
			}
			if (M[x] == num * 2 && M[0] == num) {
				ok = true;
			}
		} else {
			for (int i = 1; i < N; ++i) {
				if (a[i] != a[0]) {
					int x = a[0], y = a[i], z = x ^ y;
					if (M.count(z)) {
						if (M[x] == num && M[y] == num && M[z] == num) {
							ok = true;
						}
					}
				}
			}
		}
	}

	puts(ok ? "Yes" : "No");

	return 0;
}

Measured memory_bytes: 4224
using System;
using static System.Console;

namespace AtCorder
{
	public class Program
	{
		public static void Main()
		{
			var input = Array.ConvertAll(ReadLine().Split(), int.Parse);
			var d = input[1] - input[0];
			var ans = -input[0];
			for (int i = 1; i < d; i++)
			{
				ans += i;
			}
			WriteLine(ans);
		}
	}
}


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

int main() {
  int N, A;
  cin >> N;
  while(N--){
  	cin >> A;
    if(A % 2 == 0 && (A % 3 == 0 || A % 5 == 0)){
      continue;	
    }else if(A % 2 == 0) {
      cout << "DENIED" << endl;
      return 0;
    }
  }
  cout << "APPROVED" << endl;
  return 0;
}

Measured memory_bytes: 256
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "math.h"
#include "utility"
#include "string"
#include "map"
#include "unordered_map"
#include "iomanip"
#include "random"

using namespace std;
const long long int MOD = 1000000007;

long long int power(long long int x, long long int n, long long int M) {
	long long int tmp = 1;

	if (n > 0) {
		tmp = power(x, n / 2, M);
		if (n % 2 == 0) tmp = (tmp*tmp) % M;
		else tmp = (((tmp*tmp) % M)*x) % M;
	}
	return tmp;
}

long long int N, M, K, Q, W, H;
long long int ans;


int main() {
	ios::sync_with_stdio(false);
	cin >> N;
	cout << N * 800 - N / 15 * 200 << endl;
	return 0;
}

Measured memory_bytes: 256
/*input
1
1

*/
 
/*
                                                    ______________
                                                          |       )
                                                          |   )   /
                                                          |______/
                                                    |     |      \
                                                    |     |   )   \
                                                    |_____|_______)
 
*/
 
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <chrono>
#include <random>
#include <queue>
#include <bitset>
#include <iomanip>
#include <fstream>

using namespace std;
 
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> PII;
typedef pair<ll , ll> PLL;
typedef long double ld;
 
#define pb push_back
#define all(c) c.begin(),c.end()
#define allr(c) c.rbegin(),c.rend()
int mod = 1000000007;
const int inf = 1034567891;
const ll LL_INF = 1234567890123456789ll;
#define PI 3.14159265
#define endl '\n'
#define F first
#define S second
#define debug(x) cout << #x << " = " << x << endl;
#define TRACE
 
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cout << name << " : " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
  const char* comma = strchr(names + 1, ',');cout.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...)
#endif
 
#define out(container) for (auto it : container) cout << it << " "; cout << endl;
 
 
template < typename T > T GCD(T a, T b)            { ll t; while(a) { t = a; a = b % a; b = t; } return b; }
template < typename T > string toString(T a)       { return to_string(a); }
template < typename T > void toInt(string s, T &x) { stringstream str(s); str >> x;}
inline int add(int x, int y){ x += y; if(x >= mod) x -= mod; return x;}
inline int sub(int x, int y){ x -= y; if(x < 0) x += mod; return x;}
inline int mul(int x, int y){ return (x * 1ll * y) % mod;}
inline int powr(int a, ll b){
  int x = 1 % mod;
  while(b){
    if(b & 1) x = mul(x, a);
    a = mul(a, a);
    b >>= 1;
  }
  return x;
}
inline int inv(int a){ return powr(a, mod - 2);}

int main()
{
  ios_base::sync_with_stdio(false); // 🏁 👀 💕
  cin.tie(NULL);
  
  vector <string> vec = {"SUN", "MON", "TUE", "WED", "THU", "FRI", "SAT"};
  string str;
  cin >> str;
  int d = 0;
  for (int i = 0; i < 7; i++) {
    d = i;
    if (str == vec[i]) {
      break;
    }
  }
  int ans = 7 - d;
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<iomanip>
#include<cmath>
#include<vector>
#include<algorithm>

using namespace std;

#define int long long
#define endl "\n"

constexpr long long INF = (long long)1e18;
constexpr long long MOD = 1'000'000'007; 

string yn(bool f){return f?"Yes":"No";}
string YN(bool f){return f?"YES":"NO";}



signed main(){
	// cin.tie(nullptr);
	// ios::sync_with_stdio(false);
	// cout<<fixed<<setprecision(10);
	
	const int MAX = 102;
		
	while(true){
		int T, N, maximum = 0;
		vector<int> sc(MAX, 30);
		vector<int> cycle, dp;
		
		cin>>T;
		
		if(!T) break;
		
		cycle.resize(T);
		dp.resize(MAX, INF);
		
		for(int i = 0; i < T; i++){
			cin>>cycle[i];
		}
		
		cin>>N;
		
		for(int i = 0; i < N; i++){
			int D, M;
			
			cin>>D>>M;
			
			maximum = max(maximum, D+1);
			
			sc[D] = min(sc[D], M);
		}
		
		
		dp[1] = -1;
		
		for(int i = 1; i <= maximum; i++){
			
			for(int j = i+1; j <= maximum; j++){
				if(cycle[(j - i)%T] > sc[j]) {
					
					dp[j] = min(dp[j], dp[i] + 1);
					break;
				}
				
				dp[j] = min(dp[j], dp[i] + 1);
			}
			// cout<<"i = "<<i<<" dp "<<dp[i]<<endl;
		}
		
		cout<<dp[maximum]<<endl;
	}
	
	
	return 0;
}


Measured memory_bytes: 3052
#include <iostream>
#include <string>
#include <algorithm>
#include <map>

using namespace std;

int main()
{
	map<string, int> strnum;
	string str;
	int num;
	int cnt = 0;
	
	cin >> str;
	cin >> num;
	
	for (int i = 0; i < str.size(); i++) {
		for (int j = 0; j <= num; j++) {
			strnum[str.substr(i, j)] = i;
		}
	}
	
	strnum[str] = 810931;
	
	for (auto x: strnum) {
		if (cnt == num) {
			cout << x.first << endl;
		}
		cnt++;
	}
}


Measured memory_bytes: 1920
#include <iostream>
#include <iomanip>
#include <vector>
#include <cmath>
#include <algorithm>
#include <iomanip>
#include <cstring>
#include <map>

#define rep(i, N) for (int i = 0; i < (int)N; i++)
using namespace std;
typedef long long ll;
const ll LLINF = 9223372036854775807;
const int MOD = 1000000007;

vector<ll> len(51, -1); 

ll dl(ll n) {
  if (len[n]!=-1) return len[n];
  if (n==0) return len[n] = 1;
  return len[n] = 2 * dl(n-1) + 3;
}

ll dfs(ll n, ll x) {
  // cout << n << " " << x << " " << len[n-1] << endl;;
  if (n==0) return 1;
  if (x==1) return 0;
  else if (x<=len[n-1]+1) return dfs(n-1, x-1);
  else if (x==len[n-1]+2) return pow(2,n);
  else if (x<=2*len[n-1]+2) return pow(2,n)+dfs(n-1, x-(len[n-1]+2));
  else return pow(2,n+1)-1;
}

int main() {
  ll N, X; cin >> N >> X;
  dl(N);
  cout << dfs(N, X) << endl;
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <iomanip>
#include <vector>
#include <cstdlib>
#include <cmath>
#include <numeric>
#include <algorithm>
#include <sstream>
#include <string>
#include <map>
#include <set>
#include <stack>
#include <deque>
#include <bitset>
using namespace std;

#define rep(i, n) for (int i=0; i<int(n); i++)
#define ARRAY_LENGTH(array) (sizeof(array) / sizeof(array[0]))
using ll = long long;


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

	if (n==0) cout << 0 << endl;

	string res = "";
	while(n) {
		if (n%2!=0) {
			res += "1";
			n--;
		}
		else {
			res += "0";
		}
		n /= -2;
	}
	reverse(res.begin(), res.end());
	cout << res << endl;
}

Measured memory_bytes: 3632
import java.util.Scanner;

public class Main {
    public static void main(String... args) {
        Scanner sc = new Scanner(System.in);

        while(true) {
        	String str = sc.next();
        	int sum = 0;

        	if(str.equals("0")) {
        		break;
        	}

        	for(int i = 0; i < str.length(); i++) {
        		sum += Integer.parseInt(str.substring(i, i+1));
        	}

        	System.out.println(sum);
        }
    }
}


Measured memory_bytes: 26680
#include <cstdio>
#include <iostream>
#include <vector>
#include <string>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <list>
#include<unordered_set>

#include <queue>
using namespace std;

struct Edge{
  int cost;
  int to;
  Edge(int c,int t){
    cost=c;
    to=t;
  }
};
struct Node{
  int number;
  int cost=INT32_MAX;
  std::vector<Edge> edge;
  bool operator<(const Node& a)const{
    return cost<a.cost;
  }
  bool operator>(const Node& a)const{
    return cost>a.cost;
  }
};
int main(void){

  int n;
  cin>>n;
  int result[100000];
  vector<int> grid(n);
  for(int i=0;i<n;i++){
    cin>>grid[i];
    result[i]=INT32_MAX;
  }

  Node node[100000];
  for(int i=0;i<n;i++){
    node[i].number=i;
    for(int dice=1;dice<=6;dice++){
      if(grid[i]!=0){
        node[i].edge.push_back(Edge(0,i+grid[i]));
      }
      else if(i+dice<n){
        node[i].edge.push_back(Edge(1,i+dice));
      }
    }

  }
  node[0].cost=0;

  std::priority_queue<Node,std::vector<Node>,std::greater<Node>> pq;
  pq.push(node[0]);
  while(!pq.empty()){
    // cerr<<"next"<<endl;
    Node new_node=pq.top();

    pq.pop();
    if(new_node.cost>=result[new_node.number]){
      continue;
    }else{
      // cerr<<new_node.number<<" "<<new_node.cost<<endl;
      result[new_node.number]=new_node.cost;
      for(auto x:new_node.edge){
        // cerr<<"to: "<<x.to<<" cost: "<<x.cost<<endl;
        Node push_node;
        push_node.number=x.to;
        push_node.edge=node[x.to].edge;
        push_node.cost=new_node.cost+x.cost;
        pq.push(push_node);
      }
    }


  }
  cout<<result[n-1]<<endl;


  return 0;
}



Measured memory_bytes: 14808
#include <math.h>
#include <stdio.h>
int n, sqrtN;
long long ans, d;
char buf[8],out[20];
char k;
s;
size_t i;
int main() {
    s = read(0, buf, 8);
    for(;;) {
        k = buf[i++];
        if(k < '0') break;
        n = n * 10 + k - '0';
    }
    if(n == 1) {
        putchar(49);
    } else {
        const int sqrtN = sqrt(n);
        ans = -(long long)(sqrtN) * (sqrtN + 1) * (2 * sqrtN + 1) / 6;
        for(int i = 1; i <= sqrtN; ++i) {
            const int a = n / i;
            ans += ((long long)i * (i + a) * (a + 1 - i));
        }
        i = 20;
        do{
            out[--i]=ans%10+'0';
            ans/=10;
        }while(ans);
        write(1,out+i,20-i);
    }
}


Measured memory_bytes: 1868
#include<iostream>
#include<algorithm>
#include<math.h>
#include<queue>
#include<vector>
#include<climits>
#include<map>
#include<string>
#include<functional>
#include<iomanip>
#include<deque>
#include<random>
#include<set>
#include<bitset>
#include<cassert>

using namespace std;
typedef long long ll;
typedef double lldo;
#define mp make_pair
#define pub push_back
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define sz(x) int(x.size())
ll gcd(ll a, ll b) { if (a % b == 0) { return b; } else  return gcd(b, a % b); }
ll lcm(ll a, ll b) { if (a == 0) { return b; }return a / gcd(a, b) * b; }
template<class T>ll LBI(vector<T>& ar, T in) { return lower_bound(ar.begin(), ar.end(), in) - ar.begin(); }
template<class T>ll UBI(vector<T>& ar, T in) { return upper_bound(ar.begin(), ar.end(), in) - ar.begin(); }

ll n, p, ans = 0, ten = 1;
string s;

int main() {
	cin >> n >> p;
	vector<ll> d(n + 1), cnt(p);
	cin >> s;
	if (10 % p == 0) {
		rep(i, n) {
			if ((s[i] - '0') % p == 0)ans += i + 1;
		}
	}
	else {
		cnt[0] = 1;
		for (int i = n - 1; i >= 0; i--) {
			d[i] = (d[i + 1] + ten * (s[i] - '0')) % p;
			ten *= 10;
			ten %= p;
			ans += cnt[d[i]];
			cnt[d[i]]++;
		}

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

Measured memory_bytes: 2304
/// Bismillahir Rahmanir Rahim
/* Mohammad Morsalin
   Dept of ICE, NSTU
*/
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define ll long long
#define pb push_back
#define mp make_pair
#define endl "\n"
#define int long long
#define f0(n) for(int i=0;i<n;i++)
#define ms(x) memset(x,0,sizeof(x))
#define ms2d(x,m,n) memset(x, 0, sizeof(x[0][0]) * m * n)
#define uniq(vec) vec.resize(distance(vec.begin(),unique(vec.begin(),vec.end())))
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
#define pi pair<int,int>
#define tc(t) int t;cin>>t;while(t--)
#define bits(n) __builtin_popcount(n)
#define maxpq priority_queue<int>
#define minpq priority_queue<int, vector<int>, greater<int> >
#define ins insert
#define ALL(v) v.begin(),v.end()
#define highest(x) numeric_limits<x>::max()
#define lowest(x) numeric_limits<x>::min()
#define Inf INFINITY
#define minv(v) *min_element(v.begin(),v.end())
#define maxv(v) *max_element(v.begin(),v.end())
#define fi first
#define se second
#define PI acos(-1)
#define sz(a) (int)a.size();
#define IOS ios::sync_with_stdio(false);
using namespace std;
int gcd(int a, int b) { if (a == 0) return b; return gcd(b % a, a);}
typedef tree<pair<int, int>,null_type,less<pair<int, int>>,rb_tree_tag,tree_order_statistics_node_update> ordered_multiset;
int dx8[] = {0, 0, 1, 1, 1, -1, -1, -1};
int dy8[] = {1,-1, 1, -1, 0, 0, -1, 1};
int dx4[] = {0, 0, 1, -1};
int dy4[] = {1, -1, 0, 0};
const long long MOD = 1000000007;
double sq(double x) {return x*x;}
template<typename T>inline T Bigmod(T base, T power, T MOD){
    T ret=1;
    while(power)
    {
        if(power & 1)ret=(ret*base)%MOD;
        base=(base*base)%MOD;
        power>>=1;
    }
    return ret;
}

bool sortinrev(const pair<int,int> &a,
               const pair<int,int> &b)
{
       return (a.first > b.first);
}
signed main()
{
    IOS
    int n;
    cin>>n;
    if(n==1)cout << "0\n";
    else cout << "1\n";
    return 0;
}
///Alhamdulillah


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

typedef long long ll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef pair<int,int> pii;
typedef pair<char,int> pci;
typedef unordered_map<int,int> mii;
typedef unordered_map<int,int>::iterator iter;
typedef stack<int> si;
typedef stack<char> sc;





bool comp(int a,int b){
    cout<<a<<" "<<b<<endl;
    return a<b;
}

int main(){
    
    ll n,d,x,y,ct=0;
    cin>>n>>d;

    for(ll i=0;i<n;i++){
        cin>>x>>y;

        if((x*x+y*y)<=d*d)
            ct++;
    }   
    cout<<ct<<endl;
    
    return 0;

}

Measured memory_bytes: 3628
n, a, b = map(int, input().split())
s = input()
cnt = 0
cnt_f = 0
for i in s:
    if i == "a" and cnt < a + b:
        cnt += 1
        print("Yes")
    elif i == "b":
        if cnt < a + b and cnt_f < b:
            cnt += 1
            cnt_f += 1
            print("Yes")
        else:
            print("No")
    else:
        print("No")

Measured memory_bytes: 4016
#include<algorithm>
#include<string>
#include<vector>
#include<cmath>
#include<iostream>
# define ll int64_t
# define rep(i,n) for(ll i=0;i<n;i++)
# define rrep(i,n) for(ll i=1;i<=n;i++)
# define ALL(x) (x).begin(), (x).end()
# define SZ(x) ((int)(x).size())
# define pb push_back
# define mod 1000000007
# define vec vector
#define dump(x) cerr<<#x<<"="<<x<<endl
using namespace std;

bool compare_by_b(pair<string,ll> a,pair<string,ll> b){
    if(a.second != b.second) return a.second<b.second;
    else return a.first<b.first;
}

bool my_compare(pair<string,ll> a,pair<string,ll> b){
    
    if(a.first != b.first) return a.first<b.first;
    if(a.second != b.second) return a.second>b.second;
    else return true;
}

ll factorial(ll n){
    ll x=1;
    rrep(i,n) (x*=i)%=mod;
    return x;
}

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

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

//累乗だってさ
ll modpow(ll a,ll n,ll mod1) {
    ll res=1;
    while(n>0){
        if(n&1) res=res*a%mod1;
        a = a*a%mod1;
        n >>= 1;
    }
    return res;
}
//逆元だってさ
ll modinv(ll a,ll mod1) {
    return modpow(a, mod1 - 2, mod1);
}

const ll MAX = 1000000;
const ll MOD = 1000000007;

ll fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (ll i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
ll COM(ll n, ll k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}



int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    ll n,k;
    cin>>n>>k;
    vector<ll> a(n),dp(100000,mod);
    rep(i,n) cin>>a[i];
    dp[0]=0;
    for(ll i=0;i<n;i++) {
        rrep(j,k){
            dp[i+j]=min(dp[i]+abs(a[i+j]-a[i]),dp[i+j]);
        }
    }
    cout<<dp[n-1]<<endl;
    return 0;
}


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

using namespace std;

int main(void) {
    string s, t;

    cin >> s >> t;

    int n = (int)s.size();
    int m = (int)t.size();

    vector<vector<int>> dp(n + 1, vector<int>(m + 1));
    string ans;
    for (int i = 1; i <= n; i++) {
        for (int j = 1; j <= m; j++) {
            if (s[i - 1] == t[j - 1]) {
                dp[i][j] = 1 + dp[i - 1][j - 1];
            } else {
                dp[i][j] = max(dp[i - 1][j], dp[i][j - 1]);
            }
        }
    }

    int p1 = n, p2 = m;
    while (dp[p1][p2]) {
        if (s[p1 - 1] == t[p2 - 1]) {
            ans.push_back(s[p1 - 1]);
            p1--, p2--;
        } else if (dp[p1 - 1][p2] > dp[p1][p2 - 1]) {
            p1--;
        } else {
            p2--;
        }
    }

    reverse(ans.begin(), ans.end());
    cout << ans << endl;

    return 0;
}

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

const long long INF = 1000000000000000;

int main() {
	int a, b, q; cin >> a >> b >> q;
	vector<long long> s(a + 2), t(b + 2);
	s.at(0) = t.at(0) = -INF;
	for (int i = 1; i <= a; i++) {
		cin >> s.at(i);
	}
	for (int i = 1; i <= b; i++) {
		cin >> t.at(i);
	}
	s.at(a + 1) = INF; t.at(b + 1) = INF;
	vector<long long> ans(q, INF);
	for (int i = 0; i < q; i++) {
		long long x; cin >> x;
		int sh = lower_bound(s.begin(), s.end(), x) - s.begin();
		int tem = lower_bound(t.begin(), t.end(), x) - t.begin();
		for (int j = 0; j < 2; j++) {
			for (int k = 0; k < 2; k++) {
				ans[i] = min(ans[i], abs(s.at(sh - j) - x) + abs(t.at(tem - k) - s.at(sh - j)));
				ans[i] = min(ans[i], abs(t.at(tem - k) - x) + abs(s.at(sh - j) - t.at(tem - k)));
			}
		}
	}
	for (int i = 0; i < q; i++) {
		cout << ans.at(i) << endl;
	}
}

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

typedef long long ll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<long long> vll;
typedef vector<vector<long long>> vvll;
typedef pair<int,int> pii;
typedef pair<long long, int> pli;

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

ll mod = 998244353;

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

  string s,t;
  cin >> s >> t;
  string ret = "Yes";
  if(s.size() != t.size()-1)ret = "No";

  rep(i,s.length()){
    if(s[i] != t[i])ret = "No";
  }

  cout << ret << endl;
}

Measured memory_bytes: 3652
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define mfill(x,y) memset(x,y,sizeof(x))
#define all(v) v.begin(), v.end()
#define in(x,y,h,w) if(0<=x&&x<h&&0<=y&&y<w)
#define y0 y12345
#define y1 y54321

#ifdef LOCAL
#define debug(...) fprintf(stderr,__VA_ARGS__)
#else
#define debug(...) 42
#endif

using ul = unsigned long;
using ll = long long;
using P = pair<int, int>;
using vint = vector<int>;using vvint = vector<vector<int>>;
using vll = vector<ll>;using vvll = vector<vector<ll>>;
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;}
template <class T>void initvv(vector<vector<T> > &v, int a, int b, const T &t = T()){
	v.assign(a, vector<T>(b, t));
}
template <class T>T gcd(T &a, T &b){if(a<b){swap(a,b);} T r = a%b; while(r!=0){a=b;b=r;r=a%b;} return b;}

vint dx = {-1, 0, 1, 0}, dy = {0, -1, 0, 1};
vint dx8 = {-1, -1, -1, 0, 1, 1, 1, 0}, dy8 = {-1, 0, 1, 1, 1, 0, -1, -1};

int main() {
	cin.tie(0);
   	ios::sync_with_stdio(false);
	debug("debug test\n");
   	int n,m;cin>>n;
	vint x(n), y(n), h(n);
	int p = -1;
	rep(i, n){cin>>x[i]>>y[i]>>h[i];if(h[i]!=0)p = i;}
	
	rep(i, 101){
		rep(j, 101){
			int eh;
			bool flag = true;
			eh = abs(x[p]-i) + abs(y[p]-j) + h[p];
			rep(k, n){
				if(h[k] != max(0, eh - abs(x[k]-i) - abs(y[k]-j))){
					flag = false;
				}
			}
			if(flag){
				cout << i << ' ' << j << ' ' << eh<< endl;
				return 0;
			}
		}
	}
	return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

class Main {

	public static void main(String[] args) {
		Scanner s = new Scanner(System.in);
		int num = Integer.parseInt(s.next());
		if(num == 1 || num == 0){
			System.out.println(1);
		}else{
			int fib = 1;
			int sub = 0;
			int sub2;
			for(int i = 0; i < num; i++){
				sub2 = fib;
				fib += sub;
				sub = sub2;
			}
			
			System.out.println(fib);
			
		}
	}

}

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

int main() {
  double A, B, H, M;
  cin >> A >> B >> H >> M;
  double pi = acos(-1);
  double a = (60.0 * H + M) / 720.0;
  double b = M/60.0;
  double x_B = B * sin(2.0*pi*b);
  double y_B = B * cos(2.0*pi*b);
  double x_A = A * sin(2.0*pi*a);
  double y_A = A * cos(2.0*pi*a);
  double length = sqrt((x_A - x_B)*(x_A - x_B) + (y_A - y_B)*(y_A - y_B));
  cout << fixed << setprecision(20);
  cout << length << endl;
}


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

def cmb(n, r, mod):
	if (r < 0) or (n < r):
		return 0
	r = min(r, n-r)
	return fact[n]*factinv[r]*factinv[n-r]%mod

N = 10**6  # N は必要分だけ用意する
fact = [1, 1]  # fact[n] = (n! mod p)
factinv = [1, 1]  # factinv[n] = ((n!)^(-1) mod p)
inv = [0, 1]  # factinv 計算用

for i in range(2, N+1):
	fact.append((fact[-1]*i)%mod)
	inv.append((-inv[mod%i]*(mod//i))%mod)
	factinv.append((factinv[-1]*inv[-1])%mod)

"""
1つ当たっている→Freeはn-1個→m-1 C n-1
同様に2つ→m-2 C n-2
数は？→ n C 2
包除原理
"""
mode = -1
ans = 0
for i in range(n+1):
	mode = -mode
	ans = (ans + mode * cmb(n, i, mod) * cmb(m-i, n-i, mod) * fact[n-i]) % mod
print(ans * cmb(m, n, mod) * fact[n] % mod)

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

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n, T, c, t;
	cin>>n>>T;
	int ans=1333;
	REP(i, n){
		cin>>c>>t;
		if(t<=T){
			ans=min(ans, c);
		}
	}
	if(ans!=1333){
		cout<<ans<<'\n';
	}
	else{
		cout<<"TLE"<<'\n';
	}
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define mp make_pair
#define pb push_back
#define pii pair<int,int>
const int maxn = 5000 + 5;
const int mod = 1e9 + 7;
string a;
int dp[maxn][maxn];
ll ksm (ll a , ll b)
{
    ll ans = 1 , base = a;
    while (b){
        if (b & 1) ans = ans * base % mod;
        b >>= 1;
        base = base * base % mod;
    }
    return ans;
}
int main()
{
    ios::sync_with_stdio(false);
    int n; cin >> n;
    cin >> a; int m = a.size();
    dp[0][0] = 1;
    for (int i = 0 ; i <= n ; i++){
        for (int j = 0 ; j <= n ; j++){
            dp[i + 1][j + 1] = (dp[i + 1][j + 1] + 2 * dp[i][j]%mod)%mod;
            dp[i + 1][max(0,j - 1)] = (dp[i + 1][max(0,j - 1)] + dp[i][j]) % mod;
        }
    }
  //  cout << dp[n][m] << endl;
    ll res = ksm(ksm(2 , m) , mod - 2);
    ll ans = dp[n][m] * res % mod;
    cout << ans << endl;
    return 0;
}

/*
2 3
1 2
1 2
*/


Measured memory_bytes: 101384
// Created by Nandu Vinodan
#include "bits/stdc++.h"

#define db1(x) cout<<#x<<"="<<x<<'\n'
#define db2(x,y) cout<<#x<<"="<<x<<","<<#y<<"="<<y<<'\n'
#define db3(x,y,z) cout<<#x<<"="<<x<<","<<#y<<"="<<y<<","<<#z<<"="<<z<<'\n'
#define rep(i,a,n) for(int i=a;i<=(n);++i)
#define repD(i,a,n) for(int i=a;i>=(n);--i)
#define pb(a) push_back(a)
#define eb(a) emplace_back(a)
#define vi vector<int>
#define pi pair<int, int>
#define INF INT_MAX
#define _INF INT_MIN
#define TC 0

using namespace std;
using ll = long long;

int nc2(int n) {

	return (n*(n-1))/2;
}
void testcase() {
    int n, m;
    cin >> n >> m;

    cout << nc2(n) + nc2(m) << "\n";
}

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int t=1;
    if (TC)
        cin>>t;
    while(t--) {
        testcase();
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;
int main() {
  int n;cin >> n;vector<ll> A(n), B(n);ll suma = 0, sumb = 0;
  rep(i,n) cin >> A[i];
  rep(i,n)  cin >> B[i];
  rep(i,n){
    if(A[i] > B[i]) suma += A[i] - B[i];
    if(B[i] > A[i]) sumb += (B[i] - A[i])/2;
  }
  if(sumb >= suma) cout << "Yes" << endl;
  else cout << "No" <<endl;
}

Measured memory_bytes: 384
#include <stdio.h>
int main(void)
{
	double r, s, l;
	scanf("%lf", &r);
	s = (double)r*(double)r * 3.14159265358979;
	l = 2 * (double)r * 3.14159265358979;
	printf("%.6f %.6f\n", s, l);
	return 0;
}

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

using namespace std;

int main()
{
    string s, t; cin >> s >> t;

    sort(s.begin(), s.end());
    sort(t.begin(), t.end(), greater<char>());

    cout << ((s < t) ? "Yes" : "No") << endl;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(void){
	long long n,m,a,b,c[131072]={0},i;
	scanf("%lld%lld",&n,&m);
	for(i = 1;i <= m;i++){
		scanf("%lld%lld",&a,&b);
		c[a]++;c[b]++;
	}
	for(i = 1;i <= n;i++){
		if(c[i]%2){printf("NO\n");return 0;}
	}
	printf("YES\n");
	return 0;
}

Measured memory_bytes: 1152
import fractions
from functools import reduce

n = int(input())
t = []
for _ in range(n):
    t.append(int(input()))

def lcm_b(x,y):
    return (x*y) // fractions.gcd(x,y)

def lcm(num):
    return reduce(lcm_b, num, 1)

print(lcm(t))



Measured memory_bytes: 5076
#include <bits/stdc++.h>
#include <math.h>
#include <float.h>
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rrep(i, n) for(int i = 0; i <= (n); i++)
using namespace std;
typedef long long ll;
 
const ll INF = 1LL<<62;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
// 多次元 vector 生成
template<class T>
vector<T> make_vec(size_t a){
    return vector<T>(a);
}
template<class T, class... Ts>
auto make_vec(size_t a, Ts... ts){
  return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}

const int MOD = 1000000007;

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

    ll ans = 0;
    rep(i,N-1){
        ll total = a[i]+a[i+1];
        if (total > x){
            ans += total-x;
            a[i+1] -= total-x;
            a[i+1] = max(0LL,a[i+1]);
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 4032
($n,$s)=<>;
exit!print$n+1if$n==$s;
for(2..sqrt($n)+1){
	$%=$n;
	$t=0;
	0while$t+=$%%$_,$%/=$_;
	exit!print if$t==$s
}
for$p(1..sqrt($n)-1){
	$q=$s-$p;
	$_=($n-$q)/$p|0;
	$_<($b//1e12)&&($b=$_)if 0<$p&&$p<$_ && 0<=$q&&$q<$_ && $p*$_+$q==$n
}
print$b//-1


Measured memory_bytes: 384
#include <queue>
#define OK puts("Possible")
#define NO puts("Impossible")
#include <vector>
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#define ll long long
using namespace std;

template <typename T>
void read(T &x) {
    x = 0; bool f = 0;
    char c = getchar();
    for (;!isdigit(c);c=getchar()) if (c=='-') f=1;
    for (;isdigit(c);c=getchar()) x=x*10+(c^48);
    if (f) x=-x;
}

const int N = 200500;
int f[N<<1][24], n, v;
int x[N], R[N][24], D[100], LG;
vector<int> to;

inline int T(int x) { return 1 << x; }
inline void Mx(int &x, int y) { y > x && (x = y); }

int main() {
	read(n), read(v);
	for (int i = 1;i <= n; i++) read(x[i]);
	while (v) D[LG++] = v, v >>= 1; LG++;
	for (int i = 0;i < LG; i++) {
		R[n+1][i] = R[n][i] = n;
		if (i == 0) to.push_back(n);
		for (int j = n - 1;j >= 1; j--)
			if (x[j+1] - x[j] <= D[i]) R[j][i] = R[j+1][i];
			else {
				R[j][i] = j; if (i == 0) to.push_back(j);
			}
	}
	if (to.size() > LG) { for (int i = 1;i <= n; i++) NO; return 0; }
	if (to.size() == 1) { for (int i = 1;i <= n; i++) OK; return 0; }
	LG--; int all = (1 << LG) - 1;
	for (int i = 0;i <= all; i++) {
		for (int j = 0;j < to.size(); j++) {
			if (R[f[i][j]+1][0] == to[j]) f[i][j] = to[j];
			for (int k = 1;k <= LG; k++) {
				if (i & T(k-1)) continue;
				Mx(f[i | T(k-1)][j], R[f[i][j]+1][k]);
			}
		}
	}
	
	int block = to.size() - 1;
	for (int i = 1;i <= n; i++) {
		f[all][block] == n ? OK : NO;
		if (to[block] == i) block--;
	}
	return 0;
}

Measured memory_bytes: 47488
#include <iostream>
using namespace std;
#define rep(i,q) for(int i = 0; (q) > i; i++)
int main(){
  int a,b,k;cin>>a>>b>>k;
  //b-k+1
  rep(i,min(b-a+1,k)){
    cout << a << endl;
    a++;
  }
  int mx = max(a,b-k+1);
  for(int i = mx;b >= i; i++){
    cout << mx << endl;
    mx++;
  }
}

Measured memory_bytes: 256
N = int(input())
S =[]
times = {}
for i in range(N):
  word = input()
  if word in times:
    times[word] = times[word] + 1
  else:
    times[word] = 1
max_value = max(times.values())
words = []
for i in times.items():
  if i[1] == max_value:
    words.append(i[0])
words = sorted(words)
for i in words:
  print(i)

Measured memory_bytes: 32988
#include <iostream>
#include <algorithm>
#include<string>
#include<cmath>
#include<stack>
#include <vector>
#include<queue>
#include <random>
#include <cstdint>
#include <bitset>
#include <iomanip>
using namespace std;

int main() {
	long long n, a,ans=0;
	cin >> n;
	long long count = 0;
	for (int i = 0; i < n; i++) {
		cin >> a;
		if (a == 0) {
			ans += count / 2;
			count = 0;
		}
			count += a;
	}
	ans += count / 2;
	cout << ans << endl;
	return 0;
}


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


int main() {
  int a,b; cin >> a >> b;
  if (a <= b) cout << a;
  else cout << a-1;

  cout << endl;
  
  return 0;

}
  


Measured memory_bytes: 256
#![allow(non_snake_case)]
#![allow(unused_variables)]
#![allow(dead_code)]

fn main() {
    let X: i64 = {
        let mut line: String = String::new();
        std::io::stdin().read_line(&mut line).unwrap();
        line.trim().parse().unwrap()
    };

    let a = X / 105;
    let b = X / 100;
    let ans = if (a..(b + 1)).any(|i| {
        let r = X - 100 * i;
        0 <= r && r <= 5 * i
    }) {
        1
    } else {
        0
    };

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


Measured memory_bytes: 4352
N, M, X, Y = map(int, input().split())
Xi = list(map(int, input().split()))
Yi = list(map(int, input().split()))

max_X = max(Xi)
min_Y = min(Yi)

# min_X < Z <= max_Y
# X < Z <= Y

if max_X < min_Y and X < min_Y and max_X < Y:
    print('No War')
else:
    print('War')


Measured memory_bytes: 2940
import numpy as np

N,K=map(int,input().split())
R,S,P=map(int,input().split())
T1=input()
T2=T1.replace('r', str(P)+' ').replace('s',str(R)+' ').replace('p',str(S)+' ')[:-1]
T2=np.array(list(map(int, T2.split())))

for i in range(N):
  if i >=K and T1[i]==T1[i-K] and T2[i-K] != 0:
    T2[i]=0

print(T2.sum())

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

int main()
{

	long long int N;
	long long int A[200005];
	long long int count[200005];
	long long int ways=0;

	long long int out;
	scanf("%lld",&N);
	for(int i=0;i<200005;i++)	count[i]=0;
	for(int i=0;i<N;i++)
	{
		scanf("%lld",&A[i]);
		count[A[i]]++;
	}
	for(int i=0;i<200005;i++)
	{
		ways+=count[i]*(count[i]-1)/2;
	}
	for(int i=0;i<N;i++)
	{
		out=ways-count[A[i]]+1;
		printf("%lld\n",out);
	}
	return 0;
}


Measured memory_bytes: 5632