akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cctype>
#include <cstring>
#include <iomanip>
#include <bitset>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <list>
#include <map>

using namespace std;

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

int main() {
  int n;
  cin >> n;
  long long ans = -1;
  for (int i = 0; i < n; i++) {
    long long x;
    cin >> x;
    if (ans == -1) {
      ans = x;
    } else {
      ans = gcd(ans, x);
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
  public static void main(String args[]) {
    Scanner scan = new Scanner(System.in);
    int N = scan.nextInt();
    int W = scan.nextInt();
    int[][] weightValues = new int[2][N];

    for (int i = 0; i < N; i++) {
      for (int j = 0; j < 2; j++) {
        weightValues[j][i] = scan.nextInt();
      }
    }
    scan.close();
    
    System.out.println(knapsack(weightValues, N, W));
  }

  private static long knapsack(int[][] weightValues, int N, int W) {
    if (N == 0 || W == 0)
      return 0;

    long[][] dp = new long[N][W + 1];

    for (int i = 0; i < dp.length; i++) {
      for (int j = 1; j < dp[0].length; j++) {
        int currentWeight = weightValues[0][i];
        int weightLeftover = j - currentWeight;
        if (weightLeftover < 0) {
          dp[i][j] = i == 0 ? 0 : dp[i-1][j];
        } else {
          int currentValue = weightValues[1][i];
          long additionalValue = i == 0 ? 0 : dp[i-1][weightLeftover];
          long oldValue = i == 0 ? 0 : dp[i-1][j];
          dp[i][j] = Math.max(oldValue, currentValue + additionalValue);
        }
      }
    }
    
    //for (long[] a : dp)
      //System.out.println(Arrays.toString(a));
    
    return dp[dp.length - 1][dp[0].length - 1];
  }

}


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

int main() {
	long long int X;
	cin >> X;
	long long money;
	money = 100;
	double i = 1.01;
	int count = 0;
	while (money < X)
	{
		money += money * 0.01;
		count++;
	}
	cout << count << endl;
}

Measured memory_bytes: 3628
x, k, d = map(int, input().split())

pm = 1 if x > 0 else -1
a = abs(x) // abs(d)
if abs(x-pm*d*a) > abs(x-pm*d*(a+1)):
    a = a + 1
if k <= a:
    print(abs(x-pm*d*k))
elif (k-a) % 2 == 0:
    print(abs(x-pm*d*a))
else:
    print(min(abs(x-pm*d*(a+1)), abs(x-pm*d*(a-1))))

Measured memory_bytes: 9132
#include<stdio.h>

int main(void)
{
  int s;
  int h, m;
  scanf("%d", &s);

  m = s / 60;
  s = s - m * 60;
  h = m / 60;
  m = m - h * 60;

  printf("%d:%d:%d\n", h, m, s);

  return 0;
}

Measured memory_bytes: 1848
#include<bits/stdc++.h>
#include<vector>
#include<string>
#include<stack>
#include<iostream>
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define ll long long
#define MOD 1000000007
#define vec(a) vector<int>a
using namespace std;

bool isPrime(ll n)
{
	if(n==1||n==2||n==3||n==5||n==7)
		return 1;
	else
	{
		ll i,j,k,l,m;
		for(i=2;i<=sqrt(n);i++)
		{
			if(n%i==0)
				return 0;
		}
		return 1;
	}
}

int main()
{
#ifndef ONLINE_JUDGE
	freopen("output.txt", "w", stdout);
	freopen("input.txt", "r", stdin);
#endif
	ll arr[3];
	cin>>arr[0]>>arr[1]>>arr[2];
	sort(arr,arr+3);
	cout<<arr[0]+arr[1];
	return 0;
}
	

Measured memory_bytes: 3676
#include <bits/stdc++.h>
using namespace std;
int main()
{
    vector<string> x;
    int tmp;
    while (1)
    {
        cin >> tmp;
        if (tmp == 0)
            break;
        x.push_back("Case " + to_string(x.size() + 1) + ": " + to_string(tmp));
    }
    for (int i = 0; i < x.size(); i++)
    {
        cout << x[i] << endl;
    }
    //system("pause");
    return 0;
}


Measured memory_bytes: 3896
#include<algorithm>
#include<complex>
#include<ctype.h>
#include<iomanip>
#include<iostream>
#include<map>
#include<math.h>
#include<numeric>
#include<queue>
#include<set>
#include<stack>
#include<stdio.h>
#include<string>
#include<string>
#include<vector>

using namespace std;
typedef long long ll;

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define ALL(v) (v).begin(), (v).end()
#define p(s) cout<<(s)<<endl
#define p2(s, t) cout << (s) << " " << (t) << endl
#define pn(s) cout << (#s) << " " << (s) << endl

const ll mod = 1e9 + 7;
const ll inf = 1e18;

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

    // input
    string a, b;
    cin >> a >> b;

    ll c = stoi(a+b);

    FOR(i, 0, 400){
        if(c == i*i){
            p("Yes");
            return 0;
        }
    }    
    
    p("No");
    return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize ("O3")
#pragma GCC optimize("unroll-loops")
#include"bits/stdc++.h"
using namespace std;
typedef long long ll;
#define int ll

int32_t main()
{
	#ifdef ONLINE_JUDGE
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	#endif
	
	int x,y,a,b,c;
	cin>>x>>y>>a>>b>>c;
	vector<int> red(a);for(auto &i:red)cin>>i;
	vector<int> gre(b);for(auto &i:gre)cin>>i;
	vector<int> col(c);for(auto &i:col)cin>>i;
	sort(red.rbegin(),red.rend());
	sort(gre.rbegin(),gre.rend());
	for(int i=0;i<x;i++)col.push_back(red[i]);
	for(int i=0;i<y;i++)col.push_back(gre[i]);
	sort(col.rbegin(),col.rend());
	
	int ans=accumulate(col.begin(),col.begin()+x+y,0LL);
	cout<<ans;

	
}

Measured memory_bytes: 7788
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
constexpr int di[] = { 0, 1, 0, -1 }, dj[] = { 1, 0, -1, 0 };
#define rep(i, n) for (int i = 0; i < n; i++)
#define repr(i, n) for (int i = n; i >= 0; i--)
#define sort(v) sort((v).begin(), (v).end())
#define sortr(v) sort((v).rbegin(), (v).rend())
#define all(v) (v).begin(), (v).end()
#define MAX 2000001
#define vmax 10000
constexpr ll inf = 1000000000000;
/*cout<<fixed<<setprecision(20);cin.tie(0);ios::sync_with_stdio(false);*/

struct edge{
    int to,cost;
};

vector<vector<edge>> g;
vector<ll> d;
int V;

void dij(int s){
    priority_queue<P,vector<P>,greater<P>> que;
    d.resize(V+1);
    fill(d.begin(),d.end(),inf);
    d[s]=0;
    que.push(P(0,s));
    while(!que.empty()){
        P p=que.top();que.pop();
        int v=p.second;
        if(d[v]<p.first) continue;
        for(auto e:g[v]){
            if(d[e.to]>d[v]+e.cost){
                d[e.to]=d[v]+e.cost;
                que.push(P(d[e.to],e.to));
            }
        }
    }

}


int main() {
    int E,r,s,t,c;
    cin>>V>>E>>r;
    d.resize(V+1);
    g.resize(V+1);
    for(int i=0;i<E;i++){
        cin>>s>>t>>c;
        g[s].push_back({t,c});
    }

    dij(r);

    for(int i=0;i<V;i++){
        if(d[i]==inf){
            cout<<"INF"<<endl;
        }else{
            cout<<d[i]<<endl;
        }
    }
    return 0;
}














Measured memory_bytes: 13272
#pragma GCC optimize("Ofast,inline,unroll-loops,fast-math")
#include <iostream>
#include <algorithm>
#include <cstdio>
#define N 2020
using namespace std;

int a[N];
int f[N];

int main(void)
{
    int n;
    int i, j;
    long long o;

    cin >> n;
    for(i = 0; i < n; i ++)
    {
        cin >> a[i];
        f[a[i]] ++;
    }
    for(i = 1; i < N; i ++)
        f[i] += f[i - 1];
    sort(a, a + n);

    // for(i=0;i<n;i++)cout<<a[i]<<' ';cout<<endl;
    for(i = o = 0; i < n; i ++)
        for(j = i + 1; j < n; j ++)
        {
            o += f[a[i] + a[j] - 1] - f[max(a[i] - a[j], a[j] - a[i])];
            if(a[i] + a[i] > a[j])
                o --;
            if(a[j] + a[j] > a[i])
                o --;
        }
    cout << o / 3 << endl;

    return 0;
}


Measured memory_bytes: 256
// Template
#include "bits/stdc++.h"
#define rep_override(x, y, z, name, ...) name
#define rep2(i, n) for (int i = 0; i < (int)(n); ++i)
#define rep3(i, l, r) for (int i = (int)(l); i < (int)(r); ++i)
#define rep(...) rep_override(__VA_ARGS__, rep3, rep2)(__VA_ARGS__)
#define per(i, n) for (ll i = (ll)(n) - 1; i >= 0; --i)
#define all(x) (x).begin(), (x).end()
using namespace std;
using ll = long long;
constexpr int inf = 1001001001;
constexpr ll INF = 3003003003003003003LL;
template <typename T>
inline bool chmin(T &x, const T &y) {
    if (x > y) {
        x = y;
        return true;
    }
    return false;
}
template <typename T> 
inline bool chmax(T &x, const T &y) {
    if (x < y) {
        x = y;
        return true;
    }
    return false;
}
struct IOSET {
    IOSET() {
        cin.tie(nullptr);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(10);
    }
} ioset;

// Main
int main() {
    auto st = chrono::high_resolution_clock::now();
    auto tim = [&]() {
        auto ed = chrono::high_resolution_clock::now();
        return chrono::duration_cast<chrono::milliseconds>(ed - st).count();
    };

    int d;
    cin >> d;
    vector<int> c(26);
    rep(i, 26) cin >> c[i];
    vector<vector<int>> s(d, vector<int>(26));
    rep(i, d) rep(j, 26) cin >> s[i][j];

    vector<int> t(d);
    vector<vector<int>> ds(26);
    int score = 0;
    auto rescore = [&](int x, int y) {
        if (y == t[x]) return;
        int mn = -inf, mx = inf;
        for (int i : ds[t[x]]) {
            if (i < x) chmax(mn, i);
            if (i > x) chmin(mx, i);
        }
        score -= s[x][t[x]];
        score += (x - mn) * (x - mn - 1) / 2 * c[t[x]];
        score += (mx - x) * (mx - x - 1) / 2 * c[t[x]];
        score -= (mx - mn) * (mx - mn - 1) / 2 * c[t[x]];
        mn = -inf, mx = inf;
        for (int i : ds[y]) {
            if (i < x) chmax(mn, i);
            if (i > x) chmin(mx, i);
        }
        score += s[x][y];
        score += (mx - mn) * (mx - mn - 1) / 2 * c[y];
        score -= (x - mn) * (x - mn - 1) / 2 * c[y];
        score -= (mx - x) * (mx - x - 1) / 2 * c[y];
        vector<int> new_;
        for (int i : ds[t[x]]) if (i != x) new_.push_back(i);
        ds[t[x]] = new_;
        new_.clear();
        rep(i, ds[y].size()) {
            if (ds[y][i] > x && ds[y][i - 1] < x) new_.push_back(x);
            new_.push_back(ds[y][i]);
        }
        ds[y] = new_;
        t[x] = y;
    };

    vector<int> last(26, -1);
    rep(i, d) {
        int mx = -inf, idx = -1;
        rep(j, 26) {
            if (chmax(mx, (i - last[j]) * c[j] * 13 + s[i][j])) idx = j;
        }
        t[i] = idx;
        last[t[i]] = i;
    }
    last = vector<int>(26, -1);
    rep(i, d) {
        score += s[i][t[i]];
        last[t[i]] = i;
        rep(j, 26) score -= (i - last[j]) * c[j];
    }
    rep(i, 26) ds[i].push_back(-1);
    rep(i, d) ds[t[i]].push_back(i);
    rep(i, 26) ds[i].push_back(d);

    rep(i, d) cout << t[i] + 1 << "\n";
}

Measured memory_bytes: 3684
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <limits.h>


/*
 * ?????????????´¢???rolling-hash???
 * String??????????????????Pattern????????????????????????
 * !!????????????????????????????????¨?????????????????¨?????¨???????¶???????????´¢???????????????!!
 * ??????????????????http://www.algolism.iinaa.net/80/83.htm#L3
 *
 */

char String[1000001];
char Pattern[10001];


typedef unsigned long long ull;
#define P (1000000007)
#define MOD (1000007)

/*
 * string:????´¢????±??????????
 * s_num:????´¢????±???????????????????
 * pattern:????´¢??????????????????
 * p_num:????´¢???????????????????????????
 */
void rolling_hash(char * string, int s_num, char * pattern, int p_num)
{
    int i;
    ull pow = 1, target_hash = 0, pattern_hash = 0;
    
    for (i=0; i < p_num; i++) {
        pow *= P;
    }
    
    for (i=0; i < p_num; i++) {
        pattern_hash = (pattern[i] + pattern_hash * P) ;
    }
    for (i=0; i < p_num; i++) {
        target_hash = (string[i] + target_hash * P) ;
    }
    
    
    for (i = 0; i < s_num; i++) {
        if (target_hash == pattern_hash) {
            printf("%d\n", i);
        }
        target_hash = target_hash * P - pow * string[i] + string[i + p_num] ;
    }
    
    return;
}


int main( ){
    
    scanf("%s", String);
    scanf("%s", Pattern);
    
    rolling_hash(String, strlen(String), Pattern, strlen(Pattern));
   
    
    return 0;
}

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

int main() {
	long long n, ans = 0;
	cin >> n;

	for (long long a = 1; a*a <= n; a++) {
		if (n%a == 0) {
			ans = a + n/a - 2;
		}
	}
	cout << ans << endl;
}

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

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

  for(int i = 0; i < S.size()/2 + 1; i++){
    if(S.at(i) != S.at(S.size()-i-1)){
      cout << "No" << endl;
      return 0;
    }
  }
  
  string M = S.substr(0, S.size()/2);
  
  for(int i = 0; i < M.size()/2 + 1; i++){
    if(M.at(i) != M.at(M.size()-i-1)){
      cout << "No" << endl;
      return 0;
    }
  }
  
  string N = S.substr(S.size()/2 + 1, S.size()/2);
  
  for(int i = 0; i < N.size()/2 + 1; i++){
    if(N.at(i) != N.at(N.size()-i-1)){
      cout << "No" << endl;
      return 0;
    }
  }
  
 cout << "Yes" << endl;
}

Measured memory_bytes: 256
#include <iomanip>
#include <tuple>
#include <vector>
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <functional>
using namespace std;
using ll	= long long;
using ull	= unsigned long long;
using ld	= long double;
using pii	= pair<int,int>;
using pll	= pair<ll,ll>;
using vi	= vector<int>;
using vb	= vector<bool>;
using vc	= vector<char>;
using vvi	= vector<vi>;
using vvb	= vector<vb>;
using vpii	= vector<pii>;
using vpll	= vector<pll>;
using vll	= vector<ll>;
using vull	= vector<ull>;
using vvll	= vector<vll>;
#define ever (;;)
#define f first
#define s second
#define pb emplace_back
#define sz size()
#define graph vector<vertex>
#define deg(X) (int)G[X].e.size()
#define INF 1234567890
#define INFll 2000000000000000000
#define maxe(X, Y) if((Y) > (X)) (X) = (Y)
#define mine(X, Y) if((Y) < (X)) (X) = (Y)
#define rep(i, begin, end) for(__typeof(end) i = (begin); i < (end); ++i)
#define repr(i, begin, end) for(__typeof(end) i = (begin)-1; i >= (end); --i)
#define bend(X) X.begin(), X.end()
pii operator+(const pii& A, const pii& B) { return {A.f+B.f, A.s+B.s}; }
pii operator-(const pii& A, const pii& B) { return {A.f-B.f, A.s-B.s}; }
pii operator-(const pii& A) { return {-A.f, -A.s}; }

//
// END OF DEFINES
//

int n;
vector<ld> T;
vector<vector<ld>> DP;

bool in() {
	cin >> n;
	T.resize(n+1);
	DP.resize(n+1, vector<ld>(n+1));
	rep(i, 1, n+1)
		cin >> T[i];
	
	return true;
}

ll solve() {
	
	DP[1][1] = T[1];
	DP[1][0] = 1-T[1];
	
	rep(i, 2, n+1)
		rep(j, 0, i) {
			// heads
			DP[i][j+1] += DP[i-1][j]*T[i];
			// tails
			DP[i][j] += DP[i-1][j]*(1-T[i]);
		}
	
	ld R = 0;
	rep(i, (n+1)/2, n+1)
		R += DP[n][i];
	
	cout << fixed << setprecision(10) << R << '\n';
	
	return -INF;
}

int main() {
	int noOfTests = 1;
	//scanf("%d", &noOfTests);
	
	while(noOfTests --> 0) {
		if(!in()) {
			printf("popsute wejscie\n");
			continue;
		}
		ll result = solve();
		if(result == ll(-'t'))
			printf("TAK\n");
		else if(result == ll(-'n'))
			printf("NIE\n");
		else if(result != -INF)
			printf("%lld\n", result);
	}
	
	return 0;
}


Measured memory_bytes: 141312
#include<stdio.h>
int main(){
  int n,a,b=0,c=0,i,mi;
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&a);
    if(a>b){
      b=a;
      if(a>c){
	mi=i;
	b=c;
	c=a;
      }
    }
  }
  for(i=0;i<n;i++)printf("%d\n",i==mi?b:c);
  return 0;
}


