akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define pb push_back
#define mp make_pair
#define rep(i,n) for(int i=0;i<(n);++i)
const int mod=1000000007;

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	string s;cin >> s;
	string ans="";
	rep(i,s.size()){
		if(s.at(i)=='0') ans+='0';
		else if(s.at(i)=='1') ans+='1';
		else{
			if(ans.size()) ans=ans.substr(0,ans.size()-1);
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
import java.util.*;

class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);

		int n = Integer.parseInt(sc.nextLine());

		int[][][] res = new int[4][3][10];
		
		for(int i = 0; i < n; i++){
			String[] str = sc.nextLine().split(" ");
			int b = Integer.parseInt(str[0]) - 1;
			int f = Integer.parseInt(str[1]) - 1;
			int r = Integer.parseInt(str[2]) - 1;
			int v = Integer.parseInt(str[3]);
			res[b][f][r] = res[b][f][r] + v;
		}
		
		StringBuilder sb = new StringBuilder();
		final String lb = System.getProperty("line.separator");
		for(int b = 0; b < 4; b++){
			for(int f = 0; f < 3; f++){
				for(int r = 0; r < 10; r++){
					sb.append(" ").append(res[b][f][r]);
				}
				sb.append(lb);
			}
			if(b == 3) break;
			sb.append("####################").append(lb);
		}

		System.out.print(sb.toString());
	}
}

Measured memory_bytes: 20732
#include<bits/stdc++.h>
using namespace std;
int main(){
int n,c=0,d=0;
cin>>n;
 if(n%4==0||n%7==0)cout<<"Yes"<<endl;
else{
        for(int i=7;i<=n;i+=7){
            for(int j=4;i+j<=n;j+=4){
                if(i+j==n){
                    cout<<"Yes"<<endl;
                    return 0;
                }
            }

        }
        cout<<"No"<<endl;
}
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define mp(a,b) make_pair(a,b)
#define ff first
#define setp(a) setprecision(a)<<fixed
#define ss second
#define fori(v) for(ll i=0; i<v; i++)
#define forj(v) for(ll j=0; j<v; j++)
#define fork(v) for(ll k=0; k<v; k++)
#define forl(v) for(ll l=0; l<v; l++)
#define fort(v) for(ll t=0; t<v; t++)
#define forz(v) for(ll z=0; z<v; z++)
#define forx(v) for(ll x=0; x<v; x++)
#define fory(v) for(ll y=0; y<v; y++)
#define ll long long
#define ld long double
#define MAX (int)(pow(10,6) + 10)
#define pb(a) push_back(a)
const ll INF = 0x3f3f3f3f;
const ll inf = pow(10,18);
ll modulo = pow(10,9)+7;
ld eps = 1e-9;


void deal(){
	vector<pair<ll,ll> > all;
	ll n;
	cin>>n;
	fori(n){
		ll ed;
		cin>>ed;
		all.pb(mp(ed, i+1));
	}
	sort(all.rbegin(), all.rend());
	
	vector<ll> dp(n+10, -inf);
	dp[0] = 0;
	
	fori(all.size()){
		vector<ll> dpn(n+10, -inf);
		
		ll vl = all[i].ff, idx = all[i].ss;
		
		forj(dp.size()){
			if(dp[j] == -inf){
				break;
			}
			{
				ll ind = n-(i-j);
				dpn[j] = max(dp[j] + (ll)fabs(ind-idx)*vl, dpn[j]);
			}
			{
				ll ind = j+1;
				dpn[j+1] = max(dpn[j+1], dp[j] +  (ll)fabs(ind-idx)*vl);
			}
		}
		dp = dpn;
		
//		cout<<"dps after "<<vl<<" "<<idx<<endl;
		
//		forj(dp.size()){
//			cout<<dp[j]<<" ";
//		}
//		cout<<endl;
		
	}
	
	ll mx = -inf;
	fori(dp.size()){
		mx = max(mx, dp[i]);
	}
	
	cout<<mx;
	
}


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





























Measured memory_bytes: 3728
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
import java.util.Scanner;
import java.util.TreeMap;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		int N = sc.nextInt();
		int M = sc.nextInt();

		Map<Integer, ArrayList> map = new TreeMap<Integer, ArrayList>();

		for (int i = 0; i < M; i++) {
			int p = sc.nextInt();
			int y = sc.nextInt();
			map.put(y,new ArrayList<Integer>(Arrays.asList(p,i)));
		}

		int[] cnt = new int[N + 1];
		String[] ans = new String[M+1];

		Arrays.fill(cnt,0);

		int i = 0;
		for (List<Integer> ii : map.values()) {
			ans[ii.get(1)] = String.format("%06d%06d",ii.get(0),++cnt[ii.get(0)]);
			i++;
		}

		for(i = 0; i < M; i++){
			System.out.println(ans[i]);
		}
	}
}


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

class Program {
    static void Main(string[] args) {
        var l = Console.ReadLine().Split(' ')
        .Select(x => long.Parse(x)).ToArray();
        var n = l[0]; var k = l[1]; var q = l[2];
        var jo = new long[n].Select(x => k).ToArray();
        var al = new List<int>();
        for (var i = 0; q > i; i++) {
            var per = int.Parse(Console.ReadLine());
            jo[--per]++;
        }
        jo = jo.Select(x => x - q).ToArray();
        for (var i = 0; n > i; i++) {
            if (jo[i] > 0) Console.WriteLine("Yes");
            else Console.WriteLine("No");
        }
    }
}


Measured memory_bytes: 32996
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <cstdlib>
#include <utility>
#include <cstdio>
#include <vector>
#include <string>
#include <queue>
#include <stack>
#include <cmath>
#include <set>
#include <map>
using ll = long long;
using itn = int;
using namespace std;
int GCD(int a, int b){
    return b ? GCD(b, a%b) : a;
}
int main() {
    int n,m,d;
    cin >> n >> m >> d;
    double ans=0.0;
    if(d==0){
        ans=1.0/n;
    }else{
        ans=(2.0*(n-d))/powf(n,2);
    }
    ans *= (m-1);
    printf("%.10lf",ans);
    return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
	Scanner sc = new Scanner(System.in);
	final int MOD = 998244353;
	final int MAX = Integer.MAX_VALUE;
	final long LMAX = Long.MAX_VALUE;
	int len = (int)1e6 + 1;
	
	
	List<Integer>[] link;
	boolean[] used;
	int H[];
	void doIt() {
		int N = sc.nextInt();
		int M = sc.nextInt();
		used = new boolean[N];
		Arrays.fill(used, false);
		link = new ArrayList[N];
		for(int i = 0; i < N; i++) {
			link[i] = new ArrayList<>();
		}
		H = new int[N];
		for(int i = 0; i < N; i++) H[i] = sc.nextInt();
		for(int i = 0; i < M; i++) {
			int A = sc.nextInt() - 1;
			int B = sc.nextInt() - 1;
			link[A].add(B);
			link[B].add(A);
		}
		int cnt = 0;
		for(int i = 0; i < N; i++) {
			if(!used[i]) {
				cnt += search(i);
			}
		}
		System.out.println(cnt);
	}
	
	int search(int cur) {
		if(used[cur]) return 0;
		used[cur] = true;
		int ans = 1;
		for(int i : link[cur]) {
			if(H[i] >= H[cur]) {
				ans = 0;
			}
			else {
				search(i);
				
			}
		}
		return ans;
	}
	
	public static void main(String[] args) {
		new Main().doIt();
	}

}


