akhauriyash/Code-Regression huggingface dataset:
/*

                   _ooOoo_
                  o8888888o
                  88" . "88
                  (| -_- |)
                  O\  =  /O
               ____/`---'\____
             .'  \\|     |//  `.
            /  \\|||  :  |||//  \
           /  _||||| -:- |||||-  \
           |   | \\\  -  /// |   |
           | \_|  ''\---/''  |   |
           \  .-\__  `-`  ___/-. /
         ___`. .'  /--.--\  `. . __
      ."" '<  `.___\_<|>_/___.'  >'"".
     | | :  `- \`.;`\ _ /`;.`/ - ` : | |
     \  \ `-.   \_ __\ /__ _/   .-` /  /
======`-.____`-.___\_____/___.-`____.-'======
                   `=---='
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
                    prayer
*/

// g++ -std=c++11 a.cpp
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<unordered_map>
#include<utility>
#include<cmath>
#include<random>
#include<cstring>
#include<queue>
#include<stack>
#include<bitset>
#include<cstdio>
#include<sstream>
#include<iomanip>
#include<assert.h>
#include<typeinfo>
#define loop(i,a,b) for(long long i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)
#define FOR(i,a) for(auto i:a)
#define pb push_back
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
#define show1d(v) {rep(_,v.size())cout<<" "<<v[_];cout<<endl;}
#define show2d(v) {rep(__,v.size())show1d(v[__]);}
using namespace std;
//kaewasuretyuui
typedef long long ll;
#define int ll
typedef int Def;
typedef pair<Def,Def> pii;
typedef vector<Def> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<Def,pii> pip;
typedef vector<pip>vip;
#define mt make_tuple
typedef tuple<int,int,int,int> tp;
typedef vector<tp> vt;
template<typename A,typename B>bool cmin(A &a,const B &b){return a>b?(a=b,true):false;}
template<typename A,typename B>bool cmax(A &a,const B &b){return a<b?(a=b,true):false;}
const double PI=acos(-1);
const double EPS=1e-9;
Def inf = sizeof(Def) == sizeof(long long) ? 2e18 : 1e9+10;
#define yes cout<<"Yes"<<"\n"
#define no cout<<"No"<<"\n"

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

	int n;
	cin>>n;
	string a,b,c;
	cin>>a>>b>>c;
	int out=0;
	rep(i,n){
		if(a[i]==b[i]&&a[i]==c[i]);
		else if(a[i]==b[i]||a[i]==c[i]||b[i]==c[i])out+=1;
		else out+=2;
	}
	cout<<out<<endl;
}


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

#define show(x) cerr << #x << " = " << x << endl ;
#define input_from_file freopen("input.txt","r",stdin)
#define output_to_file freopen("output.txt" , "w",stdout)
#define output_to_error freopen("error.txt" , "w" ,stderr)
#define fastio ios_base::sync_with_stdio(0)
#define endl '\n'

const int N = 2e5+5;
int arr[N];
int main()
{
	#ifdef LOCAL
        input_from_file;
        output_to_file;
        output_to_error;
    #endif
	fastio;cin.tie(0);cout.tie(0);
	int n , k , x;
	long long tot = 0;
	cin >> n >> k ; 
	for(int i = 1 ; i <= n ; ++i)
	{
		cin >> x ; arr[i] = x ;
	}
	sort(arr+1,arr+n+1);
	for(int i = 1 ; i <= n - k ; ++i)
		tot += arr[i];
	cout << tot ;

	return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
const long long MAXN = 1e5 + 10 ;
long long n , W ;
vector<long long> v , w ;
long long dp[110][MAXN] ;
long long dfs(long long x,long long curr){
    if ( x == n ){
        return 0 ;
    }
    if ( dp[x][curr] != -1 ) return dp[x][curr] ;
    long long choice1 = 0 + dfs(x+1,curr) ;
    long long choice2 = -1e18 ;
    if ( curr + w[x] <= W ){
        choice2 = v[x] + dfs(x+1,curr+w[x]) ;
    }
    long long ans = max(choice1,choice2);
    dp[x][curr] = ans ;
    return ans ;
}


int main(){
    memset(dp,-1,sizeof dp);
    cin >> n >> W ;
    v.resize(n) ;
    w.resize(n) ;
    for(int i=0;i<n;i++){
        cin >> w[i] >> v[i] ;
    }
    cout << dfs(0,0) << endl;
    return 0 ;
}



Measured memory_bytes: 86144
S = input()

if len(S) < 26:
    st = set(S)
    for c in range(26):
        if not chr(ord('a') + c) in st:
            S += chr(ord('a') + c)
            break
    print(S)
else:
    i = len(S) - 1
    while i - 1 >= 0 and ord(S[i]) < ord(S[i - 1]):
        i -= 1
    if i == 0:
        print(-1)
    else:
        next_chr = ord(S[i - 1]) - ord('a')
        st = set(S[i:])
        for c in range(next_chr + 1, 26):
            if chr(ord('a') + c) in st:
                print(S[:i - 1] + chr(ord('a') + c))
                break

Measured memory_bytes: 38256
#include<bits/stdc++.h>
using namespace std;
int main(){
	cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);
	int H, N; cin>>H>>N;
	vector<int> dmg(N), mp(N), dp(H+1, 1e9+7);
	dp[0]=0;
	for(int i=0;i<N;i++) cin>>dmg[i]>>mp[i];
	for(int i=0;i<N;i++){
		for(int h=0;h<=H;h++){
			if(dmg[i]+h>=H) dp[H]=min(dp[H], dp[h]+mp[i]);
			else dp[dmg[i]+h]=min(dp[dmg[i]+h],dp[h]+mp[i]);
		}
	}
	cout<<dp[H]<<endl;
	return 0;
}

Measured memory_bytes: 256
using System;

public class Range {
  static int Main(string[] args)
  {
    string inputData = Console.ReadLine();
    string[] dataArray = inputData.Split();
    int a = int.Parse(dataArray[0]);
    int b = int.Parse(dataArray[1]);
    int c = int.Parse(dataArray[2]);

    if(a < b && b < c) {
      Console.WriteLine("Yes");
    } else {
      Console.WriteLine("No");
    }
    return 0;
  }
}


Measured memory_bytes: 9008
//0009
#include <stdio.h>

//static unsigned char flag[125000] = {0};
static unsigned char flag[10000000] = {0};

void setFlag(int n)
{
	int idx = n / 8;
	int m = n % 8;

	flag[idx] |= (0x01 << m);
}
int getFlag(int n)
{
	int idx = n / 8;
	int m = n % 8;

	return flag[idx] & (0x01 << m);
}

void furui(int n)
{
	int i, j;
	flag[2] = 0;

	for (i = 2; i <= n; i++) {
		if (getFlag(i) != 0)
			continue;
		for (j = 2; i * j <= n; j++) {
			setFlag(i * j);
		}
	}
}

int count(int n)
{
	int i, sum = 0;

	for (i = 2; i <= n; i++) {
		if (getFlag(i) == 0)
			sum++;
	}
	return sum;
}

int main()
{
	int i, n, sum = 0;

	while (scanf("%d", &n) != EOF) {
		furui(n);
		sum = count(n);
		printf("%d\n", sum);
	}
	return 0;
}