Measured memory_bytes: 1536
N = int(input())
a = list(map(int, input().split()))
m = min(a)
M = max(a)


flag = 1
plus = 0
minus = 0
for x in a:
    if x > 0:
        plus += 1
    elif x < 0:
        minus += 1
if m*M < 0:
    if m + M >= 0:
        id = a.index(M)
        print(minus + N-1)
        for i in range(N):
            if a[i] < 0:
                a[i] += M
                print(id+1, i+1)

    else:
        id = a.index(m)
        print(plus + N-1)
        for i in range(N):
            if a[i] > 0:
                a[i] += m
                print(id+1, i+1)

        flag = 0

else:
    print(N-1)
    if m < 0:
        flag = False


if flag:  # 正の数列
    # M = max(a)
    # id = a.index(M)
    for i in range(1, N):
        # if i == 0:
        #     a[i] += M
        #     print(id+1, 1)
        # else:
        a[i] += a[i-1]
        print(i, i+1)

else:
    # m = min(a)
    # id = a.index(m)
    for i in range(N-2, -1, -1):
        # if i == N-1:
        #     a[i] += m
        #     print(id, i+1)
        # else:
        a[i] += a[i+1]
        print(i+2, i+1)
# print(a)


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

using namespace std;

#define boost ios::sync_with_stdio(0);cin.tie(0);
#define debug(s) cout << #s << " = " << s << endl
#define forn(i,n) for ( int i=0 ; i < n ; i++ )
#define all(a) (a).begin(), (a).end()
#define lb lower_bound
#define ub upper_bound
#define F first
#define S second
#define MP make_pair
#define PB push_back
#define ll long long
#define endl '\n'
#define mod 1000000007

