akhauriyash/Code-Regression huggingface dataset:
numOfRouts,TotTime=map(int,input().split())
cost=[]
time=[]
z=[]
for i in range(numOfRouts):
    a,b=map(int,input().split())
    cost.append(a)
    time.append(b)
    if time[i]<=TotTime:
        z.append(cost[i])
if len(z)==0:
    print("TLE")
else:
    print(min(z))

Measured memory_bytes: 3060
N=int(input())
S=[(0,0,0)]
for i in range(N):
  t,x,y=map(int,input().split())
  S.append((t,x,y))
flag=0
for i in range(N):
  if abs(S[i+1][1]-S[i][1])+abs(S[i+1][2]-S[i][2])>S[i+1][0]-S[i][0]:
    flag=1
    break
  elif (S[i+1][0]-S[i][0])%2==1 and (abs(S[i+1][1]-S[i][1])+abs(S[i+1][2]-S[i][2]))%2==0:
    flag=1
    break
  elif (S[i+1][0]-S[i][0])%2==0 and (abs(S[i+1][1]-S[i][1])+abs(S[i+1][2]-S[i][2]))%2==1:
    flag=1
    break

if flag==1:
  print("No")
else:
  print("Yes")

Measured memory_bytes: 17332
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
	ll a,n,b,i,j,k,l,m,s=0,op=0;
	cin>>n;
	ll h[n+1]={0},dp[n+1]={0};
	for(i=0;i<n;i++) cin>>h[i];
	dp[0]=0;
	dp[1]=abs(h[0]-h[1]);
	for(i=2;i<n;i++)
	{
		dp[i]=min(dp[i-1]+abs(h[i]-h[i-1]),dp[i-2]+abs(h[i]-h[i-2]));
	}
	cout<<dp[n-1];

}

Measured memory_bytes: 1792
// #pragma GCC optimize("O3", "unroll-loops")
// #pragma GCC target("avx2")
 
#include <bits/stdc++.h>
using namespace std;
 
// #include <ext/pb_ds/assoc_container.hpp> 
// #include <ext/pb_ds/tree_policy.hpp> 
// using namespace __gnu_pbds;
// #define ost tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> 
 
#define    int                      long long int
#define    ld                       long double
#define    f(i,j,n)                 for(int i = j; i <= n; i++)
#define    r(i,n,j)                 for(int i = n; i >= j; i--)
#define    mod                      1000000007
#define    speed                    ios_base::sync_with_stdio(false);
#define    upp                      cin.tie(NULL),cout.tie(NULL);
#define    pb                       push_back
#define    mp                       make_pair
#define    T                        int ttt; cin >> ttt; while(ttt--)
#define    ff                       first
#define    ss                       second
#define    all(container)            container.begin() , container.end()
#define    sz(container)            (int)container.size()
#define    pii                      pair <int , int>
#define    sp(x)                    setprecision(x)
#define    bp(x)                    __builtin_popcount(x)
#define    endl                     "\n"
int power(int x, int y, int p)  
{  
    int res = 1;    
    x = x % p; 
    if (x == 0) return 0; 
    while (y > 0)  
    {     
        if (y & 1)  
            res = (res*x) % p;  
        y = y>>1; 
        x = (x*x) % p;  
    }  
    return res; 
}

int32_t main()
{
    speed upp
    string s,a="ARC";
    cin>>s;
    if(s==a)
        cout<<"ABC";
    else
        cout<<a;
}


Measured memory_bytes: 3656
#include<bits/stdc++.h>
#define pb push_back
#define F first
#define S second
#define ll long long
#define endl "\n"
#define vi vector<int>
#define vl vector<ll>
#define all(v) (v).begin(),(v).end()
#define mst(a,b) memset(a,b,sizeof(a))
#define pii pair<int,int>
#define pll pair<ll,ll>
#define mt make_tuple
#define eb emplace_back
using namespace std;
const int N=2e5+5,mod=998244353;
const ll inf=3e18;
void solve(){
    int a,b,c,k;
    cin>>a>>b>>c>>k;
    int ans=0;
    if(k>0 && k<=a){
        ans=k;
        k=0;
    }
    else if(k>0 && k>a){
        ans=a;
        k=k-a;
    }
    if(k>0 && k<=b){
        k=0;
    }
    if(k>0 && k>b){
        k=k-b;
    }
    if(k>0 && k<=c){
        ans=ans-k;
        k=k-c;
    }
    if(k>0 && k>c){
        ans=ans-c;
        k=k-c;
    }
    cout<<ans<<endl;
}

int main(){
    #ifdef ONLINE_JUDGE
	ios_base::sync_with_stdio(0);
	cin.tie(0);cout.tie(0);
	#endif
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    ll t,p;
    t=1;
    //cin>>t;
    for(p=1;p<=t;p++){
        solve();
    }
    return 0;
}


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

public class Main {
	public static void main(String[] args) {
		FastScanner fs = new FastScanner(System.in);
		int n = fs.nextInt();
		long m = fs.nextLong();
		int a[] = fs.nextIntArray(n);
		
		long lcm = 1;
		for(int i=0;i<n;i++) {
			lcm = lcm(a[i],lcm);
			if(lcm > 2*m) {
				System.out.println(0);
				return;
			}
		}
		for(int i=0;i<n;i++) {
			if((lcm/a[i]) %2 == 0) {
				System.out.println(0);
				return;
			}
		}
		
		long ans = (m - lcm/2)/lcm + 1;
		System.out.println(ans);
		
	}
	static long lcm(long x, long y) {
		return x / gcd(x, y) * y;
	}

	static long gcd(long x, long y) {
		return y == 0 ? x : gcd(y, x % y);
	}
}

//高速なScanner
class FastScanner {
	private BufferedReader reader = null;
	private StringTokenizer tokenizer = null;

	public FastScanner(InputStream in) {
		reader = new BufferedReader(new InputStreamReader(in));
		tokenizer = null;
	}

	public String next() {
		if (tokenizer == null || !tokenizer.hasMoreTokens()) {
			try {
				tokenizer = new StringTokenizer(reader.readLine());
			} catch (IOException e) {
				throw new RuntimeException(e);
			}
		}
		return tokenizer.nextToken();
	}

	public String nextLine() {
		if (tokenizer == null || !tokenizer.hasMoreTokens()) {
			try {
				return reader.readLine();
			} catch (IOException e) {
				throw new RuntimeException(e);
			}
		}
		return tokenizer.nextToken("\n");
	}

	public long nextLong() {
		return Long.parseLong(next());
	}

	public int nextInt() {
		return Integer.parseInt(next());
	}

	public double nextDouble() {
		return Double.parseDouble(next());
	}

