akhauriyash/Code-Regression huggingface dataset:
#include<cmath>
#include<cstdio>
#include<cstring>
#include<vector>
#include<assert.h>
#include<iostream>
#include<algorithm>
using namespace std;
#define pb push_back
#define mp make_pair
#define sz(x) ((int)(x).size())
#define rep(i,l,r) for(int i=(l);i<(r);++i)
#define setIO(x) freopen(x".in","r", stdin);freopen(x".out","w",stdout);
typedef long long ll;
typedef pair<int, int> pii;
const ll LINF = 1e10 + 7;
const int N = 1e2 + 7;
const int INF = 1e9 + 7;
int n, a[N];
int calc(int x) {
	int ret = 0;
	rep(i, 0, n)
		ret += (a[i] - x) * (a[i] - x);
	return ret;
}
int main() {
	scanf("%d", &n);
	int l = INF, r = -INF;
	rep(i, 0, n)
	{
		scanf("%d", &a[i]);
		l = min(l, a[i]), r = max(r, a[i]);
	}
	int ans = INF;
	rep(i, l, r + 1)
		ans = min(ans, calc(i));
	printf("%d", ans);
	return 0;
}


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

int main(){
  int n,ans=0;ll d;cin>>n>>d;
  REP(i,n){
    ll x,y;
    cin>>x>>y;
    if(x*x+y*y<=d*d) ans++;
  }
 
  cout<<ans;
}

Measured memory_bytes: 3632
#include <iostream>
#include <vector>
using namespace std;
 
int main() {
  int n, m;
  cin >> n >> m;
  int curr = 1;
  vector<bool> solved(n, false);
  vector<int> fails(n, 0);
  int wa = 0, ac = 0;
  for (int i = 0; i < m; ++i)
  {
    int problem;
    string result;
    cin >> problem >> result;
    if (result == "AC" && !solved[problem])
    {
      solved[problem] = true;
      ac++;
      wa += fails[problem];
    }
    if (result == "WA" && !solved[problem])
      fails[problem]++;
  }
  cout << ac << " " << wa;
}

Measured memory_bytes: 640
#include <iostream>

int main()
{
        int a[3], n, t;
        std::cin >> n;
        for(int i = 0; i < n; ++i)
        {
                std::cin >> a[0] >> a[1] >> a[2];
                int max_index=0;
                for(int j = 1; j < 3; ++j)
                        if(a[max_index] < a[j])
                                max_index = j;
                t = 0;
                for(int j = 0; j < 3; ++j)
                        if(j != max_index)
                                t += a[j]*a[j];
                if(t == (a[max_index]*a[max_index]))
                        std::cout << "YES" << std::endl;
                else
                        std::cout << "NO" << std::endl;
        }
        return 0;
}

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

int main(){
	int N;
  cin>>N;
  int a[N],b[N],c[N];
  
  rep(i,N){
  	cin>>a[i]>>b[i]>>c[i];
  }
  
  ll dp[N+10][3];
  /*rep(i,N+10){
  	dp[i][]=0;
  }
  */
  //a
  dp[0][0]=0;
  dp[0][1]=0;
  dp[0][2]=0;
  
  
  
  
  for(int i=0;i<N;i++){
  	dp[i+1][0]=max(dp[i][1]+b[i],dp[i][2]+c[i]);
    dp[i+1][1]=max(dp[i][2]+c[i],dp[i][0]+a[i]);
    dp[i+1][2]=max(dp[i][0]+a[i],dp[i][1]+b[i]);
  }
  
  //rep(i,N)cout<<dp[i]<<" ";
  //cout<< ;
  ll ans=0;
  ans=max(dp[N][0],dp[N][1]);
  cout<<max(ans,dp[N][2]);
}

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

int main() {
  int l;
  cin >> l;
  double ans = (double)l / 3.0;
  ans = pow(ans, 3.0);
  
  printf("%.10f\n", ans);
  return 0;
}

Measured memory_bytes: 4192
#include <bits/stdc++.h>
#define rep(i,a) for(int i=0;i<int(a);++i)
#define REP(i,a,b) for(int i=int(a);i<int(b);++i)
#define pb push_back
#define mp make_pair
#define F first
#define S second
using ll = long long;
using itn = int;
using namespace std;
static const long double GRATIO=(long double)(1+sqrt(5))/2;
ll GCD(ll a, ll b){
    return b ? GCD(b, a%b) : a;
}
ll LCM(ll a, ll b){
    return a/GCD(a,b)*b;
}
int main(){
    ll N;
    cin>>N;
    int ans=10;
    for(ll i=1; i<=sqrt(N); i++){
        if(N%i==0){
            ll A=i;
            ll B=N/i;
            string a = to_string(A);
            string b = to_string(B);
            ans=min(ans,(int)max(a.size(),b.size()));
        }
    }
    cout<<ans<<endl;
}


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

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

template<class T> inline bool chmax(T& a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}
struct Unionfind {
    vector<int> par;
    vector<int> sizes;

    Unionfind(int n) : par(n), sizes(n, 1) {
        for(int i = 0; i < n; ++i) par[i] = i;
    }

    int root(int x) {
        if(par[x] == x) return x;
        return par[x] = root(par[x]);
    }

    void unite(int x, int y) {
        int rx = root(x);
        int ry = root(y);
        if(rx == ry) return;
        if(sizes[x] < sizes[y]) swap(x, y);
        par[ry] = rx;
        sizes[rx] += sizes[ry];
    }

    bool same(int x, int y) {
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }

    int size(int x) {
        return sizes[root(x)];
    }

};

