akhauriyash/Code-Regression huggingface dataset:
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int, int> pi;
#define debug(x) cerr << #x << ": " << x << endl;
#define debug2(x, y) debug(x) debug(y);
#define repn(i, a, b) for(int i = (int)(a); i < (int)(b); i++)
#define rep(i, a) for(int i = 0; i < (int)(a); i++)
#define all(v) v.begin(), v.end() 
#define mp make_pair
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define fi first
#define se second
#define sq(x) ((x) * (x))

template<class T> T gcd(T a, T b){ return ((b == 0) ? a : gcd(b, a % b)); }

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	//freopen("input.in", "r", stdin);
	//freopen("output.out", "w", stdout);
	int h, w, K;
	cin >> h >> w >> K;
	vector<string> s(h);
	rep(i, h) cin >> s[i];
	int ans = 0;
	rep(i, 1 << h) rep(j, 1 << w){
		vector<string> s1 = s;
		rep(k, h) if(i & (1 << k)) rep(l, w) s1[k][l] = 'R';		
		rep(l, w) if(j & (1 << l)) rep(k, h) s1[k][l] = 'R';		
		int num = 0;
		rep(k, h) rep(l, w) if(s1[k][l] == '#') num++;
		if(num == K) ans++;
	}
	cout << ans << endl;
	return 0;
}
/*
Things to look out for:
	- Integer overflows
	- Array bounds
	- Special cases
Be careful!
*/


Measured memory_bytes: 3644
#include<stdio.h>
#include<algorithm>
using namespace std;
struct  mund{
	int s,e;
}a[200100];
bool cmp(mund a,mund b)
{
 return a.s<b.s;	
}
int main()
{
	int n,m,i,j,g=0;
	scanf("%d",&n);
	for(i=0;i<n;i++)
	scanf("%d %d",&a[i].e,&a[i].s);
	sort(a,a+n,cmp);
	int sum=0;
	for(i=0;i<n;i++)
		{
			sum=sum+a[i].e;
			if(sum>a[i].s)
			{
				g=1;
				break;
			}
		}
	if(g==1) printf("No");
	else printf("Yes");
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int (i)=0;(i)<(n);i++)
#define INF 1001001001
#define LLINF 1001001001001001001
#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; }
#define ALL(v) v.begin(), v.end()
typedef long long ll;


int main(){

int d,g;
cin >> d >> g;


for(int i=1;i<4;i++){
    if(d!=i and g!=i)cout << i << endl;
}

return 0;
}


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

int main()
{
	int ans[5];
	cin>>ans[0]>>ans[1]>>ans[2]>>ans[3]>>ans[4];
	for(int i=0;i<5;i++)
	{
		for(int j=4;j>i;j--)
		{
			if(ans[j]>ans[j-1])
			{
				int tmp=ans[j];
				ans[j]=ans[j-1];
				ans[j-1]=tmp;
			}
		}
	}
	for(int i=0;i<5;i++)
	{
		if(i!=0) cout<<" ";
		cout<<ans[i];
	}
	cout<<endl;
	return 0;
}

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

#define NREP() for(ll i = 0; i < n; i++)
#define REP(i, n) for(ll i = 0; i < n; i++)
#define ALL(x) (x).begin(), (x).end()
#define MSG(x) cout << x << endl;
#define IPT(x) ll t; cin >> t; x.push_back(t);
#define YN(x) x ? cout << "YES" << endl : cout << "NO" << endl;
#define Yn(x) x ? cout << "Yes" << endl : cout << "No" << endl;
#define yn(x) x ? cout << "yes" << endl : cout << "no" << endl;

using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef vector<string> vs;
typedef vector<string> vvs;

const static ll MOD = 1e9 + 7;