Measured memory_bytes: 73232
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repr(i, n) for (int i = (n); i >= 0; --i)
#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define FORR(i, m, n) for (int i = (m); i >= (n); --i)
using namespace std;
typedef long long ll;
const ll mod = 1000000007;
const ll mod2 = 998244353;
const int INF = 1000000005;
const int MAX = 105;

class edge {
  public:
  int t, c;

  edge(int t = -1, int c = INF): t(t), c(c) {}

  bool operator < (const edge &e) const {
    return c > e.c;
  }
};

vector<edge> to[MAX];
bool seen[MAX];
int n;

int prim() {
  seen[0] = true;
  priority_queue<edge> pq;
  int sum = 0, u = 0;

  rep(l, n-1) {
    for (edge e: to[u]) {
      if (seen[e.t]) continue;
      pq.push(e);
    }

    edge d;
    while (1) {
      d = pq.top();
      pq.pop();
      if (!seen[d.t]) break;
    }

    seen[d.t] = true;
    sum += d.c;
    u = d.t;
  }

  return sum;
}

int main() {
  cin >> n;
  edge e;
  rep(i, n) {
    rep(j, n) {
      cin >> e.c;
      if (e.c == -1) continue;
      e.t = j;
      to[i].push_back(e);
    }
  }

  rep(i, n) seen[i] = false;

  cout << prim() << endl;

  
  return 0;
}


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

typedef long long ll;
const int N = 7;

ll cnt[N], ans;

int main() {
	ios::sync_with_stdio(false), cin.tie(0);
	for (int i = 0; i < N; i++)
		cin >> cnt[i];
	ans += 2 * cnt[1];
	cnt[1] = 0;

	
	ll maxi = 0;
	for (int i = 0; i <= min({1LL, cnt[0], cnt[3], cnt[4]}); i++) {
		ll X = 6 * i;
		
		X += 4 * ((cnt[3] - i) / 2);
	
		X += 4 * ((cnt[4] - i) / 2);
	
		X += 4 * ((cnt[0] - i) / 2);

		maxi = max(maxi, X);
	}

	cout << (ans + maxi) / 2;
}


Measured memory_bytes: 256
import numpy as np
N = int(input())

coin = [6**n for n in range(10) if 6**n <= N]
coin += [9**n for n in range(10) if 9**n <= N]

dp = np.zeros(N+1, dtype=np.int32)
dp += 10**9
dp[0] = 0

for c in coin:
  # それぞれの額は9回以下なので
  for _ in range(9):
    dp[c:] = np.minimum(dp[:-c] + 1, dp[c:])

answer = dp[-1]
print(answer)

Measured memory_bytes: 13632
#include<bits/stdc++.h>
using namespace std;
#define ll int64_t
#define sec second
#define f first
#define pb push_back
#define pf push_front
#define po pop_back
const ll mod=1000000007;
#define fast ios_base::sync_with_stdio(false)
#define vi vector<ll>
#define vii vector< pair<ll,ll> >
#define pi pair<ll,ll>
#define pii pair< pair<ll,ll> ,ll >
#define set set<ll>
#define map map<ll,ll>
#define tostr to_string
#define toint stoi
#define gcd __gcd
ll maxm(ll a,ll b){return a>b?a:b;}
ll minm(ll a,ll b){return a>b?b:a;}
#define max maxm
#define min minm
const ll inf=1e18;


int main()
{
    fast;

  ll a,b,c,d;cin>>a>>b>>c>>d;

  ll p=(c%b==0)?c/b:c/b +1;
  ll q=(a%d==0)?a/d:a/d +1;
  if(p>q)
    cout<<"No"<<endl;
  else
    cout<<"Yes"<<endl;
}


Measured memory_bytes: 3668
#貪欲法(greedy)
#ABC076C - Dubious Document 2
#https://atcoder.jp/contests/abc076/tasks/abc076_c
##自己考察
import sys

s = list(input())
sl = len(s)
t = list(input())
tl = len(t)

for i in range(sl-tl,-1,-1):
    count = 0
    for j in range(tl):
        if s[i+j] == "?" or s[i+j] == t[j]:
            count +=1
    if count == tl:
        ans = (''.join((s[0:i] + t + s[i+tl:]))).replace("?","a")
        print(ans)
        sys.exit()

print("UNRESTORABLE")

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define ll long long
#define INF 999999999

const ll mod = 1e9+7;

int main(){
	ll n;
	cin >> n;
	vector<ll> a(n);
	REP(i, n){cin >> a[i];}
	sort(a.begin(), a.end());
	cout << a[n-1] - a[0] << endl;
}


Measured memory_bytes: 256
using System;
using System.Linq;
using System.Collections.Generic;
class Program
{
    static void Main()
    {
        var input = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToList();

        var group = new int[] { 0, 0, 1, 0, 2, 0, 2, 0, 0, 2, 0, 1, 0 };

        if (group[input[0]] == group[input[1]])
        {
            Console.WriteLine("Yes");
        }
        else
        {
            Console.WriteLine("No");
        }
    }
}

Measured memory_bytes: 11220
import java.util.PriorityQueue;
import java.util.Queue;
import java.util.Scanner;
import java.util.stream.IntStream;

/**
 * 解説どおりに作成したソースコード
 */
public class Main {

	public static void main(String[] args) {
		try (Scanner scanner = new Scanner(System.in)) {
			int n = scanner.nextInt();
			int[] a = new int[3 * n];
			IntStream.range(0, 3 * n).forEach(i -> a[i] = scanner.nextInt());
			// それぞれ前半と後半の計算結果
			long[] result1 = new long[n + 1], result2 = new long[n + 1];
			// 前半の計算用
			Queue<Integer> minQueue = new PriorityQueue<>((x, y) -> x.compareTo(y));
			result1[0] = IntStream.range(0, n).mapToLong(i -> (long) a[i]).sum();
			// 後半の計算用
			Queue<Integer> maxQueue = new PriorityQueue<>((x, y) -> y.compareTo(x));
			result2[n] = IntStream.range(2 * n, 3 * n).mapToLong(i -> (long) a[i]).sum();
			IntStream.range(0, n).forEach(i -> {
				minQueue.add(a[i]);
				maxQueue.add(a[3 * n - i - 1]);
			});
			IntStream.rangeClosed(1, n).forEach(i -> {
				// 前半の計算
				minQueue.add(a[n + i - 1]);
				result1[i] = result1[i - 1] + a[n + i - 1] - minQueue.poll();
				// 後半の計算
				maxQueue.add(a[n + n - i]);
				result2[n - i] = result2[n - i + 1] + a[n + n - i] - maxQueue.poll();
			});
			System.out.println(IntStream.rangeClosed(0, n).mapToLong(i -> result1[i] - result2[i]).max().getAsLong());
		}
	}
}


