akhauriyash/Code-Regression huggingface dataset:
MOD = 10 **9 + 7
INF = 10 ** 10

def main():
    N = int(input())
    K = 0
    for i in range(2,N + 2):
        if i*(i - 1)//2 == N:
            K = i
            break
    if K == 0:
        print('No')
        return
    ans = [[0] * (K - 1) for _ in range(K)]

    before = 1
    for i in range(K - 1):
        for j in range(i,K - 1):
            ans[i][j] = before
            ans[j + 1][i] = before
            before += 1
    print('Yes')
    print(K)
    for i in range(K):
        print(len(ans[i]),*ans[i])
if __name__ == '__main__':
    main()

Measured memory_bytes: 9296
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int A, B, C;
		A = sc.nextInt();
		B = sc.nextInt();
		C = sc.nextInt();
		if (A + B < C) {
			System.out.println("No");
		} else {
			System.out.println("Yes");
		}
		sc.close();
	}

}


Measured memory_bytes: 23764
from sys import exit, stdin

class WeightedUnionFind:

    def __init__(self, n=1, sum_unity=0):

        self.par = [i for i in range(n)]

        self.rank = [0]*n

        self.diff_weight = [sum_unity]*n

    

    def find_root(self, x):

        if self.par[x] == x:

            return x

        else:

            y = self.find_root(self.par[x])

            self.diff_weight[x] += self.diff_weight[self.par[x]]

            self.par[x] = y

            return y

    def merge(self, x, y, w):

        rx, ry = self.find_root(x), self.find_root(y)

        if self.rank[rx] < self.rank[ry]:

            self.par[rx] = ry

            self.diff_weight[rx] = w - self.diff_weight[x] + self.diff_weight[y]

        else:

            self.par[ry] = rx

            self.diff_weight[ry] = -w - self.diff_weight[y] + self.diff_weight[x]

            if self.rank[rx] == self.rank[ry]:

                self.rank[rx] += 1

    def issame(self, x, y):

        return self.find_root(x) == self.find_root(y)

    def diff(self, x, y):

        return self.diff_weight[x] -  self.diff_weight[y]

N, M = [int(_) for _ in stdin.readline().rstrip().split()]

wuf = WeightedUnionFind(N)

for i in range(M):

    l, r, d = [int(_) for _ in stdin.readline().rstrip().split()]

    l -= 1

    r -= 1

    if wuf.issame(l, r):

        diff = wuf.diff(l, r)

        if diff != d:

            print("No")

            exit()

    else:

        wuf.merge(l, r, d)

print("Yes")



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

int main(){

    long long a,b,k;
    long long res_a,res_b;

    cin >> a>>b>>k;

    if(a<k){
      res_a = 0;
      res_b = b - (k-a);
      if(res_b<0){
        res_b=0;
      }
    }else{
      res_a = a-k;
      res_b = b;
    }

    cout << res_a << " "<< res_b << endl;

    return 0;
}



Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include<iostream>
#include<string>
#include<cmath>
#include<queue>
#include<map>
#include<set>
#include<list>
#include<iomanip>
#include<vector>
#include<random>
#include<functional>
#include<algorithm>
#include<cstdio>
#include<unordered_map>
using namespace std;
//---------------------------------------------------
//ライブラリゾーン！！！！
typedef long long ll;
typedef long double ld;
#define str string
#define rep(i,j) for(ll i=0;i<(long long)(j);i++)
const ll Mod = 1000000007;
const ll gosenchou = 5000000000000000;
short gh[2][4] = { { 0,0,-1,1 },{ -1,1,0,0 } };
struct P {
	ll pos, cost;
};
bool operator<(P a, P b) { return a.cost < b.cost; }
bool operator>(P a, P b) { return a.cost > b.cost; }
struct B {//隣接リスト表現
	ll to;
	ld cost;
};
struct E {//辺の情報を入れる変数
	ll from, to, cost;
};
bool operator<(E a, E b) {
	return a.cost < b.cost;
}
struct H {
	ll x, y;
};
bool operator<(H a, H b) {
	if (a.x != b.x) return a.x < b.x;
	return a.y < b.y;
}
bool operator>(H a, H b) {
	if (a.x != b.x) return a.x > b.x;
	return a.y > b.y;
}
bool operator==(H a, H b) {
	return a.x == b.x&&a.y == b.y;
}
bool operator!=(H a, H b) {
	return a.x != b.x || a.y != b.y;
}
ll gcm(ll i, ll j) {//最大公約数
	if (i > j) swap(i, j);
	if (i == 0) return j;
	return gcm(j%i, i);
}
ld rad(H a, H b) {
	return sqrt(pow(a.x - b.x, 2.0) + pow(a.y - b.y, 2.0));
}//rad＝座標上の2点間の距離
ll ari(ll a, ll b, ll c) {
	return (a + b)*c / 2;
}//等差数列の和
bool suf(ld a, ld b, ld c, ld d) {
	if (b <= c || d <= a) return 0;
	return 1;
}//[a,b),[c,d)
ll fact(ll x, ll k,ll p) {//最大値、個数
	ll sum = 1;
	for (int i = 0; i < k; i++) {
		sum *= (x--);
		sum %= p;
	}
	return sum;
}//階乗(正）
ll mod_pow(ll x, ll n, ll p) {
	ll res = 1;
	while (n > 0) {
		if (n & 1) res = res*x%p;
		x = x*x%p;
		n >>= 1;
	}
	return res;
}//x^n%p
#define int long long
const long long inf = 4523372036854775807;
const int iinf = 1500000000;
//----------------------------------------------------
//++++++++++++++++++++++++++++++++++++++++++++++++++++
int m, t, p, r;
struct A {
	int cost, time, id;
};
bool operator<(A a, A b) {
	if (a.cost != b.cost) return a.cost > b.cost;
	if (a.time != b.time) return a.time < b.time;
	return a.id > b.id;
}
A a[51];
int w[51][11];//間違えた数
bool b[51][11];//正解した？
signed main() {
	while (cin >> m >> t >> p >> r&&m + t + p + r > 0) {
		for (int i = 0; i < 51; i++) {
			for (int j = 0; j < 11; j++)
				w[i][j] = 0;
			a[i].cost = 0;
			a[i].time = 0;
			a[i].id = i;
		}
		for (int i = 0; i < r; i++) {
			int mi, ti, pi, ji;
			cin >> mi >> ti >> pi >> ji;
				if (!ji) {
					a[ti].cost++;
					a[ti].time += w[ti][pi] * 20 + mi;
				}
				else
					w[ti][pi]++;
		}
		sort(a + 1, a + t + 1);
		for (int i = 1; i <= t;) {
			int j = i;
			while (j <= t&&a[i].cost == a[j].cost&&a[i].time == a[j].time) {
				if (i == j) cout << a[i].id;
				else cout << "=" << a[j].id;
				j++;
			}
			i = j;
			if (i <= t)cout << ",";
		}
		cout << endl;
	}
	getchar(); getchar();
}


