akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

int main() {
  int N;
  cin >> N ;
  
  for(int i=0; i < N; i++){
    string s;
    cin >> s;
    
    if( s =="Y"){
      cout << "Four" <<endl;
      break;
    }
    if(i == (N-1)){
      cout << "Three" <<endl;
    }
  }
  
}

Measured memory_bytes: 256
import numpy as np

def main():
        A, B, H, M = map(int, input().split())

        A_angle = 2*np.pi*(H+M/60)/12
        B_angle = 2*np.pi*M/60

        theta = abs(A_angle-B_angle)

        ans = np.sqrt( A*A + B*B - 2*A*B*np.cos(theta) )

        print("{}".format(ans))

if __name__=="__main__":
        main()

Measured memory_bytes: 27200
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a) for(int i = 0; i < (a); i++)
#define ALL(a) (a).begin(),(a).end()
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1e9;
const int MOD = 1e9 + 7;

signed main(){
    int n,k;
    cin >> n >> k;
    int d;
    bool judge[11] = {};
    REP(i,k){
        cin >> d;
        judge[d] = true;
    }
    while(true){
        int tmp = n;
        while(tmp > 0){
            if(judge[tmp % 10] == true){
                break;
            }
            tmp /= 10;
        }
        if(tmp == 0){
            cout << n << endl;
            break;
        }
        n++;
    }
}

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

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

    ll cnt = n / (a + b);
    ll ans = cnt * a;

    ll rest = n - (a + b) * cnt;
    if (rest <= a)
        ans += rest;
    else
        ans += a;

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


Measured memory_bytes: 256
use std::io::{stdin, Read, StdinLock};
use std::str::FromStr;
use std::iter::FromIterator;
use std::cmp::max;

fn main() {
    let cin = stdin();
    let mut scan = Scanner::new(cin.lock());
    let n = scan.read::<usize>();
    let mut a = scan.readn::<i64>(n);
    a.sort();
    a.reverse();
    let mut ret = 0;
    if n % 2 == 0 {
        let mut k = vec![2;n];
        k[n/2-1] = 1;
        k[n/2] = -1;
        for i in n / 2 + 1..n {
            k[i] = -2;
        }
        for i in 0..n {
            ret += a[i] * k[i];
        }
    } else {
        let mut k = vec![2;n];
        k[n/2-1] = 1;
        k[n/2] = 1;
        for i in n / 2 + 1..n {
            k[i] = -2;
        }
        let mut p = 0;
        for i in 0..n {
            p += a[i] * k[i];
        }
        k[n/2-1] = 2;
        k[n/2] = -1;
        k[n/2+1] = -1;
        let mut q = 0;
        for i in 0..n {
            q += a[i] * k[i];
        }
        ret = max(p, q);
    }
    println!("{}", ret);
}

// region template
#[allow(dead_code)]
fn iu(i: i64) -> usize { i as usize }

#[allow(dead_code)]
fn ui(i: usize) -> i64 { i as i64 }

#[allow(dead_code, deprecated)]
fn join<T: std::fmt::Display>(slice: &[T], sep: &str) -> String {
    let strings = slice.iter().map(|t| format!("{}", t)).collect::<Vec<_>>();
    strings.connect(sep)
}

#[allow(dead_code)]
fn arr<'a, S, T>(n: usize, mut f: S) -> Vec<T> where S: FnMut(usize) -> T + 'a {
    (0..n).map(|i| f(i)).collect::<Vec<T>>()
}

struct Scanner<'a> {
    cin: StdinLock<'a>,
}

#[allow(dead_code)]
impl<'a> Scanner<'a> {
    fn new(cin: StdinLock<'a>) -> Scanner<'a> {
        Scanner { cin: cin }
    }

    fn read1<T: FromStr>(&mut self) -> Option<T> {
        let token = self.cin.by_ref().bytes().map(|c| c.unwrap() as char)
            .skip_while(|c| c.is_whitespace())
            .take_while(|c| !c.is_whitespace())
            .collect::<String>();
        token.parse::<T>().ok()
    }

    fn read<T: FromStr>(&mut self) -> T {
        self.read1().unwrap()
    }

    fn readn<T: FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.read::<T>()).collect()
    }

    fn chars(&mut self) -> Vec<char> {
        self.read::<String>().chars().collect()
    }
}
// endregion

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

int main() {
	int a[3];cin>>a[0]>>a[1]>>a[2];
	int ans=0;
	if((a[0]%2+a[1]%2+a[2]%2)==1){//1odd
		ans=1;
		for(int i=0;i<3;i++){
			if(a[i]%2==0){
				a[i]+=1;
			}
		}
	}else if((a[0]%2+a[1]%2+a[2]%2)==2){//2odd
		ans=1;
		for(int i=0;i<3;i++){
			if(a[i]%2){
				a[i]+=1;
			}
		}
	}
	int max=0;
	for(int i=0;i<3;i++){
		if(a[i]>max){
			max=a[i];
		}
	}
	for(int i=0;i<3;i++){
		ans+=(max-a[i])/2;
	}
	cout<<ans<<endl;

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
  string S; cin >> S;
  int t = 0;
  for(int i = 0; i < S.size(); i++) {
    for(int j = 1; j <= S.size() - i; j++) {
      if(regex_match(S.substr(i, j), regex("(A|C|G|T)*"))) t = max(j, t);
    }
  }
  cout << t << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
vector<int>v[200005];
int main()
{
    long int n,a;
    cin>>n;
    for(int i=0;i<n-1;i++) {
        cin>>a;
        v[a-1].push_back(i);
    }
    for(int i=0;i<n;i++){
        cout<<v[i].size()<<endl;
    }
    return 0;
}


Measured memory_bytes: 14528
# coding: utf-8
# Your code here!
a=list(input())
for i in range(4):
    a[i]=int(a[i])
cnt=[]
#print(a)
for i in range(2**3):
    su=a[0]
    cnt=[]
    for j in range(3):
        if (i>>j)&1==1:
            su+=a[j+1]
            cnt.append('+')
        elif (i>>j)&1==0:
            su-=a[j+1]
            cnt.append('-')
        #print(su,cnt)
    if su==7:
        print(str(a[0])+cnt[0]+str(a[1])+cnt[1]+str(a[2])+cnt[2]+str(a[3])+'='+'7')
        exit()
            
    

Measured memory_bytes: 38256
n, m = map(int, input().split())
x = list(map(int, input().split()))
x.sort()

if n >= m:
    print(0)
else:
    diff = [x[i+1]-x[i] for i in range(m-1)]
    diff.sort()
    for i in range(n-1):
        diff.pop()
    print(sum(diff))

Measured memory_bytes: 13960
#include <bits/stdc++.h>    
using namespace std;
#define fastio() ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define pb  push_back
#define show(x) cout<<(#x)<<" : "<<x<<endl;
#define ll  long long
#define int long long
#define ld  long double
#define fill(a,val) memset(a,val,sizeof(a))
#define mp  make_pair
#define ff  first
#define ss  second
#define pii pair<ll,ll>
#define sq(x) ((x)*(x))
#define all(v) v.begin(),v.end()
#define fone for(i=0;i<n;i++)
#define endl "\n"
const ll MOD     = 1000*1000*1000+7;
const ll INF     = 1ll*1000*1000*1000*1000*1000*1000 + 7;
const ll MOD2    = 998244353;
const ll N          = 5000*100+1;
const ll N2      = 1000*1000+5;
const ld PI  = 3.14159265;
const ll R   = 250;
ll gcd(ll a, ll b){if(!b)return a;return gcd(b, a % b);} 
ll power(ll x,ll y,ll p){ll res=1;x%=p;while(y>0){if(y&1)res=(res*x)%p;y=y>>1;x=(x*x)%p;}return res;} 
bool sortbysec(const pair<int,int> &a, const pair<int,int> &b) 
{ return (a.second < b.second); }

void dfs(int node, vector<int> adj[], int dp[], bool vis[]) 
{
    vis[node] = true; 

    for (int i = 0; i < adj[node].size(); i++) { 
        if (!vis[adj[node][i]]) 
            dfs(adj[node][i], adj, dp, vis); 
        dp[node] = max(dp[node], 1 + dp[adj[node][i]]); 
    } 
} 
void addEdge(vector<int> adj[], int u, int v) 
{ 
    adj[u].push_back(v); 
} 
  
signed main ()
{
  fastio();

  int n,m,l,r;
   cin>>n>>m;
   int dp[n+1];
   bool vis[n+1];
   fill(dp,0);
   fill(vis,false);
   vector<int> adj[n + 1]; 
   for(int i=0;i<m;i++)
   {
    cin>>l>>r;
    addEdge(adj,l,r);
  }
   
   for(int i=1;i<=n;i++)
   {
      if(!vis[i])
      {
        dfs(i,adj,dp,vis);
      }
   }
   int ans=1;

   for(int i=1;i<=n;i++)
   {
    ans=max(ans,dp[i]);
   }
   cout<<ans<<endl;


  

  return 0;
}


Measured memory_bytes: 9984
from heapq import heappush, heappop
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**9)

