akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    vector<int> d(n);
    for (int i = 0; i < n; i++) cin >> d[i];
    sort(d.begin(), d.end());
    cout << d[n / 2] - d[n / 2 - 1];
    return 0;
}


Measured memory_bytes: 640
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <ctime>
#include <string>
#include <queue>

using namespace std;

const int MAX_N = 100;
int n;
int suji[MAX_N];
int	num[MAX_N];
int adj[MAX_N][MAX_N];
int ans[MAX_N][MAX_N];
int D[MAX_N];

void bfs(int src){
	queue<int> Q;
	Q.push(src);
	D[src] = 0;

	while(!Q.empty()){
		int cur = Q.front();
		Q.pop();

		for(int i = 1; i < n; i++){
			if(ans[cur][i] == 1 && D[i] == -1){
				D[i] = D[cur] + 1;
				Q.push(i);
			}
		}
	}
}


int main(void){

	cin >> n;
	for(int i = 0; i < n; i++){
		
		cin >> suji[i] >> num[i];
		D[i] = -1;
		
		for(int j = 0; j < num[i]; j++){
			cin >> adj[i][j];
			adj[i][j] -= 1;
		}
	}

	for(int i = 0; i < n; i++){
		for(int j = 0; j < n; j++){
			ans[i][j] = 0;
		}
	}

	for(int i = 0; i < n; i++){
		for(int j = 0; j < num[i]; j++){
			ans[i][adj[i][j]] = 1;
		}
	}

	bfs(0);

	for(int i = 0; i < n; i++){
		cout << i + 1 << " " << D[i] << endl;
	}
	
    return 0;
}

Measured memory_bytes: 1280
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define rep2(i,n) for (int i = 1; i < (n); ++i)
#define var auto
int main() {
   int n,m;cin>>n>>m;
   if(n==m){
       cout<<"Yes"<<endl;
   }else{
       cout<<"No"<<endl;
   }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,j,n) for(int i=(int)(j);i<(int)(n);i++)
#define REP(i,j,n) for(int i=(int)(j);i<=(int)(n);i++)
#define MOD 1000000007
#define int long long
#define ALL(a) (a).begin(),(a).end()
#define vi vector<int>
#define vii vector<vi>
#define pii pair<int,int>
#define priq priority_queue<int>
#define disup(A,key) distance(A.begin(),upper_bound(ALL(A),(int)(key)))
#define dislow(A,key) distance(A.begin(),lower_bound(ALL(A),(int)(key)))
#define tii tuple<int,int,int>
signed main(){
  int N; string S; cin>>N>>S;
  int ans=0;
  rep(i,2,N){
    if(S[i]=='C'){
      if(S[i-1]=='B'){
        if(S[i-2]=='A')
          ans++;
      }
    }
  }
  cout<<ans<<endl;
  }


Measured memory_bytes: 256
import itertools
n, m, q = map(int, input().split())
li = []
ans=0
for i in range(q):
    a, b, c, d = map(int, input().split())
    li.append([a, b, c, d])

for v in itertools.combinations_with_replacement(range(1,m+1),n):
    cnt=0
    for i in range(q):
        if v[li[i][1]-1]-v[li[i][0]-1]==li[i][2]:
            cnt+=li[i][3]
    ans=max(ans,cnt)
print(ans)

Measured memory_bytes: 9068
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
    ll a,v,b,n,m,i,j,k,l,c;
    ll aa[10000],bb[10000];
    while(cin>>n)
    {

        for(i=0; i<n; i++)
        {
            cin>>m;
            aa[i]=m;


        }
        for(i=0; i<n; i++)
        {
            cin>>m;
            bb[i]=m;
        }
        c=-10000;
        k=0;
        for(j=0; j<n; j++)
        {
            k+=aa[j];
            l=0;
            for(i=j; i<n; i++)
            {
                l+=bb[i];
            }
             c=max((k+l),c);
        }
        cout<<c<<endl;

    }
}




Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
#define LL long long
using namespace std;
int a;
string s;
int main()
{
	scanf("%d",&a);
	cin>>s;
	if(a>=3200) cout<<s<<endl;
	else cout<<"red"<<endl;
	return 0;
}

Measured memory_bytes: 256
import java.util.*;

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

        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();
        if (c > a - b)
            System.out.println(c - (a - b));
        else
            System.out.println(0);
    }
}

Measured memory_bytes: 21844
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>

//#define DEBUG
#ifdef DEBUG
#define debug_printf printf
#else
#define debug_printf 1 ? 0 : printf
#endif

using namespace std;
typedef long long int ll;
typedef vector<ll> Vl;
typedef vector<int> Vi;
typedef pair<int, int> Pi;

#define INF   (1e9 + 7)
#define MAX_N (100000)
#define MAX_A (100000)
int N, M, K, COUNTS[MAX_A];

int main() {
  M = K = 0;
  for (int i = 0; i < N; i++) COUNTS[i] = 0;

  scanf("%d", &N);
  for (int i = 0; i < N; i++) {
    int a;
    scanf("%d", &a);
    if (COUNTS[a] == 0) M++;
    if (COUNTS[a] > 0) K++;
    COUNTS[a]++;
  }
  debug_printf("%d %d\n", M, K);

  int ans = (K % 2 == 0)? M: M - 1;
  printf("%d\n", ans);

  return 0;
}


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

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

	string s;
	//int n,a,b;

	//cin >> n >> a >> b;
	cin >> s;
	
	string ans="Yes";
	
	int a[4];
	vector<int> b(30,0);
	
	rep(i,4){
		a[i]=s[i]-'A';
		b[a[i]]++;
	}
	
	
	
	rep(i,30){
		if(b[i]%2 || b[i]==4){
			ans="No";
			break;
		}
	}
		
	
	cout << ans << "\n";
	
	
	return 0;

    }

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

