akhauriyash/Code-Regression huggingface dataset:
#include <iostream>

int main()
{
    int K;
    std::string S;

    std::cin >> K;
    std::cin >> S;

    if(S.size() > K)
    {
        std::string tmp;
        tmp = S.substr(0, K);
        tmp += "...";
        S = tmp;
    }

    std::cout << S;
}

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

using namespace std;

#define mp make_pair
#define pb push_back
#define f first
#define s second
#define ll long long

#define for(i,a,b) for (i=a; i<b; i++)
#define forb(i,a,b) for (i=a; i>b; i--)
#define all(S) S.begin(),S.end()
#define sort(S) sort(all(S))

const int inf = 1e9;
const ll INF = 1e18;

int h,w,k,t[10][1000];
vector <vector <int> > V;

int go(int q)
{
    int dp[10],i,j;
    for (j,0,q)
        dp[j]=0;
    int l = 0;
    bool b = false;
    int x;
    for (i,0,w) {
    for (j,0,q)
    {
        for (x,0,V[j].size())
            dp[j]+=t[V[j][x]][i];
        if (dp[j]>k)
        {
            b=true;
            l++;
            break;
        }
    }
    if (b)
    {
        b=false;
        for (j,0,q)
            dp[j]=0;
        for (j,0,q) {
            for (x,0,V[j].size())
            dp[j]+=t[V[j][x]][i];
            if (dp[j]>k)
                return inf;
        }
    }
    }
    return l+q-1;
}

int main()
{
    cin.tie(0);
    cout.tie(0);
    ios_base::sync_with_stdio(false);
    int m,i,j;
    string s;
    cin >> h >> w >> k;
    m=h+w-2;
    for (i,0,h)
    {
        cin >> s;
        for (j,0,w)
            t[i][j]=s[j]-'0';
    }
    for (i,0,(1<<(h-1)))
    {
        int p = i;
        int q = 0;
        while (p>0)
        {
            q+=(p&1);
            p/=2;
        }
        V.clear();
        V.resize(q+1);
        p=0;
        V[0].pb(0);
        for (j,0,(h-1))
        {
            if (i&(1<<j))
                p++;
            V[p].pb(j+1);
        }
        int d=m;
        d = go(q+1);
        m=min(m,d);
    }
    cout << m << endl;
    return 0;
}


Measured memory_bytes: 3672
import math
n,m = [int(x) for x in input().split()]

INF = 10**9 + 7

if n == m:
    print(2 * math.factorial(n) * math.factorial(m) % INF)
elif abs(n-m) > 1:
    print(0)
else:
    print(math.factorial(n) * math.factorial(m) % INF)

Measured memory_bytes: 5180
def solve(string):
    n, *a = map(int, string.split())
    a = [0] + a + [0]
    diff = [abs(j - i) for i, j in zip(a, a[1:])]
    base = sum(diff)
    ans = [str(base - diff[i] - diff[i + 1] + abs(a[i + 2] - a[i])) for i in range(n)]
    return "\n".join(ans)


if __name__ == '__main__':
    print(solve('\n'.join([input(), input()])))


Measured memory_bytes: 20104
from collections import deque
N=int(input())
Ball=deque([])
m,M=float("inf"),0
for i in range(N):
  a,b=map(int,input().split())
  if a>b:
    a,b=b,a
  if a<m:
    m=a
    mp=i
  if b>M:
    M=b
    Mp=i
  Ball.append((a,b))
s=max([a[0] for a in Ball])
t=min([a[1] for a in Ball])
ans=(s-m)*(M-t)
if mp==Mp:
  print(ans)
  exit()
l=min(Ball[mp][1],Ball[Mp][0])
r=max(Ball[mp][1],Ball[Mp][0])
for i in range(2*N):
  if Ball:
    a,b=Ball.popleft()
    if l<=a<=r or l<=b<=r:
      pass
    elif a>r:
      r=a
    elif b<l:
      l=b
    elif a<l and b>r:
      Ball.append((a,b))
  else:
    break
if Ball:
  Ball=sorted(list(Ball),key=lambda x:(x[0],-x[1]))
  Max=[r]
  for i in range(len(Ball)):
    Max.append(max(Max[-1],Ball[i][1]))
  for i in range(len(Ball)):
    ans=min(ans,(M-m)*(Max[i]-Ball[i][0]))
  ans=min(ans,(M-m)*(Max[len(Ball)]-l))
else:ans=min(ans,(M-m)*(r-l))
print(ans)
               


          

Measured memory_bytes: 68900
#include <iostream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <algorithm>
#include <set>
#include <map>
#define vv(a, b, c, d) vector<vector<d> >(a, vector<d>(b, c))
#define vvi std::vector<std::vector<int> >
#define vvl std::vector<std::vector<ll> >
#define MODs 1000000007;
typedef long long int ll;
using namespace std;

//-------------------------------------------------------------------
int M=1;
std::vector<int> seg;
void init(int N){
  while(M<N) M*=2;
  M=M*2-1;
  for(int i=0;i<M;i++) {
    seg.push_back(0);
  }
}
void update(ll k){
  k += (M+1)/2-1;
  seg[k] ++;
  while(k>0){
    k = (k-1)/2;
    seg[k] = seg[k*2+1] + seg[k*2+2];
  }
}
ll query(ll a, ll b, ll l, ll r, ll k){
  if(r<=a || b <= l) return 0;
  if(a<=l && r<=b) return seg[k];
  else{
    ll le = query(a, b, l, (l+r)/2, k*2+1);
    ll ri = query(a, b, (l+r)/2, r, k*2+2);
    return le + ri;
  }
}
//-------------------------------------------------------------------
int main(int argc, char const *argv[]) {
  ll N;
  std::cin >> N;
  init(N+100001);
  std::vector<ll> A(N), A_sum(N);
  for(int i=0;i<N;i++) scanf("%lld", &A[i]);
  ll r=2000000000, l=0, las_size = N*(N+1)/2;
  while(r - l > 1){
    ll ans = 0, mid = (r+l)/2;
    for(int i=0;i<seg.size();i++) seg[i]=0;
    for(int i=0;i<N;i++){
      A_sum[i] = (i==0?(A[i]<mid?-1:1):A_sum[i-1]+(A[i]<mid?-1:1));
      ans += query(0, A_sum[i]+100002, 0, (M+1)/2, 0);
      update(A_sum[i]+100001);
      if(A_sum[i]>=0) ans++;
    }
    if(ans >= las_size/2 + (las_size%2==1?1:0)) l = mid;
    else r = mid;
  }
  std::cout << l << '\n';
  return 0;
}


Measured memory_bytes: 3952
#define _CRT_SECURE_NO_WARNINGS
#include<iostream>
#include<sstream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<climits>
#include<cmath>
#include<string>
#include<vector>
#include<set>
#include<map>
#include<queue>
#include<numeric>
#include<functional>
#include<algorithm>
#include<bitset>
#include<tuple>
#include<unordered_set>
#include<random>
#include<array>
#include<cassert>
using namespace std;
#define INF (1<<29)
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(v) v.begin(),v.end()
#define uniq(v) v.erase(unique(all(v)),v.end())




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

	long long n, k;
	long long ans = 0;
	cin >> n >> k;
	if (k == 0) {
		cout << n*n << endl;
		return 0;
	}

	for (int b = k + 1; b <= n; b++) {
		ans += n / b * (b-k);
		int r = n - n / b*b;
		if (r) {
			if (r >= k) ans += r - k + 1;
		}
	}
	cout <<ans<< endl;


	return 0;
}

