akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

#define NREP() for(ll i = 0; i < n; i++)
#define MREP() for(ll j = 0; j < m; j++)
#define REP(i, x, y) for(ll i = x; i < y; i++)
#define ALL(x) (x).begin(), (x).end()
#define MSG(x) cout << x << endl;
#define MSGF(x, n) MSG(fixed << setprecision(n) << x)
#define END(x) cout << x << endl; exit(0);
#define IPT(v, n) REP(i, 0, n){ cin >> v[i]; }
#define YN(x) x ? cout << "YES" << endl : cout << "NO" << endl;
#define Yn(x) x ? cout << "Yes" << endl : cout << "No" << endl;
#define yn(x) x ? cout << "yes" << endl : cout << "no" << endl;

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<bool> vb;
typedef vector<vector<bool>> vvb;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef vector<ull> vul;
typedef vector<vector<ull>> vvul;
typedef vector<char> vc;
typedef vector<vector<char>> vvc;
typedef vector<string> vs;
typedef vector<vector<string>> vvs;

const static ll MOD = 1e9 + 7;
const static ll INF = 1LL << 30;

ll a, b, c, d, k, l, m, n, h, w, q, x, y;
string s, t;

ll ans = 0;
ll sum = 0;
ll cnt = 0;
ll cur = 0;
ll tmp = 0;
ll mini = INF;
ll maxi = 0;

double ave = 0.0;

ll mod_pow(ll base, ll power) {
    if (power == 0) return 1;
    if (power == 1) return base % MOD;
    if (power % 2 == 0) return ((mod_pow(base % MOD, (power / 2)) % MOD) * (mod_pow(base, (power / 2)) % MOD)) % MOD;
    return (base % MOD * (mod_pow(base % MOD, power - 1) % MOD)) % MOD;
}

ll mod_fact(ll number) {
    ll ret = 1;
    ll count = 1;
    while (count <= number) {
        ret *= (count % MOD);
        ret %= MOD;
        count++;
    }
    return ret % MOD;
}

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

int main() {
    cin >> s;
    t = "CODEFESTIVAL2016";
    REP(i, 0, s.size()) {
        if (s.at(i) != t.at(i)) ans++;
    }
    MSG(ans)
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main(){
    ll n,t,a,ans;
    scanf("%lld",&n);
    scanf("%lld %lld",&t,&a);
    double h[n+1],x,mn;
    for(int i=0;i<n;i++){
        scanf("%lf",&h[i]);
        h[i]=t-h[i]*0.006;
    }
    mn=abs(1.0*a-h[1]);
    ans=1;
    for(int i=1;i<n;i++){
        if(mn>abs(1.0*a-h[i])){
            mn=abs(1.0*a-h[i]);
            ans=i+1;
        }
    }
    printf("%lld",ans);
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <climits>
#include <set>
#include <algorithm>
#include <unordered_map>
#include <queue>
#include <iomanip>
#include <map>
#include <utility>
#include <numeric>
#include <chrono>
#include <ctime>
#include <bitset>
#include <iterator>
#include <cmath>
#include <stack>

#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define debug(x) cerr << #x << ": " << x << ", "
#define debugln(x) cerr << #x << ": " << x << '\n'

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 namespace std;
using ll = long long;
using P = pair<int, int>;

constexpr ll mod = 1e9 + 7;
const double PI = acos(-1.0);

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

  ll n, k; cin >> n >> k;
  vector<int> bit(50);
  rep(i, n) {
    ll a; cin >> a;
    for(int i=0; i<50; i++) {
      ll s = 1LL<<i;
      if (a & s) {
        bit[i]++;
      }
    }
  }

  ll ans = 0;
  ll sum = 0;
  for(int i=49; i>=0; i--) {
    ll s = 1LL<<i;
    if (bit[i] >= n-bit[i]) {
      ans += bit[i]*s;
    } else {
      if (sum + s <= k) {
        ans += (n-bit[i])*s;
        sum += s;
      } else {
        ans += bit[i]*s;
      }
    }
  }
  cout << ans << endl;
}


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

#define EPS (1e-10)
#define rep(i, a, b) for (int i = a; i < (int)(b); ++i)
#define rrep(i, a, b) for (int i = b - 1; i >= (int)(a); --i)
#define all(a) a.begin(), a.end()

using namespace std;
using ll = long long;
using vi = vector<int>;
using vb = vector<bool>;
using vll = vector<ll>;
using vd = vector<double>;
using vvi = vector<vi>;
using vvb = vector<vb>;

constexpr int MOD = 1000000007;

inline bool check(int x) { return x >= 1 && x <= 9; }

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

    int a, b;
    cin >> a >> b;
    cout << (check(a) && check(b) ? a * b : -1) << endl;

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL)
#define  endl "\n"
#define ll long long int
#define yes cout<<"Yes\n"
#define no cout<<"No\n"

using namespace std;


int main(){
	fastio;
	//write some code here
	int t;cin>>t;
	(t>=30)?yes:no;
	return 0;
}




Measured memory_bytes: 3648
#include<stdio.h>
#include<string.h>

#define M 1701761
#define L 14

char H[M][L];

int getChar(char ch){
	if ( ch == 'A') return 1;
	else if ( ch == 'C') return 2;
	else if ( ch == 'G') return 3;
	else if ( ch == 'T') return 4;
	return 0;
}

long long getKey(char str[]){
	long long sum = 0, p = 1, i;
	for ( i = 0; i < strlen(str); i++ ){
		sum += p*(getChar(str[i]));
		p *= 5;
	}
	return sum;
}

int h1(int key){ return key % M; }
int h2(int key){ return 1 + (key % (M-1)); }

int find(char str[]){
	long long key, i, h;
	key = getKey(str);
	for (i = 0;; i++) {
		h = (h1(key) + i * h2(key)) % M;
		if (strcmp(H[h],str) == 0) return 1;
		else if (strlen(H[h]) == 0) return 0;
	}
	return 0;
}

