akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef pair<int, int> P;
#define MOD 1000000007
#define INF (1 << 30)
#define REP(i, m, n) for(int i = (int)m; i < (int)n; ++i)
#define rep(i, n) REP(i, 0, n)


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

    string s; cin >> s;
    int N = s.size();
    rep(i, N-8) cout << s[i];
    cout << '\n';
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int a;
  cin >> a;
  vector<int> b(a);
    int p = 1;
    for(int i = 0;i < a;i++){
      cin >> b.at(i);
    if(b.at(i) == p){p++;}
    }
  int m;
  m = a - p + 1;
  if(p == 1){m = -1;} 
  cout << m << endl;
 }

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef vector<int> vi;
#define INF 1000000000
#define mod 1000000007

void solve() {
    long long s = 0;
    int n;
    cin >> n;
    for (int i = 1; i <= n; ++i)
    for (int j = 1; j <= n; ++j)
    for (int k = 1; k <= n; ++k)
        s += __gcd(__gcd(i,j),k);
    cout << s << "\n";
}

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



Measured memory_bytes: 3640
using System;

class problem{
  public static void Main(){
    int n = int.Parse(Console.ReadLine());
    int[] num = new int[n];
    for(int i=0; i<n; i++){
      num[i] = int.Parse(Console.ReadLine());
    }
    max m = new max(num);
    for(int i=0; i<n; i++){
      if(num[i] == m.retmax1()){
        Console.WriteLine(m.retmax2());
      }
      else{
        Console.WriteLine(m.retmax1());
      }
    }
  }
}

class max{
  int max1=0,max2=0;
  public int retmax1(){return max1;}
  public int retmax2(){return max2;}
  public max(int[] num){
    for(int i=0; i<num.Length; i++){
      if(max2 < num[i]){
        if(max1 < num[i]){
          max2 = max1;
          max1 = num[i];
        }
        else{
          max2 = num[i];
        }
      }
    }
  }
}


Measured memory_bytes: 18608
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define repo(i,n) for(int i = 1; i < (int)(n); i++)
#define pb push_back
#define np next_permutation
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()
#define mod 1000000007
#define pi acos(-1.0)
ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; }
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }
//cout << fixed << setprecision (20);   小数点以下2０桁まで
//intの最大値2147483647 ≒ 2×10^9
//long longの最大値9223372036854775807 ≒ 9×10^18
//'0'+=16;        で大文字に
//'大文字'+=32;    で小文字に
//s[i]-'0'でchar文字→int数に;
//string s = to_string(int数);
//int n = stoi(string文字列)
//実行時間制約2秒では２×10^8回くらいまで計算できる


