akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <stdlib.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<ll,ll> llP;

int main() {
  int n;
  cin>>n;
  ll a[n],sum[n];
  for(int i=0;i<n;i++){
    cin>>a[i];
    if(i==0){
      sum[i]=a[i];
    }
    else sum[i]=sum[i-1]+a[i];
  }
  ll ans=1e18;
  for(int i=0;i<n-1;i++){
    ans=min(ans,abs((sum[n-1]-sum[i])-sum[i]));
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 3328
// Gear4        
#define _CRT_SECURE_NO_WARNINGS
#include <bits/stdc++.h>
using namespace std;
#define DEBUG(x) cout << '>' << #x << ':' << x << endl;
#define FOR0(i,n) for(int i=0, _##i=(n); i<_##i; ++i)
#define FOR(i,l,r) for(int i=(l), _##i=(r); i<_##i; ++i)
#define FORD(i,l,r) for(int i=(r), _##i=(l); --i>=_##i; )
#define SZ(a) ((int)((a).size()))
#define printCase() "Case #" << caseNum << ": "
#define pb push_back
#define mp make_pair
#define SYNC std::ios::sync_with_stdio(false);  cin.tie(NULL);
#define ff first
#define ss second
template<typename T> using V = vector<T>;
template<typename T, typename U> using P = pair<T,U>;
using ld = long double;
using ll = long long;
#define endl '\n'
const int inf = 1e9, mod = 1e9 + 7;
const ll INF = 9e18;
const ld EPS = 1e-9, PI = acosl(-1.0);
const int N = 105;
int n, a[5][N], dp[5][N];
int main() {
    SYNC
    cin >> n;
    FOR0(i, 2) {
        FOR0(j, n) {
            cin >> a[i][j];
        }
    }
    dp[0][0] = a[0][0];
    FOR0(i, 2) {
        FOR0(j, n) {
            if(i) dp[i][j] = max(dp[i][j], dp[i-1][j] + a[i][j]);
            if(j) dp[i][j] = max(dp[i][j], dp[i][j-1] + a[i][j]);
        }
    }
    cout << dp[1][n-1];
}

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

int main()
{
  ll a,b,c,d;
  cin>>a>>b>>c>>d;
  cout<<max({a*c,a*d,b*c,b*d})<<endl;
}

Measured memory_bytes: 3620
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin>>n;
  vector<int> a(n);
  for(int i=0;i<n;i++)
    cin>>a.at(i);
  int64_t c=1;
  vector<int> rgb(3,0);
  for(int i=0;i<n;i++){
    int p=0;
    int x=0;
    for(int j=0;j<3;j++){
      if(rgb.at(j)==a.at(i)){
        p=j;
        x++;
      }
    }
    c=c*x%1000000007;
    rgb.at(p)++;
  }
  cout<<c<<endl;
}

Measured memory_bytes: 3788
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define FOR(i,a,b) for(int i=(a); i<=(b); i++)
#define rep(i,n) for(int i = 0; i < (n); i++)
#define chmin(a,b) if((a)>(b)) (a)=(b);
#define chmax(a,b) if((a)<(b)) (a)=(b);
#define vi vector<int>
#define pii pair<int,int>
#define all(v) (v).begin(),(v).end()
#define allr(v) (v).rbegin(),(v).rend()
#define pb push_back
#define pf push_front
int gcd(int a,int b){/*a>=0,b>=0,￢(a=b=0)*/
  while(min(a,b)>0){if(a<b)swap(a,b);a%=b;}return max(a,b);
}
int dx[]={1,0,-1,0,1,-1,-1,1};
int dy[]={0,1,0,-1,1,1,-1,-1};
const int MOD = 1e9+7;
const long long INF = 1e18+10;

/*--------------------------------------------------------------------*/
int cnt;
void insertionsort(int *a,int n,int g){
	for(int i=g;i<n;i++){
		int v=a[i];
		int j=i-g;
		while(j>=0&&a[j]>v){
			a[j+g]=a[j];
			j-=g;
			cnt++;
		}
		a[j+g]=v;
	}
}

signed main(){
	int n;
	cin>>n;
	int a[n];
	rep(i,n) cin>>a[i];

	cnt=0;
	vi G;

	for(int i=1;i<=n;){
		G.pb(i);
		i=i*3+1;
	}
	int m=G.size();
	
	reverse(all(G));

	rep(i,m){
		insertionsort(a,n,G[i]);
		// printf("g=%d\n",G[i]);
	}
	cout<<m<<endl;
	rep(i,m){
		if(i>0) cout<<' ';
		cout<<G[i];
	}
	cout<<endl;

	cout<<cnt<<endl;

	rep(i,n){
		cout<<a[i]<<endl;
	}

	return 0;
}




Measured memory_bytes: 10896
#include <bits/stdc++.h>
using namespace std;
int main()
{
	long long a,b,k;
	cin>>a>>b>>k;
	vector<long long> v;
	for (int i = 1; i <= max(a,b); ++i)
	{
		if(a%i == 0 && b%i ==0){
			v.push_back(i);
		}
	}
	reverse(v.begin(), v.end());
	cout<<v[k-1]<<endl;
	// if(v[0] == k) { cout<<k<<endl; }
	// else{ cout<<v[1]<<endl; }
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> l_l;
typedef pair<int , int> i_i;
typedef vector<ll> vl;
typedef vector<int> vi;
typedef vector<char> vec;
typedef vector<bool> veb;
typedef vector<string> ves;
typedef vector<vector<ll>> vvl;
typedef vector<vector<int>> vvi;
typedef vector<vector<char>> vvec;
typedef vector<vector<bool>> vveb;
typedef vector<vector<string>> vves;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<(int)(n);i++)
#define rep2(i,n) for(int i=2;i<(int)(n);i++)
#define repk(i,k,n) for(int i=k;i<(int)(n);i++)
#define fs first
#define sc second
#define pb push_back
#define pp pop_back
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define maxel(a) *max_element(all(a))
#define minel(a) *min_element(all(a))
#define acc accumulate
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define mod (1000000007)
typedef long long int64;
//const int64 INF = 1LL << 58;
#define dame { puts("-1"); return 0;}
#define YES { cout << "YES" << endl; return 0; }
#define NO { cout << "NO" << endl; return 0; }
#define Yes { cout << "Yes" << endl; return 0; }
#define No { cout << "No" << endl; return 0; }
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
int dx[] = {0, 0, -1, 1};
int dy[] = {1, -1, 0, 0};

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

    int n;
    cin >> n;
    string s;
    cin >> s;
    ll r=0;
    ll g=0;
    ll b=0;
    rep(i,n){
        if(s[i]=='R'){r++;}
        else if(s[i]=='G'){g++;}
        else b++;
    }
    //cout<<r<<g<<b<<endl;

    ll ans = r*g*b;

    rep(i,n){
        repk(j,i+1,n){
            bool ok = true;
            if(s[i]==s[j])ok=false;
            if(2*j-i >=n ||s[i]==s[2*j-i]||s[j]==s[2*j-i])ok = false;
            if(ok)ans--;
            //if(ok)cout << s[i] << s[j]<<s[2*j-i]<<endl;
        }
    }
    cout << ans <<endl;
    return 0;
}