Measured memory_bytes: 256
void main() {
	auto S = rs;
	auto T = rs;
	if(S.length + 1 == T.length && T[0..$-1] == S) {
		writeln("Yes");
	} else writeln("No");
}

// ===================================

import std.stdio;
import std.string;
import std.functional;
import std.algorithm;
import std.range;
import std.traits;
import std.math;
import std.container;
import std.bigint;
import std.numeric;
import std.conv;
import std.typecons;
import std.uni;
import std.ascii;
import std.bitmanip;
import core.bitop;

T readAs(T)() if (isBasicType!T) {
	return readln.chomp.to!T;
}
T readAs(T)() if (isArray!T) {
	return readln.split.to!T;
}

T[][] readMatrix(T)(uint height, uint width) if (!isSomeChar!T) {
	auto res = new T[][](height, width);
	foreach(i; 0..height) {
		res[i] = readAs!(T[]);
	}
	return res;
}

T[][] readMatrix(T)(uint height, uint width) if (isSomeChar!T) {
	auto res = new T[][](height, width);
	foreach(i; 0..height) {
		auto s = rs;
		foreach(j; 0..width) res[i][j] = s[j].to!T;
	}
	return res;
}

int ri() {
	return readAs!int;
}

long rl() {
	return readAs!long;
}

double rd() {
	return readAs!double;
}

string rs() {
	return readln.chomp;
}

Measured memory_bytes: 2748
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
using namespace std;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define rep2(i, s, n) for (ll i = s; i < (ll)(n); i++)
typedef long long ll;
typedef vector<vector<ll>> vvl;
typedef vector<ll> vl;
typedef vector<vector<char>> vvc;
typedef vector<char> vc;
typedef pair<ll,ll> pll;
ll max(ll x,ll y){
if(x>y)return x;
else return y;
}
ll min(ll x,ll y){
  return x+y-max(x,y);
}


int main() {
  char c;
  cin >> c;
  char s;
  if(c=='A')s='T';
  if(c=='T')s='A';
  if(c=='C')s='G';
  if(c=='G') s='C';
  cout  << s << endl;
}

Measured memory_bytes: 256
#include <iostream>

using namespace  std;

int main(int argc, char *argv[])
{
	int N;
	string S;

	cin >> N >> S;

	for (int i = 0; i < S.size(); i++) {
		S[i] = S[i] + N;
		if (S[i] > 90) {
			S[i] = 'A' + (S[i] - 1 - 90);
		}
	}

	cout << S << endl;

	return 0;
}

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