int main() {
  int n,a,b;
  cin>>n>>a>>b;
  
  cout << ((a-b)%2==0?"Alice":"Borys") << endl;
  
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <bitset>
#include <algorithm>
#include <cmath>
#include <limits>
#define FOR(x,n) for(int i = (x); i < (n); i++)
#define FOR2(x,n) for(int j = (x); j < (n); j++)
#define FOR3(x,n) for(int k = (x); k < (n); k++)
using namespace std;

int main(void){
    int N, ans = 0;
    cin >> N;
    vector<int> data(N);
    if (N < 3)
    {
        cout << 0 << endl;
        return 0;
    }
    FOR(0, N)
        cin >> data[i];
    FOR(0, N - 2)
    {
        FOR2(i + 1, N - 1)
        {
            if (data[i] == data[j])
                continue;
            FOR3(j + 1, N)
            {
                if (data[i] == data[k] || data[j] == data[k])
                    continue;
                if (data[i] + data[j] > data[k] && data[i] + data[k] > data[j] && data[j] + data[k] > data[i])
                {
                    ans++;
                    // cout << i + 1 << j + 1 << k + 1 << endl;
                }
            }
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3608
N = int(input())
xyh = [list(map(int,input().split(' '))) for i in [0]*N]


ls = [[0]*101 for i in [0]*101]

cor = [[i,j] for i in range(101) for j in range(101)]


for cx,cy in cor:
	H = 0
	for x,y,h in xyh:
		if h != 0:
			hx = abs(cx-x)
			hy = abs(cy-y)
			H = h + hx + hy
			break
	ok = True 
	for x,y,h in xyh:
		hx = abs(cx-x)
		hy = abs(cy-y)
		if h != max(H-hx-hy,0):
			ok = False
			break
	if ok:
		break

print(cx,cy,H)






Measured memory_bytes: 4212
#include <iostream>
#include <string>
#include <time.h>
#include <algorithm>
#include <map>
#include <set>
#include <vector>
using namespace std;
typedef long long  ll;
static const ll INF = (ll)1 << 62;
#define rep(i,s,n)for(ll i=s;i<n;i++)
#define repe(i,s,n)for(ll i=s;i<=n;i++)

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

	k--;
	repe(i, 0, s.size()) {
		if (i == k) {
			if (s[i] == 'A') s[i] = 'a';
			else if (s[i] == 'B') s[i] = 'b';
			else if (s[i] == 'C') s[i] = 'c';
		}
	}
	cout << s << endl;
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<algorithm>
using namespace std;
long long dp[13][1<<18];
int L[10];
int R[10];
int main(){
	int a;
	while(scanf("%d",&a),a){
		for(int i=0;i<a;i++){
			scanf("%d%d",L+i,R+i);
		}
		for(int i=0;i<13;i++)for(int j=0;j<(1<<(a*3));j++)dp[i][j]=0;
		for(int i=1;i<10;i++){
			int to=0;
			if(L[0]<=i&&i<=R[0])to+=1;
			if((L[0]/10<=i&&i<R[0]/10)||(L[0]/10==R[0]/10&&i==L[0]/10))to+=2;
			if(L[0]/10<i&&i<=R[0]/10)to+=4;
			dp[1][to]++;
		}
		for(int i=1;i<a*2;i++){
			for(int j=0;j<(1<<(a*3));j++){
				if(!dp[i][j])continue;
				if(!j)continue;
			//	printf("%d %d: %lld\n",i,j,dp[i][j]);
				for(int k=0;k<10;k++){
					int to=0;
					for(int l=0;l<a*3;l++){
						if(!(j&(1<<l)))continue;
						if(l==a*3-3)continue;
						if(l%3==0){
							if(k==0)continue;
							if(L[l/3+1]<=k&&k<=R[l/3+1])to|=(1<<(l+3));
							if((L[l/3+1]/10<=k&&k<R[l/3+1]/10)||(L[l/3+1]/10==R[l/3+1]/10&&k==L[l/3+1]/10))to|=(1<<(l+4));
							if(L[l/3+1]/10<k&&k<=R[l/3+1]/10)to|=(1<<(l+5));
						}else if(l%3==1&&(j&(1<<(l+1)))){
							to|=(1<<(l-1));
						}else if(l%3==1){
							if(L[l/3]/10==R[l/3]/10){
								if(L[l/3]%10<=k&&k<=R[l/3]%10)to|=(1<<(l-1));
							}else if(L[l/3]%10<=k)to|=(1<<(l-1));
						}else{
							if(k<=R[l/3]%10)to|=(1<<(l-2));
						}
					}
					if(to)dp[i+1][to]+=dp[i][j];
				}
			}
		}
		long long ret=0;
		for(int i=0;i<=a*2;i++){
			for(int j=0;j<(1<<(a*3));j++){
				if(j&(1<<(a*3-3)))ret+=dp[i][j];
			}
		}
		printf("%lld\n",ret);
	}
}

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

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

  ll ans = 0;
  for(int a = 1; a <= n-1; a++){
    for(int b = 1; b <= n-1; b++){
      if(a*b>=n) break;
      else ans++;
    }
  }

  cout << ans << endl;

  return 0;
}


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

int masu[20][20];
int W,H;

int dfs(int x,int y){
     if(x>=W||y>=H||x<0||y<0)return 0;
     if(masu[x][y]==1)return 0;
     masu[x][y]=1;
     return dfs(x+1,y)+dfs(x,y+1)+dfs(x-1,y)+dfs(x,y-1)+1;
}

int main(){
     while(1){
	  cin>>W>>H;
	  if(W==0)break;
	  int pos[2];
	  for(int j=0;j<H;j++){
	       string temp;
	       cin>>temp;
	       for(int i=0;i<W;i++){
		    switch(temp[i]){
		    case '.':
			 masu[i][j]=0;
			 break;
		    case '@':
			 masu[i][j]=0;
			 pos[0]=i;pos[1]=j;
			 break;
		    case '#':
			 masu[i][j]=1;
			 break;
		    }
	       }
	  }
	  int ans=dfs(pos[0],pos[1]);
	  cout<<ans<<endl;
     }
}

Measured memory_bytes: 0
n = int(input())
a = {}
for i in range(n):
  a[i+1] = int(input())

p = 1
ok = 0

for i in range(n):
  p = a[p]
  if p == 2:
    ok = 1
    break

if ok == 1:
  print(i+1)
else:
  print(-1)

  

Measured memory_bytes: 17892
#include <bits/stdc++.h>
#define rep(i,n)for(int i=0;i<(n);i++)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef tuple<ll,ll,ll> T;
const long long INF = 1LL<<60;
const int MOD = 1000000000+7;
#define rev(s) (string((s).rbegin(), (s).rend()))
// cout << fixed << setprecision(10) << ans << endl; 有効桁数指定
// *min_element(c + l, c + r) *max_element(c + l, c + r) 配列の中のmin-max
// int dx[8]={1,1,0,-1,-1,-1,0,1};
// int dy[8]={0,1,1,1,0,-1,-1,-1};
// int dx[4]={1,0,-1,0};
// int dy[4]={0,1,0,-1};
// ~ は、-1の時だけfalse

int a[100010];

int main () {

    int n;cin>>n;

    rep(i,n) cin>>a[i];

    sort(a,a+n);

    if (n%2==0) {
        ll ans=1;
        for (int i=0;i<n;i+=2) {
            if (a[i]!=i+1||a[i+1]!=i+1) {
                cout<<0<<endl;
                return 0;
            }
            ans=ans*2%MOD;
        }
        cout<<ans%MOD<<endl;
    } else {
        ll ans=1;
        if (a[0]!=0) {
            cout<<0<<endl;
            return 0;
        }
        for (int i=1;i<n;i+=2) {
            if (a[i]!=i+1||a[i+1]!=i+1) {
                cout<<0<<endl;
                return 0;
            }
            ans=ans*2%MOD;
        }
        cout<<ans%MOD<<endl;
    }

}

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

    int main() {
      int A; cin >> A;  // 開始≧１００００
      int B; cin >> B;  // 終了≦９９９９９
      int R = 0;        // 結果
      
      int i = 0;
      for(i=A;i<=B;i++){

        int w = i; // 計算用ワーク
        int i1 = w % 10; // １の位

        w /= 10;
        int i2 = w % 10; // １０の位

        w /= 10;
        w /= 10;
        int i4 = w % 10; // １０００の位
        w /= 10;
        int i5 = w % 10; // １００００の位
        
        if ( i1 == i5 && i2 == i4) {
          R += 1;
//          cout << i << endl;  // 回文数
        }
      }
        cout << R << endl;
    }

Measured memory_bytes: 256
n, l = map(int, input().split())
list_taste = [l+i for i in range(n)]
 
if 0 in list_taste:
  ans = sum(list_taste)
else:
  if list_taste[0] > 0:
  	ans = sum(list_taste) - min(list_taste)
  else:
    ans = sum(list_taste) - max(list_taste)

print(ans)

Measured memory_bytes: 3060
N, K, C = map(int, input().split())
S = input()
A = []
cnt = 0
for i, s in enumerate(S, 1):
    if cnt > 0:
        cnt -= 1
    elif s == "o":
        cnt = C
        A.append(i)
if len(A) > K:
    exit()
B = []
cnt = 0
for i, s in zip(range(N, 0, -1), S[::-1]):
    if cnt > 0:
        cnt -= 1
    elif s == "o":
        cnt = C
        B.append(i)
assert len(B) == K
B.reverse()
Ans = []
for a, b in zip(A, B):
    if a == b:
        Ans.append(a)
print("\n".join(map(str, Ans)))


Measured memory_bytes: 42116
N = int(input())
H = list(map(int,input().split()))
Height = H[0]-1
Judge = True
for i in range(N):
    if H[i] - Height == 0:
        Height = H[i]
    elif H[i] - Height == 1:
        Height = H[i] - 1
    elif H[i] - Height > 1:
        Height = H[i] - 1
    else:
        Judge = False
if Judge:
    print('Yes')
else:
    print('No')

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


int keta_val[20];

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

	// 奇数はならない
	if ((N&1)==1) {
		cout << 0 << endl;
		return 0;
	}

	long long ans = 0;
	long long div = 10;
	while (N >= div) {
		ans += N / div;
		div *= 5;
	}

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


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

class Procon
{
    public Procon() { }
    static void Main(string[] agrs)
    {
        new Procon().Do();
    }

    Scanner cin;

    public void Do()
    {
        cin = new Scanner();
        string S = cin.nextString();
        long K = cin.nextLong();

        for (int i = 0; i < K; i++)
        {
            if (S[i] != '1')
            {
                Console.WriteLine(S[i]);
                return;
            }
        }
        Console.WriteLine(1);
    }
}

class Scanner
{
    string[] s;
    int i;
    int max_i;

    public Scanner()
    {
        s = new string[0];
        max_i = 0;
        i = 0;
    }

    public string nextString()
    {
        if (i >= s.Length)
        {
            s = Console.ReadLine().Split(' ');
            max_i = s.Length;
            i = 0;
            if (max_i == 0)
            {
                return "";
            }
            return s[i++];
        }
        else
        {
            return s[i++];
        }
    }

    public int nextInt()
    {
        return int.Parse(nextString());
    }


    public long nextLong()
    {
        return long.Parse(nextString());
    }

    public double nextDouble()
    {
        return double.Parse(nextString());
    }

    public string[] arrayString()
    {
        return Console.ReadLine().Split(' ');
    }

    public int[] arrayInt()
    {
        string[] str = Console.ReadLine().Split(' ');
        int[] array = new int[str.Length];
        for (int i = 0; i < str.Length; i++)
        {
            array[i] = int.Parse(str[i]);
        }
        return array;
    }

    public long[] arrayLong()
    {
        string[] str = Console.ReadLine().Split(' ');
        long[] array = new long[str.Length];
        for (int i = 0; i < str.Length; i++)
        {
            array[i] = long.Parse(str[i]);
        }
        return array;
    }

    public double[] arrayDouble()
    {
        string[] str = Console.ReadLine().Split(' ');
        double[] array = new double[str.Length];
        for (int i = 0; i < str.Length; i++)
        {
            array[i] = double.Parse(str[i]);
        }
        return array;
    }
}


Measured memory_bytes: 13140
a, b, k = map(int, input().split())
n = b - a + 1
if n <= k * 2:
    for i in range(a, b + 1):
        print(i)
else:
    for i in range(a, a + k):
        print(i)
    for j in range(b - k + 1, b + 1):
        print(j)

Measured memory_bytes: 9128
H, W = [int(x) for x in input().split()]
c_h, c_w = [int(x) - 1 for x in input().split()]  # Convert to 0-origin
d_h, d_w = [int(x) - 1 for x in input().split()]  # Convert to 0-origin
s = [['.' for w in range(W)] for h in range(H)]
for h in range(H):
    s[h] = input()

def in_the_map(x):
    if x[0] < 0 or H <= x[0] or x[1] < 0 or W <= x[1]:
        return False
    return True
 
costs = [[-1 for w in range(W)] for h in range(H)]
 
def dfs(h, w, c, q):
    if not in_the_map((h, w)):
        return
    if costs[h][w] >= 0:
        return
    if s[h][w] != '.':
        return
    q.append((h, w))
    costs[h][w] = c 
    dfs(h - 1, w, c, q)
    dfs(h + 1, w, c, q)
    dfs(h, w - 1, c, q)
    dfs(h, w + 1, c, q)

queue = [(c_h, c_w)]
cost = 0
while len(queue) > 0:
    visited = []
    for q in queue:
        dfs(q[0], q[1], cost, visited)
    
    next_queue = []
    for v in visited:
        for dh in range(-2, 3):
            for dw in range(-2, 3):
                hh = v[0] + dh 
                ww = v[1] + dw
                if not in_the_map((hh, ww)):
                    continue
                if costs[hh][ww] >= 0:
                    continue
                if s[hh][ww] != '.':
                    continue
                next_queue.append((hh, ww))

    cost += 1
    queue = next_queue

print(costs[d_h][d_w])

Measured memory_bytes: 127048
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = s; i < (int)(n); i++)
#define chmax(a, b) a = max(a, b)
#define chmin(a, b) a = min(a, b)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

using namespace std;
using ll = long long;
using pii = pair<int, int>;

//const ll INF = 1e18L + 5;
//const int INF = 1e9 + 5;
//const double pi = 3.14159265358979323846;

void	solve()
{
	int k;
	cin >> k;

	int ans = 0;
	for (int i = 1; i <= k; i ++) {
		for (int j = i + 1; j <= k; j++) {
			if ((i % 2 && j % 2 == 0) || (i % 2 == 0 && j % 2))
				ans++;
		}
	}
	cout << ans << endl;
}

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

	solve();
}


Measured memory_bytes: 256
n=int(input())
A=[int(_) for _ in input().split()]
B=[int(_) for _ in input().split()]
C=[int(_) for _ in input().split()]
ans=sum(B)
for i in range(n-1):
    if A[i+1]==A[i]+1:
        ans+=C[A[i]-1]

print(ans)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i=0; i<n; i++)
#define rep1(i, n) for(int i=1; i<=n; i++)
#define repr(i, n) for(int i=n-1; i>=0; i--)
#define repr1(i, n) for(int i=n; i>=1; i--)
#define all(v) v.begin(),v.end()
using ll = long long;
using pii = pair<int, int>;
using pil = pair<int, ll>;
using pli = pair<ll, int>;
using pll = pair<ll, ll>;
const int INF = 1e9;
const ll LLINF = 1e18;
const ll MOD = 1e9+7;
const double EPS = 1e-10;
const double PI = acos(-1);
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int main() {
    int n; cin >> n;
    vector<int> res(n+1, 0);

    for (int x = 1; x <= 100; x++) {
        for (int y = 1; y <= 100; y++) {
            for (int z = 1; z <= 100; z++) {
                int t = x*x + y*y + z*z + x*y + y*z + z*x;
                if (t <= n) res[t]++;
            }
        }
    }

    for (int i = 1; i <= n; i++) cout << res[i] << endl;
}


