akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstdio>
#include <math.h>
using namespace std;
int main(){
	int n = 45000;
	int p[n];
	for(int i=0;i<n;i++) p[i] = 0;
	for(int i=2;i<n;i++){
		if(p[i]==0) for(int j=2;j<n/i;j++) p[i*j] = 1;
	}
	int q[n];
	int c = -1;
	for(int i=2;i<n;i++){
		if(p[i]==0){
			c++;
			q[c] = i;
		}
	}
	long a,b;
	while(cin >> a >> b){
		int t[c],s[c];
		for(int i=0;i<c;i++) t[i] = 0;
		for(int i=0;i<c;i++) s[i] = 0;
		int as = a;
		while(1){
			int temp = as;
			for(int i=0;i<c;i++){
				if(as%q[i]==0){
					s[i]++;
					as = as/q[i];
				}
			}
			if(temp==as) break;
		}
		int at = b;
		while(1){
			int temp = at;
			for(int i=0;i<c;i++){
				if(at%q[i]==0){
					t[i]++;
					at = at/q[i];
				}
			}
			if(temp==at) break;
		}
		long z = 1;
		if(at==as) z = at;
		long y = z;
		for(int i=0;i<c;i++){
			y *= pow(q[i],max(s[i],t[i]));
			z *= pow(q[i],min(s[i],t[i]));
		}
		cout << z << " " << y << endl;
	}
}

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

int main(){
   string S;
   cin >> S;
   sort(S.begin(), S.end());
   //cout << S << endl;
   if (S.at(0) == S.at(1) && S.at(2) == S.at(3) && S.at(1) != S.at(2))
      cout << "Yes" << endl;
   else
      cout << "No" << endl;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
                    
                    
int main(){
    int N;
    cin >> N;
    string S;
    set<string> ans;

    for(int i = 0; i < N; i++){
        cin >> S;
        ans.insert(S);
    }

    cout << ans.size() << endl;

    return 0;

}

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

using namespace std;

int main()
{
    //freopen("cbarn.out", "w", stdout) ;
    //freopen("cbarn.in", "r", stdin) ;
    ios_base::sync_with_stdio(0);
    cin.tie(NULL);
    cout.tie(0);
    int a;
    cin>>a;
    for(int i=1;i<10;i++)
    {
        if(a%i==0&&a/i<=9)
        {
            cout<<"Yes";
            return 0;
        }
    }
    cout<<"No";
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
 
int main(){
    int H, W, i, j;
     
    while(1) {
        cin >> H >> W;
        if(H == 0 && W == 0) {
            break;
        }
        for(i = 0; i < H; i++) {
            for(j = 0; j < W; j++) {
                if(j == 0 || j == W - 1 || i == 0 || i == H - 1) {
                cout << '#';
            }else{
                cout << '.';
            }
        }
        cout << endl;
        }
    cout << endl;
    }
    return 0;
}

Measured memory_bytes: 3084
#include  <bits/stdc++.h>
using namespace std;
const int maxn=190;

int n,m;
char s[maxn][maxn];
int dp[maxn][maxn][maxn];

int main(){
	scanf("%d%d",&n,&m);
	for (int i=1;i<=n;++i)
		scanf("%s",s[i]+1);
	for (int i=1;i<=n;++i)
		for (int j=m;j>=1;--j){
			dp[i][j][j]=s[i][j]==s[i-1][j]?dp[i-1][j][j]+1:1;
			for (int k=j+1;k<=m;++k)
			dp[i][j][k]=s[i][k]==s[i][k-1]?min(dp[i][j][k-1],dp[i][j+1][k]):0;
		}
	if (dp[n][1][m]==n) return puts("0"),0;
	for (int depth=1;;++depth){
		for (int i=n;i>=1;--i){
			for (int j=1;j<=m;++j){
				vector<int>tmp(m+1);
				for (int k=j+1,p=j;k<=m;++k){
					while(p+2<k&&dp[i][j][p]>dp[i][p+1][k]&&dp[i][j][p+1]>dp[i][p+2][k])++p;
					tmp[k]=max(tmp[k],min(dp[i][j][p],dp[i][p+1][k]));
					if (p+2<=k) tmp[k]=max(tmp[k],min(dp[i][j][p+1],dp[i][p+2][k]));
				}
				for (int k=j;k<=m;++k)
					dp[i][j][k]=max(dp[i-dp[i][j][k]][j][k]+dp[i][j][k],tmp[k]);
			}
		}
		if (dp[n][1][m]==n){printf("%d\n",depth);break;}
	}
}

Measured memory_bytes: 26752
#include<bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rep2(i, m, n) for(int i = (int)(m); i < (int)(n); i++)
#define rep_inv(i, n, m) for(int i = (int)(n); i > (int)(m); i--)
using namespace std;
using ll = long long;
using vl = vector<ll>;
using vc = vector<char>;
using vvl = vector<vl>;
using vvc = vector<vc>;
using pll = pair<ll, ll>;
using vpll = vector<pll>;

int main(){
  ll A, B;
  cin >> A >> B;

  if(A == 1) A = 14;
  if(B == 1) B = 14;

  if(A == B) cout << "Draw" << endl;
  else if(A > B) cout << "Alice" << endl;
  else cout << "Bob" << endl;
  
  return 0;
}

Measured memory_bytes: 256
import scala.io.StdIn._

object Main extends App {
  val n: Int = readInt()
  val Array(t, a) = readLine().split(' ').map(_.toInt)
  val hs = readLine().split(' ').map(_.toInt).toList
  
  val result = hs.zipWithIndex.map { case (h, i) =>
    val temperature = t - h * 0.006
    ((temperature - a).abs, i + 1)
  }.min
  println(result._2)
}

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

using ll = long long;

int main(){
	int n;
	cin >> n;
	
	vector<int>v(n);
	for(int i=0;i<n;i++){
		cin >> v[i];
	}
	bool flag = 1;
	for(int i=0;i<n;i++){
		if(v[i]%2 == 0){
			if(v[i]%3 == 0 || (v[i]%5==0)){

			}
			else{
				flag = 0;
				break;
			}
		}
	}
	if(flag){
		cout << "APPROVED\n";
	}
	else{
		cout << "DENIED\n";
	}

	return 0;
}

Measured memory_bytes: 256
# N>=x>=0
# return max(floor(A*x/B)-A*floor(x/B))
# floor(t) は実数t以下の最大の整数
# x = Nの時が最大
# x/Bが一の直前になるようにとってみる
A, B, N = [int(i) for i in input().split()]
x = 0
if N >= B:
    x = B-1
else:
    x = N 
y = (A * x)// B - A * (x//B)
print(y)

Measured memory_bytes: 61684
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
vector<pair<int,int> > p;
bool cmp(pair<int,int> p1,pair<int,int> p2){
    return min(p1.second,p1.first+p2.second)>min(p2.second,p2.first+p1.second);
}//{cnt,mn} 
int main(){
    int n,sum=0;
    scanf("%d",&n);
    for(int i=0;i<n;i++){
        string s;
        int cnt=0,mn=0;
        cin>>s;
        for(int j=0;j<s.length();j++){
            char c=s[j];
            if(c=='(') cnt++;
            else cnt--;
            mn=min(mn,cnt);
        }
        p.push_back({cnt,mn});
        sum+=cnt;
    }
    if(sum!=0) {
        printf("No");
        return 0;
    }
    sort(p.begin(),p.end(),cmp);
    int res=0;
    for(int i=0;i<p.size();i++){
        if(res+p[i].second<0 ){
            printf("No");
            return 0;
        }
        res+=p[i].first;
    }
    printf("Yes");
}


Measured memory_bytes: 11676
import java.util.*
fun main(args: Array<String>){
	val cin = Scanner(System.`in`)
    val l = cin.nextInt()
    val r = cin.nextInt()

    val l_a = l / 2019
    val l_b = l % 2019
    val r_a = r / 2019
    val r_b = r % 2019

    if (l_a != r_a) {
        println(0)
    } else {
        var ans = 2018
        for (i in l_b..r_b-1) {
            for (j in i+1..r_b) {
                if (ans > (i*j)%2019) {
                    ans = (i*j)%2019
                }
            }
        }
        println(ans)
    }
}

Measured memory_bytes: 29600
import java.util.*;
import java.io.*;

public class Main{
	public static void main(String[] args){
		Scanner stdIn = null;
		
		try{
			stdIn = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
		
			while( stdIn.hasNext() ){
				int n = stdIn.nextInt(), m = stdIn.nextInt();
				Map<String, Integer> road = new HashMap<String, Integer>();
				while( n != 0 || m != 0 ){
					road.put(Integer.toString(n), (road.get(Integer.toString(n)) == null) ? 1 : road.get(Integer.toString(n))+1);
					road.put(Integer.toString(m), (road.get(Integer.toString(m)) == null) ? 1 : road.get(Integer.toString(m))+1);
					n = stdIn.nextInt();
					m = stdIn.nextInt();
				}
				if( road.get("1")%2 == 1 ){
					road.put("1", 0);
				} else {
					road.put("1", 1);
				}
				if( road.get("2")%2 == 1 ){
					road.put("2", 0);
				} else {
					road.put("2", 1);
				}
				boolean flag = true;
				for(String s : road.keySet()){
					if( road.get(s)%2 != 0 ){
						flag = false;
					}
				}
				if( flag ){
					System.out.println("OK");
				} else {
					System.out.println("NG");
				}
			}
		} finally {
			if( stdIn != null ){
				stdIn.close();
			}
		}
	}
}

Measured memory_bytes: 12000
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int x = sc.nextInt();
		int y = sc.nextInt();
		if(x > 0 && y > 0 && x > y) {
			System.out.println(Math.abs(x - y) + 2);
		} else if(x > 0 && y >= 0 && x > y) {
			System.out.println(Math.abs(x - y) + 1);
		} else if(x >= 0 && y >= 0 && x < y) {
			System.out.println(Math.abs(x - y));
		} else if(x >= 0 && y < 0 || x < 0 && y > 0) {
			System.out.println(Math.abs(x + y) + 1);
		} else if(x < 0 && y == 0) {
			System.out.println(y - x);
		} else if(x < 0 && y < 0 && x < y) {
			System.out.println(y - x);
		} else {
			System.out.println(Math.abs(-x + y) + 2);
		}
	}
}


