akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <stdlib.h>
#include <string.h>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <set>
#include <stdio.h>
#include <tuple>
#include <bitset>
#include <cfloat>
#include <fstream>
#include <limits.h>
#include <list>
#include <math.h>
#include <random>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <numeric>
#include <utility>
#include <sstream>

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

using namespace std;
#define int long long
#define ll long long
#define rep(i, n) for (ll i = 0; i < (n); i++)
#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 repr(i,n) for(ll i=n;i>=0;i--)
#define P pair<ll, ll>
#define sz(x) (ll)x.size()
#define ALL(x) (x).begin(),(x).end()
#define ALLR(x) (x).rbegin(),(x).rend()
#define VE vector<ll>
#define COUT(x) cout<<(x)<<endl
#define MA map<ll,ll>
#define SE set<ll>
#define PQ priority_queue<ll>
#define PQR priority_queue<ll,VE,greater<ll>>
#define COUT(x) cout<<(x)<<endl
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define EPS (1e-10)
ll gcd(ll a, ll b) {
	if (a < b)swap(a, b);
	if (b == 0) return a;
	return gcd(b, a % b);
}
ll lcm(ll a, ll b) {
	ll g = gcd(a, b);
	return a / g * b;
}
bool prime(ll n) {
	for (ll i = 2; i <= sqrt(n); i++) {
		if (n%i == 0)return false;
	}
	return n != 1;
}


const long long MOD = 1000000007;
const long long INF = 1LL << 60;


