akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <map>
using namespace std;

const int divisor = 1000000007;

int main(){
	// 100000!までの数をdivisorで割った余りを格納しておく
	long long* factmodary = new long long[100001];
	long long fact = 1;
	for (int i = 1; i <= 100000; i++){
		fact *= i;
		fact %= divisor;
		factmodary[i] = fact;
	}

	int* word = new int[100000] {0};

	for (;;){
		int N, R;
		cin >> N;
		if (N == 0) break;
		cin >> R;
		
		//まず0番目の単語を入れておく
		for (int i = 0; i < N; i++) word[i] = i + 1;

		for (int i = 0; i < R; i++){
			int s, t;
			cin >> s >> t;
			/* swap */
			int tmp = word[s - 1]; word[s - 1] = word[t - 1]; word[t - 1] = tmp;
		}

		//word[i]をkey, word[i]より小さい数がそれ以前にいくつ使われていたかをvalueとして格納するmap
		map<int, int> bubblehist;
		bubblehist[word[0]] = 0;

		long long ans = factmodary[N-1] * (word[0] - 1);

		for (int i = 1; i < N; i++){
			int facttime = word[i] - 1;
			int bubblenum;
			map<int, int>::iterator it = bubblehist.lower_bound(word[i]);

			if (it != bubblehist.end()){
				bubblenum = it->second;
				it--;
			}
			else {
				it--;
				bubblenum = it->second + 1;
			}
			pair<int, int> p;
			p.first = word[i];
			p.second = bubblenum;
			map<int, int>::iterator it2 = bubblehist.insert(it, p);
			//word[i]より大きい数はすべてvalueが1増える
			for (++it2; it2 != bubblehist.end(); it2++) (it2->second)++;

			facttime -= bubblenum;
			ans += factmodary[N - (i + 1)] * facttime;
		}
		cout << ans % divisor << "\n";
	}

	delete[] word;
	delete[] factmodary;
	return 0;
}

Measured memory_bytes: 6816
/* ****revpro**** */
#include<bits/stdc++.h>
#define ll          long long
#define pb          push_back
#define endl       '\n'
#define pii         pair<ll,ll>
#define vi          vector<ll>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (ll)x.size()
#define hell        1000000007
#define rep(i,a,b)  for(ll i=a;i<b;i++)
#define repr(i,a,b) for(ll i=b-1;i>=a;i--)    
#define lbnd        lower_bound
#define ubnd        upper_bound
#define bs          binary_search
#define mp          make_pair
#define present(c,x) ((c).find(x) != (c).end())
#define cpresent(c,x) (find(all(c),x) != (c).end())
#define mii        map<ll,ll>
using namespace std;

bool isPrime(ll N) {
    if(N<2)return false;
    if(N<4)return true;
    if((N&1)==0)return false;
    if(N%3==0)return false;
    ll curr=5;
    while (curr<=sqrt(N)){
        if(N%curr==0)return false;
        curr+=2;
        if(N%curr==0)return false;
        curr+=4;
    }
    return true;
}
signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    
    int TESTS=1;
//    cin>>TESTS;
    while(TESTS--)
    {
        ll x;
        cin>>x;
        rep(i,x,hell){
            if(isPrime(i)){
                cout<<i;
                return 0;
            }
        }
    }
    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include<iostream>
#include<stdio.h>
#include <algorithm>
#include<iostream>
#include<stdio.h>
#include<vector>
#include<set>
#include<string>
#include <iomanip>
#define rep(i,n) for(int i=0; i<(int)n; i++)//n回繰り返す
using namespace std;
using ll = long long;
using P = pair<int, int>;
int main() {
	int N, K; cin >> N >> K;
	vector<double> P(N); 
	rep(i, N) {
		double p; cin >> p;
		P[i] = (p+1)/2;
	}
	vector<double> S(N + 1,0);
	rep(i, N) {
		S[i + 1] = S[i] + P[i];
	}
	 double M = 0,w;

	rep(i,N-K+1){
		w = S[i + K] - S[i];
		M = max(M, w);
	}
	cout << fixed << setprecision(10) << M << endl;
	
}

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

using ll=long long;
const int inf=100000000;

int in(){
  int a;
  cin >> a;
  return a;
}//int型関数の受け取り

void forin(int* x,int y){
  for (int i=0;i<y;i++){
    cin >> x[i];
  }
}//(x,y) int型配列x[y]の受け取り

int intpow(int x,int y){
  double a=x,b=y;
  return pow(a,b);
}//(x,y) xをy乗

int intfabs(int x){
  double a=x;
  return fabs(a);
}//(x) xの絶対値

int fact(int x){
  if (x == 1) return 1;
  return x*fact(x-1);
}//(x) x!

int fib(int x){
  if (x <= 2) return x;
  int a[x];
  a[0]=1;
  a[1]=2;
  for (int i=2;i<x;i++){
    a[i]=a[i-1]+a[i-2];
  }
  return a[x-1];
}//(x) フィボナッチ数列のx番目

int div1(ll x){
  return x%1000000007;
}

main(){
    double w=in(),h=in(),x=in(),y=in();
    cout << fixed << setprecision(9) << w*h/2 << ' ';
    if (x==w/2 && y==h/2) cout << '1' << endl;
    else cout << '0' << endl;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
const long long lim = 1000000000;
int main() {
	long long S;
	cin >> S;
	if (S != lim * lim) {
		cout << 0 << ' ' << 1 << ' ' << lim << ' ' << 0 << ' ' << S % lim << ' ' << S / lim + 1 << endl;
	}
	else {
		cout << 0 << ' ' << 0 << ' ' << lim << ' ' << 0 << ' ' << 0 << ' ' << lim << endl;
	}
	return 0;
}

Measured memory_bytes: 256
# https://atcoder.jp/contests/abc061/tasks/abc061_b

n, m = map(int, input().split())

graph = [0] * n
for _ in range(m):
    a, b = map(int, input().split())
    a -= 1
    b -= 1
    graph[a] += 1
    graph[b] += 1

for g in graph:
    print(g)


Measured memory_bytes: 38396
#include<bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < n; i++)
#define vi vector<int>
#define all(x) (x).begin(),(x).end()
#define INF 1e9
using ll = long long;
using namespace std;
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; }

int main(){
  int n,c,k; cin >> n >> c >> k;
  vi t(n); rep(i,n) cin >> t[i];

  int ans = 0, cnt = 0, j = 0;
  sort(all(t));
  rep(i,n){
    if(c == cnt || t[j]+k < t[i]){
      cnt = 0;
      j = i;
      ans++;
    }
    cnt++;
  }
  cout << ans+1;
  cout << "\n";
  return 0;
}


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