Measured memory_bytes: 3572
#include <bits/stdc++.h>
using namespace std;
#define N 205
#define ll long long
#define set(a,v) memset(a,v,sizeof(a))
int T,n;ll a[N],v[65];char b[N];
void ins(ll _v)
{
	for(int i=60;i>=0;--i)
		if((_v>>i)&1) {if(!v[i]) v[i]=_v;_v^=v[i];}
}
bool find(ll _v)
{
	for(int i=60;i>=0;--i)
		if((_v>>i)&1) {if(!v[i]) return 0;_v^=v[i];}return 1;
}
void slv()
{
	set(v,0);scanf("%d",&n);
	for(int i=1;i<=n;++i) scanf("%lld",&a[i]);scanf("%s",b+1);
	for(int i=n;i>=1;--i)
		if(b[i]=='0') ins(a[i]);
		else if(!find(a[i])) {puts("1");return;}
	puts("0");
}
int main() {scanf("%d",&T);while(T--) slv();return 0;}

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

bool isPrime(int x) {
  if (x == 2) return true;
  if (x < 2 || x % 2 == 0) return false;

  int i = 3;
  while (i <= sqrt(x)) {
    if (x % i == 0) return false;
    i += 2;
  }
  return true;
}

int main() {
  int q;
  cin >> q;
  vector<int> v(100010, 0);
  int cnt = 0;
  for (int i = 1; i < 100010; i++) {
    if (isPrime(i) && isPrime((i + 1) / 2)) cnt++;
    v.at(i) = cnt;
  }

  for (int i = 0; i < q; i++) {
    int l, r;
    cin >> l >> r;
    cout << v.at(r) - v.at(l - 1) << endl;
  }
}


Measured memory_bytes: 1024
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <bitset>
#include <cmath>

static const int MOD = 1000000007;
using ll = long long;
using u32 = uint32_t;
using namespace std;

template<class T> constexpr T INF = ::numeric_limits<T>::max()/32*15+208;