Measured memory_bytes: 3572
import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedList;
import java.util.Map;
import java.util.Queue;
import java.util.Scanner;
import java.util.Set;

public class Main {
	static int N, Q;
	static int a, b, p, x;
	static Scanner scan = new Scanner(System.in);
	public static void main(String[] args) {
		N = scan.nextInt();
		Q = scan.nextInt();
		Map<Integer, Set<Integer>> map = new HashMap<>();
		int[] scores = new int[N];

		for (int i = 0; i < N - 1; i++) {
			a = scan.nextInt();
			b = scan.nextInt();
			setMap(map, a, b);
		}
		setValues(scores);

		Queue<Integer> queue = new LinkedList<>();
		queue.add(1);
		boolean[] visited = new boolean[N];
		while (!queue.isEmpty()) {
			int before = queue.poll();
			Set<Integer> tgtSet = map.get(before);
			visited[before - 1] = true;
			for (Integer next : tgtSet) {
				if (!visited[next - 1]) {
					scores[next - 1] += scores[before - 1];
					queue.add(next);
				}
			}
		}

		// 結果の出力
		StringBuilder sb = new StringBuilder();
		for (int i = 0; i < N; i++) {
			sb.append(scores[i] + " ");
		}
		System.out.print(sb);
	}

	public static void setMap(Map<Integer, Set<Integer>> map, int a, int b) {
		Set<Integer> tmpSet = map.get(a);
		if (tmpSet == null) {
			tmpSet = new HashSet<>();
		}
		tmpSet.add(b);
		map.put(a, tmpSet);

		tmpSet = map.get(b);
		if (tmpSet == null) {
			tmpSet = new HashSet<>();
		}
		tmpSet.add(a);
		map.put(b, tmpSet);
	}
	public static void setValues(int[] scores) {
		// カウンターの値を設定
		for (int i = 0; i < Q; i++) {
			p = scan.nextInt();
			x = scan.nextInt();
			scores[p - 1] += x;
		}
	}
}


Measured memory_bytes: 284704
#include <stdio.h>

int main(void) {
	int n;
	int ans;
	while (scanf("%d", &n)) {
		if (n == 0)
			break;
		ans = 0;
		do {
			n /= 5;
			ans += n;
		} while (n != 0);
		printf("%d\n", ans);
	}
	return 0;
}

Measured memory_bytes: 600
#include<cstdio>
#include<queue>
#include<cstring>
#define MN 200005
using namespace std;
typedef long long ll;
int n,m,num,S,T,head[MN],x[MN],y[MN];
bool vis[MN];
const int mod=1e9+7;
ll d1[MN],d2[MN],v[MN],f1[MN],f2[MN];
struct edge{int to,next;ll w;}g[MN<<1];
struct node{
	int x;ll y;
	friend bool operator<(node x,node y){return x.y>y.y;}
};
priority_queue<node> q;
void dij(ll *d,ll *f,int u){
	memset(vis,0,sizeof(vis));
	d[u]=0;f[u]=1;q.push((node){u,0});
	while(!q.empty()){
		node tmp=q.top();q.pop();if(vis[tmp.x]||tmp.y>d[tmp.x])continue;vis[tmp.x]=1;
		for(int i=head[tmp.x];i;i=g[i].next)
			if(d[g[i].to]>d[tmp.x]+g[i].w)f[g[i].to]=f[tmp.x],q.push((node){g[i].to,d[g[i].to]=d[tmp.x]+g[i].w});
			else if(d[g[i].to]==d[tmp.x]+g[i].w)f[g[i].to]+=f[tmp.x],f[g[i].to]%=mod;
	}
}
void ins(int u,int v,ll w){g[++num].next=head[u];head[u]=num;g[num].to=v;g[num].w=w;}
void dec(ll &x,ll y){(x-=y)<0?(x+=mod):0;}
int main(){
//	freopen("03.in","r",stdin);
//	freopen("03.out","w",stdout);
	scanf("%d%d%d%d",&n,&m,&S,&T);
	for(int i=1;i<=m;i++)scanf("%d%d%lld",&x[i],&y[i],&v[i]),ins(x[i],y[i],v[i]),ins(y[i],x[i],v[i]);
	memset(d1,0x3f,sizeof(d1));memset(d2,0x3f,sizeof(d2));
	dij(d1,f1,S);dij(d2,f2,T);ll ans=f1[T]*f1[T]%mod;
	for(int i=1;i<=n;i++)if(d1[i]+d2[i]==d1[T]&&d1[i]==d2[i])dec(ans,f1[i]*f2[i]%mod*f1[i]%mod*f2[i]%mod);
	for(int i=1;i<=m;i++){
		if(d1[x[i]]+d2[y[i]]+v[i]==d1[T]&&(d1[x[i]]+v[i]>d2[y[i]]&&d2[y[i]]+v[i]>d1[x[i]]))dec(ans,f1[x[i]]*f2[y[i]]%mod*f1[x[i]]%mod*f2[y[i]]%mod);
		if(d1[y[i]]+d2[x[i]]+v[i]==d1[T]&&(d1[y[i]]+v[i]>d2[x[i]]&&d2[x[i]]+v[i]>d1[y[i]]))dec(ans,f1[y[i]]*f2[x[i]]%mod*f1[y[i]]%mod*f2[x[i]]%mod);
	}printf("%lld\n",((ans%mod)+mod)%mod);
}

Measured memory_bytes: 18804
#ifdef _MSC_VER
#define _CRT_SECURE_NO_WARNINGS
#  include <intrin.h>
#  define __builtin_popcount __popcnt
#endif

#define _USE_MATH_DEFINES

#include <stdio.h>
#include <iostream>
#include <vector>
#include <unordered_map>
#include <stack>
#include <list>
#include <math.h>
#include <map>
#include <iomanip>
#include <functional>
#include <string>
#include <algorithm>
#include <queue>
#include <set>

using namespace std;

template<class T> ostream& operator<<(ostream& os, const vector<T>& v) {
	for (auto i = begin(v); i != end(v); i++) os << *i << (i == end(v) - 1 ? "" : " "); return os;
}
template<class T> istream& operator>>(istream& is, vector<T>& v) {
	for (auto i = begin(v); i != end(v); i++) is >> *i; return is;
}

int main()
{
#if defined(_DEBUG) 
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	cin.tie(NULL);
	ios_base::sync_with_stdio(false);
	cout.tie(NULL);

	string str;
	cin >> str;

	vector<string> sub;
	for (int sz = 1; sz <= 5; sz++)
	{
		for (int i = sz - 1; i < str.size(); i++)
		{
			sub.push_back(str.substr(i - sz + 1, sz));
		}
	}

	sort(sub.begin(), sub.end());
	sub.erase(unique(sub.begin(), sub.end()), sub.end());
	int k;
	cin >> k;
	cout << sub[k-1];


	return 0;
}

Measured memory_bytes: 1660
/*																													   
 Templatka c++ Kacper Fis																							   																											   //
*/																													  
																								   
#include <bits/stdc++.h>																							   
																													   
using namespace std; 																								   
		
