akhauriyash/Code-Regression huggingface dataset:
#pragma region Macros

#include <bits/stdc++.h>
using namespace std;

using ll = long long;
#define int ll
using vi = vector<int>;
using vvi = vector<vi>;

#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define ALL(x) (x).begin(), (x).end()
#define SIZE(x) ((ll)(x).size())
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))

template <class T>
bool chmax(T &a, const T &b) {
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chmin(T &a, const T &b) {
    if (b < a) {
        a = b;
        return 1;
    }
    return 0;
}

// debug methods
// usage: debug(x,y);
#define CHOOSE(a) CHOOSE2 a
#define CHOOSE2(a0, a1, a2, a3, a4, x, ...) x
#define debug_1(x1) cout << #x1 << ": " << x1 << endl
#define debug_2(x1, x2) cout << #x1 << ": " << x1 << ", " #x2 << ": " << x2 << endl
#define debug_3(x1, x2, x3) cout << #x1 << ": " << x1 << ", " #x2 << ": " << x2 << ", " #x3 << ": " << x3 << endl
#define debug_4(x1, x2, x3, x4) cout << #x1 << ": " << x1 << ", " #x2 << ": " << x2 << ", " #x3 << ": " << x3 << ", " #x4 << ": " << x4 << endl
#define debug_5(x1, x2, x3, x4, x5) cout << #x1 << ": " << x1 << ", " #x2 << ": " << x2 << ", " #x3 << ": " << x3 << ", " #x4 << ": " << x4 << ", " #x5 << ": " << x5 << endl
#ifdef _DEBUG
#define debug(...)                                                        \
    CHOOSE((__VA_ARGS__, debug_5, debug_4, debug_3, debug_2, debug_1, ~)) \
    (__VA_ARGS__)
#else
#define debug(...)
#endif

#pragma endregion

void Main() {
    string N;
    cin >> N;
    if (find(ALL(N), '7') == N.end()) {
        cout << "No";
        return;
    }

    cout << "Yes";
    return;
}

#pragma region main
signed main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    Main();
    cout << flush;
}
#pragma endregion


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

int main()
{
  int n;
  cin >> n;
  string s, t;
  cin >> s >> t;
  int i = 0;
  for (; i < n; ++i)
  {
    if (s.substr(i, s.size() - i) == t.substr(0, t.size() - i))
      break;
  }
  cout << (n - i) + i * 2 << endl;

  return 0;
}

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

int main()
{
    int x, y, i;
    map <int, int> m;
    m[1] = 1;
    m[3] = 1;
    m[5] = 1;
    m[7] = 1;
    m[8] = 1;
    m[10] = 1;
    m[12] = 1;
    m[4] = 2;
    m[6] = 2;
    m[9] = 2;
    m[11] = 2;
    m[2] = 3;
    cin>>x>>y;
    if(m[x] == m[y]) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    return 0;
}


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

int main() {
    int h,w;
    cin>>h>>w;
    int a[h][w];
    for (int i=0;i<h;i++)
        for (int j=0;j<w;j++)
            cin>>a[i][j];
    int ans=1e9;
    for (int i=0;i<h;i++)
        for (int j=0;j<w;j++) {
            int sum=0;
            for (int k=0;k<h;k++)
                for (int l=0;l<w;l++)
                    sum+=min(abs(i-k),abs(j-l))*a[k][l];
            ans=min(ans,sum);
        }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 3100
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
int main() {
  int M,D,d1,d10,cnt=0;
  cin>>M>>D;
  
  for(int i=1;i<=M;i++){
  	for(int j=22;j<=D;j++){
      d10=j/10;
  	  d1=j%10;
      if(i==d1*d10&&(d1>=2&&d10>=2)) cnt++;
    }
  }
  
  cout<<cnt<<endl;
}


Measured memory_bytes: 256
n = gets.chomp.to_i
v_arr = gets.chomp.split(" ").map(&:to_i)
c_arr = gets.chomp.split(" ").map(&:to_i)

result = 0
v_arr.zip(c_arr).each do |v, c|
  result += (v - c) if v > c
end

puts result



Measured memory_bytes: 3836
main :: IO ()
main = do
  k <- readLn :: IO Int
  if k `mod` 7 == 0
    then solve ((9 * k) `div` 7)
    else solve  (9 * k)

powMod :: Integral int => int -> int -> int -> int
powMod base ex _mod
  | ex == 0   = 1
  | even ex   = square (powMod base (ex `div` 2) _mod) `mod` _mod
  | otherwise = (base * (powMod base (ex - 1) _mod)) `mod` _mod
  where
    square x = x * x

solve :: Int -> IO ()
solve l
  | l `mod` 2 == 0 = print (-1)
  | l `mod` 5 == 0 = print (-1)
  | otherwise = print $ head [i | i <- [1 .. 9000000], powMod 10 i l == 1]

Measured memory_bytes: 3900
S=input()

SR=S[::-1]

A=[0]*len(S)
if SR[0]=="W":
    A[0]=1


for i in range(1,len(S)):
    if SR[i]=="W":
        A[i]=A[i-1]+1
    else:
        A[i]=A[i-1]

ANS=0

for i in range(len(S)):
    if SR[i]=="B":
        ANS+=A[i]

print(ANS)
    

Measured memory_bytes: 11240
#include<bits/stdc++.h>
#define p_ pair<int,int>
#define mp_ make_pair
#define ll long long
#define pb push_back
#define fi first
#define se second
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define show1(a) cout<<#a<<" = "<<a<<endl
#define show2(a,b) cout<<#a<<" = "<<a<<"; "<<#b<<" = "<<b<<endl
using namespace std;
const ll INF = 1LL<<60;
const int inf = 1<<30;
const int maxn = 2e5+5;
inline void fastio() {ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);}
int vis[maxn];
int main()
{
    fastio();
    int n,m,cnt=0,l,r;
    cin>>n>>m;
    if(n%2==0) n--;
    if(m&1){
        l=1,r=n/2;
        while(1){
            if(cnt==m) return 0;
            if(l>=r) break;
            cout<<l<<" "<<r<<endl;
            l++,r--,cnt++;
        }
        l=n/2+1,r=n%2==0?n-1:n;
        while(1){
            if(cnt==m) return 0;
            if(l>=r) break;
            cout<<l<<" "<<r<<endl;
            l++,r--,cnt++;
        }
    }
    else{
        l=1,r=n/2+1;
        while(1){
            if(cnt==m) return 0;
            if(l>=r) break;
            cout<<l<<" "<<r<<endl;
            l++,r--,cnt++;
        }
        l=n/2+2,r=n;
        while(1){
            if(cnt==m) return 0;
            if(l>=r) break;
            cout<<l<<" "<<r<<endl;
            l++,r--,cnt++;
        }
    }
    return 0;
}


