akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <queue>
using namespace std;
int main(){
	long long int Fac[100010] = {}; long long int P = 998244353; 
	Fac[0] = 1; 
	for(int i = 1; i <= 100005; i++){
		Fac[i] = (Fac[i-1] * (long long) i) % P; 
	}
	int N; cin >> N; 
	vector<int> r = {}, g = {}, b = {}; 
	string S; cin >> S; 
	for(int i = 0; i < N * 3; i++){
		if(S.at(i) == 'R') r.push_back(i+1); 
		if(S.at(i) == 'G') g.push_back(i+1); 
		if(S.at(i) == 'B') b.push_back(i+1); 
	}
	int A[300010] = {}; 
	for(int i = 0; i < N; i++){
		int x = r.at(i); int y = g.at(i); int z = b.at(i); 
		A[min({x,y,z})] = 1; 
		A[max({x,y,z})] = 3; 
		A[x+y+z-min({x,y,z})-max({x,y,z})] = 2; 
	}
	long long int ans = Fac[N]; 
	int by1 = 0, by2 = 0, by3 = 0; 
	for(int i = 1; i <= N * 3; i++){
		if(A[i] == 1) by1 ++; 
		if(A[i] == 2){
			ans *= (long long) by1; ans %= P; 
			by1 --; by2 ++; 
		}
		if(A[i] == 3){
			ans *= (long long) by2; ans %= P; 
			by2 --; by3 ++; 
		}
	}
	cout << ans << endl; 
}

Measured memory_bytes: 4092
package main

import (
    "fmt"
    "math"
)

func main() {
    var n int
    var sum int
    var sum_sq int

    fmt.Scan(&n)

    for i:=0; i<n; i++ {
        var a int
        fmt.Scan(&a)
        sum += a
        sum_sq += a * a
    }

    avg := int(math.Floor(float64(sum) / float64(n) + 0.5))

    fmt.Println(avg * avg * n + sum_sq - 2 * sum * avg)
}

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

#include <string>
void _150() {
    int n;
    string s;
    cin >> n;
    cin >> s;

    int count = 0;
    for (int i = 0; i < s.size() - 2; ++i) {
        if (s.substr(i, 3) == "ABC") {
            count++;
        }
    }
    cout << count << endl;
}

void _151() {
    int n, k, m;
    cin >> n >> k >> m;
    int a[100];
    int goal = m * n;
    for (int i = 0; i < n - 1; ++i) {
        cin >> a[i];
        goal -= a[i];
    }

    if (goal > k) {
        cout << -1 << endl;
    } else {
        cout << max(goal, 0) << endl;
    }
}

void _152() {
    int a, b;
    cin >> a >> b;

    string result("");
    if (a < b) {
        for (int i = 0; i < b; ++i) {
            result += to_string(a);
        }
    } else {
        for (int i = 0; i < a; ++i) {
            result += to_string(b);
        }
    }
    cout << result << endl;
}

void _153() {
    long long h;
    int n, a;
    cin >> h >> n;
    for (int i = 0; i < n; ++i) {
        cin >> a;
        h -= a;
        if (h <=0) {
            cout << "Yes" << endl;
            return;
        }
    }
    cout << "No" << endl;
    return;
}

void _154() {
    string s;
    cin >> s;

    for (int i = 0; i < s.size(); ++i) {
        cout << 'x';
    }
    cout << endl;
}

void _155() {
    int n, a;
    cin >> n;
    for (int i = 0; i < n; ++i) {
        cin >> a;
        if (a % 2 == 0) {
            if ((a % 3 != 0) && (a % 5 != 0)) {
                cout <<"DENIED" << endl;
                return;
            }
        }
    }

    cout << "APPROVED" << endl;
}

#include <cmath>
void _156() {
    int n, k;
    cin >> n >> k;

    for (int i = 0; ; ++i) {
        if (pow(k, i) > n) {
            cout << i << endl;
            return;
        }
    }
}

#include <cstring>
void _157() {
    int a[3][3];
    int n;
    int b[10];
    for (int i = 0; i < 3; ++i)
        for (int j = 0; j < 3; ++j)
            cin >> a[i][j];
    cin >> n;
    for (int i = 0; i < n; ++i) 
        cin >> b[i];
    
    int judge[3][3];
    memset(judge, 0, sizeof(judge));
    for (int i = 0; i < 3; ++i) {
        for (int j = 0; j < 3; ++j) {
            for (int k = 0; k < n; ++k) {
                if (a[i][j] == b[k]){
                    judge[i][j] = 1;
                    break;
                }
            }
        }
    }

    for (int i = 0; i < 3; ++i) {
        if (judge[i][0] == 1 && judge[i][1] == 1 && judge[i][2] == 1) {
            cout << "Yes" << endl;
            return;
        } else if (judge[0][i] == 1 && judge[1][i] == 1 && judge[2][i] == 1) {
            cout << "Yes" << endl;
            return;
        }
    }
    if (judge[0][0] == 1 && judge[1][1] == 1 && judge[2][2] == 1) {
        cout << "Yes" << endl;
        return;
    } else if (judge[0][2] == 1 && judge[1][1] == 1 && judge[2][0] == 1) {
        cout << "Yes" << endl;
        return;
    }

    cout << "No" << endl;
}

int main()
{
    _157();
    return 0;
}



Measured memory_bytes: 256
use std::io;

fn main() {
    let mut input = String::new();
    io::stdin().read_line(&mut input).expect("error");

    let n = str::parse::<i64>(&input.trim()).unwrap();

    if n % 2 == 0 {
        println!("{}", n);
    } else {
        println!("{}", n * 2);
    }
}

Measured memory_bytes: 4352
#include<iostream>
#include<cstdlib>
#include<stack>
using namespace std;

int main() {
    // 標準ライブラリからstackを使用
    stack<int> S;
    int a, b, x;
    string s;

    while (cin >> s){
        if (s[0] == '+'){
            a = S.top(); S.pop();
            b = S.top(); S.pop();
            S.push(a+b);
        }
        else if(s[0] == '-'){
            b = S.top(); S.pop();
            a = S.top(); S.pop();
            S.push(a - b);
        }
        else if (s[0] == '*'){
            a = S.top(); S.pop();
            b = S.top(); S.pop();
            S.push(a*b);
        }
        else {
            S.push(atoi(s.c_str()));
        }
    }
    cout << S.top() << endl;

    return 0;
}



Measured memory_bytes: 3232
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <cmath>
#include <iomanip>
#include <stack>
#include <queue>
#include <numeric>
#define rep(i,n) for(int i=0;i<(n);i++)
#define pb push_back
#define mod 1000000007
typedef long long ll;
using namespace std;