INF = float('inf')

N, M = map(int, input().split())
adjL = [[] for _ in range(N)]
for _ in range(M):
    a, b = map(int, input().split())
    a, b = a-1, b-1
    adjL[a].append(b)
    adjL[b].append(a)

# 単一始点最短経路を求める（Dijkstra法）
def Dijkstra(adjList, vSt):
    numV = len(adjList)
    numUsed = 0
    costs = [INF] * numV
    costs[vSt] = 0
    prevs = [None] * numV
    PQ = []
    heappush(PQ, (0, vSt))
    while PQ:
        cNow, vNow = heappop(PQ)
        if cNow > costs[vNow]: continue
        numUsed += 1
        if numUsed == numV: break
        for v2 in adjList[vNow]:
            c2 = cNow + 1
            if c2 < costs[v2]:
                costs[v2] = c2
                prevs[v2] = vNow
                heappush(PQ, (c2, v2))
    return (costs, prevs)

costs, prevs = Dijkstra(adjL, 0)

#print('costs:', costs)
#print('prevs:', prevs)

print('Yes')
print('\n'.join(map(lambda x: str(x+1), prevs[1:])))


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

using namespace std;

void solve() {
	int N, M, Q;
	cin >> N >> M >> Q;
	int x[N + 1][N + 1] = { };
	for (int i = 1; i <= M; ++i) {
		int L, R;
		cin >> L >> R;
		x[L][R]++;
	}

	for (int i = 1; i <= N; ++i) {
		for (int j = 1; j <= N; ++j) {
			x[i][j] += x[i][j - 1];
//			cout << "(i,j):(" << i << "," << j << ") c(i,j):" << c[i][j] << endl;
		}
	}
	for (int j = 1; j <= N; ++j) {
		for (int i = 1; i <= N; ++i) {
			x[i][j] += x[i - 1][j];
//			cout << "(i,j):(" << i << "," << j << ") c(i,j):" << c[i][j] << endl;
		}
	}

	/* calculate */
	for (int i = 0; i < Q; ++i) {
		int ans = 0;
		int p, q;
		cin >> p >> q;
		ans = x[q][q] - x[p - 1][q] - x[q][p - 1] + x[p - 1][p - 1];
		cout << ans << endl;
	}
}

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


Measured memory_bytes: 1920
from collections import deque, Counter as cnt
from collections import defaultdict as dd
from operator import itemgetter as ig
from bisect import bisect_right as bsr
from math import factorial, ceil, floor
import sys
sys.setrecursionlimit(1000000)

# お約束
args = None
INF = float("inf")
MOD = int(1e9 + 7)


def input(*ps):
    if type(ps[0]) is list:
        return [input(*ps[0][:-1]) for _ in range(ps[0][-1])]
    elif len(ps) == 1:
        return ps[0](next(args))
    else:
        return [p(next(args)) for p in ps]


def nlist(n, v):
    if not n:
        return [] if type(v) is list else v
    return [nlist(n[1:], v) for _ in range(n[0])]

# エントリーポイント


def main():
    N, K = input(int, int)
    ans = [N % K]
    for _ in range(100):
        ans.append(abs(ans[-1] - K))
    print(min(ans))
    return


if __name__ == '__main__':
    args = iter(sys.stdin.read().split())
    main()


Measured memory_bytes: 3436
f=lambda:[list(map(int,input().split())) for _ in range(n)]
n=int(input())
llf,llp=f(),f()
a=-10**9
import itertools as it
for t in it.product([0,1],repeat=10):
  if sum(t):
    lc=[sum(t[i]*lf[i] for i in range(10)) for lf in llf]
    a=max(a,sum(llp[i][lc[i]] for i in range(n)))
print(a)

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


int main() {
    int a,b,c,k,sol=0;
    cin >> a >> b >> c >> k;
    if (a<k) {
        sol+=a;
        k-=a;
    }
    else {
        sol+=k;
        k=0;
    }
    k-=b;
    if (k>0) {sol-=k;}
    cout << sol;


}


Measured memory_bytes: 3588
N = int(input())
A = list(map(int, input().split()))
Q = int(input())
bc = [list(map(int, input().split())) for _ in range(Q)]

mem = [0]*(10**5)

sum = 0
for i in A:
    mem[i-1] += 1
    sum += i

for q in range(Q):
    b = bc[q][0]
    if mem[b-1] != 0:
        c = bc[q][1]
        num = mem[b-1]
        mem[c-1] += num
        mem[b-1] = 0
        sum = sum - num*b + num*c
    print(sum)



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

const long long INF = 1e18;