int insert(char str[]){
	long long key, i, h;
	key = getKey(str);
	for (i = 0;;i++) {
		h = (h1(key) + i * h2(key)) % M;
		if (strcmp(H[h],str) == 0) return 1;
		else if (strlen(H[h]) == 0) {
			strcpy(H[h],str);
			return 0;
		}
	}
	return 0;
}

int main(){
	int i, n, h;
	char str[L], com[9];
	for ( i = 0; i < M; i++ ) H[i][0] = '\0';

	scanf("%d", &n);

	for ( i = 0; i < n; i++ ){
		scanf("%s %s", com, str);

		if ( com[0] == 'i' ){
			insert(str);
		} else {
			if (find(str)){
				printf("yes\n");
			} else {
				printf("no\n");
			}
		}
	}

	return 0;
}

Measured memory_bytes: 23872
def cmb(n,r,mod):
  if r<0 or r>n:
    return 0
  r=min(r,n-r)
  return g1[n]*g2[r]*g2[n-r]%mod

import sys
x,y=map(int,input().split())
if (x+y)%3!=0:
  print(0)
  sys.exit()
z=(x+y)//3
mod=10**9+7

g1=[1,1]
g2=[1,1]
inverse=[0,1]
 
for i in range(2,z+1):
  g1.append((g1[-1]*i)%mod)
  inverse.append((-inverse[mod%i]*(mod//i))%mod)
  g2.append((g2[-1]*inverse[-1])%mod)

print(cmb(z,y-z,mod))

Measured memory_bytes: 118764
public class Main {

  private static void solve() {
    int n = ni();

    for (int x = 1; x <= 1000000; x++) {
      int m = (int) (x * 1.08);

      if (m == n) {
        System.out.println(x);
        return;
      }
    }
    System.out.println(":(");

  }

  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: 21204
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace StringFormation
{
    class Program
    {
        static void Main(string[] args)
        {
            bool hantenFlg = false;
            var first = Console.ReadLine().Split(' ');
            LinkedList<string> kotae = new LinkedList<string>();
            foreach(var a in first[0])
            {
                kotae.AddLast(a.ToString());
            }
            var nagasa = int.Parse(Console.ReadLine().Split(' ')[0]);

            for(int i = 0; i < nagasa; i ++)
            {
                var yarukoto = Console.ReadLine().Split(' ');
                if (yarukoto[0] == "1")
                {
                    hantenFlg = Hanten(hantenFlg);
                }
                else
                {
                    kotae = Tuika(kotae, int.Parse(yarukoto[1]), yarukoto[2], hantenFlg);
                }
            }


            StringBuilder sb = new StringBuilder();

            if (hantenFlg)
            {
                foreach (var a in kotae.Reverse())
                {
                    sb.Append(a);
                }
            }
            else
            {
                foreach (var a in kotae)
                {
                    sb.Append(a);
                }
            }

            Console.WriteLine(sb);
        }

        static bool Hanten(bool hantenFlg)
        {
            return !hantenFlg;
        }

        static LinkedList<string> Tuika(LinkedList<string> taisho, int sentoFlg, string moji, bool hantenFlg)
        {
            if(hantenFlg)
            {
                // 反転の状態
                if (sentoFlg == 1)
                {
                    // 末尾に追加
                    taisho.AddLast(moji);
                }
                else
                {
                    // 先頭に追加
                    taisho.AddFirst(moji);
                }
            }
            else
            {
                // 通常の状態
                if (sentoFlg == 1)
                {
                    // 先頭に追加
                    taisho.AddFirst(moji);
                }
                else
                {
                    // 末尾に追加
                    taisho.AddLast(moji);
                }
            }

            return taisho;
        }
    }
}


Measured memory_bytes: 41376
#include <iostream>
#include <vector>
#include <cmath>

using namespace std;

int main() {
	int n, m; cin >> n >> m;
	vector<vector<bool> > s(m, vector<bool>(n + 1, false));
	vector<int> p(m);
	for (int i = 0; i < m; ++i) {
		int k; cin >> k;
		for (int j = 0; j < k; ++j) {
			int t; cin >> t;
			s[i][t] = true;
		}
	}
	for (int i = 0; i < m; ++i) cin >> p[i];

	int ans = 0;
	vector<int> swio (n);
	for (int i = 0; i < (int)pow(2, n); ++i) {
		int tmp = i;
		for (int j = 0; j < n; ++j) {
			swio[j] = tmp % 2;
			tmp /= 2;
		}
		bool flag = true;
		for (int j = 0; j < m; ++j) {
			int cnt = 0;
			for (int k = 1; k <= n; ++k) {
				if (swio[k - 1] && s[j][k]) cnt++;
			}
			if (cnt % 2 != p[j]) {
				flag = false;
				break;
			}
		}
		if (flag) ans++;
	}
	cout << ans << endl;


	return 0;
}

Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define ll long long
#define REP(i, n) for (ll (i) = 0; (i) < (n); (i)++)
#define REPI(i, a, b) for (ll (i) = (a); (i) < (b); (i)++)
#define int long long
using namespace std;
using P = pair<int, int>;
using VI = vector<int>;
using VVI = vector<VI>;
using VVVI = vector<VVI>;

int H, W;
VVI a;
vector<string> ans;
void add(int y1, int x1, int y0, int x0) {
  ans.push_back(to_string(y1+1) + ' ' + to_string(x1+1) + ' ' + to_string(y0+1) + ' ' + to_string(x0+1));
}
void solve() {
  REP (i, H) {
    REP (j, W) {
      if (!a[i][j] || (i == H-1 && j == W-1)) { continue; }
      if (j == W-1) {
        add(i, j, i+1, j);
        a[i+1][j] ^= 1;
      } else {
        add(i, j, i, j+1);
        a[i][j+1] ^= 1;
      }
    }
  }
}
signed main() {
  cin >> H >> W;
  a = VVI(H, VI(W, 0));
  REP (i, H) {
    REP (j, W) {
      cin >> a[i][j];
      a[i][j] %= 2;
    }
  }
  solve();
  cout << ans.size() << endl;
  for (string s: ans) {
    cout << s << endl;
  }
}

Measured memory_bytes: 12916
/*------------------------------------
........Bismillahir Rahmanir Rahim....
..........created by Abdul Aziz.......
------------------------------------*/
#include <iostream>
#include <algorithm>
#include <stdio.h>
#include <cmath>
#include <vector>
#include <set>
#include <list>
#include <stack>
#include <map>
#include <cstring>
#include <unordered_map>
#include <queue>
#include <functional>
#define   mod  998244353
#define   int  long long 
#define   ld   long double
#define   pb   push_back
#define   vi   vector<int> 
#define   co(x)  cout << x << '\n' 
#define   dbg(x)  cerr << #x << " = " << x << '\n'
#define   sz(x)  (int)x.size()
#define   all(a) a.begin(),a.end()
#define   ff   first
#define   ss   second
#define   pii  pair<int,int> 
#define   lcm(a,b) (a*b)/__gcd(a,b) 
using namespace std;

vi  g[10005]; 
bool vis[10005];

inline void solve(){
	int n,ans = 0; cin>>n; 
    vi c(n),res(n+1); 
    for (int i=0;i<n-1;i++){ 
    	int  u, v ; 
    	cin >> u >> v ; 
    	g[u].pb(v) ; 
    	g[v].pb(u) ; 
    } 
    for (int i=0;i<n;i++) cin >> c[i] ; 
    sort(all(c)) ; 
	int  i = n-2 ; 
    function < void(int) > dfs = [&] (int u){
    	if (vis[u]) return ; 
    	vis[u] = true;
    	for (auto &it: g[u]){
    		if (!vis[it]){
    			ans += min(res[u],c[i]);
    			res[it] = c[i] ; 
    			i--; 
    			dfs(it); 
    		}
    	}
    };
    res[1] = c[n-1] ; 
    dfs(1) ; 
    co (ans) ; 
    for (int i=1;i<=n;i++) 
    	cout << res[i] << " " ; 
    cout << endl; 
}

signed main()
{
    solve();
    return 0;
}
/* 

5 
1 2 
1 3 
3 4 
3 5 
2 3 4 5 6 

		ans -> 14 



*/

Measured memory_bytes: 4884
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main () {
    int H, W;
    cin >> H >> W;
    int a[26] = {};
    for (int i = 0; i < H; i++) {
        string S;
        cin >> S;
        for (auto c: S) {
            a[c-'a']++;
        }
    }
    int b[5] = {};
    for (int i = W; i > 0; i-=2) {
        for (int j = H; j > 0; j-=2) {
            b[min(2, i)*min(2, j)]++;
        }
    }
    for (int i = 0; i < 26; i++) {
        if (a[i] % 2 == 1 && b[1]) {
            a[i]--;
            b[1]--;
        }
    }
    for (int i = 0; i < 26; i++) {
        int c = min(a[i]/4, b[4]);
        a[i] -= c*4;
        b[4] -= c;
    }
    for (int i = 0; i < 26; i++) {
        int c = min(a[i]/2, b[2]);
        a[i] -= c*2;
        b[2] -= c;
    }
    if (b[1] == 0 && b[2] == 0 && b[4] == 0) {
        puts("Yes");
    }
    else {
        puts("No");
    }
}

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

vector<pair<int, int>> bfs(vector<pair<int, int>> not_yet, vector<vector<int>> maze)
{
  pair<int, int> check = not_yet.at(0);
  queue<pair<int, int>> a;
  a.push(check);
  maze.at(check.first).at(check.second) = 0;
  while (!a.empty())
  {
    pair<int, int> now = a.front();
    a.pop();
    not_yet.erase(find(not_yet.begin(), not_yet.end(), now));
    vector<int> move = {1, 0, -1};
    for (int i = 0; i < 3; ++i)
    {
      for (int j = 0; j < 3; ++j)
      {
        if (i == 1 && j == 1)
        {
          continue;
        }
        if (maze.at(now.first + move.at(i)).at(now.second + move.at(j)) == 1)
        {
          a.push({now.first + move.at(i), now.second + move.at(j)});
          maze.at(now.first + move.at(i)).at(now.second + move.at(j)) = 0;
        }
      }
    }
  }
  return not_yet;
}

int main()
{
  while (true)
  {
    int w, h;
    cin >> w >> h;
    if (w == h && w == 0)
    {
      break;
    }
    vector<vector<int>> maze(h + 2, vector<int>(w + 2, -1));
    vector<pair<int, int>> not_yet(0);// h w
    for (int i = 1; i < h + 1; ++i)
    {
      for (int j = 1; j < w + 1; ++j)
      {
        int point;
        cin >> point;
        maze.at(i).at(j) = point;
        if (point == 1)
        {
          not_yet.push_back({i, j});
        }
      }
    }

    int ans = 0;
    while (not_yet.size() != 0)
    {
      not_yet = bfs(not_yet, maze);
      ans += 1;
    }
    cout << ans << endl;
  }
}



Measured memory_bytes: 3196
IDENTIFICATION DIVISION.
PROGRAM-ID. PROGRAM_ID.

DATA DIVISION.
WORKING-STORAGE SECTION.
01 a          PIC 9(10).
01 s          PIC X(10).

PROCEDURE DIVISION.
  ACCEPT a.
  ACCEPT s.
  IF 3200 <= a
    DISPLAY FUNCTION TRIM(s)
  ELSE
    DISPLAY "red"
  END-IF.
  STOP RUN.


Measured memory_bytes: 3704
fn main() {
    let s: String = read();
    if s.contains("A") && s.contains("B") {
        println!("Yes");
        return;
    }
    println!("No");
}

use std::io::stdin;
use std::io::Read;
use std::str::FromStr;

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


Measured memory_bytes: 4352
'''catupper
ポイントA.再帰DFSを使う。
ポイントB.入力に注意。
辺は頂点を結ぶので(a[i], b[i])で表現され、対応する色を
color_dict[(a[i], b[i])]としている。
配列が二重配列になっているので、注意。
ポイントC.色を頂点の順番で辺毎に出力する。辺の数は頂点-1個。
for i in range(n-1):    if (a[i], b[i]) in color_dict:
'''

import sys
sys.setrecursionlimit(1000000)#DFSは再帰の上限回数に注意

n = int(input())
edge = [[] for i in range(n)]
#どの頂点とどの頂点が繋がっているかを格納しておく配列
a = [0] * n#頂点aに繋がっている頂点bの番号を格納しておく配列
b = [0] * n

color_dict = {}#色を覚えておく
k = 0

def dfs(x, last = -1, ban_color = -1):
#lastは、どこから来たか、逆走を防ぐ。使っちゃいけない色も引数
    global k#グローバル変数
    color = 1
    for to in edge[x]:
    #配列edgeに格納されている次の頂点toを順番にチェック
        if to == last:continue
        #来た頂点に戻ろうとしたら、何もしない
        if color == ban_color:color += 1
        #使っちゃいけない色なら、新しい色にする
        color_dict[(x, to)] = color
        dfs(to, x, color)
        #次の頂点toについてDFS。来たのはxから。前の頂点で使った色はダメ。
        color += 1#色を新しくする
    k = max(k, color-1)#何色を使ったか、覚えておく

for i in range(n-1):
    a[i], b[i] = map(int, input().split())
    a[i] -= 1#0-indexにする
    b[i] -= 1
    edge[a[i]].append(b[i])#無向グラフ
    edge[b[i]].append(a[i])

dfs(0)#最初の頂点をDFSに入れてスタート
#print(color_dict)

print(k)#まず、何色必要かを出力

for i in range(n-1):#辺の色を1から頂点番号-1まで出力
    print(color_dict[(a[i], b[i])])
'''  
    if (a[i], b[i]) in color_dict:#辞書から答を出力
        print(color_dict[(a[i], b[i])])
    else:
        print(color_dict[(b[i], a[i])])
'''

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

int main(){
    int h1,m1,h2,m2,k;
    cin>>h1>>m1>>h2>>m2>>k;
    int s,e; s=e=0;
    s=h1*60+m1;
    e=h2*60+m2;
    int pass=e-s;
    int ans=0;
    ans=pass-k;
    if(ans<0)ans=0;
    cout<<ans;
	return 0;
}


Measured memory_bytes: 3592
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a) for(int i = 0; i < (a); i++)
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1e9;
const int MOD = 1e9 + 7;

int main(){
	int n;
	cin >> n;
	ll a[n];
	REP(i,n){
		cin >> a[i];
	}
	int i = 0;
	int ans = 0;
	while(i < n){
		while(a[i] == a[i + 1] && i < n - 1){
			i++;
		}
		if(a[i] < a[i + 1]){
			while(a[i] <= a[i + 1] && i < n - 1){
				i++;
			}
			i++;
		}else if(a[i] > a[i + 1]){
			while(a[i] >= a[i + 1] && i < n - 1){
				i++;
			}
			i++;
		}
		ans++;
	}
	cout << ans << endl;
}

Measured memory_bytes: 1024
import java.util.Scanner;

public class Main {

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

		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();

		System.out.println((a + b >= c) ? "Yes" : "No");

		sc.close();
	}

}




Measured memory_bytes: 21844
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

/*
 */

public class ALDS1_7_A
{
    private struct Node
    {
        public int NodeId;
        public int ParentId;
        public List<int> Children;
        public int Depth;
        public string Type
        {
            get
            {
                if (ParentId == -1)
                {
                    return "root";
                }
                else if (Children.Count == 0)
                {
                    return "leaf";
                }
                else
                {
                    return "internal node";
                }
            }
        }

        public Node(int nodeId)
        {
            NodeId = nodeId;
            ParentId = -1;
            Children = new List<int>();
            Depth = -1;
        }
    }

    public static void Main(string[] args)
    {
        //var exStdIn = new System.IO.StreamReader( "input.txt" );
        //System.Console.SetIn( exStdIn );

        int n = int.Parse(Console.ReadLine());
        Node[] nodes = new Node[n];
        for (int i = 0; i < n; i++)
        {
            nodes[i] = new Node(i);
        }

        for (int i = 0; i < n; i++)
        {
            string[] str = Console.ReadLine().Split(' ');
            int index = int.Parse(str[0]);
            int k = int.Parse(str[1]);
            for (int j = 0; j < k; j++)
            {
                int child = int.Parse(str[j + 2]);
                nodes[index].Children.Add(child);
                nodes[child].ParentId = index;
            }
        }

        int rootId = -1;
        for (int i = 0; i < n; i++)
        {
            if (nodes[i].ParentId == -1)
            {
                rootId = i;
                break;
            }
        }

        Depth(nodes, rootId, 0);

        for (int i = 0; i < n; i++)
        {
            StringBuilder builder = new StringBuilder();
            for (int j = 0; j < nodes[i].Children.Count; j++)
            {
                builder.Append(nodes[i].Children[j].ToString());
                if (j < nodes[i].Children.Count - 1)
                {
                    builder.Append(", ");
                }
            }
            Console.WriteLine(string.Format("node {0}: parent = {1}, depth = {2}, {3}, [{4}]", i, nodes[i].ParentId, nodes[i].Depth, nodes[i].Type, builder.ToString()));
        }
    }

    private static void Depth(Node[] nodes, int i, int depth)
    {
        nodes[i].Depth = depth;
        foreach (var child in nodes[i].Children)
        {
            Depth(nodes, child, depth + 1);
        }
    }
}



Measured memory_bytes: 36616
#include<stdio.h>
int m[]={5,1,2,4,1,3,1,0,0,2,3,2,2,4,5,1,4,0,4,3,3,5,0,5},a,b,c,d,r;char s[99];int main(){	for(s[87]=1,s[78]=4,s[69]=3,s[83]=2;~scanf("%s",s);*s<60?printf(r?"%d\n":"",r),a=c=0,b=r=1:(d=s[*s],d?d=d+c&3,a=m[4*a+d],b=m[4*b+d]:c+=*s-76?1:3,r+=a%3?b%3?(b+6-a)%6<3?2:5:3+!b:a?6:1));}

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

using namespace std;

int square(int x) { return x * x; }

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

    int n, ans = 2e9;
    cin >> n;
    int x[n];

    for (int i = 0; i < n; i++)
        cin >> x[i];

    for (int i = 1; i <= 100; i++) {
        int cur = 0;
        for (int X : x)
            cur += square(X - i);
        ans = min(cur, ans);
    }

    cout << ans << '\n';

    return 0;
}

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

int main() {

    int N;
    cin >> N;

    int p[N];
    rep(i, N) cin >> p[i];

    int k = 0;

    rep(i, N) {
        if (p[i] != i+1) {
            k++;
        }
            
    }

    if (k <= 2) cout << "YES" << endl;
    else cout << "NO" << endl;

    return 0;
}

Measured memory_bytes: 3612
#include<stdio.h>
#include<math.h>
#include<string.h>
#include<stdlib.h>
#include<math.h>
int main(){
 long long a,b,n;
 scanf("%lld%lld%lld",&a,&b,&n);
 
 if(n<b){
  printf("%lld\n",a*n/b);
  return 0;}
 
 if(n==b){
  printf("%lld\n",a*(n-1)/b);
  return 0;}
  
 else{
   long long x=n/b;
   x=x*b-1;
   printf("%lld\n",a*x/b-a*(x/b));
  return 0;}

} 

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

using namespace std;

#define N 100000
int n, arr[N], x;

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cin >> n;
    memset(arr, 0, sizeof(arr));
    for (int i = 0; i < n; i++) {
        cin >> x;
        arr[x]++;
    }
    int m = 0;
    for (int i = 0; i < N; i++) {
        int v = arr[i];
        if (i - 1 >= 0)
            v += arr[i - 1];
        if (i + 1 < N)
            v += arr[i + 1];
        if (v > m)
            m = v;
    }
    cout << m << endl;
    return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> lpair;
const ll MOD = 1e9 + 7;
const ll INF = 1e18;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define rREP(i,m,n) for(ll i = (m); i >= (n); i--)
#define print(x) cout << (x) << endl;
#define printa(x,n) for(ll i = 0; i < n; i++){ cout << (x[i]) << " ";} cout<<endl;
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    string n;
    cin >> n;
    cout << "ABC" << n << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>

using namespace std;
int main(){
	string s;
	cin >> s;
	int i,n = s.size(),m = 0;
	string t;
	for(i=0;i<n;i++){
		if(s[i]!='x'){
			t = t + s[i];
			m++;
		}
	}
	for(i=0;i<m;i++){
		if(t[i]!=t[m-1-i]){
		cout << -1 << endl;
		return 0;
		}
	}
	int ans = 0;
	int c = 0, d = 0;
	int l = 0,r = n-1;
	while(l<r){
		if(s[l]=='x'){
			l++;
			c++;
		}
		if(s[r]=='x'){
			r--;
			d++;
		}
		if(s[l]!='x' && s[r]!='x'){
			l++; r--;
			ans += max(c-d,d-c);
			c = 0; d = 0;
		}
	}
	cout << ans << endl;
}


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

int main(){
  int i, m, n, sum, N, N1;

  cin >> N;
  N1 = N;
  sum = 0;

  for(i = 0; i < 9; i++){
    m = pow(10,8-i);
  	n  = N1/m;
    N1 -= n*m;
    sum +=  n;
  }
  
  if((N%sum)==0)
  	cout << "Yes" << endl;
  else
    cout << "No" << endl;
}

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

int main(){
  string s;
  cin >> s;
  int n = s.size();
  if((s.at(0) == s.at(n-1) && n % 2 != 0) || (s.at(0) != s.at(n-1) && n % 2 == 0)){
    cout << "Second" << endl;
  }
  else{
    cout << "First" << endl;
  }
}

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

int main() {
    int n;
    cin >> n;
    vector<vector<int>> a(2, vector<int>(n));
    rep(i,2) rep(j,n) cin >> a.at(i).at(j);

    int ans = 0, sum = 0;
    rep(i,n) sum += a.at(0).at(i);
    sum += a.at(1).at(n-1);
    ans = max(ans, sum);
    for (int i = n-1; 0 < i; --i) {
        sum -= a.at(0).at(i);
        sum += a.at(1).at(i-1);
        ans = max(ans, sum);
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3568
use proconio::input;

fn main() {
    input! {
        n: usize,
        d: [(usize, usize); n],
    }
    let z = d.windows(3).any(|w| {
        let (x, y, z) = (w[0], w[1], w[2]);
        x.0 == x.1 && y.0 == y.1 && z.0 == z.1
    });
    if z {
        println!("Yes");
    } else {
        println!("No");
    }
}


Measured memory_bytes: 2140
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
using ll = long long;
using ld = long double;
const int INF = (1<<30)-1;
const long long LINF = (1LL<<62)-1;
const long double PI = acos(-1.0L);
const int dx[] = {-1, 0, 1, 0};
const int dy[] = {0, 1, 0, -1};
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n, i;
  cin >> n >> i;
  cout << n-i+1 << endl;
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>

int main()
{
    int a, b;
    scanf("%d%d", &a, &b);
    int k;
    k=(a+b)/2;
    if((a+b)%2==0) printf("%d", k);
    else printf("IMPOSSIBLE");
    return 0;
}


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

int main(){
  int y = 700;
  char a, c, n;
  cin >> a >> c >> n;
  if(a=='o'){
    y+=100;
  }
  if(c=='o'){
    y+=100;
  }
  if(n=='o'){
    y+=100;
  }
  cout << y << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <array>
#include <tuple>
#include <random>

using namespace std;
typedef long long int ll;

#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for(int i = int(a); i < int(b); i++)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep,)(__VA_ARGS__)
#define all(x) (x).begin(), (x).end()

#define inf 10000000000

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

    ll n, a;
    cin >> n >> a;
    cout << ((n % 500 <= a) ? "Yes" : "No") << endl;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <deque>
#include <list>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>

using namespace std;

//conversion
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}

//typedef
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(auto i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//repetition
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define UNTIL(p) while(!(p))

//constant
const double EPS = 1e-5;
const double PI  = acos(-1.0);

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

#define PUTS(x) cout << (x) << endl;

LL gcd(LL m,LL n){
    if(m<n) swap(m,n);
    while(true){
        if(n==0) break;
        LL t = n;
        n = m%n;
        m = t;
    }
    return m;
}
LL lcm(LL a,LL b){
    return (a*b)/gcd(a,b);
}

int main(void){
    cin.tie(0);
    ios::sync_with_stdio(false);
    LL N,M;
    cin>>N>>M;
    string S,T;
    cin>>S>>T;
    LL l = lcm(N, M);
    LL ln = l / N;
    LL lm = l / M;
    map<LL, char> x;
    REP(i,N)x[ln*i] = S[i];
    REP(i,M){
        if(EXIST(x,lm*i)){
            if(x[lm*i] != T[i]){
                l = -1;
                break;
            }
        }
    }
    PUTS(l);
}

Measured memory_bytes: 6144
H = int(input())
A = list(map(int, input().split()))
A.insert(0, 0)

def maxheapify(i):
    l = i*2
    r = i*2+1
    if l <= H and A[l] > A[i]:
        largest = l
    else:
        largest = i
    if r <= H and A[r] > A[largest]:
        largest = r
    if largest != i:
        tmp = A[i]
        A[i] = A[largest]
        A[largest] = tmp
        maxheapify(largest)


for i in range(int(H/2), 0, -1):
    maxheapify(i)

for i in range(1, H+1):
    print(' ', end='')
    print(A[i], end='')
print()


Measured memory_bytes: 63704
//------------------------------------------
// C++ templete 
//------------------------------------------
#include <bits/stdc++.h>
using namespace std;
using ll = long long;

#define endl "\n"

//typedef
//------------------------------------------
typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef vector<PII> VP;

//REPEAT
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

//container util
//------------------------------------------
#define pb push_back
#define paired make_pair
#define ALL(a) (a).begin(),(a).end()
#define PRINT(V) for (auto v : (V)) cout << v << " "
#define SORT(V) sort((V).begin(),(V).end())
#define RSORT(V) sort((V).rbegin(), (V).rend())

//constant
//------------------------------------------
const int MOD = 1000000007;
const int INF = 1061109567;
const double EPS = 1e-10;
const double PI  = acos(-1.0);
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

//math
//------------------------------------------
int QP(int a,int b){int ans=1;do{if(b&1)ans=1ll*ans*a%MOD;a=1ll*a*a%MOD;}while(b>>=1);return ans;}
int QP(int a,int b,int MOD){int ans=1;do{if(b&1)ans=1ll*ans*a%MOD;a=1ll*a*a%MOD;}while(b>>=1);return ans;}
int GCD(int a,int b){return b?GCD(b,a%b):a;}

//debug
//------------------------------------------
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

//grobal variable
//------------------------------------------
int N,M;
VI Vec;

//動的計画法で役に立つ関数
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; }

//最大公約数と最小公倍数
ll gcd(ll a, ll b) {
    if(b==0)return a;
    return gcd(b, a%b);
}

ll lcm(ll a, ll b) {
  ll g = gcd(a, b);
  return a/g*b;
}

vector<vector<long long> > comb(int n) {
  vector<vector<long long> > v(n + 1,vector<long long>(n + 1, 0));
  for (int i = 0; i < v.size(); i++) {
    v[i][0] = 1;
    v[i][i] = 1;
  }
  for (int j = 1; j < v.size(); j++) {
    for (int k = 1; k < j; k++) {
      v[j][k] = (v[j - 1][k - 1] + v[j - 1][k]);
    }
  }
  return v;
}

int count(int x)
{
    int c=0;
    while(x % 2 == 0)
    {
        x /= 2;
        c++;
    }
    return c;
}

int main() 
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    
    int N;cin >> N;
    VI A(N); 
    REP(i,N)
    {
        int a;
        cin >> a;
        A[i] = count(a);
    }
    
    cout << accumulate(ALL(A),0) << endl;


    return 0;
}



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

#pragma warning(disable : 4996)

typedef long long ll;
#define all(x) (x).begin(), (x).end()  // sortなどの引数を省略
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define max3(x, y, z) max(x, max(y, z))
#define min3(x, y, z) min(x, min(y, z))

using namespace std;
//#define int long long;

double dist(double x1, double y1, double x2, double y2) {
  return sqrt((x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2));
}
ll idist(ll x1, ll y1, ll x2, ll y2) {
  return (x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2);
}
using namespace std;

signed main() {
  ll a,b,c,d;
  cin >> a >> b >> c >> d;
  cout << max(max(a*c,b*c),max(a*d,b*d));
}




Measured memory_bytes: 3680
package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
	"strconv"
)

func makeSuffixArray(s string) []int {
	n := len(s)
	sa := make([]int, n)
	for i := 0; i < n; i++ {
		sa[i] = i
	}
	rnk := make([]int, n)
	for i, b := range []byte(s) {
		rnk[i] = int(b)
	}
	tmp := make([]int, n)

	for k := 1; k < n; k *= 2 {
		cmp := func(x, y int) bool {
			if rnk[sa[x]] != rnk[sa[y]] {
				return rnk[sa[x]] < rnk[sa[y]]
			}
			rx, ry := -1, -1
			if sa[x]+k < n {
				rx = rnk[sa[x]+k]
			}
			if sa[y]+k < n {
				ry = rnk[sa[y]+k]
			}
			return rx < ry
		}
		sort.Slice(sa, cmp)
		tmp[sa[0]] = 0
		for i := 1; i < n; i++ {
			tmp[sa[i]] = tmp[sa[i-1]]
			if cmp(i-1, i) {
				tmp[sa[i]]++
			}
		}
		tmp, rnk = rnk, tmp
	}
	return sa
}

func makeLcpArray(s string, sa []int) []int {
	b := []byte(s)
	n := len(s)
	rnk := make([]int, n)
	for i := 0; i < n; i++ {
		rnk[sa[i]] = i
	}
	lcp := make([]int, n-1)
	h := 0
	for i := 0; i < n; i++ {
		if h > 0 {
			h--
		}
		if rnk[i] == 0 {
			continue
		}
		j := sa[rnk[i]-1]
		for j+h < n && i+h < n {
			if b[j+h] != b[i+h] {
				break
			}
			h++
		}
		lcp[rnk[i]-1] = h
	}
	return lcp
}

func main() {
	defer flush()

	S := readString()
	sa := makeSuffixArray(S)

	result := len(S) * (len(S) + 1) / 2
	for _, x := range makeLcpArray(S, sa) {
		result -= x
	}
	println(result)
}

const (
	ioBufferSize = 1 * 1024 * 1024 // 1 MB
)

var stdinScanner = func() *bufio.Scanner {
	result := bufio.NewScanner(os.Stdin)
	result.Buffer(make([]byte, ioBufferSize), ioBufferSize)
	result.Split(bufio.ScanWords)
	return result
}()

func readString() string {
	stdinScanner.Scan()
	return stdinScanner.Text()
}

func readInt() int {
	result, err := strconv.Atoi(readString())
	if err != nil {
		panic(err)
	}
	return result
}

var stdoutWriter = bufio.NewWriter(os.Stdout)

func flush() {
	stdoutWriter.Flush()
}

func println(args ...interface{}) (int, error) {
	return fmt.Fprintln(stdoutWriter, args...)
}


Measured memory_bytes: 23572
using System;
using System.Text;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using static System.Console;
using static System.Math;

namespace AtCoder
{
    public class Program
    {
        public static void Main(string[] args)
        {
            new Program().Solve(new ConsoleInput(Console.In, ' '));
        }

        public void Solve(ConsoleInput cin)
        {
            int N = 2;
            var a = cin.ReadIntArray(N);

            int result = a[0] * a[1];

            if (result % 2 == 0)
            {
                Console.WriteLine("Even");
            }
            else
            {
                Console.WriteLine("Odd");
            }

        }
    }

    public class ConsoleInput
    {
        private readonly System.IO.TextReader _stream;
        private char _separator = ' ';
        private Queue<string> inputStream;
        public ConsoleInput(System.IO.TextReader stream, char separator = ' ')
        {
            this._separator = separator;
            this._stream = stream;
            inputStream = new Queue<string>();
        }
        public string Read
        {
            get
            {
                if (inputStream.Count != 0) return inputStream.Dequeue();
                string[] tmp = _stream.ReadLine().Split(_separator);
                for (int i = 0; i < tmp.Length; ++i)
                    inputStream.Enqueue(tmp[i]);
                return inputStream.Dequeue();
            }
        }
        public string ReadLine { get { return _stream.ReadLine(); } }
        public int ReadInt { get { return int.Parse(Read); } }
        public long ReadLong { get { return long.Parse(Read); } }
        public double ReadDouble { get { return double.Parse(Read); } }
        public string[] ReadStrArray(long N) { var ret = new string[N]; for (long i = 0; i < N; ++i) ret[i] = Read; return ret; }
        public int[] ReadIntArray(long N) { var ret = new int[N]; for (long i = 0; i < N; ++i) ret[i] = ReadInt; return ret; }
        public long[] ReadLongArray(long N) { var ret = new long[N]; for (long i = 0; i < N; ++i) ret[i] = ReadLong; return ret; }
    }
}

Measured memory_bytes: 11220
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pll pair<ll,ll>
#define pii pair<int,int>
#define mii map<int,int>
#define msi map<string,int>
#define pb push_back
#define mp make_pair
#define M 1101
#define MOD 1000000007
#define fi first
#define se second
#define vi vector<int>
#define vl vector<ll>
#define all(v) v.begin(),v.end()
#define allr(v) v.rbegin(),v.rend()
#define repl(i,l,r) for(long long i=l;i<=r;++i)
#define rep(i,l,r) for(int i=l;i<=r;++i)
#define ins insert
#define inf INT_MAX
#define vpi vector< pair<int,int> >
#define vpl vector< pair<ll,ll> >
#define eps 1e-9
ll mat[105][105];
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll n,k;cin>>n>>k;
    if(k>((n-1)*(n-2)/2))
    {
        cout<<"-1"<<"\n";
        return 0;
    }
    rep(i,1,n)
    {
        rep(j,1,n)
        {
            if(i!=j)
            {
                mat[i][j]=1;
            }
        }
    }
    ll ans=n*(n-1)/2;
    ans-=k;
    ll z=n-2;
    rep(i,2,n)
    {
        if(k>z)
        {
            k-=z;
            rep(j,2,n)
            {
                mat[i][j]=0;
                mat[j][i]=0;
            }
        }
        else
        {
            ll x=k;
            k-=x;
            rep(j,2,n)
            {
                if(mat[i][j]==1)
                {
                    x--;
                    mat[i][j]=0;
                    mat[j][i]=0;
                }
                if(x==0)
                {
                    break;
                }
            }
        }
        if(k==0)
        {
            break;
        }
        z--;
    }
    cout<<ans<<"\n";
    rep(i,1,n)
    {
        rep(j,1,n)
        {
            if(mat[i][j])
            {
                cout<<i<<" "<<j<<"\n";
                mat[i][j]=0;
                mat[j][i]=0;
            }
        }
    }
    return 0;

    //check for long long or int
}


