akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i, n) for (int i=0;i<(n);i++)
typedef long long ll;
using namespace std;

vector< ll > divisor(ll n) {
  vector< ll > ret;
  for(ll i = 1; i * i <= n; i++) {
    if(n % i == 0) {
      ret.push_back(i);
      if(i * i != n) ret.push_back(n / i);
    }
  }
  sort(begin(ret), end(ret));
  return (ret);
}

int main() {
  ll n;
  cin >> n;
  
  vector<ll> yakusu = divisor(n);
  
  sort(yakusu.begin(), yakusu.end());
  
  ll size = yakusu.size();
  ll ans = 0;
  if (ll(size) % 2 == 0) {
    ans = yakusu[size/2] + yakusu[(size/2)-1] - 2;
  } else {
    ans = 2 * yakusu[size/2] - 2;
  }
  
  cout << ans << endl;
  
  return 0;
}


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

public class Main {
  public static void main(String[] args) throws IOException {
    BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
    String[] str = in.readLine().split(" ");
    StringBuilder buf = new StringBuilder();
    buf.append(str[0]);
    buf.append(str[1]);
    buf.append(str[2]);
    System.out.println(Integer.parseInt(buf.toString())%4==0?"YES":"NO");
  }
}

Measured memory_bytes: 32816
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#define rep(i, a, b) for(int i = (a); i < (b); i++)
#define ill long long
using namespace std;

int main() {
  int n;
  cin >> n;
  vector<int> v(n, 0);
  rep(i, 1, n) cin >> v[i];
  vector<int> vv(n, 0);
  rep(i, 1, n) {
    vv[v[i]-1]++;
  }
  rep(i, 0, n) cout << vv[i] << "\n";
}

Measured memory_bytes: 4840
#include<stdio.h>
#include<stdlib.h>
#include<math.h>


int main(){
	int dinheiro, bolo, dun, eq=0, eq2=0;
	scanf("%d %d %d", &dinheiro, &bolo, &dun);
	eq=(dinheiro-bolo)/dun;
	eq2= dinheiro-bolo-(eq*dun);
	printf("%d\n", eq2);

	return 0;	
}

Measured memory_bytes: 128
import java.awt.geom.Line2D;
import java.awt.geom.Point2D;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
    public static void main(String[] args) throws IOException, NumberFormatException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        
        int n = Integer.parseInt(br.readLine());
        
        for(int i = 0; i < n; i++) {
            String[] tmpArray = br.readLine().split(" ");
            
            Point2D[] points = new Point2D[4];
            
            for(int j = 0; j < 4; j++) {
                int x = Integer.parseInt(tmpArray[j * 2]);
                int y = Integer.parseInt(tmpArray[j * 2 + 1]);
                
                points[j] = new Point2D.Double(x, y);
            }
            
            Line2D[] lines = new Line2D[2];
            for(int j = 0; j < 2; j++) {
                lines[j] = new Line2D.Double(points[j * 2], points[j * 2 + 1]);
            }
            
            if(lines[0].intersectsLine(lines[1])) {
                System.out.println(1);
            } else {
                System.out.println(0);
            }
        }
    }
}


Measured memory_bytes: 28656
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end())
#define VRSORT(v) sort(v.rbegin(), v.rend())
#define ll long long
#define pb(a) push_back(a)
#define INF 1000000000
#define MOD 1000000007
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

typedef vector<unsigned int>vec;
typedef vector<vec> mat;

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; }
template<class T> inline void add(T &a, T b){a = ((a+b) % MOD + MOD) % MOD;};

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

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin>>n;
    priority_queue<int, vector<int>> minus_q;
    priority_queue<int, vector<int>, greater<int>> p_q;
    REP(i,n){
        int a;
        cin>>a;
        if(a<0) minus_q.push(a);
        else p_q.push(a);
    }
    vector<P> ans;
    while(minus_q.size() + p_q.size() >= 2){
        if(!minus_q.empty() && !p_q.empty()){
            int m,p;
            m=minus_q.top();minus_q.pop();
            p=p_q.top();p_q.pop();
            if(minus_q.empty() && p_q.empty()){
                p_q.push(p-m);
                ans.push_back({p,m});
                break;
            }
            else if(p-m==0){
                p_q.push(0);
                ans.push_back({m,p});
            }
            else if(minus_q.size() < p_q.size()){
                minus_q.push(m-p);
                ans.push_back({m,p});
            }
            else{
                p_q.push(p-m);
                ans.push_back({p,m});
            }
            //cout<<m-p<<endl;
        }
        else if(p_q.empty()){
            int m1,m2;
            m1=minus_q.top();minus_q.pop();
            m2=minus_q.top();minus_q.pop();
            ans.push_back({m1,m2});
            p_q.push(m1-m2);
        }
        else{
            int p1,p2;
            p1=p_q.top();p_q.pop();
            p2=p_q.top();p_q.pop();
            ans.push_back({p1,p2});
            minus_q.push(p1-p2);
            //cout<<p1-p2<<endl;
        }
    }
    cout<<p_q.top()<<endl;
    for(auto x:ans) cout<<x.first<<" "<<x.second<<endl;
}

Measured memory_bytes: 3188
from collections import Counter
N = int(input())
A = [int(i) for i in input().split()]

def c(n):
    return n *(n-1) // 2

m = Counter(A)
s = 0
for x, y in m.items():
    if y != 1:
        s += c(y)
for a in A:
    print(s - (m[a] - 1))

Measured memory_bytes: 34048
n = int(input())
if n in range(400, 600):
  print("8")
if n in range(600, 800):
  print("7")
if n in range(800, 1000):
  print("6")
if n in range(1000, 1200):
  print("5")
if n in range(1200, 1400):
  print("4")
if n in range(1400, 1600):
  print("3")
if n in range(1600, 1800):
  print("2")
if n in range(1800, 2000):
  print("1")


Measured memory_bytes: 9192
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
        s: chars,
    }
    let mut res = 0;
    for bit in 0..(1 << (s.len() - 1)) {
        let mut r: u64 = 0;
        let mut tmp: std::vec::Vec<char> = std::vec::Vec::with_capacity(s.len() * 2);
        for i in 0..s.len() {
            tmp.push(s.get(i).unwrap().clone());
            if bit & 1 << i != 0 {
                r += tmp.into_iter().collect::<String>().parse::<u64>().unwrap();
                tmp = std::vec::Vec::with_capacity(s.len());
            }
        }
        r += tmp.into_iter().collect::<String>().parse::<u64>().unwrap();
        res += r;
    }
    println!("{:?}", res);
}

Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
int n,m;
vector<int> v[100010];
bool vis[100010];
void dfs(int x){
	vis[x]=1;
	for(int i=0;i<v[x].size();i++){
		if(!vis[v[x][i]]){
			dfs(v[x][i]);
		}
	}
}
int main(){
	cin>>n>>m;
	for(int i=0;i<m;i++){
		int a,b;
		cin>>a>>b;
		v[a].push_back(b);
		v[b].push_back(a);
	}
	int ans=0;
	for(int i=1;i<=n;i++){
		if(!vis[i]){
			dfs(i);
			ans++;
		}
	}
	cout<<ans-1<<endl; 
	return 0;
}

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

