akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <bitset>
#include <climits>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>

#define MOD 1000000007
#define MOD2 998244353
#define int long long
#define double long double
#define EPS 1e-9
//#define PI 3.14159265358979

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

using namespace std;

template < typename T >
ostream &operator<<(ostream &os, const vector< T > &A) {
	for (int i = 0; i < A.size(); i++)
		os << A[i] << " ";
	os << endl;
	return os;
}
template <>
ostream &operator<<(ostream &os, const vector< vector< int > > &A) {
	int N = A.size();
	int M;
	if (N > 0)
		M = A[0].size();
	for (int i = 0; i < N; i++) {
		for (int j = 0; j < M; j++)
			os << A[i][j] << " ";
		os << endl;
	}
	return os;
}

typedef pair< int, int > pii;
typedef long long ll;

struct edge {
	int from, to, d, c;
	edge(int _from = 0, int _to = 0, int _d = 0, int _c = 0) {
		from = _from;
		to = _to;
		d = _d;
		c = _c;
	}
	bool operator<(const edge &rhs) const {
		return (d == rhs.d) ? (c < rhs.c) : (d < rhs.d);
	}
};
struct aabb {
	int x1, y1, x2, y2;
	aabb(int x1, int y1, int x2, int y2) : x1(x1), y1(y1), x2(x2), y2(y2) {}
};

typedef vector< edge > edges;
typedef vector< edges > graph;
struct flow {
	int to, cap, rev, cost;
	flow(int to = 0, int cap = 0, int rev = 0, int cost = 0) : to(to), cap(cap), rev(rev), cost(cost) {}
};
typedef vector< vector< flow > > flows;

const int di[4] = {0, -1, 0, 1};
const int dj[4] = {-1, 0, 1, 0};
const int ci[5] = {0, 0, -1, 0, 1};
const int cj[5] = {0, -1, 0, 1, 0};
const ll LINF = LLONG_MAX / 2;
const int INF = INT_MAX / 2;
const double PI = acos(-1);

int pow2(int n) { return 1LL << n; }
template < typename T, typename U >
bool chmin(T &x, const U &y) {
	if (x > y) {
		x = y;
		return true;
	}
	return false;
}
template < typename T, typename U >
bool chmax(T &x, const U &y) {
	if (x < y) {
		x = y;
		return true;
	}
	return false;
}

struct initializer {
	initializer() {
		cout << fixed << setprecision(20);
	}
};
initializer _____;

int N, M, K, T, Q, H, W;
signed main() {
	cin >> N;
	vector< vector< int > > A(N, vector< int >(N));
	rep(i, N) rep(j, N) cin >> A[i][j];
	vector< int > B(N, 0);
	rep(i, N) rep(j, N) B[i] += A[i][j];
	vector< vector< int > > dp(N + 1, vector< int >(1 << N, 0));
	dp[0][0] = 1;
	rep(i, N) {
		rep(b, 1 << N) {
			bitset< 21 > bit(b);
			if (bit.count() != i)
				continue;
			rep(k, N) {
				if (!bit[k] && A[k][i]) {
					int nb = b | (1 << k);
					(dp[i + 1][nb] += dp[i][b]) %= MOD;
				}
			}
		}
	}
	cout << dp[N][(1 << N) - 1] << endl;
	return 0;
}

Measured memory_bytes: 377216
#include<bits/stdc++.h>
using namespace std;
long long a,b;
int main()
{
	cin>>a>>b;
	for(long long i=a;i<=1000000000000000000;i+=a)
	if(i%b!=0){cout<<i<<endl;return 0;}
	else if(i%b==0){cout<<-1<<endl;return 0;}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i, n) for (ll i = 0; i < n; ++i)
#define P pair<ll, ll>
#define Graph vector<vector<ll>>
#define fi first
#define se second
constexpr ll mod = 1000000007;
constexpr ll INF = (1ll << 60);
constexpr double pi = 3.14159265358979323846;
template <typename T> inline bool chmax(T &a, T b){if (a < b){a = b;return 1;}return 0;}
template <typename T> inline bool chmin(T &a, T b){if (a > b){a = b;return 1;}return 0;}

int main(){
    ll h,w;cin>>h>>w;
    vector<vector<char>> grid(h,vector<char>(w));
    rep(i,h){
        rep(j,w){
            cin>>grid[i][j];
        }
    }

    vector<ll> gyou(h),retu(w);
    rep(i,h){
        bool all_white=true;
        rep(j,w){
            if(grid[i][j]=='#') all_white=false;
        }
        if(all_white) gyou[i]=1;
    }
    rep(j,w){
        bool all_white=true;
        rep(i,h){
            if(grid[i][j]=='#') all_white=false;
        }
        if(all_white) retu[j]=1;
    }

    rep(i,h){
        if(gyou[i]==1) continue;
        rep(j,w){
            if(retu[j]==1) continue;

            cout<<grid[i][j];
        }
        cout<<endl;
    }
    return 0;
}

Measured memory_bytes: 3648
K = int(input())
A = [int(i) for i in input().split()]
A.reverse()

# L: 最小の生存人数
# H: 最大の生存人数
L, H = 2, 2
for i in range(K):
    # [L,H]で最小のA[i]の倍数
    MIN = (L + A[i] - 1) // A[i] * A[i]
    # [L,H]で最大のA[i]の倍数
    MAX = H // A[i] * A[i]

    if L <= MIN <= H:
        L = MIN
        H = MAX + A[i] - 1
    else:
        print(-1)
        exit()

print(L,H)

Measured memory_bytes: 14252
import java.util.*;

public class Main
{
	public static void main(String args[])
	{
		Scanner s1=new Scanner (System.in);
		int n,r,sum=0;
		n=s1.nextInt();
		int[] m=new int[n];
		for(int i=0;i<n;i++)
		{
			m[i]=s1.nextInt();


		}
		Arrays.sort(m);
		int min = n* m[n-1] * m[n-1];
		for(int i = m[0] ; i <= m[n-1] ;i++) 
		{
			int temp = 0;
			for(int j = 0 ; j < n ; j++) 
			{
				temp += Math.pow(i-m[j], 2);
			}
			min = Math.min(temp, min);
		}
		
		System.out.println(min);
	}
}
			

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

int main() {
	int N, K;
	string S;
	cin>>N>>K;
	cin>>S;
	int LNum = 0;
	int RNum = 0;
	char tmp = S[0];
	for(int i=0;i<S.length();++i){
		if(tmp != S[i]){
			if(tmp == 'L') LNum++;
			else RNum++;
			tmp = S[i];
		}
	}
	if(tmp=='L') LNum++;
	else RNum++;
	int ans = N - (LNum + RNum);
	if (LNum==1 && RNum==1) ans++;
	else {
		ans += 2*min(min(RNum, LNum), K);
		if((K >= min(RNum, LNum)) && (S[0] != tmp)){
			ans -= 1;
		}
	}
	cout<<ans<<endl;
}


Measured memory_bytes: 512
N, X = map(int, input().split())
x_list = list(map(int, input().split()))


# 最小公倍数
def gcd(a, b):
        while b:
                a, b = b, a % b
        return a