int main() {
    long long n;
    cin >> n;
    long long min_s = INF;
    for (long long i = 1; i*i <= 1e12; i++) {
        if (n%i == 0) {
            min_s = min(min_s, i+n/i);
        }
    }
    long long ans = min_s - 2;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Diagnostics;

namespace AtCoder
{
    class Program
    {
        private static string Read() { return Console.ReadLine(); }
        private static int ReadInt() { return int.Parse(Read()); }
        private static long ReadLong() { return long.Parse(Read()); }
        private static double ReadDouble() { return double.Parse(Read()); }
        private static int[] ReadInts() { return Array.ConvertAll(Read().Split(), int.Parse); }
        private static long[] ReadLongs() { return Array.ConvertAll(Read().Split(), long.Parse); }
        private static double[] ReadDoubles() { return Array.ConvertAll(Read().Split(), double.Parse); }

        static void Main(string[] args)
        {
            int N = ReadInt();
            int[] W = ReadInts();
            int min = int.MaxValue;
            for (int i = 0; i < N; ++i)
            {
                int a = W.Take(i).Sum();
                int b = W.Skip(i).Sum();
                min = Math.Min(Math.Abs(a - b), min);
            }
            Console.WriteLine(min);
        }
    }
}


Measured memory_bytes: 13268
#include <stdio.h>
   
int main()
{
    int n;
   
    scanf("%d", &n);
   
    int a[n], i;
    long int sum = 0;
    for (i = 0; i < n; i++) {
        scanf("%d", &a[i]);
        sum += a[i];
    }
   
    int j;
    for (i = 0; i < n; i++) {
        for (j = 0; j < n - i - 1; j++) {
            if (a[j] > a[j + 1]) {
                int tmp = a[j];
                a[j] = a[j + 1];
                a[j + 1] = tmp;
            }
        }
    }
   
    printf("%d %d %ld\n", a[0], a[n - 1], sum);
   
    return 0;
}

Measured memory_bytes: 636
W, H, w, h, x, y = map(lambda x: int(x)*2, raw_input().split())
X1 = -W/2
X2 =  W/2
Y1 = -H/2
Y2 =  H/2
x1 = max(x - w/2, X1)
y1 = max(y - h/2, Y1)
x2 = min(x + w/2, X2)
y2 = min(y + h/2, Y2)
mx = (x1 + x2) / 2.0
my = (y1 + y2) / 2.0
print "%.10f" % (my / mx)



Measured memory_bytes: 4688
#include <iostream>
#include <vector>
#include <array>
#include <string>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <tuple>
#include <bitset>
#include <memory>
#include <cmath>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <numeric>
#include <climits>
#include <cfloat>

int cal_max_length(int left, int right, const std::string& str, std::vector<std::vector<int>>& memo) {
	if (right == str.size()) return 0;
	if (memo[left][right - left - 1] >= 0) return memo[left][right - left - 1];
	if (str[left] != str[right]) return memo[left][right - left - 1] = 0;
	auto succ = cal_max_length(left + 1, right + 1, str, memo);
	if (left + succ != right) return memo[left][right - left - 1] = succ + 1;
	else return memo[left][right - left - 1] = succ;
}
int main() {
	int n; std::cin >> n;
	std::string str; std::cin >> str;
	std::vector<std::vector<int>> memo(n);
	for (auto i = 0; i < n; ++i) {
		memo[i] = std::vector<int>(n - i - 1, -1);
	}
	int max_length = 0;
	for (auto i = 0; i < n - 1; ++i) {
		for (auto j = i + 1; j < n; ++j) {
			max_length = std::max(max_length, cal_max_length(i, j, str, memo));
		}
	}
	std::cout << max_length << std::endl;
}


Measured memory_bytes: 49536
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define MOD 1000000007
#define INF 1LL<<30
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()


int main() {
    int n,m;
    cin>>n>>m;
    vector<pair<ll,int>> v;
    rep(i,n){
        ll a;
        cin>>a;
        v.push_back({a,1});
    }
    rep(i,m){
        int b;
        ll c;
        cin>>b>>c;
        v.push_back({c,b});
    }
    sort(all(v));
    reverse(all(v));

    int cnt=0;
    ll ans=0;
    rep(i,n+m){
        ans+=min(v[i].second,n-cnt)*v[i].first;
        cnt+=min(v[i].second,n-cnt);
    }

    cout<<ans<<endl;
}



Measured memory_bytes: 6512
concatAltenatively :: String -> String -> String
concatAltenatively "" ""     = ""
concatAltenatively (a:as) (b:bs) = a:b:concatAltenatively as bs

main = do
    n <- getLine
    [s, t] <- words <$> getLine
    let ans = concatAltenatively s t
    putStrLn ans


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

using namespace std;

#define INF 1001000100010001000
#define MOD 1000000007
#define EPS 1e-10
#define int long long
#define rep(i, N) for (int i = 0; i < N; i++)
#define Rep(i, N) for (int i = 1; i < N; i++)
#define For(i, a, b) for (int i = (a); i < (b); i++)
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define pii pair<int, int>
#define vi vector<int>
#define vvi vector<vi >
#define vb vector<bool>
#define vvb vector<vb >
#define vp vector< pii >
#define all(a) (a).begin(), (a).end()
#define Int(x) int x; cin >> x;
#define int2(x, y) Int(x); Int(y);
#define int3(x, y, z) Int(x); int2(y, z);
#define in(x, a, b) ((a) <= (x) && (x) < (b))
#define fir first
#define sec second
#define ffir first.first
#define fsec first.second
#define sfir second.first
#define ssec second.second
#define Decimal fixed << setprecision(10)

//int dxy[5] = {0, 1, 0, -1, 0};
// cmd

int n;
int a[50], b[50];

bool solve(int mask, int targ)
{
    vvi dp(n+1, vi(51, 0));
    rep(i, n) {
        dp[i][a[i]] = 1;
    }

    for (int i = 50; i > 0; i--) {
        if ((1ll << i) & mask || i <= targ) {
            rep(j, n) {
                rep(k, 51) {
                    if (dp[j][k]) dp[j][k % i] = 1;
                }
            }
        }
    }

    rep(i, n) {
        if (!dp[i][b[i]]) return false;
    }
    return true;
}

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

    cin >> n;
    rep(i, n) {
        cin >> a[i];
    }
    rep(i, n) {
        cin >> b[i];
    }

    if (!solve(0, 50)) {
        std::cout << -1 << std::endl;
        return 0;
    }

    int mmn = 0;
    for (int i = 50; i > 0; i--) {
        if (!solve(mmn, i-1)) {
            mmn |= 1ll << i;
        }
    }

    int ans = 0;
    rep(i, 50) {
        ans += mmn & (1ll << i);
    }

    std::cout << ans << std::endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ALL(A) (A).begin(), (A).end()
#define ll long long
#define rep(i, n) for (int i = 0; i < (n); i++)

const ll mod = 1e9 + 7;
const ll INF = -1 * ((1LL << 63) + 1);
const int inf = -1 * ((1 << 31) + 1);

using namespace std;

int main(void){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(20);
    ll N,x,sum = 0;
    cin >> N >> x;
    vector<ll> a(N);
    rep(i,N){
        cin >> a[i];
        sum += a[i];
    }
    vector<ll> mn = a;
    ll ans = sum;
    rep(i,N+1){
        ll t = i * x;
        // i 回魔法を使うとすると各jについて
        rep(j,N){
            mn[j] = min(mn[j],a[(j - i + N) % N]);
            t += mn[j];
        }
        ans = min(ans,t);
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int INF = 2147483647;
using ll = long long;

int main(){
    ll n,m;
    cin >> n >> m;
    vector<ll> a(m);
    for (int i=0;i<m;i++){
        cin >> a.at(i);
    }
    ll sum=0;
    for (int i=0;i<m;i++){
        sum+= a.at(i);
    }
    if (n-sum<0){
        cout << -1 << endl;
        return 0;
    }
    cout << n-sum << endl;
    return 0;
}

Measured memory_bytes: 3680
#include <iostream>
#include <algorithm>
#include <string>
#include <math.h>
#include<iomanip>
#include <cstdint>
#include <sstream>
#include <map>
#include<vector>

using namespace std;
typedef long long ll;

ll mx,sum,mn=1e8,cnt;

int main(){
	ll w,h,x,y;
	cin>>w>>h>>x>>y;
	double ans=(w*h)/2.0;
	if(w-x==x && h-y==y){
		cout<<fixed<<setprecision(6)<<(double)x*h;
		cout<<" 1"<<endl;
	}
	else if(w-x==x){
		cout<<fixed<<setprecision(6)<<(double)x*h;
		cout<<" 0";
	}
	else if(w-y==y){
		cout<<fixed<<setprecision(6)<<(double)y*h;
		cout<<" 0";
	}
	else {
		cout<<fixed<<setprecision(6)<<(double)ans;
		cout<<" 0";
	}
	
}



Measured memory_bytes: 256
import java.util.*;
public class Main{

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc = new Scanner(System.in);
		
		String s = sc.next();
		
		for(int i = 97; i<=97+25; i++) {
			char c = (char) i;
			
			for(int j = 0; j<s.length(); j++) {
				if(s.charAt(j) == c) {
					break;
				}
				if(j == s.length()-1) {
					System.out.println(c);
					System.exit(0);
				}
			}
			
		}
		
		System.out.println("None");
	}

}


Measured memory_bytes: 25428
import java.util.Scanner;

//Subdivide The Land
public class Main{

	static int[] size;
	static int[][] pos;
	static int[][] assign;
	static int w, h, n;
	static int c;
	static int[][] ans;
	
	static boolean col(int k1, int k2){
		if(assign[k2][0]<assign[k1][2]&&assign[k1][0]<assign[k2][2] && assign[k2][1]<assign[k1][3]&&assign[k1][1]<assign[k2][3])
			return true;
		return false;
	}
	
	static void f(int k){
		if(k==n+1){
			c++;
			if(c==2)return;
			for(int x=1;x<=n;x++){
				for(int i=assign[x][0];i<assign[x][2];i++){
					for(int j=assign[x][1];j<assign[x][3];j++){
						ans[i][j] = x;
					}
				}
			}
			return;
		}
		if(c>=2)return;
		int s = size[k];
		for(int x=1;x<=s;x++){
			if(s%x!=0)continue;
			for(int lj=pos[k][1]+1-x;lj<=pos[k][1];lj++){
				if(lj<0||lj>w)continue;
				for(int li=pos[k][0]+1-s/x;li<=pos[k][0];li++){
					if(li<0||li>h)continue;
					int rj = lj+x;
					int ri = li+s/x;
					if(rj>w)continue;
					if(ri>h)continue;
					assign[k][0] = li;
					assign[k][1] = lj;
					assign[k][2] = ri;
					assign[k][3] = rj;
					boolean col = false;
					for(int d=1;d<k;d++){
						if(col(d, k)){
							col = true;
							break;
						}
					}
					if(col)continue;
//					System.out.println("ASSIGN: " + k + " ("+li+","+lj+") ("+ri+","+rj+")");
					f(k+1);
				}
			}
		}
	}
	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		while(true){
			w = sc.nextInt();
			h = sc.nextInt();
			n = sc.nextInt();
			if((w|h|n)==0)break;
			size = new int[n+1];
			pos = new int[n+1][2];
			for(int i=0;i<n;i++){
				int b = sc.nextInt();
				int k = sc.nextInt();
				size[b] = k;
			}
			int[][] m = new int[h][w];
			for(int i=0;i<h;i++){
				for(int j=0;j<w;j++){
					int x = sc.nextInt();
					m[i][j] = x;
					if(x>0){
						pos[x][0] = i;
						pos[x][1] = j;
					}
				}
			}
			assign = new int[n+1][4];
			c = 0;
			ans = new int[h][w];
			f(1);
			if(c!=1)System.out.println("NA");
			else {
				for(int i=0;i<h;i++){
					for(int j=0;j<w;j++){
						if(j>0)System.out.print(" ");
						System.out.print(ans[i][j]);
					}
					System.out.println();
				}
			}
		}
	}
}

Measured memory_bytes: 13000
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <iostream>
#include <queue>
#include <string>
using namespace std;
int main(){
  int N,L;
  priority_queue<string,vector<string>,greater<string> > que;
  scanf("%d %d",&N,&L);
  for(int i=0;i<N;i++){
    string str;
    cin>>str;
    que.push(str);
  }
  while(que.size()){
    cout<<que.top();
    que.pop();
  }
  printf("\n");
  return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(){
  string a,b,c;
  cin>>a>>b>>c;
  
  a[0]-=32;
  b[0]-=32;
  c[0]-=32;
  cout<<a[0]<<b[0]<<c[0]<<endl;
  return 0;
}

Measured memory_bytes: 3592
#include <iostream>
#include <string>
#include <cstring>
#include <vector>
#include <algorithm>
#include <set>
#include <stack>
#include <deque>
#include <cmath>
#include <map>
using namespace std;
using ll = long long;
#define rep(i, n) for (ll i = 0; i < n; i++)
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}

int main() {
    ll n;
    cin >> n;
    vector<ll> h(n);
    rep(i, n) cin >> h[i];
    ll ans=0;
    while(true){
        if(*max_element(h.begin(), h.end()) == 0) break;
        rep(i, n) {
            if(h[i]==0) continue;
            for(ll j=i; j<n; j++) {
                if(h[j]==0) break;
                h[j]--;
            }
            break;
        }
        ans++;
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#pragma GCC optimize(2)
#define ex_0 return 0
#include<bits/stdc++.h>
using namespace std;
inline int read()
{
   int s=0,w=1;
   char ch=getchar();
   while(ch<'0'||ch>'9'){if(ch=='-')w=-1;ch=getchar();}
   while(ch>='0'&&ch<='9') s=s*10+ch-'0',ch=getchar();
   return s*w;
}

int main()
{
	int n=read(),t,x,y;
	while(n--){
		t=read(),x=read(),y=read();
		if(x+y>t){
	    cout<<"No"<<endl;
	    ex_0;
		}
		int bo1=((x+y)%2),bo2=(t%2);
		if(bo1!=bo2){
			cout<<"No"<<endl;
			ex_0;
		}
	}
	cout<<"Yes"<<endl;
	ex_0;
}


Measured memory_bytes: 256
n = int(input())
s = input()
S = [i for i in s]
a = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
for i, value1 in enumerate(S):
    for j, value2 in enumerate(a):
        if value1 == value2:
            if j+n >= len(a):
                S[i] = a[j+n-len(a)]
                break
            else:
                S[i] = a[j+n]
                break    
S = "".join(S)
print(S)

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

using ll = long long;
using ull = unsigned long long;
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
#define rep(i, n) REP(i, 0, n)
#define rep_rev(i, n) for (int (i) = (int)(n) - 1 ; (i) >= 0 ; --(i))
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for(int i = x; i < n; i++)
#define all(x) (x).begin(),(x).end()
ll t1,t2,t3;
const ll mod = 1000000007;
const int INF = 1e9;
const ll INFLONG = 1e18;

int main(){
    ll n;
    cin >> n;
    vector<ll> a(n),b(n);
    vector<ll> vec1(n),vec2(n);
    rep(i,n){
        cin >> a[i];
        vec1[a[i]-1]++;
    }
    rep(i,n){
        cin >> b[i];
        vec2[b[i]-1]++;
    }
    bool can = true;
    rep(i,n){
        if(vec1[i]+vec2[i] > n){
            can = false;
        }
    }
    if(can){
        cout << "Yes" << endl;
        int piv1 = 0,piv2 = n-1;
        rep(i,n){
            if(a[i] == b[i]){
                bool fin = false;
                while(!fin){
                    while(!fin && piv1 < i){
                        if(b[i] != b[piv1] && b[i] != a[piv1]){
                            swap(b[i],b[piv1]);
                            fin = true;
                        }
                        piv1++;
                    }
                    while(!fin && i < piv2){
                        if(b[i] != b[piv2] && b[i] != a[piv2]){
                            swap(b[i],b[piv2]);
                            fin = true;
                        }
                        piv2--;
                    }
                    if(!fin){
                        piv1 = 0;
                        piv2 = n-1;
                    }
                }
            }
            // rep(i,n){
            //     cout << b[i] << " ";
            // }
            // cout << endl;
        }
        rep(i,n){
            cout << b[i] << " ";
        }
        cout << endl;
    }else{
        cout << "No" << endl;
    }
}


Measured memory_bytes: 9588
import java.io.PrintWriter

val pw = PrintWriter(System.out)

fun main(args : Array<String>) {
    func()
    pw.flush()
}

fun func() {
    val x = nextInt()
    val a = nextInt()
    val b = nextInt()
    println((x - a)%b)
}

fun next() = readLine()!!
fun nextInt() = next().toInt()

fun println(value : Any) {
    pw.println(value)
}

Measured memory_bytes: 33688
#include <bits/stdc++.h>
using namespace std;
int main() {
    /* 自然数 */
  int num;
  cin >> num;
  int N = num;
  /* 各桁の数字 */
  int dig;
 
  /* 和 */
  int sum = 0;
 
  /* 自然数の各桁の数字の和を計算 */
  
  while(num > 0) {
    dig = num % 10;
    sum = sum + dig;
    num = num / 10;
  }
  if (N % sum == 0) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
}

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

alias Tuple!(int, "id", int, "ans", int, "rank") Team;



void main() {
    Team[] team;
    Team[] ranking;
    int i = 0;

    while (true) {
        int[] input = readln.chomp.split(",").map!(to!int).array;
        if (input == [0,0]) break;

        team ~= Team(input[0], input[1], 0);
    }

    sort!((a, b) => a.ans > b.ans)(team);
    auto prev = team[0].ans;
    auto rankOfNow = 1;
    foreach(ref t; team[0..$]) {
        if (prev > t.ans) rankOfNow++;
        t.rank = rankOfNow;
        prev = t.ans;
    }

    while (true) {
        string number = readln.chomp;
        if (stdin.eof()) break;
        foreach(t; team) if (number.to!int == t.id) writeln(t.rank);
    }
}

Measured memory_bytes: 1084
using System;

namespace _116_ABC
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] Input = Read();
            uint AB = uint.Parse(Input[0]);
            uint BC = uint.Parse(Input[1]);

            Console.WriteLine(AB * BC * 0.5);

        }

        static string[] Read()
        {
            return Console.ReadLine().Split(' ');
        }
    }
}


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