int main() {
    int n, m;
    while(cin >> n >> m, n|m){
        vector<int> v(n);
        v[0] = 1;
        vector<array<int, 3>> p(m);
        for (int i = 0; i < m; ++i) {
            for (int j = 0; j < 3; ++j) {
                scanf("%d", &p[i][j]);
            }
        }
        sort(p.begin(),p.end());
        for (int i = 0; i < m; ++i) {
            v[p[i][2]-1] |= v[p[i][1]-1];
        }
        cout << count(v.begin(),v.end(), 1) << "\n";
    }
    return 0;
}


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

int main(){
  int n,x,i,j,k,l;
  int sum = 0,ans = 0;

  while(n!=0 || x!=0){
    cin >> n >> x;
    if(n==0 && x==0)break;
    else{
      for(i=1;i<=n;i++){
        for(j=i+1;j<=n;j++){
          for(k=j+1;k<=n;k++){
             if(i+j+k == x)ans++;
          }  
        }
      }
    }
    cout << ans << endl;
    ans = 0;
  }
}


Measured memory_bytes: 3092
import java.util.Scanner;
public class Main {
	void swap(){
		int x,y;
		Scanner s = new Scanner(System.in);
		x = s.nextInt();
		y = s.nextInt();
		while(x != 0 || y != 0){
			if(x < y){
				System.out.println(x + " " + y);
			}else{
				System.out.println(y + " " + x);
			}
			x = s.nextInt();
			y = s.nextInt();
		}
	}
	public static void main(String args[]){
		Main m = new Main();
		m.swap();
	}
}

Measured memory_bytes: 33988
// tested on node version 0.10.36
var fs = require("fs");

function count_combinations(n) {
    var count = 0;
    for(var a = 0; a < 10; a++) {
        for(var b = 0; b < 10; b++) {
            for(var c = 0; c < 10; c++) {
                for(var d = 0; d < 10; d++) {
                    if(a + b + c + d === n) {
                        count++;
                    }
                }
            }
        }
    }
    return count;
}

var input = fs.readFileSync('/dev/stdin').toString();
var lines = input.split("\n");
for(var i = 0; i < lines.length; i++) {
    var n = parseInt(lines[i]);
    if(!isNaN(n)) {
        console.log(count_combinations(n));
    }
}

Measured memory_bytes: 15944
#include <iostream>

using namespace std;

 int main()
{
    int a, b, c;
    cin >> a >> b >> c;
    if (a <= b && b <= c)
       cout << a << " " << b << " " << c << endl;
    else if(a <= c && c <= b)
       cout << a << " " << c << " " << b << endl;
    else if (b <= a && a <= c)
       cout << b << " " << a << " " << c << endl;
    else if (b <= c && c <= a)
       cout << b << " " << c << " " << a << endl;
    else if (c <= b && b <= a)
       cout << c << " " << b << " " << a << endl;
    else if(c <= a && a <= b)
       cout << c << " " << a << " " << b << endl;   

   
   return 0;
}


Measured memory_bytes: 3100
ini=map(int, raw_input().split())
kind=map(int, raw_input().split())
kind.sort()
kind.reverse()
a=0
b=0
for i in range(ini[1]):
	if i==0:
		a=kind[0]-1
		b=2
	else:
		if a>=kind[i]:
			a-=kind[i]
			if a==kind[i]:
				b+=kind[i]*2-1
			else:
				b+=kind[i]*2
		else:
			kind[i]-=a
			b+=kind[i]
			a=0

print a

Measured memory_bytes: 2696
def check(a,b):
    for i in range(3):
        diffc[i] = c[i][a]-c[i][b]
        diffr[i] = c[a][i]-c[b][i]
    if diffc[0] != diffc[1] or diffc[1] != diffc[2] or diffr[0] != diffr[1] or diffr[1] != diffr[2]:
        print("No")
        exit()
        

c = [[int(i) for i in input().split()] for i in range(3)]
diffr = [0]*3
diffc = [0]*3
check(0,1)
check(1,2)
print("Yes")

Measured memory_bytes: 3064
#define LOCAL
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<(n); ++i)
#define rrep(i, n) for(int i=(n-1); i>=0; --i)
#define rep2(i, s, n) for(int i=s; i<(n); ++i)
#define ALL(v) (v).begin(), (v).end()
#define memr(dp, val) memset(dp, val, sizeof(dp))
using namespace std;
typedef long long ll;
static const int INTINF = (INT_MAX >> 1); // 10^9 + 10^7
static const ll LLINF = (LLONG_MAX >> 1);
static const int MAX = 100001;
static const ll MOD = 1000000007;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<class T> inline bool int_ceil(T a, T b) { T res = a / b; if(a % b != 0) res++; return res; }
template<typename T>
using min_priority_queue = priority_queue<T, vector<T>, greater<T> >;
string to_string(string s) { return '"' + s + '"'; }
string to_string(bool b) { return b ? "true" : "false"; }
template <size_t N> string to_string(bitset<N> bs) {
  string res;
  for (size_t i = 0; i < N; ++i) res += '0' + bs[i];
  return res;
}
string to_string(vector<bool> v) {
  string res = "{";
  for (bool e : v) res += to_string(e) + ", ";
  return res += "}";
}
template <class T, class U> string to_string(pair<T, U> p);
template <class C> string to_string(C c) {
  string res = "{";
  for (auto e : c) res += to_string(e) + ", ";
  return res += "}";
}
template <class T, class U> string to_string(pair<T, U> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}
void debug() { cerr << '\n'; }
template <class Head, class... Tail> void debug(Head head, Tail... tail) {
  cerr << '\t' << to_string(head), debug(tail...);
}
#ifdef LOCAL
#define print(...) cerr << "[" << #__VA_ARGS__ << "]:", debug(__VA_ARGS__)
#else
#define print(...)
#endif

ll n, k;
vector<ll> v;
ll ans = 0;
bool rec(double mid){
	ll res = 0;
	rep(i, n){
		ll tmp = (double)v[i] / (double)mid;
		if(tmp < (double)v[i] / (double)mid) tmp++;
		res += tmp-1;
	}
	// print(res);
	if(res <= k) return  true;
	else return false;
}

int main(int argc, const char * argv[]) {
	std::cout << std::fixed << std::setprecision(15);

	cin >> n >> k;
	v.resize(n);
	rep(i, n) cin >> v[i];
	sort(ALL(v), greater<ll>());
	if(k <= 0){
		cout << v[0] << endl;
		return 0;
	}

	ll l = 1, r = 1e9+1;
	rep(_, 100){
		ll mid = (r + l) / 2;
		if(rec(mid)){
			r = mid;
		}
		else{
			l = mid;
		}
	}

	cout << (ll)r << endl;
	return 0;
}


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

int main() {
  string s, t;
  cin >> s >> t;
  
  int ans = t.size();
  for(int i = 0; i < s.size(); i++){
  	if(i + t.size() > s.size()) break;
    int cnt = 0;
    for(int j = 0; j < t.size(); j++){
      if(s.at(i+j) != t.at(j)) cnt++;
    }
    ans = min(ans, cnt);
  }
  cout << ans << endl;
}



