akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>
#include <climits>
using namespace std;

#define REP(i,n) for(int i=0; i<n; ++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(c) (c).begin(), (c).end()

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;

const int N_MAX = 100000;
vector<pair<int, int>> graph[N_MAX]; //[from] -> (to, cost)
vector<bool> visited(N_MAX, false);
VI cost_sum(N_MAX, 0);
bool ans = true;

void dfs(int v) {
    visited[v] = true;
    for(auto& edge : graph[v]) {
        int next_v = edge.first;
        int cost = edge.second;
        if(!visited[next_v]) {
            cost_sum[next_v] = cost_sum[v] + cost;
            dfs(next_v);
        } else if(cost_sum[next_v] != cost_sum[v] + cost) {
            ans = false;
        }
    }
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, m;
    cin >> n >> m;
    REP(i, m) {
        int l, r, d;
        cin >> l >> r >> d;
        l--;
        r--;
        graph[l].push_back(make_pair(r, d));
        graph[r].push_back(make_pair(l, -d));
    }

    REP(i, n)if(!visited[i]) dfs(i);
    cout << (ans ? "Yes" : "No") << endl;

    return 0;
}


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

int main() {
  int n,a;
  long long int sum=0;
  cin >> n;
  int min=1000000;
  int max=-1000000;
  for(int i = 0; i < n; i++){
    cin >> a;    
    sum += a;
    
    if(min>a)
      min=a;
    
    if(max<a)
      max=a;
  }
  cout << min << ' ' << max << ' ' << sum <<endl;
}


Measured memory_bytes: 3116
/*BISMILLAH
THE WHITE WOLF
NO DREAM IS TOO BIG AND NO DREAMER IS TOO SMALL*/

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef vector<long long> vll;
typedef vector<int> vi;

#define io ios_base::sync_with_stdio(false)
#define pb push_back
#define eb emplace_back
#define mod   1000000000
#define PI 2*acos(0.0)
#define dbg(a) cout<<#a<<" ->->->-> "<<a<<"\n"
int dirx[] = {1, -1,0, 0}, diry[] = {0, 0, 1, -1};

ll bigmod(ll x, ll p)
{
    ll res = 1;
    while(p)
    {
        if(p&1)
            res = (res*x)%mod;
        x = (x*x)%mod;
        p >>= 1;
    }
    return res;
}



//=============================================ASIFAZAD==============================================//

const int N = 100010;
int n, p;
vll ppl(N), vis(N), good(N) , h(N);
vector<vi> adj;
bool ans = true;

void dfs(int par, int pp)
{
    vis[par] = ppl[par];
    ll totg = 0;

    for(auto x: adj[par])
    {
        if(x == pp)
            continue;

        dfs(x, par);
        vis[par] += vis[x];
        totg += good[x];

    }

    ll ck = (vis[par] + h[par]);
    if(ck < 0 || ck%2 != 0 || ck/2 > vis[par])
        ans = 0;
    if(totg > ck/2)
        ans = 0;
    if(!ans)
        return;
    good[par] = ck/2;

}


int32_t main()
{
    io;
    int x;
    cin >>x;
    cout<<(x >= 30?"Yes":"No");
    return 0;
}

Measured memory_bytes: 6280
#include <bits/stdc++.h>
using namespace std;
const int N = 10;
vector<int> g[N];
bool vis[N];
int n,m;
int dfs(int from, int tot) {
	for(int to : g[from]) if(!vis[to]) {
		vis[to] = true;
		tot = dfs(to, tot);
		vis[to] = false;
	}
	bool ok = true;
	// cout<<"from: "<<from<<endl;
	// for(int i = 1; i <= n; ++i) cout<<vis[i]<<" "; cout<<endl;
	for(int i = 1; i <= n; ++i) if(!vis[i]) ok = false; if(ok) tot++;
	// cout<<tot<<endl;
	return tot;
}
int main() {
	scanf("%d %d", &n, &m);
	for(int i = 0; i < m; ++i) {
		int u, v; scanf("%d %d", &u, &v);
		g[u].emplace_back(v); g[v].emplace_back(u);
	}
	vis[1] = true;
	int ans = dfs(1, 0);
	printf("%d\n", ans);
	return 0;
}


Measured memory_bytes: 256
b = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512]
b.reverse()
try:
    while 1:
        n = int(input())
        l = []
        for i in b:
            if i <= n:
                l.insert(0, i)
                n -= i
        print(*l)
except:
    pass

Measured memory_bytes: 7652
import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		while (true) {
			int n = sc.nextInt();
			if (n == 0)
				break;
			char[][] map = new char[n][n];
			for (int i = 0; i < n; i++) {
				map[i] = sc.next().toCharArray();
			}
			int ans = 0;
			for (int i = 0; i < n; i++) {
				for (int j = 0; j < n; j++) {
					if (map[i][j] == '1') {
						int dx[] = { 0, 1, 1, -1 };
						int dy[] = { 1, 0, 1, 1 };
						for (int k = 0; k < 4; k++) {
							int nx = j + dx[k];
							int ny = i + dy[k];
							int c = 1;
							while (nx >= 0 && ny >= 0 && nx < n && ny < n
									&& map[ny][nx] == '1') {
								nx += dx[k];
								ny += dy[k];
								c += 1;
							}
							ans = Math.max(ans, c);
						}
					}
				}
			}
			System.out.println(ans);
		}
	}
}
// loop do
// n = gets.to_i
// break if n==0
// map = Array.new(n).map!{Array.new(n)}
// n.times do |i|
// map[i]=gets.chomp.split("")
// end
// ans =0
// n.times do |y|
// n.times do |x|
// if(map[y][x]=="1")
// dx=[0,1,1,-1]
// dy=[1,0,1,1]
// 4.times do |i|
// nx = x + dx[i]
// ny = y + dy[i]
// c=1
// while(nx>=0&&ny>=0&&nx<n&&ny<n&&map[ny][nx]=="1")
// nx+=dx[i]
// ny+=dy[i]
// c+=1
// end
// ans = [ans,c].max
// end
// end
// end
// end
// puts ans
// end

Measured memory_bytes: 13000
using System;