Measured memory_bytes: 3132
#include <bits/stdc++.h>
using namespace std;
typedef long long lint;
#define rep(i,n) for(lint (i)=0;(i)<(n);(i)++)
#define repp(i,m,n) for(lint (i)=(m);(i)<(n);(i)++)
#define repm(i,n) for(lint (i)=(n-1);(i)>=0;(i)--)
#define INF (1ll<<60)
#define all(x) (x).begin(),(x).end()
const lint MOD =1000000007;
const lint MAX = 1000000;
using Graph =vector<vector<lint>>;
typedef pair<lint,lint> P;
typedef map<lint,lint> M;
#define chmax(x,y) x=max(x,y)
#define chmin(x,y) x=min(x,y)
 
lint fac[MAX], finv[MAX], inv[MAX];
 
void COMinit() 
{
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (lint 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;
    }
}
 
long long COM(lint n, lint k)
{
    if (n < k)
        return 0;
    if (n < 0 || k < 0)
        return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
 
lint primary(lint num)
{
    if (num < 2) return 0;
    else if (num == 2) return 1;
    else if (num % 2 == 0) return 0;
 
    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2)
    {
        if (num % i == 0)
        {
            return 0;
        }
    }
 
    return 1;
}
   long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
    lint lcm(lint a,lint b){
        return a/__gcd(a,b)*b;
    }
     lint gcd(lint a,lint b){
        return __gcd(a,b);
    } 

  int main(){
   string s,t;
   cin>>s>>t;
   lint ans=INF;
    rep(i,s.size()-t.size()+1){
        lint count=0;
        rep(j,t.size()){
            if(s[i+j]!=t[j])count++;
        }
        ans=min(ans,count);
    }
    cout<<ans<<endl;
  }
      

Measured memory_bytes: 3620
using System;
using System.Collections.Generic;
using System.Linq;

class Program {
    static void Main(string[] args) {
        string s, t;
        Input(out s, out t);
        Console.WriteLine(t + s);
    }
    static T ChangeT<T>(string s) => (T)Convert.ChangeType(s, typeof(T));
    static void Input<A, B>(out A a, out B b) {
        var words = Console.ReadLine().Split(new[] { ' ' }, options: StringSplitOptions.RemoveEmptyEntries);
        a = ChangeT<A>(words[0]);
        b = ChangeT<B>(words[1]);
    }
}

Measured memory_bytes: 13268
def main():
    from sys import stdin
    readline = stdin.readline
    H, N = map(int, readline().split())
    AB = [list(map(int, readline().split())) for _ in range(N)]

    max_A = max(a for a, _ in AB)
    inf = float('inf')
    dp = [inf] * (H + max_A + 1)
    dp[0] = 0
    for i in range(H):
        if dp[i] == inf:
            continue
        t1 = dp[i]
        for a, b in AB:
            t2 = t1 + b
            if t2 < dp[i + a]:
                dp[i + a] = t2
    print(min(dp[H:]))


main()


Measured memory_bytes: 3724
package main
import "fmt"
const MOD int64 = 1000000007
func main() {
  var l,r,ans int64
  fmt.Scan(&l,&r)
  dp := [61][2][2][2]int64{}
  dp[60][0][0][0] = 1
  for i:=59;i>=0;i-- {
    lb := int(l>>uint(i))&1
    rb := int(r>>uint(i))&1
    for j:=0;j<2;j++ {
      for k:=0;k<2;k++ {
        for s:=0;s<2;s++ {
          for x:=0;x<2;x++ {
            for y:=0;y<2;y++ {
              if x-y == 1 { continue }
              jj,kk,ss := j,k,s
              if s == 0 && x != y { continue }
              if x*y == 1 { ss = 1 }
              if lb-j-x == 1 { continue }
              if x-lb == 1 { jj = 1 }
              if y-k-rb == 1 { continue }
              if rb-y == 1 { kk = 1 }
              dp[i][jj][kk][ss] = (dp[i][jj][kk][ss]+dp[i+1][j][k][s])%MOD
            }
          }
        }
      }
    }
  }
  for j:=0;j<2;j++ {
    for k:=0;k<2;k++ {
      for s:=0;s<2;s++ { ans += dp[0][j][k][s] }
    }
  }
  fmt.Println(ans%MOD)
}

Measured memory_bytes: 512
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<functional>
#include<vector>
#include<queue>
#include<stack>
#include<set>
#include<map>
using namespace std;
#define MOD 1000000007
#define f(i,n) for(int i=0;i<int(n);i++)
#define N 502
vector<long long>p;
bool pri[200000];

void p_m(void) {
	long long x;
	f(i, 200000)pri[i] = true;
	for (long long i = 2; i < 200000; i++) {
		if (pri[i]) {
			p.push_back(i);
			x = i;
			while (x < 200000) {
				pri[x] = false;
				x += i;
			}
		}
	}
	return;
}



int main() {
	int n;
	int x, y, k;
	long long a[N][N];
	scanf("%d", &n);
	p_m();
	f(i, n) {
		f(j, n)a[i][j] = 1;
	}
	x = 0;
	k = 0;
	while (x < (2 * n)) {
		f(i, n) {
			y = x - i - 1;
			if (y >= 0 && y < n)a[i][y] *= p[k];
			y = x - i;
			if (y >= 0 && y < n)a[i][y] *= p[k];
			y = x - i + 1;
			if (y >= 0 && y < n)a[i][y] *= p[k];
		}
		x += 2;
		k++;
	}
	if (n % 2 == 0)x = - n;
	else x = 1 - n;
	while (x <= n) {
		f(i, n) {
			y = x + i - 1;
			if (y >= 0 && y < n)a[i][y] *= p[k];
			y = x + i;
			if (y >= 0 && y < n)a[i][y] *= p[k];
			y = x + i + 1;
			if (y >= 0 && y < n)a[i][y] *= p[k];
		}
		x += 2;
		k++;
	}
	f(i, n){
		f(j,n) {
			if ((i + j) % 2 == 1)a[i][j]++;
}
		}
	f(i, n) {
		f(j, n) {
			printf("%lld", a[i][j]);
			if (j < n - 1)printf(" ");
			else printf("\n");
		}
	}






	return 0;
}