Measured memory_bytes: 3612
#include<stdio.h>
#include<stdlib.h>
#include<iostream>
#include<string>
#include<algorithm>
#include<vector> 
#include<limits>
#include<numeric>
#include<type_traits>
#include<math.h>
#include<fstream>
#include<set>
using namespace std;
typedef long long ll;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repi(i,a,b) for(int i = (int)(a); i < (int)(b); i++)
#define out(str) cout << str << endl
#define ALL(a) (a).begin(),(a).end()
#define INF (1<<29)

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

int N,cnt,a;

int main(){
    cin>>N;
    rep(i,N){
        cin>>a;
        if(a!=(i+1))cnt++;
    }
    if(cnt<3)out("YES");
    else out("NO");
    
    
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define rep(i, s, n) for (int i = (s); i < (int)(n); i++)
#define all(v) v.begin(), v.end()
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
using ll = long long;
const ll MOD = 1e9+7; ll LLINF = 1LL << 60; int INF = INT_MAX;

//
int main(){
    int n; cin>>n;
    vector<int> h(n);
    rep(i,0,n) cin>>h[i];
    int maxi=0;
    int cnt=0;
    rep(i,0,n){
        if(h[i]>=maxi){
            cnt++;
            maxi=h[i];
        }
    }
    cout<<cnt<<endl;
}

Measured memory_bytes: 256
ans=[11, 31, 41, 61, 71, 101, 131, 151, 181, 191, 211, 241, 251, 271, 281, 311, 331, 401, 421, 431, 461, 491, 521, 541, 571, 601, 631, 641, 661, 691, 701, 751, 761, 811, 821, 881, 911, 941, 971, 991, 1021, 1031, 1051, 1061, 1091, 1151, 1171, 1181, 1201, 1231, 1291, 1301, 1321, 1361, 1381]
for i in range(int(input())):
    print(ans[i],end=" ")

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
ll mod = 1000000007;

ll r(ll x, ll y) {
  if (y == 0) return 1;
  else if (y % 2 == 0) return r(x, y/2) * r(x, y/2) % mod;
  else return x * r(x, (y-1)/2) % mod * r(x, (y-1)/2) % mod;
}

int main() {
  int n;
  cin >> n;
  vector<int> pr(1, 2);
  if (n == 2) cout << 2 <<endl;
  else {
  for (int i = 3; i < 1000000; i++) {
    bool f = 1;
    for (int x : pr) {
      if (i % x == 0) {
        f = 0;
        break;
      }
    }
    if (f) {
      pr.push_back(i);
      if (i >= n) {
        cout << i <<endl;
        break;
      }
    }
  }
  }
}

Measured memory_bytes: 384
#include <stdio.h>
int main(void){
    int i,j,d;
    for(i=0;i<100;i++){
        for(j=0;j<100;j++){
            scanf("%d",&d);
            if(d==0){
                break;
            }else{
                printf("Case %d: %d\n",i*100+j+1,d);
            }
        }
    }
    return 0;
}

Measured memory_bytes: 596
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <unordered_map>
#include <map>
#include <queue>
#include <set>
#include <unordered_set>
#include <algorithm>
#include <cctype>
#define rep(x,y,z) for(long long x=y;x<z;++x)
#define dwn(x,y,z) for(long long x=y;x>z;--x)
using namespace std;

typedef long long ll;

ll h, w;

bool IsBorder(ll i, ll j) {
    return (i == -1 || j == -1 || i == h || j == w);
}

ll GetId(ll i, ll j) {
    return i * w + j;
}

pair<ll, ll> GetCoords(ll id) {
    return make_pair(id / w, id % w);
}

int main() {
    vector<pair<ll, ll>> sh = {{1, 0}, {0, 1}, {-1, 0}, {0, -1}};
    cin >> h >> w;
    vector<string> v(h);
    rep(i,0,h) {
        cin >> v[i];
    }
    ll size = h * w;
    vector<vector<ll>> g(size);
    rep(i,0,h) {
        rep(j,0,w) {
            rep(k,0,4) {
                ll x = i + sh[k].first;
                ll y = j + sh[k].second;
                ll id = GetId(i, j);
                ll sid = GetId(x, y);
                if (!IsBorder(x, y)) {
                    if (v[i][j] != v[x][y]) {
                        g[id].push_back(sid);
                    }
                }
            }
        }
    }
    vector<bool> used(size);
    vector<pair<ll, ll>> res;
    rep(i,0,size) {
        if (!used[i]) {
            ll bl = 0, wh = 0;
            queue<pair<ll, ll>> q_;
            q_.push(make_pair(i, -1));
            used[i] = true;
            while(!q_.empty()) {
                ll id = q_.front().first;
                ll par = q_.front().second;
                pair<ll, ll> coord = GetCoords(id);
                if (v[coord.first][coord.second] == '#') {
                    ++bl;
                } else {
                    ++wh;
                }
                rep(j,0, g[id].size()) {
                    ll sid = g[id][j];
                    if (sid == par || used[sid]) {
                        continue;
                    }
                    used[sid] = true;
                    q_.push(make_pair(sid, id));
                }
                q_.pop();
            }
            res.push_back(make_pair(bl, wh));
        }
    }
    ll ans = 0;
    rep(i,0,res.size()) {
        ans += res[i].first * res[i].second;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 11776
#include "bits/stdc++.h"
using namespace std;
const int MAX = 700000;
const int MOD = 1000000007;

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

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

// 二項係数計算
long long COM(int n, int k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
/*第二引数で第一引数を割ったときの切り上げの計算*/
long long int maxtime(long long int x, long long int y){
	return(x + y - 1) / y;

}
/*最大公約数*/
long long int lcm(long long int number1, long long int number2) {
	long long int m = number1;
	long long int n = number2;

	if (number2 > number1) {
		m = number2;
		n = number1;
	}
	long long int s = -1;
	while (s != 0) {
		s = m % n;
		m = n;
		n = s;
	}
	return m;
}
/*最大公倍数*/
long long int gcd(long long int number1, long long int number2) {
	long long int m = number1;
	long long int n = number2;
	return m / lcm(m, n) * n;
}
/*逆元計算*/
long long int  modinv(long long a, long long m) {
	long long int b = m, u = 1, v = 0;
	while (b) {
		long long int t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}
// index が条件を満たすかどうか
vector<long long int >meguru;
bool isOK(int index, int key) {
	if (meguru[index] >= key) return true;
	else return false;
}
// 汎用的な二分探索のテンプレ
int binary_search(int key) {
	int left = -1; //「index = 0」が条件を満たすこともあるので、初期値は -1
	int right = (int)meguru.size(); // 「index = a.size()-1」が条件を満たさないこともあるので、初期値は a.size()
	/* どんな二分探索でもここの書き方を変えずにできる！ */
	while (right - left > 1) {
		int mid = left + (right - left) / 2;

		if (isOK(mid, key)) right = mid;
		else left = mid;
	}
	/* left は条件を満たさない最大の値、right は条件を満たす最小の値になっている */
	return right;
}
long long modpow(long long a, long long n, long long mod) {
	long long res = 1; 
	while (n > 0) {
		if (n & 1) res = res * a % mod;
		a = a * a % mod;
		n >>= 1;
	}
	return res;
}

int main() {
	int n;
	cin >> n;
	int AC, WA, TLE, RE;
	AC = 0;
	WA = 0;
	TLE = 0;
	RE = 0;
	for (int i = 0; i < n; i++) {
		string s;
		cin >> s;
		if (s[0] == 'A') {
			AC++;
		}
		else if (s[0] == 'W') {
			WA++;
		}
		else if (s[0] == 'T') {
			TLE++;
		}
		else if (s[0] == 'R') {
			RE++;
		}
	}
	cout << "AC x "<<AC << endl;
	cout << "WA x "<<WA<<endl;
	cout << "TLE x "<<TLE<<endl;
	cout << "RE x "<<RE<<endl;
}

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

int main(){ 
	long long a,b;
	cin >> a >> b;
	if(b & 1){
		cout << "No";
		return 0;
	}

	cout << (a * 4 >= b && a * 2 <= b? "Yes" : "No");
}

Measured memory_bytes: 3632
import java.util.NoSuchElementException;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        try {
            String s = sc.nextLine();
            String p = sc.nextLine();
            String ss = s.concat(s);
            boolean hasAString = ss.contains(p);
            System.out.println(hasAString ? "Yes" : "No");
        } catch (IllegalTestCaseException
                | NoSuchElementException
                | NumberFormatException e) {
            System.out.println(e);
        }
    }

    private static class IllegalTestCaseException extends RuntimeException {
        IllegalTestCaseException() {
            super("Illegal condition.");
        }
    }
}



Measured memory_bytes: 26344
/*
 *  author : Atul Anand   
 *  created on : Sat Mar 14 2020
 */

import java.io.*;
import java.util.*;

public class Main{
    
    public static void main(String[] args) throws IOException {
        long H = in.nextLong();
        long W = in.nextLong();
        if(H == 1 || W == 1){
            println(1);
        }
        else{
            long ans = H*W;
            if(ans % 2 == 0){
                println(ans/2);
            }
            else{
                println(ans/2 + 1);
            }
        }
        
        in.close();
        out.close();
    }

    static int MIN = Integer.MIN_VALUE;
    static int MAX = Integer.MAX_VALUE;
    static Reader in = new Reader();
    static PrintWriter out = new PrintWriter(System.out);
    static void read(int arr[], int N) throws IOException{ for(int i = 0; i < N; i++){ arr[i] = in.nextInt(); } }
    static void read(long arr[], int N) throws IOException{ for(int i = 0; i < N; i++){ arr[i] = in.nextLong(); } }
    static void read(String arr[], int N) throws IOException{ for(int i = 0; i < N; i++){ arr[i] = in.next(); } }
    static void print(Object O){ out.print(O); }
    static void println(Object O){ out.println(O); }
    static void print(int arr[]){ for(int i = 0; i < arr.length; i++){ print(arr[i]+" "); } println(""); }
    static void print(int arr[][]){ for(int i = 0; i < arr.length; i++){ print(arr[i]); } }
    static void debug(Object O){ System.out.println(O); }
}

class Reader {
    BufferedReader reader;
    StringTokenizer tokenizer;

    Reader() {
        reader = new BufferedReader(new InputStreamReader(System.in));
        tokenizer = new StringTokenizer("");
    }

    String next() throws IOException {
        while (!tokenizer.hasMoreTokens() ) { 
            tokenizer = new StringTokenizer(reader.readLine()); 
        }
        return tokenizer.nextToken();
    }

    int nextInt() throws IOException { 
        return Integer.parseInt(next()); 
    }
    
    double nextDouble() throws IOException { 
        return Double.parseDouble(next());
    }
    
    long nextLong() throws IOException { 
        return Long.parseLong(next()); 
    }
    
    String nextLine() throws IOException { 
        return reader.readLine(); 
    }
    
    void close() throws IOException { 
        reader.close(); 
    }
}

Measured memory_bytes: 22356
#include<stdio.h>

void trace(int A[], int N){
	int i;
	for(i = 0; i < N; i++){
		if ( i > 0 ) printf(" ");
		printf("%d", A[i]);
	}
	printf("\n");
}

void insertationSort(int A[], int N){
	int j,i,v;
	for ( i = 1; i < N; i++ ){
		v = A[i];
		j = i - 1;
		while( j >= 0 && A[j] > v ){
			A[j + 1] = A[j];
			j--;
		}
		A[j + 1] = v;
		trace(A, N);
	}
}

int main(){
	int N,i,j;
	int A[100];
	
	scanf("%d", &N);
	for( i = 0; i < N; i++ ) scanf("%d", &A[i]);
	
	trace(A, N);
	insertationSort(A, N);
	
	return 0;
}
		
	

Measured memory_bytes: 2664
import java.util.*;

public class Main {


    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);
        int time_1 = 100000;
        int time_2 = 4;

        int D = sc.nextInt();
        int[] c = new int[27];
        int[] t = new int[D + 1];
        int[] last_day = new int[27];
        Arrays.fill(last_day, 0);
        int[][] s = new int[D + 1][27];
        for (int i = 1; i <= 26; i++) {
            c[i] = sc.nextInt();
        }
        for (int i = 1; i <= D; i++) {
            for (int j = 1; j <= 26; j++) {
                s[i][j] = sc.nextInt();
            }
        }

        for (int i = 1; i <= D; i++) {
            Random random = new Random();
            t[i] = 1 + random.nextInt(26);
        }
        int[] last_array = t;

        long last_sum = 0;
        for (int j = 0; j < time_1; j++) {
            long tmp_sum = 0;
            Arrays.fill(last_day,0);
            for (int k = 0; k < time_2; k++) {
                Random random = new Random();
                int d = 1 + random.nextInt(D);
                int q = 1 + random.nextInt(D);
                int tmp = t[d];
                t[d] = t[q];
                t[q] = tmp;
            }
            for (int i = 1; i <= D; i++) {
                last_day[t[i]] = i;
                tmp_sum += calcS(c, s, t[i], i, last_day);
            }
            if (tmp_sum > last_sum) {
                last_array = t;
                last_sum = tmp_sum;
            } else {
                t = last_array;
            }
        }


        for (int i = 1; i <= D; i++) {
            System.out.println(t[i]);
        }

    }

    private static long calcS(int[] c, int[][] s, int kaisai, int day, int[] last_day) {

        long loss = 0;
        for (int i = 1; i <= 26; i++) {
            if (i == kaisai) {
                last_day[i] = day;
                continue;
            }
            loss -= c[i] * (day - last_day[i]);
        }

        long plus = s[day][kaisai];
        return plus + loss;
    }

}


Measured memory_bytes: 46584
#include <bits/stdc++.h>
#include <vector>
#include <math.h>

using namespace std;



int main(){

 string s; cin>>s;
  int n = s.length(),flag = 0;

  if(s[0] != 'A'){
    flag = 1;
    cout<<"WA"<<endl;
    return 0; }

    int cnt=0,pos=-1;
    for(int i=2;i<n-1;i++){
        if(s[i] == 'C'){
            cnt++;
            pos = i;}
    }

  if(cnt!=1 || pos == -1){
     flag = 1;
    cout<<"WA"<<endl;
    return 0;}


 for(int i=0;i<n;i++)
    if( (s[i] >= 'a' && s[i]<='z') && s[i] != 'C' && s[i]!= 'A')
     continue;
   else if(i != 0 && i!= pos){
        //cout<<i<<endl;
    cout<<"WA";
    return 0;}

  if(flag == 0)
  cout<<"AC"<<endl;


return 0;

}


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

int main(){
    
    int h,w;
    while(cin >> h >> w && !(h==0 && w==0)){
        for(int i=0; i < h; ++i){
            if   (i==0 || i==h-1) cout << string(w, '#') << endl;
            else  cout << '#' << string(w-2, '.') << '#' << endl;
        }
        cout << endl;
    }
    
    return 0;
}


Measured memory_bytes: 3008
#include <iostream>
#include <fstream>
#include <vector>
#include <algorithm>
#include <queue>
#include <map>
#include <random>
#include <cstdio>
#include <cstring>
#include <cmath>

// for i in f..<t {... : as Swift
#define forin(i, f, t) for(auto i = f; i < t; i++)

using namespace std;
using ll = long long;


int main() {
    ll n;
    cin >> n;
    vector<ll> a(n);
    for (auto i = 0; i < n; i++)
        cin >> a[i];
    
    vector<ll> ca(n);
    ll sum = 0;
    for (auto i = 0; i < n; i++) {
        sum += a[i];
        ca[i] = sum;
    }
    
    ll shList[n][2];
    for (auto m = 1, lsh = 0; m < n - 2; m++) {
        auto l = ca[lsh], r = ca[m] - ca[lsh];
        while (r - l > a[lsh + 1]) {
            lsh++;
            l = ca[lsh];
            r = ca[m] - ca[lsh];
        }
        shList[m][0] = lsh;
    }
    for (auto m = n - 3, rsh = n - 2; m >= 1; m--) {
        auto l = ca[rsh] - ca[m], r = ca[n - 1] - ca[rsh];
        while (l - r > a[rsh]) {
            rsh--;
            l = ca[rsh] - ca[m];
            r = ca[n - 1] - ca[rsh];
        }
        shList[m][1] = rsh;
    }
    
    ll diffMin = 1000000000;
    for (auto m = 1; m < n - 2; m++) {
        auto lsh = shList[m][0];
        auto rsh = shList[m][1];
        ll sums[4] = {
            ca[lsh],
            ca[m] - ca[lsh],
            ca[rsh] - ca[m],
            ca[n - 1] - ca[rsh],
        };
        ll Max = max(max(sums[0], sums[1]), max(sums[2], sums[3]));
        ll Min = min(min(sums[0], sums[1]), min(sums[2], sums[3]));
        diffMin = min(diffMin, Max - Min);
        cerr << shList[m][0] << ' ' << m << ' ' << shList[m][1] << ": " << Max - Min << endl;
    }
    cout << diffMin << endl;
}



Measured memory_bytes: 6528
# でつoO(YOU PLAY WITH THE CARDS YOU'RE DEALT..)
from collections import deque
import sys
def main(N, M, G, R, I, root):
    P = [-1] * N
    D = [-1] * N
    D[root] = 0
    q = deque()
    q.append(root)
    while q:
        v = q.popleft()
        for to in G[v]:
            I[to] -= 1
            if I[to] == 0:
                p = pd = -1
                for r in R[to]:
                    if D[r] > pd:
                        pd = D[r]
                        p = r
                D[to] = pd + 1
                P[to] = p
                q.append(to)
    for p in P:
        print(p + 1)

if __name__ == '__main__':
    input = sys.stdin.readline
    N, M = map(int, input().split())
    G = [[] for _ in range(N)]
    R = [[] for _ in range(N)]
    I = [0] * N
    for _ in range(N - 1 + M):
        a, b = map(int, input().split())
        a, b = a - 1, b - 1
        G[a].append(b)
        R[b].append(a)
        I[b] += 1
    main(N, M, G, R, I, I.index(0))


Measured memory_bytes: 99900
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
    int n;
    cin>>n;
    if(n%1000==0)
        cout<<"0";
    else{
        int k=n/1000;
        k++;
        k=k*1000;
        cout<<k-n;
    }
}


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