# 最大公約数
def lcm(a, b):
        return a * b // gcd (a, b)


ans = 0
for i, x in enumerate(x_list):

    diff = abs(x - X)

    # print(i, x, diff, ans)

    if i == 0:
        ans = diff
    else:
        larger = min(ans, diff)
        smaller = max(ans, diff)

        if smaller % larger == 0:
            ans = larger
        else:
            ans = gcd(ans, diff)

print(ans)


Measured memory_bytes: 14224
#AGC029-A Irreversible operation
"""
問題：
一直線上にオセロがある
一回の操作で[黒白]を裏返す時[白黒]、最大何回の操作が行えるか
解法：
まずいちばん最初のBが出てくるところまでは無視できる
そこから、Wが出てくる度にそこまでに出現したBの数を足した合計が答え
"""
import sys
readline = sys.stdin.buffer.readline
def even(n): return 1 if n%2==0 else 0
s = readline().rstrip().decode('utf-8')
flag = 0
black = 0
white = 0
ans = 0
for i in s:
    if flag:
        if i == "B":
            black += 1
        else:
            ans += black
    else:
        if i == "B":
            flag = 1
            black += 1
print(ans)

Measured memory_bytes: 42056
#http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ALDS1_1_B&lang=jp
#??????????????????????????????
#?????§??¬?´???°???????????????????????????????????¨????????¨?¨????????????????
def gcd(x,y):
    tmp = y
    
    if y > x:
        y = x
        x = tmp

    while not y == 0:
        y = x % y
        x = tmp
        tmp = y

    return x
def main():
    target = [int(a) for a in input().split()]
    print(gcd(target[0], target[1]))
    
if __name__ == "__main__":
    main()

Measured memory_bytes: 7744
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;++i)
#define rrep(i,n) for(int i=n-1;i>=0;--i)
#define yesno(flg) if(flg){cout<<"YES"<<endl;}else{cout<<"NO"<<endl;}
#define MAX_N 1002
#define i197 1000000007

using namespace std;

typedef long long ll;
typedef pair<ll,ll> P1;
typedef pair<int,int> Pi;
typedef pair<double,Pi> Pdi;
typedef pair<ll,int>Pli;
typedef pair<P1,ll> P2;
const ll INF=1000000000000000001;
struct edge{int to,cost;};
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};
struct Road{double cost;int a,b;};

int main() {

	int n;
	char s[101];
	int t1=0,t2=0;

	cin>>n;

	rep(i,n){
		cin>>s[i];
		if(s[i]=='B')t1++;
		if(s[i]=='R')t2++;
	}
	if(t1>=t2)cout<<"No"<<endl;
	else cout<<"Yes"<<endl;
	return 0;

}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <queue>
#include <stack>
#include <algorithm>
#include <list>
#include <vector>
#include <complex>
#include <utility>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <bitset>
#include <ctime>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <cassert>
#include <cstddef>
#include <iomanip>
#include <numeric>
#include <tuple>
#include <sstream>
#include <fstream>

using namespace std;
#define REP(i, n) for (int (i) = 0; (i) < (n); (i)++)
#define FOR(i, a, b) for (int (i) = (a); (i) < (b); (i)++)
#define RREP(i, a) for(int (i) = (a) - 1; (i) >= 0; (i)--)
#define FORR(i, a, b) for(int (i) = (a) - 1; (i) >= (b); (i)--)
#define DEBUG(C) cerr << #C << " = " << C << endl;
using LL = long long;
using VI = vector<int>;
using VVI = vector<VI>;
using VL = vector<LL>;
using VVL = vector<VL>;
using VD = vector<double>;
using VVD = vector<VD>;
using PII = pair<int, int>;
using PDD = pair<double, double>;
using PLL = pair<LL, LL>;
using VPII = vector<PII>;
template<typename T> using VT = vector<T>;
#define ALL(a) begin((a)), end((a))
#define RALL(a) rbegin((a)), rend((a))
#define SORT(a) sort(ALL((a)))
#define RSORT(a) sort(RALL((a)))
#define REVERSE(a) reverse(ALL((a)))
#define MP make_pair
#define FORE(a, b) for (auto &&a : (b))
#define FIND(s, e) ((s).find(e) != (s).end())
#define EB emplace_back
template<typename T> inline bool chmax(T &a, T b){if (a < b){a = b;return true;}return false;}
template<typename T> inline bool chmin(T &a, T b){if (a > b){a = b;return true;}return false;}

const int INF = 1e9;
const int MOD = INF + 7;
const LL LLINF = 1e18;

const int MAX = 1e5 + 10;
int n;
LL a[MAX];

int main(void) {
    scanf("%d", &n);
    REP(i, n) scanf("%lld", a + i);
    sort(a, a + n);
    reverse(a, a + n);
    LL pre = INF;
    int ans;
    REP(i, n - 1) {
        if (chmin(pre, llabs(a[0] / 2 - a[i + 1]))) {
            ans = i + 1;
        }
    }
    cout << a[0] << " " << a[ans] << endl;
}


Measured memory_bytes: 1024
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<string.h>
#include<functional>

using namespace std;

int main() {
	vector<string> S;
	vector<string> tempstr;
	vector<char> res;
	int n, mins=51;
	cin >> n;

	for (int i = 0; i < n; i++) {
		string str;
		cin >> str;
		sort(str.begin(), str.end());
		S.push_back(str);
	}

	int mode;
	//初期設定
	if (n == 1) {
		string str;
		str = S[0];
		tempstr.push_back(str);
		mode = 1;
	}
	else {
		string str;

		for (int i = 0; i < S[0].size(); i++) {
			for (int j = 0; j < S[1].size(); j++) {
				if (S[0][i] == S[1][j]) {
					str.push_back(S[0][i]);
					S[1][j] = '0';
					break;
				}
			}
		}
		tempstr.push_back(str);
		if (n == 2)mode = 2;
		else mode = 3;
	}

	if (mode == 3) {

		for (int f = 2; f < n; f++) {
			string str = tempstr[f - 2];
			string temp;
			
			for (int i = 0; i < str.size(); i++) {
				for (int j = 0; j < S[f].size(); j++) {
					if (str[i] == S[f][j]) {
						temp.push_back(str[i]);
						S[f][j] = '0';
						break;
					}
				}
			}
			tempstr.push_back(temp);
		}
	}

	if (mode <= 2) {
		sort(tempstr[0].begin(), tempstr[0].end());
		cout << tempstr[0] << endl;
	}
	else {
		sort(tempstr[n-2].begin(), tempstr[n-2].end());
		cout << tempstr[n-2] << endl;
	}

	return 0;
}

Measured memory_bytes: 256
import java.util.*;

class Main{
    int INF=1<<28;
    int H,W;
    int[][] k;
    char[][] s;

    void run(){
	Scanner sc=new Scanner(System.in);
	int tt=sc.nextInt();
	while(tt-->0){
	    H=sc.nextInt();W=sc.nextInt();
	    k=new int[200][200];
	    s=new char[H+2][W+2];

	    for(int i=0;i<s.length;i++)
		for(int j=0;j<s[0].length;j++)
		    s[i][j]='.';
			
	    for(int i=1;i<H+1;i++){
		String ss=sc.next();
		for(int j=1;j<W+1;j++){
		    s[i][j]=ss.charAt(j-1);
		}
	    }

	    System.out.println(check()?"SAFE":"SUSPICIOUS");
	}
    }

