akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
using ll = long long ;
using P = pair<ll, ll>;
using Vec = vector<ll>;
using VecP = vector<P>;
#define REP(i, m, n) for(ll (i) = (m); (i) < (n); ++(i))
#define REPN(i, m, n) for(ll (i) = (m); (i) <= (n); ++(i))
#define REPR(i, m, n) for(ll (i) = (m); (i) >= (n); --(i))
#define rep(i, n) REP(i, 0, n)
#define repn(i, n) REPN(i, 1, n)
#define repr(i, n) REPR(i, n, 0)
#define repnr(i, n) REPR(i, n, 1)
#define co(n) cout << (n) << endl
#define cosp(n) cout << (n) << ' '
#define setp(n) cout << fixed << setprecision(n);
#define all(s) (s).begin(), (s).end()
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define fs first
#define sc second
template <typename T> bool chmax(T &a, const T& b){if(a < b){a = b; return true;} return false;}
template <typename T> bool chmix(T &a, const T& b){if(a > b){a = b; return true;} return false;}
const ll INF = 1e9+1;
const ll LINF = 1e18+1;
const ll MOD = 1e9+7;
//const ll MOD = 998244353;
const double PI = acos(-1);
const double EPS = 1e-9;

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

	Vec a(n);
	vector<VecP> t(n);
	rep(i, n){
		cin >> a[i];
		t[i].resize(a[i]);
		rep(j, a[i]){
			cin >> t[i][j].fs >> t[i][j].sc;
			t[i][j].fs--;
		}
	}

	ll ans = 0;
	rep(bit, (1 << n)){
		bitset<15> bits(bit);

		bool flg = true;
		rep(i, n){
			if(bits[i]){
				for(P j : t[i]){
					if(j.sc != bits[j.fs]){
							flg = false;
							break;
					}
				}
			}
			if(!flg) break;
		}
		if(flg) chmax(ans, (ll)bits.count());
	}
	co(ans);

	return 0;
}


Measured memory_bytes: 256
# 入力
N, M = map(int, input().split())
a = [int(input()) for _ in range(M)]

MOD = 10**9 + 7
A = set(a)

# i段目までにたどりつく方法を順に求める
dp = [0 for _ in range(N + 1)]
dp[0] = 1
dp[1] = int(1 not in A)
for i in range(2, N + 1):
    if i not in A:
        dp[i] = (dp[i - 1] + dp[i - 2]) % MOD
ans = dp[N]

# 出力
print(ans)


Measured memory_bytes: 13216
import java.util.LinkedList;
import java.util.Scanner;

public class Main {

	public static void main(String atgs[]) {
		Scanner scan = new Scanner(System.in);
		String s = scan.next();
		String t = scan.next();

		int[][] dp = new int[s.length() + 1][t.length() + 1];
		for (int i = 1; i <= s.length(); i++) {
			for (int j = 1; j <= t.length(); j++) {
				//System.out.println(i + "  " + j);
				if (i == 0 || j == 0) {
					dp[i][j] = 0;
				} else if (s.charAt(i - 1) == t.charAt(j - 1)) {
					dp[i][j] = dp[i - 1][j - 1] + 1;
				} else {
					dp[i][j] = Math.max(dp[i][j - 1], dp[i - 1][j]);
				}
			}
		}
		//System.out.println(dp[s.length()][t.length()]);

		int i = s.length();
		int j = t.length();
		LinkedList<Character> lcs = new LinkedList<>();

		//System.out.println(Arrays.deepToString(dp));
		while (i != 0 && j != 0) {
			//.System.out.println(i + "  "+ j);
			if (s.charAt(i - 1) == t.charAt(j - 1)) {
				
				lcs.addFirst(s.charAt(i - 1));
				i -=1;
				j-=1;
			} else {
				if (dp[i - 1][j] >= dp[i][j-1]) {
					i -= 1;
				} else {
					j -= 1;
				}
			}
			
			
		}
		//lcs.addFirst(s.charAt(i - 1));
		StringBuilder sb = new StringBuilder();
		for(char c : lcs) {
			sb.append(c);
		}
		System.out.println(sb.toString());

	}
}


Measured memory_bytes: 86744
#include <iostream>
#include <algorithm>
#include <tuple>
#include <vector>
#include <string>
#include <queue>
#include <cmath>
#include <set>
#include <map>
#include <cassert>

using namespace std;
using ll = long long;

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

Measured memory_bytes: 3628
#include<bits/stdc++.h>
using namespace std;
#define int long long
//With the aura of Homura-chan, AC
signed main(){
        int n, i;
        scanf("%lld", &n);
        int a[n], dp[n];
        for(i=1; i<=n; i++){
                scanf("%lld", &a[i]);
        }
        dp[1]=0;
        dp[2]=abs(a[2]-a[1]);
        for(i=3; i<=n; i++){
        	dp[i] = min(dp[i-1]+abs(a[i]-a[i-1]), dp[i-2]+abs(a[i]-a[i-2]));
        }
        printf("%lld", dp[n]);
}

Measured memory_bytes: 1792
#include <iostream>
#include <cmath>
#include <complex>
#include <string>
#include <sstream>
#include <limits>
#include <numeric>
#include <algorithm>
#include <functional>

#include <vector>

using namespace std;

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

	int N;
	cin >> N;

	vector<int> k(N, 0);
	vector<int> h(N, 0);

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

	int result = 0;
	while (true)
	{
		vector<int> diff(N, 0);
		bool all_zero = true;
		for (int i = 0; i < N; i++)
		{
			diff[i] = h[i] - k[i];
			if (diff[i] != 0) all_zero = false;
		}

		if (all_zero) break;

		int l = -1;
		for (int i = 0; i < N; i++)
		{
			if (l == -1 && diff[i] != 0)
			{
				l = i;
			}
			else if (l != -1 && diff[i] == 0)
			{
				for (int j = l; j < i; j++)
				{
					k[j]++;
				}

				l = -1;
				result++;
			}
		}

		if (l != -1)
		{
			for (int j = l; j < N; j++)
			{
				k[j]++;
			}

			result++;
		}
	}

	cout << result;

	return 0;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
	int x,y,h,w,t,sum,n;
	while(cin>>n,n){
		sum=0;
		for(int i=0;i<n;i++){
		cin>>x>>y>>h>>w;
		t=x+y+h;
		if(60>=t&&2>=w)
		sum+=600;
		else if(80>=t&&5>=w)
		sum+=800;
		else if(100>=t&&10>=w)
		sum+=1000;
		else if(120>=t&&15>=w)
		sum+=1200;
		else if(140>=t&&20>=w)
		sum+=1400;
		else if(160>=t&&25>=w)
		sum+=1600;
	}cout<<sum<<endl;
	}
	
	return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