int main(){
    int n;
    string s;
    cin>>n>>s;
    vector<int> e(n,0),w(n,0);
    for(int i=0;i<n-1;i++){
        if(s[i]=='W') e[i+1]=e[i]+1;
        else e[i+1]=e[i];
    }
    for(int i=n-1;i>0;i--){
        if(s[i]=='E') w[i-1]=w[i]+1;
        else w[i-1]=w[i];
    }
    int ans=1e9;
    for(int i=0;i<n;i++){
        ans=min(ans,w[i]+e[i]);
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 3076
#include <stdio.h>
#define MAX(x,y)	((x)>(y)?(x):(y))
#define MAX3(x,y,z)	((x)>(MAX(y,z)) ? (x):(MAX(y,z)))
int main(){
  int a, b;
  scanf("%d%d", &a, &b);
  printf("%d", MAX3( a+b, a-b, a*b ));
  return 0;
}


Measured memory_bytes: 1704
#define _CRT_SECURE_NO_WARNINGS
#include "bits/stdc++.h"
using namespace std;
#define rep(i, n) for(int i=0; i<(n); ++i)
#define FOR(i, m, n) for(int i=(m); i<(n); ++i)
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
#define mp make_pair
#define pb push_back
#define Cout(x) cout << (x) << endl
#define dump(x) cerr << #x << " = " << (x) << endl;
typedef long long LL;
typedef vector<int> VI;
typedef vector<long long> VL;
typedef vector<string> VS;
typedef vector<vector<int>> VVI;
typedef pair<int, int> PII;
const int inf = (int)1e9;
const long long mod = (long long)1e9 + 7;
const double pi = acos(-1.0);

int main() {
	int a, b, c; cin >> a >> b >> c;
	Cout(min(c, b / a));
}

Measured memory_bytes: 256
#include<stdio.h>
int main(void){
  int a,b;
  scanf("%d %d",&a,&b);
  if(a==b){
    printf("Draw");
  }
  else if(a==1){
    printf("Alice");
  }
  else if(b==1){
    printf("Bob");
  }
  else if(a>b){
    printf("Alice");
  }
  else{
    printf("Bob");
  }
  return 0;
}

Measured memory_bytes: 128
#include <stdio.h>
#include <string.h>
typedef long long ll;

int main(void) {
  ll i, ans = 0, now = 0;
  char s[200010];
  scanf("%s", s);
  for(i = 0; i < strlen(s); ++i) {
    if(s[i] == 'S') ++now;
    else --now;
    if(now < 0) ans -= now, now = 0;
  }
  printf("%lld", ans + now);
  return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
typedef long long lint;
typedef pair<int, int> pi;

lint n, a[100005], b[100005], sum;

int main(){
	scanf("%lld",&n);
	for(int i=1; i<=n; i++){
		scanf("%lld",&a[i]);
		sum += a[i];
	}
	if(sum % ((n * n + n) / 2) != 0){
		puts("NO");
		return 0;
	}
	sum /= (n * n + n) / 2;
	for(int i=1; i<=n; i++){
		if(i > 1) b[i] = a[i] - a[i-1];
		else b[i] = a[1] - a[n];
		b[i] = sum - b[i];
	}
	for(int i=1; i<=n; i++){
		if(b[i] < 0 || b[i] % n){
			puts("NO");
			return 0;
		}
	}
	puts("YES");
}


Measured memory_bytes: 1792
#ARC075C
import sys

n=int(raw_input())
s=[]
for i in xrange(n):
 s.append(int(raw_input()))
ss=sum(s)
if ss%10:
 print ss
 sys.exit()
s=sorted(s)
for x in s:
 if x%10:
  print ss-x
  sys.exit()
print 0


Measured memory_bytes: 2568
#pragma GCC optimize ("O3")
#pragma GCC target ("avx")
//#include<bits/stdc++.h>
#include<cstdio>
#include<algorithm>
//#include<vector>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define Would
#define you
#define please

const int cm = 1 << 17;
char cn[cm], * ci = cn + cm, ct;
inline char getcha() {
	if (ci - cn == cm) { fread(cn, 1, cm, stdin); ci = cn; }
	return *ci++;
}
inline int getint() {
	int A = 0;
	if (ci - cn + 16 > cm) while ((ct = getcha()) >= '0') A = A * 10 + ct - '0';
	else while ((ct = *ci++) >= '0') A = A * 10 + ct - '0';
	return A;
}

int A[100010];
int main() {
	//cin.tie(0);
	//ios::sync_with_stdio(false);


	int N = getint();
	rep(i, N) A[getint()]++;
	int saidai = 0;
	rep1(i, 99998) {
		chmax(saidai, A[i - 1] + A[i] + A[i + 1]);
	}
	printf("%d", saidai);

	Would you please return 0;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
int main()
{
  long long i,j,n,k;
  cin>>n;
  string t="";
  while(n>0)
  {
    k=n%26-1;
    if(k==-1){
     t+='z';
     n--;
    }
    else
    t+=('a'+k);
    n/=26;
  }
  reverse(t.begin(),t.end());
  cout<<t;
  
}

Measured memory_bytes: 3632
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <vector>
#include <string>
#include <queue>
#include <deque>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <sstream>
#include <iomanip>

using namespace std;

typedef long long ll;
typedef vector <int> vi;
typedef vector <vector <int>> vii;
typedef vector <long long> vll;
typedef vector <string> vs;
typedef vector <char> vc;
typedef set <int> si;
typedef set <string> ss;
typedef queue <int> qi;
typedef queue <long long> qll;
typedef queue <string> qs;
typedef queue <char> qc;
typedef struct board board;
typedef pair <int, int> pi;
typedef pair <long long, long long> pll;
typedef pair <int, pair<int, int>> pii;

#define eb emplace_back
#define ppb pop_back
#define clr(a) a.clear()
#define F first
#define S second
#define mkp make_pair

#define sz(x) (int)(x).size()
#define all(x) (x).begin(), (x).end()

#define left(x) x * 2
#define right(x) x * 2 + 1

#define meme(a, b, c) fill(a + 1, a + 1 + b, c)

#define max(a, b) (a > b ? a : b)
#define min(a, b) (a > b ? b : a)
#define abs(a) (a > 0? a : -(a))

#define move(s) s += "#"

#define fr(i, a, b) for (ll i = a; i <= b; ++ i)
#define rf(i, a, b) for (ll i = a; i >= b; -- i)

#define eprintf(...) fprintf(stderr, __VA_ARGS__);

void to_pray() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    cerr << "Ready\n";
}

const int N = 4e6 + 10;
const int NN = 1e3 + 10;
const int NNN = 2e3 + 9;
const int MOD = 1e9 + 7;
const int INF = 1e9 + 7;
const ll LLINF = 1e12 + 7;
const ll P = 53;
const int EPS = 1e-9 - 8;
const int vN = 2e4 + 10;
const int sz = (1 << 22) - 1;
const double PI = acos(-1);

int cnt = 0;

int main () {
    to_pray();
    
    int a, b, c;
    cin >> a >> b >> c;
 	while(true) {
 		b -= a;
 		if (b < 0)
 			break;
 		++cnt;
 		if (cnt == c)
 			break;
 	}
 	cout << cnt;
    
    cout << '\n';
    return 0;
}

Measured memory_bytes: 256
function Main(input)
{
	input = input.split("\n");

	var len = parseInt(input[0]);

	if (input[1].length <= len)
	{
		console.log(input[1]);
	}else{
		console.log(input[1].substr(0, len)+"...");
	}
	
}

Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 29504
#pragma GCC optimize("Ofast")
#pragma GCC optimize("no-stack-protector")
#pragma GCC optimize("unroll-loops")
#pragma GCC optimize("fast-math")
#pragma GCC target("sse,sse2,sse3,ssse3,popcnt,abm,mmx,tune=native")
#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <stdio.h>
#include <cstdio>
#include <math.h>
#include <cmath>
#include <string>
#include <cstring>
#include <queue>
#include <deque>
#include <random>
#include <iomanip>
#include <bitset>

using namespace std;

template<typename T> void uin(T &a, T b) {
    if (b < a) {
        a = b;
    }
}

template<typename T> void uax(T &a, T b) {
    if (b > a) {
        a = b;
    }
}

#define int long long
#define left left228
#define right right228
#define prev prev228
#define mp make_pair
#define all(v) v.begin(), v.end()
#define forn(i, n) for (int i = 0; i < (int)n; ++i)
#define firn(i, n) for (int i = 1; i < (int)n; ++i)
#define x first
#define y second

const int INF = 3e18 + 228;

vector<int> repr(int x) {
    vector<int> v;
    for (int i = 0; i < 61; ++i, x >>= 1) {
        v.push_back(x & 1);
    }
    reverse(v.begin(), v.end());
    return v;
}

int up(int x) {
    int i = 1;
    while (i - 1 < x) i <<= 1;
    return i - 1;
}

int base[100];

signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int A, B;
    cin >> A >> B;
    if (A == B) {
        cout << 1 << endl;
        return 0;
    }
    base[0] = 1;
    for (int i = 1; i < 62; ++i) {
        base[i] = base[i - 1] * 2;
    }
    vector<int> a = repr(A);
    vector<int> b = repr(B);
    int pref = -1;
    int pp = 0;
    while (pref + 1 < 61 & a[pref + 1] == b[pref + 1]) {
        ++pref;
        pp += a[pref] * base[61 - pref - 1];
    }
    ++pref;
    pp = pp + base[61 - pref - 1];
    int lb = 0;
    int rb = 0;
    for (int i = pref + 1; i < 61; ++i) {
        lb = lb * 2 + a[i];
        rb = rb * 2 + b[i];
    }
    rb = up(rb);
    int rest = 61 - pref - 1;
    // lb...pw pw...rb
    int L = pp + rb; //  pp...L
    int R = pp + lb; // R...pp+2^rest-1
    int l1 = pp;
    int r1 = L;
    int l2 = R;
    int r2 = pp + (1LL << rest) - 1;
    int res = 0;
    vector< pair<int, int> > v;
    v.emplace_back(l1, r1);
    v.emplace_back(l2, r2);
    v.emplace_back(A, B);
    int k = -INF;
    sort(v.begin(), v.end());
    for (auto p : v) {
        p.first = max(p.first, k);
        res += max(0LL, p.second - p.first + 1);
        k = p.second + 1;
    }
    cout << res << '\n';
    return 0;
}

/*
3
1 1 2
2 2 2
3 3 2
2 1 1
3 2 1


2 2
1 1 2
2 2 2
1 2 3
2 1 1

2
2 1 2 2 3
2 2 2 1 1

*/

Measured memory_bytes: 256
N,M = map(int,input().split())
divisors = []
for i in range(1,int(M**.5)+1):
    if M%i == 0:
        divisors.append(i)
        if M//i != i:
            divisors.append(M//i)
ans = 1
for x in divisors:
    if x <= M//N:
        ans = max(ans,x)
print(ans)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#include <cstring>
#include <limits>
using namespace std;
#define ll long long int
#define lli long long int
#define fw(i, s, e) for (ll i = s; i < e; ++i)
#define fe(i, s, e) for (ll i = s; i <= e; ++i)
#define fb(i, e, s) for (ll i = e; i >= s; --i)
#define L(T)  \
    ll T;     \
    cin >> T; \
    while (T--)
#define FASTIO                   \
    ios::sync_with_stdio(false); \
    cin.tie(nullptr);            \
    cout.tie(nullptr);
#define mem(a, i) memset(a, i, sizeof(a))
#define ld long double
#define endl "\n"
#define in(P) \
    ll P;     \
    cin >> P;
ll h[10000089];
int main()
{
    FASTIO
    in(n);
    // mem(h, 0);
    fw(i, 1, n + 1)
    {
        for (ll j = i; j <= n; j += i)
        {
            h[j]++;
        }
    }
    // fw(i, 0, n)
    // {
    //     // cout << h[i] << " " << endl;
    // }
    ll ans = 0;
    fw(i, 1, n + 1)
    {
        ans += (i * h[i]);
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 81644
#include<cstdio>

#define MAXN 10000
int N,K;
bool D[10];

int main(){
    scanf("%d%d",&N,&K);
    for(int i=1;i<=K;i++){
        int x;
        scanf("%d",&x);
        D[x]=1;
    }
    int i=N;
    while(1){
        int j=i;
        bool flag=1;
        while(j){
            int num=j%10;
            if(D[num]){
                flag=0;
                break;
            }
            j/=10;
        }
        if(flag){
            printf("%d",i);
            return 0;
        }
        i++;
    }
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef tuple<ll, ll, ll> T;

int A, B;
vector<string> grid(101);

int main(void){
    
    scanf("%d %d", &A, &B);
    for(int i = 1; i <= 50; ++i){ string s(101, '#'); grid[i] = s; }
    for(int i = 51; i <= 100; ++i){ string s(101, '.'); grid[i] = s; }
    
    int black = 1, white = 1;
    
    for(int i = 1; i <= 50; i += 2){
        for(int j = 1; j <= 100; ++j){
            if(white == A) continue;
            if(j % 2 != 0) grid[i][j] = '.', ++white;
        }
    }
    
    for(int i = 100; i >= 51; i -= 2){
        for(int j = 1; j <= 100; ++j){
            if(black == B) continue;
            if(j % 2 == 0) grid[i][j] = '#', ++black;
        }
    }
    
    printf("100 100\n");
    for(int i = 1; i <= 100; ++i){
        for(int j = 1; j <= 100; ++j){
            printf("%c", grid[i][j]);
        }
        printf("\n");
    }
    
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(){
	
    int a,b;
    for(int i=0 ; ; i++){
        scanf("%d %d",&a,&b);
        if(a==0 && b==0){
            break;
        }
        if(a>b){
            printf("%d %d\n",b,a);
        }
        else{
            printf("%d %d\n",a,b);
        }
    }
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	return 0;
}


Measured memory_bytes: 1968
#include <iostream>
#include <vector>
#define N_MAX 200000
using namespace std;
int main(){
  vector<int> ball;
  int N,a[N_MAX]={0},b[N_MAX]={0};
  cin >> N;
  int M=0;
  for(int i=0;i<N;i++)cin >> a[i];
  for(int i=N-1;i>=0;i--){
    int cnt=0;
    for(int k=i;k<N;k=k+(i+1))if(b[k]==1)cnt++;
    if(cnt%2!=a[i]){b[i]++;M++;ball.push_back(i+1);}  }
  //出力
  cout << M << endl;
  for(int i=0;i<M-1;i++)cout << ball[i] << " ";
  if(M>0)cout << ball[M-1] << endl;
  return 0;
}

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

int main() {
  int a, sum=0;
  
  cin >> a;
  sum = a % 2;
  a = a / 10;
  sum += a % 2;
  a = a / 10;
  sum += a % 2;
  
  cout << sum << endl;
}

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

using namespace std;

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

	vector<pair<int, int>> ans;
	int n = N + (1 - N % 2);
	for (int i = 1; i < N; ++i) {
		for (int j = i + 1; j <= N; ++j) {
			if (j == i || i + j == n) { continue; }
			ans.emplace_back(i, j);
		}
	}

	cout << ans.size() << endl;
	for (auto p : ans) {
		cout << p.first << " " << p.second << endl;
	}

	return 0;
}


Measured memory_bytes: 384
/*                                  /   \                                 */      
/*                                 /*****\                               */
/*     Jai Shree Mataji           /       \ |\| |_| $ |-| K             */
#include<vector>
#include<iostream>
#include<algorithm>                
#include<string.h>                 
#include<bits/stdc++.h>            
#include<cstring>                  
#include<map>                     
#include<cmath>                  
#include<set>
using namespace std;            
#define ll long long int        
#define ld long double
#define MOD 1000000007 
#define PI 3.1415926535897932384626433832795                                               
#define YY cout<<"YES"
#define NN cout<<"NO"
#define ee cout<<"\n"
#define ne cout<<"-1"
#define pb push_back 
#define fi first
#define se second
#define mkp make_pair    
#define sall(v ) sort(v.begin(), v.end())      
#define all(v )  v.begin(), v.end()      
#define fo(i , n) for(ll i = 0 ; i < n ; i++)
#define vl vector<ll>
#define vll vector< pair<ll,ll> > 
#define mpl map<ll, ll>
#define pr pair<ll,ll>
bool sortbysec(const pair<int,int> &a,const pair<int,int> &b) {return (a.second < b.second); }
ll pow1(ll n,ll p){if(p==0)return 1;ll x=pow1(n, p/2);x=(x*x)%MOD;if(p%2==0) return x%MOD;else return (x*n)%MOD;}
ll pd(ll x,ll y){if(x%y==0) return x/y;else return x/y+1;}  
int main(){
ios_base::sync_with_stdio(0);
cin.tie(0);	
	  ll t=1;


//	   cin>>t;
	      while(t--)
{

string s;
cin>>s;
if(s[s.length()-1]=='s')
cout<<s<<"es";
else
cout<<s<<"s";
ee;








}
return 0;
}




Measured memory_bytes: 3620
#include <bits/stdc++.h>
using namespace std;
using ll =long long;
#define all(v) v.begin(),v.end()
 
int main() {
ll N,D;
  cin>>N>>D;
  ll kansi=0;
  ll ans=0;
  while(kansi<N) {
kansi+=2*D+1;
    ans++;
  }
  cout<<ans<<endl;
}
  
  
 

Measured memory_bytes: 3576
using System;

namespace Main
{
    class Program
    {
        static void Main(string[] args)
        {
            var N = Console.ReadLine();
            int ans = 0;
            for (int i = 0; i < N.Length; i++)
                if (N[i] == '2')
                    ans++;
            Console.WriteLine(ans);
            Console.ReadLine();
        }
    }
}


Measured memory_bytes: 13140
while 1:
    n = int(input())
    if n == 0:
        break
    S = [input() for i in range(n)]

    dup = [0]*n
    for i in range(n):
        si = S[i]
        for j in range(i+1, n):
            sj = S[j]
            if si.find(sj)+1:
                dup[j] = 1
            if sj.find(si)+1:
                dup[i] = 1
    S = [S[i] for i in range(n) if not dup[i]]
    n -= sum(dup)

    P = [[0]*n for i in range(n)]
    for i in range(n):
        si = S[i]
        l = len(si)
        for j in range(n):
            sj = S[j]
            pos = l
            for k in range(l):
                if sj.startswith(si[k:]):
                    pos = k
                    break
            P[i][j] = len(sj) - (l - pos)

    ALL = 2**n - 1
    up = 300
    memo = {(ALL, i): 0 for i in range(n)}
    def dfs(state, i):
        if (state, i) in memo:
            return memo[state, i]
        res = up
        for j in range(n):
            if (state >> j) & 1 < 1:
                res = min(res, dfs(state | (1 << j), j) + P[i][j])
        memo[state, i] = res
        return res
    print(min(dfs(1 << i, i) + len(S[i]) for i in range(n)))

Measured memory_bytes: 30968
#include <bits/stdc++.h>
#define UNVISITED -1
#define POS_INF 1 << 25
#define NEG_INF -1 << 25
#define _ ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0), cout.precision(15);
using namespace std;

typedef long long int64;
typedef pair<int, int> ii;

int main(){ _
  int N, i; cin >> N >> i;
  cout << N + 1 - i << endl;
  return 0;
}


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

int main() {
  int A, B;
  cin >> A >> B;

  if (A >= 13) {
    cout << B << endl;
  }
  else if (A > 5) {
    cout << B / 2 << endl;
  }
  else {
    cout << 0 << endl;
  }
}


Measured memory_bytes: 256
X, Y = map(int, input().split())


def cmb(n, r, mod):
    if ( r<0 or r>n ):
        return 0
    r = min(r, n-r)
    return g1[n] * g2[r] * g2[n-r] % mod

# A=(+1,+2)をM回、B=(+2,+1)をN回
# X=M+2N, Y=2M+N => (X+Y)/3 = M+N
ans = 0
if (X+Y)%3==0:
    Z = int((X+Y)/3)
    for m in range(Z+1):
        n = Z-m
        if X==m+2*n:
            # これが遅い
            # ans = math.factorial(n+m) // (math.factorial(n)*math.factorial(m)) % (10**9+7)

            mod = 10**9+7 #出力の制限
            N = 10**6
            g1 = [1, 1] # 元テーブル
            g2 = [1, 1] #逆元テーブル
            inverse = [0, 1] #逆元テーブル計算用テーブル

            for i in range( 2, N + 1 ):
                g1.append( ( g1[-1] * i ) % mod )
                inverse.append( ( -inverse[mod % i] * (mod//i) ) % mod )
                g2.append( (g2[-1] * inverse[-1]) % mod )

            ans = cmb(n+m,min(n,m),mod)
            break
    print(int(ans))
else:
    print(ans)

Measured memory_bytes: 122044
#include <iostream>
#include <algorithm>
#include <functional>
#include <vector>
#include <queue>
#include <stack>
#include <set>
#include <bitset>
#include <cmath>
#include <string>
#include <cstring>
#include <fstream>
#define FI first
#define SE second
#define VE vector<int>
#define PB push_back
#define PA pair<int,int>
#define MA make_pair
#define LLI long long int
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define ROF(i,a,b) for(int i=b-1;i>=a;i--)
#define YES(i) cout<<(i?"YES":"NO")<<endl
#define Yes(i) cout<<(i?"Yes":"No")<<endl
#define POS(i) cout<<(i?"POSSIBLE":"IMPOSSIBLE")<<endl
#define Pos(i) cout<<(i?"Possible":"Impossible")<<endl
#define co(i) cout<<i<<endl
using namespace std;
//
const int INF=1e9+7;
const int MOD=1e9+7;
//
int main(){
    int n; cin>>n;
    string s; cin>>s;
    int m=0;
    FOR(i,1,n){
        int ans=0;
        int a[30]={},b[30]={};
        FOR(j,0,i){
            a[s[j]-'a']++;
        }
        FOR(j,i,n){
            b[s[j]-'a']++;
        }
        FOR(j,0,30){
            if(a[j]>0&&b[j]>0){
                ans++;
            }
        }
        m=max(m,ans);
    }
    co(m);

}


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

//mitsuisumitomo2019-d.cppだとなぜか変数の色分けがうまくされない
int main(){
    int n;
    cin>>n;

    //sの入力は分割されていない(数字の間に空白がない)ので配列ではなくstringを使う
    string s;
    cin>>s;

    int cnt=0;
    
    for(int i=0;i<1000;i++){
        int v[3]={i/100,(i/10)%10,i%10};
        
        int f=0;
        for(int j=0;j<n;j++){
            if(s[j]==v[f]+'0') f++;
            if(f==3) break;
        }
        if(f==3) cnt++;
    }

    cout<<cnt<<endl;
}

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

using namespace std;
using ll = long long;

#define INF (1LL << 60)
#define MOD 1000000007

#define REP(i,m,n) for(ll (i)=(m),i##_len=(n);(i)<(i##_len);++(i))
#define FORR(i,v) for(auto (i):v)
#define ALL(x) (x).begin(), (x).end()
#define _PR(x) cout << (x) << endl
#define _PS(x) cout << (x) << " "
#define SZ(x) ((int)(x).size())
#define MAX(a,b) (((a)>(b))?(a):(b))
#define MIN(a,b) (((a)<(b))?(a):(b))
#define pb push_back

int main()
{
    ll N, M;
    cin >> N >> M;
    if(N == M) _PR("Yes");
    else _PR("No");

    return 0;
}

/*



*/

Measured memory_bytes: 256
n,a,b=map(int,input().split())
mod=10**9+7
def nCk(n,k):
    x=1
    y=1
    for i in range(k):
        x=(x*(n-i))%mod
        y=(y*(k-i))%mod
    y_inv=pow(y,mod-2,mod)
    return (x*y_inv)%mod

ans=(pow(2,n,mod)-1-nCk(n,a)-nCk(n,b))%mod
print(ans)

Measured memory_bytes: 3064
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
	public static void main(String[] args)throws IOException{
		InputStreamReader isr = new InputStreamReader(System.in);
        BufferedReader br = new BufferedReader(isr);
        int y , x;
        while (true)
        {
        String z;
        	String[] list = br.readLine().split(" ");
        	x = Integer.parseInt(list[0]);
        	y = Integer.parseInt(list[2]);
        	z = list[1];
        	
        	if (z.equals("?"))
        		break;
        	else if (z.equals("+"))
        		System.out.println(x + y);
        	else if (z.equals("-"))
        		System.out.println(x - y);
        	else if (z.equals("*"))
        		System.out.println(x * y);
        	else if (z.equals("/"))
        		System.out.println(x / y);
        		
        }	
	}

}

Measured memory_bytes: 24320
import java.util.*;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt(), b = sc.nextInt(), c = sc.nextInt();
		sc.close();
		int ans = c - (a - b);
      	if(c < (a - b))ans = 0;
		System.out.println(ans);
	}
}


Measured memory_bytes: 22612
from itertools import product

H, W, K = map(int, input().split())
l = [[0]*W for _ in range(H)]
for i in range(H):
    for j, s in enumerate(input()):
        if s=="1":
            l[i][j] = 1

dp = [[0]*(W+1) for _ in range(H+1)]
for i in range(1, H+1):
    for j in range(1, W+1):
        dp[i][j] = l[i-1][j-1]+dp[i-1][j]+dp[i][j-1]-dp[i-1][j-1]

f=lambda lx,ly,rx,ry:dp[ry][rx]-dp[ly-1][rx]-dp[ry][lx-1]+dp[ly-1][lx-1]

ans = H*W
for i in product(range(2), repeat=H-1):
    candidate = []
    if any(i):
        start = 1
        for j, k in enumerate(i, start=1):
            if k:
                candidate.append((start, j))
                start = j+1
        candidate.append((start, H))
    else:
        candidate.append((1, H))
    
    q = [1]
    cutx = 0

    while q:
        s = q.pop()
        for t in range(s, W+1)[::-1]:
            if all(f(s, j, t, k)<=K for j, k in candidate):
                if t!=W:
                    q.append(t+1)
                    cutx += 1
                break
        else:
            cutx = H*W
    v = cutx+sum(i)
    ans = min(ans, v)

print(ans)

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

#define FAST ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

#define MAXX 1005

#define PI 3.14159265358979323846264338327950

#define ll  int
vector<ll> v;
ll p[MAXX];
multiset<ll> ms;
multiset<ll>::iterator it;
signed main()
{
	FAST;
	ll   h = 0, t = 0; ll ans = 0;
	ll a, b, c;
	cin >> a >> b >> c;
	for(ll i = 1; i <= min(a, b); i++){
		if(a % i == 0 && b % i == 0){
			p[t] = i;
			t ++;
		}
	}
	reverse(p, p + t);
	cout << p[c-1];;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <iomanip>
#include <functional>
using namespace std;
int n;
int main() {
	while (cin >> n, n) {
		vector<int> v;
		for (int i = 0; i < n; ++i) {
			int a; cin >> a;
			v.push_back(a);
		}
		sort(v.begin(), v.end());
		int sum = 0;
		for (int i = 1; i < v.size() - 1; ++i) {
			sum += v[i];
		}
		cout << sum/(v.size()-2) << endl;
	}
	
	return 0;
}


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

int main() {
	int a, b;
	cin >> a >> b;
	if (a > 0 && b > 0) {
		if (a <= 9 && b <= 9) {
			cout << a * b << endl;
		}
		else cout << -1 << endl;
	}
	else cout << -1 << endl;

	return 0;
}

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

string s;
typedef pair<char, int> P;
vector<P> t;

int main(){
//	cin.tie(0);
//	ios::sync_with_stdio(false);
	cin >> s;
	t.push_back(P('A', -1));
	for(int i=0; i<s.size(); ++i)
		if(s[i] != 'x')
			t.push_back(P(s[i], i));
	t.push_back(P('A', s.size()));
	int n = t.size();
	int m = n / 2;
	string l, r;
	for(int i=0; i<m; ++i){
		l.push_back(t[m-n%2-i-(n+1)%2].first);
		r.push_back(t[m+n%2+i].first);
	}
//	cout << l << "\n" << r << "\n";
	if(l != r) cout << -1 << "\n";
	else{
		int ans = 0;
		for(int i=0; i<(n-1)/2; ++i){
			int a = t[(n-1)/2-i].second-t[(n-1)/2-i-1].second;
			int b = t[n/2+1+i].second-t[n/2+i].second;
			ans += max(a, b) - min(a, b);
		}
		cout << ans << "\n";
	}
}

Measured memory_bytes: 1528
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <fstream>
#include <sstream>
#include <set>
#include <map>
#include <vector>
#include <list>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <string>
#include <queue>
#include <bitset>     //UWAGA - w czasie kompilacji musi byc znany rozmiar wektora - nie mozna go zmienic
#include <cassert>
#include <iomanip>        //do setprecision
#include <ctime>
#include <complex>
using namespace std;

#define FOR(i,b,e) for(int i=(b);i<(e);++i)
#define FORQ(i,b,e) for(int i=(b);i<=(e);++i)
#define FORD(i,b,e) for(int i=(b)-1;i>=(e);--i)
#define REP(x, n) for(int x = 0; x < (n); ++x)

#define ST first
#define ND second
#define PB push_back
#define MP make_pair
#define LL long long
#define ULL unsigned LL
#define LD long double

vector<LL> d;
vector<LL> d2;
vector<vector<int>> a;
vector<int> used;

const double pi = 3.141592653589793238462643383279502884197169399375105820974944592307816406286208998628034825342;
const int mod=1000000007;
void f(int nw){
	d[nw]=d2[nw]=1;
	for(auto nx:a[nw]){
		if(used[nx])continue;
		used[nx]=1;
		f(nx);
		d[nw]=(d[nw]*(d[nx]+d2[nx]))%mod;
		d2[nw]=(d2[nw]*d[nx])%mod;
	}
}

int main(){
	int n;
	cin>>n;
	vector<vector<int>> g=vector<vector<int>>(n+1,vector<int>());
	FOR(i,0,n-1){
		int a,b;
		cin>>a>>b;
		g[a].PB(b);
		g[b].PB(a);
	}
	a=g;
	vector<LL> dp(n+1,0);
	vector<LL> dp2(n+1,0);
	d=dp;
	d2=dp2;
	vector<int> u(n+1,0);
	used=u;
	used[1]=1;
	f(1);
	cout<<(d[1]+d2[1])%mod<<endl;

    return 0;
}


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

#define DEBUG 1

#define INF (1.0/0.0)
#define EPS 1e-8
#define PI 3.1415926535
#define EQ(x, y) (abs((x)-(y))<EPS)
#define X real()
#define Y imag()

typedef complex<double> Point;
typedef pair<double, int> Pair;

struct Edge {
  int to;
  double len;
};

int n;
int m;
priority_queue<Pair> q;
Point ps[114514];
double mind[114514];
vector<Edge> es[114514];

int main() {
  scanf("%d%d", &n, &m);
  for (int i=0; i<n; i++) {
    int x, y;
    scanf("%d%d", &x, &y);
    ps[i] = Point(x, y);
  }

  double sum = 0.0;
  for (int i=0; i<m; i++) {
    int a, b;
    scanf("%d%d", &a, &b);
    --a;
    --b;
    double t = abs(ps[a]-ps[b]);
    es[a].push_back(Edge{b, t});
    es[b].push_back(Edge{a, t});
    sum += t;
  }

  double total = 0.0;
  fill(mind, mind+n, -INF);
  for (int v=0; v<n; v++) {
    if (mind[v] != -INF) continue;
    mind[v] = 0;
    q.push(Pair(0, v));
    while (!q.empty()) {
      Pair p = q.top(); q.pop();
      double c = p.first;
      int v = p.second;
      if (mind[v] > c) continue;
      total += mind[v];
      mind[v] = INF;
  
      for (int i=0; i<es[v].size(); i++) {
        int u = es[v][i].to;
        double len = es[v][i].len;
        if (mind[u] < len) {
          mind[u] = len;
          q.push(Pair(mind[u], u));
        }
      }
    }
  }
  printf("%.10f\n", sum-total);
}

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

#define pb push_back
#define mp make_pair
typedef long long ll;
typedef pair<ll, ll> ii;
typedef vector<ll> vi;
typedef vector<ii> vii;

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

	string s; cin >> s;
	for(int i=0;i<3;i++){
		if(s[i] == s[i+1]){
			cout << "Bad" << endl;
			return 0;
		}
	}
	cout << "Good" << endl;
}


Measured memory_bytes: 3632
#[allow(dead_code)]
fn main() {
    let n = i::u();
    let mut d = HashMap::new();
    let mut k = n;
    let mut l = 2;
    while l * l <= k {
        if k % l == 0 {
            k /= l;
            *d.entry(l).or_insert(0) += 1;
        } else {
            l += 1;
        }
    }
    *d.entry(k).or_insert(0) += 1;
    d.remove(&1);
    let mut ans = 0;
    for (_, &count) in &d {
        let mut t = 1;
        let mut sum = 0;
        while count >= sum + t {
            ans += 1;
            sum += t;
            t += 1;
        }
    }
 //   dbg!(&d);
    println!("{}", ans);
}

#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::{BTreeMap, BTreeSet, HashMap, HashSet, VecDeque};
#[allow(unused_imports)]
use std::io::*;
#[allow(unused_imports)]
use std::num::*;
#[allow(unused_imports)]
use std::str::*;

#[allow(dead_code)]
mod i {
    use super::*;

    pub fn read<T: FromStr>() -> T {
        stdin()
            .bytes()
            .map(|c| c.unwrap() as char)
            .skip_while(|c| c.is_whitespace())
            .take_while(|c| !c.is_whitespace())
            .collect::<String>()
            .parse::<T>()
            .ok()
            .unwrap()
    }
    pub fn str() -> String {
        read()
    }
    pub fn s() -> Vec<char> {
        str().chars().collect()
    }
    pub fn i() -> i64 {
        read()
    }

    pub fn u() -> usize {
        read()
    }

    pub fn u2() -> (usize, usize) {
        (read(), read())
    }

    pub fn u3() -> (usize, usize, usize) {
        (read(), read(), read())
    }

    pub fn u4() -> (usize, usize, usize, usize) {
        (read(), read(), read(), read())
    }

    pub fn u5() -> (usize, usize, usize, usize, usize) {
        (read(), read(), read(), read(), read())
    }

    pub fn u6() -> (usize, usize, usize, usize, usize, usize) {
        (read(), read(), read(), read(), read(), read())
    }

    pub fn f() -> f64 {
        read()
    }

    pub fn c() -> char {
        read::<String>().pop().unwrap()
    }

    pub fn iv(n: usize) -> Vec<i64> {
        (0..n).map(|_| i()).collect()
    }

    pub fn iv2(n: usize) -> Vec<(i64, i64)> {
        (0..n).map(|_| iv(2)).map(|a| (a[0], a[1])).collect()
    }

    pub fn iv3(n: usize) -> Vec<(i64, i64, i64)> {
        (0..n).map(|_| iv(3)).map(|a| (a[0], a[1], a[2])).collect()
    }

    pub fn uv(n: usize) -> Vec<usize> {
        (0..n).map(|_| u()).collect()
    }

    pub fn uv2(n: usize) -> Vec<(usize, usize)> {
        (0..n).map(|_| uv(2)).map(|a| (a[0], a[1])).collect()
    }

    pub fn uv3(n: usize) -> Vec<(usize, usize, usize)> {
        (0..n).map(|_| uv(3)).map(|a| (a[0], a[1], a[2])).collect()
    }

    pub fn uv4(n: usize) -> Vec<(usize, usize, usize, usize)> {
        (0..n)
            .map(|_| uv(4))
            .map(|a| (a[0], a[1], a[2], a[3]))
            .collect()
    }

    pub fn fv(n: usize) -> Vec<f64> {
        (0..n).map(|_| f()).collect()
    }

    pub fn cmap(h: usize) -> Vec<Vec<char>> {
        (0..h).map(|_| s()).collect()
    }
}


Measured memory_bytes: 2172
<?php
$n = trim(fgets(STDIN));

if($n % 2 == 0) {
    echo (int)((int)($n + 1) * (int)($n / 2)) - (int)$n;
} else {
    $tmp = (int)floor((int)$n / 2);
    echo (int)((int)((int)($n + 1) * (int)$tmp) + (int)((int)$tmp + 1)) - (int)$n;
}

Measured memory_bytes: 4856
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MM = 1000000000;
const int MOD = MM + 7;
const int MAX = 510000;
#define rep(i, n) for(ll i=0; i<n; i++)
#define Rep(i, j, n) for(ll i=j; i<n; i++)
#define all(vec) vec.begin(), vec.end()
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;}
const ll INF = 1LL << 60;
const double pi = acos(-1.0);

int main() {
    ll n; cin >> n;
    vector<ll> a(n);
    rep(i, n) cin >> a[i];
    ll dp[n];
    rep(i, n) dp[i] = INF;
    ll now = 0;
    rep(i, n) {
        if(dp[now] < a[i]) {
            dp[now + 1] = a[i];
            now++;
        } else {
            ll l = -1, r = now;
            while(r - l > 1) {
                ll mid = (l + r) / 2;
                if(dp[mid] < a[i]) l = mid;
                else r = mid;
            }
            dp[r] = a[i];
        }
    }
    ll ans = 0;
    rep(i, n) if(dp[i] != INF) ans++;
    cout << ans << endl;
}



Measured memory_bytes: 4352
#include <stdio.h>

int check(int *a, int x)
{
	int i = 0;
	while (a[i])
	{
		if (x == a[i])
			return 1;
		i++;
	}
	return (0);
}

int		main(void)
{
	int n,m,x;
	scanf("%d%d%d", &n, &m, &x);
	int a[m];
	int i = 0;
	int count1 = 0;
	int count2 = 0;
	while (i < m)
		scanf("%d", &a[i++]);
	i = x;
	int zero = a[0] - 1;
	if (x <= n)
	{
		while (i < n)
		{
			if (check(a, i))
				count1++;
			i++;
		}
	}
	else
	{
		while (i > n)
		{
			if (check(a, i))
				count1++;
			i--;
		}
	}
	i = x;
	while (i > zero)
	{
		if (check(a, i))
			count2++;
		i--;
	}
	if (count1 < count2)
		printf("%d\n", count1);
	else
		printf("%d\n", count2);
	return (0);
}


Measured memory_bytes: 128
//2017-11-4
//miaomiao
//
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <iostream>
#include <algorithm>

using namespace std;

#define For(i, a, b) for(int i = (a); i <= (int)(b); ++i)
#define N (200000+5)

int a[N];
bool use[N];

int main(){
	int x, n;
	scanf("%d%d", &n, &x);
	
	if(x == 1 || x == 2*n-1){
		puts("No"); return 0;
	}

	puts("Yes");
	
	a[n-1] = x;
	if(x == 2){
		a[n] = x-1;
		
		int p = 0;
		For(i, 1, n*2-1){
			if(i == n-1 || i == n) continue;
			
			++p;
			if(p == x-1) p = x+1;
			a[i] = p;
		}
	}else{
		a[n] = x+1; a[n-2] = x-1; a[n+1] = x-2;
		use[x-1] = use[x] = use[x+1] = use[x-2] = true;
		
		int p = 1;
		For(i, 1, n*2-1){
			if(i >= n-2 && i <= n+1) continue;
		
			while(use[p]) ++p;
			use[p] = true; a[i] = p;
		}
	}

	For(i, 1, n*2-1) printf("%d\n", a[i]);

	return 0;
}

Measured memory_bytes: 2432
import heapq
n, m = map(int, input().split())
jobs = [[] for _ in range(m)]
for i in range(n):
    a, b = map(int, input().split())
    if a-1 < m:
        jobs[a-1].append(-b)

heap = []
ans = 0
for i in range(m):
    for reword in jobs[i]:
        heapq.heappush(heap, reword)
    if len(heap) > 0:
        b = heapq.heappop(heap)
        ans += -b
print(ans)

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

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

const ll mo=1000000007;
ll comb(ll N_, ll C_) {
	const int NUM_=2400001;
	static ll fact[NUM_+1],factr[NUM_+1],inv[NUM_+1];
	if (fact[0]==0) {
		inv[1]=fact[0]=factr[0]=1;
		for (int i=2;i<=NUM_;++i) inv[i] = inv[mo % i] * (mo - mo / i) % mo;
		for (int i=1;i<=NUM_;++i) fact[i]=fact[i-1]*i%mo, factr[i]=factr[i-1]*inv[i]%mo;
	}
	if(C_<0 || C_>N_) return 0;
	return factr[C_]*fact[N_]%mo*factr[N_-C_]%mo;
}

int X1,Y1,X2,Y2;

void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>X1>>Y1>>X2>>Y2;
	ll ret=0;
	ll pat=0;
	FOR(i,Y1+1) pat+=comb(X1+Y1,i);
	ret=pat;
	for(y=Y1+1;y<=Y2;y++) {
		pat=(pat*2+comb(X1+y-1,y))%mo;
		(ret+=pat)%=mo;
	}
	for(x=X1+1;x<=X2;x++) {
		pat=(pat*2+mo-comb(x+Y2-1,x-1))%mo;
		(ret+=pat)%=mo;
	}
	pat=0;
	FOR(i,Y1) pat+=comb(X1+Y1,i);
	ret-=pat;
	for(x=X1+2;x<=X2+1;x++) {
		pat=(pat*2+mo-comb(x+Y1-2,x-1))%mo;
		ret-=pat;
	}
	for(y=Y1;y<Y2;y++) {
		pat=(pat*2+comb(X2+1+y-1,X2))%mo;
		ret-=pat;
	}
	
	cout<<(ret%mo+mo)%mo<<endl;
	
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	cout.tie(0); solve(); return 0;
}

Measured memory_bytes: 56448
#include <stdio.h>
#include <stdlib.h>
#include <math.h>

#define MAXOP 100
#define NUMBER '0'

int getop(char []);
void push(double);
double pop(void);

/*逆ポーランド電卓プログラム*/
main()
{
	int type;
	double op2;
	char s[MAXOP];

	while((type = getop(s)) != EOF) {
		switch (type) {
		case NUMBER:
			push(atof(s));
			break;
		case '+':
			push(pop() + pop());
			break;
		case '*':
			push(pop() * pop());
			break;
		case '-':
			op2 = pop();
			push(pop() - op2);
			break;
		case '/':
			op2 = pop();
			if (op2 != 0.0)
				push(pop() / op2);
			else
				printf("error: zero divisor\n");
			break;
		case '\n':
			printf("%g\n", pop());
			break;
		default:
			printf("error: unknown command %s\n", s);
			break;
		}
	}
	return 0;
}

#define MAXVAL 100

int sp = 0;
double val[MAXVAL];

/* push: fを値スタックにプッシュする*/
void push(double f)
{
	if (sp < MAXVAL)
		val[sp++] = f;
	else
		printf("error: stack full, can't push %g\n", f);
}

/* pop: スタックをポップし，一番上の値を返す*/
double pop(void)
{
	if (sp > 0)
		return val[--sp];
	else {
		printf("error: stack empty\n");
		return 0.0;
	}
}

#include <ctype.h>

int getch(void);
void ungetch(int);

/* getop:　次の演算子あるいは数値の被演算数をとってくる*/
int getop(char s[])
{
	int i, c;

	while ((s[0]= c = getch()) == ' ' || c == '\t')
		;
	s[1] = '\0';
	if (!isdigit(c) && c != '.')
		return c;	/*　cは数ではない */
	i = 0;
	if (isdigit(c)) /*　整数部を集める　*/
		while (isdigit(s[++i] = c = getch()))
			;
	if (c == '.') /*　小数部を集める　*/
		while (isdigit(s[++i] = c = getch()))
			;
	s[i] = '\0';
	if (c != EOF)
		ungetch(c);
	return NUMBER;
}

#define BUFSIZE 100

char buf[BUFSIZE];
int bufp =0;

int getch(void) /* 1文字を取ってくる */
{
	return (bufp > 0) ? buf[--bufp] : getchar();
}

void ungetch(int c) /* 文字を入力に戻す */
{
	if (bufp >= BUFSIZE)
		printf("ungetch: too many characters\n");
	else
		buf[bufp++] = c;
}

Measured memory_bytes: 568
#include <stdio.h>
int main(){
  int N,A[100],i,j,a,count;
  scanf("%d",&N);
  for(i=0;i<N;i++) scanf("%d",&A[i]);

  for(i=0;i<N;i++){
    for(j=N-1;j>=i+1;j--){
      if(A[j]<A[j-1]){
        a = A[j];
        A[j] = A[j-1];
        A[j-1] = a;
        count++;
      }
    }
  }
  for(i=0;i<N;i++){
    if(i==0) printf("%d",A[i]);
    else printf(" %d",A[i]);
  }
  printf("\n");
  printf("%d\n",count);
  return 0;
}


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

int main() {
    int N, K;
    cin >> N >> K;
    
    int a = N/K;
    int cnt=1;
    for(int i=1; i<N; i++){
      if(N-1 <= (K-1)*i) break;
      cnt++;
    }
    
    cout << cnt << endl;
    
    return 0;
}

Measured memory_bytes: 256
using System;

namespace abc077A
{
    class MainClass
    {
        public static void Main(string[] args)
        {
            string A = Console.ReadLine();
            string[] s = new string[3];
            for(int i = 0; i < 3; i++)
            {
                s[i] = A.Substring(i, 1);
            }
            string B = Console.ReadLine();
            if (B == s[2] + s[1] + s[0])
                Console.WriteLine("YES");
            else
                Console.WriteLine("NO");
        }
    }
}


Measured memory_bytes: 13140