akhauriyash/Code-Regression huggingface dataset:
//


#pragma GCC optimize ("O3")


#pragma GCC optimize("Ofast")

/* 
   *********************************************************
    Code_Blooded Human == @{{ samrat_12   [  0_0  ^_^  ] }}
   *********************************************************
*/
#include <bits/stdc++.h>
#include<algorithm>
#include<queue>
#include<list>
#include<map>
#include <math.h>
#include<numeric>
using namespace std;
#define endl '\n'
#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define ipfile    ifstream cin ("input.txt");std::cin.rdbuf(std::cin.rdbuf())
#define pb(x) push_back(x)
#define int long long int
#define ull unsigned long long int
#define db long double
#define mod 1000000007
#define vll vector<ll>
#define all(v) v.begin(),v.end()
#define GCD(m,n) __gcd(m,n)
#define LCM(m,n) m*(n/GCD(m,n))
#define REVVEC(v) reverse(v.begin(),v.end())
#define REVARR(a) reverse(a,a+n)
#define maxc(v) max_element(all(v))
#define minc(v) min_element(all(v))
#define inputarr(a,n) for(int xxx=0;xxx<n;++xxx) cin>>a[xxx]
#define outputarr(a,n) for(int xxx=0;xxx<n;xxx++) cout<<a[xxx]<<" "
#define rep(i,m, n)    for(int i = m; i < (n); ++i)
#define sp setprecison(10)

clock_t time_p = clock();
void time()
{
  time_p = clock() - time_p;
  cerr << "Time elapsed : " << (double)(time_p)/CLOCKS_PER_SEC <<endl;
}

void Block()
{
    int a,b;
    cin>>a>>b;
    cout<<LCM(a,b)<<endl;
}

signed main()
{
    FAST
    
    Block();
    time();
    return 0;
}

Measured memory_bytes: 256
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author Tarek
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        DFlatSubsequence solver = new DFlatSubsequence();
        solver.solve(1, in, out);
        out.close();
    }

    static class DFlatSubsequence {
        final static int N = (int) 6e5 + 7;
        int[] tree = new int[4 * N];
        int[] a = new int[N];

        void update(int pos, int v, int l, int r, int node) {
            if (l == r) {
                tree[node] = v;
                return;
            }
            int m = (l + r) / 2;
            if (pos <= m) update(pos, v, l, m, 2 * node);
            else update(pos, v, m + 1, r, 2 * node + 1);
            tree[node] = Math.max(tree[2 * node], tree[2 * node + 1]);
        }

        int query(int ql, int qr, int l, int r, int node) {
            if (ql <= l && qr >= r) return tree[node];
            int m = (l + r) / 2;
            int ans = 0;
            if (ql <= m) ans = Math.max(ans, query(ql, qr, l, m, 2 * node));
            if (qr > m) ans = Math.max(ans, query(ql, qr, m + 1, r, 2 * node + 1));
            return ans;
        }

        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int n = in.nextInt();
            int k = in.nextInt();
            int ans = 0;
            for (int i = 1; i <= n; i++) {
                a[i] = in.nextInt();
            }
            for (int i = 1; i <= n; i++) {
                int res = query(Math.max(a[i] - k, 0), a[i] + k, 0, N, 1) + 1;
                ans = Math.max(ans, res);
                update(a[i], res, 0, N, 1);
            }
            out.println(ans);
        }

    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

    }
}



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

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

Measured memory_bytes: 3808
#include <iostream>
#include <cstdlib>
#include <algorithm>

using namespace std;

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

    if (n == 1 && m == 1) {
        cout << 1 << endl;
    } else if (n == 1 || m == 1) {
        cout << max(n, m) - 2 << endl;
    } else {
        cout << abs((n - 2)*(m - 2)) << endl;
    }

   return 0;
}

Measured memory_bytes: 256
# include<iostream>

int main(){
  int a,b,c=0;
  int min=0;
  int buf=0;
  
  std::cin>>a>>b>>c;
  min=a;
  if ((min<b)||(min<c)){
    buf=a;
    if (b<c){
      buf=buf+b;
    }else{
      buf=buf+c;
    }
  }else{
      buf=b+c;
  }
  std::cout<<buf<<std::endl;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(){

    int n;

    cin >> n;

    bool f = true;
    for (int i = 0; i < n; i++) {
        char a;
        cin >> a;
        if (a == 'Y'){
            f = false;
        }
    }
    if (f == true) cout << "Three" << endl;
    else cout << "Four" << endl;
}

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

int main(void) {
  string s;
  cin >> s;
  if (s == "Sunny") cout << "Cloudy" << '\n';
  if (s == "Cloudy") cout << "Rainy" << '\n';
  if (s == "Rainy") cout << "Sunny" << '\n';
  return 0;
}

Measured memory_bytes: 3564
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <stdio.h>
#include <string.h>
#include <math.h>
using namespace std;

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

    int r = k;
    for (int i = 1; i < n; i++) {
        r *= k - 1;
    }

    cout << r << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
using namespace std;
 
int main(){
    long long n,p;
    cin>>n>>p;
    long long ans;
    if(n==1){
        ans=p;
    }else if(p==1){
        ans=1;
    }else if(n<4){
        for(long long i=1000001;i>0;i=i-1){
            if(p%((long long int)pow(i,n))==0){
                ans=i;
                break;
            }
        }
    }else{
        for(long long i=10001;i>0;i=i-1){
            if(p%((long long int)pow(i,n))==0){
                ans=i;
                break;
            }
        }
    }
    cout<<ans;
    return 0;
}

Measured memory_bytes: 256
N = list(input())
if 1 <= int(N[0]+N[1]) <=12 and 1 <= int(N[2]+N[3]) <=12:
  print('AMBIGUOUS')
elif 1 <= int(N[0]+N[1]) <=12:
  print('MMYY')
elif 1 <= int(N[2]+N[3]) <=12:
  print('YYMM')
else:
  print('NA')


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

int num[11111]={0};

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

  return 0;
}

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

#define rep(i, a, b) for (int i = a; i < (int)(b); ++i)
#define rrep(i, a, b) for (int i = b - 1; i >= (int)(a); --i)