#define rep(i,n) for (ll i = 0; i < (n); ++i)
#define All(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()   //reverse
#define strall(v) (v).cbegin(),(v).cend() //const_itterator
#define IN(a, b, x) (a<=x&&x<b)
using namespace std;
using ll = long long;
using P = pair<int,int>;
using Graph = vector<vector<ll>>;
template<typename T> using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;
template<typename t, typename u, typename Comp=less<>>
bool chmax(t& xmax, const u& x, Comp comp={}) { if(comp(xmax, x)) { xmax = x; return true; } return false;}
template<typename t, typename u, typename Comp=less<>>
bool chmin(t& xmin, const u& x, Comp comp={}) { if(comp(x, xmin)) { xmin = x; return true;} return false;}
const int INF = 1e9;
const ll infl = ll(1e18)+5;
/*
*ios::sync_with_stdio(false);
*cin.tie(0);
*/

int main(){
 int N;
 cin >> N;
 vector<ll> vx(N),vy(N),vh(N);
 int si=-1;
 for(int i=0;i<N;i++){
   cin >> vx[i] >> vy[i] >> vh[i];
   if(vh[i] > 0) si = i;
 }
 ll resx = -1,resy = -1, resh = -1;
 for(ll x = 0;x<=100;++x){
   for(ll y = 0;y<=100;++y){
     ll h = vh[si] + abs(x-vx[si]) + abs(y-vy[si]);
     bool ok = true;
     for(int i=0;i<N;i++){
       if(vh[i] > 0 && h-vh[i] != abs(x-vx[i]) + abs(y - vy[i]))
         ok = false;
       if(vh[i] == 0 && h > abs(x-vx[i]) + abs(y-vy[i]))
         ok = false;
     }
     if(ok) resx = x, resy = y,resh = h;
   }
 }
 cout << resx << " " << resy << " " << resh << endl;
}

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

int main(){
  int n,x;
  cin >> n >> x;
  int count=0;
  
  vector<int> m(n);
  for(int i=0; i<n; i++){
    cin >> m.at(i);
    x = x - m.at(i);
  }
  
   sort(m.begin(), m.end());
  
  count = x/m.at(0);
  
  cout << n + count << endl;
}


Measured memory_bytes: 256
import java.util.Scanner;
import java.util.Arrays;

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

		int[] list = {sc.nextInt(),sc.nextInt(),sc.nextInt()};

		Arrays.sort(list);

		System.out.printf("%d %d %d\n",list[0],list[1],list[2]);
	}
}


Measured memory_bytes: 26528
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define IOS                  \
    ios::sync_with_stdio(0); \
    cin.tie(0);              \
    cout.tie(0)
#define rep(i, a, b) for (int i = a; i < (b); ++i)
#define repd(i, a, b) for (int i = a; i >= (b); --i)
#define all(x) (x).begin(), (x).end()
#define sz(x) (int)(x).size()
typedef long long ll;
const int INF = 0x3f3f3f3f;
const ll LINF = 0x3f3f3f3f3f3f3f3fll;

int main()
{
    int n;
    cin >> n;
    vector<int> a(n);
    rep(i, 0, n) cin >> a[i];
    sort(all(a));
    cout << a[n - 1] - a[0] << endl;
}


Measured memory_bytes: 3596
s = input()

odd = s[::2]
even = s[1::2]

odd_list = list(odd)
even_list = list(even)

for c in odd_list:
  if c == 'L':
    print('No')
    exit()

for c in even_list:
  if c == 'R':
    print('No')
    exit()

print('Yes')

Measured memory_bytes: 3064
#define _CRT_DISABLE_PERFCRIT_LOCKS
#include<bits/stdc++.h>

#define ll long long int
#define pb push_back
#define ifor for(i=0; i<n; i++)

using namespace std;

ll INF=1e18;

int sz(ll a)
{
    ll c=0;
    while(a>0) {a/=10; c++;}
    return c;
}

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

    ll n;
    cin>>n;
    ll i, j, sq, a, b;
    sq=(ll)sqrt(n);
    ll mini=INF;
    for(i=1; i<=sq; i++)
    {
        if(n%i==0)
        {
            a=max(i, n/i);
            a=sz(a);
            if(a<mini) mini=a;
        }
    }
    cout<<mini<<endl;
    return 0;
}


Measured memory_bytes: 256
n = int(raw_input())
q = raw_input()

etow = []
wtoe = []

nowe = 0
noew = 0

for a in range(n):
  etow.append(noew)
  wtoe.append(nowe)
  if q[a] == "W":
    nowe += 1
  if q[n - 1 - a] == "E":
    noew += 1

wtoe = wtoe[::-1]
mi = 999999999

#print etow
#print wtoe

for a in range(n):
  #print etow[a] , wtoe[a]
  if etow[a] + wtoe[a] < mi:
    mi = etow[a] + wtoe[a]
print mi


Measured memory_bytes: 24364
#include <stdio.h>
#include <iostream>
using namespace std;

int gcd(int a, int b){
    if(a < b) swap(a, b);
    if(a % b == 0){
        return b;
    }
    return gcd(b, a % b);
}

int main(void){
    int i, j;
    scanf("%d %d", &i, &j);

    printf("%d\n", gcd(i, j));
}



Measured memory_bytes: 3220
#include<iostream>
#include<cstdio>
#include<algorithm>
using namespace std;
int a[4];
int main(){
	for(int i=0 ; i<3 ;i++){
		cin>>a[i];
	}
	sort(a,a+3);
	cout<<a[0]*a[1]/2<<endl;
	return 0;
} 

Measured memory_bytes: 256
//include
//------------------------------------------
#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;

//typedef
//------------------------------------------
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef long long ll;

//container util
//------------------------------------------
#define all(a)  (a).begin(),(a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define pb push_back
#define mp make_pair

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