int main(int argc, char *argv[]) {
    ll n;
    string s;
    cin >> n >> s;
    
    REP(i, s.length()) {
        if (int(s.at(i)) + n <= int('Z')) cout << (char) (int(s.at(i)) + n);
        else cout << (char) (int(s.at(i)) + n - (int('Z') - int('A') + 1));
    }
    cout << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//#include <boost/multiprecision/cpp_int.hpp>
//typedef boost::multiprecision::cpp_int ll;
typedef long double dd;
#define i_7 (ll)(1E9+7)
//#define i_7 998244353
#define i_5 i_7-2
ll mod(ll a){
    ll c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
typedef pair<ll,ll> l_l;
ll inf=(ll)1E16;
#define rep(i,l,r) for(ll i=l;i<=r;i++)
#define pb push_back
ll max(ll a,ll b){if(a<b)return b;else return a;}
ll min(ll a,ll b){if(a>b)return b;else return a;}
void Max(ll &pos,ll val){pos=max(pos,val);}//Max(dp[n],dp[n-1]);
void Min(ll &pos,ll val){pos=min(pos,val);}
void Add(ll &pos,ll val){pos=mod(pos+val);}
dd EPS=1E-9;
#define fastio ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
///////////////////////////


int main(){
    char s;cin>>s;
    string t="qwertyuiopasdfghjklzxcvbnm";
    sort(t.begin(),t.end());
    /*
     cout<<t.size()<<endl;
    cout<<t<<endl;*/
    
    rep(i,0,t.size()-1){
        if(s==t[i]){
            cout<<t[(i+1)]<<endl;
        }
    }
    
    return 0;
}


Measured memory_bytes: 256
import java.util.*;
public class Main{
	public static void main(String[] args){
		Scanner sc=new Scanner(System.in);
		int a=sc.nextInt();
		double[] x=new double[a];
		double[] y=new double[a];
		double aa=1;
		for(int i=0; i<a; i++){
			x[i]=sc.nextDouble();
			y[i]=sc.nextDouble();
			aa*=i+1;
		}
		double k=(aa/a)*2;
		double sum=0;
		for(int i=0; i<a; i++){
			for(int j=i+1; j<a; j++){
				sum+=k*Math.sqrt((x[i]-x[j])*(x[i]-x[j])+(y[i]-y[j])*(y[i]-y[j]));
			}
		}
		System.out.println(sum/aa);
	}
}


Measured memory_bytes: 23252
N = int(input())
arr = list(map(int, input().split()))
ans_list = [0] * (N)
ans = []
for i in range(N):
    summ = 0
    j = N - i
    while j < N:
        j = j + N - i
        if j - 1 < N:
            summ += ans_list[j-1]
    if (summ % 2) != arr[N - i - 1]:
        ans_list[N - i - 1] = 1
        ans.append(N - i)

ans.sort()
print(len(ans))
for i in range(len(ans)):
    if i == len(ans)-1:
        print(ans[i])
    else:
        print(ans[i],'', end="")







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

int main(){
  int64_t X,K,D;
  cin>>X>>K>>D;
  X=abs(X);
  if(X/D>K){
    cout<<X-D*K<<endl;
  }
  else{
    int64_t A=K-X/D;
    if(A%2==0){
      cout<<X-D*(X/D)<<endl;
    }
    else{
      cout<<D*(X/D)+D-X<<endl;
    }
  }
}

Measured memory_bytes: 3632
#include<iostream>
#include<vector>
#include<algorithm>
#include<utility>
#include<string>
#include<cmath>
#include<cstring>
#include<queue>
#include<map>
#include<climits>
#include<set>

#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)
using namespace std;
typedef pair<int, int> pii;
typedef long long int ll;
typedef pair<ll,ll> pll;
int dx[4] = {1,0,0,-1};
int dy[4] = {0,1,-1,0};
#define MOD 1000000007
#define ARRAY_MAX 100005

const ll INF = 1LL << 60;

ll calc(ll b,ll n){

    if(n < b){
        return n;
    }else{
        return calc(b,n/b) + n % b;
    }
}

int main(){

    ll n,s;
    cin >> n >> s;

    if(n < s){
        cout << "-1" << endl;
        return 0;
    }
    if(n == s){
        cout << s+1 << endl;
        return 0;
    }
    ll mini = INF;

    for(ll i = 2;i*i <= n;i++){
        if(calc(i,n) == s){
            mini = min(mini,i);
        }
    }

    if(mini != INF){
        cout << mini << endl;
        return 0;
    }
    //ここからは2 <= b <= sqrt(n)までに解がなかった場合

    for(ll p = 1;p*p < n;p++){

        ll b = (n-s)/p+1;
        if(b == 1){
            //1進数は無視
            //この場合は計算が終わらないので飛ばす
            continue;

        }
        if(calc(b,n) == s){
            mini = min(mini,b);
        }
    }

    if(mini != INF){
        cout << mini << endl;
    }else{
        cout << "-1" << endl;
    }



    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<map>
#include<cstring>
#include<math.h>
#include<bitset>
#include<queue>
#include<set>
#include<iomanip>
#include<math.h>
#include<assert.h>
#include<string>
#include<cstdlib>
#include<cctype>
#include<unordered_map>
#include<sstream>
#include<numeric>
// #include<bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int,int>;
constexpr ll INF = 1LL<<60;
const double INFD = 1e100;
const ll mod = 1000000007;
const double PI = 3.1415926535897932384626433832795028841971;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
};
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
};

// intやllをstringに変換
template<typename T> inline string toString(const T &a){
  ostringstream oss;
  oss << a;
  return oss.str();
};
// ----------------------------------------------------------------------------
int main(){
  int n,d,x;
  cin >> n >> d >> x;
  vector<vector<int>> p(d, vector<int> (n));
  for(int i=0; i<d; i++){
    for(int j=0; j<n; j++){
      cin >> p[i][j];
    }
  }
  for(int i=0; i<d-1; i++){
    vector<int> dp(x+1,0);
    iota(dp.begin(),dp.end(),0);
    for(int j=0; j<=x; j++){
      for(int k=0; k<n; k++){
        int now = j + p[i][k];
        if(now > x) continue;
        dp[now] = max(dp[now],dp[j] + p[i+1][k]);
      }
    }
    x = *max_element(dp.begin(),dp.end());
  }
  cout << x << endl;
  return 0;
}



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

using namespace std;

#define SZ(x) (int)(x.size())

using ll = long long;
using ld = long double;
using P = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
const double eps = 1e-10;
const int MOD = 1000000007;
const int INF = 1000000000;
const ll LINF = 1ll<<50;

template<typename T>
void printv(const vector<T>& s) {
  for(int i=0;i<(int)(s.size());++i) {
    cout << s[i];
    if(i == (int)(s.size())-1) cout << endl;
    else cout << " ";
  }
}

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

  string s, t; cin >> s  >> t;
  cout << t << s << endl;

}


Measured memory_bytes: 764
#include<stdio.h>
int main(void)
{
	int e,y;
	scanf("%d %d",&e,&y);
	if(e==1){
		e=1867+y;
		printf("%d\n",e);
	}
	else if(e==2){
		e=1911+y;
		printf("%d\n",e);
	}
	else if(e==3){
		e=1925+y;
		printf("%d\n",e);
	}
	else if(e==4){
		e=1988+y;
		printf("%d\n",e);
	}
	if(y>=1868&&y<=1911){
		y=y-1867;
		printf("M%d\n",y);
	}
	else if(y>=1912&&y<=1925){
		y=y-1911;
		printf("T%d\n",y);
	}
	else if(y>=1926&&y<=1988){
		y=y-1925;
		printf("S%d\n",y);
	}
	else if(y>=1989){
		y=y-1988;
		printf("H%d\n",y);
	}
	return 0;
}


Measured memory_bytes: 2124
x,y,a,b,c = [int(c) for c in input().split()]
ps = [int(c) for c in input().split()]
qs = [int(c) for c in input().split()]
rs = [int(c) for c in input().split()]

ps.sort(reverse=True)
qs.sort(reverse=True)
rs.sort(reverse=True)

pind = x-1
qind = y-1
rind = 0
for i in range(c+1):
    p = ps[pind]
    q = qs[qind]
    r = rs[rind]
    if min(p,q)>= r:
        break
    if p <= q:
        ps[pind] = r
        pind -= 1
    else:
        qs[qind] = r
        qind -= 1
    rind += 1
    if rind >= c:
        break
    pind = max(pind,0)
    qind = max(qind,0)
print(sum(ps[:x]) + sum(qs[:y]))

Measured memory_bytes: 104548
#include <iostream>
#include <string>
#include <vector>
#include <map>

using ll = long long;

int main() {
    std::string S;
    std::cin >> S;
    ll K;
    std::cin >> K;

    for (int i = 0; i < S.length(); i++) {
        if (S[i] != '1' || (i + 1) == K) {
            std::cout << S[i] << std::endl;
            return 0;
        }
    }

    return 0;
}

Measured memory_bytes: 256
from collections import defaultdict
def readInt():
  return int(input())
def readInts():
  return list(map(int, input().split()))
def readChar():
  return input()
def readChars():
  return input().split()

n = readInt()
a = readInts()

ans = 0
for i in a:
  ans+=i-1
print(ans)

Measured memory_bytes: 9512
#include <iostream>
#include <string>
#include <vector>

