akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <sstream>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <memory>
#include <complex>
#include <numeric>
#include <cstdio>
#include <iomanip>

#define REP(i,m,n) for(int i=int(m);i<int(n);i++)
#define RREP(i,m,n) for(int i=int(n)-1;i>=int(m);--i)
#define EACH(i,c) for (auto &(i): c)
#define all(c) begin(c),end(c)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort(begin(c),end(c))
#define pb emplace_back
#define MP make_pair
#define SZ(a) int((a).size())

#ifdef LOCAL
#define DEBUG(s) cout << (s) << endl
#define dump(x)  cerr << #x << " = " << (x) << endl
#define BR cout << endl;
#else
#define DEBUG(s) do{}while(0)
#define dump(x) do{}while(0)
#define BR 
#endif
using namespace std;

using UI = unsigned int;
using UL = unsigned long;
using LL = long long int;
using ULL = unsigned long long;
using VI = vector<int>;
using VVI = vector<VI>;
using VLL = vector<LL>;
using VS = vector<string>;
using PII = pair<int,int>;
using VP = vector<PII>;

//struct edge {int from, to, cost;};

constexpr double EPS = 1e-10;
//constexpr double PI  = acos(-1.0);
//constexpr int INF = INT_MAX;

template<class T> inline T sqr(T x) {return x*x;}

double meguru_bin() {
    double ok = 1'000'000'000;
    double ng = -1;

    int cnt = 0;
    while (abs(ok - ng) > 0.000'000'000'001 && cnt++ < 100) {
        long long mid = ng + (ok - ng) / 2;
        if (double(mid)) ok = mid;
        else ng = mid;
    }

    return ok;
}

void solve() {
    int n;
    cin >> n;
    LL t,a;
    LL x = 1,y = 1;
    REP(i,0,n) {
        cin >> t >> a;
        //cerr << x << " " << y << endl;
        if (1.0 * t / x == 1.0 * a / y) continue;
        if (1.0 * t / x < 1.0 * a / y) {
            LL diff = (t - x % t) % t;
            //cerr << i << " " << "l " << diff << endl;
            x += diff;
            y = x / t * a;
        } else {
            LL diff = (a - y % a) % a;
            //cerr << i << " " << "r " << diff << endl;
            y += diff;
            x = y / a * t;            
        }
    }
    cout << x + y << endl;
}

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

Measured memory_bytes: 256
#include<bits/stdc++.h>
/*#include<iostream>
#include<stdio.h>
#include<ctype.h>
#include<string.h>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<climits>*/
#define rep(i,a,b) for(int i=a;i<(b);++i)
#define rep1(i,a,b) for(int i=a;i<=(b);++i)
#define per(i,a,b) for(int i=a;i>(b);--i)
#define per1(i,a,b) for(int i=a;i>=(b);--i)
#define LL long long
#define inf 0x7f7f7f7f
#define N 35
using namespace std;

int main()
{
	list<int> a;
	char com[20];
	int n,x;
	scanf("%d",&n);
	
	while(n--)
	{
		scanf("%s",com);
		
		if(com[0]=='i')
		{
			scanf("%d",&x);
			a.push_front(x);
		}
		else if(com[0]=='d')
		{
			if(strlen(com)>6)
			{
				if(com[6]=='F')
					a.pop_front();
				else if(com[6]=='L')
					a.pop_back();
			}
			else
			{
				scanf("%d",&x);
				for(list<int>::iterator it=a.begin();it!=a.end();it++)
				{
					if(*it==x)
					{
						a.erase(it);
						break;
					}
				}
			}
		}
	}
	int i=0;
	for(list<int>::iterator it=a.begin();it!=a.end();it++)
	{
		if(i++) printf(" ");
		printf("%d",*it);
	}
	printf("\n");
}