int main(){
    int n,m,ans=0; cin>>n >>m;
    if(n>=m){
        cout<<0<<endl;
        return 0;
    }
    vi x(m),l(m-1);
    rep(i, m)cin>>x[i];
    
    sort(all(x));
    
    rep(i,m-1)l[i]=x[i+1]-x[i];
    
    sort(rall(l));
    
    rep(i, n-1)l[i]=0;
    
    rep(i, m-1)ans+=l[i];
    
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 1024
#pragma GCC optimize ("O3")
#include <bits/stdc++.h>
#define abdelrahman010 ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
typedef long long ll;
using namespace std;
const int N = 2e3 + 5;
const int mod = 1e9 + 7;
int n , k;
int fact[N] , inv[N];
int fp(int x , int y) {
    if(!y)
        return 1;
    int res = fp(x , y / 2);
    res = (1ll * res * res) % mod;
    if(y & 1)
        res = (1ll * res * x) % mod;
    return res;
}
void pre() {
    fact[0] = inv[0] = 1;
    for(int i = 1;i < N;i++) {
        fact[i] = (1ll * fact[i - 1] * i) % mod;
        inv[i] = fp(fact[i] , mod - 2);
    }
}
int ncr(int n , int r) {
    if(r > n)
        return 0;
    return (1ll * (1ll * fact[n] * inv[r]) % mod * inv[n - r]) % mod;
}
int main() {
    abdelrahman010
    pre();
    cin >> n >> k;
    for(int i = 1;i <= k;i++)
        cout << (1ll * ncr(n - k + 1, i) * ncr(k - 1 , i - 1)) % mod << '\n';
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include<bits/stdc++.h>
using namespace std;
long long int dp[500][500];
long long int min(long long int a,long long int b)
{
    if(a>b) return b;
    return a;
}
long long int util(vector<long long int>&v,int i,int j)
{
    if(i>=j) return 0;
    if(dp[i][j]!=-1) return dp[i][j];
    long long int tot=0;
    for(int in = i;in<=j;in++)
    {
        tot+=v[in];
    }
    long long int mi = LLONG_MAX;
    for(int k=i;k<j;k++)
    {
        long long int temp = tot+util(v,i,k)+util(v,k+1,j);
        mi = min(mi,temp);
    }
    dp[i][j]=mi;
    return mi;
}
int main() {
	int n;
	cin>>n;
	vector<long long int>v(n);
	memset(dp,-1,sizeof(dp));
	for(int i=0;i<n;i++)
	{
	    cin>>v[i];
	}
	cout<<util(v,0,n-1)<<endl;
	return 0;
}

Measured memory_bytes: 5548
# coding: utf-8
import sys
import numpy as np

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

H, W = lr()
S = [list(sr()) for _ in range(H)]
S = np.array([[1 if x == '.' else 0 for x in row] for row in S])
up = np.ones((H, W), np.int32)
up *= S
down = np.ones((H, W), np.int32)
down *= S
right = np.ones((H, W), np.int32)
right *= S
left = np.ones((H, W), np.int32)
left *= S
for i in range(H-1):
    up[i+1] += up[i]
    up[i+1] *= S[i+1]
for i in range(H-1, 0, -1):
    down[i-1] += down[i]
    down[i-1] *= S[i-1]
for i in range(W-1):
    left[:, i+1] += left[:, i]
    left[:, i+1] *= S[:, i+1]
for i in range(W-1, 0, -1):
    right[:, i-1] += right[:, i]
    right[:, i-1] *= S[:, i-1]

answer = (up + down + left + right).max() - 3
print(answer)


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

#define rep(i,s,n) for (int i = (int)s; i < (int)n; i++)
#define ll long long
#define ld long double
#define pb push_back
#define eb emplace_back
#define All(x) x.begin(), x.end()
#define Range(x, i, j) x.begin() + i, x.begin() + j
#define lbidx(x, y) lower_bound(x.begin(), x.end(), y) - x.begin()
#define ubidx(x, y) upper_bound(x.begin(), x.end(), y) - x.begin()
#define llbidx(x, y, z) lower_bound(x.begin(), x.end(), z) - lower_bound(x.begin(), x.end(), y) // 二要素間の距離
// #define M_PI 3.14159265358979323846 // CFでは定義しておく必要あり
#define deg2rad(deg) ((((double)deg)/((double)360)*2*M_PI))
#define rad2deg(rad) ((((double)rad)/(double)2/M_PI)*(double)360)
#define Find(set, element) set.find(element) != set.end()
#define Decimal(x) printf("%.10f\n", x) // 小数点を10桁まで表示
// debug用
#define PrintVec(x) for (auto elementPrintVec: x) { cout << elementPrintVec << " "; } cout << "\n";
#define debug(x) cerr << #x << ": " << (x) << "\n";
#define endl "\n"
// gcj print用
#define Case(x) printf("Case #%d: ", x);

typedef pair<int, int> PI;
typedef pair<ll, ll> PLL;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<vector<vector<int>>> vvvi;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef vector<vector<vector<int>>> vvvl;
typedef vector<PI> vpi;
typedef vector<vector<PI>> vvpi;
typedef vector<vector<vector<PI>>> vvvpi;
typedef vector<PLL> vpl;
typedef vector<vector<PLL>> vvpl;
typedef vector<vector<vector<PLL>>> vvvpl;

int POWINT(int x, int n) {
  int ret = 1;
  while (n > 0) {
    if (n & 1) ret *= x;
    x *= x;
    n >>= 1;
  }
  return ret;
};

ll POWLL(ll x, int n) {
  ll ret = 1;
  while (n > 0) {
    if (n & 1) ret *= x;
    x *= x;
    n >>= 1;
  }
  return ret;
};

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

void print() {
  cout << endl;
};

template <class T>
void print(vector<T> &vec) {
  for (auto& a : vec) {
    cout << a;
    if (&a != &vec.back()) cout << " ";
  }
  cout << endl;
};

template <class T>
void print(vector<T> &vec, ll k){
   ll n = vec.size();
   k = min(k, n);
   rep(i, 0, k-1) cout << vec[i] << " ";
   cout << vec[k-1] << endl;
};

template <class T>
void print(vector<vector<T>> &df) {
  for (auto& vec : df) {
    print(vec);
  }
};

template<class T, class U>
void print(pair<T,U> &p){
  cout << p.first << " " << p.second << "\n";
};

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

int digit(ll x) {
  int ret = 0;
  while (x) {
    x /= 10;
    ret++;
  }
  return ret;
};

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

  ll N;
  cin >> N;
  auto divs = divisor(N);
  int ans = 1e9+7;
  for (ll d: divs) {
    ll dd = N / d;
    chmin(ans, max(digit(d), digit(dd)));
  }

  cout << ans << endl;

  return 0;
};


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long int
#define pb push_back

#define mod 1000000007
#define sp fixed<<setprecision(12)
using namespace std;
/*
const int MAX=10000005;
vector<int> primes;
bitset<MAX> is_prime;
void sieve(){
    is_prime.set();
    is_prime[0]=is_prime[1]=0;
    for(int i=4;i<MAX;i+=2){
        is_prime[i]=0;
    }
    for(int i=3;i*i<MAX;i+=2){
        if(is_prime[i]){
            primes.pb(i);
            for(int j=i*i;j<MAX;j+=i){
                is_prime[j]=0;
            }
        }
    }
}
*/
/*
void lcs(char s1[],char s2[]){
    int n=strlen(s1);
    int m=strlen(s2);
    vector<vector<int>> dp(n+1,vector<int>(m+1,0));
    for(int i=1;i<=n;i++){
        for(int j=1;j<=m;j++){
            int sum=0;
            if(s1[i-1]==s2[j-1]){
                sum=1+dp[i-1][j-1];
            }
            else{
                sum=max(dp[i-1][j],dp[i][j-1]);
            }
            dp[i][j]=sum;
        }
    }
    
    int index=dp[n][m];
    //cout<<index<<endl;
    char ans[index+1];
    ans[index]='\0';
    index--;
    int x=n;
    int y=m;
    while(x>0 and y>0){
        if(dp[x-1][y]==dp[x][y-1] and dp[x-1][y]!=dp[x][y]){
            ans[index]=s1[x-1];
            index--;
            x--;
            y--;
        }else if(dp[x-1][y]>dp[x][y-1]){
            x--;
        }else{
            y--;
        }

    }
    //reverse(ans.begin(),ans.end());

    cout<<ans;
    return;
}
*/



int32_t main(){

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    #ifndef ONLINE_JUDGE
        freopen("input.txt","r",stdin);
        freopen("output.txt","w",stdout);
    #endif
    //double    pi=3.14159265358979323846;
    //sieve();
    int t=1;
    
    //cin>>t;
    
    for(int tc=1;tc<=t;tc++){
        int n;
        cin>>n;
        int val=7%n;
        int f=0;
        for(int i=1;i<10000000;i++){
            if(val==0){
                cout<<i<<'\n';
                f=1;
                break;
            }
            val=(val*10+7)%n;
        }
        if(f==0){
            cout<<"-1\n";
        }
    }
    
    return 0;
    
}

Measured memory_bytes: 3620
/* https://atcoder.jp/contests/abc124/tasks/abc124_c */

#include <iostream>
#include <string>
#include <vector>

/* {{{ Variables */
std::string S;
/* }}} */

int main(int argc, char *argv[])
{
  /* {{{ Input */
  std::cin >> S;
  /* }}} */

  /* {{{ Output */
  int N = S.length();
  int min_num = N;

  for (int i = 0; i < 2; ++i) {
    int num = 0;
    int c = i%2 == 0 ? 0 : 1;

    for (int j = 0; j < N; ++j) {
      int s = S.at(j) - '0';

      if (j%2 == 0) {
        num += s != c;
      } else {
        num += s == c;
      }
    }

    min_num = std::min(min_num, num);
  }

  std::cout << min_num << std::endl;
  /* }}} */

  return 0;
}


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

int main(){
  string s;
  cin >> s;
  //cin >> t;
  if(s.at(0)==s.at(1)||s.at(1)==s.at(2)||s.at(2)==s.at(3))cout << "Bad" << endl;
  //else if(6<=a&&a<=12)cout << b/2 << endl;
  else cout << "Good" << endl;
  //cout << b*(int)((t+0.5)/a) << endl;
  return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int a,b,c,i,j=0;

int main(){
  scanf("%d",&i);
  while(j<i){
    scanf("%d%d%d",&a,&b,&c);
    if (a*a+b*b==c*c || b*b+c*c==a*a || c*c+a*a==b*b)
      {printf("YES\n");
      j++;
      }
    else
      {printf("NO\n");
      j++;
      }
  }
    return 0;
}

Measured memory_bytes: 580
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,m;
  cin>>n;
  vector<int> a(n);
  for(int i=0;i<n;i++){
    cin>>a[i];
  }
  sort(a.begin(),a.end());
  reverse(a.begin(),a.end());
  m=a[0];
  bool ab=false;
  long long h,w;
  for(int i=1;i<n;i++){
    if(m==a[i]){
      if(ab){
        w=m;
        cout<<h*w;
        return 0;
      }else{
        h=m;
        ab=true;
        m=0;
      }
    }else{
      m=a[i];
    }
  }
  cout<<0;
}

Measured memory_bytes: 640
import java.io.PrintWriter
import java.util.*
import java.math.*
import java.lang.*

val pw = PrintWriter(System.out)
val MOD: Long = (1e+9 + 7).toLong()

fun main(args: Array<String>) {
    val (a, b) = readListOfInt() 
    val ans = Math.max( Math.max(a+b, a-b), a*b )
    println(ans)
    pw.flush()
}

/****** Decrared Functions and Data Structures ******/
// IO
fun read() = readLine()!!
fun readInt() = read().toInt()
fun readLong() = read().toLong()
fun readDouble() = read().toDouble()
fun readListOfString() = read().split(" ")
fun readListOfInt() = readListOfString().map { it.toInt() }
fun readListOfLong() = readListOfString().map { it.toLong() }
fun readListOfDouble() = readListOfString().map { it.toDouble() }

fun Double.format(digits: Int) = String.format("%.${digits}f", this)
fun Float.format(digits: Int) = String.format("%.${digits}f", this)

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

fun<T> permutations(src: List<T>): List<List<T>> {
    if(src.size == 1) return listOf(src)
    val perms = mutableListOf<List<T>>()
    val insertElement = src[0]
    permutations(src.drop(1)).forEach { perm ->
        for(i in 0..perm.size) {
            val newPerm = perm.toMutableList()
            newPerm.add(i, insertElement)
            perms.add(newPerm.toList())
        }
    }
    return perms
}

// return nCr, if you want nCr, please access v[n][r]
fun combinations(n: Long): List<List<Long>> {
    val v = (0..n).map { (0..n).map{0L}.toMutableList() }.toMutableList()
    for(i in 0 until v.size) {
        v[i][0] = 1L
        v[i][i] = 1L
    }
    for(i in 0 until v.size) {
        for(j in 1 until i) {
            v[i][j] = (v[i-1][j-1] + v[i-1][j] % MOD)
        }
    }
    return v.map { it.toList() }.toList()
}

// should be a >= b
fun gcd(a: Long, b: Long): Long = 
    if(b == 0L) a else gcd(b, a % b)

// shoud be a >= b
fun lcm(a: Long, b: Long): Long = 
    a / gcd(a, b) * b

fun sumDigits(num_: Long): Long {
    var num = num_
    var rtn: Long = 0
    while(num != 0.toLong()) {
        val tmp = num % 10
        rtn += tmp
        num /= 10
    }
    return rtn
}

fun isDecimal(v: Double): Boolean = ((v - Math.floor(v)) != 0.0)

// Data Structures
class Stack<T>(private var st: MutableList<T> = mutableListOf<T>()) {
    fun isEmpty() = st.isEmpty()
    fun top(): T = st.last()
    fun push(e: T) { st.add(e) }
    fun pop() { st = st.dropLast(1).toMutableList() }
}

class Queue<T>(private var que: MutableList<T> = mutableListOf<T>()) {
    fun isEmpty() = que.isEmpty()
    fun top(): T = que.first()
    fun push(e: T) { que.add(e) }
    fun pop() { que = que.drop(1).toMutableList() }
}


Measured memory_bytes: 37824
#include <bits/stdc++.h>
using i64 = long long;

int main() {
    i64 a, b, c;
    std::cin >> a >> b >> c;
    i64 d = c - a - b;
    if (d > 0 && 4 * a * b < d * d) std::cout << "Yes" << std::endl;
    else std::cout << "No" << std::endl;

    return 0;
}


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

public class Main {
  private static class FastScanner {
    private BufferedReader reader = null;
    private StringTokenizer tokenizer = null;

    public FastScanner(InputStream in) {
      reader = new BufferedReader(new InputStreamReader(in));
      tokenizer = null;
    }

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

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

      return tokenizer.nextToken("\n");
    }

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

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

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

    public int[] nextIntArray(int n) {
      int[] a = new int[n];
      for (int i = 0; i < n; i++)
        a[i] = nextInt();
      return a;
    }

    public long[] nextLongArray(int n) {
      long[] a = new long[n];
      for (int i = 0; i < n; i++)
        a[i] = nextLong();
      return a;
    }
  }

  public static void main(String[] args) {
    FastScanner sc = new FastScanner(System.in);
    int x = sc.nextInt();
    System.out.println(1 - x);
  }
}

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