int main()
{
    string str,command;
    int x;
    cin>>str>>x;
    REP(i,x)
    {
        cin>>command;
        if(command=="replace")
        {
            int a,b;
            string r;
            cin>>a>>b>>r;
            str.replace(a,b-a+1,r);
        }else if(command=="reverse")
        {
            int a,b;
            cin>>a>>b;
            reverse(str.begin()+a,str.begin()+b+1);
        }else if(command=="print")
        {
            int a,b;
            cin>>a>>b;
            cout<<str.substr(a,b-a+1)<<endl;
        }
    }
}



Measured memory_bytes: 3200
var obj = init();
Main();
function nextInt(){return myconv(next(),1);}
function nextStrArray(){return myconv(next(),2);}//半角スペース分割
function nextIntArray(){return myconv(next(),4);}//半角スペース + 数値化
function nextCharArray(){return myconv(next(),6);}//1文字分割
function next(){return obj.next();}
function hasNext(){return obj.hasNext();}
function myin(){return require("fs").readFileSync("/dev/stdin", "utf8").trim().split("\n");}
function init(){
  var inputFile = myin();
  var returnObj = {
    "list" : inputFile, "index" : 0, "max" : inputFile.length,
    "hasNext" : function(){return (this.index < this.max);},
    "next" : function(){if(!this.hasNext()){throw "ArrayIndexOutOfBoundsException これ以上ないよ";}else{var returnInput = this.list[this.index];this.index++;return returnInput;}}
  };
  return returnObj;
}
function myout(t){console.log(t);}//標準出力
function myerr(t){console.error(t);}//標準エラー出力
//[no]要素の扱い。数値型
//不明値、異常時:引数そのまま返す　1:数値へ変換
//2:半角SPで分割 4:半角SPで分割し、数値配列へ
//6:1文字で分割  7:1文字で分割し、数値配列へ
//8:半角SPで結合 9:改行で結合 0:文字なしで結合
function myconv(i,no){try{switch(no){case 1:return parseInt(i);case 2:return i.split(" ");case 4:return i.split(" ").map((a)=>Number(a));case 6:return i.split("");case 7:return i.split("").map((a)=>Number(a));case 8:return i.join(" ");case 9:return i.join("\n");case 0:return i.join("");default:return i;}}catch(e){return i;}}
function Main(){
  var one = nextIntArray();
	var H = one[0];
	var W = one[1];
	var list = new Array(H);
	var access = new Array(H);
	for(var i = 0; i < H; i++){
		list[i] = nextCharArray();
		access[i] = new Array(W).fill(false);
	}
	var dy = [-1,0,1,0];
	var dx = [0,-1,0,1];
	var group = [];
	for(var i = 0; i < H; i++){
		for(var j = 0; j < W; j++){
			if(!access[i][j] && list[i][j] == "#"){
				group.push({
					white : 0,
					black : 1
				});
				bfs(i,j);
			}
		}
	}
	//myerr(group);
	var output = 0;
	for(var i = 0; i < group.length; i++){
		output += group[i]["white"] * group[i]["black"];
	}
	myout(output);
	function bfs(y,x){
		var queue = [[y,x]];
		access[y][x] = true;
		list[y][x] = 0;
		while(queue.length > 0){
			var tmp = queue.shift();
			for(var i = 0; i < 4; i++){
				var nextY = tmp[0] + dy[i];
				var nextX = tmp[1] + dx[i];
				if(nextY >= 0 && nextY < H && nextX >= 0 && nextX < W){
					if(!access[nextY][nextX]){
						if(list[tmp[0]][tmp[1]] % 2 == 0 && list[nextY][nextX] == "."){
							list[nextY][nextX] = list[tmp[0]][tmp[1]] + 1;
							group[group.length - 1]["white"]++;
							queue.push([nextY,nextX]);
							access[nextY][nextX] = true;
						}else if(list[tmp[0]][tmp[1]] % 2 == 1 && list[nextY][nextX] == "#"){
							list[nextY][nextX] = list[tmp[0]][tmp[1]] + 1;
							group[group.length - 1]["black"]++;
							queue.push([nextY,nextX]);
							access[nextY][nextX] = true;
						}
					}
				}
			}
		}
	}
}

Measured memory_bytes: 30708
N,K = map(int, input().split())
d = [0] * K
A = []
Nlist = []
B = 0

for _ in range(N):
    Nlist.append(0)


for i in range(K):
    d[i] = int(input())
    A.append(list(map(int,input().split())))

for j in range(K):
    for k in range(d[j]):
        Nlist[A[j][k]-1] += 1

for l in range(N):
    if Nlist[l] == 0:
        B = B + 1

print(B)


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

class ModComb {
    long long *fact, *facti;
    const int mod;
public:
    explicit ModComb(int n, int m) : mod(m) {
        fact = new long long[n+1];
        facti = new long long[n+1];
        fact[0] = 1; facti[0] = 1;
        for (int i = 1; i <= n; i++) fact[i] = (fact[i-1] * i) % m;
        // calc 1/n!
        long long &inv = facti[n], pw = fact[n];
        inv = 1;
        for (int e = mod-2; e > 0; e /= 2) {
            if (e&1) inv = inv * pw % mod;
            pw = pw * pw % mod;
        }
        for (int i = n-1; i > 0; i--) facti[i] = (facti[i+1] * (i+1)) % m;
    }

    ~ModComb() {
        if (fact) delete[] fact;
        if (facti) delete[] facti;
    }

    long long getComb(int n, int k) const {
        if (n < 0 || k < 0 || k > n) return 0;
        return fact[n] * facti[k] % mod * facti[n-k] % mod;
    }

    long long getPerm(int n, int k) const {
        if (n < 0 || k < 0 || k > n) return 0;
        return fact[n] * facti[n-k] % mod;
    }
};

const int M = 1000000007;

int main() {
    int n, m; cin >> n >> m;
    ModComb mc(m, M);
    long long ans = 0;
    for (int i = 0; i <= n; i++)
        ans += (i % 2 ? -1 : 1) * mc.getComb(n, i) * mc.getPerm(m-i, n-i) % M;
    cout << (ans % M * mc.getPerm(m, n) % M + M) % M << endl;
}


