akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#pragma GCC optimize("O3")
#define REP(i,n) for(int i=0;i<n;i++)
#define REPP(i,n) for(int i=1;i<=n;i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define EPS (1e-9)
#define INF (1e17)
#define PI (acos(-1))
//const double PI = acos(-1);
//const double EPS = 1e-15;
//long long INF=(long long)1E17;
#define i_7 (long long)(1e9+7)
//#define i_7 998'244'353
long mod(long a){
    long long c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
using namespace std;

bool prime_(int n){
  if(n==1){
    return false;
  }else if(n==2){
    return true;
  }else{
    for(int i=2;i<=sqrt(n);i++){
      if(n%i==0){
        return false;
      }
    }
    return true;
  }
}

long long gcd_(long long a, long long b){
  if(a<b){
    swap(a,b);
  }
  if(a%b==0){
    return b;
  }else{
    return gcd_(b,a%b);
  }
}
 
long long lcm_(long long x, long long y){
  return (x/gcd_(x,y))*y;
}

int main(){
  
  string s;
  cin>>s;
  int ans;
  if(s == "SUN"){
    ans = 7;
  }else if(s == "MON"){
    ans = 6;
  }else if(s == "TUE"){
    ans = 5;
  }else if(s == "WED"){
    ans = 4;
  }else if(s == "THU"){
    ans = 3;
  }else if(s == "FRI"){
    ans = 2;
  }else{
    ans = 1;
  }
  cout<<ans<<endl;
  return 0; 
}


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

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

	vector<int> dp(2019, 0);
	dp[s[0] - '0'] = 1;
	int ans = 0;
	for (int i = 1; i < s.length(); ++i) {
		int d = s[i] - '0';
		vector<int> tdp(2019, 0);
		tdp[d] = 1;
		for (int j = 0; j < 2019; ++j) {
			if (dp[j] > 0) {
				int r = (10 * j + d) % 2019;
				if (r == 0) {
					ans += dp[j];
				}

				tdp[r] += dp[j];
			}
		}

		copy(tdp.begin(), tdp.end(), dp.begin());
	}

	cout << ans;
	
	return 0;
}
	

Measured memory_bytes: 3724
#include <iostream>
#include <vector>

using namespace std;

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

int main(){
  int n;
  cin >> n;
  vector<int> a(n), b(n), c(n - 1);
  rep(i, 0, n) cin >> a[i];
  rep(i, 0, n) cin >> b[i];
  rep(i, 0, n - 1) cin >> c[i];
  
  int ans = 0;
  rep(i, 0, n) {
    if (a[i] + 1 == a[i + 1]) ans += c[a[i] - 1];
    ans += b[a[i] - 1];
  }
  cout << ans << endl;
}

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

using namespace std;
using ll = long long;

int main(int argc, const char *argv[]) {
  ll n;
  cin >> n;

  ll sub_groups = 2, elms = 1;
  vector<vector<ll>> ans(sub_groups);
  ans[0].push_back(1);
  ans[1].push_back(1);

  while (elms < n) {
    ans.push_back({});
    for (int i = 0; i < sub_groups; ++i) {
      ans[i].push_back(elms + i + 1);
      ans.back().push_back(elms + i + 1);
    }

    elms += sub_groups;
    sub_groups++;
  }

  if (elms != n) {
    cout << "No" << '\n';
    return 0;
  }

  cout << "Yes" << '\n';
  cout << ans.size() << '\n';
  for (int i = 0; i < ans.size(); ++i) {
    cout << ans[i].size();
    for (int j = 0; j < ans[i].size(); ++j) {
      cout << ' ' << ans[i][j];
    }

    cout << '\n';
  }
}

Measured memory_bytes: 5460
H, W = map(int, input().split())
D = []
res = []
for _ in range(H):
    D.append(list(map(int, input().split())))
for i in range(H-1):
    for j in range(W):
        if D[i][j]%2:
            D[i+1][j] += 1
            res.append((i+1,j+1,i+2,j+1))
for j in range(W-1):
    if D[H-1][j]%2:
        D[H-1][j+1] += 1
        res.append((H,j+1, H, j+2))
print(len(res))
for i,j,k,l in res:
    print(i,j,k,l)

Measured memory_bytes: 97748
#include <cstdio>
#include <iostream>
#include <string>
#include <algorithm>
#include <cstring>
#include <utility>
#include <vector>
#include <map>
#include <set>
#include <cmath>
#include <queue>
#include <bitset>
#include <stack>
#include <deque>
using namespace std;
typedef pair<int, int> pii;
typedef long long LL;
const int MAXN = 2345;
int x[] = {0, -1, -1, 0};
int y[] = {0, 0, -1, -1};
bool OK[MAXN][MAXN];
int bd[MAXN][MAXN];
int l[MAXN][MAXN], r[MAXN][MAXN], visit[MAXN][MAXN];
int curl[MAXN], curr[MAXN], curh[MAXN];
char s[MAXN];

int main() {
    int H, W;
    while (~scanf("%d %d", &H, &W)) {
          memset(l, 0, sizeof(l));
          memset(r, 0, sizeof(r));
          for (int i = 1; i <= H; i++) {
              scanf("%s", s + 1);
              for (int j = 1; j <= W; j++) {
                  if (s[j] == '.') bd[i][j] = 0;
                  else bd[i][j] = 1;
                  visit[i][j] = OK[i][j] = 0;
              }
          }
          for (int i = 1; i <= H; i++) {
              for (int j = 1; j <= W; j++) {
                  if (i == 1 || j == 1) continue;
                  int tsum = 0;
                  for (int k = 0; k < 4; k++) {
                      tsum += bd[i + y[k]][j + x[k]];
                  }
                  if ((tsum % 2) == 0) OK[i][j] = 1;
              }
          }
          for (int i = 1; i <= H; i++) {
              for (int j = 1; j <= W; j++) {
                  if (!OK[i][j]) continue;
                  l[i][j] = l[i][j - 1] + 1;
              }
              for (int j = W; j >= 1 ;j--) {
                  if (!OK[i][j]) continue;
                  r[i][j] = r[i][j + 1] + 1;
              }
          }
          int ans = max(H, W);
          for (int i = 1; i <= H; i++) {
              for (int j = 1; j <= W; j++) {
                  if (!OK[i][j]) curh[j] = 0;
                  else curh[j] += 1;
                  if (!curr[j]) curr[j] = r[i][j];
                  else curr[j] = min(curr[j], r[i][j]);
                  if (!curl[j]) curl[j] = l[i][j];
                  else curl[j] = min(curl[j], l[i][j]);
              }
              for (int j = 1; j <= W; j++) {
                  if (!OK[i][j]) continue;
                  ans = max(ans, (curr[j] + curl[j]) * (curh[j] + 1));
              }
          }
          printf("%d\n", ans);
    }
    return 0;
}


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