Measured memory_bytes: 3592
#include <bits/stdc++.h>
 
#define ll long long
#define FOR(i,a,b) for (int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<(n);++i)
#define debug(x) cerr<<#x<<": "<<x<<'\n'
 
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;
 
int dy[]={0, 0, 1, -1, 0};
int dx[]={1, -1, 0, 0, 0};
 
template<class T=int>
T in(){T x;cin>>x;return (x);}
template<class T>
void print(T& x){cout<<x<<'\n';}
 
const int MOD =(int)1e9+7;
const int MAX =510000;
 
ll fac[MAX],finv[MAX],inv[MAX];
void COMint(){
    fac[0]=fac[1]=1;
    finv[0]=finv[1]=1;
    inv[1]=1;
    for(int i=2;i<MAX;i++){
        fac[i]=fac[i-1]*i%MOD;
        inv[i]=MOD-inv[MOD%i]*(MOD/i)%MOD;
        finv[i]=finv[i-1]*inv[i]%MOD;
    }
}
ll COM(int n,int k){
    if(n<k) return 0;
    if(n<0||k<0)return 0;
    return fac[n]*(finv[k]*finv[n-k]%MOD)%MOD;
}
 
ll gcd(ll a,ll b){
    if(b==0)return a;
    if(a>b){
        swap(a,b);
    }
    return gcd(a,b%a);
}
ll lcm(ll a,ll b){
    ll g;g=gcd(a,b);
    return a*b/g;
}
int main() {
    //COMint();
	int M_lim;
 	int N=in();
  	M_lim=sqrt(N);
  	vector<int> exp;
  	exp.push_back(1);
  	int ans;
  	ans=1;
  	for(int i=2;i<=M_lim;i++){
    	for(int j=2;j<11;j++){
        	if(pow(i,j)<=N){
            	if(pow(i,j)>ans)ans=pow(i,j);
            }else{
            	break;
            }
        }
    }
  	print(ans);
  	return 0;
}

Measured memory_bytes: 256
#abc174_e
from math import ceil
n,k=map(int,input().split())
a=list(map(int,input().split()))
a.sort()

if k==0:
    ans=max(a)
    print(ans)
    exit()
