akhauriyash/Code-Regression huggingface dataset:
/**
 * Title: D - Blue and Red Balls
 * Url: https://atcoder.jp/contests/abc132/tasks/abc132_d
 */
#include<bits/stdc++.h>

using namespace std;

#define ll long long

const int MAX = 510000;
const int MOD = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

int main() {

    COMinit();

    int n, k; cin >> n >> k;

    for(int i=1; i<=k; i++) {
        cout << (COM(k-1, i-1) * COM(n-k+1, i))%MOD << endl;
    }

    return 0;
}

Measured memory_bytes: 12160
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int64_t i=0; i<n; i++)
const double PI=3.14159265358979323846;
const long long INF = 1LL << 60;

int main() {
	int64_t N;
	cin >> N;
	int64_t a=0, b=0, c=0, x, y, z;
	rep(i, 2001) {
		rep(j, 2001)  {
			x = (i-1000)*(i-1000)*(i-1000)*(i-1000)*(i-1000);
			y = (j-1000)*(j-1000)*(j-1000)*(j-1000)*(j-1000);
			if (x-y == N) {
				std::cout << i-1000 << " " << j-1000 << '\n';
				return 0;
			}
		}
	}
}


Measured memory_bytes: 3636
#!/usr/bin/env python3
import sys
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
read = sys.stdin.buffer.read
sys.setrecursionlimit(10 ** 7)
INF = float('inf')

N = int(input())
A = list(map(int, input().split()))

shojikin = 1000
stock = 0
for i in range(N):
    if stock:
        shojikin += stock * A[i]
        stock = 0
    if i+1 < N:
        if A[i] < A[i+1]:
            q, mod = divmod(shojikin, A[i])
            stock = q
            shojikin = mod

print(shojikin)


Measured memory_bytes: 9172
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef vector<ll> vl;
typedef pair<ll, ll> PP;
#define rep(i, n) for(ll i = 0; i < ll(n); i++)
#define all(v) v.begin(), v.end()
#define inputv(v, n)                                                           \
    vl v;                                                                      \
    rep(i, n) {                                                                \
        ll x;                                                                  \
        cin >> x;                                                              \
        v.push_back(x);                                                        \
    }
bool chmin(ll& a, ll b) { if (b < a) { a = b; return 1; } return 0; }
bool chmax(ll& a, ll b) { if (b > a) { a = b; return 1; } return 0; }
const ll INF = 999999999999999;
const ll MOD = 1000000007;
const ll MAX_N = 500010;
ll a, b, c, d, e, f, p, t, x, y, z, q, m, n, r, h, k, w, l, ans;
ll dp[3010][3010];
int main() {
    cin >> n >> t;
    vector<PP> V;
    rep(i, n) {
        cin >> x >> y;
        V.push_back({ y,x });
    }

    sort(all(V));
    reverse(all(V));

    for (ll i = n-1; i > -1; i--) {
        rep(j, t+1) {
        	dp[i][j]=dp[i+1][j];
            if(j>0)chmax(dp[i][j],dp[i][j-1]);
            if (j >=V[i].second)chmax(dp[i][j], dp[i+1][j - V[i].second] + V[i].first);
        }
    }

    a = 0;
    b = 0;
    c = 0;
    while (b <= t-1&&a<n) {
        chmax(ans, V[a].first + dp[a + 1][t-1 - b] + c);
        b += V[a].second;
        c += V[a].first;
        a++;
    }

    cout << ans << endl;
}


Measured memory_bytes: 70912
d,n=map(int,input().split())
if d==0:
  if n==100:
    print(101)
  else:
    print(n)
elif d==1:
  if n==100:
    print(10100)
  else:
    print(n*100)
elif d==2:
  if n==100:
    print(1010000)
  else:
  	print(n*10000)

Measured memory_bytes: 3060
#include <stdio.h> 
int main()
{
 int n,i,x; 
 scanf("%d",&n); 
 for(i=1;i<=n;i++)
 {
  x=i; 
  if(x%3==0)
  {
   printf(" %d",x); 
  } 
  else
  {
   while(x)
   {
    if(x%10==3)
    {
     printf(" %d",i);
     break; 
    } 
    x=x/10; 
   } 
  } 
 } 
 printf("\n"); 
 return 0; 
}


Measured memory_bytes: 2124
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <cmath>
#include <map>
#include <string>
#define int long long
#define REP(i,n) for(int i=0; i<n; i++)
#define pb push_back
#define mp make_pair
#define Pii pair< int, int > 
#define Pid pair< int, double > 
#define Pdd pair< double, double > 
#define MOD 998244353
#define EPS 0.00000001
#define MAX 200001

using namespace std;

signed main() {
    int h,w,k;
    cin >> h >> w >> k;
    vector<vector<int> > s(h, vector<int>(w));
    vector<vector<int> > st(h, vector<int>(w));
    string numt;
    REP(i,h) {
        cin >> numt;
        REP(j,w) s[i][j] = (int)(numt[j] - '0');
    }
    int bitmax = (int)pow(2,h-1);
    int ans = MAX;
    int anst;
    REP(i,bitmax) {
        anst = h-1;
        REP(it,h) REP(jt,w) st[it][jt] = s[it][jt];
        REP(shift,h-1) {
            int nowall = (i >> shift) % 2;
            if (nowall == 1) {
                anst--;
                REP(jt,w) {
                    st[shift + 1][jt] += st[shift][jt];
                    //cout << st[shift + 1][jt] << " ";
                    if (st[shift + 1][jt] > k) anst = MAX;
                }
                //cout << "\n";
            }
        }
        vector<int> rowsum(h);
        REP(j,w) {
            REP(it,h) {
                rowsum[it] += st[it][j];
                if(rowsum[it] > k) {
                    REP(itt,h) rowsum[itt] = st[itt][j];
                    anst++;
                    break;
                }
            }
        }
        //cout << i << " " << anst << "\n";
        if (anst < ans) {
            ans = anst;
        }
    }
    cout << ans << "\n";
    return 0;
}

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

int dfs(int now, vector<vector<int> > &adjlist, vector<bool> &used, int m){
  used[now] = true;
  int result = now < m ? 0 : 1;
  for(int i = 0; i < (int)adjlist[now].size(); i++){
    if(!used[adjlist[now][i]]){
      result += dfs(adjlist[now][i], adjlist, used, m);
    }
  }
  return result;
}

int main(void){
  int n, m;
  cin >> n >> m;

  int k, l;
  vector<vector<int> > adjlist(n + m);
  for(int i = 0; i < n; i++){
    cin >> k;
    for(int j = 0; j < k; j++){
      cin >> l;
      --l;
      adjlist[i + m].push_back(l);
      adjlist[l].push_back(i + m);
    }
  }

  vector<bool> used(n + m, false);
  int result = dfs(m, adjlist, used, m);
  if(result == n){ cout << "YES" << endl; }
  else{ cout << "NO" << endl; }

  return 0;
}