int main(){
    int n;
    cin >> n;
    int a[30];

    for(int i = 0;i < n;i++){
        cin >> a[i];
    }

    int cnt = 0;

    for(int i = 1;i < n-1;i++){
        if(a[i-1] < a[i] && a[i] < a[i+1]){
            cnt++;
        }else if(a[i-1] > a[i] && a[i] > a[i+1]){
            cnt++;
        }
    }

    cout << cnt << endl;

    return 0;
}




Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define rrep(i,n) for (int i = (n)-1; i >= 0; i--)
#define rep2(i,s,n) for (int i = (s); i < (n); ++i)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define pb push_back
#define eb emplace_back
#define vi vector<int>
#define vvi vector<vector<int>>
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vd vector<double>
#define vs vector<string>
#define vc vector<char>
#define vb vector<bool>
#define vp vector<P>
using namespace std;
using ll = long long;
using P = pair<int,int>;
using LP = pair<ll,ll>;
template<class S,class T> istream& operator>>(istream &is,pair<S,T> &p) { return is >> p.first >> p.second; }
template<class S,class T> ostream& operator<<(ostream &os,const pair<S,T> &p) { return os<<'{'<<p.first<<","<<p.second<<'}'; }
template<class T> istream& operator>>(istream &is,vector<T> &v) { for(T &t:v){is>>t;} return is; }
template<class T> ostream& operator<<(ostream &os,const vector<T> &v) { os<<'[';rep(i,v.size())os<<v[i]<<(i==v.size()-1?']':','); return os; }
void Yes(bool b) { cout << (b ? "Yes" : "No") << endl; }
void YES(bool b) { cout << (b ? "YES" : "NO") << endl; }
template<class T> bool chmin(T& a,T b) {if(a > b){a = b; return true;} return false;}
template<class T> bool chmax(T& a,T b) {if(a < b){a = b; return true;} return false;}
const int inf = 1001001001;
const ll linf = 1001001001001001001;