	public int[] nextIntArray(int n) {
		int[] a = new int[n];
		for (int i = 0; i < n; i++)
			a[i] = nextInt();
		return a;
	}

	public long[] nextLongArray(int n) {
		long[] a = new long[n];
		for (int i = 0; i < n; i++)
			a[i] = nextLong();
		return a;
	}
}

Measured memory_bytes: 38356
#include<stdio.h>
int main(){
    int n;
    long int sum = 0;
    scanf("%d",&n);
    for(int i = 1;i <= n;i++){
        if(i % 3 == 0 || i % 5 == 0){
            continue;
        }
        //printf("i = %d %d\n",i,sum);
        sum += i;
    }
    printf("%lld\n",sum);

}

Measured memory_bytes: 1732
#include <iostream>
using namespace std;
#define rep(i,s,n)for(int i = s;i<n;i++)

char s[101];
char t[101];

int strlength(const char *s) {
	int len = 0;
	while (*s++) len++;
	return len;
}
void sort(char *s, bool asc) {
	int len = strlength(s);
	char d;
	rep(i, 0, len) {
		rep(j, i + 1, len) {
			if (asc) {
				if (s[i] > s[j]) {
					d = s[i];
					s[i] = s[j];
					s[j] = d;
				}
			}
			else {
				if (s[i] < s[j]) {
					d = s[i];
					s[i] = s[j];
					s[j] = d;
				}
			}
		}
	}
}

int strcomp(const char* s, const char *t) {
	while (*s == *t) {
		if (*s == '\0') {
			return 0;
		}
		s++;
		t++;
	}
	return *s - *t;
}
int main() {
	cin >> s >> t;
	sort(s, true);
	sort(t, false);
	cout << (strcomp(s, t) < 0 ? "Yes" : "No") << endl;
	return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <queue>
#include <vector>
#include <map>
#include <cmath>

using namespace std;

#define rep(i,a) for(int i=0;i<a;i++)
typedef long long ll;

ll ans, n, cnt;
bool used[15];
ll keisu[15];
bool dame[15];

void dfs(int k, ll sum){
    // cout << k << ' ' << sum << endl;    
    if(k==cnt){
        // 
        if(!sum)ans++;
        return;
    }

    rep(i,10){
        if(used[i] || (i==0 && dame[k])) continue;
        
        used[i] = true;
        dfs(k+1,sum+i*keisu[k]);
        used[i] = false;
    }
    return;
}

int main(){
    while(cin>>n,n){
        vector<string> str(n);
        map<char,int> id;
        cnt = 0;
        ans = 0;

        rep(i,15){
            used[i] = false;
            keisu[i] = 0;
            dame[i] = false;
        }

        rep(i,n){
            cin >> str[i];

            rep(j,str[i].size()){
                if(id.find(str[i][j]) == id.end()){
                    id[str[i][j]] = cnt++;
                }
                if(j == 0 && str[i].length() > 1) dame[id[str[i][j]]] = true;

                if(i != n-1) keisu[id[str[i][j]]] += (int)pow(10.0,str[i].size()-j-1);
                else keisu[id[str[i][j]]] -= (int)pow(10.0,str[i].size()-j-1);
                
            }
        } 

        dfs(0,0);
        cout << ans << endl;
    }
}

Measured memory_bytes: 1252
#include <iostream>
#include <vector>
#include <cstdlib>
using namespace std;
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; }

const long long INF = 1LL << 60;

// 入力
int N;
long long h[110000];

// DP テーブル
long long dp[110000];

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

    // 初期化 (最小化問題なので INF に初期化)
    for (int i = 0; i < 110000; ++i) dp[i] = INF;

    // 初期条件
    dp[0] = 0;

    // ループ
    for (int i = 0; i < N; ++i) {
        for (int j = 1; j <= K; ++j) {
            chmin(dp[i + j], dp[i] + abs(h[i] - h[i + j]));
        }
    }

    // 答え
    cout << dp[N-1] << endl;
}


Measured memory_bytes: 1920
n, k = list(map(int, input().split()))


digits = [0]*10
digits_disliked = list(map(int, input().split()))

for i in digits_disliked:
    digits[i] = 1

for i in range(n, 10**7+1):
    temp = i
    flag = True

    while(temp):
        rem = temp%10
        temp = temp//10
        if(digits[rem] != 0):
            flag = False
            break
    
    if(flag == True):
        print(i)
        break

Measured memory_bytes: 3060
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};
    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

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

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

fn main() {
    input! {
        d: usize,
        g: usize,
        pc: [[usize; 2]; d]
    }
    let mut total_steps = 1000000000;
    for pat in 0..(1 << d) {
        let mut sum = 0;
        let mut steps = 0;
        for k in 0..d {
            let p = pc[k][0];
            let c = pc[k][1];
            if (pat & (1 << k)) > 0 {
                sum += 100 * (k + 1) * p + c;
                steps += p;
            }
        }
        if sum < g {
            for k in (0..d).rev() {
                let p = pc[k][0];
                if (pat & (1 << k)) > 0 {
                    continue;
                }
                for _ in 0..p {
                    if sum >= g {
                        break;
                    }
                    sum += 100 * (k + 1);
                    steps += 1;
                }
            }
        }
        total_steps = ::std::cmp::min(total_steps, steps);
    }
    println!("{}", total_steps);
}


Measured memory_bytes: 4352
#include <cstdio>
#include <algorithm>

using namespace std;

int main(){
  int a, b, c;
  scanf("%d %d %d", &a, &b, &c);

  int ans = a + b + c;
  ans -= max(max(a, b), c);

  printf("%d\n", ans);

  return 0;
}


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

int main()
{
    int N;
    cin >> N;
    vector<int> L(N);
    int sum = 0;
    for (int i = 0; i < N; i++)
    {
        cin >> L[i];
        sum += L[i];
    }
    sort(L.begin(), L.end());
    if ((sum - L[N - 1]) > L[N - 1])
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }
}

Measured memory_bytes: 256
import sys,queue,math,copy,itertools,bisect,collections,heapq

def main():
    sys.setrecursionlimit(10**7)
    INF = 10**18
    MOD = 10**9 + 7
    LI = lambda : [int(x) for x in sys.stdin.readline().split()]
    _LI = lambda : [-int(x) for x in sys.stdin.readline().split()]
    NI = lambda : int(sys.stdin.readline())
    SI = lambda : sys.stdin.readline().rstrip()
    DD = ((1,0),(0,1),(-1,0),(0,-1))

    N,K = LI()
    a = LI()

    for _ in range(K):
        x = [0] * N
        for i in range(N):
            s = i - a[i]
            if s < 0: s = 0
            x[s] += 1
            t = i + a[i] + 1
            if t < N:
                x[t] -= 1
        a = []
        cnt = 0
        finish = True
        for i in range(N):
            cnt += x[i]
            if cnt < N: finish = False
            a.append(cnt)
        if finish: break
    print(*a,sep=' ')


