akhauriyash/Code-Regression huggingface dataset:
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#include <algorithm>
#include <utility>
#include <functional>
#include <sstream>
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>

using namespace std;

inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v;}
template<class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str();}

typedef vector<int> vi;
typedef vector<vi>  vvi;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef long long ll;

#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define EACH(t,i,c) for(t::iretator i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)

const double EPS = 1e-10;

int main() {
	int n, tmp;
	string str;

	while(cin >> n, n) {
		int ue = 1, shita = 6;
		int migi = 3, hidari = 4;
		int	mae = 5, ushiro = 2;
		int score = 1;		
		
		REP(i, n) {
			cin >> str;

			if(str == "North") {
				tmp = ue;
				ue = ushiro;
				ushiro = shita;
				shita = mae;
				mae = tmp;
			} else if(str == "East") {
				tmp = ue;
				ue = hidari;
				hidari = shita;
				shita = migi;
				migi = tmp;
			} else if(str == "West") {
				tmp = ue;
				ue = migi;
				migi = shita;
				shita = hidari;
				hidari = tmp;
			} else if(str == "South") {
				tmp = ue;
				ue = mae;
				mae = shita;
				shita = ushiro;
				ushiro = tmp;
			} else if(str == "Right") {
				tmp = mae;
				mae = hidari;
				hidari = ushiro;
				ushiro = migi;
				migi = tmp;
			} else if(str == "Left") {
				tmp = mae;
				mae = migi;
				migi = ushiro;
				ushiro = hidari;
				hidari = tmp;
			}

			score += ue;
		}
	
		cout << score << endl;
	}
}

Measured memory_bytes: 0
#include <iostream>
#include <sstream>
#include <string>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <cassert>

using namespace std;

#define FOR(i,k,n) for(int i=(k); i<(int)(n); ++i)
#define REP(i,n) FOR(i,0,n)
#define FORIT(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)

template<class T> void debug(T begin, T end){ for(T i = begin; i != end; ++i) cerr<<*i<<" "; cerr<<endl; }
inline bool valid(int x, int y, int W, int H){ return (x >= 0 && y >= 0 && x < W && y < H); }

typedef long long ll;
const int INF = 100000000;
const double EPS = 1e-8;
const int MOD = 1000000007;
int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};

#include <complex>
typedef complex<double> Point;
double cross(Point a, Point b){
  return imag(conj(a) * b);
}
struct Line : public vector<Point> {
  Line(Point a, Point b){
    push_back(a);
    push_back(b);
  }
  Point vector(){
    return back() - front();
  }
};
bool parallel(Line l, Line m){
  if(abs(cross(l.vector(), m.vector())) < EPS) return true;
  else return false;
}
Point input(){
  Point p;
  cin >> p.real() >> p.imag();
  return p;
}

int main(){
  int N;
  cin >> N;
  while(N--){
    Point a[4];
    REP(i, 4) a[i] = input();
    if(parallel(Line(a[0], a[1]), Line(a[2], a[3]))){
      cout << "YES" << endl;
    }else{
      cout << "NO" << endl;
    }
  }
  return 0;
}

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

#define PI 3.14159265358979323846
  
double min(double x, double y)  
{  
    return (x < y)? x: y;  
      
}  
  
double calcAngle(double h, double m)  
{  
    // validate the input  
    if (h <0 || m < 0 || h >12 || m > 60)  
       // printf("Wrong input");  
  
    if (h == 12) h = 0;  
    if (m == 60) m = 0;  
  
    // Calculate the angles moved  
    // by hour and minute hands  
    // with reference to 12:00  
    double hour_angle = 0.5 * (h * 60 + m);  
    double minute_angle = 6 * m;  
  
    // Find the difference between two angles  
    double angle = abs(hour_angle - minute_angle);  
  
    // Return the smaller angle of two possible angles  
    angle = min(360 - angle, angle);  
  
    return angle;  
}  

int main() 
{
    double a,b,h,m;
    cin>>a>>b>>h>>m;
    double d=calcAngle(h,m);
    //cout<<d<<"\n";
    //cout<<fixed<<setprecision(20)<<cos((117*PI)/(180));
    double y=cos((d*PI)/180.0);
   // cout<<y<<"\n";
//     			double ans=(double)a*a+(double)b*b-(double)2*a*b*y;
// 			cout<<fixed<<setprecision(10)<<sqrt(ans);
    // if(d==180)
    // cout<<fixed<<setprecision(20)<<a+b;
    // else if(d==0)
    // cout<<fixed<<setprecision(20)<<abs(b-a);
    // else
    // {
        
          double r=a*a+b*b-(2*a*b*y);
        
        r=sqrt(r);
        cout<<fixed<<setprecision(20)<<r;
   // }
}

/*1.000000000
2.414213562
127.321336469



*/

Measured memory_bytes: 4192
#include <algorithm>  
#include <iostream>  
#include <sstream>  
#include <string>  
#include <cstring>
#include <vector>  
#include <queue>  
#include <set>  
#include <map>  
#include <cstdio>  
#include <cstdlib>  
#include <cctype>  
#include <cmath>  
#include <list>  
#include <cassert>
#include <ctime>
#include <climits>
using namespace std;

#define PB push_back  
#define MP make_pair  
#define SZ(v) ((int)(v).size())  
#define FOR(i,a,b) for(int i=(a);i<(b);++i)  
#define REP(i,n) FOR(i,0,n)  
#define FORE(i,a,b) for(int i=(a);i<=(b);++i)  
#define REPE(i,n) FORE(i,0,n)  
#define FORSZ(i,a,v) FOR(i,a,SZ(v))  
#define REPSZ(i,v) REP(i,SZ(v))  
typedef long long ll;
typedef unsigned long long ull;
ll gcd(ll a, ll b) { return b == 0 ? a : gcd(b, a%b); }

const int MAXN = 1000;
const int MAXM = 200000;

int n, m;
vector<pair<int, int> > e[MAXN];
vector<int> adj[MAXN];
vector<int> radj[MAXN];

int ans[MAXM];

int q[MAXN], qhead, qtail;
int mn[MAXN], mx[MAXN]; bool reach[MAXN];