int main()
{
    vector<int> v(3);

    cin >> v[0]>>v[1]>>v[2];
    sort(v.begin(),v.end());
        cout << v[2]*10+v[1]+v[0] << endl;

    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<cstdlib>
#include<stdio.h>
#include<time.h>
#include<math.h>
#include<algorithm>
#include<string>
#include<vector>
#include<list>
#include<queue>
#include<stack>
#include<deque>
#include<set>
#include<map>
#define REP(i, N) for(ll i = 0; i < N; ++i)
#define FOR(i, a, b) for(ll i = a; i < b; ++i)
#define ALL(a) (a).begin(),(a).end()
#define pb push_back
#define INF 1000000000
#define MOD 1000000007
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
int qx[8] = {1, 1, 0, -1, -1, -1, 0, 1};
int qy[8] = {0, 1, 1, 1, 0, -1, -1, -1};

int main(void) {
	ll N, K;
	cin>>N>>K;
	vector<P> s;
	REP(i, N) {
		ll a, b;
		cin>>a>>b;
		s.pb(P(a, b));
	}
	sort(ALL(s));
	REP(i, N) {
		K -= s[i].second;
		if(K <= 0) {
			cout<<s[i].first<<endl;
			break;
		}
	}
}


Measured memory_bytes: 2420
#include <cstdio>
 
int c[12][12],g[12][12];
int u[1200000],v[1200000],w[1200000];
int i,j,k,m,n,x,y,z;
bool b;
 
int main()
{
	scanf("%d%d",&n,&m);
	for (i=1;i<=n;i++)
		for (j=1;j<=m;j++)
			scanf("%d",&g[i][j]);
	for (x=0;x<=100;x++)
		for (y=0;y<=100;y++)
			for (z=0;z<=100;z++)
			{
				b=false;
				for (i=1;i<=n;i++)
					for (j=1;j<=m;j++)
						if (x*i+y*j+z<g[i][j])
							b=true;
				if (b)
					continue;
				b=false;
				for (i=1;i<=n;i++)
					for (j=1;j<=m;j++)
						if (x*i+y*j+z==g[i][j])
							b=true,c[i][j]=1;
				if (! b)
					continue;
				k++,u[k]=x,v[k]=y,w[k]=z;
			}
	for (i=1;i<=n;i++)
		for (j=1;j<=m;j++)
			if (! c[i][j])
			{
				puts("Impossible");
				return 0;
			}
	puts("Possible");
	printf("%d %d\n",202,k+200);
	for (i=1;i<=100;i++)
		printf("%d %d X\n",i,i+1);
	for (i=102;i<=201;i++)
		printf("%d %d Y\n",i,i+1);
	for (i=1;i<=k;i++)
		printf("%d %d %d\n",1+u[i],202-v[i],w[i]);
	printf("%d %d\n",1,202);
	return 0;
}

Measured memory_bytes: 4352
#include<iostream>
#include<cstdio>
#include<algorithm>
using namespace std;
char x,y;
int x1,y1;
int rt()
{
	if(x1>y1) return 62;
	if(x1<y1) return 60;
	if(x1=y1) return 61;
}
int main()
{
	cin>>x>>y;
	x1=int(x-48);
	y1=int(y-48);
	cout<<char(rt());
	return 0;
}

Measured memory_bytes: 256
data class Edge(val from: Int, val to: Int)

fun main(args: Array<String>) {
  val n = readLine()!!.toInt()
  val labels = readLine()!!
  val graph = Array(n, { mutableListOf<Edge>() })
  repeat(n - 1) {
    val (v1Raw, v2Raw) = readLine()!!.split(" ").map(String::toInt)
    val v1 = v1Raw - 1
    val v2 = v2Raw - 1
    graph[v1].add(Edge(v1, v2))
    graph[v2].add(Edge(v2, v1))
  }

  fun solveForRoot(r: Int): Int? {
    val dpCount = IntArray(n, { -1 })
    val dpMin = IntArray(n, { -1 })
    val dpMax = IntArray(n, { -1 })

    fun dfs(v: Int, prev: Int) {
      val children = graph[v].filter { it.to != prev }.map { it.to }
      if (children.isEmpty()) {
        // Leaf
        dpCount[v] = if (labels[v] == '1') 1 else 0
        dpMin[v] = 0
        dpMax[v] = 0
      } else {
        children.forEach { dfs(it, v) }

        val maxSum = children.sumBy { dpMax[it] + dpCount[it] }
        val maxRemaining = children
            .map { Math.max(dpMin[it] + dpCount[it] - (maxSum - dpMax[it] - dpCount[it]), 0) }
            .max()!!
        if (maxRemaining == 0) {
          dpCount[v] = children.sumBy { dpCount[it] } + if (labels[v] == '1') 1 else 0
          dpMin[v] = maxSum % 2
          dpMax[v] = maxSum
        } else {
          dpCount[v] = children.sumBy { dpCount[it] } + if (labels[v] == '1') 1 else 0
          dpMin[v] = maxRemaining
          dpMax[v] = maxSum
        }
      }
    }

    dfs(r, -1)
    val ans = if (dpMin[r] == 0) dpMax[r] / 2 else null
    return ans
  }

  val ans = (0 until n).map(::solveForRoot).filterNotNull().min() ?: -1
  println(ans)
}


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

int main () {
  int H,W;
  cin >> H >> W;
  string before = ".................................................."
    ,now,after = "..................................................";
  cin >> now >> after;
  for (int l = 0; l < H;l++){
    for (int i = 0; i < W;i++){
      if(now.at(i) == '#'){
        cout << '#';
      }else{
        int count = 0;
        if(before.at(i) == '#') count++;
        if(after.at(i) == '#') count++;
        if(i != 0){
          if(before.at(i - 1) == '#') count++;
          if(now.at(i - 1) == '#') count++;
          if(after.at(i - 1) == '#') count++;
        }
        if(i != W - 1){
          if(before.at(i + 1) == '#') count++;
          if(now.at(i + 1) == '#') count++;
          if(after.at(i + 1) == '#') count++;
        }
        cout << count;
      }
    }cout << endl;
    before = now;
    now = after;
    cin >> after;
    if (l == H - 2)
      after = "..................................................";
  }
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
	int   h,m,s;
	scanf("%d" ,&s);
	h = s/3600;
	s = s%3600;
	m = s/60;
	s = s%60;
	printf("%d:%d:%d\n" ,h,m,s);
	return 0;
}

Measured memory_bytes: 592
#include<bits/stdc++.h>
using namespace std;
const int N=205;
int n,a[N],b[N];
vector<int>p;
char s[10];
int R()
{
    fflush(stdout);
    scanf("%s",s);
    if(s[0]=='R') return 1;
    return 2;
}
int ask()
{
    printf("?");
    for(int i=0;i<p.size();i++)
        printf(" %d",p[i]);
    printf("\n");
    return R();
}
int main()
{
    scanf("%d",&n);
    for(int i=1;i<=n;i++)
        p.push_back(i);
    int t=ask();
    if(n==1)
    {
        if(t==1) printf("! RB\n");
        else printf("! BR\n");
        return 0;
    }
    int l=1,r=n+1;
    while(r-l>1)
    {
        int m=l+r>>1;
        p.clear();
        for(int i=m;i<=m+n-1;i++)
            p.push_back(i);
        if(ask()==t) l=m;
        else r=m;
    }
    p.clear();
    for(int i=l+1;i<=l+n-1;i++)
        p.push_back(i);
    for(int i=1;i<=2*n;i++)
        if(b[i]==0&&!(i>=l+1&&i<=l+n-1))
    {
        p.push_back(i);
        b[i]=ask();
        p.pop_back();
    }
    p.clear();
    int s1=n/2,s2=n/2;
    for(int i=1;i<=2*n;i++)
        if(b[i]==1&&s1)
    {
        s1--;p.push_back(i);
    }
    else if(b[i]==2&&s2)
    {
        s2--;p.push_back(i);
    }
    for(int i=1;i<=2*n;i++)
        if(!b[i])
        {
            p.push_back(i);
            b[i]=ask();
            p.pop_back();
        }
    printf("! ");
    for(int i=1;i<=2*n;i++)
        if(b[i]==1) putchar('R');
    else putchar('B');
    putchar('\n');
}


Measured memory_bytes: 724
n,k=map(int,input().split())
A=list(map(int,input().split()))
#dpテーブルの初期化
#最小化問題
dp=[10*18]*n
dp[0]=0

for i in range(1,n):
    tmpmin=9999999999999999999999
    for j in range(k): 
        if i-j-1<0:
            break
        ans=dp[i-j-1]+abs(A[i]-A[i-j-1])
        if tmpmin>ans:
            tmpmin=ans

    dp[i]=tmpmin
print(dp[-1])

Measured memory_bytes: 52448
#include <iostream>
#include <algorithm>
#include <functional>
#include <string>
#include <numeric>
#include <vector>
using namespace std;
#define MAXSIZE 200
#define MAXL 100
#define NUM 1000000007
typedef long long int lli;

lli getAns(lli n, string s1, string s2);

int main(){
    lli n;
    cin >> n;
    string s1, s2;
    cin >> s1 >> s2;

    cout << getAns(n, s1, s2) << endl;
    return 0;
}

lli getAns(lli n, string s1, string s2){
    lli res = 1;
    for(lli i = 0; i < n; i++){
        if(i == 0){
            if(s1[i] == s2[i]) res = ((res % NUM) * 3) % NUM;
            else{
                res = ((res % NUM) * 6) % NUM;
                i++;
            }
        }else{
            if(s1[i - 1] == s2[i - 1]){
                res = ((res % NUM) * 2) % NUM;
                i += (s1[i] != s2[i]);
            }else{
                if(s1[i] != s2[i]){
                    res = ((res % NUM) * 3) % NUM;
                    i++;
                }
            }
        }
    }
    return res;
}

Measured memory_bytes: 256
n, m = map(int, input().split())
h = list(map(int, input().split()))
A = 0
B = 1
ab = []
cnt = [0] * (n+1)
for i in range(m):
    a, b = map(int, input().split())
    if h[a-1] < h[b-1]:
        cnt[a] = -1
    elif h[b-1] < h[a-1]:
        cnt[b] = -1
    else:
        cnt[a] = -1
        cnt[b] = -1
    ab.append([a, b])

# print(cnt)
ans = 0
for i in range(1,n+1):
    if cnt[i] == 0:
        ans += 1
print(ans)

Measured memory_bytes: 28928
while True:
    m,f,r = map(int,input().split())
    if m == -1 and f == -1 and r == -1:
        break
    if m == -1 or f == -1:
        print("F")
    elif m+f >= 80:
        print("A")
    elif m+f >= 65:
        print("B")
    elif m+f >= 50:
        print("C")
    elif m+f >= 30:
        if r >= 50:
            print("C")
        else:
            print("D")
    else:
        print("F")




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

int main() {
	double min_h = 100000000, max_h = -100000000;
	double h;
	while(cin >> h) {
		min_h = min(min_h, h);
		max_h = max(max_h, h);
	}
	cout << max_h - min_h << endl;
}

Measured memory_bytes: 1280
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define INF 1e9
#define PI 3.14159265359
#define MOD 1000000007
#define ALL(v) v.begin(),v.end()
#define ALLR(v) v.rbegin(),v.rend()
typedef long long ll;
const int dx[4] = {1,0,-1,0};
const int dy[4] = {0,1,0,-1};
//isPrime
//modpow modinv
//getDigit
template<class T> inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
template<class T> inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
void dfs(vector<vector<int>> &g, vector<int> &c, int v, int p){
  for(auto nv:g[v]){
    if(nv==p)continue;
    c[nv]+=c[v];
    dfs(g,c,nv,v);
  }
  return;
}
int main() {
  cout << fixed << setprecision(10);
  int n,q;
  cin >> n >> q;
  vector<vector<int>> g(n);
  rep(i,n-1){
    int a,b;
    cin >> a >> b;
    a--; b--;
    g[a].push_back(b);
    g[b].push_back(a);
  }
  vector<int> count(n,0);
  rep(i,q){
    int p,x;
    cin >> p >> x;
    p--;
    count[p]+=x;
  }
  dfs(g,count,0,-1);
  rep(i,n){
    cout << count[i] << " ";
  }
  cout << endl;
}


Measured memory_bytes: 29696
#include <bits/stdc++.h>
#define endl "\n"
#define INF (int)1e9
#define ll long long
#define ull unsigned long long

using namespace std;

int main()
{
    ll n;
    cin >> n;

    ll ans = INT64_MAX;
    ll lim = sqrt(n);
    for (ll i = 1; i <= lim; i++)
    {
        if (n % i == 0)
        {
            ll other = n / i;
            ans = min(ans, i + other - 2);
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;
import java.util.stream.IntStream;

public class Main {
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc = new Scanner(System.in);
		int N = Integer.parseInt(sc.next());

		long ans = IntStream.rangeClosed(1, N).mapToObj(s -> String.valueOf(s)).filter(s -> s.length() % 2 != 0).count();

		System.out.println(ans);

		sc.close();
	}
}



Measured memory_bytes: 30780
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1LL<<62
#define inf 1000000007 

int main() {
	ll n;
	cin>>n;
	map<string ,ll>a;
	for(int i=0;i<n;i++){
		string s;
		cin>>s;
		sort(s.begin(),s.end());
		a[s]++;
	}
	ll ans=0;
    for(auto itr = a.begin(); itr != a.end(); ++itr) {
        ll num= itr->second ;
        if(num>1){
        	ans+=num*(num-1)/2;
        }
    }
    cout << ans;
}

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

namespace MyApp
{
    class Contest
    {
        public static int Main()
        {
            string[] ar = Console.ReadLine().Split(' ');
            string[] g = Console.ReadLine().Split(' ');
            int n = int.Parse(ar[0]);
            int count = 0;
            List<int> t = new List<int>();
            Dictionary<int, int> ca = new Dictionary<int, int>();
            for(int i = 0; i < n; ++i)
            {
                int k = int.Parse(g[i]);
                if(ca.ContainsKey(k))
                {
                        ca[k]++;
                }
                else
                {
                    ca.Add(k, 1);
                }
            }

            var keys = ca.Keys.ToArray();
            var values = ca.Values.ToArray();

            for(int i = 0; i < keys.Length; ++i)
            {
                var key = keys[i];
                var value = values[i];
                if(key > value)
                {
                    count += value;
                    continue;
                }

                count += value - key;
            }

            Console.WriteLine(Math.Min(n, count));

            return 0;
        }
    }
}

Measured memory_bytes: 26844
#include <stdio.h>

int main(void) {
  int a,b,c,k;
  scanf("%d %d",&a,&b);
  
  k=(a+b)/2;
  c=(a+b)%2;

  if(c==0)
     {printf("%d\n",k);}
  
  else{
    printf("IMPOSSIBLE\n");

  }
  return 0;
}

Measured memory_bytes: 128
import sys


def comb(n, r, MOD, factrial, fact_inv):
    if n < 0 or r < 0 or n < r:
        return 0
    else:
        return (factrial[n] * fact_inv[r] * fact_inv[n-r]) % MOD

def main():
    input = sys.stdin.readline
    H, W, A, B = map(int, input().split())
    MOD = 10**9 + 7

    n = H + W - 2

    factrial = [1] * (n+1)
    for k in range(1, n+1):
        factrial[k] = (factrial[k-1] * k) % MOD

    fact_inv = [1] * (n+1)
    fact_inv[n] = pow(factrial[n], MOD - 2, MOD)
    for k in range(n-1, -1, -1):
        fact_inv[k] = (fact_inv[k+1] * (k+1)) % MOD
    

    ans = 0
    for w in range(B+1, W+1):
        n_a = H - A + w -2
        r_a = w - 1
        a = comb(n_a, r_a, MOD, factrial, fact_inv)

        n_b = A - 1 + W - w
        r_b = A - 1
        b = comb(n_b, r_b, MOD, factrial, fact_inv)

        ans += (a * b) % MOD

    return ans % MOD


if __name__ == '__main__':
    print(main())


Measured memory_bytes: 18804
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;++i)
using namespace std;
using ll=long long;
constexpr ll mod=1000000007;
constexpr int inf=1000000000;
constexpr ll linf=1000000000000000000;

int main(){
    int n,k;
    cin>>n>>k;
    ll a[n];
    int plus=0;
    int minus=0;
    int zero=0;
    rep(i,n){
        cin>>a[i];
        if(a[i]==528543174)a[i]=0;
        if(a[i]>0)++plus;
        else if(a[i]<0)++minus;
        else ++zero;
    }
    sort(a,a+n);
    if(plus+minus<k){
        cout<<0<<endl;
        return 0;
    }
    else if(zero==0&&plus==0&&k%2==1){
        ll ans=1;
        rep(i,k){
            ans*=a[n-1-i];
            ans%=mod;
        }
        cout<<ans+mod<<endl;
        return 0;
    }
    else if(minus%2==1&&minus+plus==k){
        if(zero)cout<<0<<endl;
        else{
            ll ans=1;
            rep(i,n){
                if(a[i]!=0)ans*=a[i];
                ans%=mod;
            }
            cout<<ans+mod<<endl;
        }
        return 0;
    }
    else if(k==1){
        cout<<(a[n-1]+mod)%mod<<endl;
        return 0;
    }
    ll ans=1;
    int l=0,u=n-1;
    while(k>2){
        bool flag=false;
        if(plus<=2){
            if(minus>2)flag=true;
            else if(-a[l]>a[u])flag=true;
        }
        else if(minus<=2);
        else if(-a[l]>a[u])flag=true;
        if(flag){
            ans*=a[l];
            ans%=mod;
            ++l;
            --minus;
            --k;
        }
        else{
            ans*=a[u];
            ans%=mod;
            --u;
            --plus;
            --k;
        }
    }
    ll ma=min(a[l],0LL);
    ll mb=min(a[l+1],0LL);
    ll pa=max(a[u],0LL);
    ll pb=max(a[u-1],0LL);
    ll sgn=ans/abs(ans);
    ll tmp=max({ma*mb*sgn,pa*pb*sgn,ma*pa*sgn});
    tmp%=mod;
    ans=(abs(ans)*tmp)%mod;
    cout<<ans<<endl;
}


Measured memory_bytes: 5208
#include<iostream>

using namespace std;

int main()
{

    long long int x,y,i;

    cin>>x>>y;

    if((x==y) || (x%y==0))
    {
        cout<<"-1"<<endl;
    }
    else
    {
        for(i=2*x; ;i+=x)
        {
            if((i%x==0) && (i%y!=0))
            {
                cout<<i<<endl;

                return 0;
            }

        }

    }

    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;
import java.util.regex.Pattern;

public class Main {

	public static void main(String[] args) {

		Scanner stdin = new Scanner(System.in);
		String tpp = stdin.nextLine();
		Pattern p = Pattern.compile("[,.\\s]");
		String[] result = p.split(tpp);
		int cnt = 0;
		for (int i=0; i<result.length ; i++){


			if(result[i].length() > 2 && result[i].length() < 7) {
				if(cnt == 0) {
					System.out.print(result[i]);
				} else {
					System.out.print(" " + result[i]);
				}
				cnt++;
			}
		}
		System.out.println("");
	}


}

Measured memory_bytes: 26208
#include<iostream>
#include<algorithm>
using namespace std;
int main(void){
    int n;
    cin>>n;
    int x[200000]={0};
    int order[200000]={0};
    for(int i(0);i<n;i++){
        cin>>x[i];
        order[i] = x[i];
    }
    sort(order,order+n);
    int before = n/2 -1;
    int after = n/2;
    for(int i(0);i<n;i++){
        if(x[i]<=order[before])cout<<order[after]<<endl;
        else if(x[i]>=order[after])cout<<order[before]<<endl;
    }
    return 0;
}

Measured memory_bytes: 3712
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int N; scanf("%d", &N);
  int sum = 0;
  for(int i=0; i<N; ++i)
  {
    int t; scanf("%d", &t); sum += t-1;
  }
  printf("%d\n", sum);
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define optimizar_io ios_base::sync_with_stdio(false);cin.tie(0);

int main() {
	optimizar_io
	
	string s, t, u;
	int a, b; 

	cin >> s >> t >> a >> b >> u;
	if (u == s)
		a--;
	else
		b--;
	cout << a << " " << b << "\n";
	return 0;
}

Measured memory_bytes: 256
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}
 
#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};
 
    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}
 
#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };
 
    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };
 
    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };
 
    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };
 
    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };
 
    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}
 
