akhauriyash/Code-Regression huggingface dataset:
#include <iostream> // cin, cout, cerr, clog
#include <algorithm> // minmax, sort, swap
#include <numeric> // iota, gcd, lcm 
#include <cstdio> // printf, scanf
#include <climits> // INT_MIN, LLONG_MIN
#include <cmath> // long, trig, pow
#include <vector> // vectors
#include <string> // string
#include <queue> // queue
#include <stack> // stack
#include <map> // key-value pairs sorted by keys
#include <unordered_map> // hashed by keys
#define _for(i,n) for(int i = 0; i < n; i++)

typedef long long ll; // at least int64 > 9*10^18
typedef unsigned long long ull; // at least uint64

int main() {
  int h,w;
  std::cin >> h >> w;
  std::vector<std::string> grid;
  std::vector<std::pair<int,int> > que;
  std::vector<std::vector<int> > dist(h, std::vector<int>(w,-1));
  _for(i,h) {
    std::string s;
    std::cin >> s;
    grid.emplace_back(s);
    _for(j,w) {
      if (s[j]=='#') {
        que.emplace_back(i,j);
        dist[i][j] = 0;
      }
    }
  }
  for (int b = 0; b < que.size(); b++) {
    for (int dx = -1; dx<=1; dx++) {
      for (int dy = -1; dy<=1; dy++) {
        if (dx*dx + dy*dy==1) {
          int xk = que[b].first + dx;
          int yk = que[b].second + dy;
          if (xk>=0&&yk>=0&&xk<h&&yk<w&&dist[xk][yk]==-1) {
            que.emplace_back(xk,yk);
            dist[xk][yk] = dist[que[b].first][que[b].second] + 1;
          }
        }
      }
    }
  }
  std::cout << dist[que.back().first][que.back().second] << std::endl;
  return 0;
}

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

struct UnionFind {
    vector<int> par;

    UnionFind(int n) : par(n, -1) { }
    void init(int n) { par.assign(n, -1); }

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

    bool issame(int x, int y) {
        return root(x) == root(y);
    }

    bool merge(int x, int y) {
        x = root(x); y = root(y);
        if (x == y) return false;
        if (par[x] > par[y]) swap(x, y); // merge technique
        par[x] += par[y];
        par[y] = x;
        return true;
    }

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

int main() {
    int N,M,K;cin >> N >> M >> K;
    vector<vector<int>> F(N);
    vector<vector<int>> B(N);
    UnionFind uf(N);
    for (int i = 0;i < M;i++){
        int a,b;cin >> a >> b;
        uf.merge(a - 1,b - 1);
        F[a - 1].push_back(b - 1);
        F[b - 1].push_back(a - 1);
    }
    for (int i = 0;i < K;i++){
        int c,d;cin >> c >> d;
        if (!uf.issame(c - 1,d - 1)) continue;
        B[c - 1].push_back(d - 1);
        B[d - 1].push_back(c - 1);
    }
    for (int i = 0;i < N;i++){
        int sum = uf.size(i) - 1;
        sum -= F[i].size();
        sum -= B[i].size();
        cout << sum << " ";
    }
    cout << endl;
}

Measured memory_bytes: 12152
#include <cstring>
#include <sstream>
#include <cstdio>
#include <algorithm>
#include <iostream>
#include <vector>
#include <iomanip>
#include <map>
#include <unordered_map>
#include <cmath>
#include <queue>
#include <set>
#include <numeric>
#include <stack>

using namespace std;
typedef long long ll;
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define repr(i, n) for(ll i = n - 1; i >= 0; i--)
#define repone(i, n) for(ll i = 1; i <= (ll)(n); i++)
#define each(i, mp) for(auto i:mp)
#define eb emplace_back
#define F first
#define S second
#define all(obj) (obj).begin(), (obj).end()
const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
const ll mod = 1000000007;
const ll inf = ll(1e9);
const ll half_inf = ll(1e5);
const ll ll_inf = ll(1e9) * ll(1e9);
typedef unordered_map<ll, ll> mpll;
typedef unordered_map<char, ll> mpcl;
typedef unordered_map<string, ll> mpsl;
typedef pair<ll, ll> P;
typedef vector<ll> vl;
typedef vector<vl> vvl;
template<typename T> using PQ = priority_queue<T>;
template<typename T> using minPQ = priority_queue<T, vector<T>, greater<T>>;

ll inl() {
    ll x;
    cin >> x;
    return (x);
}

string ins() {
    string x;
    cin >> x;
    return (x);
}

int main() {
#ifdef MY_DEBUG
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wmissing-noreturn"
    while (true) {
#pragma clang diagnostic pop
#endif
        ll n = inl(), a = inl(), b = inl(), c = inl(), d = inl();
        a--, b--, c--, d--;
        string s = ins();
        if (c < d) {
            for (int i = a; i < d; i++) {
                if (s[i] == '#' && s[i + 1] == '#') {
                    cout << "No" << endl;
                    return 0;
                }
            }
            cout << "Yes" << endl;
            return 0;
        } else {
            for (int i = a; i < c; i++) {
                if (s[i] == '#' && s[i + 1] == '#') {
                    cout << "No" << endl;
                    return 0;
                }
            }
            if (a + 2 == b && s[a + 1] == '.') a++;

            for (int i = a; i <= d; i++) {
                if ((i == d && s[i + 1] == '#') || (s[i] == '#' && i + 1 == d)) {
                    cout << "No" << endl;
                    return 0;
                }
                if (b - 1 <= i && i + 1 <= d) {
                    if (s[i] == '.' && s[i + 1] == '.' && s[i + 2] == '.') {
                        cout << "Yes" << endl;
                        return 0;
                    }
                }
            }
            cout << "No" << endl;
            return 0;
        }

#ifdef MY_DEBUG
    }

#endif
    return 0;
}

Measured memory_bytes: 640
#include <stdio.h>
int main(){
  int a,b,r,tmp;
  scanf("%d%d",&a,&b);
    if(a<b){
    tmp = a;
    a = b;
    b = tmp;
  }
  r = a % b;
  while(r!=0){
    a = b;
    b = r;
    r = a % b;
  }
  printf("%d\n",b);
  return 0;
}



Measured memory_bytes: 2140
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define REP(i, start, end) for (ll i = start, i##Len = (end); i < i##Len; ++i)
#define REPR(i, start, end) for (ll i = start, i##Len = (end); i > i##Len; --i)
using ll = long long;
using namespace std;

int main()
{
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);

    ll n, m, k;
    cin >> n >> m >> k;
    vector<ll> a(n + 2), b(m + 2);
    REP(i, 1, n + 1)
    {
        cin >> a[i];
        a[i] += a[i - 1];
    }
    a[n + 1] = k + 1;
    REP(i, 1, m + 1)
    {
        cin >> b[i];
        b[i] += b[i - 1];
    }
    b[m + 1] = k + 1;

    ll j = 0;
    while (k >= b[j + 1])
        ++j;
    ll ans = j;

    REP(i, 1, n + 1)
    {
        if (a[i] > k)
            break;
        while (a[i] + b[j] > k)
            --j;
        ans = max(ans, i + j);
    }

    cout << ans << endl;
}


Measured memory_bytes: 6368
#include<cstdio>
#include<cmath>
#include<string>
#include<iostream>
#include<algorithm>
#include<utility>
#include<vector>
#include<map>
#include<set>
#include<limits>
#include<bitset>
#include<array>
#include<numeric>
#include<iomanip>

using namespace std;
typedef long long int ll;

int n,va[100010],vi[100010],r;
map<int,int> ma,mi;
vector<int> af,as,bf,bs;

void sortvec(vector<int> &target, vector<int> &secondnum)
{
    int vecsize=target.size();
    vector<int> baseint,target2(vecsize),secondnum2(vecsize);
    for(int i=0;i<vecsize;i++)baseint.push_back(i);
    sort(baseint.begin(),baseint.end(),[&](int a,int b){return target[a]>target[b];});
    for(int i=0;i<vecsize;i++){
        target2[i]=target[baseint[i]];
        secondnum2[i]=secondnum[baseint[i]];
    }
    target=target2;secondnum=secondnum2;
}

int main(){
    scanf("%d",&n);
    ma[-1]=0;
    mi[-1]=0;
    for(int i=0;i<n/2;i++){
        scanf("%d %d",&va[i],&vi[i]);
        ma[va[i]]=0;
        mi[vi[i]]=0;
    }
    for(int i=0;i<n/2;i++){
        ma[va[i]]++;
        mi[vi[i]]++; 
    }
    for(auto g=ma.begin();g!=ma.end();++g){
        af.push_back(g->first); //要素の種類（入力から)
        as.push_back(g->second);//出てきた数
    }
    for(auto g=mi.begin();g!=mi.end();++g){
        bf.push_back(g->first);
        bs.push_back(g->second);
    }
    sortvec(as,af);
    sortvec(bs,bf);
    if(af[0]!=bf[0]){
        r=n-as[0]-bs[0];
    }
    else{
        r=min(n-as[1]-bs[0],n-as[0]-bs[1]);
    }
    printf("%d\n",r);
    
}

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

using namespace std;
using namespace std;
#define rep(i,n) for(long long i=0; i<(long long)(n);i++)
//rep…「0からn-1まで」の繰り返し
#define rep2(i,s,n) for(long long i=s; i<=(long long)(n);i++)
//rep2…「sからnまで」の繰り返し
#define repr(i,s,n) for(long long i=s;i>=(long long)(n);i--)
//repr…「ｓからnまで」の降順の繰り返し

typedef long long ll;

const ll inf = 1e9+7;
const ll mod = 1e9+7;

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

