akhauriyash/Code-Regression huggingface dataset:
#define REP(i,n) for(int i=0; i<(int)(n); i++)

#include <cstdio>
inline int getInt(){ int s; scanf("%d", &s); return s; }

#include <set>
using namespace std;

int a[100][100];

int main(){
  const int m = getInt();
  const int n = getInt();
  REP(i,m) REP(j,n) a[i][j] = getInt();

  int ans = 0;

  REP(i,m){
    int mx = 0;

    REP(j,n){
      int t = 0;
      REP(k,n){
	int now = a[i][k]; if(i) now = !now;
	if(n != 1){
	  if(k != 0 && k != n - 1) now = !now;
	  if(k == j) now = !now;
	}
	t += now;
      }
      // printf("%d %d: %d\n", i, j, t);
      mx = max(mx, t);
    }

    // printf("%d: %d\n", i, mx);
    ans += mx;
  }

  printf("%d\n", ans);

  return 0;
}

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

//46
typedef long long ll;

int main() {
	int n;
	cin >> n;
	vector<int> v(n);
	for (int i = 0; i < n; ++i) {
		cin >> v[i];
	}
	int ans = 0;
	int cnt = 0;
	for (int i = 1; i < n; ++i) {
		if (v[i] <= v[i - 1]) {
			cnt++;
		}else {
			cnt = 0;
		}
		ans = max(ans,cnt);
	}
	cout << ans;
}


Measured memory_bytes: 3784
<?php /*atcoder.php*/

$at = new Atcoder();
$at->main();
unset($at);

class Atcoder{
	private function arrayIn(){
		$buf = explode(" ", fgets(STDIN));
		return $this->killNewLine($buf);
	}
	private function killNewLine($buf = null){
		$buf = str_replace("\r\n", "", $buf);
		$buf = str_replace("\n", "", $buf);
		$buf = str_replace("\r", "", $buf);
		return $buf;
	}

	public function main(){
		$s = $this->arrayIn();
	
		$n = $s[0];
		$t = $s[1];

		$c = array();
		for($i = 0; $i < $n; $i++){
			$c[] = $this->arrayIn();
		}
		
		sort($c);

		foreach($c as $v){
			if($t >= $v[1]){
				echo $v[0] . "\n";
				return true;
			}else{
				continue;
			}
		}
		unset($v);

		echo "TLE\n";

	}
}
?>

Measured memory_bytes: 4856
#include <cstdio>
#include <cstdlib>
#include <cstdint>
#include <cstring>
#include <cctype>
#include <iostream>
#include <sstream>
#include <vector>
#include <list>
#include <deque>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <functional>
#include <complex>
using namespace std;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef long long ll;
const double PI = 3.141592653589793238462643383279502884L;
const int LARGE_PRIME = 1000000007;
#define all(c) (c).begin(), (c).end()
#define rall(c) (c).rbegin(), (c).rend()
#define tr(c, i) for(auto i = (c).begin(); i != (c).end(); i++)
#define rtr(c, i) for(auto i = (c).rbegin(); i != (c).rend(); i++)
#define repfn(i,a,cont,next) \
  for(auto i = (a); [=](){return(cont);}(); i = [=](){return(next);}())
#define repby(i,a,b,s) repfn(i,a,i<b,i+s)
#define repab(i,a,b) repby(i,a,b,1)
#define rep(i,b) repab(i,0,b)
#define pb push_back
#define sz(c) int((c).size())

double find_floor(double v)
{
  double t = v / 9.8;
  double y = 4.9 * t * t;
  return ceil(y/5)+1;
}

int main(int argc, char **argv)
{
  double v;
  while (cin >> v) {
    cout << find_floor(v) << endl;
  }
  return 0;
}

Measured memory_bytes: 1280
import sys
inputs = sys.stdin.readlines()
n = int(inputs[0])
p = [int(x) for x in inputs[1].split(' ')]

counter = 0
for i in range(1, n-1):
    if p[i-1] < p[i] <= p[i+1] or p[i+1] < p[i] <= p[i-1]:
        counter += 1

print(counter)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define INF 1e18
#define int long long
#define Rep(i, a, n) for (int i = (a); i < (n); i++)
#define rep(i, n) Rep(i, 0, n)
#define all(a) (a).begin(), (a).end()
using namespace std;
typedef pair<int, int> P;
typedef pair<int, P> PP;
const int mod = 1000000007;
//const int mod = 998244353;