ll f(int x) {
    ll res = 1;
    for(int i = 0; i < 3; ++i) {
        res *= x;
    }
    return res;
}

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

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

    ll ans = 0;
    if(k % 2 != 0) {
        ans = f(n / k);
        cout << ans << endl;
        return 0;
    }
    else {
        int cnt = 0;
        ans = f(n / k);
        int v = k / 2;
        for(int i = 1; i <= n; ++i) {
            if(i % k == v) ++cnt;
        }
        ans += f(cnt);

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

Measured memory_bytes: 3556
#include <iostream>

int main()
{
    std::string str;
    std::cin >> str;
    int a = str[0] - '0';
    int b = str[1] - '0';
    int c = str[2] - '0';
    int d = str[3] - '0';
    for (int op1 = 0; (op1 < 2); ++op1) {
        for (int op2 = 0; (op2 < 2); ++op2) {
            for (int op3 = 0; (op3 < 2); ++op3) {
                int flag = op1 * 4 + op2 * 2 + op3;
                switch (flag) {
                    case 0:
                        if (a+b+c+d == 7) {
                            std::cout << a << "+" << b << "+" << c << "+" << d << "=7" << std::endl;
                            return 0;
                        }
                        break;
                    case 1:
                        if (a+b+c-d == 7) {
                            std::cout << a << "+" << b << "+" << c << "-" << d << "=7" << std::endl;
                            return 0;
                        }
                        break;
                    case 2:
                        if (a+b-c+d == 7) {
                            std::cout << a << "+" << b << "-" << c << "+" << d << "=7" << std::endl;
                            return 0;
                        }
                        break;
                    case 3:
                        if (a+b-c-d == 7) {
                            std::cout << a << "+" << b << "-" << c << "-" << d << "=7" << std::endl;
                            return 0;
                        }
                        break;
                    case 4:
                        if (a-b+c+d == 7) {
                            std::cout << a << "-" << b << "+" << c << "+" << d << "=7" << std::endl;
                            return 0;
                        }
                        break;
                    case 5:
                        if (a-b+c-d == 7) {
                            std::cout << a << "-" << b << "+" << c << "-" << d << "=7" << std::endl;
                            return 0;
                        }
                        break;
                    case 6:
                        if (a-b-c+d == 7) {
                            std::cout << a << "-" << b << "-" << c << "+" << d << "=7" << std::endl;
                            return 0;
                        }
                        break;
                    case 7:
                        if (a-b-c-d == 7) {
                            std::cout << a << "-" << b << "-" << c << "-" << d << "=7" << std::endl;
                            return 0;
                        }
                        break;
                    default:
                        return -1;
                }
            }
        }
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int dx[] = {1, 0, -1, 0}, dy[] = {0, 1, 0, -1};
using pii = pair<int, int>;
int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }

  ll ans = 1000;

  for (int i = 0; i < n - 1; i++) {
    if (a[i + 1] - a[i] > 0) {
      ll temp = ans / a[i];  //枚数
      ans -= a[i] * temp;

      ans += temp * a[i + 1];
    }
  }

  cout << ans << endl;
}

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

int main() {
	int n, u, k, v, V[101][101] = {};
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> u >> k;
		for (int j = 0; j < k; j++) {
			cin >> v;
			V[u][v] = 1;
		}
	}
	for (int i = 1; i <= n; i++) {
		for (int j = 1; j <= n; j++) {
			cout << V[i][j];
			if (j == n) cout << endl;
			else cout << " ";
		}
	}
	return 0;
}


Measured memory_bytes: 3132
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define endl "\n"
#define se second
#define ll long long
#define inf 0x3f3f3f3f
#define fast    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
const int N = 3000+10;
const ll mod =   998244353;
ll s,dp[N][N],n,arr[N];
int main()
{  fast
cin>>n>>s;
for(int i=1;i<=n;i++)cin>>arr[i];
dp[0][0]=1ll;
for(int i=1;i<=n;i++){
	for(int j=0;j<=s;j++){
		(dp[i][j]+=2*dp[i-1][j])%=mod;
		if(j-arr[i]>=0)
		(dp[i][j]+=dp[i-1][j-arr[i]])%=mod;
	}
}
cout<<dp[n][s]%mod;

}

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

// #define rep(i,n) for(int i = 0; i < (n); i++)
// #define FOR(i,d,n) for(int i = (d); i < (n); i++)
// using ll = long long;
// using vi = vector<int>;
// using vs = vector<string>;

// void dec(const string s,int& n,int d[1000]){
//     int de=0;
//     int left=1;
//     int nn=0;
//     FOR(i,0,n){
//         if(s[i]=='('){
//             de++;
//         }else if(s[i]==')'){

//         }else if(s[i]=='['){

//         }else if(s[i]==']'){

//         }else{

//         }
//     }
// }

// int main()
// {
//     string s[2]={};
//     cin>>s[0]>>s[1];
//     int n[2]={s[0].length(),s[1].length()};
//     int num[2]={};
//     int depth[2][1000]={};
//     int 
//     dec(s[0],num[0],depth[0]);
//     return 0;
// }

#include <bits/stdc++.h>

std::string A, B;

void calcSum(int&, int&);
void throughTree(int&, std::string&);
int64_t calcNum(int&, std::string&);

int main()
{
    std::cin >> A >> B;
    int a_i{}, b_i{};
    calcSum(a_i, b_i);
    putchar('\n');

    return 0;
}

void calcSum(int& a_i, int& b_i)
{
    a_i++; b_i++;
    putchar('(');
    if (A[a_i] != ')' && B[b_i] != ')')
        calcSum(a_i, b_i);
    else if (A[a_i] != ')')
        throughTree(a_i, A);
    else if (B[b_i] != ')')
        throughTree(b_i, B);
    a_i++; b_i++;
    putchar(')');

    putchar('[');
    std::cout << std::to_string(calcNum(a_i, A) + calcNum(b_i, B));
    putchar(']');

    a_i++; b_i++;
    putchar('(');
    if (A[a_i] != ')' && B[b_i] != ')')
        calcSum(a_i, b_i);
    else if (A[a_i] != ')')
        throughTree(a_i, A);
    else if (B[b_i] != ')')
        throughTree(b_i, B);
    a_i++; b_i++;
    putchar(')');

    return;
}

void throughTree(int& s_i, std::string& str)
{
    if (str[s_i] == ')') return;
    s_i++;
    throughTree(s_i, str);
    s_i++;

    calcNum(s_i, str);

    s_i++;
    throughTree(s_i, str);
    s_i++;

    return;
}

int64_t calcNum(int& s_i, std::string& str)
{
    s_i++;
    int64_t ret{};
    while (str[s_i] != ']')
    {
        ret = 10 * ret + str[s_i] - '0';
        s_i++;
    }
    s_i++;
    return ret;
}



Measured memory_bytes: 3296
#include<stdio.h>

int main(void){

	int sosuu[1000000],kazu,n,i,j;

	while(scanf("%d",&n)!=EOF){

		kazu=n-1;

		for(i=2;i<=n;i++){
			sosuu[i]=1;
		}
		sosuu[0]=0;sosuu[1]=0;

		for(i=2;i<=n;i++){
			if(sosuu[i]==1){
				for(j=i*2;j<=n;j+=i){
					if(sosuu[j]==1){
						kazu--;
						sosuu[j]=0;
					}
				}
			}
		}

		printf("%d\n",kazu);
		
	}

	return 0;
}

Measured memory_bytes: 4500
import java.util.Scanner

object Main extends App {
  val sc = new Scanner(System.in)

  val h = sc.nextLong
  val w = sc.nextLong

  val res =
    if (h % 3 == 0 || w % 3 == 0) 0
    else {
      val l = math.max(h, w)
      val s = math.min(h, w)

      val formT = {
        (1 to (s / 2).toInt).toVector.map { i =>
          val list = List(i * l, (s - i) * (l / 2), (s - i) * (l - l / 2)).sorted
          list.last - list.head
        }
      }.min

      val formTT = {
        (1 to (l / 2).toInt).toVector.map { j =>
          val list = List(j * s, (l - j) * (s / 2), (l - j) * (s - s / 2)).sorted
          list.last - list.head
        }
      }.min

      List(s,formT,formTT).min
    }