Measured memory_bytes: 10660
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<utility>
#include<vector>
#include<queue>
#include<functional>
#include<map>
#include<set>
#include<cstring>
#include<string>
#include<stack>
#include<malloc.h>
#include<math.h>
using namespace std;
#define int long long
typedef pair<int, int> pii;
typedef priority_queue<pii, vector<pii>, greater<pii> > RPQ;
#define mk make_pair
#define INF (1 << 30)
#define INFL (1ll << 60ll)
#define mod 1000000007

int N, a[2000200], b[2000200], c[10100];

void countingsort(int k){
    for(int i = 0; i < N; i++){
        c[a[i]]++;
    }
    for(int i = 1; i <= k; i++){
        c[i] += c[i - 1];
    }
    for(int i = N - 1; i >= 0; i--){
        b[c[a[i]]] = a[i];
        c[a[i]]--;
    }
}

signed main(){
    cin >> N;
    int k = 0;
    for(int i = 0; i < N; i++){
        cin >> a[i];
        k = max(k, a[i]);
    }
    countingsort(k);
    for(int i = 0; i < N; i++){
        cout << b[i + 1] << ((i == N - 1) ? "\n" : " ");
    }

    return 0;
}

/*

*/


Measured memory_bytes: 34364
#include <string>
#include <vector>
#include <cmath>
#include <iostream>

using namespace std;
string s;
int ans=999;
int temp;
vector<int> list;
#define E 753
#define rep(i,n) for(int i=0; i<n; i++)