int main() {
    string c1, c2; cin >> c1 >> c2;
    if (c1[0] == c2[2] && c1[1] == c2[1] && c1[2] == c2[0]) {
        cout << "YES" << endl;
    } else {
        cout << "NO" << endl;
    }
}


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

int main(){
  int x;
  cin >> x;
  bool found=false;
  
  while(!found){
    bool prime=true;
    rep2(i,2,(int)sqrt(x)+1){
      if(x%i==0){
        prime = false;
      	break;
      }
    }
    if(prime) found=true;
    x++;
  }
  
  cout << (x-1) << endl;
  
  return 0;
}

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

#define pb push_back
#define F first
#define S second
#define fo(i,a,b)  for(int i = a; i < b; i++)

using ll = long long;
using ld = long double;
using ul = unsigned long long;
using ii = pair<int, int>;
#define Mosta     ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define ReadFile            freopen("input.in","r",stdin)
#define WriteFile           freopen("output.txt","w",stdout)
const ll mod7 = 1000000007,mod = 1000000000,OO = 0x3f3f3f3f;
const ld EPS = 1e-7;
double Pi=acos(-1);
const ld rad=Pi/180.0;
ll power(ll x, ll y, ll p)
{
    ll res = 1;
    while (y > 0)
    {
        if (y & 1)
            res = (res*x) % p;
        y = y>>1;
        x = (x*x) % p;
    }
    return res;
}
ll nCr (ll n,ll m)
{
        return(m == 0)?1:n*nCr(n-1,m-1)/m;
}
/*****************************************************/