if __name__ == '__main__':
    main()

Measured memory_bytes: 171244
n = int(input())
t = [[] for _ in range(n)]
for i in range(n):
    a = int(input())
    for _ in range(a):
        x, y = map(int, input().split())
        t[i].append([x, y])

res = 0
for i in range(1 << n):
    p = [-1] * n
    contradiction_flag = False
    for j in range(n):
        if (i >> j) & 1:
            if p[j] == 0:
                contradiction_flag = True
                break
            p[j] = 1

            for person, h_or_u in t[j]:
                if h_or_u == 0:
                    if p[person-1] == 1:
                        contradiction_flag = True
                        break
                    p[person-1] = 0
                else:
                    if p[person-1] == 0:
                        contradiction_flag = True
                        break
                    p[person-1] = 1
        
        else:
            if p[j] == 1:
                contradiction_flag = True
                break
            p[j] = 0
    
    if not contradiction_flag:
        res = max(res, n - p.count(0))

print(res)


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

using namespace std;
typedef long long ll;

#define rep(i, N) for (int i = 0; i < (int)N; i++)
const ll MOD = pow(10,9)+7;
const ll LLINF = pow(2,61)-1;
const int INF = pow(2,30)-1;


int main() {
  ll A, B, C; cin >> A >> B >> C;
  ll result = 0;
  while(A%2==0&&B%2==0&&C%2==0) {
    if (A==B&&B==C) { cout << -1 << endl; return 0; }
    ll ta = B/2+C/2, tb = C/2+A/2, tc = A/2+B/2;
    A = ta; B = tb; C = tc;
    result++;
  }
  cout << result << endl;
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
using namespace std;
string S; int p[11];
char V[11] = "0123456789";
int main() {
	while (true) {
		S = "";
		while (S == "") {
			getline(cin, S);
		}
		if (S == "0") { break; }
		S += ' '; string T = "";
		for (int i = 0; i < 11; i++) { p[i] = 0; }
		for (int i = 0; i < S.size(); i++) {
			if (S[i] == ' ') {
				if (T.size() >= 2) { p[10]++; }
				else {
					for (int j = 1; j < 10; j++) {
						if (V[j] == T[0]) { p[j]++; }
					}
				}
				T = "";
			}
			else {
				T += S[i];
			}
		}
		int sum = 0;
		for (int i = 0; i < 11; i++) { sum += p[i] * i; }
		if (sum <= 11 && p[1] >= 1) { sum += 10; }
		if (sum >= 22) { sum = 0; }
		cout << sum << endl;
	}
	return 0;
}

Measured memory_bytes: 1188
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<cmath>
#define LL long long
using namespace std;
int n; 
struct data{
	char s[101];
	int x,o;
}s[101];
int cmp(const data &x,const data &y)
{
	if(strcmp(x.s,y.s)<0) return true;
	else if(strcmp(x.s,y.s)>0) return false;
	return x.x>y.x;
}
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
	{
		cin>>s[i].s>>s[i].x;
		s[i].o=i;
	}
	sort(s+1,s+n+1,cmp);
	for(int i=1;i<=n;i++) printf("%d\n",s[i].o);
	return 0;
}

Measured memory_bytes: 888
n,k = [int(x) for x in input().split()]
h = [int(x) for x in input().split()]
dp = [float("inf") for _ in range(n)]
dp[0] = 0
for i in range(1,n):
    for j in range(1,min(k,i)+1):
        dp[i] = min(dp[i],dp[i-j]+abs(h[i]-h[i-j]))
print(dp[-1])

Measured memory_bytes: 56800
#Hopscotch Addict

N,M=map(int,input().split())
graph={(i,j):[] for i in range(1,N+1) for j in range(1,4)}
for _ in range(M):
    u,v=map(int,input().split())
    graph[(u,1)].append((v,2))
    graph[(u,2)].append((v,3))
    graph[(u,3)].append((v,1))
S,T=map(int,input().split())

import heapq
def dijkstra(s,graph):
    dist={(i,j):float("inf") for i in range(1,N+1) for j in range(1,4)}
    dist[(s,3)]=0
    pq=[]
    heapq.heapify(pq)
    heapq.heappush(pq,(0,(s,3)))
    while pq:
        x=heapq.heappop(pq)
        node,mini_dis=x[1],x[0]
        for next_node in graph[node]:
            newlen=dist[node]+1
            if newlen<dist[next_node]:
                heapq.heappush(pq,(newlen,next_node))
                dist[next_node]=newlen
    return dist
K=dijkstra(S,graph)[(T,3)]
if K==float("inf"):
    print(-1)