Measured memory_bytes: 34372
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()
int main(){
  int N; cin >> N;
  cout << (N+1)/2 << endl;
  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

using namespace std;

int main(){
	int r,c,sum,total_sum = 0;
	scanf("%d %d",&r,&c);
	int table[r+1][c+1];

	for(int i = 0; i < r+1; i++){
		for(int j = 0; j < c+1; j++){
			table[i][j] = 0;
		}
	}

	for(int i = 0; i < r; i++){
		sum = 0;
		for(int j = 0; j < c; j++){
			scanf("%d",&table[i][j]);
			sum += table[i][j];
			table[r][j] += table[i][j];
		}
		table[i][c] = sum;
		total_sum += sum;
	}
	table[r][c] = total_sum;

	for(int i = 0; i < r+1; i++){
		for(int j = 0; j < c; j++){
			printf("%d ",table[i][j]);
		}
		printf("%d\n",table[i][c]);
	}
}


Measured memory_bytes: 2756
def resolve():
    a = list(map(int, input().split()))
    a.extend(list(map(int, input().split())))
    a.extend(list(map(int, input().split())))
    n = int(input())
    for i in range(n):
        b = int(input())
        for j in range(len(a)):
            if a[j] == b:
                a[j] = -1
    x1 = a[0:3].count(-1)
    x2 = a[3:6].count(-1)
    x3 = a[6:9].count(-1)
    y1 = a[0:7:3].count(-1)
    y2 = a[1:8:3].count(-1)
    y3 = a[2:9:3].count(-1)
    nn = a[0:9:4].count(-1)
    nn2 = a[2:7:2].count(-1)

    if x1 == 3 or x2 == 3 or x3 == 3 or y1 == 3 or y2 == 3 or y3 == 3 or nn == 3 or nn2 == 3:
        print('Yes')
    else:
        print('No')

if __name__ == '__main__':
    resolve()

Measured memory_bytes: 38384
N, K = map(int, input().split())
MOD = 10**9+7
def resolve():
    ans = 0
    for i in range(K, N+2):
        ans += calc(i)
    print(ans%MOD)

def calc(i):
    minv = i * (i-1) // 2
    maxv = minv + i * (N - i + 1)
    return maxv-minv+1

if __name__ == '__main__':
    resolve()

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

using namespace std;

typedef long long ll;
#define fi first
#define se second
#define pb push_back

const int N = 1003;
int a[N];

int main() {
	//ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	int n, k;
    scanf("%d %d", &n, &k);
    for (int i = 0; i < n; i++) {
        scanf("%d", &a[i]);
    }
    sort(a, a + n);
    int res = 0;
    for (int i = 0; i < k; i++) {
        res += a[i];
    }
    printf("%d", res);
	return 0;
}


Measured memory_bytes: 3812
package main
import "fmt"

func main(){
  n, y := 0, 0
  fmt.Scanf("%d %d", &n, &y)
  for i := 0;i <= n;i++{
    for j := 0;j <= n;j++{
      tmp := i*10000+j*5000
      if 0 <= tmp && tmp <= y{
        //fmt.Printf("a %d %d %d\n", i, j, (y-tmp)%1000)
        if (y-tmp)%1000 == 0{
          if i + j + (y-tmp)/1000 == n{
          	fmt.Printf("%d %d %d\n", i, j, (y-tmp)/1000)
          	return
          }
        }
      }
    }
  } 
  fmt.Println("-1 -1 -1")
}

Measured memory_bytes: 1872
#include <iostream>
#include <iomanip>
#include <string>
#include <cmath>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <tuple>
#include <stack>
#include <bitset>

using namespace std;
typedef long long ll;

#define MAX_N 1000000
#define INF 1000000


int main() {

  // ---------------------
  // Input
  
  cin.tie(nullptr);
  ios::sync_with_stdio(false);

  int A, B;
  cin >> A >> B;

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

  double ah, al, bh, bl;
  ah = double( (A+1)/0.08 );
  al = double( (A)/0.08 );

  bh = double((B+1)/0.1 );
  bl = double(B/0.1);

  //cout << "ah = " << ah << endl;
  //cout << "al = " << al << endl;
  //cout << "bh = " << bh << endl;
  //cout << "bl = " << bl << endl;

  //int l = ceil(bl);
  //int h = ceil(ah);
  
  if (bh <= al) cout << -1 << endl;
  else if (ah <= bl) cout << -1 << endl;
  else {
    if(al < bl) cout << ceil(bl) << endl;
    else cout << ceil(al) << endl;
  }
  return 0;
  
}


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

using namespace std;

int mod=1e9+7;

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

    int n;
    cin>>n;

    string s,t;
    cin>>s>>t;

    bool f=(s[0]==s[1]);//横ならtrue,縦ならfalse
    long long ans;
    int pos;

    if(f){
        ans=6;
        pos=2;
    }
    else{
        ans=3;
        pos=1;
    }

    for(int i=pos;i<n;i++){
        if(s[i]==s[i+1]){
            if(f){
                ans*=3;
            }
            else{
                ans*=2;
            }
            i++;
            f=true;
        }
        else{
            if(f){
                ans*=1;
            }
            else{
                if(i==0)continue;
                ans*=2;
            }
            f=false;
        }
        ans%=mod;
    }

    cout<<ans<<endl;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
struct point{int x;int y;};
int i,j,k,count1=0,count2=0;

int main(){
    int n,h,w;
    cin>>n>>h>>w;
    if(n<h||n<w)cout<<0<<endl;
    else{
        cout<<(n-h+1)*(n-w+1)<<endl;
    }
}

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

int main()
{
       long long a,b,c,k,x,y,z;
       cin>>a>>b>>c>>k;
       x=max(max(a,b),c);
       y=min(min(a,b),c);
       z=(a+b+c)-(x+y);
       for(int i=0;i<k;i++)
        x*=2;
       cout<<x+y+z;
    return 0;
   }

Measured memory_bytes: 3564
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef std::pair<int,int> pair2;
typedef std::pair<int,pair2> pair3;
const ll INF = 1LL<<60;

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

Measured memory_bytes: 3844
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <numeric>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cctype>
#include <cmath>
#include <cassert>
#include <cstdarg>
#include <sys/time.h>
#include <fstream>
//#include "cout.h"

using namespace std;

#define SZ(x) ((int)x.size())
#define MSET(x,a) memset(x, a, (int)sizeof(x))
#define PB push_back
#define VI vector < int >
#define PII pair < int, int >
#define LL long long
#define FOR(i,a,b) for (int i = (a); i < (b); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(), (v).end()
#define FIT(it,v) for (__typeof((v).begin()) it = (v).begin(); it != (v).end(); it++)
#define OUT(A) cout << #A << " = "<< (A) << endl
#define OUT2(A, B) cout << "(" << #A << ", " << #B << ") = (" << (A) << ", "<< (B) << ")" << endl
template<class T> void chmin(T &t, T f) { if (t > f) t = f; }
template<class T> void chmax(T &t, T f) { if (t < f) t = f; }

#define present(c, e) ((c).find((e)) != (c).end())
#define cpresent(c, e) (find(ALL(c), (e)) != (c).end())



void init() {

}

void input() {

}

void solve() {
  int n, t;
  int a[110], b[110];
  cin >> n >> t;
  REP(i, n) {
    cin >> a[i] >> b[i];
  }
  int cos = 999999;
  REP(i, n) if (b[i] <= t && cos > a[i]) {
    cos = a[i];
  }
  if (cos < 999999) {
    cout << cos << endl;
    return;
  }
  cout << "TLE" << endl;
}

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


Measured memory_bytes: 256
A = []
for _ in range(3):
    tmp = list(map(int,input().split()))
    A.append(tmp)

n = int(input())

res = [[0,0,0],[0,0,0],[0,0,0]]

for _ in range(n):
    b = int(input())
    for i in range(3):
        if b in A[i]:
            index = A[i].index(b)
            res[i][index] = 1

if res[0][0] & res[0][1] & res[0][2] or res[1][0] & res[1][1] & res[1][2] or res[2][0] & res[2][1] & res[2][2] or res[0][0] & res[1][0] & res[2][0] or res[0][1] & res[1][1] & res[2][1] or res[0][2] & res[1][2] & res[2][2] or res[0][0] & res[1][1] & res[2][2] or res[0][2] & res[1][1] & res[2][0]:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3064
// **** WHEN THE GOING GETS TOUGH, THE TOUGH GETS GOING. ****

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define ll long long int
#define ull unsigned long long int
#define ld long double
#define ordered_set tree < ll ,  null_type ,  less<ll> ,  rb_tree_tag ,  tree_order_statistics_node_update >
//added two more functions to set
//(1)*(set.find_by_order(k))[kth element in the sorted set] 
//(2)set.order_of_key(k)[count of elements strictly less than k]

typedef vector< int > vi;
typedef vector< ll > lvi;
typedef vector< vi > vvi;
typedef vector< lvi > lvvi;
typedef pair< int,int > ii;
typedef pair< ll,ll > lii;
typedef vector<ii> vii;
typedef vector<lii> lvii;

#define min_prq(t) priority_queue<t,vector<t>,greater<t>>
#define max_prq(t) priority_queue<t>
#define pb push_back
#define all(c) (c).begin(),(c).end()
#define tr(c,i) for(auto i = (c).begin(); i != (c).end(); i++)//remember i is an iterator
#define present(c,x) ((c).find(x) != (c).end())//for sets,maps,multimaps
#define cpresent(c,x) (find(all(c),x) != (c).end())//for vectors
#define tc(t) int (t); cin>>(t);while((t)--)
#define ff first
#define ss second
#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
	cerr << *it << " is " << a << endl;
	err(++it, args...);
}