int main(){
    deque<pair<string,int> > deq;
    int N,q;cin>>N>>q;

    string a;int b;
    pair<string,int> p;
    for(int i=0;i<N;i++){
        cin>>a>>b;
        p.first=a;p.second=b;
        deq.push_back(p);
    }

    int ans=0;
    while(deq.size()!=0){
        if(deq.front().second<=q){
            ans+=deq.front().second;
            cout<<deq.front().first<<" "<<ans<<endl;
            deq.pop_front();
        }
        else{
            ans+=q;
            deq.front().second-=q;
            p.first=deq.front().first;p.second=deq.front().second;
            deq.push_back(p);
            deq.pop_front();
        }
    }
    
    return 0;
}


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

int main(){
  long long int A, B, N, ans = 0, score = 0 ;
  cin >> A >> B >> N ;
  if(N >= B){
    ans = (A * (B-1) ) / B ;
  }
  else{
    ans = A * N / B ;
  }
  cout << ans << endl ;
  return 0 ;
}  

Measured memory_bytes: 3676
n,m=map(int,input().split())
a=list(map(int,input().split()))
b=[[a[i],1] for i in range(n)]
for i in range(m):
    x,y=map(int,input().split())
    b.append([y,x])
b.sort(reverse=True)
ans=0
cnt=n
for i in range(len(b)):
    use=min(b[i][1],cnt)
    ans+=use*b[i][0]
    cnt-=use