const int MAX_N = 100010;
signed main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int n; cin >> n;
	VE a(n); rep(i, n)cin >> a[i];
	int sum = 0;
	int ans = INF;
	rep(i, n) {
		sum += a[i];
	}
	int now = 0;
	rep(i, n-1) {
		now += a[i];
		chmin(ans, abs(now-(sum - now)));
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 1792
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using static System.Console;
using static System.Math;
using static MyIO;
using static MyUtil;

public class A
{
	public static void Main() => (new Solver()).Solve();
}

public class Solver
{
	public void Solve()
	{
		int a = GetInt();
		int b = GetInt();

		if(a < b)
			WriteLine("a < b");
		else if(a > b)
			WriteLine("a > b");
		else
			WriteLine("a == b");
	}
}

public static class MyIO
{
	private static string[] args = null;
	private static int num = -1;
	private static int used = -1;

	private static string getArg()
	{
		if(used == num)
		{
			args = Console.ReadLine().Split(' ');
			num = args.Length;
			used = 0;
		}
		return args[used++];
	}

	public static int GetInt() => int.Parse(getArg());
	public static long GetLong() => long.Parse(getArg());
	public static double GetDouble() => double.Parse(getArg());
	public static decimal GetDecimal() => decimal.Parse(getArg());
	public static string GetString() => getArg();
	public static char GetChar() => getArg()[0];
	public static int[] GetInts(long N) => Enumerable.Range(0, (int)N).Select(_ => GetInt()).ToArray();
	public static long[] GetLongs(long N) => Enumerable.Range(0, (int)N).Select(_ => GetLong()).ToArray();
	public static double[] GetDoubles(long N) => Enumerable.Range(0, (int)N).Select(_ => GetDouble()).ToArray();
	public static decimal[] GetDecimals(long N) => Enumerable.Range(0, (int)N).Select(_ => GetDecimal()).ToArray();
	public static string[] GetStrings(long N) => Enumerable.Range(0, (int)N).Select(_ => GetString()).ToArray();
}

public static class MyUtil
{
	public static void chmax<T>(ref T x, T y) where T : IComparable<T>
	{
		if(x.CompareTo(y) < 0)
			x = y;
	}

	public static void chmin<T>(ref T x, T y) where T : IComparable<T>
	{
		if(x.CompareTo(y) > 0)
			x = y;
	}

	public static void swap<T>(ref T x, ref T y)
	{
		T tmp = x;
		x = y;
		y = tmp;
	}
}


Measured memory_bytes: 15964
#include <iostream>
#include <iomanip>
#include <vector>
#include <array>
#include <string>
#include <stack>
#include <queue>
#include <deque>
#include <unordered_map>
#include <unordered_set>
#include <set>
#include <tuple>
#include <cmath>
#include <algorithm>
#include <functional>
#include <numeric>
#include <cfloat>
#include <climits>
#include <cassert>
#include <random>
#include <bitset>
#include <memory>



int main() {
	int n, r; std::cin >> n >> r;
	if (n >= 10) {
		std::cout << r << '\n';
	}
	else {
		std::cout << r + 100 * (10 - n) << '\n';
	}
}


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

using namespace std;

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

int main() {
  int n;
  string s;
  cin >> n >> s;

  int r = 0, g = 0, b = 0;
  for (char c : s) {
    if (c == 'R') {
      r++;
    } else if (c == 'G') {
      g++;
    } else if (c == 'B') {
      b++;
    }
  }

  long long answer = (long long)r * g * b;

  Rep(j, n) {
    Rep(i, j) {
      int k = j + j - i;
      if (k < n && s[i] != s[j] && s[i] != s[k] && s[j] != s[k]) {
        answer--;
      }
    }
  }

  cout << answer << endl;

  return 0;
}


Measured memory_bytes: 3640
//設定言語check
#include <bits/stdc++.h>
#include <iostream>
#include <string>
#include <limits.h>
#include <algorithm>
#include <iomanip>
#include <math.h>
using namespace std;

int main(){
  int N, ans = 0 ;
  cin >> N ;
  if(N >= 30){
    cout << "Yes" << endl ;
  }  
  else{
    cout << "No" << endl ;
  }  
  return 0 ;
}  

Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
typedef long long LL;

//UF
int par1[100021];
int rank1[100021];
//n要素で初期化
void init(int n){
   for(int i=0;i<n;i++){
       par1[i]=i;
       rank1[i]=0;
   }
}
//木の根を求める
int find(int x){
    if(par1[x] ==x){
         return x;
    }else{
         return par1[x]=find(par1[x]);
    }
}
//xとyの属する集合を併合
void unite(int x,int y){
    x=find(x);
    y=find(y);
    if(x==y) return;

    if(rank1[x]<rank1[y]){
         par1[x]=y;
    }else{
         par1[y]=x;
         rank1[x]++;
    }
}
//xとyが同じ集合に属するか否か
bool same(int x,int y){
     return find(x)==find(y);
}



int N,M;
LL A[100001];
LL B[100001];
LL C[100001];
LL dp[100001];
LL s[100001];
bool used[100001];

vector<int>G[100001];
typedef pair<LL,LL>P;
vector<P>v;
int main(){
	cin>>N>>M;
	REP(i,N){
		cin>>A[i]>>B[i];
		C[i]=max(A[i],B[i]);

	}

	REP(i,M){
		int u,vv;
		cin>>u>>vv;
		u--;vv--;
		G[u].push_back(vv);
		G[vv].push_back(u);
	}
	init(N+10);
	REP(i,N){
		dp[i]=B[i];//得られたお金
		s[i]=C[i]-B[i];//最後の資金
		used[i]=false;
				v.push_back(P(s[i],i));
	}
		sort(v.begin(),v.end());
	REP(i,v.size()){
		int x=v[i].second;
		used[x]=true;
		vector<int>k;
		REP(j,G[x].size()){
			if(used[G[x][j]]==true){
				k.push_back(find(G[x][j]));
			}
		}
		sort(k.begin(),k.end());
		k.erase(unique(k.begin(), k.end()), k.end());
		//要素のソート
		vector<P>u;
		REP(j,k.size()){
			u.push_back(P(dp[k[j]],k[j]));
		}
		sort(u.begin(),u.end());
		REP(j,u.size()){
			if(same(x,u[j].second))continue;
			if(s[find(x)]<=s[u[j].second]){
				LL a=s[find(x)];
				LL b=dp[find(x)]+dp[u[j].second];
				unite(find(x),u[j].second);
				s[find(x)]=a;
				dp[find(x)]=b;
			}else if(s[u[j].second]+dp[u[j].second]>=(C[x]-B[x])){
				LL a=s[u[j].second];
				LL b=dp[find(x)]+dp[u[j].second];
				unite(find(x),u[j].second);
				s[find(x)]=a;
				dp[find(x)]=b;
			}else if(((C[x]-B[x])-dp[u[j].second])<=s[find(x)]){
				LL a=(C[x]-B[x])-dp[u[j].second];
				LL b=dp[find(x)]+dp[u[j].second];
				unite(find(x),u[j].second);
				s[find(x)]=a;
				dp[find(x)]=b;
			}else{
				LL a=s[find(x)];
				LL b=dp[find(x)]+dp[u[j].second];
				unite(find(x),u[j].second);
				s[find(x)]=a;
				dp[find(x)]=b;
			}
			//cout<<"x="<<x<<" dp[find(x)]="<<dp[find(x)]<<" s[x]="<<s[find(x)]<<endl;
		}
		//cout<<"xx="<<x<<" dp[find(x)]="<<dp[find(x)]<<" s[x]="<<s[find(x)]<<endl;
	}
	cout<<dp[find(0)]+s[find(0)]<<endl;
	/*REP(i,5){
		cout<<"f"<<dp[find(i)]<<endl;
	}*/
	return(0);
}

Measured memory_bytes: 13932
#include <bits/stdc++.h>
#define int long long
using namespace std;
const int MOD = pow(10, 9) + 7;
//const int MOD = 998244353;
//const int MOD = ;
int mod(int A, int M) {return (A % M + M) % M;}
const int INF = 1LL << 60;
const string ABC = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
const string abc = "abcdefghijklmnopqrstuvwxyz";
template <class T> bool chmin(T& a, T b) {if (a > b) {a = b; return true;} return false;}
template <class T> bool chmax(T& a, T b) {if (a < b) {a = b; return true;} return false;}
int divCeil(int A, int B) {return (A + (B - 1)) / B;}
int myctoi(char C) {return C - 48;}
char myitoc(int N) {return '0' + N;}

signed main()
{
  int N, W;
  cin >> N >> W;

  vector<vector<int>> dp(N + 10, vector<int>(W + 10, 0));
  for (int i = 0; i < N; i++)
  {
    int w, v;
    cin >> w >> v;
    
    for (int j = 0; j <= W; j++)
    {
      if (j + w <= W) 
        chmax(dp.at(i + 1).at(j + w), dp.at(i).at(j) + v);

      chmax(dp.at(i + 1).at(j), dp.at(i).at(j));
    }
  }
  
  int ans = dp.at(N).at(W);

  cout << ans << endl;
}

Measured memory_bytes: 87296
#include<bits/stdc++.h>
using namespace std;
int main(){
  int a,b,c,x; cin >> a >> b >> c >> x;
  int ans = 0;
  for(int i = 0; i <= a; i++){
    for(int j = 0; j <=b; j++){
      for(int k = 0; k <=c; k++){
        int money = 500 * i + 100 * j + 50 * k;
        if(money == x) ans++;
      }
    }
  }
  cout << ans;
}
  

Measured memory_bytes: 3584
#include<bits/stdc++.h>
using namespace std;
int main(){
  int K,S;cin>>K>>S;
  int res=0;
  for(int i=0;i<=K;i++){
    for(int j=0;j<=K;j++){
      if(S-i-j>=0&S-i-j<=K)++res;
    }
  }
  cout<<res;
}

Measured memory_bytes: 256
#include<stdio.h>

int main() {
 int A;
 int B;
 
 scanf("%d""%d",&A,&B);
 
 
 
 if(A + B < 10) {
   printf("%d", A + B);
 } else { 
   printf("error");
 }
  
  return 0;
  
 }
 

Measured memory_bytes: 128
#include<stdio.h>

int main(void)
{
	int i,a,b;
	
	for(i=0;i<7;i++)
	{
		scanf("%d %d",&a,&b);
		if(a>=0&&b>=0)
			printf("%d",a-b);
		else if(a>0&&b<0)
			printf("%d",a+(b*(-1)));
		else if(a==0)
			printf("%d",b*(-1));
		else
			printf("%d",(b*(-1))-(a*(-1)));
		printf("\n");
	}
	return 0;
}

Measured memory_bytes: 604
#include<iostream> 
#include<string> 
#include<vector> 
#include<algorithm> 
#include<cmath> 
using namespace std; 
int main()
{ 
	string s; 
	cin >> s; 
	
	int e = 0;
	int z=0;
	for (int i = 0; i < s.size(); i++)
	{
		if (s.at(i)=='A')
		{
			e =i; 
			break;
		} 
		
	}  
	
	for (int i = s.size()-1; i >=0 ; i--)
	{
		if (s.at(i)=='Z')
		{
			z = i; 
			break;
		}
	} 
	cout << z - e+1 << endl;
	return 0;
}

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

using namespace std;

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

#define int ll

const ll mod = 1e9 + 7;


int f[200001];
int p[200001];
int a[200001];
int b[200001];
int c[200001];

int pp(int n){
	if(f[n]!=-1) return f[n];
	return pp(n%p[n]) + 1;
}

void func(){
	for(int i=0;i<=200000;i++) f[i] = -1;
	f[0] = 0;
	f[1] = 1;
	for(int i=0;i<=200000;i++){
		int t = i;
		int tmp = 0;
		while(t>0){
			if (t%2==1) tmp++;
			t /= 2;
		}
		p[i] = tmp;
	}
	for(int i=2;i<=200000;i++){
		f[i] = pp(i);
	}
}

main(){
	int n;
	cin >> n;
	string s;
	cin >> s;

	func();

	int num = 0;
	int d2 = s[0]-'0';
	int d3 = s[0]-'0';
	for(int i=0;i<s.length();i++) if(s[i]=='1') num++;

	if(num==1){
		for(int i=0;i<s.length();i++){
			if(s[i]=='1') cout << 0 << endl;
			else if(i==s.length()-1||s[s.length()-1]=='1') cout << 2 << endl;
			else cout << 1 << endl;
		}
		return 0;
	}else if(num==0){
		for(int i=0;i<s.length();i++){
			cout << 1 << endl;
		}
		return 0;
	}


	for(int i=1;i<s.length();i++){
		d2 *= 2;
		if(s[i]=='1') d2++;
		d2 %= (num+1);
	}
	for(int i=1;i<s.length();i++){
		d3 *= 2;
		if(s[i]=='1') d3++;
		d3 %= (num-1);
	}
	int tt = 1;
	for(int i=s.length()-1;i>=0;i--){
		b[i] = tt%(num+1);
		tt *= 2;
		tt %= (num+1);
	}
	tt = 1;
	for(int i=s.length()-1;i>=0;i--){
		c[i] = tt%(num-1);
		tt *= 2;
		tt %= (num-1);
	}
	
	
	for(int i=0;i<s.length();i++){
		int ans;	
		if(s[i]=='1'){
			ans = d3 - c[i];
			ans = (ans+num-1)%(num-1);
		}else{
			ans = d2 + b[i];
			ans = ans%(num+1);
		}
		
		cout << f[ans]+1 << endl;
		
	}

	return 0;
}


Measured memory_bytes: 9932
#include <bits/stdc++.h>
using namespace std;
int main() {
    string s;
	getline(cin, s);
	for (auto c : s) {
	    if ('a' <= c && c <= 'z') c += 'A' - 'a';
	    else if ('A' <= c && c <= 'Z') c += 'a' - 'A';
	    cout << c;
	}
	cout << endl;
}


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

int main() {
  int k, s;
  cin >> k >> s;
  int count = 0;
  for (int x = 0; x <= k; x++) {
    for (int y = 0; y <= k; y++) {
      int z = s - y - x;
      // x + y + z == s となるが z は 0以上k以下である必要
      if ( z >= 0 && z <= k ) {
        count += 1;
      }
    }
  }
  cout << count << endl;
}


Measured memory_bytes: 256
#include<stdio.h>

typedef long long int int64;

int N, K, i, j, k, l, c;
int64 answer, sum;
int a[1000];
int64 b[500500];

int main(void){
	scanf("%d%d",&N,&K);
	for(i=0; i<N; i++){
		scanf("%d",a+i);
	}
	l = N*(N+1)/2;
	k = 0;
	for(i=0; i<N; i++){
		sum=0;
		for(j=i; j<N; j++){
			sum+=a[j];
			b[k++]=sum;
		}
	}
	answer = 0;
	for(k=39; k>=0; k--){
		c=0;
		for(i=0; i<l; i++){
			if((b[i]>>k)&1){c++;}
		}
		if(c>=K){
			answer+=((int64)1)<<k;
			j=0;
			for(i=0; i<l; i++){
				if((b[i]>>k)&1){b[j++]=b[i];}
			}
			l=j;
		}
	}
	printf("%lld\n", answer);
	return 0;
}


Measured memory_bytes: 4096
n = int(input())
s = input()
acc_cnt_a = [0] * n
acc_cnt_b = [0] * n
acc_cnt_ab = [0] * n
c_loc = []
cnt_a = 0
cnt_b = 0
cnt_ab = 0
for i in range(n):
    c = s[i]
    if c == 'D':
        cnt_a += 1
    elif c == 'M':
        cnt_b += 1
        cnt_ab += cnt_a
    elif c == 'C':
        c_loc.append(i)
    acc_cnt_a[i] = cnt_a
    acc_cnt_b[i] = cnt_b
    acc_cnt_ab[i] = cnt_ab

q = int(input())
buf = []
for k in map(int, input().split()):
    ans = 0
    for r in c_loc:
        l = r - k
        if l >= 0:
            rejected_a = acc_cnt_a[l]
            cnt_internal_b = acc_cnt_b[r] - acc_cnt_b[l]
            cnt_internal_ab = acc_cnt_ab[r] - acc_cnt_ab[l]
            ans += cnt_internal_ab - rejected_a * cnt_internal_b
        else:
            ans += acc_cnt_ab[r]
    buf.append(ans)
print('\n'.join(map(str, buf)))


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

ll n, ret;

void dfs(ll num, bool three, bool five, bool seven) {
	if (num > n) return ;
	if (three && five && seven) ret++;

	dfs(10 * num + 3, true, five, seven);
	dfs(10 * num + 5, three, true, seven);
	dfs(10 * num + 7, three, five, true);
	return ;
}

int main() {
	cin >> n;
	dfs(0, false, false, false);
	cout << ret << '\n';
	return 0;
}


Measured memory_bytes: 3640
#include <bits/stdc++.h>
 
using namespace std;
 
#define int long long
#define endl '\n'
#define maxn 100010
const int MOD = 1000000007;
 
void solve() {
    int n,e;cin>>n>>e;
    vector<int> vc[300005];
    int hash[300005]={0};
    for(int i=1;i<=n-1;i++){int u,v;cin>>u>>v;vc[u].push_back(v);vc[v].push_back(u);}
    for(int i=1;i<=e;i++){int a,b;cin>>a>>b;hash[a]+=b;}
    queue<int> q;q.push(1);
    bool visited[n+1]={0};
    while(!q.empty())
    {
    	int tp=q.front();q.pop();
    	 visited[tp]=true;
    	for(int i=0;i<vc[tp].size();i++)
    	{
    		if(!visited[vc[tp][i]]){
    		hash[vc[tp][i]]+=hash[tp];
    		q.push(vc[tp][i]);}
    	}
    }
    for(int i=1;i<=n;i++)
    cout<<hash[i]<<" ";
    cout<<endl;
}
 
int32_t main() {
int t=1;
    while (t--)
        solve();
    return 0;
}

Measured memory_bytes: 21232
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double lf;
typedef pair<ll,ll> ii;
#define REP(i,n) for(int i=0;i<n;i++)
#define REP1(i,n) for(ll i=1;i<=n;i++)
#define FOR(i,j,n,m) for(int i=j;i<n;i+=m)
#define RST(i,n) memset(i,n,sizeof i)
#define SZ(a) (int)a.size()
#define ALL(a) a.begin(),a.end()
#define F first
#define S second
#define pb push_back
#define pob pop_back
#define MP make_pair
#ifdef cold66
#define debug(...) do{\
    fprintf(stderr,"%s - %d (%s) = ",__PRETTY_FUNCTION__,__LINE__,#__VA_ARGS__);\
    _do(__VA_ARGS__);\
}while(0)
template<typename T>void _do(T &&_x){cerr<<_x<<endl;}
template<typename T,typename ...S> void _do(T &&_x,S &&..._t){cerr<<_x<<" ,";_do(_t...);}
template<typename _a,typename _b> ostream& operator << (ostream &_s,const pair<_a,_b> &_p){return _s<<"("<<_p.F<<","<<_p.S<<")";}
template<typename It> ostream& _OUTC(ostream &_s,It _ita,It _itb)
{
    _s<<"{";
    for(It _it=_ita;_it!=_itb;_it++)
    {
        _s<<(_it==_ita?"":",")<<*_it;
    }
    _s<<"}";
    return _s;
}
template<typename _a> ostream &operator << (ostream &_s,vector<_a> &_c){return _OUTC(_s,ALL(_c));}
template<typename _a> ostream &operator << (ostream &_s,set<_a> &_c){return _OUTC(_s,ALL(_c));}
template<typename _a,typename _b> ostream &operator << (ostream &_s,map<_a,_b> &_c){return _OUTC(_s,ALL(_c));}
template<typename _t> void pary(_t _a,_t _b){_OUTC(cerr,_a,_b);cerr<<endl;}
#define IOS()
#else
#define debug(...)
#define pary(...)
#define endl '\n'
#define IOS() ios_base::sync_with_stdio(0);cin.tie(0);
#endif // cold66
//}

template<class T> inline bool chkmax(T &a, const T &b) { return b > a ? a = b, true : false; }
template<class T> inline bool chkmin(T &a, const T &b) { return b < a ? a = b, true : false; }
template<class T> using MaxHeap = priority_queue<T>;
template<class T> using MinHeap = priority_queue<T, vector<T>, greater<T>>;

const ll MAXn=1e5+5,MAXlg=__lg(MAXn)+2;
const ll MOD=1000000007;
const ll INF=(ll)1e18;

MaxHeap<ll> pq;
int main(){
  IOS();
  ll a,b,c,k;
  cin>>a>>b>>c>>k;
  pq.push(a);
  pq.push(b);
  pq.push(c);
  while(k--){
    ll cur=pq.top();
    pq.pop();
    pq.push(cur*2);
  }
  ll ans=0;
  while(SZ(pq)){
    ans+=pq.top();
    pq.pop();
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 384
n=int(input())
a=list(map(int,input().split()))
d={}
ans=0
cnt=0
for i in range(n):
  if a[i] not in d:
    d[a[i]]=1
  else:
    d[a[i]]+=1
nd=list(d.items())
for i in range(len(nd)):
  ans+=nd[i][1]-1
  if nd[i][1]%2==0:
    cnt+=1
print(n-ans-cnt%2)

Measured memory_bytes: 21084
#include<bits/stdc++.h>
using namespace std; 
  
typedef long long ll; 
typedef pair<ll, ll> pll;
typedef vector<ll> vl; 
typedef vector<vl> vvl; 
 
#define MOD 1000000007  
#define f(a, b, c) for (ll(a) = (b); (a) < (c); ++(a))  
#define fast ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);srand(time(NULL)); 
#define rep(i, n) f(i, 0, n) 
#define ff first 
#define ss second  
#define pb push_back 
#define all(v) v.begin(), v.end()  
#define wh(t) while (t--) 
#define inf 1e18
#define modd 998244353
#define pp(var) cout<<var<<"\n";
#define pm(var1, var2) cout<<var1<<" "<<var2<<"\n"; 

const ll N = 2e5 + 5;

ll binpow(ll a,ll n)
{
    ll i=1;
    while(n>0)
    {
        if(n&1)
            i=(i*a);
        a=(a*a);
        n = n>>1;
    }
    return i;
}
 
ll isprime(ll n)
{
    if(n==0||n==1)
        return n;
    if(n%2==0)
        return (ll)2;
    if(n%3==0)
        return (ll)3;
    else
    {
        for(ll i=5;i*i<=n;i+=6)
        {
            if(n%i==0)
                return i;
            if(n%(i+2)==0)
                return (i+2);
        }
        return n;
    }
}

ll ans[N];
bool mark[N];
vvl adj;
void bfs(){
	queue<ll> q;
	q.push(1); mark[1] = false;
	while(q.size() != 0){
		ll x = q.front(); q.pop();
		for(ll i=0; i<adj[x].size(); ++i){
			if(mark[adj[x][i]]){
				mark[adj[x][i]] = false;
				ans[adj[x][i]] = x;
				q.push(adj[x][i]);
			}
		}
	}
}

int main(){
    fast;
    ll n,m,l,r,i,j,k,a,b,c,q,t,x,y,d;
    cin>>n>>m;
    adj.resize(n+1,vl());
    memset(ans,-1,sizeof(ans));
    memset(mark,true,sizeof(mark));
    rep(i,m){
    	cin>>x>>y;
    	adj[x].pb(y); adj[y].pb(x);
	}
	ans[1]=1;
	bfs();
	rep(i,n){
		if(ans[i+1] == -1) {
			pp("No");
			return 0;
		}
	}
	pp("Yes");
	f(i,1,n) cout<<ans[i+1]<<"\n";
}

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

typedef long long ll;
#define ar array
#define vi vector<int>
#define vvi vector<vector<int>>
#define vll vector<long long>
#define fork(i, n) for (ll i = 0; i < (n); i++)
#define forn for (ll i = 0; i < (n); i++)
#define fori(i, k, n) for (ll i = k; i < (n); i++)
#define all(x) (x).begin(), (x).end()
#define en '\n'
#define FILL(x, v) memset(x, v, sizeof(x))
#define pb push_back
#define fast                     \
	ios::sync_with_stdio(false); \
	cin.tie(NULL);               \
	cout.tie(NULL);

template <typename A, typename B>
inline void chmin(A &a, B b)
{
	if (a > b)
		a = b;
}
template <typename A, typename B>
inline void chmax(A &a, B b)
{
	if (a < b)
		a = b;
}
template <typename T>
void print(vector<T> &a)
{
	for (int i = 0; i < a.size(); i++)
		cout << a[i] << ' ';
	cout << en;
}
template <typename T>
void print(deque<T> &a)
{
	for (int i = 0; i < a.size(); i++)
		cout << a[i] << ' ';
	cout << en;
}
template <typename T>
void print(vector<vector<T>> &a)
{
	for (int i = 0; i < a.size(); i++)
	{
		for (int j = 0; j < a[i].size(); j++)
			cout << a[i][j] << ' ';
		cout << en;
	}
}

int main()
{
	fast;
	int x, n;
	cin >> x >> n;
	vector<bool> a(n + 1, 0);
	if (n == 0)
	{
		cout << x << en;
		return 0;
	}
	forn
	{
		int t;
		cin >> t;
		if (t < 0)
			continue;
		a[t] = 1;
	}
	int ans, cur = 1e9 + 5;
	for (int i = x + n; i >= 0 && i >= x - n; i--)
	{
		if (a[i])
			continue;
		// cout << i << en;
		int dif = abs(i - x);
		if (dif <= cur)
		{
			cur = dif;
			ans = i;
		}
	}
	cout << ans << en;
}

Measured memory_bytes: 3656
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const double PI = 4*atan(1);
const int INF = 0x3f3f3f3f;
const ll LINF = 0x3f3f3f3f3f3f3f3f;
const double EPS = 1e-6;
const string YES = "Possible";
const string NO = "Impossible";
#define pb push_back
#define mp make_pair

const int MAX_N = 1005;
const int MOD = 1e9+7;
int N;

map<int, int> primeCount;

void factor(int n)
{
	for(int i=2;i*i<=n;++i){
		int cnt = 0;
		while(n%i==0){
			n/=i;
			cnt++;
		}
		primeCount[i] += cnt;
	}
	if(n>1) primeCount[n]++;
}

void solve()
{
	for(int i=1; i<=N; ++i) factor(i);
	ll ans = 1;
	for(auto& p : primeCount){
		ans = (ans * (p.second+1))%MOD;
	}
	cout << ans << endl;
}

int main()
{
	cin >> N;
	solve();
}

Measured memory_bytes: 256
from bisect import bisect_left, bisect_right
from collections import Counter, defaultdict, deque, OrderedDict
from copy import deepcopy
from functools import lru_cache, reduce
from math import ceil, floor
from sys import setrecursionlimit

import heapq
import itertools
import operator


inf = float('inf')


def get_int():
    return int(input())


def get_float():
    return float(input())


def get_str():
    return input().strip()


def get_li():
    return [int(i) for i in input().split()]


def get_lf():
    return [float(f) for f in input().split()]


def get_lc():
    return list(input().strip())


def get_data(n, types):
    if len(types) == 1:
        return [types[0](input()) for _ in range(n)]
    return zip(*(
        [t(x) for t, x in zip(types, input().split())]
        for _ in range(n)
    ))


# inputs
B = ""


def set_inputs():
    global B
    B = get_str()
    return


def main():
    setrecursionlimit(100000)
    set_inputs()
    d = {"A": "T", "C": "G", "G": "C", "T": "A"}
    print(d[B])
    return


if __name__ == '__main__':
    main()


Measured memory_bytes: 38256
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
using namespace std;
int main()
{
	long long n;
	cin>>n;
	int ans=0;
	for(long long i=1;i*i<=n-1;++i){
		if((n-1)%i==0){
			if(i!=(n-1)/i)
				ans+=2;
			else ans++;
		}
	}
	for(long long i=2;i*i<=n;++i){
		if(n%i==0){
			long long k=n;
			while(k%i==0){
				k/=i;
			}
			if(k%i==1) ans++;
		}
	}
	cout<<ans;
	// system("pause");
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(){
    int H, W, i, j;
    while(1){
        scanf("%d %d\n", &H, &W);
        if(H == 0 && W == 0) break;
        for(i = 0; i < H; i++){
            for(j = 0; j < W; j++){
                printf("#");
            }
            printf("\n");
        }
        printf("\n");
    }
    return 0;
}

Measured memory_bytes: 2616
def run(N, M, X):
    if N >= M:
        return 0
    X = sorted(X)
    diff = []
    for i in range(M-1):
        diff.append(X[i+1] - X[i])
    diff = sorted(diff)
    ret = X[-1] - X[0]
    for i in range(N-1):
        ret -= diff[-i-1]
    return ret


def main():
    N, M = map(int, input().split())
    X = list(map(int, input().split()))
    print(run(N, M, X))


if __name__ == '__main__':
    main()


Measured memory_bytes: 13960
#include<bits/stdc++.h>
using namespace std;
typedef  long long int ll;
const ll mod = 1e9+7;
const ll mod1 = 998244353;
#define rep(i,a,b) for(ll i=a;i<b;i++)

void swap(ll &a , ll &b){
    ll t = a;
    a = b;
    b = t;
}

ll min(ll a, ll b){
    if(a<b)return a;
    return b;
}

ll max(ll a, ll b){
    if(a>b)return a;
    return b;
}

 ll pow(ll a, ll b) {
    a %= mod;
    ll ans = 1;
    while (b > 0) {
        if (b & 1)
            ans = ans * a % mod;
        a = a * a % mod;
        b /= 2;
    }
    return ans;
}



int main(){
   

  ios_base :: sync_with_stdio(0);
   cin.tie(0);
    ll a[3];
    rep(i ,0 , 3){
        cin>>a[i];
    }
    swap(a[0] , a[1]);
    swap(a[0] , a[2]);
    rep(i, 0 ,3){
        cout<<a[i]<<" ";
    }
    
}


Measured memory_bytes: 256
n, k = map(int, input().split())
a = list(map(int, input().split()))

a = sorted(a)
count = [0] * n
for i in range(n):
    count[a[i] - 1] += 1
index = sorted(range(len(count)), key=lambda j: count[j], reverse=True)
ans = 0
for i in range(k):
    ans += count[index[i]]
ans = sum(count) - ans
print(ans)


Measured memory_bytes: 24996
h, n = [int(i) for i in input().split()]

magics = [None]


class Magic:
    def __init__(self, attack, cost):
        self.attack = attack
        self.cost = cost


maxA = 0
for i in range(n):
    attack, cost = [int(i) for i in input().split()]
    maxA = max(maxA, attack)
    magics.append(Magic(attack, cost))

dp = [[10 ** 9 for i in range(h + maxA)] for j in range(n + 1)]

for i in range(n + 1):
    for j in range(h + maxA):
        if j == 0:
            dp[i][j] = 0
        elif i == 0:
            continue
        elif j - magics[i].attack >= 0:
            dp[i][j] = min(dp[i - 1][j], dp[i][j - magics[i].attack] + magics[i].cost)
        else:
            dp[i][j] = dp[i - 1][j]

print(min(dp[-1][h:]))


Measured memory_bytes: 172728
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

using namespace std;
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}

long long gcd( long long m, long long n ){

  if ( n == 0) return m;
  return gcd(n,m%n);
}//gcd




int main(){
  int n,x;
  cin >> n >> x;
  vector<int> p(n);
  for(int i = 0; i < n; i++){
    cin >> p[i];
  }
  p.push_back(x);
  vector<long> dif;
  sort(p.begin(),p.end());
  for(int i = 0; i < p.size() - 1; i++){
    dif.push_back(p[i+1] - p[i]);
  }
  dif.erase(unique(dif.begin(),dif.end()),dif.end());
  long long ans = dif[0];
  for(int i = 1; i < dif.size(); i++){
    ans = gcd(ans,dif[i]);
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 2168
#include <iostream>
#include <iomanip>
#include <cmath>

using namespace std;

int main() {
	double a, b, c, d, e, f, x, y, t;
	while(cin >> a >> b >> c >> d >> e >> f) {
		t = 1.0 / (a*e - b*d);
		x = (e*c - b*f) * t;
		y = (a*f - d*c) * t;
		x = abs(x) < 0.001 ? 0.0 : x;
		y = abs(y) < 0.001 ? 0.0 : y;
		cout << fixed << setprecision(3) << x
			 << ' '
			 << fixed << setprecision(3) << y
			 << endl;
	}
	return 0;
}

Measured memory_bytes: 1284
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <functional>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef vector<vector<pair<ll, ll>>> vvpll;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define exrep(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) cout << x << endl
#define exout(x) printf("%.10f\n", x)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define re0 return 0
const ll mod = 1000000007;
const ll INF = 1e16;
const ll MAX_N = 100010;

ll calc(char c) {
    if(c == 'r') {
        return 0;
    }
    if(c == 's') {
        return 1;
    }
    if(c == 'p') {
        return 2;
    }
}

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

    vl rsp(3);
    rep(i, 3) {
        cin >> rsp[i];
    }

    string t;
    cin >> t;

    vvl dp(n+1, vl(3));  // dp[i][j] : i回目に自分がj('r' = 0, 's' = 1, 'p' = 2)を出すとき i mod.k の手番についての得点の総和の最大値
    rep(i, n) {
        rep(j, 3) {
            ll hand = calc(t[i]);  // 敵の出す手
            if(i >= k) {
                rep(x, 3) {
                    if(j != x) {
                        chmax(dp[i][j], dp[i-k][x]);
                    }
                }
            }
            if((j+1)%3 == hand) {
                dp[i][j] += rsp[j];
            }
        }
    }

    ll ans = 0;
    rep(i, k) {
        ll now = 0;
        rep(j, 3) {
            chmax(now, dp[n-1-i][j]);
        }
        ans += now;
    }

    out(ans);
    re0;
}

Measured memory_bytes: 5760
#include <iostream>
#include <math.h>
using namespace std;

int main(void){
    long long A, B, N, x, i, t, p[20], c, d;
    scanf("%lld%lld", &A, &B);
    if (A>B) {
        t=A;
        A=B;
        B=t;
    }
    N=(long long)(floor(sqrt(A)));
    c=0;
    for (i=2; i<=N; i++) {
        d=0;
        while (1) {
            if (A%i==0) {
                if (d==0) {
                    c++;
                    p[c]=i;
                    d=1;
                    // printf("!(%lld, %lld)\n", A, i);
                }
                A/=i;
                // printf("?(%lld, %lld)\n", A, i);
            }
            else break;
            // printf("(%lld, %lld)\n", i, A%i);
        }
    }
    d=1;
    for (i=2; i<=N; i++) {
        if (A%i==0) {
            d=0;
            break;
        }
    }
    // printf("%d\n\n", A);
    if (d==1 && A!=1) {
        c++;
        p[c]=A;
    }
    if (c==0 && A!=1) {
        c=1;
        p[1]=A;
    }
    // for (i=1; i<=c; i++) printf("%lld\n", p[i]);
    x=0;
    for (i=1; i<=c; i++) {
        if (B%p[i]==0) x++;
    }
    printf("%lld", x+1);
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
// For output
 int main(void){
 int a, b, c;

 scanf("%d%d%d", &a, &b, &c);

 int ispoor = 0;
 if (a == b && b != c) ispoor = 1;
 if (b == c && c != a) ispoor = 1;
 if (c == a && a != b) ispoor = 1;

 if (ispoor) {
 puts("Yes");
 } else {
 puts("No");
 }

 return 0;
}

Measured memory_bytes: 256
package main

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

var sc = bufio.NewScanner(os.Stdin)

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func main() {
	sc.Split(bufio.ScanWords)
	n, x := nextInt(), nextInt()

	a := make([]int, n)
	for i := 0; i < n; i++ {
		a[i] = nextInt()
	}

	ans := 0
	for i := 0; i < n-1; i++ {

		delta := max(0, a[i]+a[i+1]-x)
		a[i+1] -= delta

		if a[i+1] < 0 {
			a[i] += a[i+1]
			a[i+1] = 0
		}

		ans += delta

	}

	fmt.Println(ans)
}

func max(a, b int) int {
	if a < b {
		return b
	}

	return a
}


Measured memory_bytes: 3072
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)

using namespace std;

string s;
vector<string> res;

void dfs(int id,int ch,string nw)
{
    if(id == (int)s.size()){
        res.push_back(nw);
        return;
    }
    if(s[id] == 'a'){
        nw.push_back('a');
        dfs(id+1,ch,nw);
        nw.pop_back();
        if(!(ch&1)){
            ch++;
            nw.push_back('b');
            dfs(id+1,ch,nw);
            nw.pop_back();
            ch--;
        }
    }else{
        int val = s[id]-'a';
        if((ch >> (val-1))&1){
            nw.push_back(s[id]);
            dfs(id+1,ch,nw);
            nw.pop_back();
        }
        if(s[id] != 'z' && !((ch >> val)&1)){
            ch += (1 << val);
            nw.push_back(s[id]+1);
            dfs(id+1,ch,nw);
            nw.pop_back();
            ch -= (1 << val);
        }
    }
}

int main()
{
    while(1){
        cin >> s;
        if(s == "#"){
            break;
        }
        res.clear();
        dfs(0,0,"");
        sort(res.begin(),res.end());
        res.erase(unique(res.begin(),res.end()),res.end());
        cout << (int)res.size() << "\n";
        if((int)res.size() <= 10){
            for(auto& it : res){
                cout << it << "\n";
            }
        }else{
            rep(i,5){
                cout << res[i] << "\n";
            }
            for(int i=5;i>=1;i--){
                cout << res[(int)res.size()-i] << "\n";
            }
        }
    }
}



Measured memory_bytes: 4224
import java.io.PrintWriter
val pw = PrintWriter(System.out)

fun main(args : Array<String>) {
    func()
    pw.flush()
}

fun func() {
    val (a, b) = listOfInt()

    var open = 1
    var ans = 0

    while (open < b) {
        open += (a - 1)
        ans ++
    }

    println(ans)
}

fun next() = readLine()!!
fun listOfString() = next().split(" ")
fun listOfInt() = listOfString().map { it.toInt() }

fun println(value : Any) {
    pw.println(value)
}

Measured memory_bytes: 37812
package main

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

// I/O
type Scanner struct {
	sc *bufio.Scanner
}

func NewScanner() *Scanner {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 1024), int(1e+9))
	return &Scanner{sc}
}

func (s *Scanner) nextStr() string {
	s.sc.Scan()
	return s.sc.Text()
}

func (s *Scanner) nextInt() int {
	i, e := strconv.Atoi(s.nextStr())
	if e != nil {
		panic(e)
	}
	return i
}

func (s *Scanner) nextFloat() float64 {
	f, e := strconv.ParseFloat(s.nextStr(), 64)
	if e != nil {
		panic(e)
	}
	return f
}

func (s *Scanner) nextRuneSlice() []rune {
	return []rune(s.nextStr())
}

func (s *Scanner) nextIntSlice(n int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ {
		res[i] = s.nextInt()
	}
	return res
}

func (s *Scanner) nextFloatSlice(n int) []float64 {
	res := make([]float64, n)
	for i := 0; i < n; i++ {
		res[i] = s.nextFloat()
	}
	return res
}

// Arithmetic
func max(nums ...int) int {
	m := nums[0]
	for _, i := range nums {
		if m < i {
			m = i
		}
	}
	return m
}

func min(nums ...int) int {
	m := nums[0]
	for _, i := range nums {
		if m > i {
			m = i
		}
	}
	return m
}

func abs(x int) int {
	if x > 0 {
		return x
	}
	return -x
}

func pow(x, y int) int {
	res := 1
	for i := 0; i < y; i++ {
		res *= x
	}
	return res
}

// Sort
type Val struct {
	id, num int
}
type ByNum []Val

func (a ByNum) Len() int           { return len(a) }
func (a ByNum) Less(i, j int) bool { return a[i].num < a[j].num }
func (a ByNum) Swap(i, j int)      { a[i], a[j] = a[j], a[i] }

func main() {
	sc := NewScanner()
	wtr := bufio.NewWriter(os.Stdout)
	N := sc.nextInt()

	fmt.Fprintln(wtr, N/3)
	wtr.Flush()
}


Measured memory_bytes: 640
#include <iostream>
using namespace std;
int main(void){
    int w, h, x, y, r;
    cin >> w >> h >> x >> y >> r;
    
    if (x<=0) {cout << "No" << endl;}
    else if (y<=0) {cout << "No" << endl;}
    else if ((x-r)>=0 && (y-r)>=0 && (x+r)<=w && (y+r)<=h) {cout << "Yes" << endl;}
    else {cout << "No" << endl;}
    
    return 0;

    
    
    
}



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

using namespace std;
#define  ll  long long
#define f first
#define s second
#define matrix vector<vector<ll>>
#define zero(n,m) matrix(n , vector<ll>(m,0))
#define one(n,m) matrix(n , vector<ll>(m,1))
#define pii pair<ll,ll>
const int N = 2e5+5;

ll n , a[N] , sum , rem , ans , tmp , mod = 1e9+7;

int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

    cin >> n;
    for(int i=1; i<=n; i++)
    {
        cin >> a[i];
        sum = (sum+a[i])%mod;
    }

    for(int i=1; i<=n; i++)
    {
        sum = (sum-a[i]%mod) , sum = (sum+mod)%mod;
        tmp = ( (sum) * (a[i]%mod) )%mod;
        ans += tmp;
        ans %= mod;

    }

    cout << ans << '\n';

    return 0;
}



Measured memory_bytes: 5204
#ABC077C
N=int(input())
A=list(map(int,input().split()))
A.sort()
B=list(map(int,input().split()))
B.sort()
C=list(map(int,input().split()))
C.sort()
ans=0
a=0
c=0
for b in B:
	if a!=N:
		while A[a]<b:
			a+=1
			if a==N:
				break
	if c!=N:
		while C[c]<=b:
			c+=1
			if c==N:
				break
	ans+=a*(N-c)
print(ans)

Measured memory_bytes: 23328
#include <bits/stdc++.h>
#define rep(i, n) for(int i= 0; i < (n); i++)
using ll= long long int;
using namespace std;
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; }
ll mod= 1e9 + 7;