Measured memory_bytes: 5500
#include<iostream>
#include<cstring>
#include<algorithm>
using namespace std;
int main()
{
	int a[101][101];
	int row[101],col[101];
	int n,i,j,temp[101],k,num[101],s[10001];
	while(cin>>n)
	{
		memset(num,0,sizeof(num));
		if(n==0)return 0;
		for(i=0;i<n;i++)
			for(j=0;j<n;j++)
			   cin>>a[i][j];
		
			for(i=0;i<n;i++)
			{
		      for(j=0;j<n;j++)
			  { 
				  temp[j]=a[i][j];
				   num[j]=a[j][i];
			  }
			  sort(temp,temp+n);
			  sort(num,num+n);
			  row[i]=temp[0];
			  col[i]=num[n-1];
			}
			k=0;
			memset(s,0,sizeof(s));
			for(i=0;i<n;i++)
			for(j=0;j<n;j++)
			{
				if(a[i][j]==row[i]&&a[i][j]==col[j])
				{
					s[k]=a[i][j];
				     k++;
				}
			}
			sort(s,s+k);
			cout<<s[0];
			for(i=1;i<k;i++)
			{
				if(s[i]!=s[i-1]&&s[i]!=0)
					cout<<" "<<s[i];
			}
			cout<<endl;


	}
	return 0;

}

Measured memory_bytes: 0
s1=input()
s2=input()
ls1=len(s1)
ls2=len(s2)
f=[[0 for j in range(ls2+1)] for i in range(ls1+1)]
for i in range(ls1+1):
    f[i][0]=i
for i in range(ls2+1):
    f[0][i]=i
for i in range(1,ls1+1):
    for j in range(1,ls2+1):
        if s1[i-1]!=s2[j-1]:
            f[i][j]=min(f[i-1][j]+1,f[i][j-1]+1,f[i-1][j-1]+1)
                       #insert       delete?     change?
        else:
            f[i][j]=f[i-1][j-1]
print(f[i][j])


Measured memory_bytes: 42892
#include <stdio.h>
 
using namespace std;
 
int main(){
    int n,x;
    scanf("%d",&n);
 
    for(int i = 1; i<= n; i++)
    {
        if(i%3 == 0){
            printf(" %d",i);
        }else{
            x = i;
            do{
                if(x%10 == 3){
                    printf(" %d",i);
                    break;
                }
                x /=10;
            }while(x);
        }
    }
    printf("\n");
}


Measured memory_bytes: 2688
#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
#include<map>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < n; ++i)
#define rrep(i, st, n) for (int i = st; i < n; ++i)
int main() {
    string a, b; cin >> a >> b;
    string c = a + b;
    int cc = stoi(c);
    rrep(i, 1, cc) if (i * i == cc) {
        cout << "Yes" << endl;
        return 0;
    }
    cout << "No" << endl;
    return 0;
    
    
}


Measured memory_bytes: 256
class UnionFind:
    def __init__(self,size):
        self.parent=range(size)
        self.rank=[0]*size

    def findset(self,x):
        if self.parent[x]==x:
            return x
        else:
            self.parent[x]=self.findset(self.parent[x])
            return self.parent[x]

    def unite(self,x,y):
        x=self.findset(x)
        y=self.findset(y)
        if x==y:
            return
        if self.rank[x]<self.rank[y]:
            self.parent[x]=y
        else:
            self.parent[y]=x
            if self.rank[x]==self.rank[y]:
                self.rank[x]+=1

    def same(self,x,y):
        if self.findset(x)==self.findset(y):
            return True
        else:
            return False

def kruskal(n,m,edges):
    edges.sort()
    node=UnionFind(n)
    ret=0
    for i in xrange(m):
        cost,a,b=edges[i][0],edges[i][1],edges[i][2]
        if node.same(a,b):
            continue
        else:
            ret+=cost
            node.unite(a,b)
    return ret

n,m=map(int,raw_input().split())
edges=[]
for i in xrange(m):
    s,t,w=map(int,raw_input().split())
    edges.append([w,s,t])
print(kruskal(n,m,edges))

Measured memory_bytes: 24624
#include<bits/stdc++.h>
#define    ll          unsigned long long int
#define    sz          200010
#define    md          1000000007
#define    py          printf("Yes\n")
#define    pn          printf("No\n")
#define    sc1(a)      scanf("%lld",&a)
#define    sc2(a,b)    scanf("%lld %lld",&a,&b)
#define    pv(a)      printf("%lld\n",a)

using namespace std;


set<string>st;


int main()
{

    ll n,d;
    string s;

    cin>>n;

    while(n--)
    {
        cin>>s;
        st.insert(s);
    }

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

    return 0;
}


Measured memory_bytes: 19124
def main():
    N, K = map(int, input().split())
    count = 0
    if K == 0:
        return N**2

    for b in range(K+1, N+1):
        cc = N//b
        count += cc * (b-K)
        dd = N-cc*b
        if dd >= K:
            count += dd - K + 1

    return count

if __name__ == '__main__':
    print(main())



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

const int mod = 1e9 + 7;

ll dp[2020][2020];
ll sum[2020][2020];

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

  vector<int> s(n), t(m);
  rep(i,n) cin >> s[i];
  rep(i,m) cin >> t[i];

  memset(dp,0,sizeof(dp));
  memset(sum,0,sizeof(sum));

  dp[0][0] = 1;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      if(s[i] == t[j]) {
        dp[i + 1][j + 1] = sum[i][j] + 1;
        dp[i + 1][j + 1] %= mod;
      } else {
        dp[i + 1][j + 1] = 0;
      }
      sum[i + 1][j + 1] = (sum[i + 1][j] + sum[i][j + 1] + dp[i + 1][j + 1] + mod - sum[i][j]) % mod;
    }
  }
  ll answer = 0;
  for (int i = 0; i <= n; i++) {
    for (int j = 0; j <= m; j++) {
      answer += dp[i][j];
      answer %= mod;
    }
  }
  cout << answer << '\n';
}


Measured memory_bytes: 67356
function Main(s) {
  s = s.split("\n");
  s[0] = s[0].split(" ").map(a => +a);
  const n = s[0][0];
  const c = s[0][1];
  if(n === 1){
    s[1] = s[1].split(" ").map(a => +a);
    console.log(Math.max(0, s[1][1] - s[1][0], s[1][1] - c + s[1][0]));
    return;
  }
  var x = [];
  var p = [];
  var m = [];
  var ans;
  var kp = [];
  var km = [];
  x[0] = s[1].split(" ").map(a => +a);
  p[0] = x[0][1];
  ans = Math.max(0, p[0] - x[0][0]);
  kp[0] = ans;
  for(var i = 1; i < n; i++){
    x[i] = s[i+1].split(" ").map(a => +a);
    p[i] = p[i-1] + x[i][1];
    ans = Math.max(ans, p[i] - x[i][0]);
    kp[i] = ans;
  }
  m[n-1] = x[n-1][1];
  km[n-1] = Math.max(0, m[n-1] - c + x[n-1][0]);
  ans = Math.max(ans, km[n-1]);
  for(i = n-2; i >= 0; i--){
    m[i] = m[i+1] + x[i][1];
    km[i] = Math.max(km[i+1], m[i] - c + x[i][0]);
    ans = Math.max(ans, m[i] - c + x[i][0], km[i+1] + kp[i] - x[i][0], km[i+1] + kp[i] - c + x[i+1][0]);
  }
  console.log(ans);
}
Main(require("fs").readFileSync("/dev/stdin","utf8"));