  println(res)
}

Measured memory_bytes: 51264
import sys
n = int(sys.stdin.readline())
a = [int(sys.stdin.readline()) for _ in range(n)]

first = max(a)
if a.count(first) > 1:
    second = first
else:
    b = a[:]
    b.remove(first)
    second = max(b)

for i in a:
    if i != first:
        print(first)
    else:
        print(second)


Measured memory_bytes: 14060
#include <stdio.h>
#include <stdlib.h>

int main()
{
    int a,b,c,d,e;
    scanf("%d%d",&a,&b);
    c=a%10;
    d=b%10;
    e=c*d;
    if(e%2==0)
        printf("Even\n");
    else
        printf("Odd\n");
    return 0;
}


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

const int MOD = (int)1e9+7;

int main(){
	int N;
	cin >> N;
	vector<pair<string,pair<int,int>>> S_P(N);
	for(int i=0;i<N;i++){
		int x;
		cin >> S_P.at(i).first >> x;
		S_P.at(i).second.first=-x;
		S_P.at(i).second.second=i+1;
	}

	sort(S_P.begin(),S_P.end());
	for(int i=0;i<N;i++){
		cout << S_P.at(i).second.second << endl;
	}

	return 0;
}


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

int main() {

  while( true ) {

    long long int n;
    cin >> n;
    if ( n == 0 ) break;

    long long int p[21][21] = {};

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

      long long int x, y;
      cin >> x >> y;
      p[x][y]++;

    }

    long long int m;
    cin >> m;
    if ( m == 0 ) break;

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

    long long int cnt = 0;

    long long int x = 10;
    long long int y = 10;
    cnt += p[x][y];
    p[x][y] = 0;

    for ( long long int i = 0; i < m; i++ ) {

      char d;
      long long int l;
      cin >> d >> l;

      long long int dr;
      if ( d == 'N' ) {
	dr = 0;
      }else if ( d == 'E' ) {
	dr = 1;
      }else if ( d == 'S' ) {
	dr = 2;
      }else {
	dr = 3;
      }
      for ( long long int j = 0; j < l; j++ ) {
	x += dx[dr];
	y += dy[dr];
	cnt += p[x][y];
	p[x][y] = 0;
      }

    }

    if ( cnt == n ) {
      cout << "Yes" << endl;
    }else {
      cout << "No" << endl;
    }

  }

  return 0;

}

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

int main() {
  char c;
  cin >> c;
  if(c == 'a' || c == 'e' || c == 'i' || c == 'o' || c == 'u')
    cout << "vowel" << endl;
  else
    cout << "consonant" << endl;

}


Measured memory_bytes: 256
class Dice:
    def __init__(self, dice):
        self.dice = dice
        self.face = {'head':1, 'tail':4, 'left':3, 'right':2, 'above':0, 'below':5}
    
    def roll(self, ch):
        dice = self.dice
        face = self.face
        if ch == 'S':
            tmp = dice[face['head']]
            dice[face['head']] = dice[face['above']]
            dice[face['above']] = dice[face['tail']]
            dice[face['tail']] = dice[face['below']]
            dice[face['below']] = tmp
        elif ch == 'N':
            tmp = dice[face['head']]
            dice[face['head']] = dice[face['below']]
            dice[face['below']] = dice[face['tail']]
            dice[face['tail']] = dice[face['above']]
            dice[face['above']] = tmp
        elif ch == 'W':
            tmp = dice[face['left']]
            dice[face['left']] = dice[face['above']]
            dice[face['above']] = dice[face['right']]
            dice[face['right']] = dice[face['below']]
            dice[face['below']] = tmp
        else:
            tmp = dice[face['left']]
            dice[face['left']] = dice[face['below']]
            dice[face['below']] = dice[face['right']]
            dice[face['right']] = dice[face['above']]
            dice[face['above']] = tmp
    def top(self):
        dice = self.dice
        face = self.face
        return dice[face['above']]
dice = Dice([*map(int, input().split())])
for ch in input():
    dice.roll(ch)
print(dice.top())


Measured memory_bytes: 5612
#include <stdio.h>
#define INF 1000000000
#define BLACK 1
#define WHITE 0
#define NIL -1

int G[101][101],d[101],pi[101],n,color[101],sum;

void prim(int);
int main(){
  int i,j,k,v,c,num;
  scanf("%d",&n);

  for(i=0;i<n;i++){
    for(j=0;j<n;j++){
      G[i][j]=INF;
    }
    }
  for(i=0;i<n;i++){
    scanf("%d%d",&num,&k);
    for(j=0;j<k;j++){
      scanf("%d%d",&v,&c);
	G[num][v]=c;
	}
  }


  /*  for(i=1;i<=n;i++){
    for(j=1;j<=n;j++){
      scanf("%d",&G[i][j]);
    }
    }*/
  prim(0);

 

  return 0;
  
}

void prim(int r){
  int mincost,u,i,v;

   for(i=0;i<n;i++){
    d[i]=INF;
    pi[i]=NIL;
    color[i]=WHITE;
  }
  d[r]=0;
  while(1){
    mincost=INF;
    for(i=0;i<n;i++){
      if(color[i]!=BLACK && d[i]<mincost){
	mincost=d[i];
	u=i;
      }
    }
    if(mincost==INF) break;
    color[u]=BLACK;
    for(v=0;v<n;v++){
      if(color[v]!=BLACK && d[u]+G[u][v]<d[v] && G[u][v]!=INF){
	pi[v]=u;
	d[v]=G[u][v]+d[u];
      }
    }

  }

  for(i=0;i<n;i++){
 
      printf("%d %d\n",i,d[i]);
      
  

  }
}

Measured memory_bytes: 640
#include<iostream>
#include<cstring>
#include<algorithm>
#include<string>
#include<vector>
#include<cstdio>
#include<cmath>
#define pb(in,tmp) in.push_back(tmp)
#define loop(i,a,b) for(i=a;i<b;i++)
#define rep(i,b) loop(i,0,b)
#define all(in) in.begin(),in.end()
const double PI=acos(-1);
using namespace std;
int main(){
  int n;
  while(cin>>n,n){
    int a,b,i;
	int m[12];
	rep(i,12){
	  cin>>a>>b;
	  m[i]=a-b;
	}
	int sum=0;
	rep(i,12){
	  sum+=m[i];
	  if(n<=sum)break;
	}
	if(i==12)cout<<"NA"<<endl;
	else cout<<i+1<<endl;
  }
}

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