int main(){
  int x,y;
  cin >> x >>y;
  rep(i,x+1){
    if(y==2*i+4*(x-i)){cout << "Yes" << endl; return 0;}
  }
  cout << "No" << endl;
}

Measured memory_bytes: 3624
#include<stdio.h>

int main(void) {
	int i = 0;
	char num[5];
	scanf("%s", num);
	while (i < 3) {
		if (num[i] == num[i + 1]) {
			printf("Bad\n");
			break;
		}
		if (i == 2) {
			printf("Good\n");
			break;
		}
		i++;
	}
	return 0;
}

Measured memory_bytes: 128
use std::io::Read;

fn main() {
    let mut buf = String::new();
    std::io::stdin().read_to_string(&mut buf).unwrap();

    let answer = solve(&buf);

    println!("{}", answer);
}

fn solve(input: &str) -> String {
    let mut iterator = input.split_whitespace();

    let n: usize = iterator.next().unwrap().parse().unwrap();
    return match n % 10 {
        3 => { "bon".to_string() }
        2 | 4 | 5 | 7 | 9 => { "hon".to_string() },
        _ => { "pon".to_string() }
    };
}


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

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


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

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


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<utility>
#include<vector>
using namespace std;
typedef long long ll;//ベルマンとかはllにしよ
//ここ十分にしないとだめ
#define INF 1000000000000