int main()
{
    string s , x = "AC";
    cin >> s;
    int m = 0;
    if(s[0] != 'A')
        x = "WA";

    for(int i = 1; i < s.length(); ++i)
        if(isupper(s[i])){
            if(i == 1 || i == s.length() - 1 || s[i] != 'C')
                x = "WA";
            m++;
        }
    if(m != 1)
        x = "WA";

    cout << x << "\n";

    return 0;
}


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

#define rep(i,x) for(int i=0;i<x;i++)
using namespace std;

int main(){
    int n; cin >> n;
    vector<int> order(n);
    rep(i, n) order[i] = i + 1;
    vector<int> p(n), q(n);
    rep(i, n) cin >> p[i];
    rep(i, n) cin >> q[i];
    int cnt = 1, a, b;
    do {
        if (order == p) a = cnt;
        if (order == q) b = cnt;
        cnt++;
    }while(next_permutation(order.begin(), order.end()));
    cout << abs(a - b) << endl;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define be(v) (v).begin(),(v).end()
#define pb(q) push_back(q)
typedef long long ll;
using namespace std;
const ll mod=1000000007;
#define doublecout(a) cout<<fixed<<setprecision(10)<<a<<endl;

ll uni[160005];
ll root(ll u){
    if(uni[u]<0)return u;
    return uni[u]=root(uni[u]);
}

void connect(int a,int b){
    a=root(a);
    b=root(b);
    if(a==b)return;
    if(uni[a]>uni[b]){
        a^=b;
        b^=a;
        a^=b;
    }
    uni[a]+=uni[b];
    uni[b]=a;
    return;
}
ll size(ll u){
    return -uni[root(u)];
}
ll dx[4]={1,0,-1,0};
ll dy[4]={0,1,0,-1};
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    memset(uni,-1,sizeof(uni));
    ll h,w;
    cin>>h>>w;
    string s[h];
    for(int i=0;i<h;i++){
        cin>>s[i];
    }
    ll x,y,x2,y2;
    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
            if(s[i][j]=='#'){
                for(int k=0;k<4;k++){
                    x=j+dx[k];
                    y=i+dy[k];
                    if(x>=0 && x<w && y>=0 && y<h && s[y][x]=='.'){
                        for(int m=0;m<4;m++){
                            x2=x+dx[m];
                            y2=y+dy[m];
                            if(x2>=0 && x2<w && y2>=0 && y2<h && s[y2][x2]=='#'){
                                connect(i*400+j,y2*400+x2);
                            }
                        }
                    }
                }
            }
        }
    }
    vector<set<ll> > v(160005);
    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
            if(s[i][j]=='#'){
                for(int k=0;k<4;k++){
                    x=j+dx[k];
                    y=i+dy[k];
                    if(x>=0 && x<w && y>=0 && y<h && s[y][x]=='.'){
                        v[root(i*400+j)].insert(y*400+x);
                    }
                }
            }
        }
    }
    ll ans=0;
    for(int i=0;i<160005;i++){
        ans+=uni[i]*(v[i].size());
    }
    cout << -ans<<endl;
    return 0;
}