int main() {
  std::string str;
  std::cin >> str;
  int n = str.size();
  long long sum = 0;
  for (int s = 0; s < (1 << (n - 1)); ++s) {
    long long num = str[0] - '0';
    for (int i = 0;i < n; ++i) {
      if ((s >> i) % 2 == 0) {
	sum += num;
	num = 0;
      }
      num = 10 * num + (str[i + 1] - '0');
    }
  }
  std::cout << sum << std::endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define rep(i,a,b) for(ll i=a;i<b;i++)
#define rrep(i,a,b) for(ll i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()

int main(void){
    ll n, m;
    cin >> n >> m;

    if(n == m){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    return 0;
}


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

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
const ull mod = 1e9 + 7;
#define REP(i,n) for(int i=0;i<(int)n;++i)

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

template < typename T >
void vprint(T &v){
	REP(i, v.size()){
		cout << v[i] << " ";
	}
	cout << endl;
}

int main(){
	ll N;
	cin >> N;
	vector<ll> a(N), b(N), c(N);
	REP(i, N) cin >> a[i] >> b[i] >> c[i];

	ll dp[3][101010];
	REP(i, 3)REP(j, 101010) dp[i][j] = 0;
	REP(i, N){
		dp[0][i+1] = max(dp[1][i], dp[2][i]) + a[i];
		dp[1][i+1] = max(dp[2][i], dp[0][i]) + b[i];
		dp[2][i+1] = max(dp[0][i], dp[1][i]) + c[i];
	}
	ll res = -1;
	REP(i, 3) res = max(res, dp[i][N]);
	cout << res << endl;
    return 0;
}

Measured memory_bytes: 4992
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 d = sc.nextInt();

		if(a>=b) {
			a=b;
		}

		if(c>=d){
			c=d;
		}

		System.out.println(a+c);
	}
}




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

int main() {
  int a,b,c,d;
  cin >> a >> b >> c >> d;
  if(a > c){
    swap(a,c);
    swap(b,d);
  }
  if(a <= b && b <= c){
    cout << 0 << endl;
  }else if(a <= c && c <= b && b <= d){
    cout << b - c << endl;
  }else if(a <= c && c <= d && d <= b){
    cout << d - c << endl;
  }
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
void Say(bool say, string a = "Yes", string b = "No"){cout << (say ? a : b) << endl;};

int main(){

    ll a, b;
    cin >> a >> b;
    cout << max(a+b, max(a-b, a*b)) << endl;

    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main( void )
{
	int a, b;
	char op;
	
	while( 1 ){
		scanf( "%d %c %d", &a, &op, &b );
		if( op == '?' ){
			break;
		}else if( op == '+' ){
			printf( "%d\n", a + b );
		}else if( op == '-' ){
			printf( "%d\n", a - b );
		}else if( op == '*' ){
			printf( "%d\n", a * b );
		}else if( op == '/' ){
			printf( "%d\n", a / b );
		}
	}
	
	return 0;
}

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

int main() {
	long int n,i;
	cin>>n;
	long int a[n];
	for(i=0;i<n;i++)
	  cin>>a[i];
    sort(a,a+n);
	long int re=upper_bound(a,a+n,((a[n-1]+1)/2))-a;
	if(re==0)
	  {
	  	cout<<a[n-1]<<" "<<a[re]<<"\n";
	  }
	else
	  {		cout<<a[n-1]<<" ";
		//cout<<a[re]<<" "<<a[re-1]<<" "<<abs((a[n-1]+1)/2)<<' ';
	  	   if(abs((a[n-1]+1)/2-a[re]) < abs((a[n-1]+1)/2-a[re-1]))
	  	     {
	  	     	cout<<a[re];
	  	     }
	  	   else
	  	     {
	  	     	cout<<a[re-1];
	  	     }
	  	   cout<<'\n';  
	  }
	  
	// your code goes here
	return 0;
}

Measured memory_bytes: 1024
/**
 * @brief  : c++ code for AtCoder
 * @author : rk222
 * @created: 2019.09.09 16:57:07
 */

#include <algorithm>
#include <cmath>
#include <cstdio>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int, int> P;
typedef pair<int, P> P1;

#define fr first
#define sc second
#define mp make_pair
#define pb push_back
#define rep(i, x) for (ll i = 0; i < x; i++)
#define rep1(i, x) for (ll i = 1; i <= x; i++)
#define rrep(i, x) for (ll i = x - 1; i >= 0; i--)
#define rrep1(i, x) for (ll i = x; i > 0; i--)
#define sor(v) sort(v.begin(), v.end())
#define rev(s) reverse(s.begin(), s.end())
#define lb(vec, a) lower_bound(vec.begin(), vec.end(), a)
#define ub(vec, a) upper_bound(vec.begin(), vec.end(), a)
#define uniq(vec) vec.erase(unique(vec.begin(), vec.end()), vec.end())
#define mp1(a, b, c) P1(a, P(b, c))

#define disp(x) cout << #x << ": " << x << endl
#define disp_vec(v)                                                                           \
    cout << #v << ":";                                                                        \
    rep(i, v.size()) cout << " " << v[i];                                                     \
    cout << endl

const int INF = 100000000;
const ll M = 1000000007;
const int dir_4[4][2] = {{1, 0}, {0, 1}, {-1, 0}, {0, -1}};
const int dir_8[8][2] = {{1, 0}, {1, 1}, {0, 1}, {-1, 1}, {-1, 0}, {-1, -1}, {0, -1}, {1, -1}};

/* ------------------------------------- */

string s;
ll sl;
ll dp[100010][15];

int ctoi(char c) {
    int ret = c - '0';
    if (0 <= ret && ret < 10) {
        return ret;
    } else {
        return -1;
    }
}

int main() {
    cin >> s;
    sl = s.size();

    dp[0][0] = 1;
    rep(i, sl) {
        int c = ctoi(s[i]);
        if (c == -1) {
            rep(k, 10) {
                rep(j, 13) {
                    int r = (j * 10 + k) % 13;
                    dp[i + 1][r] += dp[i][j];
                    dp[i + 1][r] = dp[i + 1][r] % M;
                }
            }
        } else {
            rep(j, 13) {
                int r = (j * 10 + c) % 13;
                dp[i + 1][r] = dp[i][j];
            }
        }
    }

    printf("%lld\n", dp[sl][5]);

    /* --------------------------------- */
    return 0;
}

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

int main(){
  int r,g,b;
  cin >> r >> g >> b;
  if((100*r+10*g+b)%4 == 0) cout << "YES" << endl;
  else cout << "NO" << endl;
  return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<cctype>
#include<cstdlib>
using namespace std;
int main(){
    char str[1000]={0};
    scanf("%[^\n]",str);
    for(int i = 0;str[i] != 0; i++){
        if(str[i] == 'a'&&str[i+1] == 'p'&&str[i+2] == 'p'&&str[i+3] == 'l'&&str[i+4] == 'e'){
            str[i] = 'p';
            str[i+1] = 'e';
            str[i+2] = 'a';
            str[i+3] = 'c';
            str[i+4] = 'h';
        }
        else if(str[i] == 'p'&&str[i+1] == 'e'&&str[i+2] == 'a'&&str[i+3] == 'c'&&str[i+4] == 'h'){
            str[i] = 'a';
            str[i+1] = 'p';
            str[i+2] = 'p';
            str[i+3] = 'l';
            str[i+4] = 'e';
        }
    }
    printf("%s\n",str);
}

Measured memory_bytes: 944
#include <iostream>
#include <tuple>
#include <sstream>
#include <vector>
#include <cmath>
#include <ctime>
#include <bitset>
#include <cassert>
#include <cstdio>
#include <queue>
#include <set>
#include <map>
#include <fstream>
#include <cstdlib>
#include <string>
#include <cstring>
#include <algorithm>
#include <numeric>

#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define ford(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)

using namespace std;

typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vpi;
typedef vector<vi> vvi;
typedef long long i64;
typedef vector<i64> vi64;
typedef vector<vi64> vvi64;
typedef pair<i64, i64> pi64;
typedef double ld;

template<class T> bool uin(T &a, T b) { return a > b ? (a = b, true) : false; }
template<class T> bool uax(T &a, T b) { return a < b ? (a = b, true) : false; }

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.precision(10);
    cout << fixed;
#ifdef LOCAL_DEFINE
    freopen("input.txt", "rt", stdin);
#endif

    i64 a, b, c;
    cin >> a >> b >> c;
    if (a % 2 == 0 && a == b && a == c) {
        cout << -1 << '\n';
        return 0;
    }

    int ans = 0;
    while (a % 2 == 0 && b % 2 == 0 && c % 2 == 0) {
        i64 na = (b + c) / 2, nb = (a + c) / 2, nc = (a + b) / 2;
        a = na; b = nb; c = nc;
        ++ans;
    }
    cout << ans << '\n';

#ifdef LOCAL_DEFINE
    cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;
public class Main{
 
	public static void main(String[] args) {
      int max = 0;
      int a = 0;
		Scanner sc = new Scanner(System.in);
		
		int n = sc.nextInt();
      for(int i = 0;i<=n;i++){
        if(i==n){
          System.out.println("Yes");
          break;
        }
        
        a=sc.nextInt();
        if(max<a)
          max=a-1;
        else if(max==a)
          max=a;
        else{
          System.out.println("No");
          break;
        }
      }
 
      
      
 
 
 
		
		
	}
 
}

Measured memory_bytes: 48464
n,m,c = map(int,input().split())
b = [int(i) for i in input().split()]
flag = 0
for i in range(n):#行
    a = [int(j) for j in input().split()]
    sigma = 0
    for j in range(m):#列
        sigma = sigma + a[j]*b[j]
    sigma = sigma + c
    if sigma > 0:
        flag = flag + 1
print(flag)


Measured memory_bytes: 3060
# coding: utf-8
# Your code here!
N,M=map(int,input().split())

ball=[1]*N
red=[1]+[0]*N

for _ in range(M):
    x,y=map(int,input().split())
    ball[y-1]+=1
    if red[x-1]==1:
        red[y-1]=1
    ball[x-1]-=1
    if ball[x-1]==0:
        red[x-1]=0

print(sum(red))
    


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

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

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

                if (n == 0) break;

                int count = 0;

                while (n != 1)
                {
                    n = n % 2 == 0 ? n / 2 : n * 3 + 1;
                    count++;
                }
                sb.AppendLine(count.ToString());
            }
            Console.Write(sb);
        }
    }
}

