akhauriyash/Code-Regression huggingface dataset:
use std::io::*;
use std::str::FromStr;

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

fn main() {
    let n:usize = read();
    let v:Vec<usize> = (0..n).map(|_| read()).collect();
    let mut ans = 0;
    let mut pos = 0;
    loop {
        if pos == n {
            break;
        }
        let mut nondec = pos;
        let mut noninc = pos;
        while nondec < n - 1 && v[nondec] <= v[nondec + 1] {
            nondec += 1;
        }
        while noninc < n - 1 && v[noninc] >= v[noninc + 1] {
            noninc += 1;
        }
        pos = std::cmp::max(nondec, noninc) + 1;
        ans += 1;
    }
    println!("{}", ans);
}


Measured memory_bytes: 2752
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>

using namespace std;

int main(){
	string s;
	cin >> s;
	sort(s.begin(), s.end());

	if(s=="abc") {
		cout << "Yes" << endl;
	} else {
		cout << "No" << endl;
	}

	return 0;
}


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

inline int read(){
    int s=0,w=1;
    char ch=getchar();
    while(ch<'0'||ch>'9'){
        if(ch=='-')w=-1;ch=getchar();
    }
    while(ch>='0'&&ch<='9') s=s*10+ch-'0',ch=getchar();
    return s*w;
}

inline bool read(int& a){
    int s=0,w=1;
    char ch=getchar();
    if(ch==EOF){
		return false;
	}
    while(ch<'0'||ch>'9'){
        if(ch=='-')w=-1;ch=getchar();
    }
    while(ch>='0'&&ch<='9') s=s*10+ch-'0',ch=getchar();
    a=s*w;
    return true;
}

inline void write(int x){
    if(x<0) putchar('-'),x=-x;
    if(x>9) write(x/10);
    putchar(x%10+'0');
}

inline void writeln(int x){
    if(x<0) putchar('-'),x=-x;
    if(x>9) write(x/10);
    putchar(x%10+'0');
    puts("");
}

signed main(){
	int x;
	read(x);
	if(x==1)
		writeln(0);
	else
		writeln(1);
		
	return 0;
}

Measured memory_bytes: 3616
#include <iostream>
#include <math.h>//累乗計算用
#include <cstring>//配列初期化
using namespace std;

bool field[ 10 ][ 10000 ];//せんべいの初期状態
bool binary[ 10 ];//2進数カウンタ
long flag;//解答の候補
int r ,c ,ans;//r,c:入力用  ans:答え

long FlagMake( void );//解答の候補の列挙
void Count( int area );//2進数カウンタの計算

int main( void ){
    cin >> r >> c;
    while(r != 0 && c != 0){//r=0,c=0でプログラム終了
        for(long i = 0 ; i < r ; i++ ){
            for(long j = 0 ; j < c ; j++ ){
                cin >> field[ i ][ j ];
            }
        }//ここまで入力

        ans = 0;//解答の初期化
        memset(binary , 0 , sizeof( binary ) );//配列の初期化

        for(long i = 0 ; i < pow( 2 , r ) ; i++ ){
            if(i != 0){Count( 0 );}//カウンタを1進める
            FlagMake();//カウンタごとの解答の候補を検索
            if( ans < flag ) ans = flag;//出荷枚数が解答多ければ、解答更新
        }

        cout << ans << endl;//解答出力

        cin >> r >> c;//再入力
    }
}

long FlagMake(){
    int low ,high;
    
    flag = 0;
    
    for(long i = 0 ; i < c ; i++ ){
        
        low = 0; high = 0;//low:裏側,high:表側
        
        for(int j = 0 ; j < r ; j++ ){
            if( binary[ j ] == 1 ){//行が裏返されているとき
                if( field[ j ][ i ] == 0){high++; }
                else{low++; }
            }
            else{//行が裏返っていないとき
                if( field[ j ][ i ] == 0 ){low++; }
                else{high++; }
            }
        }
        if( low > high ){flag += low; }//列を裏返すかどうかの判定
        else{flag += high; }
    }
    
    return flag;//解答の候補を返す
}

void Count( int area ){
    if( binary[ area ] == 0 ){binary[ area ] = 1;}//繰り上げなしの時
    else{//繰り上げありの時
        binary[ area ] = 0;
        Count( area + 1 );
    }
}



Measured memory_bytes: 3220
#include <bits/stdc++.h>
using namespace std;
#define pi acos(-1)
#define IOS ios_base::sync_with_stdio(0); cin.tie(); cout.tie();
#define ff first
#define ss second
#define pb push_back
#define debug(val) cerr << "The Value Of " << #val << " is : " << val << '\n';
typedef long double ld;
typedef long long ll;
typedef unsigned long long ull;
const ll mod = 1e9 + 7;
const ll inf = 1e18;
const ll mininf = -922337203685477;
const ll nax = 2e5+5;
ll n, arr[nax], pref[nax];	

int main(){
	IOS
	cin >> n;
	pref[0]=0;
	for(int i=1;i<=n;i++){
		cin >> arr[i];
		pref[i]=pref[i-1]+arr[i];
	}
	ll mins=inf;
	for(int i=1;i<n;i++){
		ll ans=abs(pref[n]-2*(pref[i]));
		mins=min(mins, ans);
	}	
	cout << mins << '\n';
}


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

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

int main()
{
	vector<string> island(12);
	while (cin >> island[0]) {
		for (int i = 1; i < 12; ++i)
			cin >> island[i];

		int ans = 0;
		for (int i = 0; i < 12; ++i) {
			for (int j = 0; j < 12; ++j) {
				if (island[i][j] == '1') {
					++ans;
					queue<pair<int, int> > que;
					que.push(pair<int, int>(i, j));
					while (!que.empty()) {
						const pair<int, int> p = que.front();
						que.pop();

						island[p.first][p.second] = '0';
						for (int d = 0; d < 4; ++d) {
							pair<int, int> pp(pair<int, int>(p.first+dx[d], p.second+dy[d]));
							if (pp.first < 0 || 12 <= pp.first || pp.second < 0 || 12 <= pp.second || island[pp.first][pp.second] == '0')
								continue;
							que.push(pp);
						}
					}
				}
			}
		}
		cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 6688
import java.util.*;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        String x = "A?KIHA?BA?RA?";
        if (s.matches(x)) {
            System.out.println("YES");
            return;
        }
        System.out.println("NO");
    }
}


Measured memory_bytes: 22612
#include <algorithm>
#include <cmath>
#include <climits>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <fstream>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <cassert>
#include <functional>