Measured memory_bytes: 8440
#include<bits/stdc++.h>
using namespace std;
#define ALL(v) (v).begin(),(v).end()
#define REP(i,p,n) for(int i=p;i<(int)(n);++i)
#define rep(i,n) REP(i,0,n)
#define SZ(x) ((int)(x).size())
#define debug(x) cerr << #x << ": " << x << '\n'
#define INF 999999999
typedef long long int Int;
typedef pair<int,int> P;
using ll = long long;
using VI = vector<int>;

int main(){
    int n,k;cin >> n >> k;
    vector<Int> num(k,0);
    for(int i=1;i<=n;i++) num[i%k]++;
    Int res = 0;
    for(int a=0;a<k;a++){
        int b = (k-a)%k;
        int c = (k-a)%k;
        if((b+c)%k!=0) continue;
        res += num[a] * num[b] * num[c];
    }
    cout << res << endl;
}

Measured memory_bytes: 1792
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <climits>

#define LP(i,n) for(int i=0;i<n;i++)
#define Mset(x,v) memset(x,v,sizeof(x))
#define INF INT_MAX

using namespace std;
using LL=long long;

int main(){
    int n,q,y1=1,y2;
    string name="kogakubu10gokan";
    cin>>n>>q;
    LP(i,n){
        cin>>y2;
        if(q<y2&&q>=y1){
            cout<<name<<endl;
        }
        cin>>name;
        y1=y2;
    }
    if(q>=y2) cout<<name<<endl;
    return 0;
}



Measured memory_bytes: 3196
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))

ans = 0
for i in range(N):
    b = B[i]
    a0, a1 = A[i], A[i+1]

    taosu0 = min(a0, b)
    b -= taosu0

    taosu1 = min(a1, b)
    A[i+1] -= taosu1

    ans += taosu0 + taosu1

print(ans)

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

using ll=long long;

int main() {
    ll i,N,x;
    cin >> N;
    x = N;

    for(i=1; i*i<=N; i++) {
        if(N%i == 0)
            x = min(x, i+N/i);
    }
  
  	if(x == N)
      x = N+1;

    cout << x-2 << endl;
}

Measured memory_bytes: 256
/*2020/03/15 ABC 050*/

#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using p = pair<int, int>;  


int main() {
    int n, m, p, x, sum=0;
    cin >> n;
    int t[n];
    for(int i=0; i<n; i++) {
        cin >> t[i];
        sum += t[i];
    }
    cin >> m;
    int ans[m];
    for(int i=0; i<m; i++) {
        cin >> p >> x;
        ans[i] =  sum + x - t[p-1] ;
    }

    for(int i=0; i<m; i++) cout << ans[i] << endl;
    
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>

int main(){
	
	int A,B,C,D,E,F,water,sugar,i,j,k,l,mass;
	double nodo,nodoans=0.0;
	
	scanf("%d",&A);
	scanf("%d",&B);
	scanf("%d",&C);
	scanf("%d",&D);
	scanf("%d",&E);
	scanf("%d",&F);
	
	int sugarans=0,waterans=100*A;
	
	
	for(i=0;100*A*i<=F;i++){
		for(j=0;100*B*j+100*A*i<=F;j++){
			if(i==0&&j==0){
				continue;
			}
			water=100*(A*i+B*j);
			for(k=0;C*k+water<=F;k++){
				for(l=0;D*l+water+C*k<=F;l++){
					
					sugar=C*k+D*l;
					if(sugar<=(water/100)*E){
						nodo=(sugar*100.0)/(water+sugar);
						if(nodoans<nodo){
					nodoans=nodo;
					sugarans=sugar;
					waterans=water;
					
					
					}
					}
				}
		
		
		
			}
		}
	}
	
	
	
	
	printf("\n%d %d\n\n",waterans+sugarans,sugarans);
	
	
	
	return 0;
}

Measured memory_bytes: 128
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <map>
#define INT long long
using namespace std;

int n, a[100100], b[100010], ans;
map<int, int> d;

int main()
{
    scanf("%d", &n);
    for(int i = 0 ; i < n ; i++ ) scanf("%d", a+i), b[i] = a[i], d[a[i]] = i%2;
    sort(b, b+n);
    for(int i = 0 ; i < n ; i++ )
        if( d[b[i]] != i%2 ) ans++;
    printf("%d\n", ans/2);
    return 0;
}


Measured memory_bytes: 5760
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
int main(){
  int A,B,C,K;
  cin>>A>>B>>C>>K;
  ll sum=0;
  if(K>=A){
    sum+=A;
    K=K-A;
  }else{
    sum+=K;
    cout<<sum<<endl;
    return 0;
  }
  if(K>=B){
    K=K-B;
  }else{
    cout<<sum<<endl;
    return 0;
  }
  
  if(K>=C){
    sum-=C;
    K=K-C;
  }else{
    sum-=K;
    cout<<sum<<endl;
    return 0;
  }
  cout<<sum<<endl;
}

Measured memory_bytes: 3636
#include <iostream>
#include <algorithm>

using namespace std;

int dp[3010][3010];
int main()
{
	string a, b;
	cin >> a >> b;
	int n = a.size(), m = b.size();
	for (int i = 1; i <= n; i++)
	{
		for (int j = 1; j <= m; j++)
		{
			if (a[i - 1] == b[j - 1])
				dp[i][j] = dp[i - 1][j - 1] + 1;
			else
				dp[i][j] = max(dp[i - 1][j], dp[i][j - 1]);
		}
	}
	int i = n, j = m;
	string out = "";
	int maxi = dp[n][m];
	while (j > 0 && i > 0)
	{
		if (a[i - 1] == b[j - 1])
		{
			if (dp[i - 1][j - 1] + 1 == dp[i][j])
			{
				out += b[j - 1];
				i--;
				j--;
				maxi--;
			}
		}
		else if (dp[i - 1][j] == maxi)
			i--;
		else
			j--;
	}
	for (int i = 0; i < out.size(); i++)
		cout << out[out.size() - i - 1];
	cout << endl;
}

Measured memory_bytes: 35584
#include <iostream>
#include <vector>
#include <utility>
#include <algorithm>
#include <cstdio>
using namespace std;

int main(void){
  while(true){
    int t, p, r;
    cin >> t >> p >> r;
    if(t == 0 && p == 0 && r == 0){ break; }

    vector<vector<int> > wa(t, vector<int>(p, 0));
    vector<pair<pair<int, int>, int> > penalty;
    for(int i = 0; i < t; i++)
      penalty.push_back(make_pair(make_pair(0, 0), i));

    int tID, pID, time;
    string message;
    for(int i = 0; i < r; i++){
      cin >> tID >> pID >> time >> message;
      --tID;
      --pID;
      if(wa[tID][pID] < 0){ continue; }
      if(message == "CORRECT"){
        --penalty[tID].first.first;
        penalty[tID].first.second += wa[tID][pID] * 1200 + time;
        wa[tID][pID] = -1;
      }
      else{ ++wa[tID][pID]; }
    }
    sort(penalty.begin(), penalty.end());

    for(int i = 0; i < t; i++){
      printf("%d %d %d\n", penalty[i].second + 1, -penalty[i].first.first, penalty[i].first.second);
    }
  }

  return 0;
}

Measured memory_bytes: 3360
const long mod=998244353;
const int M=1_000_00*4;

void main(){
  import std.stdio, std.algorithm;
  
  long n, a, b, k; rd(n, a, b, k);

  auto fact=genFact(M, mod);
  auto invFact=genInv(fact, mod);

  long comb(long nn, long rr){
    if(nn<rr) return 0;
    long ret=fact[nn]%mod;
    (ret*=invFact[rr])%=mod;
    (ret*=invFact[nn-rr])%=mod;
    return ret;
  }

  long tot=0;
  for(long x=0; x<=n; x++)if(k-a*x>=0){
    if((k-a*x)%b==0){
      long y=(k-a*x)/b;
      if(y>n) continue;
      (tot+=comb(n, x)*comb(n, y)%mod)%=mod;
    }
  }
  writeln(tot);
}

long[] genFact(int n, long mod){
  auto fact=new long[](n);
  fact[0]=fact[1]=1;
  foreach(i; 2..n) fact[i]=i*fact[i-1]%mod;
  return fact;
}

long[] genInv(long[] arr, long mod){
  auto inv=new long[](arr.length);
  inv[0]=inv[1]=1;
  foreach(i, elem; arr[1..$]) inv[i]=powmod(arr[i], mod-2, mod);
  return inv;
}

long powmod(long a, long x, long mod){
  if(x==0) return 1;
  else if(x==1) return a;
  else if(x&1) return a*powmod(a, x-1, mod)%mod;
  else return powmod(a*a%mod, x/2, mod);
}

void rd(T...)(ref T x){
  import std.stdio, std.string, std.conv;
  auto l=readln.split;
  assert(l.length==x.length);
  foreach(i, ref e; x) e=l[i].to!(typeof(e));
}


Measured memory_bytes: 9596
n = int(input())

felicidade = []

for x in range(n):
    felicidade.append(list(map(int,input().split())))

DP = [0,0,0]

if n == 1:
    print(max(felicidade[0]))

else:

    for x in range(3):
        DP[x] = felicidade[0][x]


    for dia in range(1,n):
        m = [0] * 3
        for x  in range(3):#As duas possíveis escolhas são x e y
            for y  in range(3):
                if x != y: #Se elas forem diferentes
                    m[x] = max(m[x], DP[y] + felicidade[dia][x])
        DP = m
    
    print(max(DP))


Measured memory_bytes: 90436
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		
		System.out.printf("%d %d %.6f\n", a/b,  a%b , (double)a/b);
	}
}	