Measured memory_bytes: 384
#include <iostream>

using namespace std;

int main()
{
    long long int a, b;
    cin >> a >> b;
    long int k;
    long long int sum = (a+b);
    if(sum % 2 == 0)
    {
        k = sum / 2;
        cout << k << endl;
    }
    else
        cout << "IMPOSSIBLE" << endl;
    return 0;
}


Measured memory_bytes: 256
#![allow(unused_imports)]
#![allow(unused_macros)]
use std::cmp::{max, min};
use std::collections::*;
use std::io::{stdin, Read};

#[allow(unused_macros)]
macro_rules! parse {
    ($it: ident ) => {};
    ($it: ident, ) => {};
    ($it: ident, $var:ident : $t:tt $($r:tt)*) => {
        let $var = parse_val!($it, $t);
        parse!($it $($r)*);
    };
    ($it: ident, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = parse_val!($it, $t);
        parse!($it $($r)*);
    };
}

#[allow(unused_macros)]
macro_rules! parse_val {
    ($it: ident, [$t:tt; $len:expr]) => {
        (0..$len).map(|_| parse_val!($it, $t)).collect::<Vec<_>>();
    };
    ($it: ident, ($($t: tt),*)) => {
        ($(parse_val!($it, $t)),*)
    };
    ($it: ident, u1) => {
        $it.next().unwrap().parse::<usize>().unwrap() -1
    };
    ($it: ident, $t: ty) => {
        $it.next().unwrap().parse::<$t>().unwrap()
    };
}