Measured memory_bytes: 9212
#include <iostream>                                                                              
#include <string>                                                                                
                                                                                                 
using namespace std;                                                                             
                                                                                                 
int main (void) {                                                                                
  int n;                                                                                         
  string tcard, hcard;                                                                           
  int tpoint=0, hpoint=0;                                                                        
  cin >> n;                                                                                      
  for (int i=0; i<n; i++) {                                                                      
    cin >> tcard >> hcard;                                                                       
    if (tcard == hcard) {                                                                        
      tpoint++;                                                                                  
      hpoint++;                                                                                  
    } else if (tcard > hcard) {                                                                  
      tpoint += 3;                                                                               
    } else {                                                                                     
      hpoint += 3;                                                                               
    }                                                                                            
  }                                                                                              
  cout << tpoint << " " << hpoint << endl;                                                       
}                                                                                                
                             

Measured memory_bytes: 3128
#include<stdio.h>
#include<algorithm>
#include<iostream>
using namespace std;
#define LEN 100005

typedef struct pp{
	char name[100];
	int t;
}P;

P Q[LEN];
int head, n, tail, total;

void encueue(P x){
	Q[tail] = x;
	tail = (tail + 1) % LEN;
}

P decueue(){
	P x = Q[head];
	head = (head + 1) % LEN;
	return x;
}

int roundrobin(int rest, int q){
	if (rest > q){
		total += q;
		rest -= q;
	}
	else{
		total += rest;
		rest = 0;
	}
	return rest;
}

int main(){
	P u;
	int q;
	scanf("%d %d", &n, &q);
	for (int i = 1; i <= n; i++){
		scanf("%s %d", Q[i].name, &Q[i].t);
	}
	head = 1;
	tail = n + 1;
	total = 0;
	while (head != tail){
		u = decueue();
		u.t = roundrobin(u.t, q);
		if (u.t > 0){
			encueue(u);
		}
		else{
			printf("%s %d\n", u.name, total);
		}
	}
	return 0;
}

Measured memory_bytes: 13356
#include<vector>
#include<list>
#include<algorithm>
#include<iostream>
#include<string>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
using namespace std;
void f(vector<int> t[],int k[],int b[],int c,int s,int d,int v){
  int i;
  if(v==0);
  else if(s==d){
    if(b[s]==0||b[s]>c)
      b[s]=c;
  }else if(b[s]==0||b[s]>c){
    b[s]=c;
    for(i=0;i<k[s];i++)
      f(t,k,b,c+1,t[s][i],d,v-1);
  }
  return;
}
int main(){
  int i,j;
  int k[101],b[101],n,p,s,d,v;
  vector<int> t[101],u;
  cin>>n;
  for(i=0;i<n;i++){
    int q,r;
    cin>>r>>q;
    k[r]=q;
    t[r].reserve(k[r]);
    for(j=0;j<k[r];j++)
      cin>>t[r][j];
  }
  cin>>p;
  u.reserve(p);
  for(i=0;i<p;i++){
    cin>>s>>d>>v;
    memset(b,0,sizeof(b));
    f(t,k,b,1,s,d,v);
    u[i]=b[d];
  }
  for(i=0;i<p;i++){
    if(u[i])
      cout<<u[i]<<endl;
    else
      cout<<"NA"<<endl;
  }
  return 0;
}