    boolean check(){

	for(char c='A';c<='Z';c++){
	    int xmin=INF,ymin=INF;
	    int xmax=-1,ymax=-1;

	    for(int i=0;i<H+2;i++){
		for(int j=0;j<W+2;j++){
		    if(s[i][j]==c){
			xmin=Math.min(xmin,j);
			xmax=Math.max(xmax,j);
			ymin=Math.min(ymin,i);
			ymax=Math.max(ymax,i);
		    }
		}
	    }

	    for(int i=ymin;i<=ymax;i++){
		for(int j=xmin;j<=xmax;j++){
		    if(s[i][j]=='.')return false;
		    else if(s[i][j]!=c){
			char cc=s[i][j];
			if(k[c][cc]==1)return false;
			k[c][cc]=-1;k[cc][c]=1;
		    }
		}
	    }
	}

	    //テ、ツスツ催ァツスツョテゥツ鳴「テ、ツソツづ」ツ?古ァツ淞崚ァツ崢セテ」ツ?療」ツ?ヲテ」ツ??」ツ?ェテ」ツ??」ツ??
	    for(int z=0;z<10;z++){ //テゥツォツ佚」ツ??テァツィツョテゥツ。ツ?
		for(char i='A';i<='Z';i++){
		    for(char j='A';j<='Z';j++){
			if(k[i][j]==1 || k[j][i]==-1){
			    //テ」ツつづ」ツ?擁テ」ツ?桂テ」ツつ暗」ツつ甘、ツクツ甘」ツ?ォテ」ツ?づ」ツつ古」ツ?ー
			    for(char t='A';t<='Z';t++){
				if(k[t][i]==1 || k[i][t]==-1){
				if(k[t][j]==-1 || k[j][t]==1)return false;
				k[t][j]=1;k[j][t]=-1;
				}
			    }
			}
		    }
		}
	    }
	    return true;
    }

    public static void main(String[] args){
	new Main().run();
    }
}

	

Measured memory_bytes: 63256
#include<iostream>
#include<vector>
#include<algorithm>
#include<functional>
#include<queue>
#include<stack>
#include<set>
#include<climits>
#include<cstdlib>
#include<cmath>
#include<string>

using namespace std;

#define INF 1 << 29
#define LL long long int

LL const MOD = 1000000007;

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

    LL n;
    cin >> n;

    vector<string> str(n);
    for(int i = 0; i < n; i++){
        cin >> str[i];
    }

    for(int i = 1; i < n; i++){
        if(str[i][0] == str[i-1].back()){
            for(int j = 0; j < i; j++){
                if(str[i] == str[j]){
                    cout << "No" << endl;
                    return 0;
                }
            }
        }else{
            cout << "No" << endl;
            return 0;
        }
    }

    cout << "Yes" << endl;
    
    return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;

#define rep(i,n) for(long long i=0;i<(long long)(n);i++)
#define REP(i,k,n) for(long long i=k;i<(long long)(n);i++)
#define all(a) a.begin(),a.end()
#define NP next_permutation
#define pb push_back
#define eb emplace_back
#define lb(v,k) (lower_bound(all(v),k)-v.begin())
#define ub(v,k) (upper_bound(all(v),k)-v.begin())
#define fi first
#define se second
typedef long long ll;
typedef pair<ll,ll> P;
typedef tuple<ll,ll,ll> PP;
typedef multiset<ll> S;
typedef priority_queue<ll> PQ;
typedef priority_queue<P,vector<P>,greater<P>> SPQ;
using vi=vector<ll>;
using vvi=vector<vi>;
using vvvi=vector<vvi>;

const ll inf=1001001001001001;
const int INF=1001001001;
const int mod=1000000007;
const double pi=3.14159265358979323846;

template<class T> bool chmin(T&a,T b){if(a>b){a=b; return true;}return false;}
template<class T> bool chmax(T&a,T b){if(a<b){a=b; return true;}return false;}
template<class T> void decimal(T a){cout<<fixed<<setprecision(a);}
template<class T> void out(T a){cout<<a<<endl;}
template<class T> void outp(T a){cout<<'('<<a.fi<<','<<a.se<<')'<<endl;}
template<class T> void outvp(T v){rep(i,v.size())outp(v[i]);}
template<class T> void outv(T v){rep(i,v.size()){if(i)cout<<' ';cout<<v[i];}cout<<endl;}
template<class T> void outvv(T v){rep(i,v.size()){rep(j,v[i].size()){if(j)cout<<' ';cout<<v[i][j];}cout<<endl;}}

void YesNo(bool a){if(a) out("Yes"); else out("No");}
void yesno(bool a){if(a) out("yes"); else out("no");}
void YESNO(bool a){if(a) out("YES"); else out("NO");}
ll GCD(ll a,ll b){ll c; while(b!=0){c=a%b; a=b; b=c;} return a;}
ll LCM(ll a,ll b){return(a/GCD(a,b))*(b/GCD(a,b))*GCD(a,b);}
ll POW(ll a,ll b){ll c=1; while(b>0){if(b&1){c=a * c%mod;} a=a * a%mod; b>>=1;} return c;}
vi calc(ll x){vi res; while(x>0){res.pb(x%10); x/=10;} reverse(all(res)); return res;}

void solve() {
  int n,m;
  cin>>n>>m;
  if(m==0){
    if(n==1){
      out(0); return;
    }
    else{
      out(POW(10,n-1)); return;
    }
  }
  vi keta(n+1);
  vector<bool> a(n+1,false);
  rep(i,m){
    int p,q;
    cin>>p>>q;
    if(a[p]==true && q!=keta[p]){
      out(-1); return;
    }
    if(n!=1 && p==1 && q==0){
      out(-1); return;
    }
    keta[p]=q;
    a[p]=true;
  }
  vi ans(n+1);
  if(a[1]==false) ans[1]=1;
  else ans[1]=keta[1];
  REP(p,2,n+1){
    if(a[p]==false) ans[p]=0;
    else ans[p]=keta[p];
  }
  REP(p,1,n+1) cout<<ans[p];
  cout<<endl;
}

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


Measured memory_bytes: 256
N, M = map(int, input().split())
A = [input() for _ in range(N)]
B = [input() for _ in range(M)]
be_included = False

for i in range(N - M + 1):
    for j in range(N - M + 1):
        tmp = [A[k][j:j+M] for k in range(i, i + M)]
        if tmp == B:
            be_included = True
            break
    if be_included:
        break

if be_included:
    print('Yes')
else:
    print('No')


Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
#define LL long long

int main(){
	// sengen
	LL l,r;
	// nyuryoku
	cin >> l >> r;
	// keisan
	if(r - l > 2019){
		cout << '0';
		return 0;
	}else{
		LL ans = 2018;
		for(LL i=l;i<=r-1;i++){
			for(LL j=i+1;j<=r;j++){
				ans = min(ans,i*j%2019);
			}
		}
		cout << ans;
		return 0;
	}
	// syutsuryoku
}