Measured memory_bytes: 12928
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n;
	cin>>n;
	int a,b;
	int s=0;
	for(int i=1;i<=n;++i){
		cin>>a>>b;
		if(a==b)s++;
		else s=0;
		if(s==3){
			cout<<"Yes";
			return 0;
		}
	}
	cout<<"No";
}

Measured memory_bytes: 3628
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;++i)
#define rrep(i,n) for(int i=n-1;i>=0;--i)
#define yesno(flg) if(flg){cout<<"YES"<<endl;}else{cout<<"NO"<<endl;}
#define MAX_N 1002
#define i197 1000000007

using namespace std;

typedef long long ll;
typedef pair<ll,ll> P1;
typedef pair<int,int> Pi;
typedef pair<double,Pi> Pdi;
typedef pair<ll,int>Pli;
typedef pair<P1,ll> P2;
const ll INF=1000000000000000001;
struct edge{int to,cost;};
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};
struct Road{double cost;int a,b;};

int main() {

	string s;

	cin>>s;

	int a=0,b=0;
	rep(i,s.size()){
		if(s[i]=='0')a++;
		else b++;
	}
	cout<<2*min(a,b)<<endl;
	return 0;
}



Measured memory_bytes: 512
package main

import (
	"fmt"
)

func main() {
	var n string
	fmt.Scan(&n)

	if isAll9(n[1:len(n)]) {
		fmt.Println(int(n[0]-'0') + 9*(len(n)-1))
	} else {
		fmt.Println(int(n[0]-'0') - 1 + 9*(len(n)-1))
	}
}

func isAll9(s string) bool {
	for _, c := range s {
		if c != '9' {
			return false
		}
	}
	return true
}


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

vector<int> solve(int k, int n) {
    if (k == 1 and n == 1) {
        return vector<int>(1, 1);

    } else if (k % 2 == 0) {
        // the last sequence starting with k / 2
        vector<int> a(n, k);
        a[0] = k / 2;
        return a;

    } else {
        // basically the sequence whose all elements are k / 2 + 1
        vector<int> a(n, k / 2 + 1);
        REP (i, n / 2) {
            // decrement
            if (a.back() >= 2) {
                -- a.back();
                while (a.size() < n) {
                    a.push_back(k);
                }
            } else {
                a.pop_back();
            }
        }
        return a;
    }
}

int main() {
    int k, n; cin >> k >> n;
    auto a = solve(k, n);
    for (int a_i : a) {
        cout << a_i << ' ';
    }
    cout << endl;
    return 0;
}


Measured memory_bytes: 3456
#include <bits/stdc++.h>
#define ll long long int
#define soja(i,a,n) for(ll i=a;i<=n;i++)
#define ulta(i,n,a) for(ll i=n;i>=a;i--)
using namespace std;
int main()
{
  ll n,m,k,t,sum=0;
  string s;
  cin>>s;
  soja(i,0,s.size()-1)
  {
      sum+=s[i]-48;
  }
if(sum%9==0)
    cout<<"Yes"<<endl;
else
    cout<<"No"<<endl;
	return 0;
}


Measured memory_bytes: 3748
#include <bits/stdc++.h>
using namespace std;
#define rep(i,c) for(int i=0;i<c;++i)
int main(){
 int a,b,c,d,e,k;
 cin >> a>> b>> c>> d>> e>> k;
 if(e-a>k){
     cout << ":(" <<endl;
 }else{
     cout << "Yay!" << endl;
 }
 return 0;
}

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

ll gcd(ll a, ll b) {
    if (a < b) {
        ll tmp = a;
        a = b;  b = tmp;
    }
    ll r = a % b;
    while (r != 0) {
        a = b;  b = r;
        r = a % b;
    }
    return b;
}

vector<pair<ll, int>> fs;

void PF(ll n) {
    ll base = n;
    for (ll i = 2; i * i <= base; i++) {
        if (base % i == 0) {
            int cnt = 0;
            while (base % i == 0) {
                base /= i;
                cnt++;
            }
            fs.emplace_back(i, cnt);
        }
    }
    
    if (base > 1) {
        fs.emplace_back(base, 1);
    }
    
    /*
    for (int i = 0; i < fs.size(); i++) {
        cout << fs[i].first << " " << fs[i].second << endl;
    }
    */
}

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

    ll g = gcd(a, b);
    PF(g);
    cout << fs.size() + 1 << endl;
}

Measured memory_bytes: 256
import itertools
N,M=map(int,input().split())
ab=list(list(map(int,input().split())) for _ in range(M))
l=list(l for l in range(1,N+1))
numlist=list(itertools.permutations(l))
ans=0
for I in numlist:
    if I[0]==1 and all(sorted([I[j],I[j+1]]) in ab for j in range(N-1)):
        ans+=1
print(ans)


Measured memory_bytes: 8052
#include <bits/stdc++.h>
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define pb push_back
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define rep(i, n) FOR(i, 0, n)
#define ll long long
using namespace std;

const ll P = 1000000007;
int gcd(int a, int b) { return b != 0 ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a / gcd(a, b) * b; }
ll dp[1000];

int main()
{
  cout << fixed << setprecision(10);
  int N;
  cin >> N;
  dp[0] = 2;
  dp[1] = 1;
  for(int i=2;i<87;i++)
  {
    dp[i] = dp[i-1] +dp[i-2];
  }
  cout << dp[N] << endl;
  return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main{
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();
		int d = sc.nextInt();
		String ans;
		if( a + b < c + d) {
			ans = "Right";
		}else if(c + d < a + b) {
			ans = "Left";
		}else {
			ans = "Balanced";
		}
		System.out.print(ans);
	}
	
}