struct Edge{
  ll to_Node;
  ll cost;
  Edge(ll t,ll c){to_Node=t;cost=c;}
};

//関係ないループを外す
bool bellmanford(vector< vector<Edge> >& Edges,vector<ll>& mincost,ll n){
  bool f=false;
  //(l1-1)(普通のbellman)+1(検出)
  for(ll i=0;i<n;i++){
    f=false;
    for(ll j=0;j<n;j++){
      if(mincost[j]!=INF){
        ll e=Edges[j].size();
        for(ll k=0;k<e;k++){
          ll new_mincost=mincost[j]+Edges[j][k].cost;
          if(mincost[Edges[j][k].to_Node]>new_mincost){
            mincost[Edges[j][k].to_Node]=new_mincost;
            if(Edges[j][k].to_Node==n-1)f=true;
          }
        }
      }
    }
  }
  return f;//負の閉路があればtrue
}

int main(){
  ll n,m;cin >> n >> m;
  vector<ll> mincost(n,INF);
  vector< vector<Edge> > Edges(n);
  //mincost0の更新だけしっかりやる
  mincost[0]=0;

  for(ll i=0;i<m;i++){
    ll a,b,c;cin >> a >> b >> c;
    Edges[a-1].push_back(Edge(b-1,-c));
  }
  //Nodesを更新
  if(bellmanford(Edges,mincost,n)){
    cout << "inf" << endl;
  }else{
    cout << -mincost[n-1] << endl;
  }

}