int main()
{
  cin >> s;
  rep(i, s.length()) {
    list.push_back(s[i]-'0');
  }
  rep(i, s.length()-2) {
    temp = list[i]*100 + list[i+1]*10 + list[i+2];
    if(abs(temp-E)<ans) {
      ans = abs(temp-E);
    }
  }
  printf("%d\n", ans);
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    string N;
    cin >> N;
    
    int size = N.size();
    int ans=0;
    string s;
    for(int i = 0;i<size;i++){
        s = N.at(i);
        ans += stoi(s);
    }

    if(ans % 9 == 0){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
}

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

using u128 = __uint128_t;

#define int long long
#define MOD 1000000007
int32_t main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    int n , k;
    cin>>n>>k;
    cout<<(int)ceil(n/(float)k)<<endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main{
	public static void main(String[] args){
		int i,count;
		Scanner scan = new Scanner(System.in);
		String[] s = scan.nextLine().split("[ ,\\.]");

		for(i=count=0;i<s.length;i++){
			if(3 <= s[i].length() && s[i].length() <= 6){
				if(count != 0) System.out.print(" ");
				System.out.print(s[i]);
				count++;
			}
		}
		System.out.println();
	}
}

Measured memory_bytes: 12000
#include <iostream>
#include <cstdio>
using namespace std;
int main()
{
    string a,b="CODEFESTIVAL2016";
    int s=0;
    cin>>a;
    for(int i=0;i<16;i++)
        if(a[i]!=b[i])
            s++;
    cout<<s<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,temp;
    vector <int> v;
    cin>>n;
    
    for (int i=0 ;i<n ;i++)
    {
        v.push_back(0);
    }
    
    while(cin>>temp)
    {
        v[temp-1]=v[temp-1]+1;
    }
    
    for (auto &i:v)
        cout<<i<<endl;
    return 0;
}

Measured memory_bytes: 4316
#include <bits/stdc++.h>
using namespace std;
 
#define ll long long
#define vvi vector< vector<int> >
#define vi vector<int>
#define All(X) X.begin(),X.end()
#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define pb push_back
#define pii pair<int,int>
#define mp make_pair
#define shosu(X) fixed << setprecision(X)
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
 
int main(){
  int x,y,z,k;
  cin >> x >> y >> z >> k;
  vector<ll int> da(1000),db(1000),dc(1000);
  REP(i, x) cin >> da[i];
  REP(i, y) cin >> db[i];
  REP(i, z) cin >> dc[i];
  sort(All(da), greater<ll int>());
  sort(All(db), greater<ll int>());
  sort(All(dc), greater<ll int>());

  vector<ll int> arr;
  REP(ii, x){
    REP(jj, y){
      REP(kk, z){
        if((ii+1)*(jj+1)*(kk+1) > k) continue;
        ll int sum = da[ii] + db[jj] + dc[kk];
        arr.pb(sum);
      }
    }
  }
  sort(All(arr), greater<ll int>());

  REP(i, k){
    cout << arr[i] << endl;
  }
}	


Measured memory_bytes: 1404
N=int(input())
s=[]
for i in range(N):
    x=input()
    s.append(x)
M=int(input())
t=[]
for i in range(M):
    y=input()
    t.append(y)

dict_s = {}
for i in range(N):
    if s[i] in dict_s:
        dict_s[s[i]] += 1
    else:
        dict_s[s[i]] = 1

dict_t = {}
for i in range(M):
    if t[i] in dict_t:
        dict_t[t[i]] += 1
    else:
        dict_t[t[i]] = 1

cnt=0
for i in dict_s:
    x = dict_s[i]
    if i in dict_t:
        x -= dict_t[i]
    if x >= cnt:
        cnt = x
print(cnt)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
//#define num 1000000007
#define num 998244353
#define REP(i,a,n) for(ll i=a;i<n;i++)
#define inarr(i,a,n,A) for(ll i=a;i<n;i++) { cin>>A[i]; }
#define vll vector<long long>
#define pii pair <int,int>
#define pll pair<long long, long long>
#define vpii vector< pair <int,int>>
#define vpll vector< pair<long long, long long>>
#define max(a,b) ((a>b)?a:b)
#define min(a,b) ((a>b)?b:a)
#define max3(a,b,c) ((a>b)?(a>c)?a:c:(b>c)?b:c)
#define min3(a,b,c) ((a<b)?(a<c)?a:c:(b<c)?b:c)
#define avg(a,b) ((a)+(b))/2
//#define push push_back
//#define pop pop_back
#define sf int flag=0     //Remember semicolon
#define assmin(a,b) if(b<=a) { a=b; }
#define assmax(a,b) if(b>=a) { a=b; }
#define f first
#define s second
#define fix(f,n) std::fixed<<std::setprecision(n)<<f
typedef long long ll;
// ll mod(ll a, ll b)
// {
// 	if(a%b<0)
// 	{
// 		return a%b + b;
// 	}
// 	return a%b;
// }
 
 
// ll mod_exp(ll a, ll b, ll c)
// {
// 	ll res=1;
// 	a=a%c;
// 	while(b>0)
// 	{
// 		if(b%2==1)
// 		{
// 			res=(res*a)%c;
// 		}
// 		b/=2;
// 		a=(a*a)%c;
// 	}
// 	return res;
// }
// ll mymod(ll a,ll b)
// {
//     return ((a%b)+b)%b;
// }
// bool prime[200001];
// void SieveOfEratosthenes() 
// { 
//     memset(prime, true, sizeof(prime)); 
//     prime[1]=false;
//     for (int p=2; p*p<=200000; p++) 
//     { 
//         if (prime[p] == true) 
//         { 
//             for (int i=p*p; i<=200000; i += p) 
//                 prime[i] = false; 
//         } 
//     } 
//     return;
// }
// ll powe[200005];
// void power()
// {
//     powe[0]=1;
//     REP(i,1,200005)
//     {
//         powe[i]=mymod(2*powe[i-1],num);
//     }
// }
// ll gcdExtended(ll,ll,ll *,ll *);
// ll modInverse(ll a, ll m) 
// { 
//     ll x, y; 
//     ll g = gcdExtended(a, m, &x, &y); 
//         ll res = (x%m + m) % m;
//         return res;
// } 
// ll gcdExtended(ll a, ll b, ll *x, ll *y) 
// { 
//     if (a == 0) 
//     { 
//         *x = 0, *y = 1; 
//         return b; 
//     } 
//     ll x1, y1; 
//     ll gcd = gcdExtended(b%a, a, &x1, &y1); 
//     *x = y1 - (b/a) * x1; 
//     *y = x1; 
//     return gcd; 
// } 
// ll facto[200005];
// void f()
// {
// 	facto[0]=1;
// 	REP(i,1,200005)
// 	{
// 		facto[i]=mymod((i*facto[i-1]),num);
// 	}
// }
string ans="";
void dfs(set<ll> adj[], ll a, bool def[], ll parent=-1)
{
    def[a]=true;
    for(auto x: adj[a])
    {
        if(parent!=-1 && x!=parent && def[x])
        {
            cout<<"Impossible\n";
            exit(0);
        }
        if(!def[x])
        {
            dfs(adj,x,def,a);
        }
    }
    ans+=(char)(a+97);
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
   ll n,a,b;
   cin>>n>>a>>b;
   ll ans=0;
   ans+=(a*(n/(a+b)));
   ans+=(n%(a+b)>=a)?a:(n%(a+b));
   cout<<ans<<"\n";
	return 0;
}

Measured memory_bytes: 384
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<cmath>
using namespace std;
#define G() Cr=getchar()
#define LL long long
int Xr;char Cr;
inline int rd(){
	Xr=0, G();
	while(Cr<'0'||Cr>'9')G();
	while(Cr>='0'&&Cr<='9')Xr=(Xr<<3)+(Xr<<1)+Cr-'0', G();
	return Xr;
}
int n;
string s="0";
bool check(int t){
	for(int i=0;i<=t;i++)if(s[i]!='9')return 0;
	return 1;
}

void work(){//cout<<s<<endl;
	int t=s.size()-1;
	if(check(t)){
		s="1";
		for(int i=0;i<=t;i++)s+='0';
		return;
	}
	if(s[t]<=s[t-1]&&s[t]!='9'){
		s[t]++;
		return;
	}
	int la=t-1;
	for(la;la>=0;la--)if(s[la]!='9')break;
	for(la;la;la--)if(s[la+1]-s[la]!=1)break;
	if(s[la+1]-s[la]!=1)la++;
	s[la]++;
	for(int i=la+1;i<=t;i++)s[i]=max(s[i-1]-1-'0',0)+'0';
}
int main(){
	n=rd();
	if(n<=10){
		cout<<n;
		return 0;
	}
	s="10";
	for(int i=11;i<=n;i++)work();
	cout<<s;
}

Measured memory_bytes: 256
open Scanf
let () =
  let xs = scanf " %d" (fun n -> Array.init n (fun _ -> scanf " %d" (fun t -> t))) in
  let total = Array.fold_left (+) 0 xs in
  scanf " %d" (fun m -> Array.init m (fun _ -> scanf " %d %d" (fun p u -> p, u)))
  |> Array.iter (fun (p, u) -> Printf.printf "%d\n" (total + (u - xs.(p-1))))


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

int main(){
    int a,b,c;
    int x[3];

    cin >> a >> b >> c;
    x[0] = a;
    x[1] = b;
    x[2] = c;
    
    sort(x, x+3);

    cout << x[0] <<" "<< x[1] <<" "<< x[2] << endl;
    return 0;
}

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

using namespace std;

#define pb push_back
#define fs first
#define sc second
#define sz size
#define forn(i, n) for (ll i = 0; i < (ll) (n); ++i)
#define forni(i, n) for (ll i = 2; i <= (ll) (n); ++i)
#define IO ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)

using ll = long long;
const ll inf = 1e9+7; 

const double PI =  3.141592653589793;

int main(){
	IO;
	ll d,n;
	cin>>d>>n;
	if(d==0){
		(n==100)?cout<<"101\n":cout<<n<<"\n";
	}else if(d==1){
		(n==100)?cout<<(n+1)*100<<"\n":cout<<n*100<<"\n";
	}else {
		(n==100)?cout<<(n+1)*10000:cout<<n*10000<<"\n";
	}
	return 0;
}

// _   .-')                .-. .-')                 .-')                                               
//( '.( OO )_              \  ( OO )               ( OO ).                                             
// ,--.   ,--.).-'),-----. ,--. ,--.  .-'),-----. (_)---\_) ,--. ,--.     .-----.  ,-.-')  .-'),-----. 
// |   `.'   |( OO'  .-.  '|  .'   / ( OO'  .-.  '/    _ |  |  | |  |    '  .--./  |  |OO)( OO'  .-.  '
// |         |/   |  | |  ||      /, /   |  | |  |\  :` `.  |  | | .-')  |  |('-.  |  |  \/   |  | |  |
// |  |'.'|  |\_) |  |\|  ||     ' _)\_) |  |\|  | '..`''.) |  |_|( OO )/_) |OO  ) |  |(_/\_) |  |\|  |
// |  |   |  |  \ |  | |  ||  .   \    \ |  | |  |.-._)   \ |  | | `-' /||  |`-'| ,|  |_.'  \ |  | |  |
// |  |   |  |   `'  '-'  '|  |\   \    `'  '-'  '\       /('  '-'(_.-'(_'  '--'\(_|  |      `'  '-'  '
// """    """     """""""" """  """"      """""""  """""""  """"""""      """"""   """         """""""


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
using namespace std;
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
 
const int MOD = 1e9 + 7;struct ModularInt{int n;ModularInt(int n_=0):n(n_){}};
ModularInt operator-(ModularInt a){return -a.n+MOD*(a.n!=0);}
ModularInt operator+(ModularInt a,ModularInt b){int x=a.n+b.n;return x-(x>=MOD)*MOD;}
ModularInt operator-(ModularInt a,ModularInt b){int x=a.n-b.n;return x+(x<0)*MOD;}
ModularInt operator*(ModularInt a,ModularInt b){return (long long)a.n*b.n%MOD;}
ModularInt &operator+=(ModularInt &a,ModularInt b){return a=a+b;}
ModularInt &operator-=(ModularInt &a,ModularInt b){return a=a-b;}
ModularInt &operator*=(ModularInt &a,ModularInt b){return a=a*b;}
istream &operator>>(istream &i,ModularInt &a){return i>>a.n;}
ostream &operator<<(ostream &o,ModularInt a){return o<<a.n;}
 
int N, K;
vector <int> G[1000005];
 
ModularInt answer = 1;
 
void dfs(int v, int depth, int p = -1) {
  int kids_count = 0;
  for(auto u: G[v]) if(u != p) {
    answer *= max(0, K - (kids_count++) - min(2, (depth + 1)));
    dfs(u, depth + 1, v);
  }
}
 
int main() {
  ios_base::sync_with_stdio(false);
  cin >> N >> K;
  for(int i = 0; i < N - 1; i++) {
    int a, b;
    cin >> a >> b;
    G[a].push_back(b);
    G[b].push_back(a);
  }
  dfs(1, 0);
  answer *= K;
  cout << answer << endl;
}


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

constexpr int inf = 0x3f3f3f3f;
constexpr ll linf = 0x3f3f3f3f3f3f3f3fLL;

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

    int n; cin >> n;
    for (int i = 0; i < 50000; i++) {
        if ((int)(1.08 * i) == n) {
            cout << i << endl;
            return 0;
        }
    }
    cout << ":(" << endl;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<list>
#include<set>
#include<map>
#include<utility>
#include<queue>
#include<cmath>
 
#define rep(i,x) for(int i=0;i<(int)(x);i++)
#define reps(i,x) for(int i=1;i<=(int)(x);i++)
#define rrep(i,x) for(int i=((int)(x)-1);i>=0;i--)
#define rreps(i,x) for(int i=((int)(x));i>0;i--)
 
#define all(x) (x).begin(),(x).end()
#define SZ(x) ((int)(x).size())
#define INF 2e9
#define MOD 1000000007
 
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
typedef long long ll;
typedef std::pair<ll, ll> P;
int gcd(ll a,ll b){return b?gcd(b,a%b):a;}
 
 
using namespace std;

int main()
{
    ll n, m;
    cin >> n >> m;
    vector< vector<ll> > v(n+1);
    vector< pair<ll,ll> > p(m);
    rep(i, m){
        cin >> p[i].first >> p[i].second;
        v[p[i].first].push_back(p[i].second);
    }
    reps(i, n){
        sort(all(v[i]));
    }
    rep(i, m){
        ll pt = p[i].first;
        ll yt = p[i].second;
        auto itr0 = lower_bound(all(v[pt]), yt);
        ll idx = itr0 - v[pt].begin()+1;
        string pd = to_string(pt);
        string id = to_string(idx);
        ll ps = pd.size();
        ll is = id.size();
        if(ps<6){
            rep(j, 6-ps) pd = '0' + pd;
        }
        if(is<6){
            rep(j, 6-is) id = '0' + id;
        }
        cout << pd+id << endl;
    }
}

Measured memory_bytes: 8576
#include<bits/stdc++.h>
using namespace std;
vector<string> vec_splitter(string s) {
	s += ',';
	vector<string> res;
	while(!s.empty()) {
		res.push_back(s.substr(0, s.find(',')));
		s = s.substr(s.find(',') + 1);
	}
	return res;
}
void debug_out(
vector<string> __attribute__ ((unused)) args,
__attribute__ ((unused)) int idx,
__attribute__ ((unused)) int LINE_NUM) { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(vector<string> args, int idx, int LINE_NUM, Head H, Tail... T) {
	if(idx > 0) cerr << ", "; else cerr << "Line(" << LINE_NUM << ") ";
	stringstream ss; ss << H;
	cerr << args[idx] << " = " << ss.str();
	debug_out(args, idx + 1, LINE_NUM, T...);
}
#define XOX
#ifdef XOX
#define debug(...) debug_out(vec_splitter(#__VA_ARGS__), 0, __LINE__, __VA_ARGS__)
#else
#define debug(...) 42
#endif


signed main()
{
    string a;
    cin >> a;
    int ans = 0;
    int mx = 0;
    for (int i = 0; i < a.size(); i++) {
        if (a[i] == 'R') {
            ans++;
        }
        else {
            mx = max(mx, ans);
            ans = 0;
        }
    }
    cout << max(mx, ans)<< "\n";
}






























Measured memory_bytes: 3628
#include <stdio.h>
#include <ctype.h>
 
int main() {
 
  char ch[1200];
  int i,n;
  n=0;
  char a[1200];
 
  while(1) {
    scanf("%c",&a[n]);
    if(a[n] == '\n') {
      break;
    }
    ch[n] = a[n];
    if('A' <= a[n] && a[n] <= 'Z') {
      ch[n] = a[n] + 32;
    } else if(a[n] >= 'a' && a[n] <= 'z') {
      ch[n] = a[n] - 32;
 
    }
     
     
    n = n +1;
     
  }
   
  for(i=0; i<n ; i++) {
    printf("%c" ,ch[i]);
  }
  printf("\n"); 
  return 0;
   
}


Measured memory_bytes: 2076
# https://qiita.com/gogotealove/items/11f9e83218926211083a
N = input()
L = len(N) - 1  # 隙間の個数

# bit全探索
for i in range(2 ** L):
    # ["-", "-", "-"] というリストの作成
    op = ["-"] * L
    for j in range(L):
        if (i >> j) & 1:
            op[L - 1 - j] = '+'

    formula = ""
    for p_n, p_o in zip(N, op + [""]):
        formula += (p_n + p_o)
    if eval(formula) == 7:
        print(formula + "=7")
        break


Measured memory_bytes: 3060
#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>;
const int MOD=1000000007;

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

  cout << max(a-2*b,0) << endl;
}


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

using namespace std;
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9 + 7;
const ll LINF = 1e18;

int main() {

    ll n, m; cin >> n >> m;

    if (n * 2 < m) {
        ll t = m - 2 * n;

        cout << n + t / 4 << endl;
    } else {
        cout << m / 2 << endl;
    }
}

Measured memory_bytes: 256
s=list(input())
a,b,c,d=s[0],s[1],s[2],s[3]
aa,bb,cc,dd=int(a),int(b),int(c),int(d)
ops=['+']*3
ans='=7'
def sumsum(a,b,c,d):
    return a+b+c+d

if sumsum(aa,bb,cc,dd)==7:
    print(a+ops[0]+b+ops[1]+c+ops[2]+d+ans)
    exit()
if sumsum(aa,bb,cc,dd)-2*bb==7:
    ops[0]='-'
    print(a+ops[0]+b+ops[1]+c+ops[2]+d+ans)
    exit()
if sumsum(aa,bb,cc,dd)-2*cc==7:
    ops[1]='-'
    print(a+ops[0]+b+ops[1]+c+ops[2]+d+ans)
    exit()
if sumsum(aa,bb,cc,dd)-2*dd==7:
    ops[2]='-'
    print(a+ops[0]+b+ops[1]+c+ops[2]+d+ans)
    exit()
if sumsum(aa,bb,cc,dd)-2*bb-2*cc==7:
    ops[0],ops[1]='-','-'
    print(a+ops[0]+b+ops[1]+c+ops[2]+d+ans)
    exit()
if sumsum(aa,bb,cc,dd)-2*cc-2*dd==7:
    ops[1],ops[2]='-','-'
    print(a+ops[0]+b+ops[1]+c+ops[2]+d+ans)
    exit()
if sumsum(aa,bb,cc,dd)-2*bb-2*dd==7:
    ops[0],ops[2]='-','-'
    print(a+ops[0]+b+ops[1]+c+ops[2]+d+ans)
    exit()
    exit()
if sumsum(aa,bb,cc,dd)-2*bb-2*cc-2*dd==7:
    ops='-'*3
    print(a+ops[0]+b+ops[1]+c+ops[2]+d+ans)
    exit()


Measured memory_bytes: 3192
#include<bits/stdc++.h>
using namespace std;
#define SC scanf
#define PR printf
#define pb push_back
#define mp make_pair
#define SZ(v) ((int)(v).size())
#define rep(i,n) for(int i=0;i<(n);i++)
#define ll long long
typedef pair<int,int> pii;
typedef pair<pii,int> ppi;
typedef pair<int,pii> pip;
typedef pair<pii,pii> ppp;
typedef vector<int> vi;
typedef vector<pii> vii;
const int INF=0x3f3f3f3f;
const ll LL_INF=0x3f3f3f3f3f3f3f3f;
const int xx[4]={1,-1,0,0};
const int yy[4]={0,0,1,-1};
int inline in(){
	int x=0,c;
	for(;(unsigned int)((c=getchar())-'0')>=10;){
		if(c=='-')return -in();
		if(!~c)throw ~0;
	}
	do{
		x=(x<<3)+(x<<1)+(c-'0');
	}while((unsigned int)((c=getchar())-'0')<10);
	return x;
}
int a[20][20];
int main(){
    ios::sync_with_stdio(false);
	int n,d;
	cin>>n>>d;
	for(int i=1;i<=n;i++){
		for(int j=1;j<=d;j++){
			cin>>a[i][j];
		}
	}
	int ans=0;
	for(int i=1;i<=n;i++){
		for(int j=1;j<i;j++){
			int sum=0;
			for(int k=1;k<=d;k++){
				sum+=(a[i][k]-a[j][k])*(a[i][k]-a[j][k]);
			}
			int k;
			for(k=1;k*k<=sum;k++);
			k--;
			if(k*k==sum)ans++;
		}
	}
	cout<<ans<<endl;
	return 0;
}

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

int main() {    
    string S;
    cin >> S;
    if (S[S.size() - 1] == 's') S = S + "es";
    else S = S + 's';
    cout << S << endl;
    return 0;
}


Measured memory_bytes: 3636
import java.util.Scanner;

class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int N;int X;
		do{
		N=  Integer.parseInt(sc.next());
		X= Integer.parseInt(sc.next());
		if(N!=0||X!=0) System.out.println(calc(N,X));
		}while(N!=0||X!=0);
		
		sc.close();
	}
	static int calc(int n,int x){
		int cnt=0;
		for(int i=1;i<=n;i++){
			for(int j=1;j<i;j++){
				for(int k=1;k<j;k++){
					if(i+j+k==x) cnt++;
				}
			}
		}
		return cnt;
	}
}