const double eps = 1e-9;																							   
const int INF = 1000000001;																						   
const float PI = 3.14;																								   
typedef long long LL;																								   
																													   
typedef vector<int> vi;																								   
typedef list<int> li;																								   
typedef queue<int> qi; 																								   
typedef pair<int,int> ii; 																							   
typedef map<string,int> msi; //np msi['nazwa'] = 'liczba'															   
typedef vector<ii> vii; //vector par<int>, do tworzenia tablicy dla grafów wagowych #dijkstra #Bellman_Ford			   
typedef priority_queue< ii, vector<ii>, greater<ii> > pq; //kolejka priorytetowa vectorów par(top()=min) #dijkstra	   
																													   																				   
vector<ii>::iterator iter;																							   
																													   																				   
#define print_list(x) for(it = (x).begin(); it != (x).end(); it++) {cout << *it << " ";}							   
#define print_vector(x) for(it2 = (x).begin(); it2 != (x).end(); it2++) {cout << *it2 << " ";}						   
#define search_list(x) for(it = (x).begin(); it != (x).end(); it++)													   
#define search_vector(x) for(it2 = (x).begin(); it2 != (x).end(); it2++);											   
#define pb(x) push_back(x) 																							   
#define pf(x) push_front(x)																							   
#define mp(x, y) make_pair(x, y)                                                                                       
///////////////////////////////////////////////GLOBAL DEFINITIONS////////////////////////////////////////////////////////

int even[100005];
int odd[100005];

///////////////////////////////////////////////////FUNCTIONS/////////////////////////////////////////////////////////////



/////////////////////////////////////////////////////MAIN////////////////////////////////////////////////////////////////
int main(int argc, char* argv[])																					 
{ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);                  												       
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
    
	int n, m;
	cin >> n >> m;
	for(int i = 0; i < n; i++){
		even[i] = 2;
	}
	for(int i = 0; i < m; i++){
		odd[i] = 1;
	}
	
	int ans = 0;
	
	for(int i = 0; i < n; i++){
		for(int j = i+1; j < n; j++){
			if(i != j){
				if((even[i] + even[j]) % 2 == 0){
					ans++;
				}
			}
		}
	}
	
	for(int i = 0; i < m; i++){
		for(int j = i+1; j < m; j++){
			if(i != j){
				if((odd[i] + odd[j]) % 2 == 0){
					ans++;
				}
			}
		}
	}
	
	cout << ans << endl;
	
	
	return 0;
}


Measured memory_bytes: 256
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author aajisaka
 */

#include<bits/stdc++.h>

using namespace std;

void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}
#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

#define SPEED ios_base::sync_with_stdio(false);cin.tie(nullptr)
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define all(v) v.begin(), v.end()
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; }

using ll = long long;
using P = pair<ll, ll>;

constexpr long double PI = 3.14159265358979323846264338327950288L;
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());

class ASheepAndWolves {
public:
    void solve(istream& cin, ostream& cout) {
      SPEED;
      int s, w; cin >> s >> w;
      if (w >= s) {
        cout << "unsafe" << endl;
      } else {
        cout << "safe" << endl;
      }
    }
};

signed main() {
  ASheepAndWolves solver;
  std::istream& in(std::cin);
  std::ostream& out(std::cout);
  solver.solve(in, out);
  return 0;
}

Measured memory_bytes: 3588
function main (s) {
	var a=0,b=0,c=0;
	for(var i=0;i<s.length;i++)if(s[i]==='a')a++;
	else if(s[i]==='b')b++;
	else if(s[i]==='c')c++;
	if(a===1&&b===1&&c===1)console.log("Yes\n");
	else console.log("No\n");
}
 
main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 7372
from collections import Counter
n,k,q = map(int,input().split())
a=[]
for i in range(q):
    a.append(int(input()))
point=[k-q]*n
r=Counter(a)
for i,j in r.items():
    point[i-1] += j
for i in point:
    if i>0:
        print('Yes')
    else:
        print('No')

Measured memory_bytes: 13944
#include<iostream>
#include<string>
#include<algorithm>
using namespace std;
int s[100000];
int pleft[100000],pright[100000];
int main(){
	int n,k;
	while(true){
	cin>>n>>k;
	if(n==0&&k==0)
		break;
	bool zero=false;
	for(int i=0;i<k;i++){
		cin>>s[i];
		if(s[i]==0)
			zero=true;
	}
	sort(s,s+k);
	if(zero==false){
		int best=1;
		int count=1;
		for(int i=1;i<k;i++){
			if(s[i-1]+1==s[i])
				count++;
			else{
				best=max(best,count);
				count=1;
			}
		}
		best=max(best,count);
		cout<<best<<endl;
	}
	else{
		int top=0;
		bool start=true;
		for(int i=2;i<k;i++){
			if(s[i-1]+1==s[i]&&start==true){
				pleft[top]=s[i-1];
				start=false;
			}
			if(s[i-1]+1!=s[i]){
				if(start==true)
					pleft[top]=s[i-1];
				pright[top]=s[i-1];
				top++;
				start=true;
			}
		}
		pright[top]=s[k-1];
		top++;
		int best=1;
		for(int i=1;i<top;i++){
			if(pright[i-1]+2==pleft[i])
				best=max(best,1+pright[i]-pleft[i-1]);
		}
		cout<<best<<endl;
	}
	}
	return 0;
}

Measured memory_bytes: 1624
//
//AtCoder Beginner Contest 171
//D - Replacing
//

#include <iostream>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
#include <ctime>
#include <queue>
#include <map>
#include <set>
#include <tuple>
#include <functional>
#include <cassert>

using namespace std;

#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
#define ALL(x) (x).begin(),(x).end()
#define RALL(x) (x).rbegin(),(x).rend()
#define SIZE(x) (int)(x).size()
#define SIZEL(x) (ll)(x).size()
#define MSG(a) cout << #a << " " << a << endl;

using ll = long long;
using ld = long double;

const double PI = 3.14159265358979323846;

ll gcd(ll x, ll y) { return (x % y)? gcd(y, x % y): y; }    //最大公約数
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }            //最小公倍数

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

    ll sum=0;
    map<int,int> am;
    REP(i, n) {
        int a;
        cin >> a;
        sum+=a;
        am[a]++;
    }
    int q;
    cin >> q;
    vector<int> b(q);
    vector<int> c(q);
    REP(i, q) cin >> b[i] >> c[i];
    
    vector<ll> s(q, 0);
    REP(i,q){
        if(am[b[i]]>0){
            sum -= (b[i]-c[i])*am[b[i]];
            am[c[i]] += am[b[i]];
            am[b[i]] = 0;
        }
        s[i]=sum;
    }

    REP(i,q) cout << s[i] << endl;
    return 0;
}


Measured memory_bytes: 9064
#include <iostream>
#include <cstdio>
#include <iomanip>
#include <string>
#include <cmath>
#include <algorithm>
#include <iomanip> 
#include <cstring>
#include <queue>
#include <stack> 
#include <vector>
#include <map>
#include <set>
using namespace std;
typedef long long ll;
ll n,k;
int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	cin >> n >> k;
	n = n % k;
	if(n > abs(n - k)){
		n = abs(n - k);
	}
	cout << n << endl;

	return 0;
}

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