Measured memory_bytes: 22736
// https://atcoder.jp/contests/abc110/tasks/abc110_d
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;
#define EPS (1e-9)
#define INF (1e9)
#define INFL (1e18)
#define MOD (1000000007)
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define ALL(obj) (obj).begin(), (obj).end()
#define ALLR(obj) (obj).rbegin(), (obj).rend()
#define BIT(n) (1LL << (n))
// ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
// ll lcm(ll c, ll d) { return c / gcd(c, d) * d; }

vector<pair<long long, long long>> prime_factorize(long long n) {
    vector<pair<long long, long long>> res;
    for (long long p = 2; p * p <= n; ++p) {
        if (n % p != 0)
            continue;
        int num = 0;
        while (n % p == 0) {
            ++num;
            n /= p;
        }
        res.push_back({p, num});
    }
    if (n != 1)
        res.push_back({n, 1});
    return res;
}

const int MAX = 210000;

long long fac[MAX], finv[MAX], inv[MAX];
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++) {
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}
long long COM(int n, int k) {
    if (n < k)
        return 0;
    if (n < 0 || k < 0)
        return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n, m;
    cin >> n >> m;
    vector<PLL> v = prime_factorize(m);

    COMinit();
    ll ans = 1;
    for (auto x : v) {
        ans = (ans * COM(x.second + n - 1, n - 1)) % MOD;
    }

    cout << ans << endl;

    return 0;
}


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

#define ALL(v) v.begin(), v.end()
#define V vector
#define P pair
#define ld long double
#define ll long long
#define mod 1000000007
#define IINF INT_MAX
#define INF 1LL << 60


int main() {
    int n, m; cin >> n >> m;
    ll k; cin >> k;
    V<ll> a(n), b(m);
    for(int i = 0; i < n; i++) cin >> a[i];
    for(int i = 0; i < m; i++) cin >> b[i];

    V<ll> sa(n + 1, 0), sb(m + 1, 0);
    for(int i = 0; i < n; i++){
        sa[i + 1] = sa[i] + a[i];
    }
    for(int i = 0; i < m; i++){
        sb[i + 1] = sb[i] + b[i];
    }

    ll ans = 0;
    for(int i = 0; i <= n; i++){
        ll sum = sa[i];
        ll sub = k - sum;
        ll cnt = 0;
        if(0 <= sub){
            cnt += i;
            auto ite = upper_bound(ALL(sb), sub);
            ll tmp = ite - sb.begin();
            if(0 < tmp) cnt += tmp - 1;
        }
        ans = max(ans, cnt);
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 9592
#include<bits/stdc++.h>
using namespace std;
#define int long long int
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define r0 return 0;
#define f(k,i,n,j) for(ll k=i;k<=n;k=k+j)
#define cin(a) cin>>a;
#define loop while(t--)
#define vi vector<int>
#define vii vector<long long int>
#define SORT(v) sort(v.begin(),v.end());
#define mod (1e9+7)
#define crap ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define endl "\n"
signed main()
{
    crap;
    int n,a,b;
    cin>>n>>a>>b;
    int ans=n/(a+b);
    ans*=a;
    ans+=min(a,n%(a+b));
    cout<<ans<<endl;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;

namespace Problem0001
{
    class Program
    {
        static void Main(string[] args)
        {
            var mountainHeights = GetInputLines().Select(line => int.Parse(line));
            var top3Heights = mountainHeights.OrderByDescending(n => n).Take(3);
            foreach (int height in top3Heights)
            {
                Console.WriteLine(height);
            }
        }

        static IEnumerable<string> GetInputLines()
        {
            string line;
            while (!string.IsNullOrEmpty(line = System.Console.ReadLine()))
            {
                yield return line;
            }
        }
    }
}

Measured memory_bytes: 10108
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<math.h>
#include<string>
#include<string.h>
#include<stack>
#include<queue>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<stdlib.h>
#include<iomanip>

using namespace std;

#define ll long long
#define ld long double
#define EPS 0.0000000001
#define INF 1e9
#define MOD 1000000007
#define rep(i,n) for(i=0;i<n;i++)
#define loop(i,a,n) for(i=a;i<n;i++)
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)

typedef vector<int> vi;
typedef pair<int,int> pii;

int main(void) {
  int i,j;
  int n,num=0;
  char s[50]={};
  vector<pair<string,int> > p;
  while(scanf("%s %d",s,&n)!=EOF){
      p.push_back(pair<string,int>(s,n));
      num++;
    }
  sort(all(p));
  cout<<p[0].first<<endl;
  cout<<p[0].second;
  for(i=1;i<num;i++){
    if(p[i].first!=p[i-1].first){
      cout<<endl;
      cout<<p[i].first<<endl;
      cout<<p[i].second;
    }
    else
      cout<<" "<<p[i].second;
  }
  cout<<endl;
}

Measured memory_bytes: 3116
#include <iostream>
#include <vector>
#include <map>
#include <unordered_map>
#include <queue>
#include <set>
#include <algorithm>
#include <string>
#include <math.h>
#include <limits.h>
#include <stack>
#include <complex>
#include <stdlib.h>
#include <stdio.h>
#include <functional>
#include <cfloat>
#include <math.h>


#define fs first
#define sc second

using namespace std;

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


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

    int bcnum = 0;
    ll res = 0;
    int index = s.length() - 1;
    while(index >= 0){
        if(s[index] == 'C' && index-1 >= 0 && s[index-1] == 'B'){
            bcnum++;
            index -= 2;
        }
        else if(s[index] == 'A'){
            res += bcnum;
            index--;
        }
        else{
            bcnum = 0;
            index--;
        }
    }

    cout << res << endl;


    return 0;
}


Measured memory_bytes: 640
import java.util.Scanner;
import java.util.LinkedList;
import java.util.Queue;

public class Main {

	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int numProcesses = in.nextInt();
		int quantum = in.nextInt();
		Main r = new Main();
		Queue<Process> q = new LinkedList<Process>();

		for (int i = 1; i <= numProcesses; i++) {
			Process p = r.new Process(in.next(), in.nextInt());
			q.add(p);
		}

		performQOps(q, quantum);
	}

	public static void performQOps(Queue<Process> q, int quantum) {
		int totalTime = 0;

		while (q.size() != 0) {

			Process cur = q.poll();

			if (cur.getTimeRemaining() <= quantum) {
				totalTime += cur.getTimeRemaining();
				System.out.println(cur + " " + totalTime);
			} else {
				totalTime += quantum;
				cur.setTimeRemaining(cur.getTimeRemaining() - quantum);
				q.add(cur);
			}
		}
	}

	private class Process {

		String name;
		int timeRemaining;

		public Process(String name, int timeRemaining) {
			this.name = name;
			this.timeRemaining = timeRemaining;
		}

		public String getName() {
			return name;
		}

		public int getTimeRemaining() {
			return timeRemaining;
		}

		public void setName(String name) {
			this.name = name;
		}

		public void setTimeRemaining(int timeRemaining) {
			this.timeRemaining = timeRemaining;
		}

		public String toString() {
			return name;
		}
	}
}