Measured memory_bytes: 66656
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int a,b,c,sum,mx,mn;
    cin>>a>>b>>c;
    mx=max(a,b);
    mx=max(mx,c);
    mn=min(a,b);
    mn=min(mn,c);
    sum=mx-mn;

    cout<<sum<<endl;
    return 0;
}




Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int n;
  cin>>n;
  int a[n],b[n],c[n-1];
  for(int i=0;i<n;i++) cin>>a[i];
  for(int i=0;i<n;i++) cin>>b[i];
  for(int i=0;i<n-1;i++)cin>>c[i];
  int ret=0;
  for(int i=0;i<n-1;i++)
  {
	if(a[i]+1==a[i+1])ret+=(b[a[i]-1]+c[a[i]-1]);
    else ret+=b[a[i]-1];
  }
  ret+=b[a[n-1]-1];
  cout<<ret<<endl;
    return 0;
}

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


#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define MOD 1000000007
#define pii pair<int,int>
#define pli pair<long long,int>
#define pil pair<int,long long>
#define ll long long
#define el '\n'

using namespace std;

char c;

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

    cin >> c;
    if ('A' <= c && c <= 'Z'){
        cout << "A" << el;
    } else{
        cout << "a" << el;
    }

    return 0;
}

Measured memory_bytes: 3560
x = list(map(int, input().split()))

x.sort()
count=0

x[0]=x[2]-x[0]
x[1]=x[2]-x[1]

if x[0]%2==0:
    count+=int(x[0]/2)-1
    x[0]=2
else:
    count+=int(x[0]/2)
    x[0]=1
    
if x[1]%2==0:
    count+=int(x[1]/2)-1
    x[1]=2
else:
    count+=int(x[1]/2)
    x[1]=1

if (x[0]==1 and x[1]==1):
    print(count+1)
    quit()

if (x[0]==2 and x[1]==2):
    print(count+2)
    quit()

if (x[0]*x[1]==2):
    print(count+3)
    quit()



Measured memory_bytes: 3064
#include <bits/stdc++.h>
#include <atcoder/all>
using namespace std;
using namespace atcoder;
int main(){
    int T;
    cin >> T;
    for(int i = 0; i < T; i++){
        long long N, M, A, B;
        cin >> N >> M >> A >> B;
        long long ans = floor_sum(N, M, A, B);
        cout << ans << endl;
    }
}

Measured memory_bytes: 3648
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <cmath>
#include <map>
#include <cstdlib>
using namespace std;
using ll = long long int;

int main()
{
    int N,T;
    cin >> N >> T;
    pair<int,int> a[N];
    int m = 1001;
    for (int i = 0; i < N; i++) {
        cin >> a[i].first >> a[i].second;
    }
    for (int i = 0; i < N; i++) {
        if (a[i].second <= T) {
            if (m > a[i].first) {
                m = a[i].first;
            }
        }
    }
    if (m == 1001) {
        cout << "TLE" << endl;
    }
    else
        cout << m;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
	double x1,y1,x2,y2;
	cin>>x1>>y1>>x2>>y2;
	cout<<setprecision(10)<<fixed<<sqrt((pow(x1-x2,2)+pow(y1-y2,2))*1.0)<<endl;
}


Measured memory_bytes: 3272
#include <bits/stdc++.h>
using i64 = long long;

int main() {
    std::string s;
    std::cin >> s;
    s += 'Z';
    int n = s.size();
    std::deque<int> q;
    i64 ret = 0;
    for (int i = 0; i < n; i++) {
        if (s[i] == 'A') q.push_back(1);
        else if (s[i] == 'B' && s[i + 1] == 'C') { q.push_back(0); i++; }
        else if (q.size()) {
            i64 p = 0;
            for (int j = q.size() - 1; j >= 0; j--) {
                if (q[j] == 1) ret += p;
                else p++;
            }
            q.clear();
        }
    }
    std::cout << ret << std::endl;

    return 0;
}


Measured memory_bytes: 1284
#include <bits/stdc++.h>
using namespace std;
#define FAST ios_base::sync_with_stdio(0); cin.tie(); cout.tie();

#define MAXX 500005
#define PI 3.14159265358979323846264338327950
#define F first
#define S second
#define ll  int
#define mod  1000000007



int main()
{
	FAST;
	ll n;
	cin >> n;
	if(n >= 400 && n < 600){
		cout << 8;
	}
	else if(n >= 600 && n < 800){
		cout << 7;
	}
	
	else if(n >= 800 && n < 1000){
		cout << 6;
	}
	else if(n >= 1000 && n < 1200){
		cout << 5;
	}
	else if(n >= 1200 && n < 1400){
		cout << 4;
	}
	else if(n >= 1400 && n < 1600){
		cout << 3;
	}
	else if(n >= 1600 && n < 1800){
		cout << 2;
	}
	else if(n >= 1800 && n < 2000){
		cout << 1;
	}
}

Measured memory_bytes: 3636
def main():
    s = input()
    t = input()
    if t in s:
        print(s.replace('?', 'a'))
        return
    s = "".join(reversed(list(s)))
    t = "".join(reversed(list(t)))
    anses = []

    for i in range(len(s)):
        for j in range(len(t)):
            sw1, sw2 = False, False
            if i+j < len(s) and (s[i+j] == t[j] or s[i+j] == '?'):
                continue
            else:
                # '?' でもなく文字が合わなかった
                sw2 = True
                break
        else:
            # 合っていた
            ans = (s[:i]+t+s[i+len(t):]).replace('?', 'a')
            anses.append("".join(reversed(list(ans))))
            continue
    anses.sort()
    print(anses[0] if anses else "UNRESTORABLE")

if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
#include <algorithm>
#include <iostream>
#include <cstring>
#include <cstdio>
#include <queue>
const int N = 1e6 + 5;
typedef long long ll;
using namespace std; 

ll n, m; 