using namespace std;
using ll = long long;
using vi = vector<int>;
using vll = vector<ll>;
using vd = vector<double>;
using vvi = vector<vi>;
using vvll = vector<vll>;
using vvd = vector<vd>;
using vvvi = vector<vvi>;
using vvvll = vector<vvll>;
using vvvd = vector<vvd>;

constexpr int MOD = 1000000007;

double calc(vvvd& dp, int i, int j, int k, int ni, int nj, int nk) {
    if (i == 0 && j == 0 && k == 0) { return 0; }
    if (dp[i][j][k] != -1) { return dp[i][j][k]; }

    double sum = ni + nj + nk;
    if (i > 0) { sum += i * calc(dp, i - 1, j, k, ni, nj, nk); }
    if (j > 0) { sum += j * calc(dp, i + 1, j - 1, k, ni, nj, nk); }
    if (k > 0) { sum += k * calc(dp, i, j + 1, k - 1, ni, nj, nk); }
    sum /= double(i + j + k);
    return dp[i][j][k] = sum;
}

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

    int n;
    cin >> n;

    vi cnt(4, 0);
    rep(i, 0, n) {
        int a;
        cin >> a;
        ++cnt[a];
    }

    int ni = cnt[1], nj = cnt[2], nk = cnt[3];
    vvvd dp(n + 1, vvd(nj + nk + 1, vd(nk + 1, -1)));
    printf("%.10f\n", calc(dp, ni, nj, nk, ni, nj, nk));

    return 0;
}

Measured memory_bytes: 216960
#include <cstdio>
#include <algorithm>
using namespace std;
int main() {
	int N;
	scanf("%d", &N);
	int A[N], B[N];
	for (int i = 0; i < N; ++i) scanf("%d %d", &A[i], &B[i]);
	sort(A, A + N);
	sort(B, B + N);
	int l = (A[(N - 1) / 2] + A[N / 2]), r = (B[(N - 1) / 2] + B[N / 2]);
	printf("%d", (r - l) / (1 + N % 2) + 1);
	return 0;
}

Measured memory_bytes: 3284
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<string>
#include<cstring>
#include<algorithm>
#include<queue>
#include<map>
#include<set>
using namespace std;
int n;
int b[300];
int a[300];
bool flag[300];
int ans[300];
int t=0;
int nown;