Measured memory_bytes: 23764
n, m = list(map(int, input().split()))
ps = []
for i in range(m):
    tmp = input().split()
    ps.append([int(tmp[0]), tmp[1]])

ac = [False] * (n + 1)
wa = [0] * (n + 1)
for i in range(m):
    if not ac[ps[i][0]]:
        if ps[i][1] == "WA":
            wa[ps[i][0]] += 1
        elif ps[i][1] == "AC":
            ac[ps[i][0]] = True
wa_sum = 0
for i in range(n + 1):
    if ac[i]:
        wa_sum += wa[i]
print(str(ac.count(True)) + " " + str(wa_sum))


Measured memory_bytes: 67416
K = int(input())

l=[1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]

print(l[K-1])

Measured memory_bytes: 3060
#include <stdio.h>
int main (){
	int a,b,c,count;
	scanf ("%d %d %d",&a,&b,&c);
	for (int i=a;i<=b;i++){
		if (c%i == 0){
			count++;
		}
	}
	printf ("%d\n",count);
	return 0;
}


Measured memory_bytes: 1992
import java.io.*;
import java.util.*;


public class Main {

    private static BufferedReader br;
    private static StreamTokenizer st;
    private static PrintWriter pw;

    static final int INF = 1000000007;
    static final int MOD = 1000000007;

    private static void solve() throws IOException {
        int n = nextInt();
        int a[] = new int[n + 1];
        long res = 0;
        for (int i = 0; i <= n; i++) {
            a[i] = nextInt();
        }
        for (int i = 0; i < n; i++) {
            int b = nextInt();
            res += Math.min(b, a[i] + a[i + 1]);
            a[i + 1] -= Math.min(a[i + 1], Math.max(0, b - a[i]));
        }
        pw.println(res);
    }

    static long gcd(long a, long b) {
        if (a < b) {
            a ^= b;
            b ^= a;
            a ^= b;
        }
        while (b != 0) {
            long t = a % b;
            a = b;
            b = t;
        }
        return a;
    }

    static long inv(long t, long p) {
        return t == 1 ? 1 : (p - p / t) * inv(p % t, p) % p;
    }

    public static void main(String args[]) throws IOException {
//        System.out.println(System.getProperty("java.library.path"));

//        boolean oj = System.getProperty("ONLINE_JUDGE") != null;
//        if (!oj) {
//            System.setIn(new FileInputStream("src/in.txt"));
//            System.setOut(new PrintStream("out.txt"));
//        }
        br = new BufferedReader(new InputStreamReader(System.in));
        st = new StreamTokenizer(br);
        pw = new PrintWriter(new OutputStreamWriter(System.out));
        st.ordinaryChar('\'');
        st.ordinaryChar('\"');
        st.ordinaryChar('/');

//        long t = System.currentTimeMillis();
        solve();
//        if (!oj) {
//            pw.println("[" + (System.currentTimeMillis() - t) + "ms]");
//        }
        pw.flush();
    }