class unionfind {
    int n;
    vector<int> par,rank;
public:
    unionfind(int n):n(n),par(n,-1),rank(n,0) {}
    int root(int x) {
        if(par[x] < 0) return x;
        else return par[x] = root(par[x]);
    }
    bool same(int x,int y) { return root(x) == root(y); };
    bool merge(int x,int y) {
        x = root(x); y = root(y);
        if(x == y) return false;
        if(rank[x] < rank[y]) swap(x,y);
        if(rank[x] == rank[y]) rank[x]++;
        par[x] += par[y];
        par[y] = x;
        return true;
    }
    int size(int x) { return -par[root(x)]; };
    int number_of_components() {
        int ret = 0;
        rep(i,n) if(par[i] < 0) ret++;
        return ret;
    }
    bool connected() { return number_of_components() == 1; }
};

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr); cout.tie(nullptr);
    int n,m;
    cin >> n >> m;
    unionfind uf(n);
    rep(_,m) {
        int x,y,z;
        cin >> x >> y >> z;
        x--; y--;
        uf.merge(x,y);
    }
    cout << uf.number_of_components() << endl;
}


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

namespace ziyuutyou
{
    class Program
    {
        static void Main(string[] args)
        {
            var aaa = Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);

            Console.WriteLine((aaa[0] + aaa[1]) % 24);
                
        }
    }
}