Measured memory_bytes: 26132
#include <iostream>
#include <math.h>
#include <string>
#include <stdio.h>
#include <algorithm>
#include <queue>
#include <stack>
#include <functional>
#include <iomanip>
//#include <bits/stdc++.h>
#define micro 0.01

using namespace std;

int main()
{
	 long n;
	cin >> n;
	long sum=0;
	for (int i = 1; i <= n; i++)
	{
		//FizzBuzz
		if (i % 3 != 0 && i % 5 != 0)
		{
		sum+=i;
         }
	}
	cout << sum << endl;
}


Measured memory_bytes: 3632
function div(y, x){
    return Math.floor(y/x);
}
function solve(A,B,C){
    return Math.min(div(B,A),C)
}
function readInt(str){
    return parseInt(str, 10);
}
function Main(raw) {
    const input = raw.split("\n");
    const [A,B,C] = input[0].split(" ").map(readInt);
    
    //出力
    console.log("%d", solve(A,B,C));
}

//DO NOT EDIT
Main(require("fs").readFileSync("/dev/stdin", "utf8"));
  

Measured memory_bytes: 7372
class UnionFind:
    def __init__(self, size):
        self.table = [None] * size

    def find(self, x):
        if self.table[x] == None:
            return x
        else:
            # compression of the path
            self.table[x] = self.find(self.table[x])
            return self.table[x]
    
    def union(self, parent, child):
        p_root = self.find(parent)
        c_root = self.find(child)
        if p_root != c_root:
            self.table[c_root] = p_root
        