int main()
{
    //freopen ("f.in","r",stdin);
    //freopen ("f.out","w",stdout);
    boost
    //code
    int n;
    cin >> n;
    int sum = 0;
    vector<int> v(n);
    forn(i,n){
        cin >> v[i];
        sum += v[i];
    }
    int diff = INT_MAX;
    int ans = 0;
    forn(i,n){
        if(diff>abs(sum-n*v[i])){
            diff = abs(sum-n*v[i]);
            ans = i;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
class Program{
	static void Main(){
		string s=Console.ReadLine();
		int n=s.Length,ans=0;
		int[,,,] dp=new int[n+1,2,2,8];
		dp[0,0,0,0]=1;
		for(int i=0;i<n;i++){
			for(int j=0;j<2;j++){
				for(int k=0;k<2;k++){
					for(int l=0;l<8;l++){
						int lm=j==0?Math.Min(s[i]-'0',8):7;
						for(int d=k*3;d<=lm;d=(d|1)+2){
							int q=0;
							if((l&1)==1||d==3){q|=1;}
							if((l&2)==2||d==5){q|=2;}
							if((l&4)==4||d==7){q|=4;}
							dp[i+1,(j==1||d<lm)?1:0,(k==1||d!=0)?1:0,q]+=dp[i,j,k,l];
						}
					}
				}
			}
		}
		for(int j=0;j<2;j++){ans+=dp[n,j,1,7];}
		Console.WriteLine("{0}",ans);
	}
}

Measured memory_bytes: 13140
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <tuple>
#include <cmath>
#include <algorithm>
#include <map>
#include <iomanip>
#include <queue>

using namespace std;



int main() {

    int A, B;
    cin >> A >> B;

    if ((B % A) == 0) {
        cout << (A + B) << "\n";
    } else {
        cout << (B - A) << "\n";
    }

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <algorithm>
using namespace std;
#include <cstdio>
#include <tuple>
#include <string>
#include <vector> 
#include <set>
#include <string.h>
#include <map>
#include <cmath>
#include <deque>
using ll = long long;
using Graph = vector<vector<int>>;
#include <queue>
#include <stack>
#include <stdlib.h>

int main(){
    
    string a;
    cin >> a;
    bool flag = true;
    string a0 = a;
    int n = a.length();
    string a1_0 = a.substr(0,(n - 1)/2);
    string a1_1 = a.substr(0,(n - 1)/2);
    
    string a2_0 = a.substr((n + 3)/2 - 1);
    string a2_1 = a.substr((n + 3)/2 - 1);
    string a3; 
    //条件１
    reverse(a.begin(),a.end());
    if(a0 != a) flag = false;
    reverse(a1_1.begin(),a1_1.end());
    if(a1_0 != a1_1) flag = false;
    reverse(a2_1.begin(),a2_1.end());
    if(a2_0 != a2_1) flag = false;



    //substr 開始位置　取り出す長さ
    if(flag) cout << "Yes" << endl;
    else cout << "No" << endl;
    

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define INF 1e18
#define int long long
#define Rep(i, a, n) for (int i = (a); i < (n); i++)
#define rep(i, n) Rep(i, 0, n)
#define all(a) (a).begin(), (a).end()
using namespace std;
typedef pair<int, int> P;
typedef pair<int, P> PP;
const int mod = 1000000007;

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

    string s;
    cin >> s;
    for (int i = 1; i < s.size(); i++)
    {
        int len = s.size() - i;
        if (len % 2)
            continue;
        int mid = len / 2;
        bool f = true;
        rep(j, mid) if (s[j] != s[j + mid]) f = false;
        if (f)
        {
            cout << len << 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[] array = new int[5];
        for(int i=0;i<5;i++){
            array[i]=(-1)*sc.nextInt();
        }
        Arrays.sort(array);
        for(int i=0;i<5;i++){
            System.out.print((-1)*array[i]);
            if(i<4){
                System.out.print(" ");
            }
        }
        System.out.println();
    }
}

Measured memory_bytes: 17300
#include <stdio.h>

int main(void) {
	int x, y= 0;
	while(1){
	    scanf("%d %d", &x, &y);
	    if((x==0) && (y==0)){
	        break;
	    }
		if(x>y){
		    printf("%d %d\n", y, x);
		}else{
		    printf("%d %d\n", x, y);
		}
	}
	return 0;
}




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

int main(void){
    char s[10],t[10],u[10];
    int a,b;
    scanf("%s %s",s,t);
    scanf("%d %d",&a,&b);
    scanf("%s",u);
    if(strcmp(s,u)==0){
        a=a-1;
    }else if(strcmp(t,u)==0){
        b=b-1;
    }
    printf("%d %d",a,b);
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
const int INF = 2*1e9;
#define ll long long
// ll knapsack(vector<pair<ll,ll>>&A,vector<vector<ll>>&dp,ll i,ll totalWeight){
//     if(i>=A.size())
//         return 0;
//     if(dp[i][totalWeight]!=-1)
//         return dp[i][totalWeight];
//     ll itemWt = A[i].first;
//     ll itemVa = A[i].second;
    
//     if(itemWt<=totalWeight){
//         ll cost1  = itemVa+knapsack(A,dp,i+1,totalWeight-itemWt);
//         ll cost2 = knapsack(A,dp,i+1,totalWeight);
        
//         dp[i][totalWeight] = max(cost1,cost2);
//     }
//     else
//         return dp[i][totalWeight] = knapsack(A,dp,i+1,totalWeight);
//     return dp[i][totalWeight];
     
// }
int main(){
  ll n,w;
  cin>>n>>w;
  vector<pair<ll,ll>> A(n);
  ll val,wt,V;
  for(ll i=0;i<n;i++){
      cin>>wt>>val;
      A[i]={wt,val};
      V+=val;
  }
  
  //vector<vector<ll>> dp(n,vector<ll>(w+1,-1));
  vector<ll> dp(n*1000+1,INF);
  dp[0]=0;
  for(int i=0;i<n;i++){
      ll itemVa=A[i].second,itemWt=A[i].first;
      for(int j=V;j>=itemVa;j--){
          dp[j] = min(dp[j],dp[j-itemVa]+itemWt);
      }
  }
  for(int i=V;i>=0;i--){
      if(dp[i]<=w){
          cout<<i<<endl;
          break;
      }
  }
  //cout<<knapsack(A,dp,0,w)<<endl;
  return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <sstream>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <memory>
#include <complex>
#include <numeric>
#include <cstdio>
#include <iomanip>

#define REP(i,m,n) for(int i=int(m);i<int(n);i++)
#define RREP(i,m,n) for(int i=int(n)-1;i>=int(m);--i)
#define EACH(i,c) for (auto &(i): c)
#define all(c) begin(c),end(c)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort(begin(c),end(c))
#define pb emplace_back
#define MP make_pair
#define SZ(a) int((a).size())

#ifdef LOCAL
#define DEBUG(s) cout << (s) << endl
#define dump(x)  cerr << #x << " = " << (x) << endl
#define BR cout << endl;
#else
#define DEBUG(s) do{}while(0)
#define dump(x) do{}while(0)
#define BR 
#endif
using namespace std;

using UI = unsigned int;
using UL = unsigned long;
using LL = long long int;
using ULL = unsigned long long;
using VI = vector<int>;
using VVI = vector<VI>;
using VLL = vector<LL>;
using VVLL = vector<VLL>;
using VS = vector<string>;
using PII = pair<int,int>;
using VP = vector<PII>;

//struct edge {int from, to, cost;};

constexpr double EPS = 1e-10;
//constexpr double PI  = acos(-1.0);
//constexpr int INF = INT_MAX;
constexpr int MOD = 1'000'000'007;
//inline void modAdd(LL &l, LL &r) {l = (l + r) % MOD;}

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

void solve() {
    int n,k;
    cin >> n >> k;
    VI h(n);
    REP(i,0,n) cin >> h[i];
    int cnt = 0;
    REP(i,0,n) if (h[i] >= k) ++cnt;
    cout << cnt << endl;
}

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

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
int A, B;
int main () {
	cin  >> A >> B;
	if (A==1) A+=13;
	if (B==1) B+=13;
	if (A > B) {
		cout << "Alice" << endl;
	}
	if (A<B){
		cout << "Bob" << endl;
	}
	if (A==B){
		cout << "Draw" << endl;
	}

}


Measured memory_bytes: 256
/*input
7
1 7
7 4
3 4
7 5
6 3
2 1
*/
#include <bits/stdc++.h>
#pragma GCC optimize("unroll-loops,no-stack-protector")
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<ld,ld> pdd;
#define IOS ios_base::sync_with_stdio(0); cin.tie(0)
#define ALL(a) a.begin(),a.end()
#define SZ(a) ((int)a.size())
#define F first
#define S second
#define REP(i,n) for(int i=0;i<((int)n);i++)
#define pb push_back
#define MP(a,b) make_pair(a,b)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
template<typename T1,typename T2>
ostream& operator<<(ostream& out,pair<T1,T2> P){
	out<<'('<<P.F<<','<<P.S<<')';
	return out;
}

//}}}
const ll maxn=300005;
const ll maxlg=__lg(maxn)+2;
const ll INF64=8000000000000000000LL;
const int INF=0x3f3f3f3f;
const ll MOD=ll(1e9+7);
const ld PI=acos(-1);
const ld eps=1e-9;
//const ll p=880301;
//const ll P=31;

ll mypow(ll a,ll b){
	ll res=1LL;
	while(b){
		if(b&1) res=res*a%MOD;
		a=a*a%MOD;
		
		b>>=1;
	}
	return res;
}

bool vis[maxn];
vector<int> q;
vector<int> edge[maxn];
int dis[maxn];
int pt=0;
int main(){
	IOS;
	int n;
	cin>>n;
	REP(i,n-1){
		int u,v;
		cin>>u>>v;
		u--;v--;
		edge[u].pb(v);
		edge[v].pb(u);
	}

	q.pb(0);
	while(pt<SZ(q)){
		int cur=q[pt++];
		for(int v:edge[cur]) if(!vis[v]){
			q.pb(v);
			vis[v]=1;
			dis[v]=dis[cur]+1;
		}
	}

	int c=max_element(dis,dis+n)-dis;

	q.clear();
	pt=0;
	q.pb(c);
	dis[c]=0;
	REP(i,n) vis[i]=0;
	while(pt<SZ(q)){
		int cur=q[pt++];
		for(int v:edge[cur]) if(!vis[v]){
			q.pb(v);
			vis[v]=1;
			dis[v]=dis[cur]+1;
		}
	}
	int tmp=*max_element(dis,dis+n);
	if(tmp%3==1) cout<<"Second\n";
	else cout<<"First\n";

	return 0;
}


Measured memory_bytes: 16500
import sys
sys.setrecursionlimit(10000000)
MOD = 10 ** 9 + 7
INF = 10 ** 15

from heapq import heapify,heappop,heappush
def main():
    Q = int(input())
    total_b = 0
    total_a = 0
    less_than_middle = 0
    left = []
    right = []
    cnt = 0
    for _ in range(Q):
        query = tuple(map(int,input().split()))
        if query[0] == 1:
            a,b = query[1:]
            total_b += b
            total_a += a
            cnt += 1
            heappush(right,a)
            while left and right and (-left[0] > right[0]):
                p = -heappop(left)
                q = heappop(right)
                heappush(left,-q)
                heappush(right,p)
                less_than_middle += -p + q
            if cnt%2 == 0:
                p = heappop(right)
                heappush(left,-p)
                less_than_middle += p
        else:
            if cnt%2 == 0:
                x = -left[0]
                ans = total_a - 2*less_than_middle + total_b
                print(x,ans)
            else:
                x = right[0]
                ans = total_a - 2*less_than_middle - x + total_b
                print(x,ans)
if __name__ == '__main__':
    main()

Measured memory_bytes: 11296
from collections import Counter

def main():
    n = int(input())
    a = list(map(int,input().split()))
    q = int(input())
    c = Counter(a)
    allsum = 0
    for k,v in c.items():
        allsum += k*v
    ans = []
    for i in range(q):
        bi,ci = list(map(int,input().split()))
        allsum += ci*c[bi] - bi*c[bi]
        c[ci] = c[ci] + c[bi]
        c[bi] = 0
        ans.append(allsum)
    for i in ans:
        print(i)    
main()

Measured memory_bytes: 26988
#include <bits/stdc++.h>
using namespace std;
using pi = pair<int, int>;
using lint = long long;
const int mod = 1e9 + 7;
const int MAXN = 205;

lint ipow(int x, int p){
	lint ret = 1, piv = x;
	while(p){
		if(p & 1) ret = ret * piv % mod;
		piv = piv * piv % mod;
		p >>= 1;
	}
	return ret;
}

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

int n, m, k, c;
vector<int> gph[MAXN];
vector<int> bcc[MAXN], cmp[MAXN];
vector<pi> tedg;

int dfn[MAXN], low[MAXN], piv;
lint cyc[MAXN];
lint bino[MAXN][MAXN];
int ecnt[MAXN];

void color(int x, int p){
	if(p){
		bcc[p].push_back(x);
		cmp[x].push_back(p);
	}
	for(auto &i : gph[x]){
		if(cmp[i].size()) continue;
		if(low[i] >= dfn[x]){
			bcc[++c].push_back(x);
			cmp[x].push_back(c);
			color(i, c);
		}
		else color(i, p);
	}
}

void dfs(int x, int p){
	dfn[x] = low[x] = ++piv;
	for(auto &i : gph[x]){
		if(i == p) continue;
		if(!dfn[i]){
			tedg.emplace_back(x, i);
			dfs(i, x);
			low[x] = min(low[x], low[i]);
		}
		else{
			if(dfn[x] < dfn[i]) tedg.emplace_back(x, i);
			low[x] = min(low[x], dfn[i]);
		}
	}
}

lint solve(int c){
	if(bcc[c].size() == 2){
		lint ret = k;
		int v = bcc[c][1];
		for(auto &i : cmp[v]){
			if(i != c){
				ret *= solve(i);
				ret %= mod;
			}
		}
		return ret;
	}
	lint ret = 1;
	if(ecnt[c] == bcc[c].size()) ret = cyc[ecnt[c]];
	else ret = bino[ecnt[c] + k - 1][k - 1];
	for(int i=1; i<bcc[c].size(); i++){
		int v = bcc[c][i];
		for(auto &j : cmp[v]){
			if(j != c) ret = ret * solve(j) % mod;
		}
	}
	return ret;
}

int main(){
	for(int i=0; i<MAXN; i++){
		bino[i][0] = 1;
		for(int j=1; j<=i; j++){
			bino[i][j] = (bino[i-1][j] + bino[i-1][j-1]) % mod;
		}
	}
	scanf("%d %d %d",&n,&m,&k);
	for(int i=1; i<=n; i++){
		lint ret = 0;
		for(int j=0; j<i; j++){
			ret += ipow(k, gcd(i, j));
		}
		ret %= mod;
		ret *= ipow(i, mod - 2);
		ret %= mod;
		cyc[i] = ret;
	}
	for(int i=0; i<m; i++){
		int s, e; scanf("%d %d",&s,&e);
		gph[s].push_back(e);
		gph[e].push_back(s);
	}
	lint ret = 1;
	for(int i=1; i<=n; i++){
		if(!dfn[i]){
			tedg.clear();
			dfs(i, 0);
			color(i, 0);
			for(auto &i : tedg){
				map<int, int> bcnt;
				int l = i.first, r = i.second;
				for(auto &j : cmp[l]) bcnt[j]++;
				for(auto &j : cmp[r]) bcnt[j]++;
				for(auto &k : bcnt){
					if(k.second == 2) ecnt[k.first]++;
				}
			}
			for(auto &j : cmp[i]) ret = ret * solve(j) % mod;
		}
	}
	cout << ret << endl;
}


Measured memory_bytes: 640
#include<iostream>
using namespace std;
int main()
{
    int D, T, S, t, r;
    cin >> D >> T >> S;
    t = D / S;
    r = D % S;
    if(t < T || (t == T && r == 0)){
        cout << "Yes";
    }
    else{
        cout << "No";
    }
}

Measured memory_bytes: 3592
#include <iostream>
#include <vector>
#include <numeric>
#include <string>
using namespace std;

int main(){
  int N, M;
  cin >> N >> M;
  vector <int> num(N);
  int a, b;

  for (int i=0; i<M; i++){
    cin >> a >> b;
    num.at(a-1)++;
    num.at(b-1)++;
  }
  for (int i=0; i<N; i++) cout << num.at(i) << endl;
}

Measured memory_bytes: 764
#include <iostream>

using namespace std;

int main(){


    int n, m;
    cin >> n >> m;

    ++n;

    int cities[n];

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


    for (int i = 0; i < m; i++){
        int t1, t2;
        cin >> t1 >> t2;

        cities[t1]++;
        cities[t2]++;
    }


    for (int i = 1; i < n; i++){
        cout << cities[i] << endl;
    }





    return 0;
}

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

int main()
{
    while (1)
    {
        int w, h;
        cin >> w >> h;
        if (w == 0 && h == 0)
        {
            break;
        }
        set<tuple<int, int, int, int>> wall;
        for (int i = 0; i < h; i++)
        {
            for (int j = 0; j < w - 1; j++)
            {
                int wall_num;
                cin >> wall_num;
                if (wall_num == 0)
                {
                    continue;
                }
                wall.insert(make_tuple(i, j, i, j + 1));
                wall.insert(make_tuple(i, j + 1, i, j));
            }
            if (i == h - 1)
            {
                continue;
            }
            for (int j = 0; j < w; j++)
            {
                int wall_num;
                cin >> wall_num;
                if (wall_num == 0)
                {
                    continue;
                }
                wall.insert(make_tuple(i, j, i + 1, j));
                wall.insert(make_tuple(i + 1, j, i, j));
            }
        }
        vector<vector<int>> dist(h, vector<int>(w, -1));
        queue<pair<int, int>> q;
        q.push(make_pair(0, 0));
        dist[0][0] = 0;
        int dh[4] = {0, 0, -1, 1};
        int dw[4] = {1, -1, 0, 0};
        while (!q.empty())
        {
            pair<int, int> p = q.front();
            q.pop();
            for (int i = 0; i < 4; i++)
            {
                int hh = p.first + dh[i];
                int ww = p.second + dw[i];
                if (hh < 0 || hh >= h || ww < 0 || ww >= w)
                {
                    continue;
                }
                if (dist[hh][ww] != -1)
                {
                    continue;
                }
                if (wall.find(make_tuple(p.first, p.second, hh, ww)) == wall.end())
                {
                    dist[hh][ww] = dist[p.first][p.second] + 1;
                    q.push(make_pair(hh, ww));
                }
            }
        }
        int ans = dist[h - 1][w - 1];
        if (ans != -1)
        {
            cout << ans + 1 << endl;
        }
        else
        {
            cout << "0" << endl;
        }
    }
}



Measured memory_bytes: 3200
def kyori(a, b, c, d):
    x = (int(a) - int(b)) ** 2
    y = (int(c) - int(d)) ** 2
    z = (x + y) ** 0.5
    return z

n = int(input())
city_list = [0]*n
total_kyori = 0.0

for i in range(n):
  city_list[i] = input().split(' ')

for j in range(n):
  for k in range(n):
    ret_kyori = kyori(city_list[j][0], city_list[k][0], city_list[j][1], city_list[k][1])
    total_kyori += ret_kyori

ret_value = total_kyori / n
print(ret_value)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
long long a[100];
long long num[300005];
set<long long> s;
set<int >ss;
int cmp(int a,int b){
	return a>b;
}
map<int ,int>m;
int main(){
//	long long a[100];
	set<int>::const_iterator iter;
     set<int>::iterator first;
     set<int>::iterator second;
	a[0]=1;
	for(int i=1;i<=35;i++)
		a[i]=a[i-1]*2;
	int n;
	cin>>n;
	for(int i=0;i<n;i++){
		scanf("%d",&num[i]);
		m[num[i]]++;
	}
	sort(num,num+n);
	int cnt=0;
	for(int i=n-1;i>=0;i--){
		if(m[num[i]]-->0)
		for(int j=32;j>=1;j--)
			if(m[a[j]-num[i]]-->0){
				cnt++;
			//	printf("%d %d %d\n",a[j],num[i],a[j]-num[i]);
			//	break;
			}
			else if(a[j]<=num[i]){
				break;
			}
	}
	cout<<cnt<<endl;
} 

Measured memory_bytes: 58752
#include <stdio.h>

int main(void) {
  int a, b;
  scanf("%d %d", &a, &b);
  if (a % 3 == 0 || b % 3 == 0 || (a + b) % 3 == 0)
    printf("Possible\n");
  else
    printf("Impossible\n");
  return 0;
}

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

#define REP(i,num) for(int i=0;i<(num);++i)
#define ALL(c) c.begin(),c.end()
#define PRINTALL(c) for(auto& x:c){cout<<x<<' ';}cout<<endl;
#define PAIRCOMP(c,comp) [](const pair<ll,ll>& lhs,const pair<ll,ll>& rhs){return lhs.c comp rhs.c;}

constexpr int atcoder_mod = 1e9+7;

using namespace std;
using ll = long long;

template<typename T=int>
T in(){T x; cin >> x; return (x);}
template<typename T=int,typename C=vector<T>>
C vecin(int N){C x(N);REP(i,N){x[i]=in();}return move(x);}

void vout(){cout << endl;}
template<typename Head,typename... Tail>
void vout(Head&& h,Tail&&... t){cout << ' ' << h;vout(forward<Tail>(t)...);}
void out(){cout << endl;}
template<typename Head,typename... Tail>
void out(Head&& h,Tail&&... t){cout << h;vout(forward<Tail>(t)...);}

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

	ll H=in<ll>(),W=in<ll>();
	if(H==2 || W==2){
		out(0);
	}
	else if(H==1){
		if(W==1) out(1);
		else out(W-2LL);
	}
	else if(W==1){
		out(H-2LL);
	}
	else{
		out((H-2LL)*(W-2LL));
	}
	
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cstring>
#include <vector>
#include <algorithm>
#include <set>
#include <stack>
#include <deque>
#include <cmath>
#include <map>
using namespace std;
using ll = long long;
#define rep(i, n) for (ll i = 0; i < n; i++)
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}

int main() {
    ll N, M, K;
    cin >> N >> M >> K;
    for(ll n = 0; n <= N; n++) {
        for (ll m = 0; m <= M; m++) {
            if (n*M + m*N - 2*n*m == K) {
                cout << "Yes\n" ;
                return 0;
            }
        }
    }
    cout << "No\n";
}

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

int main() {
  int A, B, count = 0, n[4];
  cin >> A >> B;
  for(int i = A; i <= B; i++) {
    n[0] = i / 10000;
    n[1] = i % 10;
    n[2] = (i / 1000) % 10;
    n[3] = (i % 100) / 10;
    if((n[0] == n[1]) && (n[2] == n[3]))
      count++;
  }
  cout << count << endl;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(void){
	int n,m;
	cin>>n>>m;
	int h[100000];
	for(int i(0);i<n;i++){
		cin>>h[i];
	}
	int a[100000],b[100000];
	for(int i(0);i<m;i++){
		cin>>a[i]>>b[i];
	}
	bool bad_view[100000]={0};
	for(int i(0);i<m;i++){
		if(h[a[i]-1] >= h[b[i]-1])bad_view[b[i]-1] = true;
		if(h[a[i]-1] <= h[b[i]-1])bad_view[a[i]-1] = true;
	}
	int ans(0);
	for(int i(0);i<n;i++){
		if(bad_view[i] == false)ans++;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 4424
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<bool> vb;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef map<int,int> mii;
typedef map<ll,ll> mll;
typedef vector<pii> vii;
typedef vector<pll> vll;
#define fi first
#define se second
#define pi 3.141592653589793
#define mod 998244353
#define pb push_back
#define all(v) v.begin(),v.end()
#define tc int t;cin>>t;while(t--)
#define pqmax priority_queue<int>
#define pqmin priority_queue<int,vi,greater<int>>
#define fast_io ios_base::sync_with_stdio(0), cin.tie(NULL)
#define tc_g int tt;cin>>tt;for(int ti=1;ti<=tt;ti++)
#define case_g "Case #"<<ti<<": "
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
typedef tree<int, null_type, less_equal<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_multiset;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
typedef tree<int, int, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_map;

int main() {
	int n, s;
	cin >> n >> s;
	vi a(n + 1);
	for (int i = 1;i <= n;i++)
		cin >> a[i];
	ll dp[n + 1][s + 1] = {};
	dp[0][0] = 1;
	for (int i = 1;i <= n;i++) {
		for (int j = 0;j <= s;j++)
			dp[i][j] = dp[i - 1][j] * 2 % mod;
		for (int j = 0;j + a[i] <= s;j++)
			dp[i][j + a[i]] = (dp[i][j + a[i]] + dp[i - 1][j]) % mod;
	}
	cout << dp[n][s] << '\n';
}


Measured memory_bytes: 73968
#include<iostream>
#include<stdio.h>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>

using namespace std;
string S1;
string S2;
int n;
long long int kotae;
int i;
int jou;

int main(){
	cin >> n;
	cin >> S1 >> S2;
	if(S1[0] == S2[0]){
		kotae = 3;
		jou = 1;
		i = 1;
	}
	if(S1[0] != S2[0]){
		kotae = 6;
		jou = 2;
		i = 2;
	}		
	while(1){
		if(i>=n)break;
		if(S1[i] == S2[i]){
			if(jou == 1){
				kotae = (2*kotae)%1000000007;
				jou = 1;
			}
			else{
				jou = 1;
			}
			i = i+1;
		}	
		else{
			if(jou == 1){
				kotae = (2*kotae)%1000000007;
				jou = 2;
			}
			else{
				kotae = (3*kotae)%1000000007;
				jou = 2;
			}
			i = i+2;
		}
	}
	cout << kotae << endl;
	return 0;
}



	
			
				
			

Measured memory_bytes: 256
#include <stdio.h>
#include <algorithm>
#include <assert.h>
#include <bitset>
#include <cmath>
#include <complex>
#include <deque>
#include <functional>
#include <iostream>
#include <limits.h>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <time.h>
#include <unordered_map>
#include <unordered_set>
#include <vector>

#pragma warning(disable:4996)
#pragma comment(linker, "/STACK:336777216")

using namespace std;

#define mp make_pair
#define all(x) (x).begin(), (x).end()

typedef tuple<int, int, int> t3;
typedef long long ll;
typedef unsigned long long ull;
typedef double db;
typedef long double ldb;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
typedef pair <db, db> pdd;

int IT_MAX = 1 << 18; // segment tree size
const ll MOD = 1000000007;
const int INF = 0x3f3f3f3f; // memset(dp, 0x3f, sizeof(dp)), 2*INF < INT_MAX
const ll LL_INF = 0x3f3f3f3f3f3f3f3f;
const db PI = acos(-1);
const db ERR = 1e-10; // double EPS

int main() {
	int A, B, K, i, j;
	scanf("%d %d %d", &A, &B, &K);
	if (B - A + 1 <= 2 * K) for (i = A; i <= B; i++) printf("%d\n", i);
	else {
		for (i = A; i < A + K; i++) printf("%d\n", i);
		for (i = B - K + 1; i <= B; i++) printf("%d\n", i);
	}
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
int acs(const void *a, const void *b) { 
  return *(int*)a - *(int*)b;
} /* 1,2,3,4.. */
int des(const void *a, const void *b) {
  return *(int*)b - *(int*)a;
} /* 8,7,6,5.. */
int cmp_char(const void *a, const void *b) { 
  return *(char*)a - *(char*)b;
} /* a,b,c,d.. */
int cmp_str(const void *a, const void *b) {
  return strcmp(*(const char **)a, *(const char **)b);
} /* aaa,aab.. */
#define min(a,b) (a < b ? a : b)
#define max(a,b) (a > b ? a : b)
#define rep(i, l, r) for (int i = l; i < r; i++)
#define MAX 200005
#define MOD 1000000007

typedef long long int lli;

int main(void) {
  int used[MAX] = {0};
  int n;
  int a[MAX];
  scanf("%d", &n);
  rep(i, 0, n) scanf("%d", &a[i]);

  qsort(a, n, sizeof(int), acs);

  int ok = 1;
  rep(i, 0, n) {
    if (a[i] == a[i+1]) {
      ok = 0;break;
    }
  }
  printf( ok ? "YES\n" : "NO\n");
  return 0;
}


Measured memory_bytes: 1788
package main

import (
	"fmt"

	"os"
	"io"
	"bufio"
	"bytes"

	"strings"
	"strconv"
)

//  長い入力を読む
func ReadLongLines(times int) ([]string, error) {
	result := make([]string, times)
	reader := bufio.NewReader(os.Stdin)
	buffer := bytes.NewBuffer(make([]byte, 0))
	readBytes := int64(2)
	for i := 0; i < times; i++ {
		for {
			readBuf, isPrefix, err := reader.ReadLine()
			// fmt.Printf("Reader.Read: %d\n", len(readBuf))
			readBytes += int64(len(readBuf) + 1)
			if err != nil {
				if err == io.EOF {
					fmt.Println("EOF")
					break
				} else {
					return result, err
				}
			}
			_, err = buffer.Write(readBuf)
			if err != nil {
				return result, err
			}
			// end of line
			if !isPrefix {
				result[i] = buffer.String()
				buffer.Reset()
				// reader = bufio.NewReader(os.Stdin)
				break
			}
		}
	}
	// 先読みしてしまうようなので、戻しておく
	os.Stdin.Seek(-int64(reader.Buffered()), os.SEEK_CUR)
	return result, nil
}

// 出力 for 競プロ
type Console struct {
	writer *bufio.Writer
}
func NewConsole() Console {
	return Console{ bufio.NewWriter(os.Stdout) }
}
func (this *Console) Printf(format string, a ...interface{}) {
	fmt.Fprintf(this.writer, format, a...)
}
func (this *Console) Println(s string) {
	fmt.Fprintf(this.writer, s)
}
func (this *Console) Close() {
	this.Flush()
}
func (this Console) Flush() {
	this.writer.Flush()
}


func main() {
	con := NewConsole()
	defer con.Flush()

	// create list
	var n int
	fmt.Scanf("%d", &n)

	list := make([]int, n)
	lines, _ := ReadLongLines(1)
	elements := strings.Split(lines[0], " ")
	for i := 0; i < n; i++ {
		list[i], _ = strconv.Atoi(elements[i])
	}

	// query
	var q int
	fmt.Scanf("%d", &q)
	lines, _ = ReadLongLines(q)
	for _, v := range lines {
		arg := strings.Split(v, " ")
		begin, _ := strconv.Atoi(arg[0])
		end, _ := strconv.Atoi(arg[1])
		k, _ := strconv.Atoi(arg[2])
		count := 0
		for i := begin; i < end; i++ {
			if list[i] == k {
				count++
			}
		}
		con.Printf("%d\n", count)
	}
}


Measured memory_bytes: 1320
#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e5 + 100;
long long a[maxn];

long long sa[maxn];
long long sb[maxn];
int main() {
    int n;
    cin >> n;
    sa[0] = 0;
    sb[0] = 0;
    long long cnt = 0;
    for(int i = 1 ;i <= n ; ++i) {
        cin >> a[i];
    }
    long long ans1 = 0 , ans2 = 0;
    for(int i = 1 ; i <= n ; ++i) {
        sa[i] = sa[i - 1] + a[i];
        sb[i] = sb[i - 1] + a[i];
        if(i & 1) {
            if(sa[i] >= 0) {
                ans1 += sa[i] + 1;
                sa[i] = -1;
            }
            if(sb[i] <= 0) {
                    ans2 += -sb[i] + 1;
                    sb[i] = 1;
            }
        }
        else {
            if(sa[i] <= 0){
                ans1 += -sa[i] + 1;
                sa[i] = 1;
            }
            if(sb[i] >= 0) {
                ans2 += sb[i] + 1;
                sb[i] = -1;
            }
        }
    }
    cout << min(ans1 , ans2) << endl;
    return 0;
}


Measured memory_bytes: 2560
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define P pair<ll,ll>
#define FOR(I,A,B) for(ll I = ll(A); I < ll(B); ++I)
#define FORR(I,A,B) for(ll I = ll((B)-1); I >= ll(A); --I)
#define TO(x,t,f) ((x)?(t):(f))
#define SORT(x) (sort(x.begin(),x.end())) // 0 2 2 3 4 5 8 9
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin()) //xi>=v  x is sorted
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin()) //xi>v  x is sorted
#define NUM(x,v) (POSU(x,v)-POSL(x,v))  //x is sorted
#define REV(x) (reverse(x.begin(),x.end())) //reverse
ll gcd(ll a,ll b){if(a<b)swap(a,b);if(a%b==0)return b;return gcd(b,a%b);}
ll lcm(ll a,ll b){ll c=gcd(a,b);return ((a/c)*(b/c)*c);}//saisyo kobaisu
#define NEXTP(x) next_permutation(x.begin(),x.end())
const ll INF=1e18+7;
const ll MOD=1e9+7;
#define out(a) cout<<fixed<<setprecision((a))

int main(){
	ll N,ans=0;
	cin >> N;
	vector<ll> d(N);
	FOR(i,0,N)cin >> d[i];
	SORT(d);
	FOR(i,(d[N/2-1]),d[N/2])ans++;
	cout << ans << endl;;
}


Measured memory_bytes: 1024
using System;
using System.Collections.Generic;
using System.Windows;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Atcoder
{
    public class Program
    {
        static void Main(string[] args)
        {
            var r1 = ReadSplit();
            var n = r1[0].ToDecimal();
            var k = r1[1].ToDecimal();
            //var min = n;
            //decimal cNum = min;
            //while (min >= cNum)
            //{
            //    cNum = Math.Abs(cNum - k);
            //    if (cNum < min)
            //    {
            //        min = cNum;
            //    }
            //}
            var a = n % k;
            if (a > Math.Abs(a - k))
            {
                a = Math.Abs(a - k);
            }
            WriteRead(a);
        }

        public static string Read()
        {
            return Console.ReadLine();
        }

        public static string[] ReadSplit()
        {   
            return Console.ReadLine().Split(' ');
        }

        public static void WriteRead(object str)
        {
            Console.WriteLine(str);
            Read();
        }

        public static void Write(object str)
        {
            Console.WriteLine(str);
        }
    }
}


public static class Extentions
{
    public static int ToInt(this object obj)
    {
        return int.Parse(obj.ToString());
    }

    public static decimal ToDecimal(this object obj)
    {
        return decimal.Parse(obj.ToString());
    }

    public static double ToDouble(this object obj)
    {
        return double.Parse(obj.ToString());
    }

    public static T2 GetValueZero<T1, T2>(this Dictionary<T1, T2> d, T1 key) where T2 : struct
    {
        T2 value;
        if (d.TryGetValue(key, out value))
        {
            return value;
        }
        return new T2();
    }
}



Measured memory_bytes: 11092