akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define forna(i,a,n) for(int i=a;i<n;i++)
typedef long long int lli;
using namespace std;

int main()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);
lli t,n,m;string s,s2;
// cin>>t;
// while(t--){
cin>>s;
s2+='S';
s2+=s;
s2+='S';
vector<int>v,v2;
forna(i,0,s2.length()){
  if(s2[i]=='S') v.push_back(i);
}
// vector<int>v2;
forna(i,0,v.size()-1) v2.push_back(v[i+1]-v[i]-1);
sort(v2.begin(),v2.end());
 n=v2.size();
if(v2[n-1]>=0) cout<<v2[n-1]<<endl;
else cout<<0<<endl;
}


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

#define ll long long
#define fastio ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

using namespace std;
int a,b,c,d;
int main(){
	fastio
	int n;
	cin >> n;
	while(n--){
		string s;
		cin >> s;
		if(s=="AC") a++;
		else if(s=="WA") b++;
		else if(s=="TLE") c++;
		else if(s=="RE") d++;
	}
	cout << "AC x " <<  a << "\n";
	cout << "WA x " <<  b << "\n";
	cout << "TLE x " << c << "\n";
	cout << "RE x " << d << "\n";
}

Measured memory_bytes: 3652
#include <stdio.h>

int main( void )
{
int n, lank;
char pict[2];

int spades[13] = { 0 };
int hearts[13] = { 0 };
int clubs[13] = { 0 };
int diamonds[13] = { 0 };


scanf( "%d", &n );

for ( int i = 0; i < n; ++i ) {
scanf( "%s %d", pict, &lank );
if ( pict[0] == 'S' ) {
spades[lank - 1] = 1;
}
else if ( pict[0] == 'H' ) {
hearts[lank - 1] = 1;
}
else if ( pict[0] == 'C' ) {
clubs[lank - 1] = 1;
}
else { // 'D'
diamonds[lank - 1] = 1;
}
}

for ( int i = 0; i < 13; ++i ) {
if ( spades[i] == 0 ) {
printf( "S %d\n", i + 1 );
}
}
for ( int i = 0; i < 13; ++i ) {
if ( hearts[i] == 0 ) {
printf( "H %d\n", i + 1 );
}
}
for ( int i = 0; i < 13; ++i ) {
if ( clubs[i] == 0 ) {
printf( "C %d\n", i + 1 );
}
}
for ( int i = 0; i < 13; ++i ) {
if ( diamonds[i] == 0 ) {
printf( "D %d\n", i + 1 );
}
}

return 0;
}


Measured memory_bytes: 2612
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <math.h>
#include <queue>
using namespace std;
typedef long long ll;

int main() {
    int N, R;
    cin >> N;
    cin >> R;
    if (N >= 10) {
        cout << R << endl;
    } else {
        cout << R + (100 * (10 - N)) << endl;
    }
    return 0;
}

Measured memory_bytes: 256
package main

import (
	"fmt"
)

func main() {
	var n, W int
  	fmt.Scanf("%d%d", &n, &W)

	ws := make([]int, n)
	vs := make([]int, n)
	for i := 0; i < n; i++ {
		fmt.Scanf("%d%d", &ws[i], &vs[i])
	}

	dp := make([][]int, n+1)
	for i := range dp {
		dp[i] = make([]int, W+1)
	}

	for i := 1; i < n+1; i++ {
		for j := range dp[i-1] {
          	dp[i][j] = dp[i-1][j]
			if j-ws[i-1] >= 0 {
				dp[i][j] = max(dp[i][j], dp[i-1][j-ws[i-1]]+vs[i-1])
			}
		}
	}

	fmt.Println(dp[n][W])
}

func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

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


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

#ifdef DEBUG
    #include "debug.h"
    #define DEB
    #define dump(...)                                                              \
        DUMPOUT << "  " << string(#__VA_ARGS__) << ": "                            \
                << "[" << to_string(__LINE__) << ":" << __FUNCTION__ << "]"        \
                << endl                                                            \
                << "    ",                                                         \
            dump_func(__VA_ARGS__)
#else
    #define DEB if (false)
    #define dump(...)
#endif


// http://beet-aizu.hatenablog.com/entry/2018/04/08/145516
template<typename T>
vector<T> make_v(size_t a){return vector<T>(a);}

template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
  return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}

template<typename T,typename V>
typename enable_if<is_class<T>::value==0>::type
fill_v(T &t,const V &v){t=v;}

template<typename T,typename V>
typename enable_if<is_class<T>::value!=0>::type
fill_v(T &t,const V &v){
  for(auto &e:t) fill_v(e,v);
}

//////////////////

#define int long long
 
#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)

#define YES puts("YES")
#define Yes puts("Yes")
#define NO  puts("NO")
#define No  puts("No")
#define ALL(v) (v).begin(), (v).end()
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
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; }

/*
#define mod 1000000007 /*/
#define mod 998244353 //*/

typedef pair<int, int> P;
#define INF (1LL<<60)


void solve(){
    int A, B, C, D;
    cin >> A >> B >> C >> D;
    
    auto dp = make_v<int>(C+1,D+1);
    fill_v(dp, 0);
    
    dp[A][B]=1;

    for(int i=A; i<=C; i++){
        for(int j=B; j<=D; j++){
            if(i==A && j==B) continue;

            dp[i][j] = (dp[i-1][j] * j + dp[i][j-1] * i - dp[i-1][j-1] * (i-1) * (j-1)%mod + mod) % mod;
        }
    }
    cout << dp[C][D] << endl;

}


signed main(){
    cout << fixed << setprecision(18);
    cerr << fixed << setprecision(18);
    solve();
}


Measured memory_bytes: 73744
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define ALL(a) (a).begin(),(a).end()
using namespace std;
using ll = long long;
using P = tuple<ll,ll,int>;

int main(){
    int n; cin >> n;
    ll al = 0;
    vector<ll> a(n);
    rep(i,n) {
        cin >> a[i];
        al = al^a[i];
    }
    rep(i,n){
        ll ans = al^a[i];
        cout << ans << endl;
    }
}

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

using namespace std ;

const int MAX = 3e5 + 10 ;

int r[MAX] , c[MAX] , freq[MAX] ;
vector<int>v[MAX] ;

int n , m , q ;

int main()
{
	ios_base::sync_with_stdio(0) ;
	cin.tie(0) ;
	cin>>n>>m>>q ;
	int Max = 0 ;
	while(q--)
	{
		int i , j ;
		cin>>i>>j ;
		r[i]++ , c[j]++ ;
		Max = max(Max , c[j]) ;
		v[j].push_back(i) ;
	}
	int cnt = 0 ;
	for(int j = 1 ; j < MAX ; ++j)
	{
		if(c[j] != Max)
			continue ;
		cnt++ ;
		for(auto &i : v[j])
			freq[i]++ ;
	}
	int ans = 0 ;
	for(int i = 1 ; i < MAX ; ++i)
	{
		int x = Max ;
		if(freq[i] == cnt)
			x-- ;
		ans = max(ans , r[i] + x) ;
	}
	return cout<<ans<<"\n" , 0 ;
}