Measured memory_bytes: 97596
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define REP(i,a,b) for(int i=(a),_end_=(b);i<=_end_;i++)
#define DREP(i,a,b) for(int i=(a),_end_=(b);i>=_end_;i--)
#define EREP(i,u) for(int i=start[u];i;i=e[i].next)
#define fi first
#define se second
#define mkr(a,b) make_pair(a,b)
#define SZ(A) ((int)A.size())
template<class T>inline void chkmin(T &a,T b){ if(a>b)a=b;}
template<class T>inline void chkmax(T &a,T b){ if(a<b)a=b;}
inline int read()
{
	int s=0,f=1; char ch=getchar();
	while(!isdigit(ch) && ch!='-')ch=getchar();
	if(ch=='-')ch=getchar(),f=-1;
	while(isdigit(ch))s=s*10+ch-'0',ch=getchar();
	return ~f?s:-s;
}

const int maxn=5e3+20;

int n,mod;
int dp[maxn];

inline void init()
{
	n=read();mod=read();
}

inline void pls(int &a,int b){ a+=b; a-=a>=mod?mod:0;}

int f[maxn][maxn];

inline void doing()
{
	int len=n-1>>1;
	dp[0]=1;
	REP(i,1,len+(~n&1))
	{
		int w=i;
		for(int j=w;j<=n;j++)
			pls(dp[j],dp[j-w]);
	}
	f[0][0]=1;
	REP(i,1,n)
	{
		REP(j,0,n)f[i][j]=f[i-1][j];
		REP(j,i,n)pls(f[i][j],f[i][j-i]);
	}
	DREP(i,n,1)
	{
		int s=0;
		REP(j,0,n)
		{
			pls(s,f[i-1][j]);
			int nj=j+len+1;
			if(nj<=n)pls(f[i][nj],mod-s);
		}
	}
	int ans=0;
	REP(x,1,n)
	{
		int a=x-1,mx=n-x;
		int suf=0;
		DREP(j,a,0)
		{
			suf=(suf+dp[a-j])%mod;
			ans=(ans+(ll)suf*f[mx][j])%mod;
		}
	}
	printf("%d\n",ans);
}

int main()
{
	init();
	doing();
	return 0;
}


Measured memory_bytes: 98560
#include <algorithm>
#include <iostream> //入出力
#include <stdio.h>
#include <map>
#include <set>
#include <string>
#include <math.h> //算術演算子
#include <vector>
#include <cstdlib>
#include <queue>
#include <stack>
#include <list>
#include <iomanip> //小数点以下を表示させる(setprecision())
//#include <bits/stdc++.h>
using namespace std;
typedef long long ll; //64bit型

#define rep(i, n) for (int i = 0; i < (n); i++)
#define all(a) (a).begin(), (a).end()
#define debug(x) cerr << x << " " \
                      << "(L:" << __LINE__ << ")" << '\n'
#define PRINT(V)                                   \
        {                                          \
                for (int i = 0; i < V.size(); i++) \
                {                                  \
                        cout << V[i] << " ";       \
                }                                  \
                cout << endl;                      \
        }

int gcd(int a, int b)
{
        return b ? gcd(b, a % b) : a;
}

int main()
{
        //input->compute->output//

        int N;
        cin >> N;

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

        vector<int> t(N);
        for (int i = 0; i < N; i++)
        {
                t[i] = p[i];
        }

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

        int cnt = 0;
        for (int i = 0; i < N; i++)
        {
                if (p[i] != t[i])
                {
                        cnt++;
                }
        }
        if (cnt == 2 || cnt == 0)
        {
                cout << "YES" << endl;
        }
        else
        {
                cout << "NO" << endl;
        }

        return 0;
}


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

#define ff              first
#define ss              second
#define int             long long
#define pb              push_back
#define mp              make_pair
#define pii             pair<int,int>
#define vi              vector<int>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define mod             1000000007
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define mk(arr,n,type)  type *arr=new type[n];
#define w(x)            int x; cin>>x; while(x--)


void aryan_p() {
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	return;
}


int32_t main() {


	int n, k, q;
	cin >> n >> k >> q;
	int a[n];
	for (int i = 0 ; i < n ; i++) {
		a[i] = k;
	}
	while (q--) {
		int v ;
		cin >> v;
		a[v - 1]++;
	}
	int m = 0 ;
	for (int i = 0 ; i < n ; i++) {
		if (a[i] != k) {
			m += (a[i] - k);
		}
	}
	// cout << m << "\n";
	if (m >= k) {
		for (int i = 0; i < n ; i++) {
			if ((m - a[i]) >= 0) {
				cout << "No\n";
			}
			else {
				cout << "Yes\n";
			}
		}
	}
	else {
		for (auto x : a) {
			cout << "Yes\n";
		}
	}

	return 0;
}

Measured memory_bytes: 4392
#include<iostream>
#include<string>
using namespace std;
int main()
{
    int n;
    string s, t;
    cin >> n >> s >> t;
    for(int i = 0; i < n; i++){
        if(s[i] == t[0]){
            bool f = 0;
            for(int j = i; j < n; j++){
                if(s[j] != t[j-i]){
                    f = 1;
                    break;
                }
            }
            if(f == 0){
                cout << n * 2 - (n - i) << endl;
                return 0;
            }
        }
    }
    cout << 2 * n << endl;
    return 0;
}

Measured memory_bytes: 256
# coding: utf-8
from __future__ import unicode_literals
from __future__ import print_function
import sys
import itertools

def main():
    k,s = map(int,sys.stdin.read().split())
    ans = []
    count = 0
    for x in xrange(k+1):
        for y in xrange(k+1):
            if x + y <= s:
                z = s - (x + y)
                if(z>=0 and z <= k):
                    count += 1
                    # ans.append([x,y,z])
            else:
                break
    # sys.stdout.write("%d" % len(ans))
    sys.stdout.write("%d" % count)

if __name__ == '__main__':
    main()  


Measured memory_bytes: 2688
#ifdef LOCAL
#define _GLIBCXX_DEBUG
#endif
#include <bits/stdc++.h>
 
using namespace std;
 
#define forn(i, n) for (int i = 0; i < int(n); ++i)
#define forab(i, a, b) for (int i = int(a); i < int(b); ++i)
#define ford(i, n) for (int i = int(n) - 1; i >= 0; --i)
#define sz(c) int((c).size())
#define all(c) (c).begin(), (c).end()
#define mp(x, y) make_pair(x, y)
#define pb push_back
#define fst first
#define snd second
 
using ll = long long;
using vi = vector<int>;
using vll = vector<ll>;
using pii = pair<int, int>;
using vvi = vector<vi>;
using vii = vector<pii>;