using namespace std;

#define LOG(...) printf(__VA_ARGS__)
//#define LOG(...)
#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 ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define RSORT(c) sort((c).rbegin(),(c).rend())
#define CLR(a) memset((a), 0 ,sizeof(a))

typedef long long ll;
typedef unsigned long long ull;
typedef vector<bool> vb;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vb> vvb;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

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

struct UnionFind {
	vector<int> v;
	UnionFind(int n) : v(n)  { for (int i = 0; i < n; i++) v[i] = i; }
	int  find(int x)         { return v[x] == x ? x : v[x] = find(v[x]); }
	void unite(int x, int y) { v[find(x)] = find(y); }
};
int n, m, cut;
int cnt[10001];
void dfs(int sum,int loop) {
	if (loop == 0) {
		cnt[sum]++;
		return;
	}
	loop--;
	FOR(i, 1, m + 1) {
		dfs(sum + i, loop);
	}
}

int main() {
	while (cin>>n>>m>>cut,n) {
		REP(i, 10001)
			cnt[i] = 0;
		dfs(0,n);
		double ans = 0.0;
		REP(i, 10001) {
			ans += (double)max(i - cut, 1)*(double)cnt[i] / pow(m,n);
		}
		printf("%.8lf\n", ans);
	}
}

Measured memory_bytes: 3352
#include<bits/stdc++.h>
#include<unordered_set>
#include<unordered_map>
#include <algorithm> 
#include <iostream>
#include <string>
#include <cmath>
using namespace std;
#define ll long long
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define FORR(i,a,b)for(ll i=(a);i<=(b);i++)
#define repR(i,n) for(ll i=n;i>=0;i--)
#define all(v)(v).begin(),(v).end()
#define rall(v)(v).rbegin(),(v).rend()
#define F first
#define S second
#define pb push_back
#define pu push
#define COUT(x) cout<<(x)<<endl
#define PQ priority_queue<ll>
#define PQR priority_queue<ll,vector<ll>,greater<ll>>
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define mp make_pair
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define sz(x) (ll)(x).size()
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const ll MOD = 1000000007LL;
const ll INF = 1LL << 60;
using vll = vector<ll>;
using vb = vector<bool>;
using vvb = vector<vb>;
using vvll = vector<vll>;
using vstr = vector<string>;
using pll = pair<ll, ll>;
using vc = vector<char>;
using vvc = vector<vc>;
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; 
}
ll dx[4]={0,1,0,-1};
ll dy[4]={1,0,-1,0};
int main(){
  ll n,k;
  cin>>n>>k;
  set<ll> s;
  rep(i,n){
    ll d;
    cin>>d;
    rep(j,d){
      ll a;
      cin>>a;
      s.insert(a);
    }
  }
  COUT(n-sz(s));
}

Measured memory_bytes: 3632
import Data.List
import Data.Bool

main = do
    n <- read <$> getLine
    as <- map read . words <$> getLine
    let x4 = length $ filter ((==0) . (`rem` 4)) as
        x2 = subtract x4 . length $ filter ((==0) . (`rem` 2)) as
        xN = n - x4 - x2
    putStrLn . bool "No" "Yes" $ (x2 == 0 && xN <= x4+1) || (xN <= x4)


Measured memory_bytes: 36220
import heapq

N = int(input())
stones = input()

red = []
white = []
heapq.heapify(red)
heapq.heapify(white)

for i in range(N):
    if stones[i] == 'R':
        heapq.heappush(red, -i)
    else:
        heapq.heappush(white, i)

a = len(red)
b = N - a

if a == 0 or b == 0:
    print(0)
else:
    count = 0
    while True:
        biggest_red = -(heapq.heappop(red))
        smallest_white = heapq.heappop(white)
        if biggest_red > smallest_white:
            count += 1
            heapq.heappush(red, smallest_white * -1)
            heapq.heappush(white, biggest_red)
        else:
            break
    print(min(a, b, count))


Measured memory_bytes: 17436
n = int(input())
a = list(map(int,input().split()))
flg = 0
ans = 0
for i in range(1,n):
  if a[i] == a[i-1]:
    continue
  elif a[i] > a[i-1]:
    if flg == -1:
      ans += 1
      flg = 0
    else:
      flg = 1
  elif a[i] < a[i-1]:
    if flg == 1:
      ans += 1
      flg = 0
    else:
      flg = -1
print(ans+1)


Measured memory_bytes: 14224
#include "bits/stdc++.h"
#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##_len=(b);i<i##_len;++i)
#define BUGAVOID(x) x
#define rep(...) BUGAVOID(_overload3(__VA_ARGS__,repi,_rep,_rep)(__VA_ARGS__))
#define sz(c) (int)(c.size())
#define all(c) c.begin(),c.end()
#define ms(a,v) memset(a,v,sizeof(a))
#define unq(v) v.erase(unique(v.begin(),v.end()),v.end());
#define mp make_pair
#define write(x) cout<<(x)<<endl
using namespace std; typedef long long ll;
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; }
const int INF = 1 << 28; const ll LINF = 1ll << 60;
const int MAX = 1e5 + 5; const int MOD = 1e9 + 7; const double EPS = 1e-6;
const int dy[4] = { 0,1,0,-1 }; const int dx[4] = { 1,0,-1,0 };
struct aaa { aaa() { cin.tie(0); ios::sync_with_stdio(0); }; }aaaa;

int N, M, H, W, K;
int n, m, a, b, c, d, ans;
string s;

int main() {
    cin >> N >> K;

    bool b = N >= K * 2 - 1;

    write(b ? "YES" : "NO");
}

Measured memory_bytes: 256
using System;
using System.Linq;

class Program
{
    static void Main()
    {
        while(true)
        {
            var line = Console.ReadLine().Split(' ').Select(s => int.Parse(s)).ToArray();
            var m = line[0];
            var f = line[1];
            var r = line[2];
            string result = "A";
            
            if(m == -1 && f == -1 && r == -1){
                break;
            }else if((m == -1 || f == -1) || m+f < 30){
                result = "F";
            }else if(m+f >= 65 && m+f < 80){
                result = "B";
            }else if(m+f >= 50 && m+f < 65){
                result = "C";
            }else if(m+f >= 30 && m+f < 50){
                result = "D";
                if(r >= 50){
                    result = "C";
                }
            }
            
            Console.WriteLine(result);
        }
    }
}


Measured memory_bytes: 18392
#include <bits/stdc++.h>
#include <stdio.h>
using namespace std;
#define vsort(vec) sort(vec.begin(), vec.end())
#define vreverse(vec) reverse(vec.begin(), vec.end())
using ll =long long;
const ll INF =1001001001;

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