use std::cmp::Ordering;
 
use std::cmp;
use std::cmp::min;
use std::collections::BTreeMap;
use std::process;
use std::cmp::Ord;
use std::collections::HashMap;
use std::collections::HashSet;
use std::collections::VecDeque;
use std::collections::BTreeSet;
use std::mem;
 
use std::ops::{Deref, DerefMut, Index, IndexMut};
use std::any::{Any, TypeId};

fn main(){
    input!{
        q:usize,
        a:[(usize, usize);q],
    }
    for i in 0..q{
        let m = (((a[i].0 * a[i].1) as f64).sqrt()) as usize;
        if a[i].0*a[i].1 == m*m{
            if a[i].0 == a[i].1{
                println!("{}", (m*2-2));
            }
            else{
                println!("{}", ((m*2)-3) );
            }
        }
        else if m*(m+1) >= a[i].0 * a[i].1{
            println!("{}", (m*2 - 2) );
        }
        else{
            println!("{}", (m*2-1) );
        }
    }
}



Measured memory_bytes: 4352
// https://atcoder.jp/contests/abc150/tasks/abc150_c

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

void recursive_comb(int *indexes, int s, int rest, function<void(int *)> f) {
  if (rest == 0) {
    f(indexes);
  } else {
    if (s < 0) return;
    recursive_comb(indexes, s - 1, rest, f);
    indexes[rest - 1] = s;
    recursive_comb(indexes, s - 1, rest - 1, f);
  }
}