Measured memory_bytes: 528
#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long i,j,k,n,m,s;
    cin>>n;s=0;
    long long a[n+3],b,c[n+3];
    for(i=0;i<=n;i++) scanf("%lld",&a[i]);
    for(i=0;i<n;i++){
        scanf("%lld",&b);
        if(b>=a[i]){s+=a[i];b-=a[i];}
        else {s+=b;b=0;}
        if(b>=a[i+1]){s+=a[i+1];a[i+1]=0;}
        else {s+=b;a[i+1]-=b;}
    } printf("%lld",s);
}


Measured memory_bytes: 4480
#include<stdio.h>

int main(){

  int a,b,sum,i=0,j=0,keta=1,count=1,data[200];

  while(scanf("%d %d",&a,&b)!=EOF){
    for(j=0,keta=1,count=1;j<7;j++,keta++,count=count*10){
      sum = (a+b) / count;
      if( -1 < sum && sum < 10){
        printf("%d\n",keta);
        break;
      }
    }
  }

  return 0;

}

Measured memory_bytes: 600
#include <bits/stdc++.h>
 
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rrep(i, n) for(int i = ((int)(n)-1); i >= 0; i--)
#define all(x) (x).begin(),(x).end()
 
using namespace std;
using ll = long long;
 
struct edge { int to, cost; };
 
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> P;
 
const int INF = ~(1<<31);
const int MOD = 1e9+7;
const double EPS = 1e-10;
const double PI = acos(-1.0);
 
const int mx4[] = {0,1,0,-1};
const int my4[] = {1,0,-1,0};
const int mx8[] = {0,1,1,1,0,-1,-1,-1};
const int my8[] = {1,1,0,-1,-1,-1,0,1};

int main(){
	int n;
	cin >> n;
	vi h(n);
	rep(i,n) cin >> h[i];

	if(n == 1){
		cout << 0 << endl;
		return 0;
	}

	int cnt = 0,ans = -INF;
	for(int i = 1; i < n; i++){
		if(h[i-1] >= h[i]) cnt++;
		if(h[i-1] < h[i] || i == n-1){
			ans = max(ans,cnt);
			cnt = 0;
		}
	}
	cout << ans << endl;

	return 0;
}

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

int main() {
    using vi = vector<int>;
    
    long long a,b,c,k;
    cin >> a >> b >> c >> k;
    if(k <= a+b){
        if(k<=a){
            cout << k << endl;
        }else{
cout << a << endl;
        }
        
    }else{
        cout << a-(k-(a+b)) << endl;
    }
}

Measured memory_bytes: 3548
#include<bits/stdc++.h>
#define rep(i,N) for(int i=0;i<(N);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
using namespace std;
const long long MOD = 1e9 + 7;
const long long INF = 1e12;
const int inf = 1e9;
const int mod = 1e9+7;
typedef long long ll;
typedef pair<ll,int> P;
typedef set<int> S;
int main(){
    cout << fixed << setprecision(10);
    ll n,a,b;
    cin >> n >> a >> b;
    vector<ll> v(n);
    rep(i,n) cin >> v[i];
    ll sum = 0;
    rep(i,n-1){
        sum += min((v[i+1]-v[i])*a,b);
    }
    cout << sum << endl;
    return 0;
}

Measured memory_bytes: 4048
import java.util.Scanner;

public class Main {
	public static void main(String args[]) {
		Scanner scan = new Scanner(System.in);

		int a = scan.nextInt();
		int b = scan.nextInt();

		System.out.println(String.format("%d %d %.5f", a/b, a%b, 1.0*a/b));
	}
}



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

public class Main {
	public static void main(String[] args) throws Throwable {
		MyScanner sc = new MyScanner();
		String s = sc.nextString();
		String[] strArr = s.split("");
		boolean easy = true;
		for (int i = 0; i < strArr.length; i++) {
			if (i % 2 == 0) {
				// 奇数番目
				if (strArr[i].equals("L")) {
					// 奇数番目にLがあると踏みにくい
					easy = false;
					break;
				}
			} else {
				// 偶数番目
				if (strArr[i].equals("R")) {
					// 偶数番目にRがあると踏みにくい
					easy = false;
					break;
				}
			}
		}
		if (easy) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}

	}

	static class MyScanner {

		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		public String nextString() throws IOException {
			return br.readLine();
		}

		public int nextInt() throws NumberFormatException, IOException {
			return Integer.parseInt(nextString());
		}

		public String[] nextStringArr() throws IOException {
			return nextString().split(" ");
		}

		public Integer[] nextIntArr() throws IOException {
			String[] strArr = nextStringArr();
			Integer[] intArr = new Integer[strArr.length];
			for (int i = 0; i < strArr.length; i++) {
				intArr[i] = Integer.parseInt(strArr[i]);
			}
			return intArr;
		}
	}

}


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

int main() {
  int N;
  string S;
  cin >> N >> S;
  if (N%2 == 1) 
    cout << "No" << endl;
  else {
    int count = 0;
    for (int i = 0; i < N/2; i++) {
      if (S.at(i) != S.at(N/2 + i))
        count++;
    }
    if (count == 0)
      cout << "Yes" << endl;
    else
      cout << "No" << endl;
  }
    
}


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

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

int main() {
  int H, W;
  cin >> H >> W;
  vector<vector<int>> c(10, vector<int>(10, 0));
  rep(i,10){
    rep(j,10){
      cin >> c[i][j];
    }
  }
  vector<vector<int>> A(H, vector<int>(W, 0));
  rep(i,H){
    rep(j,W){
      cin >> A[i][j];
    }
  }

  // 各数値を1に変える最小コストを予め計算する
  rep(k,10){
    rep(i,10){
      rep(j,10){
        c[i][j] = min(c[i][j], c[i][k] + c[k][j]);
      }
    }
  }
  int cost = 0;
  rep(i,H){
    rep(j,W){
      if(-1 != A[i][j]){
        cost += c[A[i][j]][1];
      }
    }
  }
  cout << cost << endl;
}

Measured memory_bytes: 384
#include <iostream>
#include <vector>
#include <map>
#include <cstdio>
#include <string>
#include <algorithm>
using namespace std;

int main(void){
	int D;
	cin >> D;
	if (D == 25)
		cout << "Christmas" << endl;
	else if(D == 24)
		cout << "Christmas Eve" << endl;
	else if(D == 23)
		cout << "Christmas Eve Eve" << endl;
	else 
		cout << "Christmas Eve Eve Eve" << endl;
	return 0;
}



Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <iostream>
#include <sstream>
#include <cmath>
#include <algorithm>
#include <queue>
#include <stack>
#include <limits>
#include <map>
#include <string>
#include <cstring>
#include <set>
#include <deque>

using namespace std;

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

static const double eps = 10e-9;