print(ans)

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

int main() {
  string S;
  cin >> S;

  for (int i = 0; i < 1 << 4; ++i) {
    string T;
    for (int j = 0; j < 4; ++j) {
      if (i & 1 << j)
        T += 'A';
      if (j == 0)
        T += "KIH";
      if (j == 1)
        T += 'B';
      if (j == 2)
        T += 'R';
    }

    if (S == T) {
      cout << "YES" << endl;
      return 0;
    }
  }

  cout << "NO" << endl;
}

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

Measured memory_bytes: 256
while True:
    H, W = map(int, input().split())
    if (H, W) == (0,0):
        break
    for h in range(H):
        odd = h % 2
        for i in range(W):
            if (i + odd) % 2 == 0:
                print('#', end = '')
            else:
                print('.', end = '')
        print('')
    print('')



Measured memory_bytes: 7012
#include<bits/stdc++.h>
#define LL long long
#define clr(x,i) memset(x,i,sizeof(x))
using namespace std;
const int N=305;
int n;
LL mp[N][N],f[N][N];
LL sum;
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
	  for(int j=1;j<=n;j++)
	    scanf("%lld",&mp[i][j]);
	memcpy(f,mp,sizeof(f));
	for(int k=1;k<=n;k++)
	  for(int i=1;i<=n;i++)
	    for(int j=1;j<=n;j++)
	      f[i][j]=min(f[i][j],f[i][k]+f[k][j]);
	for(int i=1;i<=n;i++)
	  for(int j=1;j<=n;j++)
	    if(f[i][j]!=mp[i][j])
	      {puts("-1");return 0;}