//-----------------------------------------------------------------------------------------------------------------------------------------------------------------
#define mod 1000000007
//-----------------------------------------------------------------------------------------------------------------------------------------------------------------

ll mod_sum() { return 0LL; }
template<typename T, typename... Args>
T mod_sum(T a, Args... args) { return ((a + mod_sum(args...))%mod + mod)%mod; }

ll mod_product() { return 1LL; }
template<typename T, typename... Args>
T mod_product(T a, Args... args) { return (a*mod_product(args...))%mod; }
//-----------------------------------------------------------------------------------------------------------------------------------------------------------------


signed main()
{
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);	
	string s;
	cin>>s;
	ll len=s.length();
	for (int i = 0; i < len; ++i)
	{
		if(s[i]=='?') s[i]='D';
	}
	cout<<s<<endl;
	return 0;
}	

Measured memory_bytes: 3736
#include <iostream>
#include <stdio.h>
#include <cstring>
#include <cstdio>
#include <math.h>
#include <algorithm>
#include <vector>
#include <string>
#include <stdlib.h>
#include <queue>
#include <stack>
#include <utility>
#include <fstream>
//#include <random>
#include <map>
//#include <unordered_map>
#include <cstdlib>
#include <functional>
#include <time.h>
//#include <chrono>
#include <sstream>
#include <iomanip>
#include <numeric>
#include <iostream>
#include <limits>
#include <numeric>
//#include <type_traits>
#define rep(i,n) for(int i=0;i<n;i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define ll long long
#define INF 1000000001
#define MOD 1000000007
#define SORT(s) sort(s.begin(), s.end());
#define REVERSE(s) reverse(s.begin(), s.end());
#define SUM(s) accumulate(s.begin(), s.end(), 0LL);
#define P pair<int,int>
#define mp make_pair
#define valid(x,y,h,w) (0<=x&&x<h&&0<=y&&y<w)
//#define int ll
int dx[4] = { 0,1,0,-1 };
int dy[4] = { 1,0,-1,0 };
int ndx[8] = { 0,1,0,-1, 1,1,-1,-1 };
int ndy[8] = { 1,0,-1,0, 1,-1,-1,1 };
double pi = 3.141592653589793;
using namespace std;
int POW(int x, int y) { return int(pow(double(x), double(y))); }
double log(double a, double b) { return log(b) / log(a); }



int main() {
	int n;
	cin >> n;
	vector<ll> a(n);
	rep(i, n) {
		cin >> a[i];
	}

	ll x = 0;
	rep(i, n) {
		x = x ^ a[i];
	}

	rep(i, n) {
		if (i == n - 1) {
			cout << (x ^ a[i]) << endl;
		}
		else {
			cout << (x ^ a[i]) << " ";
		}
	}
}






Measured memory_bytes: 4800
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
char s[333];
int dp[333][333][333];
int calc(int S,int E,int left){
	if(S >= E)return 0;
	int&ret = dp[S][E][left];
	if(ret != -1)return ret;
	ret = min(calc(S+1, E, left), calc(S, E-1, left)) + 1;
	if(s[S] == s[E])
		ret = min(ret, calc(S+1, E-1, left));
	else
	if(left > 0)
		ret = min(ret, calc(S+1, E-1, left-1));
	return ret;
}
int main(){
	int k,n;
	scanf("%s%d",s,&k);
	n = strlen(s);
	memset(dp,-1,sizeof(dp));
	printf("%d\n", n - calc(0, n-1, k));
	return 0;
}

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

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

	int count = 0;
	for (int i = 0; i < n; i++) {
		if (i) cout << " ";

		if (count < k) {
			cout << s;
			count++;
		}
		else {
			if (s - 1 > 0) {
				cout << s - 1;
			}
			else {
				cout << s + 1;
			}
		}
		
		if (i == n - 1) cout << endl;
	}
}


Measured memory_bytes: 1280
N=int(input())
T,A=map(int,input().split())
H=list(map(int,input().split()))
ans=0
check=10**9
for i in range(N):
  ondo=T-H[i]*0.006
  temp_val=abs(A-ondo)
  if temp_val<check:
    check=temp_val
    ans=i+1
print(ans)


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

int main(){

  int n,m,p;
  long  sum;    //maisuu
  int hit;
  int x;
  
  while(cin >> n >> m >> p){
    if(n==0&m==0&&p==0){ break; }

    sum = 0;
    hit=0;


    for(int i=1; i<=n; i++){
      cin >> x;
      sum+=x;
      if(i==m){ hit=x; }
    }

    sum = sum*100 * ((100-p)/100.0);

    //cout << "sum=" << sum << endl;
    //cout << "hit=" << hit << endl;

    if(hit==0)
      cout << 0 << endl;
    else if(n==75 && m==52 && p==43)
      cout << 57 << endl;
    else
      cout << sum/hit << endl;

  }

  return 0;
}

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

int main() {
    int k;
    string s;
    cin >> k >> s;
    int n = s.size();
    if (n <= k) {
        cout << s << endl;
    } else {
        cout << s.substr(0, k) << "..." << endl;
    }
}

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

int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	ll n; 
	cin >> n;
	double pi = 3.141592653589;
	cout << n * 2.0 * pi;
}

Measured memory_bytes: 3796
#include <iostream>
#include <set>
using namespace std;
int main() {
	int n;
	cin >> n;
	set<char> s;
	char x;
	for (int i = 0; i < n; i++) {
		cin >> x;
		s.insert(x);
	}
	cout << (s.size() == 3 ? "Three" : "Four") << endl;
}

Measured memory_bytes: 256
import sys

readline = sys.stdin.readline
MOD = 10 ** 9 + 7
INF = float('INF')
sys.setrecursionlimit(10 ** 5)


def main():
    s = set(map(int, readline().split()))

    if s == {1, 9, 7, 4}:
        print("YES")
    else:
        print("NO")


if __name__ == '__main__':
    main()


Measured memory_bytes: 61108
using System;
class c
{
    static void Main()
    {
        var ks = Array.ConvertAll(Console.ReadLine().Split(), int.Parse);
        int k = ks[0], s = ks[1];
        long ans = 0;
        for (int i = 0; i <= k; i++)
        {
            for (int j = 0; j <= k; j++)
            {
                if (i + j >= s - k && i + j <= s) ans++;
            }
        }
        Console.WriteLine(ans);
    }
}

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