    private static long[] anLong(int n) throws IOException {
        long a[] = new long[n];
        for (int i = 0; i < n; i++) {
            a[i] = nextInt();
        }
        return a;
    }

    private static String next(int len) throws IOException {
        int b = br.read();
        while (b == '\n' || b == ' ' || b == '\r' || b == '\t') {
            b = br.read();
        }
        char ch[] = new char[len];
        ch[0] = (char) b;
        int idx = 1;
        while (idx < len && (b = br.read()) != ' ' && b != '\n' && b != '\r' && b != '\t') {
            ch[idx++] = (char) b;
        }
        return String.valueOf(ch).trim();
    }

    private static int nextInt() throws IOException {
        st.nextToken();
        return (int) st.nval;
    }

    private static long nextLong() throws IOException {
        return Long.parseLong(nextLine());
    }

    private static double nextDouble() throws IOException {
        st.nextToken();
        return st.nval;
    }

    private static String[] nextSS(String reg) throws IOException {
        return br.readLine().split(reg);
    }

    private static String nextLine() throws IOException {
        return br.readLine();
    }
}

Measured memory_bytes: 25864
#include <algorithm>
#include <climits>
#include <cmath>
#include <cstdio>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
#define REP(var, a, b) for (int var = (a); var < (b); var++)
#define rep(var, n) for (int var = 0; var < (n); ++var)
#define ALL(c) (c).begin(), (c).end()
#define rALL(c) (c).rbegin(), (c).rend()
ll MOD = 1000000007;
ll INF = 1LL << 60;

class Dijkstra {
 private:
  struct edge {
    ll to, cost;
    edge(ll t, ll c) : to(t), cost(c) {}
  };

  ll n_;
  vector<vector<edge>> G_;
  vl d_;

 public:
  Dijkstra(ll n) : n_(n), G_(n), d_(n, INF) {}
  void addEdge(ll v, ll to, ll cost) { G_[v].push_back(edge(to, cost)); }
  void exec(ll s) {
    priority_queue<pll, vector<pll>, greater<pll>> que;
    d_[s] = 0;
    que.push({0, s});

    while (!que.empty()) {
      pll p = que.top();
      que.pop();
      ll v = p.second;
      if (d_[v] < p.first) continue;
      for (auto& e : G_[v]) {
        if (d_[e.to] > d_[v] + e.cost) {
          d_[e.to] = d_[v] + e.cost;
          que.push({d_[e.to], e.to});
        }
      }
    }
  }
  ll dist(ll g) { return d_[g]; }
};

int main() {
  //
  ll n;
  cin >> n;
  Dijkstra d(n);
  rep(i, n - 1) {
    ll a, b, c;
    cin >> a >> b >> c;
    a--;
    b--;
    d.addEdge(a, b, c);
    d.addEdge(b, a, c);
  }
  ll q, k;
  cin >> q >> k;
  k--;
  d.exec(k);
  rep(i, q) {
    ll x, y;
    cin >> x >> y;
    x--;
    y--;
    cout << d.dist(x) + d.dist(y) << endl;
  }
  return 0;
}


Measured memory_bytes: 11120
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<list>
#include<set>
#include<map>
#include<utility>
#include<queue>

#define rep(i,x) for(int i=0;i<(int)(x);i++)
#define reps(i,x) for(int i=1;i<=(int)(x);i++)
#define rrep(i,x) for(int i=((int)(x)-1);i>=0;i--)
#define rreps(i,x) for(int i=((int)(x));i>0;i--)

#define all(x) (x).begin(),(x).end()
#define SZ(x) ((int)(x).size())
#define INF 2e9
#define MOD 1000000007

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
typedef long long ll;
typedef std::pair<ll, ll> P;
int gcd(int a,int b){return b?gcd(b,a%b):a;}


using namespace std;

int main()
{
    int n;
    string s;
    cin >> n >> s;
    int r=0;
    int b=0;
    rep(i, n){
        if(s[i] == 'R') r++;
        if(s[i] == 'B') b++;
    }
    if(r>b) cout << "Yes";
    else cout << "No";
}

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