Measured memory_bytes: 0
//#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>
using namespace std;
template <class A, class B> inline bool chmax(A &a, const B &b) { return b > a && (a = b, true); }
template <class A, class B> inline bool chmin(A &a, const B &b) { return b < a && (a = b, true); }
typedef long long ll;
typedef vector<int> vint;
typedef pair<int, int> pint;
typedef vector<long long> vlong;
typedef vector<string> vstring;
#define vpush(a,x) a.push_back(x);
#define rep(i, n) REP(i, 0, n)
#define all(v) v.begin(), v.end()
#define REP(i, x, n) for(int i = x; i < n; i++)
const int INF = 1 << 30;
const int dx[] = {1,0,-1,0,1,1,-1,-1};
const int dy[] = {0,-1,0,1,1,-1,-1,1};
#define stp(x)  setprecision(x)
const long double PI=3.14159265358979323846264338327950;
int main(){
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  vint a(3);
  cin>>a[0]>>a[1]>>a[2];
  sort(all(a));
  cout<<a[0]<<' '<<a[2]<<'\n';
  return(0);
}


Measured memory_bytes: 3224
#include <iostream>
#include <vector>
#include <array>
#include <algorithm>
using namespace std;

int main() {
    vector<int> prime;
    array<bool, 2001000> is_prime;
    fill(is_prime.begin(), is_prime.end(), true);
    is_prime[0] = is_prime[1] = false;
    for(int i=2; i<is_prime.size(); ++i) {
        if(is_prime[i]) {
            prime.push_back(i);
            for(int j=i+i; j<is_prime.size(); j+=i) {
                is_prime[j] = false;
            }
        }
    }

    int N, P;
    while(cin >> N >> P, N != -1) {
        int idx = 0;
        while(N >= prime[idx]) {
            idx++;
        }
        vector<int> ans;
        for(int i=idx; i<idx+100; ++i) {
            for(int j=idx; j<=i; ++j) {
                ans.push_back(prime[i]+prime[j]);
            }
        }
        sort(ans.begin(), ans.end());
        cout << ans[P-1] << endl;
    }
}


Measured memory_bytes: 5708
#include <stdio.h>
int main(void)
{
    int a,b,c;
    scanf("%d%d%d",&a,&b,&c);
    if((a == b && a != c && b != c) || (a == c && a != b && c != b) || (b == c && b != a && c != a))
        printf("Yes");
    else
        printf("No");
        
    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define rep(i,ini,n) for(int i=ini;i<n;i++)
#define _rep(i,ini,n) for(int i=ini;i>=n;i--)
#define ToEnd(a) a.begin(),a.end()
uint64_t MOD=1000000007;

int main(){
    string S; cin>>S;

    map<char,int> mapS;
    mapS['a']=0,mapS['b']=0,mapS['c']=0;
    for(auto s:S) mapS[s]++;

    int maxC=0,minC=INT_MAX;
    for(auto m:mapS){
        maxC=max(maxC,m.second);
        minC=min(minC,m.second);
    }

    string ans="YES";
    if(maxC-minC>1) ans="NO";

    cout<<ans<<endl;
}

Measured memory_bytes: 512
#include<iostream>
#include<cstdio>
#include<cstring>
#include <cstdlib>  
#include <cmath>   
#include<cctype>
#include<string>
#include<set>
#include <map>
#include<algorithm>
#include <functional>
#include<vector>
#include<climits>
#include<stack>
#include<queue>
#include <deque>
#include <climits>
#include <typeinfo>
#include <utility> 
#define all(x) (x).begin(),(x).end()
#define rep(i,m,n) for(int i = m;i < n;++i)
#define pb push_back
#define fore(i,a) for(auto &i:a)
#define rrep(i,m,n) for(int i = m;i >= n;--i)
#define INF INT_MAX/2
using namespace std;
using ll = long long;
using R = double;
const ll inf = 1LL << 50;
const ll MOD = 1e9 + 7;
struct edge { ll from; ll to; ll cost; };

void chmin(int &a, int b) {
	if (a > b)a = b;
}


int main(){
	int n;
	string s;
	cin >> n >> s;

	int dif1 = 101010;
	int cnt1 = 0;
	rep(i, 0, n) {
		if (s[i] == '(')cnt1++;
		else cnt1--;
		chmin(dif1,cnt1);
	}

	if (dif1 < 0) {
		reverse(all(s));
		rep(i, 0, abs(dif1))s += '(';
		reverse(all(s));
	}


	int cnt2 = 0;
	rep(i, 0, s.size()) {
		if (s[i] == '(')cnt2++;
		else cnt2--;
	}

	if (cnt2 > 0) {
		rep(i, 0, abs(cnt2))s += ')';
	}

	cout << s << endl;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using vi = vector<int>;
using vc = vector<char>;
using vs = vector<string>;
using vvi = vector<vector<int>>;
using vvc = vector<vector<char>>;

int main()
{
    int X;
    cin >> X;
    if(X>=30)
        cout << "Yes" << endl;
        else
        {
            cout << "No" << endl;
        }
    return 0;
}

Measured memory_bytes: 3620
double s[999][3],t[3],p,d,n1,n2;r[999];
main(n,m,i,j){for(;scanf("%d",&n),n;printf("%d\n",m)){
	for(i=0;i<n;i++)scanf("%lf%lf%lf",s[i],s[i]+1,s[i]+2);
	for(memset(r,0,sizeof(r)),scanf("%d",&m),j=0;j<m;j++){
		scanf("%lf%lf%lf%lf",t,t+1,t+2,&p);
		n2=sqrt(t[0]*t[0]+t[1]*t[1]+t[2]*t[2]);
		for(i=0;i<n;i++){
			n1=sqrt(s[i][0]*s[i][0]+s[i][1]*s[i][1]+s[i][2]*s[i][2]);
			d=t[0]*s[i][0]+t[1]*s[i][1]+t[2]*s[i][2];
			if(acos(d/n1/n2)<p)r[i]=1;
		}
	}
	for(m=i=0;i<n;i++)m+=r[i];
}exit(0);}

Measured memory_bytes: 724
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<cmath>
using namespace std;
const long long inf=1LL<<60;
long long h,n,cnt,ans;
long long f[1007][20007];
struct data{
	long long a,b;
}x[1007];
int main(){
	ios::sync_with_stdio(false);
	cin>>h>>n;
	ans=inf;
	for (int i=1; i<=n; i++) {
		cin>>x[i].a>>x[i].b;
		cnt=max(cnt,x[i].a);
	}
	for (int i=1; i<=h+cnt; i++) f[0][i]=inf;
	for (int i=1; i<=n; i++) {	
		for (int j=1; j<=h+cnt; j++) {
			f[i][j]=f[i-1][j];
			if (j>=x[i].a) f[i][j]=min(f[i][j],f[i][j-x[i].a]+x[i].b);
			if (j>=h) ans=min(ans,f[i][j]);
		}
	}
	cout<<ans<<endl;
	return 0;
} 

Measured memory_bytes: 155520
#include<iostream>
#include<algorithm>
using namespace std;
int m=1e9,M,n,a[1<<17];
main()
{
	cin>>n;
	for(int i=0;i<n;i++)
	{
		cin>>a[i];
		m=min(m,a[i]);
		M=max(M,a[i]);
	}
	if(M==m)
	{
		cout<<(m==n-1||m<=n/2?"Yes":"No")<<endl;
	}
	else if(M==m+1)
	{
		int cntm=0,cntM=0;
		for(int i=0;i<n;i++)cntm+=a[i]==m,cntM+=a[i]==M;
		cout<<(M<=(n-cntm)/2+cntm&&m>=cntm?"Yes":"No")<<endl;
	}
	else cout<<"No"<<endl;
}


Measured memory_bytes: 768
#include <bits/stdc++.h>
using namespace std;
int main(){
  long long n,sum=0,ans=10000000;
  cin >> n;
  long long w[n];
  for(int i=0;i<n;i++){
    cin >> w[i];
    sum+=w[i];
  }
  long long sum2=0;
  for(int i=0;i<n-1;i++){
    sum2+=w[i];
    ans=min(ans, abs(sum-sum2-sum2));
  }
  cout << ans << endl;
  return 0;
}


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

signed main(){
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif

	int n;
	string s;
	cin >> n >> s;
	if(s==string(n,'W') || s==string(n,'R')){
		cout << 0;
		return 0;
	}

	int c=0;
	for(int i=0; i<n; i++){
		if(s[i]=='R')
			c++;
	}

	int d=0;
	for(int i=c; i<n; i++){
		if(s[i]=='R')
			d++;
	}

	cout << d;


	
	

	return 0;
}

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


int INF = 1001001001;
int n;
vector<int> h(100010);
vector<int> dp(100010);

template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }

    return false;
}