int main() {
  char b;
  cin >> b;

  if (b == 'A') {
    cout << "T" << endl;
  }
  if (b == 'T') {
    cout << "A" << endl;
  }
  if (b == 'C') {
    cout << "G" << endl;
  }
  if (b == 'G') {
    cout << "C" << endl;
  }
}

Measured memory_bytes: 256
import math
a,b,x = map(int,input().split())
deep = x/a**2
if deep >= b/2:
    tan = (b-deep)/(a/2)
    ans = (math.atan(tan))*180/math.pi
else:
    tan = b/((2*x)/(a*b))
    ans = (math.atan(tan))*180/math.pi
print(ans)

Measured memory_bytes: 3060
#include<cstdio>

int main(){
	double x[4], y[4];
	int xi[4], yi[4];
	while(1 + scanf("%lf %lf %lf %lf %lf %lf %lf %lf", &x[0],&y[0],&x[1],&y[1],&x[2],&y[2],&x[3],&y[3])){
		for(int j = 0; j < 4; j++){
 			xi[j] = (int)(x[j] * 1000000);
			yi[j] = (int)(y[j] * 1000000);
		}

		if((yi[0] - yi[1])*(yi[2] - yi[3]) == -(xi[0] - xi[1])*(xi[2] - xi[3])){
			printf("YES\n");
		}else{
			printf("NO\n");
		}
	}
	return 0;
}

Measured memory_bytes: 1040
import java.io.IOException;
import java.io.InputStream;
import java.util.NoSuchElementException;

public class Main {

	public static void main(String[] args) {
		FScanner sc = new FScanner();
		String S = sc.next();
		if ("Sunny".equals(S)) {
			System.out.println("Cloudy");
		} else if ("Cloudy".equals(S)) {
			System.out.println("Rainy");
		} else {
			System.out.println("Sunny");
		}

	}

}

class FScanner {
	private final InputStream in = System.in;
	private final byte[] buffer = new byte[1024];
	private int ptr = 0;
	private int buflen = 0;

	private boolean hasNextByte() {
		if (ptr < buflen) {
			return true;
		} else {
			ptr = 0;
			try {
				buflen = in.read(buffer);
			} catch (IOException e) {
				e.printStackTrace();
			}
			if (buflen <= 0) {
				return false;
			}
		}
		return true;
	}

	private int readByte() {
		if (hasNextByte())
			return buffer[ptr++];
		else
			return -1;
	}

	private static boolean isPrintableChar(int c) {
		return 33 <= c && c <= 126;
	}

	public boolean hasNext() {
		while (hasNextByte() && !isPrintableChar(buffer[ptr]))
			ptr++;
		return hasNextByte();
	}

	public String next() {
		if (!hasNext())
			throw new NoSuchElementException();
		StringBuilder sb = new StringBuilder();
		int b = readByte();
		while (isPrintableChar(b)) {
			sb.appendCodePoint(b);
			b = readByte();
		}
		return sb.toString();
	}

	public long nextLong() {
		if (!hasNext())
			throw new NoSuchElementException();
		long n = 0;
		boolean minus = false;
		int b = readByte();
		if (b == '-') {
			minus = true;
			b = readByte();
		}
		if (b < '0' || '9' < b) {
			throw new NumberFormatException();
		}
		while (true) {
			if ('0' <= b && b <= '9') {
				n *= 10;
				n += b - '0';
			} else if (b == -1 || !isPrintableChar(b)) {
				return minus ? -n : n;
			} else {
				throw new NumberFormatException();
			}
			b = readByte();
		}
	}

	public int nextInt() {
		long nl = nextLong();
		if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE)
			throw new NumberFormatException();
		return (int) nl;
	}

	public double nextDouble() {
		return Double.parseDouble(next());
	}
}

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

int main() {
    int n, m, l;
    cin >> n >> m >> l;
    long mt1[n][m];

    for (int i = 0; i < n; i++) {
        for (int j = 0; j < m; j++) {
            cin >> mt1[i][j];
        }
    }

    long mt2[m][l];
    for (int i = 0; i < m; i++) {
        for (int j = 0; j < l; j++) {
            cin >> mt2[i][j];
        }
    }

    long mt;
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < l; j++) {
            mt = 0;
            for (int k = 0; k < m; k++) {
                mt += (mt1[i][k] * mt2[k][j]);
            }
            if (j < l - 1) {
                cout << mt << " ";
            }
            else {
                cout << mt << endl;
            }
        }
    }
}


Measured memory_bytes: 3256
#include<iostream>
using namespace std;
 
int main() {
	string N;
	cin >> N;
	int rem = 0;
	for (int i = 0; i < N.length(); i++) {
		rem += (N[i] - '0');
		rem = rem % 9;
	}
	if (rem == 0) {
		cout << "Yes";
	}
	else {
		cout << "No";
	}
 
}

Measured memory_bytes: 3720
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <cstring>
#include <sstream>
#include <cassert>
#include <list>
using namespace std;
static const double EPS = 1e-10;
typedef long long ll;
typedef pair<int,int> PI;
typedef vector<int> vi;
#ifndef M_PI
#define M_PI 3.14159265358979323846
#endif
#define rep(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
#define mp(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define F first
#define S second


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

typedef struct _mulnum{
  string number;
  bool operator<(const _mulnum&r)const{
    if(number.size()!=r.number.size())return number.size()<r.number.size();

    rep(i,number.size()){
      if(number[i]!=r.number[i])return number[i]<r.number[i];
    }
    return 0;
  };
  _mulnum operator+(const char&r){
    _mulnum ret=*this;
    ret.number+=r;
    return ret;
  }
}mulnum;


main(){
  int w,h;
  while(cin>>w>>h,w|h){
    char in[h][w+2];
    rep(i,h)cin>>in[i];
    mulnum dp[h][w];

    mulnum ans;

    rep(i,h){
      rep(j,w){
	if(isdigit(in[i][j])){
	  if(in[i][j]!='0')dp[i][j].number+=in[i][j];
	  if(i && (dp[i-1][j].number.size() || in[i][j]!='0')){
	    dp[i][j]=max(dp[i-1][j]+in[i][j],dp[i][j]);
	  }
	  if(j && (dp[i][j-1].number.size() || in[i][j]!='0')){
	    dp[i][j]=max(dp[i][j-1]+in[i][j],dp[i][j]);
	  }
	}
	ans=max(ans,dp[i][j]);
      }
    }
    cout<<ans.number<<endl;
  }
}
	    