if k==1:
    if n==1:
        print(-(-a[0]//2))
        exit()
    ans=max(a[-1]/2,a[-2])
    print(ceil(ans))
    exit()
    
ok=10**9+1
ng=1
def check(x):
    k_cnt=0
    for q in a:
        k_cnt+=ceil(q/x-1)
    if k_cnt<=k:
        return True
    else:
        return False

    
for i in range(100):
    mid=(ok+ng)/2
    if check(mid):
        ok=mid
    else:
        ng=mid
    # print(ok,ng)
print(ceil(ok))


Measured memory_bytes: 104804
//author:luckYrat(twitter:@luckYrat_)
//#include <tourist>

//#include <bits/stdc++.h>

//def
#include <iostream>

#include <cmath>
#include <algorithm>
#include <iomanip>

//array
#include <vector>
#include <set>
#include <stack>
#include <queue>
#include <map>
#include <utility>
#include <climits>



using namespace std;

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

#define anyfill(n,s) setw(n) << setfill(s)
#define loop(s) for(int i = 0; s > i; i++)
#define rep(i,q) for(int i = 0; (q) > i; i++)
#define repp(i,n,q) for(int i = n; (q) > i; i++)
#define dep(i,q) for(int i = (q); 0 < i; i--)


#define MAX 1000000000
const int mod = 1000000007;
#define EPS (1e-10)

#define pb push_back
#define fir first
#define scn second
#define ednl endl

#define YesNo(a) (a?"Yes":"No")
#define YESNO(a) (a?"YES":"NO")
#define yesno(a) (a?"yes":"no")


P ar4[4] = {{0,1},{0,-1},{1,0},{-1,0}};
P ar8[8] = {{-1,-1},{-1,0},{-1,1},{0,-1},{0,1},{1,-1},{1,0},{1,1}};
/*
確認ポイント
cout << fixed << setprecision(n) << 小数計算//n桁の小数表記になる
vector.unique()は隣接した同じ要素を削除するので先にソートをする

計算量は変わらないが楽できるシリーズ
C++11以降でmin({a,b,c...})で複数個のmic,maxを処理できる
min(max)_element(iter,iter)で一番小さい(大きい)値のポインタが帰ってくる
count(iter,iter,int)でintがiterからiterの間にいくつあったかを取得できる

*/
__attribute__((constructor))
void initial() {
 cin.tie(0);
 ios::sync_with_stdio(false);
}
int main(){
  int a,b,m;cin>>a>>b>>m;
  int mna = 1000000;
  vector<int> A(a);
  for(int i = 0; a > i; i++){
    cin>>A[i];
    mna = min(mna,A[i]);
  }
  int mnb = 1000000;
  vector<int> B(b);
  for(int i = 0; b > i; i++){
    cin>>B[i];
    mnb = min(mnb,B[i]);
  }
  int ans = mna+mnb;

  for(int i = 0; m > i; i++){
    int x,y,z;cin>>x>>y>>z;
    x--;y--;
    ans = min(ans,A[x]+B[y]-z);
  }
  cout << ans << endl;
}

Measured memory_bytes: 1024
A, B = (int(x) for x in input().split())

Amin = 0
Amax = 0
if A%2 == 0:
    Amin = 100*A//8
    Amax = 100*(A + 1)//8
else:
    Amin = 100*A//8 + 1
    Amax = 100*(A + 1)//8 - 1
Bmin = 10*B
Bmax = 10*(B + 1) - 1
if Amin > Bmax or Bmin > Amax:
    print(-1)
else:
    if Amin < Bmin:
        print(Bmin)
    else:
        print(Amin)


Measured memory_bytes: 3064
#include<iostream>

using namespace std;

int gcd(int x, int y)
{
	int z;
	while(y) {
		z=x%y;
		x=y;
		y=z;
	}
	return x;
}

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	int x, y;
	cin>>x>>y;
	cout<<gcd(x, y)<<'\n';
	return 0;
}



Measured memory_bytes: 3192
#include <iostream>
#include <vector>
#include <string>
#include <map>
using namespace std;

int main(){
	int m, min, max;

	while (1){
		cin >> m >> min >> max;
		if (m == 0 && min == 0 && max == 0) break;
		vector<int> student;
		for (int i = 0; i < m; i++){
			int x;
			cin >> x;
			student.push_back(x);
		}
		int MaxGap = 0;
		int count = 0;
		for (int i = min; i <= max; i++){
			if (i == 0)continue;

			int gap = student[i-1] - student[i];
			if (MaxGap <= gap){
				count = i;
				MaxGap = gap;
			}
		}
		cout << count << endl;
	}

	return 0;
}

Measured memory_bytes: 3180
import sys
def rs(): return sys.stdin.readline().rstrip()
def ri(): return int(rs())
def rs_(): return [_ for _ in rs().split()]
def ri_(): return [int(_) for _ in rs().split()]

N, K = ri_()
a = [1] * N
for _ in range(K):
    d = ri()
    A = ri_()
    for i in A:
        a[i - 1] = 0
print(sum(a))

Measured memory_bytes: 9140
import java.util.*;

public class Main{
  public static void main(String[] args){
    Scanner sc =new Scanner(System.in);
    int a=sc.nextInt();
    int b=sc.nextInt();
    int c=sc.nextInt();
    System.out.println(a>b?0:(b/a<c?b/a:c));
  }
}

Measured memory_bytes: 22996
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.NoSuchElementException;

import java.util.*;

public class Main{
  static final boolean DEBUG = true;

  public static void main(String[] args){
    FastScanner sc = new FastScanner();

    int a = sc.nextInt();
    int b = sc.nextInt();
    int k = sc.nextInt();

    TreeSet< Integer > set = new TreeSet< >();
    for(int i = a; i <= Math.min(b, a + k - 1); i++){
      set.add(i);
    }
    for(int i = Math.max(a, b - k + 1); i <= b; i++){
      set.add(i);
    }

    StringBuilder sb = new StringBuilder();
    for(int i: set){
      sb.append(i + "\n");
    }

    System.out.print(sb);
  }
}

class FastScanner {
  private static final InputStream in = System.in;
  private static final PrintWriter out = new PrintWriter(System.out);
  private final byte[] buffer = new byte[2048];
  private int p = 0;
  private int buflen = 0;

  public FastScanner(){
  }

  private boolean hasNextByte() {
    if(p < buflen){
      return true;
    }
    p = 0;
    try{
      buflen = in.read(buffer);
    }catch (IOException e) {
      e.printStackTrace();
    }
    if(buflen <= 0){
      return false;
    }
    return true;
  }

  public boolean hasNext() {
    while(hasNextByte() && !isPrint(buffer[p])){
      p++;
    }
    return hasNextByte();
  }

  private boolean isPrint(int ch) {
    if(ch >= '!' && ch <= '~'){
      return true;
    }
    return false;
  }

  private int nextByte() {
    if(!hasNextByte()){
      return -1;
    }
    return buffer[p++];
  }

  public String next() {
    if(!hasNext()){
      throw new NoSuchElementException();
    }
    StringBuilder sb = new StringBuilder();
    int b = -1;
    while(isPrint((b = nextByte()))){
      sb.appendCodePoint(b);
    }
    return sb.toString();
  }

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

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

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


Measured memory_bytes: 23124
#include <cstdio>
#include <algorithm>
#include <cstdlib>
#include <cmath>

int main() {
	int N, B[20], A[20], C[19];
	std::scanf("%d", &N);
	for (int i = 0; i < N; ++i) {
		std::scanf("%d", A + i);
	}
	for (int i = 0; i < N; ++i) {
		std::scanf("%d", B + i);
	}
	for (int i = 0; i < N - 1; ++i) {
		std::scanf("%d", C + i);
	}

	int result = 0;
	int prev = -1;
	for (int i = 0; i < N; ++i) {
		result += B[A[i] - 1];
		if (prev != -1 && prev + 1 == A[i]) {
			result += C[prev - 1];
		}
		prev = A[i];
	}

	std::printf("%d", result);
}

Measured memory_bytes: 128
#include <bits/stdc++.h>  // clang-format off
using namespace std;
using Int = long long;
#define REP_(i, a_, b_, a, b, ...) for (int i = (a), lim_i = (b); i < lim_i; i++)
#define REP(i, ...) REP_((i), __VA_ARGS__, __VA_ARGS__, 0, __VA_ARGS__)
struct SetupIO { SetupIO() { cin.tie(nullptr), ios::sync_with_stdio(false), cout << fixed << setprecision(13); } } setup_io;
#ifndef _MY_DEBUG
#define dump(...)
#endif  // clang-format on

/**
 *    author:  knshnb
 *    created: Thu Mar  5 10:16:46 JST 2020
 **/

void yes() {
    cout << "Yes" << endl;
    exit(0);
}
signed main() {
    vector<int> a(9), filled(9);
    REP(i, 9) cin >> a[i];
    int n;
    cin >> n;
    REP(i, n) {
        int x;
        cin >> x;
        REP(j, 9) {
            if (a[j] == x) filled[j] = true;
        }
    }
    // horizontal
    REP(i, 3) {
        bool all = true;
        REP(j, 3) {
            if (!filled[3 * i + j]) all = false;
        }
        if (all) yes();
    }
    // vertical
    REP(j, 3) {
        bool all = true;
        REP(i, 3) {
            if (!filled[3 * i + j]) all = false;
        }
        if (all) yes();
    }
    // diagonal
    if (filled[0] && filled[4] && filled[8]) yes();
    if (filled[2] && filled[4] && filled[6]) yes();
    cout << "No" << endl;
}


Measured memory_bytes: 256
//#include <bits/stdc++.h>
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <stdio.h>
#include <complex>
#include <iomanip>
#include <queue>
//定数
#define MOD 1000000007
//マクロ
#define rep(i,n)    for(int (i)=0;(i)<(n);(i)++)
#define reprev(i,n) for(int (i)=(n-1);(i)>=0;(i)--)
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))

#define vsort(v) sort((v).begin(), (v).end());

typedef unsigned long long int ull;
typedef long long lint;

using namespace std;




int main(){
    int A, B;
    int ans;


    //入力
    cin >> A >> B;

    if(A <= 5) ans = 0;
    else if(A <= 12) ans = B/2;
    else ans = B;

    cout << ans << endl;
    

    return 0;
}

Measured memory_bytes: 256
S = input()
Q = int(input())

num_turn = 0

front = []
end = []

for i in range(Q):
    query = input()
    if query == '1':
        num_turn += 1
    else:
        _, f, c = query.split()
        f = int(f)
        if f == 1:
            if num_turn%2==0:
                front.append(c)
            else:
                end.append(c)
        else:
            if num_turn%2==0:
                end.append(c)
            else:
                front.append(c)

S = list(S)
if num_turn%2==1:
    ans = end[::-1] + S[::-1] + front
else:
    ans = front[::-1] + S + end
print(''.join(ans))