int rec(int i) {
    if (dp[i] < INF) return dp[i];
    if (i == 0) return 0;
    int res = INF;
    chmin(res, rec(i-1) + abs(h[i]-h[i-1]));
    if (i > 1) chmin(res, rec(i-2) + abs(h[i]-h[i-2]));

    return dp[i] = res; 
}

int main() {
    int n;
    cin >> n;
    rep(i,n) cin >> h[i];

    rep(i,n) dp[i] = INF;

    cout << rec(n-1) << endl;
    return 0;
}

Measured memory_bytes: 8728
#include <bits/stdc++.h>
using namespace std;
int main() {
    int N;
    int a=1;
    cin >> N;
    vector<int> X(N+1),Y(N+1),T(N+1);
    T.at(0)=0;
    X.at(0)=0;
    Y.at(0)=0;
    for (int i = 1; i < N+1; i++) { 
        cin >> T.at(i) >> X.at(i) >> Y.at(i);
    }
    for (int i = 0; i < N; i++) {
        int t =abs(T.at(i) - T.at(i+1));
        int x =abs(X.at(i) - X.at(i+1));
        int y =abs(Y.at(i) - Y.at(i+1));
        if((x+y)>t){
            a=2;
            break;
        }else{
            if((x+y)%2==0&&t%2==0) continue;
            else if ((x+y)%2!=0&&t%2!=0) continue;
            else{
                a=3;
                break;
            }   
        } 
    }
    if(a==1) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 1408
import java.util.*;

public class Main{
    public static void main(String args[]){
        Scanner scanner = new Scanner(System.in);
        long n = scanner.nextLong();
        long a = scanner.nextLong();
        long b = scanner.nextLong();
        long prime = 1000000007;

        long total = 1;
        total = modPow(2, n, prime);

        long ax = 1;
        for(int i = 1; i <= a; i++){
            ax = (ax * (n - i + 1)) % prime;
        }
        long ay = 1;
        for(int i = 1; i <= a; i++){
            ay = (ay * i) % prime;
        }
        ay = modPow(ay, prime-2, prime);
        long nCa = (ax * ay) % prime;

        long bx = 1;
        for(int i = 1; i <= b; i++){
            bx = (bx * (n - i + 1)) % prime;
        }
        long by = 1;
        for(int i = 1; i <= b; i++){
            by = (by * i) % prime;
        }
        by = modPow(by, prime-2, prime);
        long nCb = (bx * by) % prime;
        total = (total - nCa - nCb -1) % prime;
        
        System.out.println((total >= 0)?total : total + prime);
        
    }
    
    public static long modPow(long a, long n, long p){
    	long ans = 1;
    	while (n > 0){
    		if((n & 1) == 1){
    			ans = (ans * a) % p;
    		}
			a = (a * a) % p;
			n >>= 1;
    	}
    	return(ans);
    }
}

Measured memory_bytes: 23124
use rand::seq::SliceRandom;

fn main() {
    let timer = std::sync::Arc::new(std::time::Instant::now());
    let mut rng = rand::thread_rng();
    proconio::input! {
        d: usize,
        cs: [i64; 26],
        sss: [[i64; 26]; d],
    }
    let mut ans = "".to_string();
    let mut max_score = std::i64::MIN;
    let v = (0usize..26).collect::<Vec<_>>();
    while timer.elapsed().as_millis() < 1900 {
        let mut lastd = vec![vec![]; 26];
        fn lastdi(d: usize, i: usize, lastd: &Vec<Vec<usize>>) -> usize {
            let v = &lastd[i];
            *v.iter().filter(|x| **x <= d).last().or(Some(&0)).unwrap()
        }
        fn calc_score(
            score: i64,
            d: usize,
            t: usize,
            cs: &[i64],
            sss: &[Vec<i64>],
            lastd: &mut Vec<Vec<usize>>,
        ) -> (i64, usize) {
            let mut score = score;
            score += sss[d - 1][t];
            lastd[t].push(d);
            let decline = (0..26)
                .map(|j| cs[j] * (d as i64 - lastdi(d, j, &lastd) as i64))
                .sum::<i64>();
            score -= decline;
            lastd[t].pop();
            (score, t)
        }
        let mut score = 0i64;
        let mut s = "".to_string();
        for d in 1..=d {
            let t = *v.choose(&mut rng).unwrap();
            let (max, t) = calc_score(score, d, t, &cs, &sss, &mut lastd);
            score = max;
            lastd[t].push(d);
            s += &format!("{}\n", t + 1);
        }
        if max_score < score {
            max_score = score;
            ans = s;
        }
    }
    println!("{}", ans.trim());
}


Measured memory_bytes: 2836
#include <stdio.h>

int main() {
  int n, x;

  do {
    scanf("%d %d", &n, &x);
    if (n != 0 || x != 0) {
      int count = 0;
      for (int a = 1; a <= n-2; a++) {
        for (int b = a+1; b <= n-1; b++) {
          int c = x - a - b;
          if (c <= n && c > b) {
            count = count + 1;
          }
        }
      }
      printf("%d\n", count);
    }
  } while (n != 0 || x != 0);
  
  return 0;
}


Measured memory_bytes: 2040
import java.util.AbstractMap;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.List;
import java.util.Scanner;
import java.util.AbstractMap.SimpleEntry;

class Main {

    static final long MOD = 1000000000 + 7;

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int K = sc.nextInt();
        int Blue = K;
        int Red = N - K;
        for (int i = 1; i <= K; i++) {
            long blueCov = combination(Blue - 1, i - 1) % MOD;
            int moveableRed = Red - (i - 1);
            // System.out.println(moveableRed);//ok
            long redCov = combination(moveableRed + i, i) % MOD;
            long ans = blueCov * redCov;
            ans %= MOD;
            // System.out.println(blueCov+" "+redCov+" "+ans);
            System.out.println(ans);
        }
    }

    // private static long permutation(long num1, long num2) {
    // if (num2 == 1) {
    // return num1;
    // }
    // return num1 * permutation(num1 - 1, num2 - 1);
    // }

    // private static long combination(long num1, long num2) {
    // if (num2 == 0) {
    // return 1;
    // }
    // return (num1 - num2 + 1) * combination(num1, num2 - 1) / num2;
    // }

    // static long combination(long n, long r){
    // long num = 1;
    // for(long i = 1; i <= r; i++){
    // num = num * (n - i + 1) / i;
    // num %= MOD;
    // }
    // return num;
    // }

    static long[] fac = new long[5100], finv = new long[5100], inv = new long[5100];

    static long combination(int n, int k){        
        fac[0] = fac[1] = 1;
        finv[0] = finv[1] = 1;
        inv[1] = 1;
        for (int i = 2; i < 5100; i++){
            fac[i] = fac[i - 1] * i % MOD;
            inv[i] = MOD - inv[(int)MOD%i] * (MOD / i) % MOD;
            finv[i] = finv[i - 1] * inv[i] % MOD;
        }

        if (n < k) return 0;
        if (n < 0 || k < 0) return 0;
        return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
    }

}