int main() {
  int A, B, C, X, Y;
  cin >> A >> B >> C >> X >> Y;

  int price = min(X,Y) * min(A+B, C*2);

  if (X > Y) {
    price += (X-Y) * min(A, C*2);
  } else if (X < Y) {
    price += (Y-X) * min(B, C*2);
  }

  cout << price << endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define modulo 1000000007
#define mod(mod_x) ((((long long)mod_x+modulo))%modulo)
#define Inf 1000000000


int beki(long long a,long long b,int M = modulo){
	int x = 1;
	while(b!=0){
		if(b&1){
			x=((long long)x*a)%M;
		}
		a=((long long)a*a)%M;
		b>>=1;
	}
	return x;
}


int gyakugen(int a){
	return beki(a,modulo-2);
}


int main(){
	
	int N;
	cin>>N;
	
	vector<int> A(N);
	int ans = 0;
	for(int i=0;i<N;i++){
		cin>>A[i];
		ans = mod(ans + A[i]);
	}

	ans = mod(ans * ans);
	
	for(int i=0;i<N;i++){
		ans = mod(ans - mod(A[i]*A[i]));
	}
	
	cout<<mod(ans * gyakugen(2))<<endl;
	
	return 0;
}


Measured memory_bytes: 4044
#include<iostream>
#include<cmath>
#include<algorithm>
#include<vector>
#include<functional>
#include<string>
#include<iomanip>
#include<utility>
#include<string>
#include<map>
#include<unordered_map>
#include<queue>
 
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;
 
typedef long long ll;
typedef pair<int, int> P;
int gcd(int a, int b){return b ? gcd(b, a%b) : a;}
int lcm(int a, int b){return a*b / gcd(a, b);}
 
 
int main(){
    int H, W, K;
    cin >> H >> W >> K;
    vector<string> c(H);
    for(int i = 0; i < H; i++) cin >> c[i];
 
    
    int ans = 0;
    for(int i = 0; i < (1<<H); i++){
        for(int j = 0; j < (1<<W); j++){
            int cnt = 0;
 
            for(int k = 0; k < H; k++){
                for(int l = 0; l < W; l++){
                    if(i & (1<<k)) continue;
                    if(j & (1<<l)) continue;
                    if(c[k][l] == '#') cnt++;
                }
            }
            if(cnt == K) ans++;
        }
    }
 
    cout << ans << endl;
    return 0;
}

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

int main() {
    double w, h, x, y;
    cin >> w >> h >> x >> y;
    double ans1 = h * w / 2;
    int ans2 = 0;
    if (x == w / 2 & y == h / 2) ans2 = 1;
    cout << ans1 << ' ' << ans2 << endl;
}

Measured memory_bytes: 3728
import java.util.*;
import java.io.*;
import java.awt.Point;
import java.math.BigInteger;

public class Main {
	
	static int N;
	
	public static void main(String[] args) throws Exception {
		FastIO sc = new FastIO(System.in);
		PrintWriter pw = new PrintWriter(System.out);
		
		N = sc.nextInt();
		long K = sc.nextLong();
		
		long arr[][] = new long[N][N];
		for(int i = 0; i < N; i++) {
			for(int j = 0; j < N; j++) {
				arr[i][j] = sc.nextInt();
			}
		}
		
		arr = fast_exp(arr, K);
		
		long tot = 0;
		for(int i = 0; i < N; i++) {
			for(int j = 0; j < N; j++) {
				tot += arr[i][j];
				tot %= 1000000007;
			}
		}
		
		pw.println(tot);
		pw.close();
		
	}
	
	
	
	static long[][] fast_exp(long[][] base, long exponent) {
		long[][] ret = new long[N][N];
		for(int i = 0; i < N; i++) ret[i][i] = 1;
		while(exponent > 0) {
			if(exponent % 2 == 1) ret = mult(ret, base);
			base = mult(base, base);
			exponent /= 2;
		}
		return ret;
	}
	
	static long[][] mult(long[][] a, long[][] b) {
		long[][] ret = new long[N][N];
		for(int i = 0; i < N; i++) {
			for(int j = 0; j < N; j++) {
				for(int k = 0; k < N; k++) {
					ret[i][j] += a[i][k]*b[k][j];
					ret[i][j] %= 1000000007;
				}
			}
		}
		
		return ret;
	}

	static class FastIO {

		//Is your Fast I/O being bad?

		InputStream dis;
		byte[] buffer = new byte[1 << 17];
		int pointer = 0;

		public FastIO(String fileName) throws Exception {
			dis = new FileInputStream(fileName);
		}

		public FastIO(InputStream is) throws Exception {
			dis = is;
		}

		int nextInt() throws Exception {
			int ret = 0;

			byte b;
			do {
				b = nextByte();
			} while (b <= ' ');
			boolean negative = false;
			if (b == '-') {
				negative = true;
				b = nextByte();
			}
			while (b >= '0' && b <= '9') {
				ret = 10 * ret + b - '0';
				b = nextByte();
			}

			return (negative) ? -ret : ret;
		}

		long nextLong() throws Exception {
			long ret = 0;

			byte b;
			do {
				b = nextByte();
			} while (b <= ' ');
			boolean negative = false;
			if (b == '-') {
				negative = true;
				b = nextByte();
			}
			while (b >= '0' && b <= '9') {
				ret = 10 * ret + b - '0';
				b = nextByte();
			}

			return (negative) ? -ret : ret;
		}

		byte nextByte() throws Exception {
			if (pointer == buffer.length) {
				dis.read(buffer, 0, buffer.length);
				pointer = 0;
			}
			return buffer[pointer++];
		}

		String next() throws Exception {
			StringBuffer ret = new StringBuffer();

			byte b;
			do {
				b = nextByte();
			} while (b <= ' ');
			while (b > ' ') {
				ret.appendCodePoint(b);
				b = nextByte();
			}

			return ret.toString();
		}

	}
}


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

#define hell                         1000000007
#define lcm(a,b)                     (a*b)/__gcd(a,b)
#define ll                           long long
#define vll                          vector<ll>
#define vi                           vector<int>
#define pll                          vector< pair<ll,ll> >
#define pb                           push_back
#define mp                           make_pair
#define all(v)                       v.begin(),v.end()
#define lbnd                         lower_bound
#define ubnd                         upper_bound
#define bs                           binary_search
#define F                            first
#define S                            second
#define rep(i,a,b)                   for(i=a;i<b;i++)
#define parr(a,n)                    for(ll it=0;it<n;it++) cout<<a[it]<<" ";cout<<endl;
#define pcont(a)                     for(auto it:a) cout<<it<<" ";cout<<endl;
#define ret(x)                       return cout<<x,0;
#define endl                           '\n'

/*constants*/
#define MAXN                         200005
#define PI                           3.14159265358979323846

/*debug*/
#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
    template <typename Arg1>void __f(const char* name, Arg1&& arg1){ std::cout << name << " : " << arg1 << '\n';}
    template <typename Arg1, typename... Args>void __f(const char* names, Arg1&& arg1, Args&&... args){const char* comma = strchr(names + 1, ','); std::cout.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);}
#else
#define trace(...)
#endif

using namespace std;
ll s[MAXN],vis[MAXN],out[MAXN];
vll adj[MAXN];
void dfs(ll u,ll k){
	vis[u]=1;
	out[u]=s[u]+k;
	for(auto it:adj[u]){
		if(!vis[it]){
			dfs(it,k+s[u]);
		}
	}
}
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);cout.tie(NULL);
	
	ll i,j,n,m,k,cnt=0,ans=0,t=1;
	cin>>n>>t;
	rep(i,0,n-1){
		cin>>j>>k;
		adj[j].pb(k);
		adj[k].pb(j);
	}	
	rep(i,0,t){
		cin>>j>>k;
		s[j]+=k;
	}
	dfs(1,0);
	rep(i,1,n+1) cout<<out[i]<<" ";
	return 0;
}

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

using ll = long long; 

/*
given n coins, each coin with p that is the probability of getting heads

find the the probability of getting more heads than tails

3
0.30 0.60 0.80

0.612

push dp
dp[i][j] means we have i heads and j tails

dp[i+1][j] += dp[i][j] * P(head)
dp[i][j+1] += dp[i][j] * P(tail)

ans = sum(dp[i][j]) where i + j = N

N = 3 
.3 .6 .8
   0  1   2   3 
0  
1  
2 
3 

dp[i][c] means the probability of getting to i heads up to c

*/

int main() {
    int n;
    
    scanf("%d", &n);
    
    vector<double> dp(n+1);
    
    dp[0] = 1;
    
    for (int i = 1; i <= n; i++) {
        double p_head;
        scanf("%lf", &p_head);
        for (int j = i; j >= 0; j--) {
            dp[j] = dp[j] * (1-p_head);
            if (j-1 >= 0) {
                dp[j] += dp[j-1] * p_head;
            }
            //dp[j] = (dp[j-1] * p_head) + (dp[j] * (1-p_head));
        }
    }
    
    double ans = 0;
    // 0 1 2 3 4 5
    // 0 1 2 3
    for (int i = n/2+1; i <= n; i++) {
        ans += dp[i];
    }
    
    printf("%.10lf", ans);
    
    
    //vector<double> coins(n);
    /*
    vector<vector<double>> dp(n+1, vector<double>(n+1));
    dp[0][0] = 1;
    for (int k = 0; k < n; k++) {
        int p_head;
        scanf("%lf", &p_head);
        for (int i = n; i >= 0; i--) {
           for (int j = n; j >= 0; j--) {
                if (i+1 <= n) {
                    dp[i+1][j] += dp[i][j] * p_head;    
                }
                if (j+1 <= n) {
                    dp[i][j+1] += dp[i][j] * (1-p_head);   
                }
                dp[i][j] = 0;
           }
        }
    }
    */
	
	return 0;
}