template < typename T >
inline T read()
{
	T x = 0, w = 1; char c = getchar();
	while(c < '0' || c > '9') { if(c == '-') w = -1; c = getchar(); }
	while(c >= '0' && c <= '9') x = x * 10 + c - '0', c = getchar();
	return x * w; 
}

ll mabs(ll x) { return x < 0 ? -x : x; }

int main()
{
#ifndef ONLINE_JUDGE
	freopen("cpp.in", "r", stdin);
#endif
	n = read <ll> (), m = read <ll> ();
	if(mabs(n - m) <= 1) puts("Brown"); 
	else puts("Alice"); 
	return 0; 
}


Measured memory_bytes: 2976
#include <stdlib.h>
#include <stdio.h>
#include <time.h>
#include <math.h>
#include <iostream>
#include <string>
#include<algorithm>
#include <vector>
#include <cassert>
#include<cmath>
using namespace std;
int main() {
	int N;
	int D=0;
	int L[1000];
	int X = 0;
	int count = 1;
	int i;
	cin >> N >> X;

	for (i = 0; i < N; ++i) {
		cin >> L[i];
	}

	for (i = 0; i < N; ++i) {
		D += L[i];
		if (D > X) {
			break;
		}
		++count;


	}

	cout << count << endl;
}


Measured memory_bytes: 256
#include <stdio.h>
int main(){
  int S,h,m,s, r;
  scanf("%d",&S);
  
  h=S/3600;
  r=S%3600;
  m=r/60;
  s=r%60;

printf("%d:%d:%d\n",h,m,s);

return 0;
}

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

int main(){
    int N,i;
    char S;
    int p=0,w=0,g=0,y=0;
    int color=0;

    cin >> N;

    for(i=0;i<N;i++){
        cin >> S;
        if(S=='P'){
            p=1;
        }
        else if(S=='W'){
            w=1;
        }
        else if(S=='G'){
            g=1;
        }
        else if(S=='Y'){
            y=1;
        }
        else{
            cout << "error" << endl;
            break;
        }
    }
    color=p+w+g+y;
    if(color==3){
        cout << "Three" << endl;
    }
    else if(color==4){
        cout << "Four" << endl;
    }
    else{
        cout << "Error" << endl;
    }
}

Measured memory_bytes: 256
//
// Created by watemus on 04.07.2020.
//

#ifdef LOCAL
#define _GLIBCXX_DEBUG
#endif

#include <bits/stdc++.h>

using namespace std;

#define ALL(a) a.begin(), a.end()
#define RALL(a) a.rbegin(), a.rend()
#define FF first
#define SS second

using ll = long long;
using ld = long double;

template<typename T>
using vec = std::vector<T>;

template<typename T>
using uset = std::unordered_set<T>;

template<typename T1, typename T2>
using umap = std::unordered_map<T1, T2>;

constexpr ll INFL = 1'000'000'000'000'000'228;
constexpr int INFI = 1'000'000'228;
const ld PI = acos(-1);
std::mt19937 rnd(std::chrono::steady_clock::now().time_since_epoch().count());

vec<pair<int, int>> DD = {{1, 0}, {-1, 0}, {0, 1}, {0, -1}};

#ifdef LOCAL
#else
#endif

void run() {
  ll n;
  cin >> n;
  vec<ll> a(n);
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  ll all = 0;
  for (int i = 0; i < n; i += 2) {
    all ^= a[i] ^ a[i + 1];
  }
  for (int i = 0; i < n; i++) {
    cout << (a[i] ^ all) << ' ';
  }
  cout << '\n';
}
/* stuff you should look for
	* int overflow, array bounds
	* special cases (n=1?)
	* do smth instead of nothing and stay organized
	* WRITE STUFF DOWN
*/

signed main() {
#ifdef LOCAL
  std::freopen("input.txt", "r", stdin);
#else
  std::ios_base::sync_with_stdio(false);
  std::cin.tie(nullptr);
#endif
  int t = 1;
  //cin >> t;
  while (t--) {
    run();
  }
  return 0;
}



Measured memory_bytes: 4776
while True:
    n = int(input())
    if n == 0:
        break
    arr = [[] for i in range(n)]
    for i in range(n):
        arr[i] = list(map(int, input().split()))[1:]
    k = list(map(int, input().split()))[1:]
    res = -1
    for num, i in enumerate(arr):
        ge = True
        for e in k:
            if e not in i:
                ge = False
                break
        if ge:
            if res >= 0:
                res = -1
                break
            else:
                res = num + 1

    print(res)



Measured memory_bytes: 5660
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = Integer.parseInt(sc.next());
		List<int[]> num = new ArrayList<>();
		for (int i = 0; i < n; i++) {
			int o = sc.nextInt();
			int r = sc.nextInt();
			int[] node = { o - r, o + r };
			num.add(node);
		}
		Collections.sort(num, new NumComp());

		int tmp = num.get(0)[1];
		int cnt = 1;
		for (int i = 1; i < n; i++) {
			if (tmp <= num.get(i)[0]) {
				tmp = num.get(i)[1];
				cnt++;
			}
		}
		System.out.println(cnt);

	}

	static class NumComp implements Comparator<int[]> {
		@Override
		public int compare(int[] a, int[] b) {
			return a[1] > b[1] ? 1 : -1;
		}
	}
}

Measured memory_bytes: 85200
#include <iostream>
#include <vector>
#include <cmath>

using namespace std;

int main() {
	int N, T, A, H;
	cin >> N >> T >> A;
	int minH;
	long double minsub=100000;
	for (int i = 0; i < N; ++i) {
		cin >> H;
		long double sub = abs(A - (T - H * 0.006));
		if (sub < minsub) {
			minsub = sub;
			minH = i + 1;
		}
	}
	cout << minH << endl;
	return 0;
}

Measured memory_bytes: 888
def main():
    flg = 0
    num = int(input())
    for i in range(100):
        if i * 4 > num:
            break
        for j in range(100):
            if i * 4 + j * 7 == num:
                flg = 1
                break
            elif i * 4 + j * 7 > num:
                break
    if flg:
        print('Yes')
    else:
        print('No')




if __name__ == '__main__':
    main()


Measured memory_bytes: 2940
#include<iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <tuple>
#include <cmath>
#include <queue>
#include <map>


using namespace std;


int main()
{
  long a,b,c;
  cin >> a >> b >> c;
  long k;
  cin >> k;

  priority_queue <long> p;
  p.push(a);
  p.push(b);
  p.push(c);

  a = p.top()*pow(2,k);
  p.pop();
  b = p.top();
  p.pop();
  c = p.top();


  cout << a+b+c  << endl;


  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
  	long long A,B;
  	cin >> A >> B;
  	for(int i = 1; ;i++){
  		A *= 2;
    	if(A > B){
    		cout << i << endl;
        	return 0;
    	}
  	}
	return 0;
}

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