// nCkの組み合わせに対して処理を実行する
void foreach_comb(int n, int k, function<void(int *)> f) {
  int indexes[k];
  recursive_comb(indexes, n - 1, k, f);
}

// nPnの順列に対して処理を実行する
void foreach_permutation(int n, std::function<void(int *)> f) {
  int indexes[n];
  for (int i = 0; i < n; i++) indexes[i] = i;
  do {
    f(indexes);
  } while (std::next_permutation(indexes, indexes + n));
}

// nPkの順列に対して処理を実行する
void foreach_permutation(int n, int k, std::function<void(int *)> f) {
  foreach_comb(n, k, [&](int *c_indexes) {
    foreach_permutation(k, [&](int *p_indexes) {
      int indexes[k];
      for (int i = 0; i < k; i++) {
        indexes[i] = c_indexes[p_indexes[i]];
      }
      f(indexes);
    });
  });
}

int main() {
  int n;
  cin >> n;
  vector<int> p(n);
  vector<int> q(n);
  rep(i, n) cin >> p[i];
  rep(i, n) cin >> q[i];

  auto is_same = [&](vector<int> &vec, int *indexes) {
    for(int i=0;i<n;i++) {
      int index = indexes[i] + 1;
      if(vec[i] != index) {
        return false;
      }
    }
    return true;
  };

  int a, b;
  int cnt = 0;
  foreach_permutation(n, n, [&](int *indexes) {
    if(is_same(p, indexes)) {
      a = cnt;
    }
    if(is_same(q, indexes)) {
      b = cnt;
    }
    cnt++;
  });

  cout << abs(a-b) << endl;
  return 0;
}