Measured memory_bytes: 256
import std.algorithm;
import std.array;
import std.conv;
import std.math;
import std.range;
import std.stdio;
import std.string;
import std.typecons;

void scan(T...)(ref T a) {
    string[] ss = readln.split;
    foreach (i, t; T) a[i] = ss[i].to!t;
}
T read(T)() { return readln.chomp.to!T; }
T[] reads(T)() { return readln.split.to!(T[]); }
alias readint = read!int;
alias readints = reads!int;

void main() {
    int n =readint;
    auto a = readints;

    int m = (n - 1) / 2; // 中央値の位置
    auto b = a.dup.sort();
    foreach (x; a) {
        writeln(x <= b[m] ? b[m + 1] : b[m]);
    }
}


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

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

  string W;
  cin >> W;
  set<string> S;
  S.insert(W);

  char prev = W.back();
  bool flag = true;
  for (int i = 1; i < N; i++) {
    cin >> W;
    if (W.front() != prev || S.count(W) == 1) {
      flag = false;
    }
    prev = W.back();
    S.insert(W);
  }
  if (flag) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
#include <iostream>
#include <array>
#include <vector>
#include <iomanip>
#include <string>
#include <cmath>
#include <algorithm>
#include <queue>
#include <map>
#include <set>

using namespace std;

typedef  pair<int,int> P;
typedef long long LL;
typedef vector<LL> VEC;
typedef vector<VEC> VVEC;

const LL INF=1<<30;
const LL MOD=1000000007;






int main(){
    char x,y;
    cin>>x>>y;
    if(x>y)cout<<'>'<<endl;
    else if(x<y) cout<<'<'<<endl;
    else cout<<'='<<endl;
}



Measured memory_bytes: 256
#!/usr/bin/env python
# -*- coding: utf-8 -*-

import itertools as ite
import math
import random
import sys
import codecs
from collections import defaultdict

INF = 10 ** 18
MOD = 10 ** 9 + 7

sys.setrecursionlimit(1000000)

N = input()
p = map(int, raw_input().split())

cnt = 0
for i in range(N):
    if p[i] != i + 1:
        cnt += 1
print "YES" if cnt <= 2 else "NO"


Measured memory_bytes: 3560
# -*- coding: utf-8 -*-
import sys

def get_num():
    return int(input())


def get_nums(n):
    res = [0 for _ in range(n)]
    for i in range(n):
        res[i] = int(input())
    return res


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


n = get_num()
p = list(map(int, input().split()))

cnt = 0
for i, pi in enumerate(p):
    if pi != i + 1:
        cnt += 1

if cnt < 3:
    print('YES')
else:
    print('NO')

Measured memory_bytes: 38256
while s=gets do
	break if s.size < 5
	
	q1, b, c1, c2, q2 = s.split().map(&:to_i)
	
	if b < (q1-1)*c2 + c1
		puts "NA"
		next
	end
	
	if b >= q1*c1
		r1 = [b/c1, q2].min
	else
		r2 = q1
		s = c1 - c2
		b2 = b - q1*c2
		r1 = [b2/s, q2].min
	end
	
	b -= c1*r1
	r2 = b/c2
	puts "#{r1} #{r2}"
end

Measured memory_bytes: 8716
#AIsing2020 d
 
def f(n):
        cnt = 0
        while n:
            cnt+= 1
            n = n%bin(n).count('1')
        return cnt
 
def main():
    N = int(input())
    X = input()
    X10 = int(X,2)
    X10_num1 = X.count('1')
    X10_pulse = X10%(X10_num1+1)
    X10_ninus = X10%(X10_num1-1) if X10_num1 >1 else 0
 
 
    for i in range(N,0,-1):
        if (X10>>(i-1) & 1) and X10_num1 >1:
            mod = X10_num1-1
            amari = (X10_ninus - pow(2,i-1,mod))%(mod) 
        elif (X10>>(i-1) & 1) and X10_num1 ==1:
            print(0)
            continue
        else:
            mod = X10_num1+1
            amari = (X10_pulse + pow(2,i-1,mod))%(mod) 
 
        print(1+f(amari))
 
 
main()


Measured memory_bytes: 91876
#if 0

#endif

#include <bits/stdc++.h>
#define REP(i, n) for(int i=0;i<int(n);++i)
using namespace std;
template<class A>void p(A a){cout << (a) << endl;}
template<class A,class B>void p(A a,B b){cout << a << " "  ;p(b);}
template<class A,class B,class C>void p(A a,B b,C c){cout << a << " " ;p(b,c);}
template<class A,class B,class C,class D>void p(A a,B b,C c,D d){cout << a << " " ;p(b,c,d);}
typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
int INF=numeric_limits<int>::max();
// for copy
// for(int i=0;i<N;++i) {

int main(void) {
  int N;cin>>N;
  if(N%2==1) {
    int r = N/2 + 1;
    p(r);
  } else {
    p(N/2);
  }
  return 0;
}



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

#define INF 1e9
#define llINF 1e18
#define MOD 1e9+7
#define pb push_back
#define mp make_pair 
#define F first
#define S second
#define ll long long
using namespace std;
int main(){
  int n,m;
  while(cin>>n>>m,n){
    int num[2500100]={};
    int takasa[10600]={};
    int num2[10600]={};
    ll ans=0;
    for(int i=1;i<=n;i++){
      int a;cin>>a;
      takasa[i]=takasa[i-1]+a;
    }
    for(int i=1;i<=m;i++){
      int a;cin>>a;
	num2[i]=num2[i-1]+a;
      for(int j=0;j<i;j++){
	num[num2[i]-num2[j]]++;
      }
    }
    for(int i=0;i<=n;i++){
      for(int j=0;j<i;j++){
	ans+=num[takasa[i]-takasa[j]];
      }
    }
    cout<<ans<<endl;
  }
  return 0;
}



Measured memory_bytes: 12860
<?php
[$X, $K, $D] = explode(' ', trim(fgets(STDIN)));

if($D == 0 || $K == 0) dsp(abs($X));