int digit(int x)
{
    int res = 0;
    while (x > 0)
    {
        res++;
        x /= 10;
    }
    return res;
}

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

    int n;
    cin >> n;
    int ans = INF;
    for (int i = 1; i * i <= n; i++)
    {
        if (n % i != 0)
            continue;
        int f = max(digit(i), digit(n / i));
        ans = min(ans, f);
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
N = int(input())
As = list(map(int, input().split(" ")))

IDs = range(1, len(As)+1)
result_dict = dict(zip(IDs,As))
result_dict = sorted(result_dict.items(), key=lambda x:x[1])
result_list = list(map(lambda x: str(x[0]), result_dict))
result = " ".join(result_list)
print(result)


Measured memory_bytes: 25536
#include<stdio.h>
#include<stdlib.h>
#include<string.h>

#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define MIN(a, b) ((a) < (b) ? (a) : (b))

int main(void){
	int a, b;
	scanf("%d%d",&a ,&b);
	if(MAX(a,b) >= 10)
		printf("-1");
	else
		printf("%d",a*b);
    return 0; 
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#define INF 0x3f3f3f3f
using namespace std;

void run() {
    int x, n;
    cin >> x >> n;
    vector<bool> has(102);
    for (int i = 0; i <n; i++) {
        int t;
        cin >> t;
        has[t] = true;
    }
    for (int d = 0;; d++) {
        int l = x - d, r = x + d;
        if (l < 0 || !has[l]) {
            cout << l << '\n';
            return;
        }
        if (!has[r]) {
            cout << r <<'\n';
            return;
        }
    }
}

int main() {
    ios::sync_with_stdio(0); cin.tie(0);
    run();
    return 0;
}


Measured memory_bytes: 3620
#include <stdio.h>

int main(){
  int k, a, b;
  scanf("%d\n%d%d", &k, &a, &b);
  if(a % k == 0) puts("OK");
  else{
    if(a / k != b / k) puts("OK");
    else puts("NG");
  }
  return 0;
}

Measured memory_bytes: 1632
#include <iostream>
#include <vector>
#include <cstring>
using namespace std;

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

void dfs( int x, int y ){
	field[y][x] = 0;
	for( int i=0; i<4; i++ ){
		for( int j=1; j<=3; j++ ){
			int nx = x+dx[i]*j;
			int ny = y+dy[i]*j;
			if( nx < 0 || 8 <= nx || ny < 0 || 8 <= ny ) continue;
			if( field[ny][nx] == 1 ){
				dfs( nx, ny );
				break;
			}
		}
	}
	return;
}

int main(){
	int n;
	cin >> n;
	for( int a=0; a<n; a++ ){
		for( int i=0; i<8; i++ ){
			string line;
			cin >> line;
			for( int j=0; j<line.size(); j++ ){
				field[i][j] = (int)(line[j]-'0');
			}
		}
		int sx, sy;
		cin >> sx >> sy;
		cout << "Data " << a+1 << ":" << endl;
		dfs( sx-1, sy-1 );
		for( int i=0; i<8; i++ ){
			for( int j=0; j<8; j++ ){
				cout << field[i][j];
			}
			cout << endl;
		}
	}
}

Measured memory_bytes: 1208
# -*- coding: utf-8 -*-
from collections import Counter, defaultdict


import sys
# sys.setrecursionlimit(10**6)
readline = sys.stdin.buffer.readline
# readline = sys.stdin.readline

INF = 1 << 60


def read_int():
    return int(readline())


def read_int_n():
    return list(map(int, readline().split()))


def read_float():
    return float(readline())


def read_float_n():
    return list(map(float, readline().split()))


def read_str():
    return readline().strip()


def read_str_n():
    return readline().strip().split()


def ep(*args):
    print(*args, file=sys.stderr)


def mt(f):
    import time

    def wrap(*args, **kwargs):
        s = time.perf_counter()
        ret = f(*args, **kwargs)
        e = time.perf_counter()

        ep(e - s, 'sec')
        return ret

    return wrap


@mt
def slv(N, A):
    g = defaultdict(list)
    rg = Counter()

    V = set()

    def ij2v(i, j):
        if i > j:
            i, j = j, i
        return i * 10**6 + j
    for i, a in enumerate(A, start=1):
        for j in range(len(a)-1):
            u = ij2v(i, a[j])
            v = ij2v(i, a[j+1])
            g[u].append(v)
            rg[v] += 1
            V.add(u)
            V.add(v)

    s = []
    for v in V:
        if not rg[v]:
            s.append(v)

    done = len(s)
    ans = 0
    while s:
        ans += 1
        ns = []
        for u in s:
            for v in g[u]:
                rg[v] -= 1
                if rg[v] == 0:
                    ns.append(v)
                    done += 1
        s = ns

    if done != N * (N-1) // 2:
        return -1

    return ans



def main():
    N = read_int()
    A = [read_int_n() for _ in range(N)]
    print(slv(N, A))


if __name__ == '__main__':
    main()


Measured memory_bytes: 248372
#include<bits/stdc++.h>
using namespace std;
#define LOCAL 0
#define lli long long int
const lli mod=(lli)(1e9 + 7);
const lli pINF=(lli)(1e15);
const lli nINF=-LLONG_MAX;
void fast() {std::ios::sync_with_stdio(false);cin.tie(NULL);}
lli power(lli a,lli b){lli ans=1;while(b!=0){ if(b%2==1){ans*=a;}b/=2;a*=a;} return ans;}
lli invmod(lli a) {return pow(a,mod-2);}
#define vi vector<int>
#define vlli vector<lli>
#define pb push_back
#define mp make_pair
#define F first
#define S second
const int INT=1000000000;
const int INF=0x3f3f3f3f;
#define PII pair<int,int>
#define si(n) scanf("%d",&n)
#define sli(n) scanf("%lld",&n)
#define printi(n) printf("%d\n",n)
#define ld long double
#define printli(n) printf("%lld\n",n)
#define all(v) v.begin(),v.end()
#define forn(i,n) for(int i=0;i<n;i++)
void print(int a[],int n){for(int i=0;i<n;i++) cout<<a[i]<<" ";}
#define MAX 1000000000

int main() 
{
    int n;
    si(n);
    int ans=n;
    
    for(int i=0;i<=n;i++){
        int f=i;
        int ct=0;
        while(f){
            ct+=(f%6);
            f/=6;
        }
        
        int s=n-i;
        
        while(s){
            ct+=(s%9);
            s/=9;
        }
        
        ans=min(ans,ct);
    }
    
    cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
// inputに入力データ全体が入る
function Main(input) {
	// 1行目がinput[0], 2行目がinput[1], …に入る
	input = input.split("\n");
	A1 = input[1].split(" ");
  	B1 = input[2].split(" ");
	//文字列から10進数に変換するときはparseIntを使います
	var N = parseInt(input[0], 10);
  	var i = 0;
  	var aCount = 0;
  	var j = 0;
  	while(i < N){
      	var A = parseInt(A1[i]);
      	var B = parseInt(B1[i]);
      	aCount = aCount + Math.min(A, j + B);
      	if(B > (A - j)){
        	j = B - Math.max(A - j, 0);
        }else{
        	j = 0;
        }
    	i = i + 1; 
    }
	var A = parseInt(A1[i]);
  	aCount = aCount + Math.min(A, j);

	console.log('%d',aCount);
}
//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 30948
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <list>
#include <vector>
#include <queue>
#include <algorithm>
#include <climits>
#include <cstring>
#include <cmath>
#include <stack>
#include <iomanip>
#include <tuple>
#include <functional>

#define int long long
#define CONTAINS(v,n) (find((v).begin(), (v).end(), (n)) != (v).end())
#define SORT(v) sort((v).begin(), (v).end())
#define RSORT(v) sort((v).rbegin(), (v).rend())
#define ARY_SORT(a, size) sort((a), (a)+(size))
#define MAX(a,b) (((a) > (b)) ? (a) : (b))
#define MIN(a,b) (((a) < (b)) ? (a) : (b))
#define REMOVE(v,a) v.erase(remove(v.begin(), v.end(), a), v.end())
#define REP(i, n) for (int (i) = 0; (i) < (n); (i)++)
using namespace std;

int gcd(int x, int y) //最大公約数
{
	int r;
	while ((r = x % y) != 0)
	{
		x = y;
		y = r;
	}
	return y;
}

int lcm(int x, int y) //最小公倍数
{
	return (x / gcd(x, y) * y);
}

signed main()
{
	int N;
	cin >> N;
	int ans = 0;
	cin >> ans;
	REP(i, N - 1)
	{
		int a;
		cin >> a;
		ans = lcm(ans, a);
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>
#include <cmath>
#include <algorithm>
#include <string>
#define shosu(x) fixed<<setprecision(x)
using namespace std;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,P> pip;
const int inf=(1<<31)-1;

int n,m;
vvi date;

int func(int x){
	int an=1;
	for(int i=0;i<x;i++) an*=3;
	return an;
}

int main(){
	while(1){
		cin>>n>>m;
		if(!n&&!m) break;
		int lef=0,rig=0;
		date=vvi(3);
		for(int i=0;i<3;i++){
			int tn;
			cin>>tn;
			for(int j=0;j<tn;j++){
				int tmp;
				cin>>tmp;
				date[i].push_back(tmp);
			}
		}
		for(int  i=0;i<3;i+=2){
			int now=i;
			for(int j=1;j<=n;j++){
				int tmp1;
				for(int k=0;k<3;k++){
					bool q=1;
					for(int r=0;r<date[k].size();r++){
						if(j==date[k][r]){
							tmp1=k;
							q=0;
							break;
						}
						if(j<date[k][r]) break;
					}
					if(!q) break;
				}
				int t=abs(now-tmp1);
				if(!t) continue;
				if(i==0){
					lef+=t*func(n-j);
					if(lef>m) break;
				}
				else{
					rig+=t*func(n-j);
					if(rig>m) break;
				}
				for(int k=0;k<t;k++){
					if(now==0) now=2;
					else now=0;
				}
			}
		}
		int ans=min(lef,rig);
		if(ans>m) cout<<-1<<endl;
		else cout<<ans<<endl;
	}
}

Measured memory_bytes: 1216
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<ll,ll> mp;
#define inf 1e9
int dx[] = { 1 ,0,-1,0};
int dy[] = { 0, 1,0,-1};

int n,m;
bool dfs(int x,int y,vector<vector<bool> > &used,int d, int cnt){
 //   cout<<x<<' '<<y<<endl;
    if( x== 1 && y == 1 &&cnt==3) return true;
    //if( !used[x][y] )return  false;
    //used[x][y] = false;
    if( x== 1 && y== m ) cnt++;
    if( x== n && y== 1 ) cnt++;
    if( x== n && y== m ) cnt++;
    //if( cnt == 3 ) return true;
    for(int i=0;i<4;i++){
    	int nd =  ( d + 3 + i) % 4;
    	int nx = x + dx[nd];
    	int ny = y + dy[nd];
    	//if( nx == 1 && ny == 1 && cnt == 3) return true;
    	if(used[nx][ny]){
	    used[nx][ny] = false;
	    if( dfs(nx,ny,used,nd,cnt) ) return true;
    	}
    }
    return false;
}

int main(){
    while(1){
	cin>>n>>m;
	if(n==0)break;
	vector<vector<bool> > used(n+2,vector<bool>(m+2,false) );
	for(int i=1;i<=n;i++){
	    for(int j=1;j<=m;j++){
		char tmp;
		cin>>tmp;
		if(tmp=='.'){
		    used[i][j] = true;
		}
	    }
    	}
	if(dfs(1,1,used,0,0) ) cout<<"YES"<<endl;
	else cout<<"NO"<<endl;
    }
    return 0;
}



Measured memory_bytes: 3168
import "dart:io";

int gcd(int a, int b) {
  var temp = 0;
  var rem = 0;
  if (a < b) {
    temp = a;
    a = b;
    b = temp;
  }
  while (b > 0) {
    rem = a % b;
    if (rem == 0) {
      break;
    }
    a = b;
    b = rem;
  }
  return (b);
}

void main() {
  var k = int.parse(stdin.readLineSync()); 
  var sum = 0;
  for (int l = 0; l <= k; l++) {
    for (int m = 0; m <= k; m++) {
      for (int n = 0; n <= k; n++) {
        sum += gcd(gcd(l, m), n);
      }
    }
  }
  print(sum);
}

Measured memory_bytes: 13152
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; i++)
using namespace std;
using ll = long long;
int INF = 1000000009;
int main()
{
  int k;
  cin >> k;
  ll ans = 0;
  vector<int> dp;
  for (int a = 1; a <= k; a++)
  {
    for (int b = 1;b<=k;b++){
      dp.push_back(__gcd(b, a));
    }
  }
  for (int i = 1; i <= k;i++){
    for (int j = 0; j < k * k;j++){
      ans += __gcd(dp[j], i);
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 3752
#include <iostream>
#include <string>
#include <algorithm>
#include <set>
#include <map>
#include <vector>
#include <queue>
#include <stack>
#include <math.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);i++)

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

    int ans = a;
    int num = 1;
    if(b == 1){
        cout << 0 << endl;
        return 0;
    }
    while(1){
        if(ans >= b){
            break;
        }
        ans += a-1;
        num++;
    }
    cout << num << endl;
    return 0;
}

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

int main()
{
    int a,b,d,i;
    char c;

    while(i <= 1000)
    {
        cin >> a >> c >> b ;
        if (c == '+') d = a+b;
        else if (c == '-') d = a-b;
        else if (c == '*') d = a*b;
        else if (c == '/') d = a/b;
        else if (c == '?') break;
        cout << d << endl;
        i++;
    }
    return 0;
}

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
#define rrep(i,n) for(int i=1;i<(n);++i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int inf = 1001001001;
const int mod = 1000000007;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	string s;
	cin >> s;
	int n = s.size();
	int ans = 0;
	rep(i, n) {
		if (i == 0) continue;
		if (i % 2 != 0) continue;
		if (s.substr(0, (n - i) / 2) == s.substr((n - i) / 2, (n - i) / 2)) {
			ans = max(ans, n - i);
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pb push_back
int N = 2e5 + 5;

void solve_test_case(){
	ll n,x,t;
	cin>>n>>x>>t;
	ll d = n/x;
	if(n > x)
		cout<<(d * t + (t * (n % x != 0)))<<"\n";
	else{
		cout<<t<<"\n";
	}
}
signed main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	int t = 1;
	//cin>>t;
	for(int i = 1;i <= t;++i){
		solve_test_case();
	}
}


Measured memory_bytes: 3552
//By Zank100
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ull unsigned long long
#define mod 1000000007
#define din(t) long long t;cin>>t;
#define in(t) cin>>t;
int main() 
{
	ios_base::sync_with_stdio(false); cin.tie(NULL);
	din(n);din(m);
	ll ans=((n*(n-1))/2) + ((m*(m-1))/2);
	cout<<ans<<endl;
	
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <functional>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <bitset>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef pair<int,int> P;
#define rep(i,a,n) for(ll i = (a);i < (n);i++)
#define per(i,a,n) for(ll i = (a);i > (n);i--)
#define lep(i,a,n) for(ll i = (a);i <= (n);i++)
#define pel(i,a,n) for(ll i = (a);i >= (n);i--)
#define clr(a,b) memset((a),(b),sizeof(a))
#define pb push_back
#define mp make_pair
#define all(c) (c).begin(),(c).end()
#define sz size()
#define print(X) cout << (X) << endl
const int INF = 1e+8+7;
ll n,m,l;
string s,t;
int d[100],dp1[500][500],dp2[500][500];
char field[100][100];

int main(){
  cin >> n >> m >> l;
  if(m-n == l-m)puts("YES");
  else puts("NO");
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define lvector vector<ll>
#define cvector vector<char>
#define svector vector<string>
#define lque queue<ll>
#define lpque priority_queue<ll>
#define dlpque priority_queue<ll,lvector,greater<ll>>
#define P pair<ll,ll>
#define ALL(a) a.begin(),a.end()
#define RALL(a) a.rbegin(),a.rend()
#define rep(i,n) for(ll i=0; i<n; ++i)
#define print(a) cout << (a) << endl

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll x,n,ans=1e9,pos=0;cin>>x>>n;
  lvector v(n);rep(i,n) cin>>v[i];
  sort(ALL(v));
  if(n==0) ans=x;
  else {
    for(ll i=0;i<=101;++i) {
      if(i==v[pos]) {
        pos++;
        continue;
      }
      if(abs(x-i)<abs(x-ans)) ans=i;
    }
  }
  print(ans);
  return 0;
}

Measured memory_bytes: 3656
#include <iostream>
#include <string>
#include <cstring>
#include <fstream>
#include <cmath>
#include <iomanip>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <map>
#include <deque>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <list>
#include <unordered_map>
#include <bitset>
#include <sstream>

typedef  long long ll;
#define mop 1000000007
using namespace std;

static const ll MAX = 3000;
long double dp[MAX][MAX] = {};

int main() {
    

    ll n;
    cin >> n;
    dp[0][0] = 1;
    for (ll i=1;i<=n;i++){
        long double p;
        cin >> p;
        for (ll j=0;j<=i;j++){
            if(j==0){
                dp[i][j] = dp[i-1][j] * (1-p);
            }else if(j==i){
                dp[i][j] = dp[i-1][j-1] * p;
            }else{
                dp[i][j] = dp[i-1][j] * (1-p) + dp[i-1][j-1] * p;
            }
        }
    }
    long double ans = 0;
    for (ll i=n/2+1;i<=n;i++){
        ans += dp[n][i];
    }
    cout << fixed;
    cout << setprecision(10);
    cout << ans << endl;

}


Measured memory_bytes: 139008
# pragma GCC optimize("O3")
# include <bits/stdc++.h>
std::pair<int,int> DR[] = {{-1,0},{0,1},{1,0},{0,-1},{-1,1},{-1,-1},{1,1},{1,-1}};
# define ll long long
# define clock (clock() * 1000.0 / CLOCKS_PER_SEC)
# define rc(s) return cout << s,0
# define _ ios_base::sync_with_stdio(false);cin.tie(0);cerr.tie(0);cout.tie(0);
# define db(x) cerr << #x << " = " << x << '\n'
# define pb push_back
# define mp make_pair
# define all(s) s.begin(),s.end()
# define sz(x) (int)((x).size())
# define int ll
using namespace std;

int ans;
int viz[1 << 17];
vector<multiset<int>>f;
vector<int>vec[1 << 17];
int x,y,m;
int cnt;
int a[1 << 17];
int n;

void dfs(int nod)
{
    viz[nod] = 1;
    for(auto it : vec[nod])
    {
        if(!viz[it]) dfs(it);
    }
    f[cnt].insert(a[nod]);
}

int32_t main(){_
    //freopen("input","r",stdin);
    cin >> n >> m;
    for(int i = 1;i <= n;i++) cin >> a[i];
    for(int i = 1;i <= m;i++)
    {
        cin >> x >> y;
        x++;
        y++;
        vec[x].pb(y);
        vec[y].pb(x);
    }
    for(int i = 1;i <= n;i++)
    {
        if(!viz[i]){
            multiset<int>rudi;
            f.pb(rudi);
            dfs(i);
            cnt++;
        }
    }
    sort(f.begin(),f.end(),[](multiset<int>a,multiset<int>b){return sz(a) > sz(b);});
    for(int i = 1;i < cnt;i++)
    {
        if(!sz(f[0])) rc("Impossible");
        ans += *(f[0].begin()) + *(f[i].begin());
        f[0].erase(f[0].begin());
        f[i].erase(f[i].begin());
        for(auto it : f[i]) f[0].insert(it);
    }
    rc(ans);
}

Measured memory_bytes: 17920
#include<iostream>
#include<algorithm>
#include<bits/stdc++.h>
using namespace std;
int main () {
    int   n;
    cin>>n;
    double s;
   // double p=n;
      if (n%2==0) s=0.5;
      else {s=(n+1)/((double)2*n);}
      //cout<<s<<endl;
      cout<<fixed<< setprecision(10) << s<<endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cassert>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
using namespace std;
typedef long long ll;

#define rep(i, n) for(ll i = 0; i < n; i++)
#define REP(i, n) for(ll i = 1; i < n + 1; i++)
#define PI 3.14159265359
#define EPS 0.0000000001
#define MOD 1000000007
//cout << std::fixed << std::setprecision(15) << y << endl;


int main(){
    ll N, M;
    cin >> N >> M;

    ll a[N + 1], b[N + 1];
    ll c[M + 1], d[M + 1];
    REP(i, N){
        cin >> a[i] >> b[i];
    }
    REP(i, M){
        cin >> c[i] >> d[i];
    }

    ll dist;
    ll closest;
    REP(i, N){
        dist = 500000000;
        closest = 0;
        REP(j, M){
            if(dist > abs(c[j] - a[i]) + abs(d[j] - b[i])){
                dist = abs(c[j] - a[i]) + abs(d[j] - b[i]);
                closest = j;
            }
        }
        cout << closest << endl;
    }

    return 0;
}

Measured memory_bytes: 3620
fun main(args: Array<String>) {
    val n = readLine()!!.toInt()
    val xs = readLine()!!.split(' ').map { it.toInt() }

    val l = IntArray(n)
    val r = IntArray(n)

    for (i in (0 until n)) {
        l[i] = if (i == 0) {
            gcd(xs[0], 0)
        } else {
            gcd(xs[i], l[i - 1])
        }
    }

    for (i in (n - 1 downTo 0)) {
        r[i] = if (i == n - 1) {
            gcd(xs[i], 0)
        } else {
            gcd(xs[i], r[i + 1])
        }
    }

    var ans = 0

    for (i in (0 until n)) {
        val d = when (i) {
            0 -> r[i + 1]
            n - 1 -> l[i - 1]
            else -> gcd(l[i - 1], r[i + 1])
        }
        ans = Math.max(ans, d)
    }

    println(ans)
}

private fun gcd(a: Int, b: Int): Int {
    if (b == 0) return a
    return gcd(b, a % b)
}


Measured memory_bytes: 61732
import java.util.*;

public class Main {

    static int gcd (int a, int b) {return b>0?gcd(b,a%b):a;}
    static long mod = 1000000007;

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int[] A = new int[N];
        long money = 1000;
        long stock = 0;
        boolean haveStock = false;

        for(int i=0;i<N;i++){
            A[i] = sc.nextInt();
        }

        for(int i=0;i<N-1;i++){
            if(A[i] < A[i+1]){
                stock += money / A[i];
                money = money % A[i];
            }

            if(A[i] > A[i+1]){
                money += stock * A[i];
                stock = 0;
            }
        }
        System.out.println(money + (stock * A[N-1]));


    }

}




Measured memory_bytes: 35836
import sys
sys.setrecursionlimit(2147483647)
INF=float("inf")
MOD=10**9+7
input=lambda :sys.stdin.readline().rstrip()
def resolve():
    from math import factorial
    n,m=map(int,input().split())
    if abs(n-m)>1:
        print(0)
    elif abs(n-m)==1:
        print(factorial(n)%MOD*factorial(m)%MOD)
    else:
        print(2*factorial(n)%MOD*factorial(m)%MOD)
resolve()

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

int main(){
	int N,M;
	cin>>N>>M;
	int a,b;
	int Count[N+1];
	memset(Count,0,sizeof(Count));
	for(int i=0;i<M;i++){
		cin>>a>>b;
		Count[a]++;
		Count[b]++;
	}
	for(int i=1;i<=N;i++){
		cout<<Count[i]<<endl;
	}
	return 0;
}

Measured memory_bytes: 256
s = input()

aa = int(s[0])*10 + int(s[1])
bb = int(s[2])*10 + int(s[3])

if 1 <= aa <= 12 and 1 <= bb <= 12 :
    print("AMBIGUOUS")
elif 1 <= aa <= 12 and bb == 0 :
    print("MMYY")
elif 1 <= aa <= 12 and 13 <= bb :
    print("MMYY")
elif aa == 0 and 1<= bb <= 12 :
    print("YYMM")
elif 13<=aa and 1<=bb<=12 :
    print("YYMM")
else :
    print("NA")


Measured memory_bytes: 9084
#include <bits/stdc++.h>
 
int ctoi(char c) {
	switch (c) {
    case '0': return 0;
    case '1': return 1;
    case '2': return 2;
    case '3': return 3;
    case '4': return 4;
    case '5': return 5;
    case '6': return 6;
    case '7': return 7;
    case '8': return 8;
    case '9': return 9;
    default: return 0;
	}
}

int main() {   
    int N;
    std::cin >> N;

    const int x = ctoi(std::to_string(N).back());
    const std::string ret =
        x == 2 || x == 4 || x == 5 || x == 7 || x == 9 ? "hon" :
        x == 0 || x == 1 || x == 6 || x == 8 ? "pon":
        "bon";
    
    std::cout << ret << std::endl;
}


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

typedef long long ll;
#define REP(i,n) for(int i=0,_n=(int)(n);i<_n;++i)
#define ALL(v) (v).begin(),(v).end()
#define CLR(t,v) memset(t,(v),sizeof(t))
template<class T1,class T2>ostream& operator<<(ostream& os,const pair<T1,T2>&a){return os<<"("<<a.first<<","<<a.second<< ")";}
template<class T>void pv(T a,T b){for(T i=a;i!=b;++i)cout<<(*i)<<" ";cout<<endl;}
template<class T>void chmin(T&a,const T&b){if(a>b)a=b;}
template<class T>void chmax(T&a,const T&b){if(a<b)a=b;}

int nextInt() {
  int x; scanf("%d", &x); return x;
}

const ll MOD = (ll)(1e9 + 7);
const int SZ = 312345;
ll inv[SZ];
ll fact[SZ];
ll fact_inv[SZ];
ll choose(int n, int r) {
  if (n < 0 || r < 0 || n < r) return 0;
  return fact[n] * fact_inv[n-r] % MOD * fact_inv[r] % MOD;
}

// (r1, c1) -> (r2, c2)
ll ways(int r1, int c1, int r2, int c2) {
  int r = r2 - r1;
  int c = c2 - c1;
  if (r < 0 || c < 0) return 0;
  return choose(r+c, r);
}

typedef pair<int,int> P;
const int MAX_N = 3005;
P ps[MAX_N];
ll dp[MAX_N];

int main2() {
  int H = nextInt() - 1;
  int W = nextInt() - 1;
  int N = nextInt();
  REP(i, N) {
    int r = nextInt() - 1;
    int c = nextInt() - 1;
    ps[i] = {r, c};
  }
  ps[N] = {H, W};
  sort(ps, ps + N);

  CLR(dp, 0);
  REP(i, N+1) {
    ll here = ways(0, 0, ps[i].first, ps[i].second);
    for (int j = 0; j < i; j++) {
      here -= dp[j] * ways(ps[j].first, ps[j].second, ps[i].first, ps[i].second);
      here %= MOD;
    }
    dp[i] = here;
  }
  ll ans = dp[N];
  ans = (ans % MOD + MOD) % MOD;
  cout << ans << endl;
  return 0;
}

int main() {

  inv[1] = 1;
  for (int i = 2; i < SZ; i++) inv[i] = inv[(int) (MOD % i)] * (MOD - MOD / i) % MOD;
  fact[0] = 1;
  for (int i = 1; i < SZ; i++) fact[i] = fact[i-1] * i % MOD;
  fact_inv[0] = 1;
  for (int i = 1; i < SZ; i++) fact_inv[i] = fact_inv[i-1] * inv[i] % MOD;

  for (;!cin.eof();cin>>ws)
    main2();

  return 0;
}

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

int main() {
  int N,a[200000],i;
  long long step=0;
  cin>>N>>a[0];
  for (i=1;i<N;i++) {
    cin>>a[i];
    if (a[i] < a[i-1]) {
      step += (a[i-1] - a[i]);
      a[i] = a[i-1];
    }
  }
  cout<<step<<endl;
  return 0;
}


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

using namespace std;

using ll = long long;

int main(){
   string s;
   cin >> s;
   ll start = 0, end = s.length() - 1, x = 0;
   while(start < end){
        if(s[start] == s[end]){
            start++;
            end--;
        }
        else if(s[start] == 'x'){
            start++;
            x++;
        }
        else if(s[end] == 'x'){
            end--;
            x++;
        }else{
            cout << -1;
            return 0;
        }
   }
   cout << x;
   return 0;
}


Measured memory_bytes: 512
#include<iostream>
#include<algorithm>
#include<climits>
#include<vector>
#include<utility>
#include<cmath>
#include<cstring>
#include<map>
#include<sstream>
 
using namespace std;

int A[32] = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};

int K = 0;

int main(){
    cin>>K;
  
  cout<<A[K-1];

}


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

int main() {
  int N,M,S;
  M =0;
  cin >> N;
  S = N -1;
  vector<int>P(N);
  for(int i = 0;i < N;i++) cin >> P[i];
  sort(P.begin(), P.end());
  P[S] /= 2;
  for(int i = 0;i < N;i++) M += P[i];
  cout << M <<endl;
}

Measured memory_bytes: 3572
/*
I believe on myself and I will achieve
this->author = Fuad Ashraful Mehmet, CSE-UAP
Todo:
https://codeforces.com/contest/1398/problem/E
https://codeforces.com/problemset/problem/374/C
*/
#include<bits/stdc++.h>
#define forn(i,n) for(int i=0;i<(int)n;++i)
#define all(o) (o).begin(),(o).end()
#define dbg(o)  cerr<<"at "<<__LINE__<<" response = "<<o<<endl;
#define pb push_back
using namespace std;

const int N=2e5+5;
int n,k,m;
#define ll long long
ll a[N];
ll pref[N];

const ll mod=1e9+7;

void HalfDead()
{
      cin>>n;
      for(int i=1;i<=n;++i)
      {
            cin>>a[i];
      }

      for(int i=1;i<=n;++i)
      {
            pref[i]=pref[i-1]+a[i];
            pref[i]%=mod;
      }


      ll res=0;

      for(int i=1;i<=n;++i)
      {
            ll sum=pref[i-1];
            res+=(sum*a[i]);
            res%=mod;
      }

      cout<<res<<endl;
}
int main()
{
      ios_base::sync_with_stdio(0); cin.tie(nullptr);  cout.tie(0);
      int tc=1;
     // cin>>tc;
      while(tc--)
      {
            HalfDead();
      }
      return 0;
}

Measured memory_bytes: 6656
MAX = 600000
MOD = 998244353
fac = [0] * MAX
ifac = [0] * MAX
fac[0] = 1
for i in range(1,MAX):
    fac[i] = (fac[i-1] * i) % MOD
ifac[MAX-1] = pow(fac[MAX-1],MOD-2,MOD)
for i in reversed(range(1,MAX)):
    ifac[i-1] = (ifac[i] * i) % MOD

def combinations(n, k):
    if k < 0 or n < k:
        return 0
    else:
        return (fac[n] * ifac[k] * ifac[n-k]) % MOD
n, m, k = map(int ,input().split())
ans = 0
color = m
for i in reversed(range(n)):
    val = color
    val *= combinations(n-1,i)
    val %= MOD
    if i <= k:
        ans += val
        ans %= MOD
    color *= (m-1)
    color %= MOD
print(ans)


Measured memory_bytes: 80024
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
#include <queue>
#include <stack>
#include <cstdlib>
#include <map>
#include <iomanip>
#include <set>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define pie 3.141592653589793238462643383279
#define int long long
#define mod 1000000007
#define INF 1145141919364364
#define all(vec) vec.begin(),vec.end()
#define P pair<int,int>
#define S second
#define F first
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x%y);
}
int lcm(int x, int y) {
	return x / gcd(x, y)*y;
}
bool prime(int x) {
	for (int i = 2; i <= sqrt(x); i++) {
		if (x%i == 0)return false;
	}
	return true;
}

int kai(int x) {
	if (x == 0)return 1;
	return kai(x - 1)*x%mod;
}

int mod_pow(int x, int y, int mood) {
	int res = 1;
	while (y > 0) {
		if (y & 1)res = res * x%mood;
		x = x * x%mood;
		y >>= 1;
	}
	return res;
}

int comb(int x, int y) {
	return kai(x)* mod_pow(kai(x - y), mod - 2, mod) % mod * mod_pow(kai(y), mod - 2, mod) % mod;
}

int h, w;
char a;
int cnt[30];

signed main() {
	cin >> h >> w;
	for (int i = 0; i < h; i++) {
		for (int j = 0; j < w; j++) {
			cin >> a;
			cnt[a - 'a']++;
		}
	}
	if (h % 2 == 0 && w % 2 == 0) {
		for (int i = 0; i < 30; i++) {
			if (cnt[i] % 4) {
				cout << "No" << endl;
				return 0;
			}
		}
		cout << "Yes" << endl;
	}
	else if (h % 2 && w % 2) {
		int cnt1 = 0, cnt2 = 0;
		for (int i = 0; i < 30; i++) {
			if (cnt[i] % 4 == 3) {
				cout << "No" << endl;
				return 0;
			}
			else if (cnt[i] % 2)cnt1++;
			else if (cnt[i] % 4)cnt2++;
		}
		if (cnt1 > 1 || cnt2 > h / 2 + w / 2)cout << "No" << endl;
		else cout << "Yes" << endl;
	}
	else {
		if (h % 2)swap(h, w);
		int cnt2 = 0;
		for (int i = 0; i < 30; i++) {
			if (cnt[i] % 2) {
				cout << "No" << endl;
				return 0;
			}
			else if (cnt[i] % 4)cnt2++;
		}
		if (cnt2 > h / 2)cout << "No" << endl;
		else cout << "Yes" << endl;
	}
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <set>
#include <algorithm>
#include <math.h>
#include <string.h>
#include <map>
#include <numeric>
#include <random>
#include <queue>
#include <deque>
#include <tuple>
#include <iomanip>

using namespace std;

const int MOD = 1000000007;
typedef long long ll;

int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  int N,K;
  cin>>N>>K;
  vector<int> V(N);
  for(int i=0;i<N;i++){
    cin>>V[i];
  }
  int ans=0;
  for(int k=0;k<=min(K,N);k++){
    for(int i=0;i<=k;i++){
      vector<int> hand;
      for(int left=0;left<i;left++){
        hand.push_back(V[left]);
      }
      for(int right=0;right<k-i;right++){
        hand.push_back(V[N-1-right]);
      }
      int max_count=K-k;
      int tmp=0;
      sort(hand.begin(),hand.end());
      for(int j=0;j<hand.size();j++){
        if(hand[j]<0 && j<max_count){
          true;
        }else{
          tmp+=hand[j];
        }
      }
      ans=max(ans,tmp);
    }
  }
  cout<<ans<<endl;

}


Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#include <math.h>
#include <stdlib.h>
#define MAX(a,b) ((a)>(b)?(a):(b))
typedef long long ll;
int main(void) {
   int n;
   scanf("%d", &n);
   int *L = (int *)malloc((n+1) * sizeof(int));
   ll **dp = (ll **)malloc((n+2) * sizeof(ll *));
   for (int i = 0; i < n+2; i++) {
      dp[i] = (ll *)malloc(sizeof(ll) * 2);
   }
   for (int i = 0; i < n; i++) {
      scanf("%d", &L[i]);
   }
   L[n+1] = 0; 
   dp[0][0] = L[0];
   dp[0][1] = -L[0];
   for (int i = 0; i < n; i++) {
      dp[i+1][0] = MAX(dp[i][0]+L[i+1],dp[i][1]-L[i+1]);
      dp[i+1][1] = MAX(dp[i][0]-L[i+1],dp[i][1]+L[i+1]);
   }
   printf("%lld\n",dp[n-1][0]);
}


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

int main(){
  int w , Q;
  int a[101];

  while(1) {
  cin >> w >> Q;
  if(w == 0 && Q == 0) break;

  for(int i=0;i<w;i++) a[i] = -1;

  for(int q=0;q<Q;q++) {
    string sta;
    int neko,haba;
    cin >> sta;

    int count = 0,flg = -1;
    if(sta[0] == 's'){
      cin >> neko >> haba;
      for(int i=0;i<w;i++) {
	if(a[i] == -1)count++;
	else  count = 0;

	if(count == haba) {
	  for(int j=i-count+1;j<=i;j++) a[j] = neko; 
	  flg = i - count+1;
	  break;
	}
      }
      if(flg != -1) cout << flg << endl;
      else cout << "impossible" << endl;
    }
    else if(sta[0] == 'w') {
      cin >> neko;
      for(int i=0;i<w;i++) {
	if(a[i] == neko) 
	  a[i] = -1;
      }
    }
  }
   cout << "END" <<endl;
  }
  return 0;
}
  

Measured memory_bytes: 1204
// @date		2013/9/13
// @algorithm	dijkstra
#include<iostream>
#include<queue>
#include<algorithm>
using namespace std;

#define rep(i,n) for(int i=0; i<n; i++)
const int INF = 1<<30;

struct t_node{
	int c;			// 合計コスト
	int from,to;	// どこから来たか、どこへ行くか
	int ticket;		// チケット残り枚数
};
bool operator<( const t_node &l, const t_node &r ){
	return l.c > r.c;
}
t_node makeNode(int c, int from, int to, int ticket){
	t_node n;
	n.c = c;
	n.from = from;
	n.to = to;
	n.ticket = ticket;
//	cout << "makeNode(" << n.c << "," << n.from << "," << n.to << "," << n.ticket << ")" << endl;
	return n;
}

int main(){
	int n, m;
	while( cin >> n >> m, n||m ){
		int cost[101][101];		// コスト[from][to]
		int memo[3] = {INF,INF,INF};			// 最後のメモ用
		bool decided[101][3];	// 確定したか否か[地点][チケット使用状況]

		// 初期化
		rep(i,n+1){
			rep(j,n+1)  cost[i][j] = INF;
			decided[i][0] = decided[i][1] = decided[i][2] = false;
		}
		decided[1][2] = true;
		rep(i,m){
			int a, b, c;
			cin >> a >> b >> c;
			cost[a][b] = cost[b][a] = c;
		}
		priority_queue<t_node> que;
		rep(i,n+1){
			if( cost[1][i] != INF ){
				que.push(makeNode(cost[1][i],1,i,2));
				que.push(makeNode(0,1,i,1));
			}
		}

		while(!que.empty()){
			t_node tn = que.top();
			que.pop();
			if( decided[tn.to][tn.ticket] )	continue;
//			cout << "loop : index=[" << tn.to << "][" << tn.ticket << "]" << endl;
			decided[tn.to][tn.ticket] = true;
			if( tn.to == n )	memo[tn.ticket] = tn.c;
			if(decided[n][0] && decided[n][2])	break;
			rep(i,n+1){
				if( cost[tn.to][i] != INF ){
					t_node next = makeNode(tn.c, tn.to, i, tn.ticket);
					// チケット使用
					if( next.ticket > 0 ){
						next.ticket--;
						que.push(next);
						next.ticket++;
					}
					// チケット非使用
					if( next.ticket != 1 ){
						next.c += cost[next.from][next.to];
						que.push(next);
					}
				}
			}
		}
		cout << min(memo[0],memo[2]) << endl;
	}
	return 0;
}

Measured memory_bytes: 1272
#include<bits/stdc++.h>
using namespace std;
using Int = long long;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}

//INSERT ABOVE HERE
Int n,k;
string calc(string s){
  reverse(s.begin(),s.end());
  Int cnt=0;
  while(cnt<n&&s[0]==s[cnt]) cnt++;
  Int len=cnt<<k;
  if(len>=n) return string(n,s[0]);
  return string(len,s[0])+s.substr(cnt,n-len);
}

signed main(){
  string s;
  cin>>n>>k>>s;
  chmin(k,20);
  k--;
  
  string t(s);
  reverse(t.begin(),t.end());
  string b=s+t;
  
  string ans=s;
  for(Int i=0;i<=n;i++)
    chmin(ans,calc(b.substr(i,n)));
  
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 256
/// Containers Start
#include <algorithm>
#include <bitset>
#include <cstdlib>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
/// C Header Files
#include <cassert>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <ctime>
#include <math.h>
#include <stdio.h>
/// Containers End

using namespace std;

/// Math Start
#define PI acos(-1.0)
#define Pi 3.141592653589793
#define EPS (1e-7)
#define INF (0x3f3f3f3f)
/// Math End

/// Extra Start
#define nn '\n'
#define pb push_back
#define ull unsigned long long
#define ll long long
#define MOD 1000000007
#define sz(a) int((a).size())
#define space " "
#define All(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
/// Extra End

#define rep(i, n) for (int i = 0; i < n; i++)
#define Cini(a)                                                                \
    int a;                                                                     \
    cin >> a;
#define Cinii(a, b)                                                            \
    int a, b;                                                                  \
    cin >> a >> b;
#define Ciniii(a, b, c)                                                        \
    int a, b, c;                                                               \
    cin >> a >> b >> c;
#define Cins(s)                                                                \
    string s;                                                                  \
    cin >> s;
#define Cinss(s1, s2)                                                          \
    string s1, s2;                                                             \
    cin >> s1 >> s2;
#define Cinc(c)                                                                \
    char c;                                                                    \
    cin >> c;
/// Functions End


/// Debug Start
#define deb(x) cout << #x << ": " << x << endl
#define deb2(x, y) cout << #x << ": " << x << '\t' << #y << ": " << y << endl;
#define deb3(x, y, z)                                                          \
    cout << #x << ": " << x << '\t' << #y << ": " << y << '\t' << #z << ": "   \
         << z << endl;
/// Debug End

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

/**>>>>>>>>>>>>>>>>>>> END <<<<<<<<<<<<<<<<<<**/

/// template


signed main(void) {
    cin.sync_with_stdio(false);
    cin.tie(0);
    Ciniii(N,H,W);
    vector<int> A(N),B(N);
    rep(i, N) cin >> A[i] >> B[i];
    int ansCount =0;
    rep(i,N){
        if(A[i]>=H && B[i]>=W){
            ansCount++;
        }
    }
    cout << ansCount << nn;
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#include<string.h>

int main(int argc, char *argv[]){


	int n;
	int *a;
	int i;
	unsigned char colFlags = 0x00;
	int master=0;
	int min=0, max;
	
	scanf("%d", &n);
	a = (int *)malloc(n*sizeof(int));

	for(i=0;i<n;i++){
		scanf("%d", &a[i]);	
		a[i] /= 400;

		if(a[i] > 7){
			master++;
		}else{
			if(!((colFlags>>a[i]) & 0x01)){
				min++;
				colFlags = colFlags | (0x01 << a[i]);
			}
		}
	}

	max = min + master;
	min = min==0 ? 1 : min;

	printf("%d %d\n", min, max);


	return 0;
}


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

using namespace std;

long long p[100005];

int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	
	long long n, a;
	cin >> n;
	for(long long i = 1; i <= n; ++i){
		cin >> a;
		p[a] = i;
	}
	for(long long i = 1; i <= n; ++i) cout << p[i] << " ";

	return 0;
}



Measured memory_bytes: 1664
#define _GLIBCXX_DEBUG
// header {{{
#include <bits/stdc++.h>
using namespace std;
#define CPP_STR(x) CPP_STR_I(x)
#define CPP_CAT(x,y) CPP_CAT_I(x,y)
#define CPP_STR_I(args...) #args
#define CPP_CAT_I(x,y) x ## y
#define ASSERT(expr...) assert((expr))
using i8  = int8_t;
using u8  = uint8_t;
using i16 = int16_t;
using u16 = uint16_t;
using i32 = int32_t;
using u32 = uint32_t;
using i64 = int64_t;
using u64 = uint64_t;
using f32 = float;
using f64 = double;
using f80 = __float80;
// }}}
constexpr i64 INF = 1'010'000'000'000'000'017LL;
constexpr i64 MOD = 1'000'000'007LL;
constexpr f64 EPS = 1e-12;
constexpr f64 PI = 3.14159265358979323846;
// util {{{
#define FOR(i, start, end) for(i64 i = (start), CPP_CAT(i,xxxx_end)=(end); i < CPP_CAT(i,xxxx_end); ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(f,c,...) (([&](decltype((c)) cccc) { return (f)(std::begin(cccc), std::end(cccc), ## __VA_ARGS__); })(c))

template<typename C>
i64 SIZE(const C& c) { return static_cast<i64>(c.size()); }
template<typename T, size_t N>
i64 SIZE(const T (&)[N]) { return static_cast<i64>(N); }
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;
}
// }}}

// init {{{
struct ProconInit {
    static constexpr int IOS_PREC = 15;
    static constexpr bool AUTOFLUSH = false;

    ProconInit() {
        cin.tie(nullptr);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(IOS_PREC);
        if(AUTOFLUSH)
            cout << unitbuf;
    }
} PROCON_INIT;
// }}}

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

signed main() {
    i64 h;
    cin>>h;

    i64 n = 0;
    while(1){
        h = h/2;
        n++;
        if(h == 0) break;
    }
    
    i64 sum = 0;
    REP(i,n){
        sum += pow(2,i);
    }
    cout<<sum<<endl;

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

Measured memory_bytes: 512
#include<stdio.h>
int main(void){
  int k,d;
  long sum;
  while(scanf("%d",&d)!=EOF){
    sum=0;
    for(k=1;k<=(600-d)/d;k++){
      sum += d * (k*d)*(k*d);
    }
    printf("%d\n",sum);
  }
  return 0;
}

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

using namespace std;

#define int long long
#define ALL(x) (x).begin(),(x).end()
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))

typedef pair<int,int> PI;
typedef pair<int,pair<int,int>> PII;
static const int INF=1010000000000000017LL;
static const double eps=1e-12;
static const double pi=3.14159265358979323846;
static const int dx[4]={1,-1,0,0};
static const int dy[4]={0,0,1,-1};
static const int ddx[8]={1,-1,0,0,1,1,-1,-1};
static const int ddy[8]={0,0,1,-1,1,-1,1,-1};

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


int N;
string X;

int modPow(int a, int n, int mod) {
    if(n==0)return 1%mod;
    if(n==1)return a%mod;
    if (n%2==1)return(a*modPow(a,n-1,mod))%mod;
    int t=modPow(a,n/2,mod);
    return (t*t)%mod;
}

int calc(int x,int depth){
    int m=0;
    int d=0;
    if(x==0)return depth;
    for(int i=60;i>=0;--i){
        if((x>>i)&1)d++;
    }
    if(d==0)return depth;
    for(int i=60;i>=0;--i){
        if((x>>i)&1){
            m+=modPow(2,i,d);
            m%=d;
        }
    }
    if(m==0)return depth+1;
    return calc(m,depth+1);
}

int maesyori(string x,int mod){
    int ret=0;
    int m=0;
    for(int i=x.size()-1;i>=0;--i){
        if(x[i]=='1'){
            m+=modPow(2,x.size()-1-i,mod);
            m%=mod;
        }
    }
    if(m==0)return 0;
    for(int i=60;i>=0;--i){
        if((m>>i)&1)ret+=modPow(2,i,mod);
    }
    return ret;
}

signed main(){
    cin>>N;
    int d=0;
    for(int i=0;i<N;++i){
        char x;
        cin>>x;
        X+=x;
        if(x=='1')d++;
    }
    int pls=maesyori(X,d+1);
    int mns=maesyori(X,max(d-1,1ll));
    for(int i=0;i<N;++i){
        int x;
        if(X[i]=='0'){
            x=pls+modPow(2,X.size()-1-i,d+1);
            x%=(d+1);
            //cout<<x<<endl;
            cout<<calc(x,0)+1<<endl;
        }
        else{
            if(d-1==0)cout<<0<<endl;
            else {
                x=mns-modPow(2,X.size()-1-i,d-1);
                x=(x+d-1)%(d-1);
                //cout<<x<<endl;
                cout<<calc(x,0)+1<<endl;
            }
        }
    }
    /*int x=mns-modPow(2,1,d-1);
    x*/
    //cout<<calc("111",0)<<endl;
}

Measured memory_bytes: 3892