Measured memory_bytes: 23512
#include <cstdio>
int main()
{
	int N, C = 0, i, x;
	scanf("%d", &N);
	for(i=0; i<N; ++i)
	{
		scanf("%d", &x);
		if(x & 1) ++C;
	}
	puts(C&1 ? "NO" : "YES");
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
template <typename T> using vec = vector<T>;

int main()
{
    string s;
    cin >> s;
    bool flag =1;
    for (size_t i = 0; i < s.size(); i++)
    {
        if(s[i] != s[s.size()-i-1])
        {
            flag = false;
        }
    }
    for (size_t i = 0; i < s.size()/2; i++)
    {
        if (s[i] != s[s.size()/2-i-1])
        {
            flag = false;
        }
        
    }
    if (flag)
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }
    
    
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main() {

	/* ----- 変数宣言 ----- */
	int x;
	int a;
	int b;
	
	int ans=0;


	/* ----- 入力 ----- */
	cin >> x;
	cin >> a;
	cin >> b;

	/* ----- 計算 ----- */
	x -= a;

	while (x >= b)	x -= b;

	ans = x;

	cout << ans << endl;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#define rep(i, a, b) for (int i = (a), i##_end = (b); i < i##_end; ++i)
#define per(i, a, b) for (int i = (a), i##_end = (b); i >= i##_end; --i)

using namespace std;

deque<int> S;

int main()
{
	bool t = 1;
	int n;
	scanf("%d", &n);
	rep (i, 0, n)
	{
		int a;
		scanf("%d", &a);
		if (t) S.push_back(a);
		else S.push_front(a);
		t ^= 1;
	}
	if (t)
		rep (i, 0, n)
			printf("%d ", S[i]);
	else
		per (i, n-1, 0)
			printf("%d ", S[i]);
	puts("");
	return 0;
}


Measured memory_bytes: 2944
//#pragma GCC optimize("Ofast")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,fma")
//#pragma GCC optimize("unroll-loops")

#include "bits/stdc++.h"

using namespace std;

#define PI          3.1415926535897932384626433832795l

#define pb push_back
#define mp make_pair
#define lb lower_bound // First element which is not less than val
#define ub upper_bound // First element greater than val
#define f first
#define s second

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vb = vector<bool>;
using vd = vector<double>;
using vs = vector<string>;
using vpii = vector<pair<int,int>>;
using vpll = vector<pair<ll,ll>>;

using pii = pair<int,int>;
using pll = pair<ll,ll>;

#define endl '\n'
#define re return
#define repz(i, a) for (ll i = 0; i < (a); i++)
#define vecin(n,v) for(ll i = 0; i < n; i++) cin>>v[i];
#define full(v) v.begin(),v.end()

const int N = 1e5+7;
vi adj[N];
bool visited[N];

void dfs(int s)
{
  if (visited[s])
    return;
  visited[s]=true;

  for (auto u: adj[s])
  {
    dfs(u);
  }
}

void solve()
{
  int n,m;
  cin >> n >> m;
  ll ans = 0;

  repz(i,m)
  {
    int x,y;
    cin >> x >> y;
    x--;
    y--;
    adj[x].pb(y);
    adj[y].pb(x);
  }

  for (int i = 0; i < n; i++)
  {
     if (!visited[i])
     {
       dfs(i);
       ans++;
     }
  }

  cout << ans-1 << endl;

}

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

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



Measured memory_bytes: 9712
N,A,B = map(int,input().split())
a=0
b=0
c=0
d=0
e=0
y=0
for i in range(1,N+1,1):
  n = str(i)
 
  if int(n)==10000:
    e=n[0]
    d=n[1]
    c=n[2]
    b=n[3]
    a=n[4]
  if 1000<=int(n)<10000:
    d=n[0]
    c=n[1]
    b=n[2]
    a=n[3]
  if 100<=int(n)<1000:
    c=n[0]
    b=n[1]
    a=n[2]
  if 10<=int(n)<100:
    b=n[0]
    a=n[1]
  if int(n)<10:
    a=n[0]
  x = int(d) + int(c) + int(b) + int(a) + int(e)
  if A <= x <= B:
    y = y + int(n)
print(y)

Measured memory_bytes: 9268
#!/usr/bin/env python3
import math
n, k = map(int, input().split())
a = list(map(int, input().split()))
min_a = min(a)
ans = 0
l = 0
while l < n:
    if a[l] == min_a:
        l += 1
    else:
        if min_a in a[l : l + k - 1]:
            l += k
        else:
            l += k - 1
        ans += 1
print(ans)


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

int main()
{

    int K; // 黒く塗られた部分の連続数
    cin >> K;

    int X; // 座標Ｘ（既知の黒く塗られた箇所）
    cin >> X;

    int min = X - (K - 1); //最小値
    int max = X + (K - 1); //最大値
    int ans = 0;           //答え
    int count = max - min + 1;

    for (int i = 0; i < count; i++)
    {
        ans = min + i;
        cout << ans << " ";

        if (ans > max)
        {
            break;
        }
    }

}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<stack>
#include<queue>
#include<algorithm>
#include<cstring>
#include<map>
using namespace std;

const int maxn = 2e6 + 10;
typedef long long int ll;
ll mod = 998244353;
ll s[maxn * 4];
ll ans[maxn * 4],add[maxn * 4];

#define mid (l + r) / 2
#define lson (rt * 2)
#define rson (rt * 2) + 1

void pushdown(int rt,int l,int r){
    if(add[rt]){
        ans[lson] = (s[mid] - s[l - 1] + mod) % mod * add[rt] % mod;
        ans[rson] = (s[r] - s[mid] + mod) % mod * add[rt] % mod;
        add[lson] = add[rson] = add[rt];
        add[rt] = 0;
    }
}
void update(int rt,int ql,int qr,int l,int r,int v){
    if(l >= ql && r <= qr){
        ans[rt] = (s[r] - s[l - 1] + mod) % mod * v % mod;
        add[rt] = v;
        return ;
    }
    pushdown(rt,l,r);
    if(ql <= mid)update(lson,ql,qr,l,mid,v);
    if(qr > mid)update(rson,ql,qr,mid + 1,r,v);
    ans[rt] = (ans[lson] + ans[rson])% mod;
}
void solved(){
    int n,q;cin>>n>>q;
    /*s[n] = 1;
    for(int i = n - 1;i >= 1; i--)
        s[i] = ((s[i + 1] % mod) * 10) % mod;
    for(int i = 1; i <= n; i++)
        s[i] = ((s[i - 1] % mod) + s[i]) % mod;
    for(int i = 1; i <= n; i++)
        update(1,i,i,1,n,1);
    */
    s[1] = 1;
    for(int i = 2; i <= n; i++)
        s[i] = s[i - 1] * 10 % mod;
    for(int i = 1; i <= n; i++){
        s[i] = (s[i] + s[i - 1]) % mod;
        update(1,i,i,1,n,1);
    }
    while(q--){
        int l,r,v;cin>>l>>r>>v;
        l = n - l + 1;r = n - r + 1;
        swap(l,r);
        update(1,l,r,1,n,v);    
        printf("%lld\n",ans[1]);
    }
}
int main(){
    solved();
    return 0;
}

Measured memory_bytes: 12920
using System;

namespace abc122_b
{
    class Program
    {
        static void Main(string[] args)
        {
            int count = 0;
            int countmax = 0;
            string array = Console.ReadLine();
            for(int i = 0; i < array.Length; i++)
            {

                char ch = array[i];
                if (ch=='A'|| ch == 'T'|| ch == 'C'|| ch == 'G')
                {
                    count++;
                    if (countmax < count)
                    {
                        countmax = count;
                    }

                }
                else
                {
                    count = 0;
                }

            }
            Console.WriteLine(countmax);

        }
    }
}


Measured memory_bytes: 11092
#include <iostream>
#include <set>
#include <string>
#include <vector>

using namespace std;

int main(void) {
  size_t N;
  cin >> N;
  long long M = (1000000000 + 7);
  vector<long long> A(N), B(N);
  for (size_t i = 0; i < N; i++) cin >> A[i];
  B[N - 1] = A[N - 1];
  for (size_t i = 1; i < N; i++) {
    B[N - i - 1] = (A[N - i - 1] + B[N - i]) % M;
  }

  long long sum = 0;
  for (size_t i = 0; i + 1 < N; i++) {
    sum += (A[i] * B[i + 1]) % M;
    sum = sum % M;
  }

  cout << sum << endl;
  return 0;
}

Measured memory_bytes: 6412
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    int A,B;
    int i;
        cin >> A >> B;
    if(A==B)
    {
        cout << 2*A <<endl;
    }
    else
    {
        cout << 2*max(A,B) - 1 <<endl;
    }
    return 0;
    
}

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

int main(){

	int n, q;
	cin >> n >> q;
	vector< deque<int> > a(n);
	int querynum = 0;
	while (querynum < q) {
		int var1;
		cin >> var1;
		if (var1 == 0) {
			int var2, var3;
			cin >> var2 >> var3;
			a[var2].push_back(var3);
		}
		else if (var1 == 1) {
			int var2;
			cin >> var2;
			if (!a[var2].empty())  cout << a[var2].back() << endl;
		}
		else {
			int var2;
			cin >> var2;
			if (!a[var2].empty()) a[var2].pop_back();
		}
		querynum++;
	}
	
	return 0;
}


Measured memory_bytes: 4360
a = int(input())
b = int(input())
c = int(input())
x = int(input())

ll = []

for i in range(a+1):
    for j in range(b+1):
        for k in range(c+1):
            ll.append(10*i+2*j+k)
ans = 0
for s in ll:
    if s == x//50:
        ans += 1
    else:
        pass

print(ans)


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

vector<P> G[100000];
int used[100000];

P dfs(int n) {
	used[n] = 1;
	P res(n, 0);
	for (auto e : G[n]) {
		if (used[e.first] == 0) {
			auto p = dfs(e.first);
			if (p.second + e.second > res.second) {
				res = p;
				res.second += e.second;
			}
		}
	}
	used[n] = 0;
	return res;
}

int main()
{
	int n;
	cin >> n;
	for (int i = 0, s, t, w; i < n - 1; i++) {
		cin >> s >> t >> w;
		G[s].push_back(P(t, w));
		G[t].push_back(P(s, w));
	}
	auto s = dfs(0);
	auto t = dfs(s.first);
	cout << t.second << endl;
	return 0;
}

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

int main()
{
	int nInput[10000] = { 0 };
	int nIn = 1;
	int i = 0;
	while (nIn != 0)
	{
		cin >> nIn;
		nInput[i] = nIn;
		++i;
	}
	for (int j=0;j<i-1;++j)
	{
		cout << "Case " << j+1 << ": " << nInput[j] << endl;
	}
	//system("pause");
	return 0;
}

Measured memory_bytes: 3032
#include<bits/stdc++.h>
using namespace std;
int n,x[10005],sum,ans1,ans2;
int main() {
	scanf("%d",&n);
	for(int i=1; i<=n; i++)
		scanf("%d",&x[i]),sum+=x[i];
	sum/=n;
	for(int i=1; i<=n; i++)
		ans1+=(x[i]-sum)*(x[i]-sum);
	sum++;
	for(int i=1; i<=n; i++)
		ans2+=(x[i]-sum)*(x[i]-sum);
	printf("%d\n",min(ans1,ans2));
}

Measured memory_bytes: 256
#include<stdio.h>
int main(){
int n[28],i,j,a=0,b=0,flag;
for(i=0;i<28;i++){
scanf("%d\n",&n[i]);
}
for(j=1;j<=30;j++){
for(i=0;i<28;i++){
if(n[i]==j)flag=1;
}
if(flag==0){
if(a==0)a=j;else b=j;
}else{
flag=0;
}
if(b>0)break;
}
printf("%d\n%d\n",a,b);
return 0;
}

Measured memory_bytes: 600
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ll long long
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b;return true;}return false;}
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