if(abs($X) >= $K * $D) {
  if($X >= 0) dsp(abs($X - $K * $D));
  else dsp(abs($X + $K * $D));
}

$K -= floor(abs($X) / $D);
if($X >= 0) {
  $X -= $D * floor(abs($X) / $D);
} else {
  $X += $D * floor(abs($X) / $D);
}
if($K % 2 == 0) dsp(abs($X));
else if($X >= 0) dsp(abs($X - $D));
else dsp(abs($X + $D));

function dsp($n) {
  printf("%d\n", $n);
  exit();
}

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

long long n, a[100009], b[100009], c[100009], s[100009], dist[100009], dp[100009]; vector<int>x[100009]; bool used[100009];
vector<pair<long long, long long>>X[200009];

long long dfs(int pos, int depth) {
	used[pos] = true;
	dist[pos] = depth;
	dp[pos] = 1;
	for (int i = 0; i < x[pos].size(); i++) {
		if (used[x[pos][i]] == true) continue;
		dp[pos] += dfs(x[pos][i], depth + 1);
	}
	return dp[pos];
}
void dfs2(int pos, long long depth) {
	if (used[pos] == true) return;
	dist[pos] = depth; used[pos] = true;
	for (int i = 0; i < X[pos].size(); i++) {
		dfs2(X[pos][i].first, depth + X[pos][i].second);
	}
}

int main() {
	cin >> n;
	for (int i = 1; i <= n - 1; i++) {
		cin >> a[i] >> b[i];
		x[a[i]].push_back(b[i]);
		x[b[i]].push_back(a[i]);
	}
	for (int i = 1; i <= n; i++) cin >> s[i];
	dfs(1, 0);
	for (int i = 1; i <= n - 1; i++) {
		if (dist[a[i]] > dist[b[i]]) swap(a[i], b[i]);
		if (s[b[i]] - s[a[i]] == 0) continue;
		else  c[i] = (s[b[i]] - s[a[i]]) / (n - dp[b[i]] * 2);
	}
	for (int i = 1; i <= n - 1; i++) {
		X[a[i]].push_back(make_pair(b[i], c[i]));
		X[b[i]].push_back(make_pair(a[i], c[i]));
	}
	for (int i = 1; i <= n; i++) used[i] = false;
	dfs2(1, 0);
	long long sum = 0; for (int i = 1; i <= n; i++) sum += dist[i];
	for (int i = 1; i <= n - 1; i++) {
		if (c[i] == 0) c[i] = (s[1] - sum) / (n / 2);
	}
	for (int i = 1; i <= n - 1; i++) {
		cout << c[i] << endl;
	}
	return 0;
}

Measured memory_bytes: 25088
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
import math
import bisect
import random
from itertools import permutations, accumulate, combinations
import sys
import string
from bisect import bisect_left