Measured memory_bytes: 22484
#include<stdio.h>
#include<algorithm>
using namespace std;
long long dat[100000];
long long dp[100000];
long long a,b;
long long solve(long long  k){
//	printf("%d %lld\n",k,dp[k]);
	if(dp[k]>0)return dp[k];
	if((k==0&&dat[k]>dat[k+1])||(k==a-1&&dat[k]>dat[k-1])||(dat[k]>dat[k-1]&&dat[k]>dat[k+1])){
		return dp[k]=b-dat[k];
	}
	if(k==0)return dp[k]=solve(1)+b-dat[k];
	if(k==a-1)return dp[k]=solve(a-2)+b-dat[k];
	if(dat[k]<dat[k-1])dp[k]=max(dp[k],solve(k-1)+b-dat[k]);
	if(dat[k]<dat[k+1])dp[k]=max(dp[k],solve(k+1)+b-dat[k]);
	return dp[k];
}
int main(){
	scanf("%lld%lld",&a,&b);
	for(int i=0;i<a;i++){
		scanf("%lld",dat+i);
	}
	long long ret=0;
	for(long long  i=0;i<a;i++){
		ret=max(ret,solve(i));
	}
	printf("%lld\n",ret);
}

Measured memory_bytes: 2068
using System;

class Program {
    static void Main() {
        string[] stdin = Console.ReadLine().Split();
        int[] a = new int[3];
        for(int i = 0; i < 3; i++) a[i] = int.Parse(stdin[i]);
        Array.Sort(a);
        Console.WriteLine(string.Join(" ", a));
    }
}


Measured memory_bytes: 17980
import sys
s = input()[::-1]
t = input()[::-1]
ans = 'UNRESTORABLE'
if len(t)>len(s):
  print(ans)
  sys.exit()
for i in range(len(s)-len(t)+1):
  flag = True
  for j in range(len(t)):
    if t[j] != s[i+j] and s[i+j] != '?':
      flag = False
  if flag:
    for j in range(len(t)):
      ans = s[:i]+t+s[i+len(t):]
      ans = ans.replace('?','a')
      ans = ans[::-1]
      print(ans)
      sys.exit()
print(ans)


Measured memory_bytes: 3064
#include <cstdio>
#include <cstring>

int main()
{
while(true) {
char str[20000];
if(scanf("%s", str) == EOF)
break;
int len = strlen(str);
int joi = 0, ioi = 0;
char joistr[] = "JOI", ioistr[] = "IOI";
for(int it = 0; it < len - 2; ++it) {
bool joivalid = true, ioivalid = true;
for(int i = 0; i < 3; ++i) {
if(joistr[i] != str[i + it])
joivalid = false;
if(ioistr[i] != str[i + it])
ioivalid = false;
}
if(joivalid) ++joi;
if(ioivalid) ++ioi;
}
printf("%d\n%d\n", joi, ioi);
}
return 0;
}

Measured memory_bytes: 984
#include <bits/stdc++.h>
using namespace std;
 
using ll=long long;
 
#define rng(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,b) rng(i,0,b)
#define gnr(i,a,b) for(int i=int(b)-1;i>=int(a);i--)
#define per(i,b) gnr(i,0,b)
#define pb push_back
#define eb emplace_back
#define a first
#define b second
#define bg begin()
#define ed end()
#define all(x) x.bg,x.ed
const ll MOD = 998244353;

void rec(int pnode, vector<int>& xs, vector<vector<int>>& nodes, vector<bool>& isdone) {
    for(int n : nodes[pnode]) {
        if (isdone[n]) continue;
        isdone[n] = true;
        xs[n] += xs[pnode];
        rec(n, xs, nodes, isdone);
    }
}