def solve():
    import sys
    input_lines = sys.stdin.readlines()
    while True:
        N, Q = map(int, input_lines[0].split())
        if N == 0:
            break
        
        unmarked = [True] * (N + 1)
        unmarked[1] = False
        operation = []
        for o in input_lines[N:N+Q]:
            mq, v = o.split()
            v = int(v)
            if mq == 'M':
                if unmarked[v]:
                    unmarked[v] = False
                    operation.append((mq, v))
            else:
                operation.append((mq, v))
        
        uf = UnionFind(N + 1)
        parent = [None, 1] + list(map(int, input_lines[1:N]))
        for v, p in enumerate(parent[2:], start=2):
            if unmarked[v]:
                uf.union(p, v)
        
        ans = 0
        for o, v in reversed(operation):
            if o == 'M':
                uf.union(parent[v], v)
            else:
                ans += uf.find(v)
        
        print(ans)
        
        del input_lines[:N+Q]

solve()


Measured memory_bytes: 88892
#include <iostream>
#include <fstream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <chrono>

using namespace std;
using namespace chrono;
 
typedef long long ll;
typedef long double ld;

typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;

typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;

//#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define loop(x,n) for(int x = 0; x < n; ++x)
#define FORd(i,a,b) for (int i = (b)-1; i >= (a); i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)
#define trav(a, x) for (auto& a : x)