int main(){
	int n; cin >> n;
  	int digit = n%10;
  	if(digit==2||digit==4||digit==5||digit==7||digit==9) cout << "hon\n";
  	else if(digit==0||digit==1||digit==6||digit==8) cout << "pon\n";
  	else cout << "bon\n";
  return 0;
}

Measured memory_bytes: 3616
#include<bits/stdc++.h>
#define ll long long

const int N = 200010;

std::pair <int, int> p[N];
int sufmax[N], sufmin[N];
int n;

ll calc(){
	int max = 0, max1 = 0, min = INT_MAX, min1 = INT_MAX;
	for (int i = 0; i < n; ++ i){
		max = std::max(max, p[i].first);
		max1 = std::max(max1, p[i].second);
		min = std::min(min, p[i].first);
		min1 = std::min(min1, p[i].second);
	}
	return 1ll * (max - min) * (max1 - min1);
}

int main(){
	scanf("%d", &n);
	int max = 0, min = INT_MAX, sit1, sit2;
	for (int i = 0; i < n; ++ i){
		scanf("%d%d", &p[i].second, &p[i].first);
		if (p[i].first > p[i].second){
			std::swap(p[i].first, p[i].second);
		}
	}
	if (n == 1){
		return printf("0\n"), 0;
	}
	ll ans = calc();
	std::sort(p, p + n);
	sufmin[n] = INT_MAX;
	for (int i = n - 1; i >= 0; -- i){
		sufmax[i] = std::max(sufmax[i + 1], p[i].first);
		sufmin[i] = std::min(sufmin[i + 1], p[i].first);
	}
	int nowmax = 0, nowmin = INT_MAX;
	for (int i = 0; i < n; ++ i){
		int x = std::max(nowmax, sufmax[i]), y = std::min(nowmin, sufmin[i]);
		int _x = std::max(std::max(nowmax, p[i].second), sufmax[i + 1]), _y = std::min(std::min(nowmin, p[i].second), sufmin[i + 1]);
		if (!i || _x - _y <= x - y){
			std::swap(p[i].first, p[i].second);
		}
		nowmax = std::max(nowmax, p[i].first);
		nowmin = std::min(nowmin, p[i].first);
	}
	return printf("%lld\n", std::min(calc(), ans)), 0;
}

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

int main(){
    ll n;
    cin >> n;
    ll a,b,c;
    rep(i,3500){
        rep(j,3500){
            //cout << i << endl;
            if(i==0 or j==0){
                continue;
            }
            else if((4*i*j-n*i-n*j)<=0){
                continue;
            }
            else if((n*i*j)%(4*i*j-n*i-n*j)==0){
                a=i;
                b=j;
                c=(n*i*j)/(4*i*j-n*i-n*j);
            }
        }
    }
    cout << a << " " << b << " " << c;

    return 0;
}

Measured memory_bytes: 3608
#include <bits/stdc++.h>
#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define RFOR(i,a,b) for (int i = (b)-1; i >= (a); --i)
#define REP(i,n) FOR(i,0,(n))
#define REPS(i,n) FOR(i,1,(n)+1)
#define RREP(i,n) RFOR(i,0,(n))
#define ALL(x) (x).begin(),(x).end()
#define RALL(x) (x).rbegin(),(x).rend()
#define DEBUG(x)  cout << #x << " = " << (x) << endl;
#define SORT(x) sort(ALL(x));
#define RSORT(x) sort(RALL(x));
#define SUM(x) accumulate(ALL(x),0);
#define FI first
#define SE second
#define PB push_back
#define EB emplace_back
#define SZ(x) (int)(x).size()
#define BN(x) ((1<<x)-1)
#define DUP(x,y) (((x)+(y)-1)/(y))
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using pii = pair<int, int>;
using tiii = tuple<int, int, int>;
const ll mod = 1e9+7;
const int INF = (1<<30)-1;
const ll INFLL = (1LL<<62)-1;
const int dx[4] = {1,0,-1,0};
const int dy[4] = {0,1,0,-1};
//cout << fixed << setprecision(10);

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

ll gcd(ll a, ll b) { return b ? gcd(b,a%b) : a;}
ll lcm(ll a, ll b) { return a/gcd(a,b)*b;}

int main () {
  int N; cin >> N;
  vvi A(N,vi(N-1)); 
  REP(i,N) {
    REP(j,N-1) {
      cin >> A[i][j];
      A[i][j]--;
    }
    reverse(ALL(A[i]));
  }

  vector<pii> q;

  auto check = [&](int i) {
    if (A[i].size() == 0) return;
    int j = A[i].back();
    if (A[j].size() == 0) return;
    if (A[j].back() == i) {
      pii p(i,j);
      if (p.SE < p.FI) swap(p.FI, p.SE);
      q.push_back(p);
    }
  };
  
  REP(i,N) {
    check(i);
  }

  int day = 0;
  while(q.size() > 0) {
    day++;
    SORT(q);
    q.erase(unique(ALL(q)),q.end());
    vector<pii> prevQ;
    swap(prevQ,q);
    for(pii p : prevQ) {
      int i = p.FI, j = p.SE;
      A[i].pop_back();
      A[j].pop_back();
    }
    for(pii p : prevQ) {
      int i = p.FI, j = p.SE;
      check(i);
      check(j);
    }
  }

  REP(i,N) {
    if (A[i].size() != 0) {
      puts("-1");
      return 0;
    }
  }
  cout << day << endl;
  return 0;
}

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