int main(){
  int K,X;
  cin >> K >> X;
  int mini = X-K;
  int maxi = X+K;
  for(int i=mini+1;i<maxi;i++){
    if(i!=mini+1) cout << " ";
    cout << i;
  }
  cout << endl;
  return 0;
}


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

using namespace std;

int main() {
  int N, L;
  cin >> N >> L;


  int min = 999999999;
  vector<int> tastes;
  for (int i = 0; i < N; i++) {
    tastes.emplace_back(L + i);
    if (abs(min) > abs(L + i)) {
      min = L + i;
    }
  }

  int result = 0;
  for (int i = 0; i < N; i++) {
    result += tastes[i];
  }
  cout << result - min << endl;

  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define ALL(x) (x).begin(),(x).end()
#define LL long long
#define pii pair<int,int>
#define pll pair<LL,LL>

using namespace std;

int pare[100010];
int num[100010];

int root(int x){
    if(pare[x]<0)return x;
    return pare[x]=root(pare[x]);
}

void unite(int x,int y){
    x = root(x);
    y = root(y);
    if(x == y)return;
    if(pare[y] < pare[x])swap(x,y);
    pare[x]+=pare[y];
    num[x]=(num[x]+num[y])%26;
    pare[y]=x;
}

bool issame(int x,int y){
    return root(x)==root(y);
}

int main(){

    string s;cin>>s;

    num[0]=s[0]-'a';
    num[s.size()]=('a' +26 - s[s.size()-1])%26;
    REP(i,s.size()-1){
        num[i+1]=(s[i+1]-s[i]+26)%26;
    }


    REP(i,s.size()+1)pare[i]=-1;

    REP(i,s.size()+1){
        unite(i,s.size()-i);
    }

    int n;cin>>n;
    REP(i,n){
        int l,r;cin>>l>>r;
        unite(l-1,r);
    }

//    REP(i,s.size()+1){
//        cout<<root(i)<<endl;
//        cout<<num[root(i)]<<endl;
//        cout<<endl;
//    }

    REP(i,s.size()+1)if(num[root(i)]%26 != 0){
            cout<<"NO"<<endl;
            return 0;
        }
    cout<<"YES"<<endl;

    return 0;
}

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

mt19937 rnd(chrono::high_resolution_clock::now().time_since_epoch().count());

int N, D;
vector<int> C;
vector<vector<int>> S;

vector<int> ans;

void Read(bool local = false) {
  N = 26;
  if (local) {
    D = 365;
  } else {
    cin >> D;
  }
  C.resize(N);
  for (int i = 0; i < N; i++) {
    if (local) {
      C[i] = rnd() % 100;
    } else {
      cin >> C[i];
    }
  }
  S.resize(D);
  for (int i = 0; i < D; i++) {
    S[i].resize(N);
    for (int j = 0; j < N; j++) {
      if (local) {
        S[i][j] = rnd() % 20000;
      } else {
        cin >> S[i][j];
      }
    }
  }
  ans.assign(D, 0);
}

void Write() {
  for (auto i : ans) {
    cout << i + 1 << "\n";
  }
}

int Arithmetic(int n) {
  return n * (n - 1) / 2;
}

vector<set<int>> Build(vector<int> a) {
  vector<set<int>> occ(N);
  for (int i = 0; i < D; i++) {
    occ[a[i]].insert(i);
  }
  for (int i = 0; i < N; i++) {
    occ[i].insert(-1);
    occ[i].insert(D);
  }
  return occ;
}

int Evaluate(vector<int> a) {
  vector<int> last(N, -1);
  int score = 0;
  for (int i = 0; i < D; i++) {
    score += S[i][a[i]];
    last[a[i]] = i;
    for (int j = 0; j < 26; j++) {
      score -= C[j] * (i - last[j]);
    }
  }
  return score;
}

int Evaluate(int init_score, const vector<int> &a, const vector<set<int>> &occ, int d, int q) {
  if (a[d] == q) return init_score;
  const set<int> &cur = occ[a[d]];
  auto pos = cur.lower_bound(d);
  int lst = *prev(pos);
  int nxt = *next(pos);

  int score = init_score;
  score += C[a[d]] * (Arithmetic(nxt - d) + Arithmetic(d - lst) - Arithmetic(nxt - lst));

  pos = occ[q].upper_bound(d);
  lst = *prev(pos);
  nxt = *pos;
  score -= C[q] * (Arithmetic(nxt - d) + Arithmetic(d - lst) - Arithmetic(nxt - lst));

  score -= S[d][a[d]];
  score += S[d][q];

  return score;
}

void Change(int &init_score, vector<int> &a, vector<set<int>> &occ, int d, int q) {
  int new_score = Evaluate(init_score, a, occ, d, q);
  init_score = new_score;
  occ[a[d]].erase(d);
  a[d] = q;
  occ[a[d]].insert(d);
}

void Solve() {
  vector<int> a(D);
  for (int i = 0; i < D; i++) {
    a[i] = rnd() % N;
  }
  int score = Evaluate(a);
  vector<set<int>> occ = Build(a);

  double temp = 10000;
  double cooling_rate = 0.999999;
  double absolute_zero = 0.00000001;
  int rep = 1e6;
  while (rep--) {
    int d = rnd() % D;
    int q = rnd() % N;
    int delta = Evaluate(score, a, occ, d, q) - score;
    if (delta >= 0) {
      Change(score, a, occ, d, q);
    }
    // temp *= cooling_rate;
  }
  if (Evaluate(ans) < Evaluate(a)) {
    ans = a;
  }
}

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

  Read();
  for (int rep = 0; rep < 10; rep++) {
    Solve();
  }
  Write();
  // cerr << Evaluate(ans) << "\n";
  return 0;
}


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

using namespace std;

int main() {
  int n,k;
  cin >> n >> k;
  int ans = 0;
  vector<int> a(n);
  for(int i=0;i<n;i++){
    cin >> a.at(i);
    if(a.at(i) >= k){
      ans++;
    }
  }
  
  cout << ans << endl;
  
  return 0;
}

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

int main() {

	int n;
	cin >> n;

	int p = 0;
	for (int i = 0;i < n;i++) {
		if (pow(2, i) > n) {
			p = i - 1;
			break;
		}
	}

	cout << pow(2, p) << endl;
}


Measured memory_bytes: 256
N = input()
L = list(map(int, input().split()))