//	for(int i=1;i<=n;i++)
//	  for(int j=i+1;j<=n;j++)
//	    sum+=f[i][j];
//	cout<<sum<<endl;
	
	  for(int i=1;i<=n;i++)
	    for(int j=i+1;j<=n;j++){
	    	bool vis=1;
	    	for(int k=1;k<=n;k++)
	        if(k!=i&&k!=j)
	         if(f[i][j]==f[i][k]+f[k][j])
	          {vis=0;break;}
	        if(vis) sum+=f[i][j];
	    }
	      
	cout<<sum<<endl;
	return 0;
}


Measured memory_bytes: 1664
#include <iostream>
#include <vector>
#include <cmath>
#include <iomanip>
#include <queue>
#include <algorithm>
#define shosu(x) fixed<<setprecision(x)
using namespace std;
typedef pair<int,int> P;
const int inf=1<<30;
const double pi=acos(-1);

class BIT{
	private:
	int N;
	vector<int> bit;
	public:
	BIT(int x){
		N=x;
		bit=vector<int>(++x);
	}
	void add(int x,int y){
		while(x<=N){
			bit[x]+=y;
			x+=x&-x;
		}
	}
	int sum(int x){
		int s=0;
		while(x){
			s+=bit[x];
			x-=x&-x;
		}
		return s;
	}
	int getsum(int x,int y){
		return sum(y)-sum(--x);
	}
	void open(){
		for(int i=1;i<=N;i++){
			cout<<bit[i]<<endl;
		}
	}
};

int n,q;

int main(){ 
	cin>>n>>q;
	BIT ans(n);
	for(int i=0;i<q;i++){
		int type,one,two;
		cin>>type>>one>>two;
		if(type) cout<<ans.getsum(one,two)<<endl;
		else ans.add(one,two);
	}
}

Measured memory_bytes: 1796
import itertools

def warshall_floid(graph: list) -> list:
    """warshall-floid法: 各頂点から各頂点への最短距離を求める
    計算量: O(V^3)
    """
    n = len(graph)
    INF = 10 ** 18
    dp = [[INF] * n for i in range(n)]
    for i in range(n):
        dp[i][i] = 0
    for i in range(n):
        for j, cost in graph[i]:
            dp[i][j] = cost

    for k in range(n):
        for i in range(n):
            for j in range(n):
                dp[i][j] = min(dp[i][j], dp[i][k] + dp[k][j])
    return dp

n, m, r = map(int, input().split())
r = list(map(int, input().split()))
info = [list(map(int, input().split())) for i in range(m)]

graph = [[] for i in range(n)]
for i in range(m):
    a, b, cost = info[i]
    a -= 1
    b -= 1
    graph[a].append((b, cost))
    graph[b].append((a, cost))
dp = warshall_floid(graph)

ans = 10 ** 18
for ptn in itertools.permutations(r):
    tmp = 0
    for i in range(1, len(ptn)):
        tmp += dp[ptn[i] - 1][ptn[i - 1] - 1]
    ans = min(ans, tmp)
print(ans)

Measured memory_bytes: 49752
#include <bits/stdc++.h>
#define MOD 1000000007LL
using namespace std;
typedef long long ll;
typedef pair<int,int> P;

ll fact[600005];

ll extgcd(ll a,ll b,ll& x,ll& y){
	ll d=a;
	if(b!=0LL){
		d=extgcd(b,a%b,y,x);
		y-=(a/b)*x;
	}else{
		x=1;
		y=0;
	}
	return d;
}

ll mod_inverse(ll a,ll m){
	ll x,y;
	extgcd(a,m,x,y);
	return (m+x%m)%m;
}

ll mod_fact(ll n,ll p,ll& e){
	e=0;
	if(n==0)return 1;
	ll res=mod_fact(n/p,p,e);
	e+=n/p;
	if(n/p%2!=0){
		return res*(p-fact[n%p])%p;
	}
	return res*fact[n%p]%p;
}

ll mod_comb(ll n,ll k,ll p=MOD){
	if(n<0 || k<0 || n<k)return 0;
	ll e1,e2,e3;
	ll a1=mod_fact(n,p,e1),a2=mod_fact(k,p,e2),a3=mod_fact(n-k,p,e3);
	if(e1>e2+e3)return 0;
	return a1*mod_inverse(a2*a3%p,p)%p;
}


int n,m;
ll pat_over[300005];
ll pat_dist[300005];
ll base;

ll calc(int a,int b,int r){
	ll ans=0;
	for(int over=0;(ll)over*b+(ll)m*a<=r && over<=n-m;over++){
		ll rest=r-over*b-m*a;
		ll pat=pat_over[over]*pat_dist[rest]%MOD;
		if(over%2==0){
			ans+=pat;
			ans%=MOD;
		}else{
			ans+=MOD-pat;
			ans%=MOD;
		}
	}
	return ans*base%MOD;
}

int main(void){
	int l,r;
	fact[0]=1;
	scanf("%d%d%d%d",&n,&m,&l,&r);
	for(ll i=1;i<=600000;i++){
		fact[i]=fact[i-1]*i%MOD;
	}
	for(ll i=0;i<=300000;i++){
		pat_over[i]=mod_comb(n-m,i);
		pat_dist[i]=mod_comb(n+i,i);
	}
	base=mod_comb(n,m);
	ll ans=(mod_comb(n+r,r)-mod_comb(n+l-1,l-1)+MOD)%MOD;
	for(int a=1;a<=r;a++){
		ll val=calc(a,a,r)-calc(a+1,a,r);
		ll val2=calc(a,a,l-1)-calc(a+1,a,l-1);
		ans+=MOD-(val-val2+MOD)%MOD;
		ans%=MOD;
	}
	printf("%lld\n",ans);
	return 0;
}


Measured memory_bytes: 9600
#include <bits/stdc++.h>
using namespace std;
 
using ll = long long;
constexpr ll mod = ll(1e9 + 7);
#define endl '\n'
 
int main() {
  ios::sync_with_stdio(0); cin.tie(0);
 
  int TT = 1;
  // cin >> TT;
  while (TT--) {
    ll n;
    cin >> n;
    vector<uint64_t> A(n);
    bool has_zero = false;
    for (auto& aa : A) {
      cin >> aa;
      if (!aa) has_zero = true;
    }
    if (has_zero) {
      cout << 0 << endl;
      return 0;
    }
    ll ans = A[0];
    for (int i = 1; i < n; ++i) {
      if (ans > ll(1e9)*ll(1e9)/A[i]) {
        cout << -1 << endl;
        return 0;
      }
      ans *= A[i];
    }
    cout << ans << endl;
  }
}