Measured memory_bytes: 3536
/* Made by Takauov Yerzhan - 31/01/2020 */
#include <bits/stdc++.h>
#define enter endl
#define LL long long
#define LD long double
#define UL unsigned long long
#define Okoshka ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define pb push_back
#define F first
#define S second

using namespace std;

const LL MXN = 3e5 + 7;
const LL MOD = 1e9 + 7;
const LL INF = 1e18 + 7;

int dx[] = {+1, -1, 0, 0};
int dy[] = {0, 0, -1, +1};

int n, m;

int main()
{
    ///Okoshka;
    cin >> n >> m;
    int x = (n / m);
    if(n % m) x++;
    cout << x;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<stdint.h>
#define ii pair<int,int>
#define mp make_pair
#define pb push_back
#define all(x) (x).begin(),(x).end()
#define int long long int
#define modulo 1000000007
using namespace std;

int32_t main(){
	int n,c=1;
	cin>>n;
	string s;
	cin>>s;
	int pos=0;
	vector<int>val(2*n);
	for(int i=0;i<2*n;i++){
		if(s[i]=='W'){
			if(pos%2==0){
				val[i]=-1;
			}
			else val[i]=1;
		}
		else{
			if(pos%2==0){
				val[i]=1;
			}
			else val[i]=-1;
		}
		if(val[i]==1)pos++;
		else pos--;
		if(pos<0){
			cout<<0;
			return 0;
		}
	}
	int neg=0;
	for(int i=2*n-1;i>=0;i--){
		if(val[i]==-1)neg++;
		else{
			c*=neg;
			c%=modulo;
			neg--;
		}
	}
	for(int i=1;i<=n;i++){
		c*=i;
		c%=modulo;
	}
	cout<<c;
}


Measured memory_bytes: 2180
#include <bits/stdc++.h>
#define rep3(i, s, n, a) for (int i = (s); i < (int)(n); i += a)
#define rep2(i, s, n) rep3(i, s, n, 1)
#define rep(i, n) rep2(i, 0, n)

using namespace std;
using ll = long long;
using ull = unsigned long long;
using P = pair<int, int>;

int main(){
    char a;
    cin >> a;
    if(a>='A'&&a<='Z'){
        cout << "A" << endl;
    }else{
        cout << "a" << endl;
    }
    return 0;
}

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

int main() {
	int n, a, b;
	
	while(cin>>n,n) {
		a = 0;b = 0;
		for(int i=0;i<n;i++) {
			int sa, sb;
			cin>>sa>>sb;
			if(sa>sb)a+=sa+sb;
			else if(sb>sa)b+=sa+sb;
			else {
				a+=sa;
				b+=sb;
			}
		}
		cout<<a<<" "<<b<<endl;
	}
	
	return 0;
}

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

# define REP(i,n) for (int i=0;i<(n);++i)
# define rep(i,a,b) for(int i=a;i<(b);++i)
# define p(s) std::cout << s ;
# define pl(s)  std::cout << s << endl;
# define printIf(j,s1,s2) cout << (j ? s1 : s2) << endl;
# define YES(j) cout << (j ? "YES" : "NO") << endl;
# define Yes(j) std::cout << (j ? "Yes" : "No") << endl;
# define yes(j) std::cout << (j ? "yes" : "no") << endl;
# define all(v) v.begin(),v.end()
# define showVector(v) REP(i,v.size()){p(v[i]);p(" ")} pl("")
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;}
typedef long long int ll;
typedef pair<ll,ll> P_ii;
typedef pair<double,double> P_dd;

template<class T>
vector<T> make_vec(size_t a){
    return vector<T>(a);
}

template<class T, class... Ts>
auto make_vec(size_t a, Ts... ts){
  return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(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);
}


const int MOD = 1000000007;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;

void addM(long long &a, long long b) {
    a += b;
    if (a >= MOD) a -= MOD;
}

void mulM(long long &a, long long b) {
    a = ((a%MOD)*(b%MOD))%MOD ;
}

const int MAX = 510000;
long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

vector<pair<long long, long long> > prime_factorize(long long n) {
    vector<pair<long long, long long> > res;
    for (long long p = 2; p * p <= n; ++p) {
        if (n % p != 0) continue;
        int num = 0;
        while (n % p == 0) { ++num; n /= p; }
        res.push_back(make_pair(p, num));
    }
    if (n != 1) res.push_back(make_pair(n, 1));
    return res;
}

ll N,K;

ll ans=1;

vector<ll> g[100005];

void bfs(int depth,int s,int p){
    int st;
    if(depth==1) st = K-1;
    else st = K-2;

    for(auto v:g[s]){
        if(v==p) continue;
        mulM(ans,st);
        st--;
        bfs(depth+1,v,s);
    }
}

int main() {
    cin >> N >> K;


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

    ans *= K;
    bfs(1,0,-1);

    pl(ans)

    return 0;
}


Measured memory_bytes: 13312
import functools

import os

INF = float('inf')


def inp():
    return int(input())


def inpf():
    return float(input())


def inps():
    return input()


def inl():
    return list(map(int, input().split()))


def inlf():
    return list(map(float, input().split()))


def inls():
    return input().split()


def inpm(line):
    return [inp() for _ in range(line)]


def inpfm(line):
    return [inpf() for _ in range(line)]


def inpsm(line):
    return [inps() for _ in range(line)]


def inlm(line):
    return [inl() for _ in range(line)]


def inlfm(line):
    return [inlf() for _ in range(line)]


def inlsm(line):
    return [inls() for _ in range(line)]


def debug(fn):
    if not os.getenv('LOCAL'):
        return fn

    @functools.wraps(fn)
    def wrapper(*args, **kwargs):
        print('DEBUG: {}({}) -> '.format(
            fn.__name__,
            ', '.join(
                list(map(str, args)) +
                ['{}={}'.format(k, str(v)) for k, v in kwargs.items()]
            )
        ), end='')
        ret = fn(*args, **kwargs)
        print(ret)
        return ret

    return wrapper

s=input()
if s[0]==s[1]==s[2] or s[1] ==s[2]==s[3]:
    print('Yes')
else:print('No')


Measured memory_bytes: 3568
import math

tmp = input()
tmps = tmp.split()
tmp = tmps[0] + tmps[1]
# print(tmp)

# print(pow(int(tmp),0.5))
if pow(int(tmp),0.5) / int(pow(int(tmp),0.5))  == 1:
	print("Yes")
else:
	print("No")

Measured memory_bytes: 3060
N = int(input())
d = [int(input()) for i in range(N)]
sum = 0
maxd = 1
while maxd>0:
    maxd = max(d)
    for j in range(N):
        if maxd == d[j]:
            d[j] = 0
    sum += 1
print(sum-1)
    


Measured memory_bytes: 3064
#include <iostream>
#include <cmath>
#define ll long long
using namespace std;
int main(){
    int n,d, ans = 0; cin>>n>>d;
    while(n--){
         ll x,y; cin>>x>>y;
         double sqrtn = sqrt(x*x + y*y);
         if(d >= sqrtn){
             ans++;
         }
    }
    cout<<ans;
}