vector<int> enum_div(int n){
    vector<int> ret;
    for(int i = 1 ; i*i <= n ; ++i){
        if(n%i == 0){
            ret.push_back(i);
            if(i*i != n){
                ret.push_back(n/i);
            }
        }
    }
    return ret;
}


int main() {
    int a,b,k;
    cin >> a >> b >> k;
    int gcd = __gcd(a,b);
    vector<int>common_divisors;
    common_divisors = enum_div(gcd);
    sort(common_divisors.begin(), common_divisors.end());
    reverse(common_divisors.begin(), common_divisors.end());
    cout << common_divisors.at(k-1) << endl;;

}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <chrono>
#include <random>
#include <bitset>
 
#pragma GCC optimize("Ofast")
//#pragma GCC optimization("unroll-loops, no-stack-protector")
//#pragma GCC target("avx,avx2,fma")
 
using namespace std;

using ll = long long;
using ld = long double;
using uint = unsigned int;
using ull = unsigned long long;
template<typename T>
using pair2 = pair<T, T>;
using pii = pair<int, int>;
using pli = pair<ll, int>;
using pll = pair<ll, ll>;

#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define endl '\n';
 
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
 
template <class T> inline T gcd(T a, T b) { while (b) { a %= b; swap(a, b); } return a; }
template <class T> inline T lcm(T a, T b) { return a * b / gcd(a, b); }