//素数判定
ll isprime(ll n){
  bool prime=true;
  for(int i=2;i<n;i++){
    if(n%i==0){
      prime=false; break;
    }
  }
if(prime){cout<<n<<" is prime"<<endl;
         }else{cout<<n<<" is not prime"<<endl;}

}
//階乗　20くらいが限界
ll factorial(ll n){
  ll a=1;ll b=n;
  for(int i=0;i<n;i++){
    a*=b;
    b--;
  }
  return a;
}

//組み合わせ　nCr
ll comb(ll a,ll b){
  ll c;
  c=factorial(a)/(factorial(a-b)*factorial(b));
  return c; 
}




/*10億7。　　　100000007
2*2行列 H*W
vector<vector<int>> vec(H,vector<int>(W));
for(int i=0;i<H;i++){
for(int j=0;j<W;j++){
cin>>vec[i][j];
  }
}

文字列→数列
string S;int A=atoi(S.c_str());
数列→文字列
int A;string S=to_string(A);
数字判定　isdigit(a)
pair宣言　pair<int,int> p(5,7);
ソート　sort(vec.begin(),vec.end());
*/


int main(){
cout<<fixed<<setprecision(10);
//cin.tie(0); ios::sync_with_stdio(false);

  
vector<int> vec(32);
  vec={1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
  ll N;
  cin>>N;
  
  cout<<vec[N-1]<<endl;
  
  
  
}




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

struct combination {
    combination(ll Nmax, ll mod) {
        (this->MOD) = mod;
        (this->Nmax) = Nmax;
        factorial.resize(Nmax + 1, 1);
        inverse_factorial.resize(Nmax + 1, 1);
        init_factorial();
    }

    ll calc(ll n, ll r) {
        if (r < 0 || r > n)
            return 0;
        ll ret = (factorial[n] * inverse_factorial[r]) % MOD;
        ret = (ret * inverse_factorial[n - r]) % MOD;
        return ret;
    }

private:
    ll MOD, Nmax;
    vector<ll> factorial;
    vector<ll> inverse_factorial;
    ll mod_pow(ll n, ll p, ll mod) {
        n %= mod;
        if (p == 0)
            return 1;
        ll res = mod_pow(n * n % mod, p / 2, mod);
        if (p % 2 == 1)
            res = res * n % mod;
        return res;
    }

    void init_factorial() {
        for (ll i = 1; i <= Nmax; i++) {
            factorial[i] = (factorial[i - 1] * i) % MOD;
        }
        inverse_factorial[Nmax] = mod_pow(factorial[Nmax], MOD - 2, MOD);
        for (ll i = Nmax - 1; i >= 1; i--) {
            inverse_factorial[i] = (inverse_factorial[i + 1] * (i + 1)) % MOD;
        }
    }
};

int main() {
    int N, K;
    cin >> N >> K;
    vector<ll> A(N);
    for (ll& a : A) {
        cin >> a;
    }
    sort(A.begin(), A.end());
    ll mod = 1e9 + 7;
    combination comb(N, mod);

    ll ans = 0;
    for (int i = 0; i + K - 1 < N; i++) {
        ans -= (A[i] * comb.calc(N - 1 - i, K - 1)) % mod;
        while (ans < 0) {
            ans += mod;
        }
        ans %= mod;
    }
    for (int i = K - 1; i < N; i++) {
        ans += A[i] * comb.calc(i, K - 1);
        ans %= mod;
    }
    cout << ans << endl;
}


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

int main(){
	long long int a,b,c,x,ans=0;
	cin>>a>>b>>c>>x;
	for(int i=0;i<=a;i++){
		for(int j=0;j<=b;j++){
			for(int k=0;k<=c;k++){
				if(x==i*500+j*100+k*50){
					ans++;
					break;
				}
			}
		}
	}
	cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

class Main {

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

        int N=stdIn.nextInt();
        int R=stdIn.nextInt();

        if(N>=10){
            System.out.println(R);
            
        }
        else{
            System.out.println(R+100*(10-N));
            
        }
        
        
    }

}

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

using namespace std;

void fast();

/*
*
* Watch out! Another Buggy Code From Muhammad_Mamdouh, Happy Coding;
*
*/

int main()
{
    fast();
    int n, k, price[1005] = { 0 };

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

    sort(price, price + n);

    int mn_price = 0;
    for (int i = 0; i < k; ++i)
        mn_price += price[i];

    cout << mn_price;

    return 0;
}

void fast()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
}

Measured memory_bytes: 3580
//Don't have to see. start------------------------------------------
var read = require('readline').createInterface({
  input: process.stdin, output: process.stdout
});
var obj; var inLine = [];
read.on('line', function(input){inLine.push(input);});
read.on('close', function(){
  obj = init(inLine);
  console.error('\n↑入力 ↓出力');
  Main();
});
function makeClone(obj){return (obj instanceof Set) ? new Set(Array.from(obj)) : JSON.parse(JSON.stringify(obj));}
function nextInt(){return myconv(next(),1);} function nextStrArray(){return myconv(next(),2);}
function nextIntArray(){return myconv(next(),4);} function nextCharArray(){return myconv(next(),6);}
function next(){return obj.next();} function hasNext(){return obj.hasNext();}
function init(input){  
  return {
    list : input, index : 0, max : input.length,
    hasNext : function(){return (this.index < this.max);},
    next : function(){if(this.hasNext()){return this.list[this.index++];}else{throw 'ArrayIndexOutOfBoundsException ‚There is no more input';}}
  };
}
function myout(s){console.log(s);}
function myerr(s){console.error('debug:' + require('util').inspect(s,false,null));}
//param "no" is
//unknown or outlier : return i. 1: parseInt.
//2: split space. 4: split space and parseInt.
//6: split 1 character. 7: split 1 character and parseInt.
//8: join space. 9: join nextline. 0: join no character.
function myconv(i,no){try{switch(no){case 1:return parseInt(i);case 2:return i.split(' ');case 4:return i.split(' ').map(Number);case 6:return i.split('');case 7:return i.split('').map(Number);case 8:return i.join(' ');case 9:return i.join('\n');case 0:return i.join('');default:return i;}}catch(e){return i;}}