void solve() {
	REP(i, m) ans[i] = -1;
	REP(i, n) {
		REP(j, n) mn[j] = INT_MAX; mn[i] = -1; qhead = qtail = 0;
		REPSZ(j, e[i]) {
			int rt = e[i][j].first; if (mn[rt] != INT_MAX) continue;
			q[qhead++] = rt; mn[rt] = j;
			while (qtail < qhead) { int at = q[qtail++]; REPSZ(i, adj[at]) { int to = adj[at][i]; if (mn[to] == INT_MAX) mn[to] = j, q[qhead++] = to; } }
		}
		REP(j, n) mx[j] = INT_MIN; mx[i] = -1; qhead = qtail = 0;
		for (int j = SZ(e[i]) - 1; j >= 0; --j) {
			int rt = e[i][j].first; if (mx[rt] != INT_MIN) continue;
			q[qhead++] = rt; mx[rt] = j;
			while (qtail < qhead) { int at = q[qtail++]; REPSZ(i,adj[at]) { int to = adj[at][i]; if (mx[to] == INT_MIN) mx[to] = j, q[qhead++] = to; } }
		}
		REP(j, n) reach[j] = false; qhead = qtail = 0;
		q[qhead++] = i; reach[i] = true;
		while (qtail < qhead) { int at = q[qtail++]; REPSZ(i,radj[at]) { int to = radj[at][i]; if (!reach[to]) reach[to] = true, q[qhead++] = to; } }
		REPSZ(j, e[i]) {
			int x = e[i][j].second, to = e[i][j].first;
			bool ab = mn[to] != mx[to], ba = reach[to];
			//printf("%d->%d: ab=%d ba=%d\n", i + 1, to + 1, ab ? 1 : 0, ba ? 1 : 0);
			ans[x] = ab == ba ? 0 : 1;
		}
	}
}


void run() {
	scanf("%d%d", &n, &m);
	REP(i, n) e[i].clear(), adj[i].clear(), radj[i].clear();
	REP(i, m) { 
		int a, b; scanf("%d%d", &a, &b); --a, --b;
		e[a].PB(MP(b, i)); adj[a].PB(b); radj[b].PB(a);
	}

	solve();

	REP(i, m) printf("%s\n", ans[i] ? "diff" : "same");
}

void stress() {
	printf("start\n"); fflush(stdout);
	REP(rep, 100) {
		n = MAXN, m = MAXM; REP(i, n) e[i].clear(), adj[i].clear(), radj[i].clear();
		set<pair<int, int> > seen;
		REP(i, m) while (true) {
			int a = rand() % n, b = rand() % n; if (a == b || seen.count(MP(a, b))) continue;  
			e[a].PB(MP(b, i)); adj[a].PB(b); radj[b].PB(a);
			break; 
		}
		solve();
		printf(".");
	}
}

int main() {
	run();
	//stress();
	return 0;
}


Measured memory_bytes: 8064
import scala.io.StdIn
import Math.{sqrt,pow}
/**
  * AOJ
  */
object Main {

  def main(args: Array[String]): Unit = {
    while(true){
      val n = StdIn.readInt()
      if(n == 0){return}
      val sArray = StdIn.readLine().split(" ").map(_.toDouble)
      val m:Double = sArray.sum / n
      println("%.8f".format(sqrt(sArray.foldLeft(0.toDouble){(x,y) => x + pow(y - m,2)} / n)))
    }
  }
}

Measured memory_bytes: 45216
#include <iostream>

using namespace std;
typedef long long ll;

int N, T, t, c, ans = (1<<30);

int main ()
{
	cin >> N >> T;
	for ( int i = 0; i < N; i++ )
	{
		cin >> c >> t;
		if ( t <= T )
			ans = min ( ans, c );
	}
	if ( ans == (1<<30) )
		cout << "TLE\n";
	else
		cout << ans << "\n";
	return 0;
}


Measured memory_bytes: 256
#include<algorithm>//sort,二分探索,など
#include<bitset>//固定長bit集合
#include<cmath>//pow,logなど
#include<complex>//複素数
#include<deque>//両端アクセスのキュー
#include<functional>//sortのgreater
#include<iomanip>//setprecision(浮動小数点の出力の誤差)
#include<iostream>//入出力
#include<iterator>//集合演算(積集合,和集合,差集合など)
#include<map>//map(辞書)
#include<numeric>//iota(整数列の生成),gcdとlcm(c++17)
#include<queue>//キュー
#include<set>//集合
#include<stack>//スタック
#include<string>//文字列
#include<unordered_map>//イテレータあるけど順序保持しないmap
#include<unordered_set>//イテレータあるけど順序保持しないset
#include<utility>//pair
#include<vector>//可変長配列

// vectorの重複削除
// std::sort(test.begin(), test.end());
// test.erase(std::unique(test.begin(), test.end()), test.end());

using namespace std;
using ll = long long;
using P = pair<int, int>; // vector<P> ba(n); みたいな感じですぐ使える ba[i] = P(a, b); make_pairをしなくてもいい
// typedef vector<int> v;
template <class T>ostream &operator<<(ostream &o,const vector<T>&v){o<<"{";for(int i=0;i<(int)v.size();i++)o<<(i>0?", ":"")<<v[i];o<<"}";return o;}
#define debug(v) {cerr<<"\033[1;36m[debug]\033[m "<<#v<<" : "<<v<<endl;}
#define rep(i, c) for(int i = 0; i < int(c); i++)
#define ALL(x) (x).begin(), (x).end() //sort(ALL(obj))みたいな
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x)) //最大値
#define pb push_back //
// const int MOD = 1000000007;
// string alpha="ABCDEFGHIJKLMNOPQRSTUVWXYZ";
// printf("%.20f\n", ans); あれ
// const double PI = 3.141592653589793238462643383;