Measured memory_bytes: 384
import Control.Monad
import Data.Maybe
import Debug.Trace
import Data.List
import qualified Data.Map.Strict as Map
import qualified Data.IntMap.Strict as IntMap
import qualified Data.Set as Set
import qualified Data.IntSet as IntSet
import Data.Functor
import Data.Array

main :: IO ()
main = do
  (n:m:_) <- fmap (map read . words) getLine :: IO [Int]
  pys <- replicateM m $ map read . words <$> getLine :: IO [[Int]]
  putStr $ unlines $ solve n pys

-- solve :: It -> [[Int]] -> [String]
solve n pys = map (\(p:y:_) -> (seikei p) ++ seikei (dicdic IntMap.! p IntMap.! y)) pys
  where
    dic = foldr (\(p:y:_) acc -> IntMap.insertWith (++) p [y] acc) IntMap.empty pys :: IntMap.IntMap [Int]
    dicdic = IntMap.map (\l -> IntMap.fromList (zip (sort l) [1..])) dic

seikei :: Int -> String
seikei x = (replicate (6 - l) '0') ++ xstr
  where
    xstr = show x
    l = length xstr


Measured memory_bytes: 158972
N,M = map(int,input().split())

ans = N

if N ==M or N%M ==0:
    print(0)

elif N < M:
    if abs(ans-M) > ans:
        print(ans)
    else:
        print(abs(ans-M))