Measured memory_bytes: 26620
import java.util.Scanner;

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();
		if (a < b && b < c) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}
	}
}


Measured memory_bytes: 26052
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;

typedef long long ll;
template <typename T>
    using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

template <char cmp = '<'>
    bool icmp(ll a, ll b){ if(cmp=='>') return a > b; else return a < b;}
namespace enhanced_pair{
    typedef pair<ll,ll> pll;
    ostream& operator << (ostream& o, const pll a){
        o<<a.first<<" "<<a.second;
        return o;
    }
    istream& operator >> (istream& i, pll& p){
        i>>p.first>>p.second;
        return i;
    }
    template <char cmp1 = '<', char cmp2 = '<'>
        bool pcmp(pll a, pll b){ return icmp<cmp1> (a.first,b.first) || (a.first==b.first && icmp<cmp2> (a.second,b.second));}
} using namespace enhanced_pair;
const ll NMAX = 1e7;
const ll MOD = 1e9+7;
ll lastbit(ll num){
    return num & -num;
}
ll binPow(ll num, ll p, ll mod = MOD){
    if(!p) return 1;
    ll aux = binPow(num,p/2);
    return aux*aux%mod*(p%2?num:1)%mod;
}
bool p[NMAX];
ll primes[NMAX],cnt;
void sieve(){
    for(ll i=4;i<NMAX;i+=2)
        p[i]=1;
    for(ll i=3;i*i<NMAX;i+=2){
        if(p[i]==0){
            for(ll j=i*i;j<NMAX;j+=i)
                p[j]=1;
        }
    }
    for(ll i=2;i<216;i++)
        if(!p[i])
            primes[cnt++]=i;
}
ll f(ll n){
    ll d=1,initialN=n;
    for(ll i=0;i<cnt && primes[i]*primes[i]*primes[i]<=n;i++){
        ll pw=0;
        while(n%primes[i]==0){
            n/=primes[i];
            pw++;
        }
        d*=(pw+1);
    }
    if(n==1) return d;
    if(p[n]==0)
        return d*2;
    else{
        ll x = sqrt(n);
        if(x*x==n && p[x]==0) return d*3;
    }
    return d*4;
}
int main()
{
    sieve();
    ll n,ans=0;
    cin>>n;
    for(ll i=1;i<=n;i++)
        ans+=i*f(i);
    cout<<ans;
    return 0;
}



Measured memory_bytes: 13392
#include<bits/stdc++.h>
using namespace std;
typedef pair<vector<int>,vector<int> > P;
typedef pair<int,int> S;

int w,h,n;
string s[20];
int ax[]={1,-1,0,0,0};
int ay[]={0,0,1,-1,0};

S i2s(int x){
  return S(x/2744,x%2744);
}
int s2i(const S& s){
  //cout<<s.first<<" "<<s.second<<":"<<(s.first<<13)+s.second<<endl;
  return (s.first*2744)+s.second;
}
S p2s(const P& p){
  int y=0,x=0;
  for(int i=n-1;i>=0;i--){
    y=y*14+p.first[i]-1;
    x=x*14+p.second[i]-1;
  }
  return S(y,x);
}

P s2p(const S& s){
  vector<int> y,x;
  int a=s.first,b=s.second;
  for(int i=0;i<n;i++){
    y.push_back(a%14+1);
    x.push_back(b%14+1);
    a/=14;b/=14;
  }
  return P(y,x);
}

int p2i(const P& p){
  return s2i(p2s(p));
}
P i2p(int x){
  return s2p(i2s(x));
}


int m[7530000];
queue<int> q;

vector<int> ys,xs;

int calc(){
  int y=0,x=0;
  for(int i=n-1;i>=0;i--){
    y=y*14+ys[i]-1;
    x=x*14+xs[i]-1;
  }
  return s2i(S(y,x));
}

void dfs(int d,P& p,int xyz){
  if(d==n){
    int abc=calc();
    if(~m[abc]) return;
    m[abc]=m[xyz]+1;
    q.push(abc);
    return;
  }
  for(int k=0;k<5;k++){
    int ny=p.first[d]+ay[k],nx=p.second[d]+ax[k];
    if(ny<0||h<=ny||nx<0||w<=nx) continue;
    if(s[ny][nx]=='#') continue;
    bool f=0;
    for(int j=0;j<d;j++){
      f|=(ys[j]==ny&&xs[j]==nx);
      f|=(ys[j]==p.first[d]&&xs[j]==p.second[d])&&
	 (ny==p.first[j]&&nx==p.second[j]);
    }
    if(f) continue;
    ys.push_back(ny);
    xs.push_back(nx);
    dfs(d+1,p,xyz);
    ys.pop_back();
    xs.pop_back();
  }
}