typedef long long int ll;
#define INF 1999999999
#define MODA 1000000007
#define PI 3.1415926535897932384626433

int main()
{
    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
    ios::sync_with_stdio(false);
    cin.tie(0);
    string s;
    cin >> s;
    int count = 0;
    for(int i = 0; i < s.length(); i++)
    {
        if(s[i] == '+')
        {
            count++;
        }
        else
        {
            count--;
        }
    }
    cout << count << endl;

    return 0;
}



Measured memory_bytes: 256
#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
using namespace std;

typedef long long ll;
typedef pair<int, int> P;

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

// Self settings
// clang-format off
#define MAX_N 100000
#define REP(i, N) for (int i = 0; i < (int)(N); ++i)
#define SLN(i,N) (i == N-1 ? "\n" : " ")
#define mod %
ll fact(ll n) { ll res = 1; for(ll i=2;i<=n;++i) res = res * i; return res;}
ll nCr(ll n, ll r) {return (fact(n)/fact(n-r)*fact(r)) ;}
ll gcd(ll a,ll b){if(b==0)return a;return gcd(b,a%b);}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
const ll MOD = 1e9+7;
const ll INF = 1LL << 60;
const int inf = 1 << 30;
// clang-format on
int N, M;

int main(void)
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin >> N >> M;

  if (abs(N - M) > 1) {
    cout << 0 << endl;
    return 0;
  }

  ll sum1 = 1;
  for (int i = 1; i <= N; i++) {
    sum1 = sum1 * i mod MOD;
  }

  ll sum2 = 1;
  for (int i = 1; i <= M; i++) {
    sum2 = (sum2 * i) mod MOD;
  }

  ll ans = (sum1 * sum2) mod MOD;

  if (N == M) {
    ans = (ans * 2) mod MOD;
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
int main(){
   string S;
   cin >> S;
   int n = S.size();
   int dp[100010];
   dp[0] = 0;
   for(int i = 1;i < n;i++){
       if(S[i] == S[i-1]){
           dp[i] = dp[i-1]+1;
           if(S[i] == '1') S[i] = '0';
           else S[i] = '1';
       }else{
           dp[i] = dp[i-1];
       }
   }
   cout << dp[n-1] << endl;
}


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

ll n,k,m;




int main(){
  ll ans=0;
  cin >> n >> k>>m;
  vi a(n),b(k);
  ll mina=99999999;
  ll minb=99999999;
  REP(i,n){
    cin>>a[i];
    mina=min(mina,a[i]);
  }
  REP(i,k){
    cin>>b[i];
    minb=min(minb,b[i]);
  }

  vi x(m),y(m),c(m);
  REP(i,m){
    cin>>x[i]>>y[i]>>c[i];
  }


  ans=mina+minb;

  REP(i,m){
    ans=min(ans,a[x[i]-1]+b[y[i]-1]-c[i]);
  }







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

Measured memory_bytes: 4224
#include <stdio.h>

int main()
{
  int i, j, r, c;
  int score[101][101] = {};

  scanf("%d %d", &r, &c);
  for( i = 0 ; i < r ; i++ )
  {
    for( j = 0 ; j < c ; j++ )
    {
      scanf("%d", &score[i][j]);
    }
  }

  for( i = 0 ; i < r ; i++ )
  {
    for( j = 0 ; j < c ; j++ )
    {
      score[i][c] += score[i][j];
      score[r][j] += score[i][j];
    }
    score[r][c] += score[i][c];
  }

  for( i = 0 ; i <= r ; i++ )
  {
    for( j = 0 ; j < c ; j++ )
    {
      printf("%d ", score[i][j]);
    }
    printf("%d\n", score[i][c]);
  }
}



Measured memory_bytes: 2084
#include<iostream>
#include<string>
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<functional>
using namespace std;
int main(void) {
    
   int n,k;
   cin>>n>>k;
   int a[200000];
   int sum=0;
   for(int i=0;i<n;i++){
       cin>>a[i];
   }
    int count=1;
    sort(a,a+n);
    for(int i=0;i<n-1;i++){
        if(a[i]!=a[i+1])count++;
    }
    //cout<<count<<" ";
    int min[count]={0};
    int j=0;
    int i=0;
    while(1){
        if(a[j]==a[j+1])min[i]++;
        else{
            min[i]++;
            i++;
        }
        j++;
        if(i>=count)break;
    }
   
    if(count<=k){
        cout<<"0"<<endl;
        return 0;
    }else{
        
        sort(min,min+count);
        for(int i=0;i<count-k;i++){
            sum+=min[i];
        }
    }
    cout<<sum<<endl;

    return 0;
}

Measured memory_bytes: 1792
#include <cstdint>

template <std::uint_fast64_t mod> class modint {
  using u64 = std::uint_fast64_t;

public:
  u64 v;

  constexpr modint(const u64 x = 0) noexcept : v(x % mod) {}
  constexpr modint operator+(const modint rhs) const noexcept {
    return modint(*this) += rhs;
  }
  constexpr modint operator-(const modint rhs) const noexcept {
    return modint(*this) -= rhs;
  }
  constexpr modint operator*(const modint rhs) const noexcept {
    return modint(*this) *= rhs;
  }
  constexpr modint operator/(const modint rhs) const noexcept {
    return modint(*this) /= rhs;
  }
  constexpr modint &operator+=(const modint rhs) noexcept {
    v += rhs.v;
    if (v >= mod)
      v -= mod;
    return *this;
  }
  constexpr modint &operator-=(const modint rhs) noexcept {
    if (v < rhs.v)
      v += mod;
    v -= rhs.v;
    return *this;
  }
  constexpr modint &operator*=(const modint rhs) noexcept {
    v = v * rhs.v % mod;
    return *this;
  }
  constexpr modint &operator/=(modint rhs) noexcept {
    u64 exp = mod - 2;
    while (exp != 0) {
      if (exp % 2 != 0)
        *this *= rhs;
      rhs *= rhs;
      exp /= 2;
    }
    return *this;
  }
};

#include<iostream>
#include<string>
#include<vector>

int main(){
  using mint=modint<1000000007>;
  
  int k;
  std::cin>>k;
  int n;
  {
  	std::string s;
    std::cin>>s;
    n=s.size();
  }
  int m=n+k+2;
  std::vector<mint> fact(m),ifac(m);
  fact[0]=1;
  for(int i=1;i<m;++i) fact[i]=fact[i-1]*i;
  ifac[m-1]=mint(1)/fact[m-1];
  for(int i=m-1;i>=1;--i) ifac[i-1]=ifac[i]*i;
  const auto binom=[&](int x,int y){return fact[x]*ifac[y]*ifac[x-y];};
  std::vector<mint> pow25(m);
  pow25[0]=1;
  for(int i=1;i<m;++i)pow25[i]=pow25[i-1]*25;
  mint ans=0;
  mint pow26=1;
  for(int i=0;i<=k;++i){
    ans+=pow26*pow25[k-i]*binom(k-i+n-1,n-1);
    pow26*=26;
  }
  std::cout<<ans.v<<std::endl;
}


Measured memory_bytes: 50260
#include<iostream>
#include<iomanip>
#include<cmath>
#include<string>
#include<cstring>
#include<vector>
#include<list>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<stack>
using namespace std;
typedef long long ll;
#define fi first
#define se second
#define mp make_pair
#define rep(i, n) for(int i=0;i<n;++i)
#define rrep(i, n) for(int i=n;i>=0;--i)
const int inf=1e9+7;
const ll mod=1e9+7;
const ll mod1=998244353;
const ll big=1e18;
const double PI=2*asin(1);

int main() {
  ll N, A, B;
  cin>>N>>A>>B;
  ll h[N];
  for(int i=0;i<N;++i) cin>>h[i];
  ll maxh = 0;
  for(int i=0;i<N;++i) maxh = max(maxh, h[i]);
  ll l=0, r=maxh/B+1, m;
  if(r>big) return 0;
  ll tmp;
  while(l<r) {
    m = (l+r)/2;
    tmp = 0;
    for(int i=0;i<N;++i) {
      if(h[i]-B*m<=0) continue;
      if((h[i]-B*m)%(A-B)==0) tmp += (h[i]-B*m)/(A-B);
      else tmp += (h[i]-B*m)/(A-B)+1;
    }
    if(tmp<=m) r = m;
    else l = m+1;
  }
  cout<<l<<endl;
}



Measured memory_bytes: 4412
#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>
#define int long long
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i <= (int)(n); i++)
#define rev(i, n) for(int i = (int)(n - 1); i >= 0; i--)
#define rev1(i, n) for(int i = (int)(n); i > 0; i--)
#define pb push_back
#define all(v) (v).begin(), (v).end()
#define resort(v) sort((v).rbegin(), (v).rend())
#define vi vector<int>
#define vvi vector<vector<int>>
#define vc vector<char>
#define vvc vector<vector<char>>
#define vb vector<bool>
#define vvb vector<vector<bool>>
using ll = long long;
using P = pair<int, int>;
/* ----------------よく使う数字や配列----------------- */
int dx[] = {1,0,-1,0};
int dy[] = {0,1,0,-1};
constexpr ll mod = 1e9+7;
constexpr int inf = INT32_MAX/2;
constexpr ll INF = LLONG_MAX/2;
constexpr long double eps = DBL_EPSILON;
constexpr long double pi = 3.141592653589793238462643383279;
/* ----------------------end----------------------- */
 
/* --------------------テンプレート------------------ */
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;
}
/* ----------------------end----------------------- */
 