INF = float('inf')
def LI(): return list(map(int, sys.stdin.readline().split()))
def I(): return int(sys.stdin.readline())
def LIM(): return list(map(lambda x:int(x) - 1, sys.stdin.readline().split()))
def LS(): return sys.stdin.readline().split()
def S(): return sys.stdin.readline().strip()
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def LIRM(n): return [LIM() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def LSR(n): return [LS() for i in range(n)]
def SRL(n): return [list(S()) for i in range(n)]
mod = 1000000007


n, k = LI()
s = S()
cnt = 0
if s[0] == 'L':
    cnt += 1
if s[-1] == 'R':
    cnt += 1
for i in range(n-1):
    if s[i] == 'R' and s[i+1] == 'L':
        cnt += 2



print(n - max(cnt - 2 * k, 1))

Measured memory_bytes: 40432
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using Pair = pair<int, int>;
using Vec = vector<int>;
using Graph = vector<Vec>;

int		main(void)
{
	int n, m;
	cin >> n >> m;
	if (n == m)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ZERO(a) memset(a,0,sizeof(a))
#define FILL(a,b) memset(a,b,sizeof(a))
#define SORT(v) sort((v).begin(),(v).end())
#define RSORT(v) sort((v).rbegin(),(v).rend())
#define FOR(i,a,b)  for(int i=a, i##_len=(b); i<i##_len; ++i)
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
using namespace std;
int N;
int A[200000];

int solve(void) {
    int counter = -1;
    for (int i = 0; i < N; i++) {
        if (A[i] != i-counter) {
            counter++;
        }
    }
    if (counter == N - 1) {
        counter = -1;
    } else {
        counter += 1;
    }
    return counter;
}

int main(void) {
    cin >> N;
    for (int i = 0; i < N; i++) {
        cin >> A[i];
    }

    cout << solve() << endl;
    return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
const long long MOD = 1e9 + 7;
const long long MX = 1e9;

#include <math.h>
#define PI 3.14159265358979323846264338327950L

long long gcd(long long a, long long b) {
    if (a == 0)
        return b;
    return gcd(b % a, a);
}
long long lcm(long long a, long long b) {
    return (a * b) / gcd(a, b);
}
long long digits(long long m) {
    long long cnt = 0;
    while (m) {
        cnt++;
        m /= 10;
    }
    return cnt;
}



int main() {
    int N;
    cin >> N;
    long long ans = 0;
    for (int i = 1; i <= N; i++) {
        long long i1 = i;
        long long M = N / i;
        long long cnt = 0;
        for (int j = 1; i1*j <= N; j++) cnt += i1 * j;
        ans += cnt;
    }
    cout << ans;

    return 0;
}

Measured memory_bytes: 3620
Public Class Program
  Shared Sub Main()
    Dim n As Long = Long.Parse(Console.ReadLine())
    Dim arrayH As Long() = Array.ConvertAll(Of String, Long)(Console.ReadLine().Split(" "), AddressOf Long.Parse)
    Dim output As String = "Yes"
    For i As Long = n - 1 To 1 Step -1
      Select Case arrayH(i - 1) - arrayH(i)
        Case 1
          arrayH(i - 1) -= 1
        Case > 1
          output = "No"
          Exit For
      End Select
    Next
    Console.WriteLine(output)
  End Sub
End Class

Measured memory_bytes: 27484
#include <iostream>
#include <vector>
#include <fstream>
#include <algorithm>
#include <iomanip>
#include <map>
#include <queue>
#include <stack>
#include <set>
#include <ctime>
#include <iterator>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
using namespace std;


int main()
{
    int a,b;
    while(cin>>a>>b)
    {
        int sum = a+b;
        int res = 0;
        while(sum > 0)
        {
            res++;
            sum/=10;
        }
        cout<<max(1,res)<<endl;
    }
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define pb push_back
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define rep(i, n) FOR(i, 0, n)
#define ll long long
using namespace std;

const ll P = 1000000007;
const long long INF = 1LL << 60;
int gcd(int a, int b) { return b != 0 ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a / gcd(a, b) * b; }
vector<char> Alphabet = {'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z'};
vector<char> alphabet = {'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z'};
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }


int main()
{
  cout << fixed << setprecision(10);
  string S,T;
  cin >> S >> T;
  int s = S.size(),t = T.size();
  int ans = P;
  rep(i,s)
  {
    int n = 0;
    rep(j,t)
    {
      if(i+j>=s) 
      {
        n = P;
        break;
      }
      if(S[i+j]!=T[j]) n ++;
    }
    ans = min(n,ans);
  }
  cout << ans << endl;
  return 0;
}


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

using namespace std;

#define int long long
#define ll long long
typedef pair<int, int> P;
#define mod 1000000007
#define INF (1LL<<60)

#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl



signed main(){

	int N;
	vector<int> H;
	cin >> N;
	rep(i, N){
		int t;
		cin >> t;
		H.push_back(t);
	}

	int ans = 1;
	for (int i = 1; i < N; i++){
		bool good = true;
		rep(j, i ){
			if (H[j] > H[i]){ good = false; break; }
		}
		if (good){
			ans++;
			cerr << i << endl;
		}
	}
	cout << ans << endl;


	return 0;
}

Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i, c) for (int i = 0; i < (int)c; i++)
#define all(v) v.begin(), v.end()
using ll = long long;
using P = pair<int, int>;
//const int inf = 1e9; //1(1倍)e(指数)9(10^9)
//const ll MX = 1e18; //1(1倍)e(指数)18(10^18)
//const ll MOD = 1e9 + 7; //1000000007で割った余りを聞かれたら使う
//加算代入演算子は+=
//int 2^31 10^9まで
//intは10桁、long longは18桁、doubleは308桁、long double は4932桁
//10^10くらいまででdoubleは誤差が発生しちゃう。なるべく整数にすること
//doubleからlong longにキャストするときは、+0.5で切り捨ての誤差を調整
//__int128()で128bit対応の整数（多倍長整数）
//||は片方が成り立つとき
int main()
{
    int n, k;
    scanf("%d %d", &n, &k);
    vector<int> l(n);
    rep(i, n) cin >> l[i];
    sort(l.begin(), l.end());
	reverse(l.begin(), l.end());
    int ans = 0;
    rep(i, k) ans += l[i];
    cout << ans << endl;
    return 0;
}

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

#define MAX 2000000

int A[MAX];
int heap_size=0;

void maxHeapify(int i){
  int l,r,largest,tmp;
  l=2*i;
  r=l+1;
  if(l<=heap_size && A[l]>A[i])largest=l;
  else largest=i;
  if(r<=heap_size && A[r]>A[largest])largest=r;
  if(largest!=i){
    tmp=A[i];
    A[i]=A[largest];
    A[largest]=tmp;
    maxHeapify(largest);
  }
}

void buildMaxHeap(){
  int i;
  for(i=(int)(heap_size/2);i>=1;i--){
    maxHeapify(i);
  }
}


void heapIncreaseKey(int i,int key){
  int tmp;
  A[i]=key;
  while(i>1 && A[i/2]<A[i]){
    tmp=A[i];
    A[i]=A[i/2];
    A[i/2]=tmp;
    i=i/2;
  }
}

void maxHeapInsert(int key){
  heap_size+=1;
  A[heap_size]=-1;
  heapIncreaseKey(heap_size,key);
}

int heapExtractMax(void){
  int max;
  max=A[1];
  A[1]=A[heap_size];
  heap_size-=1;
  maxHeapify(1);
  return max;
}


main(){
  char order[20];
  int x;

  while(1){
    scanf("%s",order);
    if(order[0]=='i') {
      scanf("%d",&x);
      maxHeapInsert(x);
    }
    else if(order[1]=='x') printf("%d\n",heapExtractMax());
    else if(order[2]=='d')break;
  }
  return 0;
}

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

int main()
{
    string S;
    cin >> S;
    if (S == "Sunny")
    {
        cout << "Cloudy";
    }
    else if (S == "Cloudy")
    {
        cout << "Rainy";
    }
    else if (S == "Rainy")
    {
        cout << "Sunny";
    }
    return 0;
}

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

using namespace std;
 
int main() {
    int n;cin>>n;
    int p[n];
    int ok= 0;
    for(int i = 0;i<n;i++) cin >> p[i];
    for(int i = 1;i<=n-2;i++){
      if(p[i-1] < p[i] && p[i]< p[i+1]) ok++;
      if(p[i-1] > p[i] && p[i]> p[i+1])ok++;
    }
    cout<<ok;
    return 0;
}

Measured memory_bytes: 256
def main():
    n, m = map(int, input().split())
    qry = [list(map(int, input().split())) for _ in range(m)]
    ans = -1
    for v in range(0, 1000):
        s = str(v)
        if len(s) != n:
            continue
        f = True
        for p, x in qry:
            if s[p-1] != str(x):
                f = False
                break
        if f:
            ans = v
            break
    print(ans)

if __name__ == "__main__":
    main()

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

int main(){
    int n, t;
    cin >> n >> t;
    vector<pair<int, int> > v;
    for(int i = 0; i < n; i++){
        int c, tt;
        cin >> c >> tt;
        v.push_back(make_pair(tt, c));
    }
    sort(v.begin(), v.end());
    if(v[0].first > t){
        cout << "TLE" << endl;
    }else{
        int tle = v[0].first;
        int res = v[0].second;
        for(int i = 1; i < v.size(); i++){
            if(v[i].first > t) continue;
            if(v[i].second < res) res = v[i].second;
        }
        cout << res << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

int main() {
    string s;
    cin >> s;
    int count = 0;
    vector<int> ans;
    rep(i, s.size()) {
        if (s[i] == 'A' || s[i] == 'C' || s[i] == 'G' || s[i] == 'T') {
            count += 1;
            ans.push_back(count);
        }
        else {
            count = 0;
            ans.push_back(count);
        }
    }
    sort(ans.begin() ,ans.end());
    cout << ans[ans.size() - 1] << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <utility>

using namespace std;
const long long INF = 1LL<<60;
int H, W;
vector<vector<char>> grid(100, vector<char>(100));
vector<vector<long long>> lengthOfMinPath(100, vector<long long>(100,-1));
const vector<int> dx = {1,0,-1,0};
const vector<int> dy = {0,1,0,-1};
using P = pair<int, int>;

int solve(){
    queue<P> que;
    
    que.push(P(0,0));
    lengthOfMinPath[0][0] = 1;
    
    while (que.size()){
        P p = que.front();
        que.pop();
        
        if (p.first == H-1 && p.second == W-1) break;
        
        for (int i = 0; i < 4; i++){
            int nx = p.first + dx[i];
            int ny = p.second + dy[i];
            
            if (0 <= nx && nx < H && 0 <= ny && ny < W && grid[nx][ny] != '#' && lengthOfMinPath[nx][ny] == -1){
                que.push(P(nx,ny));
                lengthOfMinPath[nx][ny] = lengthOfMinPath[p.first][p.second] + 1;
            }
        }
        
    }
    
    return lengthOfMinPath[H-1][W-1];
}

int main(){
    cin >> H >> W;
    
    int numberOfTotal = H * W;
    int numberOfBlack = 0;
    
    for (int i = 0; i < H; i++){
        for (int j = 0; j < W; j++){
            cin >> grid[i][j];
            if (grid[i][j] == '#') numberOfBlack++;
        }
    }
    
    if (grid[0][0] == '#' || grid[H-1][W-1] == '#'){
        cout << -1 << endl;
        return 0;
    }
    
    int lengthOfMinPath = solve();
    if (lengthOfMinPath == -1){
        cout << -1 << endl;
        return 0;
    }
    
    int ans = numberOfTotal - numberOfBlack - lengthOfMinPath;
    cout << ans << endl;
    
    
    
}

Measured memory_bytes: 384
import collections
import math
N = int(input())
a = list(map(int, input().split()))

S = [0]
for i in range(N):
    S.append(S[-1] + a[i])


ans = 0
for k,v in collections.Counter(S).items():
    if v >= 2:
        ans += math.factorial(v)//(math.factorial(v-2)*2)
print(ans)

Measured memory_bytes: 41688
import java.util.Scanner

object Main {
  def main(args: Array[String]): Unit = {
    val sc = new Scanner(System.in)
    val n, m, q = sc.nextInt()
    val qs = Vector.fill(q)((sc.nextInt(), sc.nextInt(), sc.nextInt(), sc.nextInt()))

    val a = (1 to n).flatMap(_ => 1 to m).combinations(n).map(_.sorted)


    def f(v: Seq[Int]): Long = {
      (for {
        (a, b, c, d) <- qs
        if v(b - 1) - v(a - 1) == c
      } yield d.toLong).sum
    }

    val res = a.map(f)
    println(res.max)

  }
}


Measured memory_bytes: 58316
from collections import deque

if __name__ == '__main__':
    n, q = input().split()
    n, q = int(n), int(q)
    S = [deque([]) for i in range(n)]

    for i in range(q):
        query = input().split()

        if query[0] == '0':
            S[int(query[1])].append(query[2])

        else:
            if len(S[int(query[1])]) == 0:
                pass
            elif query[0] == '1':
                print(S[int(query[1])][-1])
            else:
                S[int(query[1])].pop()


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

#define fastIO \
ios_base::sync_with_stdio(false); cin.tie(NULL);
#define endl "\n"
#define ll long long
#define MOD 1000000007
#define pb push_back
#define ff first
#define ss second
#define mp make_pair
#define pii pair<int,int> 

int main(){
	int n;
	cin >> n;
	cout << pow(n,3) << endl;
	return 0;
}

Measured memory_bytes: 512
{-# LANGUAGE BangPatterns #-}
import Control.Arrow
import Control.Monad.Fix
import Data.Char
import Data.Int
import Data.Foldable
import Data.List
import qualified Data.Vector as V
import qualified Data.Vector.Unboxed as VU
import qualified Data.ByteString.Char8 as B
import Debug.Trace

solve :: Int -> Int -> Int -> Int
solve !a !b !c = max (c - (a - b)) 0

main = do
  let readInt :: Integral a => B.ByteString -> Maybe (a, B.ByteString)
      readInt = fmap (first fromIntegral . second B.tail) . B.readInt

  (a, b, c) <-
    (\vec -> (vec VU.! 0, vec VU.! 1, vec VU.! 2))
    .   VU.unfoldrN 3 readInt
    <$> B.getLine
  print $ solve a b c


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

int main(){
    int N, x, count = 0;
    cin >> N >> x;
    int a[N];
    for(int i = 0; i < N; i++){
        cin >> a[i];
    }
    sort(a, a + N);
    int i = 0;
    for(i = 0; i < N - 1; i++){
        x -= a[i];
        if(x < 0) break;
        count++;
    }
    if(x == a[i]){
        count++;
    }

    cout << count << endl;
}

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

template<typename T>
ostream& operator<<(ostream &os, vector<T> &v){
	string sep = " ";
	if(v.size()) os << v[0];
	for(int i=1; i<v.size(); i++) os << sep << v[i];
	return os;
}

template<typename T>
istream& operator>>(istream &is, vector<T> &v){
	for(int i=0; i<v.size(); i++) is >> v[i];
	return is;
}

#ifdef DBG
void debug_(){ cout << endl; }
template<typename T, typename... Args>
void debug_(T&& x, Args&&... xs){
	cout << x << " "; debug_(forward<Args>(xs)...);
}
#define dbg(...) debug_(__VA_ARGS__)
#else
#define dbg(...)
#endif

int main() {
	ios_base::sync_with_stdio(false);
	cout << setprecision(20) << fixed;

	int l, r, d;
	cin >> l >> r >> d;
	int ans = 0;
	for(int x=l; x<=r; x++){
		if(x%d==0) ans++;
	}
	cout << ans << endl;
	return 0;
}


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

int main() {
    long long ans=0, cnt=0;
    int n;
    vector<long long> a(3,0);
    string s;
    cin >> n >> s;

    for(int i=0; i<s.size(); i++) {
        if(s.at(i)=='R') a[0]++;
        else if(s.at(i)=='G') a[1]++;
        else if(s.at(i)=='B') a[2]++;
    }

    for(int i=0; i<s.size()-2; i++) {
        for(int j=i+1; j<s.size()-1; j++) {
            if(s.at(i)!=s.at(j)) {
                if(2*j-i<s.size()) {
                    if(s.at(i)!= s.at(2*j-i) && s.at(j)!= s.at(2*j-i)) {
                        cnt++;
                    }
                } 
            }
        }
    }
    ans=a[0]*a[1]*a[2]-cnt;
    cout << ans;
}

Measured memory_bytes: 3632
// Copyright 2020 yaito3014
#include "bits/stdc++.h"
using namespace std;

int main() {
  cin.tie(nullptr); cout.tie(nullptr); ios::sync_with_stdio(false);
  int A, B, C;
  cin >> A >> B >> C;
  bool ans = (A == B && A != C) || (A == C && A != B) || (B == C && A != B);
  cout << (ans ? "Yes" : "No") << endl;
}


Measured memory_bytes: 256