#[cfg(debug_assertions)]
macro_rules! debug {
    ($( $args:expr ),*) => { eprintln!( $( $args ),* ); }
}

#[cfg(not(debug_assertions))]
macro_rules! debug {
    ($( $args:expr ),*) => {
        ()
    };
}

fn solve(s: &str) {
    let mut it = s.split_whitespace();
    parse!(it, n: usize);
    let mut x: Vec<usize> = it
        .next()
        .unwrap()
        .chars()
        .map(|c| c.to_digit(10).unwrap() as usize)
        .collect();
    x.reverse();
    let s: usize = x.iter().sum();
    if s == 0 {
        for _ in 0..n {
            println!("{}", 1);
        }
        return;
    }
    let mut rm1: Vec<usize> = vec![];
    let mut cur = if s > 1 { 1 % (s - 1) } else { 0 };
    if s > 1 {
        for _ in 0..n {
            rm1.push(cur);
            cur = (cur * 2) % (s - 1);
        }
    }
    let mut rp1: Vec<usize> = vec![];
    let mut cur = 1 % (s + 1);
    for _ in 0..n {
        rp1.push(cur);
        cur = (cur * 2) % (s + 1);
    }

    let mut basem1 = 0;
    let mut basep1 = 0;
    for i in 0..n {
        if x[i] == 1 {
            if s > 1 {
                basem1 = (basem1 + rm1[i]) % (s - 1);
            }
            basep1 = (basep1 + rp1[i]) % (s + 1);
        }
    }

    for i in (0..n).rev() {
        let mut r = if x[i] == 0 {
            (basep1 + rp1[i]) % (s + 1)
        } else {
            if s == 1 {
                println!("{}", 0);
                continue;
            } else {
                (basem1 + (s - 1) - rm1[i]) % (s - 1)
            }
        };
        let mut count = 0;
        while r > 0 {
            r = r % (r.count_ones() as usize);
            count += 1;
        }
        println!("{}", count + 1);
    }
}