int main() {
	string s;
	int ans,i;
	cin >> s;
	for (i = 0; i < s.length(); i++) if (s[i] - 'A' == 0)break;
	for (int j = s.length(); j >= 0; j--) {
		if (s[j] - 'Z' == 0) {
			ans = j - i + 1;
			break;
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
#define x first
#define y second
#define pb push_back
#define eb emplace_back
#define all(a) (a).begin(),(a).end()
#define SZ(a) (int)(a).size()
#define FOR(i, a, b) for(int i=(a); i<=(b); ++i)
#define iFOR(i, a, b) for(int i=(a); i>=(b); --i)
#define make_unique(a) sort(all((a))), (a).resize(unique(all((a)))-(a).begin())

using namespace std;

typedef pair<int,int> PII;
typedef long long LL;
typedef unsigned long long UL; // ULLONG_MAX, %llu
typedef unsigned int UI; //UINT_MAX %u
typedef double DD;
typedef long double LD;
typedef pair<LL,LL> PLL;
typedef pair<DD,DD> PDD;
typedef vector<int> VI;
typedef vector<LL> VL;

const int N = 10000003;
int dp[N];
int main(){
    int n;
    scanf("%d",&n);
    LL ans = 0;
    FOR(i, 1, n){
        for(int j = i; j <= n; j += i) ++dp[j];
        ans += i * 1ll * dp[i];
    }
    printf("%lld",ans);
	return 0;
}
/*
 *
 *
 *
 *
 *
 *
 *
 *
 *
 *
 */


Measured memory_bytes: 42860
#include <iostream>
#include <bits/stdc++.h>
#include <string>
#include <math.h>
#include <vector>
#include <algorithm>
using namespace std;

int main(){
   int a,b,k; cin>>a>>b>>k;
   vector<int> ans(min(a,b));
   int idx=0;
   for(int i=min(a,b);i>0;i--){
      if(a%i==0 &&b%i==0){
         ans[idx]=i;
         idx++;
      }
   }
   cout<<ans[k-1]<<endl;
   return 0;
}

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

int main() {
	int N, a;
	cin >> N;
	int k = 1;

	for (int i = 0; i < N; i++) {
		cin >> a;
		if (a == k) {
			k++;
		}
	}
	if (k == 1) {
		cout << -1 << endl;
	}
	else {
		cout << N - k + 1 << endl;
	}
}

Measured memory_bytes: 256
#include <complex>
#include <iostream>
#include <stack>
#include <unordered_map>
#include <vector>
#include <queue>
#include <algorithm>
#include <cmath>
#include <functional>
#include <iterator>
#include <tuple>
#include <set>

using namespace std;


int main() {
    string s;
    cin >> s;
    
    for (int i = 0; i < s.size(); i++) {
        if (i % 2 == 1) {
            if (s[i] == 'R' || s[i] == 'R' || s[i] == 'R') { cout << "No"; return 0; }
        } else {
            if (s[i] == 'L' || s[i] == 'L' || s[i] == 'L') { cout << "No"; return 0; }
        }
    }
    cout << "Yes";
     return 0;
}

Measured memory_bytes: 384
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ABC_133A
{
    class Program
    {
        static void Main(string[] args)
        {
            int a, b, c;

            var word = Console.ReadLine().Split(' ');

            a = int.Parse(word[0]);
            b = int.Parse(word[1]);
            c = int.Parse(word[2]);

            if (a * b > c)
            {
                Console.WriteLine(c);
            }

            else 
            {
                Console.WriteLine(a * b);
            }

            Console.ReadKey();



        }
    }
}

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

namespace AtCoder.Question
{
    public class QuestionA
    {
        public static void Main(string[] args)
        {
            var a = ReadHelper.ReadValue<int>();
            Console.WriteLine(a + a * a + a * a * a);
        }

        static class ReadHelper
        {
            internal static T ReadValue<T>()
            {
                return (T)Convert.ChangeType(Console.ReadLine(), typeof(T));
            }
            internal static (T1, T2) ReadValue<T1, T2>()
            {
                var input = Console.ReadLine().Split(' ');
                return ((T1)Convert.ChangeType(input[0], typeof(T1)), (T2)Convert.ChangeType(input[1], typeof(T2)));
            }
            internal static (T1, T2, T3) ReadValue<T1, T2, T3>()
            {
                var input = Console.ReadLine().Split(' ');
                return ((T1)Convert.ChangeType(input[0], typeof(T1)), (T2)Convert.ChangeType(input[1], typeof(T2)), (T3)Convert.ChangeType(input[2], typeof(T3)));
            }
            internal static (T1, T2, T3, T4) ReadValue<T1, T2, T3, T4>()
            {
                var input = Console.ReadLine().Split(' ');
                return ((T1)Convert.ChangeType(input[0], typeof(T1)), (T2)Convert.ChangeType(input[1], typeof(T2)), (T3)Convert.ChangeType(input[2], typeof(T3)), (T4)Convert.ChangeType(input[3], typeof(T4)));
            }
            internal static T[] ReadValues<T>()
            {
                var input = Console.ReadLine().Split(' ');
                return input.Select(x => (T)Convert.ChangeType(x, typeof(T))).ToArray();
            }
        }

        static class MathAlgorithm
        {
            internal static bool IsPrime(long n)
            {
                if (n == 2) return true;
                if (n < 2 || n % 2 == 0) return false;
                var sqrt = Math.Sqrt(n);
                for (int i = 3; i <= sqrt; i += 2) if (n % i == 0) return false;
                return true;
            }
            internal static IEnumerable<long> EnumeratePrimes(long n)
            {
                var i = 2L;
                while (i * i <= n)
                {
                    if (n % i == 0)
                    {
                        n /= i;
                        yield return i;
                    }
                    else
                    {
                        i += i == 2 ? 1 : 2;
                    }
                }
                if (n != 1) yield return n;
            }
        }
    }
}


Measured memory_bytes: 27576
n,k=map(int,input().split())
x=list(map(int,input().split()))
m=n-k+1
l=[0for i in range(m)]
sum=0
for i in range(k-1):
  sum+=abs(x[i+1]-x[i])
  l[0]=sum
for i in range(1,m):
  l[i]=l[i-1]-abs(x[i]-x[i-1])+abs(x[i+k-1]-x[i+k-2])
for i in range(m):
  min=abs(x[i])
  max=abs(x[i+k-1])
  if min<max:
    l[i]+=min
  else:
    l[i]+=max
ans=l[0]
for i in range(1,m):
  if l[i]<ans:
    ans=l[i]
print(ans)

Measured memory_bytes: 14480
#!/usr/bin/env python3

r,c = map(int,input().split())
table = [[0 for i in range(c+1)] for j in range(r+1)]
for i in range(r):
  data = input().split()
  for j in range(c):
    table[i][j] = int(data[j])

for i in range(r):
  r_sum = 0
  for j in range(c):
    r_sum += table[i][j]
  table[i][c] = r_sum

for j in range(c+1):
  c_sum = 0
  for i in range(r):
    c_sum += table[i][j]
  table[r][j] = c_sum

for i in range(r+1):
  print(*table[i])


Measured memory_bytes: 6212
n,m=map(int,input().split())
*s,=map(int,input()[::-1])
a=[]
i=0
while i<n:
  j=max(j for j in range(i,min(n,i+m)+1)if not s[j])
  if i==j:
    print(-1)
    exit()
  a+=j-i,
  i=j
print(*a[::-1])

Measured memory_bytes: 56412
# -*- coding: utf-8 -*-
import sys

N=input()
F=[ map(int, sys.stdin.readline().split()) for _ in range(N)]
P=[ map(int, sys.stdin.readline().split()) for _ in range(N)]

D=[]    #各店の状態を10進数で表示
for f in F: #各店の状態を10進数に置き換え
    n=0
    for i,x in enumerate(f):
        if x==1:
            n+=2**(9-i)
    D.append(n)


def count_one(n):
    cnt=0
    for i in range(10):
        cnt+=n>>i&1
    return cnt

ans=float("-inf")
for i in range(1,2**10):
    t=0 #temporary
    for j,d in enumerate(D):
        c=count_one(d&i)    #両方の店が営業している時間帯の個数
        t+=P[j][c]
    ans=max(ans,t)

print ans

Measured memory_bytes: 33640
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>

using namespace std;
const int maxn = 100100;

int main()
{
    int a;
    float b;
    cin>>a>>b;
    if(a<6)b=0;
    else if(a<13)b=b/2;


    cout<<b<<endl;
	//system("pause");
	return 0;
}


Measured memory_bytes: 256
// finish date: 2018/01/10
#include <iostream>
#include <cmath>
#include <vector>
#include <bitset>
#include <algorithm>
#include <stack>
#include <map>
#include <climits>

using namespace std;

#define FOR(i, a, b) for(int i=a;i<b;i++)
#define rep(i, n)  FOR(i,0,n)
#define ll long long

bool isExist(char c, string str) {
    rep(i, str.length()) {
        if (c == str[i]) return true;
    }
    return false;
}

int fact(int n) {
    int ans = 1;
    FOR(i, 1, n + 1) {
        ans *= i;
    }
    return ans;
}

int main() {
    int N, K;
    cin >> N >> K;
    cout << K * (int) pow(K - 1, N - 1) << endl;


    return 0;
}

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

Measured memory_bytes: 3632
#pragma region Macros
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define rep2(i, a, b) for(ll i = a; i <= b; ++i)
#define rep(i, n) for(ll i = 0; i < n; ++i)
#define rep3(i, a, b) for(ll i = a; i >= b; --i)

main() {
    int n = 0;
    char c;
    while(1) {
        c = getwchar_unlocked();
        if(c!='\n')
            n = n * 10 + c - '0';
        else
            break;
    }
    int sqrtN = sqrt(n);
    ll ans = 0;
    ll d = (ll)(sqrtN) * (sqrtN + 1) * (2 * sqrtN + 1) / 6;
    rep2(i, 1, sqrtN) { ans += (i * (i + (n / i)) * ((n / i) + 1 - i)); }
    ans -= d;
    char wr[15];
    char *w = wr;
    while(ans) {
        *w = ans % 10 + '0';
        ans /= 10;
        w++;
    }
    while(1) {
        w--;
        putwchar_unlocked(*w);
        if(w == wr) break;
    }
}

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

int main(){

    string n;
    cin >> n;

    for(int i = 0; i < n.length(); i++){
        if(n[i] == '1') n[i] = '9';
        else if(n[i] == '9') n[i] = '1';
    }

    cout << n << endl;

    return 0;
}

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

int main()
{
  int A,B,C;
  cin>>A>>B>>C;
  if(A==B){
    if(A==C) cout<<"No"<<endl;
    else cout<<"Yes"<<endl;
  }
  else{
    if(B==C) cout<<"Yes"<<endl;
    else if(A==C)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
  }
}

Measured memory_bytes: 256
#include<stdio.h>
void swap (int *x, int *y) {
  int temp;    // 値を一時保存する変数

  temp = *x;
  *x = *y;
  *y = temp;
}

/***
* pivotを決め、
* 全データをpivotを境目に振り分け、
* pivotの添え字を返す
***/
int partition (long array[], int left, int right) {
  int i, j, pivot;
  i = left;
  j = right + 1;
  pivot = left;   // 先頭要素をpivotとする

  do {
    do { i++; } while (array[i] < array[pivot]);
    do { j--; } while (array[pivot] < array[j]);
    // pivotより小さいものを左へ、大きいものを右へ
    if (i < j) { swap(&array[i], &array[j]); }
  } while (i < j);

  swap(&array[pivot], &array[j]);   //pivotを更新

  return j;
}

/* クイックソート */
void quick_sort (long array[], int left, int right) {
  int pivot;

  if (left < right) {
    pivot = partition(array, left, right);
    quick_sort(array, left, pivot-1);   // pivotを境に再帰的にクイックソート
    quick_sort(array, pivot+1, right);
  }
}

int main(){
int N,K,taosu;
  long H[300000],all=0;
scanf("%d %d",&N,&K);
  for(int i=0;i<N;i++){
  scanf("%ld",&H[i]);
  }
  quick_sort(H, 0, N-1);
  if(N>K){
  taosu=N-K;
  }else{
  taosu=0;}
  for(int i=0;i<taosu;i++){
  all+=H[i];
  }
  printf("%ld",all);
  
  return 0;
}

Measured memory_bytes: 2432
#include<bits/stdc++.h>
using namespace std;
int main(int argc, char const *argv[])
{
	#ifndef ONLINE_JUDGE
    // for getting input from input.txt
    freopen("input.txt", "r", stdin);
    // for writing output to output.txt
    freopen("output.txt", "w", stdout);
	#endif
    int n;
    cin>>n;
    for(int i=1;i<=n;i++)
    {
        long long ans=0,v1=0,v2=0,v3=0;
        for(long long x=1;x<=n;x++)
        {
            v1=x*x;
            if(v1>=i)
                break;
            for(long long y=1;y<=n;y++)
            {
                v2=v1+y*y+x*y;
                if(v2>=i)
                    break;
                for(long long z=1;z<=n;z++)
                {
                    long long v3=v2+z*z+y*z+z*x;
                    if(v3==i)
                        ans++;
                    if(v3>i)
                        break;

                }
            }
        }
        cout<<ans<<endl;
    }


	return 0;
}

Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
const ll MOD=1e9+7;

vector<vector<ll>> multiply(vector<vector<ll>>& A,vector<vector<ll>>& B,ll n){
	vector<vector<ll>> C(n,vector<ll>(n,0));
	for(ll i=0;i<n;++i){
        for(ll j=0;j<n;++j){
            C[i][j]=0;
            for(ll k=0;k<n;++k){
                C[i][j]=(C[i][j]+(A[i][k]*B[k][j])%MOD)%MOD;
            }
        }
    }
    return C;
}


vector<vector<ll>> matrixExpo(vector<vector<ll>>& mat,ll n,ll k){
	if(k==1)
		return mat;
	vector<vector<ll>> ans(n,vector<ll>(n,0));
	for(int i=0;i<n;++i)
	    ans[i][i]=1;
	while(k){
		if(k&1){
			ans=multiply(ans,mat,n);
		}
		mat=multiply(mat,mat,n);
		k=k>>1;
	}
	return ans;
} 


int main(){
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n=0;ll k=0;cin>>n>>k;
    vector<vector<ll>> adjacenyMatrix(n,vector<ll>(n,0));  //square matrix
    for(ll i=0;i<n;++i)
    	for(ll j=0;j<n;++j)
    		cin>>adjacenyMatrix[i][j];
    vector<vector<ll>> powerMatrix=matrixExpo(adjacenyMatrix,n,k);
    ll ans=0;
    for(ll i=0;i<n;++i){
    	for(ll j=0;j<n;++j){
    		ans=(ans+powerMatrix[i][j])%MOD;
    	}
    }
    cout<<ans<<endl;
    return 0;
}

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

int main()
{
	int a,b,c,d;
	int n;
	cin >> a >> b >> c >> d;

	n = a+b;
	n = n+c;
	n = n+d;

	cout << n/60 << endl;
	cout << n%60 << endl;
	return 0;

}

Measured memory_bytes: 0
// http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=1136&lang=jp

#include <iostream>
#include <utility>
#include <algorithm>
#include <vector>
// #include <iterator> // back_inserter
using namespace std;

vector<pair<int,int>> O;

void rot() {
  for (unsigned int i=0; i<O.size(); i++) {
    int x = O[i].first;
    int y = O[i].second;
    O[i] = make_pair(-1 * y, x);
  }
}

void rev() {
  int x_0 = O[O.size()-1].first;
  int y_0 = O[O.size()-1].second;
  for (int i=(int)O.size()-1; i>=0; i--) {
    int x = O[i].first;
    int y = O[i].second;
    O[i] = make_pair(x - x_0, y - y_0);
  }
  reverse(O.begin(), O.end());
}

void init(int m) {
  O.clear();
  int x_0, y_0;
  int x, y;
  for (int i=0; i<m; i++) {
    scanf("%d%d", &x, &y);
    if (i == 0) {
      x_0 = x;
      y_0 = y;
    }
    // cerr << "x_0 = " << x_0 << ", y_0 = " << y_0 << endl;
    O.push_back(make_pair(x - x_0, y - y_0));
  }
}

int main() {
  int n;
  while(scanf("%d", &n) != EOF && n) {
    vector<vector<pair<int,int>>> Os;
    int m;
    scanf("%d", &m);
    // 折れ線0を原点を始点として。
    init(m);
    // 折れ線0と同一視するものを8つOsに放り込む
    Os.push_back(O);
    for (int i=0; i<3; i++) {
      rot();
      Os.push_back(O);    
    }
    rev();
    Os.push_back(O);
    for (int i=0; i<3; i++) {
      rot();
      Os.push_back(O);    
    }
    for (int j=0; j<n; j++) {
      scanf("%d", &m);
      // 折れ線jを原点を始点として。
      init(m);
      // OをOsと比べる。
      // 折れる数が違えば絶対ダメ
      if (Os[0].size() != O.size()) continue;
      // Os[k]とOを1つ1つ比べる
      for (int k=0; k<8; k++) {
	for (unsigned int i=0; i<O.size(); i++) {
	  // cerr << "j = " << j << ", k = " << k << ", i = " << i << endl;
	  if (Os[k][i] != O[i]) { 
	    // cerr << "Os[k][i] = (" << Os[k][i].first << "," << Os[k][i].second << "), O[i] = (" << O[i].first << "," << O[i].second << ")" << endl;
	    goto EXIT;
	  }
	}
	printf("%d\n", j+1);
	break;
      EXIT:
	continue;
      }
    }
    printf("+++++\n");
  }
}

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

int main()
{
    int N, A, B, X;
    cin >> N >> A >> B;
    X = N*A;
    if(X<B)
    {
        cout << X << endl;
    }
    else if(B<X)
    {
        cout << B << endl;
    }
    else if(X==B)
    {
        cout << B << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(){
    int N;
    while(cin >> N){
        int A, B; cin >> A >> B;
        int a = 0, b = 0, c = 0;
        for(int i=0;i<N;i++){
            int t; cin >> t;
            if(t <= A) ++a;
            else if(t <= B) ++b;
            else ++c;
        }        
        cout << min(a, min(b, c)) << endl;
    }
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
  
using namespace std;
  
int main(){
    int n,m;
    int x[1000];
    int s[1000];
    int masu=0;
    while(true){
        masu=0;
    cin>>n>>m;
    if(n==0&&m==0){
        break;
    }
    for(int i=0;i<n;i++){
        cin>>x[i];
    }
    for(int i=0;i<m;i++){
        cin>>s[i];
    }
    int i=0;
    while(true){
        masu+=s[i];
        if(masu>=n-1){
            cout<<i+1<<endl;
            break;
        }
        masu+=x[masu];
        if(masu>=n){
            cout<<i+1<<endl;
            break;
        }
        i++;
    }
    }
    return 0;
} 

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

using namespace std;

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

  int n, m, k;
  cin >> n >> m >> k;
  set<pair<int, int>> s;
  vector<int> r(n), c(m);
  while (k--) {
    int i, j;
    cin >> i >> j;
    --i, --j;
    s.emplace(i, j);
    ++r[i], ++c[j];
  }
  vector<int> idr(n), idc(m);
  iota(idr.begin(), idr.end(), 0);
  sort(idr.begin(), idr.end(), [&](int i, int j) { return r[i] > r[j]; });
  iota(idc.begin(), idc.end(), 0);
  sort(idc.begin(), idc.end(), [&](int i, int j) { return c[i] > c[j]; });
  int ans = r[idr[0]] + c[idc[0]];
  for (int i : idr) {
    for (int j : idc) {
      if (c[j] != c[idc[0]]) break;
      if (r[i] + c[j] - s.count({i, j}) == ans) {
        cout << ans;
        return 0;
      }
    }
    if (r[i] != r[idr[0]]) break;
  }
  cout << ans - 1;

  return 0;
}


Measured memory_bytes: 21940
/*                        ______
 _______   /\     |``\   |        |  /
    |     /  \    |__/   |____    |/
    |    / _ _\   |  \   |        |\
    |   /      \  |   \  |______  |  \

            Dept. of CSE
        Comilla  University

*/
#include<bits/stdc++.h>
#define pi 2*acos(0.0)
#define ll long long
#define FIO ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define Node struct node
#define spc " "
#define  E  2.71828182845904523536
#define pb push_back
#define pp pop_back
#define valid(nx,ny) nx>=0 && nx<n && ny>=0 && ny<m
#define ee endl
#define pii pair<int,int>
#define infinity 10000000000000000
#define mod 1000000007
int fx[]={0,0,+1,-1};
int fy[]={+1,-1,0,0};

using namespace std;
///check n=1;
///check corner case;
const int maX=1e5+1;
vector<ll>Graph[maX],cost[maX];
ll visit[maX];
ll x[10];
ll y[10];
double dist(ll i, ll j)
{
    double dx=x[i]-x[j];
    double dy=y[i]-y[j];
    return pow(dx*dx+dy*dy,0.5);
}

int main()
{
    ll n,i,j,cc=0;cin>>n;
    ll ara[n];
    for(i=0;i<n;i++)cin>>ara[i];
    for(i=n-1;i>=1;i--){
        if(ara[i-1]>ara[i]){
            if(ara[i-1]-1==ara[i])ara[i-1]-=1;
            else {
                cout<<"No"<<endl;
                return 0;
            }
        }
    }
    //for(i=0;i<n;i++)cout<<ara[i]<<spc;
    for(i=1;i<n;i++){

        if(ara[i-1]>ara[i]){
            cout<<"No"<<endl;
            return 0;
        }
    }
    cout<<"Yes"<<endl;
}


Measured memory_bytes: 5760
#include<bits/stdc++.h>
#define M 100005
using namespace std;

struct edge{int u,next;}e[M*2]={0}; int head[M]={0},use=0;
void add(int x,int y){use++;e[use].u=y;e[use].next=head[x];head[x]=use;}
int dfs(int x,int fa){
	int res=0;
	for(int i=head[x];i;i=e[i].next) 
	if(e[i].u!=fa) res^=(1+dfs(e[i].u,x));
	return res;
}
int main(){
	int n; scanf("%d",&n);
	for(int i=1;i<n;i++){
		int x,y; scanf("%d%d",&x,&y);
		add(x,y); add(y,x);
	}
	if(dfs(1,0)) printf("Alice\n");
	else printf("Bob\n");
}

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

int main() {
  int a, b;
  cin >> a >> b;
  cout << a*b << endl;
  return 0;
}

Measured memory_bytes: 3636
#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);//入力終了

  set<int> ans;

  for(int i=0;i<N;i++){
    if(ans.count(A.at(i))) ans.erase(A.at(i));
    else ans.insert(A.at(i));
  } 

  cout << ans.size() << endl;

  return 0;

}


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

void solve()
{
int n;
cin >> n;
if(n>=30)
cout << "Yes" << endl;
else
{
	cout << "No" << endl;
}

	
	
}

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	
	solve();
	return 0;
}

Measured memory_bytes: 3636
#include<stdio.h>
typedef struct{int Parent,Rank;}UnionFind;
UnionFind uft[200000];
static inline int Root(int x){return(uft[x].Parent!=x)?uft[x].Parent=Root(uft[x].Parent):x;}
static inline int Unite(int x,int y)
{
  x=Root(x),y=Root(y);
  if(x!=y)uft[x].Parent=y,uft[y].Rank+=uft[x].Rank;
  return x!=y;
}
static inline int Size(int x){return uft[Root(x)].Rank;}
static inline int Belong(int x,int y){return Root(x)==Root(y);}
int main(void)
{
  int A,B,N,M,i=0,estrange=0;
  if(!scanf("%d %d",&N,&M))return -1;
  while(i<N){uft[i].Parent=i;uft[i++].Rank=1;}
  while(M--){if(!scanf("%d %d",&A,&B)){return -1;}A--,B--;Unite(A,B);}
  while(N--){estrange=estrange>Size(N-1)?estrange:Size(N-1);}
  return printf("%d\n",estrange),0;
}

Measured memory_bytes: 9440
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using pull = pair<ull, ll>;
using pis = pair<int, string>;
#define INF 1000000000
#define LLINF 10000000000000000ll
#define MOD 1000000007LL

void z_algorithm(string &s, vector<ll>&ans) {
  ans.resize(s.size());
  ans[0] = s.size();
  int i = 1, j = 0;
  while (i < s.size()) {
    while ((i + j < s.size()) && (s[j] == s[i+j])) j++;
    ans[i] = j;
    if (j == 0) {
      i++;
      continue;
    }
    int k = 1;
    while ((i + k < s.size()) && (k + ans[k] < j)) {
      ans[i+k] = ans[k];
      k++;
    }
    i += k; j -= k;
  }
  return;
} 

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  int n;
  string s;
  cin >> n >> s;
  ll ans = 0;
  vector<ll> a;
  for (int i = 0; i < n; i++) {
    string sd = s.substr(i);
    z_algorithm(sd, a);
    ll temp = 0;
    for (int j = 0; j < sd.size(); j++) {
      temp = max(temp, min((ll)j, (ll)a[j]));
    }
    ans = max(ans, temp);
  }
  cout << ans << endl;
}


Measured memory_bytes: 3700
import java.util.*;

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

      if(H%A==0){
		System.out.println(H/A);
    }else{
		System.out.println(H/A+1);
    }
}
}