Measured memory_bytes: 0
#include<bits/stdc++.h>
using namespace std;
#define inf 1000000000
#define INF 1000000000000000
#define ll long long
#define ull unsigned long long
#define M 1000000007
#define P pair<int,int>
#define PLL pair<ll,ll>
#define FOR(i,m,n) for(int i=(int)m;i<(int)n;i++)
#define RFOR(i,m,n) for(int i=(int)m;i>=(int)n;i--)
#define rep(i,n) FOR(i,0,n)
#define rrep(i,n) RFOR(i,n,0)
#define all(a) a.begin(),a.end()
#define IN(a,n) rep(i,n){ cin>>a[i]; }
const int vx[4] = {0,1,0,-1};
const int vy[4] = {1,0,-1,0};
#define PI 3.14159265
#define F first
#define S second
#define int ll

string s,t;

signed main(){
  cin>>s>>t;
  
  rep(i,s.size()+1){
    if(s==t){
      cout<<"Yes"<<endl;
      return 0;
    }
    string u = s;
    rep(i,s.size()){
      s[i] = u[(i-1+s.size())%s.size()];
    }
  }

  cout<<"No"<<endl;
}

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

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

using namespace std;
using ll = long long int;

int main(void) {
    int n, k;
    cin >> n >> k;
    vector<bool> a(n, false);
    rep(i, k) {
        int d; cin >> d;
        rep(j, d) {
            int t; cin >> t;
            t--;
            a[t] = true;
        }
    }
    int cnt = 0;
    rep(i, n) if (a[i] == false) cnt++;
    cout << cnt << endl;
}

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

#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define intll int long long
const int INF = 1e9;
const int MOD = 1e9 + 7;

int main() {
  int a , b , c , k ;
  cin >> a >> b >> c >> k ;
  
  while(b <= a) {
    b *=2 ; 
    k-- ;
  }
  
  while(c <= b) {
    c *=2 ; 
    k-- ;
  }
  
  if(k < 0) cout << "No"  ; 
  else      cout << "Yes" ;
  
 
}


Measured memory_bytes: 3620
import sys

sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep="\n")
def II(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def SI(): return sys.stdin.readline()[:-1]

n=II()
aa=LI()
ans=0
for i,a in enumerate(aa,1):
    if i&1 and a&1:ans+=1
print(ans)

Measured memory_bytes: 9176
package main

import "fmt"

func main() {
	var n, m, k int
	fmt.Scan(&n, &m, &k)

	for i := 0; i <= n; i++ {
		for j := 0; j <= m; j++ {
			if n*j+m*i-2*i*j == k {
				fmt.Println("Yes")
				return
			}
		}
	}
	fmt.Println("No")
}


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

#define ll long long
#define vll vector<ll>
#define vvll vector<vll>
#define rep(i, n) for(i = 0; i < n; i++)

int main(){
    vector<bool> isprime(100010, true);
    vll count(100010, 0);

    isprime[0] = false;
    isprime[1] = false;

    for (int i = 2; i < 100010; i++){
        count[i] = count[i-1];
        if (isprime[i]) {
            if (i != 2 && isprime[(i+1)/2]){
                count[i]++;
            }
            for (int j = 2*i; j < 100010; j += i){
                isprime[j] = false;
            }
        }
    }

    ll Q;
    ll l, r;
    cin >> Q;
    int i;
    rep(i, Q){
        cin >> l >> r;
        cout << count[r] - count[l-1] << '\n';
    }


    return 0;
}

Measured memory_bytes: 3860
public class Main {
  public static void main(String[] args) {
    java.util.Scanner s = new java.util.Scanner(System.in);
    long a = s.nextLong();
    double b = s.nextDouble();

    System.out.println(java.math.BigDecimal.valueOf(a).multiply(java.math.BigDecimal.valueOf(b)).longValue());
  }
}


Measured memory_bytes: 37240
#include <algorithm>
#include <array>
#include <bitset>
#include <cstdint>
#include <deque>
#include <functional>
#include <iostream>
#include <limits>
#include <memory>
#include <numeric>
#include <unordered_set>
#include <unordered_map>
#include <vector>

// constexpr std::int64_t INF = 1ull << 50;
constexpr int INF = 1 << 20;

auto main() -> int {
  int A, B;
  std::cin >> A >> B;

  if (A >= 13) {
    std::cout << B << std::endl;
  } else if (A <= 5) {
    std::cout << 0 << std::endl;
  } else {
    std::cout << (B / 2) << std::endl;
  }
}


Measured memory_bytes: 888
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  char s1, s2, s3, t1, t2, t3;
  int ans;
  cin >> s1 >> s2 >> s3 >> t1 >> t2 >> t3;
  ans = 0;
  if (s1 == t1) {
    ans++;
  }
  if (s2 == t2) {
    ans++;
  }
  if (s3 == t3) {
    ans++;
  }
  cout << ans << endl;
}

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

int main() {
  int N;
  cin >> N;
  if (N%10==3)
    cout << "bon"<<endl;
  else if (N%10==0||N%10==1||N%10==6||N%10==8)
    cout<<"pon"<<endl;
  else
    cout<<"hon"<<endl;
}

Measured memory_bytes: 3632
#include <stdio.h>
int n,c[510],s[510],f[510],*d=c,*t=s,*g=f,i;int main(){scanf("%d",&n);for(;d<c+n-1;++d,++t,++g)scanf("%d%d%d",d,t,g);++(*g=*d=*t=0);for(;i<n;)for(int a=0,j=i++;j<n||!printf("%d\n",a);)a=(a<s[j]?s[j]:(a/f[j]+(a%f[j]!=0))*f[j])+c[j++];}

Measured memory_bytes: 128
/*
  A - Haiku
  <http://abc051.contest.atcoder.jp/tasks/abc051_a>
*/

#include <stdio.h>

int main(int argc, char const *argv[]) {

  char s[20];

  scanf("%s", s);
  s[5] = ' ';
  s[13] = ' ';
  printf("%s", s);

  return 0;
}


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

int main() {
  
  int s1s2s3;
  
  cin >> s1s2s3;
  
  cout << s1s2s3 / 100 + (s1s2s3 % 100) / 10 + s1s2s3 % 2 << endl;
}

Measured memory_bytes: 3592
N,A,B=map(int,input().split())

minimum=min(A,B)
maximum=max(A,B)

a=max(A,B)-1
b=N-min(A,B)
c=(max(A,B)-min(A,B))//2+(max(A,B)-min(A,B))%2+min(min(A,B)-1,N-max(A,B))
d=(max(A,B)-min(A,B))//2

if((B-A)%2!=0):
    print(min(a,b,c))
else:
    print(min(a, b, c,d))

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

int main(){
  string S,T;
  cin >> S >> T;
  
  int count = 0;
  for(int i=0;i<3;i++){
    if(S.at(i) == T.at(i)){
    count++;
  }
  }
    
  cout << count << endl;
    
}

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