Measured memory_bytes: 3592
#include <bits/stdc++.h>
#define F first
#define S second
#define pii pair<int,int>
#define pb push_back
typedef long long ll;
const int N = 3 * 1e5 + 10;
using namespace std;
vector<int> adj[N];
bool dp[N]; int e[N];

void dfs(int v , int p = 0){
    for(auto u : adj[v]){
        if(u == p)continue;
        dfs(u , v);
        if(e[u] < e[v] && !dp[u])dp[v] = true;
    }
}

int main(){
    ios_base::sync_with_stdio(0); cin.tie(0);
    int n; cin >> n;
    for(int i=1;i<=n;i++)cin >> e[i];
    for(int i=0;i<n-1;i++){
        int u , v; cin >> u >> v;
        adj[u].pb(v);
        adj[v].pb(u);
    }
    for(int i=1;i<=n;i++){
        memset(dp , 0 , sizeof dp);
        dfs(i);
        if(dp[i])cout << i << ' ';
    }cout << '\n';
}


Measured memory_bytes: 7936
#include<bits/stdc++.h>
#define all(x) (x).begin(),(x).end()
using namespace std;
typedef long long ll;
ll gcd(ll a,ll b){return b!=0?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a*b/gcd(a,b);}

int main(){
    string s,t;
    cin>>s>>t;
    ll cs[26]={},ct[26]={};
    for(ll i=0;i<s.size();i++){
        cs[s[i]-'a']++;
        ct[t[i]-'a']++;
        if(cs[s[i]-'a']!=ct[t[i]-'a']){
            cout<<"No"<<endl;
            break;
        }
        if(i==s.size()-1) cout<<"Yes"<<endl;
    }
    return 0;
}

Measured memory_bytes: 776
#include <stdio.h>
#include <string.h>
#define N 200002
#define M 26

char s[N], a[N], f[N];
int head[M] = {0}, last[N][M], c[N], l;

int dfs(int p, int d)
{
	int i, td = d + 1, tp;
	
	a[d] = s[p], f[d] = 1;
	for(i = 0; i < M; i++){
		if(d + c[tp = last[p][i]] < l){
			if(tp){
				if(td < l && dfs(tp, td)) return 1;
			}
			else{
				a[td] = i + 97, f[td] = 1;
				return 1;
			} 
		}
	}
	f[d] = 0;
	return 0;
}

int main()
{		
	int i, j, m, t, mp, tp;
		
	scanf("%s", s + 1);
	l = strlen(s + 1);
	for(i = l, c[0] = 0; i; i--){
		for(j = 0, m = l; j < M; j++){
			t = c[last[i][j] = head[j]];
			if(t < m) m = t;
		}
		c[i] = m + 1;
		head[s[i] - 97] = i;
	}
	
	for(i = 1, m = c[head[mp = 0]]; i < M; i++){
		if(c[head[i]] < c[head[mp]]) mp = i;
	}
	tp = head[mp];

	if(!tp){
		putchar(mp + 97);
		putchar(10);
		return 0;
	}
	l = c[tp];
	for(i = 0; i <= l; i++) f[i] = 0;	
	dfs(tp, 0);
	a[l + 1] = 0;
	for(i = l; !f[i]; i--) a[i] = 97;
	puts(a);
						
	return 0;
}

Measured memory_bytes: 21888
import java.util.*

fun main() {
    c()
}

fun a() {
    val N = readLong()
    val otsuri = (1000 - N % 1000) % 1000
    println("${otsuri}")
}

fun b() {
    val N = readLong().toInt()
    val map = mutableMapOf<String, Long>()
    repeat(N) {
        val s = readLine()!!
        map[s] = map.getOrDefault(s, 0) + 1
    }
    listOf("AC", "WA", "TLE", "RE").forEach {
        println("$it x ${map.getOrDefault(it, 0)}")
    }
}

fun c() {
    val (H, W, K) = readLongList()
    val set = mutableSetOf<Pair<Int, Int>>()
    repeat(H.toInt()) { h ->
        readLine()!!.forEachIndexed { w, c ->
            if (c == '#') set.add(h to w)
        }
    }

    pairs((0b0 until (1 shl H.toInt()).toLong()), (0b0 until (1 shl W.toInt()).toLong())).count { bits ->
        set.count { it.first in bits.first.bitFilter(1) && it.second in bits.second.bitFilter(1) } == K.toInt()
    }.let { println(it) }
}