signed main(){
  while(cin>>w>>h>>n,w||h||n){
    cin.ignore();
    for(int i=0;i<h;i++) getline(cin,s[i]);
    vector<int> yt(n),xt(n);
    for(int i=0;i<h;i++)
      for(int j=0;j<w;j++)
	if(islower(s[i][j])){
	  yt[s[i][j]-'a']=i;
	  xt[s[i][j]-'a']=j;
	}
    memset(m,-1,sizeof(m));
    while(!q.empty()) q.pop();
    q.push(p2i(P(yt,xt)));
    m[p2i(P(yt,xt))]=0;
    int ans=-1;
    while(!q.empty()){
      int xyz=q.front();q.pop();
      P p=i2p(xyz);
      //cout<<xyz<<":"<<m[xyz]<<endl;
      //for(int i=0;i<n;i++) cout<<p.first[i]<<" "<<p.second[i]<<endl;
      bool flg=1;
      for(int i=0;i<n;i++)
	flg&=(s[p.first[i]][p.second[i]]=='A'+i);
      if(flg){
	ans=m[xyz];
	break;
      }
      dfs(0,p,xyz);
    }
    cout<<ans<<endl;
  }
  return 0;
}

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

using namespace std;

#define rep(i, a, b) for (int i = (a); i < (b); ++i)
#define sz(s) (int)s.size()

int d[100][100];

int main() {
    int h, w;
    cin >> h >> w;
    vector<string> ws(h);
    for (auto &s : ws) cin >> s;
    if (ws[0][0] == '#' || ws[h - 1][w - 1] == '#') {cout << -1; return 0;}
    memset(d, -1, sizeof(d));
    d[0][0] = 0;
    queue<int> q;
    q.push(0); q.push(0);
    int dx[] = {1, -1, 0, 0};
    int dy[] = {0, 0, -1, 1};
    while (!q.empty()) {
        int u = q.front(); q.pop();
        int v = q.front(); q.pop();
        rep(r, 0, 4) {
            int nu = u + dx[r], nv = v + dy[r];
            if (nu < 0 || nu >= h || nv < 0 || nv >= w) continue;
            if (ws[nu][nv] == '#') continue;
            if (d[nu][nv] == -1) {
                q.push(nu);
                q.push(nv);
                d[nu][nv] = d[u][v] + 1;
            }
        }
    }
    if (d[h - 1][w - 1] == -1) {cout << -1; return 0;}
    int not_paint = 0;
    rep(i, 0, h) rep(j, 0, w) {
        if (i == 0 && j == 0) continue;
        if (i == h - 1 && j == w - 1) continue;
        not_paint += (ws[i][j] == '.');
    }
    cout << not_paint - d[h - 1][w - 1] + 1 << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(v, a, b) for(int v = (a); v < (b); ++v)
#define FORE(v, a, b) for(int v = (a); v <= (b); ++v)
#define REP(v, n) FOR(v, 0, n)
#define REPE(v, n) FORE(v, 0, n)
#define REV(v, a, b) for(int v = (a); v >= (b); --v)
#define RS resize
#define CLR clear
#define PB push_back
#define ALL(x) (x).begin(), (x).end()
#define LLI long long int
using namespace std;

int powerMod(int n, int p, int m){
  if(p==0) return 1;
  if(p==1) return n;

  int x = 1;
  int k = powerMod(n, p/2, m);
  x = (1LL*x*k*k)%m;
  if(p%2) x = (1LL*x*n)%m;
  return x;
}

int modInverse(int n, int m){
  return powerMod(n,m-2,m);
}

int factorialMod(int n, int m){
  int k = 1;
  for(int i = 1; i <= n; ++i){
    k = (1LL*k*i) % m;
  }
  return k;
}

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

  int mod = 1000000007;
  int n;
  cin >> n;

  vector<int> a(n);
  REP(i,n) cin >> a[i];

  vector<LLI> inv(n);
  
  FOR(i,0,n) inv[i] = modInverse(i+1,mod);
  FOR(i,1,n) inv[i] = (1LL*inv[i-1]+inv[i])%mod;

  //REP(i,n) cout << inv[i] << endl;

  LLI ans=0;

  REP(i,n){
    (ans += (inv[i] + inv[n-i-1] - 1) * a[i]) %= mod;
  }

  int f = factorialMod(n, mod);
  ans = (ans*f) % mod;

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


Measured memory_bytes: 1408
#include <iostream>
#include <string>
#include <cstring>
#include <sstream>
#include <fstream>
#include <vector>
#include <algorithm>
#include <cmath>

using namespace std;

class cCard
{
public:
	char suit;
	int value;
	cCard(string t)
	{
		istringstream iss(t);
		iss >> suit >> value;
	}
};

class cCards
{
	int m_n;

public:
	bool isStable;
	vector<cCard> cc;

	cCards(string c, int n)
	{
		m_n = n;

		vector<string> tc;
		istringstream iss(c);
		while (!iss.eof())
		{
			string t;
			iss >> t;
			cCard tc(t);
			cc.push_back(tc);
		}
	}

	bool BubbleSort();
	void SelectionSort();
	string getStr();

};

bool cCards::BubbleSort()
{
	isStable = true;
	for (int i = 0; i < m_n; ++i)
	{
		for (int j = m_n - 1; j > i; --j)
		{
			if (cc[j].value < cc[j - 1].value)
			{
				swap(cc[j], cc[j - 1]);
				if (cc[j].value == cc[j - 1].value && cc[i].suit != cc[j - 1].suit)
				{
					isStable = false;
				}
				else
				{
					isStable = true;
				}
			}
		}
	}
	return isStable;
}

void cCards::SelectionSort()
{
	isStable = true;
	for (int i = 0; i < m_n; ++i)
	{
		int minj = i;
		for (int j = i; j < m_n; ++j)
		{
			if (cc[j].value < cc[minj].value)
			{
				minj = j;
			}
		}
		swap(cc[i], cc[minj]);
	}
}

string cCards::getStr()
{
	ostringstream oss;
	for (int i = 0; i < cc.size() - 1; ++i)
	{
		oss << cc[i].suit << cc[i].value << " ";
	}
	oss << cc[cc.size() - 1].suit << cc[cc.size() - 1].value;
	return oss.str();
}

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

	string C;
	getline(cin, C);

	cCards ccd1(C,N);
	string ans1 = ccd1.BubbleSort() ? "Stable" : "Not stable";
	cout << ccd1.getStr() << endl;
	cout << ans1 << endl;
	cCards ccd2(C,N);
	ccd2.SelectionSort();
	cout << ccd2.getStr() << endl;
	string ans2 = (ccd1.getStr() == ccd2.getStr()) ? "Stable" : "Not stable";
	cout << ans2 << endl;

	return 0;
}