#ifdef LOCAL
    #define eprintf(...) fprintf(stderr, __VA_ARGS__);fflush(stderr);
#else
    #define eprintf(...) 42
#endif

clock_t startTime;
double getCurrentTime() {
    return (double)(clock() - startTime) / CLOCKS_PER_SEC;
}

const ll MOD = (ll)1e9 + 7, INF = (ll)1e18;;
ll add(ll x, ll y) {
    x += y;
    if (x >= MOD) return x - MOD;
    return x;
}
ll sub(ll x, ll y) {
    x -= y;
    if (x < 0) return x + MOD;
    return x;
}
ll mul(ll x, ll y) {
    return (x * y) % MOD;
}
ll bin_pow(ll x, ll p) {
    if (p == 0) return 1;
    if (p & 1) return mul(x, bin_pow(x, p - 1));
    return bin_pow(mul(x, x), p / 2);
}

const int N = 200200;
int n, m;
vector<pii> g[N];
bool used[N];
ll a[N];
ll L, R;

bool dfs(int v) {
    if (v < n)
        L = max(L, -a[v]);
    else
        R = min(R, a[v]);
    used[v] = 1;
    for (pii e : g[v]) {
        int u = e.first;
        int w = e.second;
        if (used[u]) {
            if (a[v] + a[u] != w) return false;
        } else {
            a[u] = w - a[v];
            if (!dfs(u)) return false;
        }
    }
    return true;
}

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    
    startTime = clock();