fn main() {
    let mut s = String::new();
    stdin().read_to_string(&mut s).unwrap();
    solve(&s);
}

#[cfg(test)]
mod tests {
    use super::*;
    #[test]
    fn test_input() {
        let s = "
        ";
        solve(s);
    }
}


Measured memory_bytes: 7040
#include<bits/stdc++.h>
#define P pair<int,int>
using namespace std;
 
signed main(){
int a,b;
int c[100005];
while(scanf("%d%d",&a,&b),a|b){
    for(int d=0;d<b;d++)scanf("%d",&c[d+1]);
    sort(c+1,c+b+1);
    c[0]=c[b+1]=1<<29;
    int MIN=0;
    int s=0;
    vector<P>k;
   for(int x=0;x<b;x++){
       if(c[x+1]==0)continue;
       if(c[x]+1!=c[x+1]&&c[x+1]+1!=c[x+2]){if(s==0)s=1;k.push_back(P(c[x+1],c[x+1]));}
       else if(c[x+1]+1!=c[x+2]){s=max(s,c[x+1]-MIN+1);k.push_back(P(MIN,c[x]+1));}
       else if(c[x]+1!=c[x+1])MIN=c[x+1];
       }
       if(c[1]!=0)printf("%d\n",s);
       else {
	   int qq=0;
	   for(auto o=k.begin(),t=++k.begin();o!=--k.end();o++,t++){
	       if(o->second+2==t->first)qq=max(qq,t->second-o->first+1);
	       }
	       printf("%d\n",qq);
	   }
    }
}

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