Measured memory_bytes: 1244
import std.stdio;
import std.conv;
import std.string;
import std.typecons;
import std.algorithm;
import std.array;
import std.range;
import std.math;
import std.regex : regex;
import std.container;
import std.bigint;
import std.ascii;


void main()
{
  auto n = readln.chomp.to!int;
  int cnt;
  foreach (i; 1..n/2+1) {
    auto j = n - i;
    if (i < j) {
      cnt++;
    }
  }
  cnt.writeln;
}


Measured memory_bytes: 256
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <cmath>
#include <ctime>
#include <vector>
#include <cstdio>
#include <string>
#include <cstring>
#include <iostream>
#include <algorithm>

using namespace std;

#define LL long long
#define pii pair<int,int>
#define sd(x) scanf("%d",&x)
#define slld(x) scanf("%lld",&x)
#define pd(x) printf("%d\n",x)
#define plld(x) printf("%lld\n",x)
#define rep(i,a,b) for(int i = (a) ; i <= (b) ; i++)
#define per(i,a,b) for(int i = (a) ; i >= (b) ; i--)
#define mem(a) memset(a,0,sizeof(a))
#define lson l , m , rt << 1
#define rson m + 1 , r , rt << 1 | 1
#define fast_io ios::sync_with_stdio(false)

const int INF = 1e9;
const LL mod = 1e9 + 7;
const int maxn = 2e5 + 7;

int a[maxn];

int main() {
    double r;
    scanf("%lf",&r);
    printf("%lf\n",2 * acos(-1.0) * r);
    return 0;
}


Measured memory_bytes: 3824
h, w = map(int, input().split())
s = []
[s.append(list(input())) for x in range(h)]
for i in range(h):
    for j in range(w):
        if "." in s[i][j]:
            s[i][j] = 0
for i in range(h):
    for j in range(w):
        try:
            if "#" in s[i][j]:
                if i != 0 and j != 0:
                    s[i - 1][j - 1] += 1
        except IndexError:
            pass
        except TypeError:
            pass
        try:
            if "#" in s[i][j]:
                if i != 0:
                    s[i - 1][j] += 1
        except IndexError:
            pass
        except TypeError:
            pass
        try:
            if "#" in s[i][j]:
                if i != 0:
                    s[i - 1][j + 1] += 1
        except IndexError:
            pass
        except TypeError:
            pass
        try:
            if "#" in s[i][j]:
                if j != 0:
                    s[i][j - 1] += 1
        except IndexError:
            pass
        except TypeError:
            pass
        try:
            if "#" in s[i][j]:
                s[i][j + 1] += 1
        except IndexError:
            pass
        except TypeError:
            pass
        try:
            if "#" in s[i][j]:
                if j != 0:
                    s[i + 1][j - 1] += 1
        except IndexError:
            pass
        except TypeError:
            pass
        try:
            if "#" in s[i][j]:
                s[i + 1][j] += 1
        except IndexError:
            pass
        except TypeError:
            pass
        try:
            if "#" in s[i][j]:
                s[i + 1][j + 1] += 1
        except IndexError:
            pass
        except TypeError:
            pass
for i in s:
    print(''.join(map(str, i)))


Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define endl '\n'
#define SPEED ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
typedef vector<int>vi;
typedef pair<int,int>pi;
typedef vector<pi>vpi;
typedef vector<vi>vvi;
#define double long double
#define pow powl
#define sqrt sqrtl
#define cbrt cbrtl
#define floor floorl
#define ceil ceill
#define pb push_back
#define ep emplace_back
#define PB pop_back
#define pf push_front
#define ef emplace_front
#define PF pop_front
#define mp make_pair
#define ub(a,b) upper_bound(all(a),b)-a.begin()
#define lb(a,b) lower_bound(all(a),b)-a.begin()
#define bs(a,b) binary_search(all(a),b)
#define mem(a,b) memset(a,b,sizeof(a))
#define in(a,n) FOR(i,0,n-1) cin>>a[i]
#define in1(a,n) FOR(i,1,n) cin>>a[i]
#define ff first
#define ss second
#define out(a,n) FOR(i,0,n-1) cout<<a[i]<<" ";cout<<endl;
#define out1(a,n) FOR(i,1,n) cout<<a[i]<<" ";cout<<endl;
#define clr(a) a.clear()
#define pow2(a) (1LL<<a)
#define all(a) a.begin(),a.end()
#define all1(a) a.begin()+1,a.end()
#define rall(a) a.rbegin(),a.rend()
#define rall1(a) a.rbegin(),a.rend()
#define sz(a) ((int)a.size())
#define FOR(i,a,b) for(auto i=a;i<=b;i++)
#define NFOR(i,a,b) for(auto i=a;i>=b;i--)
const int mod=1e9+7;

inline int add(int a,int b){return (a%mod + b%mod)%mod;}
inline int sub(int a ,int b){return (a%mod - b%mod + mod)%mod;}
inline int mul(int a,int b){return (a%mod * b%mod)%mod;}
inline int power(int a,int b,int MOD){int res=1;while(b){if(b&1){res*=a;res%=MOD;}a=a*a;a%=MOD;b>>=1;}return res;}

#define trace(x) cout<<#x<<" :: "<<x<<endl;
#define trace2(x,y) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<endl;
#define trace3(x,y,z) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<"\t"<<#z<<" :: "<<z<<endl;
#define trace4(x,y,z,w) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<"\t"<<#z<<" :: "<<z<<"\t"<<#w<<" :: "<<w<<endl;
clock_t time_p = clock();
void time()
{
  time_p = clock() - time_p;
  cerr << "Time elapsed : " << (double)(time_p)/CLOCKS_PER_SEC <<endl;
}
signed main()
{
     SPEED;
     int n,l;
     cin>>n>>l;
     vector<string>v;
     while(n--)
     {
     	  string s;
     	  cin>>s;
     	  v.pb(s);
     }
     sort(all(v));
     for(auto x:v)
     	cout<<x;
     cout<<endl;
     time();
     return 0;
}

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

constexpr const int maxs = 4096;
int dp[maxs];

int main() {
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);
	memset(dp, 0x3f, 16384);
	dp[0] = 0;
	int n, m;
	cin >> n >> m;
	while (m--) {
		int a, b, s = 0;
		cin >> a >> b;
		while (b--) {
			int c;
			cin >> c;
			s ^= 1 << c - 1;
		}
		dp[s] = min(dp[s], a);
	}
	for (int i = 0; i != n; ++i) for (int all = (1 << n) - 1 ^ 1 << i, sub = all; sub; sub = sub - 1 & all)
		dp[sub] = min(dp[sub], dp[sub ^ 1 << i]);
	for (int s = 0; s != (1 << n); ++s) if (s != (s & -s))
		for (int t = s - 1 & s; t != s; t = t - 1 & s)
			dp[s] = min(dp[s], dp[t] + dp[s ^ t]);
	int mask = (1 << n) - 1;
	if (dp[mask] == 0x3f3f3f3f) dp[mask] = -1;
	cout << dp[mask] << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#pragma GCC optimize("O3")