fun readLong() = readLine()!!.toLong()
fun readLongList() = readLine()!!.split(" ").map { it.toLong() }

fun Long.bitEach(action: (Int) -> Unit) { (0 until Long.SIZE_BITS).forEach { action(((this shr it) and 1).toInt()) } }
fun Long.bitFilter(bit: Int) = (0 until Long.SIZE_BITS).filter { ((this shr it) and 1) == 1L }

fun <T1, T2> pairs(first: Iterable<T1>, second: Iterable<T2>) = first.flatMap { t1 -> second.map { t2 -> t1 to t2 } }

fun Long.print() { println(this) }

Measured memory_bytes: 55016
#include<cstdio>
#include<algorithm>

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

using namespace std;

typedef long long ll;

#define ceil(a,b) ((a+b-1)/(b))

struct enemy{
	int c,d,s; // ツ倒ツつキツづ慊づ?づ可叩ツつュツづ猟つォツ嘉アツ青? ツ暗ェツ嘉アツづ個攻ツ個つづ?篠ゥツ閉ェツつェツ偲ウツつッツづゥツダツδ?ーツジ, ツ敏ツ渉キツ度
	bool operator<(const enemy &e)const{ return (ll)c*e.d<(ll)d*e.c; }
};

int main(){
	int n; scanf("%d",&n);
	int h[40001],a[40001],d[40001],s[40001];
	rep(i,n+1) scanf("%d%d%d%d",h+i,a+i,d+i,s+i);

	// ツ鳴ウツ敵ツづ個敵ツづ可づつつ「ツづ?療。ツ外ツ渉按猟?
	rep(i,n) if(a[0]<=d[i+1]) {
		if(d[0]<a[i+1]){ // ツ鳴ウツ敵ツづ個敵ツつゥツづァツダツδ?ーツジツづーツ偲ウツつッツづゥツづ按づァツ閉可つッツづゥツつオツつゥツづ按つ「
			puts("-1");
			return 0;
		}
		else{ // ツ鳴ウツ敵ツづ個敵ツつゥツづァツダツδ?ーツジツづーツ偲ウツつッツづ按つ「ツづ按づァツつサツづアツづ按敵ツづ債つ「ツづ按つ「ツつアツづ?づ可つオツづ?つオツづ慊つ、
			swap(h[i+1],h[n]);
			swap(a[i+1],a[n]);
			swap(d[i+1],d[n]);
			swap(s[i+1],s[n]);
			n--;
			i--;
		}
	}

	int n_tmp=0;
	enemy E[40000];
	rep(i,n){
		if(a[i+1]<=d[0]) continue;
		E[n_tmp].c=ceil(h[i+1],a[0]-d[i+1]);
		E[n_tmp].d=a[i+1]-d[0];
		E[n_tmp].s=s[i+1];
		n_tmp++;
	}
	n=n_tmp;

	sort(E,E+n);

	ll dmg=0;
	// 1 ツタツーツδ督姪堋づ可篠ゥツ閉ェツづヲツづィツ堕ャツつ「ツ敵ツづ個攻ツ個つづーツ偲ウツつッツづゥ
	rep(i,n) if(s[0]<E[i].s) {
		dmg+=E[i].d;
		dmg=min(dmg,(ll)h[0]);
	}
	// ツつオツつゥツづゥツづ猟つォツ渉?づ?敵ツづーツ倒ツつオツつスツづ?つォツづ個債?計ツ氾ュツダツδ?ーツジツづーツ計ツ算
	ll c_sum=0;
	rep(i,n){
		c_sum+=E[i].c;
		c_sum=min(c_sum,2000000000LL);
		dmg+=(c_sum-1)*E[i].d;
		dmg=min(dmg,(ll)h[0]);
	}
	if(h[0]<=dmg) puts("-1");
	else          printf("%lld\n",dmg);

	return 0;
}

Measured memory_bytes: 2084
#include<bits/stdc++.h>
#define mp make_pair
#define fi first
#define se second
#define VAL 100000
#define ll  long  long
#define INF 10000000000000000LL
#define pll pair<long long , long long>
const int MAX=5e6+9;
const ll MOD=1e9+7;
const int TOT_PRIMES=19;
const int MAX_A=70;
using namespace std;

int main() 
{
    string s;
    cin>>s;
    int cnt=0, mx=0;
    for(int i=0;i<s.size();i++){
        if(s[i]=='R'){
            cnt = cnt+1;
        }
        else{
            mx = max(cnt, mx);
            cnt = 0;
        }
    }
    mx = max(mx, cnt);
    cout<<mx;


}


Measured memory_bytes: 3616
n, a, b = map(int, input().split())
s = input()
cnt = a+b
fc = b
for i in range(n):
  if s[i] == 'a' and cnt:
    print("Yes")
    cnt -= 1
  elif s[i] == 'b' and cnt and fc:
    print("Yes")
    cnt -= 1
    fc -= 1
  else:
    print("No")

Measured memory_bytes: 4016
#include <iostream>
using namespace std;
int main(){
  int N, K, Q;
  cin >> N >> K >> Q;
  int a;
  int P[N]={0};
  for(int q=0; q<Q; q++){
  	cin >> a;
    a--;
    P[a]++;
  }
  int sum=0;
  for(int n=0; n<N; n++){
    sum+=P[n];
  }
  for(int n=0; n<N; n++){
    if (K-sum+P[n] > 0){
      cout << "Yes" << "\n";
    }
    else{
      cout << "No" << "\n";
    }
  }
  return 0;
}

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

int main() {
	string s;
	while(cin >> s, s != "-") {
		int times;
		cin >> times;
		int word_count[times];
		for(int i = 0; i < times; i++) {
			cin >> word_count[i];
		}
		for(int i = 0; i < times; i++) {
			s = s.substr(word_count[i]) + s.substr(0, word_count[i]);
		}
		cout << s << endl;
	}
}


Measured memory_bytes: 3168
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <cassert>
#include <fstream>
#include <utility>
#include <functional>
#include <time.h>
#include <stack>
#include <array>
#include <list>
// #include <boost/multiprecision/cpp_int.hpp>
// #include <boost/multiprecision/cpp_dec_float.hpp>

using namespace std;
// using namespace boost::multiprecision;

typedef long long ll;
typedef long double ld;