public class Hello
{
    public static void Main()
    {
        Console.ReadLine();
        string[] line = Console.ReadLine().Trim().Split(' ');
        var a = Array.ConvertAll(line, int.Parse);
        var q = int.Parse(Console.ReadLine().Trim());
        for (int i = 0; i < q; i++)
        {
            line = Console.ReadLine().Trim().Split(' ');
            var c = int.Parse(line[0]);
            var b = int.Parse(line[1]);
            var e = int.Parse(line[2]);
            Console.WriteLine(c == 0 ? getMin(a, b, e) : getMax(a, b, e));
        }
    }
    public static int getMax(int[] a, int b, int e)
    {
        var ret = int.MinValue;
        for (int i = b; i < e; i++)
            ret = Math.Max(ret, a[i]);
        return ret;
    }
    public static int getMin(int[] a, int b, int e)
    {
        var ret = int.MaxValue;
        for (int i = b; i < e; i++)
            ret = Math.Min(ret, a[i]);
        return ret;
    }
}



Measured memory_bytes: 9336
import std.stdio;
import std.ascii;
import std.c.stdio;
import std.range;
import std.array;
import std.functional;
import std.algorithm;
import std.conv;
import std.container;
import std.math;
import std.numeric;
import std.string;
import std.c.string;
import std.regex;
import std.typecons;


enum int[string] unit = [
    "yotta" : 24,
    "zetta" : 21,
    "exa"   : 18,
    "peta"  : 15,
    "tera"  : 12,
    "giga"  : 9,
    "mega"  : 6,
    "kilo"  : 3,
    "hecto" : 2,
    "deca"  : 1,
    "deci"  : -1,
    "centi" : -2,
    "milli" : -3,
    "micro" : -6,
    "nano"  : -9,
    "pico"  : -12,
    "femto" : -15,
    "ato"   : -18,
    "zepto" : -21,
    "yocto" : -24
];

void main() {
    string[] xs;
    void input() {
        xs = readln.chomp.split(" ").array;
    }
    alias Tuple!(string, int) P;
    P norm(string s) {
        string[] ss = s.split(".");
        if (ss.length == 1) {
            if (s.length == 1) return P(s, 0);
            return P(s[0] ~ "." ~ s[1 .. $], cast(int)s.length - 1);
        }
        if (ss[0] == "0") {
            int i;
            for (i = 0; ss[1][i] == '0'; i++) {}
            string t = ss[1][i .. $];
            if (t.length == 1) return P(t,  - i - 1);
            return P(t[0] ~ "." ~ t[1 .. $], - i - 1);
        } else {
            s = ss[0];
            auto t = ss[1];
            if (s.length == 1) return P(s, 0);
            return P(s[0] ~ "." ~ s[1 .. $] ~ t, cast(int)(s.length - 1));
        }
    }
    void solve() {
        auto p = norm(xs[0]);
        if (xs.length == 3) {
            p[1] += unit[xs[1]];
        }
        if (xs.length == 2) {
            writeln(p[0], " * 10^", p[1], " ", xs[1]);
        } else {
            writeln(p[0], " * 10^", p[1], " ", xs[2]);
        }
    }
    int T; scanf("%d\n", &T);
    foreach (t; 0 .. T) {
        input; solve;
    }
}

Measured memory_bytes: 1132
#include <iostream>
#include <vector>
#include <algorithm>
#include <utility>
#include <string>
#include <queue>
#include <stack>

using namespace std;

typedef long long int ll;
typedef pair<int, int> Pii;