#define mp make_pair
#define pb push_back
#define ff first
#define ss second
#define lb lower_bound
#define ub upper_bound

#define sz(x) (int)x.size()
#define beg(x) x.begin()
#define en(x) x.end()
#define all(x) beg(x), en(x)
#define resz resize

const int MOD = 1000000007; // 998244353
const ll INF = 1e18;
const int MX = 100001;

string get_str() {
    string temp;
    cin >> temp;
    return temp;
}
int get_int() {
    int temp;
    cin >> temp;
    return temp;
}

void solve() {
    int x; cin >> x;
    cout << ((x >= 30) ? "Yes" : "No") << endl;

}

int main() {
    
    solve();

}

Measured memory_bytes: 3612
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
 
#define REPI(i, a, n)	for(ll (i)=(a);(i)<(n);(i++))
#define REP(i,n) REPI(i,0,n)
#define REP1(i,n) for(ll (i)=1;(i)<=(n);(i++))
#define ALL(x) x.begin(), x.end()
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))
 
struct ProconInit {
	static constexpr int IOS_PREC = 15;
	static constexpr bool AUTOFLUSH = false;
 
	ProconInit() {
		cin.tie(nullptr);
		ios::sync_with_stdio(false);
		cout << fixed << setprecision(IOS_PREC);
		if (AUTOFLUSH)
			cout << unitbuf;
	}
} PROCON_INIT;
 
int vector_finder(std::vector<int> vec, int number) {
	auto itr = std::find(vec.begin(), vec.end(), number);
	size_t index = std::distance(vec.begin(), itr);
	if (index != vec.size()) { // 発見できたとき
		return 1;
	}
	else { // 発見できなかったとき
		return 0;
	}
}
ll gcd(ll a, ll b) {
	if (a < b)swap(a, b);
	if (a % b == 0)return b;
	return gcd(a % b, b);
}
ll lcm(ll a, ll b) {
	return a / gcd(a, b) * b;
}
ll fact(ll n) {
	ll m;
	if (n == 0) {
		return 1;
	}
	m = fact(n - 1);
	return n * m;
}
 
ll Combination(unsigned long long n, unsigned long long r) {
	if (r * 2 > n) r = n - r;
	uintmax_t dividend = 1;
	uintmax_t divisor = 1;
	for (unsigned int i = 1; i <= r; ++i) {
		dividend *= (n - i + 1);
		divisor *= i;
	}
	return dividend / divisor;
}
 
struct vec {
	ll x, y;
 
	bool operator == (const vec &v) const{
		return x == v.x && y == v.y;
	}
 
};
 
namespace std {
	template<>
	class hash<vec> {
	public:
		size_t operator () (const vec& p) const { return p.x%SIZE_MAX; }
	};
}
 
int main() {
	ll N, M;
	cin >> N >> M;
	vector<ll> A(M);
	REP(i, M)
		cin >> A[i];
	if (ll s = N - accumulate(ALL(A), 0); s >= 0){
		cout << s << endl;
	}
	else{
		cout << -1 << endl;
	}
	return 0;
}

Measured memory_bytes: 3680
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
#pragma GCC optimize("Ofast")
//*********************************************DO IT NOW****************************************************************
#include<bits/stdc++.h> 
#include<random>
#define int long long   
#define pp pair<int,int> 
#define ss second 
#define ff first 
#define pb push_back
#define mod 1000000007
#define pi 3.14159265359
#define mk(arr,n,type)  type *arr=new type[n];
#define sl s1.length();
#define yes cout<< "YES"<<endl
#define no  cout<< "NO"<<endl
#define all(v) (v).begin(),(v).end()
#define s(v)   sort(v,v+n)
#define  mt mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#define read(a,n) for(int i=0;i<n;i++)cin>>a[i]
#define print(a,n) for(int i=0;i<n;i++)cout<<a[i]<<" "
#define for1(i,a,n)  for(int i=0;i<n;i++)
#define rep(i, c) for(int i = 0; i < (int)c; i++)
#define set(x) cout<<fixed<<setprecision(x);
using namespace std;
//**********************************************DO IT NO****************************************************************
void fastio()
{  
  #ifndef ONLINE_JUDGE
  freopen("INPUT.txt","r",stdin);
  freopen("OUTPUT.txt","w",stdout); 
  #endif
  ios_base :: sync_with_stdio(false); 
  cin.tie(NULL) ; 
  cout.tie(NULL);
}
int dp[101][1001],ans1=1e9,dp1[1000001];
int num[10];
int a[1000000];
signed main()
{   
    fastio();
    int t=1,x1=1;
    //cin>>t;
    while(t--)
    {  
      string s;
      cin>>s;
      int count=0;
      for(int i=0;i<4;i++)
      {
          if(s[i]=='2')
          count++;
      }
      cout<<count;
    }
}
// 🍪 🍪 🍪


Measured memory_bytes: 3588
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();
		int K = sc.nextInt();
		int ak = Math.min(K, A);
		K -= ak;
		int bk = Math.min(K, B);
		K -= bk;
		int ck = K;
		System.out.println(ak - ck);
		sc.close();
	}
}