using namespace std;

static const int INF = 1e9 + 7;

template<typename T>
using Vec = vector<T>;

template<typename T, typename T2>
using P = pair<T, T2>;

template<typename... Args>
using Tup = tuple<Args...>;

template<typename T>
using qp = priority_queue<T, Vec<T>, greater<T> >;

template<typename T>
using pq = priority_queue<T>;

using llong = long long;
using ullong = unsigned long long;
using uint = unsigned int;

int gcd(int x, int y)
{
	return y ? gcd(y, x % y) : x;
}

void hawawa()
{
	int n, a;
	cin >> n >> a;
	cout << n * n - a << "\n";
}

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


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <ctime>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <cassert>
#include <bitset>
#include <list>
#include <cstdio>
#include <stdio.h>
#include <string.h>

typedef long long ll;

using namespace std;

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, cnt_a=1, cnt_b=1;
    cin >> n;
    int array[n], a[n], b[n];
    for(int i=0; i<n; i++) array[i] = i+1;
    for(int i=0; i<n; i++) cin >> a[i];
    for(int i=0; i<n; i++) cin >> b[i];

    do
    {
        if(memcmp(a, array, n*sizeof(int)) == 0) break;
        cnt_a++;
    }
    while(next_permutation(array,array+n));

    for(int i=0; i<n; i++) array[i] = i+1;

    do
    {
        if(memcmp(b, array, n*sizeof(int)) == 0) break;
        cnt_b++;
    }
    while(next_permutation(array,array+n));

    cout << abs(cnt_a - cnt_b);

}


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

int main()
{
  int W, H, x, y, r;

  cin >> W >> H >> x >> y >> r;

  if(0 + r <= x && x <= W - r && 0 + r <= y && y <= H - r)
  {
    cout << "Yes" << endl;
  }
  else
  {
    cout << "No" << endl;
  }

  return 0;
}



Measured memory_bytes: 3096
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
int main ()
{
    char s[20];
    scanf("%s", s);
    if (s[0] == 'S') printf("Cloudy\n");
    else if (s[0] == 'C') printf("Rainy\n");
    else printf("Sunny\n");
    return 0;
}


Measured memory_bytes: 128