public class Program
{

    public void Proc()
    {

        int[] inpt = Reader.ReadLine().Split(' ').Select(a => int.Parse(a)).ToArray();

        int x1 = inpt[0];
        int y1 = inpt[1];

        int x2 = inpt[2];
        int y2 = inpt[3];


        int x3 = 0;
        int y3 = 0;
        int x4 = 0;
        int y4 = 0;

        int xKatamuki = (x1 - x2);
        int yKatamuki = (y1 - y2);

        x3 = x2 + yKatamuki;
        y3 = y2 - xKatamuki;

        x4 = x3 + xKatamuki;
        y4 = y3 + yKatamuki;


        Console.WriteLine(string.Join(" ", new int[] { x3, y3, x4, y4 }));

        if (xKatamuki == 0) {
            if(y1 < y2) {
                x3 = x2 + yKatamuki;
            }
        } else if (yKatamuki == 0) {

        } else {
            int newY1 = y2 + xKatamuki;
            int newY2 = y2 - xKatamuki;

            int newX1 = x2 + (yKatamuki * -1);
            int newX2 = x2 - (yKatamuki * -1);

            if(x1 < x2) {
                x3 = x2 + yKatamuki;
                y3 = y2 - xKatamuki;

                x4 = x3 + xKatamuki;
                y4 = y3 + yKatamuki;

            } else {
                x3 = x2 + yKatamuki;
                y3 = y2 - xKatamuki;

                x4 = x3 + xKatamuki;
                y4 = y3 + yKatamuki;
            }
        }
    }





    public class Reader
    {
        static StringReader sr;
        public static bool IsDebug = false;
        public static string ReadLine()
        {
            if (IsDebug)
            {
                if (sr == null)
                {
                    sr = new StringReader(InputText.Trim());
                }
                return sr.ReadLine();
            }
            else
            {
                return Console.ReadLine();
            }
        }
        private static string InputText = @"


0 0 0 1


";
    }

    public static void Main(string[] args)
    {
#if DEBUG
        Reader.IsDebug = true;
#endif
        Program prg = new Program();
        prg.Proc();
    }
}


Measured memory_bytes: 13396
#include <cstdint>
#include <iostream>
#include <limits>
#include <string>

using namespace std;

namespace {
int64_t H, W;
}

int64_t Horizontal() {
  int64_t h1 = H / 3;
  int64_t h2 = (H - h1) / 2;
  int64_t h3 = H - h1 - h2;
  int64_t area1 = h1 * W;
  int64_t area2 = h2 * W;
  int64_t area3 = h3 * W;
  
  return max(area1, max(area2, area3)) - min(area1, min(area2, area3));
}

int64_t Vertical() {
  int64_t w1 = W / 3;
  int64_t w2 = (W - w1) / 2;
  int64_t w3 = W - w1 - w2;
  int64_t area1 = w1 * H;
  int64_t area2 = w2 * H;
  int64_t area3 = w3 * H;
  
  return max(area1, max(area2, area3)) - min(area1, min(area2, area3));
}

int64_t HorizontalMain() {
  int64_t diff = numeric_limits<int64_t>::max();
  
  int64_t half = W / 2;
  for (int64_t h = 1; h < H; ++h) {
    int64_t area1 = h * W;
    int64_t area2 = (H - h) * half;
    int64_t area3 = (H - h) * (W - half);

    diff = min(diff, max(area1, max(area2, area3)) - min(area1, min(area2, area3)));
  }
  return diff;
}

int64_t VerticalMain() {
  int64_t diff = numeric_limits<int64_t>::max();
  
  int64_t half = H / 2;
  for (int64_t w = 1; w < W; ++w) {
    int64_t area1 = w * H;
    int64_t area2 = (W - w) * half;
    int64_t area3 = (W - w) * (H - half);

    diff = min(diff, max(area1, max(area2, area3)) - min(area1, min(area2, area3)));
  }
  return diff;
}

int main() {
  cin >> H >> W;

  if (H % 3 == 0) { cout << 0 << endl; return 0; }
  if (W % 3 == 0) { cout << 0 << endl; return 0; }

  int64_t diff = numeric_limits<int64_t>::max();
  diff = min(diff, Horizontal());
  diff = min(diff, Vertical());
  diff = min(diff, HorizontalMain());
  diff = min(diff, VerticalMain());
  
  cout << diff << endl;
  
  return 0;
}


Measured memory_bytes: 3604
#include<stdio.h>