const ll mod = 1000000007;

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

  int n;
  cin >> n;
  string s;
  cin >> s;

  vector<int> c(n);
  for (int i = 0; i < n; i++) c[i] = s[i] - '0';

  vector<vector<int> > dp(n+2, vector<int>(1000));
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < 1000; j++) dp[i+1][j] = dp[i][j];
    for (int j = c[i] * 100; j < c[i] * 100 + 100; j++) {
      if (dp[i][j] == 0) dp[i+1][j] = 1;
    }
    for (int j = c[i] * 10; j < 1000; j += 100) {
      for (int k = j; k < j + 10; k++) {
        if (dp[i][k] == 1) dp[i+1][k] = 2;
      }
    }
    for (int j = c[i]; j < 1000; j += 10) {
      if (dp[i][j] == 2) dp[i+1][j] = 3;
    }
  }

  int ans = 0;
  for (int i = 0; i < 1000; i++) {
    if (dp[n][i] == 3) ans++;
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 118784
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <cmath>
using namespace std;
using ll = long long;

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

    int m = 2019;

    if (r - l >= m) {
        cout << 0 << endl;
    } else {
        int t = 1 << 30;
        for (int i = l; i < r; i++) {
            for (int j = i + 1; j < r; j++) {
                t = min(t, (int)((ll)i * j % m));
            }
        }
        cout << t << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define lli long long int
#define vec2 vector<vector<lli>> 
#define fio ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define FRE freopen("explicit.in","r",stdin);freopen("explicit.out","w",stdout)
#define mp make_pair
#define pll pair <lli,lli>
#define vll vector <lli>
#define pq2 priority_queue<pair<lli,lli>>
#define f first
#define s second
#define pb push_back
#define pf push_front
#define minii LLONG_MAX
#define all(x) x.begin(), x.end()
#define mem(a,b) memset(a,b,sizeof(a))
#define ld long double 
const long double pi = 3.1415926535898;
#define dec greater<lli>()
const lli mod=1000000007;
//const lli mod=100000000;
using namespace std;
lli lcm (lli a, lli b) {return ((a*b)/__gcd(a,b));}
lli modpower (lli a,lli b)
{
    if(b==0) return 1;
    lli c=modpower(a,b/2)%mod;
    if (b%2) return (((a*c)%mod)*c)%mod;
    else return (c*c)%mod;
}
lli power (lli a,lli b)
{
    if(b==0) return 1;
    lli c=power(a,b/2);
    if (b%2) return (a*c*c);
    else return c*c;
}
bool prime (lli k)
{
    if (k==1||k==0) return 0;
    bool flag=1;
    lli a=sqrt(k);
    for (int i=2;i<=a;i++)
    {
        if (k%i==0)
        {flag=0;break;}
    }
    return flag;
}
lli sieve (int n)
{
    bool qrr[n+1];
    for (int i=0;i<=n;i++)
    qrr[i]=1;qrr[0]=0;qrr[1]=0;
    for (int i=2;i<=n;i++)
    {
        if (qrr[i]==1)
        {
            for (int j=i;j<=n;j+=i)
            {qrr[j]=0;}
        }
    }
    return 0;
}
int main()
{
    fio;
    lli n;
    cin>>n;
    lli a[n+1];
    for (int i=1;i<=n;i++)
    cin>>a[i];
    lli money=1000,stock=0;
    lli x,y;
    for (int i=1;i<=n;i++)
    {
        if (stock==0)
        {
            stock=money/a[i];money=money%a[i];
            x=a[i];
            continue;
        }
        if (x<a[i])
        {
            while (x<a[i]&&a[i]>a[i-1])
            {
                i++;
                if (i==n+1)
                break;
            }
            i--;
            money+=stock*a[i];
            stock=0;
        }
        else
        {
            money+=stock*x;
            stock=money/a[i];money=money%a[i];
            x=a[i];
        }
    }
    if (stock>0)
    {
        money+=stock*x;
    }
    cout<<money;
    return 0;
}

Measured memory_bytes: 3664
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <iomanip>
#include <algorithm>
#include <string>
#include <map>
#include <queue>
using namespace std;
int main()
{
 	int a,b,c;
 	cin>>a>>b>>c;
 	if(a==5&&b==5&&c==7)
	 {
		cout<<"YES"<<endl;
     }
    else if
	(a==5&&c==5&&b==7)
	{
	cout<<"YES"<<endl;
    }
	else if
	(a==7&&b==5&&c==5)
    { 
	cout<<"YES"<<endl;
	}
	else 
	cout<<"NO"<<endl; 
 	return 0;
}

Measured memory_bytes: 888
import java.io.*;

public class Main {
  public static void main(String[] args) {
    new Main().run();
  }

  private void run() {
    try(BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
        PrintWriter out = new PrintWriter(System.out)) {

        String[] lines = in.readLine().split(" ");
        final int n = Integer.parseInt(lines[0]);
        final int m = Integer.parseInt(lines[1]);

        int lc, rc;
        int[] table = new int[n+2];
        for (int i = 0; i < m; i++) {
          lines = in.readLine().split(" ");
          lc = Integer.parseInt(lines[0]);
          rc = Integer.parseInt(lines[1]);
          table[lc]   += 1;
          table[rc+1] -= 1;
        }

        for (int i = 0; i < n; i++) {
          table[i+1] += table[i];
        }

        int cnt = 0;
        for (int i : table) {
          if(i == m) cnt++;
        }

        final int ans = cnt;
        out.println(ans);
        out.flush();
    }
    catch(IOException e) {
      System.err.println(e);
    }
  }
}

Measured memory_bytes: 48356
public class Main {


  private static void solve() {
    char[] s = ns();
    long k = nl();
    
    for (int i = 0; i < k; i ++) {
      if (s[i] != '1') {
        System.out.println(s[i]);
        return;
      }
    }
    System.out.println(1);
  }

  public static void main(String[] args) {
    new Thread(null, new Runnable() {
      @Override
      public void run() {
        long start = System.currentTimeMillis();
        String debug = args.length > 0 ? args[0] : null;
        if (debug != null) {
          try {
            is = java.nio.file.Files.newInputStream(java.nio.file.Paths.get(debug));
          } catch (Exception e) {
            throw new RuntimeException(e);
          }
        }
        reader = new java.io.BufferedReader(new java.io.InputStreamReader(is), 32768);
        solve();
        out.flush();
        tr((System.currentTimeMillis() - start) + "ms");
      }
    }, "", 64000000).start();
  }

  private static java.io.InputStream is = System.in;
  private static java.io.PrintWriter out = new java.io.PrintWriter(System.out);
  private static java.util.StringTokenizer tokenizer = null;
  private static java.io.BufferedReader reader;

  public static String next() {
    while (tokenizer == null || !tokenizer.hasMoreTokens()) {
      try {
        tokenizer = new java.util.StringTokenizer(reader.readLine());
      } catch (Exception e) {
        throw new RuntimeException(e);
      }
    }
    return tokenizer.nextToken();
  }

  private static double nd() {
    return Double.parseDouble(next());
  }

  private static long nl() {
    return Long.parseLong(next());
  }

  private static int[] na(int n) {
    int[] a = new int[n];
    for (int i = 0; i < n; i++)
      a[i] = ni();
    return a;
  }

  private static char[] ns() {
    return next().toCharArray();
  }

  private static long[] nal(int n) {
    long[] a = new long[n];
    for (int i = 0; i < n; i++)
      a[i] = nl();
    return a;
  }

  private static int[][] ntable(int n, int m) {
    int[][] table = new int[n][m];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        table[i][j] = ni();
      }
    }
    return table;
  }

  private static int[][] nlist(int n, int m) {
    int[][] table = new int[m][n];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        table[j][i] = ni();
      }
    }
    return table;
  }

  private static int ni() {
    return Integer.parseInt(next());
  }

  private static void tr(Object... o) {
    if (is != System.in)
      System.out.println(java.util.Arrays.deepToString(o));
  }
}


Measured memory_bytes: 23252
idx = lambda x: x-1
n, m = map(int, input().split())
d = [list(map(int, input().split())) for _ in range(m)]
p = list(map(int, input().split()))
ans = 0
for i in range(2**n):
    b = bin(i)[2:].rjust(n, "0")
    light = True
    for i, di in enumerate(d):
        sw = 0
        for j in di[1:]:
            sw += int(b[idx(j)])
        if sw % 2 != p[i]:
            light = False
            break
    if light:
        ans += 1
print(ans)

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

//----------------ここからだよ-------------------

int main(){
    int K,N; cin>>K>>N;
    vector<int> A(N);
    rep(i,N) cin>>A[i];
    vector<int> dist;
    rep(i,N-1){
        dist.push_back(A[i+1]-A[i]);
    }
        dist.push_back(K-A[N-1]+A[0]);
    
    int maxi=0;
    rep(i,N){
        maxi=max(maxi,dist[i]);
    }
    cout<<K-maxi<<endl;
}

Measured memory_bytes: 2168
//File Name: arc082_b.cpp
  //Created Time: 2017年10月01日 星期日 17时33分00秒
                                   
#include <bits/stdc++.h>
using namespace std;
const int MAXN = 100000 + 10;
int p[MAXN];

int solve(const int n){
	int res(0),pre(0);
	for(int i(1);i<=n + 1;++i){
		if(p[i] != i){
			res += (i - pre) / 2;
			pre = i;
		}
	}
	return res;
}
int main(){
	int n;
	scanf("%d",&n);
	for(int i(1);i<=n;++i)
		scanf("%d",p + i);
	printf("%d\n",solve(n));
	return 0;
}


Measured memory_bytes: 640
# -"*- coding: utf-8 -*-

n = int(input())
lst = list(map(int, input().split()))

rst = 0
while True:
    if (sum([i%2 for i in lst]) == 0):
        lst = [i/2 for i in lst]
        rst = rst + 1
    else:
        print(rst)
        break