int main() {
    using vi = vector<long long>;
    
    long long n,k;
    cin >> n >> k;
    vi a(n);
    rep(i,n){
        cin >> a[i];
    }
    vi x;
    x.push_back(1);
    set<long long> s;
    s.insert(1);
    long long size = 1;
    long long key = 1;
    int next = 0;
    rep(i,n){
        s.insert(a[next]);
        if(size == s.size()){
            key = a[next];

            //cout << i;

            break;
        }else{
            size = s.size();
            x.push_back(a[next]);
            next = a[next]-1;

            //cout << i;
        }      
    }

    // cout << endl;
    // rep(i,x.size()){
    //     cout << x[i];
    // }
    // cout << endl;

    long long count = 0;
    rep(i,x.size()){
        if(x[i] == key){
            count = i;   
            break;
        }
    }
    if(k < x.size()){
        // if(k == x.size()){
        //     cout
        // }
        cout << x[k] << endl;
        exit(0);
    }
    k -= count;
    long long lsize = x.size() - count;
    k = k%lsize;
    cout << x[count+k] << endl;
}

Measured memory_bytes: 15996
import java.util.*;
import java.text.*;
public class Main {
	public static void main(String args[]){
		Scanner in=new Scanner(System.in);
		for(int t=1,T=in.nextInt();t<=T;t++){
			//x^2+y^2 -2xi*x -2yi*y +xi^2+yi^2 =r^2
			//G[] =>  -2xi   -2yi    xi^2+yi^2
			double g[][]=new double[5][5];
			double x=0,y=0;
			for(int i=1;i<=3;i++){
				x=in.nextDouble();
				y=in.nextDouble();
				g[i][1]=-2*x;
				g[i][2]=-2*y;
				g[i][3]=x*x+y*y;
			}
			for(int i=2;i<=3;i++)
				for(int j=1;j<=3;j++)
					g[i][j]-=g[1][j];
			double a1=g[2][1],b1=g[2][2],c1=g[2][3];
			double a2=g[3][1],b2=g[3][2],c2=g[3][3];
			double x0=(b1*c2-b2*c1)/(b2*a1-b1*a2);
			double y0=(a1*c2-a2*c1)/(a2*b1-a1*b2);
			double r=Math.sqrt((x-x0)*(x-x0)+(y-y0)*(y-y0));
			DecimalFormat df=new DecimalFormat("0.000");
			System.out.println(df.format(x0)+" "+df.format(y0)+" "+df.format(r));
		}
		in.close();
	}
}

Measured memory_bytes: 28716
import sys
import math

#sys.setrecursionlimit(10000)

n,k = map(int, input().split())
h = sorted(list(map(int, (input() for i in range(n)))))

ans = max(h)

for i in range(n - k + 1):
    ans = min(ans,h[i + k - 1] - h[i])
print(ans)


Measured memory_bytes: 8288
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <queue>
#include <set>
#include <map>
#include <functional>
#include <numeric>
#include <limits>
#include <cmath>
#include <iomanip>
#include <sstream>
 
#define ALL(a)  (a).begin(),(a).end()
 
using namespace std;
typedef long long int ll;
typedef pair <int,int> P;

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

    ll ans = 0;

    ll n, m;
    cin >> n >> m;
    int *c, *cc;
    c = new int[n];
    cc = new int[n];
    for (int i = 0; i < n; i++) {
        c[i] = 0;
        cc[i] = 0;
    }

    if (n == 1 && m == 0) {
        c[0] = 0;
    } else {
        c[0] = 1;
    }

    for (int i = 0; i < m; i++) {
        int s, t;
        cin >> s >> t;
        if (cc[s-1] == 1 && c[s-1] != t) {
            cout << -1 << endl;
            return 0;
        } else {
            c[s-1] = t;
            cc[s-1] = 1;
        }
    }
        
    if (n != 1  && c[0] == 0) {
        cout << -1 << endl;
        return 0;
    }

    int pow = 1;
    for (int i = 0; i < n; i++) {
        ans += c[n-i-1] * pow;
        pow *= 10;
    }

    cout << ans << endl;
    

}

Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.Collections;
import java.util.Scanner;
 


public class Main {
	static int a1[]= {0,-1,0,1};
	static int b1[]= {-1,0,1,0};
	private static Scanner sc = new Scanner(System.in);
	//result = Math.pow(num1, num3)
	//StringBuffer str = new StringBuffer(hoge1);
	//String hoge2 = str.reverse().toString();
	//map.containsKey(A)

	//Map<String, Integer> map = new HashMap<String, Integer>(n);
	/*for ( キーのデータ型 key : マップの名前.keySet() ) {
		データのデータ型 data = マップの名前.get( key );
		
		// keyやdataを使った処理;
	}*/
	//int i = Integer.parseInt(s);
	//Queue<String> qq=new ArrayDeque<>(); //add,poll,peek
	//Deque<String> qq=new ArrayDeque<>();//push,pop,peek
	//ArrayList<String> cc = new ArrayList<>(n);
	//Collections.sort(list);
	//Array.sort(list);   cc.contains(tmp)
	//Arrays.asList(c).contains("a")
	//list.set(1,"walk");
	public static void main(String[] args) {
		int N=sc.nextInt();
		long X=sc.nextLong();
		ArrayList<Integer> cc = new ArrayList<>(N);
		long sum=0;
		for(int i=0;i<N;i++) {
			cc.add(sc.nextInt());
			sum+=cc.get(i);
		}
		boolean a=true;
		if(sum==X) {
			p(N);
			a=false;
		}
		Collections.sort(cc);
		long ans=0;
		int ctn=0;
		for(int i:cc) {
			if(i<=X) {
				X-=i;
				ctn++;
				if(i==cc.get(cc.size()-1)) {
					if(X>0)ctn--;
				}
			}
			
		}
		if(a) {
			if(ctn==X)p(ctn-1);
			else p(ctn);
		}
	}
	static void p(String ans) {System.out.println(ans);};
	static void p(int ans) {System.out.println(ans);};
	static void p() {System.out.println();};
	static void p(long ans) {System.out.println(ans);};
	static void p(double ans) {System.out.println(ans);};
}
	

Measured memory_bytes: 21460
#include<bits/stdc++.h>
using namespace std;
#include <math.h>
#define ll long long 
// to increase precision
// std::cout<<std::fixed;
// 	std::cout<<std::setprecision(6)<<z;
#define max1 1000001

long long int mod=1e18 ;


int main(){	
	mod+=1;
	int n;
	cin>>n;
	long long int lans;
	long long int ans;
	vector<long long int> a(n);
	for (int i = 0; i < n; ++i)
	{
		cin>>a[i];
	}
	sort(a.begin(),a.end());
	ans=a[0];
	lans=a[0];
	for(int i=1;i<n;i++){
		long long int ans1=(ans*a[i])%mod;
		if(ans==0){
			break;
		}
		if((ans1/lans)!=a[i]){
			ans=-1;
			break;
		}
		//cout<<ans1<<" "<<lans<<endl;
		ans=ans*a[i];
		lans=ans;
		
	}
	cout<<ans<<endl;


}
	
	
	
	