int main() {
	int N, D, X,count=0,countmax=0;
	int A[100];

	scanf("%d", &N);
	scanf("%d %d", &D, &X);

	for (int i = 0; i < N; i++) {

		scanf("%d", &A[i]);
		count =( D-1) / A[i] ;
		countmax += count;
		count = 0;
		
	}

	printf("%d", countmax+X+N);
	return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <fstream>
#include <cmath>
#include <string>
#include <vector>
#include <map>
#include <queue>
#include <set>

typedef long long ll;
using std::vector;
template<typename T> void ndarray(vector<T> &vec, int len) { vec.resize(len); }
template<typename T, typename... Args> void ndarray(vector<T> &vec, int len, Args... args) {
    vec.resize(len);
    for (auto &v : vec) ndarray(v, args...);
}

int main() {
    //std::ifstream in("0_normal_2");
    //std::cin.rdbuf(in.rdbuf());
    
    std::string S;
    std::cin >> S;
    
    if (S=="Sunny") {
        std::cout << "Cloudy" << std::endl;
    } else if (S=="Cloudy") {
        std::cout << "Rainy" << std::endl;
    } else {
        std::cout << "Sunny" << std::endl;
    }
    
    return 0;
}


Measured memory_bytes: 256
from itertools import permutations
from scipy.sparse.csgraph import floyd_warshall as ws

def search(r,dist,ans):
    sum_=0
    for i in range(1,len(r)):
        sum_+=dist[r[i-1]][r[i]]
    return sum_

N,M,R=list(map(int,input().split()))
r=list(map(int,input().split()))
r=[x-1 for x in r]
dist=[[float('inf') for _ in range(N)] for _ in range(N)]
for i in range(M):
    A,B,C=list(map(int,input().split()))
    dist[A-1][B-1]=C
    dist[B-1][A-1]=C
for i in range(N):
    dist[i][i]=0
dist=ws(dist)

ans=float('inf')

ans=float('inf')
r=permutations(r)
for x in r:
    ans=min(ans,search(x,dist,0))
print(int(ans))

Measured memory_bytes: 20688
(defn comb [n r]
  (if (< n r)
    0
    (let [ls (range 1 (inc n))
          p  (reduce * (take-last r ls))
          r! (reduce * (take r ls))]
      (quot p r!))))

(let [n (read)
      m (read)]
  (println (+ (comb n 2)
              (comb m 2))))

Measured memory_bytes: 86304
import java.util.Scanner;

public class Main{
    public static void main(String[] args) {
        Scanner input = new Scanner(System.in);
        
        
        
       while(input.hasNextInt()){
            int x1 =input.nextInt();
           int x2 =input.nextInt();
            int x3 = x1+x2;
        String s1 = String.valueOf(x3);
        System.out.println(s1.length());
        }}
    }

Measured memory_bytes: 20392
<STDIN>;
my @p = split //, <STDIN>;
my $l = scalar(@p) - 1;
my $m = $l;
my $w = [0];
my $e = [0];
my $i = 1;
my $tw = 0, $te = 0;
foreach(@p) {
    $w->[$i] = $_ eq 'W' ? $w->[$i - 1] + 1 : $w->[$i - 1];
    $e->[$i] = $_ eq 'E' ? $e->[$i - 1] + 1 : $e->[$i - 1];
    $i++;
}
foreach(1 ... $l) {
    my $k = $_;
    my $a1 = $w->[$k - 1];
    my $a2 = $e->[$l] - $e->[$k];
    #print $k, $a1, $a2,"\n";
    $m = $a1 + $a2 if $a1 + $a2 < $m;
}

print $m;

Measured memory_bytes: 52888
#include<iostream>

#define MAX 105

int main(){
  int n,u,k;
  int adj[MAX][MAX] = {{0}};
  int A[MAX][MAX] = {{0}};
  std::cin >> n;
  for(int i=1;i<=n;i++){
    std::cin >> u >> k;
    for(int j=1;j<=k;j++){
      std::cin >> adj[u][j];
    }
    adj[u][k+1] = -1;
  }
  //std::cout << "入力\n";

  for(int i=1;i<=n;i++){
    int j=1;
    while(adj[i][j] != -1){
      A[i][adj[i][j]] = 1;
      j++;
    }
    std::cout << A[i][1] ;
    for(j=2;j<=n;j++){
      std::cout << ' ' << A[i][j] ;
    }
    std::cout << '\n';
  }

  return 0;
}




Measured memory_bytes: 3164
#include <iostream>
using namespace std;
static const int MAX = 25;
static const int NIL = -1;

class Node {
    public:
        int parent, left, right;
        Node();
};
Node::Node() {
    parent = left = right = NIL;
}
Node T[MAX];


// preorder巡回
void preParse(int u) {
    if (u == NIL) return;
    cout << " " << u;
    preParse(T[u].left);
    preParse(T[u].right);
}

// Inorder巡回
void inParse(int u) {
    if (u == NIL) return;
    inParse(T[u].left);
    cout << " " << u;
    inParse(T[u].right);
}

// Postorder巡回
void postParse(int u) {
    if (u == NIL) return;
    postParse(T[u].left);
    postParse(T[u].right);
    cout << " " << u;
}

int main() {
    int n, id, left, right, root;
    cin >> n;
    for (int i = 0; i < n; i++) {
        cin >> id >> left >> right;
        T[id].left = left;
        T[id].right = right;
        if (left != NIL) T[T[id].left].parent = id;
        if (right != NIL) T[T[id].right].parent = id;
    }
    for (int i = 0; i < n; i++) {
        if (T[i].parent == NIL) root = i;
    }
    cout << "Preorder" << endl;
    preParse(root);
    cout << endl;
    cout << "Inorder" << endl;
    inParse(root);
    cout << endl;
    cout << "Postorder" << endl;
    postParse(root);
    cout << endl;

    return 0;
}



Measured memory_bytes: 3080
// J'aime
// Chemise Blanche

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

#define int long long

#define ii pair<int,int>
#define fi first
#define sc second

#define all(x) (x).begin(),(x).end()
#define dbg(x) cerr << __LINE__ << " > " << #x << " = " << (x) << endl

void MAIN() {
  vector<int> a(6);
  for (auto &i : a) cin >> i;
  if (a[4] - a[0] > a[5]) cout << ":(" << '\n';
  else cout << "Yay!" << '\n';
}

signed main() {
#ifdef _DEBUG
  // freopen("in" , "r", stdin );
  // freopen("out", "w", stdout);
#endif
  ios::sync_with_stdio(0); cin.tie(0);
  int T = 1;
  // cin >> T;
  while (T--) MAIN();
}


Measured memory_bytes: 3604
#include <assert.h>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <algorithm>
#include <numeric>
#include <functional>
#include <iostream>
#include <string>
#include <array>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <complex>
#include <bitset>
typedef long long ll;
typedef unsigned long long ull;

#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define DEBUG(vec) for (auto v : vec) { cout << v << " "; } cout << endl;

using namespace std;

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

  int N, W;
  cin >> N >> W;

  ll w[110] = {};
  ll v[110] = {};
  REP(i, N) {
    cin >> w[i] >> v[i];
  }

  vector<vector<ll>> d = vector<vector<ll>>(4, vector<ll>());
  ll w0 = w[0];
  d[0].push_back(v[0]);
  for (int i = 1; i < N; i++) {
    d[w[i] - w[0]].push_back(v[i]);
  }
  REP(i, 4) {
    sort(d[i].begin(), d[i].end(), greater<ll>());
    // DEBUG(d[i]);
  }

  ll mx = 0;
  REP(i, d[0].size() + 1) {
    REP(j, d[1].size() + 1) {
      REP(k, d[2].size() + 1) {
        REP(l, d[3].size() + 1) {
          ll w = w0 * i + (w0 + 1) * j + (w0 + 2) * k + (w0 + 3) * l;
          // cout << "weight: " << w << endl;
          if (w <= W) {
            ll total = 0;
            REP(m, i) total += d[0][m];
            REP(m, j) total += d[1][m];
            REP(m, k) total += d[2][m];
            REP(m, l) total += d[3][m];
            mx = max(mx, total);
          }
        }
      }
    }
  }

  cout << mx << endl;
  return 0;
}


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

using namespace std;

#define lli long long int
#define REP(i,s,n) for(int i=s;i<n;i++)
#define RREP(i,s,n) for(lli i=s;i>=n;i--)
#define MOD 1000000007
#define NUM 2520
#define DEBUG 0
#define mp(a,b) make_pair(a,b)
#define SORT(V) sort(V.begin(),V.end())
#define PI (3.141592653589794)
#define INF (1LL<<50)

signed main(){

	lli n,p;
	cin>>n>>p;

	string s;
	cin>>s;
	map<lli,lli> cnt;
	reverse(s.begin(),s.end());

	cnt[0]++;
	lli ten = 1;
	lli now = 0;
	if(p==2 || p==5){
		lli ans = 0;
		REP(i,0,n){
			if( (s.at(i)-'0') %p == 0)
			{
				ans += (n-i);
			}
		}
		cout<<ans<<endl;
		return 0;
	}
	REP(i,0,n){
		now += (s.at(i)-'0')*ten;
		now %= p;
		cnt[now]++;
		ten *= 10;
		ten %= p;
	}

	lli ans = 0;
	for(auto e:cnt){
		ans += (e.second*(e.second-1))/2;
	}

	cout<<ans<<endl;


	return 0;
}

Measured memory_bytes: 1028
#include <cstdio>
#include <algorithm>

using namespace std;

int gcd(int a, int b) {
    if (a > b) {
        int buf = a;
        a = b;
        b = buf;
    }
    return a == 0 ? b : gcd(a, b%a);
}