int main() {
  int a,b; cin>>a>>b;
  int ans = 0;
  int ana = 1;
  while (ana < b) {
    ana--;
    ana += a;
    ans++;
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define ld long double
#define ull unsgned ll
#define db double
#define pint pair<int,int>
#define mk make_pair
#define pb push_back
#define eb emplace_back
#define ins insert
#define fi first
#define se second
#define Rep(x,y,z) for(int x=y;x<=z;x++)
#define Red(x,y,z) for(int x=y;x>=z;x--)
using namespace std;
const int MAXN=4e5+5,Mod=998244353;
char buf[1<<12],*pp1=buf,*pp2=buf,nc;int ny;
//inline char gc() {return pp1==pp2&&(pp2=(pp1=buf)+fread(buf,1,1<<12,stdin),pp1==pp2)?EOF:*pp1++;}
inline char gc(){return getchar();}
inline int read(){
	int x=0;for(ny=1;nc=gc(),(nc<48||nc>57)&&nc!=EOF;)if(nc==45)ny=-1;if(nc<0)return nc;
	for(x=nc-48;nc=gc(),47<nc&&nc<58&&nc!=EOF;x=(x<<3)+(x<<1)+(nc^48));return x*ny;
}
int n,a[MAXN],b[MAXN],f[MAXN],ans;char s[MAXN];
inline void Solve(int k){
	int res=0;
	Rep(i,1,k/2)res=(res<<1|a[i])%Mod,b[i]=a[i],b[i+k/2]=!a[i];
	int flg=0;
	Rep(i,1,2*n)if(a[i]!=b[(i-1)%k+1]){flg=a[i]<b[(i-1)%k+1];break;}
	f[k]=(res-flg+1)%Mod;
}
int main(){
//	freopen("std.in","r",stdin);
//	freopen("std.out","w",stdout);
	n=read(),scanf("%s",s+1);Rep(i,1,n)a[i]=s[i]^48,a[i+n]=!a[i];
	Rep(i,1,2*n)if(n%i&&2*n%i==0)Solve(i);
	Rep(i,1,2*n)if(n%i&&2*n%i==0)for(int j=i+i;j<=2*n;j+=i)if(n%j&&2*n%j==0)f[j]=(f[j]-f[i]+Mod)%Mod;
	Rep(i,1,2*n)if(n%i&&2*n%i==0)ans=(ans+1ll*f[i]*i)%Mod;cout<<ans<<'\n';
	return 0;
}





Measured memory_bytes: 6988
from itertools import permutations

N, M = map(int,input().split())
edges = [[0 for i in range(N)] for j in range(N)]
for _ in range(M):
    a, b = map(int,input().split())
    edges[a-1][b-1] = 1
    edges[b-1][a-1] = 1

ans = 0
for l in permutations(range(1,N)):
    l = [0] + list(l)
    cnt = 1
    for i in range(N-1):
        if edges[l[i]][l[i+1]] == 0:
            cnt = 0
    ans += cnt

print(ans)

Measured memory_bytes: 3064
#include<cstdio>
#include<queue>
#include<utility>
#include<cstring>
#include<stack>
#include<algorithm>
#include<cmath>
#include<iostream>
#define MAX_N 100001
#define INF 2147483647
#define REP(i,n) for(int i=0;i<(int)(n);i++)
void init(int n);
int find(int n);
void unite(int x,int y);
bool same(int x, int y);
int dx[4] = {1,0,0,-1};
int dy[4] = {0,1,-1,0};
using namespace std;
int main()
{
  int N,a[101],count=0;
  cin >> N;
  REP(i,N)cin >> a[i];
  REP(i,N-1){
    if(a[i] == a[i+1]){
      a[i+1] = -1;
      count++;
    }
  }
  cout << count << endl;
  return 0;
}

int par[MAX_N];
int ranks[MAX_N];

//n要素で初期化
void init(int n){
  REP(i,n){
    par[i] = i;
    ranks[i] = 0;
  }

}

//木の根を求める
int find(int x){
  if(par[x] == x){
    return x;
  }else{
    return par[x] = find(par[x]);
  }
}

void unite(int x,int y){
  x = find(x);
  y = find(y);
  if(x == y) return ;
  if(ranks[x] < ranks[y]){
    par[x] = y;
  }else{
    par[y] = x;
    if(ranks[x] == ranks[y]) ranks[x]++;
  }
}

bool same(int x, int y){
  return find(x) == find(y);
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int maxn=5e5+10,mod=998244353;
int fac[maxn],inv[maxn],n,m,pwn[maxn],pwm[maxn];
int qpow(int a,int b){
	int ans=1;
	for(;b;b>>=1,a=1ll*a*a%mod)
		if(b&1)ans=1ll*ans*a%mod;
	return ans;
}
int C(int x,int y){
	if(x<y||y<0)return 0;
	return 1ll*fac[x]*inv[y]%mod*inv[x-y]%mod;
}
int main(){
	scanf("%d%d",&n,&m);
	fac[0]=1,inv[0]=1;
	pwn[0]=1,pwm[0]=1;
	int M=max(n,m);
	for(int i=1;i<=M;++i){
		pwn[i]=1ll*(n+1)*pwn[i-1]%mod;
		pwm[i]=1ll*(m+1)*pwm[i-1]%mod;
	}
	for(int i=1;i<=M;++i)fac[i]=1ll*fac[i-1]*i%mod;
	inv[M]=qpow(fac[M],mod-2);
	for(int i=M-1;i>=1;--i)inv[i]=1ll*inv[i+1]*(i+1)%mod;
	int ans=0;
	for(int i=0;i<=min(n,m);++i){
		ans=(ans+1ll*C(n,i)*C(m,i)%mod*fac[i]%mod*(i&1?mod-1:1)%mod*
			pwn[m-i]%mod*pwm[n-i])%mod;
	}
	printf("%d",ans);
}

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

int n;
struct DATA
{
    int x, y, h;
};
DATA data[110];

int cx, cy, ch;

int main()
{
    scanf("%d", &n);
    int i, j, k;
    for(i=0; i<n; i++) scanf("%d%d%d", &data[i].x, &data[i].y, &data[i].h);

    for(cy=0; cy<=100; cy++)
    {
        for(cx=0; cx<=100; cx++)
        {
            int ch=-1;
            int maxch=numeric_limits<int>::max();
            bool flag=true;
            for(k=0; k<n; k++)
            {
                int dist=abs(cy-data[k].y)+abs(cx-data[k].x);
                if(data[k].h!=0)
                {
                    if(ch==-1) ch=data[k].h+dist;
                    else if(ch!=data[k].h+dist)
                    {
                        flag=false;
                        break;
                    }

                }
                else
                {
                    if(cx==data[k].x && cy==data[k].y)
                    {
                        flag=false;
                        break;
                    }
                    maxch=min(maxch, dist);
                }

                if(maxch<ch)
                {
                    flag=false;
                    break;
                }
            }

            if(ch==-1) ch=maxch;

            if(flag && ch>0)
            {
                printf("%d %d %d", cx, cy, ch);
                return 0;
            }
        }
    }

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
template<class T>
inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}

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

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
const ll mod = 1000000007;
ll inv[1000000];
ll FactorialInv[1000000];
ll Factorial[1000000];
ll beki(ll a, ll b){
    if(b == 0){
        return 1;
    }
    ll ans = beki(a, b / 2);
    ans = ans * ans % mod;
    if(b % 2 == 1){
        ans = ans * a % mod;
    }
    return ans;
}
void init_combination(){
    inv[1] = 1;
    FactorialInv[1] = 1;
    Factorial[1] = 1;
    Factorial[0] = 1;
    FactorialInv[0] = 1;
    inv[0] = 1;
    for(int i = 2; i < 1000000; i++){
        inv[i] = beki(i, mod - 2);
        Factorial[i] = Factorial[i - 1] * i % mod;
        FactorialInv[i] = FactorialInv[i - 1] * inv[i] % mod;
    }
}
ll combination(ll a, ll b){
    if((a == b) || (b == 0)){
        return 1;
    }
    if(a < b) return 0;
    ll ans = Factorial[a] * FactorialInv[b] % mod;
    ans = ans * FactorialInv[a - b] % mod;
    return ans;
}
ll N, K;
vector<ll> pathes[105000];
ll ans = 1;

void dfs(int now, int from) {
    ll NG = 1;
    ll children = 0;
    for(int i = 0; i < pathes[now].size(); i++) {
        int to = pathes[now][i];
        if(to == from) {
            NG++;
            continue;
        } else {
            dfs(to, now);
            children++;
        }
    }
    ans *= combination(K - NG, children);
    ans %= mod;
    ans *= Factorial[children];
    ans %= mod;
}

int main() {
    //cout.precision(10);
    cin.tie(0);
    ios::sync_with_stdio(false);
    init_combination();
    cin >> N >> K;
    for(int i = 0; i < N-1; i++) {
        ll a, b;
        cin >> a >> b;
        pathes[a].push_back(b);
        pathes[b].push_back(a);
    }
    ans = K;
    dfs(1, -1);
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 35200
#include <bits/stdc++.h>
using namespace std;
int main() {
	int n,T;
	int minv=1000;
	int time=0;
	cin>>n>>T;
	int c[n],t[n];
	for(int i=0;i<n;i++)
	{
		cin>>c[i];
		cin>>t[i];
		if(t[i]<=T)
		{
			minv=min(minv,c[i]);
			time++;
		}
	}
	if(time==0)
		cout<<"TLE";
	else
	cout<<minv<<endl;
	return 0;
}

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

using ll = long long;

int main() {
    int A, B;
    cin >> A >> B;
    rep(i, 3) {
        if (i + 1 != A && i + 1 != B) cout << i + 1 << "\n";
    }
}

Measured memory_bytes: 256
#include <cstdio>
#include <vector>
#include <stack>
#include <iostream>
#include <string>
#include <tuple>
#include <random>
#include <map>
#include <queue>
#include <set>
#include <complex>
#include <algorithm>
#include <cassert>
#include <iterator>
#include <numeric>
#include <chrono>

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;
typedef tuple<ll, ll, ll> T;

const ll INF = 1e15;

int main() {
	ll K, N;
	K = 42; N = K*K - K + 1;
	vector<vector<ll>> ans(N, vector<ll>());
	for (int i = 1;i <= K;i++)
		ans[0].push_back(i);
	for (int i = 1;i < N;i++)
		ans[i].push_back((i-1)/(K-1) + 1);
	for (int shift = 0; shift < K-1;shift++) {
		for (int diff = 0; diff < K-1; diff++) {
			ll now = (shift + 1) * (K - 1) + diff + 2;
			ans[shift + 1].push_back(now);
			for (int i = 1;i < K;i++)
				ans[1 + i * (K - 1) + ((diff + shift * i) % (K - 1))].push_back(now);
		}
	}
	/*
	//assert
	vector<ll> count(N);
	vector<vector<ll>> connect(N, vector<ll>(N, 0));
	for (int i = 0;i < N;i++)
		for (int j = i+1;j < N;j++) {
			for (int k = 0;k < K;k++) {
				bool cone = find(ans[j].begin(), ans[j].end(), ans[i][k]) != ans[j].end();
				//assert(!(cone && connect[i][j]));
				if (cone) {
					connect[i][j] = 1;
					connect[j][i] = 1;
				}
			}
		}
	for (int i = 0;i < ans.size();i++) {
		assert(ans[i].size() == K);
		unique(ans[i].begin(), ans[i].end());
		assert(ans[i].size() == K);
		for (int j = 0;j < ans[i].size();j++) {
			assert(ans[i][j] <= N && 1 <= ans[i][j]);
			count[ans[i][j] - 1]++;
			//if (i >= j || connect[i][j] == 1)
			//	cout << "err" << i << " " << j << endl;
			//assert(i>=j || connect[i][j]);
		}
	}
	for (int i = 0;i < N;i++) {
		assert(count[i] == K);
	}*/

	cout << N << " " << K << endl;
	for (int i = 0;i < N;i++) {
		for (int j = 0;j < ans[i].size(); j++) {
			cout << ans[i][j];
			if (j != ans[i].size() - 1)
				cout << " ";
			else
				cout << endl;
		}
	}

 	return 0;
}


Measured memory_bytes: 1536
package main

import "fmt"

func main() {
	// Code for A - ABC333
	var A, B int
	fmt.Scanf("%d %d", &A, &B)

	if A%2 == 0 || B%2 == 0 {
		fmt.Println("No")
	} else {
		fmt.Println("Yes")
	}
}


Measured memory_bytes: 1836
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int kzyou(int n,int k){
   if(k ==0){
     return 1;
   }
     int a = n;
    for(int i = 0;i<k-1;i++){
      a *= n;
    }
    return a;
}

int main() {
  int N;
  cin >> N;
  vector<int> A(N);
  rep(i,N){
      cin >> A[i];
  }
  int c = 0;
  rep(i,N){
      if(A[i]%2 == 0) c++;
  }
  int ans = kzyou(3,N) - kzyou(2,c);
  cout << ans << endl;

}
  

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define pb push_back
#define all(x) (x).begin(),(x).end()
using namespace  std ;
typedef long l ;
typedef long long ll ;
typedef vector<int>vi ;
typedef vector<l>vl ;
typedef vector<ll>vll ;
typedef vector<vector<ll> >vvl ;
typedef pair<int,int> pii ;
typedef pair<ll,ll> pll ;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    std::cout.unsetf ( std::ios::floatfield );//this and next line for floating precision upto 6
    std::cout.precision(10);
    ll a,b,c,d,x,i,j,n,t,m,k,y;
    double p,q,r,w,u ;
    string str = "",str1 = "" ;
    ll a1,a2,b1,b2 ;
    char ch ;
    cin>>ch ;
    if(ch=='A')
    {
        cout<<'T' ;
    }
    else if(ch=='C')
    {
        cout<<'G' ;
    }
    else if(ch=='T')
    {
        cout<<'A'    ;
    }
    else
    {
        cout<<'C' ;
    }
}

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

using namespace std;

typedef long long ll;

ll md = 1000000007;

int main(int, char**)
{
	ll ans = 0;
	int n;
	cin >> n;
	vector<int> x(n);
	for (int i = 0; i < n; i++)
		cin >> x[i];

	sort(&x[0], &x[n]);
	for (int i = 0; i < n - 2; i++)
		for (int j = i + 1; j < n - 1; j++)
			for (int k = n - 1; k > j; k--) {
				if (x[k] < x[i] + x[j]) {
					ans += (k - j);
					break;
				}
			}

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


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

using namespace std;

typedef long long int ll;
typedef long double ld;
typedef unsigned long long int ull;
typedef pair<ll,ll> pll;
typedef pair<int, int> pii;

#define N 100010
#define M 200010
#define endl "\n"
#define mod 1000000007 

int main(){
	
	ios_base::sync_with_stdio(0);
	cin.tie(0);cout.tie(NULL);
	
	string s, t;
	
	cin >> s >> t;
	
	int ans = 0;
	
	for(int i = 0; i < s.size(); i++){
		if(s[i] != t[i]) ans++;
	}
	
	cout << ans << endl;
	
	return 0;
}

Measured memory_bytes: 3804
N = int(input())
A = list(map(int, input().split()))
B = []
sum = 0
for i in range(N+1):
  B.append(0)
for i in range(N):
  B[A[i]] += 1
for i in range(N+1):
  if B[i] != 0:
    sum += B[i]*(B[i]-1)//2
for i in range(N):
  x = B[A[i]]
  if x != 1:
  	print(sum-x*(x-1)//2+(x-1)*(x-2)//2)
  else:
    print(sum)


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

#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

#define start_routine() int begtime = clock();
#define end_routine() int endtime = clock(); cerr << endl << "Time elapsed: " << (endtime - begtime)*1000/CLOCKS_PER_SEC << " ms"; return 0
#define speed() cin.tie(0), cout.tie(0), ios_base::sync_with_stdio(false)
// #define exit(a, b) return cout << a, b;

#define PB push_back
#define pb push_back
#define MP make_pair

#define sd(n) scanf("%lld", &n)
#define pdn(n) printf("%lld\n", n);
#define pds(n) printf("%lld ", n);
#define endl '\n'

#define forn(a, b, i) for (int i = a; i < b; i += 1)
#define all(v) v.begin(), v.end() 

#define print(stuff) cout << stuff << endl
#define len(stuff) (int) stuff.size()

#define int long long
#define float long double 
#define ll long long
#define ld long double

using vi = vector<int>;
using vb = vector<bool>;
using pii = pair<int, int>;
using mii = map<int, int>;

const int inf = (int) 2e18;
const int upper = (int) 3e5 + 50;
const int M = (ll) 1e9 + 7;
const int mod = (ll) 998244353;
const double eps =  1e-8;

int n;
vector<int> vals;
int arr[upper];
map<int, int> pos;

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

	cin >> n;
	for (int i = 1; i <= n; i += 1) {
		cin >> arr[i];
		vals.push_back(arr[i]);
	}
	int ans = 0;
	sort(all(vals));
	for (int i = 0; i < len(vals); i += 1) 
		pos[vals[i]] = (i + 1) % 2;

	for (int i = 1; i <= n; i += 1) {
		if (pos[arr[i]] != (i % 2)) ans++;
	}
	cout << ans/2;
 	end_routine();		
}


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

namespace Algorithm
{
    class Program
    {
        static void Main(string[] args)
        {
            var l = Console.ReadLine().Split().Select(int.Parse).ToArray();
            int N = l[0], A = l[1], B = l[2];

            var ans = 0;
            foreach (var val in Enumerable.Range(1, N))
            {
                var total = 0;
                var tmp = val;
                while (tmp > 0)
                {
                    total += tmp % 10;
                    tmp /= 10;
                }

                if (total >= A && B >= total) ans += val;
            }
            Console.WriteLine(ans);
        }

    }
}


Measured memory_bytes: 13396
#include <bits/stdc++.h>
using namespace std;
int H, W;

int main() {
    cin >> H >> W;
    vector<vector<int>> a(H, vector<int>(W, 0));
    for(int j = 0; j < H; j++){
        string str;
        cin >> str;
        for(int i = 0; i < W; i++){
            if(str.at(i) == '.')
                a.at(j).at(i) = 1;
        }
    }

    //横方向
    int prev = 0;
    for(int j = 0; j < H; j++){
        prev = 0;
        for(int i = 0; i < W; i++){
            if (a.at(j).at(i) == 0){
                prev = 0;
            }else{
                a.at(j).at(i) += prev++;
            }
        }
    }

    for(int j = 0; j < H; j++){
        prev = 0;
        for(int i = W - 1; i >= 0; i--){
            if (a.at(j).at(i) == 0){
                prev = 0;
            }else{
                a.at(j).at(i) += prev++;
            }
        }
    }

    //縦方向
    for(int i = 0; i < W; i++){
        prev = 0;
        for(int j = 0; j < H; j++){
            if (a.at(j).at(i) == 0){
                prev = 0;
            }else{
                a.at(j).at(i) += prev++;
            }
        }
    }

    for(int i = 0; i < W; i++){
        prev = 0;
        for(int j = H - 1; j >0; j--){
            if (a.at(j).at(i) == 0){
                prev = 0;
            }else{
                a.at(j).at(i) += prev++;
            }
        }
    }

    int ans = 0;
    for(int j = 0; j < H; j++){
        int m1 = *max_element(a.at(j).begin(), a.at(j).end());
        ans = max(ans, m1);
    }
    cout << ans << endl;
}

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


int main(){
  long long n;
  long long ans = 0;
  cin >> n;
  for (long long i = 1; i <= n; i += 1){
    long long num = n / i * i;
    ans += (num / i) * (i + num) / 2;
  }

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 3556
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <set>
using namespace std;
typedef long long ll;
int n;

int main(){
    cin >> n;
    vector<ll> v; v.resize(n);
    for(int i=0; i<n; i++){ cin >> v[i];}
    int count=0;
    for(int i=0; i<n-2; i++){
        for(int j=i+1; j<n-1; j++){
            if(v[i]==v[j]) continue;
            for(int k=j+1; k<n; k++){
                if(v[k]==v[i] || v[k]==v[j]) continue;
                if(v[i]+v[j]>v[k]){
                    if(v[j]+v[k]>v[i]){
                        if(v[k]+v[i]>v[j]){
                            count++;
                        }
                    }
                }
            }
        }
    }
    cout << count << "\n";
    return 0;
}

Measured memory_bytes: 3628
#include<cstdio>
#include<vector>
#include<algorithm>
using namespace std;
int main(){
    int n,a,b,c,x;
    while(scanf("%d%d%d%d%d",&n,&a,&b,&c,&x),n){
        int val[100];
        for(int i=0;i<n;i++)scanf("%d",val+i);
        int pos=0;
        bool flag=true;
        for(int i=0;i<=10000;i++){
            if(val[pos]==x)pos++;
            if(pos==n){
                printf("%d\n",i);
                flag=false;
                break;
            }
            x=(a*x+b)%c;
        }
        if(flag)puts("-1");
    }
    return 0;
}

Measured memory_bytes: 1040
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#define rep(i,n) for(int i = 0; i < n; i++)
#define ll long long
#define uint unsigned int
using namespace std;

int main() {
	int Value[20];
	int Cost[20];
	int N;
	cin >> N;

	for (int i = 0; i < N; i++) {
		cin >> Value[i];
	}
	for (int j = 0; j < N; j++) {
		cin >> Cost[j];
	}

	int ans = 0;
	for (int k = 0; k < N; k++) {
		ans += max(0, Value[k] - Cost[k]);
	}

	cout << ans << endl;
}

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

using namespace std;

class Vector3{
public:
	double x,y;

	Vector3(){}
	Vector3( double dx, double dy ){
		x = dx;
		y = dy;
	}

	void operator-=( Vector3 hoge ){
		x -= hoge.x;
		y -= hoge.y;
	}

	Vector3 operator-( Vector3 hoge ){
		return Vector3( x - hoge.x, y - hoge.y );
	}

};

double scaler( Vector3 hoge ){
	return sqrt( hoge.x * hoge.x + hoge.y * hoge.y );
}
int main(int argc, char const* argv[])
{
	Vector3 a,b;
	double ra,rb;

	int n;

	cin >> n;

	for( int i = 0;i < n;i++ ){
		cin >> a.x >> a.y >> ra >> b.x >> b.y >> rb;

		if( scaler( a - b ) > ra + rb ){ cout << 0 << endl; continue; }

		if( ra < rb ){
			if( rb - scaler( a - b ) <= ra ){ cout << 1 << endl; continue; }
			else { cout << -2 << endl; continue; }
		} else if( rb < ra ) {
			if( ra - scaler( a - b ) <= rb ){ cout << 1 << endl; continue; }
			else { cout << 2 << endl; continue; }
		} else { cout << 1 << endl; continue; }
	}
	return 0;



}

Measured memory_bytes: 0
#include<iostream>
using namespace std; 
int a, b; 

int main()
{
	cin >> a >> b; 
	if((b - 1) % (a - 1) == 0)
		cout << (b - 1) / (a - 1) << endl; 
	else
		cout << (b - 1) / (a - 1) + 1 << endl; 
	return 0; 
}

Measured memory_bytes: 256
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include<math.h>
#define int long long
using namespace std;

int work(int P,vector<int> vec) {
	int x = 0;
	for (int i = 0; i < vec.size(); i++) {
		x += pow(vec[i] - P, 2);
	}
	return x;
}
signed main() {
	int N;
	cin >> N;
	vector<int> X(N);
	int average = 0;
	int wa = 0;
	for (int i = 0; i < N; i++) cin >> X[i];
	int ans = 1000000000000;
	for (int i = 0; i < N; i++) {
		wa += X[i];
	}
	average = wa / N;
	for (int i = 0; i < average + 5; i++) {
		if (ans > work(i, X)) ans = work(i, X);
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int N=200;
int n,m,f[2][N][N][N];
char s[N][N];
int main()
{
	scanf("%d%d",&n,&m);
	for(int i=1;i<=n;i++)scanf("%s",s[i]+1);
	for(int i=n;i;i--)
	for(int j=i;j<=n;j++)
	for(int k=m;k;k--)
	if(i==j)
	{
		if(k==m)f[0][i][j][k]=m+1;
		else f[0][i][j][k]=s[i][k]==s[i][k+1]?f[0][i][j][k+1]:k+1;
	}
	else f[0][i][j][k]=s[i][k]==s[i+1][k]?min(f[0][i][i][k],f[0][i+1][j][k]):k;
	for(int ans=0,t=0;;ans++,t^=1)
	{
		if(f[t][1][n][1]==m+1){printf("%d\n",ans);return 0;}
		for(int i=n;i;i--)
		for(int j=i;j<=n;j++)
		for(int k=m;k;k--)
		{
			f[t^1][i][j][k]=f[t][i][j][k]==m+1?m+1:f[t][i][j][f[t][i][j][k]];
			if(i<j)
			{
				int l=i,r=j-1,mid;
				while(l<=r)
				{
					mid=l+r>>1;
					if(f[t][i][mid][k]<=f[t][mid+1][j][k])
					f[t^1][i][j][k]=max(f[t^1][i][j][k],f[t][i][mid][k]),r=mid-1;
					else f[t^1][i][j][k]=max(f[t^1][i][j][k],f[t][mid+1][j][k]),l=mid+1;
				}
			}
		}
	}
}

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

int main () {
	int x, y;
	while (1) {
		cin >> x >> y;
		if (x == 0 && y == 0) {
			break;
		} else if (x > y) {
			cout << y << " " << x << "\n";
		} else {
			cout << x << " " << y << "\n";
		}
	}
	return 0;
}

Measured memory_bytes: 1160
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;
using System.Runtime.CompilerServices;
using static MyUtil;

class MyUtil
{
    public static int[] ReadIntArray()
    {
        return ReadLine().Split().Select(x => int.Parse(x)).ToArray();
    }
}

class Program
{
    public static void Main()
    {
        int n = int.Parse(ReadLine());
        var tmp = ReadIntArray();
        int d = tmp[0], x = tmp[1];

        int sum = 0;
        for (int i = 0; i < n; i++)
        {
            int a = int.Parse(ReadLine());
            sum += (d-1) / a + 1;
        }

        WriteLine(sum + x);
    }
}

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


int main() {
  string S ; 
  cin >> S ; 
  int j = 0 ; 
  int k = 0 ; 
  int l = 0 ; 
  int m = 0 ; 
  
  for(int i = 0 ; i < 4 ; i++){
    if (S.at(0) == S.at(i)){
      j++ ;
    }
    if (S.at(1) == S.at(i)){
      k++ ;
    }
    if (S.at(2) == S.at(i)){
      l++ ;
    }
    if (S.at(3) == S.at(i)){
      m++ ;
    }    
  }
  

  
  if (j != 2 || k != 2 || l != 2 || m != 2 ){
    cout << "No" << endl ; 
  }
  else {
    cout << "Yes" << endl ; 
  }
}

Measured memory_bytes: 3596
// Created by: WeirdBugsButOkay

#include <bits/stdc++.h>

#define ll long long
#define ld long double
#define ff first
#define ss second
#define PI 3.14159265358979323846
#define endl '\n'

using namespace std;

void solve()
{
	string s;
	cin >> s;
	if(s[0] <= 90)
		cout << "A";
	else cout << "a";
}

int main()
{
	int q = 1;
	//scanf("%d", &q);
	for(int i = 1; i <= q; i++)
	{
		solve();
	}
	return 0;
}

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

int main(){
  int n;
  cin >> n;
  int q=0,p=0;
  for(int i=0;i<n;i++){
    int b;
    cin >>b;
    if(b%2==0){q++;}else{p++;}
  }
  if(p%2==0){cout << "YES" << endl;}else{cout << "NO" << endl;}
}


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

using namespace std;
int n,x;
char s[1111111111];
int main()
{
    scanf(" %s %d",s,&x);
    int n=strlen(s);
    for(int i=0;i<n;++i)if(i%x==0){
        printf("%c",s[i]);
    }puts("");
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
int main()
{
	int a ,b ,k ,t ,i;
	scanf("%d%d%d",&a,&b,&k);
	t = a+k;
	if(t > b)
		t = b;
	for(i = a; i < t; i++)
		printf("%d\n",i);
	if(b-a+1 >= 2*k)
	{
		t = b-k;
		for(i = t+1; i <= b; i++)
			printf("%d\n",i);
	}
	else for(; i <= b; i++)
			printf("%d\n",i);
	return 0;
}

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

int ipow(int a,int b){
    int ans=1;
    for (int i = 0; i < b; ++i) {
        ans=ans*a;
    }
    return ans;
}

int main(void){
    int xi[6]={};
    string inp;
    cin>>inp;
    int k=0;
    char mi='+';
    int ind=0;
    while(inp.length()>0){
        k=0;
        if(inp[0]=='x')k=1;
        else while(inp[0]!='x'&&!inp.empty()){
            k=k*10+inp[0]-'0';
            inp.erase(inp.begin());
        }
        if(!inp.empty()&&(inp[1]=='+'||inp[1]=='-')){inp.insert(inp.begin()+1,'1');inp.insert(inp.begin()+1,'^');}
        if(!inp.empty())inp.erase(inp.begin(),inp.begin()+2);
        if(inp.empty()){
            ind=0;
            if(mi=='-')k=k*-1;}
        else {
            ind=inp[0]-'0';
            if(mi=='-')k=k*-1;
            mi=inp[1];
            inp.erase(inp.begin());
        }
        if(!inp.empty())inp.erase(inp.begin());
        xi[ind]=k;
    }
    int mxi;
    for (int i = 0; i < 6; ++i) {
        if(xi[i]!=0)mxi=i;
    }
    vector <int> ans;
    for(int i=1;i<=2000;++i){
        long long t=0;
        for (int j = 0; j < 6; ++j) {
            t+=xi[j]*ipow(i,j);
        }
        if(t==0)ans.push_back(-i);
        if(ans.size()>=mxi)break;
        t=0;
        for (int j = 0; j < 6; ++j) {
            t+=xi[j]*ipow(-i,j);
        }
        if(t==0)ans.push_back(i);
        if(ans.size()>=mxi)break;
    }
    sort(ans.begin(),ans.end());
    for (int i = 0; i < ans.size(); ++i) {
        char a=ans[i]>0?'+':'-';
        ans[i]=abs(ans[i]);
        cout<<"(x"<<a<<ans[i]<<")";
    }
    cout<<endl;
    return 0;
}


Measured memory_bytes: 3208
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  int n;
  cin >> n;
  int s1 = 0;
  int s2 = 0;
  int ans = 1e9;
  vector<int> w(n);
  for(int i = 0; i < n; i++) {
    cin >> w[i];
  }
  for(int i = 1; i < n - 1; i++) {
    for(int j = 0; j < n; j++) {
      if(i >= j) {
        s1 += w[j];
      }else {
        s2 += w[j];
      }
    }
    ans = min(ans, abs(s2- s1));
    s2 = 0;
    s1 = 0;
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <map>
#include <string>
#include <set>

using namespace std;

int main(int argc, char *argv[]) {
  string word;
  int page;
  multimap<string, int> mm;
  while (cin >> word >> page)
    mm.insert(pair<string, int>(word, page));

  set<int> pages;
  word = "";
  for (multimap<string, int>::iterator itr = mm.begin();
       itr != mm.end(); itr++) {
    if (word != itr->first && !pages.empty()) {
      for (set<int>::iterator jtr = pages.begin();
           jtr != pages.end(); jtr++) {
        if (jtr != pages.begin())
          cout << ' ';
        cout << *jtr;
      }
      cout << endl;
      pages.clear();
      cout << itr->first << endl;
    } else if (word != itr->first) {
      cout << itr->first << endl;
    }
    word = itr->first;
    pages.insert(itr->second);
  }
  if (!pages.empty())
    for (set<int>::iterator jtr = pages.begin();
         jtr != pages.end(); jtr++) {
      if (jtr != pages.begin())
        cout << ' ';
      cout << *jtr;
    }
  cout << endl;
  return 0;
}

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

using namespace std;
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9 + 7;
const ll LINF = 1e18;

const ll FAC_MAX = 510000;

ll fac[FAC_MAX]; //階乗
ll finv[FAC_MAX]; //階乗の逆元

//繰り返し二乗法
//x^n mod
ll mod_pow(ll x, ll n) {
    if (n == 0) {
        return 1;
    } else if (n % 2 == 1) { //奇数
        return mod_pow(x, n - 1) * x % MOD; //偶数の再帰にできるように変形
    } else { //偶数
        ll t = mod_pow(x, n / 2); //半分のものを求めて、2乗する
        return t * t % MOD;
    }
}

void init() {
    fac[0] = 1;
    for (ll i = 1; i <= FAC_MAX; ++i) {
        fac[i] = (fac[i - 1] * i) % MOD; //階乗を計算
    }

    for (ll i = 0; i <= FAC_MAX; ++i) {
        finv[i] = mod_pow(fac[i], MOD - 2); //フェルマーの小定理を使い、階乗の逆元を計算
    }
}

//nCr
ll comb(ll n, ll r) {
    if (n < r) {
        return 0;
    }

    if (n < 0 || r < 0) {
        return 0;
    }

    return (((fac[n] * finv[r]) % MOD) * finv[n - r]) % MOD;
}

int main() {

    ll n, k; cin >> n >> k;

    vector<ll> a(n);
    for (ll i = 0; i < n; ++i) {
        cin >> a[i];
    }

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

    ll ma = 0;
    ll mi = 0;

    init();

    for (ll i = 0; i < n; ++i) {
        ma += comb(i, k-1) * a[i] % MOD;
    }

    for (ll i = n-1; i >= 0; --i) {
        mi += comb(n-1-i, k-1) * a[i] % MOD;
    }

    cout << (ma % MOD - mi % MOD) % MOD << endl;
}

Measured memory_bytes: 8960
import java.util.Scanner;

public class Main {
	
	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		
		int A = sc.nextInt();
		int B = sc.nextInt();
		
		if(A+B >= 10) {
			System.out.println("error");
		}else {
			System.out.println(A+B);
		}
		
	}

}


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

int main(){
    
    string str,dousa,str2;
    int n,a,b,s;
    cin>>str>>n;
  s=str.size();

  for(int i=0;i<n;i++)
  {
  cin >>dousa>>a>>b;
  
  if ( dousa == "print" )
  {
    cout<<str.substr(a, b-a+1)<<endl;
  }
  else if ( dousa == "reverse" ) 
  {
       str2 = str.substr(a,b-a+1);
       reverse(str2.begin(),str2.end());
//    cout<<str2<<endl;
    str = str.substr(0,a) + str2 + str.substr(b+1,s-a-1);
//  cout<<str<<endl;
  }
  else if ( dousa == "replace" ) 
  {
    cin>>str2;
    str = str.substr(0,a) + str2 + str.substr(b+1,s-a-1);
//    str = str.replace(a,b,str2);
//  cout<<str<<endl;
  }
  } 
return 0;
}


Measured memory_bytes: 3220
#include <bits/stdc++.h>
using namespace std;
typedef long long   signed int LL;
typedef long long unsigned int LU;
#define incID(i, l, r) for(LL i = (l)    ; i <  (r); ++i)
#define incII(i, l, r) for(LL i = (l)    ; i <= (r); ++i)
#define decID(i, l, r) for(LL i = (r) - 1; i >= (l); --i)
#define decII(i, l, r) for(LL i = (r)    ; i >= (l); --i)
#define inc(i, n)  incID(i, 0, n)
#define inc1(i, n) incII(i, 1, n)
#define dec(i, n)  decID(i, 0, n)
#define dec1(i, n) decII(i, 1, n)
#define inID(v, l, r) ((l) <= (v) && (v) <  (r))
#define inII(v, l, r) ((l) <= (v) && (v) <= (r))
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define  ALL(v)  v.begin(),  v.end()
#define RALL(v) v.rbegin(), v.rend()
template<typename T> bool setmin  (T & a, T b) { if(b <  a) { a = b; return true; } else { return false; } }
template<typename T> bool setmax  (T & a, T b) { if(b >  a) { a = b; return true; } else { return false; } }
template<typename T> bool setmineq(T & a, T b) { if(b <= a) { a = b; return true; } else { return false; } }
template<typename T> bool setmaxeq(T & a, T b) { if(b >= a) { a = b; return true; } else { return false; } }
LL mo(LL a, LL b) { assert(b > 0); a %= b; if(a < 0) { a += b; } return a; }
LL fl(LL a, LL b) { assert(b > 0); return (a > 0 ? a / b : (a - b + 1) / b); }
LL ce(LL a, LL b) { assert(b > 0); return (a < 0 ? a / b : (a + b - 1) / b); }
template<typename T> T gcd(T a, T b) { return (b == 0 ? a : gcd(b, a % b)); }
template<typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; }
#define bit(b, i) (((b) >> (i)) & 1)
#define BC __builtin_popcountll
#define SC static_cast
#define SI(v) SC<int>(v.size())
#define SL(v) SC<LL >(v.size())
#define RF(e, v) for(auto & e: v)
#define ef else if
#define UR assert(false)

// ---- ----

const int M = 2000;

int h, w, L[M][M], R[M][M], U[M][M], D[M][M];
string s[M];

int main() {
	cin >> h >> w;
	inc(i, h) { cin >> s[i]; }
	
	inc(i, h) { int p = -1;
	inc(j, w) {
		if(s[i][j] == '#') { p = j; }
		L[i][j] = p;
	}
	}
	
	inc(i, h) { int p = w;
	dec(j, w) {
		if(s[i][j] == '#') { p = j; }
		R[i][j] = p;
	}
	}
	
	inc(j, w) { int p = -1;
	inc(i, h) {
		if(s[i][j] == '#') { p = i; }
		U[i][j] = p;
	}
	}
	
	inc(j, w) { int p = h;
	dec(i, h) {
		if(s[i][j] == '#') { p = i; }
		D[i][j] = p;
	}
	}
	
	int ans = 0;
	inc(i, h) {
	inc(j, w) {
		if(s[i][j] == '#') { continue; }
		
		setmax(ans, R[i][j] - L[i][j] + D[i][j] - U[i][j] - 3);
	}
	}
	
	
	cout << ans << endl;
	
	return 0;
}


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

long long int GCD(long long int a, long long int b) {
    return (b % a == 0) ? a : GCD(b % a, a);
}

long long int LCM(long long int a, long long int b) {
    return (a / GCD(a, b)) * b;
}

int main() {
    long long int a, b;
    while (cin >> a >> b) {
        cout << GCD(a, b) << " " << LCM(a, b) << endl;
    }    
    return 0;
}


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

int main() {

    int n, x[200001], od[200001];
    long long sum[200002] = {0};

    cin >> n;
    for(int i = 1; i <= n; i++) {
        cin >> x[i];
        od[i - 1] = x[i];
    }


    sort(od, od + n);
    for(int i = 1; i <= n; i++) {
        if(x[i] <= od[(n + 1) / 2 - 1]) {
            cout << od[(n + 1) / 2] << endl;
        } else {
            cout << od[(n + 1) / 2 - 1] << endl;
        }
    }
}


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

int n, a[111];

void ss(){
  int minj;
  int cnt = 0;
  for(int i = 0; i < n; i++){
    minj = i;
    for(int j = i; j < n; j++){
      if(a[j] < a[minj]){
        minj = j;
      }
    }
    swap(a[i],a[minj]);
    if(a[i] < a[minj]) cnt++;
  }

  for(int i = 0; i < n; i++){
    if(i != n-1) cout << a[i] << " ";
    else cout << a[i] << endl;
  }
  cout << cnt << endl;
}

int main(){

  cin >> n;
  for(int i = 0; i < n; i++){
    cin >> a[i];
  }
  ss();
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
using namespace std;
template<class T> inline bool chmax(T& a, T b) {if(a<b) {a=b;return 1;} return 0;}

int main() {
    int N,W;
    cin >> N >> W;
    vector<long long> w(N),v(N);
    for(int i=0;i<N;i++) cin >> w[i] >> v[i];
    vector<long long> dp(W+1),dpp(W+1);
    for(int i=0;i<=W;i++) dp[i]=-1;
    dp[0]=0;
    for(int n=0; n<N; n++) {
        dpp.swap(dp);
        for(int i=0;i<=W;i++) dp[i]=dpp[i];
        for(int iw=0; iw<=W; iw++) {
            if (dpp[iw]>=0 && iw+w[n]<=W) chmax(dp[iw+w[n]], dpp[iw]+v[n]);
        }
    }
    long long ans=*max_element(dp.begin(), dp.end());
    std::cout << ans << '\n';
    return 0;
}

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

using ll = long long;

#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define pb push_back
#define mp make_pair
#define fill(x, y) memset(x, y, sizeof(x))
#define even(x) x % 2 == 0
#define odd(x) x % 2 != 0
#define all(x) x.begin(), x.end()
#define pcnt __builtin_popcount
#define buli(x) __builtin_popcountll(x)
#define F first
#define S second
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end());

ll qp(ll a, ll b, int mo) { ll ans = 1; do { if (b & 1) ans = 1ll * ans * a % mo; a = 1ll * a * a % mo; } while (b >>= 1); return ans; }
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

template <typename T>
vector<T> make_v(size_t a) { return vector<T>(a); }

template <typename T, typename... Ts>
auto make_v(size_t a, size_t b, Ts... ts) { return vector<decltype(make_v<T>(b, ts...))>(a, make_v<T>(b, ts...)); }
template <typename T, typename V>
typename enable_if<is_class<T>::value == 0>::type
fill_v(T &t, const V &v) { t = v; }
template <typename T, typename V>
typename enable_if<is_class<T>::value != 0>::type
fill_v(T &t, const V &v) { for (auto &e : t) fill_v(e, v); }
// auto dp = make_v<int>(4, h, w);
// fill_v(dp, 0);

const ll INF_LL = (1ll << 60);
const int INF_INT = (int)1e9;
const ll MOD_CONST = (ll)(1e9 + 7);

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

inline tuple<ll, ll> rotate45(tuple<ll, ll> p) { ll x = get<0>(p), y = get<1>(p); return tuple<ll, ll>(x + y, x - y); }

int lcp(const string &s1, const string &s2) {
	int cnt = 0, n = min(s1.size(), s2.size());
	REP(i, n) {
		if (s1[i] == s2[i]) cnt++;
		else break;
	}
	return cnt;
}

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

	int A, B, C, X, Y; cin >> A >> B >> C >> X >> Y;
	ll ans = INT64_MAX;
	REP(num_ab, 200001) {
		ll cost = num_ab * C;
		int anum, bnum; anum = bnum = num_ab / 2;
		if (X > anum) cost += (X - anum) * A;
		if (Y > bnum) cost += (Y - bnum) * B;
		chmin(ans, cost);
	}
	cout << ans << endl;
	

	return 0;
}


Measured memory_bytes: 256