Measured memory_bytes: 10044
/// Code By t_bone_289 (Tushar Singh)
/// An Immature Programmer.... I'm still developing !!
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/trie_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define pll pair<ll,ll>
#define fi first
#define se second
#define mp make_pair
#define pb emplace_back
#define endl '\n'
#define M 1000000007
#define error(x) cout << #x << " = " << x << endl;
#define pi 3.14159265358979323846
typedef long long ll;
typedef long double ld;
template <typename T>
void ContainerError(T &v){cout<<"{";for(auto &x:v){cout<<x<<',';}cout<<"}"<<endl;return;}
typedef tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
ll powmod(ll base,ll exp,ll MOD){ll res=1;while(exp>0){if(exp%2==1) res=(res*base)%MOD;base=(base*base)%MOD;exp/=2;}return (res%MOD);}
ll mpow(ll base,ll exp){ll res=1;while(exp>0){if(exp%2==1) res=(res*base);base=(base*base);exp/=2;}return (res);}
ll gcd(ll a, ll b){return b?gcd(b,a%b):a;}
bool isP(string s,ll a,ll b)
{
	ll i=a;
	ll j = b;
	while(i<j)
	{
		if(s[i]!=s[j])return 0;
		i++;
		j--;
	}
	return 1;
}
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    string s;
    cin>>s;
    s = " "+s;
    ll n = s.size();
    n--;
    bool a = isP(s,1,n);
    bool b = isP(s,1,(n-1)/2);
    bool c = isP(s,(n+3)/2,n);
    a = (a&b&c);
    if(a)cout<<"Yes";
    else cout<<"No";
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
 
#define ll          long long
#define ld          long double
#define pb          push_back
#define pf          push_front
#define mp          make_pair
#define pll         pair<ll,ll>
#define vl          vector<ll>
#define sl          set<ll> 
#define vll         vector<pll>
#define ml          map<ll,ll>
#define mll         map<pll,ll>
#define all(a)      a.begin(),a.end()
#define x           first
#define y           second
#define sz(x)       (ll)x.size()
#define endl        '\n'
#define mod         (ll)1000000007
#define lp(i,a,b)   for(ll i=a;i<b;++i)
#define lpr(i,a,b)  for(ll i=a;i>=b;i--)
#define lpd(i,x)    for(auto i:x)
#define ios         ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
ll inf = (ll)1e18;
ld pi = 3.141592653589;
using namespace std;

ll bpow(ll x, ll v) {	
	if (v == 0)
		return 1 % mod;
	if (v % 2 == 1)
		return (x * bpow(x, v - 1)) % mod;
	ll r = bpow(x, v / 2);
	return (r * r) % mod;	
}

ll lcm(ll a,ll b)
{
	ll ret=(a*b)/__gcd(a,b);
	return ret;
} 

ll solve(){ 
	set<string> s;
	map<string,ll> m;
	ll n,mx=-1; cin>>n;
	lp(i,0,n){
		string p; cin>>p;
		s.insert(p);
		m[p]++;
		mx=max(mx,m[p]);
	}
	lpd(i,s){
		if(m[i]==mx)
			cout<<i<<endl;
	}

}
int main(){
    ios
    ll t=1; 
    //cin>>t;
    while(t--){
    	solve();
    }
}

Measured memory_bytes: 33280
def main():
    N = int(input())
    A = list(map(int, input().split()))
    B = list(map(int, input().split()))
    
    S = 0
    count = 0
    list_A = []
    
    for i in range(N):
        d = B[i] - A[i] #AをB以上にしないといけない
        if (0 < d):
            S += d
            count += 1
        else:
            if (d < 0):
                list_A.append(-d)
    list_A.sort()

    if (count == 0):
        return 0

    for s in reversed(list_A):
        S -= s
        count += 1
        if (S < 0):
            return count
    return -1
print(main())


Measured memory_bytes: 19536
sa = list(input())
sb = list(input())
sc = list(input())
now = 'a'

while True:
    if now == 'a':
        if not sa:
            winner = 'A'
            break
        new = sa.pop(0)
    elif now == 'b':
        if not sb:
            winner = 'B'
            break
        new = sb.pop(0)
    elif now == 'c':
        if not sc:
            winner = 'C'
            break
        new = sc.pop(0)
    now = new
print(winner)



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

int main(){
  string s;
  cin >> s;
  stack<char> st;
  for(char c : s){
      if(st.empty() || st.top() == c)
          st.push(c);
      else
          st.pop();
  }
  cout << s.size() - st.size() << "\n";  
}

Measured memory_bytes: 512
#include <iostream>
#include <utility>
#include <string>
#include <algorithm>
#include <map>
#include <vector>
#include <climits>
using namespace std;
signed main()
{
	ios::sync_with_stdio(false);
	int n, m;
	cin >> n >> m;
	long long x[3][1003];
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < 3; j++) {
			cin >> x[j][i];
		}
	}
	long long ans = 0;
	long long tmp[1003];
	for (int z = 0; z < 8; z++) {
		long long cand = 0;
		for (int i = 0; i < 1003; i++) {
			tmp[i] = 0;
		}
		for (int i = 0; i < n; i++) {
			for (int j = 0; j < 3; j++) {
				if (((z >> j)&1) == 0) {
					tmp[i] += -1*(x[j][i]);
				}
				else {
					tmp[i] += x[j][i];
				}
			}
		}
		sort(tmp, tmp + n);
		for (int i = 0; i < m; i++) {
			cand += tmp[n-1-i];
		}
		ans = max(ans, cand);
	}
	cout << ans;

}

Measured memory_bytes: 256
w,h,n = map(int,input().split())
xl = []
yl = []
al = []
for _ in range(n):
  x,y,a = map(int,input().split())
  xl.append(x)
  yl.append(y)
  al.append(a)

sx = 0
gx = w
sy = 0
gy = h

for i in range(len(al)):
  if al[i] == 1 and sx < xl[i]:
      sx = xl[i]
      if sx > gx:
        print(0)
        exit()
  elif al[i] == 2 and gx > xl[i]:
      gx = xl[i]
      if sx > gx:
        print(0)
        exit()
  elif al[i] == 3 and sy < yl[i]:
      sy = yl[i]
      if sy > gy:
        print(0)
        exit()
  elif al[i] == 4 and gy > yl[i]:
      gy = yl[i]
      if sy > gy:
        print(0)
        exit()
  if i == len(al)-1:
    print((gx-sx)*(gy-sy))
    


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

int ans[51];
int main(){
	int n,m;
	int a,b;
	
	cin >> n >> m;
	for(int i = 1;i<=m;i++){
		cin >> a >> b;
		ans[a]++;
		ans[b]++;
	}
	for(int i = 1;i<=n;i++){
		cout << ans[i] << endl;
	}
}

Measured memory_bytes: 256
#include <stdio.h>

int gcd(int ,int);

int main(){
  int x,y,min;

  scanf("%d%d",&x,&y);

  if(x<y){
    min=x;
    x=y;
  }
  else min=y;
  

  printf("%d\n",gcd(x,min));

  return 0;
}

int gcd(int x,int y){ /* この関数は代入時にはすでに「x」が大きな数となっている */
  int amari;

  while(y!=0){
   amari = x%y;
   x=y;
   y=amari;
  }
  
  return x;
}

  



Measured memory_bytes: 2072
#include <bits/stdc++.h>
using namespace std;
#ifdef ENABLE_DEBUG
#define dump(a) cerr<<#a<<"="<<a<<endl
#define dumparr(a,n) cerr<<#a<<"["<<n<<"]="<<a[n]<<endl
#else
#define dump(a) 
#define dumparr(a,n) 
#endif
#define FOR(i, a, b) for(ll i = a;i < b;i++)
#define For(i, a) FOR(i, 0, a)
#define REV(i, a, b) for(ll i = b-1;i >= a;i--)
#define Rev(i, a) REV(i, 0, a)
#define REP(a) For(i, a)