#define fi first
#define se second
#define em emplace
#define eb emplace_back
#define mp make_pair
#define pi pair<int,int>
#define vi vector<int>
#define vpi vector<pair<int,int>>
#define vll vector<ll>
#define vpll vector<pair<ll,ll>>
#define endl '\n'

#define si(v) int(v.size())
#define all(v) v.begin(), v.end()
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define rep2(i, n, m) for (ll i = n; i <= (m); ++i)
#define rep3(i, n, m) for (ll i = n; i >= (m); --i)

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

using ll = long long;
using ld = long double;
using namespace std;

constexpr ll MOD = 1000000007;

signed main()
{
  cout << fixed << setprecision(20);
  ios::sync_with_stdio(false);
  cin.tie(0);
  
  int n; cin >> n;
  int cnt = 0;

  rep(i, n) {
    int a, b; cin >> a >> b;
    if (a == b) ++cnt;
    else cnt = 0;

    if (cnt == 3) {
      cout << "Yes" << endl;
      return (0);
    }
  }

  cout << "No" << endl;
  
  return (0);
}

Measured memory_bytes: 3632
D=int(input())
c=[]
c=list(map(int,input().split()))
s=[]
for i in range(D):
    s.append(list(map(int,input().split())))


t=[0 for i in range(D)]
for i in range(D):
    t[i]=int(input())






wa=0

last=[0 for i in range(26)]

for i in range(D):
    wa=s[i][t[i]-1]+wa
    last[t[i]-1]=i+1

    for j in range(26):
        wa=wa-c[j]*((i+1)-last[j])
    print(wa)


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

#define SZ(v) ((int)(v).size())
using ll = long long;

const int MAXN = 50;
const int MAXMON = 5000;

struct Arete
{
	int to, time, cost;
};

ll dp[MAXN][MAXMON];
bool seen[MAXN][MAXMON];
vector<Arete> G[MAXN];
pair<ll, ll> transaction[MAXN];

struct Situation
{
	ll dis, node, money;

	bool operator<(Situation other) const
	{
		return dis > other.dis;
	}
};

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

	int nb_sommets, nb_aretes, argent; 
	cin >> nb_sommets >> nb_aretes >> argent;
	argent = min(argent, MAXMON-1);

	for (int i(0); i < nb_aretes; ++i)
	{
		int u, v, time, cost;
		cin >> u >> v >> cost >> time;
		--u, --v;
		G[u].push_back({v, time, cost});
		G[v].push_back({u, time, cost});
	}
	for (int i(0); i < nb_sommets; ++i)
		cin >> transaction[i].first >> transaction[i].second;

	for (int i(0); i < nb_sommets; ++i)
		for (int j(0); j < MAXMON; ++j)
			dp[i][j] = 1e18;
	dp[0][argent] = 0;
	priority_queue<Situation> pq;
	pq.push({0, 0, argent});
	int nb(0);
	while (!pq.empty())
	{
		auto [dis, u, mon] = pq.top(); pq.pop();
		if (seen[u][mon]) continue;
		seen[u][mon] = true;
		{
			int nxt_mon = mon + transaction[u].first;
			nxt_mon = min(nxt_mon, MAXMON-1);
			ll d = dis + transaction[u].second;
			if (d < dp[u][nxt_mon])
			{
				dp[u][nxt_mon] = d;
				pq.push({d, u, nxt_mon});
			}
		}
		for (auto [v, t, c]  : G[u])
			if (c <= mon)
			{
				ll d = t + dis;
				if (d < dp[v][mon-c])
				{
					dp[v][mon-c] = d;
					pq.push({d, v, mon-c});
				}
			}
	}
	for (int i(1); i < nb_sommets; ++i)
	{
		ll sol(1e18);
		for (int mon(0); mon < MAXMON; ++mon)
			sol = min(sol, dp[i][mon]);
		cout << sol << '\n';
	}
}


Measured memory_bytes: 11608
import java.io.*;
import java.util.*;

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

    int S = scan.nextInt();

    int m = S % 60;
    int s = S / 60 % 60;
    int h = S / 3600;

    System.out.println(h + ":" + s + ":" + m);
    }
}

Measured memory_bytes: 26400
object Main extends App {

  import scala.io.StdIn.readLine
  val Array(n, l) = readLine().trim.split(" ").map(_.toInt)
  var arr = Array.fill(n)("")
  for (i <- 0 until n) {
    arr(i) = readLine().trim
  }
  println(arr.toList.sorted.mkString)

}


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

int main()
{
    int a, b, c, count=0;
    cin>>a>>b>>c;
    for (int i = a; i <= b; i++)
    {
        if(c%i==0) count++;
    }
    cout << count << endl;
    return 0;
}


Measured memory_bytes: 3128
//Subhash Suman
//Date: 13/02/19 ; Day: Wednesday ; Time: 12::02::44 
//Description : 

#include<bits/stdc++.h>
#define ll long long int
#define MAX INT_MAX
#define MIN INT_MIN
#define vi vector<int>
#define pii pair<int,int>
#define mii map<int,int>

using namespace std;
const int N = 1005;
ll mod = 1e9+7;
char arr[N][N];
ll ans[N][N];

int main(){
ios_base::sync_with_stdio(false);
cin.tie(NULL);
    int n,m;
    cin>>n>>m;
    for(int i = 0; i < n; i++){
        for(int j = 0; j < m; j++){
            cin>>arr[i][j];
        }
    }
    ans[0][0] = 1;
    for(int i = 1; i < n; i++){
        if(arr[i][0]=='.'){
            ans[i][0] = ans[i-1][0];
        }
        else{
            ans[i][0] = 0;
        }
    }
    for(int i = 1; i < m; i++){
        if(arr[0][i]=='.'){
            ans[0][i] = ans[0][i-1];
        }
        else {
            ans[0][i] = 0;
        }
    }
    for(int i = 1; i < n; i++){
        for(int j = 1; j < m; j++){
            if(arr[i][j]=='.'){
                ans[i][j] = (ans[i-1][j] + ans[i][j-1])%mod;
            }
            else {
                ans[i][j]=0;
            }
        }
    }
    cout<<(ans[n-1][m-1])%mod<<'\n';
    return 0;
}

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

int main() {
    int n;
    cin >>n;
    vector<bool> A(2001, false);
    A.at(0)=true;
    int MaxA=0;
    int AA;
    for (int i=0; i<n; i++) {
        cin >>AA;
        for (int j=min(MaxA, 2000); j>=0; j--) {
            if (A.at(j))
                A.at(j+AA)=true;
        }
        MaxA +=AA;
    }
    int q;
    cin >>q;
    for (int i=0; i<q; i++) {
        cin >>AA;
        if (A.at(AA))
            cout <<"yes" <<endl;
        else
            cout <<"no" <<endl;
    }
    return 0;
}


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