//Don't have to see. end------------------------------------------
function Main(){
  var one = nextIntArray();
  var N = one[0];
  var D = one[1];
  var A = one[2];
  var list = new Array(N);
  for(var i = 0; i < N; i++){
    list[i] = nextIntArray();
  }
  list.sort(function(a,b){
    return a[0] - b[0];
  });
  var output = 0;
  var sum = 0;
  var queue = [];
  for(var i = 0; i < N; i++){
    var x = list[i][0];
    var h = list[i][1];
    while(queue.length > 0){
      var first = queue[0];
      var nx = first[0];
      if(nx < x){
        sum -= first[1];
        queue.shift();
      }else{
        break;
      }
    }
    h -= sum;
    if(h > 0){
      var attack = Math.ceil(h / A);
      output += attack;
      sum += attack * A;
      queue.push([x + D * 2, attack * A]);
    }
  }
  myout(output);
}



Measured memory_bytes: 101992
lines = $stdin.read
array = lines.split("\n")

N,M = array[0].split(" ").map(&:to_i)

# E = 1/p
# p = 1/2^M
_2m = 2**M
time = _2m * 1900*M + _2m * 100 * (N-M)

puts time

Measured memory_bytes: 1788
import sys
sys.setrecursionlimit(10**9)

N = int(input())

graph = [[] for i in range(N)]

for i in range(N - 1):
    a, b = map(int, input().split())
    graph[a - 1].append((b,i))
    graph[b - 1].append((a,i))

ans = [0] * (N - 1)


def dfs(past, now, color):
    new_color = 1
    for future, edge in graph[now - 1]:
        if future == past:
            pass
        else:
            if new_color == color:
                new_color += 1
            ans[edge] = new_color
            dfs(now, future, new_color)
            new_color += 1


dfs(-1, 1, -1)

print(max(ans))
for i in ans:
    print(i)


Measured memory_bytes: 74704
import sys
input()
r = sys.stdin.readlines()
d = {}

for i in r:
    if i[0] == 'i':
        d[i[7:]] = 0
    else:
        if i[5:] in d:
            print('yes')
        else:
            print('no')
        #print('yes' if i[5:] in d else 'no')

Measured memory_bytes: 112428
import java.util.Arrays;
import java.util.Scanner;

public class Main{

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

	Scanner scan;

	private int N,M,Q;
	private int[] state;
	private LoopList circle;

	private void mainrun() {
		scan = new Scanner(System.in);

		N = scan.nextInt();
		M = scan.nextInt();
		Q = scan.nextInt();

		state = new int[N];
		circle = new LoopList();

		Arrays.fill(state, 1);
		circle.init(N);

		for(int i = 0;i < M;i++) {
			looprun(scan.nextInt());
		}

		for(int i = 0;i < Q;i++) {
			System.out.println(state[scan.nextInt()]);
		}

		scan.close();
	}

	private void looprun(int a) {
		if(a%2 == 0) {
			circle.next(a);
		}else {
			circle.prev(a);
		}

		state[circle.delete()] = 0;
	}
}

class LoopList{

	private Data head,d,n,p,now;

	public LoopList() {
		head = new Data();

		head.next = head;
		head.prev = head;

		head.num = -1;
	}

	public Data getHead() {
		return head;
	}

	public void init(int num){
		d = new Data();
		d.num = 0;
		head.next = d;

		for(int i = 1;i < num;i++) {
			p = d;
			d = new Data();
			d.num = i;

			p.next = d;
			d.prev = p;
		}

		d.next = head.next;
		head.next.prev = d;

		now = head.next;
	}

	public void next(int n) {
		for(int i = 0;i<n;i++) {
			now = now.next;
		}
	}

	public void prev(int n) {
		for(int i = 0;i<n;i++) {
			now = now.prev;
		}
	}

	public int delete(){
		n = now.next;
		p = now.prev;

		int num = now.num;
		now = now.next;

		n.prev = p;
		p.next = n;

		return num;
	}

	class Data{
		int num;
		Data next,prev;
	}
}


Measured memory_bytes: 112952
#include <stdio.h>

typedef struct{
  char mark;
  int value;
}Card;

void BubbleSort(Card *, int );
void SelectionSort(Card *, int);
int isStable(Card *,Card *,int);

int main(){
  int n=0;
  int i=0;
  char space;
  scanf("%d%c",&n,&space);
  Card card[n];
  Card card_b[n];
  Card card_s[n];
  for(i=0;i<n;i++){
    scanf("%c%d%c",&card[i].mark,&card[i].value,&space);
    card_b[i].mark=card[i].mark;
    card_b[i].value=card[i].value;
    card_s[i].mark=card[i].mark;
    card_s[i].value=card[i].value;
  }
  
  BubbleSort(card_b,n);
  for(i=0;i<n;i++){
    if(i!=0)printf(" ");
    printf("%c%d",card_b[i].mark,card_b[i].value);
  }
  printf("\n");
  
  printf("Stable\n");
  
  SelectionSort(card_s,n);
  for(i=0;i<n;i++){
    if(i!=0)printf(" ");
    printf("%c%d",card_s[i].mark,card_s[i].value);
  }
  printf("\n");

  if(isStable(card_b,card_s,n)==-1) printf("Not stable\n");
  else printf("Stable\n");
  
  return 0;
}

void BubbleSort(Card *C, int n){
  int i=0;
  int j=0;
  Card change;
  for(i=0;i<n-1;i++)
    {
      for(j=n-1;i<j;j--)
	{
	  if(C[j].value < C[j-1].value){
	    change=C[j];
	    C[j]=C[j-1];
	    C[j-1]=change;
	  } 
	}
    }
}

void SelectionSort(Card *C, int n){
  int i=0;
  int j=0;
  int min=0;
  Card change;
  for(i=0;i<n-1;i++){
    min=i;
    for(j=i;j<n;j++){
      if(C[j].value<C[min].value)
	min=j;
    }
    change=C[i];
    C[i]=C[min];
    C[min]=change;
  }
}

int isStable(Card *B,Card *S,int n){
  int i=0;
  for(i=0;i<n;i++){
    if(B[i].mark!=S[i].mark) return -1;
  }
  return 1;
}



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

if sum(B) > sum(A):
    print(-1)
    exit()

remaining_power = []
for a, b in zip(A, B):
    if a > b:
        remaining_power.append(a-b)

remaining_power.sort(reverse=True)  # 余力が大きいものほど優先的に使う

need_power = 0
ans = 0
for a, b in zip(A, B):
    if b > a:
        ans += 1
        need_power += (b-a)

cnt = 0
while need_power > 0:
    need_power -= remaining_power[cnt]
    cnt += 1

print(ans+cnt)