    while(a>0&&c>0){
        c-=b;
        if(c<=0){
            cout<<"Yes"<<endl;
            return 0;
        }
        a-=d;
        if(a<=0){
            cout<<"No"<<endl;
            return 0;
        }
    }
}


Measured memory_bytes: 3632
x,y = map(int,input().split())
ans = 'No'

a = [1,3,5,7,8,10,12]
b = [4,6,9,11]
c = [2]

if(x in a and y in a or 
x in b and y in b or
x in c and y in c):
    ans = 'Yes'

print(ans)


Measured memory_bytes: 9108
//{{{
#include <bits/stdc++.h>
using namespace std;
#define rep(...) repN((__VA_ARGS__,rep3,rep2,loop,~))(__VA_ARGS__)
#define loop(n) rep2(_loop_,n)
#define rep2(i,n) rep3(i,0,n)
#define rep3(i,begin,end) for(int i=(int)(begin),i##_end=(int)(end);i<i##_end;++i)
#define repN(a) repX a
#define repX(a0,a1,a2,x,...) x
#define foreach(x,a) for(auto &x:a)
typedef long long ll;
const ll MOD = 998244353;
//}}}

ll x[1000];
ll y[1000];
ll z[1000];
ll w[1000];
int main(){
  ll N, M;
  cin >> N >> M;
  ll ans = 0;
  rep(i, N){
    cin >> x[i];
    cin >> y[i];
    cin >> z[i];
  }

  rep(i, 8){
    rep(j, N){
      w[j] = 0;
      w[j] += ((i & 1) ? x[j] : -x[j]);
      w[j] += ((i & 2) ? y[j] : -y[j]);
      w[j] += ((i & 4) ? z[j] : -z[j]);
    }
    sort(w, w + N);
    reverse(w, w + N);
    ll sum = 0;
    rep(j, M) sum += w[j];
    ans = max(abs(sum), ans);
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize("unroll-loops")
#include<bits/stdc++.h>
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define pb push_back
using namespace std;
using ll = long long;
using vi = vector<ll>;
const int maxn = 5050, mod = 1e9 + 7;
int n, m, dp[maxn][maxn];
void add(int &a, int b) {
	a += b;
	if(a >= mod) a -= mod;
}
int main() {
	cin.tie(0)->sync_with_stdio(0);
	cin >> n >> m;
	for(int i = 0; i <= m; i++) dp[0][i] = 1;
	for(int i = 1; i <= n; i++) {
		int cur = 0;
		dp[i][0] = 1;
		add(dp[i][1], dp[i-1][1]);
		add(dp[i][1], dp[i-1][1]);
		for(int j = 2; j <= m; j++) {
			add(dp[i][j], dp[i-1][j] * 1ll * (j+1) %mod);
			add(cur, cur);
			add(cur, dp[i-1][j-1]*1ll*(j-1)%mod);
			add(dp[i][j], cur);
		}
	}
	cout << dp[n][m];
}


Measured memory_bytes: 102244
#include <iostream>
#include <fstream>
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <iomanip>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <sstream>
#include <string>
#include <vector>
using namespace std;

#define EPS 1e-9
#define INF MOD
#define MOD 1000000007LL
#define fir first
#define iss istringstream
#define sst stringstream
#define ite iterator
#define ll long long
#define mp make_pair
#define rep(i,n) rep2(i,0,n)
#define rep2(i,m,n) for(int i=m;i<n;i++)
#define pi pair<int,int>
#define pb push_back
#define sec second
#define sh(i) (1LL<<i)
#define sz size()
#define vi vector<int>
#define vc vector
#define vl vector<ll>
#define vs vector<string>

#define P complex<double>
#define PI (atan(1.)*4)

int n,L,R,t;
double D;

P e(double t){
  return P(cos(t),sin(t));
}

int main(){
	while(cin>>n>>D,n){
		P l=P(-D,0),r=P(D,0);
		while(n--){
			cin>>L>>R>>t;
			if(L==R){
				P d=(r-l)/abs(r-l)*e(PI/2)*(L*PI/180*t);
				l+=d,r+=d;
			}else if(!L||!R){
				if(!L){
					double th=R*PI/180*t/(2*D);
					r=l+(r-l)*e(th);
				}else{
					double th=L*PI/180*t/(2*D);
					l=r+(l-r)*e(-th);
				}
			}else{
				if(L>0&&R>0&&L>R||L<0&&R<0&&L<R||L>0&&R<0){
					P c=l+(r-l)*(1.*L/(L-R));
					double th=L*PI/180*t/abs(l-c);
					l=c+(l-c)*e(-th);
					r=c+(r-c)*e(-th);
				}else{
					P c=r+(l-r)*(1.*R/(R-L));
					double th=R*PI/180*t/abs(r-c);
					l=c+(l-c)*e(th);
					r=c+(r-c)*e(th);
				}
			}
		}
		printf("%.7f\n%.7f\n",(real(l)+real(r))/2,(imag(l)+imag(r))/2);
	}
}

Measured memory_bytes: 0
#include <cstdio>
#include <string>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <list>
#include <iterator>
#include <cassert>
#include <numeric>
#include <functional>
//#include <numeric>
#pragma warning(disable:4996) 
 
typedef long long ll;
typedef unsigned long long ull;
#define MIN(a, b) ((a)>(b)? (b): (a))
#define MAX(a, b) ((a)<(b)? (b): (a))
#define LINF  9223300000000000000
#define LINF2 1223300000000000000
#define LINF3 1000000000000
#define INF 2140000000
const long long MOD = 1000000007;
//const long long MOD = 998244353;

using namespace std;


void solve()
{
    int n;
    scanf("%d", &n);
    vector<ll> a(n);
    int i;
    int zero = 0;
    for (i = 0; i < n; i++) {
        scanf("%lld", &a[i]);
        if (a[i] == 0) {
            zero = 1;
        }
    }
    if (zero) {
        printf("0\n"); return;
    }
    double d = 1;
    ll s = 1;
    for (i = 0; i < n; i++) {
        s *= a[i];
        d *= a[i];
        if (d > 1e19) {
            printf("-1\n");
            return;
        }
    }
    if (s > 1000000000000000000) {
        printf("-1\n");
    }
    else {
        printf("%lld\n", s);
    }
    return;
}


int main(int argc, char* argv[])
{
#if 1
    solve();
#else
    int T;
    scanf("%d", &T);
    int t;
    for(t=0; t<T; t++) {
        //printf("Case #%d: ", t+1);
        solve();
    }
#endif
    return 0;
}


Measured memory_bytes: 3572
N=int(raw_input())
A=[]
for i in range(N):
    A.append([int(x) for x in raw_input().split()])
C=[[0,0,0] for x in range(N)]
C[0]=[A[0][0],A[0][1],A[0][2]]
for i in range(1,N):
    for j in range(3):
        C[i][j]=A[i][j] + max([ C[i-1][k] for k in range(3) if k != j])
print max(C[-1])


Measured memory_bytes: 54940
import qualified Data.Vector.Unboxed as U
import qualified Data.Vector as V
import qualified Data.ByteString.Char8 as C
import Debug.Trace
import Data.List
import Control.Monad
import Data.Ord


r :: Int -> IO (U.Vector Int)
r n = U.unfoldrN n (C.readInt . C.dropWhile (==' ')) <$> C.getLine

r' :: IO [Int]
r'  =   unfoldr    (C.readInt . C.dropWhile (==' ')) <$> C.getLine

rp :: IO (Int,Int)
rp  = toTup . unfoldr    (C.readInt . C.dropWhile (==' ')) <$> C.getLine

toTup [a,b] = (a,b)



main :: IO ()
main = do
    [n,r] <- r'
    print $ if n >= 10 then r else r + 100 * (10 - n)



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

vector<ll> v(303030);
ll n,k,m,x,y;
string s,t;

int main() {
  cin >> n;
  ll sum=0;
  rep(i,n){
  cin >> v[i]; sum+=v[i];
  }
  ll l=0,ans=1e10;
  rep(i,n) l+=v[i],ans=min(abs((sum-l)-l),ans);
  cout << ans << endl;
}

Measured memory_bytes: 2560
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

main(){
  int x,i=0,a=0,b=0;
  char s[100];
  int ans[100];

  while(scanf("%s",s)!=EOF)
    {
      if(s[0]=='+')
	{
	  a=ans[--i];
	  b=ans[--i];
	  ans[i]=b+a;
	  i++;
	}
      else if(s[0]=='-')
	{
	  a=ans[--i];
	  b=ans[--i];
	  ans[i]=b-a;
	  i++;
	}
      else if(s[0]=='*')
	{
	  a=ans[--i];
	  b=ans[--i];
	  ans[i]=b*a;
	  i++;
	}
      else 
	{
	  x=atoi(s);
	  ans[i]=x;
	  i++;
	}
    }

  printf("%d\n",ans[--i]);

  return 0;
}

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


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

  ll x;
  cin >> x;

  ll ans = x/500 *1000 + (x - x/500*500 )/5*5;
  cout << ans << endl;

  
  return 0;
    

}


Measured memory_bytes: 256
def main():
    n = int(input())
    reds = [list(map(int, input().split())) for _ in range(n)]
    blues = sorted(list(map(int, input().split())) for _ in range(n))
    res = 0
    for blue in blues:
        y_max = -1
        y_max_i = None
        for i, red in enumerate(reds):
            if red[0] > blue[0] or red[1] > blue[1]:
                continue
            if red[1] > y_max:
                y_max = red[1]
                y_max_i = i
        if y_max_i is not None:
            res += 1
            del reds[y_max_i]
    print(res)


if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
#include <iostream>
#include <algorithm>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <string.h>
#include <vector>
#include <queue>
#include <cmath>
#include <bitset>
#include <complex>
#include <functional>
#include <numeric>
#include <iomanip>

// output
#define SPBR(w, n) std::cout<<(w + 1 == n ? '\n' : ' ');
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl
// utility
#define ALL(i) (i).begin(), (i).end()
#define FOR(i, a, n) for(int i=(a);i<(n);++i)
#define RFOR(i, a, n) for(int i=(n)-1;i>=(a);--i)
#define REP(i, n) for(int i=0;i<int(n);++i)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define IN(a, x, b) (a<=x && x<b)
#define OUT(a, x, b) (x<a || b<=x)
template<class T> inline T chmax(T & a, const T b) { return a = (a < b) ? b : a; }
template<class T> inline T chmin(T& a, const T b) { return a = (a > b) ? b : a; }

// type/const
#define int ll
using ll = long long;
using ull = unsigned long long;
using ld = long double;
const int MOD = 1000000007;
/* const int MOD = 998244353; */
const int INF = 1e18;
const double PI = acos(-1);

using namespace std;
struct INIT { 
  INIT(){cin.tie(0); ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);
}}INIT;