#define vi vector<int>
#define vl vector<ll>
#define vii vector< vector<int> >
#define vll vector< vector<ll> >
#define vs vector<string>
#define pii pair<int,int>
#define pis pair<int,string>
#define psi pair<string,int>
#define pll pair<ll,ll>
#define mii map<int,int>
#define mis map<int,string>
#define msi map<string,int>
#define mll map<ll,ll>
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define rep1(i,n) for(int i=1; i<=(int)(n); i++)
#define all(c) c.begin(),c.end()
#define srta(a) sort(all(a))
#define srtd(a) sort(all(a),greater<型>())
#define rvs(s) reverse(all(s))
#define psb push_back
#define ppb pop_back
#define ers erase
#define isu isupper
#define isl islower
#define lb(a,k) lower_bound(all(a),k)
#define ub(a,k) upper_bound(all(a),k)
#define bs(a,k) binary_search(all(a),k)
#define popcount __builtin_popcount
#define popcountll __builtin_popcountll

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

const int I_INF = 1001001001;
const ll LL_INF = 1001001001001001001;
const ld EPS = 0.001;

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

    int cnt = 0;
    if (S[0] == 'R' && S[1] == 'R' && S[2] == 'R')
        cnt = 3;
    else if ((S[0] == 'R' && S[1] == 'R') || (S[1] == 'R' && S[2] == 'R'))
        cnt = 2;
    else if (S[0] == 'R' || S[1] == 'R' || S[2] == 'R')
        cnt = 1;

    cout << cnt << endl;
}


Measured memory_bytes: 3620
x = []
y = []
while True:
    x1,y1 = map(int,input().split())
    if (x1 == 0)*(y1 ==0) :
        break
    x.append(x1)
    y.append(y1)

for i in range(len(x)):
    if x[i]>y[i]:
        print(y[i],x[i])
    else:
        print(x[i],y[i])


Measured memory_bytes: 6124
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
template<class T> inline bool chmax(T &a, T b){ if(a < b) { a = b; return true;} return false;}
using ll = long long;