Measured memory_bytes: 11092
d,g = list(map(int,input().split()))
a = [list(map(int,input().split())) for _ in range(d)]
s = set(range(d))
ans = float("Inf")
x = []
for i in zip(*a):
    x.append(list(i))
c = []
for i in range(2**d):
    b = []
    for j in range(d):
        if i>>j & 1:
            b.append(j)
    c.append(b)
for i in c:
    d = 0
    count = 0
    for j in i:
        d += (100*(j+1)) * a[j][0] + a[j][1]
        count += a[j][0]
    if d < g:
        for x in sorted(s - set(i),reverse=True):
            for y in range(a[x][0]):
                if d >= g:
                    break
                d += 100*(x+1)
                count += 1
    if d < g:continue
    ans = min(ans,count)
print(ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define DAU  ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define PLEC return 0;
using namespace std;
int k, v[] = {0, 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
int main() {
    DAU
    cin >> k;
    cout << v[k];
    PLEC
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
const long long INF = 1LL << 60;
using Graph = vector<vector<int>>;

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

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

inline int gcd(int a, int b) { return (a%b == 0) ? b : gcd(b, a%b); }
inline int fac(int n) { return (n==0) ? 1 : n * fac(n - 1); }

int main() {
    ll n;
    cin >> n;
    cout << n*(n-1)/2 << endl;

    return 0;
}

Measured memory_bytes: 3640
s = input()
S = []
for i in s:
    S.append(int(i))

A = [S[0]]
B = [S[1], -S[1]]
C = [S[2], -S[2]]
D = [S[3], -S[3]]

E = []
for i in A:
    for j in B:
        for k in C:
            for l in D:
                if i + j + k + l == 7:
                    E = [i, j, k, l]
                    break
s = ""
for i in range(4):
    if i == 0:
        s += str(E[i])
    else:
        if E[i] < 0:
            s += str(E[i])
        else:
            s += "+" + str(E[i])
print(s + "=7")

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

#define repr(i,a,b) for(int i=a, i##_len=(b); i<i##_len; ++i)
#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define irepr(i,a,b) for(int i=a, i##_len=(b); i>=i##_len; --i)
#define irep(i,n) for(int i=n; i>=0; --i)

#define printline(str) cout << str << "\n"

#define lint long long

template<class T,std::size_t N>
void printArray(T (&arr)[N], string del = {','}){
  cout << arr[0];
  repr(i, 1, N){
    cout << del << arr[i];
  }
  cout << "\n";
}

constexpr int maxInt = 1000000000 + 7;


int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  string S;
  cin >> S;
  //int numS[100000];
  int N = S.size();

  lint dp[13] = {0};

  dp[0] = 1;

  rep(i, N){
    lint nextDp[13] = {0};
    if( S[i] == '?'){
      rep(j,10){
        rep(k,13){
          nextDp[ (10*k + j)%13 ] += dp[k];
          nextDp[ (10*k + j)%13 ] %= maxInt;
        }
      }

    }else{
      int j = (int)(S[i] - '0');
      rep(k, 13){
        nextDp[ (10*k + j)%13 ] += dp[k];
        nextDp[ (10*k + j)%13 ] %= maxInt;
      }
    }
      rep(k,13){
        dp[k] = nextDp[k];
      }
  }
  printline(dp[5]);
}

Measured memory_bytes: 512
import sys
sys.setrecursionlimit(10**7)
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x) - 1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def II(): return int(sys.stdin.readline())
def SI(): return sys.stdin.readline().strip()
INF = 10 ** 18
MOD = 10 ** 9 + 7

def main(): 
    N = II()
    P= LI()

    P_sort = sorted(P)

    diff = 0
    for i,j in zip(P, P_sort):
        if i != j:
            diff += 1
    if diff ==0 or diff ==2:
        print('YES')
    else:
        print('NO')

main()

Measured memory_bytes: 3064
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<string>
#include<iomanip>
#include<sstream>
#include<map>
#include<set>
#include<cmath>
using namespace std;
template<typename A, size_t N, typename T>
void Fill(A(&array)[N], const T& val) {
	std::fill((T*)array, (T*)(array + N), val);
}
#define rep(i,n) for(int i = 0;i < n;i++)
#define req(i,n) for(int i = 1;i <=n;i++)
#define rrep(i,n) for(int i = n -1;i >= 0;i--)
#define ALL(a) a.begin(),a.end()
#define RALL(a) a.rbegin(),a.rend()
typedef long long ll;
typedef long double ld;
const ll INF = 1LL << 60;
const int inf = 1 << 25;
ll n, m, k, y,a, q, d, w = 0, sum = 0, ans = 0; string s;
const int MOD = 1000000007;
int main(void) {
	cin >> n; vector<ll> a(n);
	rep(i, n) cin >> a[i];
	sort(RALL(a));
	for(;w < n/2;w++) ans += a[w];
	for (w = 1; w <= (n-1) / 2; w++)ans += a[w];
	cout << ans << endl;
}

Measured memory_bytes: 4844
def f(x):
    if x == 2:
        return 1
    if x < 2 or x % 2 == 0:
        return 0
    i = 3
    while i <= x ** (1/2):
        if x % i == 0:
            return 0
        i += 2
    return 1
    
while True:
    n = int(input())
    if n == 0:
        break
    else:
        a = 0
        for i in range(2, n // 2 + 1):
            m = n - i
            if f(m) == 1 and f(i) == 1:
                a += 1
        print(a)


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

int main()
{
	char c;
	int x, y, s;
	vector<vector<int>> b(10, vector<int>(10));
	while (cin >> x >> c >> y >> c >> s) {
		if (s == 1) {
			for (int i = -1; i <= 1; i++) {
				for (int j = abs(i) - 1; j <= 1 - abs(i); j++) {
					if (x + i >= 0 && x + i <= 9 && y + j >= 0 && y + j <= 9) {
						b[x + i][y + j]++;
					}
				}
			}
		}
		else if (s == 2) {
			for (int i = -1; i <= 1; i++) {
				for (int j = -1; j <= 1; j++) {
					if (x + i >= 0 && x + i <= 9 && y + j >= 0 && y + j <= 9) {
						b[x + i][y + j]++;
					}
				}
			}
		}
		else {
			for (int i = -2; i <= 2; i++) {
				for (int j = abs(i) - 2; j <= 2 - abs(i); j++) {
					if (x + i >= 0 && x + i <= 9 && y + j >= 0 && y + j <= 9) {
						b[x + i][y + j]++;
					}
				}
			}
		}
	}
	int ma = 0, cnt = 0;
	for (int i = 0; i <= 9; i++) {
		for (int j = 0; j <= 9; j++) {
			if (b[i][j]) {
				cnt++;
				ma = max(ma, b[i][j]);
			}
		}
	}
	cout << 100 - cnt << endl;
	cout << ma << endl;
	return 0;
}

Measured memory_bytes: 3100
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
    public static void main(String[] args) {

        BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
        String word;
        try {
            word = reader.readLine();
            int num = Integer.parseInt(word);
            int ans = num * num * num;
            System.out.println(ans);
        } catch (IOException e) {
            e.printStackTrace();
        } finally {
            try {
                reader.close();
            } catch (IOException e) {
                e.printStackTrace();
            }
        }

    }
}

Measured memory_bytes: 24188
from bisect import bisect_left
n = int(input())
l = [int(i) for i in input().split()]
l.sort()
ans = 0
for i in range(n-2):
    for j in range(i+1, n-1):
        ans += bisect_left(l, l[i]+l[j]) - j - 1
print(ans)

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

using namespace std;

using VI = vector<int>;
using VVI = vector<VI>;
using VB = vector<bool>;
using VVB = vector<VB>;
using VD = vector<double>;
using VVD = vector<VD>;
using VS = vector<string>;
using PII = pair<int, int>;
using VPII = vector<PII>;
using VL = vector<long long>;
using VVL = vector<VL>;

#define sz(var) (int)var.size()
#define REP(var, start, end) for(int var = start; var < (int)end; ++var)
#define REPC(var, start, end) for(int var = start; var <= (int)end; ++var)
#define CLEAR(var, with) memset(var, with, sizeof(var))
#define ALL(x) x.begin(), x.end()
#define LL long long
#define ULL unsigned long long
#define TIME cout << "Time elapsed: " << 1000 * clock() / CLOCKS_PER_SEC << "ms" << endl;

int w, h, n;
VVI grid;
void colouring(int x, int y, int a)
{
	if(a == 1) {
		for(int i = 0; i < h; ++i)
			for(int j = 0; j < x; ++j)
				grid[i][j] = 1;
	}
	else if(a == 2) {
		for(int i = 0; i < h; ++i)
			for(int j = x; j < w; ++j)
				grid[i][j] = 1;
	}
	else if(a == 3) {
		for(int i = h - y; i < h; ++i)
			for(int j = 0; j < w; ++j)
				grid[i][j] = 1;
	}
	else { // a == 4
		for(int i = 0; i < h - y; ++i)
			for(int j = 0; j < w; ++j)
				grid[i][j] = 1;
	}
	// REP(i, 0, h) {
	// 	REP(j, 0, w)
	// 		cerr << grid[i][j] << " ";
	// 	cerr << endl;
	// }
}

int whiteColour()
{
	grid.assign(h, VI(w, 0));

	int x, y, a;
	while(n--)
	{
		cin >> x >> y >> a;
		colouring(x, y, a);
	}

	int ret = 0;
	REP(i, 0, h) REP(j, 0, w) ret += grid[i][j] == 0;
	return ret;
}

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
#ifndef ONLINE_JUDGE
	//freopen("tmp.in", "r", stdin);
	//freopen("tmp.out", "w", stderr);
#endif
	cin >> w >> h >> n;

	cout << whiteColour() << endl;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vb=vector<bool>;
using vvb=vector<vb>;
using vd=vector<double>;
using vvd=vector<vd>;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using pll=pair<ll,ll>;
using tll=tuple<ll,ll>;
using vs=vector<string>;
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rep(i,n) range(i,0,n)
#define range(i,a,n) for(ll i=(a);i<(n);i++)
#define LINF ((ll)1ll<<60)
#define INF ((int)1<<30)
#define EPS (1e-9)
#define MOD (1000000007ll)
#define fcout(a) cout<<setprecision(a)<<fixed
#define fs first
#define sc second
#define PI 3.1415926535897932384

int dx[]={1,0,-1,0,1,-1,-1,1},dy[]={0,1,0,-1,1,1,-1,-1};
template<class T>bool chmax(T&a,T b){if(a<b){a=b; return true;}return false;}
template<class T>bool chmin(T&a,T b){if(a>b){a=b; return true;}return false;}
template<class S>S sum(vector<S>&a){return accumulate(all(a),S());}
template<class S>S max(vector<S>&a){return *max_element(all(a));}
template<class S>S min(vector<S>&a){return *max_element(all(a));}

template<class T>void puta(T&&t){cout<<t<<endl;}
template<class H,class...T>void puta(H&&h,T&&...t){cout<<h<<' ';puta(t...);}
template<class S,class T>void tf(bool b,S t,T f){if(b)puta(t);else puta(f);}
void OUT(bool b){tf(b,"YES","NO");}
void Out(bool b){tf(b,"Yes","No");}
void out(bool b){tf(b,"yes","no");}
template<class S,class T>ostream&operator<<(ostream&os,pair<S,T>p){os<<"["<<p.first<<", "<<p.second<<"]";return os;};
template<class S>auto&operator<<(ostream&os,vector<S>t){bool a=1;for(auto s:t){os<<(a?"":" ")<<s;a=0;}return os;}
template<class S>auto&operator>>(istream&is,vector<S>&t){for(S&a:t)cin>>a;return is;}

int popcnt(int x){return __builtin_popcount(x);}
int popcnt(ll x){return __builtin_popcountll(x);}
int bsr(int x){return 31 - __builtin_clz(x);}
int bsr(ll x){return 63 - __builtin_clzll(x);}
int bsf(int x){return __builtin_ctz(x);}
int bsf(ll x){return __builtin_ctzll(x);}

/*他のライブラリを入れる場所*/

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n,m,r;
	cin>>n>>m>>r;
	vi d(r);
	cin>>d;
	sort(all(d));
	vvl adj(n,vl(n,LINF));
	rep(i,m){
		int a,b,c;
		cin>>a>>b>>c;
		a--;b--;
		adj[a][b]=adj[b][a]=c;
	}
	rep(k,n)rep(i,n)rep(j,n)if(i!=j){
		chmin(adj[i][j],adj[i][k]+adj[k][j]);
	}
	ll ans=LINF;
	do{
		ll dist=0;
		rep(i,r-1){
			dist+=adj[d[i]-1][d[i+1]-1];
		}
		chmin(ans,dist);
	}while(next_permutation(all(d)));
	puta(ans);
	return 0;
}