/* --------------------ライブラリ-------------------- */
ll fact(int i) {       //階乗
    if (i == 0) return 1;
    return (fact(i - 1)) * i % mod;
}
ll gcd(ll a, ll b) {        //最大公約数
    if(b == 0) return a;
    return gcd(b, a % b); 
}
ll lcm(ll a, ll b) {      //最小公倍数
    return a / gcd(a, b) * b ;
}
int keta(ll n) {        //桁数を求める
    if(n == 0) return 1;
    int count = 0;
    while(n != 0) {
        n /= 10;
        count++;
    }
    return count;
}
ll ketasum(ll n) {    //各桁の和
    ll sum = 0;
    while(n != 0) {
        sum += n % 10;
        n /= 10;
    }
    return sum;
}
/* ----------------------end----------------------- */
int n,k,q;
struct edge {
  int to,cost;
};
vector<vector<edge>> g(100100);
int dist[100100];

void dijkstra() {
  fill(dist,dist+100100,INF);
  dist[k]=0;
  priority_queue<P,vector<P>,greater<P>> pri;
  pri.push({0,k});
  while(!pri.empty()) {
    P p = pri.top();pri.pop();
    int v = p.second;
    if(dist[v]<p.first) continue;
    for(auto e:g[v]) {
      if(chmin(dist[e.to],dist[v]+e.cost)) pri.push({dist[e.to],e.to});
    }
  }
}
signed main() {
  cin >> n;
  rep(i, n-1) {
    int a,b,c;cin >> a >> b >> c;
    a--;b--;
    g[a].push_back({b,c});
    g[b].push_back({a,c});
  }
  cin >> q >> k;
  k--;
  dijkstra();
  rep(i, q) {
    int x,y;cin >> x >> y;
    cout << dist[--x]+dist[--y] << endl;
  }
}

Measured memory_bytes: 14108
#include<iostream>
#include<cstdlib>
#include<cmath>
using namespace std;

int main(){
  int a,b,c,d;
  cin>>a>>b>>c>>d;
  if(abs(c-a)<=d||(abs(b-a)<=d&&abs(b-c)<=d)) cout<<"Yes";
  else cout<<"No";
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = int64_t;
const ll MOD = 998244353;
ll fact[3 * (ll)1e5 + 1] = {1};
ll po(ll a, ll b){return b ? (b & 1 ? a : 1) * po(a * a % MOD, b / 2) % MOD : 1;}
ll comb(ll n, ll k){return fact[n] * po(fact[k] * fact[n - k] % MOD, MOD - 2) % MOD;}
int main(){
    for(ll i = 1; i <= 3 * 1e5; i++) fact[i] = i * fact[i - 1] % MOD;
    ll N, A, B, K;
    cin >> N >> A >> B >> K;
    ll ans = 0;
    for(ll a = 0; a <= N; a++){
        if(K - a * A < 0) continue;
        if((K - a * A) % B) continue;
        ll b = (K - a * A) / B;
        if(max(a, b) > N) continue;
        ll add = comb(N, a) * comb(N, b);
        ans = (ans + add) % MOD;
    }
    cout << ans << endl;
    return 0;
}

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

typedef long long ll;
typedef pair<int, int> P;
#define MOD 1000000007
#define INF (1 << 30)
#define REP(i, m, n) for(int i = (int)m; i < (int)n; ++i)
#define rep(i, n) REP(i, 0, n)


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

    int sx, sy, tx, ty; cin >> sx >> sy >> tx >> ty;
    int dx = tx - sx, dy = ty - sy;
    cout << string(dy, 'U') << string(dx, 'R') << string(dy, 'D') << string(dx, 'L');
    cout << 'L';
    cout << string(dy + 1, 'U') << string(dx + 1, 'R');
    cout << 'D' << 'R';
    cout << string(dy + 1, 'D') << string(dx + 1, 'L');
    cout << 'U' << '\n';
    return 0;
}

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