int main() {
    cin.tie(0); ios_base::sync_with_stdio(false);
    ll n,m; cin >> n >> m;
    ll a[101010][3];
    for(int i=0;i<n;++i) {
        for(int j=0;j<3;++j) {
            cin >> a[i][j];
        }
    }

    ll ans = 0;

    for(int bit = 0; bit < (1<<3); ++bit) {

        vector<ll> sums;
        for(int i = 0; i < n; ++i) {

            ll tmp = 0;
            for(int j = 0; j < 3; ++j) {
                if(bit & (1<<j)) tmp += a[i][j];
                else tmp -= a[i][j];
            }
            sums.push_back(tmp);
        }
        sort(sums.rbegin(), sums.rend());

        ll tmp = 0;
        for(int k=0; k < m; ++k) tmp += sums[k];
        chmax(ans, tmp);
    }
    
    cout << ans << '\n';

    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main{
	static Scanner s = new Scanner(System.in);			//文字の入力

	static int N = s.nextInt();
	static int K = s.nextInt();					//マシンBの初期位置:x
	static int x[] = new int[N];
	static int sum = 0;


	static int ans = 0;
	public static void main(String[] args){

		solve();

	}


	static void solve() {
		for(int i=0;i < N;i++){
			x[i] = s.nextInt();
		}						//入力
		for(int i=0;i < N;i++){
			if(Math.abs(x[i] - K) >= x[i]){
				sum += 2*x[i];
			}else{
				sum += 2*Math.abs(x[i]-K); 
			}
		}
		System.out.println(sum);
	}

}

Measured memory_bytes: 21844
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn = 1e6 + 10;
ll a, b, n;

int main()
{
    int a, b;
    cin >> a >> b;
    for(int i = 1; i <= 10000; i ++){
      if((int)(0.08 * i) == a && (int)(0.1 * i) == b){
        printf("%d\n",i);
        return 0;
      }
    }
    puts("-1");
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <vector>
#include <string>
#include <stdlib.h>
#include <algorithm>
#include <functional>
 
using namespace std;
 
int main(void) {
    unsigned long int H = 0, A = 0, count = 0;
    cin >> H >> A;
    if(H % A == 0){
        count = H / A;
    }else{
        count = H / A + 1;
    }
    cout << count << endl;
    return 0;
}

Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
	"strconv"
)

func StdInInt() int {
	scanner := bufio.NewScanner(os.Stdin)
	scanner.Scan()
	input := scanner.Text()
	n, _ := strconv.Atoi(input)
	return n
}

type Point struct {
	X float64
	Y float64
}

func (p *Point) PrintPoint() {
	fmt.Printf("%.8f %.8f\n", p.X, p.Y)
}

// dはdepth
func Koch(d int, p1 *Point, p2 *Point) {
	if d == 0 {
		return
	}
	s := Point{float64(0.0), float64(0.0)}
	s.X = (2*p1.X + 1*p2.X) / 3
	s.Y = (2*p1.Y + 1*p2.Y) / 3
	t := Point{float64(0.0), float64(0.0)}
	t.X = (1*p1.X + 2*p2.X) / 3
	t.Y = (1*p1.Y + 2*p2.Y) / 3
	u := Point{}
	u.X = (t.X-s.X)*math.Cos(float64(60.0*math.Pi/180)) - (t.Y-s.Y)*math.Sin(float64(60.0*math.Pi/180)) + s.X
	u.Y = (t.X-s.X)*math.Sin(float64(60.0*math.Pi/180)) + (t.Y-s.Y)*math.Cos(float64(60.0*math.Pi/180)) + s.Y

	Koch(d-1, p1, &s)
	s.PrintPoint()
	Koch(d-1, &s, &u)
	u.PrintPoint()
	Koch(d-1, &u, &t)
	t.PrintPoint()
	Koch(d-1, &t, p2)
}

func main() {
	d := StdInInt()
	p1 := &Point{float64(0.0), float64(0.0)}
	p2 := &Point{float64(100.0), float64(0.0)}
	p1.PrintPoint()
	Koch(d, p1, p2)
	p2.PrintPoint()
}



Measured memory_bytes: 1156
#include<bits/stdc++.h>
#define ll long long
#define mxn 200005
using namespace std;
ll ara[mxn];
bool vis[mxn];
int main()
{
    ll n, x, m;
    scanf("%lld %lld %lld", &n, &x, &m);
    if(m==1)
    {
        printf("0\n");
        return 0;
    }
    ara[1]= x;
    for(int i=2; i<=2*m; i++)
    ara[i]= (ara[i-1]*ara[i-1])%m;
    ll st= 0, sum= 0;
    vector<ll>vec;
    for(int i=1; ;i++)
    {
        if(!vis[ ara[i] ])vis[ ara[i] ]= 1;
        else
        {
            ll x= ara[i];
            i--;
            while(ara[i]!=x)vec.push_back(ara[i]), i--;
            i--;
            st= i;
            vec.push_back(x);
            reverse(vec.begin(), vec.end());
            for(int j=0;j<vec.size(); j++)sum+= vec[j];
            break;
        }
    }
    ll res= 0;
    for(int i=1; i<=min(st, n); i++)res+= ara[i];
    n-= min(st, n);
    res+=(n/vec.size())*sum;
    for(int i=0; i<(n%vec.size()); i++)res+= vec[i];
    printf("%lld\n", res);
    return 0;
}


Measured memory_bytes: 5588
#include <bits/stdc++.h>
using namespace std;
int main(){
	string s, t;
	cin >> s >> t;
	for(int i=0; i<s.length(); ++i){
		if(s[i] != t[i]){
			cout << "No";
			return 0;
		}
	}
	cout << "Yes";
}


Measured memory_bytes: 3508
from collections import Counter

pair_dict = Counter()
for i in range(2001):
  pair_dict[i] = min(i, 2000 - i) + 1 

while True:
  try:
    n = int(input())
    ans = 0
    for i in range(n + 1):
      ans += pair_dict[i] * pair_dict[n - i]
    print(ans)

  except EOFError:
    break



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

const ll INF = 1e17;
const ll MOD = 1e9+7;

int reDevide(int i)
{
    int ret = i;
    while(ret >= 10) ret /= 10;
    return ret;
}

int main() {
    // input, ready
    int N;
    cin >> N;
    map<pi, int> ansMap;

    //resolve
    for (int i=1; i<=N; i++)
    {
        int a = i % 10;
        int b = reDevide(i);
        ansMap[pi(a,b)]++;
    }

    ll ans =0;
    for (int i=1; i<=N; i++)
    {
        int a = i % 10;
        int b = reDevide(i);
        ans += ansMap[pi(b,a)];
    }    

    // output
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#require 'prime'
#require 'openssl'
MOD=10**9+7;  cnt=0; sum=0; prev=nil; can=true; h=Hash.new(0)
def gs() gets.chomp end
def gi() gets.chomp.to_i end
def gsmi() gets.chomp.split.map(&:to_i) end

def ar2(s1,s2,de=nil) Array.new(s1){Array.new(s2,de)} end
def ar3(s1,s2,s3,de=nil) Array.new(s1){Array.new(s2){Array.new(s3,de)}} end

def desc(ar) ar.sort!{|x,y| y<=>x} end
def min(a,b) a<=b ? a : b end
def max(a,b) a>=b ? a : b end
def sum(ar) ar.inject(:+).to_i end
def ceil(a,b) (a.to_f/b).ceil end

def C(a,b) b==0||a==b ? 1 : (b=a-b if a/2<b;(a-b+1..a).inject(:*)/(1..b).inject(:*)) end
def rui(ar) s=[0]; ar.size.times{|i| s<<s[-1]+ar[i]}; s end
def rev_rui(ar) s=[0]; ar.size.times.reverse_each{|i| s<<s[-1]+ar[i]}; s end

def puts_yesno(b) puts(b ? 'Yes' : 'No') end
def putsend(s) puts s; exit end
def pu(h) begin; require './../nemi_lib/debug.rb'; puts_val(h); rescue LoadError; end; end
########### ( ˘ω˘ )ｽﾔｧ… ###########
s=gs
puts_yesno s[2]==s[3]&&s[4]==s[5]

Measured memory_bytes: 1788
import java.util.Scanner;
class Main{
    int n,x;
    public void solve(){
        Scanner sc = new Scanner(System.in);
        n = sc.nextInt();
        int a[] = new int [n];
        for(x = 0; x < n; x++){
            a[x] = sc.nextInt();
        }
        for(x = n-1;x >= 0; x--){
            if(x != 0){
                System.out.printf("%d ",a[x]);
            }else{
                System.out.printf("%d\n",a[x]);
            }
        }
    }
    public static void main(String[] args){
        new Main().solve();
    }
}

Measured memory_bytes: 20268
#include<stdio.h>

int main(){
  int n,k;
  int x,y;
  int ans;

  scanf("%d",&n);
  scanf("%d",&k);
  scanf("%d",&x);
  scanf("%d",&y);

  if(n>k){
    ans = x*k + (n-k)*y;
  }else{
    ans = x*n;
  }

  printf("%d",ans);

  return 0;
}


Measured memory_bytes: 128
#include        "iostream"
#include        "algorithm"
#include		"numeric"
#include        "cstring"
#include        "math.h"
#include        "string"
#include        "vector"
#include        "ctime"
#include        "queue"
#include        "stack"
#include        "map"
#include        "set"

#include        <ext/pb_ds/assoc_container.hpp> // Common file
#include        <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
#include        <ext/pb_ds/detail/standard_policies.hpp>

using namespace std;
using namespace __gnu_pbds;


#define          f first
#define          lgn 25
#define          endl '\n'
#define          sc second
#define          N (int)2e5+5
#define          pb push_back
#define          mod 1000000007
#define          ld long double
#define          vi vector<int>
#define          eb emplace_back
#define          vpii vector<pii>
#define          mii map<int,int>
#define          int long long 
#define          pii pair<int,int>
#define          pq priority_queue
#define          test(x) while(x--)
#define          all(x) begin(x),end(x)
#define          allr(x) rbegin(x),rend(x)
#define          fo(i,a,n) for(int i=a;i<n;i++)
#define          rfo(i,n,a) for(int i=n;i>=a;i--)
#define          db(x) cout<<#x <<" : "<< x <<endl;
#define          FAST ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define          time() cerr << "Time : " << (double)clock() / (double)CLOCKS_PER_SEC << "s\n"
#define          PI acos(-1.0)
#define 		 bug(...)       __f (#__VA_ARGS__, __VA_ARGS__)

typedef tree< int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update > 
OS ;

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

inline void INP()
{
	#ifndef ONLINE_JUDGE
	    freopen("in.txt","r",stdin);   
	    freopen("ou.txt","w",stdout);
	#endif 
}

const int inf = 0x3f3f3f3f;
const int INF = 0x3f3f3f3f3f3f3f3f;

int n,m,k,q;
string s;
int vis[N],dp[N],h[N];

void go()
{
	cin >> n;

	fo(i,0,n) cin >> h[i];

	memset( dp , 0x3f3f3f3f , sizeof dp);

	dp[0] = 0;
	dp[1] = abs(h[0] - h[1] );

	fo(i,2,n)
	{
		dp[i] = min( { dp[i-1] + abs(h[i] - h[i-1]) , dp[i-2] + abs(h[i] - h[i-2] ) } );
	}

	cout << dp[n-1] << endl;
	
}

int32_t main()
{
	//INP(); 
	FAST;     
	int t=1; 
	// cin>>t;
	test(t) go();
}


Measured memory_bytes: 3584
#include <stdio.h>
#include <stdlib.h>

int main() {

    int n, k;
    scanf("%d %d", &n, &k);
    int cnt = 0;
    int mysum = 1;
    
    while (cnt < n) {
        if (mysum * 2 >= mysum + k) {
            mysum += k;
        } else {
            mysum *= 2;
        }

        cnt++;

    }

    printf("%d", mysum);

    return 0;
}

Measured memory_bytes: 128