//    freopen("input.txt", "r", stdin);
//    freopen("output.txt", "w", stdout);
    int k;
    cin >> n >> m >> k;
    while(k--) {
        int x, y, w;
        cin >> x >> y >> w;
        x--;y--;
        g[x].push_back(mp(n + y, w));
        g[n + y].push_back(mp(x, w));
    }
    for (int v = 0; v < n; v++) {
        if (used[v]) continue;
        L = -INF; R = INF;
        if (!dfs(v) || L > R) {
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
    
    return 0;
}


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

using namespace std;

int main() {
	int n;
	cin >> n;
	int g, p, y, w;
	g = p = y = w = 0;
	for (int i = 0; i < n; i++) {
		char s;
		cin >> s;
		if (s == 'G') {
			g = 1;
		}
		else if (s == 'P') {
			p = 1;
		}
		else if (s == 'Y') {
			y = 1;
		}
		else {
			w = 1;
		}
	}
	if (g + p + y + w == 4) {
		cout << "Four" << endl;
	}
	else {
		cout << "Three" << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <tuple>
#include <vector>
#include <string>
#include <iostream>
#include <algorithm>

using std::cin;
using std::get;
using std::cout;
using std::endl;
using std::sort;
using std::tuple;
using std::string;
using std::vector;
using std::for_each;
using std::make_tuple;

using tuple_t = tuple<int,int,char,long long,string>;

bool compare(tuple_t &_t1,tuple_t &_t2) {
	bool cmp = false;
	if (get<0>(_t1) < get<0>(_t2)) {
		cmp = true;
	}
	else if (get<0>(_t1) == get<0>(_t2)) {
		if (get<1>(_t1) < get<1>(_t2)) {
			cmp = true;
		}
		else if (get<1>(_t1) == get<1>(_t2)) {
			if (get<2>(_t1) < get<2>(_t2)) {
				cmp = true;
			}
			else if (get<2>(_t1) == get<2>(_t2)) {
				if (get<3>(_t1) < get<3>(_t2)) {
					cmp = true;
				}
				else if (get<3>(_t1) == get<3>(_t2)) {
					if (get<4>(_t1) < get<4>(_t2)) {
						cmp = true;
					}
				}
			}
		}
	}
	return cmp;
}

int main() {
	int n;
	cin >> n;
	vector<tuple_t> tv(n);
	int value;
	int weight;
	char type;
	long long date;
	string name;
	for (auto &t: tv) {
		cin >> value >> weight >> type >> date >> name;
		t = make_tuple(value,weight,type,date,name);
	}
	sort(tv.begin(),tv.end(),compare);
	for_each(tv.begin(),tv.end(),[](tuple_t _t){
		cout << get<0>(_t) << " "
			 << get<1>(_t) << " "
			 << get<2>(_t) << " "
			 << get<3>(_t) << " "
			 << get<4>(_t) << endl;
	});
}


Measured memory_bytes: 12140
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <map>
#include <vector>
#include <stack>
#include <queue>
#include <tuple>
#include <cassert>
#include <functional>
#include <set>
#include <deque>
using namespace std;
typedef long long ll;
int dx[4] = {0,0,1,-1};
int dy[4] = {1,-1,0,0};
const int INF = 1<<29;
#define LNF __LONG_LONG_MAX__
const ll MOD = 1000000007;
const int MAX = 200000;

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;
}
// 法mでのaの逆元を計算
long long modinv(long long a, long long m) {
    long long b = m, u = 1, v = 0;
    while (b) {
        long long t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}
// a^n mod を計算する
long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
//最大公約数
int gcd(int x, int y) { return (x % y)? gcd(y, x % y): y; }
//最小公倍数
int lcm(int x, int y) { return x / gcd(x, y) * y; }
// nが大きく,kが10^7程度の時の二項係数
long long com[200005];
void combination(long long n,long long k){
    com[0] = 1;
    for(int i=1;i<=k;i++){
        com[i] = (com[i-1]*(n-i+1)%MOD)*modinv(i,MOD)%MOD;
    }
}

int main(){
    int H,W; cin >> H >> W;
    char a[100][100];
    for(int i=0;i<H;i++){
        for(int j=0;j<W;j++){
            cin >> a[i][j];
        }
    }
    for(int i=-1;i<=H;i++){
        for(int j=-1;j<=W;j++){
            if(i==-1 || i==H || j==-1 || j==W){
                cout << "#";
            }else{
                cout << a[i][j];
            }
        }
        cout << "\n";
    }
    return 0;
}


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

using namespace std;

#define PI          3.1415926535897932384626433832795l

#define pb push_back
#define mp make_pair
#define lb lower_bound // First element which is not less than val
#define ub upper_bound // First element greater than val
#define f first
#define s second

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

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vb = vector<bool>;
using vd = vector<double>;
using vs = vector<string>;
using vpii = vector<pair<int,int>>;
using vpll = vector<pair<ll,ll>>;

using pii = pair<int,int>;
using pll = pair<ll,ll>;

#define endl '\n'
#define re return

#define rep(i,a,b) for (ll i = (a); i < (b); i++)
#define repz(i, a) for (ll i = 0; i < (a); i++)
#define repd(i,a,b) for (ll i = (a); i >= b; i--)
#define repdz(i,a) for (ll i = a; i >=0; i--)
#define trav(a, x) for (auto& a : x)

#define vecin(n,v) for(ll i = 0; i < n; i++) cin>>v[i];
#define llin(a) ll a; cin>>a;
#define llin2(a,b) ll a,b; cin >>a>>b;
#define llin3(a,b,c) ll a,b,c; cin>>a>>b>>c;
#define full(v) v.begin(),v.end()

int gcd(int a, int b) 
{ 
    if (b == 0) 
        return a; 
    return gcd(b, a % b);  
      
}

void solve()
{
    int k;
    cin >> k;
    ll ans = 0;
    rep(i,1,k+1)
    {
        rep(j,1,k+1)
        {
            rep(t,1,k+1)
            {
                ans += gcd(i,gcd(j,t));
            }
        }
    }
    cout << ans << endl;
}

int main()
{
    ios_base::sync_with_stdio(false);
    //llin(t);
    //while (t--)
    //{
        solve();
    //}
}


Measured memory_bytes: 3612
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <cstdio>

using namespace std;

int gcd(int a, int b) {
	if (a < b) {
		int temp = a;
		a = b;
		b = temp;
	}
	if (b == 0) {
		return a;
	}

	return gcd(b, a % b);
}
int main() {

	//Q2
	/*
	int N;
	cin >> N;
	
	long long int total = 0;
	for (int i = 0; i < N; i++) {
		if (i % 3 == 0 || i % 5 == 0) {
			continue;
		}
		total += i;
	}

	cout << total << endl;
	*/

	int K;
	cin >> K;

	long long int total = 0;
	for (int i = 1; i <= K; i++) {
		for (int j = 1; j <= K; j++) {
			for (int k = 1; k <= K; k++) {
				int tempGcd = gcd(i, j);
				int trueGcd = gcd(tempGcd, k);

				total += trueGcd;
			}
		}
	}

	cout << total << endl;
	return 0;
}




Measured memory_bytes: 3636
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repI(i, d, n) for (int i = (d); i < (n); ++i)
#define reps1(i, n) for (int i = 1; i < (n); ++i)
using namespace std;
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; }

using ll = long long;
using P = pair<int, int>;
using Pl = pair<ll, ll>;
using M = map<int, int>;
using Ml = map<ll, ll>;
ll const INF = 1ll<<61;
double pi = 3.141592653589793238;

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

  queue<char> qa, qb, qc;
  for(char ch: a) qa.push(ch);
  for(char ch: b) qb.push(ch);
  for(char ch: c) qc.push(ch);
  char next = 'a';

  while(true) {
    if (next == 'a') {
      if (qa.empty()) {
        cout << 'A' << endl;
        return 0;
      }
      next = qa.front();
      qa.pop();
    }
    if (next == 'b') {
      if (qb.empty()) {
        cout << 'B' << endl;
        return 0;
      }
      next = qb.front();
      qb.pop();
    }
    if (next == 'c') {
      if (qc.empty()) {
        cout << 'C' << endl;
        return 0;
      }
      next = qc.front();
      qc.pop();
    }
  }

  return 0;
}


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

using namespace std;

int main() {
  int N, M, C;
  cin >> N >> M >> C;
  int B[M];
  for(int i = 0; i < M; i++) {
    cin >> B[i];
  }
  int A[N][M];
  for(int i = 0; i < N; i++){
    for(int j = 0; j < M; j++) {
      cin >> A[i][j];
    }
  }

  int sum = 0;
  int count = 0;
  for(int i = 0; i < N; i++){
    sum = 0;
    for(int j = 0; j < M; j++){
      sum += A[i][j] * B[j];
    }
    sum += C;
    if(sum > 0){
      count++;
    }
  }

  cout << count << endl;

  return 0;
}




Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
    int n,i,x=0;
    int a[22],b,c[22];
    cin >> n;
    for(i=1;i<=n;i++){
    	cin >> a[i];
	}
    for(i=1;i<=n;i++){
    	cin >> b;
    	x+=b;
	}
    for(i=1;i<n;i++){
    	cin >> c[i];
	}
    for(i=1;i<n;i++){
    	if(a[i]+1==a[i+1]){
    		x+=c[a[i]];
		}
	}
	cout << x << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
using ll=long long;
using vi=vector<int>;
using vl=vector<long long>;
using pii=pair<int,int>;
using pll=pair<long long,long long>;
#define ITR(i,c) for(auto i=begin(c);i!=end(c);++i)
#define FORE(x,c) for(auto &x:c)
#define REPF(i,a,n) for(int i=a,i##len=(int)(n);i<i##len;++i)
#define REP(i,n) REPF(i,0,n)
#define REPR(i,n) for(int i=(int)(n);i>=0;--i)
#define REPW(i,n) for(i=0;i<(int)(n);++i)
#define ALL(c) begin(c),end(c)
#define RALL(c) rbegin(c),rend(c)   // c++14
#define SZ(c) ((int)c.size())
#define EXIST(c,x) (c.find(x)!=end(c))
#define OUTOFRANGE(y,x,h,w) (y<0||x<0||y>=h||x>=w)
#define dump(...)
const int DX[9]={0,1,0,-1,1,1,-1,-1,0},DY[9]={-1,0,1,0,-1,1,1,-1,0};
#define INF (1001001001)
#define INFLL (1001001001001001001ll)
template<class T> ostream& operator << (ostream &os,const vector<T> &v) {
    ITR(i,v) os << *i << (i==end(v)-1 ? "" : "\n"); return os; }
template<class T> istream& operator >> (istream &is,vector<T> &v) {
    ITR(i,v) is >> * i; return is; }
template<class T> istream& operator >> (istream &is, pair<T,T> &p) {
        is >> p.first >> p.second; return is; }
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(b<a){a=b;return 1;}return 0;}
//------------------------------------------------------------------------------
struct before_main_function {
    before_main_function() {
        #ifdef int
            #undef INF
            #define INF INFLL
            #define stoi stoll
        #endif
        cin.tie(0);ios::sync_with_stdio(false);
        cout<<setprecision(15)<<fixed;
    }
} before_main_function;
//------------------------------------------------------------------------------