using namespace std;

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

#define rep(i,n) for(int i=0;i<(n);++i)
#define repi(i,a,b) for(int i=int(a);i<(b);i++)
#define repr(i,b,a) for(int i=int(b);i>=(a);i--)
#define all(x) x.begin(),x.end()

const ll mod = 1e9+7;
const ll INF = 1e9;

ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
bool valid(int lx,int ux,int ly,int uy,int x,int y){
	return lx<=x&&x<ux&&ly<=y&&y<uy; 
}
ll power(ll x,ll p){
	if(p==0)return 1;
	ll res=power(x*x%mod,p/2);
	if(p%2==1)res=res*x%mod;
	return res;
}

int main()
{
	ll n,k;
	cin>>n>>k;
	vector<ll> h(n);
	rep(i,n)cin>>h[i];
	sort(all(h));
	reverse(all(h));

	rep(i,min(n,k))h[i]=0;
	cout<<accumulate(all(h),0LL)<<endl;

	return 0;
}

Measured memory_bytes: 1920
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Console;
using System.Text;
using System.IO;
using static System.Math;
using System.Numerics;
using System.Runtime.InteropServices.ComTypes;

namespace AtCoder
{
    public class Program
    {
        public static void Main(string[] args)
        {
            //SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
            Solve();
            //Out.Flush();
            Read();
        }

        static void Solve()
        {
            var N = Sarray()[0];
            var sum = 0d;
            for (var i = 0; i < N; ++i)
            {
                var (x, u) = Slice<double, string>();
                if (u == "BTC")
                    sum += x * 380000;
                else
                    sum += x;
            }
            WriteLine(sum);
        }

        static long Mod = 998244353;
        static public long[] Sarray() { return ReadLine().Split().Select(long.Parse).ToArray(); }
        static public List<long> Slist() { return ReadLine().Split().Select(long.Parse).ToList(); }
        static public (T1 a, T2 b) Slice<T1, T2>()
        {
            var t = ReadLine().Split();
            return (
            (T1)Convert.ChangeType(t[0], typeof(T1)),
            (T2)Convert.ChangeType(t[1], typeof(T2)));
        }
        static public (T a, T b) Slice2<T>()
        {
            var t = ReadLine().Split();
            return (
            (T)Convert.ChangeType(t[0], typeof(T)),
            (T)Convert.ChangeType(t[1], typeof(T)));
        }
        static public (T a, T b, T c) Slice3<T>()
        {
            var t = ReadLine().Split();
            return (
            (T)Convert.ChangeType(t[0], typeof(T)),
            (T)Convert.ChangeType(t[1], typeof(T)),
            (T)Convert.ChangeType(t[2], typeof(T)));
        }
        static public (T a, T b, T c, T d) Slice4<T>()
        {
            var t = ReadLine().Split();
            return (
            (T)Convert.ChangeType(t[0], typeof(T)),
            (T)Convert.ChangeType(t[1], typeof(T)),
            (T)Convert.ChangeType(t[2], typeof(T)),
            (T)Convert.ChangeType(t[3], typeof(T)));
        }
    }
}

Measured memory_bytes: 28368
#include <algorithm>
#include <iomanip>
#include <iostream>
#include <queue>
#include <vector>
#define rep(i, n) for (ll i = 0; i < (n); i++)
typedef long long ll;
#define INF 1000000000000
using namespace std;

int main(void) {
  ios::sync_with_stdio(false);
  ll N, K;
  cin >> N >> K;
  vector<ll> A(N);
  rep(i, N) { cin >> A[i]; }
  sort(A.begin(), A.end());
  vector<ll> F(N);
  rep(i, N) { cin >> F[i]; }
  sort(F.begin(), F.end(), greater<ll>());
  ll left = 0;
  ll right = INF;
  while (left < right) {
    ll middle = left + (right - left) / 2;
    // cout << "l=" << left << " r=" << right << " m=" << middle << endl;
    ll tmpK = 0;
    bool flag = true;
    rep(i, N) {
      ll tmpA = middle / F[i];
      if (tmpA >= A[i]) continue;
      tmpK += max((ll)0, A[i] - tmpA);
      if (tmpK > K) {
        flag = false;
        break;
      }
    }
    if (flag) {
      right = middle;
    } else {
      left = middle + 1;
    }
  }
  cout << left << endl;
  return 0;
}


Measured memory_bytes: 3456
#define _CRT_SECURE_NO_WARNINGS
//#define _USE_MATH_DEFINES
#include<stdio.h>
//#include<stdlib.h>
//#include<math.h>
//#include<string.h>
//#include<time.h>
//#define pi acos(-1.0)
#define P(type,x) fprintf(stdout,"%"#type"\n",x)
#define S(type,x) fscanf(stdin,"%"#type,&x)
int main() {
	int a, b;
	while (fscanf(stdin, "%d%d", &a, &b), a, b)
		if (a*b % 2) puts("no");
		else puts("yes");
	return 0;
}

Measured memory_bytes: 588
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;++i)
#define all(x) (x).begin(),(x).end()
using namespace std;
const int INF=1145141919,MOD=1e9+7;
const int64_t LINF=8931145141919364364,LMOD=998244353;
// const int dy[]={0,-1,0,1,1,-1,-1,1};
// const int dx[]={1,0,-1,0,1,1,-1,-1};

int main() {
	string s; cin >> s;
	if(s[1] == 'B') {
		cout << "ARC" << '\n';
	} else {
		cout << "ABC" << '\n';
	}
	return 0;
}

Measured memory_bytes: 3628
#include <stdio.h>

int main(void) {
  int buildings[4][3][10] = {};
  int b, f, r, v, number, i, j, k;
  scanf(" %d", &number);
  for (i = 0; i < number; i++) {
    scanf(" %d %d %d %d", &b, &f, &r, &v);
    buildings[b-1][f-1][r-1] += v;
  }
  for (i = 0; i < 4; i++) {
    for (j = 0; j < 3; j++) {
      for (k = 0; k < 10; k++)
	printf(" %d", buildings[i][j][k]);
      printf("\n");
    }
    if (i != 3) {
      for (j = 0; j < 20; j++)
	printf("#");
      printf("\n");
    }
  }
  return 0;
}



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

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

const int mod =  1000000007;  //出力は (ans % mod + mod) % mod  (負の剰余を正にする)
const int inf = 1e9;
const long long INF = 1LL << 60;   // INF = 11