Measured memory_bytes: 640
#include <stdio.h>


int main(void){
    int i, n, m, ab1[50], ab2[50], city[50]={0};
    
    scanf("%d %d", &n, &m);
    
    for(i=0; i<m; i++){
        scanf(" %d %d", &ab1[i], &ab2[i]);
    }
    
    for(i=0; i<m; i++){
        city[ab1[i]-1]++;
        city[ab2[i]-1]++;
        
    }
    
    for(i=0; i<n; i++){
        printf("%d\n", city[i] );
    }
    
    
    return 0;
    
}

Measured memory_bytes: 128
#include<iostream>
#include<map>
#include<set>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>
#include<queue>
#include<stack>
#include<limits>
#include<sstream> 
#include<unordered_map>      

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef int itn;

const int inf = numeric_limits<int>::max() >> 2;
const ll linf = numeric_limits<ll>::max() >> 2;
const ull ulinf = numeric_limits<ull>::max() >> 2;
const double pi = acos(-1);
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
const int dx8[8]={-1,0,1,-1,1,-1,0,1};
const int dy8[8]={-1,-1,-1,0,0,1,1,1};

#define p_queue(i) priority_queue<i> 
#define rp_queue(i) priority_queue<i, vector<i>, greater<i>> 
#define umap(i,j) unordered_map<i,j>
#define P(p) cout<<(p)<<endl
#define PS(p) cout<<(p)<< " "
#define PN cout << endl
#define rep(i,m,n) for(int i = (m); i < (int)(n); i++)
#define rrep(i,m,n) for(int i = (n-1); i >= (int)(m); i--)
#define inrep(n,a) for(int i = 0; i < (int)(n); i++)cin >> a[i];
#define mod(i) ((i)%(ll)(1e9 + 7))
#define divm(a,b) (mod(a * modpow((ll)b,(ll)(1e9+5))))
#define rsort(a,b,c) sort(a, b, greater<c>())
#define vsort(v) sort(v.begin(), v.end())
#define rvsort(v,c) sort(v.begin(), v.end(), greater<c>()) 
#define ft first
#define sd second
#define pb push_back
#define it insert
#define sz(x) ((int)(x).size())
#define lb(a,n,k) (lower_bound(a,a+n,k) - (a)) 
#define vlb(a,k)  (lower_bound(a.begin(),a.end(),k) - a.begin())
#define ub(a,n,k) (upper_bound(a,a+n,k) - (a)) 
#define vub(a,k)  (upper_bound(a.begin(),a.end(),k) - a.begin())
#define YES cout<<"YES"<< endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl  
#define yes cout<<"yes"<<endl
#define no cout<<"no"<<endl
#define ret return