Measured memory_bytes: 3672
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);
		while(true){
			int n = stdIn.nextInt();
			int p = stdIn.nextInt();
			if(n==0&&p==0){
				return;
			}
			int[] te = new int[n];
			int table = p;
			for(int i=0;i<n;i++){
				te[i] = 0;
			}
			int i = 0;
			while(true){
				if(te[i]==p){
					break;
				}
				if(table!=0){
					table--;
					te[i]++;
				}
				else{
					table = te[i];
					te[i] = 0;
				}
				i++;
				if(i==n){
					i = 0;
				}
			}
			System.out.println(i);
		}
	}
}

Measured memory_bytes: 18740
# -*- coding: utf-8 -*-
H, W, A, B = map(int, input().split(' '))
row1 = [1 for _ in range(A)] + [0 for _ in range(W-A)]
row2 = [0 for _ in range(A)] + [1 for _ in range(W-A)]

table = [list(row1) for _ in range(B)] + [list(row2) for _ in range(H - B)]
for row in table:
    print(''.join(map(str, row)))







Measured memory_bytes: 50268
#include<bits/stdc++.h>
#include<queue>
using namespace std;
struct node{
	double x,y,c;
}a[100];
int n,k;
double f(double l,double r)
{
	if(l+0.0000000001>r)
	{
		return (l+r)/2;
	}
	double m=(l+r)/2;
	queue<pair<double,double> > que;
	for(int i=0;i<n;i++)
	{
		que.push(make_pair(a[i].x,a[i].y));
	}
	for(int i=0;i<n;i++)
	{
		for(int j=i+1;j<n;j++)
		{
			double x1=a[i].x,y1=a[i].y,r1=m/a[i].c;
			double x2=a[j].x,y2=a[j].y,r2=m/a[j].c;
			double dx=x2-x1,dy=y2-y1;
			double a=dx*dx+dy*dy;
			double b=((r1*r1-r2*r2)/a+1)/2;
			double d=r1*r1/a-b*b;
			if(d>=0)
			{
				d=sqrt(d);
				double x3=x1+dx*b;
				double y3=y1+dy*b;
				double x4=-dy*d;
				double y4=dx*d;
				que.push(make_pair(x3-x4,y3-y4));
				que.push(make_pair(x3+x4,y3+y4));
			}
		}
	}
	int nu=0;
//	printf("%lf \n",m);
	while(que.size()!=0)
	{
		pair<double,double> p=que.front();
//		printf("%lf %lf\n",p.first,p.second);
		que.pop();
		int nq=0;
		for(int i=0;i<n;i++)
		{
			double r=m/a[i].c;
			double dx=p.first-a[i].x;
			double dy=p.second-a[i].y;
			if(dy*dy+dx*dx-r*r<=0.0000001)
			{
				nq++;
			}
		}
		nu=max(nu,nq);
	}
	if(nu>=k)
	{
		return f(l,m);
	}
	else
	{
		return f(m,r);
	}
}
int main(void)
{
	scanf("%d%d",&n,&k);
	for(int i=0;i<n;i++)
	{
		scanf("%lf%lf%lf",&a[i].x,&a[i].y,&a[i].c);
	}
	if(k==1)
	{
		printf("0");
	}
	else
	{
		printf("%.10lf",f(0,1e6*1.0));
	}
}

Measured memory_bytes: 384
#define _USE_NATH_DEFINES
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <complex>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <limits>
#include <climits>
#include <cfloat>
#include <functional>
#include <iterator>
#include <random>
#include <tuple>


using namespace std;
#define REP(i,m,n) for(int i=(int)m ; i < (int) n ; ++i )
#define rep(i,n) REP(i,0,n)
using ll = long long;
#define EPS 1e-9
const int INF = 1050000000;
const long long LINF = 1LL << 60;
const ll MOD = 1e9 + 7;
const int MINF = -1050000000;

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; }

const int mod = 1000000007;
struct mint {
	ll x; // typedef long long ll;
	mint(ll x = 0) :x((x%mod + mod) % mod) {}
	mint operator-() const { return mint(-x); }
	mint& operator+=(const mint a) {
		if ((x += a.x) >= mod) x -= mod;
		return *this;
	}
	mint& operator-=(const mint a) {
		if ((x += mod - a.x) >= mod) x -= mod;
		return *this;
	}
	mint& operator*=(const mint a) {
		(x *= a.x) %= mod;
		return *this;
	}
	mint operator+(const mint a) const {
		mint res(*this);
		return res += a;
	}
	mint operator-(const mint a) const {
		mint res(*this);
		return res -= a;
	}
	mint operator*(const mint a) const {
		mint res(*this);
		return res *= a;
	}
	mint pow(ll t) const {
		if (!t) return 1;
		mint a = pow(t >> 1);
		a *= a;
		if (t & 1) a *= *this;
		return a;
	}

	// for prime mod
	mint inv() const {
		return pow(mod - 2);
	}
	mint& operator/=(const mint a) {
		return (*this) *= a.inv();
	}
	mint operator/(const mint a) const {
		mint res(*this);
		return res /= a;
	}
};

ll mod_pow(ll x, ll n, ll mod) {
	ll res = 1;
	while (n > 0) {
		if (n & 1) res = res * x % mod;
		x = x * x % mod;
		n >>= 1;
	}
	return res;
}

mint choose(int n, int a) {
	mint x = 1, y = 1;
	rep(i, a) {
		x *= n - i;
		y *= i + 1;
	}
	return x / y;
}

int main() {
	ll n, a, b;
	cin >> n >> a >> b;

	mint ans = mod_pow(2, n, MOD);
	ans -= 1;
	ans -= choose(n, a);
	ans -= choose(n, b);
	cout << ans.x << endl;
	return 0;

}