else:
    print(min(N % M,abs((N % M) - M)))


Measured memory_bytes: 9164
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define repl(i,l,r) for(ll i=(l);i<(r);i++)
#define per(i,n) for(ll i=n-1;i>=0;i--)
#define perl(i,r,l) for(ll i=r-1;i>=l;i--)
#define fi first
#define se second
#define pb push_back
#define ins insert
#define pqueue(x) priority_queue<x,vector<x>,greater<x>>
#define all(x) (x).begin(),(x).end()
#define CST(x) cout<<fixed<<setprecision(x)
#define rev(x) reverse(x);
using ll=long long;
using vl=vector<ll>;
using vvl=vector<vector<ll>>;
using pl=pair<ll,ll>;
using vpl=vector<pl>;
using vvpl=vector<vpl>;
const ll MOD=1000000007;
const ll MOD9=998244353;
const int inf=1e9+10;
const ll INF=4e18;
const ll dy[8]={1,0,-1,0,1,1,-1,-1};
const ll dx[8]={0,-1,0,1,1,-1,1,-1};
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
int main(){
    ll n;cin >> n;
    vector<string> v(n);rep(i,n)cin >> v[i];
    vector<ll> num(n),den(n);
    rep(i,n){
        ll p=-1;
        rep(j,v[i].size()){
            if(v[i][j]=='.'){
                p=v[i].size()-j-1;
                v[i].erase(j,1);
                break;
            }
        }
        //cout << v[i] <<endl;
        if(p==-1)num[i]=stoll(v[i]),den[i]=1;
        else{
            num[i]=stoll(v[i]);
            den[i]=pow(10,p);
            ll z=__gcd(num[i],den[i]);
            num[i]/=z;den[i]/=z;
        }
        //cout << num[i] <<" " << den[i] <<endl;
    }
    //vector<pl> pl,mi;
    ll ans=0;
    map<pl,ll> mp;
    rep(i,n){
        ll tc=0,fc=0;
        while(num[i]%2==0)tc++,num[i]/=2;
        while(num[i]%5==0)fc++,num[i]/=5;
        while(den[i]%2==0)tc--,den[i]/=2;
        while(den[i]%5==0)fc--,den[i]/=5;
        //cout << tc<<" " << fc <<endl;
        for(auto p:mp){
            if(p.fi.fi+tc>=0&&p.fi.se+fc>=0)ans+=p.se;
        }
        mp[{tc,fc}]++;
        //if(tc<0)mi.pb({tc,fc});
        //else pl.pb({tc,fc});
    }
    cout << ans <<endl;
    /*sort(all(mi));sort(all(pl));rev(all(mi));
    ll ans=0;
    vector<ll> z;ll tmp=0;
    for(auto p:pl){
        while(tmp<mi.size()&&p.fi+mi[tmp].fi>=0){
            z.pb(mi[tmp].se);tmp++;
        }

    }*/
}

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