#ifdef LOCAL
#define eprintf(args...) fprintf(stderr, args), fflush(stderr)
#else
#define eprintf(...) ;
#endif

#define FILE_NAME "a"
 
int n;
vi a, b;

bool read() {
    if (!(cin >> n)) {
        return 0;
    }

    a = b = vi(n);
    forn (i, n)
        cin >> a[i];
    forn (i, n)
        cin >> b[i];

    return 1;
}

bool can (const vi &a, const vi &b, ll ans)
{
    const int A = *max_element(all(a));
    forn (i, n) if (a[i] < b[i])
        return false;

    vvi reach(A + 1, vi(A + 1));
    forn (i, A + 1)
        reach[i][i] = 1;

    forn (i, A + 1) forn (rem, 60) if (rem && ((ans >> rem) & 1))
        reach[i][i % rem] = 1;

    forn (v, A + 1) forn (i, A + 1) forn (j, A + 1) if (reach[i][v] && reach[v][j])
        reach[i][j] = 1;

    bool ok = true;
    forn (i, n)
        ok &= reach[a[i]][b[i]];

    return ok;
}

ll solve() {
    const int A = *max_element(all(a));

    if (!can(a, b, (1LL << (A + 1)) - 1))
        return -1;
    
    ll ans = 0;
    for (int k = A; k >= 1; k--)
    {
        if (!can(a, b, ans + (1LL << k) - 1))
            ans += (1LL << k);
    }

    return ans;
}
 
int main() {
#ifdef LOCAL
    freopen(FILE_NAME ".in", "r", stdin);
    freopen(FILE_NAME ".out", "w", stdout);
#endif

    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
 
    while (read()) {
        ll ans = solve();
        cout << ans << endl;
//        break; 
    }
 
    return 0;
}


Measured memory_bytes: 256
S = input()
flag = True
for i, s in enumerate(S):
    if i % 2 == 1 and s == 'R':
        flag = False
        break
    elif i % 2 == 0 and s == 'L':
        flag = False
        break

if flag:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 38492
n = int(input())
a = [int(i) for i in input().split()]
b = [0] * n