ll modpow(ll i,ll j){ ll tmp=1; while(j){ if(j%2)tmp=mod(tmp*i);i=mod(i*i);j/=2;}return tmp;}
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }


/*
vector<string> split(const string &str, char sep){
    vector<string> v;
    stringstream ss(str);
    string buffer;
    while( getline(ss, buffer, sep) ) {
        v.push_back(buffer);
    }
    return v;
}
*/

/*
ll ncr[100][100];
ll nCr(int n, int r){if(n==r) ret ncr[n][r] = 1; if(r==0) ret ncr[n][r] = 1; if(r==1) ret ncr[n][r] = n;if(ncr[n][r]) ret ncr[n][r]; ret ncr[n][r] = nCr(n-1,r) + nCr(n-1,r-1);}

ll npr[100][100]={};
ll nPr(int n,int r){if(npr[n][r])ret npr[n][r];if(r==0)ret npr[n][r] = 1;if(r==1)ret npr[n][r] = n;ret npr[n][r] = n * nPr(n-1,r-1);}

ll nHr(int n,int r){ret nCr(n+r-1,r);}
*/

///////////////////////////////////////////////////////////////////////////

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

    int i = 0;
    while(1){
	if(i&1){
	    a -= d;

	    if(a <= 0){
		No;
		ret 0;
	    }
	}else{
	 
	    c -= b;
	    if(c <=0 ){
		Yes;
		ret 0;
	    }
	}
	i++;
    }
    return  0;
}