int main()
{
    cin>>n;
    for (int i=1; i<=n; ++i)
        cin>>b[i];
    nown=n;
    for (int i=1; i<=n; ++i)
    {
        int tans=0;
        for (int j=nown; j>=1; --j)
            if (b[j]==j)
            {
                tans=j;
                break;
            }
        int tnown=0;
        for (int j=1; j<=nown; ++j)
            if (j!=tans)
            {
                tnown++;
                a[tnown]=b[j];
            }
        for (int j=1; j<=tnown; ++j)
        {
            b[j]=a[j];
        }
        nown=tnown;
        if (tans!=0)
        {
            t+=1;
            ans[t]=tans;
        }
    }

    if (t!=n)
    {
        cout<<-1<<endl;
        return 0;
    }
    for (int i=t; i>=1; --i)
    {
        cout<<ans[i]<<endl;
    }

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <random>
using namespace std;
random_device seed;
mt19937_64 engine(seed());
uint_fast64_t rnd(){ return engine(); }
uint_fast64_t rnd(uint_fast64_t u){ return (u <= 1)?0:engine()%u; }
long long rnd(long long a, long long b){
    if(a > b) swap(a, b);
    return a + (engine()%(b-a+1));
}
const int alp = 26;
int D;
vector<long long> c(alp);
vector< vector< long long > > s;

long long sub(vector<int>& last, int x, int d){
    long long res = s[d][x];
    for(int j=0;j<alp;j++){
        if(j != x) res -= c[j] * (d-last[j]);
    }
    return res;
}

long long score(vector<int>& t){
    if(t.size() != D) return 0;
    vector< int > last(alp, -1);
    long long res = 0;
    for(int i=0;i<D;i++){
        res += s[i][t[i]];
        last[t[i]] = i;
        for(int j=0;j<alp;j++){
            res -= c[j] * (i-last[j]);
        }
    }
    return res;
}

void f(vector<int>& t){
    t.assign(D, 0);
    vector< int > last(alp, -1);
    for(int i=0;i<D;i++){
        int mxj = 0;
        long long mx = -1e9;
        for(int j=0;j<alp;j++){
            long long tmp = sub(last, j, i);
            if(tmp > mx){
                mxj = j;
                mx = tmp;
            }
        }
        t[i] = mxj;
        last[mxj] = i;
    }
}

bool print_t(vector<int>& t){
    if(t.size() != D) return false;
    for(int i=0;i<D;i++){
        cout << t[i]+1 << endl;
    }
    return true;
}

int main(void){
    cin >> D;
    for(int i=0;i<alp;i++) cin >> c[i];
    s.assign(D, vector<long long>(alp, 0));
    for(int i=0;i<D;i++){
        for(int j=0;j<alp;j++) cin >> s[i][j];
    }

    vector<int> t;
    f(t);
    long long old_score = score(t);
    for(int l = 0; l < 1000; l++){
        int i = rnd(0, D-1);
        int od = t[i];
        t[i] = rnd(0, alp-1);
        long long new_score = score(t);
        if(new_score > old_score){
            old_score = new_score;
        }else{
            t[i] = od;
        }
    }

    print_t(t);
}


Measured memory_bytes: 3288
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
#define mod 1000000007
#define ff first
#define ss second
using namespace std;
/*ll power(ll x,ll y)
{
    ll res=1;
    while(y>0)
    {
        if(y%2==1)
            res=(res*x)%mod;
        x=(x*x)%mod;
        y=y/2;
    }
    return res;
}*/
void dfs(vector<ll>v[],ll node,ll arr[],ll p)
{
    arr[node]=arr[node]+arr[p];
    for(auto u:v[node])
    {
        if(u!=p)
            dfs(v,u,arr,node);
    }
}
int main()
{
ll n,q,i,x,y,p,k;
cin>>n>>q;
vector<ll>v[n+1];
ll arr[n+1]={0};
for(i=0;i<n-1;i++)
{
    cin>>x>>y;
    v[x].pb(y);
    v[y].pb(x);
}
for(i=0;i<q;i++)
{
    cin>>p>>k;
    arr[p]+=k;
}
dfs(v,1,arr,0);
for(i=1;i<=n;i++)
    cout<<arr[i]<<" ";
cout<<endl;
}


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

int main() {
    ll a, b, c;
    cin >> a >> b >> c;
    if (a == b && b == c && !(a&1)) {
        puts("-1");
        return 0;
    }

    int ans = 0;
    while(true){
        if (a & 1 || b & 1 || c & 1) break;
        ll na = (b + c) / 2;
        ll nb = (a + c) / 2;
        ll nc = (a + b) / 2;
        a = na;
        b = nb;
        c = nc;
        ans++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
const int MAXN = 1e6+5;
char ans[MAXN];
int main() {
    int n;
    cin>>n;
    string s;
    cin>>s;
    s='#'+s;
    for(int i=1;i<=2;i++){
        for(int j=1;j<=2;j++){
            if(i==1){
                ans[1] = 'W';
            }else{
                ans[1] = 'S';
            }
            if(j==1){
                ans[2] = 'S';
            }else{
                ans[2] = 'W';
            }
            for(int x=2;x<n;x++){
                if(ans[x] == 'S'){
                    if(s[x] == 'o'){
                        ans[x+1] = ans[x-1];
                    }else{
                        if(ans[x-1] == 'S'){
                            ans[x+1] = 'W';
                        }else{
                            ans[x+1] = 'S'; 
                        }
                    }
                }else{
                    if(s[x] == 'x'){
                        ans[x+1] = ans[x-1];
                    }else{
                        if(ans[x-1] == 'S'){
                            ans[x+1] = 'W';
                        }else{
                            ans[x+1] = 'S'; 
                        }
                    }
                }

            }
            if((s[1] == 'o'  && ans[1] == 'S')||(s[1] == 'x' && ans[1] == 'W')){
                if(ans[2]!=ans[n]){
                    
                    continue;
                }
            }else{
                if(ans[2] == ans[n]){
                    
                    continue;
                }
            }
            if((s[n] == 'o'  && ans[n] == 'S')||(s[n] == 'x' && ans[n] == 'W')){
                if(ans[1]!=ans[n-1]){
                    continue;
                }
            }else{
                if(ans[1] == ans[n-1]){
                   // cout<<i<<" "<<j<<" "<<ans[2]<<" "<<ans[n]<<endl;
                    continue;
                }
            }
            for(int x=1;x<=n;x++){
                cout<<ans[x];
            }
            cout<<endl;
            return 0;
        }
    }
    cout<<-1<<endl;
}

Measured memory_bytes: 636
#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)
using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector<vector<int>>;
using vvl = vector<vector<ll>>;

//プロトタイプ宣言
void faster(void);
template <class T>
T gcd(T , T);
template <class T>
T get_digent(T);
template <class T>
T POW(T , T);
template <class T>
T vec_max(auto & , string);
template <class T>
T vec_min(auto & , string);

ll n,ans=0;

void dfs(ll now,int a,int b,int c){
  if(now>n) return ;
  if(a&&b&&c) ans++;
  dfs(now*10+3,1,b,c);
  dfs(now*10+5,a,1,c);
  dfs(now*10+7,a,b,1);
}




int main(){
  faster();
  cin >> n;
  dfs(0,0,0,0);
  cout << ans << endl;
}



























//同期解除
void faster(void){
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
}

//ユークリッドの互除法
template <class T>
T gcd(T a, T b) {
  return (b ? gcd(b, a%b) : a);
} 

//桁数取得
template <class T>
T get_digent(auto x){
  string s;
  s = to_string(x);
  ll digent = s.size();
  return digent;
} 

//べき乗計算
template <class T>
T POW(T x, T y){
  if(y==0) return 1;
  if(y%2 == 1){
    ll temp = POW(x,y-1);
    return (temp*x);
  }
  else{
    ll temp = POW(x,y/2);
    return temp*temp;
  }
} 

//配列内の最大要素の添え字取得or要素取得
template <class T>
T vec_max(auto &v, string s){
  auto itr = max_element(v.begin(),v.end());
  ll element = *itr;
  ll place = itr - v.begin();
  if(s == "element") return element;
  else if(s == "place") return place;
  else return -1;
}

//配列内の最小要素の添え字取得or要素取得
template <class T>
T vec_min(auto &v, string s){
  auto itr = min_element(v.begin(),v.end());
  ll element = *itr;
  ll place = itr - v.begin();
  if(s == "element") return element;
  else if(s == "place") return place;
  else return -1;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC optimize ("-ffloat-store") // to restrict undesirable precision
#pragma GCC optimize ("-fno-defer-pop")// to pop argument of function as soon as it returns
#define all(a) a.begin(),a.end()
#define ll long long int
#define ld long double
ll power(ll a,ll b,ll m){ if(b==0) return 1; if(b==1) return a%m; ll t=power(a,b/2,m)%m; t=(t*t)%m; if(b&1) t=((t%m)*(a%m))%m; return t;}
ll modInverse(ll a, ll m) { return power(a, m-2, m); }
#define ps push_back
#define fs first
#define sc second
#define takeline cin.ignore();
#define iactive cout.flush();
#define N 3000005
#define endl "\n"
#define mod 1000000007
#define PI 3.141592653589793
//((1.0l)*BIG MULTIPLY MAGIC?)
// string to integer stoi()
// string to long long stoll()
// string.substr(position,length);
// integer to string to_string();
//-----------------------------------------------
int main(){
	
	ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);

	ll i,j,k,l,n;
	cin>>n;
	ll ar[n+1];
	for(i=1;i<=n;i++){
		cin>>ar[i];
	}

	k=ar[1]; ll an=0;
	for(i=2;i<=n;i++){
		// cout<<ar[i]<<" "<<k<<endl;
		if(ar[i]<k){
			an+=k-ar[i];
			k=max(k,ar[i]);
		}
		else k=max(k,ar[i]);
	}
	cout<<an<<endl;
	return 0;	
}

Measured memory_bytes: 5172
#include <algorithm>
#include <iostream>
#include <vector>
#include <numeric>
#include <string>
#include <stdio.h>
#include <set>
#include <iomanip>
using namespace std;
 
 
int main(){
    int X;
    int N;
    int tmp;
    int ans = 0;
    cin >> X >> N;
    if (N == 0){
        cout << X << endl;
        return 0;
    }
    vector<int> a(102);
    for (int i=0; i<102; i++){
        a[i] = i;
    }
    for (int i=0; i<N; i++){
        cin >> tmp;
        a[tmp] = -200;
    }
    for (int i=0; i<102; i++){
        if (abs(X-ans) > abs(X-a[i])) ans = a[i];
    }
    cout << ans << endl;

    return 0;
}

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

int main() {
	int w_lim;
	for (int t = 1; cin >> w_lim && w_lim; t++) {
		int n;
		cin >> n;
		int v[n], w[n];
		char c;
		for (int i = 0; i < n; i++) {
			cin >> v[i] >> c >> w[i];
		}
		int dp[n + 1][w_lim + 1]{};	//dp[i][j] := 先頭i個見て重さがjの時の価値の最大値
		for (int i = 0; i < n; i++) {
			for (int j = 0; j <= w_lim; j++) {
				dp[i + 1][j] = dp[i][j];
				if (0 <= j - w[i]) {
					dp[i + 1][j] = max(dp[i + 1][j], dp[i][j - w[i]] + v[i]);
				}
			}
		}
		cout << "Case " << t << ':' << endl;
		pair<int, int> ans(0, 0);
		for (int i = 0; i <= w_lim; i++) {
			if (ans.first < dp[n][i]) {
				ans = {dp[n][i], i};
			}
		}
		cout << ans.first << endl;
		cout << ans.second << endl;
	}
	return 0;
}


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

int main() {
    string w;
    cin >>w;
    string alpha = "abcdefghijklmnopqrstuvwxyz";
    map<char, int> p;
    for (char c: alpha) {
        p.insert(pair<char,int>(c,0));
    }

    for (char& c: w) {
        p[c]++;
    }

    string ret = "Yes";
    for (char c: alpha) {
        if (p[c]%2 == 1) {ret = "No"; break;}
    }
    cout << ret << endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>

int min(int a, int b)
{
	if (a > b){
		return (b);
	}
	return (a);
}

int lose(int *ptr)
{
	int i, j;
	int temp[10];
	int ret;
	int sum;
	
	ret = 100;
	for (i = 0; i < 1 << 10; i++){
		for (j = 0; j < 10; j++){
			temp[j] = ptr[j];
		}
		for (j = 0; j < 10; j++){
			if (((i >> j) & 1) && (temp[j] >= 3)){
				temp[j] -= 3;
			}
		}
		
		for (j = 1; j <= 7; j++){
			while (temp[j] >= 1 && temp[j + 1] >= 1 && temp[j + 2] >= 1){
				temp[j]--;
				temp[j + 1]--;
				temp[j + 2]--;
			}
		}
		
		sum = 0;
		
		for (j = 1; j <= 9; j++){
			sum += temp[j];
		}
		ret = min(ret, sum);
	}
	
	return (ret);
}

int main(void)
{
	char str[14];
	char flag[10];
	int num[10], memo[10];
	int i, j;
	int ok;
	
	while (scanf("%s", str) != EOF){
		getchar();
		memset(num, 0, sizeof(num));
		memset(flag, 0, sizeof(flag));
		
		for (i = 0; i < 13; i++){
			num[str[i] - '0']++;
		}
		
		memcpy(memo, num, sizeof(num));
		
		for (i = 1; i <= 9; i++){
			memcpy(num, memo, sizeof(memo));
			if (num[i] < 4){
				memo[i]++;
				for (j = 1; j <= 9; j++){
					memcpy(num, memo, sizeof(memo));
					if (num[j] >= 2){
						num[j] -= 2;
						if (lose(num) == 0){
							flag[i] = 1;
						}
					}
				}
				
				memo[i]--;
			}
		}
		
		ok = 0;
		for (i = 1; i <= 9; i++){
			if (ok == 1 && flag[i] == 1){
				printf(" ");
			}
			if (flag[i] == 1){
				printf("%d", i);
				ok = 1;
			}
		}
		if (ok == 0){
			printf("0");
		}
		printf("\n");
	}
	
	return (0);
}

Measured memory_bytes: 412
a0 = list(map(int, input().split()))
a1 = list(map(int, input().split()))
a2 = list(map(int, input().split()))

n = int(input())
b = []
for _ in range(n):
    b.append(int(input()))

if a0[0] in b and a0[1] in b and a0[2] in b or a1[0] in b and a1[1] in b and a1[2] in b or a2[0] in b and a2[1] in b and a2[2] in b or  a0[0] in b and a1[0] in b and a2[0] in b or a0[1] in b and a1[1] in b and a2[1] in b or a0[2] in b and a1[2] in b and a2[2] in b or a0[0] in b and a1[1] in b and a2[2] in b or a0[2] in b and a1[1] in b and a2[0] in b:
    print('Yes')
else:
    print('No')


Measured memory_bytes: 61656
//code by lynmisakura.wish to be accepted!
/****************************/
#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 vector<pair<int, int>> vpi;
 
//const long long INF = 1LL << 55;
 
#define itn int
#define endl '\n'
#define pb push_back
#define mp make_pair
#define ss second
#define ff first
#define dup(x,y) ((x) + (y) - 1)/(y)
#define mins(x,y) x = min(x,y)
#define maxs(x,y) x = max(x,y)
#define all(x) (x).begin(),(x).end()
#define Rep(n) for(int i = 0;i < n;i++)
#define rep(i,n) for(int i = 0;i < n;i++)
#define rrep(i,n) for(int i = n - 1;i >= 0;i--)
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() )
 
ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
ll qp(ll a, ll b) { ll ans = 1; do { if (b & 1)ans = 1ll * ans*a; a = 1ll * a*a; } while (b >>= 1); return ans; }
ll qp(ll a, ll b, int mo) { ll ans = 1; do { if (b & 1)ans = 1ll * ans*a%mo; a = 1ll * a*a%mo; } while (b >>= 1); return ans; }
 
#define _GLIBCXX_DEBUG
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

//木の直径を測る
#define MAX_N 200020
vector<int> G[MAX_N];
int n;
int visited[MAX_N];
int longest_from_zero = 0,farest_from_zero = 0;
int diameter;
void dfs(int x,int d){
   visited[x] = 1;
   if(d > longest_from_zero){
      longest_from_zero = d;
      farest_from_zero = x;
   }
   for(auto i : G[x]){
      if(!visited[i]){
         dfs(i,d + 1);
      }
   }
}
void dfs2(int x,int d){
   visited[x] = 1;
   if(d > diameter){
      diameter = d;
   }
   for(auto i : G[x]){
      if(!visited[i]){
         dfs2(i,d + 1);
      }
   }
}
int main(void){
   cin.tie(0);
   ios::sync_with_stdio(false);
   cin >> n;
   rep(i,n-1){
      int a,b;cin >> a >> b;
      G[--a].pb(--b);
      G[b].pb(a);
   }
   //頂点0から一番遠い点を測る
   dfs(0,0);
   //farest_from_zeroから一番遠い点を測る
   fill(visited,visited + n,0);
   dfs2(farest_from_zero,0);
   //cout << diameter << endl;
   if(diameter % 3 == 1){
      cout << "Second" << endl;
   }else{
      cout << "First" << endl;
   }
   return 0;
}

Measured memory_bytes: 18176
function Main(input){
    const N = input.trim();
    const array = ['3', '5', '7'];
    let answer = 0;
    const DFS = (N, num753) => {
        // 753の数値を含んでいるかチェック
        const contains357 = array.map(val => num753.includes(val)).reduce((a, b) => a && b);
        // 桁数上限に達成
        if(N.length == num753.length){
            if(contains357 && Number(num753) <= Number(N)) answer++;
            return; 
        }
        // 現在の数値をチェック
        if(contains357 && Number(num753) <= Number(N)) answer++;
        // 3,5,7を入れていく
        array.forEach(val => DFS(N, num753 + val));
    }
    // 一桁目を入れる
    array.forEach(val => DFS(N, val));
    console.log(answer);
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 37384
from collections import defaultdict,deque
import sys,heapq,bisect,math,itertools,string,queue,copy,time
sys.setrecursionlimit(10**8)
INF = float('inf')
mod = 10**9+7
eps = 10**-7
def inp(): return int(input())
def inpl(): return list(map(int, input().split()))
def inpl_str(): return list(input().split())

N,M = inpl()
lines = defaultdict(set)
for _ in range(M):
    s,t,d = inpl()
    lines[s].add((t,d))


S = 0
dp = [[INF]*N for _ in range(1<<(N+1)-1)]
dp[0][S] = 0
for bit in range(1<<(N+1)-1):
    for s in range(N):
        now = dp[bit][s]
        for t,c in lines[s]:
            if bit & (1<<t): # 訪れたことがある
                continue
            else:
                dp[bit+(1<<t)][t] = min(dp[bit+(1<<t)][t],now+c)

ans = dp[-1][S]
if ans == INF:
    print(-1)
else:
    print(dp[-1][S])



Measured memory_bytes: 21144
#include <iostream>
#include <bitset>
#include <fstream>
#include <string>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <vector>
#include <algorithm>
#include <numeric>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#include <functional>
#include <cctype>
#include <list>
#include <limits>
#include <unordered_map>
#include <cassert>
//#include <boost/multiprecision/cpp_int.hpp>

const double EPS = (1e-10);


using namespace std;
using Int = long long;
//using namespace boost::multiprecision;

const Int MOD = 998244353;

Int mod_pow(Int x, Int n) {
    Int res = 1;
    while(n > 0) {
        if(n & 1) res = (res * x) % MOD; //ビット演算(最下位ビットが1のとき)
        x = (x * x) % MOD;
        n >>= 1; //右シフト(n = n >> 1)
    }
    return res;
}

//最大公約数
template<typename T>
T gcd(T a, T b) {
    return b != 0 ? gcd(b, a % b) : a;
}

//最小公倍数
template<typename T>
T lcm(T a, T b) {
    return a * b / gcd(a, b);
}

//入出力高速化(非同期化)
void fast_input() {
    cin.tie(0);
    ios::sync_with_stdio(false);
}

bool check(string &S, int mid) {
    bool ret = true;
    int before;
    for (int i = S.length() - mid; i < mid; i++) {
        if (i == S.length() - mid) before = S[i];
        else if (S[i] != before) {
            ret = false;
            break;
        }
    }
    return ret;
}

int main(void) {
    string S; cin >> S;
    int N = S.length();
    int ng, mid, ok;
    ng = N+1, ok = 1;
    while (abs(ok - ng) > 1){
        mid = (ok + ng) / 2;
        if (check(S, mid)){
            ok = mid;
        }else{
            ng = mid;
        }
    }
    cout << ok << endl;
}



Measured memory_bytes: 512
import sys

class Node():
    __slots__ = ['key', 'left', 'right']
    def __init__(self, key):
        self.key = key
        self.left, self.right = None, None
        
    def __str__(self):
        return self.key

root = None
def insert(z):
    global root
    x, y = root, None
    while x:
        y = x
        if z < x.key:
            x = x.left
        else:
            x = x.right
    
    if y == None:
        root = Node(z)
    elif z < y.key:
        y.left = Node(z)
    else:
        y.right = Node(z)
        
def preorder(x):
    return f" {x.key}" + preorder(x.left) + preorder(x.right) if x else ""

def inorder(x):
    return inorder(x.left) + f" {x.key}" + inorder(x.right) if x else ""
        
input()
node = {}
for s in sys.stdin:
    if s[0] == "p":
        pass
        print(inorder(root))
        print(preorder(root))
    else:
        insert(int(s[7:]))


Measured memory_bytes: 63332
#include<iostream>

using namespace std;

int main() {
	int n, x;
	bool isOver = false;

	while (!isOver) {
		cin >> n >> x;
		if (n == 0 && x == 0) {
			isOver = true;
			break;
		}
		else {
			int *numList = new int[n];
			int sum = 0;
			for (int i = 0; i < n; i++) {
				numList[i] = i + 1;
			}
			/* search for result  use x for minus*/
			for (int i = 0; i < n - 2; i++) {
				for (int j = i + 1; j < n - 1; j++) {
					if (((x - numList[i]-numList[j]) <= n)&& ((x - numList[i] - numList[j]) > (j+1))) {
						sum += 1;
					}
				}
			}
			cout << sum << endl;

			delete[] numList;
		}
	}

	//system("pause");
	return 0;
}

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

typedef long long int ll;
ll MOD = 1000000007;
ll INFL = 1ll << 60;
ll INF = 1 << 28;

// ====================================================================

int main() {
  int h, n;
  cin >> h >> n;
  vector<int> v(n);
  for (int i = 0; i < n; i++) { cin >> v[i]; }
  if (h <= accumulate(v.begin(), v.end(), 0)) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}


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

int main() {
  
  string s;
  cin >> s;
  
  if ( s[0] == s[1] && s[1] == s[2] ){
    cout << "No" << endl;
  }else{
    cout << "Yes" << endl;
  }
  
  
}



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

using namespace std;
int main() {
	int n;
	cin >> n;

	vector<int>d(n);

	for (int i = 0; i < n; i++) {
		cin >> d[i];
	}
	sort(d.begin(), d.end());

	int tmp = 0;
	int sum = 0;
	for (int i = 0; i < n;i++) {
		if (tmp != d[i]) sum++;
		tmp = d[i];
		

	}

	cout << sum << endl;
	return 0;
}

Measured memory_bytes: 256
//by (111110101)2
#include<iostream>
#include<sstream>
#include<fstream>
#include<string>
#include<vector>
#include<deque>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<algorithm>
#include<functional>
#include<utility>
#include<bitset>
#include<cmath>
#include<cstdlib>
#include<ctime>
#include<cstdio>
using namespace std;
int a,b;
bool vis[10];
int main()
{
	cin>>a>>b;
	vis[a]=true;
	vis[b]=true;
	for(int i=1;i<=3;i++)
	{
		if(!vis[i])
		{
			cout<<i<<endl;
			return 0;
		}
	}
	return 0;
}

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

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

  if (a < b) {
    cout << "a < b" << endl;
  } else if (a > b) {
    cout << "a > b" << endl;
  } else if (a == b) {
    cout << "a == b" << endl;
  }
  return 0;
}


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

using namespace std;

#define FOR(i, a, b) for(ll i = (a); i < (b); ++i)
#define FORR(i, a, b) for(ll i = (a); i > (b); --i)
#define REP(i, n) for(ll i = 0; i < (n); ++i)
#define REPR(i, n) for(ll i = n; i >= 0; i--)
#define FOREACH(x, a) for(auto &(x) : (a))
#define VECCIN(x)                                                              \
    for(auto &youso_ : (x)) cin >> youso_
#define mp make_pair
#define bitcnt __builtin_popcount
#define SZ(x) ((ll)(x).size())
#define All(a) (a).begin(), (a).end()
template <typename T = long long> inline T IN() {
    T x;
    cin >> x;
    return (x);
}
inline void CIN() {}
template <class Head, class... Tail>
inline void CIN(Head &&head, Tail &&... tail) {
    cin >> head;
    CIN(move(tail)...);
}
#define CINT(...)                                                              \
    int __VA_ARGS__;                                                           \
    CIN(__VA_ARGS__)
#define LCIN(...)                                                              \
    ll __VA_ARGS__;                                                            \
    CIN(__VA_ARGS__)
#define SCIN(...)                                                              \
    string __VA_ARGS__;                                                        \
    CIN(__VA_ARGS__)
#define Yes(a) cout << (a ? "Yes" : "No") << "\n"
#define YES(a) cout << (a ? "YES" : "NO") << "\n"
#define Printv(v)                                                              \
    FOREACH(x, v) { cout << x << " "; }                                        \
    cout << "\n";

typedef long long ll;
typedef unsigned long long ul;
typedef vector<int> V;
typedef vector<ll> VL;
typedef pair<ll, ll> PL;
typedef priority_queue<ll> PQ;
typedef priority_queue<ll, V, greater<ll>> PQG;

const int INF = 1e9;
const int MOD = 1e9 + 7;
// const int MOD = 998244353;
const ll LINF = 1e18;
const ll dx[] = {1, -1, 0, 0};
const ll dy[] = {0, 0, 1, -1};

ll N, M;
vector<PL> rl, lr;

int main() {
    cin >> N >> M;
    REP(i, M) {
        LCIN(L, R);
        lr.emplace_back(L, R);
        rl.emplace_back(R, L);
    }
    sort(All(rl));
    sort(All(lr), greater<PL>());
    ll ans = rl[0].first - lr[0].first + 1;
    cout << (ans > 0 ? ans : 0) << "\n";
}

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

#define INF 1e9+5
#define ll long long
#define lb lower_bound
#define ub upper_bound
#define pushf push_front
#define pushb push_back
#define popf pop_front
#define popb pop_back

int eucs[205][205], k;
int gcd(int, int);
ll sum;

int main(){
        scanf("%d", &k);
        for(int a=1; a<=k; ++a)
                for(int b=1; b<=k; ++b)
                        for(int c=1; c<=k; ++c)
                                sum+=gcd(a, gcd(b, c));

        printf("%lld", sum);

        return 0;
}

int gcd(int x, int y){
        if(eucs[x][y]) return eucs[x][y];
        if(eucs[y][x]) return eucs[y][x];

        if(x<y) swap(x, y);
        if(x%y==0) {
                eucs[x][y]=eucs[y][x]=y;
                return eucs[x][y];
        }

        return gcd(y, x%y);
}

Measured memory_bytes: 3940
#include <iostream>
#include <algorithm>


using namespace std;

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

	int n;
	cin >> n;
	while( n != 0){
		int t, d;
		int tile[500][2];	
		tile[0][0] = 200;
		tile[0][1] = 200;
		for(int i = 1; i < n; i++){
			cin >> t >> d;
			tile[i][0] = tile[t][0] + dx[d];
			tile[i][1] = tile[t][1] + dy[d];
		}
		int tmin[2];
		tmin[0] = tmin[1] = 1000;
		int tmax[2];
		tmax[0] = tmax[1] = 0;
		
		for(int i = 0; i < n; i++){
			tmin[0] = min(tmin[0], tile[i][0]);
			tmax[0] = max(tmax[0], tile[i][0]);
			tmin[1] = min(tmin[1], tile[i][1]);
			tmax[1] = max(tmax[1], tile[i][1]);
		}

		cout << (tmax[0] - tmin[0]) + 1<< ' ' << (tmax[1] - tmin[1]) + 1<< endl;
		cin >> n;
	}
	return 0;
}

Measured memory_bytes: 1160
n,c=map(int,input().split())
r=[[0,0]for _ in range(c)]
for s,t,c in sorted(list(map(int,input().split()))for _ in range(n)):
    for m in r:
        if m[0]<s-0.5or m[1]==c and m[0]<=s:
            m[0],m[1]=t,c
            break
print(len(list(filter(lambda x:x!=[0,0],r))))

Measured memory_bytes: 27892
n = int(input())

travel = list()
#start point
travel.append((0,0,0))

for i in range(n):
  travel.append(tuple(map(int,input().split())))


for j in range(n):
  dist = abs(travel[j][0]-travel[j+1][0])

  dd = abs(travel[j][1]-travel[j+1][1])+abs(travel[j][2]-travel[j+1][2])
  
#fail
  if dist < dd or (dd%2 != dist%2):
    print("No")
    exit(0) 

print("Yes")  


Measured memory_bytes: 17320
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        MyScanner in = new MyScanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        C solver = new C();
        solver.solve(1, in, out);
        out.close();
    }

    static class C {
        public void solve(int testNumber, MyScanner in, PrintWriter out) {
            long a = in.nextLong();
            long b = in.nextLong();
            long c = in.nextLong();
            if (c - a - b <= 0) {
                out.println("No");
                return;
            }
            long cc = c - a - b;
            cc *= cc;
            long ab = 4 * a * b;
            out.println(ab < cc ? "Yes" : "No");
        }

    }

    static class MyScanner {
        private BufferedReader in;
        private StringTokenizer st;

        public MyScanner(InputStream stream) {
            in = new BufferedReader(new InputStreamReader(stream));
        }

        public String next() {
            while (st == null || !st.hasMoreTokens()) {
                try {
                    String rl = in.readLine();
                    if (rl == null) {
                        return null;
                    }
                    st = new StringTokenizer(rl);
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return st.nextToken();
        }

        public long nextLong() {
            return Long.parseLong(next());
        }

    }
}



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

using namespace std;

int n;

void solve() {
	cin >> n;
	n %= 1000, n = 1000 - n;
	cout << n % 1000 << endl;
}

int main() {
	ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);    
    //freopen("input.txt", "r", stdin);
	solve();
    return 0;
}

Measured memory_bytes: 3648
import sys

def main():
    n = int(input())
    A = list(map(int, sys.stdin.readline().split()))

    ans = 1

    if 0 in A:
        print(0)
        sys.exit()

    for i in range(n):
        ans *= A[i]
        if ans > 10 ** 18:
            print('-1')
            sys.exit()

    print(ans)


if __name__ == '__main__':
    main()

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

int main(){
    char s[4];
    int n[4];
    int x, y;
    for(int i=0; i<4; i++){
        cin >> s[i];
        if(s[i]=='0') n[i]=0;
        else if(s[i]=='1') n[i]=1;
        else if(s[i]=='2') n[i]=2;
        else if(s[i]=='3') n[i]=3;
        else if(s[i]=='4') n[i]=4;
        else if(s[i]=='5') n[i]=5;
        else if(s[i]=='6') n[i]=6;
        else if(s[i]=='7') n[i]=7;
        else if(s[i]=='8') n[i]=8;
        else if(s[i]=='9') n[i]=9;
    }

    x=n[0]*10+n[1];
    y=n[2]*10+n[3];

    if(1<=x&&x<=12){
        if(1<=y&&y<=12){
            cout << "AMBIGUOUS";
        }
        else{
            cout << "MMYY";
        }
    }
    else{
        if(1<=y&&y<=12){
            cout << "YYMM";
        }
        else{
            cout << "NA";
        }
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>
#include <cmath>
#include <algorithm>
#include <string>
#define shosu(x) fixed<<setprecision(x)
using namespace std;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,P> pip;
typedef long long ll;
const int inf=(1<<31)-1;
const double pi=acos(-1);

double a,b,x=0,y=0,sit=0;
char t;

int main(){
	while(cin>>a>>t>>b){
		if(!a&&!b) break;
		x+=a*sin(sit/180*pi);
		y+=a*cos(sit/180*pi);
		sit+=b;
	}
	cout<<(int)x<<endl;
	cout<<(int)y<<endl;
}

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

int main() {
	int a[10];

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

	for (int i = 1; i < 10; i++) {
		int key = a[i];
		int j = i-1;
		while (j >= 0 && a[j] < key) {
			a[j+1] = a[j];
			j--;
		}
		a[j+1] = key;
	}

	for (int i = 0; i < 3; i++) {
		cout << a[i] << endl;
	}

	return 0;
}

Measured memory_bytes: 3072
#include<iostream>
#include<string>

using namespace std;

int main(){

    string cards;
    char tmp;
    unsigned int num_of_shuffle, i, j, top;
    
    while(1){

        cin >> cards;
        
        if( cards == "-") break;

        cin >> num_of_shuffle;

        for( i = 0; i < num_of_shuffle; i++ ){
            cin >> top;
            for( j = 0; j < top; j++){
                tmp = cards[0];
                cards.erase(cards.begin());
                cards.insert(cards.end(), tmp);
            }
        }

        cout << cards << endl;

    }

    return 0;

}


Measured memory_bytes: 3156
#include<iostream>
using namespace std;
#define rep(i,a) for(int i=0;i<a;i++)
int main(void){
  int maze[2][100][100];
  int n,m;
  int a,b,c,t;
  while(cin>>m>>n,n+m){
    rep(i,n)rep(j,n)rep(k,2)maze[k][i][j]=100000;
    rep(i,m){
      cin>>a>>b>>c>>t;
      maze[0][--a][--b]=c;
      maze[1][a][b]=t;
      maze[0][b][a]=c;
      maze[1][b][a]=t;
    }
    rep(k,n)rep(i,n)rep(j,n)rep(l,2)
      maze[l][i][j]=min(maze[l][i][j],maze[l][i][k]+maze[l][k][j]);
    cin>>m;
    //cout<<endl;rep(i,n)rep(j,n)cout<<maze[1][i][j]<<(j==n-1?'\n':' ');
    
    rep(i,m){
      cin>>a>>b>>c;
      cout<<maze[c][--a][--b]<<endl;
    }
  }
}

Measured memory_bytes: 1232
#include<stdio.h>
int main(void){
  long int N;
  scanf("%ld",&N);
  long int i = N%2;
  if(N == 1){
    i = 0;
  }else if(N == 2){
    i = 1;
  }else{
	switch(i){
	  case 0:
		i = N*(N-1)/2;
		break;
	  case 1:
		i = N*(N-1)/2;
        break;
	}
  }
  printf("%ld",i);
  return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <cstring>

using namespace std ;
int main ()
{
  int N ,x=0,y=0,z=0,c=0, i;
  cin >> N ;
string a[N];
for (int i =0;i<N;i++){
cin >> a[i] ;

if (a[i]=="AC")
x=x+1;
if (a[i]=="WA")
y=y+1;
if (a[i]=="TLE")
z=z+1;
if (a[i]=="RE")
c=c+1;
}
cout<<"AC x "<< x <<endl;
cout<<"WA x "<< y <<endl;
cout<<"TLE x "<< z<<endl;
cout<<"RE x "<< c <<endl;
    return 0 ;
}




Measured memory_bytes: 6780
# coding:utf-8

import sys

INF = float('inf')
MOD = 10 ** 9 + 7

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x) - 1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def II(): return int(sys.stdin.readline())
def SI(): return input()


def main():
    n = II()
    A = [II() for _ in range(n)]

    res = 0
    mod = 0
    for a in A:
        if not a:
            mod = 0
            continue
        q, mod = divmod(a + mod, 2)
        res += q

    return res


print(main())


Measured memory_bytes: 7072
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define LI list<int>
#define vct vector
#define D(a) (double)(a)
#define vi vct<int>
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vvi vct<vi>
#define vll vct<ll>
#define vvll vct<vll>
#define vpii vct<pii>
#define vpll vct<pll>
#define vb vct<bool>
#define vs vector<string>
#define all(a) a.begin(),a.end()
#define allr(a) a.rbegin(),a.rend()
#define mp(a,b) make_pair(a,b)
#define pb push_back
#define ff first
#define ss second
#define bg begin()
#define UNIQUE(X) (X).erase(unique(all(X)),(X).end())
#define ft cout<<"for test"<<endl;
#define read(v,a,n) for(int i=a; i<n; i++)cin>>v[i];
#define print(v) for(auto it:v)cout<<it<<' '; cout<<endl;
#define PI 2*acos(0.0)
#define yes cout<<"YES"<<endl
#define no cout<<"NO"<<endl
#define FIO ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define t_c int test,cs=1;cin>>test;while(test--)
#define rt return true
#define rf return false
///................function.....................///
#define siz(s) (int)(s.size())
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define mod 1000000007
#define dbg(a) cout << #a << " = " << a << " ";
///...........knight moves.....................///
///int dx[] = {+1,+1,-1,-1,+2,+2,-2,-2};
///int dy[] = {+2,-2,+2,-2,+1,-1,+1,-1};

int main()
{
    FIO;
    ///t_c
    {
        ll a,b,c;
        cin>>a>>b>>c;
        ll aa=(a%b==0)?0:1;
        a = (a/b)+aa;
        cout<<a*c<<endl;

    }

}


Measured memory_bytes: 3648
N = int(input()) #<=4000
S = list(input())

R_index = list()
G_index = list()
B_index = list()

for i in range(N):
    if S[i] == "R":
        R_index.append(i+1)
    elif S[i] == "G":
        G_index.append(i+1)
    if S[i] == "B":
        B_index.append(i+1)

#組 (i, j, k) (1≤i<j<k≤N) の数を求めてください。
#Si≠Sj かつ Si≠Sk かつ Sj≠Sk である
#j−i≠k−jの条件下で組み合わせる
#j−i=k−j
#↓
#2j−i=k ≡ 2j−k=i  ≡ (i+k)/2 = j はNGということ。

ans = len(R_index)*len(G_index)*len(B_index) #まず全通りを計算
B_set = set(B_index)

#NG分を除去する
for R in R_index:
    for G in G_index:
        #R,G,Bのi,j,kへのあてはめ方は6通り。大小関係にも注意
        #(R,G,B),(R,B,G),(G,B,R),(G,R,B),(B,R,G),(B,G,R)
        if (R+G)/2 in B_set:
            ans -= 1
        if 2*G-R in B_set:
            ans -= 1
        if  2*R-G in B_set:
            ans -= 1
        
print(ans)

Measured memory_bytes: 68852
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double ld;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const long long INF = 1LL << 60;
 
typedef pair<ll,ll> pairs;
vector<pairs> p;
bool pairCompare(const pair<double,ll>& firstElof, const pair<double,ll>& secondElof){
    return firstElof.first < secondElof.first;
}
#define MAX_N 1000100
bool x[MAX_N];
ll num[MAX_N];
ll fibl[MAX_N]={0};
 
ll fib(ll a){
    if (fibl[a]!=0)return fibl[a];
    if (a==0){
        return 0;
    }else if (a==1){
        return 1;
    }
    return fibl[a]=fib(a-1)+fib(a-2);
}
 
ll eratosthenes(ll n) {
    int p = 0;
    for (ll i=0; i<=n; ++i) x[i] = true;
    x[0] = x[1] = false;
    for(int i=2; i<=n; ++i) {
        if(x[i]) {
            p++;
            for(int j=2*i; j<=n; j+=i) x[j] = false;
        }
        
        num[i] = p;
    }
    return p;
}
 
ll gcd(ll a,ll b){
    if (a%b==0)return(b);
    else return(gcd(b,a%b));
}
 
ll keta(ll N){
    int tmp{};
    while( N > 0 ){
        tmp += ( N % 10 );
        N /= 10;
    }
    N = tmp;
    return N;
}

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



Measured memory_bytes: 256