Measured memory_bytes: 3060
import sys
from collections import deque
input = sys.stdin.readline

n = int(input())

#-1:undefined 0:unkind 1:honest
honest_thought = [[] for _ in range(n+1)] 
unkind_thought = [[] for _ in range(n+1)] 

for i in range(n):
    a = int(input())
    for j in range(a):
        x, y = list(map(int, input().split()))
        if y == 0:
            unkind_thought[i].append(x)
        else:
            honest_thought[i].append(x)


ans = 0

for i in range(2 ** n):
    #print(i)
    flag = True

    #最初を設定
    honest = [False] * (n+1)
    unkind = [False] * (n+1)

    q = deque()
    for j in range(n):  # このループが一番のポイント
        if ((i >> j) & 1):  # 順に右にシフトさせ最下位bitのチェックを行う
            honest[j+1] = True
            q.append(j)

    while len(q) > 0 and flag:
        v = q.popleft()
        for x in unkind_thought[v]:
            if honest[x]:
                flag = False
                break
            elif not unkind[x]:
                unkind[x] = True
        for x in honest_thought[v]:
            if unkind[x]:
                flag = False
                break
            elif not honest[x]:
                flag = False
                break

    if flag:
        ans = max(ans, honest.count(True))


print(ans)
    



Measured memory_bytes: 75264
#include<bits/stdc++.h>
using namespace std;
int a[510][510],c[250250][4],h,w,ans;
int main(){
    cin>>h>>w;
    for(int i=0;i<h;i++)
        for(int j=0;j<w;j++)
            cin>>a[i][j];
    for(int i=0;i<h;i++)
    {
        for(int j=0;j<w-1;j++)
        {
            if(a[i][j]%2==1)
            {
                c[ans][0]=i;
                c[ans][1]=j;
                c[ans][2]=i;
                c[ans][3]=j+1;
                ans++;
                a[i][j+1]++;
            }
        }
    }
    for(int i=0;i<h-1;i++)
    {
        if(a[i][w-1]%2==1)
        {
            c[ans][0]=i;
            c[ans][1]=w-1;
            c[ans][2]=i+1;
            c[ans][3]=w-1;
            ans++;
            a[i+1][w-1]++;
        }
    }
    cout<<ans<<endl;
    for(int i=ans-1;i>=0;i--)
        cout<<c[i][0]+1<<" "<<c[i][1]+1<<" "<<c[i][2]+1<<" "<<c[i][3]+1<<endl;
    return 0;
}

Measured memory_bytes: 6912
#include<bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(),(x).end()
const long long mod = 1e9+7;
const int dx[4] = {0,1,0,-1};
const int dy[4] = {1,0,-1,0};
const int ddx[4] = {1,1,-1, -1};
const int ddy[4] = {1,-1,-1,1};
//////////////////////////////////

int main(){
  long long h, w; cin >> h >> w;
  if (h == 1 || w == 1) {
    cout << 1 << endl;
    return 0;
  }
  cout << ((h*w)+1)/2 << endl;
  return 0;
}


// EOF


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