int main()
{
    int n; cin >> n;
    ll a[n];
    rep(i,n) cin >> a[i];
    vector<ll> v;
    ll sum = 0;
    rep(i,n){
        sum += a[i];
        sum %= mod;
    }
    ll ans = 0;
    for(int i = 0; i < n; i++){
        sum -= a[i];
        sum = (sum + mod*2) % mod;
        ans += a[i]*sum;
        ans %= mod;
    }
    cout << ans << endl;
}

Measured memory_bytes: 5180
#pragma gcc optimize("Ofast")
#include <bits/stdc++.h>

using namespace std;
using ll = long long;

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(V) (V).begin(),(V).end()
#define SORT(V) sort(ALL(V)) //小さい方からソート
#define REV(V) reverse(ALL(V)) //リバース
#define RSORT(V) SORT(V);REV(V) //大きい方からソート
#define NPN(V) next_permutation(ALL(V)) //順列
#define pb(n) push_back(n)
#define endl '\n'
#define Endl '\n'
#define DUMP(x)  cout << #x << " = " << (x) << endl
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define yes(n) cout << ((n) ? "yes" : "no"  ) << endl
#define Yay(n) cout << ((n) ? "Yay!": ":(") << endl
#define RAPID cin.tie(0);ios::sync_with_stdio(false)
#define VSUM(V) accumulate(ALL(V), 0)
#define MID(a,b,c) (a) < (b) && (b) < (c)
#define MIDe(a,b,c) (a) <= (b) && (b) <= (c)
#define IN(n) cin >> n
#define IN2(a,b) cin >> a >> b
#define IN3(a,b,c) cin >> a >> b >> c 
#define IN4(a,b,c,d) cin >> a >> b >> c >> d
#define VIN(V) for(int i = 0; i < (V).size(); i++) {cin >> (V).at(i);}
#define OUT(n) cout << n << endl
#define VOUT(V) REP(i, (V).size()) {cout << (V)[i] << endl;}
#define VOUT2(V) REP(i, (V).size()) {cout << (V)[i] << " ";} cout<<endl;
#define FIX cout << fixed << setprecision(15)

// 型マクロ定義
#define int long long
#define P pair<ll,ll>
#define Vi vector<ll>
#define VVi vector<vector<ll>>
#define Vd vector<double>
#define Vb vector<bool>
#define Vs vector<string>
#define Vc vector<char>
#define M map<ll,ll>
#define S set<ll>
#define PQ priority_queue<ll>
#define PQG priority_queue<ll,V,greater<ll>
//

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

const int MOD = 1000000007;
const int INF = 1061109567;
const double EPS = 1e-10;
const double PI  = acos(-1.0);

int gcd(int a,int b){return b != 0 ? gcd(b, a % b) : a;} //最大公約数
int lcm(int a, int b){return a * b / gcd(a, b);}
string toStrUp(string str){char diff = 'A'-'a';REP(i,str.size()) str[i] += diff;return str;}
string gCh(string str, int key){return str.substr(key,1);}

signed main() {
  RAPID;
  // デフォルト変数定義
  int n=0,m=0,a=0,b=0,c=0,d=0,x=0,y=0,z=0;
  string s="",t="";
  //

  // ここから
  IN(s);
  REP(i,s.size()){
    if(s[i]=='0') x++;
    else y++;
  }
  OUT(min(x,y)*2);
}

Measured memory_bytes: 512
# include <iostream>
# include <algorithm>
# include <vector>
# include <string>
# include <set>
# include <map>
# include <cmath>
# include <iomanip>
# include <functional>
# include <utility>
# include <stack>
# include <queue>
# include <list>
# include <bitset>
# include <complex>
#include<limits.h>
#include<unordered_map>
#include<unordered_set>
#include<deque>
#include<cstdio>
typedef long long int ll;
const int INF = 1 << 30;
using namespace std;
#define pp pair<int,int>
#define FOR(i,a,n) for(int i=(ll)a;i<(ll)n;++i)
#define TFOR(i,n)FOR(i,0,n)
#define ALL(x) x.begin(),x.end()
int main() {
	int Max=0, sum=0;
	TFOR(i, 3) {
		int n; cin >> n;
		Max = max(n,Max);
		sum += n;
	}
	cout << (sum - Max == Max ? "Yes" : "No") << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <string>
  
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
#define REP(i, n) for(int i=0; i<(n); ++i)
#define FOR(i, a, b) for(int i=(a); i<(b); ++i)
#define FORR(i, a, b) for(int i=(b)-1; i>=(a); --i)
typedef long long ll;

const ll MOD=1000000007ll;
const int MAX=5100000;

using namespace std;

int inputValue(){
    int a;
    cin >> a;
    return a;
};

void inputArray(int * p, int a){
    rep(i, a){
        cin >> p[i];
    }
};

void inputVector(vector<int> * p, int a){
    rep(i, a){
        int input;
        cin >> input;
        p -> push_back(input);
    }
}

ll fact[MAX], fact_inv[MAX];

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

// nCr
ll comb(ll n, ll r){
	ll t=1000000;
	fact[0]=1;
	REP(i, t) fact[i+1]=fact[i]*(i+1)%MOD;
	fact_inv[t]=power(fact[t], MOD-2);
	FORR(i, 0, t) fact_inv[i]=fact_inv[i+1]*(i+1)%MOD;
	return (fact[n]*fact_inv[r])%MOD*fact_inv[n-r]%MOD;
}
  
int main()
{
  int N,M,C;
  int ans=0,tmp=0,A,i,j;
  cin >> N >> M >> C;

  vector <int>B(M,0); rep(i,M){cin >> B[i];}

  rep(i,N){
      tmp=0;
      rep(j,M){
          cin >> A; tmp += A * B[j];
      }
      tmp += C;
      if(tmp > 0){ans++;}
  }

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


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

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	string n; cin >> n;
	ll sum = 0;
	for (int i = 0; i < n.size(); i++) {
		ll t = n[i] - '0';
		sum += t;
	}
	if (sum % 9 == 0) {
		cout << "Yes";
	}
	else {
		cout << "No";
	}	
	return 0;
}



Measured memory_bytes: 3720
import java.util.*;
import java.io.PrintWriter;
import static java.lang.Integer.*;
import static java.lang.Long.*;
import static java.lang.Math.*;
import static java.lang.System.*;

public class Main {
	public static final int MOD = 1000000007;
	public static void main(String[] args) {
		int i,j;
		Scanner sc = new Scanner(in);
		int n = parseInt(sc.next());
		int m = parseInt(sc.next());
		long[] h = new long[n];
		for (i = 0; i < n; i++) {
			h[i] = parseLong(sc.next());
		}
		int[] a = new int[m];
		int[] b = new int[m];
		for (i = 0; i < m; i++) {
			a[i] = parseInt(sc.next())-1;
			b[i] = parseInt(sc.next())-1;
		}
		sc.close();
		boolean[] f = new boolean[n];
		Arrays.fill(f, true);
		for (i = 0; i < m; i++) {
			if(h[a[i]]<=h[b[i]]) {
				f[a[i]] = false;
			}
			if(h[a[i]]>=h[b[i]]) {
				f[b[i]] = false;
			}
		}
		int ans=0;
//		out.println(Arrays.toString(f));
		for (i = 0; i < n; i++) {
			if(f[i])ans++;
		}
		out.println(ans);
	}
}


Measured memory_bytes: 50976
n=int(input())
maxx=0
sec=0
lis=[]
for i in range(n):
  s=int(input())
  lis.append(s)
  if s>=maxx:
    sec=maxx
    maxx=s
  elif s>sec:
    sec=s
for j in range(0,n):
  if lis[j]==maxx:
    print(sec)
  else:
    print(maxx)

Measured memory_bytes: 12520
#include<iostream>
#include<cstdlib>
#include<string>
#include<vector>
using namespace std;

int main() {
	
	int a, b, c;

	cin >> a >> b >> c;

	c = c - (a - b);

	if (c < 0) {
		c = 0;
	}
	
	cout << c << endl;

	return 0;
}

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


Measured memory_bytes: 2100
#include <bits/stdc++.h>
using namespace std;
using ll = long long;

#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
template<typename T> void view(T cont) {std::cout << cont << std::endl;}
template<typename T> void view(T* cont, ll sz) {rep(i, sz) std::cout << cont[i] << " "; std::cout << std::endl;}
template<typename T> void view(const std::vector<T>& v) {for (const auto& f: v) std::cout << f << " "; std::cout << std::endl;}
template<typename T> void view(const std::vector<std::vector<T> >& vv) { for (const auto& v: vv) {view(v);}}
const long long INF = 1LL<<60;
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}

