akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define rep(i, l, r) for(int i = (l), i##end = (r);i <= i##end;++i)
using std::cin; using std::cout;
const int maxn = 200200;
typedef long long ll;
const int mod = 1e9 + 7;
inline ll pow(ll a,int b,int ans = 1) {
	for(;b;b >>= 1,a = a * a % mod) if(b & 1)
		ans = ans * a % mod;
	return ans;
}
inline ll inverse(int x){ return pow(x, mod - 2); }
typedef std::pair<int, int> pr;
int n;
struct node {
	int x, v;
} a[maxn];
int rank[maxn];
inline int cmp0(const node & x,const node & y) { return x.v < y.v; }
inline int cmp1(const int & x,const int & y) { return a[x].x < a[y].x; }
int bit[maxn];
inline void add(int x,int v) {
	for(;x < maxn;x += x & -x)
		bit[x] += v - mod, bit[x] += bit[x] >> 31 & mod;
}
inline int qry(int x) {
	int ans = 0;
	for(;x;x &= x - 1)
		ans += bit[x] - mod, ans += ans >> 31 & mod;
	return ans;
}
pr seg[maxn];
int main() {
	std::ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
	cin >> n;
	rep(i, 1, n) {
		cin >> a[i].x >> a[i].v;
		rank[i] = i;
	}
	std::sort(a + 1,a + n + 1,cmp0);
	std::sort(rank + 1,rank + n + 1,cmp1);
	int max = 0, min = n;
	for(int i = 1;i <= n;++i) seg[rank[i]].second = max = std::max(max, rank[i]);
	for(int i = n;i >= 1;--i) seg[rank[i]].first = min = std::min(min, rank[i]);
	std::sort(seg + 1,seg + n + 1);
	add(n + 1, 1);
	for(int i = n;i >= 1;--i) {
		int s = qry(seg[i].second + 1) - qry(seg[i].first - 1);
		add(seg[i].first, s + (s >> 31 & mod));
	}
	cout << bit[1] << '\n';
}


Measured memory_bytes: 4992
while (h,w = gets.split.map(&:to_i)) != [0,0]
  line = ["#." * (w/2) + "#" * (w % 2), ".#" * (w/2) + "." * (w % 2)]
  h.times do |i|
    puts line[i % 2]
    end
  puts "\n"
end


Measured memory_bytes: 6876
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define rrep(i,n) for(int i=1; i<=(int)(n); i++)
#define pb push_back
#define all(v) v.begin(),v.end()
#define fi first
#define se second
#define bigger (char)toupper
#define smaller (char)tolower
using namespace std;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vii;
typedef vector<string> vs;
typedef vector<char> vc;
typedef long long ll;
typedef unsigned long long ull;

ll sum(ll x) {
  if(x==0) return 0;
  ll s=sum(x-1);
  return s+x;
}

int main() {
  int N;
  cin>>N;
  cout<<sum(N-1)<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define PI 				acos(-1)
#define mp				make_pair
#define pb				push_back
#define all(a)			(a).begin(), (a).end()
#define sz(a)			a.size()
#define srt(a)			sort(all(a))
#define mem(a, h)		memset(a, (h), sizeof(a))
#define f 				first
#define s 				second
#define MOD1			998244353
#define fore(i, b, e)	for(int i = b; i < e; i++)
#define forg(i, b, e, m)	for(int i = b; i < e; i+=m)
int in(){int r=0,c;for(c=getchar();c<=32;c=getchar());if(c=='-') return -in();for(;c>32;r=(r<<1)+(r<<3)+c-'0',c=getchar());return r;}

using namespace std;
using namespace __gnu_pbds;

typedef long long 		ll;
typedef unsigned long long 		ull;
typedef pair<int, int>  ii;
typedef vector<int>     vi;
typedef vector<ii>      vii;
typedef vector<ll>      vll;
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
const int tam = 100010;
const int MOD = 1e9+7;
const double EPS = 1e-9;

int main()
{
	ios::sync_with_stdio(0); cin.tie(0);
	//freopen("qwe.txt", "r", stdin);
	//freopen("asd.txt", "w", stdout);
	int n, m, d;
	cin>>n>>m>>d;
	pair<ll,ll> posis[n * m];
	int a;
	fore(i, 0, n) fore(j, 0, m) {cin>>a; posis[a-1] = mp(i, j);}
	ll costs[n * m];
	mem(costs, 0);
	fore(i, 0, d)
	{
		forg(j, i + d, n * m, d)
		{
			costs[j] = costs[j - d] + abs(posis[j - d].f - posis[j].f) + 
			abs(posis[j - d].s - posis[j].s);
		}
	}
	int q;
	int x, y;
	cin>>q;
	while(q--)
	{
		cin>>x>>y;
		cout<<costs[y - 1] - costs[x - 1]<<'\n';
	}
	return 0;
}

// read the question correctly (is y a vowel? what are the exact constraints?)
// look out for SPECIAL CASES (n=1?) and overflow (ll vs int?) ARRAY OUT OF BOUNDSS2

Measured memory_bytes: 3200
n=io.read"*n"
k=io.read"*n"
h={}for i=1,n do
h[i]=io.read"*n"end

dp={0}
for i=2,n do
for j=1,math.min(i-1,k) do
dp[i]=math.min(dp[i-j]+math.abs(h[i]-h[i-j]),dp[i]or math.huge)
end
end
print(dp[n])

Measured memory_bytes: 2304
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        
        Scanner sc = new Scanner(System.in);
        
        int k = Integer.parseInt(sc.next());
        
        long ans = 0;
        for(int i = 1; i <= k; i++){
            for(int j = 1; j <= k; j++){
                long a = gcd(i, j);
                for(int l = 1; l <= k; l++){
                    ans += gcd(a, l);
                }
            }
        }
        System.out.println(ans);
    }
    
    static long gcd(long a, long b){
        if(b == 0){
            return a;
        }else{
            return gcd(b, a % b);
        }
    }
}

Measured memory_bytes: 27216
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef pair<ll,ll> P;
typedef vector<P> vp;
typedef vector<string> vs;
typedef vector<bool> vb;

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

#define rep(i,m,n) for(ll i=m;i<n;i++)
#define repr(i,m,n) for(ll i=m-1;i>=n;i--)
#define fi first
#define se second
#define chmax(x,y) x=max(x,y)
#define chmin(x,y) x=min(x,y)
#define eb(x) emplace_back(x)
#define all(x) x.begin(),x.end()
#define gll greater<ll>()

void solve(){
  int k;
  string s;
  cin >> k >> s;
  
  if(s.size()<=k) cout << s << endl;
  else cout << s.substr(0,k) << "..." << endl;
  
}
int main(){
   cin.tie(nullptr);
  ios::sync_with_stdio(false);
  solve();
}  

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