Measured memory_bytes: 35684
#include<bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define ll long long
#define se second
using namespace std;

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

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int M = 1e3;
char mmp[M][M] , s[M][M];
int h , w , k , step[M][M] , dr[4][2] = {1 , 0 , -1 , 0 , 0 , 1 , 0 , -1};
struct TnT {
    int x , y , step , flag;
};
bool vis[M][M];
void bfs(TnT sta) {
    memset(step , 0 , sizeof(step));
    step[sta.x][sta.y] = 1;
    memset(vis , false , sizeof(vis));
    vis[sta.x][sta.y] = true;
    queue<TnT>q;
    q.push(sta);
    while(!q.empty()) {
        TnT gg = q.front();
        q.pop();
        for(int i = 0 ; i < 4 ; i++) {
            TnT gl = gg;
            gl.x += dr[i][0];
            gl.y += dr[i][1];
            if(gl.x >= 0 && gl.x < h && gl.y >= 0 && gl.y < w && mmp[gl.x][gl.y] != '#' && !vis[gl.x][gl.y]) {
                gl.step++;
                step[gl.x][gl.y] = gl.step;
                vis[gl.x][gl.y] = true;
                q.push(gl);
            }
        }
    }
}
int main() {
    scanf("%d%d%d" , &h , &w , &k);
    for(int i = 0 ; i < h ; i++) {
        scanf("%s" , mmp[i]);
    }
    TnT sta;
    for(int i = 0 ; i < h ; i++) {
        for(int j = 0 ; j < w ; j++) {
            if(mmp[i][j] == 'S') {
                sta.x = i , sta.y = j;
                break;
            }
        }
    }
    sta.step = 0 , sta.flag = k;
    bfs(sta);
    int ans = 1000000000;
    for(int i = 0 ; i < h ; i++) {
        for(int j = 0 ; j < w ; j++) {
            if(step[i][j] != 0) {
                if(i == 0 || i == h - 1 || j == 0 || j == w - 1) {
                    int gg = step[i][j];
                    if(gg % k == 0) {
                        ans = min(ans , gg / k);
                    }
                    else {
                        ans = min(ans , gg / k + 1);
                    }
                }
                else {
                    int gg = step[i][j] , gl = 0;
                    if(gg % k == 0) {
                        gl = gg / k;
                    }
                    else {
                        gl = gg / k + 1;
                    }
                    gg = i;
                    if(gg % k == 0) {
                        ans = min(ans , gl + gg / k);
                    }
                    else {
                        ans = min(ans , gl + gg / k + 1);
                    }
                    gg = j;
                    if(gg % k == 0) {
                        ans = min(ans , gl + gg / k);
                    }
                    else {
                        ans = min(ans , gl + gg / k + 1);
                    }
                    gg = h - 1 - i;
                    if(gg % k == 0) {
                        ans = min(ans , gl + gg / k);
                    }
                    else {
                        ans = min(ans , gl + gg / k + 1);
                    }
                    gg = w - 1 - j;
                    if(gg % k == 0) {
                        ans = min(ans , gl + gg / k);
                    }
                    else {
                        ans = min(ans , gl + gg / k + 1);
                    }
                }
            }
        }
    }
    printf("%d\n" , ans);
    return 0;
}

Measured memory_bytes: 6912
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
        Integer input = scan.nextInt();
 
        if(input == 1) {
        	System.out.println(1);
        } else {
        	int passKindCount = passKindCountCalc(input);
        	System.out.println(passKindCount);
        }
        scan.close();
	}
	
	private static int passKindCountCalc(int passKind) {
		
		int num = passKind * passKind * passKind;
		return num;
		
	}

}


Measured memory_bytes: 21844
#include <iostream>
#include <vector>
#include <set>
#include <algorithm>
#include <string>
#include <cmath>
#include <iomanip>
#include <map>
#include <set>
#include <numeric>
using namespace std;
#define loop(i,N) for(ll (i)=0; (i)<(N);++(i))
struct _OMAZINAI_ { _OMAZINAI_() { std::ios::sync_with_stdio(false); std::cin.tie(0); } } __omazinai_instance__;
#define INF ((1LL<<61) + (1<<29))
#define YesNo(x) {std::cout << ((x)?"Yes":"No") << std::endl;}
#define YESNO(x) {std::cout << ((x)?"YES":"NO") << std::endl;}
#define OddEven(x) {std::cout << ((x)%2?"Odd":"Even") << std::endl;}
#define ODDEVEN(x) {std::cout << ((x)%2?"ODD":"EVEN") << std::endl;}
typedef long long int ll;
ll my_gcd(ll a, ll b) { return b ? my_gcd(b, a%b) : a; };
void _INPUT_IMPL_() {};
template <class T, class... Args> void _INPUT_IMPL_(T& dest, Args&... args) { cin >> dest; _INPUT_IMPL_(args...); }
void _OUTPUT_IMPL_() {};
template <class T, class... Args> void _OUTPUT_IMPL_(T dest, Args... args) { cout << dest << (sizeof...(Args) ? " " : ""); _OUTPUT_IMPL_(args...); }
#define in(type, ...) type __VA_ARGS__; _INPUT_IMPL_(__VA_ARGS__)
#define in_v(type, name, cnt) vector<type> name(cnt); loop(i, cnt) cin >> name[i];
#define sort_v(v) std::sort(v.begin(), v.end())
#define unique_v(v) v.erase(std::unique(v.begin(), v.end()), v.end()) //必ずソート後に実行
#define out(...) (_OUTPUT_IMPL_(__VA_ARGS__), std::cout<<std::endl)
#define set_fix(x) ((std::cerr<<std::fixed<<std::setprecision(x)),(std::cout<<std::fixed<<std::setprecision(x)))
//小さい方に寄る
#define space_op(x, y, a, b, c) ([](auto x_, auto y_, auto a_, auto b_, auto c_){if(x_<y_)return a_;if(x_>y_)return c_;return b_;}(x,y,a,b,c))
#define space_out(x, y, a, b, c) out(space_op(x, y, a, b, c))

// ^^^ Template ^^^ //


int main() {
	ll ans = 0;
	map<ll, ll> m;
	in(ll, N, K);
	loop(i, N) {
		in(ll, a);
		++m[a];
	}
	vector<pair<ll, ll>> mv(m.begin(), m.end());
	std::sort(mv.begin(), mv.end(), [](auto a, auto b) {
		return a.second < b.second;
	});
	loop(i, (ll)mv.size() - K)
		ans += mv[i].second;
	out(ans);
	return 0;
}


Measured memory_bytes: 15872
#include <bits/stdc++.h>
using namespace std;
int main(void){
    
    long long N,A,B;
    cin >> N >> A >> B;
    long long C = A + B;
    long long ans = A*(N/C);
    ans += min(A,N % C);
    cout << ans <<endl;
    
    
}


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

#define REP(i,b,n) for(int i=b;i<n;i++)
#define rep(i,n) REP(i,0,n)

int n;
const string mes[3] = {"lunch", "dinner", "midnight"};

void solve() {
  int hour, minu, a_minu, res[3][2], loc;
  char c;
  
  rep(i,3)
    rep(j,2)
      res[i][j] = 0;
  
  rep(i,n) {
    cin>>hour>>c>>minu>>a_minu;
    if (minu > a_minu) a_minu += 60;
    
    if (11 <= hour && hour < 15) {
      loc = 0;
    } else if (18 <= hour && hour < 21) {
      loc = 1;
    } else if (21 <= hour && hour < 24 || 0 <= hour && hour < 2) {
      loc = 2;
    } else {
      continue;
    }
    
    //cout<<hour<<":"<<minu<<mes[loc]<<endl;
    
    if (abs(a_minu - minu) <= 8)
      res[loc][0]++;
    res[loc][1]++;
  }
  
  rep(i,3) {
    cout<<mes[i]<<" ";
    if (res[i][1] == 0) {
      cout<<"no guest"<<endl;
    } else {
      double d = (double)res[i][0] / (double)res[i][1] * 100;
      cout<<(int)d<<endl;
    }
  }
}

int main (int argc, char const* argv[]) {
  while (cin>>n, n) {
    solve();
  }
  return 0;
}

Measured memory_bytes: 0