int main(){
	int n;
	scanf("%d",&n);
		for(int i=0;i<n;i++){
			int src,dst;
			scanf("%d %d",&src,&dst);
			if(src <= 5 && dst <= 5){
				if(src < dst){
					for(int j=src;j<=dst;j++){
						printf("%d%s",j,j == dst ? "\n" : " ");
					}
				}
				else if(src > dst){
					for(int j=src;j>=dst;j--){
						printf("%d%s",j,j == dst ? "\n" : " ");
					}
				}
			}
			else if(src >= 5 && dst >= 5){
				if(src < dst){
					for(int j=src;j<=dst;j++){
						printf("%d%s",j,j == dst ? "\n" : " ");
					}
				}
				else if(src > dst){
					for(int j=src;j<=9;j++){
						printf("%d ",j);
					}

					if(dst == 5){
						cout << 5 << endl;
						continue;
					}
					for(int j=5;j>=0;j--){
						printf("%d ",j);
					}

					for(int j=1;j<=4;j++){
						printf("%d ",j);
					}

					for(int j=5;j<=dst;j++){
						printf("%d%s",j,j == dst ? "\n" : " ");
					}
				}
			}

			else{
				if(src < dst){
					for(int j=src;j<=dst;j++){
						printf("%d%s",j,j == dst ? "\n" : " ");
					}
				}
				else if(src > dst){
					for(int j=src;j<=9;j++){
						printf("%d ",j);
					}

					for(int j=5;j>=dst;j--){
						printf("%d%s",j,j == dst ? "\n" : " ");
					}
				}
			}

		}
}

Measured memory_bytes: 0
#include <iostream>
#include <string>
using namespace std;
bool a[] = {
  true,true,true,true,true,true,true,false,false,false,false,false,false,
  false,false,false,true,true,true,true,false,true,true,true,false,true,
};
int main()
{
  string s;
  int c,i;
  bool b;
  while(cin >> s, s != "#"){
    b = a[s[0]-'a'];
    c = 0;
    for(i=1;i<s.length();i++){
      if(b != a[s[i]-'a']){
	c++;
	b = a[s[i]-'a'];
      }
    }
    cout << c << endl;
  }
  return 0;
}

Measured memory_bytes: 0
//Zory-2020
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
// typedef __int128 ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
#define FR first
#define SE second
#define MP make_pair
#define PB push_back
#define vc vector
#define db double
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
#define bin(x) (1ll<<(x))
#define fo(i,l,r) for(int i=(l),I=(r);i<=I;i++)
#define fd(i,r,l) for(int i=(r),I=(l);i>=I;i--)
#define mem(x,val) memset(x,val,sizeof x)
#define Swap(a,b,n) for(int I=0;I<=n;I++) swap(a[I],b[I])
#define PC __builtin_popcountll
#ifdef DEBUG
#define DD 1
#else
#define DD 0
#endif
#define Debug if(DD) printf("line %d\n",__LINE__)
#define deb(x) if(DD) cerr<<#x<<'='<<x<<endl
#define debug if(DD) printf
namespace mine
{
	ll qread()
	{
		ll ans=0,f=1;char c=getchar();
		while(c<'0' or c>'9') {if(c=='-')f=-1;c=getchar();}
		while('0'<=c and c<='9') ans=ans*10+c-'0',c=getchar();
		return ans*f;
	}
	void write(ll num){if(num<0) putchar('-'),num=-num;if(num>=10) write(num/10);putchar('0'+num%10);}
	void write1(ll num){write(num);putchar(' ');}
	void write2(ll num){write(num);putchar('\n');}
	template<typename T>inline bool chmax(T&a,const T&b){return a<b?a=b,1:0;}
	template<typename T>inline bool chmin(T&a,const T&b){return a>b?a=b,1:0;}
	ll gcd(ll x,ll y){return y?gcd(y,x%y):x;}
	bool IN(ll x,ll l,ll r){return l<=x and x<=r;}
	void gg(){puts("No");exit(0);}
	
	const db eps=1e-8;
	const int INF=0x3f3f3f3f;
	const int MOD=1e9+7;
	int mm(const int x){return x>=MOD?x-MOD:x;}
	template<typename T> void add(T &x,const int &y){x=(x+y>=MOD?x+y-MOD:x+y);}
	ll qpower(ll x,ll e,int mod=MOD){ll ans=1;while(e){if(e&1)ans=ans*x%mod;x=x*x%mod;e>>=1;}return ans;}
	ll invm(ll x){return qpower(x,MOD-2);}
	const int M=5e6+10;
	ll fac[M],facinv[M],Inv[M];ll C(int n,int m){return n<0 or n<m?0:fac[n]*facinv[m]%MOD*facinv[n-m]%MOD;}
	void PRE()
	{
		fac[0]=1;fo(i,1,M-1) fac[i]=fac[i-1]*i%MOD;
		facinv[M-1]=invm(fac[M-1]);fd(i,M-1,1) facinv[i-1]=facinv[i]*i%MOD;
		Inv[1]=1;fo(i,2,M-1) Inv[i]=(MOD-MOD/i)*Inv[MOD%i]%MOD;
	}
	const int N=3e3+10;
	//------------------FIXED------------------
	pii a[N];int b[N*N];
	void main()
	{
		int n=qread();fo(i,1,n) a[i]={qread(),i};sort(a+1,a+n+1);
		fo(i,1,n){ int wt=a[i].SE-1;b[a[i].FR]=a[i].SE;fo(j,1,a[i].FR-1)if(!b[j] and wt)b[j]=a[i].SE,wt--;if(wt)gg(); }
		fd(i,n,1){ int wt=n-a[i].SE;fo(j,a[i].FR+1,n*n)if(!b[j] and wt)b[j]=a[i].SE,wt--;if(wt)gg(); }
		puts("Yes");fo(i,1,n*n) write1(b[i]);
	}
};//变量重名！
signed main()
{
	#ifdef DEBUG
	//freopen("a.in","r",stdin);
	freopen("z.txt","r",stdin);
	//freopen("a.out","w",stdout);
	#endif
	srand(time(0));
	mine::PRE();//线性预处理模意义
	mine::main();
	if(DD) cerr<<"\n---------------------Zory---------------------\nTime: " <<1.0*clock()/CLOCKS_PER_SEC<<"s";
}

Measured memory_bytes: 119936
// 失敗するからこそ そこから立ち向かって行く強さがあってそんな強さが本当の強さだと私は思うから
// ぜったいあきらめない
#if defined(DAIJOBU)
#include "/home/ichigo/includes.hpp"
#include "/home/ichigo/debug.hpp"
#define deb(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#include <bits/stdc++.h>
#define deb(x...)
#endif
#define FIO {ios::sync_with_stdio(0);cin.tie(nullptr);cout.tie(nullptr);}

using namespace std;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());