Measured memory_bytes: 3968
import math
number = int(input())
ruijou = int(math.sqrt(number))
check = 0
count = 0
result =100000000000

for i in range(1,int(ruijou)+1):
    if number % i == 0:
        check = int(number / i)
        while not check == 0:
            check = int(check / 10)
            count += 1
        if count < result :
            result = count
    count = 0
print(result)

Measured memory_bytes: 3064
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author tatsumack
 */

#include <iostream>
#include <fstream>

#include <iostream>
#include <limits.h>
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>

#include <list>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <queue>
#include <unordered_map>
#include <unordered_set>

#define int long long
#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define REPS(i, n) for (int i = 1, i##_len = (n); i <= i##_len; ++i)
#define FOR(i, a, b) for (int i = (a), i##_len = (b); i <= i##_len; ++i)
#define REV(i, a, b) for (int i = (a); i >= (b); --i)
#define CLR(a, b) memset((a), (b), sizeof(a))
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define INF 1001001001001001001ll
#define fcout cout << fixed << setprecision(12)

using namespace std;

typedef pair<int, int> P;

class ADDCCFinals {
public:
    static constexpr int kStressIterations = 0;

    static void generateTest(std::ostream& test) {
    }

    int calc(int v) {
        if (v == 1) {
            return 300000;
        } else if (v == 2) {
            return 200000;
        } else if (v == 3) {
            return 100000;
        }
        return 0;
    }

    void solve(std::istream& cin, std::ostream& cout) {
        int x, y;
        cin >> x >> y;

        int res = 0;
        res += calc(x);
        res += calc(y);
        if (x == 1 && y == 1) {
            res += 400000;
        }
        cout << res << endl;
    }
};


signed main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    std::istream& in(std::cin);
    std::ostream& out(std::cout);

    ADDCCFinals solver;
    solver.solve(in, out);
    return 0;
}


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

using namespace std;

int main(){
 long n; 
  cin >> n;
 
  vector<int> a(n),b(n);
  for(int i=0;i<n;i++) cin >> a[i];
  for(int i=0;i<n;i++) cin >> b[i];
  
  long res=0;
  for(int i=0;i<n;i++){ 
    res+=(b[i]-a[i]);
    if(b[i]>a[i]) res-=(b[i]-a[i]+1)/2;
  }
  
  if(res>=0) cout << "Yes" << endl;
  else cout << "No" << endl;
  
}

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

using namespace std;

int h, w, n;

int inside(int x, int y) {
	return (1 <= x && x <= h) && (1 <= y && y <= w);
}

int main() {
	cin >> h >> w >> n;
	int x, y;
	cin >> x >> y;

	string s, t;

	cin >> s >> t;

	int left = 0, right = 0, up = 0, down = 0;

	int ok = 1;

	for (int i = 0; i < n; ++i) {
		if(s[i] == 'L') {
			left++;
		} else if(s[i] == 'R') {
			right++;
		} else if(s[i] == 'U') {
			up++;
		} else {
			down++;
		}
		if(!inside(x,y-left)) {
			ok = 0;
		}
		if(!inside(x,y+right)) {
			ok = 0;
		}
		if(!inside(x-up,y)) {
			ok = 0;
		}
		if(!inside(x+down,y)) {
			ok = 0;
		}	

		if(t[i] == 'R') {
			left--;
			left = max(left, -(w-y));
		} else if(t[i] == 'L') {
			right--;
			right = max(right, -(y-1));
		} else if(t[i] == 'D') {
			up--;
			up = max(up, -(h-x));
		} else {
			down--;
			down = max(down, -(x-1));
		}
	}


	if(ok) puts("YES");
	else puts("NO");
}


Measured memory_bytes: 776
#include<bits/stdc++.h>
using namespace std;
#define rep0(i,n) for(i=0;i<n;i++)
#define test(a) cout << "*" << a << endl;
int main(){
  int i;
  int N,T;
  int c[1000];
  int t[1000];
  int costMin = 1001;
  
  cin >> N >> T;
  rep0(i,N){
    cin >> c[i] >> t[i];
    if(t[i]<=T){
        costMin = min(costMin,c[i]);
    }
  }
  if(costMin == 1001)
    cout << "TLE" << endl;
  else
    cout << costMin << endl;
 
}

Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>
int main(void){
    while(1){
        int n;
        double m = 0.0,a = 0.0;
        scanf("%d",&n);
        if(n==0)break;
        else{
            int s[n];
            int i;
            for(i=0;i<n;i++){
                scanf("%d",&s[i]);
            }
            for(i=0;i<n;i++){
                m += s[i];
            }
            m /= n;
            for(i=0;i<n;i++){
                a += (s[i]-m)*(s[i]-m);
            }
            a /= n;
            printf("%lf\n",sqrt(a));
        }
    }
    return 0;
}


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

typedef long long lli;
typedef vector<int> Vi;
typedef vector<lli> Vl;
typedef pair<int, int> Pii;
typedef pair<lli, lli> Pll;


//===