typedef long long int ll;
typedef unsigned long long ull;
typedef unsigned int uint;
typedef pair<ll, ll> pll;
typedef pair<ll,pll> ppll;
typedef vector<ll> vll;

const ll INF=(1LL<<50);

template<class S,class T>
std::ostream& operator<<(std::ostream& os,pair<S,T> a){
  os << "(" << a.first << "," << a.second << ")";
  return os;
}
template<class T>
std::ostream& operator<<(std::ostream& os,vector<T> a){
  os << "[ ";
  REP(a.size()){
    os<< a[i] << " ";
  }
  os<< " ]";
  return os;
}


void solve(long long a, std::string s){
  if(a<3200LL){
    cout<<"red"<<endl;
  }else{
    cout<<s<<endl;
  }
}

int main(){
    long long a;
    scanf("%lld",&a);
    std::string s;
    std::cin >> s;
    solve(a, s);
    return 0;
}


Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"io"
	"math"
	"os"
	"strconv"
	"strings"
)

func main() {
	io := NewIo(os.Stdin, os.Stdout)
	defer io.Flush()
	d = io.NextInt()
	c := io.NextInts(n)
	s := make([][]int, d)
	for i := 0; i < d; i++ {
		s[i] = io.NextInts(n)
	}
	ans := solve(c, s)
	for i := range ans {
		io.Println(ans[i])
	}
}

const (
	n    = 26
	ninf = -math.MaxInt64
)

var d int

func solve(c []int, s [][]int) []int {
	return greedy(c, s)
}

func greedy(c []int, s [][]int) []int {
	t := make([]int, d)
	lasts := make([]int, n)
	for i := 0; i < d; i++ {
		if i >= len(s) {
			break
		}
		_, ti := greedyStep(c, s, lasts, i+1)
		t[i] = ti
		lasts[ti-1] = i + 1
	}
	return t[:len(s)]
}

func greedyStep(c []int, s [][]int, lasts []int, day int) (int, int) {
	max, argmax := ninf, -1
	for i := 0; i < n; i++ {
		delta := calcDelta(c, s, lasts, day, i+1)
		if delta > max {
			max, argmax = delta, i+1
		}
	}
	return max, argmax
}

func calcDelta(c []int, s [][]int, lasts []int, day, contest int) int {
	up := s[day-1][contest-1]
	lasts[contest-1] = day
	down := calcDown(c, lasts, day)
	return up - down
}

func calcDown(c []int, lasts []int, day int) int {
	down := 0
	for i := 0; i < n; i++ {
		down += c[i] * (day - lasts[i])
	}
	return down
}

// Io is I/O object
type Io struct {
	reader    *bufio.Reader
	writer    *bufio.Writer
	tokens    []string
	nextToken int
}

// NewIo returns a new Io instance
func NewIo(r io.Reader, w io.Writer) *Io {
	return &Io{
		reader: bufio.NewReader(r),
		writer: bufio.NewWriter(w),
	}
}

// Flush flushes writer
func (io *Io) Flush() {
	err := io.writer.Flush()
	if err != nil {
		panic(err)
	}
}

// NextLine scans a line from stdin
func (io *Io) NextLine() string {
	var buffer []byte
	for {
		line, isPrefix, err := io.reader.ReadLine()
		if err != nil {
			panic(err)
		}
		buffer = append(buffer, line...)
		if !isPrefix {
			break
		}
	}
	return string(buffer)
}

// Next return a word from stdin
func (io *Io) Next() string {
	for io.nextToken >= len(io.tokens) {
		line := io.NextLine()
		io.tokens = strings.Fields(line)
		io.nextToken = 0
	}
	r := io.tokens[io.nextToken]
	io.nextToken++
	return r
}

// NextInt returns an integer from stdin
func (io *Io) NextInt() int {
	i, err := strconv.Atoi(io.Next())
	if err != nil {
		panic(err)
	}
	return i
}

// NextInts returns n integers from stdin
func (io *Io) NextInts(n int) []int {
	ret := make([]int, n)
	for i := 0; i < n; i++ {
		ret[i] = io.NextInt()
	}
	return ret
}

// Println is a wrapper of fmt.Fprintln
func (io *Io) Println(a ...interface{}) {
	fmt.Fprintln(io.writer, a...)
}


Measured memory_bytes: 2156
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <set>
#include <string>
#include <cmath>
#include <map>
#include <iomanip>
#include <tuple>
#include <functional>
#include <bitset>
#define INF 1000000009
#define LINF 1000000000000000009
#define double long double
#define all(a) a.begin(),a.end()
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<ll, P> PP;
template<class T> bool chmax(T &a, const T&b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T&b) { if (a > b) { a = b; return 1; } return 0; }
ll gcd(ll n, ll m) { return (m ? gcd(m, n%m) : n); }
ll lcm(ll n, ll m) { return n / gcd(n, m)*m; }

template<class T>
class segtree {
	int n;
	vector<T> data;
	T def;
	function<T(T, T)> operation;
	function<T(T, T)> update;
	T _query(int a, int b, int k, int l, int r) {
		if (r <= a || b <= l) return def;
		if (a <= l && r <= b) return data[k];
		T c1 = _query(a, b, 2 * k + 1, l, (l + r) / 2);
		T c2 = _query(a, b, 2 * k + 2, (l + r) / 2, r);
		return operation(c1, c2);
	}
public:
	segtree(size_t _n, T _def, function<T(T, T)> _operation, function<T(T, T)> _update)
		:def(_def), operation(_operation), update(_update) {
		n = 1;
		while (n < _n) {
			n *= 2;
		}
		data = vector<T>(2 * n - 1, def);
	}
	void change(int i, T x) {
		i += n - 1;
		data[i] = update(data[i], x);
		while (i > 0) {
			i = (i - 1) / 2;
			data[i] = operation(data[i * 2 + 1], data[i * 2 + 2]);
		}
	}
	T query(int a, int b) {
		return _query(a, b, 0, 0, n);
	}
	T operator[](int i) {
		return data[i + n - 1];
	}
};

int main() {
	int n;
	cin >> n;
	vector<int> a(n), b(n);
	map<int, int> mp;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
		b[i] = a[i];
		mp[a[i]]++;
	}
	sort(all(b));
	for (int i = 0; i < n - 1; i++) {
		if (b[i + 1] != b[i]) {
			mp[b[i + 1]] += mp[b[i]];
		}
	}
	for (int i = 0; i < n; i++) a[i] = mp[a[i]];
	segtree<int> seg(n + 2, 0, [](int a, int b) {return max(a, b); }, [](int a, int b) {return b; });
	for (int i = 0; i < n; i++) {
		int c = seg.query(a[i], n + 2);
		seg.change(a[i], c + 1);
	}
	cout << seg.query(0, n + 2) << endl;
}

Measured memory_bytes: 6656