Measured memory_bytes: 256
#include <stdio.h>
int main(){
	int x, y, z;

	if(scanf("%d", &x)== 1);
	if(scanf("%d", &y)== 1);
	z = 0;
	if (x == 1 && y == 1){
      z = z + 400000 + 300000 + 300000;
    }else{
	if(x == 3){
		z = z + 100000;
	}
    if(y == 3){
    	z = z + 100000;
	} 
    if (x == 2){
		z = z + 200000;
	}
    if(y == 2){
    	z = z + 200000;
	} 
    if (x == 1){
		z = z + 300000;
	}
    if(y == 1){
    	z = z + 300000;
	} 
    }
	printf("%d\n", z);
    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define int long long
#define rep(i,n) for(int i=0;i<n;++i)
#define all(a) a.begin(),a.end()
#define P pair<long long,long long>
#define double long double
using namespace std;
signed main(){
  int a,b;
  cin>>a>>b;
  int c=max(a+b,a-b);
  int d=max(c,a*b);
  cout<<d;
}

Measured memory_bytes: 256
from sys import stdin
input = stdin.readline

n = int(input())
a = [int(x) for x in input().split()]
b = [0] * 1000001
chk = [0] * 1000001
s = set(a)

for x in a:
    chk[x] += 1

for x in s:
    for y in range(x, 1000001, x):
        b[y] += 1

cnt = 0

for x in s:
    if b[x] == 1 and chk[x] == 1:
        cnt += 1

print(cnt)

Measured memory_bytes: 126828
//  cout << char(i+48) << endl;//なぜかaは47と得る時がある。+48で出力もaにできる。
//  cout << char(97) << endl;//アスキーコードでaを出力
// sort(b.begin(), b.end());//bという配列を小さい方からソート
// reverse(b.begin(), b.end());//bという配列をリターン
// 10桁でdouble出力するパターン１ 
// printf("%.10f\n", ma);
// 10桁でdouble出力するパターン２
//cout << fixed << setprecision(10);
//  cout << ma << endl;

/*01 02 03 12 13 23　と６回見ていくパターン 
for(int i=0;i<n-1;i++){
  for(int j=i+1;j<n;j++){
    }
  }
*///vector<vector<int>> data(3, vector<int>(4));//int型の2次元配列(3×4要素の)の宣言
//int64_t a;
//10のi乗pow(10, i);
/*string s; stringでの文字列を数字型に変える方法
  cin >> s;
  rep(i,s.size()-2) {
  int a= (s.at(i)-'0')*100 + (s.at(i+1)-'0')*10+ s.at(i+2) -'0';
    */
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int keisan(int n){
  int wa = 0;
  int cnt=4;
  while(n>0){
    wa += n%10 *pow(10,cnt);
    n /=10;
    cnt--;
  }
  return wa;
}

int main() {
  int a,b;
  int count = 0;
  cin >> a >> b;
  for(int i=a;i<=b;i++){
    int c = keisan(i);
    if(i==c)count++;
  }
  cout << count << endl;
}



Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
int main(){
  
  string S;
  cin >> S;
  int N;
  N = S.size();
  int A[N+1];
  A[0]=0;
  int div=1;
  for(int i=0;i<N;i++){
    A[i+1]=A[i];
    if(S[N-1-i]=='1') A[i+1] += div;
    else if(S[N-1-i]=='2') A[i+1] += 2*div;
    else if(S[N-1-i]=='3') A[i+1] += 3*div;
    else if(S[N-1-i]=='4') A[i+1] += 4*div;
    else if(S[N-1-i]=='5') A[i+1] += 5*div;
    else if(S[N-1-i]=='6') A[i+1] += 6*div;
    else if(S[N-1-i]=='7') A[i+1] += 7*div;
    else if(S[N-1-i]=='8') A[i+1] += 8*div;
    else A[i+1] += 9*div;
    A[i+1] %= 2019;
    div *= 10;
    div %= 2019;
  }
  
  long long Total=0;
  sort(A, A+N+1);
  for(int i=0;i<2019;i++){
    long long q;
    q = lower_bound(A, A+N+1, i+1) - lower_bound(A,A+N+1,i);
    Total += q*(q-1)/2;
  }
  cout << Total << endl;
  
  
}

Measured memory_bytes: 4484
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <set>
#include <map>

using namespace std;

int main()
{
    int C[11];
    int t[3];
    int lim;
    int sum;
    double ans;
    while(cin >> t[0] >> t[1] >> t[2])
    {
        for(int i=1;i<=10;++i) C[i] = 0;
        if(t[0] + t[1] >= 20) cout << "NO" << endl;
        C[t[0]] = 1; C[t[1]] = 1; C[t[2]] = 1;
        lim = 20 - t[0] - t[1];
        sum = min(lim,10);
        for(int i=0;i<3;++i){
            if(lim >= t[i]) --sum;
        }
        if(sum > 3) cout << "YES" << endl;
        else cout << "NO" << endl;
    }
}

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

#define INF 1 << 29
#define REP(i,n) for(int i=0; i<(int)(n); i++)
#define FOR(i,k,n) for(int i=(k);i<(int)(n);i++)

using namespace std;

typedef pair<int,int> pii;
typedef long long int ll;

void gen_sosuu(int sosuu[]){
  REP(i,100010){
    sosuu[i] = true;
  }
  sosuu[0] = false;
  sosuu[1] = false;
  sosuu[2] = true;
  FOR(i,2,sqrt(100000)+1){
    if(sosuu[i] == false) continue;
    for(int j = 2; i*j<=100000;j++){
      //printf("%d %d %d\n",i*j,i,j);
      sosuu[i*j] =false;
    }
  }
}

ll x;

int main(){
  scanf("%lld",&x);
  ll n = x/(5+6);
  if(x%(5+6)>6){
    printf("%lld\n",2*n+2);
  }else if(x%(5+6)==0){
    printf("%lld\n",2*n);
  }else{
    printf("%lld\n",2*n+1);
  }
}


Measured memory_bytes: 256
import java.math.*;
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		while(sc.hasNext()){
			int n=sc.nextInt();
			int arr[]=new int[n+1];
			int ans[]=new int[n+1];
			arr[1]=0;
			for(int i=2;i<=n;i++){
				arr[i]=sc.nextInt();
				ans[arr[i]]++;
			}
			for(int i=1;i<=n;i++){
				System.out.println(ans[i]);
			}
		}
	}
}

Measured memory_bytes: 62792
from sys import exit

def main():
    K = int(input())
    A, B = map(int, input().split())

    # for i in range(A, B + 1):
    #     if i % K == 0:
    #         print("OK")
    #         exit()

    # print("NG")

    if A % K == 0:
        print("OK")
        exit()
    
    if B // K > A // K:
        print("OK")
    else:
        print("NG")

if __name__ == '__main__':
    main()

Measured memory_bytes: 61832
import numpy as np

def list753(n):
    if n == 1:
        return np.array([3,5,7],dtype=np.int)
    else:
        prev = list753(n-1)
        return np.concatenate((10*prev+3,10*prev+5,10*prev+7))

def all_list753(n):
    return np.concatenate(tuple([list753(i) for i in range(1,n+1)]))

Nstr = input()
N = int(Nstr)
Nlen = len(Nstr)

candidates = all_list753(Nlen)
ans = 0

for c in candidates:
    if c > N:
        continue
    cstr = str(c)
    if '3' in cstr and '5' in cstr and '7' in cstr:
        ans += 1

print(ans)

Measured memory_bytes: 18896
#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 10;
char ch[N][2], res[N];
int n, x, y, _x, _y, a[3];
signed main() {
    scanf ("%d %d %d %d", &n, &a[0], &a[1], &a[2]);
    for (int i = 1; i <= n; ++i) scanf ("%s", ch[i]);
    if (a[0] + a[1] + a[2] == 0) return puts ("No"), 0;
    if (a[0] + a[1] + a[2] == 1) {
        for (int i = 1; i <= n; ++i) {
            x = ch[i][0] - 'A', y = ch[i][1] - 'A';
            if (!a[x] && !a[y]) return puts ("No"), 0;
            a[x] ^= 1, a[y] ^= 1;
            if (!a[x]) res[i] = y + 'A';
            else res[i] = x + 'A';
        } puts ("Yes");
        for (int i = 1; i <= n; ++i) putchar (res[i]), putchar ('\n');
        return 0;
    }
    x = ch[1][0] - 'A', y = ch[1][1] - 'A';
    if (!a[x] && !a[y]) return puts ("No"), 0;
    puts ("Yes");
    for (int i = 1; i <= n; ++i) {
        x = ch[i][0] - 'A', y = ch[i][1] - 'A';
        if (a[x] < a[y]) ++a[x], --a[y], putchar ('A' + x);
        else if (a[x] > a[y]) ++a[y], --a[x], putchar ('A' + y);
        else {
            _x = ch[i + 1][0] - 'A', _y = ch[i + 1][1] - 'A';
            if (x == _x || x == _y) ++a[x], --a[y], putchar ('A' + x);
            else ++a[y], --a[x], putchar ('A' + y);
        } putchar ('\n');
     }
     return 0;
}