int main(){
    int a,b;
    cin >> a >> b;
    if(a<b){
        for(int i=0;i<b;i++){
            cout << a ;
        }
        cout << endl;
    }else{
        for(int i=0;i<a;i++){
            cout << b ;
        }
        cout << endl;
    }
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<math.h>
#include<vector>
#include<map>
#include<set>
#include<iomanip>

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

const int MOD = 1e9 + 7;
const int MAX = 1e9;
const ll LLMAX = 1e18;
const int INF = numeric_limits<int>::max();
const ll LLINF = numeric_limits<ll>::max();
const double PI = acos(-1.0);

#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rrep(i, a, n) for (int i = a; i <= (n); ++i)

int main() {
    char c[3]; cin >> c;

    if (c[0] == c[2]) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 3612
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sca = new Scanner(System.in);
		int n = sca.nextInt();
		int m = sca.nextInt();
		int[] ai = new int[m];
		long date = 0L;

		for(int i = 0; i < m; i++) {
			ai[i] = sca.nextInt();
			date += ai[i];
		}
		if(date > n) {
			System.out.println(-1);
		}
		else {
			System.out.println(n-date);
		}


		// 後始末
		sca.close();
	}
}

Measured memory_bytes: 46304
#include<math.h>
#include<cmath>
#include<bitset>
#include<stdio.h>
#include<string>
#include<map>
#include<algorithm>
#include<vector>
#include<iostream>
#include<utility>
using namespace std;
int main(){
    int i,n,sum=0,m,a;
    scanf("%d %d\n",&n,&m);
    for(i=0;i<m;i++){
        scanf("%d ",&a);
        sum+=a;
        if(sum>n){
            printf("-1\n");
            return 0;
        }
    }
    printf("%d\n",n-sum);
    return 0;
}

Measured memory_bytes: 3828
#include<iostream>
#include<string>
#include<algorithm>
#include <string.h>
#include <stdio.h>
#include <math.h>
#include <set>
#include <queue>
#include <stack>
#include <map>

using namespace std;
typedef int status;
typedef long long ll;
typedef unsigned long long ull;
const ull base = 343;
const int INF = int(1e9);
const int MAX = 200002;

int N;
int a[3][200];
int b[3][200];

int main()
{
    cin>>N;
    for(int i = 1;i <= 2;i++){
        for(int j = 1;j <= N;j++){
            cin>>a[i][j];
            b[i][j] += b[i][j-1] + a[i][j];
        }
    }
    int Max = 0;
    for(int i = 1;i <=N;i++)
    {
        int temp = b[1][i] + (b[2][N]-b[2][i-1]);
        if(temp > Max)
            Max =temp;
    }

    cout<<Max<<endl;


    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int M = sc.nextInt();
		int Q = sc.nextInt();
		Number[] number = new Number[Q];
		Main main = new Main();
		for (int i=0;i<Q;i++) {
			Number temp = main.new Number();
			temp.a = sc.nextInt();
			temp.b = sc.nextInt();
			temp.c = sc.nextInt();
			temp.d = sc.nextInt();
			number[i] = temp;
		}
		int select[] = new int[N];
		for (int i=0;i<N;i++) {
			select[i] =1;
		}
		int max=0;
		int sum =0;
		while (true) {
			sum =0;
			for(int i=0;i<Q;i++) {
				if(select[number[i].b-1]-select[number[i].a-1]==number[i].c) {
					sum +=number[i].d;
				}
			}
			if (max<sum) {
				max =sum;
			}
			if(main.nextSelect(select, N,M)==false) {
				break;
			}
		}
		System.out.println(max);
	}
	public int doNext(int [] select ,int N ,int M) {
		int n = N-1;
		while (n>=0&&select[n]==M) {
			n--;
		}
		if (n==-1) {
			return 0;
		}
		select[n]+=1;
		for (int i=n+1;i<N;i++) {
			select[i]=select[n];
		}
//		for (int i=0;i<N;i++) {
//			System.out.print(select[i]);
//		}
//		System.out.println();
		return 1;
	}
	public boolean nextSelect(int[] select,int N,int M) {
		int n =N-1;
		while (true) {
			int returnValue = doNext(select,N,M);
			if (returnValue==0) {
				return false;
			}
			if (returnValue==1) {
				return true;
			}
		}
	}
	public class Number {
		public int a;
		public int b;
		public int c;
		public int d;

	}
}

Measured memory_bytes: 36600
N, C = gets.split.map(&:to_i)

stcs = N.times.map { gets.split.map(&:to_i) }
sorted = stcs.sort_by do |(s, t, _)|
  s
end
ch_tvshows = Array.new(C) { [] }
sorted.each do |(s, t, c)|
  c -= 1
  last_tvs = ch_tvshows[c].last
  if last_tvs && last_tvs[1] == s
    # merge
    ch_tvshows[c][-1] = [last_tvs[0], t]
  else
    ch_tvshows[c].push([s - 1, t])
  end
end
imos = Array.new(10 ** 5 + 1, 0)
ch_tvshows.flatten(1).each do |(s, t)|
  imos[s] += 1
  imos[t] -= 1
end
max = 0
current = 0
imos.each do |n|
  current += n
  max = current if current > max
end
puts max


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

int main() {
	// your code goes here
	int n;
	cin >> n;
	if(n==1){
		cout << "No" << endl;
	}
	else if(n==2){
		cout << "No" << endl;
	}
	else if(n==3){
		cout << "No" <<endl;
	}
	else if(n==5){
		cout << "No" << endl;
	}
	else if(n==6){
		cout << "No" << endl;
	}
	else if(n==9){
		cout << "No" << endl;
	}
	else if(n==10){
		cout << "No" << endl;
	}
	else if(n==13){
		cout << "No" << endl;
	}
	else if(n==17){
		cout << "No" << endl;
	}
	else cout << "Yes" << endl;
	return 0;
}

Measured memory_bytes: 256
N, M = map(int, input().split())
X = list(map(int, input().split()))
D = []

if M <= N:
    print(0)
    quit()
    
X.sort(reverse = True)

for i in range(M-1):
    D.append(X[i]-X[i+1])

D.sort(reverse = True)
ans = sum(D[N-1:])

print(ans)

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

#define FOR(i,a,b) for(int i = (a); i < (b); i++)
#define RFOR(i,b,a) for(int i = (b) - 1; i >= (a); i--)
#define ITER(it, a) for(typeof(a.begin()) it = a.begin(); it != a.end(); it++)
#define FILL(a, value) memset(a, value, sizeof(a))

#define SZ(a) (int) a.size()
#define ALL(a) a.begin(),a.end()
#define PB push_back
#define MP make_pair

typedef long long LL;
typedef vector<int> VI;
typedef pair<int, int> PII;

const double PI = acos(-1.0);
const LL INF = 1000 * 1000 * 1000 + 7;
const LL LINF = INF * (LL)INF;

int solve(int x, int y)
{
	if (x == y) return 0;
	if (abs(x) == abs(y)) return 1;

	int res = 0;

	if (abs(x) < abs(y))
	{
		if (x < 0)
		{
			x = -x;
			res++;
		}
	}
	else
	{
		if (x > 0)
		{
			x = -x;
			res++;
		}
	}

	res += abs(abs(x) - abs(y));

	x += abs(abs(x) - abs(y));

	if (x != y)
	{
		x = -x;
		res++;
	}
	return res;

}