int main(){
    int x, a, b; cin >> x >> a >> b;
    if (abs(x - a) < abs(x - b)) {
        cout << "A" << endl;
    } else {
        cout << "B" << endl;
    }
}

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

int main() {
  int n, k;
  cin >> n >> k;
  vector<ll> h(n);
  rep(i,n) cin >> h[i];
  

  sort(h.begin(), h.end());
  ll ans = pow(10,9)+1;
  for (int i = k-1; i < n; i++) {
    ans = min(ans, h[i]-h[i-k+1]);
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 1024
N=int(input())
T=list(map(int,input().split()))
M=int(input())
ans=[]
for i in range(M):
    T_tmp = T[:]
    p,x=map(int,input().split())
    T_tmp[p-1] = x
    ans.append(sum(T_tmp))

for i in range(M):
    print(ans[i])

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

ll gcd(ll a,ll b){
    if(b==0){
        return a;
    }else{
        return gcd(b,a%b);
    }
}

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

map<int,int> prime_factor(int n,map<int,int> &res){
    for(int i=2;i*i<=n;i++){
        while(n%i==0){
            res[i]++;
            n/=i;
        }
    }
    if(n!=1){
        if(res[n]==0){
            res[n]=1;
        }else{
            res[n]++;
        }
    }
    return res;
}

vector<ll> divisor(ll n){
    vector<ll> a;
    for(ll i=1;i*i<=n;i++){
        if(n%i==0){
            a.push_back(i);
            if(i*i!=n){
                a.push_back(n/i);
            }
        }
    }
    SORT(a);
    return a;
}

int extgcd(int a,int b,int &x,int &y){
    if(b==0){
        x=1;
        y=0;
        return a;
    }else{
        int d=extgcd(b,a%b,y,x);
        y-=a/b*x;
        return d;
    }
}



int main(){
    int n,mod=1e9+7;
    cin>>n;
    map<int,int> a;
    ll ans=1;
    for(int i=2;i<=n;i++){
        prime_factor(i,a);
    }
    for(auto i=a.begin();i!=a.end();i++){
        ans*=i->second+1;
        ans%=mod;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 256
#include<stdio.h>
int max(int a,int b){
  if(a > b)return a;
  return b;
}

int main(void){
  int a,b;
  scanf("%d %d",&a,&b);
  if(a == b){
    printf("%d", 2 * a);
  }else{
    printf("%d",2 * max(a,b) - 1);
  }
  return 0;
}

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

int main(){
    string s,t ;
    int ans = 0 ;
    cin >> s ;
    while(1){
        cin >> t ;
        if(t=="END_OF_TEXT") break ;
        for(int i=0;i<t.size();i++){
            if(t.at(i)>='A'&&t.at(i)<='Z') t.at(i) += 'a'-'A' ;
        }
        if(s==t) ans++ ;
    }
    cout << ans << endl ;
}


Measured memory_bytes: 3216
def bubble_sort(nums, n):
    c = 0

    loop = True
    while loop:
        loop = False

        for j in range(n-1, 0, -1):
            if nums[j] < nums[j-1]:
                nums[j], nums[j-1] = nums[j-1], nums[j]
                loop = True
                c += 1

    return (c, nums)

def main():
    n = int(input())
    nums = [int(x) for x in input().split()]

    c, nums = bubble_sort(nums, n)

    print(" ".join([str(x) for x in nums]))
    print(c)

if __name__ == '__main__':
    main()



Measured memory_bytes: 5608
#include<iostream>
using namespace std;
int main()
{
    int n, m, l, a[100][100] = { 0 }, b[100][100] = { 0 },s=0;
    long long c[100][100] = { 0 };
    cin >> n >> m >> l;
    for (int i = 0;i<n;i++){
        for (int k = 0;k<m;k++){
            cin >> a[i][k];
        }
    }
    for (int k = 0; k < m; k++){
        for (int j = 0;j < l; j++){
            cin >> b[k][j];
        }
    }
    for (int i = 0;i<n;i++){
        for (int j = 0; j < l; j++){
            for (int k = 0; k<m; k++){
                c[i][j] +=a[i][k]*b[k][j];
            }
        }
    }
    for (int i = 0; i < n; i++){
        for (int j = 0; j < l; j++){
            if (s == 1){
                cout << " ";
            }
            cout << c[i][j];
            s = 1;
        }
        cout << endl;
        s = 0;
    }
    return 0;
}

Measured memory_bytes: 3232
package main

import "fmt"

func main() {
	var x int
	fmt.Scan(&x)
	fmt.Println(360 * x / gcd(x, 360) / x)
}

func gcd(a, b int) int {
	if a == 0 {
		return b
	}
	if a > b {
		return gcd(a-b, a)
	}
	return gcd(b-a, a)
}


Measured memory_bytes: 1832
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
using namespace std;
#define int long long
#define vvectorl vector<vector<long long>>
#define vectorl vector<long long>
int gcd(int a, int b) {
	if (b == 0) {
		return a;
	}
	int r = a % b;
	return gcd(b, r);
}
int squ(int x) {
	return x * x;
}
int di(vectorl x, vectorl y, int i, int j) {
	return squ(x[i] - x[j]) + squ(y[i] - y[j]);
}
int qmmin(int &a, int b) {
	if (a == -1) {
		a = b;
	}
	else {
		a = min(a, b);
	}
	return a;
}
int nex(int a) {
	return (a + 1) % 3;
}
signed main() {
	int n, sw;
	cin >> n >> sw;
	vector<int> gw(100000+1,sw+1);
	vector<int> qgw;
	gw[0] = 0;
	for (int i = 0; i < n; i++) {
		qgw = gw;
		int w, v;
		cin >> w >> v;
		for (int j = 0; j + v <= 100000; j++) {
			gw[j + v] = min(gw[j + v], qgw[j] + w);
		}
	}
	int i = 100000;
	while (gw[i] > sw) {
		i--;
	}
	cout << i << endl;
}

Measured memory_bytes: 1792
#include <iostream>

using namespace std;

int main()
{
    int D[10000], C = 0;

    while (true)
    {
        cin >> D[C];

        if (D[C] == 0) { goto Exit; }

        C++;
    }

    Exit:;

    for (int i = 0; i < C; i++)
    {
        cout << "Case " << i + 1 << ": " << D[i] << endl;
    }

    return 0;
}

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

#define PI 3.14159265359
#define INF 1e9
#define LINF 1e18
#define IMOD 1000000007 
#define irep(i,n) for(int i = 0; i < (int)(n); i++)
#define irep2(i,a,n) for(int i = (int)(a); i <= (int)(n); i++)
#define lrep(i,n) for(long long  i = 0; i < (long long)(n); i++)
#define lrep2(i,a,n) for(long long i = (long long)(a); i <= (long long)(n); i++)

#define irrep(i,n) for(int i = (int)(n); i > -1; i--)
#define irrep2(i,a,n) for(int i = (int)(n); i >= (int)(a); i--)

typedef long long ll;
typedef std::vector<char> v_char;
typedef std::vector<v_char > v2_char;
typedef std::vector<double> v_double;
typedef std::vector<v_double > v2_double;
typedef std::vector<int> v_int;
typedef std::vector<v_int > v2_int;
typedef std::vector<ll> v_ll;
typedef std::vector<v_ll > v2_ll;
typedef std::vector<std::string> v_string;
typedef std::vector<v_string > v2_string;
typedef std::vector<bool> v_bool;
typedef std::vector<v_bool > v2_bool;
typedef std::pair<ll, ll> pll;
typedef std::pair<int, int> pii;

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

using namespace std; 

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

    ll ans = 1;

    while(n) {
        ans *= n;
        ans %= IMOD;
        n--;
    }
    cout << ans;
    return 0;
}   
/** atcoder **/


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

using namespace std;

int main() {
  string s;
  cin >> s;
  map<char, int> m;
  for (int i = 0; i < (int)s.size(); ++i) {
    m[s[i]]++;
  }

  for (auto e: m) {
    if (e.second != 2) {
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;
  return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#include<bits/stdc++.h>
using namespace std;
typedef     long long    ll;
typedef     vector<int> vi;
typedef     vector<long long> vl;
typedef     pair<int, int>pi;
typedef     pair<long long, long long>pl;
#define F   first
#define S   second
#define pb  push_back
#define     all(x)      x.begin() , x.end()
#define mp  make_pair
#define       FOR(i,a,b) for(i=a;i<=b;i++)
#define     mem(a)      memset(a , 0 ,sizeof a)
#define     memn(a)     memset(a , -1 ,sizeof a)

int main()
{
  int t;
  t=1;
  //cin>>t;
  
  while(t--)
  {
    long long n;
    cin>>n;
    n--;
    n=n*(n+1);
    n/=2;
    cout<<n<<endl;
  }

}


Measured memory_bytes: 3596
Ps = []
M = [False]*55556
for i in range(2, 55556):
  if not(M[i]):
    Ps.append(i)
    for j in range(i, 55556, i):
      M[j] = True
#print(Ps)
Ps2 = list(filter(lambda p: p%5 == 1, Ps))
#print(Ps2)
N = int(input())
r = Ps2[:N]
print(" ".join(map(str, r)))


Measured memory_bytes: 3700
n, m=map(int, raw_input().split())
s=raw_input()
t=raw_input()
def gcd(a, b):
	if b==0:
		return a
	else:
		return gcd(b, a%b)
g=gcd(n, m)
l=n*m/g
for i in range(g):
	if s[n/g*i]!=t[m/g*i]:
		print -1
		exit()
print l

Measured memory_bytes: 3460
using DataStructures
parseline(str) = parse.(Int, split(str))
function Base.maximum(dSet::IntDisjointSets, N::Integer)
    parents = dSet.parents
    nums = zeros(Int, N)
    for p in parents
        temp = p
        while temp != parents[temp]
            temp = parents[temp]
        end
        nums[temp] += 1
    end
    return maximum(nums)
end
function Friends()
    data = readlines()
    N, M = parseline(data[1])
    AB = parseline.(data[2:end])
    group = IntDisjointSets(N)
    for ab in AB
        union!(group, ab[1] , ab[2])
    end
    println(maximum(group, N))
#     println(group)
end
Friends()

Measured memory_bytes: 248812
import cmath
import math

N = int(input())
pc = []
for i in range(N):
  x, y = map(int, input().split())
  c = x + y*1j
  p = cmath.phase(c)
  pc.append([p, c])
pc = sorted(pc, key=lambda x: x[0])

ps = [pc[i][0] for i in range(N)]
cs = [pc[i][1] for i in range(N)]

def L(i, j, N):
  if i<j:
    return list(range(i, j))
  else:
    return list(range(0, j)) + list(range(i+1, N))

s = 0
m = 0

for start in range(N):
  for end in range(N):
    s = 0
    #print(start,end,N,L(start,end,N))
    for k in L(start,end,N):
      s += cs[k]
    m = max(m, abs(s))
s = 0
for k in range(N):
  s += cs[k]
  m = max(m, abs(s))
print(m)

Measured memory_bytes: 3440
#include<iostream>
#include<cstring>
#include<cstdio>
#define LL long long
#define mp make_pair
#define INF 0x3f3f3f3f
#define Inf 1000000000000000000LL
#define F first
#define S second
#define all(x) (x).begin(),(x).end()
using namespace std;
typedef pair<int,int>pii;
int n;
char s[100010];
const char t[100010]="\0AKIHABARA";
int main(){
	scanf("%s",s+1);
	n=strlen(s+1);
	int i,j;
	for(i=1,j=1;i<=n&&j<=9;){
		if(s[i]==t[j])i++,j++;
		else if(t[j]=='A')j++;
		else{
			puts("NO");
			return 0;
		}
	}
	for(;j<=9;j++)if(t[j]!='A'){
		puts("NO");
		return 0;
	}
	if(i==n+1&&j==10)puts("YES");
	else puts("NO");
	return 0;
}


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

int main() {
    int c, n, m;
    cin >> c >> n >> m;
    vector<int> dp(c + 1);
    for (int i = 0; i < n; ++i) {
        int s, p;
        cin >> s >> p;
        for (int j = c; j >= s; --j)
            dp[j] = max(dp[j], dp[j - s] + p);
    }
    for (int i = 1; i <= m; ++i)
        cout << dp[c / i] * i << "\n";

    return 0;
}



Measured memory_bytes: 3120
#include <bits/stdc++.h>
#include <string>
#include <cstring>
#include <algorithm>
#include <math.h>
#include <map>
#include <bitset>
#include <cmath>
#include <set>

#define INF 1000000000000
#define MOD 1000000007 //10^9+7:合同式の法
#define JUUHATI 1000000000000000000 
#define JUUHATIPLUS 1000000000000000001 

using namespace std;
typedef long long ll;

//マクロ
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)

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

    if(a <= b)
        for(int i = 0;i < b;i++)
            cout << a;
    else{
        for(int i = 0;i < a;i++)
            cout << b;
    }

    cout << endl;

    
    
}

Measured memory_bytes: 3632
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <climits>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <string>
#include <complex>

using namespace std;
using pii = pair<int, int>;
using ll = long long;

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

	int n, k;
	cin >> n >> k;
	int answer = 0;
	for (int i = 0; i < n; i++)
	{
		int h;
		cin >> h;
		if (h >= k) answer += 1;
	}
	cout << answer;

	return 0;
}


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

int main(void){
    using namespace  std;
    int N;
    cin >> N;
    vector<int> a(N);
    for (int i = 0; i < N;i++){
        cin >> a[i];
    }

    int count = 0;
    for (int i = 0; i < N;i++){
        if(a[i] != i+1 - count)
            count++;
    }
    if(count == N)
        count = -1;

    cout << count << endl;

    return 0;
}


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

int read() {
    int x = 0, f = 1; char ch = getchar();
    while (!isdigit(ch)) { if (ch == '-') f = -1; ch = getchar(); }
    while (isdigit(ch)) { x = x * 10 + ch - '0'; ch = getchar(); }
    return x * f;
}

const int Max = 2033;
int n, x, sum;
bitset<Max * Max> b;

int main() {
    n = read(), b[0] = 1;
    for (int i = 1; i <= n; i++) {
        x = read(), sum += x;
        b = b | (b << x);
    }
    for (x = (sum + 1) / 2; !b[x]; x++);
    cout << x << endl;
}

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

using namespace std;

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

#define INF 2<<29
#define F first
#define S second

int main(){
  int n;
  int x1,y1,z1,w1;
  int x2,y2,z2,w2;
  int x,y,z,w;

  while(1){
    scanf("%d",&n);
    if(n==0) break;
    
    for(int i=0;i<n;i++){
      scanf("%d %d %d %d %d %d %d %d",&x1,&y1,&z1,&w1,&x2,&y2,&z2,&w2);
      
      x=x1*x2-y1*y2-z1*z2-w1*w2;
      y=x1*y2+y1*x2+z1*w2-w1*z2;
      z=x1*z2+z1*x2-y1*w2+w1*y2;
      w=x1*w2+w1*x2+y1*z2-z1*y2;

      printf("%d %d %d %d\n",x,y,z,w);
    }
  }
  
  
  return (0);
}



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

using namespace std;

typedef long long ll;

double getTime() {
  return clock() / (double) CLOCKS_PER_SEC;
}

void read() {};

template<typename T, typename... Args>
void read(T& a, Args&... args) {
  cin >> a;
  read(args...);
}

void print() {};

template <typename T, typename... Args>
void print(T a, Args... args) {
  cout << a << " \n"[sizeof...(args) == 0];
  print(args...);
}

int main() {
  int n; cin >> n;
  cout << (n + 1) / 2 << '\n';
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using Int = long long int;
template<typename T> void swap(T *t1, T *t2){ T* tmp=t1; t1=t2; t2=tmp;}


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

    int n;
    long cnt = 0;
    string tmp;
    vector<char> s;
    map<string, int> m;
    cin >> n;
    for(int i=0; i<n; i++){
        cin >> tmp;
        for(int j=0; j<10; j++){
            s.push_back(tmp.at(j));
        }
        sort(s.begin(), s.end());
        string buf = "";
        for(int i=0; i<10; i++){
            buf += s[i];
        }
        if(m.find(buf) == m.end()){
            m.insert(make_pair(buf, 0));
        }else{
            cnt += m.at(buf)+1;
            m.at(buf)++;
        }
        s.clear();
    }
    cout << cnt << endl;

    return 0;
}

Measured memory_bytes: 12800
#include <iostream>

using namespace std;

int main()
{
	int i,j,n;
	
	
	while(cin >> n){
	int count = 0;
	bool flag[n+1];
		
		for(i=2;i<n+1;i++) flag[i] = true;
		
		for(i=2;i<n+1;i++){
			if(!flag[i]){
				continue;
			}
			for(j=2*i;j<n+1;j+=i){
				flag[j] = false;
			}
		}
		
		// 個数を走査
		for(i=2;i<n+1;i++){
			if(flag[i]==true){
				count++;
			}
		}
		
		cout << count << endl;
	}
	
	return 0;
}

Measured memory_bytes: 2136
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Text;

class Program
{
	static void Main(string[] args)
	{
        List<int> n = new List<int>();
        List<int> x = new List<int>();

        while (true)
        {
            string[] s = Console.ReadLine().Split(' ');
            if (int.Parse(s[0]) == 0 && int.Parse(s[1]) == 0) break;
            n.Add(int.Parse(s[0]));
            x.Add(int.Parse(s[1]));

        }



        for (int i = 0; i < n.Count;i++)
        {
            int sum = 0;
            for (int j = 1; j <= n[i] - 2;j++)
            {
                for (int k = j + 1; k <= n[i] - 1;k++)
                {
                    for (int l = k + 1; l <= n[i];l++)
                    {
                        if (j + k + l == x[i]) sum++;
                    }
                }
            }

            Console.WriteLine(sum);
        }
	}
}

Measured memory_bytes: 9140