int main() {
    int n;
    scanf("%d", &n);
    int front[n+1], back[n+1], a[n];
    for (int i=0; i<n; i++) scanf("%d", a+i);
    front[0] = 0; back[n] = 0;
    for (int i=0; i<n; i++) {
        front[i+1] = gcd(front[i], a[i]);
        back[n-1-i] = gcd(back[n-i], a[n-1-i]);
    }
    int ans=0;
    for (int i=0; i<n; i++) ans = max(ans, gcd(front[i], back[i+1]));
    printf("%d\n", ans);
    return 0;
}

Measured memory_bytes: 1280
function Main(input) {
  const arr = input.split('\n');
  const n = arr[0].split(' ')[0];
  const h = arr[1].split(' ').map(x => Number(x));
  const sum = h.reduce((acc, curr) => acc + curr);

  if (sum > n) {
    console.log('-1');
  } else {
    console.log(n - sum);
  }
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 30336
#include<bits/stdc++.h>
using namespace std;
int main(){
  long long N,A,B;cin>>N>>A>>B;
  if((B-A)%2==0){
    cout<<(B-A)/2<<endl;
  }
  else{
    if(A>N-B){
      cout<<(N-A+N-B+1)/2<<endl;
    }
    else{
      cout<<(A-1+B-1+1)/2<<endl;
    }
  }
}

Measured memory_bytes: 3604
#include <bits/stdc++.h>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<string> vs;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<int,P> pip;
typedef vector<pip> vip;
const int inf=1<<30;
const ll INF=1ll<<60;
const double pi=acos(-1);
const double eps=1e-11;
const ll mod=1e9+7;
const int dx[4]={-1,0,1,0},dy[4]={0,-1,0,1};


int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	int h,w,n;
	cin>>h>>w>>n;
	vs a(w,string(h,'.'));
	for(int i=0;i<h;i++) for(int j=0;j<w;j++) cin>>a[w-j-1][h-i-1];
	swap(h,w);
	bool B=0;
	for(int i=0;i<h-1;i++) for(int j=0;j<w;j++) if(a[i][j]!=a[i+1][j]){
		auto b=a;
		swap(b[i][j],b[i+1][j]);
		int ikkai=0;
//		for(int k=0;k<h;k++) cout<<b[k]<<endl;
		while(1){
			if(ikkai){
			vp c;
			for(int k=0;k<h;k++){
				for(int l=0;l<w;l++) if(isalpha(b[k][l])){
					int x=k,y=l;
					if(y+n-1<w){
						bool tmp=1;
						for(int I=1;I<n;I++) if(b[x][y]!=b[x][y+I]) tmp=0;
						if(tmp==1){
							for(int I=0;I<n;I++) c.push_back({x,y+I});
						}
					}
					if(x+n-1<h){
						bool tmp=1;
						for(int I=1;I<n;I++) if(b[x][y]!=b[x+I][y]) tmp=0;
						if(tmp==1){
							for(int I=0;I<n;I++) c.push_back({x+I,y});
						}
					}
				}
			}
			for(auto p:c) b[p.first][p.second]='.';
			if(c.empty()&&ikkai) break;
			}
			vs b_(h);
			for(int k=0;k<h;k++){
				for(int l=0;l<w;l++) if(isalpha(b[k][l])) b_[k]+=b[k][l];
				while(b_[k].size()<w) b_[k]+='.';
			}
			b=b_;
			ikkai=1;
//		for(int k=0;k<h;k++) cout<<b[k]<<endl;
		}
		if(b==vs(h,string(w,'.'))) B=1;
	}
	cout<<(B?"YES":"NO")<<endl;
}


Measured memory_bytes: 3240
#include <algorithm>
#include <cassert>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <vector>

#include <limits.h>

using namespace std;

typedef long long ll;

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

int main(void) {
    int a, b;
    cin >> a >> b;
    if ((a * b) % 2 == 0) {
        cout << "Even" << endl;
    } else {
        cout << "Odd" << endl;
    }
    return 0;
}


Measured memory_bytes: 3568
N, T = map(int, input().split())
A = list(map(int, input().split()))

max_bef = 0
cnt = 0
A_min = A[0]

for i in range(1,N):
    tmp = A[i] - A_min
    if max_bef < tmp:
        max_bef = tmp
        cnt = 0
    if max_bef == tmp:
        cnt += 1
    A_min = min(A_min, A[i])

print(cnt)


Measured memory_bytes: 14252
#include<stdio.h>
#define MAX 100001
#define NIL -1
struct Node{
  int A;
  int B;
  int C;
};

struct Node Three[MAX];

int getDepth(int K){
  int dep = 0;
  
  for(dep = 0; Three[K].A != NIL; dep++){
    K = Three[K].A;
  }
  return dep;
}

int main(){
  int i,j,n;
  int num,deg,child,l = 0;
    scanf("%d",&n);
    for(i = 0; i < n; i++){
      Three[i].A = NIL;
      Three[i].B = NIL;
      Three[i].C = NIL;
    }
    

    for(i = 0; i < n; i++){

      scanf("%d%d",&num,&deg);
      for(j = 0; j < deg; j++){
        scanf("%d",&child);



        if(j == 0) Three[num].B = child;
        else Three[l].C = child;


        l = child;
        Three[child].A = num;
      }

    }
    
    for(i = 0; i < n; i++){
      printf("node %d: parent = %d, depth = %d",i,Three[i].A,getDepth(i));
      


      if(getDepth(i) == 0){


        printf(", root, [");

      }
      else if(Three[i].B == NIL){

        printf(", leaf, [");

      }

      else{



        printf(", internal node, [");
      }
      
      j = Three[i].B;
      
      while(j != NIL){


        printf("%d", j);

        j = Three[j].C;
        
        if(j != NIL){

          printf(", ");


        }

      }


      printf("]\n");

    }

    
    return 0;
}

Measured memory_bytes: 1784
#include <iostream>
#include <vector>
#include <stdlib.h>

using std::cout;
using std::cin;
using std::endl;
using std::vector;