p = 0
l2 = []
while 2**p < 1000000000:
  l2.append(2**p)
  p += 1

d = 0
for l in L:
  for i in range(len(l2)-1, -1, -1):
    if l % l2[i] == 0:
      d += i
      break

print(d)

Measured memory_bytes: 4148
#include <stdio.h>

int main(){
  int flag,i,j,N,A[100],tmp,count=-1;
  flag = 1;
  i = 0;
  scanf("%d",&N);
  if(N > 100 || N < 0) return 0;  
  while(i < N){
    scanf("%d",&A[i]);   
   if(A[i] > 100 || A[i] < 0) return 0;   
   i++;
  }
  while(flag){
    flag = 0;

    for(j = N -1 ; j >= 1;j--){
      if(A[j] < A[j-1] ){

	tmp = A[j-1];
	A[j-1] = A[j];
	A[j] = tmp;
	flag = 1;
	break;
      }
    }
  	count++;	
  }
for(j = 0; j <= N-2;j++){
  	printf("%d ",A[j]);
 }
 printf("%d",A[j]);

 printf("\n%d\n",count);

  return 0;
}



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

int main() {
    char a, b;
    cin >> a >> b;
    bool ans;
    if (a == 'H') {
        if (b == 'H') ans = true;
        else ans = false;
    } else {
        if (b == 'H') ans = false;
        else ans = true;
    }
    cout << (ans ? "H" : "D") << endl;
    return 0;
}

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

using namespace std;
typedef long long ll;
typedef pair< ll , string > P;

int main(){
	ll n;
	cin>>n;
	
	set<ll>a;
	rep(i,n){
		ll an;
		cin>>an;
		a.insert(an);
	} 
	if(a.size()==n) cout<<"YES";
	else cout<<"NO";
}


Measured memory_bytes: 9600
#include <stdio.h>
#include <string>
#include <iostream>
#include <vector>
#include <queue>
#include <list>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
using namespace std;

template<typename T>
ostream& operator << (ostream& os, vector<T>& vec) {
	for (int i = 0; i<vec.size(); i++) {
		os << vec[i] << (i + 1 == vec.size() ? "" : " ");
	}
	return os;
}

int SumDigitValues(int x)
{
	int sum = 0;
	while (x)
	{
		sum += x % 10;
		x = x / 10;
	}

	return sum;
}

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

	if (s == "Sunny") cout << "Cloudy" << endl;
	if (s == "Cloudy") cout << "Rainy" << endl;
	if (s == "Rainy") cout << "Sunny" << endl;
}

Measured memory_bytes: 256
List=[int(input()) for i in range(5)]
k = int(input())
judge = False
for i in range(len(List)):
    for j in range(len(List)):
        if k < abs(List[i]-List[j]):
            print(":(")
            judge = True
            break
    if  judge:
        break
if judge != True:
    print("Yay!")