int main() {
	lli r, D, x;
	cin >> r >> D >> x;
	for (int i = 0; i < 10; ++i) {
		x = r * x - D;
		cout << x << endl;
	}
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define pll pair<ll, ll>
#define fir first
#define sec second
using namespace std;
const int MAXN = 2e5 + 7;
pll p[MAXN];
multiset<ll>X, Y;
inline ll getans() 
{
    return (*X.rbegin() - *X.begin()) * (*Y.rbegin() - *Y.begin());
}
int main()
{   
    int n; scanf("%d", &n);
    for (int i = 1; i <= n; i++)
    {
        scanf("%lld%lld", &p[i].fir, &p[i].sec);
        if (p[i].fir > p[i].sec) swap(p[i].fir, p[i].sec);
        X.insert(p[i].fir); Y.insert(p[i].sec);
    }
    sort(p + 1, p + 1 + n);
    ll ans = getans();
    for (int i = 1; i < n; i++)
    {
        X.erase(X.find(p[i].fir)); Y.insert(p[i].fir);
        Y.erase(Y.find(p[i].sec)); X.insert(p[i].sec);
        ans = min(ans, getans());
    }
    printf("%lld\n", ans);
    return 0;
}

Measured memory_bytes: 22144
/*
    @uthor: Amit Kumar
    user -->GitHub: drviruses ; CodeChef: dr_virus_ ; Codeforces,AtCoder,Hackerearth,Hakerrank: dr_virus;
*/
#include <bits/stdc++.h>
#include <chrono>
using namespace std;
using namespace std::chrono;
//#include <boost/multiprecision/cpp_int.hpp>
//namespace mp = boost::multiprecision;
//#define ln mp::cpp_int;
#define ll    long long
#define ld    long double
#define ull   unsigned long long
#define all(vec) vec.begin(),vec.end()
#define endl "\n"
ll google_itr = 1;
#define google(x) cout<<"Case #"<<x<<":"
#define pi 3.14159265358979323846264338327950L

const ll mod = 1e9+7;
const ll inf = 1e18;

vector<vector<ll>> adj;
vector<bool> visited;
vector<ll> comp;

bool mysort(pair<ll,ll> A, pair<ll,ll> B){
    if(A.first == B.first) return A.second < B.second;
    return A.first < B.first;
}

void mydfs(ll scr){
    visited[scr] = true;
    comp.push_back(scr);
    for(auto i:adj[scr]){
        if(!visited[i]) mydfs(i);
    }
}

void virus(){
    ll len,fct;
    cin>>len>>fct;
    if(fct == 0){
        cout<<"1"; return;
    }
    set<pair<ll,ll>> uniq;
    for(auto i=0; i<fct; i++){
        ll ini, fnl;
        cin>>ini>>fnl;
        if(ini > fnl) swap(ini,fnl);
        uniq.insert({ini,fnl});
    }
    vector<pair<ll,ll>> arr(uniq.begin(),uniq.end());
    sort(all(arr),mysort);
    ll actlen = (ll)arr.size();
    adj.resize(len); visited.resize(len,false);
    for(auto i:arr){
        adj[i.first-1].push_back(i.second-1);
        adj[i.second-1].push_back(i.first-1);
    }
    ll ans = LLONG_MIN;
    for(auto i=0; i<len; i++){
        if(!visited[i]){
            comp.clear();
            mydfs(i);
            ans = max(ans,(ll)comp.size());
        }
    }
    cout<<ans;
}


int32_t main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    
  /*#ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
    #endif*/

    ll t = 1;
    //cin>>t;
    while(t--){
           auto start = high_resolution_clock::now();
           virus();
           auto stop = high_resolution_clock::now();
           auto duration = duration_cast<seconds>(stop - start);
           cerr << "\n Time: "<<duration.count()<<endl;
        //your code goes here
    }
    return 0;
}

Measured memory_bytes: 44000
n, k=gets.split.map(&:to_i)
d=gets.split.map(&:to_i)

yet=true
while yet
  yet=false
  d.each do |d_|
    if n.to_s.include?(d_.to_s)
      yet=true
      n+=1
      break
    end
  end
end

puts n

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

ll n,m,q;
ll a[505][505];
ll b[505][505];

int main(){
    cin >> n >> m >> q;
    for(ll i=0;i<m;i++){
        ll l,r;
        cin >> l >> r;
        a[r][l]++;
    }
    for(ll i=0;i<=500;i++){
        for(ll j=0;j<=500;j++){
            b[i][j+1]=b[i][j]+a[i][j];
        }
    }
    for(ll i=0;i<q;i++){
        ll c,d;
        cin >> c >> d;
        ll res=0;
        for(ll j=c;j<=d;j++){
            res+=b[j][d+1]-b[j][c];
        }
        cout << res << endl;
    }
}
*/
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
int main(void){
  ll n,m,q;
  cin>>n>>m>>q;
  ll a[510][510],b[510][510];
  for(ll i=0;i<m;i++){
    ll l,r;
    cin>>l>>r;
    a[r][l]++;
  }
  for(ll i=0;i<=500;i++){
    for(ll j=0;j<=500;j++){
      b[i][j+1]=b[i][j]+a[i][j];
    }
  }
  for(ll i=0;i<q;i++){
    ll c,d;
    cin>>c>>d;
    ll ans=0;
    for(ll j=c;j<=d;j++){
      ans+=b[j][d+1]-b[j][c];
    }
    cout<<ans<<endl;
  }
  return 0;
}

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

#define F first 
#define S second

using namespace std;

typedef long long LL;
typedef pair<int, int> PII;

const int N = 200010, M = 2 * N;

int n;
int a[N], w[N];

int main()
{
	scanf("%d", &n);
	for (int i = 1; i <= n; i ++ ) scanf("%d", &a[i]);
	
	LL sum = 0;
	for (int i = 1; i <= n; i ++ )
		if (i & 1) sum += a[i];
		else sum -= a[i];
		
	w[1] = sum / 2;
	for (int i = 2; i <= n; i ++ ) w[i] = a[i - 1] - w[i - 1];
	for (int i = 1; i <= n; i ++ ) printf("%d ", w[i] * 2);
	puts("");
    return 0;
}

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

int main() {
    long double a, b, h, m, ans, argment;
    cin >> a >> b >> h >> m;
    argment = max(6.0 * m, 30.0 * h + 0.5 * m) - min(6.0 * m, 30.0 * h + 0.5 * m);
    argment = min(argment, 360.0 - argment);
    ans = sqrt(a * a + b * b - 2.0 * a * b * cos(argment * M_PI / 180.0));
    cout << fixed << setprecision(12) << ans << endl;
}

Measured memory_bytes: 4164
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(void){
    int n,T,c,t;
    cin >>n>>T;
    
    int min_t=10000;
    for(int i=0;i<n;i++){
        cin >> c >> t;
        if(t<=T&&c<min_t){
            min_t = c;
        }
    }
    
    if(min_t==10000){
        cout << "TLE" << endl;
    } else {
        cout << min_t << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<iostream>
#include<string>
#include<stack>
#include<queue>
#include<vector>
#include<map>
#include<algorithm>

#define INT unsigned long long int
#define FOR1(n) for(int i=0;i<n;i++)
#define FOR2(j, n) for(int j=0;j<n;j++)
#define FOR3(i, m, n) for(int i=m;i<=n;i++)
#define PINT(d) printf("%d\n", d);
#define PDOUBLE(lf) printf("%lf\n", lf);
#define PSTR(s) printf("%s\n", s);
#define ALL(c) c.begin(), c.end()
#define MOD 1000000007
#define MAX_N 100000

using namespace std;

main(){
	string s;
	cin >> s;
	int k;
	cin >> k;
	FOR1(s.length()){
		int tmp = (int)('z' - s[i] + 1);
		if(i == s.length() - 1){
			//char c = (int)s[i] + (k%26);
			//c = c>'z'?c-26:c;
			//s[i] = c;
			s[i] = 'a' + ((s[i] - 'a' + k) % 26);
			k = 0;
		}else if(tmp != 26 && tmp <= k){
			s[i] = 'a';
			k -= tmp;
			if(k <= 0) break;
		}
	}

	cout << s << endl;
}

Measured memory_bytes: 640
n, k = map(int, input().split())
a = list(map(int, input().split()))
c = [0] * (n + 1)
for i in range(n):
    c[i + 1] += c[i] + max(0, a[i])
s = sum(a[:k - 1])
ans = 0
for i in range(n - k + 1):
    s += a[i + k - 1]
    ans = max(ans, c[n] - c[i + k] + c[i] + max(0, s))
    s -= a[i]
print(ans)

Measured memory_bytes: 14860