void solve() {
    int a, b;
    cin >> a >> b;
    if (a < b) {
        for (int i = 0; i < b; ++i) {
            printf("%d", a);
        }
    } else {
        for (int i = 0; i < a; ++i) {
            printf("%d", b);
        }
    }
    cout << endl;
}

int main() {
    solve();
    return 0;
}


Measured memory_bytes: 256
/* コードこちらに */
#include<bits/stdc++.h> //1
using namespace std;//2
int solve(){    //3
} // 4
int main(){//5
    int n,m; //7
    cin >> n >> m; // 8
    vector<pair<long long, long long>> ab(n); // 1
    vector<pair<long long, long long>> cd(m); //2
    for(int i=0; i<n; ++i){//3
        cin>>ab[i].first>>ab[i].second; // 4 これあってるのか？
    } //5 あってるきがします…！
    for(int i=0;i<m;++i){//7
        cin>>cd[i].first>>cd[i].second; // 8
    } // 1
    for(int i=0;i<n;++i){//2
        int ans=-1,dist=1e9;//3
        for(int j=0;j<m;j++) { // 4
            if(abs(ab[i].first-cd[j].first)+abs(ab[i].second-cd[j].second)<dist){ //5 
                ans=j,dist=abs(ab[i].first-cd[j].first)+abs(ab[i].second-cd[j].second);//7
            } // 8 ifの}
        } // 1 ひゃ
        cout << ans+1 << endl;//2　
        if("true"=="true"){ //3
        } // 4 こらこら
    } //5
}//7 end

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