Measured memory_bytes: 3996
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
int main()
{

    ll n;
    cin>>n;
    vector<ll>v(n);
    vector<ll>c(n);
    for(int i=0;i<n;i++)
    {
        cin>>v[i];
        c[i]=v[i];
    }
    sort(v.begin(),v.end());
    if(n==1)
    {
        cout<<"0"<<endl;
    }
    for(int i=0;i<n;i++)
    {
        if(c[i]==v[n-1])
        {
            cout<<v[n-2]<<endl;
        }
        else cout<<v[n-1]<<endl;
    }
}


Measured memory_bytes: 6412
#include <stdio.h>
int main(){
    int n, cont=0;
    scanf("%d", &n);
    int vet[n];
    for(int i = 0; i < n; ++i)
        scanf("%d", &vet[i]);

    for(int i = 0; i < n; ++i){
        if(i % 2==0){
            if(vet[i] % 2 != 0)
                cont++;
        }
    }
    printf("%d\n", cont);


    return 0;
}

Measured memory_bytes: 1732
# -*- coding: utf-8 -*-
"""
Created on Thu Sep 10 00:32:19 2020

@author: liang
"""

N = int(input())
d = dict()
for i in range(N):
    S = input()
    S = ''.join(sorted(list(S)))
    #print(S)
    if S in d.keys():
        d[S] += 1
    else:
        d[S] = 1

ans = 0
for n in d.values():
    ans += n*(n-1)//2
print(ans)

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

int main() {
 	int n, x, t;
  	cin >> n >> x >> t;

  	int cnt = 0;

  	int tot = 0;
    while(tot < n) {
		cnt += 1;
        tot += x;
    }

  	cout << cnt*t << endl;

}


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

int compare_int(const void *a,const void *b){
		long long A=*(long long*)a;
		long long B=*(long long*)b;
		if(A>B)return -1;
		if(A<B)return 1;
		return 0;
}

int main(){
		int x,y,z,k,i,j;
		long long a[1000],b[1000],c[1000],ab[3000000],aba[3000];
		scanf("%d%d%d%d",&x,&y,&z,&k);
		for(i=0;i<x;i++)scanf("%lld",&a[i]);
		for(i=0;i<y;i++)scanf("%lld",&b[i]);
		for(i=0;i<z;i++)scanf("%lld",&c[i]);
		qsort(a,x,sizeof(long long),compare_int);
		qsort(b,y,sizeof(long long),compare_int);
		qsort(c,z,sizeof(long long),compare_int);
		for(i=0;i<x;i++){
				for(j=0;j<y;j++){
						ab[i*y+j]=a[i]+b[j];
				}
		}
		qsort(ab,x*y,sizeof(long long),compare_int);
		for(i=0;i<k;i++)aba[i]=ab[i];
		for(i=0;i<k;i++){
				for(j=0;j<z;j++){
						ab[i*z+j]=aba[i]+c[j];
				}
		}
		qsort(ab,k*z,sizeof(long long),compare_int);
		for(i=0;i<k;i++)printf("%lld\n",ab[i]);
		return 0;
}


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

using namespace std;
using ll = long long;


int n;


void solve()
{
    ;
}

int main()
{
    cin >> n;
    
    solve();
    cout << (double)n * 3.1415926535897932 * 2.0 << endl;

    return EXIT_SUCCESS;
}


Measured memory_bytes: 3788
function Main(input: string) {
  const lines = input.split('\n');
  const params1 = lines[0].split(' ');

  const n = parseInt(params1[0]);
  const x = parseInt(params1[1]);
  const xs = lines[1].split(' ').map(x => parseInt(x));

  const euclid: (m: number, n: number) => number = (m, n) => {
    if (m < n) return euclid(n, m);
    if (n === 0) return m;
    return euclid(n, m % n);
  };

  const d =
    xs.map(a => Math.abs(a - x))
      .reduce(euclid);

  console.log(d);
}

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

Measured memory_bytes: 32168
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
int tameru[100];
int dasiire=0;
void ireru(int);
int nuku(void);

int main(){
  int a,b,c;
  char kazu[100];
  while(scanf("%s",kazu)!=EOF){
    if(strcmp(kazu,"+")==0){
    a=nuku();
    b=nuku();
    ireru(a+b);
    }
    else if(strcmp(kazu,"-")==0){
    a=nuku();
    b=nuku();
    ireru(b-a);
    }
    else if(strcmp(kazu,"*")==0){
    a=nuku();
    b=nuku();
    ireru(a*b);
    }
    else {
      c=atoi(kazu);
      ireru(c);
    }
  }
  printf("%d\n",tameru[0]);
  return 0;
}


void ireru(int a){
  tameru[dasiire]=a;
  dasiire++;
}
int nuku(){
  dasiire--;
  return tameru[dasiire];
}

Measured memory_bytes: 548
N,K=map(int,input().split())
res=[0]*K
for i in range(1,N+1):
    res[i%K]=res[i%K]+1
#print(res)