Measured memory_bytes: 3600
#include<bits/stdc++.h>
using namespace std;
#define set_null(a,n) memset(a,0,sizeof(a))
#define pi acos(-1)
#define ll long long int
#define fr(a,b) for(int i=a;i<b;i++)
#define modulo 1000000007

int main()
{
    int n;
    cin>>n;
    while(n>0)
    {
        int x=n%10;
        n=n/10;
        if(x==7){
            cout<<"Yes\n";
        return 0;
        }
    }

    cout<<"No\n";
    return 0;
}



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

#define rep(i, N) for(int i = 0;i < N;i++)

typedef long long ll;

const int mod = 1e9 + 7;

using namespace std;

/* 採点コード
	vector<int> t(D);
	rep(i, D) {
		cin >> t[i];
		t[i]--;
	}
	vector<int> last(26, 0);

	int v = 0;
	rep(i, D) {
		v += s[i][t[i]];
		last[t[i]] = i+1;
		rep(j, 26) {
			v -= c[j] * (i + 1 - last[j]);
		}
		cout << v << endl;
	}
	*/

int main(void) {
	int D; cin >> D;
	vector<int> c(26, 0);
	rep(i, 26)cin >> c[i];
	vector<vector<int>> s(D, vector<int>(26, 0));
	rep(i, D)rep(j, 26)cin >> s[i][j];

	vector<int> t(D, 0);
	vector<int> ans(D, 0);
	int best = 0;

	srand(time(NULL));
	/*
	auto start = clock();
	while (clock() - start < 1500) {
		int idx = rand() % D;
		t[idx] = rand() % 26;

		//採点
		vector<int> last(26, 0);
		int v = 0;
		rep(i, D) {
			v += s[i][t[i]];
			last[t[i]] = i + 1;
			rep(j, 26) {
				v -= c[j] * (i + 1 - last[j]);
			}
		}
		//採点
		if (best <= v) {
			ans = t;
		}
	}

	for (auto x : ans) {
		cout << x + 1 << endl;
	}

	vector<int> last(26, 0);

	t = ans;

	int v = 0;
	rep(i, D) {
		v += s[i][t[i]];
		last[t[i]] = i + 1;
		rep(j, 26) {
			v -= c[j] * (i + 1 - last[j]);
		}
	}
	cout << v << endl;
	*/

	rep(i, 365)cout << i % 26 + 1 << endl;

	return 0;
}

Measured memory_bytes: 3676
import java.util.*;
import java.math.BigInteger;

public class Main{
    
    public static final int MOD = (int)1e9+7;
    
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        
        int a = Integer.parseInt(sc.next());
        int b = Integer.parseInt(sc.next());
        double h = Integer.parseInt(sc.next());
        double m = Integer.parseInt(sc.next());
        double hs = h/12+m/60/12;
        double ms = m/60;
        double e = Math.abs(hs-ms)*360;
        
        double c = a*a+b*b-2*a*b*Math.cos(Math.toRadians(e));
        System.out.println(Math.sqrt(c));
        
    }
}


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

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

using ll = long long;
using pii = pair<int, int>;

#define vt          vector
#define sz(x)       (int)(x).size()
#define all(x)      (x).begin(), (x).end()
#define rall(x)     (x).rbegin(), (x).rend()
#define fi          first
#define se          second

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

    string s;
    int k;
    cin >> s >> k;

    set<string> v;
    for (int r = 1; r <= min(5, sz(s)); r++) {
        for (int i = 0; i <= sz(s) - r; i++) {
            v.insert(s.substr(i, r));
        }
    }

    auto it = v.begin();
    for (; --k; it++);
    cout << *it;
}


Measured memory_bytes: 4820
#include <bits/stdc++.h>
 
#define pp push_back
#define pf push_front
#define mp make_pair
#define fs first
#define sc second
#define sf scanf
 
using namespace std;
 
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> ii;
 
const int N = (int) 2e5 + 7;
const int INF = (int) 1e9 + 7;
 
int a[N];
int ans[N];
vector<int> g[N];
multiset<int> ms;
 
void dfs(int s, int p) {
	ms.insert(a[s]);
	multiset<int>::iterator it = ms.lower_bound(a[s]);
	int rem = -1;
	if (++it != ms.end()) {
		rem = *it;
		ms.erase(it);
	}
	ans[s] = ms.size();
 
	for (int i = 0; i < g[s].size(); ++i) {
		if (g[s][i] != p)
			dfs(g[s][i], s);
	}

	if (rem != -1) {
		ms.insert(rem);
	}
	ms.erase(ms.find(a[s]));
 
}
 
 
int main(int argc, char *argv[])
{
	// ios_base::sync_with_stdio(false);
	// cin.tie(NULL);
 
	int n;
	sf("%d", &n);
	for (int i = 1; i <= n; ++i) {
		sf("%d", &a[i]);
	}
 
	for (int i = 0; i < n - 1; ++i) {
		int x, y;
		sf("%d %d", &x, &y);
		g[x].pp(y);
		g[y].pp(x);
	}
 
	dfs(1, 0);
 
	for (int i = 1; i <= n; ++i) {
		printf("%d\n", ans[i]);
	}
 
	return 0;
}


Measured memory_bytes: 33380