int main() {
    int n, q;
    cin >> n >> q;
    vector<vector<int>> nodes(n);
    rep(i,n-1) {
        int a, b;
        cin >> a >> b;
        --a; --b;
        nodes[a].push_back(b);
        nodes[b].push_back(a);
    } 
    vector<int> xs(n,0);
    vector<bool> isdone(n,false);
    rep(i, q) {
        int p, x; 
        cin >> p >> x;
        --p;
        xs[p] += x;
    }
    isdone[0] = true;
    rec(0, xs, nodes, isdone);
    for(int r : xs) cout << r << " ";
    cout << endl;
    return 0;
}

Measured memory_bytes: 29824
#include "bits/stdc++.h"
using namespace std;
#define mod 1000000007
#define ll long long
#define cases ll t;cin>>t;while(t--)
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL)


int main(){
    fast;
    ll i,j,n,k,m,x,y,cnt=1;
    cin>>n>>m;
    vector<ll> a(n);
    for(i=0;i<n;i++) cin>>a[i];
    ll sm=accumulate(a.begin(),a.end(),0);
    double chk=0.25*sm/m;
    ll ans=0;
    for(i=0;i<n;i++) if(a[i]>=chk) ans++;
    if(ans>=m) cout<<"Yes";
    else cout<<"No";
    return 0;
}


Measured memory_bytes: 256
# include "bits/stdc++.h"
using namespace std;
using LL = long long;
using ULL = unsigned long long;
const double PI = acos(-1);
template<class T>constexpr T INF() { return ::std::numeric_limits<T>::max(); }
template<class T>constexpr T HINF() { return INF<T>() / 2; }
template <typename T_char>T_char TL(T_char cX) { return tolower(cX); };
template <typename T_char>T_char TU(T_char cX) { return toupper(cX); };
const int vy[] = { -1, -1, -1, 0, 1, 1, 1, 0 }, vx[] = { -1, 0, 1, 1, 1, 0, -1, -1 };
const int dx[4] = { -1,0,1,0 }, dy[4] = { 0,-1,0,1 };
const char dir[4] = { 'u','l','d','r' };
int popcnt(unsigned long long n) { int cnt = 0; for (int i = 0; i < 64; i++)if ((n >> i) & 1)cnt++; return cnt; }
int d_sum(LL n) { int ret = 0; while (n > 0) { ret += n % 10; n /= 10; }return ret; }
int d_cnt(LL n) { int ret = 0; while (n > 0) { ret++; n /= 10; }return ret; }
LL gcd(LL a, LL b) { if (b == 0)return a; return gcd(b, a%b); };
LL lcm(LL a, LL b) { LL g = gcd(a, b); return a / g*b; };
# define ALL(qpqpq)           (qpqpq).begin(),(qpqpq).end()
# define UNIQUE(wpwpw)        (wpwpw).erase(unique(ALL((wpwpw))),(wpwpw).end())
# define LOWER(epepe)         transform(ALL((epepe)),(epepe).begin(),TL<char>)
# define UPPER(rprpr)         transform(ALL((rprpr)),(rprpr).begin(),TU<char>)
# define FOR(i,tptpt,ypypy)   for(LL i=(tptpt);i<(ypypy);i++)
# define REP(i,upupu)         FOR(i,0,upupu)
# define INIT                 std::ios::sync_with_stdio(false);std::cin.tie(0)
# pragma warning(disable:4996)

//using LL = long long;

//ボール(n)の区別:アリ
//箱(m)の区別:アリ
//それぞれの箱に最低限1個入れる


LL n, k;
const int mod = 1e9 + 7;

int main() {
	cin >> n >> k;
	LL ans = 1;
	REP(i, n)ans *= k, ans %= mod;
	cout << ans << endl;
}


Measured memory_bytes: 3064
#include <stdio.h>

int main(){
    int  sumPrice, sumNum, kind, price, num;
    
    sumPrice = sumNum = kind = 0;
      
    while(scanf("%d,%d", &price, &num) != EOF){
        kind++;
        
        sumPrice += price * num;
        sumNum   += num;
    }
        
    printf("%d\n%.0lf\n", sumPrice, (double)sumNum / kind + 0.05);
 
    return 0;
}

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

int main() {
	int a1, a2, a3;
	cin >> a1 >> a2 >> a3;

	cout << min({abs(a1 - a2) + abs(a2 - a3),
		abs(a1 - a3) + abs(a3 - a2),
		abs(a2 - a1) + abs(a1 - a3),
		abs(a2 - a3) + abs(a3 - a1),
		abs(a3 - a1) + abs(a1 - a2),
		abs(a3 - a2) + abs(a2 - a1)}) << endl;

	return 0;
}

Measured memory_bytes: 256
n = int(input())

def cross(a, b):
    return a[0]*b[1]-a[1]*b[0]
    
def dot(a, b):
    n = len(a)
    if n != len(b):
        return None
    ans = 0
    for i, j in zip(a, b):
        ans += i*j
    return ans
    
for i in range(n):
    pp = list(map(int, input().split()))
    a = (pp[2]-pp[0], pp[3]-pp[1])
    b = (pp[6]-pp[4], pp[7]-pp[5])
    if cross(a, b) == 0:
        print(2)
    elif dot(a, b) == 0:
        print(1)
    else:
        print(0)


Measured memory_bytes: 5620
#include <cstdio>
#include <complex>
#include <vector>
#include <cmath>

using namespace std;

#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)

typedef complex<double> P;
typedef vector<P> VP;
const double EPF = 1e-9;

#define X real()
#define Y imag()
#define EQ(x,y) (abs(x-y) < EPF)

double dot(P a, P b) {
  return (conj(a)*b).X;
}
double cross(P a, P b) {
  return (conj(a)*b).Y;
}
double distPP(P a, P b) {
  return sqrt(dot(a-b,a-b));
}
P crosspoint(P a, P b, P c, P d) {//ac , bd
  double d1 = cross(d-b,b-a);
  double d2 = cross(d-b,c-a);
  if(EQ(d1,0) & EQ(d2,0)) return a;
  if(EQ(d2,0)) return a;
  return a + (c-a)*d1/d2;
}
P normal_vector(P a) {
  P b(-a.Y, a.X);
  return b;
}


int main() {
  VP vp;

  while(1) {
    REP(i,4) {
      double x,y;
      if(scanf("%lf %lf", &x, &y) == EOF) {
	vp.clear();
	return 0;
      }
      vp.push_back(P(x,y));
    }
    double d1 = cross(vp[1]-vp[0],vp[3]-vp[0]);
    double d2 = cross(vp[2]-vp[1],vp[3]-vp[1]);
    double d3 = cross(vp[0]-vp[2],vp[3]-vp[2]);
    if((d1 > 0 && d2 > 0 && d3 > 0) || (d1 < 0 && d2 < 0 && d3 < 0)) printf("YES\n");
    else printf("NO\n");
    vp.clear();
  }
  
  return 0;
}

Measured memory_bytes: 2668