else:
    print(K//3)



Measured memory_bytes: 129404
"use strict";

const main = (input) => {
    const spi = input.split('\n');
    const [n, k] = spi[0].split(' ').map(e => BigInt(e));

    const a1 = n % k;
    const a2 = a1 - k < 0 ? -(a1 - k) : a1 - k;

    console.log((a1 <= a2 ? a1 : a2).toString());
};

main(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 29544
import sys
import math
import bisect

def query(n):
    ans = 0
    while n:
        ans += n % 10
        n //= 10
    return ans

def main():
    n = int(input())
    if n % query(n) == 0:
        print('Yes')
    else:
        print('No')

if __name__ == "__main__":
    main()


Measured memory_bytes: 3060
#include <iostream>
#include <string>
#include <algorithm>
#include <set>
#include <map>
#include <vector>
#include <numeric>
#include <climits>
#include <math.h>
#include <memory.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rrep(i, k, n) for(int i = (k); i < (int)(n); i++)
//substr
using namespace std;
using ll = long long;
int N, M;
int cnt = 0;
ll ans = 0LL;
int i_index;
int dh[4] = {1, 0, -1, 0};
int dw[4] = {0, 1, 0, -1};
string board[64];

int main(){
    string S;
    cin >> S;
    int cnt2 = 0;
    int a = S.size();
    if(S[0] == 'A'){
        for(int i = 2; i < a - 1; i++){
            if(S[i] == 'C') cnt++;
        }
        rep(i, a){
            if(S[i] >= 'a' && S[i] <= 'z') cnt2++;
        }
    }
    if(cnt == 1 && cnt2 == a - 2) cout << "AC" << endl;
    else cout << "WA" << endl;
    
    return 0;
}

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

char S[L]={};

int main(void)
{ int n,k;
   scanf("%d",&n);
 scanf("%d",&k);
    scanf("%s",S);
 if(S[k-1]=='A')S[k-1]='a';else if (S[k-1]=='B')S[k-1]='b';else S[k-1]='c';
 printf("%s",S);
}

Measured memory_bytes: 128
#include <iostream>
#include <string>
#include <set>
#include <algorithm>
#include <vector>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;

int main()
{
	int N, K; cin >> N >> K;
	vector<int> A(N, 0);
	for (int i = 0; i < N; ++i) {
		int n; cin >> n; --n;
		++A[n];
	}
	int kind = 0;
	for (int i = 0; i < N;++i) {
		if (A[i]) {
			++kind;
		}
	}
	int del = kind - K;
	int sum = 0;
	int delCnt = 0;
	sort(A.begin(), A.end());
	for (int i = 0; delCnt < del; ++i) {
		if (A[i]) {
			sum += A[i];
			++delCnt;
		}
	}
	cout << sum << endl;
}


Measured memory_bytes: 3580
use std::io;

fn main() {
    let mut line = read::<String>();

    let len: usize = line.len();

    for _i in 0..len {
        line.pop();
    }
    for _i in 0..len {
        line.push('x');
    }
    println!("{}", line);
}

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


Measured memory_bytes: 4352
// b exponentials
#include <stdio.h>
#define SIZE 10
#define NUM 40

int pow_int(int a, int x){
    int value = 1;
    for(int i = 0; i < x; i++){
        value *= a;
    }
    return value;
}

int main(void){
    int x;
    scanf("%d", &x);

    int exponential[NUM][SIZE] = {};
    int i, p;
    for(i = 0; i < NUM; i++){
        if(i == 0){
            exponential[i][0] = 1;
        }else{
            for(p = 2; p < 10; p++){
                if(pow_int(i + 1, p) > 1000) break;

                exponential[i][p - 2] = pow_int(i + 1, p);
            }
        }
    }

    int ans = 1;
    for(i = 0; i < NUM; i++){
        if(exponential[i][0] == 0) break;
        
        for(p = 0; p < 10; p++){
            if(exponential[i][p] == 0){
                //printf("\n");
                break;
            }
            
            if(i != 0) //printf(" ");
            
            //printf("exp[%d][%d] = %d", i, p, exponential[i][p]);

            if(exponential[i][p] <= x){
                ans = (exponential[i][p] > ans)? exponential[i][p] : ans + 0;
            }
        }
    }

    printf("%d\n", ans);
    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
using vi = vector<int>;
using vb = vector<bool>;
using vl = vector<long>;
using vs = vector<string>;
using vvi = vector<vector<int>>;
using vvb = vector<vector<bool>>;
using vvc = vector<vector<char>>;
using vvl = vector<vector<long>>;
using pii = pair<int, int>;
using pil = pair<int, long>;
using pll = pair<long, long>;
#define fix20 cout << fixed << setprecision(20)
#define YES cout << "Yes" << endl
#define NO cout << "No" << endl
#define rep(i,n) for(int i=0; i<(int)(n);i++)
#define REP(i,s,t) for(int i=s; i<t; i++)
#define RNG(i,s,t,u) for(int i=s; i<t; i+=u)
#define MOD 1000000007
#define all(vec) vec.begin(), vec.end()

int main(){
  int x,n;
  cin >> x >> n;
  set<int> st;
  rep(i,n){
    int p;
    cin >> p;
    st.insert(p);
  }
  int ans = 200;
  int dis = 200;
  rep(i,200){
    if(st.count(i)) continue;
    if(abs(i-x) < dis){
      ans = i;
      dis = abs(i-x);
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 3636
#include "bits/stdc++.h"
#include<unordered_map>
#pragma warning(disable:4996)
using namespace std;

const int My_Inf=2147483647;
const long long int My_LInf=9223372036854775807;
struct aa {
	int h;
	int p;
	int q;
};
int main() {
	while(1) {
		int N, M, A; cin >> N >> M >> A;
		if (!N)break;
		vector<aa>aas;
		for (int i = 0; i < M; ++i) {
			int h, p, q; cin >> h >> p >> q;
			p--; q--;
			aas.push_back(aa{ h,p,q });
		}
		sort(aas.begin(), aas.end(), [](const aa&l, const aa&r) {return l.h > r.h; });
		int now = A - 1;
		for (int i = 0; i < M; ++i) {
			if (aas[i].p == now) {
				now = aas[i].q;
			}
			else if (aas[i].q == now) {
				now = aas[i].p;
			}
		}
		now++;
		cout << now << endl;
	}
	
	return 0;
}

Measured memory_bytes: 3028
#include<iostream>
#include<vector>
#include<string>

int main(){
    int N;
    std::cin >> N;
    std::string S;
    std::cin >> S;
    for(int i = 0; i < S.size(); i++){
        if(S[i] + N > 'Z'){
            S[i] = 'A' + (S[i] + N - 'Z') - 1;
        }else{
            S[i] = S[i] + N;
        }
    }
    std::cout << S << std::endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <algorithm>
#include <set>
#include <map>
#include <bitset>
#include <cmath>
#include <functional>
#include <iomanip>
#define vll vector<ll>
#define vvv vector<vvl>
#define vvi vector<vector<int> >
#define vvl vector<vector<ll> >
#define vv(a, b, c, d) vector<vector<d> >(a, vector<d>(b, c))
#define vvvl(a, b, c, d) vector<vvl>(a, vvl(b, vll (c, d)));
#define rep(c, a, b) for(ll c=a;c<b;c++)
#define re(c, b) for(ll c=0;c<b;c++)
#define all(obj) (obj).begin(), (obj).end()
typedef long long int ll;
typedef long double ld;
using namespace std;

struct LazySegmentTree {
private:
    int n;
    vector<ll> node, lazy;

public:
    LazySegmentTree(vector<ll> v) {
        int sz = (int)v.size();
        n = 1; while(n < sz) n *= 2;
        node.resize(2*n-1);
        lazy.resize(2*n-1, 0);
        for(int i=0; i<sz; i++) node[i+n-1] = v[i];
        for(int i=n-2; i>=0; i--) node[i] = max(node[i*2+1], node[i*2+2]);
    }

    void eval(int k, int l, int r) {
        if(lazy[k] != 0) {
            node[k] += lazy[k];
            if(r - l > 1) {
                lazy[2*k+1] += lazy[k] / 2;
                lazy[2*k+2] += lazy[k] / 2;
            }
            lazy[k] = 0;
        }
    }

    void add(int a, int b, ll x, int k=0, int l=0, int r=-1) {
        if(r < 0) r = n;
        eval(k, l, r);
        if(b <= l || r <= a) return;
        if(a <= l && r <= b) {
            lazy[k] += (r - l) * x;
            eval(k, l, r);
        }
        else {
            add(a, b, x, 2*k+1, l, (l+r)/2);
            add(a, b, x, 2*k+2, (l+r)/2, r);
            node[k] = max(node[2*k+1], node[2*k+2]);
        }
    }

    ll getsum(int a, int b, int k=0, int l=0, int r=-1) {
        if(r < 0) r = n;
        eval(k, l, r);
        if(b <= l || r <= a) return 0;
        if(a <= l && r <= b) return node[k];
        ll vl = getsum(a, b, 2*k+1, l, (l+r)/2);
        ll vr = getsum(a, b, 2*k+2, (l+r)/2, r);
        return max(vl, vr);
    }
};
int main(int argc, char const *argv[]) {
  ll n, d, a;std::cin >> n >> d >> a;
  vvl x = vv(n, 2, 0, ll);
  map<ll, ll> mp;
  re(i, n) {
    std::cin >> x[i][0] >> x[i][1];
    mp.emplace(x[i][0], 0);
    mp.emplace(x[i][0]+1, 0);
    mp.emplace(x[i][0]+2*d+1, 0);
  }
  ll c = 0;
  for(auto itr=mp.begin();itr!=mp.end();itr++, c++) (*itr).second = c;
  LazySegmentTree seg(vll(mp.size()+1, 0));
  re(i, n){
    ll to = mp.at(x[i][0]);
    seg.add(to, mp.at(x[i][0]+1), x[i][1]);
  }
  sort(all(x));
  ll ans = 0;
  for(int i=0;i<n;i++){
    //std::cout << "max" << seg.getsum(0, mp.size()) << '\n';
    ll to = mp.at(x[i][0]);
    ll now = seg.getsum(to, to+1);
    if(now<=0) continue;
    ll num = now/a + (now%a!=0?1:0);
    ans += num;
    //std::cout << num << '\n';
    seg.add(to, mp.at(x[i][0]+2*d+1), -a*num);
  }
  std::cout << ans << '\n';
  return 0;
}


Measured memory_bytes: 86144
import java.util.*;
import java.math.*;

public class Main {
    public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
        String a = sc.next();
        String b = sc.next();
      
        BigDecimal a1 = new BigDecimal(a);
        BigDecimal b1 = new BigDecimal(b);
        BigDecimal res= a1.multiply(b1);
      
        System.out.println(res.setScale(0, RoundingMode.DOWN));
    }
}

Measured memory_bytes: 36048
#include<cstdio>
#include<list>
#include<queue>
#include<functional>
using namespace std;
typedef long long weight;
weight const infty = 0x3fffffffffffff;
typedef pair<weight,int> edge;
class Graph{
    int numVertex;
    list<edge> *adj;
public:
    Graph(int v);
    void addEdge(int u,int v,weight w);
    void dijkstra(weight l[],int s);
};
//v頂点{0,1,...,v-1}0辺のグラフを作成
Graph::Graph(int v){
    this->numVertex=v;
    this->adj=new list<edge>[v];
}
//グラフに重さwの辺(u-v:無向グラフ)を追加
void Graph::addEdge(int u,int v,weight w){
    adj[u].push_back({w,v});
    adj[v].push_back({w,u});
}
//頂点sから点tへの最短経路l[t]を求める
void Graph::dijkstra(weight l[],int s){
    for(int i=0;i<numVertex;i++)l[i]=infty;
    l[s]=0;//l[始点]=0,l[それ以外]=無限大
    priority_queue<edge,vector<edge>,greater<edge>> pq;//firstを優先してソートするのでweightが先
    pq.push({0,s});//pq={(最短距離0,始点s)}
    while(!pq.empty()){
        int u=pq.top().second;//頂点を取得
        pq.pop();
        for(auto i=adj[u].begin();i!=adj[u].end();i++){
            int v=(*i).second;
            weight w=(*i).first;
            if(l[v]>l[u]+w){
                l[v]=l[u]+w;
                pq.push({l[v],v});
            }
        }
    }
}
weight d[100001];
int main(){
    int n;
    scanf("%d",&n);
    Graph g(n+1);
    for(int i=1;i<n;i++){
        int a,b,c;
        scanf("%d%d%d",&a,&b,&c);
        g.addEdge(a,b,c);
    }
    int q,k;
    scanf("%d%d",&q,&k);
    g.dijkstra(d,k);
    for(int i=0;i<q;i++){
        int x,y;
        scanf("%d%d",&x,&y);
        printf("%lld\n",d[x]+d[y]);
    }
}

Measured memory_bytes: 14072
#include<stdio.h>

int main(void){
	double r,S,L;
	scanf("%lf",&r);
	S = 3.141592653589 * r * r;
	L = 2* 3.141592653589 *r;
	printf("%.6lf %.6lf\n",S,L);
	return 0;
}

Measured memory_bytes: 652
num = int(input())
t_list = []
for i in range(num):
    t = int(input())
    t_list.append(t)

minv = t_list[0]
maxv = t_list[1] - t_list[0]
for j in range(1,len(t_list)):
    m_buf = t_list[j] - minv
    if m_buf > maxv:
        maxv = m_buf
    
    if minv > t_list[j]:
        minv = t_list[j]

print('{}'.format(maxv))



Measured memory_bytes: 13596
N,A,B = map(int,input().split())
S = str(input())
for i in range(N):
    r = A + B
    if S[i] == "c":
        print("No")
    else:
        if S[i] == "a" and r > 0:
            print("Yes")
            if A >= 1:
                A -= 1
            else:
                B -= 1
        elif S[i] == "b" and B > 0:
            print("Yes")
            B -= 1
        else:
            print("No")

Measured memory_bytes: 4016
#include<bits/stdc++.h>
using namespace std;
 
const int mod = 1e9 + 7;
int32_t main() {
	int n, m; cin>>n>>m;
	vector<int> dp(n + 1);
	set<int> broken;
	for(int i = 0; i < m; i++){
		int x; cin>>x;
		broken.insert(x);
	}
	dp[0] = 1;
	dp[1] = (broken.count(1) ? 0 : 1);
	for(int i = 2; i <= n; ++i){
		dp[i] = (broken.count(i) ? 0 : (dp[i-1] + dp[i-2]) % mod);
	}
	cout<<dp[n]<<endl;
}


Measured memory_bytes: 5376
#define _USE_MATH_DEFINES
#include <iostream>
#include <numeric>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <iterator>
#include <math.h>
#include <cmath>
#include <set>   

using namespace std;


int main() {

	string s, t;

	int x = 0;
	int y = 0;
	cin >> s >> t;

	for (int i = 0; i < s.size() + t.size(); i++)
	{
		if (i % 2 == 0) {
			cout << s[x];
			x++;
		}
		else {
			cout << t[y];
			y++;
		}
	}
}

Measured memory_bytes: 256
#include <map>
#include <set>
#include <cmath>
#include <ctime>
#include <cstdio>
#include <vector>
#include <cstring>
#include <cstdlib>
#include <algorithm>

using namespace std;

#define mp make_pair
#define pb push_back
#define x first
#define y second

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

int a[310][310],p[310],s[310];
bool ok[310];

int main()
{
	#ifndef ONLINE_JUDGE
		//freopen("input.txt","r",stdin);
		//freopen("output.txt","w",stdout);
	#endif
	int n,m;scanf("%d%d",&n,&m);
	for (int i=1;i<=n;i++)
		for (int j=1;j<=m;j++)
			scanf("%d",&a[i][j]);
	int ans=n;for (int i=1;i<=n;i++) p[i]=1;
	for (int t=1;t<=m;t++)
	{
		int k=1;
		memset(s,0,sizeof(s));
		for (int i=1;i<=n;i++) s[a[i][p[i]]]++;
		for (int j=2;j<=m;j++) if (s[j]>s[k]) k=j;
		ans=min(ans,s[k]);ok[k]=1;
		for (int i=1;i<=n;i++)
			while (p[i]<=m&&ok[a[i][p[i]]]) p[i]++;
	}
	printf("%d\n",ans);
	return 0;
}


Measured memory_bytes: 512
import std.stdio, std.algorithm, std.string, std.ascii;

void main()
{
  char[] s = readln.strip.dup;
  if (s[0] != 'A') {
    writeln("WA");
    return;
  }

  auto p = s.indexOf('C');
  if (p == -1 || p <= 1 || p > s.length-2) {
    writeln("WA");
    return;
  }
  s[0] = 'a';
  s[p] = 'a';

  if (s.all!(isLower)) {
    writeln("AC");
  }
  else {
    writeln("WA");
  }


}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int k = sc.nextInt();
		int c = sc.nextInt();
		char[] s = sc.next().toCharArray();
		sc.close();

		boolean[] work = new boolean[n];
		for (int i = n - 1; i >= 0 && k > 0; i--) {
			if (s[i] == 'o') {
				work[i] = true;
				i -= c;
				k--;
			}
		}

		int idx = 0;
		for (int i = 0; i < n; i++) {
			if (work[i]) {
				while (s[idx] == 'x') {
					idx++;
				}
				if (idx >= i) {
					System.out.println(i + 1);
				}
				idx += c + 1;
			}
		}
	}
}


Measured memory_bytes: 47056
#include <bits/stdc++.h>
using namespace std;
/*{{{*/  //template
#define rep(i,n) for(int i=0;i<(int)(n);i++)
constexpr int INF = numeric_limits<int>::max()/2;
constexpr long long LINF = numeric_limits<long long>::max()/3;
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
#define sz(x) (int)(x).size()
#define debug(x) cerr<<#x<<":"<<x<<endl
#define debug2(x,y) cerr<<#x<<","<<#y":"<<x<<","<<y<<endl
//struct fin{ fin(){ cin.tie(0); ios::sync_with_stdio(false); } } fin_;
struct Double{ double d; explicit Double(double x) : d(x){} };
ostream& operator<<(ostream& os,const Double x){ os << fixed << setprecision(20) << x.d; return os; }
template<typename T> ostream& operator<<(ostream& os,const vector<T>& vec){ os << "["; for(const auto& v : vec){ os << v << ","; } os << "]"; return os; }
template<typename T,typename U> ostream& operator<<(ostream& os,const pair<T,U>& p){ os << "(" << p.first << ","<< p.second <<")"; return os; }
template<typename T> ostream& operator<<(ostream& os,const set<T>& st){ os<<"{"; for(T v:st) os<<v<<","; os <<"}"; return os; }
template<typename T,typename U> inline void chmax(T &x,U y){ if(y>x) x = y; }
template<typename T,typename U> inline void chmin(T &x,U y){ if(y<x) x = y; }
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
ll gcd(ll a,ll b){ if(b==0) return a; else return gcd(b,a%b); }
//constexpr double eps = 1e-14; 
constexpr double eps = 1e-10; 
constexpr ll mod = 1e9+7;
const int dx[]={1,0,-1,0} ,dy[] = {0,1,0,-1};
/*}}}*/

int main(){
    string s; cin >> s;
    int N = s.size();
    int K; cin >> K;

    set<string> st;
    for(char c='a';c<='z';c++){
        for(int i=0;i<N;i++) if(s[i] == c){
            for(int len = 1; len <= 10; len++){
                st.insert(s.substr(i,len));
            }
        }
        if(st.size() >= K) break;
    }
    vector<string> ans(all(st));
    cout << ans[K-1] << endl;
}


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

bool check(vector<string> words){
    int n = words.size();
    for (int i=0; i<n-1; i++){
        if (words[i].back() != words[i+1].front()){
            return false;
        }
    }
    for(int i=0; i<n; i++){
        for (int j=i+1; j<n; j++){
            if (words[i] == words[j]){
                return false;
            }
        }
    }
    return true;
}

int main(void){
    int n;
    cin >> n;
    vector<string> words(n);
    for (int i=0; i<n; i++) cin >> words[i];
    if (check(words)) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 3608
//==========================Head files==========================
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<vector>
#include<queue>
#include<cmath>
#include<map>
#include<iostream>
#include<string>
#define LL long long
#define db double
#define mp make_pair
#define pr pair<int, int>
#define fir first
#define sec second
#define pb push_back
#define ms(i, j) memset(i, j, sizeof i)
using namespace std;
//==========================Templates==========================
inline int read() {
    int x = 0, f = 1; char c = getchar();
    while(c < '0' || c > '9'){if (c == '-') f = -1; c = getchar();}
    while(c >= '0' && c <= '9'){x = x * 10 + c - '0'; c = getchar();}
    return x * f;
}
inline LL readl() {
    LL x = 0, f = 1; char c = getchar();
    while(c < '0' || c > '9'){if (c == '-') f = -1; c = getchar();}
    while(c >= '0' && c <= '9'){x = x * 10 + c - '0'; c = getchar();}
    return x * f;
}
int power(int a, int b) {
	int ans = 1;
	while (b) {
		if(b & 1) ans = ans * a;
		b >>= 1; a = a * a;
	}
	return ans;
}
int power_mod(int a, int b, int mod) {
	a %= mod;
	int ans = 1;
	while (b) {
		if(b & 1) ans = (ans * a) % mod;
		b >>= 1, a = (a * a) % mod;
	}
	return ans;
}
LL powerl(LL a, LL b) {
	LL ans = 1ll;
	while (b) {
		if(b & 1ll) ans = ans * a;
		b >>= 1ll;a = a * a;
	}
	return ans;
}
LL power_modl(LL a, LL b, LL mod) {
	a %= mod;
	LL ans = 1ll;
	while (b) {
		if(b & 1ll) ans = (ans * a) % mod;
		b >>= 1ll, a = (a * a) % mod;
	}
	return ans;
}
LL gcdl(LL a, LL b) {return b == 0 ? a : gcdl(b, a % b);}
LL abssl(LL a) {return a > 0 ? a : -a;}
int gcd(int a, int b) {return b == 0 ? a : gcd(b, a % b);}
int abss(int a) {return a > 0 ? a : -a;}
//==========================Main body==========================
#define LD "%I64d"
#define D "%d"
#define pt printf
#define sn scanf
#define pty printf("YES\n")
#define ptn printf("NO\n")
//==========================Code here==========================
string s;
map<string, int > ma;
int n;
int main() {
	cin >> n;
	for (int i = 1; i <= n; ++i) cin >> s, sort(s.begin(), s.end()), ma[s]++;
	LL ans = 0;
	for (auto it = ma.begin(); it != ma.end(); ++it) {
		LL gg = it->second;
		ans += gg * (gg - 1ll) / 2ll;
	}
	cout << ans;
	
	return 0;
}

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

int N, c = -1, cnt; vector<int> X[10009];

int main(){
    cin >> N;
    for(int i = 1; i <= 1000; i++){
        if(i*(i - 1) / 2 == N){
            c = i;
            break;
        }
    }
    if(c == -1){
        cout << "No" << endl;
        return 0;
    }
    for(int i = 0; i < c; i++){
        for(int j = i + 1; j < c; j++){
            X[i].push_back(cnt + 1);
            X[j].push_back(cnt + 1);
            cnt++;
        }
    }
    cout << "Yes" << endl;
    cout << c << endl;
    for(int i = 0; i < c; i++){
        cout << X[i].size() << ' ';
        for(int j = 0; j < X[i].size(); j++){
            if(j) cout << ' ';
            cout << X[i][j];
        }
        cout << endl;
    }
}

Measured memory_bytes: 4700
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        while (sc.hasNext()) {
            String[] d = sc.nextLine().split(" ");
            String month = null, day = null;
            if (d[1].length() == 1) {
                month = "0" + d[1];
            } else {
                month = d[1];
            }
            if (d[2].length() == 1) {
                day = "0" + d[2];
            } else {
                day = d[2];
            }
            int date = Integer.parseInt(d[0] + month + day);
            if (date >= 19890108) {
                System.out.println("heisei" + " " + (Integer.parseInt(d[0]) - 1988) + " " + d[1] + " " + d[2]);
            } else if (date >= 19261225) {
                System.out.println("showa" + " " + (Integer.parseInt(d[0]) - 1925) + " " + d[1] + " " + d[2]);
            } else if (date >= 19120730) {
                System.out.println("taisho" + " " + (Integer.parseInt(d[0]) - 1911) + " " + d[1] + " " + d[2]);
            } else if (date >= 18680908) {
                System.out.println("meiji" + " " + (Integer.parseInt(d[0]) - 1867) + " " + d[1] + " " + d[2]);
            } else {
                System.out.println("pre-meiji");
            }
        }
    }
}

Measured memory_bytes: 17160
#include <iostream>
#include<set>
#include<vector>
#include<string>
#include<iterator>
#include<iomanip>
#include<cmath>
#include<map>
#include<string.h>
#include<algorithm>

using namespace std;
void ll(){
	std::ios_base::sync_with_stdio(0);
	cin.tie(NULL);
	cout.tie(0);
}

int main() {

	ll();
	
	long long a,c=0,i=0;
	double  b;
	cin >> a;
	b = sqrt(a);
	c = sqrt(a);
	i = a;
	if ((b - c) == 0)
		cout << a << endl;
	else
	{
		while (true)
		{
			i--;
			b = sqrt(i);
			c = sqrt(i);
			if ((b - c) == 0)
			{
				cout << i << endl;
				return 0;
			}
		}
	}

}

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


int N, u, v;
vector<vector<int>> links;


void input() {
    cin >> N >> u >> v;
    u--;
    v--;
    links = vector<vector<int>>(N);
    rep(i, N-1) {
        int A, B;
        cin >> A >> B;
        A--;
        B--;
        links[A].push_back(B);
        links[B].push_back(A);
    }
}


void dfs(vector<int>& dlist, int num, int p, int d) {
    dlist[num] = d;
    for (int i : links[num]) {
        if (i == p) continue;
        dfs(dlist, i, num, d+1);
    }
}


int main() {
    input();
    vector<int> ud, vd;
    ud = vd = vector<int>(N);
    dfs(ud, u, -1, 0);
    dfs(vd, v, -1, 0);
    int ans = 0;
    rep(i, N) {
        if (ud[i] < vd[i]) ans = max(ans, vd[i]-1);
    }
    cout << ans << endl;
}


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

using namespace std;

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

	char x = toupper(a.front());
	char y = toupper(b.front());
	char z = toupper(c.front());

	cout << x << y << z << 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++)

using namespace std;

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

int main(void){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(20);
    string s;
    cin >> s;
    rep(i,s.size()-8){
        cout << s[i];
    }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
#define fr(i,n) for(int i=0;i<(n);++i)
#define Fr(i,n) for(int i=1;i<=(n);++i)
#define ifr(i,n) for(int i=(n)-1;i>=0;--i)
#define iFr(i,n) for(int i=(n);i>0;--i)
 
int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    ll a,b;
    b=0;
    cin>>a;
    int c[26];
    int s[26][365];
    ll wa[26];
    fr(i,26){
        cin>>a;
        c[i]=a;
    }
    fr(i,26){
        fr(h,365){
            int b;
            cin>>b;
            s[i][h]=b;
            wa[i]+=b;
        }
    }
  Fr(i,25){
      if(wa[b]<wa[i]) b=i+1;
  }
  fr(i,365){
      cout<<b+1<<"\n";
  }
}

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

#define REP(i,m,n) for(int i=(m); i<(int)(n); i++)
#define RREP(i,m,n) for(int i=(int)(n-1); i>=m; i--)
#define rep(i,n) REP(i,0,n)
#define rrep(i,n) RREP(i,0,n)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define aut(r,v) __typeof(v) r = (v)
#define each(it,o) for(aut(it,(o).begin()); it!=(o).end(); ++it)
#define reach(it,o) for(aut(it,(o).rbegin()); it!=(o).rend(); ++it)
#define fi first
#define se second
#define debug(...) {cerr<<"[L"<<__LINE__<<"] "; _debug(__VA_ARGS__);}

template<typename T1, typename T2> ostream& operator<<(ostream& o, const pair<T1, T2>& p)
{return o<<"("<<p.first<<", "<<p.second<<")";}
template<typename T>string join(const vector<T>&v, string del=", ")
{stringstream s;rep(i,v.size())s<<del<<v[i];return s.str().substr(del.size());}
template<typename T>ostream& operator<<(ostream& o, const vector<T>&v)
{if(v.size())o<<"["<<join(v)<<"]";return o;}
template<typename T>ostream& operator<<(ostream& o, const vector<vector<T> >&vv)
{int l=vv.size();if(l){o<<endl;rep(i,l){o<<(i==0?"[ ":",\n  ")<<vv[i]<<(i==l-1?" ]":"");}}return o;}
template<typename T>ostream& operator<<(ostream& o, const set<T>& st)
{vector<T> v(st.begin(),st.end());o<<"{ "<<join(v)<<" }";return o;}
template<typename T1, typename T2>ostream& operator<<(ostream& o, const map<T1, T2>& m)
{each(p,m){o<<(p==m.begin()?"{ ":",\n  ")<<*p<<(p==--m.end()?" }":"");}return o;}
inline void _debug(){cerr<<endl;}
template<class First, class... Rest>
void _debug(const First& first, const Rest&... rest){cerr<<first<<" ";_debug(rest...);}

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

const double PI = (1*acos(0.0));
const double EPS = 1e-9;
const ll INF = 0x3f3f3f3f;
const ll INFL = 0x3f3f3f3f3f3f3f3fLL;
const ll mod = 1e9 + 7;

inline void finput(string filename) {
    freopen(filename.c_str(), "r", stdin);
}

int main(){
    ios_base::sync_with_stdio(0);
    // finput("./input");

    int n; cin >> n;
    vi P(n); rep(i,n) cin >> P[i];
    vector<pii> A; rep(i,n) A.emplace_back(P[i], i);
    sort(rall(A));

    multiset<int> s = {-1, -1, n, n};
    ll ans = 0;
    rep(i,n){
        ll pi = A[i].first; int j = A[i].second;
        int w = *(--(--(s.lower_bound(j))));
        int x = *(--s.lower_bound(j));
        int y = *(s.lower_bound(j));
        int z = *(++s.lower_bound(j));
        ans += pi * ((x-w) * (y-j) + (j-x) * (z-y));
        s.insert(j);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 6132
#include <iostream>
using namespace std;
int main(void){
    int W,H,x,y,r;
        cin>>W;
        cin>>H;
        cin>>x;
        cin>>y;
        cin>>r;
        if(x-r>=0&&x+r<=W&&y-r>=0&&y+r<=H){
            cout<<"Yes"<<endl;
        }
        else{
            cout<<"No"<<endl;
        }
    

}


Measured memory_bytes: 3108
#include <bits/stdc++.h>
#define rep(i, a, b) for(int i = int(a); i < int(b); i++)
#define rer(i, a, b) for(int i = int(a) - 1; i >= int(b); i--)

using namespace std;
typedef long long int ll;
typedef pair <int, int> P;

const int MAX_V=100000;

vector <int> G[MAX_V];
ll V;

int color[MAX_V];

//頂点を１と−１で塗る
bool dfs(int v,int c){
    color[v] = c;
    rep(i, 0, G[v].size()){
        //隣接している頂点が同じ色ならfalse
        if (color[G[v][i]] == c) return false;
        //隣接している頂点がまだ塗られていないなら-cで塗る
        if (color[G[v][i]] == 0 && !dfs(G[v][i], -c)) return false;
    }
    //すべて塗れたらtrue
    return true;
}

int main() {
    int M;
    cin >> V >> M;
    rep(i, 0, M){
        int a,b;
        cin >> a >> b;
        G[a-1].push_back(b-1);  G[b-1].push_back(a-1);
    }
    if (dfs(0,1)){
        ll cnt=0;
        rep(i, 0, V){
            if (color[i] == 1) cnt++;
        }
        printf("%lld\n", cnt*(V-cnt)-M);
    }
    else {
        printf("%lld\n", V*(V-1)/2-M);
    }
}

Measured memory_bytes: 6528
import java.util.* ; 
class Main {
  public static void main(String[] args) {
    Scanner scan = new Scanner (System.in);
    int n  = scan.nextInt() ;
    
    ArrayList<Integer> a = new ArrayList<>();
    for (int i = 0 ; i <n ; i++){
        a.add(scan.nextInt()) ;
      
    }
    System.out.println(Collections.max(a, null) - Collections.min(a,null));   
  }
}


Measured memory_bytes: 20820
N = int(input())
S = list(input().strip())

cnt1 = 0
cnt2 = 1
stamp_0x = 0


#print(S[cnt1]==S[cnt2])
while cnt1 < N:
    if cnt1 < N-1:
        if S[cnt1] != S[cnt2]:
            stamp_0x += 1
            cnt1 += 2
            cnt2 += 2
        
        else:
            cnt1 += 1
            cnt2 += 1
            continue
    else:
        cnt1 += 1

print(stamp_0x)


Measured memory_bytes: 6492
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pi 2*acos(0.0)
#define f first
#define s second
#define pb push_back
#define gap ' '
#define fastio {ios_base::sync_with_stdio(false);cin.tie(NULL);}
#define mod 998244353
#define MAX 1000000000000
#define N 105
ll w[N],v[N];
ll dp[N][100005];
ll n;
ll solve(ll i,ll wt)
{
    if(i==n) return 0;
    if(dp[i][wt]!=-1) return dp[i][wt];
    ll ans1=0,ans2=0;
    if(wt>=w[i])
    {
        ans1=v[i]+solve(i+1,wt-w[i]);
    }
    ans2=solve(i+1,wt);
    return dp[i][wt]=max(ans1,ans2);
}
int main()
{
    scanf("%d",&n);
    ll W;
    scanf("%lld",&W);
    for(ll i=0;i<n;i++)
    {
        scanf("%lld %lld",&w[i],&v[i]);
    }
    memset(dp,-1,sizeof dp);
    ll ans=solve(0,W);
    printf("%lld\n",ans);

}



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

int main(){
  int a,b,h,m;
 static const double pi = 3.141592653589793;
  cin >> a >> b >> h >> m;
  double degree = abs(((double)h/12+(double)m/60/12))*360-((double)m/60*360);
//  cout << (double)2*a*b*cos(pi/180*degree) << endl;
//  cout << cos(pi/180*degree) << endl;
  printf("%.10f\n", (double)sqrt(a*a +b*b -2*a*b*cos(pi/180*degree)));
}



Measured memory_bytes: 4212
#include <bits/stdc++.h>
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++)
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> wi;

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

  ll a, b, k;
  cin >> a >> b >> k;

  if(a>=k)a-=k;
  else if(a+b>k){
    b-=k-a;
    a=0;
  }
  else{
    a=0;
    b=0;
  }

  cout << a << " " << b << endl;

  return 0;
}

Measured memory_bytes: 3580