int main(){
    ll n,m;
    cin>>n>>m;
    vector<pair<ll,ll>> p(n);
    rep(i,n){
        ll a,b;
        cin>>a>>b;
        p[i]=make_pair(a,b);
    }
    sort(p.begin(),p.end());
    ll sum=0;
    ll drink=0;
    ll i=0;
    while(drink<m){
        ll a =p[i].first;
        ll b= p[i].second;
        if(drink+b<=m){
            drink+=b;
            sum+=b*a;
            i++;
        }else{
            sum+=a*(m-drink);
            drink+=m-drink;
            i++;
        }
    }
    cout<<sum<<endl;
    return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
const ll INF=1LL<<60;
const double EPS = 1e-10;
const ll mod=1000000007;
//const ll mod=998244353;

int main(void){
  string s;
  cin>>s;
  ll sum=0;
  for(int i=0;i<s.size();i++){
    sum+=s[i]-'0';
    sum%=9;
  }
  if(sum==0) cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
}

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

typedef long long ll;
typedef unsigned long long ull;

int main()
{
    ll N;
    cin >> N;
    string S;
    cin >> S;
    vector<ll> nb(N, 0);;
    vector<ll> nw(N, 0);;
    for(ll i=0;i<N;i++){
        if(i>0) nb[i] += nb[i-1];
        if(i>0) nw[N-1-i] += nw[N-i];
        if(S[i]=='#') nb[i]++;
        if(S[N-1-i]=='.') nw[N-1-i]++;
    }
    ll res=LLONG_MAX;
    for(ll i=0;i<=N;i++){
        if     (i==0) res = min(res, nw[i]);
        else if(i==N) res = min(res, nb[i-1]);
        else          res = min(res, nw[i] + nb[i-1]);
    }
    cout<<res<<endl;

    return 0;
}

Measured memory_bytes: 3716
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;
const int INF=1001001;
int main(){
  vector <int> a={1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
  int n;
  cin>>n;
  cout<<a[n-1];
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(void){
    // Your code here!
    int l,n,ans=0;
    cin >> l >> n;
    vector<int> a(n),b(n);
    for (int i=0;i<n;i++){
        cin >> a.at(i) >> b.at(i);
        ans+=a.at(i)*b.at(i);
    }
    if (ans==0) cout << 0 << endl;
    if (ans>0) cout << 1 << endl << -1 << " " << ans << endl;
    if (ans<0) cout << 1 << endl << 1 << " " << (-1)*ans << endl;
}



Measured memory_bytes: 3088
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <iomanip>
#include <utility>
#include <tuple>
#include <functional>
#include <bitset>
#include <cassert>
#include <time.h>
#define int long long
#define endl '\n'
#define INF 1000000000000000000
#define EPS 1e-10
#define all(a) a.begin(),a.end()
#define rep(i, n) for (int i = 0; i < (n); i++)
#define fi first
#define se second
#define pb push_back
#define double long double
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<ll, P> PP;
template<class T, class S> bool chmax(T &a, const S &b) { if (a < b) { a = b; return 1; } return 0; }
template<class T, class S> bool chmin(T &a, const S &b) { if (a > b) { a = b; return 1; } return 0; }
ll gcd(ll n, ll m) { return (m ? gcd(m, n%m) : n); }
ll lcm(ll n, ll m) { return n / gcd(n, m)*m; }

ll mod = 1000000007;

signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(20);
	//modcalc();

	int n, m, s, t;
	cin >> n >> m >> s >> t;
	s--; t--;
	vector<vector<P>> graph(n, vector<P>());
	vector<P> a;
	vector<int> cost;
	rep(i, m) {
		int u, v, d;
		cin >> u >> v >> d;
		u--; v--;
		graph[u].pb(P(v, d));
		graph[v].pb(P(u, d));
		a.pb(P(u, v));
		cost.pb(d);
	}
	vector<int> dist(n, INF);
	vector<int> cnt(n, 0);
	dist[s] = 0; cnt[s] = 1;
	priority_queue<P, vector<P>, greater<P>> que;
	que.push(P(0, s));
	while (!que.empty()) {
		P p = que.top(); que.pop();
		int px = p.first; int py = p.second;
		if (dist[py] < px) continue;
		for (P q : graph[py]) {
			int qx = q.first; int qy = q.second;
			if (dist[py] + qy == dist[qx]) {
				cnt[qx] += cnt[py];
				cnt[qx] %= mod;
			}
			else if (dist[py] + qy < dist[qx]) {
				cnt[qx] = cnt[py];
				dist[qx] = dist[py] + qy;
				que.push(P(dist[qx], qx));
			}
		}
	}
	vector<int> dist2(n, INF);
	vector<int> cnt2(n, 0);
	dist2[t] = 0; cnt2[t] = 1;
	que.push(P(0, t));
	while (!que.empty()) {
		P p = que.top(); que.pop();
		int px = p.first; int py = p.second;
		if (dist2[py] < px) continue;
		for (P q : graph[py]) {
			int qx = q.first; int qy = q.second;
			if (dist2[py] + qy == dist2[qx]) {
				cnt2[qx] += cnt2[py];
				cnt2[qx] %= mod;
			}
			else if (dist2[py] + qy < dist2[qx]) {
				cnt2[qx] = cnt2[py];
				dist2[qx] = dist2[py] + qy;
				que.push(P(dist2[qx], qx));
			}
		}
	}
	int ans = cnt[t] * cnt2[s] % mod;
	if (dist[t] % 2 == 0) {
		rep(i, n) {
			if (dist[i] == dist2[i] && dist[i] * 2 == dist[t]) {
				int x = cnt[i] * cnt2[i] % mod;
				ans += mod - x * x%mod;
				ans %= mod;
			}
		}
	}
	rep(i, a.size()) {
		int ax = a[i].first; int ay = a[i].second;
		if (dist[ax] > dist[ay]) swap(ax, ay);
		if (2 * dist[ax] < dist[t] && dist[t] < 2 * dist[ay] && 2 * dist2[ay] < dist[t] && dist[t] < 2 * dist2[ax] && dist[ax] + cost[i] == dist[ay] && dist2[ay] + cost[i] == dist2[ax] && dist[ax] + dist2[ax] == dist[t] && dist[ay] + dist2[ay] == dist[t]) {
			int x = cnt[ax] * cnt2[ay] % mod;
			ans += mod - x * x%mod;
			ans %= mod;
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 22636
package main

import "fmt"

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

func main() {
	var n int
	fmt.Scan(&n)

	var a, b int
	for i := 1; i < n+1; i++ {
		fmt.Scan(&a)
		if i == 1 {
			b = a
		} else {
			b = gcd(b, a)
		}
	}
	fmt.Println(b)
}

Measured memory_bytes: 5504
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
static const LL INF = 1 << 31;
static const int MOD = 1e9 + 7;
static const int MAXN = 1e5 + 10;
LL inx[MAXN] , iny[MAXN] = {0};
LL QuickPlus(LL a , LL b)
{
    LL yaoyuan = 0;
    while(b)
    {
        if(b & 1)   yaoyuan = (yaoyuan + a) % MOD;
        a = (a + a) % MOD;
        b >>= 1;
    }
    return yaoyuan;
}
int main()
{
    int n , m;
    scanf("%d%d" , &n , &m);
    for(int i = 1 ; i <= n ; ++i)
        scanf("%lld" , &inx[i]);
    for(int i = 1 ; i <= m ; ++i)
        scanf("%lld" , &iny[i]);
    LL sumx = 0 , sumy = 0;
    for(int i = 1 ; i <= n ; ++i)
        sumx = (sumx + ((i - 1) * inx[i] - (n - i) * inx[i]) % MOD) % MOD;
    for(int i = 1 ; i <= m ; ++i)
        sumy = (sumy + ((i - 1) * iny[i] - (m - i) * iny[i]) % MOD) % MOD;
    printf("%lld" , QuickPlus(sumx , sumy));
}


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

#define ll long long
#define ld long double

#define rep(i,a,b) for(ll i=a;i<b;i++)
#define repb(i,a,b) for(ll i=a;i>=b;i--)
#define repA(i,A)   for(auto i:A)

#define err() cout<<"=================================="<<endl;
#define errA(A) for(auto i:A)   cout<<i<<" ";cout<<endl;
#define err1(a) cout<<#a<<" "<<a<<endl
#define err2(a,b) cout<<#a<<" "<<a<<" "<<#b<<" "<<b<<endl
#define err3(a,b,c) cout<<#a<<" "<<a<<" "<<#b<<" "<<b<<" "<<#c<<" "<<c<<endl
#define err4(a,b,c,d) cout<<#a<<" "<<a<<" "<<#b<<" "<<b<<" "<<#c<<" "<<c<<" "<<#d<<" "<<d<<endl

#define mp make_pair
#define pb push_back
#define all(A)  A.begin(),A.end()
#define allr(A)	A.rbegin(),A.rend()
#define ft first
#define sd second

#define pll pair<ll,ll>
#define V vector<ll>
#define S set<ll>
#define VV vector<V> 
#define Vpll vector<pll>

#define endl "\n"

const ll logN = 20;
const ll N = 100005;
const ll M = 1000000007;
const ll INF = 1e12;
#define PI 3.14159265

const ll dx[4] = {1,0,-1,0};
const ll dy[4] = {0,1,0,-1};

int main(){
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    ll k,x;
    cin>>k>>x;
    ll st = x-k+1;
    ll en = x+k-1;
    rep(i,st,en+1)	cout<<i<<" ";cout<<endl;
    return 0;
}

Measured memory_bytes: 256
/* AOJ0003 */
#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;

int main(){
  int n;
  cin >> n;
  while(n--){
    int a, b, c;
    cin >> a >> b >> c;
    if(a < b) swap(a, b);
    if(a < c) swap(a, c);
    cout << (a * a == b * b + c * c ? "YES" : "NO" ) << endl;
  }
  return 0;
}

Measured memory_bytes: 1152
#include<stdio.h>
#include<cstdio>
using namespace std;

int D, N;
int main() {
  scanf("%d%d", &D, &N);
  int res;
  if (D == 0) {
    if (N<=99) printf("%d\n", N);
    else printf("%d\n", 101);
  } else if (D == 1) {
    if (N<=99) printf("%d\n", 100*N);
    else printf("%d\n", 101*100);
  } else if (D == 2) {
    if (N<=99) printf("%d\n", 10000*N);
    else printf("%d\n", 101*10000);
  }
}

Measured memory_bytes: 128
#include<stdio.h>
#include<stdlib.h>
#include<string>
#include<iostream>
using namespace std;

struct Node{
  Node *r,*l,*p;
  int key;
};

Node *root, *NIL;

Node *treeMinimum(Node *x){
  while(x->l!=NIL)
    x=x->l;
  return x;
}

Node * find(Node *u,int k){
  while(u!=NIL && k!=u->key){
    if(k<u->key)
      u=u->l;
    else u=u->r;
  }
  return u;
}

Node * treeSuccessor(Node *x){
  if(x->r!=NIL)
    return treeMinimum(x->r);
  Node *y=x->p;
  while(y!=NIL && x== y->r){
    x=y;
    y=y->p;
  }
  return y;
}

void treeDelete(Node *z){
  Node *y;
  Node *x;
  if(z->l==NIL || z->r==NIL)
    y=z;
  else y =treeSuccessor(z);
  if(y->l!=NIL){
    x=y->l;
  }
  else {
    x=y->r;
  }
  if(x!=NIL){
    x->p=y->p;
  }
  if(y->p==NIL){
    root=x;
  }
  else{
    if(y==y->p->l){
      y->p->l=x;
    }
    else{
      y->p->r=x;
    }
  }
  if(y!=z){
    z->key=y->key;
  }
  free(y);
}


void insert(int k){
  Node *y = NIL;
  Node *x = root;
  Node *z;
  z =(Node *)malloc(sizeof(Node));
  z->key = k;
  z->l = NIL;
  z->r = NIL;
  while(x!=NIL){
    y=x;
    if(z->key < x->key){
      x=x->l;
    }
    else{
      x=x->r;
    }
  }
  z->p=y;
  if(y==NIL){
    root=z;
  }
  else{
    if(z->key < y->key){
      y->l=z;
    }
    else{
      y->r=z;
    }
  }
}


void inorder(Node *u){
  if(u==NIL)
    return;
  inorder(u->l);
  printf(" %d",u->key);
  inorder(u->r);
}
void preorder(Node *u){
  if(u==NIL)
    return;
  printf(" %d",u->key);
  preorder(u->l);
  preorder(u->r);

}


int main(){
  int n, i, x;
  string com;
  scanf("%d", &n);

  for ( i = 0; i < n; i++ ){
    cin>>com;
    if(com[0]=='f'){
      scanf("%d",&x);
      Node *t=find(root,x);
      if(t!=NIL)
	printf("yes\n");
      else
	printf("no\n");
    }
    else if ( com == "insert" ){
      scanf("%d", &x);
      insert(x);
    } else if ( com== "print" ){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    }
    else if(com=="delete"){
      scanf("%d",&x);
      treeDelete(find(root,x));
		 }
    }
    return 0;
  }



Measured memory_bytes: 22084
#include <bits/stdc++.h>
using namespace std;
bool f(long long A, long long B, long long C, long long D) {
	if (A < B) return false;
	if (B > D) return false;
	if (B < C) return true;
	A %= B;
	if (A > C) return false;
	if (D % B == 0) return true;
	auto e = __gcd(B, D);
	A %= e;
	A += B-e;
	if (A <= C) return true;
	return false;
}
int main() {
	int T;
	cin >> T;
	for (int tt = 0; tt < T; ++ tt) {
		long long A,B,C,D;
		cin >> A >> B >> C >> D;
		cout << (f(A,B,C,D) ? "Yes" : "No") << endl;
	}
}


Measured memory_bytes: 256
#include <iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<math.h>
using namespace std;
typedef long long ll;
#define int long long
typedef vector<int> VI;
typedef pair<int, int> pii;
typedef vector<pii> VP;
typedef vector<string> VS;
typedef priority_queue<int> PQ;
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; }
#define fore(i,a) for(auto &i:a)
#define REP(i,n) for(int i=0;i<n;i++)
#define eREP(i,n) for(int i=0;i<=n;i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define eFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define SORT(c) sort((c).begin(),(c).end())
#define rSORT(c) sort((c).rbegin(),(c).rend())
#define LB(x,a) lower_bound((x).begin(),(x).end(),(a))
#define UB(x,a) upper_bound((x).begin(),(x).end(),(a))
#define INF 1000000000
#define LLINF 9223372036854775807
#define mod 1000000007
//priority_queue<int,vector<int>, greater<int> > q2;

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

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

	int H, W, N; cin >> H >> W >> N;
	map<pii, int>mp;
	int ans[10] = { 0 };
	REP(i, N) {
		int a, b; cin >> a >> b;
		a--; b--;
		REP(j, 9) {
			int x = a + dx[j] - 1, y = b + dy[j] - 1;
			if (x >= 0 && x < H - 2 && y >= 0 && y < W - 2) {
				int t = mp[pii(x, y)]++;
				ans[t]--;
				ans[t + 1]++;
			}
		}
	}
	int sum = 0;
	FOR(i, 1, 10)sum += ans[i];
	ans[0] = (H - 2)*(W - 2) - sum;
	REP(i, 10)cout << ans[i] << endl;

	return 0;
}



Measured memory_bytes: 56576
import java.io.{BufferedReader, InputStreamReader}

object Main {
  def main(args: Array[String]): Unit = {
    val in = new BufferedReader(new InputStreamReader(System.in))
    val Array(n, k) = in.readLine().split("\\s+").map(_.toInt)
    val hs = in.readLine().split("\\s+").map(_.toInt)

    System.out.println(
      hs.sorted(Ordering[Int].reverse).drop(k).foldLeft(0L) {
        case (acc, h) => acc + h
      }
    )
  }
}


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

vector<int> G[200001];
int c[200001];
int v[200001];
map<int, int> m;

void a(int i){
    for(int k = 0; k < int(G[i].size()); k++){
        if (c[G[i][k]]) continue;
        else {
        c[G[i][k]]++;
        if (m[G[i][k]]) v[G[i][k]] = v[i] + m[G[i][k]];
        else v[G[i][k]] = v[i];
        }
        a(G[i][k]);
    }
    
}




int main()
{
    int n,q;cin>>n>>q;
    for(int i = 1; i<n; i++){
        int a, b;cin>>a>>b;
        G[a].push_back(b);
        G[b].push_back(a);
    }
    
    for(int i = 0; i<q; i++){
        int p,x;cin>>p>>x;
        m[p] += x;
    }
    if(m[1]) v[1] = m[1];
    c[1]++;
    a(1);
    for(int i = 1; i <= n; i++){
        if(i) cout << " ";
        cout << v[i];
    }
    cout << endl;
    return 0;
}


Measured memory_bytes: 46080
a[6]={2,3,5,10,12,15},b[6]={380,550,850,1520,1870,2244},m[51],T;
int s(p,n){
	int d=5;
	if(m[n]>9998)for(;~d;d--)if(a[d]<=n){
		T=s(p,n-a[d])+b[d];
		if(m[n]>T)m[n]=T;
	}
	return m[n];
}

main(n){
	for(n=1;n<51;n++)m[n]=9999;
	for(;scanf("%d",&n),n;)printf("%d\n",s(m,n/100));
	exit(0);
}

Measured memory_bytes: 600
#include<iostream>
#include<vector>
#include<map>
#include<set>
#include<numeric>
#define ll long long
#define MOD = 1e9+7
 
using namespace std;

int main(){
  int K,A,B,ans;
  cin >> K >> A >> B;
  ans = B / K;
  if(ans * K >=A) cout << "OK" << endl;
  else cout << "NG" << endl;
}

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

int x;
void input(){
    cin>>x;
}
std::vector<bool> IsPrime;

void sieve(size_t max){
    if(max+1 > IsPrime.size()){     // resizeで要素数が減らないように
        IsPrime.resize(max+1,true); // IsPrimeに必要な要素数を確保
    } 
    IsPrime[0] = false; // 0は素数ではない
    IsPrime[1] = false; // 1は素数ではない

    for(size_t i=2; i*i<=max; ++i) // 0からsqrt(max)まで調べる
        if(IsPrime[i]) // iが素数ならば
            for(size_t j=2; i*j<=max; ++j) // (max以下の)iの倍数は
                IsPrime[i*j] = false;      // 素数ではない
}

void src(){
    sieve(101000);
    repi(i,x,101000){
        if(IsPrime[i]){ cout<<i;return;}
    }
}

int main(int argc,char* argv[]){
    //ifstream in( argv[1] ); cin.rdbuf(in.rdbuf());
    input();
    src();    
    return 0;
}

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

using namespace std;

const int N = 100007;
const int INF = 1000000007;

int h[N], dp[N];

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

  for(int i = 0; i < n; ++i) cin >> h[i];

  for(int i = 0; i <= k; ++i) dp[i] = abs(h[i] - h[0]);
  for(int i = k + 1; i < n; ++i) {
    dp[i] = INF;
    for(int j = i - k; j < i; ++j) {
      dp[i] = min(dp[i], dp[j] + abs(h[i] - h[j]));
    }
  }

  cout << dp[n - 1] << "\n";
  return 0;
}


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

int main()
{
  while(1){
    int N;
    int ba=0;
    char deck[100];

    cin>>N;
    if(N==0)
      break;

    int player[N];
    for(int i=0; i<N; i++)
      player[i]=0;
    for(int i=0; i<100; i++)
      cin>>deck[i];

    for(int i=0; i<100; i++){
      if(deck[i]=='M'){
        player[i%N]++;
      }
      else if(deck[i]=='S'){
        ba+=player[i%N]+1;
        player[i%N]=0;
      }
      else if(deck[i]=='L'){
        player[i%N]+=ba+1;
        ba=0;
      }
    }
    sort(player,player+N);
     for(int i=0; i<N; i++){
      cout<<player[i]<<' ';
    }
    cout<<ba<<endl;
  }
  return 0;
}

Measured memory_bytes: 3144
#include <iostream>
#include <vector>

using namespace std;

int main()
{    
    while(1)
    {
        int H,W;
        cin >> H >> W;

        if(H == 0 && W == 0)
        {
            return 0;
        }

        for(int i = 0;i < H;i++)
        {
            for(int j = 0;j < W;j++)
            {
                cout << "#";
            }
            cout << endl;
        }
        cout << endl;
    }
}

Measured memory_bytes: 1152
#include <iostream>
using namespace std;
int main(){
	int N,M;
	long long array[100010]={0};
	cin >> N >> M;
	
	for(int i=1;i<=max(N,M);i++){
		if(i==1){
			array[i]=1;
		}else{
			array[i]=(i*array[i-1])%1000000007;
		}
	}
	
	if(N==M){
		cout << (2*array[N]*array[M])%1000000007 << endl;
	}else if(N-1==M||M-1==N){
		cout << (array[N]*array[M])%1000000007 << endl;
	}else{
		cout << 0 << endl;
	}
	
	return 0;
}


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

long long n,m;

inline long long read(){
	long long x=0,w=0; char ch=0;
	while (!isdigit(ch))
		w|=(ch=='-'),ch=getchar();
	while (isdigit(ch))
		x=(x<<3)+(x<<1)+(ch-'0'),ch=getchar();
	return w?-x:x;
}

inline void write(long long x){
	if (x<0) putchar('-'),x=-x;
	if (x>9) write(x/10);
	putchar(x%10+'0');
}

int main(){
	n=read();m=read();
	if ((n<<1)>m) write(m>>1);
	else if ((n<<1)==m) write(n);
	else {
		m-=(n<<1);
		m>>=2;
		write(n+m);
	}
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
  int X;
  cin>>X;
  int J=X/1.08;
  for(int i=J-2;i<=J+2;i++){
    int P=i*1.08;
    if(P==X){
      cout<<i;
      return 0;
    }
  }
  cout <<":(";
  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
int main(void) {
  int N, K, h[1000000], i, x;
  scanf("%d", &N);
  scanf("%d", &K);
  for (i = 0; i < N; i++) {
    scanf("%d", &h[i]);
  }
  for (i = 0; i < N; i++) {
    if (h[i] >= K) x++;
  }
  printf("%d\n", x);
  return 0;
}


Measured memory_bytes: 2432
import sys,heapq
from collections import deque,defaultdict
printn = lambda x: sys.stdout.write(x)
inn = lambda : int(input())
inl   = lambda: list(map(int, input().split()))
inm   = lambda:      map(int, input().split())
DBG = True # and False
def ddprint(x):
  if DBG:
    print(x)

x,y,z,k = inm()
a = inl()
b = inl()
c = inl()
a.sort(reverse=True)
b.sort(reverse=True)
c.sort(reverse=True)
if x < 60 or y < 60:
    loa = x
    lob = y
elif a[0]-a[60] > b[0]-b[60]:
    loa = 60
    lob = y
else:
    loa = x
    lob = 60

ab = []
for i in range(loa):
    for j in range(lob):
        ab.append(a[i]+b[j])
ab.sort(reverse=True)

u = len(ab)
if z < 60 or u < 60:
    loc = z
    loab = u
elif c[0]-c[60] > ab[0]-ab[60]:
    loc = 60
    loab = u
else:
    loc = z
    loab = 60

abc = []
for i in range(loc):
    for j in range(loab):
        abc.append(c[i]+ab[j])
abc.sort(reverse=True)

for i in range(k):
    print(abc[i])


Measured memory_bytes: 134356
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ull unsigned long long
#define fio ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define pb push_back
#define mod 1000000007
#define vi vector<int>
#define si set<int>
#define pi pair<int,int>
#define li list<int>
#define fi first
#define in insert
#define se second
#define fr(i,n) for(i = 0 ; i < n ; i++)
ll dp[101][100001];
ll v[100],wt[100];
ll sum(int i,int w)
{
    if(w<0)
        return INT_MIN;
    if(i<0 || w==0)
        return 0;
    if(dp[i][w]!=0)
        return dp[i][w];
    return dp[i][w] = max(sum(i-1,w),v[i]+sum(i-1,w-wt[i]));
}
int main()
{
    fio
    ll n,W,i,j,k;
    cin>>n>>W;
    fr(i,n)
    {
        cin>>wt[i]>>v[i];
    }

   cout<<sum(n-1,W);
    return 0;
}



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

#define max(a,b) ((a)>(b)?(a):(b))
#define min(a,b) ((a)<(b)?(a):(b))

typedef long long LL;

struct node{
  LL num=-1;
  struct node* r=NULL;
  struct node* l=NULL;
};

void decode(string s,struct node* now){
  int i=0;
  int l=0,r=0;
  for(;;i++){
    if(s[i]=='(') l++;
    else if(s[i]==')') r++;
    if(l==r){
      if(i>1){
        now->l=new struct node;
        decode(s.substr(1,i-1),now->l);
        //cout << s.substr(1,i-1) <<endl;
      }
      break;
    }
  }
  int tmp=i;
  for(;;i++){
    if(s[i]==']'){
      now->num=stoi(s.substr(tmp+2,i-tmp-2));
      break;
    }
  }
  if(i<s.length()-3){
    now->r=new struct node;
    decode(s.substr(i+2,s.length()-3-i),now->r);
    //cout << s.substr(i+2,s.length()-3-i) << endl;
  }
  return;
}

string encode(struct node* now){
  if(now!=NULL){
    return "("+encode(now->l)+")["+to_string(now->num)+"]("+encode(now->r)+")";
  }else{
    return "";
  }
}

void merge(struct node* now,struct node* anow,struct node* bnow){
  now->num=anow->num+bnow->num;
  if(anow->l!=NULL&&bnow->l!=NULL){
    now->l=new struct node;
    merge(now->l,anow->l,bnow->l);
  }
  if(anow->r!=NULL&&bnow->r!=NULL){
    now->r=new struct node;
    merge(now->r,anow->r,bnow->r);
  }
  return;
}

int main(){
  string a,b;
  cin >> a >> b;
  struct node A,B,ans;
  decode(a,&A);
  decode(b,&B);
  merge(&ans,&A,&B);
  // for(int i=0;i<50;i++){
  //   cout << A[i] << " ";
  // }
  // cout << endl;
  cout << encode(&ans) << endl;
  return 0;
}



Measured memory_bytes: 3336
#define _USE_MATH_DEFINES

#include <cmath>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <limits>
#include <cstring>
#include <string>
#include <queue>
#include <map>
#include <set>
#include <bitset>

using namespace std;

typedef long long ll;
typedef pair<int, int> P;

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

const int Maxn = 110;
const int MOD = (int) 1e9 + 7;

vector<ll> v[4];
vector<ll> sv[4];
int n;
ll w, w0, v0;
ll v1, v2, v3, v4;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cin >> n >> w;
    cin >> w0 >> v0;
    v[0].emplace_back(v0);
    for (int i = 0; i < n - 1; ++i) {
        int a, b;
        cin >> a >> b;
        v[a - w0].emplace_back(b);
    }
    for (auto &i : v) {
        sort(i.begin(), i.end(), greater<ll>());
    }
    for (int i = 0; i < 4; ++i) {
        ll x = 0;
        sv[i].emplace_back(0);
        for (auto &j : v[i]) {
            x += j;
            sv[i].emplace_back(x);
        }
    }

    ll ans = 0;
    for (int i = 0; i <= (int) v[0].size(); ++i) {
        for (int j = 0; j <= (int) v[1].size(); ++j) {
            for (int k = 0; k <= (int) v[2].size(); ++k) {
                for (int l = 0; l <= (int) v[3].size(); ++l) {
                    if (w0 * i + (w0 + 1) * j + (w0 + 2) * k + (w0 + 3) * l > w) break;
                    ans = max(ans, sv[0][i] + sv[1][j] + sv[2][k] + sv[3][l]);
                }
            }
        }
    }

    cout << ans << endl;
}


Measured memory_bytes: 256
import sys

readline = sys.stdin.readline
MOD = 10 ** 9 + 7
INF = float('INF')
sys.setrecursionlimit(10 ** 5)


def main():
    n = int(input())
    a = [0] * n
    b = [0] * n

    for i in range(n):
        a[i], b[i] = list(map(int, readline().split()))

    a.sort()
    b.sort()

    if n % 2 == 1:
        x = a[(n + 1) // 2 - 1]
        y = b[(n + 1) // 2 - 1]
        print(y - x + 1)
    else:
        x = (a[n // 2 - 1] + a[n // 2])
        y = (b[n // 2 - 1] + b[n // 2])
        print(y - x + 1)


if __name__ == '__main__':
    main()


Measured memory_bytes: 75272
#include<iostream>
#include<string>
#include<algorithm>
#include<bits/stdc++.h>

using namespace std;

int main(){
	int a,b,c;
	cin >> a >> b >> c;
	if(a+b==c)
	cout << "Yes" << endl;
	else if(a+c==b)
	cout << "Yes" << endl;
	else if(b+c==a)
	cout << "Yes" << endl;
	else
	cout << "No" << endl;
	
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define repr(i, a, b) for(int i = a; i >= b; i--)
#define int long long
#define all(a) a.begin(), a.end()
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
using namespace std;
typedef pair<int, int> P;
const int mod = 1000000007;
const int INF = 1e12;

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    map<char, int> mp;
    rep(i, 0, n){
        string s;
        cin >> s;
        mp[s[0]]++;
    } 
    int ans = 0;
    string str = "MARCH";
    rep(i, 0, 5){
        if(mp[str[i]] == 0) continue;
        rep(j, i + 1, 5){
            if(mp[str[j]] == 0) continue;
            rep(k, j + 1, 5){
                if(mp[str[k]] == 0) continue;
                ans += mp[str[i]] * mp[str[j]] * mp[str[k]];
            }
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(){

  int G[101][101];
  int n,i,j,k,l,u;

  scanf("%d",&n);
  for(i=0;i<n;i++){
    for(j=0;j<n;j++){
      G[i][j]=0;
    }
  }

  for(i=0;i<n;i++){
    scanf("%d%d",&k,&l);
    k--;
    for(j=0;j<l;j++){
      scanf("%d",&u);
      u--;
      G[k][u]=1;
    }
  }

  for(i=0;i<n;i++){
    for(j=0;j<n;j++){
      if(j==0){
	printf("%d",G[i][j]);
      }
      if(j!=0){
	printf(" %d",G[i][j]);
      }
    }
    printf("\n");
  }
  return 0;
}

Measured memory_bytes: 636
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**7)
from collections import Counter, deque
#from collections import defaultdict
from itertools import combinations, permutations, accumulate, groupby, product
from bisect import bisect_left,bisect_right
from heapq import heapify, heappop, heappush
from math import floor, ceil,pi
#from operator import itemgetter
from copy import deepcopy
def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))
def LI2(): return [int(input()) for i in range(n)]
def MXI(): return [LI()for i in range(n)]
inf = 10**17
mod = 10**9 + 7

a,b=MI()
print(ceil((a+b)/2))

Measured memory_bytes: 38384
//#include <bits/stdc++.h>
#include <iostream>
#include <fstream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <map>
#include <iomanip>
#include <stdlib.h>
#include <stdio.h>
#include <queue>
#include <deque>
#include <set>
#include <stack>
#include <time.h>
 
using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef pair<int, int> Pii;
typedef pair<int, ll> Pil;
typedef pair<ll, ll> Pll;
typedef pair<ll, int> Pli;

#define fi first
#define se second
#define mp make_pair
 
const ll MOD = 1e9 + 7;
const ll MOD2 = 998244353;
const ll MOD3 = 1812447359;
const ll INF = 1ll << 62;
const double PI = 2 * asin(1);

void yes() {printf("yes\n");}
void no() {printf("no\n");}
void Yes() {printf("Yes\n");}
void No() {printf("No\n");}
void YES() {printf("YES\n");}
void NO() {printf("NO\n");}

int main(){
  string T; cin >> T;

  for (int i = 0; i < T.length(); i++){
    if (T[i] != '?') continue;
    T[i] = 'D';
  }

  cout << T << endl;

  return 0;
}


Measured memory_bytes: 3728
#include <iostream>
 
int main(void){
    int N, B[105], i, s, a;
    scanf("%d", &N);
    for (i=1; i<=N-1; i++) scanf("%d", &B[i]);
    B[0]=200000; B[N]=200000;
    s=0;
    for (i=1; i<=N; i++) {
        a=std::min(B[i-1], B[i]);
        // printf("%d\n", a);
        s+=a;
    }
    printf("%d", s);
    return 0;
}


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

#define FOR(i, m, n) for (int i = int(m); i < int(n); i++)
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define MP make_pair
#define PB push_back
#define EB emplace_back
#define ALL(x) x.begin(), x.end()
#define F first
#define S second
#define INF 1e9 + 7

using pi = pair<int, int>;
using vi = vector<int>;
using ld = long double;

typedef long long ll;

int main() {
    int a, b;
    cin >> a >> b;
    int ans = 0;
    int outlet = 1;
    // 差込口が１口しかない！
    //　そのためタップを１つ増やすには
    // 　タップの差込口を１つ使う
    while (outlet < b) {
        --outlet; // タップを１つ増やすたびに１口使う
        outlet += a;
        ++ans;
    }
    cout << ans << endl;
    return 0;
}

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

int main() {
  int n;
  int f=0;
  cin >> n;
  for(int x=1000000000; x!=1; x=x/10){
    f += n%x/(x/10);
  }
  if(n%f==0)cout << "Yes" << endl;
  else cout << "No" << endl;
}


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

using namespace std;

int main()
{
    int S, h, m, s;
    cin >> S;
    h = S / (60 * 60);
    m = S % (60 * 60) / 60;
    s = S % (60 * 60) % 60;
    cout << h << ":" << m << ":" << s << endl;
}


Measured memory_bytes: 3096