int main()
{
	//freopen("in.txt", "r", stdin);
	//ios::sync_with_Stdio(false); cin.tie(0);

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

	printf("%d\n", solve(x, y));
}


Measured memory_bytes: 256
#include <stdio.h>
#define N 100000

typedef struct
{
  int t;
  char name[10];
//  int back;
  int next;
}queue;

int main(void)
{
  queue Q[N];
  int n,q;
  int i,j;
  int total=0;
  int count=0;
  int check=0;
  scanf("%d %d",&n,&q);
//  scanf("%s %d",Q[0].name,&Q[0].t);
//  Q[0].next = 1;
//  Q[0].back = n-1;
//printf("n:%d\n",n);
  for(i=0;i<n-1;i++)
  {
    scanf("%s %d",Q[i].name, &Q[i].t);
      Q[i].next = i+1;
//    Q[i].back = i-1;
  }
//  printf("OK\n");
  scanf("%s %d",Q[n-1].name,&Q[n-1].t);
  Q[n-1].next = 0;
//  printf("OK2\n");
//  Q[n-1].back = n-2;
  i=n-1;
  while(1)
  {
    j=Q[i].next;
//    printf("i:%s j:%s ",Q[i].name,Q[j].name);
//    printf("time:%d\n",Q[j].t);


//    printf("check1\n");
    if(Q[j].t<=q)
      {
//        printf("check1-1\n");
        total+=Q[j].t;
//          Q[i].t=0;
        printf("%s %d\n",Q[j].name,total);
        count++;
//        printf("count:%d\n",count);
        if(count==n) break;
//        printf("inext:%s jnext:%s\n",Q[Q[i].next].name,Q[Q[j].next].name);
        Q[i].next = Q[j].next;
//          Q[Q[i].next].back = Q[i].back;
      }
      else
      {
//        printf("check1-2\n");
        total+=q;
        Q[j].t-=q;
        i = Q[i].next;
      }
//      printf("check2\n");

//      i++;//=Q[i].next;
//      if(i==n)i=0;
//    printf("inext:%s\n",Q[Q[i].next].name );
  }

  return 0;
}

Measured memory_bytes: 1584
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
const int inf = 1e9;

int main(){
    int n,m;
    cin >> n >> m;
    vector<int> a(n), num(m, 0);
    vector<vector<int>> sum(m, vector<int>(n+1, 0));
    for(int i=0; i<n; i++){
        cin >> a[i];
        a[i]--;
        num[a[i]]++;
        sum[a[i]][i+1] = 1;
    }
    for(int i=0; i<m; i++){
        for(int j=0; j<n; j++){
            sum[i][j+1] += sum[i][j];
        }
    }

    vector<int> dp(1<<m, inf);
    dp[0] = 0;
    for(int i=0; i<(1<<m); i++){
        int bef = 0;
        for(int j=0; j<m; j++){
            if(i>>j&1){
                bef += num[j];
            }
        }
        for(int j=0; j<m; j++){
            if(i>>j&1) continue;
            int k = i | (1<<j);
            dp[k] = min(dp[k], dp[i]+num[j]-(sum[j][bef+num[j]]-sum[j][bef]));
        }
    }
    cout << dp.back() << endl;
    return 0;
}



Measured memory_bytes: 14980
A, B, C, X, Y = map(int, input().split())
all = A * X + B * Y
all_half = max(X, Y) * C * 2
m = min(X, Y)
appropriate_half = (m * C * 2) + A * (X - m) + B * (Y - m)
print(min(all, all_half, appropriate_half))

Measured memory_bytes: 3060
#include <iostream>

using namespace std;

typedef long long ll;
const int MAX_N = 15;
const int MAX_S = 1010;
const int MAX_ADD = 110;
int n, s;
ll memo[MAX_ADD][MAX_N][MAX_S];

ll rec(ll add, ll num, ll sum)
{
    if (memo[add][num][sum] >= 0)
        return memo[add][num][sum];

    if (num == n && sum == s)
        return 1;
    if (add > 100 || sum > s || num > n)
        return 0;
    if ((n - num) * (add - 1) > s)
        return 0;

    ll res = 0;
    res += rec(add + 1, num, sum);
    res += rec(add + 1, num + 1, sum + add);

    return memo[add][num][sum] = res;
}

int main()
{
    while (cin >> n >> s, n || s) {
        for (int i = 0; i < MAX_ADD; i++)
            for (int j = 0; j < MAX_N; j++)
                for (int k = 0; k < MAX_S; k++)
                    memo[i][j][k] = -1;

        cout << rec(0, 0, 0) << endl;
    }

    return 0;
}

Measured memory_bytes: 14180
import math

a, b, h, m = map(int, input().split())

if (h * 60 + m) > 0:
    th = 2.0 * math.pi / (12 * 60) * (h * 60 + m)
else:
    th = 0.0
xh = a * math.cos(th)
yh = a * math.sin(th)

if m > 0:
    tm = 2.0 * math.pi / 60 * m
else:
    tm = 0.0
xm = b * math.cos(tm)
ym = b * math.sin(tm)

d = ((xh - xm) ** 2 + (yh - ym) ** 2) ** 0.5
print(d)


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

long long n,t;
long long p;
long long ans;

inline long long qr()
{
	long long w=1,x=0;char a=0;
	while(a<'0'||a>'9'){if(a=='-')w=-1;a=getchar();}
	while(a>='0'&&a<='9'){x=(x<<3)+(x<<1)+(a^48);a=getchar();}
	return x*w;
}

int main()
{
	n=qr();
	t=qr();
	for(int i=1;i<=t;i++)
	{
		p=qr();
		ans+=p;
	}
	if(ans>=n)
		cout<<"Yes"<<endl;
	else
		cout<<"No"<<endl;
	return 0;
} 

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define maxn 100010
using namespace std;
typedef long long LL;
struct Edge {
    int to, ne;
    Edge(int _to=0, int _ne=0): to(_to), ne(_ne) {}
}edge[maxn*2];
int tot, ne[maxn];
void add(int u, int v) {
    edge[tot] = Edge(v, ne[u]);
    ne[u] = tot++;
}
int n, m, c[maxn];
void dfs(int u, int col) {
    c[u] = col;
    for (int i = ne[u]; ~i; i = edge[i].ne) {
        int v = edge[i].to;
        if (c[v] == -1) dfs(v, !col);
        if (c[v] != !col) { printf("%lld\n", 1LL*n*(n-1)/2-m); exit(0); }
    }
}
int main() {
    scanf("%d%d", &n, &m);
    memset(c, -1, sizeof(c));
    memset(ne, -1, sizeof(ne));
    for (int i = 0; i < m; ++i) {
        int u, v;
        scanf("%d%d", &u, &v);
        add(u, v);
        add(v, u);
    }
    dfs(1, 0);
    int b=0, w=0;
    for (int i = 1; i <= n; ++i) if (c[i]) ++b; else ++w;
    printf("%lld\n", 1LL*b*w-m);
    return 0;
}

Measured memory_bytes: 3072