int main(){
	FIO
	
	int a, b, c;
	cin >> a >> b >> c;
	map<int, int> m;
	m[a]++;m[b]++;m[c]++;
	if(m[a] == 1)cout << a << '\n';
	if(m[b] == 1)cout << b << '\n';
	if(m[c] == 1)cout << c << '\n';
	
 	return 0; 
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main{
    public static void main(String[]args){
        Scanner sc = new Scanner(System.in);
        while(true){
int H = sc.nextInt();
int W = sc.nextInt();
int i=0,k=0;

if(H==0&&W==0){
    break;
}

for(i=0;i<H;i++){
    for(k=0;k<W;k++){
        if((i+k)%2 == 0){
            System.out.printf("#");
        }else{
            System.out.printf(".");
    }
     
}   System.out.printf("\n"); 
    }
    System.out.printf("\n"); 
}
    }
}


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

const int MAX_N = 100010;
int main(void) {
	int N, M; cin >> N >> M;
	vector<int> H(N+1), v(N+1);

	for (int i = 1; i <= N; i++) {
		cin >> H[i];
	}

	for (int i = 0; i < M; i++) {
		int a, b; 
		cin >> a >> b;
		v[a] = max(v[a], H[b]);
		v[b] = max(v[b], H[a]);
	}

	int ans = 0;
	for (int i = 1; i <= N; i++) {
		if (H[i] > v[i]) ans++;
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 4048
#include <iostream>
#include <algorithm>
#include <functional>
#include <cmath>
#include <utility>
#include <tuple>
#include <vector>
#include <map>
#include <set>
#include <unordered_map>
#include <queue>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<vector<int,int>> vii;
#define rep(i,n) for (int i=0;i<n;i++)

ll mod = 1e9+7;

//約数列挙
vector<int> div(int a){
    vector<int> x;
    for (int i=1;i<=sqrt(a);i++){
        if (a%i==0){
            if (i*i==a) x.push_back(i);
            else{
                x.push_back(i);
                x.push_back(a/i);
            }
        }
    }
    return x;
}

//最大公約数
int gcd(int a,int b){
    if (a<b) swap(a,b);
    if (b==0) return a;
    else gcd(b,a%b);
    return 0;
}

int func(map<int,int> mp){
    int mx = 0;
    int cnt = 0;
    for (auto itr=mp.begin();itr!=mp.end();itr++){
        mx = max(mx,itr->second);
        cnt += itr->second;
    }
    cnt -= mx;
    return cnt;
}

int main(){
    string s;
    cin >> s;
    vector<int> l(s.size()+1,0);
    l[0] = 0;
    vector<int> r(s.size()+1,0);
    r[0] = 0;
    for (int i=0;i<s.size();i++){
        if (s[i]=='<'){
            l[i+1] = l[i] + 1;
        }
    }
    for (int i=s.size()-1;i>=0;i--){
        if (s[i]=='>'){
            r[i] = r[i+1] + 1;
        }
    }
    ll ans = 0;
    for (int i=0;i<l.size();i++){
        ans += max(l[i],r[i]);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 4740
#include <set>
#include <map>
#include <list>
#include <queue>
#include <stack>
#include <cmath>
#include <ctime>
#include <cstdio>
#include <vector>
#include <string>
#include <bitset>
#include <cctype>
#include <cstdlib>
#include <cstring>
#include <utility>
#include <numeric>
#include <complex>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <cassert>
#include <iostream>
#include <iterator>
#include <algorithm>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const double EPS = 1e-9;
#define rep(i, n) REP(i, 0, n)
#define REP(i, x, n) for(int i = x; i < (int)(n); i++)
#define rrep(i, n) RREP(i, 0, n)
#define RREP(i, x, n) for(int i = (int)(n) - 1 - (int)(x); i >= 0; i--)

int main(void){
    // Your code here!
    int X;
    cin >> X;
    ll s = 5000;
    for(ll a = -s; a <= s; a++){
        for(ll b = -s; b <= s; b++){
            //cout << a*a*a*a*a - b*b*b*b*b << endl;
            if(a*a*a*a*a - b*b*b*b*b == X) {
                cout << a << " " << b << endl;
                return 0;
            }
        }
    }
}


Measured memory_bytes: 3188
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
#define yn {puts("Yes");}else{puts("No");}
#define MAX_N 200005

int main() {
    int n;
    cin >> n;
    int a[n];
    rep(i,n)cin >> a[i];
    sort(a,a+n);
    rep(i,n-1)if(a[i] == a[i+1]){
        cout << "NO" << endl;
        return 0;
    }
    cout << "YES" << endl;
    return 0;
}
 
 


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int n,d,b[15][15];
bool check(int a[],int b[],int d){
    int dis=0;
    for(int i=1;i<=d;i++)
        dis+=(a[i]-b[i])*(a[i]-b[i]);
    int t=sqrt(dis);
    return dis==t*t;
}
int main(){
    cin>>n>>d;
    for(int i=1;i<=n;i++){
        for(int j=1;j<=d;j++)
            cin>>b[i][j];
    }
    int ans=0;
    for(int i=1;i<=n;i++){
        for(int j=i+1;j<=n;j++){
            if(check(b[i],b[j],d))
                ans++;
        }
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 256
N,M,K = (int(a) for a in input().split())
A = list(map(int,input().split()))
B = list(map(int,input().split()))
a = [0]*(N+1)
b = [0]*(M+1)
for i in range(N) :
    a[i+1] = a[i] + A[i]
for i in range(M) :
    b[i+1] = b[i] + B[i]

ans = 0
j = M
for i in range(N+1) :
    if a[i] > K :
        break
    while b[j] + a[i] > K :
        j -= 1
    ans = max(ans,i+j)
print(ans)

Measured memory_bytes: 47460
import sys
stdin = sys.stdin

def li(): return [int(x) for x in stdin.readline().split()]
def li_(): return [int(x)-1 for x in stdin.readline().split()]
def lf(): return [float(x) for x in stdin.readline().split()]
def ls(): return stdin.readline().split()
def ns(): return stdin.readline().rstrip()
def lc(): return list(ns())
def ni(): return int(ns())
def nf(): return float(ns())

# nの逆元のリスト
def inv_mod(n:int, mod:int) -> list:
    inv = [0,1]
    for i in range(2,n+1):
        inv.append(mod - ((mod//i)*inv[mod%i]) % mod)
    return inv
       
# nの階乗のリスト
def fact(n:int, mod:int) -> list:
    fac = [1,1]
    res = 1
    for i in range(2,n+1):
        res = res*i%mod
        fac.append(res)
    return fac

# nの階乗の逆元のリスト
def fact_inv(n:int, inv:list, mod:int) -> list:
    facInv = [1,1]
    for i in range(2,n+1):
        facInv.append(facInv[i-1]*inv[i] % mod)
    return facInv
        
# 二項係数
def nCr(n:int, r:int, mod:int, fac:list, facInv:list) -> int:
    if not (0<=r and r<=n):
        return 0
    
    return ((fac[n]*facInv[r]) % mod) * facInv[n-r] % mod

from itertools import accumulate
from collections import Counter

n,a,b = li()
v = li()

v.sort(reverse=True)
v_cum = list(accumulate(v))

ans_cand = []

# 貪欲に最大値を選ぶ
for i in range(a,b+1):
    ans_cand.append(v_cum[i-1] / i)
    
ans = max(ans_cand)
opt_i = a + ans_cand.index(ans) - 1

cnt_v = Counter(v)
opt_set = v[:opt_i+1]

# 貪欲最大が何通りできるか考える
MOD = 46116646144580591
inv = inv_mod(n, MOD)
fac = fact(n, MOD)
facInv = fact_inv(n,inv, MOD)

pat = 0

if v[0] == v[opt_i]:
    for i in range(a, min(b, cnt_v[v[0]]) + 1):
        pat += nCr(cnt_v[v[0]], i, MOD, fac, facInv)

else:
    cnt_opt = Counter(opt_set)
    pat = nCr(cnt_v[v[opt_i]], cnt_opt[v[opt_i]], MOD, fac, facInv)


        
print(ans)
print(pat)

Measured memory_bytes: 3444
import std.stdio, std.conv, std.string, std.array, std.range, std.algorithm, std.container;
import std.math, std.random, std.bigint, std.datetime, std.format;
void main(string[] args){ if(args.length > 1) if(args[1] == "-debug") DEBUG = 1; solve(); }
void log()(){ writeln(""); } void log(T, A ...)(T t, lazy A a){ if(DEBUG) write(t, " "), log(a); } bool DEBUG = 0; 
string rstring(){ static string[] ss; while(!ss.length) ss = readln.chomp.split; string res = ss[0]; ss.popFront; return res; }
T rtype(T)(){ return rstring.to!T; } alias rint = rtype!int, rlong = rtype!long, rreal = rtype!real;
T[] rtypes(T)(int n){ return n.iota.map!(i => rtype!T()).array; } alias rint = rtypes!int, rlong = rtypes!long, rreal = rtypes!real;
T[][] rtypess(T)(int n, int m){ return n.iota.map!(i => rtypes!T(m)).array; } alias rint = rtypess!int, rlong = rtypess!long, rreal = rtypess!real;
T chmin(T)(ref T x, T y){ if(x > y) x = y; return x; } T chmax(T)(ref T x, T y){ if(x < y) x = y; return x; }

// ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- //

void solve(){
	string s = readln.chomp;
	if(s == "AAA" || s == "BBB") "No".writeln;
	else "Yes".writeln;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
using namespace std;
typedef long long ll;

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

    int pivot = 0;
    for (int i = 0; i < n; i++)
    {
        if (abs(a[pivot]) >= abs(a[i]))
            pivot = i;
    }

    int l_minus = 0;
    for (int i = 0; i < pivot; i++)
    {
        if (a[i] < 0)
        {
            l_minus += 1;
            a[i] = abs(a[i]);
        }
    }
    if (l_minus % 2 == 1)
        a[pivot] *= -1;

    int r_minus = 0;
    for (int i = pivot + 1; i < n; i++)
    {
        if (a[i] < 0)
        {
            r_minus += 1;
            a[i] = abs(a[i]);
        }
    }
    if (r_minus % 2 == 1)
        a[pivot] *= -1;

    ll ans = 0;
    for (int i = 0; i < n; i++)
    {
        ans += a[i];
    }

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


Measured memory_bytes: 1024
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);
      
        int n = sc.nextInt();

        int m = sc.nextInt();

        int ans = (n * (n - 1) / 2) + (m * (m - 1) / 2);

        System.out.println(ans);

    }
}


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

#define in freopen("input.txt", "r", stdin);
#define out freopen("output.txt", "w", stdout);
#define clr(arr, key) memset(arr, key, sizeof arr)
#define pb push_back
#define mp(a, b) make_pair(a, b)
#define infinity (1 << 28)
#define LL long long
#define PI acos(-1)
#define gcd(a, b) __gcd(a, b)
#define CF ios_base::sync_with_stdio(0);cin.tie(0);
#define lcm(a, b) ((a)*((b)/gcd(a,b)))
#define all(v) v.begin(), v.end()
#define no_of_ones __builtin_popcount // __builtin_popcountll for LL
#define SZ(v) (int)(v.size())
#define eps 1e-7

//int col[8] = {0, 1, 1, 1, 0, -1, -1, -1};
//int row[8] = {1, 1, 0, -1, -1, -1, 0, 1};
//int col[4] = {1, 0, -1, 0};
//int row[4] = {0, 1, 0, -1};
//int months[13] = {0, ,31,28,31,30,31,30,31,31,30,31,30,31};

using namespace std;

struct point{int x, y; point () {} point(int a, int b) {x = a, y = b;}};
template <class T> T sqr(T a){return a * a;}
template <class T> T power(T n, T p) { T res = 1; for(int i = 0; i < p; i++) res *= n; return res;}
template <class T> double getdist(T a, T b){return sqrt((a.x - b.x) * (a.x - b.x) + (a.y - b.y) * (a.y - b.y));}    // distance between a and b
template <class T> T extract(string s, T ret) {stringstream ss(s); ss >> ret; return ret;}
template <class T> string tostring(T n) {stringstream ss; ss << n; return ss.str();}
//LL bigmod(LL B,LL P,LL M){LL R=1; while(P>0)  {if(P%2==1){R=(R*B)%M;}P/=2;B=(B*B)%M;} return R;}
struct fast{fast(){ios_base::sync_with_stdio(0);cin.tie(0);}}cincout;

#define MAX 20
/***********************************THE GRASS IS ALWAYS GREENER ON THE OTHER SIDE***********************************/

int arr[MAX][MAX];

int main()
{
    // in;
    int n, m, x;
    cin >> n >> m >> x;
    for(int i = 1; i <= n; i++){
        for(int j = 0; j <= m; j++)
            cin >> arr[i][j];
    }
    int res = infinity;
    for(int i = 0; i < (1<<n); i++){
        int got[20] = {0}, money = 0;
        for(int r = 0; r < n; r++){
            if(i & (1<<r))
                continue;
            for(int j = 1; j <= m; j++)
                got[j] += arr[r+1][j];
            money += arr[r+1][0];
        }
        int j;
        for(j = 1; j <= m; j++){
            // cout << got[j] << ' ';
            if(got[j] < x)
                break;
        }
        // cout << "\n";
        if(j <= m)
            continue;
        res = min(res, money);
    }
    if(res == infinity)
        res = -1;
    cout << res;
    return 0;
}


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

ll choose2(ll n) {
    return n * (n - 1) / 2;
}

int main()
{
    int n;
    cin >> n;
    vector<int> a(n);
    rep(i, n) cin >> a.at(i);
    rep(i, n) a.at(i)--;
    vector<int> cnt(n);
    rep(i, n) cnt.at(a.at(i))++;

    ll tot = 0;
    rep(i, n) {
        tot += choose2(cnt.at(i));
    }

    rep(i, n) {
        ll ans = tot;
        ans -= choose2(cnt.at(a.at(i)));
        ans += choose2(cnt.at(a.at(i)) - 1);
        cout << ans << endl;
    }
    return 0;
}

Measured memory_bytes: 4096
import Control.Applicative
import Control.Monad
import qualified Data.ByteString.Char8 as B
import Data.Maybe (fromJust)
import qualified Data.Map as M
import Data.Ratio
import Text.Printf
import Debug.Trace

getInts :: IO [Int]
getInts = map (fst . fromJust . B.readInt) . B.words <$> B.getLine

calc xs = M.mapKeysWith min (\(n,d) -> n % (max 1 d)) $ foldl upd zero xs
  where
    zero = M.singleton (0,0) 0
    upd s [a,b,c] = M.unionWith min
                    s
                    (M.map (+c) $ M.mapKeysWith min (\(n,d) -> (n+a,d+b)) s)

main = do
  [n,ma,mb] <- getInts
  xs <- replicateM n getInts
  let s = calc xs
  print $ M.findWithDefault (-1) (ma%mb) s


Measured memory_bytes: 62844
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

func main() {
	n := getInt()
	as := make([]int, n)
	for i := range as {
		as[i] = getInt()
	}

	bs := make([]int, n)
	for i := range as {
		if i%2 == 0 {
			bs[0] += as[i]
		} else {
			bs[0] -= as[i]
		}
	}

	for i := 1; i < n; i++ {
		bs[i] = (as[i-1] - bs[i-1]/2) * 2
	}

	for _, b := range bs {
		fmt.Println(b)
	}
}

/*
	2 = a2/2 + a1/2
	2 = a3/2 + a2/2
	4 = a1/2 + a3/2

	b1/2 + b2/2 = a
	b2/2 + b3/2 = b
	b3/2 + b1/2 = c

	b3/2 + (a - b2/2) = c
	b3/2 - b2/2 = c - a
	b3/2 -(-b3/2 + b) = c - a
	b3 = c - a - b


*/

// -----------------------------------------

var scanner = wordScanner()

func wordScanner() *bufio.Scanner {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	return sc
}

func getInt() int {
	scanner.Scan()
	i, err := strconv.Atoi(scanner.Text())
	if err != nil {
		panic(err)
	}
	return i
}

func getString() string {
	scanner.Scan()
	s := scanner.Text()
	return s
}


Measured memory_bytes: 5760
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<cmath>
#include<stack>
#include<queue>
#include<map>
#include<set>
using namespace std;
typedef long long ll;
typedef vector<int> VI;
#define FOR(i,n) for(int (i)=0;(i)<(n);(i)++)
#define FOR1(i,n) for(int (i)=1;(i)<(n);(i)++)
#define eFOR(i,n) for(int (i)=0;(i)<=(n);(i)++)
#define eFOR1(i,n) for(int (i)=1;(i)<=(n);(i)++)
#define SORT(i) sort((i).begin(),(i).end())
#define rSORT(i) sort((i).begin(),(i).end(), greater<int>());
#define F first
#define S second
constexpr auto INF = 1000000000;
constexpr auto LLINF = 9223372036854775807;
constexpr auto mod = 1000000007;
int main() {

	ll k, a, b;
	cin >> k >> a >> b;
	if (b - a <= 2)cout << k + 1 << endl;
	else {
		ll ans = min(k + 1, a);
		k -= min(k, a - 1);
		ans += (b - a) * (k / 2);
		k %= 2;
		cout << ans + k << endl;
	}

	return 0;
}


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

#define loop(i,n) for(int i=0;i<(n);i++)
#define pool(i,n) for(int i=(n)-1;i>=0;i--)
#define cont(i,n) for(int i=1;i<=(n);i++)
#define tnoc(i,n) for(int i=(n);i>=1;i--)
#define circ(i,a,b) for(int i=(a);i<=(b);i++)
#define cric(i,a,b) for(int i=(b);i>=(a);i--)
#define sub(i,a) for(int i=a;i;i=((i-1)&(a)))
#define subs(i,a) for(int i=a;i>=0;i=(!i?-1:((i-1)&(a))))
#define subt(i,a) for(int i=((a-1)&a);i;i=((i-1)&(a)))
#define subst(i,a) for(int i=((a-1)&a);i>=0;i=(!i?-1:((i-1)&(a))))
#define range(i,a,b,c) for(int i=(a);((c)>0?i<=(b):i>=(b));i+=(c))
#define foreach(it,v) for(__typeof((v).begin()) it=(v).begin(),_e_D_=(v).end();it!=_e_D_;it++)
#define parse(i,s) for(int i=0;s[i];i++)

#define pub push_back
#define pob pop_back
#define puf push_front
#define pof pop_front
#define mak make_pair

#define y0 y0O0OO00OO0OO0OO0OOO00OO0OO0O0O000OO0
#define y1 y1II11II11III11I1III11II111IIII1II1I1
#define ws WSrAkIoi2333wSraKIoIWSraKiOi
#define left left_jTjTJtJtIoiiOiioIAuaU66666jtIOIau
#define hash whYusEthiSnamE_caNyoUusEothERnaMesliKeHSH

#define Mask(a) (1ll<<(a))
#define Maskx(a,x) ((a)<<(x))
#define Full(a) ((1ll<<(a))-1)
#define Bit(a,x) (((a)>>(x))&1)
#define all(a) (a).begin(),(a).end()
#define SZ(a) ((int)((a).size()))

typedef long long ll;
typedef long double lf;

const int Inf=0x3f3f3f3f;
const ll INF=0x3f3f3f3f3f3f3f3fll;
const lf inF=11451419198101145141919810.1145141919810;
const lf pi=acosl(-1);
/* Source code starts here */

int n,a,b;
const int jt=1000000007;
int dp[5005][5005][2],qzh1[5005],qzh2[5005][5005];
void inline add(int &a,int b){a+=b;if(a>=jt)a-=jt;if(a<0)a+=jt;}

int main(){
	scanf("%d%d%d",&n,&a,&b);
	if(a<b)swap(a,b);
	dp[0][0][1]=1;
	loop(i,n+1){
		if(i)add(qzh1[i],qzh1[i-1]);
		add(dp[i][0][0],qzh1[i]);
		loop(j,i+1){
			if(i)add(qzh2[i-j][i],qzh2[i-j][i-1]);
			add(dp[i][j][0],qzh2[i-j][i]);
			if(j==a){
				add(dp[i][j][1],dp[i][j][0]);dp[i][j][0]=0;
				add(dp[i+1][j][1],dp[i][j][1]);
				add(dp[i+1][j][1],dp[i][j][1]);
				break;
			}
			add(dp[i+1][j+1][1],dp[i][j][0]);
			add(dp[i+1][j+1][1],dp[i][j][1]);
			add(qzh1[i+1],dp[i][j][1]);
			if(i+b<=n){
				add(qzh1[i+b],-dp[i][j][1]);
				if(j+b<=a)add(qzh2[i-j][i+b],dp[i][j][1]);
				else add(dp[i+b][a][1],dp[i][j][1]);
			}
		}
	}
	add(dp[n][a][1],dp[n][a][0]);
	printf("%d\n",dp[n][a][1]);
	return 0;
}

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

ll attack(ll H){
    if(H == 1){
        return 1;
    }
    else{
        return  (1 + 2 * attack(H/2));
    }
}

int main() {
    ll H;
    cin >> H;
    ll ans = attack(H);
    cout << ans << endl;
}

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

int main() {
    int n; cin >> n;
    vector<int> b(n); // 4
    vector<int> f(n); // 3
    vector<int> r(n); // 10
    vector<int> v(n);
    
    rep(i, n) {
        cin >> b.at(i) >> f.at(i) >> r.at(i) >> v.at(i);
        b.at(i)--;
        f.at(i)--;
        r.at(i)--;
    }
    // vector<vector<int>> a(n, vector<int>(m));
    vector<vector<vector<int>>> s(4, vector<vector<int>>(3, vector<int>(10)));

    rep(i, n) {
        s.at(b.at(i)).at(f.at(i)).at(r.at(i)) += v.at(i);
    }

    rep(i, 4) {
        rep(j, 3) {
            cout << " ";
            rep(k, 10) {
                cout << s.at(i).at(j).at(k);
                if (k != 9)
                    cout << " ";
            }
            cout << endl;
        }
        if (i != 3)
            puts("####################");
    }
}


Measured memory_bytes: 3156
#include<bits/stdc++.h>
using namespace std;
const int maxn=105;
long long a[maxn];
int n;
long long maxx=-INT_MAX,minn=INT_MAX;
int main()
{
	cin>>n;
	for(int i=1;i<=n;i++)
	{
		cin>>a[i];
		maxx=max(a[i],maxx);
		minn=min(a[i],minn);
	}
	cout<<maxx-minn;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using Graph=vector<vector<int>>;
int main(){
int N;
  cin>>N;
  Graph G(N);
  for(int i=0;i<N-1;i++){
  int a,b; cin>>a>>b;
    a--; b--;
    G[a].push_back(b);
    G[b].push_back(a);
  }queue<int>que;
  vector<int>dist(N,-1);
  que.push(0);dist.at(0)=0;
  while(!que.empty()){
  int v=que.front();
    que.pop();
    for(auto u:G[v]){
    if(dist[u]!=-1)
      continue;
      else{
      dist[u]=dist[v]+1;
        que.push(u);
      }
    }
 }int Max=0;
    int a=-1;
    for(int i=0;i<N;i++){
    if(Max<dist[i]){Max=dist[i];a=i;}
    }queue<int>que1;
  vector<int>dist1(N,-1);dist1[a]=0;
  que1.push(a);
  while(!que1.empty()){
  int v=que1.front();
    que1.pop();
    for(auto u:G[v]){
    if(dist1[u]!=-1)
      continue;
      else{
      dist1[u]=dist1[v]+1;
        que1.push(u);
      }
    }
 }int ans=0;
  for(int i=0;i<N;i++)
    if(ans<dist1[i])
      ans=dist1[i];
  if(ans%3==1)
    cout<<"Second"<<endl;
  else
    cout<<"First"<<endl;
   return 0;
}



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

vector<int> rate(9);
int main()
{
    int N;
    cin >> N;
    vector<int> a(N);
    for (int i = 0; i < N; i++)
    {
        cin >> a[i];
    }
    for (int i = 0; i < N; i++)
    {
        int r = min(a[i], 3200) / 400;
        rate[r]++;
    }
    int total = 0;
    for (int i = 0; i < 8; i++)
    {
        if (rate[i] != 0)
            total++;
    }
    if (rate[8] == 0)
    {
        cout << total << " " << total << endl;
    }
    else
    {
        int totalmin, totalmax;
        if (total == 0)
        {
            totalmin = 1;
            totalmax = rate[8];
        }
        else
        {
            totalmin = total;
            totalmax = total + rate[8];
        }
        cout << totalmin << " " << totalmax << endl;
    }
}

Measured memory_bytes: 256
// #define _CRT_SECURE_NO_WARNINGS
// #define _USE_MATH_DEFINES	// M_PI=3.1415...
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <cmath>
#include <cstdlib>
#include <functional>
#include <locale>
#include <cctype>
#include <sstream>
#include <iomanip>	// 20桁出力 cout << setprecision(20) << double;
#include <queue>
#include <bitset>	// bitset<8> bs1(131uL); // 10000011 bs1[0]は1 01stringからビット集合生成可
using namespace std;

typedef long long LL;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<LL> VL;
typedef map<int, int> MAPII;
typedef multimap<int, char, greater<int> > MuMAPIC;
typedef vector<pair<int, int> > VPII;
typedef multimap<int, string, greater<int> > MuMIS;
typedef pair<int, int> P;
typedef pair<int, pair<P, P> > PP;

#define MP make_pair
#define FAST_IO  cin.tie(0); ios::sync_with_stdio(false);
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define FORL(i,a,b) for(LL i=(a);i<(b);i++)
#define FOR_REV(i,a,b) for(int i=(a);i>=(b);i--)
//for gcc (未test)
// #define FOREACH_IT(it,c) for(typeof(c)::iterator it=(c).begin(); it!=(c).end(); ++it)
//for Visual Studio
#define foreach_it(type,it,c) for(type::iterator it=c.begin(),c_end=c.end();it!=c_end;++it)
#define FOR_ITR(d) for(auto itr=d.begin(),d_end=d.end();itr!=d_end;++itr)	// C++11
// for Debug.
#define DUMP_VVI(b) FOR(i,0,b.size()){FOR(j,0,b[i].size())printf("%d ",b[i][j]);puts("");}
#define D_OUT(str,value) if(dbgF){cout<<str<<" : "<<value<<endl;}
// 入力をpush_back(d)やarray[d]に使う時に1行で書ける
// int INPUT_INT() {int d;cin>>d;return d;}
template<class T>T IN() { T d; cin >> d; return d; }
// 最大公約数（Greatest Common Divisor）
LL gcd(LL a, LL b) { return (b > 0) ? gcd(b, a%b) : a; }
// 最小公倍数（Least Common Multiple）
LL lcm(LL a, LL b) { return a / gcd(a, b) * b; }
// Y年はうるう年か否か
bool uruu(LL Y) { return (((Y % 4 == 0 && Y % 100 != 0) || Y % 400 == 0) ? true : false); }

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

// vector注意
// vec[i][j]の形に入力を入れるとき、vecは初期化してある必要がある.

// ------------------- include, typedef, define END. -------------------

int main() {
	FAST_IO;
	// for D_OUT(str, value)  ... cout<< str <<" : "<< value <<endl;
	bool dbgF = true;

	//コードはここから書く.

	string S;
	string ans = "No";
	int n = 0, s = 0, w = 0, e = 0;
	cin >> S;

	FOR(i, 0, S.length()) {
		if (S[i] == 'N')
			n++;
		if (S[i] == 'S')
			s++;
		if (S[i] == 'W')
			w++;
		if (S[i] == 'E')
			e++;
	}
	if ((n > 0 && s > 0) || n == 0 && s == 0)
		if ((w > 0 && e > 0) || (w == 0 && e == 0))
			ans = "Yes";
	cout << ans << endl;


	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#define MAX_S 100000
#define MAX_T 50000

int main(){
  int i, j, n, q, cnt=0;
  int left=0, right=0, mid=0;
  int S[MAX_S], T[MAX_T];

  scanf("%d", &n);
  right = n;
  for(i=0; i<n; i++){
    scanf("%d", &S[i]);
  }
  scanf("%d", &q);
  for(i=0; i<q; i++){
    scanf("%d", &T[i]);
  }

  
  for(i=0; i<q; i++){
    left = 0;
    right = n;
    while(left < right){
      mid = (left+right) / 2;
      if(S[mid] == T[i]){
	cnt++;
	break;
      }
      else if(T[i] < S[mid]){
	right = mid;
      }
      else{
	left = mid+1;
      }
      //printf("left__%d, right__%d\n", left, right);
    }
  }

  printf("%d\n", cnt);
  return 0;
  
  /*
    for(i=0; i<n; i++){
    printf("%d ", S[i]);
    }printf("\n");
    for(i=0; i<q; i++){
    printf("%d ", T[i]);
    }
  */
}



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

int main(){
    char arr[200][200];
    int h,w;
    cin>>h>>w;
    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
            cin>>arr[i][j];
        }
    }
    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
            cout<<arr[i][j];
        }
        cout<<"\n";
        for(int k=0;k<w;k++){
            cout<<arr[i][k];
        }

        cout<<"\n";
    }
    cout<<"\n";
    return 0;
}


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

int main(){
  int a, b, c;
  cin >> a >> b >> c;
  if(a==7&&b==5&&c==5){
    cout << "YES";
  }
  else if(a==5&&b==7&&c==5){
    cout << "YES";
  }
  else if(a==5&&b==5&&c==7){
    cout << "YES";
  }
  else{
    cout << "NO";
  }
  cout << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define fi			first
#define se			second
#define fz(i,a,b)	for(int i=a;i<=b;i++)
#define fd(i,a,b)	for(int i=a;i>=b;i--)
#define foreach(it,v) for(__typeof(v.begin()) it=v.begin();it!=v.end();it++)
#define all(a)		a.begin(),a.end()
#define giveup(...) return printf(__VA_ARGS__),0;
#define fill0(a)	memset(a,0,sizeof(a))
#define fill1(a)	memset(a,-1,sizeof(a))
#define fillbig(a)	memset(a,0x3f,sizeof(a))
#define fillsmall(a) memset(a,0xcf,sizeof(a))
#define mask(a)		(1ll<<(a))
#define maskx(a,x)	((a)<<(x))
#define _bit(a,x)	(((a)>>(x))&1)
#define _sz(a)		((int)(a).size())
#define filei(a)	freopen(a,"r",stdin);
#define fileo(a)	freopen(a,"w",stdout);
#define fileio(a) 	freopen(a".in","r",stdin);freopen(a".out","w",stdout)
#define eprintf(...) fprintf(stderr,__VA_ARGS__)
#define put(x)		putchar(x)
#define eoln        put('\n')
#define space		put(' ')
#define y1			y_chenxiaoyan_1
#define y0			y_chenxiaoyan_0
typedef pair<int,int> pii;
inline int read(){
	int x=0,neg=1;char c=getchar();
	while(!isdigit(c)){
		if(c=='-')	neg=-1;
		c=getchar();
	}
	while(isdigit(c))	x=x*10+c-'0',c=getchar();
	return x*neg;
}
inline void print(int x){
	if(x<0){
		putchar('-');
		print(abs(x));
		return;
	}
	if(x<=9)	putchar(x+'0');
	else{
		print(x/10);
		putchar(x%10+'0');
	}
}
inline int qpow(int x,int e,int _MOD){
	int ans=1;
	while(e){
		if(e&1)	ans=ans*x%_MOD;
		x=x*x%_MOD;
		e>>=1;
	}
	return ans;
}
signed main(){
	int k=read(),a=read(),b=read();
	fz(i,a,b)	if(i%k==0)	return puts("OK"),0;
	puts("NG");
	return 0;
}

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

typedef long long ll;
map<int,int>m;
ll ans;

int main()
{
	int n;
	scanf("%d",&n);
	for(int i=1;i<=n;i++){
		int cur;
		scanf("%d",&cur);
		if(m.find(i-cur)!=m.end()){
			ans += m[i-cur];
		}
		m[i+cur]++;
	}
	printf("%lld\n",ans);
}


Measured memory_bytes: 12984
#include <iostream>
#include <vector>
#include <list>
using namespace std;

#define lint list<int>

int main() {
	vector<lint> vec; int an, tn, fn1, fn2, fn3, en, set;
	cin >> an >> tn; vec.resize(an);
	for (int i = 0; i < tn; i++) {
		cin >> fn1;
		switch (fn1) {
		case 0: cin >> fn2 >> en; vec[fn2].push_back(en); break;
		case 1: cin >> fn2; set = 0;
			for (int i : vec[fn2]) cout << (set++ ? " " : "") << i;
			cout << endl; break;
		case 2: cin >> fn2 >> fn3; 
			vec[fn3].splice(vec[fn3].end(), vec[fn2]); break;
		}
	}
	return 0;
}


Measured memory_bytes: 18708
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")

#include<bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef long double ld;
typedef double db;
typedef string str;

typedef pair<int,int> pi;
typedef pair<ll,ll> pl;
typedef pair<db,db> pd;

typedef vector<int> vi; 
typedef vector<ll> vl; 
typedef vector<db> vd; 
typedef vector<str> vs; 
typedef vector<pi> vpi;
typedef vector<pl> vpl; 
typedef vector<pd> vpd; 

#define mp make_pair
#define f first
#define s second
#define sz(x) (int)(x).size()
#define all(x) begin(x), end(x)
#define rall(x) (x).rbegin(), (x).rend() 
#define rsz resize
#define ins insert 
#define ft front() 
#define bk back()
#define pf push_front 
#define pb push_back
#define eb emplace_back 
#define lb lower_bound 
#define ub upper_bound 

#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define F0R(i,a) FOR(i,0,a)
#define ROF(i,a,b) for (int i = (b)-1; i >= (a); --i)
#define R0F(i,a) ROF(i,0,a)
#define trav(a,x) for (auto& a: x)

const int MX  = 2e5+5; 
const int MOD = 1e9+7; // 998244353;
const ll  INF = 1e18; 
const ld  PI  = acos((ld)-1);

const int xd[4] = {1,0,-1,0}, yd[4] = {0,1,0,-1};
mt19937 rng((uint32_t)chrono::steady_clock::now().time_since_epoch().count()); 

template<class T> bool ckmin(T& a, const T& b) { 
	return b < a ? a = b, 1 : 0; 
}
template<class T> bool ckmax(T& a, const T& b) { 
	return a < b ? a = b, 1 : 0; 
} 

constexpr int pct(int x) { return __builtin_popcount(x); } // number of ones 
constexpr int bits(int x) { return 31-__builtin_clz(x); } // floor(log2(x)) 
template<class T> T cdiv(T a, T b) { return a/b+!(a<0||a%b == 0); } // division of a by b rounded up, assumes b > 0 

int fstTrue(function<bool(int)> f, int lo, int hi) {
	hi++; assert(lo <= hi); // assuming f is increasing
	while (lo < hi) { // find first index such that f is true 
		int mid = (lo+hi)/2; 
		f(mid) ? hi = mid : lo = mid+1; 
	} 
	return lo;
}

template<class T> void remDup(vector<T>& v) { 
	sort(all(v)); v.erase(unique(all(v)),end(v)); 
}

// DEBUG
void DBG() { cerr << "]" << endl; }
template<class H, class... T> void DBG(H h, T... t) {
	cerr << h; if (sizeof...(t)) cerr << ", ";
	DBG(t...); 
}
#define dbg(...) cerr << "LINE(" << __LINE__ << ") -> [" << #__VA_ARGS__ << "]: [", DBG(__VA_ARGS__)

// FILE I/O
void setIn(str S) { freopen(S.c_str(),"r",stdin); }
void setOut(str S) { freopen(S.c_str(),"w",stdout); }
void setIO(str S = "") {
	ios_base::sync_with_stdio(0); cin.tie(0); // fast I/O
	// cin.exceptions(cin.failbit); 
	// throws exception when do smth illegal
	// ex. try to read letter into int
	if (sz(S)) { setIn(S+".in"), setOut(S+".out"); } // for USACO
}

int32_t main() { 
	
	setIO();

    string N; cin >> N;

    int res = 0;
    trav(x,N) res = (res+(x-'0'))%9;

    cout << (res == 0 ? "Yes\n" : "No\n");

}

Measured memory_bytes: 3776
#include <stdio.h>

int main()
{
    int n,c;
    scanf("%d %d",&n, &c);
    int s[n];
    int t[n];
    int ch[n];
    for(int i=0;i<n;i++){
        scanf("%d %d %d",&s[i], &t[i], &ch[i]);
    }
    int space[c][200000];
    int max=0;
    for(int i=0;i<c;i++){
        for(int j=0;j<200000;j++){
            space[i][j]=0;
        }
    }
    for(int i=0;i<n;i++){
        for(int j=s[i]*2-1;j<t[i]*2;j++){
            space[ch[i]-1][j]=1;
        }
    }
    int tmp=0;
    for(int i=0;i<200000;i++){
        tmp=0;
        for(int j=0;j<c;j++){
            tmp+=space[j][i];
            if(max < tmp){
                max=tmp;
            }
        }
    }
    printf("%d\n", max);
    return 0;
}


Measured memory_bytes: 24832