Measured memory_bytes: 3060
#include<iostream>
using namespace std;
int main()
{
    int a,b,c,temp,ans;
    string s,daan;
    cin>>a>>b>>c;
    temp=a;
    a=b;
    b=temp;
    temp=a;
    a=c;
    c=temp;
    cout<<a<<' '<<b<<' '<<c<<endl;;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define SIZE 200005
using namespace std;
typedef long long int ll;
typedef pair <int,int> P;

int A[SIZE];
int main()
{
	int n,k;
	scanf("%d %d",&n,&k);
	for(int i=0;i<n;i++) scanf("%d",&A[i]);
	for(int i=0;i<n-k;i++)
	{
		puts(A[i]<A[i+k]?"Yes":"No");
	}
}

Measured memory_bytes: 4468
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>
#include<cstdio>
 
using namespace std;
 
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,s,n) for(int i=(s);i<(n);i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define REPR(i,s,n) for(int i=(s);i>=(n);i--)
#define pb push_back
#define pf push_front
 
typedef vector<int> vi;
typedef vector<string> vs;
typedef long long ll;
typedef vector<ll> vll;
 
ll gcd(ll x, ll y) {
	ll r;
	while ((r = x % y) != 0) {
		x = y;
		y = r;
	}
	return y;
	}
ll lcm(ll x, ll y) {
	x /= gcd(x, y);
	y /= gcd(x, y);
	return (x*y);
}

int main()
{
	int n,a,b;
	cin >> n >> a >> b;
	cout << ((a-b)%2==0?"Alice\n":"Borys\n");
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
	int N,x=0,y=0;
	string S;
	cin>>N>>S;
	for(int i=0;i<=N;i++){
		if(S[i]=='I')
		x++;
		if(S[i]=='D')
		x--;	
		if(y<x)
		y=x;
	}
	cout<<y;
}

Measured memory_bytes: 256
s = input()
s += input()
s += input()

q = [0,0,0,0]
q[0] = s.count("1")
q[1] = s.count("2")
q[2] = s.count("3")
q[3] = s.count("4")
q.sort()

if(q == [1,1,2,2]):
    print("YES")
else:
    print("NO")

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

int main(){
    long long a, b, c, k;cin>>a>>b>>c>>k;
    long long border = 1000000000000000000;
    long long value;
    if (k % 2 == 0){
        value = a - b;
    } else {
        value = b - a;
    }
    if (abs(value) > border){
        cout << "Unfair" << endl;
    } else {
        cout << value << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long int
#define M 1000000007
#define mod 998244353
#define mp(x,y) make_pair(x,y)
#define pb(x) push_back(x)
#define pi pair<ll,ll>
using namespace std;
const ll N=500010;

ll dsu[N],size[N];

ll root(ll i)
{
    while(i!=dsu[i]){
        dsu[i]=dsu[dsu[i]];
        i=dsu[i];
    }
    return i;
}

vector<ll> adj[N];
vector<ll> vis;
vector<ll> vis1;
vector<ll> ans;
map<ll,ll> ch;
void dfs(ll v)
{
    vis[v]=1;
    ll myroot=root(v);
    ch[myroot]+=1;
    for(auto u:adj[v])
    {
        if(vis[u]==0){
            dfs(u);
        }
    }
}
void dfs1(ll v)
{
    vis1[v]=1;
    ll myroot=root(v);
    ans[v]=ch[myroot];
    for(auto u:adj[v])
    {
        if(vis1[u]==0){
            dfs1(u);
        }
    }
}

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

    ll n,k,l;
    cin>>n>>k>>l;
    for(ll i=0;i<=n;++i){
        dsu[i]=i;
        size[i]=1;
    }
    for(ll i=0;i<k;++i)
    {
        ll x,y;
        cin>>x>>y;
        ll rx=root(x);
        ll ry=root(y);
        if(size[rx]>size[ry]){
            dsu[ry]=rx;
            size[rx]+=size[ry];
        }
        else{
            dsu[rx]=ry;
            size[ry]+=size[rx];
        }
    }

    for(ll i=0;i<l;++i){
        ll a,b;
        cin>>a>>b;
        adj[a].pb(b);
        adj[b].pb(a);
    }

    vis.resize(n+1,0);
    vis1.resize(n+1,0);
    ans.resize(n+1,0);

    for(ll i=1;i<=n;++i)
    {
        if(vis[i]==0)
        {
            ch.clear();
            dfs(i);
            dfs1(i);
        }
    }

    for(ll i=1;i<=n;++i){
        cout<<ans[i]<<" ";
    }

    return (0);
}


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

        int main() {
          ll N, K, Q; 
          cin>> N >> K >> Q;
           vector<ll> B(N);
          
          for(ll i=0; i<Q; i++){
            ll x;
            cin >> x;
            B.at(x-1)++; 
          }
          
          for(ll i=0; i<N; i++){
            ll y = K - Q + B.at(i); 
            if(y>0){
              cout<< "Yes" << endl;  
            }else{
              cout<< "No" << endl;  
            }
            
          }
          
          
        }

Measured memory_bytes: 1408
#define _USE_MATH_DEFINES
#include <cassert>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <sstream>
#include <vector>
#include <queue>
#include <stack>
#include <list>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <complex>
#include <cmath>
#include <numeric>
#include <bitset>

using namespace std;

#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cerr << name << ": " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
  const char* comma = strchr(names + 1, ',');
  cerr.write(names, comma - names) << ": " << arg1 << " |";
  __f(comma + 1, args...);
}

typedef long long int64;
typedef pair<int, int> ii;
const int INF = 1 << 30;
const int MOD = 1e9 + 7;

const int N = 60;
int x[N], y[N];
int main() {
  int n, m;
  scanf("%d%d", &n, &m);
  vector<int> X, Y;
  for (int i = 0; i < n; ++i) {
    scanf("%d%d", &x[i], &y[i]);
    X.push_back(x[i]);
    Y.push_back(y[i]);
  }
  sort(X.begin(), X.end());
  X.erase(unique(X.begin(), X.end()), X.end());
  sort(Y.begin(), Y.end());
  Y.erase(unique(Y.begin(), Y.end()), Y.end());
  int64 ret = 1LL << 62;
  for (int i = 0; i < X.size(); ++i) {
    for (int j = i + 1; j < X.size(); ++j) {
      for (int u = 0; u < Y.size(); ++u) {
        for (int v = u + 1; v < Y.size(); ++v) {
          int cnt = 0;
          for (int k = 0; k < n; ++k) {
            if (x[k] >= X[i] && x[k] <= X[j] &&
                y[k] >= Y[u] && y[k] <= Y[v]) ++cnt;
          }
          if (cnt >= m) {
            ret = min(ret, (int64)(X[j] - X[i]) * (Y[v] - Y[u]));
          }
        }
      }
    }
  }
  printf("%lld\n", ret);
  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void){
	int x, y, i, tmp;

	for(i = 1; ;i++)
    {
		scanf("%d %d", &x, &y);
		if(x == 0 && y == 0) break;

        if(x > y)
        {
            tmp = y;
            y = x;
            x = tmp;

            printf("%d %d\n", x, y);
        }
		else
        {
            printf("%d %d\n", x, y);
        }
	}

    return 0;
}


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

#define long long long int
using namespace std;

// @author: pashka

int main() {
    ios::sync_with_stdio(false);

    int k, q;
    cin >> k >> q;
    vector<long> d(k);
    for (int i = 0; i < k; i++) {
        cin >> d[i];
    }
    for (int tt = 0; tt < q; tt++) {
        long n, x, m;
        cin >> n >> x >> m;
        x %= m;
        long res = n - 1;
        long s = 0;
        for (int i = 0; i < k; i++) {
//          i + (q - 1) * k <= n - 2
//          q <= (n - 2 - i) / k + 1

            int q = (n - 2 - i + k) / k;
            s += (q * (d[i] % m));

//            cout << q << "\n";

            if (d[i] % m == 0) {
                res -= q;
            }
        }
        long last = x + s;
//        cout << res << " " << last << "\n";

        res -= last / m;
        cout << res << "\n";
    }

    return 0;
}

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

#define lli long long int
#define REP(i,s,l) for(lli i=s;i<l;i++)
#define DEBUG 0
#define INF (1LL<<50)
#define MOD 1000000007

int main()
{
    int n, tmp, in_count = 0;
    int most = 1;
    int count = 0;
    bool flag = true;
    scanf("%d", &n);

    for(int i=n; i>0; i--){
        tmp = i;
        while(flag==true){
            if(tmp%2==0){
                tmp=tmp/2;
                in_count++;
            }
            else{
                flag = false;
            }
        }
        if(count < in_count){
            most = i;
            count = in_count;
        }
        in_count = 0;
        flag = true;
    }
    cout << most << endl;
    return 0;
}

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

int N, K, l[50], ans;

int main() {
  cin >> N >> K;
  for (int i = 0; i < N; i++) cin >> l[i];
  sort(l, l + N, greater<int>());
  for (int i = 0; i < K; i++) ans += l[i];
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
from sys import setrecursionlimit
setrecursionlimit(10 ** 8)

n, m = map(int,input().split())
A = [[int(i) for i in input().split()] for i in range(m)]

if m&1:
    print(-1)
    exit()

E = [[] for i in range(n + 1)]
used_e = [False] * m
ans = []

for i, (a, b) in enumerate(A):
    E[a].append((b, i))
    E[b].append((a, i))

used = [False] * (n + 1)

def dfs(prev, v):
    if used[v]:
        return
    used[v] = True
    cnt = 0

    for to, i in E[v]:
        dfs(v, to)
        if not used_e[i]:
            cnt += 1

    for to, i in E[v]:
        if cnt % 2 == 1 and to == prev:
            continue
        if not used_e[i]:
            ans.append((v, to))
            used_e[i] = True

dfs(0, 1)

for a in ans:
    print(*a)


Measured memory_bytes: 140764
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>
#include <queue>
#include <stack>

typedef long long ll;

using namespace std;

int main(int argc, const char * argv[]) {
  string S;
  cin >> S;
  if(S=="Sunny"){
    cout << "Cloudy";
  }else if(S=="Cloudy"){
    cout << "Rainy";
  }else{
    cout << "Sunny";
  }
}


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

template <typename Graph>
struct StronglyConnectedComponents {
  Graph &g;
  int n;
  vector<vector<int>> gg;
  vector<vector<int>> rg;
  vector<bool> used;
  vector<int> order;
  vector<int> comp;
  StronglyConnectedComponents(Graph &g)
    : g(g), n(g.n), gg(n), rg(n), used(n), order(n), comp(n, -1) {
    for (int v = 0; v < n; v++) {
      for (auto e : g[v]) {
        gg[v].emplace_back(e.to);
        rg[e.to].emplace_back(v);
      }
    }
  }
  void dfs1(int v) {
    if (used[v]) return;
    used[v] = true;
    for (int u : gg[v]) dfs1(u);
    order.push_back(v);
  }
  void dfs2(int v, int c) {
    if (comp[v] != -1) return;
    comp[v] = c;
    for (int u : rg[v]) dfs2(u, c);
  }
  vector<int> build() {
    for (int i = 0; i < n; i++) {
      dfs1(i);
    }
    reverse(order.begin(), order.end());
    int ptr = 0;
    for (int v : order) {
      if (comp[v] == -1) dfs2(v, ptr), ptr++;
    }
    return comp;
  }
};

struct UnWeightedGraph {
  struct Edge {
    int to;
    Edge(int to) : to(to) {}
  };
  vector<vector<Edge>> edges;
  int n;
  UnWeightedGraph(int n) : n(n) {
    edges.assign(n, vector<Edge>());
  }
  void add_edge(int v, int u) {
    edges[v].emplace_back(u);
  }
  vector<Edge> &operator[](int x) {
    return edges[x];
  }
};

int main() {
  int V, E; cin >> V >> E;
  auto graph = UnWeightedGraph(V);
  for (int i = 0; i < E; i++) {
    int s, t; cin >> s >> t;
    graph.add_edge(s, t);
  }
  auto scc = StronglyConnectedComponents<UnWeightedGraph>(graph);
  auto ans = scc.build();
  int Q; cin >> Q;
  for (int i = 0; i < Q; i++) {
    int v, u; cin >> v >> u;
    cout << (ans[v] ==  ans[u]) << '\n';
  }
  return 0;
}



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

using namespace std;

long long k;
long long ans[50];
int main() {
    cin >> k;
    long long n = 50;
    long long mod = k % 50;
    for(int i = 0; i < n; i++) ans[i] = n + (k / n) - mod - 1;
    for(int i = 0; i < mod; i++) {
        ans[i] += (mod + 1);
    }
    cout << n << endl;
    for(int i = 0; i < n; i++) i == 0 ? cout << ans[i] : cout << " " << ans[i];
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <string>
#include <queue>
#include <list>
#include <cmath>
#include <stack>

using namespace std;
typedef long long ll;
using Pll = pair<ll,ll>;

int main() {
    ll N;cin >> N;
    vector<ll> csum(N);
    for(int i=0;i<N;i++) cin >> csum[i];
    multiset<ll> mse;
    set<ll> se;
    mse.insert(0);
    se.insert(0);
    mse.insert(csum[0]);
    se.insert(csum[0]);
    for(int i=1;i<N;i++){
        csum[i]+=csum[i-1];
        mse.insert(csum[i]);
        se.insert(csum[i]);
    }
    ll ans=0;
    for(auto e : se){
        ll tmp=mse.count(e);
        ans+=tmp*(tmp-1)/2;
    }

    cout << ans << endl;
    
    return 0;
}

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

int main() {
  int a,b;
  cin >> a >> b;
  
  if(max(a,b) - min(a,b) >= 1){
    cout << max(a,b)*2 - 1 << endl;
  }
  
  else{
    cout << a*2 << endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#pragma GCC optimize("O3")

#define fi first
#define se second
#define ep emplace
#define eb emplace_back
#define mp make_pair
#define pi pair<int,int>
#define vi vector<int>
#define vpi vector<pair<int,int>>
#define vll vector<ll>
#define vpll vector<pair<ll,ll>>
#define endl '\n'

#define si(v) int((v).size())
#define all(v) (v).begin(), (v).end()
#define rep(i, n) for (ll i = 0; i < (ll)(n); ++i) 
#define rep2(i, n, m) for (ll i = n; i <= (ll)(m); ++i)
#define rep3(i, n, m) for (ll i = n; i >= (ll)(m); --i)

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

using ll = long long;
using ld = long double;
using namespace std;

constexpr ll MOD = 1000000007;

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

  int n; cin >> n;
  vector<string> s(n);
  vector<map<char,int>> mp(n);

  rep(i, n) cin >> s[i];

  rep(i, n) rep(j, si(s[i])) ++mp[i][s[i][j]];

  string ans;
  rep(i, 26) {
    int mn = MOD;
    char c = 'a' + i;

    rep(j, n) chmin(mn, mp[j][c]);

    rep(j, mn) ans += c;
  }

  cout << ans << endl;

  return (0);
}


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

public class Main {
	public static void main(String[] args) {
		Scanner s = new Scanner(System.in);
		String numA = s.nextLine();
		String a = s.nextLine();
		String numB = s.nextLine();
		String b = s.nextLine();

		String[] aa = a.split(" ");
		String[] bb = b.split(" ");

		int[] ai = Arrays.stream(aa).mapToInt(Integer::parseInt).toArray();
		int[] bi = Arrays.stream(bb).mapToInt(Integer::parseInt).toArray();

		int index = 0;
		while (true) {
			if (index >= bi.length) {
				System.out.println(0);
				break;
			} else if (index >= ai.length) {
				System.out.println(1);
				break;
			}

			if (bi[index] > ai[index]) {
				System.out.println(1);
				break;
			} else if (ai[index] > bi[index]) {
				System.out.println(0);
				break;
			}

			index++;
		}
	}
}



Measured memory_bytes: 32872
from collections import UserList


def main():
    _ = input()
    A = Array(input().split(" ")).map(int)
    ans = A.with_index().sort(lambda x: x[1]).map(lambda x: x[0] + 1).join_to_str(" ")
    print(ans)


class Array(UserList):
    def __init__(self, iterable):
        self.data = iterable

    def map(self, f):
        return Array([f(x) for x in self.data])

    def join_to_str(self, sep):
        return sep.join(self.map(str))

    def filter(self, f):
        return Array([x for x in self.data if f(x)])

    def with_index(self):
        return Array([(i, x) for i, x in enumerate(self.data)])

    def sort(self, key):
        return Array(sorted(self.data, key=key))

    def sum(self):
        return sum(self.data)

    def min(self):
        return min(self.data)

    def max(self):
        return max(self.data)

    def fold_left(self, f, init):
        ret = init
        for x in self.data:
            ret = f(ret, x)
        return ret

    def _scan_left(self, f, init):
        ret = init
        for x in self.data:
            ret = f(ret, x)
            yield ret

    def scan_left(self, f, init):
        return Array(list(self._scan_left(f, init)))

    def lower_bound(self, x):
        """x以上になる最小のindex"""
        low = 0
        high = len(self)
        while low < high:
            mid = (low + high) // 2
            if self[mid] < x:
                low = mid + 1
            else:
                high = mid
        return low

    def upper_bound(self, x):
        """xより大きくなる最小のindex"""
        low = 0
        high = len(self)
        while low < high:
            mid = (low + high) // 2
            if self[mid] <= x:
                low = mid + 1
            else:
                high = mid
        return low

    def _distinct(self):
        dic = {}
        for x in self.data:
            if dic.get(x):
                continue
            dic[x] = True
            yield x

    def distinct(self):
        return Array(list(self._distinct()))


if __name__ == "__main__":
    main()


Measured memory_bytes: 78232
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define int ll
#define REP(i, n) FOR(i, 0, n)
#define FOR(i, a, b) for (ll i = a; i < b; i++)
#define ALL(a) (a).begin(), (a).end()
typedef vector<ll> vi;
const ll INF = 1LL << 58;
const ll MOD = 1000000007;

typedef struct
{
    int me;
    vi child;
} node;

const int N_MAX = 200010;

int ans[N_MAX];
node tree[N_MAX];
int dp[N_MAX];

void solve(int id, int p = -1)
{
    auto itr = lower_bound(dp, dp + 200010, tree[id].me);
    int d = distance(dp, itr);
    int old = dp[d];
    dp[d] = tree[id].me;
    ans[id] = d;
    if (p != -1)
    {
        ans[id] = max(ans[id], ans[p]);
    }
    REP(i, tree[id].child.size())
    {
        if (tree[id].child[i] == p)
            continue;
        solve(tree[id].child[i], id);
    }
    dp[d] = old;
}

signed main()
{
    //  以降 cin の入力元が 'input.txt' になる
    //std::ifstream in("input.txt");
    //std::cin.rdbuf(in.rdbuf());
    int N;
    cin >> N;

    REP(i, N)
    {
        cin >> tree[i].me;
    }
    REP(i, N - 1)
    {
        int a, b;
        cin >> a >> b;
        a--;
        b--;
        tree[a].child.push_back(b);
        tree[b].child.push_back(a);
    }

    REP(i, N_MAX)
    {
        dp[i] = INF;
    }
    dp[0] = -1;

    solve(0);

    REP(i, N)
    {
        cout << ans[i] << endl;
    }

    return 0;
}

Measured memory_bytes: 33388
import java.util.Scanner;

public class Main {

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

		if(str.charAt(0) == str.charAt(2)) {
			System.out.println("Yes");
		}else {
			System.out.println("No");
		}


	}

}


Measured memory_bytes: 21844
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <deque>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <cctype>

using namespace std;

#define ll long long
#define ld long double
#define v vector

#define rep(i, n)      for (int i = 0; i < (int)(n); ++i)
#define rep3(i, m, n)  for (int i = (m); i < (int)(n); ++i)
#define rrep(i, n)     for (int i = (int)(n)-1; i >= 0; --i)
#define rrep3(i, m, n) for (int i = (int)(n)-1; i >= (m); --i)
#define all(x) begin(x), end(x)
#define rall(x) end(x), begin(x)

#define endl '\n'


ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }

ll solve(ll X, ll N, const vector<ll> & p) {
  vector<bool> db(110, 0);
  ll res;
  rep(i, N)
    db[p[i]] = true;

  ll i = X;
  while (db[i] == true && i < 110) ++i;
  res = i;
  i = X;
  while (db[i] == true && 0 <= i) --i;

  if (X-i <= res-X) return i;
  else return res;
}

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

  ll X, N;
  cin >> X >> N;
  if (N == 0) {
    cout << X << endl;
    return 0;
  }
  vector<ll> p(N);
  rep (i, N) {
    cin >> p[i];
  }

  auto ans = solve(X, N, p);
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 3196
#include <bits/stdc++.h>
using namespace std;
long long int ans;
long long int n;
void dfs(long long int tmp, bool flag3, bool flag5, bool flag7){
    if(tmp > n){//nより大きくなったらそこの探索終わり
        return;
    }

    if(flag3 && flag5 && flag7){
        //cout << tmp << endl;
        ans++;
    }

    dfs(tmp*10 + 3, true, flag5, flag7);//3を末尾に追加
    dfs(tmp*10 + 5, flag3, true, flag7);//5を末尾に追加
    dfs(tmp*10 + 7, flag3, flag5, true);//7を末尾に追加
}

int main(){
    ans = 0;
    cin >> n;
    dfs(0, 0, 0, 0);
    cout << ans << endl;
}

Measured memory_bytes: 3572
import java.io.*;
import java.lang.*;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.BufferedReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.io.IOException;
import java.util.StringTokenizer;
import java.math.BigInteger;

public class Main {
    static InputReader in = new InputReader(System.in);
    static PrintWriter out = new PrintWriter(System.out);

    public static void main(String[] args) {
        String s = in.next();
        if(s.contains("7")) out.println("Yes");
        else out.println("No");
        out.close();
    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

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

        public int nextInt() {
            return Integer.parseInt(next());
        }

        public long nextLong() {
            return Long.parseLong(next());
        }

        public double nextDouble() {
            return Double.parseDouble(next());
        }

        public String nextLine() {
            try {
                return reader.readLine();
            } catch (Exception e) {
                e.printStackTrace();
            }
            return null;
        }

        public boolean hasNext() {
            String next = null;
            try {
                next = reader.readLine();
            } catch (Exception e) {
            }
            if (next == null) {
                return false;
            }
            tokenizer = new StringTokenizer(next);
            return true;
        }

        public BigInteger nextBigInteger() {
            return new BigInteger(next());
        }
    }
}



Measured memory_bytes: 32824
def main():
    from collections import deque
    H, W = (int(i) for i in input().split())
    Ch, Cw = (int(i)-1 for i in input().split())
    Dh, Dw = (int(i)-1 for i in input().split())
    A = [input() for i in range(H)]
    V = [-1]*((H-1)*W + W)  # 頂点i

    def bfs_2d(sy, sx, v):
        que = deque()
        V[sy*W+sx] = v
        que.append(sy*W+sx)
        d = ((0, -1), (0, 1), (-1, 0), (1, 0))
        while que:
            u = que.popleft()
            uh, uw = u//W, u % W
            for dy, dx in d:
                next_h = uh + dy
                next_w = uw + dx
                if not(0 <= next_h < H and 0 <= next_w < W):
                    continue
                if V[next_h*W+next_w] != -1:
                    continue
                if A[next_h][next_w] == '#':
                    continue
                V[next_h*W+next_w] = v
                que.append(next_h*W + next_w)

    vertex = 0
    for h in range(H):
        for w in range(W):
            if A[h][w] == "#" or V[h*W+w] != -1:
                continue
            bfs_2d(h, w, vertex)
            vertex += 1

    G = [[] for _ in range(vertex)]
    used = [set() for _ in range(vertex)]
    for h in range(H):
        for w in range(W):
            if A[h][w] == "#":
                continue
            for dh in range(-2, 3):
                for dw in range(-2, 3):
                    if h + dh < 0 or H <= h + dh or w + dw < 0 or W <= w + dw:
                        continue
                    if A[h+dh][w+dw] == "#":
                        continue
                    if V[h*W+w] == V[(h+dh)*W + w+dw]:
                        continue
                    if V[(h+dh)*W + w+dw] in used[V[h*W+w]]:
                        continue
                    G[V[h*W+w]].append(V[(h+dh)*W + w+dw])
                    used[V[h*W+w]].add(V[(h+dh)*W + w+dw])

    # print(V)
    # for i in range(vertex):
    #     print(G[i])

    def bfs(s, g, N):
        que = deque([s])
        dist = [-1]*N
        dist[s] = 0
        while que:
            v = que.popleft()
            for i in G[v]:
                if dist[i] != -1:
                    continue
                que.append(i)
                dist[i] = dist[v] + 1
        return dist[g]

    s = V[Ch*W+Cw]
    g = V[Dh*W+Dw]
    ans = bfs(s, g, vertex)
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 145296
#include<bits/stdc++.h>
#define lli long long int
#define ulli unsigned long long int
#pragma GCC target ("sse4.2")
using namespace std;
#define fast ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL)
#define time cout<<"\nTime Elapsed: " << 1.0*clock() / CLOCKS_PER_SEC << " sec\n";

int main()
{


    lli n;
    cin>>n;
    lli sum=0;
    vector<lli>v;
    for(lli i=0;i<n;i++)
    {
        lli a;
        cin>>a;
        v.push_back(a);
    }
    lli minn=INT_MAX;
    for(lli i=1;i<=100;i++)
    {
        lli total=0;
        for(lli j=0;j<n;j++)
        {
            total+=(i-v[j])*(i-v[j]);
        }
        minn=min(total,minn);
    }
    cout<<minn;
    return 0;


}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll INF = 1LL << 60;

int main() {
    int n;
    cin >> n;
    vector<int> a(n + 1), b(n);
    for (int i = 0; i < n + 1; i++) {
        cin >> a.at(i);
    }
    for (int i = 0; i < n; i++) {
        cin >> b.at(i);
    }
    ll cnt = 0;
    for (int i = 0; i < n + 1 / 2; i++) {
        //最初
        if (a.at(i) < b.at(i)) {
            cnt += a.at(i);
            b.at(i) -= a.at(i);
            a.at(i) = 0;
            if (a.at(i + 1) > b.at(i)) {
                cnt += b.at(i);
                a.at(i + 1) -= b.at(i);
                b.at(i) = 0;
            } else {
                cnt += a.at(i + 1);
                b.at(i) -= a.at(i + 1);
                a.at(i + 1) = 0;
            }
        } else {
            cnt += b.at(i);
            a.at(i) -= b.at(i);
            b.at(i) = 0;
        }

        //最後
        if (a.at(n - i) < b.at(n - i - 1)) {
            cnt += a.at(n - i);
            b.at(n - i - 1) -= a.at(n - i);
            a.at(n - i) = 0;
            if (a.at(n - i - 1) > b.at(n - i - 1)) {
                cnt += b.at(n - i - 1);
                a.at(n - i - 1) -= b.at(n - i - 1);
                b.at(n - i - 1) = 0;
            } else {
                cnt += a.at(n - i - 1);
                b.at(n - i - 1) -= a.at(n - i - 1);
                a.at(n - i - 1) = 0;
            }
        } else {
            cnt += b.at(n - i - 1);
            a.at(n - i) -= b.at(n - i - 1);
            b.at(n - i - 1) = 0;
        }
    }
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 3972
#include <bits/stdc++.h>
// #include <iostream>
// #include <vector>
// #include <map>
// #include <algorithm>
using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())

template<typename T>
T mod(T a, T b){
    return (a + b) % b;
}

template<typename T>
T gcd(T a, T b){
    if (b == 0) return a;
    return gcd(b, a % b);
}

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

// n を素因数分解
map<ll, ll> factor(ll n){
    map<ll, ll> mp;
    for (ll i = 2; i*i <= n; i++) {
        while (n % i == 0) {
            mp[i]++;
            n /= i;
        }
    }

    if (n > 1) {
        mp[n]++;
    }

    return mp;
}

// 文字列に "hoge" が含まれているか
// string str = "hogepiyo";
// if (str.find("hoge") != string::npos) {
//     cout << "文字列が含まれています" << endl;
// }

void solve(){
    ll N, x;
    cin >> N >> x;

    ll ans = 0;
    vector<ll> a(N);
    for (int i = 0; i < N; i++) {
        cin >> a[i];
        if (a[i] > x) {
            ans += a[i] - x;
            a[i] = x;
        }
    }

    ll prev = 0;
    for (int i = 1; i < N; i++) {
        if (x < a[i-1] + a[i] - prev) {
            prev = (a[i-1] + a[i] - prev) - x;
            // cout << prev << endl;
            ans += prev;
        } else {
            prev = 0;
        }
    }

    cout << ans << endl;

    return;
}

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


Measured memory_bytes: 1024
import java.util.*;

public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
        Scanner sc = new Scanner(System.in);
        
		int a = sc.nextInt();
		int b = sc.nextInt();
		int k = sc.nextInt();
		for(int i = 0; i < k; i++) {
			if(a % 2 == 1) {
				a = a - 1;
			}
			
			b = (a/2) + b;
			a = a/2;
			i++;
			if(i >= k) {
				break;
			}
			
			if(b % 2 == 1) {
				b = b - 1;
			}
			
			a = (b/2) + a;
			b = b/2;
		}
		System.out.println(a + " " + b);
	}

}

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