signed main() {
  int N, M; 
  cin >> N >> M;

  map<int, int> m;
  REP(i, N){
    int k;
    cin >> k;
    REP(i, k){
      int a;
      cin >> a;
      m[a]++;
    }
  }

  int ans = 0;
  for(auto p : m) if(p.second == N) ans++;

  cout << ans << "\n";

  return 0;
}

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

#define int long long

typedef long long ll;
typedef pair<int,int>pint;
typedef vector<int>vint;
typedef vector<pint>vpint;
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,f,n) for(int i=(f);i<(n);i++)
#define each(it,v) for(__typeof((v).begin()) it=(v).begin();it!=(v).end();it++)
template<class T,class U>void chmin(T &t,U f){if(t>f)t=f;}
template<class T,class U>void chmax(T &t,U f){if(t<f)t=f;}

int N;

vint vec;
void dfs(int n,int d){
    if(d>1000000000ll)return;
    if(n){
        vec.pb(d);
    }
    dfs(n+1,d*10+2);
    dfs(n+1,d*10+8);
}

bool C(int d){
    if(d==1)return true;
    stringstream ss;ss<<d;
    string s=ss.str();
    rep(i,s.size())if(s[i]!='2'&&s[i]!='8')return false;
    return true;
}

signed main(){
    cin>>N;
    if(N==1){
        puts("-1");
        return 0;
    }
    dfs(0,0);
    sort(all(vec));
    reverse(all(vec));

    map<int,int>prev;prev[N]=0;
    for(int i=0;i<vec.size();i++){
        map<int,int>next;
        each(it,prev){
            chmax(next[it->fi],it->se);
            int tmp=it->fi,hoge=0;
            while(tmp%vec[i]==0){
                tmp/=vec[i];hoge++;
                chmax(next[tmp],it->se+hoge);
            }
        }
        prev=next;
    }

    int ans=-1;
    each(it,prev){
        if(C(it->fi))chmax(ans,it->se+(it->fi!=1));
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 3352
i = 0
while True:
    if i == 4: break
    t, n = map(int, input().split())
    if t == 1:
        print(n*6000)
    elif t == 2:
        print(n*4000)
    elif t == 3:
        print(n*3000)
    elif t == 4:
        print(n*2000)
    i += 1


Measured memory_bytes: 5596
#include <cstdio>
#include <vector>
#include <algorithm>

using namespace std;

int main()
{
	double n;
	int cnt=0;
	double ans;
	vector<double> h;
	
	while(~scanf("%lf",&n)){
		h.push_back(n);
		cnt++;
	}
	sort(h.begin(),h.end());
	ans=(h[cnt-1]-h[0]);
	printf("%.1lf\n",ans);
	return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
	string s,t;
	cin>>s>>t;
	if(s.length()==t.length()-1 && s==t.substr(0,t.length()-1))
		cout<<"Yes\n";
	else cout<<"No\n";
	return 0;
}

Measured memory_bytes: 3624
//ProblemC.cpp

#include <iostream>

static std::istream & ip = std::cin;
static std::ostream & op = std::cout;

#if OJ_MYPC
#include <ojio.h>
#endif

#ifndef OPENOJIO
#define OPENOJIO
#endif

#if 1 || DEFINE
/***************************************************************/
typedef unsigned long long u64;
typedef long long s64;

typedef unsigned uint;

#define ABS(x) ((x) > 0 ? (x) : -(x))

#define MIN(x, y) ((x) < (y) ? (x) : (y))
#define MAX(x, y) ((x) > (y) ? (x) : (y))

#define MIN3(x, y, z) MIN(x, MIN(y, z))
#define MAX3(x, y, z) MAX(x, MAX(y, z))

#define FillZero(arr) memset(arr, 0, sizeof(arr));

/***************************************************************/
#endif //1 || DEFINE

#include <string>
#include <vector>
#include <map>
#include <set>
#include <bitset>
#include <queue>
#include <stack>
#include <utility>
#include <algorithm>
#include <iomanip>
#include <cstring>
#include <cmath>
#include <cstdio>

//001
//op << setfill('0') << setw(3) << setiosflags(ios::right) << 1;

//op << fixed << setprecision(20);

using namespace std;

//ProblemC.cpp

#define MAXN 550

#if OJ_MYPC
#include <fstream>
#endif // OJ_MYPC

int main(int argc, char* argv[])
{
	OPENOJIO;

	char p[MAXN][MAXN];
	char r[MAXN][MAXN];
	char b[MAXN][MAXN];

	int h, w;
	ip >> h >> w;

	for (int i = 1; i <= h; ++i)
		for (int j = 1; j <= w; ++j) {
			ip >> p[i][j];
			b[i][j] = r[i][j] = p[i][j];
		}

	for (int i = 1; i <= h; ++i) {
		b[i][1] = r[i][w] = '#';
	}

	for (int i = 1; i <= h; i+=2) {
		for(int j = 2;j <= w - 1; ++j)
			b[i][j] = '#';
	}

	for (int i = 2; i <= h; i += 2) {
		for (int j = 2; j <= w - 1; ++j)
			r[i][j] = '#';
	}

	for (int i = 1; i <= h; ++i) {
		for (int j = 1; j <= w; ++j)
		{
			op << r[i][j];
		}
		op << endl;
	}
	op << endl;
	for (int i = 1; i <= h; ++i) {
		for (int j = 1; j <= w; ++j)
		{
			op << b[i][j];
		}
		op << endl;
	}

#if OJ_MYPC
	ofstream ofs("test.txt");
	ofs << h << ' ' << w << endl;
	for (int i = 1; i <= h; ++i) {
		for (int j = 1; j <= w; ++j)
		{
			if (b[i][j] == r[i][j])
				ofs << '#';
			else
				ofs << '.';
		}
		ofs << endl;
	}
	ofs.close();
#endif // OJ_MYPC


	return 0;
}
/***************************************************************/


Measured memory_bytes: 1664
import std.stdio, std.string, std.conv;
import std.range, std.algorithm, std.array, std.typecons, std.container;
import std.math, std.numeric, core.bitop;

enum inf = 1_001_001_001;
enum inf6 = 1_001_001_001_001_001_001L;
enum mod = 1_000_000_007L;



void main() {
    int H, A;
    scan(H, A);
    int ans = (H + A - 1) / A;
    writeln(ans);
}
















void scan(T...)(ref T args) {
    import std.stdio : readln;
    import std.algorithm : splitter;
    import std.conv : to;
    import std.range.primitives;

    auto line = readln().splitter();
    foreach (ref arg; args) {
        arg = line.front.to!(typeof(arg));
        line.popFront();
    }
    assert(line.empty);
}

void fillAll(R, T)(ref R arr, T value) {
    static if (is(typeof(arr[] = value))) {
        arr[] = value;
    }
    else {
        foreach (ref e; arr) {
            fillAll(e, value);
        }
    }
}

bool chmin(T, U...)(ref T x, U args) {
    bool isChanged;

    foreach (arg; args) {
        if (x > arg) {
            x = arg;
            isChanged = true;
        }
    }

    return isChanged;
}

bool chmax(T, U...)(ref T x, U args) {
    bool isChanged;

    foreach (arg; args) {
        if (x < arg) {
            x = arg;
            isChanged = true;
        }
    }

    return isChanged;
}


Measured memory_bytes: 256
#include <cstdio>
#include <vector>

using namespace std;

int a[1000];
long long sum[1001];

int main() {
    int n, k, i, j;
    long long ans = 0;
    vector <long long> v;
    
    scanf("%d %d", &n, &k);
    
    for (i = 0; i < n; i++) scanf("%d", &a[i]);
    
    for (i = 0; i < n; i++) sum[i + 1] = sum[i] + a[i];
    
    for (i = 0; i < n; i++) {
        for (j = i; j < n; j++) {
            v.push_back(sum[j + 1] - sum[i]);
        }
    }
    
    for (i = 50; i >= 0; i--) {
        int c = 0;
        
        for (j = 0; j < v.size(); j++) {
            if ((v[j] >> i) & 1) c++;
        }
        
        if (c >= k) {
            vector <long long> w;
            
            ans += (1LL << i);
            
            for (j = 0; j < v.size(); j++) {
                if ((v[j] >> i) & 1) w.push_back(v[j]);
            }
            
            v = w;
        }
    }
    
    printf("%lld\n", ans);
    
    return 0;
}


Measured memory_bytes: 6124
#include "bits/stdc++.h"
using namespace std;
using lint = long long;
#define low lower_bound
#define upp upper_bound
#define rep(i, n) for (lint i = 0; i < lint(n); ++i)
#define Rep(i, n) for (lint i = lint(n); i >= 0; --i)
#define all(vec) (vec).begin(), (vec).end()
#define cend printf("\n");
#define prique(T) priority_queue<T, vector<T>, greater<T>>
#define prique2(T) priority_queue<T>

struct edge { int to; double cost; };
using P = pair<lint, lint>;
using D = pair<double, double>;
using DI = pair<double, int>;
//const lint mod = 998244353LL;
const lint mod = 1000000007LL;
const lint inf = 3LL * mod * mod;

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

lint modpow(lint x, lint n, lint m) {
	lint ans = 1;
	while (n > 0) {
		if (n & 1) {
			ans *= x;
			if (m <= ans) ans %= m;
		}
		x *= x;
		if (m <= x) x %= m;
		n >>= 1;
	}
	return ans;
}

lint fact[1000000];
void f_init(lint n) {
	if (1000000 <= n) return;
	fact[0] = fact[1] = 1;
	for (lint i = 2; i <= n; ++i) {
		fact[i] = i * fact[i - 1];
		if (mod <= fact[i]) fact[i] %= mod;
	}
	return;
}

lint inver[1000000]; bool inve[100000];
lint inv(lint x) {
	if (x == 0) return 0;
	else if (inve[x]) return inver[x];
	else {
		inve[x] = true;
		return inver[x] = modpow(x, mod - 2, mod);
	}
}

lint comb(lint n, lint r) {
	if (n < r) return 0;
	if (n == r) return 1;
	lint ans = fact[n] * inv(fact[n - r]) % mod * inv(fact[r]) % mod;
	if (ans < 0) return ans + mod;
	return ans;
}

lint nck[1010][1010];
void comb(lint n) {
	rep(i, n + 1) {
		rep(j, i + 1) {
			if (j == 0 || i == j) nck[i][j] = 1;
			else nck[i][j] = nck[i - 1][j - 1] + nck[i - 1][j];
		}
	}
}

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

lint lcm(lint a, lint b) { return a / gcd(a, b) * b; }

bool pri(lint p) {
	for (lint i = 2; i * i <= p; i == 2 ? ++i : i += 2) if (p % i == 0) return false;
	return p > 1;
}

map<lint, lint> factring(lint n) {
	map<lint, lint>ans;
	for (lint i = 2; i * i <= n; ++i) {
		while (n % i == 0) {
			n /= i;
			++ans[i];
		}
	}
	if (n != 1) ++ans[n];
	return ans;
}

double dis(D a, D b) { return sqrt((a.first - b.first) * (a.first - b.first) + (a.second - b.second) * (a.second - b.second)); }

int n;
int main() {
	cin >> n;
	rep(i, n + 10) {
		if ((int)(1.08 * i) == n) {
			cout << i << endl;
			return 0;
		}
	}
	cout << ":(" << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <unordered_map>
#include <unordered_set>
#include <cmath>
#include <cstdio>
#include <map>
#include <set>
#include <utility>
#include <string>
#include <functional>
#include <queue>
#include <stack>

using namespace std;

typedef long long ll;
typedef long double ld;

ll mod = 1e9 + 7;
vector<ll> fact;
vector<ll> rfact;

ll fastpow(ll base, ll p) {
	ll ans = 1;
	while(p > 0) {
		if(p % 2 == 1) {
			ans = (ans * base) % mod;
		}
		base = (base * base) % mod;
		p /= 2;
	}
	return ans;
}

ll ncr(ll n, ll r) {
	if(r > n || n < 0 || r < 0) {
		return 0;
	}
	ll ans = (fact[n] * rfact[r]) % mod;
	ans = (ans * rfact[n - r]) % mod;
	return ans;
}

int main() {
    ios_base::sync_with_stdio(false);
	int n;
	cin >> n;
	vector<int> arr(n + 1);
	vector<int> first(n + 1, -1);
	int i;
	int val;
	int bet = 0;
	for(i = 0; i <= n; i++) {
		cin >> val;
		if(first[val] != -1) {
			bet = i - first[val] - 1;
		}
		first[val] = i;
	}
	fact = vector<ll> (n + 2, 1);
	rfact = vector<ll> (n + 2, 1);
	for(i = 1; i <= n + 1; i++) {
		fact[i] = (i * fact[i - 1]) % mod;
		rfact[i] = fastpow(fact[i], mod - 2);
	}
	for(i = 1; i <= n + 1; i++) {
		ll ans = 0;
		ans += ncr(n - 1, i);
		ans = (ans + ncr(n - 1, i - 2)) % mod;
		ans = (ans + ncr(n - 1 - bet, i - 1)) % mod;
		ll temp = (ncr(n - 1, i - 1) - ncr(n - 1 - bet, i - 1) + mod) % mod;
		temp = (2 * temp) % mod;
		ans = (ans + temp) % mod;
		cout << ans << "\n";
	}
		
		
	
	return 0;
}



Measured memory_bytes: 3584
package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func Scanner() string {
	sc.Scan()
	return sc.Text()
}

func intScanner() int {
	n, _ := strconv.Atoi(Scanner())
	return n
}

func floatScanner() float64 {
	n, _ := strconv.ParseFloat(Scanner(), 64)
	return n
}
func stringToInt(s string) int {
	n, _ := strconv.Atoi(s)
	return n
}
func stringSliceScanner(n int) []string {
	a := make([]string, n)
	for i := 0; i < n; i++ {
		a[i] = Scanner()
	}
	return a
}
func intSliceScanner(n int) []int {
	a := make([]int, n)
	for i := 0; i < n; i++ {
		a[i] = intScanner()
	}
	return a
}
func larger(a, b int) int {
	if a < b {
		return b
	} else {
		return a
	}
}
func smaller(a, b int) int {
	if a > b {
		return b
	} else {
		return a
	}
}
func max(a []int) int {
	x := a[0]
	for i := 0; i < len(a); i++ {
		if x < a[i] {
			x = a[i]
		}
	}
	return x
}
func min(a []int) int {
	x := a[0]
	for i := 0; i < len(a); i++ {
		if x > a[i] {
			x = a[i]
		}
	}
	return x
}
func abs(x int) int {
	if x < 0 {
		x = -x
	}
	return x
}

var mod int

func main() {
	mod = 1000000007
	buf := make([]byte, 0)
	sc.Buffer(buf, mod)
	sc.Split(bufio.ScanWords)
	n := intScanner()
	as := intSliceScanner(n)
	sort.Sort(sort.Reverse(sort.IntSlice(as)))
	x := make(map[int]int)
	for _, v := range as {
		x[v]++
	}
	ans := 0
	for i := 0; i < n; i++ {
		if x[as[i]] > 0 {
			rem := 1
			for rem <= as[i] {
				rem *= 2
			}
			x[as[i]]--
			rem -= as[i]
			if x[rem] > 0 {
				ans++
				x[rem]--
			}
		}
	}
	fmt.Println(ans)
}


Measured memory_bytes: 15152
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 100100;
int n , m ;
int vis[N];
ll dis[N];
vector<pair<int,ll>>adj[N];

bool dfs(int u,ll d){

if( vis[u] )return dis[u]==d;
vis[u]=1;
dis[u]=d;
for(auto p:adj[u]){
    int v = p.first;
    ll dx = p.second;
    if( !dfs(v,d+dx) )
        return 0;
}
return 1;
}

int main(){

scanf("%d %d",&n,&m);
while( m-- ){
    int i,j;
    ll d;
    scanf("%d %d %lld",&i,&j,&d);
    adj[i].push_back({j,d});
    adj[j].push_back({i,-d});
}

for(int i=1;i<=n;i++)
    if( !vis[i] )
if( !dfs(i,0) ){
    printf("No\n");
    return 0;
}

printf("Yes\n");
return 0;
}


Measured memory_bytes: 15872
import copy
N = int(input())
series = list(map(int,input().split()))
final = [0 for _ in range(len(series))]
count = 0
while series != final:
	start = 0
	end = 0
	for i in range(len(series)):
		if series[i] == 0:
			if start != i:
				end = i
				m = min(series[start:end])
				for j in range(start,end):
					series[j] -= m
				count += m
			else:
				start = i + 1
		elif i == len(series)-1:
			end = i
			m = min(series[start:i+1])
			for j in range(start,i+1):
				series[j] -= m
			count += m
print(count)

Measured memory_bytes: 3700
# -*- coding: utf-8 -*-
import sys
sys.setrecursionlimit(10**6)


class LinkedList:
    def __init__(self, n):
        self.n = n
        self.ll = [[] for _ in range(self.n)]

    def link(self, u, v, direction=False):
        self.ll[u].append(v)
        if not direction:
            self.ll[v].append(u)

    def dfs(self):
        self.cc = [None] * self.n

        color = 1
        for u in range(self.n):
            if not self.cc[u]:
                self.dfs_visit(u, color)
                color += 1

    def dfs_visit(self, u, color):
        self.cc[u] = color
        for v in self.ll[u]:
            if not self.cc[v]:
                self.dfs_visit(v, color)

    def check(self, u, v):
        if self.cc[u] == self.cc[v]:
            print('yes')
        else:
            print('no')


if __name__ == '__main__':
    n, m = map(int, input().split())
    ll = LinkedList(n)

    for _ in range(m):
        u, v = map(int, input().split())
        ll.link(u, v)
    ll.dfs()

    q = int(input())
    for _ in range(q):
        u, v = map(int, input().split())
        ll.check(u, v)



Measured memory_bytes: 126988
#include<bits/stdc++.h>
#define rep(i,l,r) for (int i=l;i<=r;i++)
using namespace std;
char s[505][505];
int a[505][505];
int n,m;
int main(){
    scanf("%d%d",&n,&m);
    rep(i,1,n) scanf("%s",s[i]+1);
    rep(i,1,n) {
        if (i&1){
            rep(j,2,m-1) a[i][j]=1;
        }
        else{
            rep(j,2,m-1) a[i][j]=2;
        }
    }
    rep(i,1,n) a[i][1]=1;
    rep(i,1,n) a[i][m]=2;
    rep(i,1,n){
        rep(j,1,m) {
            if (a[i][j]==1||s[i][j]=='#') printf("#");
            else printf(".");
        }
        puts("");
    }
    puts("");
    rep(i,1,n){
        rep(j,1,m) {
            if (a[i][j]==2||s[i][j]=='#') printf("#");
            else printf(".");
        }
        puts("");
    }
    return 0;
}

Measured memory_bytes: 1920
using Atcoder;
using System;
using System.Collections.Generic;
using System.ComponentModel.Design;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Atcoder
{
    class Program
    {
        static void Main(string[] args)
        {
            var first = Console.ReadLine().Split((' ')).Select(int.Parse).ToArray();
            var A = first[0];
            var B = first[1];
            int tmp = 0;
            int add = 0;
            if (A > B)
            {
                tmp = A - B;
                add = B;
            }
            else
            {
                tmp = B - A;
                add = A;
            }

            if (tmp % 2 == 0)
            {
                Console.WriteLine(add + (tmp /2));
            }
            else
            {
                Console.WriteLine("IMPOSSIBLE ");
            }
        }
        //static void Main(string[] args)
        //{
        //    var temp = new Atcoder.ABC130.D();
        //    temp.Run();
        //}

    }
}

Measured memory_bytes: 13268
#include<cstdio>
#include<cctype>
#include<cstring>
#include<cstdlib>
#include<algorithm>
#include<stack>
#include<queue>
#include<deque>
#include<vector>
#include<list>
#include<bitset>
#include<set>

using namespace std;

#define MAX_N 100
#define INF 1 << 20

int n, m, a, b, c, d[MAX_N][MAX_N], i, j, min[3], cnt, ans;
bool array[MAX_N];

int main(){
	while (true){
		scanf("%d", &n);
		if (n == 0) return 0;
		scanf("%d", &m);
		cnt = 1;
		ans = 0;
		for (i = 0; i < n; i++){
			for (j = 0; j < n; j++){
				if (i == j){
					d[i][j] = 0;
					continue;
				}
				d[i][j] = INF;
			}
			array[i] = false;
		}
		array[0] = true;
		for (i = 0; i < m; i++){
			scanf("%d,%d,%d", &a, &b, &c);
			d[a][b] = c / 100 - 1;
			d[b][a] = c / 100 - 1;
		}
		for (cnt = 1; cnt < n; cnt++){
			c = INF;
			for (i = 0; i < n; i++){
				for (j = 0; j < n; j++){
					if (array[i] && !array[j] && c > d[i][j]){
						c = d[i][j];
						b = j;
					}
				}
			}
			ans += c;
			array[b] = true;
		}
		printf("%d\n", ans);
	}
}

Measured memory_bytes: 1064
#include <iostream>
#include <vector>
#include <algorithm>
#define rep(i, n) for(int i = 0; i < (n); i++)
using namespace std;

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

int main() 
{
	int n;
	ll k;
	cin >> n >> k;
	vector<int> a(n), f(n);
	rep(i, n) cin >> a[i];
	rep(i, n) cin >> f[i];
	sort(a.begin(), a.end());
	sort(f.rbegin(), f.rend());
	// 二分探索
	ll l = -1, r = 1e12, m;
	while (l + 1 < r)
	{
		m = (l + r) / 2;
		bool ok = [&] {
			ll s = 0;
			rep(i, n)
				s += max(0ll, a[i] - m / f[i]);
			return s <= k;
		}();
		if (ok) r = m;
		else l = m;
	}
	cout << r;
	return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
#define LL long long
#define N 555555
int n,m,c[N];
int lowbit(int x){
	return x&(-x);
}
int sum(int x){
	int res=0;
	while (x){
		res+=c[x];
		x-=lowbit(x);
	}
	return res;
}
void add(int x,int val){
	while (x<=n){
		c[x]+=val;
		x+=lowbit(x);
	}
}
int read(){
	int x=0,f=1;
	char ch=getchar();
	while (ch<'0' || ch>'9'){
		if (ch=='-') f=-1;
		ch=getchar();
	}
	while (ch>='0' && ch<='9'){
		x=x*10+ch-'0';ch=getchar();
	}
	return x*f;
}
struct pt{
	int l,r;
}a[N];
bool cmp(pt x,pt y){
	return x.r-x.l<y.r-y.l;
}
signed main(){
	while (scanf("%d%d",&m,&n)!=-1){
		memset(c,0,sizeof(c));
		for (int i=1;i<=m;++i){
			a[i].l=read();
			a[i].r=read();
		}
		sort(a+1,a+1+m,cmp);
		int j=0;
		for (int d=1;d<=n;++d){
			int tmp=0;
			for (int i=d;i<=n;i+=d){
				tmp+=sum(i);
			}
			printf("%d\n",tmp+m-j);
			while (j<m && a[j+1].r-a[j+1].l<=d){
				add(a[j+1].l,1);
				add(a[j+1].r+1,-1);
				j++;
			}
		}
	}
	return 0;
}

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

int main() {
  vector<int> a(3);
  cin>>a[0]>>a[1]>>a[2];
  sort(a.begin(),a.end());
  int ans = a[0]+a[1]+a[2]*10;
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <inttypes.h>

int main(void)
{
    uint_fast8_t a, b;
    scanf("%" SCNuFAST8 " %" SCNuFAST8, &a, &b);
    puts((a % 3 == 0 || b % 3 == 0 || (a + b) % 3 == 0) ? "Possible" : "Impossible");
    return 0;
}


Measured memory_bytes: 128
#include<iostream>
#include<map>
using namespace std;
typedef long long ll;


map<ll, ll> factorize (ll n) {
    map<ll, ll> f;

    for (ll i = 2; i * i <= n; i++) {
        while (n % i == 0) {
            n /= i;
            f[i]++;
        }
    }

    if (n != 1) f[n]++;
    return f;
}

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

    ll n, p;
    cin >> n >> p;

    map<ll, ll> f = factorize(p);
    ll ans = 1;
    for(auto u:f) {
        if (u.second >= n) {
            for (int i = 0; i < u.second / n; i++) ans *= u.first;
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 3652
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize ("Ofast")
#pragma GCC target ("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
 
 
#include <iostream>
#include <iomanip>
#include <sstream>
#include <cstring>
#include <vector>
#include <deque>
#include <queue>
#include <set>
#include <map>
#include <valarray>
#include <iterator>
#include <functional>
#include <limits>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <cassert>
#include <unordered_map>
#include <unordered_set>
#include <stack>

using namespace std;
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
 
typedef int64_t ll;
 
#define endl '\n'
#define int ll
ll mod=1e9+7;
ll mod1=1e9+5;
int power(int a,int b)
{
    if(b==0) return 1;
    else if(b%2==0)
        return power((((a%mod)*(a%mod))%mod),b/2)%mod;
    else return ((a%mod)*(power((((a%mod)*(a%mod))%mod),b/2)%mod))%mod;
}


int32_t main()
{
    IOS
    
    
        
        int n;
        cin>>n;
        n--;
        cout<<((n)*(n+1))/2;

}

Measured memory_bytes: 256
/*#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <queue>
#include <stack>
#include <map>
#include <vector>
#include <set>
#include <utility>
#define ll long long
const int inf=0x3f3f3f3f;
const int mod=1e6;
using namespace std;

ll a[1005];
int n;
void get_table()
{
    memset(a,0,sizeof(a));
    a[0]=a[1]=1;
    for(int i=2;i<=1000;i++)
    {
        int mid=i/2;
        for(int j=0;j<mid;j++)
            a[i]+=a[j]*a[i-1-j]*2;
        if(i&1) a[i]+=a[mid]*a[mid];
        a[i]%=(ll)mod;
    }
}
int main()
{
    //freopen("input.txt","r",stdin);
    get_table();
    while(scanf("%d",&n)&&n)
        printf("%lld\n",a[n]);
    return 0;
}
*/
#include <iostream>
#include <cstdio>
using namespace std;
const int maxn=100;
const int INF=999999999;
int M[maxn][maxn];
void floyd(int n)
{
    for (int l=0;l<=n;l++)
    for (int k=0;k<=n;k++)
    for (int r=0;r<=n;r++)
    if (M[k][l]+M[l][r]<M[k][r])
    M[k][r]=M[k][l]+M[l][r];
}
int main()
{
    int m,a,b,num;
    while (scanf("%d",&m),m)
    {
        for (int i=0;i<=12;i++)
        for (int j=0;j<=12;j++)
        if (i!=j)
        M[i][j]=INF;
        else M[i][j]=0;
        int n=0;
        while (m--)
        {
            scanf("%d%d%d",&a,&b,&num);
            M[a][b]=min(num,M[a][b]);
            M[b][a]=M[a][b];
            n=max(n,max(a,b));
        }
        floyd(n);
        int pos,ans=INF;
        for (int i=0;i<=n;i++)
        {
            int sum=0;
            for (int j=0;j<=n;j++)if (i!=j)
                sum+=M[i][j];
            if (ans>sum)
            {
                ans=sum;
                pos=i;
            }
        }
        printf("%d %d\n",pos,ans);
    }
    return 0;
}

Measured memory_bytes: 1192
/*
 * Author       : YangDavid
 * Created Time : 2020年01月11日 星期六 19时50分27秒
 */

#include<bits/stdc++.h>
#define rep(i, n) for(int i = 1; i <= n; ++i)
#define eprintf(...) fprintf(stderr, __VA_ARGS__)
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;

const int maxn = 102020, MOD = 1000000007;
int add(int x, int y) { return x+y>=MOD ? x+y-MOD : x+y; }
int sub(int x, int y) { return x-y<0 ? x-y+MOD : x-y; }
int mul(int x, int y) { return 1LL*x*y%MOD; }
int qpow(int x, int y) {
	int ret = 1;
	for(; y; y >>= 1, x = mul(x, x))
		if(y & 1) ret = mul(ret, x);
	return ret;
}
int inv(int x) { return qpow(x, MOD - 2); }

int a[maxn], coef[maxn], fac[maxn], n;

int main() {
	fac[0] = 1;
	for(int i = 1; i < maxn; ++i)
		fac[i] = mul(fac[i - 1], i);
	scanf("%d", &n);
	int ans = 0, df = fac[n];
	coef[1] = fac[n - 1];
	for(int i = 2; i < n; ++i) {
		df = mul(fac[n - 1], inv(i));
		coef[i] = add(coef[i - 1], df);
	}

	rep(i, n) {
		scanf("%d", &a[i]);
		if(i > 1) ans = add(ans, mul(a[i]-a[i-1], coef[i-1]));
	}
	printf("%d\n", ans);


    return 0;
}


Measured memory_bytes: 1408
/* code of Ayush Tiwari
    codeforces- servermonk
    codechef- ayush572000
*/

#include <bits/stdc++.h>
#define ll long long

//STL
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define mp make_pair
#define all(v) v.begin(), v.end()

//loops
#define forn(i,a,b) for(int i=a;  i<b; i++)
#define rforn(i,a,b) for(int i=a; i>=b; i--)

// defined values
#define maxn 200004
#define Mod 1000000007

// fast io
#define FIO() ios_base::sync_with_stdio(0);cin.tie(0);


using namespace std;

int n;
int a[maxn][4],dp[maxn][4];

int func(int day,int flag){
    if(day==n) return 0;
    if(dp[day][flag]!=-1) return dp[day][flag];
    int m=-1;
    if(flag==0){
        m=max(m,a[day][1]+func(day+1,1));
        m=max(m,a[day][2]+func(day+1,2));
        m=max(m,a[day][3]+func(day+1,3));
    }
    else if(flag==1){
        m=max(m,a[day][2]+func(day+1,2));
        m=max(m,a[day][3]+func(day+1,3));
    }
    else if(flag==2){
        m=max(m,a[day][1]+func(day+1,1));
        m=max(m,a[day][3]+func(day+1,3));
    }
    else{
        m=max(m,a[day][2]+func(day+1,2));
        m=max(m,a[day][1]+func(day+1,1));
    }
    dp[day][flag]=m;
    return m;
}

void solution(){

    // This is the main code
    cin>>n;
    memset(dp,-1,sizeof(dp));
    forn(i,0,n){
        forn(j,1,4) cin>>a[i][j];
    }
    cout<<func(0,0);

}


int main(){
    
    #ifndef ONLINE_JUDGE
    freopen("E:/CP/input.txt","r",stdin);
    freopen("E:/CP/output.txt","w",stdout);
    #endif  
    
    FIO()   
    
    ll t=1;
    //cin>>t;
    while (t--)
    {
        solution();
    }
    return 0;
}

Measured memory_bytes: 16004
n = int(input())
info =[list(map(int,input().split())) for i in range(n)] 

diff = [[0] for i in range(n)]
sorted_diff = [[0] for i in range(n)]

for i in range(n):
  diff[i][0] = info[i][0]+info[i][1] 

for i in range(n):
  info[i].extend(diff[i])
#print(info)

sorted_diff = sorted(info, key=lambda x: x[2])

#print(sorted_diff)
takahashi =0
aoki = 0
for i in range(n):
  if i%2==0:
    takahashi+= sorted_diff[-1][0]
#    print(sorted_diff[0][1])
    del sorted_diff[-1]
  else:
    aoki+=sorted_diff[-1][1]
#    print(sorted_diff[0][1])
    del sorted_diff[-1]
    
print(takahashi-aoki)

Measured memory_bytes: 47368
#include <cstring>
#include <cstdio>
#include <algorithm>
#include <iostream>
#include <vector>
#include <map>
#include <unordered_map>
#include <cmath>
#include <queue>
#include <set>
#include <stack>

using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define repr(i, n) for(ll i = n - 1; i >= 0; i--)
#define repone(i, n) for(ll i = 1; i <= (ll)(n); i++)
#define each(i, mp) for(auto i:mp)
#define FOR(i, m, n) for(ll i = m;i < n;i++)
const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
const ll mod = 1000000007;
const ll inf = ll(1e9);
const ll half_inf = ll(1e5);
const ll ll_inf = ll(1e9) * ll(1e9);

ll n, h;
vector<ll> a, b;

void solve() {
    sort(a.begin(), a.end(), greater<>());
    sort(b.begin(), b.end());
    auto bound = lower_bound(b.begin(), b.end(), a[0]);
    ll ans = 0;
    for (auto i = b.end() - 1; i >= bound; --i) {
        h -= *i;
        ans++;
        if (h <= 0) break;
    }
    if (h > 0) ans += (h % a[0] == 0 ? h / a[0] : (h / a[0] + 1));
    cout << ans << endl;
}

int main() {
    cin >> n >> h;
    a.resize(n);
    b.resize(n);
    rep(i, n) cin >> a[i] >> b[i];
    solve();
    return 0;
}

Measured memory_bytes: 1792
#include <iostream>
#include <algorithm>
#include <vector>
#include <tuple>
#include <cstring>
#include <queue>


#define REP(i, n) for(int (i) = 0; (i) < (n); ++(i))
#define eREP(i, n) for(int (i) = 0; (i) <= (n); ++(i))
#define rREP(i, n) for(int (i) = (n) - 1; (i) >= 0; ++(i))
#define ALL(TheArray) TheArray.begin(), TheArray.end()

template <class T> inline T& chmax(T& a, T b){return (a < b) ? a = b : a;}
template <class T> inline T& chmin(T& a, T b){return (a > b) ? a = b : a;}

using lli = long long int;
using pli = std::pair<lli, int>;


int main(void){
    int a, b, k; std::cin >> a >> b >> k;
    int cnt = 0, x = b;
    while(true){
        if(a % x == 0 and b % x == 0) cnt++;
        if(cnt == k) break;
        else x--;
    }
    std::cout << x << '\n';
    return 0;
}


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

class Main
{
    public static void main(String[] args) throws IOException{
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        StringTokenizer st = new StringTokenizer(br.readLine());

        PrintWriter out = new PrintWriter(System.out);
        int n = Integer.parseInt(st.nextToken());
        double d = Double.parseDouble(st.nextToken());

        long[][] points = new long[n][2];

        for (int i=0; i<n; i++) {
            st = new StringTokenizer(br.readLine());
            points[i][0] = Long.parseLong(st.nextToken());
            points[i][1] = Long.parseLong(st.nextToken());
        }
        int ans = 0;
        for (int i=0; i<n; i++) {
            if(Math.pow(points[i][0]*points[i][0]+points[i][1]*points[i][1],0.5)<=d)
                ans++;
        }

        out.println(ans);

        out.close();
    }
    

}



Measured memory_bytes: 63432