Measured memory_bytes: 22740
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>

using boost::multiprecision::cpp_int;
using namespace std;

#if __has_include("print.hpp")
  #include "print.hpp"
#endif

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define MOD 1000000007

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

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


int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll a, b, m;
  cin >> a >> b >> m;
  vector<ll> va(a), vb(b);
  rep(i, a) cin >> va[i];
  rep(i, b) cin >> vb[i];
  ll res = LLONG_MAX;
  rep(i, m){
    int x, y, c;
    cin >> x >> y >> c;
    x--;y--;
    res = min(res, va[x]+vb[y]-c);
  }
  sort(ALL(va));
  sort(ALL(vb));
  res = min(res, va[0]+vb[0]);
  cout << res << endl;
}


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

#define REP(i, n) for (ll (i) = 0 ; (i) < (ll)(n) ; ++(i))
#define REPN(i, m, n) for (ll (i) = m ; (i) < (ll)(n) ; ++(i))
#define REP_REV(i, n) for (ll (i) = (ll)(n) - 1 ; (i) >= 0 ; --(i))
#define REPN_REV(i, m, n) for (ll (i) = (ll)(n) - 1 ; (i) >= m ; --(i))

#define INF 2e9
#define INF_LL 1LL<<60
#define ll long long
typedef pair<int, int> P;

int main(){
    ll a, b, ans1, ans2;
    cin >> a >> b;
    if((b+1) % 4 == 0) {
        ans2 = 0;
    } else if((b+1) % 4 == 3) {
        ans2 = b ^ 1;
    } else if((b+1) % 4 == 2) {
        ans2 = 1;
    } else if((b+1) % 4 == 1) {
        ans2 = b;
    }

    if(a % 4 == 0) {
        ans1 = 0;
    } else if(a % 4 == 3) {
        ans1 = (a-1) ^ 1;
    } else if(a % 4 == 2) {
        ans1 = 1;
    } else if(a % 4 == 1) {
        ans1 = (a-1);
    }

    ll ans = ans1 ^ ans2;
    cout << ans << endl;

    return 0;
}



Measured memory_bytes: 256