int main(){
    double N,K;
    cin >> N >> K;
    double p = 0.0;

    for(int x=1; x <= N; ++x){

        for(int a=0; a<1000000; ++a){
        if(x*pow(2,a) >= K){
            p += pow(0.5,a)/N;
            break;
        }
        }
    }

    cout << setprecision(10) << p << endl;
    
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <math.h>

using namespace std;


int main(){
	long a,b;
	cin >> a >> b;
	
	long p=max(a,b)-min(a,b);
	long sum=0;
	for(long i=1;i<=p;i++){
		sum+=i;
	}
	cout << sum-max(a,b) << endl;
}



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

namespace AtCoder0627
{
	class Program
	{
		static void Main(string[] args)
		{
			D();
		}

		private static void D()
		{
			long n = long.Parse(Console.ReadLine());
			long s = 0;

			for (long i = 1; i <= n; i++)
			{
				var count = n / i;
				s += ((count + 1) * count / 2) * i;
			}

			Console.WriteLine(s);
		}

		private static void C()
		{
			var ints = Console.ReadLine().Split().Select(x => long.Parse(x)).ToArray();
			var n = ints[0];
			var m = ints[1];
			long k = ints[2];

			var a = Console.ReadLine().Split().Select(x => long.Parse(x)).ToArray();
			var b = Console.ReadLine().Split().Select(x => long.Parse(x)).ToArray();
			long max = 0;
			var sa = InclusiveSums(a);
			var sb = InclusiveSums(b);
			long sum = 0;

			for (int i = 0; i <= Math.Max(n, m); i++)
			{
				var maxOnlyA = UpperBound(i, a.Length, t => sa[t] - sa[i] <= k - sum) - i;
				var maxOnlyB = UpperBound(i, b.Length, t => sb[t] - sb[i] <= k - sum) - i;

				max = Math.Max(max, Math.Max(maxOnlyA, maxOnlyB) + 2 * i);
				if (i >= n || i >= m || sum + a[i] + b[i] > k)
					break;

				sum += a[i];
				sum += b[i];
			}

			Console.WriteLine(max);
		}

		public static long[] InclusiveSums(long[] list)
		{
			if (list.Length == 0)
				return Array.Empty<long>();

			var result = new long[list.Length + 1];
			result[0] = 0;
			for (int i = 0; i < result.Length - 1; i++)
				result[i + 1] = result[i] + list[i];

			return result;
		}

		public static long UpperBound(long min, long max, Predicate<long> test)
		{
			long ans = min;
			long s = min;
			long e = max;
			while (s <= e)
			{
				long mid = (s + e) / 2;
				if (test(mid))
				{
					ans = mid;
					s = mid + 1;
				}
				else
					e = mid - 1;
			}

			return ans;
		}

		private static void B()
		{
			var s = Console.ReadLine();
			var t = Console.ReadLine();
			var count = Enumerable.Range(0, s.Length).Count(x => s[x] != t[x]);
			Console.WriteLine(count);
		}

		private static void A()
		{
			var a = int.Parse(Console.ReadLine());
			Console.WriteLine(a + a * a + a * a * a);
		}
	}
}


Measured memory_bytes: 27480
#include<iostream>
#include<sstream>
#include<fstream>
#include<string>
#include<vector>
#include<deque>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<algorithm>
#include<functional>
#include<utility>
#include<bitset>
#include<cmath>
#include<cstdlib>
#include<ctime>
#include<cstdio>

using namespace std;

#define REP(i,n) for(int i=0;i<int(n);i++)
#define foreach(c,itr) for(__typeof((c).begin()) itr=(c).begin();itr!=(c).end();itr++)
typedef long long ll;
typedef pair<int,int> P;

const ll MOD=1000000007;

int main(void){
	          int i;

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

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

	      	  if(n==1){
	      		  cout << (m+1)%MOD << endl;
	      		  return 0;
	      	  }

	      	  ll ans=0;
	      	  ll N=m/(n-1LL);

	      	  ans=(((2*m+2)%MOD)*(N%MOD))%MOD;
	      	  ll u=(((n-1)%MOD)*(N%MOD))%MOD;
	      	  u=(u*((N+1)%MOD))%MOD;
	      	  ans-=u;
	      	  ans+=(m+1)%MOD;

	      	  cout << (ans+MOD)%MOD << endl;



	          return 0;
}

Measured memory_bytes: 3152
#include<iostream>
#include<cmath>

using namespace std;

int isPrime(int a) {
  int flag = 1;
  if(a<2) {
    return 0;
  }
  for(int i=2; i<sqrt(a)+1 && flag==1; i++) {
    if(a%i==0 && a!=i) {
      flag = 0;
    }
  }
  return flag;
}

int main() {
  int a, d, n;
  while(cin>>a>>d>>n && a>0 && d>0) {
    int count = 0;
    int i = 0;
    while(count<n) {
      if(isPrime(a+d*i)) {
	count++;
	if(count == n) {
	  cout<<a+d*i<<endl;
	}
      }
      i++;
    }
  }
}

Measured memory_bytes: 1160
#include <iostream>
#include <vector>
#include <numeric>

using namespace std;

int main()
{
    int N;
    cin>>N;
    vector<int> a(N);
    for (int &t: a)
        cin>>t;

    int S = accumulate(a.begin(), a.end(), 0);
    long long M = 998244353;
    vector<long long> T(S+1), T2(S+1);
    T[0] = 1;
    T2[0] = 1;
    for (int i=0; i<N; i++)
    {
        vector<long long> P = T;
        T = vector<long long>(S+1);
        vector<long long> P2 = T2;
        T2 = vector<long long>(S+1);
        for (int j=0; j<=S; j++)
        {
            if (P[j] != 0)
            {
                T[j+a[i]] += P[j];
                T[j+a[i]] %= M;
                T[j] += 2*P[j];
                T[j] %= M;
            }
            if (P2[j] != 0)
            {
                T2[j+a[i]] += P2[j];
                T2[j+a[i]] %= M;
                T2[j] += P2[j];
                T2[j] %= M;
            }
        }
    }

    long long ans = 1;
    for (int i=0; i<N; i++)
    {
        ans *= 3;
        ans %= M;
    }
    for (int i=(S+1)/2; i<=S; i++)
    {
        ans -= T[i]*3;
        ans += M;
        ans %= M;
    }
    if (S%2==0)
    {
        ans += T2[S/2]*3;
        ans %= M;
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 3808