using ll = long long;

int main() {
    int n; cin >> n;
    int ans = 0;
    for(int i = 0; i < n; ++i) {
        int a; cin >> a;
        while(a % 2 == 0) {
            a /= 2;
            ans++;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <cassert>
#include <string>
#include <algorithm>
#include <cstring>
#include <utility>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <cmath>
#include <deque>
#include <unordered_map>
using namespace std;
typedef long long LL;
typedef pair<int, int> pii;
typedef pair<LL, LL> pll;
const int MAXN = 87;
char s[MAXN];
int cnt[MAXN], tmpcnt[MAXN];

int main() {
    int N;
    scanf("%d", &N);
    for (int i = 0; i < MAXN; i++)
        cnt[i] = 8787;
    for (int i = 0; i < N; i++) {
        scanf("%s", s);
        int len = strlen(s);
        memset(tmpcnt, 0, sizeof(tmpcnt));
        for (int j = 0; j < len; j++)
            tmpcnt[s[j] - 'a']++;
        for (int j = 0; j < MAXN; j++)
            cnt[j] = min(cnt[j], tmpcnt[j]);
    }
    for (int i = 0; i < MAXN; i++) {
        if (cnt[i] == 8787 || !cnt[i]) continue;
        for (int j = 0; j < cnt[i]; j++)
            printf("%c", i + 'a');
    }
    puts("");
    return 0;
}


Measured memory_bytes: 256
use std::io::*;
use std::str::FromStr;

pub fn read<T: FromStr>() -> T {
  let stdin = stdin();
  let stdin = stdin.lock();
  let token: String = stdin
    .bytes()
    .map(|c| c.expect("failed to read char") as char)
    .skip_while(|c| c.is_whitespace())
    .take_while(|c| !c.is_whitespace())
    .collect();
  token.parse().ok().expect("failed to parse token")
}

fn main() {
  let n = read::<i32>();
  if n == 2 {
    let a = read::<i32>();
    let b = read::<i32>();
    println!("{}", a + b);
  } else {
    println!("Hello World");
  }

}



Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
#define PRINT(s) cout << s << endl;
#define FOR(i, n) for (int i = 0; i < (n); i++)

int main() {

    int n;
    cin >> n;
    vector<long long> H(n);
    FOR(i, n) {
        cin >> H[i];
    }
    vector<long long> dp(n, -1);
    
    FOR(i, n) {
        if (i == 0) { 
            dp[0] = 0;
            continue;
        } else if (i == 1) {
            dp[i] = dp[i - 1] + abs(H[i] - H[i - 1]);
            continue;
        }
        long long shortJump = abs(H[i] - H[i - 1]);
        long long longJump = abs(H[i] - H[i - 2]);

        dp[i] = min(dp[i - 1] + shortJump, dp[i - 2] + longJump);
    }
    
    PRINT(dp[n - 1]);
}


Measured memory_bytes: 1792
#include"bits/stdc++.h"
using namespace std;
using ll = int64_t;

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

    sort(A.begin(), A.end());

    if (N % 2 == 0) {
        vector<ll> B;
        B.push_back(A[N / 2]);
        for (ll i = 0; i < N / 2 - 1; i++) {
            B.push_back(A[i]);
            B.push_back(A[N - 1 - i]);
        }
        B.push_back(A[N / 2 - 1]);

        ll ans1 = 0;
        for (ll i = 0; i < N - 1; i++) {
            ans1 += abs(B[i] - B[i + 1]);
        }

        vector<ll> C;
        C.push_back(A[N / 2 - 1]);
        for (ll i = 0; i < N / 2 - 1; i++) {
            C.push_back(A[N - 1 - i]);
            C.push_back(A[i]);
        }
        C.push_back(A[N / 2]);

        ll ans2 = 0;
        for (ll i = 0; i < N - 1; i++) {
            ans2 += abs(C[i] - C[i + 1]);
        }

        cout << max(ans1, ans2) << endl;
    } else {
        vector<ll> B;
        B.push_back(A[N / 2]);
        for (ll i = 0; i < N / 2; i++) {
            B.push_back(A[i]);
            B.push_back(A[N - 1 - i]);
        }
        ll ans1 = 0;
        for (ll i = 0; i < N - 1; i++) {
            ans1 += abs(B[i] - B[i + 1]);
        }

        vector<ll> C;
        C.push_back(A[N / 2]);
        for (ll i = 0; i < N / 2; i++) {
            C.push_back(A[N - 1 - i]);
            C.push_back(A[i]);
        }
        ll ans2 = 0;
        for (ll i = 0; i < N - 1; i++) {
            ans2 += abs(C[i] - C[i + 1]);
        }

        cout << max(ans1, ans2) << endl;

    }
}

Measured memory_bytes: 3444
from collections import deque
N = int(input())
G = [[] for i in range(N)]
for i in range(N-1):
    u,v,w = map(int, input().split())
    G[u-1].append((v-1, w))
    G[v-1].append((u-1, w))

st = deque()
push, pop = st.appendleft, st.pop
push(0)
dist = [0]*N
cnt = [0]*N
cnt[0] = 1

while st:
    u = pop()
    for v,w in G[u]:
        if cnt[v] == 1:
            continue
        dist[v] = dist[u] + w
        push(v)
        cnt[v] = 1

for d in dist:
    if d%2 == 0:
        print(0)
    else:
        print(1)

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

// = f(0,x)
ll f(ll x) {
    if (x < 0) return 0;
    if (x % 4 == 0) return x;
    if (x % 4 == 1) return 1;
    if (x % 4 == 2) return x+1;
    if (x % 4 == 3) return 0;
    assert(false);
}

int main(void){
    ll a,b;
    cin >> a >> b;
    cout << (f(a-1)^f(b)) << endl;
    return 0;
}


Measured memory_bytes: 384
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <map>
#include <set>
#include <string>
#include <vector>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
using ll = long long;
using namespace std;

int main() {
    int l, r, d;
    cin >> l >> r >> d;

    cout << r / d - (l - 1) / d << endl;
}

Measured memory_bytes: 3632
#include <iostream>
#include <algorithm>
#include <string>
#include <queue>
#include <cmath>
#include <map>
#include <iomanip>

using namespace std;
using ll = long long;

int main() {
	ll N, K;
	cin >> N >> K;
	vector<ll> a(N);
	for (ll i = 0; i < N; i++)
	{
		cin >> a[i];
	}
	cout << (ll)ceil((double)(N - 1) / (K - 1)) << endl;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
// Begin Header {{{
#define all(x) (x).begin(), (x).end()
#define lli long long int
#define rep(i,n) for(lli i=0; i<n; i++)
#define loop(i, j, n) for(lli i=j; i<n; i++)
#define Max(a, b) ((a) > (b) ? (a) : (b))
#define Min(a, b) ((a) < (b) ? (a) : (b))
constexpr int INF  = 0x3f3f3f3f;
const long long mod=1e9+7;
//Function
lli combi(lli n, lli r)
{
	if(r==0 || r==n) return 1;
	else return combi(n-1,r) + combi(n-1,r-1);
}
lli sigma1(lli n){return n*(n+1)/2;}
lli sigma2(lli s, lli n){return sigma1(n) - sigma1(s -1);}
using namespace std;
// }}} End Header

int main()
{
	ios::sync_with_stdio(false); cin.tie(nullptr);
	lli n, T, ans=INF;
	cin >> n >> T;
	rep(i,n){
		lli c, t;
		cin >> c >> t;
		if(t <= T){
			ans = Min(c, ans);
		}
	}
	if(ans == INF) cout << "TLE" << endl;
	else cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <stdio.h>
#include <algorithm>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <cstring>

using namespace std;

#define f first
#define s second
#define pb push_back
#define mp make_pair
#define ll long long
#define pii pair < int, int >
#define pll pair < long long, long long>
#define ull unsigned long long
#define vi vector < int >
#define vll vector < long long >
#define sz(a) (int)a.size()
#define forit(it, s) for(__typeof(s.begin()) it = s.begin(); it != s.end(); it++)
#define all(a) a.begin(), a.end()
#define sqr(x) ((x) * (x))
#define fname "searching"

const int inf = (int)1e9;
const ll INF = (ll)1e18;
const double eps = 1e-9;
const double pi = acos(-1.0);
const int mod = (int)1e9 + 7;

int n;
ll a, b;

ll solve(){
    cin >> n >> a >> b;
    
    for(int i = 0; i < n - 1; ++i){
        ll x, y;
        cin >> x >> y;
        ll dx = a / x + (a % x != 0);
        ll dy = b / y + (b % y != 0);
        a = x * max(dx, dy);
        b = y * max(dx, dy);
    }

    return a + b;
}

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

    cout << solve() << "\n";
    
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
	string s;
	cin>>s;
	int x=0;
	for(int i=0;i<s.size();i++){
		if(x==1){
			if(s[i]=='F'){
				cout<<"Yes";
				return 0;
			}
		}
		if(s[i]=='C'){
			x=1;
		}
	}
	cout<<"No";
	return 0;
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
using namespace std;
#ifndef FAST_IO
 #define IOS ios_base::sync_with_stdio(false);cin.tie(nullptr);
#endif
#define FILE_IO freopen("input.txt","r",stdin);
#define f first
#define int long long
#define s second
#define endl '\n'
#define all(c) c.begin(),c.end()
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
template<typename T>void print(T t){for(auto &it:t)cout<<it<<" ";}
inline int powerexp(int a,int b,int m){int res=1;while(b){if(b&1)res=res*a%m;a=a*a%m,b>>=1;}return res%m;}
const int MAXN=1e5+1;
bool isprime[MAXN];
int v[MAXN];
void solve(){
   int n;
   cin>>n;
   vector<int> v(n);
   map<int,int> m;
   for(auto& it:v){
    cin>>it;
    m[it+1]++;
    m[it]++;
    m[it-1]++;
   }
   int ans=INT_MIN;
   for(auto it:m){
      ans=max(ans,it.s);
   }
   cout<<ans<<endl;
}
//-----------------------------
//comment from here for TOPCODER 
int32_t main(){
    IOS;
    solve();
    #ifdef LOCAL_DEFINE
    cerr<<"time elapsed "<<(double)clock()/CLOCKS_PER_SEC<<endl;
    #endif
}


Measured memory_bytes: 7040
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    int H,W;
    while(true){
        cin>>H>>W;
        if(H==0&&W==0){
            break;
        }
        for(int j=0;j<W;j++){
            cout<<'#';
        }
        cout<<endl;
        for(int i=1;i<H-1;i++){
            cout<<'#';
            for(int j=1;j<W-1;j++){
                cout<<'.';
            }
            cout<<'#'<<endl;
        }
        for(int j=0;j<W;j++){
            cout<<'#';
        }
            cout<<endl<<endl;
        }
        
    }




Measured memory_bytes: 3076
#include <bits/stdc++.h>
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

// 二項係数を用いる
const int MAX = 1000100;
const int MOD = 1000000007;

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

  // テーブルを作る前処理
  /* facが普通の階乗を求めている。invが逆数を求めている。finvが逆数の階乗を求めている。*/
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 k, s;

int main() {
    cin >> k >> s;
    // COMinit();

    long long cnt = 0;
    for(int x = 0; x <= k; ++x) {
        for(int y = 0; y <= k; ++y) {
            int check = s-x-y;
            if(check >= 0 && check <= k) cnt++;
        }
    }

    cout << cnt << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
//#define int long long
const int N=1000002,M=998244353;
#define For(i,x,y) for(register int i=(int)(x);i<=(int)(y);i++)
#define Rep(i,x,y) for(register int i=(int)(x);i>=(int)(y);i--)
int pw(int x,int y){int z=1;for(;y;y>>=1,x=1ll*x*x%M)if(y&1)z=1ll*z*x%M;return z;}
int n,K,i,a[N],b[N],c[N];
signed main(){
	scanf("%d%d",&n,&K);
	if (K>(n+1)/2) return puts("-1"),0;
	for (i=1;i<=n;i++) a[i]=K+i-1,b[i]=a[i]+n,c[i]=b[i]+n;
	if (n&1){
		K=n/2;
		For(i,1,K+1) printf("%d %d %d\n",a[i],b[i+K],c[2*i-1]);
		For(i,K+2,n) printf("%d %d %d\n",a[i],b[i-K-1],c[(i-K-1)*2]);
	}else{
		K=n/2;
		For(i,1,K) printf("%d %d %d\n",a[i],b[i+K],c[2*i-1]);
		For(i,K+1,n) printf("%d %d %d\n",a[i],b[i-K],c[(i-K)*2]);
	}
}

Measured memory_bytes: 10880
n = int(input())
a = list(map(int,input().split()))
q = int(input())
summary = 0
dic = {}
for i in range(n):
  summary += a[i]
  if a[i] in dic:
    dic[a[i]] += 1
  else:
    dic[a[i]] = 1
for j in range(q):
  b,c = map(int,input().split())
  if b in dic:
    summary = summary - b*dic[b] + c*dic[b]
    if c in dic:
      dic[c] += dic[b]
    else:
      dic[c] = dic[b]
    dic.pop(b)
  print(summary)

Measured memory_bytes: 20824
#include <bits/stdc++.h>
using namespace std;
int n, ans;
int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	cin >> n;
	for(int x = 1; x <= n; x++)
	{
		for(int y = 1; y <= n; y++)
		{
			for(int z = 1; z <= n; z++)
			{
				ans += __gcd((__gcd(x, y)), z);
			}
		}
	}
	cout << ans;
}


Measured memory_bytes: 3608
#include<bits/stdc++.h>
using namespace std;
struct z{
  int x;
  int y;
};

double distance(z a,z b){
  return sqrt((a.x-b.x)*(a.x-b.x)+(a.y-b.y)*(a.y-b.y));
}

int kai(int n){
  if(n==0) return 1;
  else return n*kai(n-1);
}

int main(){
  int n;
  double sum=0;
  cin >> n;
  vector<z> place(n);
  vector<vector<double>> d(n,vector<double>(n));
  for(int i=0;i<n ;i++){
    cin >> place.at(i).x;
    cin >> place.at(i).y;
  }
  for(int i=0;i<n;i++){
    for(int j=i+1;j<n;j++){
      double temp = distance(place.at(i),place.at(j));
      sum += d.at(i).at(j)=temp;
    }
  }
  
  printf("%0.11lf\n",2*sum/n);

}


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

int main(){
  int h,w,n;
  cin >> h >> w >> n;
  int a;
  vector<int> place(h*w);
  int now=0;
  for(int i=0;i<n;i++){
    cin >> a;
    for(int j=0;j<a;j++){
      place[now]=i+1;
      now++;
    }
  }
  string ans;
  for(int i=0;i<h;i++){
    ans="";
    if(i%2){
      for(int j=w-1;j>=0;j--){
        ans+=to_string(place[w*i+j]);
        ans+=" ";
      }
      ans.pop_back();
    }else{
      for(int j=0;j<w;j++){
        ans+=to_string(place[w*i+j]);
        ans+=" ";
      }
      ans.pop_back();
    }
    cout << ans << endl;
  }
  return 0;
}


Measured memory_bytes: 384
//by Top1
#include <bits/stdc++.h>
     
#define f first
#define s second
#define int long long
#define ld long double
#define ull unsigned long long
#define pii pair <int, int>
#define pll pair <long, long>
#define mp make_pair
#define pb push_back
#define pf push_front
#define pp pop_back
#define rev reverse
#define all(s) s.begin(), s.end()
#define sz(s) (int)s.size()
#define forn(i, a, b) for (int i = a; i <= b; i++)
#define boost ios_base::sync_with_stdio(false); cin.tie(0),cout.tie(0);
#define nxtp next_permutation
#define pvtp prev_permutation
#define KZ return 
#define x1 x21212121
#define y1 y21212121
#define sqr(x) x * x 
 
const int inf = (1e9) + 1;
const int mod = 1e9 + 7;
const int maxn = 3e3 + 111;
     
using namespace std;

int n, q, a[maxn], dp[maxn][maxn], sum, pref[maxn];
                           
int get(int l, int r){
	return pref[r] - pref[l - 1];
}

void solve(){
	cin >> n;

	for (int i = 1; i <= n; i++){
		cin >> a[i];
		dp[i][i] = a[i];
		sum += a[i];
		pref[i] = pref[i - 1] + a[i];
	}

	for (int len = 2; len <= n; len++)
		for (int l = 1, r = l + len - 1; r <= n; l++, r++)
			dp[l][r] = max(get(l, r) - dp[l + 1][r], get(l, r) - dp[l][r - 1]);
	
	cout << 2 * dp[1][n] - sum;	
}

main(){
    boost;
	    
	q = 1;

	while (q--){
		solve();
	}
}

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

int main(){
    int a1, a2, a3;
    cin >> a1 >> a2 >> a3;
    if(a1+a2+a3>=22){
        cout << "bust" << endl;
    }else{
        cout << "win" << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
   
   
   int main(void) {
    int A,B,C;

    
    
     scanf("%d%d%d",&A,&B,&C);

      
     if(A<=C&&C<=B) {
                  printf("Yes");
              } else {
                  printf("No");
              }
   
   
   
   return 0;
   
   }

Measured memory_bytes: 128
#include <iostream>
#include <algorithm>
#include <cstring>
#include <cstdio>
#include <vector>
#include <queue>
#include <stack>
#include <cstdlib>
#include <iomanip>
#include <cmath>
#include <cassert>
#include <ctime>
#include <map>
#include <set>
using namespace std;
#define lowbit(x) (x&(-x))
#define max(x,y) (x>=y?x:y)
#define min(x,y) (x<=y?x:y)
#define MAX 100000000000000000
#define MOD 1000000007
#define pi acos(-1.0)
#define ei exp(1)
#define PI 3.141592653589793238462
#define ios() ios::sync_with_stdio(true)
#define INF 1044266558
#define mem(a) (memset(a,0,sizeof(a)))
typedef long long ll;
ll g[212][202],vis[10],n,x,y,w,m,s;
void init()
{
    for(int i=0;i<=n;i++)
    {
        for(int j=0;j<=i;j++)
            g[j][i]=g[i][j]=INF;
        g[i][i]=0;
    }
    for(int i=0;i<m;i++)
    {
        scanf("%lld%lld%lld",&x,&y,&w);
        g[x][y]=g[y][x]=min(g[x][y],w);
    }
}
void flyod()
{
    for(int i=1;i<=n;i++)
    {
        for(int j=1;j<=n;j++)
        {
            for(int k=1;k<=n;k++)
            {
                g[j][k]=min(g[j][k],g[j][i]+g[i][k]);
            }
        }
    }
}
int main()
{
    while(scanf("%lld%lld%lld",&n,&m,&s)!=EOF)
    {
        for(int i=0;i<s;i++)
            scanf("%lld",&vis[i]);
            sort(vis,vis+s);
        init();
        flyod();
        ll ans=INF;
        do
        {
            ll pos=0;
            for(int i=0;i<s-1;i++)
                pos+=g[vis[i]][vis[i+1]];
            ans=min(ans,pos);
        }while(next_permutation(vis,vis+s));
        printf("%lld\n",ans);
    }
    return 0;
}

Measured memory_bytes: 512
#include<iostream>
#include<algorithm>
#include<utility>
#include<vector>
using namespace std;

bool compair(pair<string,int> a,pair<string,int> b){
    //first
    if(a.first != b.first){
        //ascending
        return a.first < b.first;
    }
    //next
    if(a.second != b.second){
        //descending
        return a.second > b.second;
    }else{
        return true;
    }
}

int main(){
    int n;
    cin >> n;
    vector<pair<string,int> > city,origin;   
    for(int i = 0;i < n;i++){
        string s;
        int p;
        cin >> s >> p;
        city.push_back(make_pair(s,p));
        origin.push_back(make_pair(s,p));
    }
    sort(city.begin(),city.end(),compair);
    for(int i = 0;i < n;i++){
        for(int j = 0;j < n;j++){
            if(city[i] == origin[j]){
                cout << j+1 << endl;
                break;
            }
        }
    }
}

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

int main() {
  int N;

  cin >> N;

  int minActCount = 10e9;
  for (int i = 0; i < N; i++) {
    int A;

    cin >> A;

    int actCount = 0;
    for (int n = A; n > 0 && n % 2 == 0; n /= 2) {
      actCount++;
    }

    if (actCount < minActCount) {
      minActCount = actCount;
    }

    if (actCount == 0) {
      break;
    }
  }

  cout << minActCount << endl;
}


Measured memory_bytes: 3640
#include <stdio.h>
long long MIN(long long a,long long b){
    if(a<b)return a;
    return b;
}
int main()
{   int n;
    scanf("%d",&n);
    int a[n],sum=0;
    for(int i=0;i<n;i++){
        scanf("%d",&a[i]);
        sum+=a[i];
    }
    long long ans1=0,ans2=0,ans3=0;
    int ave=sum/n,avep=ave+1,aven=ave-1;
    for(int i=0;i<n;i++){
        ans1+=((a[i]-ave)*(a[i]-ave));
        ans2+=((a[i]-avep)*(a[i]-avep));
        ans3+=((a[i]-aven)*(a[i]-aven));
    }
    
    printf("%lld",MIN(ans1,MIN(ans2,ans3)));
    return 0;
}


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

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


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int N =1e3;
int main()
{
    char s[N];

    while(~scanf("%s",s+1))
    {
        int flag =1;
        for(int i=1;s[i]!='\0';i++)
        {
            if(s[i]=='U'||s[i]=='D')
                continue;
            if(i&1&&s[i]!='R')
                flag =0;
            else if(i%2==0&&s[i]!='L')
                flag =0;
        }
        if(flag)
            printf("Yes\n");
        else
            printf("No\n");
    }
    return 0;
}


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

bool dp[5001][1<<12],mat[5000][12];

int main()
{
	int N,M;
	while(cin >> N >> M, (N||M))
	{
		int cnt=0;
		string str[12], text;
		memset(dp,0,sizeof(dp));
		memset(mat, 0, sizeof(mat));
		
		for(int i=0; i<N; i++)
			cin >> str[i];
			
		while(M--)
		{
			string t;
			cin >> t;
			text+=t;
		}
		
		for(int i=0; i<N; i++)
		for(int j=0; j<=text.size()-str[i].size(); j++)
		{
			bool g=true;
			for(int k=0; k<str[i].size(); k++)
			{
				if(text[j+k]!=str[i][k])
				{
					g=false;
					break;
				}
			}
			mat[j][i]=g;
		}
		

		for(int i=0; i<text.size(); i++)
		for(int j=0; j<(1<<N); j++)
		{
			for(int k=0; k<N; k++)
			{
				if(mat[i][k])
				{
					if(j==(1<<k)) 
					{
						dp[i+str[k].size()][j]=1;
					}
					else
					{
						if(j&(1<<k)) continue;
						if(dp[i][j]) dp[i+str[k].size()][j+(1<<k)]=1;
					}
				}
			}
		}
		
		for(int i=0; i<=text.size(); i++)
			if(dp[i][(1<<N)-1]) cnt++;
			
		
		cout << cnt << endl;
	}
}

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

using namespace std;

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

    int n, d;

    cin >> n >> d;

    d = d*2 + 1;

    if(n%d==0){
        cout << n/d << endl;
    }
    else{
        cout << n/d + 1 << endl;
    }

    return 0;
}


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

void solve(long long X) {
    long long money = 100;
    for (long long i = 1;; i++) {
        money = (long long)(money * 1.01);
        if (money >= X) {
            cout << i << endl;
            return;
        };
    }
}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can
// remove this line by using your custom template)
int main() {
    long long X;
    scanf("%lld", &X);
    solve(X);
    return 0;
}


Measured memory_bytes: 3764
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define lf long double
#define vi vector<int>
#define vl vector<long long int>
#define pii pair <int,int>
#define pll pair <long long int, long long int>
#define vpii vector< pair<int,int> >
#define vpll vector < pair <long long int,long long int> >
#define MOD 1000000007
#define pb push_back
#define mk make_pair
#define f first
#define s second
#define in insert
#define all(x) x.begin(),x.end()
#define zapp ios::sync_with_stdio(false);cin.tie(0)
const int MAXN = 1e5 + 5;

int main()
{
	zapp;
	char c;
	cin >> c;
	if (c < 91)
		cout << "A";
	else
		cout << "a";

	return 0;
}

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

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int a,b; cin>>a>>b;
  cout<<max(max(a+b,a-b),a*b)<<endl;
}


Measured memory_bytes: 256
def read_int():
    return int(input())

def read_int_map():
    return map(int,input().split(' '))

def read_int_list():
    return list(map(int,input().split(' ')))

def read_s_list_loop(n):
    return [input() for _ in range(n)]

S = input()
T = input()
if S == T[:len(T)-1]:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 61728
use std::cmp::*;
use std::collections::BTreeSet;
use std::io::*;
use std::str::FromStr;
//portable utility
#[allow(dead_code)]
fn switch<T>(flag: bool, true_value: T, false_value: T) -> T {
    if flag {
        true_value
    } else {
        false_value
    }
}

#[allow(dead_code)]
fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

#[allow(dead_code)]
fn read_string() -> Vec<char> {
    read::<String>().chars().collect()
}

#[allow(dead_code)]
fn read_vector<T: FromStr>(number: i32) -> Vec<T> {
    (0..number).map(|_| read()).collect()
}

fn main() {
    let (a, b, c): (i32, i32, i32) = (read(), read(), read());
    println!("{} {} {}", c, a, b)
}


Measured memory_bytes: 4352
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <string>
#include <cstring>
#include <utility>
#include <set>
#include <stack>
#include <climits>
#include <cmath>

#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define rep1(i,n) for(int i=1, i##_len=(n); i<=i##_len; ++i)
#define reps(i,s,n) for(int i=s, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
#define MEMSET(v, h) memset((v), h, sizeof(v))
typedef long long ll;
const char sp = ' ';


using namespace std;

int main(void){
    ll K, N, A[200003];
    cin>>K>>N;
    ll Maxim=0;
    rep(i, N) cin>>A[i];
    rep(i, N){
        if(i==N-1){
            Maxim=max(Maxim, (K-A[i])+A[0]);
        } else{
            Maxim=max(Maxim, A[i+1]-A[i]);
        }
    }
    cout<<K-Maxim<<endl;
    return 0;
}


Measured memory_bytes: 1792
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main(){
	int n=0;
	vector<int> data;
	cin >> n;
	for(int i=0;i<2*n;i++){
		int temp=0;
		cin >> temp;
		data.push_back(temp);
	}
	sort(data.begin(),data.end());
	int res=0;
	for(int i=0;i<n;i++){
		res+=data[2*i];
	}
	cout << res << endl;
	return 0;
}

Measured memory_bytes: 256
N=int(input())
A=list(map(int,input().split()))

ans=sum(A)%(2*(10**9+7))
ans=ans**2%(2*(10**9+7))

for i in range(N):
  ans-=A[i]**2
  ans=ans%(2*(10**9+7))

print(ans//2%(10**9+7))

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

int main(){
	int n=0;
	int a[1000];
	int i=0;
	int j=0;
	int t=0;
	for(i=0;i<1000;i++){
		a[i]=0;
	}
	cin>>n;
	for(i=0;i<n;i++){
		cin>>a[i];
	}
	for(i=0;i<n;i++){
		for(j=i;j<n;j++){
			if(a[i]>a[j]){
				t=a[i];
				a[i]=a[j];
				a[j]=t;
			}
		}
	}
	
	cout<<a[n-1]-a[0]<<endl;
} 

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

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

int N,A,B,C,D;
string S;

void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>N>>A>>B>>C>>D;
	cin>>S;
	A--,B--,C--,D--;
	x=A;
	while(x<C) {
		if(x+1==C) break;
		if(x+2==C) break;
		if(S[x+1]=='.') {
			x++;
			continue;
		}
		if(S[x+2]=='.') {
			x+=2;
			continue;
		}
		return _P("No\n");
	}
	
	x=B;
	while(x<D) {
		if(x+1==D) break;
		if(x+2==D) break;
		if(S[x+1]=='.') {
			x++;
			continue;
		}
		if(S[x+2]=='.') {
			x+=2;
			continue;
		}
		return _P("No\n");
	}
	
	if(C>D) {
		int ok=0;
		for(i=B;i<=D;i++) {
			if(S[i-1]=='.' && S[i]=='.' && S[i+1]=='.') ok=1;
		}
		if(ok==0) return _P("No\n");
	}
	cout<<"Yes"<<endl;
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	cout.tie(0); solve(); return 0;
}


Measured memory_bytes: 892
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main()
{
    int n, ex = 0;
    cin >> n;
    vector<int> a(n);
    for(int i = 0; i < n; i++){
        scanf("%d", &a[i]);
    }
    sort(a.begin(), a.end());
    int i = 0, j = 0;
    while(j < n){
        while(a[i] == a[j]) j++;
        ex += j - i - 1;
        i = j;
    }
    cout << n - ex - (ex % 2) << endl;
    return 0;
}

Measured memory_bytes: 640
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<set>
#include<map>
#include<queue>
#include<cmath>
#define REP(i,a) for (int i = 0;i < (a);++i)
#define FOR(i,a,b) for (int i = (a);i < (b); ++i)
#define FORR(i,a,b) for (int i = (a);i >= (b); --i)
#define ALL(obj) (obj).begin(),(obj).end()
#define SORT(list) sort(ALL((list)));
#define MOD 1000000007
using namespace std;
using ll = long long;

#define NUM_OF_CONTESTS 26
int main(){
    int d;
    cin >> d;
    vector<int>c(NUM_OF_CONTESTS);
    REP(i,NUM_OF_CONTESTS)cin >> c[i];

    int s[d][NUM_OF_CONTESTS];
    REP(i,d){REP(j,NUM_OF_CONTESTS){cin >> s[i][j];}}

    vector<int>t(d);
    REP(i,d){
        cin >> t[i];
        t[i]--;
    }

    ll sat = 0;
    vector<int>last(NUM_OF_CONTESTS,0);

    REP(i,d){
        sat+=s[i][t[i]];
        last[t[i]]=i+1;
        REP(j,NUM_OF_CONTESTS){
            sat-=c[j]*(i+1-last[j]);
        }
        cout << sat <<endl;
    }
    return 0;
}

Measured memory_bytes: 3584
#include<iostream>
#include <cstdlib>
#include <algorithm>
#include <vector>
using namespace std;

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

    if(A >= 13) cout << B << endl;
    else if(A >= 6) cout << B/2 << endl;
    else cout << 0 << endl;

    return 0;
}


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

typedef long long ll;
const int mod=998244353;

int a,b,c,d;
ll dp[3005][3005];

int main(){

    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

    cin>>a>>b>>c>>d;
    dp[a][b]=1;
    for(int i=a+1;i<=c;i++)dp[i][b]=dp[i-1][b]*b%mod;
    for(int i=b+1;i<=d;i++)dp[a][i]=dp[a][i-1]*a%mod;
    for(int i=a+1;i<=c;i++){
        for(int j=b+1;j<=d;j++){
            dp[i][j]=((dp[i-1][j]*j+dp[i][j-1]*i-dp[i-1][j-1]*(i-1)*(j-1))%mod+mod)%mod;
        }
    }
    cout<<dp[c][d]<<endl;

    return 0;
}

Measured memory_bytes: 74084
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;

const int N = 200005;
const long double EPS = 1e-9;
const long double PI = acos(-1.);


int main()
{
//    #ifdef LOCAL
//    freopen("input.txt", "r", stdin);
//    freopen("output.txt", "w", stdout);
//    #endif

    ll n, m, sum = 0, a[N];
    scanf("%I64d%I64d", &n, &m);
    for(int i = 0; i < m; i++){
        scanf("%I64d", &a[i]);
        sum += a[i];
    }
    if(sum > n) return printf("%d\n", -1) , 0;
    printf("%I64d\n", n-sum);

    return 0;
}




















Measured memory_bytes: 3896
#include<bits/stdc++.h>
using namespace std;
 
int main(){
  int N,K;
  cin >> N >> K;
  long long ans=0;
  for(int i=1;i<=N;i++){
    int q=N/i;
    ans+=(long long)q*max(0,i-K);
    ans+=(long long)max(0,N-q*i-K+1);
  }
  if(K==0){ans=(long long)N*N;}
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
void tansaku(int X,int Y,vector<vector<int>> masu, vector<vector<int>> &data, queue<tuple<int, int>> &Q,int H,int W){
    Q.pop();
    if(data[X][Y] != -1 || masu[X][Y] == 1){
        return;
    }
    int p = 1000000;
    if (X - 1 >= 0 && data [X - 1][Y] != -1){
        p = min(p,data[X - 1][Y]);
    }
    if (Y - 1 >= 0 && data[X][Y - 1] != -1){
        p = min(p,data[X][Y - 1]);
    }
    if (X + 1 < H && data[X + 1][Y] != -1){
        p = min(p,data[X + 1][Y]);
    }
    if (Y + 1 < W && data[X][Y + 1] != -1){
        p = min(p,data[X][Y + 1]);
    }
    if(p == 1000000){
        data[X][Y] = 0;
    }
    else{
        p++;
        data[X][Y] = p;
    }
    if (X > 0){
        Q.push(make_tuple(X - 1,Y));
    }
    if (Y > 0){
        Q.push(make_tuple(X,Y - 1));
    }
    if (X + 1 < H){
        Q.push(make_tuple(X + 1, Y));
    }
    if (Y + 1 < W){
        Q.push(make_tuple(X, Y + 1));
    }
    return;
}
int main(){
    int H,W,i,j,A,p = 0;;
    char C;
    cin >> H >> W;
    vector<vector<int>> masu(H, vector<int>(W)),data(H, vector<int>(W,-1));
    for(i = 0;i < H;i++){
        for(j = 0;j < W;j++){
            cin >> C;
            if(C == '.'){
                masu[i][j] = 0;
            }
            else{
                masu[i][j] = 1;
                p++;
            }
        }
    }
    queue<tuple<int,int>> Q;
    Q.push(make_tuple(0,0));
    while(!(Q.empty())){
        tansaku(get<0>(Q.front()),get<1>(Q.front()),masu,data,Q,H,W);
    }
    if(data[H - 1][W - 1] == -1){
        cout << -1 << endl;
    }
    else{
        cout << H * W - p - data[H - 1][W - 1] - 1 << endl;
    }
}

Measured memory_bytes: 3656
#include <stdio.h>

int main (){
    int a=0;
    int b=0;
    int c=0;
    int temp=0;


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

    temp=c-(a-b);
    if(temp<0){
        printf("0\n");
    }else{
        printf("%d\n",temp);
    }

    return 0;
}

Measured memory_bytes: 128
a, b=[int(i) for i in input().split()]
c, d=[int(i) for i in input().split()]
e, f=[int(i) for i in input().split()]

A = [a, b, c, d, e, f]

p = A.count(1)
q = A.count(2)
r = A.count(3)
s = A.count(4)

B = [p, q, r, s]
B.sort()
if B == [1, 1, 2, 2]:
    print("YES")
else:
    print("NO")

Measured memory_bytes: 3064
(N,*v),*A=$<.map{_1.split.map &:to_i}
E=(r=0..N).map{[]}
A.map{E[_1]<<_2;E[_2]<<_1}
p r.map{|i|*q=i
q.count{|j|!v[j]&&v[j]=E[j].map{q<<_1}}}.max

Measured memory_bytes: 67872
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int n;
  cin >> n;
  
  int64_t num=0;
  int i=1;
  while(i<n+1){
    if(i%3!=0){
      if(i%5!=0){
      num = num + i;
      }
    }
    i++;
  }
  
 cout << num << endl;
  
  }


Measured memory_bytes: 3584
#include<bits/stdc++.h>
using namespace std;
#define rep(i,s, n) for(int i = s; i < (int)(n); i++)
#define co(x) cout<<x<<endl
#define SQvec(i,j) vector<vector<int>> data(i, vector<int>(j))
#define mod 1000000007
typedef long long int lint;

int main() {
  int N;
  cin >> N;
  bool ok = false;
  
  for(;N >= 0;){
    if(N%4 == 0){ok = true;}
    N -= 7;
  }
  if(ok){co("Yes");}
  else{co("No");}
}

Measured memory_bytes: 3648
#include <iostream>
#include <cmath>
#include <limits>

using namespace std;

int main() {
    long long a,b,x; cin >> a >> b >> x;
    // double theta = atan(2.0*(a*a*b-x)/a/a/a);
    if(a*a*b <= 2*x) {
        double theta = atan(2.0*(a*a*b-x)/(a*a*a));
        printf("%.8lf\n", theta*180/M_PI);
    } else {
        double theta = atan(a*b*b/2.0/x);
        printf("%.8lf\n", theta*180/M_PI);
    }
    // double theta = atan(2.0*(a*a*b-x)/(a*a*a));
    // printf("%.8lf\n", theta*180/M_PI);
}


Measured memory_bytes: 256
#include<stdio.h>
#include<algorithm>
using namespace std;
int main()
{
    int  a,b;
    int c[55];
    while(~scanf("%d%d",&a,&b))
     {
     int i,j,t,sum=0;;
    for(i=0;i<a;i++)
      scanf("%d",&c[i]);
    for(i=0;i<a-1;i++)
        for(j=0;j<a-1-i;j++)
    if(c[j]<c[j+1])  { t=c[j];c[j]=c[j+1];c[j+1]=t; }
    for(i=0;i<b;i++)
        sum+=c[i];
    printf("%d\n",sum);
    }
}


Measured memory_bytes: 128
import sys

sys.setrecursionlimit(10 ** 6)
INF = float("inf")
MOD = 10 ** 9 + 7


def input():
    return sys.stdin.readline().strip()


def main():
    T1, T2 = map(int, input().split())
    A1, A2 = map(int, input().split())
    B1, B2 = map(int, input().split())
    A = A1 * T1 + A2 * T2
    B = B1 * T1 + B2 * T2

    if A1 < B1 and A < B:
        print(0)
        return

    if A1 > B1 and A > B:
        print(0)
        return

    if A == B:
        print("infinity")
        return

    # T1 + T2 分後にできる差
    diff = abs(A - B)

    if T1 * abs(A1 - B1) % diff == 0:
        ans = T1 * abs(A1 - B1) // diff * 2
    else:
        ans = T1 * abs(A1 - B1) // diff * 2 + 1

    print(ans)


if __name__ == "__main__":
    main()


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

int main()
{
  int a, b;
  cin >> a >> b;
  long long int l = 0;
  for (int i = b - a; i >= 1; i--)
  {
    l += i;
  }
  int ans = l - b;
  cout << ans << endl;
}


Measured memory_bytes: 256
H, W = map(int, input().split())
N = int(input())
A = list(map(int, input().split()))

ans_lst = [[0 for _ in range(W)] for _ in range(H)]

# 色ヌル場所のポインタ
pointer = [0, 0]
direction = 1

for i in range(1, N + 1):
	color_stock = A[i - 1]
	while color_stock:
		ans_lst[pointer[0]][pointer[1]] = i
		color_stock -= 1
		
		# ポインタの更新
		if pointer[1] == 0 and direction == -1:
			pointer[0] += 1
			direction = 1
		elif pointer[1] == W - 1 and direction == 1:
			pointer[0] += 1
			direction = -1
		elif direction == 1:
			pointer[1] += 1
		elif direction == -1:
			pointer[1] -= 1
		else:
			print("what!?")
			
for i in range(H):
	print(*ans_lst[i])

Measured memory_bytes: 42608
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define dd double
#define endl "\n"
#define pb push_back
#define all(v) v.begin(),v.end()
#define mp make_pair
#define fi first
#define se second
#define fo(i,n) for(int i=0;i<n;i++)
#define fo1(i,n) for(int i=1;i<=n;i++)
ll mod=1000000007;
ll n,k,t,m,q,flag=0;
ll po(ll k ,ll n,ll ans,ll temp,ll ans1){
    if(n==0)return ans;
    while(temp<=n){
        ans*=ans1;ans%=mod;ans1=ans1*ans1;ans1%=mod;n=n-temp;temp*=2;
    }
    return po(k,n,ans,1,k)%mod;
    //eg. po(2,78,1,1,2);
}
ll min(ll a,ll b){if(a>b)return b;else return a;}
ll max(ll a,ll b){if(a>b)return a;else return b;}
vector<ll>v[500000];
ll children[200005];
void dfs(ll node,ll root){
    fo(i,v[node].size()){
        if(v[node][i]==root)continue;
        dfs(v[node][i],node);
        children[node]+=1+children[v[node][i]];
    }
}

ll ans[200005];
ll fac[200005];
ll infac[200005];

void calans(ll node, ll root){
    ans[node]=1;
    ll temp=children[node];
    fo(i,v[node].size()){
        if(v[node][i]==root)continue;
        calans(v[node][i],node);
        ll kk1=infac[children[v[node][i]] +1];
        ll kk2=infac[ temp -children[v[node][i]] -1 ] * kk1;
        kk2%=mod;
        ans[node]*=(ans[v[node][i]] * ((fac[temp]*kk2)%mod) )%mod;
        ans[node]%=mod;
        temp-=children[v[node][i]] +1;

    }
}

void dfs2(ll node, ll root , ll n){
    ll temp=n-1;
    fo(i,v[node].size() ){
        if(v[node][i]== root)continue;

        ll kk1=fac[children[v[node][i]] +1];
        ll kk2=fac[ temp -children[v[node][i]] -1 ] * kk1;
        kk2%=mod;
        kk2*=infac[temp];
        kk2%=mod;
        //if(v[node][i]==3)cout<<((fac[7]* ((infac[5] * infac[2])%mod)))%mod<<" "<<children[v[node][i]]<<endl;
        //kk1=fac[n-1]*infac[child]
        ans[v[node][i]]=ans[node] *(( kk2 * ((fac[n-1]* ((infac[children[v[node][i]]] * infac[n-1 -children[v[node][i]]])%mod))%mod)%mod )%mod);
        ans[v[node][i]]%=mod;


        dfs2(v[node][i] , node , n); 

    }
}

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    
    //cin>>t;
    
    fac[0]=1;
    fo(i,200004){
        fac[i+1]=fac[i]*(i+1)%mod;
    }
    infac[0]=1;
    infac[1]=1;
    for(int i=2;i<200004;i++){
        infac[i]=infac[i-1]*po(i,mod-2,1,1,i)%mod;
        //infac[i]%=mod;
    }
    t=1;
    while(t--){
        cin>>n;
        fo(i,n-1){
            ll a,b;
            cin>>a>>b;
            v[b].pb(a);
            v[a].pb(b);
        }
        fo(i,n+1)children[i]=0;
        dfs(1,1);
        calans(1,1);
        dfs2(1,1,n);
        fo(i,n)cout<<ans[i+1]<<endl;

        

    }

    return 0;
}


Measured memory_bytes: 28016
#include<bits/stdc++.h>
#define int long long
using namespace std;
signed main(){
  int N;
  cin>>N;
  vector<int> A(N);
  for(int &i:A)
    cin>>i;
  A.push_back(0);
  sort(A.begin(),A.end());
  uint32_t B=0;
  for(int i=0;i<N;i++){
    if((A[i+1]-A[i])%2)
      B^=(i+1);
  }
  cout<<(B==0?"second":"first")<<endl;
}

Measured memory_bytes: 4816
#include<iostream>
using namespace std;
int a[10005];
int main(){
	int n, m;
	int sum = 0;
	cin >> n >> m;
	for(int i = 1; i <= m; i++){
		cin >> a[i];
		sum += a[i];
	}
	if(sum > n)  cout << -1 << endl;
	else cout << n - sum << endl;
}

Measured memory_bytes: 3660
#include <iostream>
#include <vector>
#include <utility>
#include <algorithm>
#include <cmath>
#include <string>
#include <map>

#define pb push_back
#define mp make_pair

using namespace std;

typedef vector<int> vi;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef unsigned long long ull;
typedef long long ll;

int main() {
	double N;
	cin >> N;
	
	double floorGang = floor(N/1.08);
	double ceilingGang = ceil(N/1.08);
	
	if ((int)floor(floorGang*1.08) == N) {
		cout << floorGang;
	} else if ((int)floor(ceilingGang*1.08) == N) {
		cout << ceilingGang;
	} else {
		cout << ":(";
	}
	cout << endl;
  return 0;
}

Measured memory_bytes: 256
#![allow(dead_code)]
fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}
fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>().split_whitespace()
        .map(|e| e.parse().ok().unwrap()).collect()
}
fn read_vec2<T: std::str::FromStr>(n: u32) -> Vec<Vec<T>> {
    (0..n).map(|_| read_vec()).collect()
}
use std::collections::BTreeMap;
fn prime_factor(n: i64) -> BTreeMap<i64, i64> {
    let mut n = n;
    let mut m = BTreeMap::new();
    let mut i = 2;
    while i * i <= n {
        while n % i == 0 {
            *m.entry(i).or_insert(0) += 1;
            n /= i;
        }
        i += 1;
    }
    if n != 1 {
        *m.entry(n).or_insert(0) = 1;
    }
    m
}
fn main() {
    let n: i64 = read();
    let m = prime_factor(n);
    let mut ans = 0;
    for i in m {
        let mut cnt = 0;
        let mut t = 1;
        while cnt + t <= i.1 {
            cnt += t;
            t += 1;
            ans += 1;
        }
    }
    println!("{}", ans);
}

Measured memory_bytes: 2172
#include <iostream>
#include <cmath>
#include <map>
#include <utility>
#include <list>
#include <string>

using namespace std;

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

    int total = 0;
    int t;
    for (int i = 0; i < n; i++){

        cin >> t;
        total += t;
        a[i] = t;
    }

    double avg = ((double)total) / n;
    double dist = 1000;
    int index;
    for (int i = n - 1; i >= 0; i--) {
        if (abs(a[i] - avg) <= dist){
            dist = abs(a[i] - avg);
            index = i;
        }
    }
    cout << index << endl;

    return 0;
}

Measured memory_bytes: 256