int main() {
  int a, b, k;
  cin >> a >> b >> k;

  for (int i = 0; i < k; ++i) {
    if (i % 2 == 0) {
      if (a % 2 != 0)
        --a;
      a /= 2;
      b += a;
    } else {
      if (b % 2 != 0)
        --b;
      b /= 2;
      a += b;
    }
  }

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


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

int main() {
	int a[3][3];
	for (int i = 0; i < 3; i++) {
		for (int j = 0; j < 3; j++) {
			cin >> a[i][j];
		}
	}
	int n;
	cin >> n;
	int b[n];
	for (int i = 0; i < n; i++) {
		cin >> b[i];
	}
	int l[3][3] = {0};
	for (int h = 0; h < n; h++) {
		for (int i = 0; i < 3; i++) {
			for (int j = 0; j < 3; j++) {
				if (b[h] == a[i][j]) {
					l[i][j]++;
				}
			}
		}
	}
	string ans = "No";
	for (int i = 0; i < 3; i++) {
		if (l[i][0] == 1 && l[i][1] == 1 && l[i][2] == 1) {
			ans = "Yes";
		}
		if (l[0][i] == 1 && l[1][i] == 1 && l[2][i] == 1) {
			ans = "Yes";
		}
	}
	if (l[0][0] == 1 && l[1][1] == 1 && l[2][2] == 1) {
			ans = "Yes";
	}
	if (l[0][2] == 1 && l[1][1] == 1 && l[2][0] == 1) {
			ans = "Yes";
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
using namespace std;
int main(){
        vector<int> point,runner;
        int d;
        string s;
        cin>>d;
        point.reserve(d);
        runner.reserve(d);
        for(int j = 0 ; j < d ; j++){
        fill(point.begin(),point.end(),0);
        fill(runner.begin(),runner.end(),0);
        for(int i=0; i < 3;){
                
                cin>>s;
                
                        if(s=="HIT"){
                        runner[j]++;
                                if(runner[j]>3){
                                        runner[j]--;
                                        point[j]++;
                                }
                        }
                        else if(s=="HOMERUN"){
                        point[j] += (1 + runner[j]);
                        runner[j] =0;
                        }
                        else if(s=="OUT"){
                        i++;
                        }
                
                }
        
        }
        
        for(int i = 0;i < d; i++) cout<<point[i]<<endl; 
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
#define PI acos(-1)
using namespace std;
int main()
{
    int a,b,h,m;
    cin>>a>>b>>h>>m;
    double x,y,z,v;
    x=0.5*((60*h)+m);
    y=6*m;
    z=abs(x-y);
    if ( z > 180 )
    {
        z = 360 - z;
    }
    v = z * PI / 180.0;
    double ans = a * a + b * b - 2 * a * b * cosl(v);
    cout << setprecision(14)<<sqrt(ans)<<endl;
}


Measured memory_bytes: 4160
A = int(input())
B = int(input())
C = int(input())
D = int(input())
E = int(input())

d = 10
ans = 0
if A % 10 == 0:
    ans += A
else:
    ans += (A//10+1)*10
    d = min(A - A//10*10, d)

if B % 10 == 0:
    ans += B
else:
    ans += (B//10+1)*10
    d = min(B - B//10*10, d)

if C % 10 == 0:
    ans += C
else:
    ans += (C//10+1)*10
    d = min(C - C//10*10, d)

if D % 10 == 0:
    ans += D
else:
    ans += (D//10+1)*10
    d = min(D - D//10*10, d)
    
if E % 10 == 0:
    ans += E
else:
    ans += (E//10+1)*10
    d = min(E - E//10*10, d)

if d != 10:
    ans -= 10 - d
    
print(ans)

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

int main(){

    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

    ll t = 1;
    //cin>>t;

    while(t--){

       ll n;
       cin>>n;

       string s;
       cin>>s;

       if(n%2==1)
        cout<<"No\n";
       else{
        ll mid = n/2;

        int f = 0;

        for(int i=0;i<mid;i++){
            if(s[i]!=s[i+mid]){
                f=1;
                break;
            }
        }

        if(f)
            cout<<"No\n";
        else cout<<"Yes\n";
       }



    }

}


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

int main(){
    int n,k; cin>>n>>k;
    vi h(n);
    rep(i,n)cin>>h[i];
    
    sort(h.begin(), h.end());
    
    int ans = 1001001001;
    
    for(int i=0; i<=n-k; i++){
        ans = min(ans, h[i+k-1]-h[i]);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3772
from itertools import accumulate
from math import ceil

N, X = map(int, input().split())
xs = list(map(int, input().split()))

accXs = [0] + list(accumulate(reversed(xs)))

# ロボット台数kを全て試す
ans = float('inf')
for k in range(1, N + 1):
    cost = (N + k) * X

    # i番目に拾うゴミについて、追加コストをまとめて計算する
    cost += 5 * (accXs[k] - accXs[0])

    m = ceil(N / k)
    for i in range(2, m):
        cost += (2 * i + 1) * (accXs[i * k] - accXs[(i - 1) * k])

    cost += (2 * m + 1) * (accXs[N] - accXs[(m - 1) * k])

    ans = min(ans, cost)

print(ans)


Measured memory_bytes: 25828
#include<bits/stdc++.h>
using namespace std;
#define arep(i,x,n) for(int i=int(x);i<(int)(n);i++)
#define rep(i,n) for(long long i = 0;i < n;++i)
#define pi 3.141592653589793
#define eps 0.00000001
#define INF 1e9+7  
using ll = long long; 
using P=pair<int,int>;
using lP=pair<ll,ll>;
using fP=pair<double,double>;


int main(){
   int n;
   cin>>n;
   vector<int>a(n);
   rep(i,n)cin>>a[i];
   rep(i,n)a[i]--;
   int index=0;
   vector<int>used(n);
  bool ok=true;
  int ans=0;
   while(index!=1){
        used[index]=1;
       index=a[index];
       ans++;
       if(used[index]==1){
           ok=false;
           break;
       }
   }
   if(ok)cout<<ans<<endl;
   else cout<<-1<<endl;
    return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (int) n; i++)
using ll = long long;
template <class T>
using vt = vector<T>;
using vvi = vector<vt<int>>;

int main(){
  string S;
  cin >> S;
  vt<int> tmp(3);
  for(size_t i = 0; i < S.size(); i++){
    tmp[S[i]-'a']++;
  }

  int ma = *max_element(tmp.begin(),tmp.end());
  int mi = *min_element(tmp.begin(),tmp.end());

  cout << (ma-mi <= 1 ? "YES" : "NO") << endl;

  return 0;
}


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

int main(){
	int n;
	cin >> n;
	string s;
	cin >> s;
	int sum[26];
	REP(i,26) sum[i] = 1;
	REP(i,n) sum[s[i] - 'a']++;
	ll res = 1;
	REP(i,26) res = (res * sum[i]) % 1000000007;
	cout << (res - 1) % 1000000007 << endl;
}

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

int main(){
    int n,c=0,ans=0;
    cin>>n;
    for(int i=1;i<=n;i=i+2){
        for(int j=1;j<=i;j=j+2){
            if(i%j==0){
                c++;
            }
        }  
        if(c==8){
            ans++;
        }
        c=0;
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int sub(int x,int y) {
  if ( x-y>0 ) {
    return x-y;
  }
  else {
    return y-x;
  }
}

int main() {
  int n, x, y;
  cin  >> n >> x >> y;
  vector<int> ans(n-1,0);
  
  
  for ( int i = 0 ; i < n ; i++ ) {
    for ( int j = i ; j < n ; j++ ) {
      
      if ( i == j ) {
        continue;
      }
      else {
        int a = j-i; 
        int b = sub(i,x-1);
        int c = sub(j,y-1);
        int d = b+1+c;
        int e = min(a,d);
        
        ans.at(e-1)+=1;
      }
    }
  }
  for ( int i = 0 ; i < n-1 ; i++ ) {
    cout << ans.at(i) << endl;
  }
  
}

Measured memory_bytes: 256
n,m = map(int, input().split())
ps = [list(input().split()) for _ in range(m)]

ac = [0] * (n+1)
pena = [0] * (n+1)
for p,s in ps:
    p = int(p)
    if s == "AC":
        ac[p] = 1
        continue
    if ac[p] == 0:
        pena[p] += 1
ans = [0,0]
for x,y in zip(ac[1:],pena[1:]):
    if x == 1:
        ans[0] += 1
        ans[1] += y
print(" ".join(map(str, ans)))

Measured memory_bytes: 33276
program prob5
    implicit none
    character(len=100005)::S
    integer::l(500000)
    integer::m, i, j, tmp, ans
    read(*,*) S
    m = len_trim(S)
    tmp = 200000
    l = 0
    j = 1
    do i = 1, m
        if(S(i:i) .eq. "x") then
            tmp = tmp + 1
        else
            l(j) = tmp
            l(j+1) = ichar(S(i:i)) - ichar('a')
            tmp = 200000
            j = j+2
        end if
    end do
    l(j) = tmp
    !write(*,*) j

    ans = 0
    do i = 1, j/2
        if(mod(i,2) == 1) then
            ans = ans + abs(l(i) - l(j-i+1))
        else
            if(l(i) /= l(j-i+1)) then
                write(*,*) -1
                stop
            end if
        end if
    end do

    write(*,*) ans
    stop
end program

Measured memory_bytes: 5088
#include<cstdio>
#include<algorithm>
#include<cctype>
#include<cstring>
#include<iostream>
#include<cmath>
#include<vector>
#define LL long long
#define N (100005)
using namespace std;
int n,m,t,cnt;
LL tot,ans[N];
int x[N],y[N],fa[N],root[N],lson[N*50],rson[N*50],size[N*50];
template <typename T> void read(T&t) {
	t=0;
	bool fl=true;
	char p=getchar();
	while (!isdigit(p)) {
		if (p=='-') fl=false;
		p=getchar();
	}
	do {
		(t*=10)+=p-48;p=getchar();
	}while (isdigit(p));
	if (!fl) t=-t;
}
int ask(int x){
	if (fa[x]==x) return x;
	fa[x]=ask(fa[x]);
	return fa[x];
}
inline void build(int &u,int l,int r,int op){
	u=++cnt;
	size[u]=1;
	if (l==r) return;
	int mid=l+r>>1;
	if (op<=mid) build(lson[u],l,mid,op);
	else build(rson[u],mid+1,r,op);
}
inline int merge(int x,int y){
	if (!x||!y) return x|y;
	tot+=1ll*size[lson[x]]*size[rson[y]]+1ll*size[rson[x]]*size[lson[y]];
	lson[x]=merge(lson[x],lson[y]);
	rson[x]=merge(rson[x],rson[y]);
	size[x]=size[lson[x]]+size[rson[x]];
	return x;
}
int main(){
	read(n),read(m);
	for (int i=1;i<=m;i++){
		read(x[i]),read(y[i]);
	}
	for (int i=1;i<=n;i++) fa[i]=i,build(root[i],1,n,i);
	ans[m]=1ll*n*(n-1)/2;
	for (int i=m;i>=1;i--){
		ans[i-1]=ans[i];
		int fx=ask(x[i]),fy=ask(y[i]);
		if (fx==fy) continue;
		tot=0;
		root[fx]=merge(root[fx],root[fy]);
		fa[fy]=fx;
		ans[i-1]-=tot;
	}
	for (int i=1;i<=m;i++) printf("%lld\n",ans[i]);
	return 0;
}


Measured memory_bytes: 29440
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define mp make_pair
#define fi first
#define se second
const ll mod = 1e9 + 7;
ll powmod(ll a, ll b) { ll res=1; a%=mod; assert(b>=0); for(;b;b>>=1) { if(b&1) res=res*a%mod; a=a*a%mod; } return res; }
ll gcd(ll a, ll b) { return b ? gcd(b,a%b) : a; }

int main() {
	int t;
	// cin >> t;
    t = 1;

	while(t--) {
		vector<int> arr(6);
        int res;
		for(int i=1; i<6; i++) {
            cin >> arr[i];
            if(arr[i] == 0)
                res = i;
        }
        
        cout << res << endl;
	}

	return 0;
}

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

//.define
// #define FILE_IN_OUT
#define RET(_x)    return cout << (_x) << '\n', 0;
#define all(_obj)  (_obj).begin(), (_obj).end()
#define loop(_n)   for (int i = 0; i < (_n); ++i)
#define sz(_obj)   static_cast<int>((_obj).size())
#ifdef SHJ_LOCAL
#define debug(_x)  std::cerr << (#_x) << " = " << (_x) << '\n' << std::flush;
#else
#define debug(_x)  {}
#endif
#define endl "\n"
template<typename P, typename Q>
P CeilDiv(P _dividend, Q _divider) {
    return static_cast<P>((_dividend - 1LL + _divider) / _divider);
}
template<typename Tp>
inline void outarr(Tp _begin, Tp _end, const char* _delim = " ") {
    for (Tp current = _begin; current != _end; ++current) {
        std::cout << *current << _delim;
    }
    std::cout << '\n';
}

//.constant
using ll  = long long;
using pii = std::pair<int, int>;
constexpr int INF = 0x3f3f3f3f;
constexpr int MOD = static_cast<const int>(1e9 + 7);

//.data
vector<int> gr[200000];
bool used[200000];

int g_cnt = 0;
void Dfs(int from) {
    used[from] = true;
    ++g_cnt;
    for (int to : gr[from]) {
        if (!used[to]) {
            Dfs(to);
        }
    }
}

//.code
int main() {
#ifdef FILE_IN_OUT
    std::ifstream cin ("input.txt",  std::ios::in);
    std::ofstream cout("output.txt", std::ios::out);
#else
    std::ios_base::sync_with_stdio(false);
    std::cin.tie(nullptr);
#endif

    int n, m;
    cin >> n >> m;
    loop(m) {
        int a, b;
        cin >> a >> b;
        --a; --b;
        gr[a].push_back(b);
        gr[b].push_back(a);
    }
    int ans = 0;
    loop(n) {
        if (!used[i]) {
            g_cnt = 0;
            Dfs(i);
            ans = max(ans, g_cnt);
        }
    }
    cout << ans << endl;

#ifdef FILE_IN_OUT
    cin.close();
    cout.close();
#endif
    return 0;
}

Measured memory_bytes: 20908
n = int(input())
s = [int(input()) for i in range(n)]

ans = sum(s)
s.sort()

if ans % 10 != 0:
    print(ans)
else:
    for i in range(n):
        if s[i] % 10 != 0:
            print(ans - s[i])
            break
    else:
        print(0)

Measured memory_bytes: 3060
inputLine=input()
N=int(inputLine.split(" ")[0])
K=int(inputLine.split(" ")[1])

A = []
for i in range(K):
    inputLine=input()
    d = int(inputLine)
    inputLine=input()
    A.append(inputLine.split(" "))

allSunukeStates=[]
for i in range(N):
    allSunukeStates.append(True)

for i in range(len(A)):
    for j in range(len(A[i])):
        allSunukeStates[int(A[i][j]) - 1] = False

result = 0
for i in range(N):
    if allSunukeStates[i] == True:
        result += 1

print(result)











Measured memory_bytes: 9656
import math

r = 105000
sqrt = int(math.sqrt(r))
p = [1]*r
p[0] = 0
for i in range(1,sqrt):
    if p[i]:
        p[2*i+1::i+1] = [0 for x in range(2*i+1,r,i+1)]

s = [0 for i in range(11000)]
s[0] = 2
k = 1
for i in range(2,r):
    if p[i]:
        s[k] = i+1+s[k-1]
        k += 1
        
while True:
    n = int(raw_input())
    if not n:
        break
    print s[n-1]

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

string rotate(string s){
  int n = s.size();
  char buf = s.at(n-1);
  for (int i=n-1; i>=1; i--){
    s.at(i) = s.at(i-1);
  }
  s.at(0) = buf;
  return s;
}

int main() {
  string s,t; cin >>s >>t;
  string ans = "No";
  for (int i=0; i<s.size(); i++){
    s = rotate(s);
    if (s==t) ans = "Yes";
  }
  cout <<ans;
  cout <<endl;
}


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

using namespace std;

int main(){
	string s;
	cin >> s;
	int ans = 1000;
	for (int i = 0; i < s.length() -2; i++){
		int a = 100 * (s[i] - '0') + 10 * (s[i+1] - '0') + (s[i+2] - '0');
		if (a < 753){
			if (753 - a < ans){
				ans = 753 - a;
			}
		}
		else {
			if (a - 753 < ans){
				ans = a - 753;
			}
		}
	}
	cout << ans << endl;
	return 0;
}


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

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

int main(){
  int N;
  cin >> N;
  string S[N],list[N];
  int P[N];
  vector<string> tmp;

  for(int i=0;i<N;i++){
    cin >> S[i] >> P[i];
    if(P[i]==100){
      list[i] = S[i] + " 000 " + to_string(i+1);
    }else if(P[i]==0){
      list[i] = S[i] + " 100 " + to_string(i+1);
    }else if(90 < P[i] && P[i]< 100){
      list[i] = S[i] + " 00" + to_string(100-P[i]) + " " + to_string(i+1);
    }else{
      list[i] = S[i] + " 0" + to_string(100-P[i]) + " " + to_string(i+1);
    }

  }

  sort(list,list+N);

  for(int j=0;j<N;j++){
    tmp = StringSplit(list[j],' ');
    cout << tmp[2] << endl;
  }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
 string a,b,c;
 char d,e,f;
 cin>>a>>b>>c;
 d=a.at(0)-0x20;
 e=b.at(0)-0x20;
 f=c.at(0)-0x20;
cout<<d<<e<<f<<endl;
}

		

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

int main(){
  int H, W;

  while(true){
    cin >> H >> W;

    if(H==0 && W==0){
      return 0;
    } else{
      for(int i=0; i<H; i++){
        for(int j=0; j<W; j++){
          if(i==0 || i==H-1 || j==0 || j==W-1){
            cout << "#";
          }else{
            cout << ".";
          }
        }
        cout << endl;
      }
    }
    cout << endl;
  }

}

Measured memory_bytes: 3072
import java.io.*;
import java.math.*;
import java.security.*;
import java.text.*;
import java.util.*;
import java.util.concurrent.*;
import java.util.regex.*;

 class Main 
 {

    public static void main(String[] args) 
    {
        Scanner sc=new Scanner(System.in);
        
        int a[]=new int[3];
        for(int i=0;i<3;i++)
        {
           a[i]=sc.nextInt();
        }
        
        Arrays.sort(a);
        int sum=0;
        for(int i=1;i<=2;i++)
        {
            int diff=a[i]-a[i-1];
            sum=sum+diff;
        }
        System.out.println(sum);
    }
}

Measured memory_bytes: 23124
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using static System.Math;
using System.Text;
using System.Threading;
using System.Globalization;
using System.Runtime.CompilerServices;
using Library;

namespace Program
{
    public static class ABC069B
    {
        static public int numberOfRandomCases = 0;
        static public void MakeTestCase(List<string> _input, List<string> _output, ref Func<string[], bool> _outputChecker)
        {
        }
        static public void Solve()
        {
            var s = NS;
            Console.WriteLine(s.First() + (s.Length - 2).ToString() + s.Last());
        }
        static class Console_
        {
            static Queue<string> param = new Queue<string>();
            public static string NextString() { if (param.Count == 0) foreach (var item in Console.ReadLine().Split(' ')) param.Enqueue(item); return param.Dequeue(); }
        }
        class Printer : StreamWriter
        {
            public override IFormatProvider FormatProvider { get { return CultureInfo.InvariantCulture; } }
            public Printer(Stream stream) : base(stream, new UTF8Encoding(false, true)) { base.AutoFlush = false; }
            public Printer(Stream stream, Encoding encoding) : base(stream, encoding) { base.AutoFlush = false; }
        }
        static public void Main(string[] args) { if (args.Length == 0) { Console.SetOut(new Printer(Console.OpenStandardOutput())); } var t = new Thread(Solve, 134217728); t.Start(); t.Join(); Console.Out.Flush(); }
        static long NN => long.Parse(Console_.NextString());
        static double ND => double.Parse(Console_.NextString());
        static string NS => Console_.NextString();
        static long[] NNList(long N) => Repeat(0, N).Select(_ => NN).ToArray();
        static double[] NDList(long N) => Repeat(0, N).Select(_ => ND).ToArray();
        static string[] NSList(long N) => Repeat(0, N).Select(_ => NS).ToArray();
        static IEnumerable<T> OrderByRand<T>(this IEnumerable<T> x) => x.OrderBy(_ => xorshift);
        static long Count<T>(this IEnumerable<T> x, Func<T, bool> pred) => Enumerable.Count(x, pred);
        static IEnumerable<T> Repeat<T>(T v, long n) => Enumerable.Repeat<T>(v, (int)n);
        static IEnumerable<int> Range(long s, long c) => Enumerable.Range((int)s, (int)c);
        static uint xorshift { get { _xsi.MoveNext(); return _xsi.Current; } }
        static IEnumerator<uint> _xsi = _xsc();
        static IEnumerator<uint> _xsc() { uint x = 123456789, y = 362436069, z = 521288629, w = (uint)(DateTime.Now.Ticks & 0xffffffff); while (true) { var t = x ^ (x << 11); x = y; y = z; z = w; w = (w ^ (w >> 19)) ^ (t ^ (t >> 8)); yield return w; } }
    }
}
namespace Library {
}


Measured memory_bytes: 14816
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        
        int n = Integer.parseInt(sc.next());
        
        String x = sc.next();
        String y = sc.next();
        
        StringBuilder bld = new StringBuilder();
        for(int i = 0;i<n;i++){
            bld.append(x.charAt(i));
            bld.append(y.charAt(i));
        }
        
        System.out.println(bld.toString());
    }
}

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

#define FOR(a,b,c) for (int a=(b);a<(c);++a)
#define REP(i,n) FOR(i,0,n)
#define ll long long
#define pii pair<int,int>
#define x first
#define y second
#define pb push_back
#define lf double

using namespace std;

const int MAX = (int)1e6 + 5;

int p[MAX];
int n,k;

bool ok(int mi){
	int sum=0;
	REP(i,n){
		sum+=(p[i]-1)/mi;
	}
	return sum<=k;
}

int main(){
	scanf ("%d%d",&n,&k);
	REP(i,n) scanf ("%d",p+i);
	int lo=1,hi=(int)0;
	REP(i,n) hi=max(hi,p[i]);
	while(lo<hi){
		int mi=(lo+hi)/2;
		if (ok(mi)){
			hi=mi;
		}
		else lo=mi+1;
	}
	printf ("%d\n",lo);
	
	
	
	
	return 0;
}


Measured memory_bytes: 4600
import java.util.*
import java.util.ArrayDeque

fun main(args: Array<String>) {
    val sc = java.util.Scanner(System.`in`)
    var h = sc.nextInt()
    val n = sc.nextInt()
    val a = sc.asSequence().take(n).map(String::toInt).sum()

    print(if (h <= a) "Yes" else "No")
}


Measured memory_bytes: 43568
#include <algorithm>
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define ll long long
#define INF 100000000000000000

int main() {
    string s;
    cin >> s;
    vector<ll> A(26);
    rep(i, s.size()) { A[s[i] - 'a']++; }

    rep(i, A.size()) { A[i] -= 1; }

    ll sum = 0;

    rep(i, 26) {
        if (A[i] == -1)
            continue;
        else if (A[i] == 1)
            sum += 1;
        else
            sum += ((A[i] + 1) * A[i] / 2);
    }

    ll whole = s.size() * (s.size() - 1) / 2;
    cout << whole - sum + 1 << endl;
}

Measured memory_bytes: 640
#include <iostream>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <map>
#include <vector>
#include <set>
#include <algorithm>
#include <sstream>
#include <queue>
#include <cctype>
#include <cmath>
#include <fstream>

using namespace std;

typedef long long ll;
#define REP(i,k) for(int (i)=0;(i)<(k);(i)++)
#define INF ~(1<<31)
#define CLR(a) memset((a),0,sizeof((a)))
#define EPS 1e-9
#define DBG 1
#define D(s,v) if(DBG) cout<<(s)<<": "<<(v)<<endl;
#define DVEC(s,v) if(DBG) {cout<<(s)<<": "; for(int i=0;i<(v).size();i++) cout<<(v)[i]<<" "; cout<<endl;}
#define DARR(s,v,n) if(DBG) {cout<<(s)<<": "; for(int i=0;i<n;i++) cout<<(v)[i]<<" "; cout<<endl;}

int main(){
    ios_base::sync_with_stdio(0);

    int N;
    while(cin>>N){
        vector<int> candies[2];

        for(int i=0;i<2;i++){
            for(int j=0;j<N;j++){
                int x; cin>>x;
                candies[i].push_back(x);
            }
        }

        int res = 0;
        for(int right=0;right<N;right++){
            int cur = 0;
            int row = 0;
            for(int k=0;k<N;k++){
                if(k==right){                    
                    cur += candies[row][k];
                    cur += candies[row+1][k];
                    row = 1;
                }
                else{
                    cur += candies[row][k];
                }
            }
            res = max(res, cur);
        }

        cout<<res<<endl;
    }
}

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

const int BITS = 30;

int N;
vector<long long> A, B;

void stable_sort_by_bit(vector<long long> &numbers, int bit) {
    int ones = 0;

    for (auto number : numbers)
        ones += number >> bit & 1;

    int positions[2] = {0, N - ones};
    vector<long long> new_numbers(N);

    for (auto number : numbers)
        new_numbers[positions[number >> bit & 1]++] = number;

    swap(numbers, new_numbers);
}

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

    cin >> N;
    A.resize(N);
    B.resize(N);

    for (auto &a : A)
        cin >> a;

    for (auto &b : B)
        cin >> b;

    long long answer = 0;

    for (int bit = 0; bit < BITS; bit++) {
        long long full = (1LL << bit) - 1;
        long long ones = 0;

        for (int i = 0, j = N; i < N; i++) {
            while (j > 0 && (A[i] & full) + (B[j - 1] & full) > full)
                j--;

            ones += N - j;
        }

        long long a_ones = 0, b_ones = 0;

        for (int i = 0; i < N; i++) {
            a_ones += A[i] >> bit & 1;
            b_ones += B[i] >> bit & 1;
        }

        ones += N * (a_ones + b_ones);

        if (ones % 2 != 0)
            answer |= 1LL << bit;

        stable_sort_by_bit(A, bit);
        stable_sort_by_bit(B, bit);
    }

    cout << answer << '\n';
}


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

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

	for (int i = 0; i <= 1250; i++) {
		if ((int)(i * 0.08) == a)
			for (int j = 0; j <= 1000; j++) {
				if ((int)(j*0.1) == b)
					if (i == j) {
						cout << i << endl;
						goto exit_loop;
					}
			}
	}
	cout << -1 << endl;
exit_loop:
	return 0;
}

Measured memory_bytes: 256
//#include <bits/stdc++.h>
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <vector>
#include <string>
#include <climits>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#include <stdio.h>
//#define int long long
using namespace std;
#define loop(n) for(int i=0;i<n;i++)
#define endl '\n'
#define OnlineJudgec
#define F first
#define S second
#define  precision(n)  cout << fixed << setprecision(n)
#define clr(v,d ) memset(v, d, sizeof(v))
typedef long long ll;
typedef vector<int> vi;
void init()
{
    cin.tie(0);
    cin.sync_with_stdio(0);
    cout.tie(0);
    #ifdef OnlineJudge
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
    #endif
}
ll S(ll x){ll s = 0;while(x){s += x % 10;x /= 10;}return s;} /// sum of digits.
ll powe(ll a , ll n){if(n == 1)return a;return a * powe(a ,n-1);}
ll com(int n,int m){ll z = 1;for(int i = 0; i < m;i++){z = z * ( n - i) / (i + 1) ;}return z;}
int dx[] = {1,-1,0,0};
int dy[] = {0,0,1,-1};
int dr[] = {0,0,0,1,1,1,-1,-1,-1};
int dc[] ={-1,0,1,-1,0,1,-1,0,1};
/// <<------------------------------------------------------------------------------>>
const int mx = 100009;
int n;
int arr[mx];
int dp[mx];
int solve(int idx)
{
    if(idx == n-1)return 0;
    int &rst = dp[idx];
    if(~rst) return rst;
    int choice = 1e9 , choice2 = 1e9;
    if(idx + 1 < n)
        choice = solve(idx+1) + abs(arr[idx] - arr[idx + 1]);
    if(idx + 2 < n)
       choice2 = solve(idx+2) + abs(arr[idx] - arr[idx + 2]);
    return rst = min(choice , choice2);
}
/// <<------------------------------------------------------------------------------>>
int main()
{
    init();
    cin >> n;
    loop(n) cin >> arr[i];
    clr(dp,-1);
    cout<<solve(0);
}


Measured memory_bytes: 5760