if K%2==0:
    print(pow(res[K//2],3)+pow(res[0],3))
else:
    print(pow(res[0], 3))


Measured memory_bytes: 40048
#include <cstdio>
#include <iostream>
#include <sstream>
#include <cstring>
#include <algorithm>
#include <vector>
#include <string>
#include <map>
#include <set>

using namespace std;

#define rep(i,a,n) for(int (i)=a;(i)<(int)(n);(i)++)
#define rrep(i,a,n) for(int (i)=(n)-1;(i)>=a;(i)--)
#define all(x) (x).begin(),(x).end()

typedef long long ll;

const int INF = 1e9;

int main() {
	while (true) {
		int m,f,r;
		cin>>m>>f>>r;
		if(m==-1 and f==-1 and r==-1) return 0;
		if(m==-1 or f==-1) {
			cout<<"F"<<endl;	
		}else if(m+f>=80){
			cout<<"A"<<endl;
		}else if(m+f>=65){
			cout<<"B"<<endl;
		}else if(m+f>=50 or (m+f>=30 and r>=50)){
			cout<<"C"<<endl;
		}else if(m+f>=30){
			cout<<"D"<<endl;
		}else{
			cout<<"F"<<endl;
		}
	}    
}

Measured memory_bytes: 3084
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define IOS                      \
    ios::sync_with_stdio(false); \
    cin.tie(0)

// *start on @date: 2020-05-10 20:04

int main()
{
    IOS;
    string s1, s2;
    cin >> s1 >> s2;
    int i;
    for (i = 0; i < s1.size(); i++)
    {
        if (s1[i] != s2[i])
            break;
    }
    if (i == s1.size() && s2.size() - 1 == s1.size() && s2[i] >= 'a' && s2[i] <= 'z')
        cout << "Yes";
    else
        cout << "No";
    return 0;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
using pint = pair<int,int>;
ll mod = 1000000007;
int dx[8] = {1,0,-1,0,1,1,-1,-1};
int dy[8] = {0,1,0,-1,1,-1,1,-1};
void chmin(long long &a, long long b) { if (a > b) a = b; }
const long long INF = 1LL<<60;
ll gcd(ll a,ll b){
    if(b == 0) return a;
    else return gcd(b,a%b);
}
ll lcm(ll a,ll b){
    ll g = gcd(a,b);
    return (a/g*b);
}
int main() {
    string x,y;
    cin >> x >> y;
    if(x < y) cout << "<" << endl;
    else if(x > y) cout << ">" << endl;
    else cout << "=" << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define put(i) cout<<fixed<<i<<endl
using namespace std;
using ll = long long;

int main(){
    ll w, h, n; cin >> w >> h >> n;
    vector<ll> x(n), y(n), a(n);
    rep(i,n) cin >> x[i] >> y[i] >> a[i];

    ll x1, x2, y1, y2;

    x1 = y1 = 0;
    x2 = w;
    y2 = h;

    rep(i,n){
        switch (a[i]){  
        case 1:
            x1 = max(x1, x[i]);
            break;
        case 2:
            x2 = min(x2, x[i]);
            break;
        case 3:
            y1 = max(y1, y[i]);
            break;
        case 4:
            y2 = min(y2, y[i]);
            break;
        }
    }

    if((x2 - x1) < 0 or (y2 - y1) < 0) put(0);
    else put(max(0LL, (x2 - x1) * (y2 - y1)));
}

Measured memory_bytes: 3596
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <map>
#include <queue>
#include <iomanip>
#include <set>
#include <tuple>
#define mkp make_pair
#define mkt make_tuple
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
const ll MOD=1e9+7;

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

  if((B-A)%2==0) cout<<(B-A)/2<<endl;
  else{
    ll ans=N;
    ans=min(ans,A-1+1+(B-A-1)/2);
    ans=min(ans,N-B+1+(B-A-1)/2);
    cout<<ans<<endl;
  }

  return 0;
}


Measured memory_bytes: 256
def solve(n, d, l, r)
    return $h[r] if $h.has_key?(r)
    max = 0
    n.times do |i|
        if r & d[i] == d[i]
            ret = l[i] + solve(n, d, l, r - d[i]) 
            max = ret if ret > max
        end
    end
    return $h[r] = max
end
loop do
    $h = Hash.new
    n = gets.to_i
    break if n == 0
    d = Array.new(n, 0)
    l = Array.new(n)
    n.times do |p|
        m, l[p] = gets.split.map(&:to_i)
        m.times do
            t = gets.split.map(&:to_i)
            for i in ((t[0] - 6)...(t[1] - 6))
                d[p] += 1 << i
            end
        end
    end
    p solve(n, d, l, (1 << 16) - 1)
end

Measured memory_bytes: 10004
import java.util.*;

public class Main{
  public static void main(String[] args){
    Scanner scan = new Scanner(System.in);
    int n = scan.nextInt();
    int[] a = new int[n];
    for (int i=0;i<n;i++){
      a[i] = scan.nextInt();
    }

    int count = 0;
    int sum = 0;
    for (int j=0;j<n-1;j++){
      if (a[j] >= a[j+1]){
        sum += 1;
      }
      else{
        if (count < sum){
          count = sum;
        }
        sum = 0;
      }
    }
    if (sum > count){
      count = sum;
    }
    System.out.println(count);

  }
}


Measured memory_bytes: 59580
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin >> N;
  
  vector<int>a(N);
  for (int i = 0; i < N; i++) {
    cin >> a.at(i);
  }
  
  int over = 0;
  vector<int>count(100000,0);
  for (int i = 0; i < N; i++) {
    if (a.at(i) > N){
      over++;
    }
    else {
      count.at(a.at(i)-1)++;
    }
  }
  
  for (int i = 0; i < 100000; i++) {
    if (count.at(i) > i+1){
      over += count.at(i) - i - 1;
    }
    else if (count.at(i) != 0 && count.at(i) < i+1){
      over += count.at(i);
    }
  }
  cout << over << endl;
}
  
  
 

  

Measured memory_bytes: 4040
#include<stdio.h>
int main(void){
    int a,b,c,i = 0,ans = 0;
    scanf("%d %d %d",&a,&b,&c);
    
    while(ans < c){
        i++;
        ans += a;
        if(i % 7 == 0)  ans += b;
    }
    printf("%d\n",i);
    return 0;
}


Measured memory_bytes: 2120
#include<bits/stdc++.h>
#define pb           push_back
#define pii          pair<int,int>
#define vi           vector<int>
#define vpii         vector<pair<int,int>>
#define gph          map<int, vector<int>>
#define mp           make_pair
#define FOR(i, n) for (int i = 0; i <  (int)(n); i++)
#define FOR1(i, n) for (int i = 1; i <= (int)(n); i++)
#define FORD0(i, n) for (int i = (int)n; i >= 0; i--)
#define FORD1(i, n) for (int i = (int)n; i >= 1; i--)
#define FORS(i, n) for(; i < (int)(n); i++)
#define debug(X) { cout << #X << " = " << (X) << endl; }
#define printArr(A,n) { cout << #A << " = "; FOR(i,n) cout << A[i] << ' '; cout << endl; }
using namespace std;
#define int long long int
const int lim = (int)2e5 + 5;
vector<int> adj[(int)2e5 + 10];
vector<int> adj2[(int)2e5 + 10];
vi ro(lim), ri(lim);
vector<bool> vis(lim);
void dfs(int cur, int comp, vi * arr, vi & c){
    if(vis[cur])return;
    vis[cur] =true;
    c[cur] = comp;
    for(int child: arr[cur]){
        dfs(child, comp, arr, c);
    }
}
signed main(){
    ios_base::sync_with_stdio(false);cin.tie(NULL);
    
    int n, roads, rails;cin >> n >> roads >> rails;
    int x, y;
    FOR(i, roads){
       cin >> x >> y;
      adj[x].pb(y);
      adj[y].pb(x); 
    }
    FOR(i, rails){
        cin >> x >> y;
        adj2[x].pb(y);
        adj2[y].pb(x);
    }
    
    int cnt = 1;
    FOR1(i, n){
        ro[i] = lim*2 + i;
        ri[i] = lim*4 + i;
    }
    FOR1(i, n){
        if(!vis[i])dfs(i, cnt, adj, ro), cnt++;
        //cout << ro[i] << endl;
    }
    FOR1(i, n)vis[i] = false;
    FOR1(i, n){
        if(!vis[i])dfs(i, cnt, adj2, ri), cnt++;
        //cout << ri[i] << endl;
    }
    map<pii, int> ans;
    FOR1(i, n){
        ans[mp(ro[i], ri[i])]++;
    }
    FOR1(i, n){
        cout << ans[mp(ro[i], ri[i])] << " ";
    }

}




Measured memory_bytes: 30464