Measured memory_bytes: 3944
#include <iostream>
#include <algorithm>
#include <string>

using namespace std;

int main()
{
    string str;
    int cnt[27] = {};
    int f = 1;

    cin >> str;
    for (int i = 0; i < str.size(); i++) {
        cnt[str[i] - 'a']++;
    }

    for (int i = 0; i < 26; i++) {
        if (cnt[i] & 1) {
            f = 0;
        }
    }

    if (f) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }

    return 0;
}


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

#define fast_io ios_base::sync_with_stdio(false); cin.tie(0);
#define ll long long
#define en "\n"
#define eps 1e-9
#define VECT(v)  vector<int>v
#define SCAN(v)  int temp; for(int i=0; i<n; i++) {cin>>temp; v.push_back(temp);}
#define PRINT(v) for(int i = 0; i < v.size(); i++) cout << v[i] << " "; cout << en;
#define SORT(v)  sort(v.begin(), v.end());
#define CASEP(v) cout<<"Case "<<tc<<": "<<v<<"\n"
#define DEBUG(v) cout << v << " "; cout << en;

int main(void)
{
	#ifndef ONLINE_JUDGE
		freopen("in.txt", "r", stdin);
		freopen("out.txt", "w", stdout);
	#endif

	fast_io

	int n;
	cin >> n;

	set <int> s;
	int val;

	for(int i = 0; i < n; i++)
	{
		cin >> val;
		s.insert(val);
	}
	if(s.size() == n)
		cout << "YES\n";
	else
		cout << "NO\n";

	return 0;
}

Measured memory_bytes: 13012
import itertools
from collections import Counter
 
N = int(input())
V = [int(x) for x in input().split()]
# print(V)
EV_counter = Counter(V[::2])
OD_counter = Counter(V[1::2])
EV_counter[-1] = 0
OD_counter[-2] = 0
EV = EV_counter.most_common(2)
OD = OD_counter.most_common(2)
# print(EV)
# print(OD)
# print(EV_counter)
# print(OD_counter)
answer = N
for (k1,v1), (k2,v2) in itertools.product(EV,OD):
    # print(k1, v1, k2, v2)
    if k1 == k2:
        continue
    x = (N - v1 - v2)
    if answer > x:
        answer = x 

print(answer) 

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

int N,M;
int sum;
typedef struct{
	int D;
	int P;
} section;

section s[10000];

int comp(const void* c1, const void* c2){
	section *s1=(section*)c1;
	section *s2=(section*)c2;
	return s2->P - s1->P;
}

void solve(){
	int i;

	for(i=0;i<N;i++){
		scanf("%d %d",&s[i].D,&s[i].P);
	}
	qsort(s,N,sizeof(section),comp);
	sum=0;
	for(i=0;i<N;i++){
		if(M>s[i].D){
			M-=s[i].D;
		}else if(M){
			sum+=(s[i].D-M)*s[i].P;
			M=0;
		}else{
			sum+=s[i].D*s[i].P;
		}
	}
	printf("%d\n",sum);
	return;
}

int main(void){

	while(scanf("%d %d",&N,&M),N){
		solve();
	}
	return 0;
}

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


int main() {
	int n, k, x, y;
	int fees = 0;

	// #n=total nights
	// #k=number of first nights
	// #(n-k) is the number of succeeding nigths

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

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

	

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



	return 0;
}


Measured memory_bytes: 1732
import java.util.Scanner;

public class Main {
	public static void main(String[] args)
	{
		Scanner sc=new Scanner(System.in);
		int mark=9999;
		int n;
		int i;
		int a[]=new int[10000];
		n=sc.nextInt();
		for(i=0;i<n;i++)
		{
			a[i]=sc.nextInt();
		}
		for(i=1;i<n;i++)
		{
			if(a[i]==a[i-1])
			{
				a[i]=mark;
				mark--;
			}
		}
		System.out.print(9999-mark);
	}
}


Measured memory_bytes: 21844
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author Joy
 */

#include <bits/stdc++.h>
#define REP(i, N) for (int i = 0; i < (N); ++i)
#define ALL(x) (x).begin(), (x).end()
#define MOD 1000000007
#define PB push_back
#define MP make_pair
using namespace std;
typedef long long ll;
ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; }

class BYYMMOrMMYY {
public:
	void solve(std::istream& in, std::ostream& out) {
        int s;
        in >> s;
        string ans;
        int left = s/100;
        int right = s % 100;
        bool isMl = 1 <= left && left <= 12;
        bool isMr = 1 <= right && right <= 12;
        if (isMl) {
            if (isMr) ans = "AMBIGUOUS";
            else ans = "MMYY";
        } else {
            if(isMr) ans = "YYMM";
            else ans = "NA";
        }
        out << ans << '\n';
	}
};


int main() {
	BYYMMOrMMYY solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
  int n,k,sz,count=0;
  cin>>n>>k;
  bool snacks[n+1]={false};
  while(k--){
    cin>>sz;
    for(int i=0,a;i<sz;i++){
      cin>>a;
      snacks[a]=true;
    }
  }
  for(int i=1;i<=n;i++){
    if(snacks[i]) continue;
    count++;
  }
  cout<<count<<endl;
  return 0;
}
      

Measured memory_bytes: 3612
#include <bits/stdc++.h>
#define LL long long
using namespace std;
int main()
{
    int n; scanf("%d",&n);
    int a[n+5];
    for(int i=1;i<=n;i++)scanf("%d",&a[i]);
    int c=0,x,i=1;
    while(++c<2000000)
    {
        x=a[i];
        i=x;
        if(x==2)return printf("%d",c),0;
    }
    puts("-1");
return 0;
}


Measured memory_bytes: 640
#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<ll,ll>;
//マクロ
//forループ関係
//引数は、(ループ内変数,動く範囲)か(ループ内変数,始めの数,終わりの数)、のどちらか
//Dがついてないものはループ変数は1ずつインクリメントされ、Dがついてるものはループ変数は1ずつデクリメントされる
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
//xにはvectorなどのコンテナ
#define ALL(x) (x).begin(),(x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x)) //最大値を求める
#define MIN(x) *min_element(ALL(x)) //最小値を求める
//定数
#define INF 1000000000000 //10^12:極めて大きい値,∞
#define inf 2147483647 //int値の最大値
#define MOD 1000000007 //10^9+7:合同式の法
#define MAXR 100000 //10^5:配列の最大のrange(素数列挙などで使用)
//略記
#define PB push_back //vectorヘの挿入
#define MP make_pair //pairのコンストラクタ
#define F first //pairの一つ目の要素
#define S second //pairの二つ目の要素
#define CST(x) cout<<fixed<<setprecision(x)//小数点以下の桁数指定
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
int gcd(int a, int b) {
    if (b==0) return a;
    else return gcd(b, a%b);
}
int lcm(int a, int b) {
    return a * b / gcd(a, b);
}
int two(int n){
	ll ans=1;
	rep(i,n){
		ans*=2;
	}
	return ans;
}
int main() {
	cin.tie(0);
	cout.tie(0);
	ios::sync_with_stdio(false);

   string s;
   cin>>s;
   int sum =s.size()-2;

   cout<<s[0]<<sum<<s[s.size()-1]<<endl;


   
}