int main() {
  int A, B;
  cin >> A >> B;
  string S;
  cin >> S;
  bool C[S.length()];
  for (int i = 0; i < A; i++) {
    if (S[i]=='0'||S[i]=='1'||S[i]=='2'||S[i]=='3'||S[i]=='4'||S[i]=='5'||S[i]=='6'||S[i]=='7'||S[i]=='8'||S[i]=='9') {
      C[i] = true;
    }
  }
  for (int i = A + 1; i < A + B + 1; i++) {
    if (S[i]=='0'||S[i]=='1'||S[i]=='2'||S[i]=='3'||S[i]=='4'||S[i]=='5'||S[i]=='6'||S[i]=='7'||S[i]=='8'||S[i]=='9') {
      C[i] = true;
    }
  }
  if (S[A] == '-') {
    C[A] = true;
  }
  bool D = true;
  for (int i = 0; i < S.length(); i++) {
    if (C[i] == false) {
      D = false;
    }
  }
  if (D) {
    cout << "Yes";
  }
  else {
    cout << "No";
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int a[1010][1010];
int d[5] = {1, 0, -1, 0, 1};
int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int h, w; cin >> h >> w;
    queue<pair<int, int>> q;
    for (int i = 0; i < h; i++) {
        string s; cin >> s;
        for (int j = 0; j < w; j++) {
            a[i+1][j+1]++;
            if (s[j] == '#') {
                a[i+1][j+1]++;
                q.push({i+1, j+1});
            }
        }
    }
    int cur = 0;
    while(!q.empty()) {
        auto it = q.front(); q.pop();
        cur = a[it.first][it.second];
        for (int i = 0; i < 4; i++) {
            if (a[it.first+d[i]][it.second+d[i+1]] == 1) {
                a[it.first+d[i]][it.second+d[i+1]] = a[it.first][it.second]+1;
                q.push({it.first+d[i],it.second+d[i+1]});
            }
        }
    }
    cout << cur - 2 << endl;
    return 0;
}

Measured memory_bytes: 12432
#include <bits/stdc++.h>
using namespace std;
#define lli long long int
#define INF 999999999
#define rep(i, n) for(int i = 0;i < n;i++)
#define pb(n) push_back(n)
#define Sort(n) sort(n.begin(), n.end())
#define Rev(n) reverse(n.begin(),n.end())
#define Out(S) cout << S << endl
#define Vecpr vector<pair<lli,lli>>
int main() {
  lli A,B,C,D;
  cin >>A>>B;
  vector<int>P{0,1,2,1,3,1,3,1,1,3,1,3,1};
  if(P[A]==P[B])Out("Yes");
  else Out("No");
}


Measured memory_bytes: 256
import sys
line = []
for i in sys.stdin.readlines():
    line.append(i.rstrip())
data = line.pop(0).split(" ")
num_list = line.pop().split(" ")

def pick_up(num_list):
    use_list = ['0','1','2','3','4','5','6','7','8','9']
    for i in num_list:
        use_list.remove(i)
    return use_list

def advance(n_list, num):
    n_list[len(n_list)-1] += 1
    while((num) in n_list):
        chk = n_list.index(num)
        if chk == 0:
            return [0 for i in range(len(n_list))]
        else:
            n_list[chk] = 0
            n_list[chk-1] += 1
    return n_list

def solve(num, num_list):
    use_list = pick_up(num_list)
    ans_list = [0 for i in range(len(num))]
    count = 0

    while(count < len(use_list)**len(ans_list)):
        ans_num = ""
        for i in ans_list:
            ans_num += use_list[i]
        if (int(ans_num) - int(num) >= 0):
            break
        ans_list = advance(ans_list, len(use_list))
        count += 1

    if count == len(use_list)**len(ans_list):
        ans_num = ""
        if use_list[0] != "0":
            for i in range(len(num)+1):
                ans_num += use_list[0]
        else:
            ans_num += use_list[1]
            for i in range(len(num)):
                ans_num += use_list[0]
    
    return ans_num
    
def main():
    print(solve(data[0], num_list))
    
if __name__ == '__main__':
    main()

Measured memory_bytes: 3188
// 基本テンプレート
// #define _GLIBCXX_DEBUG // for STL debug (optional)
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
using namespace std;

#define debug(...) fprintf(stderr, __VA_ARGS__)
#define int long long int
 
template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}
 
typedef pair<int, int> pii;
typedef long long ll;
 
int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
const ll INF = 1001001001001001LL;
const ll MOD = 1000000007LL;

int h[100010];
signed main() {
    int N, K; cin >> N >> K;
    for(int i=0; i<N; i++) {
        cin >> h[i];
    }
    sort(h, h+N);

    int ans = INF;
    for(int i=K-1; i<N; i++) {
        chmin(ans, h[i] - h[i-K+1]);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 1024
import java.util.*;
class Main{
    public static void main(String[] args){
	Scanner stdIn = new Scanner(System.in);
        int P = stdIn.nextInt();
	int Q = stdIn.nextInt();
	int R = stdIn.nextInt();
	int[] a={P,Q,R};
	Arrays.sort(a);
	System.out.println(a[0]+a[1]);
    }
}

Measured memory_bytes: 23892
#include <bits/stdc++.h>
using namespace std;
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
#define all(x) (x).begin(),(x).end()
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; }
typedef long long ll;
const long long INF = 1LL << 60;
typedef pair<ll, int> P;
int main()
{
    int X, Y, A, B, C;
    cin >> X >> Y >> A >> B >> C;
    priority_queue<P> que;
    rep(i, A) {
        ll q;
        cin >> q;
        que.push({q, 1});
    }
    rep(i, B) {
        ll q;
        cin >> q;
        que.push({q, 2});
    }
    rep(i, C) {
        ll q;
        cin >> q;
        que.push({q, 0});
    }

    int sum = 0;
    ll ans = 0;
    int a = 0, b = 0, c = 0;
    while (sum < X + Y) {
        ll d = que.top().first;
        int k = que.top().second;
        que.pop();
        if (k == 1) {
            if (a < X) {
                ans += d;
                sum++;
                a++;
            }
        }
        else if (k == 2) {
            if (b < Y) {
                ans += d;
                sum++;
                b++;
            }
        }
        else {
            sum++;
            ans += d;
        }
    }

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

Measured memory_bytes: 11572