int main (int args, char** argv){
    int a, b, c;
    cin >> a;
    cin >> b;
    cin >> c;

    cout << c << " " << a << " " << b << endl;
return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int a[110];
int main(){
	int n;
	scanf("%d",&n);
	for(int i=0;i<n;i++)scanf("%d",a+i);
	for(int i=0;i<n;i++){
		int j=i;
		while(i>0&&a[j-1]>a[i])j--;
		int t=a[i];
		for(int k=i;k>j;k--)a[k]=a[k-1];
		a[j]=t;
		for(int j=0;j<n;j++)printf("%d%c",a[j],j==n-1?10:32);
	}
}


Measured memory_bytes: 2056
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cstring>
#include <map>
#define pii pair<int,int>
#define MP make_pair
#define fir first
#define sec second
#define PB push_back
#define db long double
#define ll long long
using namespace std;
template <class T>
inline void rd(T &x) {
	x=0; char c=getchar(); int f=1;
	while(!isdigit(c)) { if(c=='-') f=-1; c=getchar(); }
	while(isdigit(c)) x=x*10-'0'+c,c=getchar(); x*=f;
}
/*
f[l,r,xl,xr]:
	in range [l,r], l and r were the first values vomitted
	l is counted xl times
	r is counted xr times
	f is the minimum possible sum of the contribution of values in range (l,r) ? 
*/
const int N=20;
map<pii,ll> mp[N][N];
int n;
int a[N];
ll dfs(int l,int r,int xl,int xr) {
	if(r==l+1) return 0;
	if(mp[l][r].count(MP(xl,xr))) return mp[l][r][MP(xl,xr)];
	ll ans=1e18;
	for(int k=l+1;k<r;++k)
		ans=min(ans,dfs(l,k,xl,xl+xr)+dfs(k,r,xl+xr,xr)+(xl+xr)*(ll)a[k]);
	return mp[l][r][MP(xl,xr)]=ans;
}
int main() {
	rd(n);
	for(int i=1;i<=n;++i) rd(a[i]);
	printf("%lld\n",dfs(1,n,1,1)+a[1]+a[n]);
	return 0;
}


Measured memory_bytes: 16512
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll n,a[3009],dp[3009][3009];
ll best(ll l,ll r,bool b)
{
    if(l>r) return 0;
    ll &ret=dp[l][r];
    if(ret<1e14) return ret;
    if(b)
    return ret=min(best(l+1,r,0)-a[l],best(l,r-1,0)-a[r]);
    return ret=max(best(l+1,r,1)+a[l],best(l,r-1,1)+a[r]);
}
int main()
{
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
cin>>n;
for(ll i=0;i<n;i++)
    cin>>a[i];
for(ll i=0;i<=n;i++)
    for(ll j=0;j<=n;j++)
    dp[i][j]=1e14;
cout<<best(0,n-1,0);
return 0;
}


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

#define ASC(vec) vec.begin(), vec.end()		// 昇順ソート 例：sort(ASC(vec));
#define DESC(vec) vec.rbegin(), vec.rend()	// 降順ソート 例:sort(DESC(vec));
#define rep(i, n) for(int i = 0; i < n; i++)
#define Rep(i, n) for(int i = 1; i < n; i++)

const int mod = 1000000007;
const int inf = (int)1e9 + 7;
const long long INF = 1LL << 60;

using ii = pair<int, int>;
using ll = long long;
using vi = vector<int>;
using vd = vector<double>;
using vb = vector<bool>;
using vl = vector<ll>;
using vs = vector<string>;
using vvi = vector<vector<int>>;
using vvl = vector<vector<ll>>;
using vii = vector<pair<int, int>>;

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

ll GCD(ll a, ll b) { return b ? GCD(b, a % b) : a; }
ll LCM(ll a, ll b) { return (a * b) / GCD(a, b); }
int round_int(int a, int b) { return (a + (b - 1)) / b; }

// 素因数分解; 返り値は(素数, 乗数)のvector配列
vector<pair<ll, int>> factorize(ll n) {
	vector<pair<ll, int>> res;
	for (ll i = 2; i * i <= n; ++i) {
		if (n % i) continue;
		res.emplace_back(i, 0);
		while (n % i == 0) {
			n /= i;
			res.back().second++;
		}
	}
	if (n != 1) res.emplace_back(n, 1);
	return res;
}

constexpr array<int, 9> dx = { 0, 1, 0, -1, -1, 1, 1, -1, 0 };
constexpr array<int, 9> dy = { 1, 0, -1, 0, 1, 1, -1, -1, 0 };
constexpr auto MAX = 100010;

// ──────────────────────────────────────────────────────────────────────────────

int main() {
	int n;
	cin >> n;
	vs s(n);
	rep(i, n) cin >> s[i];

	map<string, int> cnt;
	rep(i, n) cnt[s[i]]++;
	vector<pair<int, string>> t;
	for (auto itr = cnt.begin(); itr != cnt.end(); ++itr) {
		auto i = *itr;
		t.push_back({ i.second, i.first });
	}
	sort(DESC(t));
	int mx = t[0].first;
	vs ans;
	for (int i = 0; i < t.size() && t[i].first == mx; ++i) {
		ans.push_back(t[i].second);
	}
	//cout << endl;
	sort(ASC(ans));
	rep(i, ans.size()) cout << ans[i] << endl;
}

Measured memory_bytes: 33900
#include <iostream>
#include <algorithm>
#include <complex>
#include <utility>
#include <vector>
#include <string>
#include <queue>
#include <tuple>
#include <cmath>
#include <bitset>
#include <cctype>
#include <set>
#include <numeric>
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(ll i=ll(a);i<ll(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
#define PRINT(V) cout << V << "\n"
#define SORT(V) sort((V).begin(),(V).end())
#define RSORT(V) sort((V).rbegin(), (V).rend())
using namespace std;
using ll = long long;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
inline bool Yes(bool condition){ if(condition) PRINT("Yes"); else PRINT("No"); }
template<class itr> void cins(itr first,itr last){
    for (auto i = first;i != last;i++){
        cin >> (*i);
    }
}
template<class itr> void array_output(itr start,itr goal){
    string ans = "",k = " ";
    for (auto i = start;i != goal;i++) ans += to_string(*i)+k;
    if (!ans.empty()) ans.pop_back();
    PRINT(ans);
}
ll gcd(ll a, ll b) {
    return a ? gcd(b%a,a) : b;
}
const ll INF = 1e17;
const ll MOD = 1000000007;
typedef pair<ll,ll> P;
const ll MAX = 200005;
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s;
    cin >> s;
    ll ans = 0;
    rep(i,3) if (s[i] == '1') ans++;
    PRINT(ans);
}


Measured memory_bytes: 256
a=gets.split.map(&:to_i).sort
a[0]+=2*x=(a[2]-a[0])/2
a[1]+=2*y=(a[2]-a[1])/2
res=x+y
while a.uniq.size>1
    a.sort!
    a[2]-=1
    res+=1
end
puts res

Measured memory_bytes: 1788
#include "bits/stdc++.h"
#define ALL(x) x.begin(), x.end()
#define iostreamBooster() do{ cin.tie(nullptr); ios_base::sync_with_stdio(false); }while(0)
using namespace std;
typedef int64_t i64;
typedef pair<int,int> pii;
template<class A, class B>inline bool chmax(A &a, const B &b){return b>a ? a=b,1 : 0;}
template<class A, class B>inline bool chmin(A &a, const B &b){return b<a ? a=b,1 : 0;}
constexpr int INF = 0x3f3f3f3f;

signed main()
{
  int N;
  i64 ans = 0;

  cin >> N;
  for (int i = 0; i < N; ++i) {
    i64 a; cin >> a;
    ans += a-1;
  }

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



Measured memory_bytes: 256
s = input()

s_p = []

#print(len(s))

for i in range(len(s)):
    s_p += s[i]
    s_p += "+"
s_p = s_p[:-1]
# print(s_p)

s_p_list = []

def bit_list(i, n, bit_str):
    #print(bit_str)
    tmp = bit_str[:]
    if (i*2+1 == n):
        tmp = "".join(tmp)
        tmp = tmp.split('+')
        tmp = sum(list(map(int, tmp)))
        #print(i, i*2+1, tmp)

        s_p_list.append(tmp)
        return

    #print(i, i*2+1)
    tmp[i*2+1] = ''
    bit_list(i+1, n, tmp)

    tmp[i*2+1] = '+'
    bit_list(i+1, n, tmp)

#print(len(s_p), s_p)
bit_list(0, len(s_p), s_p)

print(sum(s_p_list))
#print(len(s_p_list))
# print(s)

Measured memory_bytes: 3064
// みなさん私はカーティキー・シャルマです。LNMIITで勉強しています。私は2年目で、コロナパンデミックが発
// 生しています。世界は終わりそうだ。だから私はそれを最大限に生きたいと思っています。それはつまり、コー
// ドを最大限に意味しているのです。私の好きなアニメは「キメツノヤイバ」で、私の一番の男の子はゼニツで、
// 私の一番の女の子はネズコです。私の好きな呼吸スタイルは息吹です。私の最高の悪魔の血の芸術は、
// ククシボによって使用される月の息です。ムーザンは亡くなり、今ではタンジローがポップの新しい魔王です。
#include <bits/stdc++.h>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <vector>
#include <string>
using namespace std;
typedef double  dbl;
typedef long long int lld;
#define PI 3.14159265358979323
#define foi(i,n) for(lld i = 0; i < n; i+=1)
#define fod(i,n) for(lld i=n-1; i >=0; i-=1)
#define MAX std::numeric_limits<lld>::max()
#define MIN std::numeric_limits<lld>::min()
#define FastIO  ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
map <lld, lld> vis;
lld rec_ (lld pos, lld A[], lld n)
{
	if (!vis.count(pos)){
		if (pos == n-0) vis[pos] = 0;
		else if (pos == n-1) vis[pos] = rec_(pos+1, A, n) + abs(A[pos]-A[pos+1]);
		else vis[pos] = min(rec_(pos+1, A, n) + abs(A[pos]-A[pos+1]), rec_(pos+2, A, n) + abs(A[pos]-A[pos+2]));
	}
	return vis[pos];
}
int main ()
{
      FastIO
      lld n;
      cin >> n;
      lld A[n+1];
      for(lld i = 1; i <= n; i += 1){
      	cin >> A[i];
      }
      cout << rec_(1,A,n);
      return 0;
}

Measured memory_bytes: 14576
#include <iostream>
#include <algorithm>
#include <array>
#include <cstdint>
#include <functional>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stack>
#include <stdlib.h>
#include <string>
#include <time.h>
#include <utility>
#include <vector>

#define INF 1000000000
#define MOD 1000000007
#define rep(i,a,b) for(uint32 i = (a); i < (b); ++i)
#define bitget(a,b) (((a) >> (b)) & 1)
#define ALL(x) (x).begin(),(x).end()
#define C(x) std::cout << #x << " : " << x << std::endl
#define scanf scanf_s

using int32 = std::int_fast32_t;
using int64 = std::int_fast64_t;
using uint32 = std::uint_fast32_t;
using uint64 = std::uint_fast64_t;
#define N 100000
std::vector<uint32> G[N];
bool r[N];
int main(void) {
	std::ios::sync_with_stdio(false);
	std::cin.tie(0);
	uint32 n, m;
	std::cin >> n >> m;
	uint32 a, b;
	rep(i, 0, m) {
		std::cin >> a >> b;
		--a;--b;
		G[a].push_back(b);
		G[b].push_back(a);
	}
	std::vector<uint32> s, t;
	uint32 temp = 0;
	uint32 itr = 0;
	if (G[0].size() == 1) {
		temp = G[0][0];
		while (1) {
			r[temp] = 1;
			if (G[temp].size() != 2) {
				break;
			}
			else {
				if (r[G[temp][0]]) {
					temp = G[temp][1];
				}
				else {
					temp = G[temp][0];
				}
			}
		}
	}
	rep(i, 0, N) { r[i] = 0; }
	s.push_back(temp);
	while (1) {
		r[s[itr]] = 1;
		bool f = 1;
		rep(i, 0, G[s[itr]].size()) {
			if (r[G[s[itr]][i]]) continue;
			f = 0;
			s.push_back(G[s[itr]][i]);
			++itr;
			break;
		}
		if (f) break;
	}
	t.push_back(temp);
	itr = 0;
	while (1) {
		r[t[itr]] = 1;
		bool f = 1;
		rep(i, 0, G[t[itr]].size()) {
			if (r[G[t[itr]][i]]) continue;
			f = 0;
			t.push_back(G[t[itr]][i]);
			++itr;
			break;
		}
		if (f) break;
	}
	std::cout << s.size() + t.size() - 1 << "\n";
	std::cout << t[t.size() - 1]+1;
	for (uint32 i = t.size() - 2;~i;--i) {
		std::cout << " " << t[i]+1;
	}
	rep(i, 1, s.size()) {
		std::cout << " " << s[i] + 1;
	}
	std::cout << "\n";
	return 0;
}

Measured memory_bytes: 7284
N = int(input())
A = map(int, input().split())
MOD = 1000000007
ans = 1
cnt = [3 if i == 0 else 0 for i in range(N + 1)]

for a in A:
    ans = ans * cnt[a] 
    if ans == 0:
        break
    cnt[a] -= 1
    cnt[a+1] += 1

print(ans%MOD)


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

int main(){
  int64_t N ; 
  cin >> N ; 
  vector<int64_t> A(N) ;
  
  for(int i = 0 ; i < N ; i++){
    cin >> A.at(i) ; 
  }
  
  int64_t M = 0 ; 
  int64_t cnt = 0 ; 
  
  for(int64_t i = 0 ; i < N ; i++){
    M = max(M , A.at(i)) ; 
    
    if( M >= A.at(i) ){
      //cout << M - A.at(i) ; 
      cnt += M - A.at(i) ; 
    }
    
  }
  cout << cnt << endl ; 
}

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

using namespace std;
#define DBG(x)                         \
    (void)(cout << "L" << __LINE__     \
                << ": " << #x << " = " \
                << (x) << '\n')

typedef long long ll;
using pii = pair<int, int>;
using pli = pair<ll, int>;
using pll = pair<ll, ll>;
const int INF = 0x3f3f3f3f;
const int maxn = 1100000;
int main()
{
    //检查有没有特判0,有没有越界限.
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << setiosflags(ios::fixed) << setprecision(12);
    char c;
    cin >> c;
    cout << char(c + 1) << "\n";
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int n,a[100005],b[100005];
int main(){
	cin>>n;
	for(int i=1;i<=n;i++) cin>>a[i],b[a[i]]=i;
	for(int i=1;i<=n;i++) cout<<b[i]<<" ";
	return 0;
}

Measured memory_bytes: 1536
#include <cstdio>
#include <vector>

int main() {
  size_t N, M;
  scanf("%zu %zu", &N, &M);

  std::vector<int> res(N+1);
  for (size_t i = 0; i < M+M; ++i) {
    int a;
    scanf("%d", &a);
    ++res[a];
  }

  for (size_t i = 1; i <= N; ++i)
    printf("%d\n", res[i]);
}

Measured memory_bytes: 760