Measured memory_bytes: 3596
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll INF = 1LL << 60;
#define tl 1'000'000'007
#define REP(i, n) for (ll i = 0; i < n; i++)
#define REREP(i, n) for (ll i = n; i >= 0; i--)
#define FOR(i, a, n) for (ll i = a; i < n; i++)
#define REFOR(i, n, a) for (ll i = n; i >= a; i--)
struct p{
    ll x,y;
};
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false); 
    ll h,w;
    cin >> h >> w;
    vector<p> A;
    REP(i,h){
        REP(j,w){
            string s;
            cin >> s; 
            if(s=="snuke") A.push_back({i,j});
        }
    }
    REP(i,A.size()) cout << (char)(A[i].y+'A') << A[i].x+1 << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<vector>
#include<list>
#include<stack>
#include<queue>
#include<set>
#include<map>
#include<string>
#include<algorithm>
#include<functional>
#include<math.h>
#include<unordered_set>
using namespace std;

int main() {
	int N, A, B;
	cin >> N >> A >> B;

	cout << min(N * A, B) << endl;
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

void selectionSort(int A[],int N){
    int i = 0;
    int j = 0;
    int minj = 0;
    int temp = 0;
    int counter = 0; 
    for(i = 0; i < N; i++){
         minj = i;
         for(j = i; j < N; j++){
            if(A[j] < A[minj]) minj = j;
         } 
        if(i!=minj){
                temp = A[i];
                A[i] = A[minj];
                A[minj] = temp;
                counter++;
        
         }
    }
    for(i = 0;i < N; i++){
        if(i!=0) printf(" ");
        printf("%d", A[i]);
    }
    printf("\n");
    printf("%d\n", counter);
    return;
}


int main(void){
    int i = 0;
    int N = 0;
    int A[100];
    scanf("%d\n", &N);
    for(i=0; i<N; i++){
        scanf("%d",&A[i]);
    }
    selectionSort(A, N);
    return 0;
}

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

taste = [L+i-1 for i in range(1, N+1)]

absolutes = []

for v in taste:
    if v >= 0:
        absolutes.append(v)
    else:
        absolutes.append(-v)

min = min(absolutes)
index = absolutes.index(min)
w = taste[index]
sum = sum(taste)-w

print(sum)

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

int main()
{
	string buf;
	while (getline(cin, buf))
	{
		for (int i=0; i<buf.size(); i++)
		{
			if (islower(buf[i]))
			{
				cout << (char) toupper(buf[i]);
			}
			else
			{
				cout << buf[i];
			}
		}
		cout << endl;
	}

	return 0;
}

Measured memory_bytes: 0
import re

s = str(input())
t = str(input())


#Sの?を正規表現　英文字1つに変換する
#tがsのどこに含まれるかどうかを、開始位置を一文字ずつずらしながら調査
#最初に見つかった場所を対象にtを代入
#残りの文字は'a'に変換
#リストに格納
#sortして最初に来たものがanswer
#リストがからの場合は UNRESTORABLE

NS = []

for i in range(len(s)):
    #対象外のものは?をaに変換
    s_res = s[:i]
    s_res = s_res.replace('?', 'a')
    
    #対象外のものは?を.に変換
    #探索範囲は探る文字列tと同じ長さ
    s_obj = s[i:i+len(t)]
    s_obj = s_obj.replace('?', '.')
    s_comp = re.compile(s_obj)

    s_res_f = s[i+len(t):]
 
    matchobj = s_comp.fullmatch(t)

    if matchobj:
        start = matchobj.start()
        new_s = s_res + t + s_res_f
        new_s = new_s.replace('?', 'a')
        NS.append(new_s)

if len(NS) == 0:
    ans = 'UNRESTORABLE'
else:
    ans = sorted(NS)[0]

print(ans)

Measured memory_bytes: 3188
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main()
{
    vector <int> n(3);
    for(int i=0;i<3;++i) cin >> n[i];
    sort(n.begin(),n.end());
    cout << n[2]*10+n[1]+n[0] << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define pir pair<lli,lli>
#define mpa make_pair
#define fi first
#define se second
typedef long long lli;
using namespace std;
struct Edge{
	lli to,nxt;
}e[400010];
lli n,cnt,sum;
lli d[100010],h[100010],siz[100010],dis[100010];
map <lli,lli> id;
vector <pir> ans;
void add(lli u,lli v)
{
	e[++cnt].to=v;
	e[cnt].nxt=h[u];
	h[u]=cnt;
}
void dfs(lli u)
{
	for(lli i=h[u];i;i=e[i].nxt){
		lli v=e[i].to;
		dis[v]=dis[u]+1;
		dfs(v);
	}
}
int main()
{
	scanf("%lld",&n);
	for(lli i=1;i<=n;i++){
		scanf("%lld",&d[i]);
		id[d[i]]=i;
		siz[i]=1;
	}
	sort(d+1,d+n+1);
	for(lli i=n;i>1;i--){
		lli u=id[d[i]],tmp=n-2*siz[u];
		if(tmp<=0||id.count(d[i]-tmp)==0){
			puts("-1");
			return 0;
		}
		lli f=id[d[i]-tmp];
		add(f,u);
		ans.push_back(mpa(f,u));
		siz[f]+=siz[u];
	}
	dfs(id[d[1]]);
	for(lli i=1;i<=n;i++) sum+=dis[i];
	if(sum!=d[1]){
		puts("-1");
		return 0;
	}
	for(lli i=0;i<ans.size();i++)
		printf("%lld %lld\n",ans[i].fi,ans[i].se);
}

Measured memory_bytes: 17012
import sys
from io import StringIO
import unittest


def resolve():
    a, b, c, k = map(int, input().split())

    if k <= a:
        print(k)
    elif k <= a + b:
        print(a)
    elif k <= (a + b + c):
        print(a - (k - (a + b)))


class TestClass(unittest.TestCase):
    def assertIO(self, input, output):
        stdout, stdin = sys.stdout, sys.stdin
        sys.stdout, sys.stdin = StringIO(), StringIO(input)
        resolve()
        sys.stdout.seek(0)
        out = sys.stdout.read()[:-1]
        sys.stdout, sys.stdin = stdout, stdin
        self.assertEqual(out, output)

    def test_入力例_1(self):
        input = """2 1 1 3"""
        output = """2"""
        self.assertIO(input, output)

    def test_入力例_2(self):
        input = """1 2 3 4"""
        output = """0"""
        self.assertIO(input, output)

    def test_入力例_3(self):
        input = """2000000000 0 0 2000000000"""
        output = """2000000000"""
        self.assertIO(input, output)


if __name__ == "__main__":
    # unittest.main()
    resolve()


Measured memory_bytes: 16340
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define mod 1000000007
ll dp[101][100001];
int main(){
	ll n,k;
	cin>>n>>k;
	ll a[n+1]={};
	for(int i=1;i<=n;i++)
	cin>>a[i];
	ll z=a[1],v=0;
	for(int j=0;j<=a[1];j++){
		dp[1][j]=1;
	}
	for(int i=2;i<=n;i++){
		z=(z+a[i]);
		z=min(z,k);
		ll r=0,v=0;
		for(int j=0;j<=z;j++){
			if(j>a[i]){
				r=(r-dp[i-1][v]+mod)%mod;
				//cout<<r<<endl;
				v++;
			}
			r=(r+dp[i-1][j])%mod;
			dp[i][j]=r;
		}
	}
	cout<<dp[n][k];
	return 0;
}

Measured memory_bytes: 78336
#include <iostream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <algorithm>
#include <set>
#include <map>
#include <bitset>
#include <cmath>
#include <functional>
#define vv(a, b, c, d) vector<vector<d> >(a, vector<d>(b, c))
#define vvi vector<vector<int> >
#define vvl vector<vector<ll> >
#define vll vector<ll>
#define rep(c, a, b) for(ll c=a;c<b;c++)
#define re(c, b) for(ll c=0;c<b;c++)
#define all(obj) (obj).begin(), (obj).end()
typedef long long int ll;
typedef long double ld;
using namespace std;

int main(int argc, char const *argv[]) {
  string a, b, c;std::cin >> a >> b >> c;
  std::cout << (a[a.size()-1]==b[0]&&b[b.size()-1]==c[0]?"YES":"NO") << '\n';
  return 0;
}


Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10**6)
readline = sys.stdin.readline
a,b,c,d = [int(i) for i in readline().split()]

while True:
  c -= b
  if c <= 0:
    print('Yes')
    break
  a -= d
  if a <= 0:
    print('No')
    break

Measured memory_bytes: 9200
import java.io.*;
import java.util.ArrayList;

class Main{
    public static void main(String[] args) throws IOException{
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String str = br.readLine();
        String[] sl = str.split(" ");
        int N = Integer.parseInt(sl[0]);
        int K = Integer.parseInt(sl[1]);
        str = br.readLine();
        ArrayList<Integer> nums = new ArrayList<>();
        int tmp = 1;
        int cont = 0;
        for (String s:str.split("")){
            if (Integer.parseInt(s)== tmp){
                cont++;
            } else {
                nums.add(cont);
                cont = 1;
                tmp = 1 - tmp;
            }
        }
        if (cont != 0){
            nums.add(cont);
        }
        if (nums.size() % 2 == 0){
            nums.add(0);
        }
        Integer[] nums_ = nums.toArray(new Integer[nums.size()]);
        ArrayList<Integer> ans = new ArrayList<>();
        ArrayList<Integer> cml = new ArrayList<>();
        cml.add(0);
        for (int i=0;i<nums_.length;i++){
            cml.add(cml.get(i)+nums_[i]);
        }
        int k = K * 2 + 1;
        for (int i=0;i<cml.size();i+=2){
            ans.add(cml.get(Math.min(i+k,cml.size()-1))-cml.get(i));
        }
        int max = 0;
        for (int i:ans){
            if (i > max){
                max = i;
            }
        }
        System.out.println(max);
    }
}

Measured memory_bytes: 35404
N, Y = map(int, input().split())
ans = -1,-1,-1
for x in range(N+1):
    for y in range(N - x + 1):
        z = N - x - y
        if 0<=z<=2000 and 10000*x+5000*y+1000*z == Y:
            ans = x,y,z
            break
    else:
        continue
    break
print(*ans)    

Measured memory_bytes: 3064
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using System.Text;
using System.Globalization;
using System.Diagnostics;
using System.Threading.Tasks;



class Myon
{
    public Myon() { }
    public static int Main()
    {
        new Myon().calc();
        return 0;
    }
    

    Scanner cin;
    
    void calc()
    {
        cin = new Scanner();
        int N = cin.nextInt();
        string ans = "Three";
        for (int i = 0; i < N; i++)
        {
            if (cin.next() == "Y") ans = "Four";
        }
        Console.WriteLine(ans);
    }
}




class Scanner
{
    string[] s;
    int i;

    char[] cs = new char[] { ' ' };

    public Scanner()
    {
        s = new string[0];
        i = 0;
    }

    public string next()
    {
        if (i < s.Length) return s[i++];
        string st = Console.ReadLine();
        while (st == "") st = Console.ReadLine();
        s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
        if (s.Length == 0) return next();
        i = 0;
        return s[i++];
    }

    public int nextInt()
    {
        return int.Parse(next());
    }
    public int[] ArrayInt(int N, int add = 0)
    {
        int[] Array = new int[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextInt() + add;
        }
        return Array;
    }

    public long nextLong()
    {
        return long.Parse(next());
    }

    public long[] ArrayLong(int N, long add = 0)
    {
        long[] Array = new long[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextLong() + add;
        }
        return Array;
    }

    public double nextDouble()
    {
        return double.Parse(next());
    }


    public double[] ArrayDouble(int N, double add = 0)
    {
        double[] Array = new double[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextDouble() + add;
        }
        return Array;
    }
}



Measured memory_bytes: 11092
N, M = map(int, input().split())
sub = [[0, 0] for _ in range(N)]  # 0: WC_num, 1: AC
ac, penalty = 0, 0
for _ in range(M):
    p, s = input().split()
    p = int(p)
    if s == 'WA':
        sub[p-1][0] += 1
    elif s == 'AC' and sub[p-1][1] == 0:
        sub[p-1][1] = 1
        ac += 1
        penalty += sub[p-1][0]
print(ac, penalty)

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

int main() {
 int n;
 cin >> n;
 
 vector<int> a(n),b(n);
 
 rep(i,n) {
  cin >> a.at(i);
  }
  
  rep(i,n) {
   cin >> b.at(i);
   }
   
   vector<int> k(n);
   rep(i,n) {
    k.at(i) = i + 1;
    }
   
   map<vector<int>, int> mp;
   do {
   mp[k] = mp.size();
   } while(next_permutation(k.begin(),k.end()));
   
   int ans = abs(mp[a] -mp[b]);
   cout << ans;
 }

Measured memory_bytes: 8652
N,M=map(int,input().split())
lst=[[] for _ in range(M)]
dif=10**19
v1,v2=map(int,input().split())
for i in range(M-1):
  v_1,v_2=map(int,input().split())
  v1,v2=max(v1,v_1),min(v2,v_2)
if v2-v1+1<=0:
  print(0)
else:
  print(v2-v1+1)

Measured memory_bytes: 10280
#include<bits/stdc++.h>
using namespace std;
char s[51],h[51];
int main()
{
    scanf("%s%s",s+1,h+1);
    if(strlen(s+1)==strlen(h+1))
        for(int i=1;i<=strlen(s+1);++i)printf("%c%c",s[i],h[i]);
    else
    {
    	for(int i=1;i<=strlen(h+1);++i)printf("%c%c",s[i],h[i]);
        printf("%c",s[strlen(s+1)]);
	}
    printf("\n");
}

Measured memory_bytes: 256
#include <stdio.h>

main()
{
  int length, i, j, count = 0, tmp, min, flag = 0;
  int A[100];

  scanf("%d", &length);

  for(i = 0; i < length; i++)
    {
      scanf("%d", &A[i]);
    }

  for(i = 0; i < length; i++)
    {
      min = i;
      for(j = i + 1; j < length; j++)
	{
	  if(A[j] < A[min])
	    {
	      min = j;
	      flag = 1;
	    }
	}
      if(flag == 1)
	{
	  tmp = A[i];
	  A[i] = A[min];
	  A[min] = tmp;
	  count++;
	}
      flag = 0;
    }
  for(i = 0; i < length; i++)
    {
      if(i == length - 1)
	{
	  printf("%d\n", A[i]);
	}
      else
	{
	  printf("%d ", A[i]);
	}
    }
  printf("%d\n", count);
  return 0;
}

Measured memory_bytes: 600
N = gets.to_i
p_list = gets.split.map(&:to_i)
count = 0
(1..(N - 2)).each do |i|
  a = p_list[i - 1]
  b = p_list[i]
  c = p_list[i + 1]
  count += 1 if [a, b, c].sort[1] == b
end
puts count


Measured memory_bytes: 1788
#include <iostream>
#include <algorithm>
#include <vector>
#include <limits.h>

using namespace std;
typedef unsigned long long ll;

ll E(ll i, ll x)
{
    if (i == 1)
    {
        return 5 * x;
    }
    return (2 * i + 1) * x;
}

int main()
{
    ll N, X;
    cin >> N >> X;
    vector<ll> x(N);
    for (ll i = 0; i < N; i++)
    {
        cin >> x[i];
    }
    sort(x.begin(), x.end(), std::greater<ll>());
    for (ll i = 1; i < x.size(); i++)
    {
        x[i] += x[i - 1];
    }
    x.insert(x.begin(), 0);
    ll energy = LLONG_MAX;
    for (ll k = 1; k <= N; k++)
    {
        ll cost = (N + k) * X;
        for (ll i = 1; i <= N; i++)
        {
            if (i * k <= N)
            {
                cost += E(i, x[i * k] - x[(i - 1) * k]);
            }
            else
            {
                cost += E(i, x.back() - x[(i - 1) * k]);
                break;
            }
        }
        if (cost < energy)
        {
            energy = cost;
        }
    }
    cout << energy << endl;
    return 0;
}

Measured memory_bytes: 4352
#include<cstdio>
#include<cstring>
#include<algorithm>
const int MAXN=5010;
const long long INF=1ll<<61;

struct data
{
	int h,p;
	bool operator<(const data &rsh)const
	{
		return h+p<rsh.h+rsh.p;
	}
}p[MAXN];
long long f[MAXN];

int main()
{
	int n;scanf("%d",&n);
	for(int i=1;i<=n;i++)
	{
		scanf("%d%d",&p[i].h,&p[i].p);
		f[i]=INF;
	}
	std::sort(p+1,p+n+1);
	for(int i=1;i<=n;i++)
		for(int j=n;j;j--)
			if(f[j-1]<=p[i].h)
                f[j]=std::min(f[j],f[j-1]+p[i].p);
	for(;n;n--)
		if(f[n]!=INF)
			break;
	printf("%d\n",n);
	return 0;
}

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

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<int, int> Pi;
typedef vector<ll> Vec;
typedef vector<int> Vi;
typedef vector<string> Vs;
typedef vector<vector<ll>> VV;

#define REP(i, a, b) for(ll i=(a); i<(b); i++)
#define rep(i, n) REP(i, 0, n)
const int INF=1e9;
const int MOD=1000000007;
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl;
#define ALL(v) v.begin(), v.end()
#define dbg(x_) cerr << #x_ << ":" << x_ << endl;
#define pb(x) push_back(x)
#define mp(a, b) make_pair(a,b)
#define Each(a,b) for(auto &a :b)
#define REPM(i, mp) for (auto i = mp.begin(); i != mp.end(); ++i)
#define dbgmap(mp) for (auto i = mp.begin(); i != mp.end(); ++i) { cout << i->first <<":"<<i->second << endl;}
#define sum(v) accumulate(ALL(v),0)
#define fi first
#define se second

template<typename T1, typename T2>
ostream &operator<<(ostream &s, const pair<T1, T2> &p) { return s<<"("<<p.first<<", "<<p.second<<")"; }

// vector
template<typename T>
ostream &operator<<(ostream &s, const vector<T> &v) {
    int len=v.size();
    for(int i=0; i<len; ++i) {
        s<<v[i];
        if(i<len-1) s<<" ";
    }
    return s;
}

// 2 dimentional vector
template<typename T>
ostream &operator<<(ostream &s, const vector<vector<T> > &vv) {
    int len=vv.size();
    for(int i=0; i<len; ++i) {
        s<<vv[i]<<endl;
    }
    return s;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s;
    cin>>s;
    ll ans=0;
    for(ll i=0; i<(s.length()/2); i++) {
        char tmp1 = s[i];
        char tmp2 = s[s.length()-1-i];
        if (tmp1!=tmp2){
            ans++;
        }
    }
    cout<<ans<<endl;
    return  0;
}


Measured memory_bytes: 256
D[101][101],i,j,k,t;main(n,m,s,g,h){for(;scanf("%d%d%d%d%d",&n,&m,&s,&g,&h)*n;printf("%d\n",k)){memset(D,1,40804);for(;m--;D[i][j]=k,D[i][i]=0)scanf("%d%d%d",&i,&j,&k);for(k=n;k;k--)for(i=n;i;i--)for(j=n;j;j--)t=D[i][k]+D[k][j],t<D[i][j]?D[i][j]=t:0;k=1e9;for(i=n;i;i--)t=D[s][i]+D[i][g]+D[i][h],t<k?k=t:0;}}

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

using namespace std;
#define PI 3.14159265
int main()
{
    double result,a,b,h,H,V,x,tg,y;
    cin>>a>>b>>x;

    V=a*a*b;
    H=x/(a*a);

    h=b-H ;

    if( V/x <= 2.0)
    {
       // tg = (a/2.0)/h;
        result= 90 - atan2 (a,2*h) * 180.0 / PI;
    }
    else
    {
        y=(2*x)/(b*a);
        result =  atan2 (b,y) * 180.0 /PI;
    }
  cout<< fixed << setprecision(9) << result ;
    return 0;
}


Measured memory_bytes: 256
{-# LANGUAGE FlexibleContexts #-}
import Control.Monad
import Control.Monad.State
import Control.Monad.Reader
import Control.Arrow
-- import Control.Comonad
import Data.Maybe
import Data.List
import Data.Bool
import Data.Fixed
import Data.Tuple
import Data.Ratio
import Text.Printf
import qualified Data.Map.Strict as M
import qualified Data.Array.IO as IA
import qualified Data.Vector as V
 
getI = read <$> getLine :: IO Int
getIs = map read . words <$> getLine :: IO [Int]
getD = read <$> getLine :: IO Double
getDs = map read . words <$> getLine :: IO [Double]
getInt = read <$> getLine :: IO Integer
getInts = map read . words <$> getLine :: IO [Integer]
 
type Row = Integer
type Col = Integer
type PointI = (Integer, Integer)
type Point = (Int, Int)
 
mmm = 1000000007
fact n
    | n < 1 = 1
    | True = foldr1 (*) [1..n]
fi = fromInteger
fig = fromIntegral
rf = realToFrac
 
(.<.) f g -- combination
    | f < g = 0 
    | g < 1 || f < 1 = 1
    | True = foldr1 (*) (take g [f,f-1..]) `div` fact g
(.>.) f g --combination with repetition
    | g < 1 || f < 1 = 1
    | True = fact (f + g - 1) `div` (fact (f - 1) * fact g)
comb = (.<.)
combWp = (.>.)
 
unique a = unique_ (reverse . sort $ a) [] Nothing
    where
        unique_ [] arr _ = arr
        unique_ (x:xs) arr n
            | n == Just x = unique_ xs arr n
            | otherwise = unique_ xs (x:arr) $ Just x
 
zeroume keta num
    | (length . show $ num) > keta = show num
    | otherwise = do 
        let zeros = take keta $ repeat '0'
        reverse . take keta $ (reverse . show $ num) ++ zeros
 
i2b num
    | num < 2 = show num
    | otherwise = i2b_ num []
        where
            i2b_ num str
                | num == 0 = str
                | num == 1 = '1':str
                | otherwise = do
                    let next = num `div` 2
                    let this = if odd num then '1' else '0'
                    i2b_ next (this:str)
 
mapIncr = mapPlus 1
mapPlus n Nothing = Just n
mapPlus n a = (+) n <$> a
 
countIf f = length . filter f
 
-- 
--
--

main = do
  [t, _] <- getIs
  inps <- replicateM t getLine
  let out = filter (any (== '#')) >>> transpose >>> filter (any (== '#')) >>> transpose >>> intercalate "\n" $ inps
  putStrLn out


Measured memory_bytes: 1788
// Copyright 2019 yaito3014
#include "bits/stdc++.h"
using namespace std;
using namespace literals;

int main() {
  cin.tie(nullptr); ios::sync_with_stdio(false);
  int a, b;
  cin >> a >> b;
  cout << min(string(b, '0' + a), string(a, '0' + b)) << endl;
}


Measured memory_bytes: 256
#include <algorithm>
#include <climits>
#include <iostream>
#include <utility>
#include <vector>

using namespace std;

int main() {
    int n, w;
    cin >> n >> w;

    vector<pair<long long, long long>> goods(n + 1);
    for (int i = 1; i <= n; ++i) {
        long long w, v;
        cin >> w >> v;
        goods[i] = make_pair(w, v);
    }

    const int inf = INT_MAX / 2;
    const int dp_max = 100 * 1e3;
    vector<vector<long long>> dp(n + 1, vector<long long>(dp_max + 1, inf));
    dp[0][0] = 0;
    for (int i = 1; i <= n; ++i) {
        for (int j = 0; j <= dp_max; ++j) {
            dp[i][j] = dp[i - 1][j];
            if (j - goods[i].second >= 0) {
                dp[i][j] = min(dp[i][j],
                               dp[i - 1][j - goods[i].second] + goods[i].first);
            }
        }
    }

    long long result = 0;
    for (int i = dp_max; i >= 0; --i) {
        if (dp[n][i] <= w) {
            result = i;
            break;
        }
    }
    cout << result << '\n';
}


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

int main(){
    long N;
    long long int T[100004]={};
    long long int A[100004]={};
    unsigned long long int count=1;

    cin >> N;
    for(long i=1;i<=N;i++){
        cin >> T[i];
    }
    for(long i=1;i<=N;i++){
        cin >> A[i];
    }

    for(long i=1;i<=N;i++){
        count = count % 1000000007;
        if(T[i]==T[i-1]){
            if(A[i]==A[i+1]){
                if(A[i]>T[i]){
                    count *= T[i];
                }
                else{
                    count *= A[i];
                }
            }
            else{
                if(A[i]<=T[i]){
                    count *= 1;
                }
                else{
                    count *= 0;
                }
            }
        }
        else{
            if(A[i]==A[i+1]){
                if(T[i]<=A[i]){
                    count *= 1;
                }
                else{
                    count *= 0;
                }
            }
            else{
                if(T[i]==A[i]){
                    count *= 1;
                }
                else{
                    count *= 0;
                }
            }
        }
    }

    cout << count % 1000000007 << "\n";
    
    return 0;
}

Measured memory_bytes: 1792
#include "bits/stdc++.h"
using namespace std;

int main() {
	int n, c, k;
	cin >> n >> c >> k;

	vector<int> vec(n);
	for (auto& e : vec) {
		cin >> e;
	}

	sort(vec.begin(), vec.end());

	int bus = 0;
	for (int i = 0; i < n;) {
//		cout << "bus:" << bus << endl;
//		cout << "  i:" << i << endl;
//		cout << "vec:" << vec.at(i) << endl;

		int x = 0;
		for (int j = i + 1; j < i + c; j++) {
			if (j < n) {
				if (vec.at(j) <= vec.at(i) + k) {
					x++;
				}
				else {
					break;
				}
			}
		}
		if (x == (c - 1)) {
			bus++;
			i += c;
		}
		else {
			bus++;
			i += x + 1;
		}
	}
	cout << bus << endl;
}


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

//define gcd and lcm (using 64bit)
ll gcd(ll a,ll b){
    if (a < b) {
        //^はxor(bitwise operator)。以下三行でswap(a,b)を行っている。
        a ^= b;
        b ^= a;
        a ^= b;
    }
    //only when b==0,this program finds that b means false and returns a.
    return b ? gcd(b, a % b) : a;
}

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


int main(){
    int n;
    cin>>n;
    double odd=0,even=0;
    rep(i,n){
        if((i+1)%2==1) ++odd; else ++even;
    }
    cout<<setprecision(10)<<(odd/n)<<endl;
    return 0;
}

Measured memory_bytes: 256
"use strict";
const Main = (input) =>{
   let xs = input.trim().split('\n');
   let O = xs[0].trim().split('');
   let E = xs[1].trim().split('');
   
   let ans = '';
   for(let i=0; i<E.length; i++){
     ans +=(O[i]+E[i]);
   }
   
   if(O.length==E.length){
     console.log(ans);
     }else if(O.length>E.length){
     console.log(ans+O[O.length-1]);
     }else{
     console.log(ans+E[E.length-1]);
     }
       




}
Main(require('fs').readFileSync('/dev/stdin','utf8'));

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

int main() {
  int n;
  cin >> n;
  
  map<string, int> mp;
  for (int i = 0; i < n; ++i) {
    string s;
    cin >> s;
    sort(s.begin(), s.end());
    ++mp[s];
  }
  
  long ans = 0;
  for (auto&& p : mp) {
    ans += p.second * long(p.second - 1) / 2;
  }
  cout << ans << endl;
}

Measured memory_bytes: 11136
#include <bits/stdc++.h>
using namespace std;
typedef pair<long long, long long> P;
#define int long long
#define override_rep(i, l, r, mes, ...) mes
#define rep1(i, n) for (int i = 0; i < n; i++)
#define rep2(i, l, r) for (int i = l; i < r; i++)
#define rep(...) override_rep(__VA_ARGS__, rep2, rep1)(__VA_ARGS__)
#ifdef DEBUG
std::ostream& dout = cout;
#else
stringstream dout;
#endif
template<typename T, typename U>
istream& operator>>(istream& in, pair<T, U>& p) {
    in >> p.first >> p.second;
    return in;
}
vector<string> ans;
void dfs(string s,int i,int n){
    if(s.size()==n){
        ans.push_back(s);
        return;
    }
    i++;
    rep(j,i){
        dfs(s+char('a'+j),max(i-1,j+1),n);
    }
}
signed main(signed argc, char* argv[]) {
    cin.tie(0);
    ios::sync_with_stdio(false);
    const int MOD = 1000000007;
    int n;
    cin>>n;
    dfs("",0,n);
    sort(ans.begin(),ans.end());
    for(const string& s:ans)cout<<s<<endl;
}


Measured memory_bytes: 7796
using System;

class Program {
  static void Main(string[] args) {
    string s = Console.ReadLine();
    for (int i=0; i<s.Length; i++) {
      int n =  int.Parse("" + s[i]);
      if (n == 9) {
        Console.WriteLine("Yes");
        return;
      }
    }
    Console.WriteLine("No");
  }
}


Measured memory_bytes: 11092
#include <bits/stdc++.h>
#include <iostream>
#include<math.h>
using namespace std;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
int main()
{
    int64_t N, X, M;
    cin >> N >> X >> M;
    vector<int>ord(M, -1);
    vector<int64_t>rereki, syu;
    int64_t res = 0;
    for (int n=0; n<N; n++) {
        if (ord[X] != -1) {
            int p = ord[X];
            for (int64_t i=p; i<n; i++) {
                syu.push_back(rereki[i]);
            }
            break;
        }

        ord[X] = n;
        rereki.push_back(X);
        res += X;
        X = (X * X) % M;
    }

    N -= rereki.size();
    if (N == 0) {
        cout << res << endl;
    } else {
        vector<int64_t>sum(syu.size() + 1, 0);
        for (int i=0; i<syu.size(); i++) {
            sum[i+1] = sum[i] + syu[i];
        }

        int64_t q = N / syu.size();
        int64_t r = N % syu.size();
        res += sum[syu.size()] * q + sum[r];
        cout << res << endl;
    }
    return 0;
}

Measured memory_bytes: 4760
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<set>
#include<map>
#include<queue>
#include<cmath>
#define REP(i,a) for (int i = 0;i < (a);++i)
#define FOR(i,a,b) for (int i = (a);i < (b); ++i)
#define FORR(i,a,b) for (int i = (a);i >= (b); --i)
#define ALL(obj) (obj).begin(),(obj).end()
#define SORT(list) sort(ALL((list)));
#define MOD 1000000007
using namespace std;
using ll = long long;
int main(){
    int n;
    cin >> n;
    vector<int>l(n);
    REP(i,n)cin >> l[i];
    vector<int>index(3);
    ll answer = 0;
    REP(i,n-2){
        FOR(j,i+1,n-1){
            FOR(k,j+1,n){
                if(l[i]!=l[j] and l[i]!= l[k] and l[j]!=l[k]){
                    if(l[i]+l[j] > l[k] and l[i]+l[k] > l[j] and l[j]+l[k] > l[i])answer++;
                }
            }
        }
    }
    cout << answer << endl;
    return 0;
}

Measured memory_bytes: 3624
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main{
	public static void main(String[] args)throws IOException{
		InputStreamReader isr = new InputStreamReader(System.in);
		BufferedReader reader = new BufferedReader(isr);
		String string, mf = "";
		int max, hoge;
		
		while(!(string = reader.readLine()).equals("0 0")){
			max = 0;
			for(int i = 0; i < 4; i++){
				hoge = Integer.valueOf(string.split(" ")[0]) +
					   Integer.valueOf(string.split(" ")[1]);
				max = Math.max(max, hoge);
				
				if(max == hoge){
					mf = String.valueOf((char)(65 + i));
				}
				string = reader.readLine();
			}
			max = Math.max(max, hoge = Integer.valueOf(string.split(" ")[0]) +
					   			Integer.valueOf(string.split(" ")[1]));
			if(max == hoge){
				mf = String.valueOf((char)(65 + 4));
			}
			
			System.out.println(mf + " " + max);
		}
	}
}

Measured memory_bytes: 25772
import sys
sys.setrecursionlimit(10**9)
input=lambda :sys.stdin.readline()

def sol():

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

  for _ in range(Q):
    p, x = map(int,input().split())
    ans[p-1] += x 
 
  def dfs(v,p=-1):
    for u in graph[v]:
      if u == p: continue
      ans[u] += ans[v]
      dfs(u,v)
  dfs(0)
  print(*ans)

sol()

Measured memory_bytes: 268348
#include<iostream>
#include<string>
#include<algorithm>	
#include<cmath>
using namespace std;
int main() {
	long long n, x, y; cin >> x >> y;
	while (true) {
		if (x > y) {
			x = x % y;
		}
		else if (x < y) {
			y = y % x;
		}
		if (x == 0 || x == y) {
			cout << y << endl; cin >> n;
			return 0;
		}
		if (y == 0) {
			cout << x << endl; cin >> n;
			return 0;
		}
	}
	cin >> n;
}


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


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

    bool che[100010];
    long long sum_w[100010];
    for(long long i=0;i<100010;i++){
        che[i] = false;
        sum_w[i]=0;
    }
    long long p;
    string s;

    long long sum_a=0,s_w=0;
    for(long long i=0;i<m;i++){
        cin >> p >> s;
        if(s=="AC" && !che[p]){
            sum_a++;
            che[p]=true;
            s_w += sum_w[p];
        }
        /*else if(s=="AC" && che[p]){

            continue;
        }*/
        else if(s=="WA"&&!che[p]){
            sum_w[p]++;
        }
    }

    cout << sum_a << " " << s_w << endl;
}

Measured memory_bytes: 1152