if (n % 2 == 0) :
  b[n // 2] =a[0]
  b[0] = a[n - 1]
  for i in range(n//2 - 1) :
    b[(n // 2) - i - 1] = a[2 * i + 1]
    b[(n // 2) + i + 1] = a[2 * (i+1)]
  for i in range(n-1) :
    print(b[i], end = ' ')
  print(b[n-1])

if (n % 2 == 1) :
  b[n // 2] =a[0]
  for i in range(n//2) :
    b[(n // 2) + i + 1] = a[2 * i + 1]
    b[(n // 2) - i - 1] = a[2 * (i+1)]
  for i in range(n-1) :
    print(b[i], end = ' ')
  print(b[n-1])

Measured memory_bytes: 26020
N,K = map(int,input().split())
A = list(map(int,input().split()))
g = A[0]
import fractions
for i in range(1,N):
    g = fractions.gcd(g,A[i])
if K % g == 0:
    if K <= max(A):
        print('POSSIBLE')
    else:
        print('IMPOSSIBLE')
else:
    print('IMPOSSIBLE')

Measured memory_bytes: 14224
#include <iostream>
#include <math.h>
#include <stdio.h>
#include <algorithm>   
static int N, K;
static int stones[100004];
static int rem[100004];

using namespace std;




int solotion(int i) {
	if (i >= N - 1) {
		return 0;
	}
	if (rem[i] != -1) {
		return rem[i];
	}
	

	int first = abs(stones[i] - stones[i + 1]) + solotion(i + 1);

	for (int j = 2; j <= K; j++) {
		
		int ks = i+j < N ? abs(stones[i] - stones[i+j]) + solotion(i + j) : first + 1;
		first = min(first, ks);
		rem[i] = first;
	}
	rem[i] = first;
	return rem[i];
}

int main() {
	cin >> N;
	cin >> K;
	for (int i = 0; i < N; i++) {
		cin >> stones[i];
		rem[i] = -1;
	}

	printf("%d", solotion(0));
}



Measured memory_bytes: 5760
#include<bits/stdc++.h>
using namespace std;
int n,m,hsh1[200005],hsh2[200005],a,b,type=-1;
int main()
{
	scanf("%d%d",&n,&m);
	for(int i=1;i<=m;i++)
	{
		scanf("%d%d",&a,&b);
		if(a==1)
		{
			++hsh1[b];
		}
		if(b==n)
		{
			++hsh2[a];
		}
	}
	for(int i=1;i<=n;i++)
	{
		if(hsh1[i]==1&&hsh2[i]==1)
		{
			type=0;
		}
	}
	if(type==0)
	{
		printf("POSSIBLE\n");
	}else
	{
		printf("IMPOSSIBLE\n");
	}
}

Measured memory_bytes: 5208
n,k=map(int,input().split())
a=[0]+list(map(int,input().split()))
c=[0]*(n+1)
c[1]=1
q=[0,1]
while True:
  i=a[q[-1]]
  if c[i]:break
  c[i]=c[q[-1]]+1
  q+=[i]
if c[i]<k:
  k-=c[i]-1
  t=c[q[-1]]-c[i]+1
  print(q[c[i]+k%t])
else:print(q[k+1])

Measured memory_bytes: 96920
#include <iostream>
#include <functional>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <string>
#include <set>
#include <queue>
#include <map>
#include <iomanip>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;++i)
#define repi(i,n) for(ll i=n-1;i>=0;--i)
#define sll(n) scanf("%lld", &n);
#define slf(n) scanf("%lf", &n);
typedef long long ll;
typedef double lf;
static const ll max_n = 100010;
static const ll mod = 1000000007;
static const ll max_value = 100000000000100;

ll N, M;


void Main(){
    // bool is_ok = true;
    // printf("------------- V=%lld---------\n", V);
    string S;
    cin >> S;

    if (S[1]=='B'){
        printf("ARC\n");
    }else{
        printf("ABC\n");
    }


    // cout<<fixed<<setprecision(10)<<num<<endl;
    // cout << num << endl;

}

int main(){
    Main();

    return 0;

}

Measured memory_bytes: 3132
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <queue>
#include <string>

using namespace std;

int n, l, r , ans;
int main() {
	cin >> n;
	while(n--)
	{
		cin >> l >> r;
		ans += r - l + 1;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
import java.util.*;
public class Main {
	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String S = sc.next();
		long ret = 0;
		long countB = 0;
		int N = S.length();
		for(int i=0;i<N;i++) {
			if(S.charAt(i)=='B') {
				ret += (long)N-1-i;
				countB++;
			}
		}
		System.out.println(ret-(countB*(countB-1))/2);
	}
}

Measured memory_bytes: 26024
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AtCoder.Abc
{
    //https://atcoder.jp/contests/abc141/tasks/abc141_a
    public class QuestionA
    {
        public static void Main(string[] args)
        {
            var sw = new System.IO.StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);

            long x = long.Parse(Console.ReadLine());
            long a = long.Parse(Console.ReadLine());
            long b = long.Parse(Console.ReadLine());

            long result = 0;

            for(int i = 0; (b * i) + a <= x; i++) {
                result = x - (b * i) - a;
            }

            Console.WriteLine(result);

            Console.Out.Flush();
        }
    }
}


Measured memory_bytes: 11092
use std::io;
use std::str::FromStr;

static MOD: u64 = 998244353;

fn input_tuple() -> (usize, usize) {
    let mut line: String = String::new();
    io::stdin().read_line(&mut line);
    let vec: Vec<usize> = line.split_whitespace().map(|s| s.parse().unwrap()).collect();
    (vec[0], vec[1])
}

fn input_vec() -> Vec<u64> {
    let mut line: String = String::new();
    io::stdin().read_line(&mut line);
    line.split_whitespace().map(|s| s.parse().unwrap()).collect()
}

fn main() {
    let (n, s) = input_tuple();
    let a_vec = input_vec();
    let mut dp: Vec<Vec<u64>> = vec![vec![0; s+1]; n+1];
    dp[0][0] = 1;
    for i in 1..(n+1) {
        for j in 0..(s+1) {
            dp[i][j] = dp[i-1][j] * 2;
            dp[i][j] %= MOD;
            if j as u64 >= a_vec[i - 1] {
                dp[i][j] += dp[i-1][j - a_vec[i-1] as usize];
                dp[i][j] %= MOD;
            }
        }
    }
    // println!("{:?}", dp);
    println!("{}", dp[n][s]);
}


Measured memory_bytes: 72460
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rrep(i,m, n) for(int i = m; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define aall(x,n) (x).begin(),(x).begin()+(n)
#define pb push_back
#define pf push_front
#define lb lower_bound
#define ub upper_bound
#define fi first
#define se second
#define sum accumulate
#define keta fixed<<setprecision
#define vvector(name,typ,m,n,a)vector<vector<typ> > name(m,vector<typ> (n,a))
#define vvvector(name,t,l,m,n,a) vector<vector<vector<t> > > name(l, vector<vector<t> >(m, vector<int>(n,a)));
typedef long long ll;
const int INF = 2000000000;
const long INF64 = 1000000000000000ll;
const ll MOD = 1000000007LL;
int main(){
  int n;
  std::cin >> n;
  std::vector<int> a;
  if(n==1){
    std::cout << 1 << std::endl;
    exit(0);
  }
  for (int i = 2; i < sqrt(n); i++) {
    /* code */
    for(int j=2;pow(i,j)<=n;j++){
      a.pb(pow(i,j));
    
    }
  }
  sort(all(a),greater<int>());
  std::cout << a[0] << std::endl;
}

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

int main() {
    int n, k;
    cin >> n >> k;
    vector<vector<int>> snuke(n, vector<int>(0));
    for (int i = 0; i < k; ++i) {
        int d;
        cin >> d;
        for (int j = 0; j < d; ++j) {
            int x;
            cin >> x;
            --x;
            snuke[x].emplace_back(1);
        }
    }
    int ans = 0;
    for (int l = 0; l < n; ++l) {
        if (snuke[l].empty()) ans++;
    }
    cout << ans << endl;
}


Measured memory_bytes: 3608
#include <bits/stdc++.h>
#include <math.h>
#define ALL(a)    a.begin(), a.end()
using namespace std;

int main() {
int N;cin >> N;
long long A = 0, B = 0, C = 0, count = 0;
vector<char> V(N);

for(int i = 0; i < N; i++){
cin >> V[i];
if(V[i] == 'R')A++;
if(V[i] == 'G')B++;
if(V[i] == 'B')C++;
}

for(int i = 0; i < N; i++){
for(int j = 1 + i; j < N; j++){

if(2*j - i < N){
    
    if(V[i] != V[j] && V[i] != V[2*j - i] && V[2*j - i] != V[j])count++;

}

}}

cout << A*B*C - count;
}

Measured memory_bytes: 3604
#include <stdio.h>
int main()
{
    int a,sum=2,i;
    scanf("%d",&a);
    if(a==1)
    printf("1\n");
    else
    for(i=1;;i++)
    {
        if(sum>a)
        {printf("%d\n",sum/2);break;}
        sum*=2;
    }
}


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

string s, t;
int dp[3010][3010];
pair <int, int> path[3010][3010];

int main(){
	cin >> s >> t;
	s = " " + s, t = " " + t;
	for (int i = 1; i < s.length(); i++){
		for (int j = 1; j < t.length(); j++){
			dp[i][j] = dp[i - 1][j - 1] + (s[i] == t[j]);
			path[i][j] = make_pair(i - 1, j - 1);
			if (dp[i - 1][j] > dp[i][j]) dp[i][j] = dp[i - 1][j], path[i][j] = make_pair(i - 1, j);
			if (dp[i][j - 1] > dp[i][j]) dp[i][j] = dp[i][j - 1], path[i][j] = make_pair(i, j - 1);
		}
	}
	pair <int, int> now(s.length() - 1, t.length() - 1);
	string res;
	while (now != make_pair(0, 0)){
		if (s[now.first] == t[now.second]) res.push_back(s[now.first]);
		now = path[now.first][now.second];
	}
	reverse(res.begin(), res.end());
	printf("%s\n", res.c_str());
	return 0;
}


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


typedef long long ll; // -9,223,372,036,854,775,808 から 9,223,372,036,854,775,807

template <class T> using vec = std::vector<T>;
template <class T> using vec2 = vec<vec<T>>;
template <class T> using vec3 = vec<vec<vec<T>>>;

// #define DEBUG


ll f(ll A, ll B, ll N, ll x){
    if(x < 0){
        x = 0;
    }
    if(x > N){
        x = N;
    }
    return ((A*x)/B) - A*(x/B);
}

void solve(long long A, long long B, long long N){
    cout << f(A, B, N, B-1) << endl;

}

// 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 A;
    scanf("%lld",&A);
    long long B;
    scanf("%lld",&B);
    long long N;
    scanf("%lld",&N);
    solve(A, B, N);
    return 0;
}


Measured memory_bytes: 3764
import java.util.*;
 
public class Main {
    public static void main(String[] args) throws NumberFormatException{
        Scanner sc = new Scanner(System.in);
        int w = sc.nextInt();
        int n = sc.nextInt();
        int[] values = new int[w];
        for(int i = 0; i < values.length; i++){
            values[i] = i + 1;
        }
        for(int i = 0; i < n; i++){
            String str = sc.next();
            String[] ab = str.split(",");
            int a = Integer.parseInt(ab[0]) - 1;
            int b = Integer.parseInt(ab[1]) - 1;
            int tmp = values[a]; values[a] = values[b]; values[b] = tmp;
        }
        for(int i = 0; i < values.length; i++)
            System.out.println(values[i]);
    }
}

Measured memory_bytes: 26260
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <map>
#include <cmath>
#include <ctime>

using namespace std;

int main( int argc, char** argv ){
	int N;

	cin >> N;

	vector<double> x( N );
	vector<string> u( N );

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

	double ans = 0.0;

	for (int i = 0; i < N; i++){
		if (u[i] == "JPY"){
			ans += x[i];
		}
		else{
			ans += x[i] * 380000.0;
		}
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
import bisect

while(1):
    n=int(raw_input())
    m=n/2+1
    if n==0:
        break
    else:
        S=sorted([int(x) for x in raw_input().split()])
        i=0
        while(i<n):
            s=S[i]
            num=bisect.bisect(S,s)-bisect.bisect_left(S,s)
            if num>=m:
                print s
                break
            else:
                i=bisect.bisect(S,s)
        else:
            print 'NO COLOR'

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

int main(){
  int a,b;scanf("%d%d",&a,&b);
  double ret=0;
  for(int i=1;i<=a;i++){
    double tmp=1.0/a;
    int now=i;
    while(now<b){
now*=2;
tmp/=2; }
ret+=tmp; }
  printf("%.12f\n",ret);
}

Measured memory_bytes: 256
#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, m;
  cin >> n >> m;
  vector<ll> h(n);
  for (int i = 0; i < n;i++) {
    cin >> h[i];
  }
  
  vector<vector<int>> mi(n, vector<int>(0));
  for (int i = 0; i < m; i++) {
    int a, b;
    cin >> a >> b;
    a--;
    b--;
    mi[a].push_back(b);
    mi[b].push_back(a);
  }
  int count = 0;
  for (int i = 0; i < n; i++) {
    ll M = 0;
    for (int x : mi[i]) {
      M = max(M, h[x]);
    }
    if (h[i] > M) {
      count++;
    }
  }
  cout << count <<endl;
}

Measured memory_bytes: 9068
from functools import cmp_to_key

def cmp(a, b):
    if a[0] == b[0]:
        return -1 if a[1] > b[1] else 1
    else:
        return -1 if a[0] < b[0] else 1


def main():
    N = int(input())
    SP = []
    for i in range(N):
        sp = input().split()
        SP.append((sp[0], int(sp[1]), i+1))
    for a in sorted(SP, key=cmp_to_key(cmp)):
        print(a[2])


main()


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

int main()
{
  int k, n;
  cin >> k >> n;
  valarray<int> va(n);
  for (int i = 0; i < n; i++)
    cin >> va[i];
  valarray<int> d = va.shift(1) - va;
  d[n - 1] = va[0] + k - va[n - 1];
  cout << d.sum() - d.max() << endl;
}


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

class Program
{
    static void Main(string[] args)
    {
        var inputs = Console.ReadLine().Split(' ');
        var X = int.Parse(inputs[0]);
        var Y = int.Parse(inputs[1]);

        var result = X + Y / 2;
        Console.WriteLine(result);

    }



}



Measured memory_bytes: 13140
#include <bits/stdc++.h>
 
using namespace std;
 
#define lli long long int
#define REP(i,s,n) for(int i=s;i<n;i++)
#define MOD 1000000007
#define NUM 2520
#define INF (1LL<<50)
#define DEBUG 0
#define mp(a,b) make_pair(a,b)
#define SORT(V) sort(V.begin(),V.end())
#define PI (3.141592653589794)

signed main(){

	lli n,x;
	cin>>n>>x;

	vector<lli> a(n);
	REP(i,0,n)cin>>a[i];

	lli ans = 0;
	REP(i,1,n){
		lli sum = a[i]+a[i-1]-x;
		if(sum>0){
			ans += sum;
			if(a[i]>sum){
				a[i] -= sum;
			}
			else{
				sum -= a[i];
				a[i] = 0;
				a[i-1] -= sum;
			}
		}
	}
	cout<<ans<<endl;

	return 0;
 
}

Measured memory_bytes: 1024
gets
T, A = gets.split(" ").map{|d|d.to_i}
H = gets.split(" ").map{|d|d.to_i}

temps = []
min_t = (0..H.size-1).map{|n|
	temps[n] = (A - (T - H[n] * 0.006)).abs
}.min
ret = 0
(0..temps.size-1).map{|n|
  if min_t == temps[n]
    ret = n+1
  end
}
puts ret



Measured memory_bytes: 1788
#float型を許すな
#numpyはpythonで
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**7)
from collections import Counter, deque
from collections import defaultdict
from itertools import combinations, permutations, accumulate, groupby, product
from bisect import bisect_left,bisect_right
from heapq import heapify, heappop, heappush
from math import floor, ceil,pi,factorial
from operator import itemgetter
def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))
def LI2(): return [int(input()) for i in range(n)]
def MXI(): return [[LI()]for i in range(n)]
def SI(): return input().rstrip()
def printns(x): print('\n'.join(x))
def printni(x): print('\n'.join(list(map(str,x))))
inf = 10**17
mod = 10**9 + 7

s=input().rstrip().split("T")
x,y=MI()
    #print(s)
x0=len(s[0])
x=x-x0
X=[]
Y=[]
for i in range(1,len(s)):
    if i%2==1:
        Y.append(len(s[i]))
    else:
        X.append(len(s[i]))
#print(x,y)
#print(X)
#print(Y)
dpx=[[0]*(2*sum(X)+1) for i in range(len(X)+1)]
dpx[0][sum(X)]=1
for i in range(len(X)):
    for j in range(len(dpx[i])):
        if dpx[i][j]==1:
            dpx[i+1][j+X[i]]=1
            dpx[i+1][j-X[i]]=1
#print(dpx)
dpy=[[0]*(2*sum(Y)+1) for i in range(len(Y)+1)]
dpy[0][sum(Y)]=1
for i in range(len(Y)):
    for j in range(len(dpy[i])):
        if dpy[i][j]==1:
            dpy[i+1][j+Y[i]]=1
            dpy[i+1][j-Y[i]]=1
##print(sum(X)+x)
#print(sum(Y)+y)
if sum(X)+x<0 or sum(X)+x>=len(dpx[-1]) or sum(Y)+y<0 or sum(Y)+y>=len(dpy[-1]):
    print("No")
    sys.exit()
if dpx[-1][sum(X)+x]==1 and dpy[-1][sum(Y)+y]==1:
    print("Yes")
else:
    print("No")
    
    
    

    
    


    
    

        
        
    


    

Measured memory_bytes: 199480
k = 40 # 多倍長整数内で、一整数を何bitでもつか。
MOD = 200003
list_size = 2 * MOD - 1


def n2l(num, list_size = list_size):
    "number to list"
    s = '{0:0{1}b}'.format(num, k * list_size)
    return [int(s[i-k:i], 2) for i in range(k * list_size, 0, -k)]

def l2n(ls):
    "list to number"
    return int(''.join(('{0:0{1}b}'.format(n, k) for n in reversed(ls))), 2)


def rn2l(num, list_size = list_size):
    "reversed n2l"
    s = '{0:0{1}b}'.format(num, k * list_size)
    return [int(s[i:i+k], 2) for i in range(0, k * list_size, k)]

def rl2n(ls):
    "reversed l2n"
    return int(''.join(('{0:0{1}b}'.format(n, k) for n in ls)), 2)


N = int(input())
As = sorted(map(int, input().split()))

two_pow = [1] * MOD
for i in range(1, MOD):
    two_pow[i] = two_pow[i-1] * 2 % MOD

two_pow_inv = [0] * MOD
for i, e in enumerate(two_pow[:-1]):
    two_pow_inv[e] = i

cnt = [0] * MOD # cnt[i] counts 2 ** i % P
for A in As:
    if A != 0:
        cnt[two_pow_inv[A]] += 1

cnt_conv = rn2l(rl2n(cnt) ** 2)
ans = 0
for i, cnt in enumerate(cnt_conv):
    if i < MOD:
        ans += two_pow[i] * cnt
    else:
        ans += two_pow[i - MOD + 1] * cnt

ans -= sum((A**2 % MOD for A in As))
ans //= 2
print(ans)

Measured memory_bytes: 263304
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
int main(){
  ll N,K;
  cin>>N>>K;
  vector<ll>ac(N,0);
  vector<ll>ce(K,0);
  ll c=0;
  ll d=0;
  for(ll i=0;i<K;i++){
    ll a;
    string b;
    cin>>a>>b;
    if(b=="AC"&&ac.at(a-1)==0){
      ac.at(a-1)=i+1;
    }
    if(b=="WA"){
      ce.at(i)=a;
    }
  }
  for(ll i=0;i<K;i++){
    if(ce.at(i)!=0){
      if(ac.at(ce.at(i)-1)>i+1){
        c+=1;
      }
    }
  }
  for(ll i=0;i<N;i++){
    if(ac.at(i)!=0){
      d+=1;
    }
  }
  cout<<d<<" "<<c<<endl;
}

Measured memory_bytes: 4768
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <cstring>
#include <climits>
using namespace std;

int n, m;
int a[28], b[28];
int t[8] = {};
int k[8] = {};
int e[8][8] = {};

int f(int v, int d) {
    if (t[v]) return 0; else t[v] = 1;
    if (d == 0) {
        t[v] = 0;
        return 1;
    }
    int s = 0;
    for (int i = 0; i < k[v]; i++) {
        s += f(e[v][i], d - 1);
    }
    t[v] = 0;
    return s;
}

int main() {
    cin >> n >> m;
    for (int i = 0; i < m; i++) {
        cin >> a[i] >> b[i];
        int v0 = a[i] - 1, v1 = b[i] - 1;
        e[v0][k[v0]++] = v1;
        e[v1][k[v1]++] = v0;
    }
    cout << f(0, n - 1) << endl;
    return 0;
}


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

int main() {
  string S;
  cin >> S;
  
  bool check = true;
  bool power = true;
  int N = S.size() - 1;
  
  for (int i = 0;i < (N / 2);i++) {
    if (S.at(i) != S.at(N-i)){
      check = false;
    }
  }
  
  if (check == true){
    for (int i = 0;i < (N / 2);i++){
      if (S.at(i) != S.at((N/2)-i-1)){
        power = false;
      }
    }
  }
  
  if (check == true && power == true){
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
  
  
}


Measured memory_bytes: 256
/*
Author: Srinjoy
Language: C++ 17
*/
#include<bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define de(a) cout << #a << " = " << a << endl
#define dd(a) cout << #a << " = " << a << " "
#define optimiza_io cin.tie(0); ios_base::sync_with_stdio(0);
#define ZERO(a) memset(a,0,sizeof(a))
#define fileinput(s) freopen(s,"r",stdin)
#define MINUS(a) memset(a,0xff,sizeof(a))
typedef long long ll;
const ll mod = 1000000007;

template<class T>
istream& operator >> (istream& in, vector<T>& v){ for (auto &x : v) { in >> x; } return in; }
 
template<class T>
istream& operator >> (istream& in, pair<T, T> & v){ in >> v.fi >> v.se;return in; }

void printArr(vector<int> arr){
	cout<<"\n------------------------------------\n";

	for(int i=0;i<arr.size();i++) cout<<arr[i]<<" ";
	
	cout<<"\n------------------------------------\n";
}

void printArr(vector<vector<int> > arr){
	cout<<"\n------------------------------------\n";

	for(vector<int> i:arr){
		for(int j:i){
			cout<<j<<" ";
		}
		cout<<endl;
	}
	
	cout<<"\n------------------------------------\n";

}


int main(){
	optimiza_io
	ll h,n;
	cin>>h>>n;
	vector<int> arr(n);
	cin>>arr;

	for(int i:arr){
		h-=i;
	}

	if(h<=0) cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
}

Measured memory_bytes: 640
#include<iostream>
#include<stdio.h>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<map>
#define ll long long
using namespace std;
int a[200009];
int main(){
    int n;
    cin>>n;
    int two=0;
    int fou=0;
    for(int i=1;i<=n;i++){
        cin>>a[i];
 
        if(a[i]%4==0){
            fou++;
        }
        else if(a[i]%2==0){
            two++;
        }
    }
    n-=(two/2)*2;
    n-=fou;
    if(fou>=n-1){
        cout<<"Yes"<<endl;
    }
    else{
        cout<<"No"<<endl;
    }
}

Measured memory_bytes: 768
#include <iostream>
using namespace std;
int main(void){

    int n,m;
    
    cin >> n >> m;
    
    int A[n][m];
    int b[m];
    int c;
    
    int d;
    for(int i=0;i<n;i++){
        for(int j=0;j<m;j++){
            cin >> d;
            A[i][j]=d;
        }
    }
    for(int j=0;j<m;j++){
        cin >> d;
        b[j]=d;
    }

    for(int i=0;i<n;i++){
        c=0;
        for(int j=0;j<m;j++){
            c += (A[i][j] * b[j]);
        }
        cout << c << endl;
    }
    return 0;
}



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

bool is_black_out(int x, int y, int xi, int yi, int a) {
  switch (a) {
    case 1:
      return x < xi;
    case 2:
      return x >= xi;
    case 3:
      return y < yi;
    case 4:
      return y >= yi;
    default:
      return false;
  }
}

int main() {
  int W, H, N;
  cin >> W >> H >> N;

  bool xy_plane[W][H];
  for (int x = 0; x < W; x++) {
    for (int y = 0; y < H; y++) {
      xy_plane[x][y] = false;
    }
  }

  for (int i = 0; i < N; i++) {
    int xi, yi, a;
    cin >> xi >> yi >> a;

    for (int x = 0; x < W; x++) {
      for (int y = 0; y < H; y++) {
        xy_plane[x][y] = xy_plane[x][y] || is_black_out(x, y, xi, yi, a);
      }
    }
  }

  int counter = 0;
  for (int x = 0; x < W; x++) {
    for (int y = 0; y < H; y++) {
      if (!xy_plane[x][y]) counter++;
    }
  }

  cout << counter << endl;
}

Measured memory_bytes: 3600
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc=new Scanner(System.in);
        int K=sc.nextInt();
        int N=sc.nextInt();
        int first=sc.nextInt();
        int before=first;
        int haba=-1;
        int next=0;
        
        for(int i=0;i<N-1;i++){
            next=sc.nextInt();
            if(haba<next-before){
                haba=next-before;
            }
            before=next;
        }
        
        if(first+K-next>haba){
            haba=first+K-next;
        }
        
        System.out.println(K-haba);
    }
}


Measured memory_bytes: 65496
//Twitter@KonoLv1 2020年春卒で現在就職活動中！

#include <stdio.h>
int main(void){
    int i,j;            //  ループ文に使用
    int x,y,z;
    int count,count2;   //  カウント用に使用
    char s[256];        //  文字列
    int l,r;
    count = 0;
    count2 = 0;
    
    //  入力処理
    
    scanf("%d %d %d",&x,&y);
    
    //  計算処理
    l = y - x + 1;
    r = y + x - 1;

    //  出力処理
    
    for (i = l; i <= r; i++){
        printf("%d ",i);
    }
    
    
}

Measured memory_bytes: 128
#include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<utility>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<unordered_set>
#include<unordered_map>
#include<bitset>
using namespace std;
#define INF 2000000007
#define LINF 100000000000000007
#define MOD 1000000007
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define repb(i, n) for (int i = n - 1; i >= 0; i--)
#define MODE 0
#ifdef MODE
#define DEB(X) cout<< #X <<": "<<X<<" ";
#define ARDEB(i,X) cout<< #X <<"["<<i<<"]: "<<X[i]<<" ";
#define END cout<<endl;
#else
#define DEB(X) {}
#define ARDEB(i,X) {}
#define END {}
#endif
typedef long long ll;
typedef pair<int,int> P;
struct edge{int to,cost;};
int ceil2(int a,int b){if(a%b){return a/b+1;}else{return a/b;}}
using namespace std;

int n,m,ans;
int a[111111];
signed main(){
	int sum=0;
	cin>>n>>m;
	rep(i,n){
		cin>>a[i];
		sum+=a[i];
	}
	int m2=m;
	rep(i,n){
		if(double(sum)/((double)m2*(double)4)<=(double)a[i])m--;
	}
	if(m<=0)cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
	
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using db = double;
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define all(v) (v).begin(), (v).end()
#define siz(v) (ll)(v).size()
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define repi(i, x, n) for (ll i = x; i < (ll)(n); i++)
#define lb lower_bound
#define ub upper_bound
typedef pair<int, int> P;
typedef pair<ll, ll> PL;
const ll mod = 1000000007;
const ll INF = 1000000099;
vector<ll> dx = {-1, 1, 0, 0}, dy = {0, 0, -1, 1};
//cin.tie(0);ios::sync_with_stdio(false);

int dpx[4010][16010]={};
int dpy[4010][16000]={};

signed main()
{
    string s;
    cin >> s;
    s.pb('T');

    ll xg, yg, cnt = 0, ind = 0;
    cin >> xg >> yg;
    vector<ll> x(0), y(0);

    bool tox = false;

    while (s[ind] == 'F')
    {
        xg--;
        ind++;
    }

    repi(i, ind+1, siz(s))
    {
        if (s[i] == 'F')
        {
            cnt++;
        }
        else
        {
            if (tox)
            {
                x.pb(cnt);
                cnt = 0;
                tox = !tox;
            }
            else
            {
                y.pb(cnt);
                cnt = 0;
                tox = !tox;
            }
        }
    }

    dpx[0][8000]=1;
    rep(i,siz(x)){
        rep(j,16010){
            if(dpx[i][j]==0)continue;
            dpx[i+1][j+x[i]]=dpx[i][j];
            dpx[i+1][j-x[i]]=dpx[i][j];
        }
    }

    dpy[0][8000]=1;
    rep(i,siz(y)){
        rep(j,16010){
            if(dpy[i][j]==0)continue;
            dpy[i+1][j+y[i]]=dpy[i][j];
            dpy[i+1][j-y[i]]=dpy[i][j];
        }
    }

    if(dpx[siz(x)][xg+8000] && dpy[siz(y)][yg+8000]){
        cout<<"Yes"<<endl;
    }else{
        cout<<"No"<<endl;
    }

}

Measured memory_bytes: 377344
#include<bits/stdc++.h>
using namespace std ;
typedef long long int ll ;
typedef vector< ll > vi ;
typedef pair<ll, ll > ii ;
int n , m ;
char a[9][9];
int dfs(int i , int j )
{
    if( i == n || j == m )
        return 0 ;
    if( a[i][j] =='.')
        return 0 ;
    int c1 = dfs(i+1,j) +1 ;
    c1 = max(c1 , dfs(i,j+1)+1);
    return c1 ;
}
int main()
{
    cin >> n >> m ;
    int x , y ;
    bool b = 0 ;
    int aux = 0 ;
    for(int i = 0 ; i < n ; i ++ )
        for(int j = 0 ; j < m ; j ++ ){
            cin >> a[i][j] ;
            if(a[i][j] =='#')
                aux++;
            if(a[i][j] == '#' && !b)
                x = i , y = j , b =1 ;
        }
    if(dfs(0,0) == aux)
        cout << "Possible";
    else
        cout << "Impossible";
}


Measured memory_bytes: 256
#include<stdio.h>

int main()
{
  int i,N,K,num=0;

scanf("%d",&N);
scanf("%d",&K);

for(i=1;i<=N;i++)
{
  if(i%2!=0)
  {
    num++;
  }
}

if(num>=K)
{
  printf("YES\n");
}
else
{
printf("NO\n");
}

return 0;
}

Measured memory_bytes: 128
const lines=readlines()
state=0
input()=lines[global state+=1]
int(s::String)=parse(Int32,s)
intSub(s::SubString{String})=parse(Int32,s)
floatSub(s::SubString{String})=parse(Float64,s)
intLine()=map(intSub,split(input()))
function main()
    n=int(input())
    t,a=intLine()
    m=10^9
    h=intLine()
    c=0
    for i=1:n
        v=abs(t-0.006h[i]-a)
        if m>v
            m=v
            c=i
        end
    end
    println(c)
end
main()

Measured memory_bytes: 118980
#include<stdio.h>
#include<math.h>
int main(void){
	int a,b;
	char op;
	for(;;){
		scanf("%d %c %d",&a,&op,&b);
		if(op=='+'){
			printf("%d\n",a+b);
		}else if(op=='-'){
			printf("%d\n",a-b);
		}else if(op=='*'){
			printf("%d\n",a*b);
		}else if(op=='/'){
			printf("%d\n",a/b);
		}else if(op=='?'){
			break;
		}
	}
	return 0;
}

Measured memory_bytes: 1756