int main(int argc, char *argv[]){
  int N;
  string S;
  cin>>N>>S;
  pair<int,int> s[N+1];
  for(int i=0; i<N+1; i++){
    s[i].first=0;
    s[i].second=0;
  }
  for(int i=0; i<N; i++){
    if(S[i]=='W'){
      s[i+1].first=s[i].first+1;
      s[i+1].second=s[i].second;
    }
    else{
      s[i+1].second=s[i].second+1;
      s[i+1].first=s[i].first;
    }
  }
   
  int min=1000000;
  int val;
  for(int i=0; i<N; i++){
    
    val=s[i].first+(s[N].second-s[i+1].second);
    //  cout<<s[i].first<<"+"<<s[N].second<<"-"<<s[i+1].second<<endl;
    if(val<min) min=val;
  }
  cout<<min<<endl;
}




Measured memory_bytes: 3076
h,w = map(int,input().split())
l = []
for _ in range(h):
    a = list(map(str,input()))
    l.append(a)

tmp = 0

for i in range(h):
    for j in range(w):
        if l[i][j] == "#":
            if j < tmp:
                print("Impossible")
                exit()
            else:
                tmp = j


print("Possible")

Measured memory_bytes: 61876
#include <bits/stdc++.h>
using namespace std;
#define repr(i,a,b) for(int i=a;i<b;i++)//半開区間[a, b)
#define rep(i,n) for(int i=0;i<n;i++)//半開区間[0, n)
#define reprrev(i,a,b) for(int i=b-1;i>=a;i--)//半開区間[a, b)を上から
#define reprev(i,n) reprrev(i,0,n)//半開区間[0, n]を上から
typedef long long ll;//intは[-2147483648, 2147483647]の範囲 
typedef unsigned long long ull;//非負整数
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
                     
const ll mod = 1e9+7;
/* <-----------------------------------------------------------------------------------> */
/* <-----------------------------------------------------------------------------------> */
/* <-----------------------------------------------------------------------------------> */
/* <-----------------------------------------------------------------------------------> */
                     
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int N, X; cin >> N >> X;
  vector<int> L(N);
  rep(i, N) cin >> L[i];
  int sum = 0;
  int ans = 1;
  int i=0;
 for(int i=0; i<N; i++) {
  sum += L[i]; 
  if(X>=sum) ans++;
  }
  cout << ans << endl;

 return 0;
}

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

#define mem(a,n) memset(a,n,sizeof(a))
#define rep(i,a,n) for(int i=a;i<n;i++)

typedef long long ll;
const double eps=1e-5;
const int N=1e5+5;
const int INF=0x3f3f3f3f;
const int dir[4][2]= {1,0,-1,0,0,1,0,-1}; ///обиосрвС

int main()
{
    int T;
    int n;
    int a[3];
    for(int i=0;i<3;i++) scanf("%d",&a[i]);
    sort(a,a+3);
    int tmp1=a[2]-a[1];

    if((a[1]-a[0])%2==1)
    {
        a[2]++;
        tmp1+=(a[2]-a[0]-tmp1)/2;
        tmp1++;
    }
    else tmp1+=(a[1]-a[0])/2;
    printf("%d\n",tmp1);
    return 0;
}


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

int main(){
    string s;
    int n;
    cin >> n;
    cin >> s;
    for(int i = 0; i < s.size(); i++){
        char l = s[i]  - 'A';
        l = (l + n) % 26;
        s[i] = l + 'A';
    }
    cout << s << endl;
}

Measured memory_bytes: 256