signed main() {
    int n,A,B;
    cin>>n>>A>>B;
    vector<int> h(n);
    cin>>h;
    int ans=INF;
    int l=-1,r=100000000000001ll;
    while(r-l>1) {
        int m=(l+r)/2;
        int t=m;
        REP(i,n) {
            if(B*m>=h[i]) continue;
            if(m>h[i]/B) continue;
            int ll=-1,rr=m+1;
            int a=INF;
            while(rr-ll>1) {
                int mm=(ll+rr)/2;
                if(mm*A+(m-mm)*B>=h[i] || mm>(h[i]-(m-mm)*B)/A) {
                    // ok
                    rr=mm;
                    chmin(a,mm);
                }
                else {
                    ll=mm;
                }
            }
            if(a==INF) {
                t=-1;
                break;
            }
            else t-=a;
        }
        if(t>=0) {
            //ok
            r=m;
            chmin(ans,m);
        }
        else {
            l=m;
        }
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 1024
#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++)
using namespace std;
using P = pair<int, int>; 
using ll = long long;
using M = map<int, int>;

int main()
{
  string s;
  cin >> s;
  int ans = 0;
  int n = s.size();
  if(n == 1) cout << ans << endl;
  else{
    for(int i = 1; i < n; i++){
      if(s[i - 1] == s[i]){
        ans++;
        if(s[i] == '1') s[i] = '0';
        else s[i] = '1';
      }
    }
    cout << ans << endl;
  }

  return 0;
}

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

vector <int> g[200005];

int st[200005], ed[200005], dfs_time;

int bit[200005];
inline void add(int x, int val) {
  while (x < 200005)
    bit[x] += val, x += x & -x;
}
inline int query(int x) {
  int res = 0;
  while (x)
    res += bit[x], x &= x - 1;
  return res;
}

void dfs(int u, int par) {
  st[u] = ++dfs_time;
  for (int i = 0; i < (int)g[u].size(); ++i)
    if (g[u][i] != par)
      dfs(g[u][i], u);
  ed[u] = dfs_time;
}

int main() {
  int n, q;
  cin >> n >> q;
  for (int i = 1; i < n; ++i) {
    int u, v;
    cin >> u >> v;
    g[u].push_back(v);
    g[v].push_back(u);
  }
  dfs(1, -1);
  while (q--) {
    int u, val;
    cin >> u >> val;
    add(st[u], val);
    add(ed[u] + 1, -val);
  }
  for (int i = 1; i <= n; ++i)
    printf("%d%c", query(st[i]), " \n"[i == n]);
  return 0;
}


Measured memory_bytes: 31104
import sys
T,D = [int(x) for x in sys.stdin.readline().split()]
t = [int(x) for x in sys.stdin.readline().split()]
d = [int(x) for x in sys.stdin.readline().split()]
ans = float("inf")
for i in range(D+1):
    va = d[0]*i
    if va > D:continue
    for j in range(D+1):
        vb = d[1]*j
        k = va+vb
        if k > D or k < 1:continue
        T_ = va*t[0]+vb*t[1]
        T_ /= k
        if abs(T-T_) < ans:
            ans = abs(T-T_)
print(ans)



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

#define IN inline
#define CO const
typedef long long int64;

template<class T> IN T read(){
	T x=0,w=1;char c=getchar();
	for(;!isdigit(c);c=getchar())if(c=='-') w=-w;
	for(;isdigit(c);c=getchar()) x=x*10+c-'0';
	return x*w;
}
template<class T> IN T read(T&x){
	return x=read<T>();
}

CO int N=1e4+10;
int f[N];

int main(){
	int n=read<int>(),m=sqrt(n);
	for(int x=1;x<=m;++x)for(int y=1;y<=m;++y)for(int z=1;z<=m;++z){
		int sum=x*x+y*y+z*z+x*y+y*z+z*x;
		if(sum<=n) ++f[sum];
	}
	for(int i=1;i<=n;++i) printf("%d\n",f[i]);
	return 0;
}


Measured memory_bytes: 3616
num_list =[1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
k = int(input())
print(num_list[k-1])

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
ll get(ll n,vector<pair<ll,ll>>& vp){
  if(vp.empty()) return n;
  ll e1 = vp[0].first, e2 = vp[0].second;
  if(vp.size() == 1){
    return (n%e1) + (n/e1)*e2;
  }
  ll f1 = vp[1].first, f2 = vp[1].second;
  ll ret = 0;
  if(vp.size() == 2){
    for(ll i = 0; i <= n/e1; ++i){
      ll a = i*e2, n2 = n-i*e1;
      ret = max(ret,a+(n2%f1)+(n2/f1)*f2);
    }
    return ret;
  }
  ll g1 = vp[2].first, g2 = vp[2].second;
  for(ll i = 0; i <= n/e1; ++i){
    ll a = i*e2, n2 = n-i*e1;
    for(ll j = 0; j <= n2/f1; ++j){
      ll b = a+j*f2, n3 = n2-j*f1;
      ret = max(ret,b+(n3%g1)+(n3/g1)*g2);
    }
  }
  return ret;
}
int main(){
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  ll n,ga,sa,ba,gb,sb,bb;
  cin >> n >> ga >> sa >> ba >> gb >> sb >> bb;
  vector<pair<ll,ll>> vp1,vp2;
  if(ga < gb) vp1.emplace_back(ga,gb);
  else if(ga > gb) vp2.emplace_back(gb,ga);
  if(sa < sb) vp1.emplace_back(sa,sb);
  else if(sa > sb) vp2.emplace_back(sb,sa);
  if(ba < bb) vp1.emplace_back(ba,bb);
  else if(ba > bb) vp2.emplace_back(bb,ba);
  ll n2 = get(n,vp1);
  cout << get(n2,vp2);
  return 0;
}


Measured memory_bytes: 256
//Author: intoabhi

#include<iostream>
using namespace std;

int main(){

	ios_base::sync_with_stdio(false);
    cin.tie(NULL);

	int a1, a2, a3;
	cin>>a1>>a2>>a3;

	if((a1+a2+a3)>=22) cout<<"bust";
	else cout<<"win";

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long  ll;
#define FOR(i,a,n) for(ll i=(ll)a;i<(ll)n;i++)
#define RFOR(i,a,n) for(ll i=(ll)n-1;i >= (ll)a;i--)
#define rep(i,n) FOR(i,0,n)
#define rrep(i,n) RFOR(i,0,n)
#define ALL(v) v.begin(), v.end()
#define bra(x,y) '(' << x << ',' << y << ')'
ll MOD = 1000000007;
ll INF = 214748364700000000;
double EPS = 1e-12;
double PI = 3.141592653589793238;
template<typename T>
void remove(std::vector<T>& vector, unsigned int index){
    vector.erase(vector.begin() + index);
}

using Graph = vector<vector<ll>>;

ll N,K;
int B[4010][4010];
int W[4010][4010];

int FB(int X,ll Y,ll x,ll y){
    int res = 0;
    res += B[X][Y] - B[X][y] - B[x][Y] + B[x][y];
    return res;
}

int FW(int X,ll Y,ll x,ll y){
    int res = 0;
    res += W[X][Y] - W[X][y] - W[x][Y] + W[x][y];
    return res;
}

int main(){
   cin >> N >> K;
   rep(i,N){
       int x,y;char c;
       cin >> x >> y >> c;
       if(c == 'B') B[x % (2*K) + 1][y % (2*K) + 1]++;
       if(c == 'W') W[x % (2*K) + 1][y % (2*K) + 1]++;
   }
   FOR(i,1,4*K+1) FOR(j,1,4*K+1){
       if(i <= 2 * K && j <= 2*K) continue;
       if(i <= 2*K && j > 2*K){
           B[i][j] = B[i][j-2*K];
           W[i][j] = W[i][j-2*K];
       }
       if(i > 2*K && j <= 2*K){
           B[i][j] = B[i-2*K][j];
           W[i][j] = W[i-2*K][j];
       }
       if(i > 2*K && j > 2*K){
           B[i][j] = B[i-2*K][j-2*K];
           W[i][j] = W[i-2*K][j-2*K];
       }
   }
   FOR(i,1,4*K+1) FOR(j,1,4*K+1){
       B[i][j] += B[i-1][j] + B[i][j-1] - B[i-1][j-1];
       W[i][j] += W[i-1][j] + W[i][j-1] - W[i-1][j-1];
   }
   int ans = 0;
   rep(i,2*K+1) rep(j,2*K+1){
       int cost = 0;
       cost += FB(i+K,j+K,i,j) + FB(i+2*K,j+2*K,i+K,j+K);
       cost += FW(i+2*K,j+K,i+K,j) + FW(i+K,j+2*K,i,j+K);
       ans = max(ans,cost);
   }
   cout << ans << endl;
}


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

typedef pair<int,int> P;

int main() {
  while (true) {
    vector<P> v;

    for (int i = 0; i < 2; i++) {
      int n;

      if (!(cin >> n)) return 0;

      while (n--) {
        int h, m;
        cin >> h >> m;
        v.push_back(P(h, m));
      }
    }

    sort(v.begin(), v.end());
    v.erase(unique(v.begin(), v.end()), v.end());

    for (int i = 0; i < v.size(); i++) {
      if (i != 0) cout << " ";
      printf("%d:%02d", v[i].first, v[i].second);
    }
    cout << endl;
  }
}

Measured memory_bytes: 1236
#include<iostream>
#include<string>
#include<algorithm>
using namespace std;
int main(){
  int n; string s; cin>> s;
  if(s[0]=='S'&&s[1]=='A'){ cout<<1<<endl; }
  if(s[0]=='F'){ cout<<2<<endl; }
  if(s[0]=='T'&&s[1]=='H'){ cout<<3<<endl; }
  if(s[0]=='W'){ cout<<4<<endl; }
  if(s[0]=='T'&&s[1]=='U'){ cout<<5<<endl; }
  if(s[0]=='M'){ cout<<6<<endl; }
  if(s[0]=='S'&&s[1]=='U'){ cout<<7<<endl; }
}

Measured memory_bytes: 256
#include<stdio.h>
int main(void)
{
	int H,W;
	int i,j;
	
	while(1){
		scanf("%d %d",&H,&W);
		if(H==0 && W==0)break;
		for(i=0;i<H;i++){
			for(j=0;j<W;j++){
				if(i==0 || i==(H-1)){
				printf("#");
				}else if(i!=0 && i!=(H-1)){
					if(j==0 || j==(W-1)){
						printf("#");
					}else if(j!=0 && j!=(W-1)){
						printf(".");
					}
				}
			}
			printf("\n");
		}
		printf("\n");
	}
	return 0;
}

Measured memory_bytes: 572
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <cmath>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <iostream>
#include <random>
#include <map>
#include <iomanip>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
#include <cassert>
#include <fstream>
#include <unordered_map>
#include <cstdlib>
#include <complex>
#include <cctype>
#include <bitset>
using namespace std;

using ll = long long;
using vll = vector<long long>;
using pll = pair<long long, long long>;
using qll = queue<ll>;
using vb = vector<bool>;
using sll = stack<ll>;
#define rep(i,n) for(long long i(0);(i)<(n);(i)++)
#define REP(i,n) for(long long i(0);(i)<(n);(i)++)
#define ALL(a) a.begin(), a.end()
#define elnd endl //* missspell check
ll INF = 1LL << 60;

const long long MOD = 1000000007;
ll extgcd(ll a, ll b, ll &x, ll &y){
    if(b == 0){
        x = 1; y = 0;
        return a;
    }
    ll d = extgcd(b, a % b, y, x);
    y -= (a / b) * x;
    return d;
}
//* calculate a^-1 mod m
ll mod_inverse(ll a, ll m){
    ll x, y;
    extgcd(a, m, x, y);
    return(m + x%m) % m;
}

//* calculate n! % p in O(n)
ll mod_fact_simple(ll n, ll p){
    ll res = 1;
    if(n == 0) return res;
    for(ll i=1; i<= n; i++){
        res *= i;
        res = res % p;
    }
    return res;
}
//* calculate C(n, k)%p in O(n)
ll mod_comb(ll n, ll k, ll p){
    if(n < 0 || k < 0 || n < k) return 0;
    ll a1 = mod_fact_simple(n, p);
    ll a2 = mod_fact_simple(k, p);
    ll a3 = mod_fact_simple(n-k, p);
    return (a1 * mod_inverse(a2 * a3 % p, p)) % p;
}

void solve(long long N, long long K){
    ll L = N-K;
    if(L == 0){
        for(ll i=1; i<=K; i++){
            cout << (i==1? 1: 0) << endl;
            
        }
        return;
    }

    ll tmp = 0;
    
    for(ll i=1; i<=K; i++){
        tmp = 0;
        tmp = (tmp + mod_comb(L-1, i, MOD)) % MOD;
        tmp = (tmp + mod_comb(L-1, i-2, MOD)) % MOD;
        tmp = (tmp + 2* mod_comb(L-1, i-1, MOD)) % MOD;
        tmp = (tmp * mod_comb(K-1, i-1, MOD)) % MOD;
        cout << tmp << endl;
    }
}
int main(){
    long long N;
    scanf("%lld",&N);
    long long K;
    scanf("%lld",&K);
    solve(N, K);
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<map>
#include <iomanip>
#define rep(i,n) for(int i=0;i<(n);++i)
using ll = long long;
#define _GLIBCXX_DEBUG

using namespace std;


int main() {
    int n,m;
    cin >> n>>m;
    vector<int> ac(n);
    vector<int>pena(n);
    for (int i = 0; i < m; i++) {
        int a;
        string s;
        cin >> a >> s;
        a--;
        if (ac[a] == 1) continue;
        if (s == "AC") {
            ac[a] = 1;
        }
        else {
            pena[a]++;
        }
    }
    int AC = 0;
    int PENA = 0;
    rep(i, n) {
        AC += ac[i];
        if (ac[i] == 1) PENA += pena[i];
    }
    printf("%d %d\n", AC, PENA);
}


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

int a,b,c;

int main()
{
	scanf("%d %d %d",&a,&b,&c);
	if(a==b)printf("%d\n",c);
	if(a==c)printf("%d\n",b);
	if(b==c)printf("%d\n",a);
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <sstream>
#include <string>
#define _repargs(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _repargs(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
#define mod 1000000007
#define inf 2000000007
#define mp make_pair
#define pb push_back
typedef long long ll;
using namespace std;
template <typename T>
inline void output(T a, int p = 0) {
    if(p) cout << fixed << setprecision(p)  << a << "\n";
    else cout << a << "\n";
}
// end of template

int main() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    // source code
    int a;
    cin >> a;
    output(a ^ 1);
    
    return 0;
}


Measured memory_bytes: 3564
import sys
import numpy as np
sys.setrecursionlimit(10 ** 7)

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

MOD = 10 ** 9 + 7


def myPow(x, n, MOD):
    if n == 0:
        return 1

    res = 1
    while(n > 0):
        if n & 1 == 1:
            res = res * x % MOD

        x = x * x % MOD
        n = n >> 1

    return res


ans = myPow(2, N, MOD)
ans -= 1

# print("hoge")


def cumprod(arr, MOD):
    L = len(arr)
    Lsq = int(L**.5+1)
    arr = np.resize(arr, Lsq**2).reshape(Lsq, Lsq)
    for n in range(1, Lsq):
        arr[:, n] *= arr[:, n-1]
        arr[:, n] %= MOD
    for n in range(1, Lsq):
        arr[n] *= arr[n-1, -1]
        arr[n] %= MOD
    return arr.ravel()[:L]


def make_fact(U, MOD):
    x = np.arange(U, dtype=np.int64)
    x[0] = 1
    fact = cumprod(x, MOD)
    x = np.arange(U, 0, -1, dtype=np.int64)
    x[0] = pow(int(fact[-1]), MOD-2, MOD)
    fact_inv = cumprod(x, MOD)[::-1]
    return fact, fact_inv


fact, fact_inv = make_fact(B + 10, MOD)

arr = cumprod(list(range(N, N-B, -1)), MOD)

a = arr[A - 1] * fact_inv[A]
a %= MOD
b = arr[B-1] * fact_inv[B]
b %= MOD

# print(mb)
# print(fact_inv)

'''
a = ma * fact_inv[A]
a %= MOD

b = mb * fact_inv[B]
b %= MOD
'''

ans -= (a + b)
ans %= MOD

print(ans)


Measured memory_bytes: 30864
#include <iostream>
#include <string>

using namespace std;

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

	for (int i = 0; i <= n; i++) {
		for (int j = 0; j <= m; j++) {
			if (i * (m - j) + j * (n - i) == k) {
				cout << "Yes" << endl;
				return 0;
			}
		}
	}
	cout << "No" << endl;

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cstdio>
using namespace std;
const int N=2e5+5;
int inf=0x3f3f3f3f;
typedef pair<int,int> pa;

long double PI=3.141592654;

int p[N];
int main()
{
   int n;scanf("%d",&n);
   int x;
   for(int i=1;i<n;i++){
    scanf("%d",&x);
    p[x]++;
   }
   for(int i=1;i<=n;i++)
    printf("%d\n",p[i]);
   return 0;
}


Measured memory_bytes: 4024
#include <bits/stdc++.h>
using namespace std;
int main() {
    int n;
    while(cin>>n,n){
        int wh,hi;
        cin>>wh>>hi;
        bool place[100][100]={};
        for(int i=0,x,y;i<n;i++){
            cin>>x>>y;
            place[y][x]=1;
        }
        int w,h,ans=0;
        cin>>w>>h;
        for(int i=1;i<=hi-h+1;i++){
            for(int j=1;j<=wh-w+1;j++){
                int co=0;
                for(int k=i;k<i+h;k++)
 for(int l=j;l<j+w;l++)
 if(place[k][l]==1)co++;
                ans=max(co,ans);
            }
        }
        cout<<ans<<endl;
    }
}
 


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

typedef long long ll;
const int N = 2e5 + 10, OO = 0x3f3f3f3f, mod = 1e9 + 7;

#define PI acos(-1)
#define clr(arr, val) memset(arr, val, sizeof(arr))
#define loop(i, n) for (int i = 0; i < int(n); i++)
#define rloop(i, n) for (int i = int(n) - 1; i >= 0; i--)
#define xloop(i, a, b) for (int i = int(a); i <= int(b); i++)
#define ALL(v) ((v).begin()), ((v).end())
#define SZ(v) ((int)((v).size()))
//int dx[] = {1, 0, -1, 0};
//int dy[] = {0, 1, 0, -1}; //4 Direction
int dx[] = {1, 1, 0, -1, -1, -1, 0, 1};
int dy[] = {0, 1, 1, 1, 0, -1, -1, -1}; //8 direction
//int dx[]={2,1,-1,-2,-2,-1,1,2};int dy[]={1,2,2,1,-1,-2,-2,-1};//Knight Direction
//int dx[6]={2,1,-1,-2,-1,1};int dy[6]={0,1,1,0,-1,-1}; //Hexagonal Direction

int n;

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

  scanf("%d" , &n);
  //if i choose x , y , z = 100 each, and substitue in equation i will exceed MAX N (10^4)
  map < int , int > ans;
  for(int i = 1 ; i <= 100 ; ++i){
    for(int j = 1 ; j <= 100 ; ++j){
      for(int k = 1 ; k <= 100 ; ++k){
        int value = (i * i) + (j * j) + (k * k) + (i * j) + (j * k) + (k * i);
        //if((i*i)+(j*j)+(k*k)+(i*j)+(j*k)+(k*i) == n)
        if(value <= 1e4)
          ans[value]++;
      }
    }
  }
  for(int i = 1 ; i <= n ; ++i)
    if(ans.find(i) != ans.end())
      printf("%d\n" , ans[i]);
    else 
      puts("0");

  return 0;
}


Measured memory_bytes: 4108
let () = Scanf.scanf "%d %d\n" @@ fun n wmax ->
  let wvs = Array.init n @@ fun _ ->
    Scanf.scanf "%d %d\n" @@ fun w v -> w, v in
  let vmax = Array.fold_right (fun (_, v) -> ( + ) v) wvs 0 in
  let dp = Array.make (1 + vmax) (1 + wmax) in
  dp.(0) <- 0;
  Array.iter (fun (w, v) ->
    for v' = vmax - v downto 0 do
      dp.(v + v') <- min dp.(v + v') (dp.(v') + w)
    done) wvs;
  try
    for v = vmax downto 0 do
      if dp.(v) <= wmax then begin
        Printf.printf "%d\n" v;
        raise Not_found
      end
    done
  with Not_found -> ()


Measured memory_bytes: 3200
import sys
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
MOD = 10 ** 9 + 7

N = INT()

print(N*(N-1)//2)


Measured memory_bytes: 2940