Measured memory_bytes: 18292
import java.io.*;
import java.util.*;

    public class Main extends PrintWriter {
        Main() { super(System.out, true); }
        Scanner sc = new Scanner(System.in);
        public static void main(String[] $) {
            Main o = new Main(); o.main(); o.flush();
        }

        void main(){
            char C = sc.next().charAt(0);

            if(C == 'z'){
                print('z');
            }
            else{
                int u;
                u = (int) C;
                u = u+1;
                C = (char) u;
                print(C);
            }



    }
}


Measured memory_bytes: 20692
#include <iostream>
#include <cstdio>
#include <vector>
#include <string>
#include <bitset>
#include <cmath>
#include <iomanip>
#include <stack>
#include <set>
#include <queue>
#include <algorithm>
#include <deque>
#include <map>
using namespace std;

#define INF 1e18
#define int long long
#define MOD 1000000007

int factorial(int n) {
    if(n == 0) return 1;
    return n * factorial(n - 1) % MOD;
}

signed main() {
    int n, m; cin >> n >> m;

    if(abs(n - m) >= 2) {
        cout << 0 << endl;
        return 0;
    }

    if(n == m) {
        int ans = factorial(n) * factorial(m) * 2 % MOD;
        cout << ans << endl;
        return 0;
    }

    int ans =  factorial(n) * factorial(m) % MOD;
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll mod = 1e9+7;
ll inf = 1e18;
int n,q;
string s;
int a[(1<<19)][26];

void di(int pos, char aa, char bb) {
    int tmp = pos;
    int p1 = (aa - 'a');
    int p2 = (bb - 'a');
    while (tmp < (1<<19)) {
        a[tmp][p1]--;
        a[tmp][p2]++;
        tmp += -tmp & tmp;
    }
}

void insertt(int pos, char c) {
    int tmp = pos;
    int p = (c - 'a');
    while (tmp < (1<<19)) {
        a[tmp][p]++;
        tmp += -tmp & tmp;
    }
}

vector<int> gett(int k) {
    vector<int> ret(26);
    for (int i = 0; i < 26; i++) ret[i] = 0;
    int tmp = k;
    while (tmp > 0) {
        for (int i = 0; i < 26; i++) {
            ret[i] += a[tmp][i];
        }
        tmp -= -tmp & tmp;
    }
    return ret;
}

int gettt(int f, int t) {
    vector<int> aa = gett(t);
    vector<int> bb = gett(f - 1);
    // for (int i = 0; i < 26; i++) {
    //     cout << (char)('a' + i) << aa[i] << " ";
    // }
    // cout << endl;
    // for (int i = 0; i < 26; i++) {
    //     cout << (char)('a' + i) << bb[i] << " ";
    // }
    // cout << endl;
    int cnt = 0;
    for (int i = 0; i < 26; i++) {
        if (aa[i] - bb[i] != 0) cnt++; 
    }
    return cnt;
}

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cin >> n >> s >> q;
    for (int i = 0; i < n; i++) {
        insertt(i+1,s[i]);
    }
    while (q--) {
        int cmd;
        cin >> cmd;
        if (cmd == 1) {
            int pos;
            char c;
            cin >> pos >> c;
            di(pos,s[pos-1],c);
            s[pos-1] = c;
        } else {
            int frm, to;
            cin >> frm >> to;
            cout << gettt(frm,to) << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 54172
# coding:utf-8

import sys

INF = float('inf')
MOD = 10 ** 9 + 7

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x) - 1 for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def II(): return int(sys.stdin.readline())
def SI(): return input()


def main():
    n = II()
    s, t = SI(), SI()

    for i in range(n + 1)[::-1]:
        if s[n - i:] == t[:i]:
            return 2 * n - i


print(main())


Measured memory_bytes: 3064
import sys

stdin = sys.stdin
 
ni = lambda:int(ns())
na = lambda:list(map(int,stdin.readline().split()))
ns = lambda:stdin.readline().rstrip()  # ignore trailing spaces

N = ni()
AB = [na() for _ in range(N-1)]
graph = [[] for _ in range(N+1)]

for a, b in AB:
    graph[a].append(b)
    graph[b].append(a)

root = 1
parent = [0] * (N+1)
order = []
stack = [root]

while stack:
    x = stack.pop()
    order.append(x)
    for y in graph[x]:
        if y == parent[x]:
            continue
        parent[y] = x
        stack.append(y)

color = [-1] * (N+1)
for o in order:
    ng = color[o]
    c = 1
    for y in graph[o]:
        if y == parent[o]:
            continue
        if c == ng:
            c += 1
        color[y] = c
        c += 1
answer = []
append = answer.append
for a, b in AB:
    if parent[a] == b:
        append(color[a])
    else:
        append(color[b])
print(max(answer))
print('\n'.join(map(str,answer)))


Measured memory_bytes: 44712
#include <bits/stdc++.h>
#define rep(i, s, n) for (int i = s; i < n; i++)
#define rp(i,n) for (int i=0;i<n;i++)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define all_acc(x) (x).begin(), (x).end(), 0LL
#define int long long
#define absSort(v) sort(a.begin(), a.end(), [](int i, int j) -> bool { return abs(i) < abs(j); });
using namespace std;
using P = pair<int, int>;
using Graph = vector<vector<int>>;
using ll = long long;
double pi=3.14159265359;

template <class T, class U>
void chmin(T& t, const U& u) {
    if (t > u) t = u;
}
template <class T, class U>
void chmax(T& t, const U& u) {
    if (t < u) t = u;
}

//出力するよ
void output_tate(vector<int> s){
    int n = s.size();
    for (int i = 0; i < n; i++){
        //if (i != 0)
        //    cout << " ";
        cout << s[i]<<endl;
    }
    //cout << endl;
}

void output_yoko(vector<int> s){
    int n = s.size();
    for (int i = 0; i < n; i++){
        if (i != 0)
            cout << " ";
        cout << s[i];//<<endl;
    }
    cout << endl;
}


signed main() {
    int n; cin>>n;
    vector<int> a(n);
    for(int i=0;i<n;i++) cin>>a[i];

    int res=0;
    int big=a[0];

    for(int i=1;i<n;i++){
        if(a[i]<big){
            res += big-a[i];
        }
        else{
            big = a[i];
        }
    }

    cout<<res<<endl;
}


Measured memory_bytes: 4856
#include <iostream>
#include <string>
#include <vector>
#include <cassert>
#include <algorithm>
#include <math.h> 
#include <set>
#include <map>
#include <utility>
#include <deque>
#include <queue>


using namespace std;

#define ll long long int
#define rep(i, n) for(ll i = 0; i < n; i++)
#define repp(i, n) for(int i = 1; i <= n; i++)
#define sort(v) sort((v).begin(), (v).end())
#define riverse(v) reverse((v).begin(), (v).end())
#define pb push_back
#define mp make_pair
using vi = vector<int>;
using vs = vector<string>;
using vll = vector<ll>;
using vvi = vector<vi>;
const ll MOD = 1e9 + 7;
vi alphabet = { 'a','b','c','d','e','f','g','h','i','j','k','l','m',
               'n','o','p','q','r','s','t','u','v','w','x','y','z' };


int main() {
    string s;
    cin >> s;
    string ans = "None";
    for (char x : alphabet) {
        bool frag = true;
        rep(i, s.size()) {
            if (s[i] == x) frag = false;
        }
        if (frag) {
            ans = x;
            break;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 512
import java.util.Scanner;

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

		int N = sc.nextInt();

		int count = 0;
		for(int i=1; i<=N; i++) {
			if(String.valueOf(i).length()%2 != 0) {
				count++;
			}
		}

		System.out.println(count);
		sc.close();
	}
}


Measured memory_bytes: 27732
#include<cstdio>
#include<algorithm>
using namespace std;
const int N=1e5+5,M=2*N,inf=1e8;
int n,i,et,he[N],l[N],r[N];bool flag;
struct edge{int l,to;}e[M];
int read(){
	char c=getchar();int k=0;for (;c<48||c>57;c=getchar());
	for (;c>47&&c<58;c=getchar()) k=(k<<3)+(k<<1)+c-48;return k;
}
void put(int x){if (x>9) put(x/10);putchar(x%10+48);}
void write(int x){
	if (x<0) putchar('-'),x=-x;
	put(x);putchar('\n');
}
void dfs1(int x,int fa){
	for (int i=he[x];i;i=e[i].l){
		int y=e[i].to;if (y==fa) continue;
		dfs1(y,x);
		l[x]=max(l[x],l[y]-1);
		r[x]=min(r[x],r[y]+1);
	}
}
void dfs2(int x,int fa){
	for (int i=he[x];i;i=e[i].l){
		int y=e[i].to;if (y==fa) continue;
		l[y]=max(l[y],l[x]-1);
		r[y]=min(r[y],r[x]+1);
		if (l[x]==l[y]) flag=0;
		dfs2(y,x);
	}
}
int main(){
	for (n=read(),i=1;i<n;i++){
		int x=read(),y=read();
		e[++et].l=he[x];he[x]=et;e[et].to=y;
		e[++et].l=he[y];he[y]=et;e[et].to=x;
	}
	for (i=1;i<=n;i++) l[i]=-inf,r[i]=inf;
	for (i=read();i--;){
		int x=read();l[x]=r[x]=read();
	}
	dfs1(1,0);flag=1;dfs2(1,0);
	for (i=1;i<=n;i++) if (l[i]>r[i]) flag=0;
	if (!flag){puts("No");return 0;}
	for (puts("Yes"),i=1;i<=n;i++) put(r[i]),putchar('\n');
}

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

int main() {
    int A,B,C,D;
    int flag = 0;
    cin >> A >> B >> C >> D;

  for(;;){

    if(C <= 0){
        break;
		}else if(A <= 0){
		flag++;
		break;
	}
      C -= B;
      A -= D;
  }

  if(flag == 0){
      cout << "Yes";
  }else{
      cout << "No";
  }
    
}

Measured memory_bytes: 3632
#include <iostream>
#include <string>
#include <cmath>

using namespace std;

int main(){
  int n;
  int A=1,B=1;
  int c=1,d=1;
  int ans;
  cin >> n;
  int p[9];
  for (int i = 0; i < n; ++i){
      cin >> p[i];
  }
  int q[9];
  for (int i = 0; i < n; ++i){
      cin >> q[i];
  }

  int a[9];
  a[0] = 1;
  for(int i=1; i<n; i++){
    a[i] = 1;
    for(int j=0; j < i;j++){
	  if(p[j]<p[i]){
		a[i] += 1;
      }
    }
  }
  int b[9];
  b[0] =1;
  for(int i=1; i<n; i++){
    b[i] =1;
    for(int j=0; j < i;j++){
	  if(q[j]<q[i]){
		b[i] += 1;
      }
    }
  }
  for(int i=0; i<n-1;i++){
    c = 1;
	for(int j=n-i-1;j>0;j--){
	  c *= j;
    }
	A += (p[i] - a[i]) * c;
  }
  for(int i=0; i<n-1;i++){
    d = 1;
	for(int j=n-i-1;j>0;j--){
	  d *= j;
    }
	B += (q[i] - b[i]) * d;
  }
  ans = A-B;
  if(ans<0){
    ans = - ans;
  }
  cout << ans;
  }

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

#define MP make_pair
#define PB push_back
#define ALL(x)      (x).begin(),(x).end()
#define REP(i,n)    for(int i=0;i<(n);i++)
#define REP1(i,n)   for(int i=1;i<(n);i++)
#define REP2(i,d,n) for(int i=(d);i<(n);i++)
#define RREP(i,n)   for(int i=(n);i>=0;i--)
#define CLR(a)      memset((a),0,sizeof(a))
#define MCLR(a)     memset((a),-1,sizeof(a))
#define RANGE(x,y,maxX,maxY) (0 <= (x) && 0 <= (y) && (x) < (maxX) && (y) < (maxY))

typedef long long LL;
typedef unsigned long long ULL;
typedef vector<int> VI;
typedef vector<VI > VVI;
typedef vector<string> VS;
typedef vector<LL> VLL;
typedef pair<int,int> PII;

const int INF = 0x3f3f3f3f;
const LL INFL = 0x3f3f3f3f3f3f3f3fLL;
const double EPS = 1e-9;

const int DX[]={1,0,-1,0},DY[]={0,-1,0,1};


void solve(long long ABCD){
    int a = ABCD / 1000;
    int b = (ABCD / 100) % 10;
    int c = (ABCD / 10) % 10;
    int d = ABCD % 10;

    REP(i, 2) REP(j, 2) REP(k, 2) {
        int now = a;
        now += (i == 0 ? b : b * -1);
        now += (j == 0 ? c : c * -1);
        now += (k == 0 ? d : d * -1);

        if(now == 7) {
            cout << a;
            cout << (i == 0 ? "+" : "-");
            cout << b;
            cout << (j == 0 ? "+" : "-");
            cout << c;
            cout << (k == 0 ? "+" : "-");
            cout << d << "=7" << endl;

            return;
        }
    }
}

int main(){
    long long ABCD;
    scanf("%lld",&ABCD);
    solve(ABCD);
    return 0;
}


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

int main()
{
  string S;
  cin >> S;
  string ans = "Sunny";
  if (S == "Sunny")
    ans = "Cloudy";
  else if (S == "Cloudy")
    ans = "Rainy";

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 256
import std.stdio;
import std.string;
import std.conv;
import std.bigint;
import std.typecons;
import std.algorithm;
import std.array;
import std.math;
import std.range;
 
void main() {
    auto tmp = readln.split.to!(int[]);
    auto H = tmp[0], W = tmp[1];
    char[][] S;
    foreach (i; 0..H) {
        S ~= readln.chomp.dup;
    }
    foreach (i; 0..W) {
        foreach (j; 0..H) {
            if (S[j][i] == '#') continue;
            auto c = 0;
            foreach (k; -1..2) {
                if (i+k == -1) continue;
                if (i+k == W) continue;
                foreach (l; -1..2) {
                    if (j+l == -1) continue;
                    if (j+l == H) continue;
                    if (S[j+l][i+k] == '#') c++;
                }
            }
            S[j][i] = cast(char)(c + '0');
        }
    }
    foreach (i; 0..H) {
        writeln(S[i]);
    }
}


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

template <typename T> T mod_sub (T a, T b, T m);

int main() {
	uint32_t N, K;
	cin >> N >> K;
	
	vector<uint32_t> dp(K+1);
	dp[0] = 1;
	
	uint32_t tmax = 0;
	uint32_t mod = pow(10, 9) + 7;
	
	for(uint32_t i=0; i<N; i++) {
		uint32_t a;
		cin >> a;
	
		tmax = min(tmax + a, K);	
		
		uint32_t tsum = 0;
		queue<uint32_t> qdp;
		
		for(uint32_t j=0; j<=K && j<=tmax; j++) {
			tsum = (tsum + dp[j]) % mod;

			if(qdp.size() > a) {
				tsum = mod_sub(tsum, qdp.front(), mod);
				qdp.pop();
			}
			
			qdp.push(dp[j]);
			dp[j] = tsum;
		}
	}
		
	cout << dp[K];
	return 0;
}

template <typename T> T mod_sub (T a, T b, T m) {
	return (a == b) ? 0 : (a > b) ? (a - b) % m : m + a - b;
}

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

using namespace std;

#define S scanf
#define P printf
#define G getline
#define SZ size()
#define C clear()
#define B begin()
#define F front()
#define T top()
#define E end()
#define EM empty()
#define V vector
#define Q queue
#define DQ deque
#define PQ priority_queue
#define ST stack
#define FI first
#define SE second
#define PI acos(-1)
#define PS push
#define PP pop()
#define PSF push_front
#define PSB push_back
#define PPF pop_front()
#define PPB pop_back()
#define MP make_pair
#define LL long long int
#define ULL unsigned long long int
#define PII pair<int,int>
#define PSI pair<string,int>
#define PIS pair<int,string>
#define PLI pair<long long int,int>
#define PLL pair<long long int,long long int>
#define MII map<int,int>
#define MSI map<string,int>
#define MIS map<int,string>
#define MLI map<long long int,int>
#define FAST() ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)





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






int main()
{
    FAST();

//    freopen("input.txt","r",stdin);
//    freopen("input.txt","w",stdout);

    string s;
    cin >> s;
    if(s[0] == 'S')
    {
        cout << "Cloudy";
    }
    else if(s[0] == 'C')
    {
        cout << "Rainy";
    }
    else
    {
        cout << "Sunny";
    }
    return 0;
}


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

using namespace std;
typedef long long ll;

int main(void) {
    int N;
    cin >> N;

    vector<ll> H(N + 1);
    for(int i = 1; i <= N; i++) {
        cin >> H[i];
    }

    H[1]--;

    for(int i = 2; i <= N; i++) {
        if(H[i - 1] == H[i]) continue;

        if(H[i - 1] < H[i]) {
            H[i]--;
            continue;
        }

        cout << "No" << endl;
        return 0;
    }

    cout << "Yes" << endl;
    return 0;
}

Measured memory_bytes: 1024
import java.util.*;

public class Main
{

    static Scanner sc = new Scanner(System.in);
    static int dp[][][];
    static int edges[][];
    static boolean del[][];
    public static void main(String[] args) {
        int n = sc.nextInt();

        edges = new int[n][n];
        del = new boolean[n][n];
        long total = 0;
        for (int i = 0; i < n; i++) {
            for (int j = 0; j < n; j++) {
                edges[i][j] = sc.nextInt();
                total += edges[i][j];
            }
        }
        dp = new int[n][n][n];
        for (int i = 0; i < n; i++) {
            for (int j = 0; j < n; j++) {
                dp[i][j][0] = edges[i][j];
            }
        }
        for (int k = 1; k < n; k++) {
            for (int i = 0; i < n; i++) {
                for (int j = 0; j < n; j++) {
                    dp[i][j][k] = Math.min(dp[i][j][k-1], dp[i][k][k-1] + dp[k][j][k-1]);
                }
            }
        }
        for (int i = 0; i < n; i++) {
            for (int j = 0; j < n; j++) {
                if (i != j && dp[i][j][n-1] != edges[i][j]){
                    System.out.println(-1);
                    return;
                }
            }
        }
        for (int k = 0; k < n; k++) {
            for (int i = 0; i < n; i++) {
                for (int j = 0; j < n; j++) {
                    if (i!=j&& j!=k && i !=k &&edges[i][j] == edges[i][k] + edges[k][j] && !del[i][j]) {
                        total -= edges[i][j];
                        del[i][j] = true;
                    }
                }
            }
        }

        total /= 2;
        System.out.println(total);
    }
}

Measured memory_bytes: 218596
function main()
  RR,GG,BB,N=map(x->parse(Int,x),split(readline()))
  num=[RR,GG,BB]
  R=maximum(num)
  B=minimum(num)
  G=RR+GG+BB-R-B
  ans=0
  if R==G && G==B && N%R==0
    temp=N/R
    ans=Int(floor((temp+1)*(temp+2)/2))
  elseif R==G || G==B
    for rr=N:-R:0
      if rr%B==0
        ans+=Int(rr/B)+1
      end
    end
  else
    for rr=N:-R:0,rg=rr:-G:0
      ans+=rg%B==0
    end
  end
  println(ans)
end
main()


Measured memory_bytes: 117636
#include<bits/stdc++.h>
typedef long long ll;
using namespace std;
#define fastIO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define what_is(x) cerr << #x << " = " << x << endl;
bool pr[1000009];
void sieve ()
{
    pr[0]=1; pr[1]=1;
    for (int i=2; i<=1000000; ++i)
    {
        if (pr[i]==0)
        {
            for (int j=i*2; j<=1000000; j+=i)
            {
                pr[j]=1;
            }
        }
    }
}
int divv[1000009];
int main()
{
    fastIO
    for (int i=1; i<=1000000; ++i)
    {
        for (int j=i; j<=1000000; j+=i)
        {
            divv[j]++;
        }
    }

    int n;
    cin>>n;
    int ans=0;
    for (int i=n-1; i>=1; --i)
    {
        ans+=divv[i];

    }
    cout<<ans;
}


Measured memory_bytes: 7548
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define mp make_pair
#define F first
#define S second


int main()
{
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n;
    cin>>n;
    ll a[n];
    for(int i=0;i<n;i++)
    {
    	cin>>a[i];
    }
    sort(a,a+n);
    ll ans = 0;
    for(int i=0;i<n;i++)
    {
    	for(int j=0;j<i;j++)
    	{
    		for(int k=0;k<j;k++)
    		{
    			if(a[i] != a[j] && a[j] != a[k] && a[k] != a[i] && a[j]+a[k] > a[i])
    			{
    				ans++;
    			}
    		}
    	}
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 3656
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define INF 100000000000


int main(){
    int n, m;
    cin >> n >> m;
    int k[11];
    vector <int> p(m);
    vector<vector<int>> S(m);
    for(int i = 0; i < m; ++i){
        cin >> k[i];
        S[i].resize(k[i]);
        vector<int> tmp(k[i]);
        for(int j = 0; j < k[i]; j++){
            cin >> tmp[j];
            --tmp[j];
        }
        S[i] = tmp;
    }
    for(int i = 0; i < m; ++i) cin >> p[i];

    int ans = 0;
    for (int bit = 0; bit < (1<<n); ++bit){
        bool ok = true;
        for(int j = 0; j < m; j++){
            int cnt = 0;
            for(int sw : S[j]){
                if(bit & (1 << sw)) cnt++;
            }
            cnt = cnt & 1;
            if(cnt != p[j]) ok = false;
        }
        if(ok) ans++;
    }
    cout << ans << endl;
    return 0;
}

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

namespace ConsoleApplication1
{
    struct Food
    {
        internal string name;
        internal int id, wt, cap;

        public override string ToString()
        {
            return name;
        }
    }

    class Program
    {
        static void Main(string[] args)
        {
            StringBuilder sb = new StringBuilder();

            while (true)
            {
                int n = int.Parse(Console.ReadLine());

                if (n == 0) break;

                Food[] foods = new Food[n];
                Food temp;

                for (int i = 0; i < n; i++)
                {
                    string[] input = Console.ReadLine().Split(' ');
                    temp.name = input[0];
                    temp.id = i;
                    temp.wt = int.Parse(input[1]);
                    temp.cap = int.Parse(input[2]);
                    foods[i] = temp;
                }

                var sumW = foods.Sum(f => f.wt);
                bool[] used = new bool[n];

                for (int i = 0; i < n; i++)
                {
                    List<Food> candidate = new List<Food>();

                    for (int j = 0; j < n; j++)
                    {
                        if (used[foods[j].id] || foods[j].cap < sumW - foods[j].wt) continue;
                        candidate.Add(foods[j]);
                    }
                    candidate.Sort((a, b) => b.wt - a.wt);
                    sb.AppendLine(candidate[0].ToString());
                    sumW -= candidate[0].wt;
                    used[candidate[0].id] = true;
                }
            }
            Console.Write(sb);
        }
    }
}

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

int main() {
	double_t n, k;
	cin >> n >> k;
	cout << fixed << setprecision(15);
	double_t ans = 0;
	for (double_t i = 1; i <= n; i++) {
		if (k <= i)ans += 1.0 / n;
		else {
			int x = ceil(log2(k / i));
			ans += pow(0.5, x) / n;
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
using namespace std;
 
int main() {
    ll k;
    cin >> k;
 
    ll n=7;
    vector<bool> r(k);
    for (ll i=1; i<=k; ++i) 
    {
        ll m = n % k;
        if (m == 0) 
        {
            cout << i << endl;
            return 0;
        }
        if (r.at(m))
            break;
        r.at(m) = true;
        n = n*10+7;
        n %= k;
    }
    
    cout << -1 << endl;
    return 0;
}

Measured memory_bytes: 3684
#ifdef _MSC_VER
#define _CRT_SECURE_NO_WARNINGS
#  include <intrin.h>
#  define __builtin_popcount __popcnt
#endif

#define _USE_MATH_DEFINES

#include <stdio.h>
#include <iostream>
#include <vector>
#include <unordered_map>
#include <stack>
#include <list>
#include <math.h>
#include <map>
#include <iomanip>
#include <functional>
#include <string>
#include <algorithm>
#include <queue>
#include <set>

using namespace std;

template<class T> ostream& operator<<(ostream& os, const vector<T>& v) {
	for (auto i = begin(v); i != end(v); i++) os << *i << (i == end(v) - 1 ? "" : " "); return os;
}
template<class T> istream& operator>>(istream& is, vector<T>& v) {
	for (auto i = begin(v); i != end(v); i++) is >> *i; return is;
}

#define MOD 1000000007



int main() {

#if defined(_DEBUG) 
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif

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

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

	int total = 0;
	for (int j : vec)
		total += j;

	if (total % 10 != 0)
	{
		cout << total;
		return 0;
	}
	sort(vec.begin(), vec.end());
	for (int i = 0; i < vec.size(); i++)
	{
		if (vec[i] % 10 != 0)
		{
			cout << total - vec[i];
			return 0;
		}
	}

	cout << 0;

	return 0;
}


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

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

    ll a[100005];
    ll n;
    cin>>n;
    for(ll i=0; i<n; i++){
        cin>>a[i];
        if(a[i]==0){
            cout<<"0\n";
            return 0;
        }
    }  
    ll ans = 1;
    for(ll i=0; i<n; i++){
        if(a[i] > 1000000000000000000/ans){
            cout<<"-1\n";
            return 0;
            
        }
        else{
            ans *= a[i];
        }
    }
    cout<<ans<<"\n";

    return 0;
}

Measured memory_bytes: 4420