Measured memory_bytes: 75720
#include <bits/stdc++.h>
using namespace std;
using vi = vector<int>;
using vb = vector<bool>;
using vl = vector<long>;
using vs = vector<string>;
using vvi = vector<vector<int>>;
using vvb = vector<vector<bool>>;
using vvc = vector<vector<char>>;
using pii = pair<int, int>;
using pll = pair<long, long>;
#define fix20 cout << fixed << setprecision(20);
#define rep(i,n) for(int i=0; i<(int)(n);i++)
#define rrep(i,n) for(int i=(n)-1;i>=0;i--)
#define MOD 1000000007
#define all(vec) vec.begin(), vec.end()

int main(){
    long n,a,b;
    cin >> n >> a >> b;
    long c = a + b;
    long ans = 0;
    ans += (n / c)*a;
    long rest = n % c;
    ans += min(a,rest);
    cout << ans << endl;
    
}

Measured memory_bytes: 256
N,M = map(int,input().split())
AB = [list(map(int,input().split())) for _ in range(N)]
CD = [list(map(int,input().split())) for _ in range(M)]

ANS = []
for a,b in AB:
  md = 10 ** 9
  nearest = -1
  for i in range(M):
    c,d = CD[i]
    d = abs(a-c) + abs(d-b)
    if d < md:
      nearest = i+1
      md = d
  ANS.append(nearest)
  
print('\n'.join(map(str,ANS)))

Measured memory_bytes: 3064
#include <algorithm>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <tuple>
#include <vector>

using namespace std;

#define rep(i, n) for (int64_t i = 0; i < (n); i++)
#define irep(i, n) for (int64_t i = 0; i <= (n); i++)
#define rrep(i, n) for (int64_t i = (n)-1; i >= 0; i--)
#define rirep(i, n) for (int64_t i = n; i >= 0; i--)

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

  using P = pair<int, int>;
  vector<P> pos, neg;
  rep(i, n) {
    string s;
    cin >> s;

    int close = 0, open = 0;
    rep(i, s.size()) {
      if (s[i] == ')') {
        if (open == 0) {
          close++;
        } else {
          open--;
        }
      } else {
        open++;
      }
    }

    if (open - close >= 0) {
      pos.push_back(P(close, open));
    } else {
      neg.push_back(P(close, open));
    }
  }
  sort(pos.begin(), pos.end());
  sort(neg.begin(), neg.end(),
       [](const P& lh, const P& rh) { return lh.second > rh.second; });

  int total = 0;
  for (auto p : pos) {
    int close, open;
    tie(close, open) = p;
    total -= close;
    if (total < 0) {
      cout << "No" << endl;
      return 0;
    }
    total += open;
  }
  for (auto p : neg) {
    int close, open;
    tie(close, open) = p;
    total -= close;
    if (total < 0) {
      cout << "No" << endl;
      return 0;
    }
    total += open;
  }

  cout << (total == 0 ? "Yes" : "No") << endl;

  return 0;
}

Measured memory_bytes: 11268
////   template  ///////////////////////////////////////////////////////
#include <stdlib.h>
#include <sys/time.h>
#include <stdio.h>
#include <sys/resource.h>
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;

class timer{
	enum KIND{ REAL, CPU }; // real_time or cpu_time
	double t0; // start
	double t1; // end
	KIND kind_of_time; // default is real_time
	double get_realtime(){struct timeval tv; gettimeofday(&tv, NULL);
		return tv.tv_sec + (double)tv.tv_usec*1e-6;}
	double get_cputime(){struct rusage RU; getrusage(RUSAGE_SELF, &RU); 
		return RU.ru_utime.tv_sec + (double)RU.ru_utime.tv_usec*1e-6;}
public:
	timer(){kind_of_time = REAL;}
	void set(KIND k){kind_of_time = k;}
	void start(){t0 = get_realtime();}
	void stop(){t1 = get_realtime();}
	void print(){printf("TotalTime : %.3fsec\n", t1-t0);}
};
////////////////////////////////////////////////////////////////////////

struct LINE{
	int h;
	int p;
	int q;
};

bool comp(struct LINE l1, struct LINE l2){ return l1.h > l2.h; }

int main()
{
	while(1){
	int n, m, a; // 縦線数、横線数、調べる線
	cin >> n >> m >> a;
	if(!n && !m && !a) break;
	vector<int> lots;
	for(int i=0; i<=n; i++) lots.push_back(i);

	vector<struct LINE> lines;
	for(int i=0; i<m; i++){
		struct LINE l;
		cin >> l.h >> l.p >> l.q;
		lines.push_back(l);
	}
	
	sort(lines.begin(), lines.end(), comp);
	
	for(int i=0; i<m; i++)
		swap(lots.at(lines.at(i).p), lots.at(lines.at(i).q));
	
	for(int i=1; i<=n; i++)
		if(lots.at(i)==a){ cout << i << endl; break; }
	}

    return 0;
}

Measured memory_bytes: 1252
#include <cstdio>

int main(){
  int A, B; scanf("%d%d", &A, &B);
  B++; // [A, B)

  if(A <= 0 && B > 0) puts("Zero");
  else{
    int Aneg = (A < 0 ? -A : 0);
    int Bneg = (B < 0 ? -B : 0);

    puts(Aneg % 2 == Bneg % 2 ? "Positive" : "Negative");
  }
  return 0;
}

Measured memory_bytes: 128