akhauriyash/Code-Regression huggingface dataset:
// clang-format off
#include <bits/stdc++.h>
using namespace std;
#define overload4(_1, _2, _3, _4, name, ...) name
#define rep4(i, a, b, c) for (int i = int(a), i##__b = int(b), i##__c = int(c); i < i##__b; i += i##__c)
#define rep1(n) rep4(i, 0, n, 1)
#define rep2(i, n) rep4(i, 0, n, 1)
#define rep3(i, a, b) rep4(i, a, b, 1)
#define REP(...) overload4(__VA_ARGS__, rep4, rep3, rep2, rep1)(__VA_ARGS__)
#define rrep3(i, a, b) for (int i = int(b) - 1, i##__a = int(a); i >= i##__a; i--)
#define rrep1(n) rrep3(i, 0, n)
#define rrep2(i, n) rrep3(i, 0, n)
#define rrep4(i, a, b, c) for (int i = int(a + (b - a - 1) / c * c), i##__a = int(a), i##__c = int(c); i >= i##__a; i -= i##__c)
#define RREP(...) overload4(__VA_ARGS__, rrep4, rrep3, rrep2, rrep1)(__VA_ARGS__)
#define FOR(i, x) for (auto &i : x)
#define ALL(v) (v.begin()), (v.end())
#define pb(x) push_back(x)
#define mp(x, y) make_pair(x, y)
#define mt make_tuple
#define endl '\n'
const int MOD = 1e9 + 7;
const int INF = 1e9 + 9;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using pdd = pair<double, double>;
using vint = vector<int>;
using vvint = vector<vector<int>>;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using vbool = vector<bool>;
using vvbool = vector<vector<bool>>;
using vstring = vector<string>;
template <class T> using vv = vector<vector<T>>;
#define vvint(A, H, W) vvint A(H, vint(W))
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 print(x){cout<<x<<endl;}
// clang-format on

int main() {
    int n;
    cin >> n;
    vv<pii> tos(n);
    vint color_of_edge(n - 1);
    REP(n - 1) {
        int a, b;
        cin >> a >> b;
        a -= 1, b -= 1;
        tos[a].pb(mp(b, i));
        tos[b].pb(mp(a, i));
    }
    stack<pii> stk;
    stk.emplace(mp(0, 0));
    while (!stk.empty()) {
        int now, fromcolor;
        tie(now, fromcolor) = stk.top();
        stk.pop();
        int color = 1;
        FOR(tmp, tos[now]) {
            int to, i;
            tie(to, i) = tmp;
            // color_of_edge[i]>0ならtoは来た方向なのでそっちには探索しない
            if (color_of_edge[i] == 0) {
                if (color == fromcolor) color++;
                color_of_edge[i] = color;
                stk.emplace(mp(to, color));
                color++;
            }
        }
    }
    int K = *max_element(ALL(color_of_edge));
    print(K) FOR(x, color_of_edge) {
        print(x);
    }
}


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

int main(){
  //素因数列挙
  /*for(int i=2; i*i<=n; i++){
    while(n%i == 0 && n/i != 1){
      cout << i << ' ';
      n /= i;
    }
  }
  cout << n;*/
  //約数の列挙
  /*for(int i=1; i*i<=n; i++){
    if(n%i == 0) cout << i << ' ' << n/i << endl;
  }*/
  int n;
  cin >> n;
  vector<int> ns(n);
  vector<int> ans(n);
  rep(i, n){
    cin >> ns.at(i);
    ans.at(i) = 0;
  }
  for(int i=n; i>0; i--){
    int cou = 0;
    for(int k=2; i*k<=n; k++){
      cou += ans.at(i*k-1);
    }
    if((cou+ns.at(i-1))%2 == 1){
      ans.at(i-1) = 1;
    }else{
      ans.at(i-1) = 0;
    }
  }
  int count = 0;
  rep(i, n){
    if(ans.at(i) == 1) count++;
  }
  cout << count << endl;
  rep(i, n){
    if(ans.at(i) == 1) cout << i+1 << ' ';
  }
  return 0;
}


Measured memory_bytes: 2432
#include <bits/stdc++.h>
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
int main() {
  ll A, B, C;
  cin >> A >> B >> C;
  vector<ll> v = {A, B, C};
  sort(v.begin(), v.end());
  if((A % 2 == 0 || B % 2 == 0) || C % 2 == 0) {
    cout << 0 << endl;
  }
  else {
    cout << v.at(0) * v.at(1) << endl;
  }
}


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

#define int long long
using namespace std;
#define rep(i, n) for(int i=0;i<(n);++i)
typedef pair<int, int> pii;
const int INF = 1l << 60;


signed main() {
    int a, b, x;
    cin >> a >> b >> x;
    double can = 0, cant = M_PI;
    while (cant - can > 0.0000000001) {
        double m = (can + cant) / 2;
        double y;
        if (b * cos(m) < a * sin(m)) {
            y = b * b * cos(m) / sin(m) / 2 * a;
        } else {
            y = a * b - a * a * tan(m) / 2;
            y *= a;
        }
        if (x <= y)can = m;
        else cant = m;
    }
    cout << fixed << setprecision(20) << can / M_PI * 180 << endl;
    return 0;
}


Measured memory_bytes: 384
#include<iostream>
#include<cmath>
#include<queue>
#include<cstdio>
#include<cstdlib>
#include<cassert>
#include<cstring>
#include<climits>
#include<sstream>
#include<deque>
#include<vector>
#include<algorithm>
#include<set>
#include<map>
#include<bitset>

#define REP(i,s,n) for(int i=s;i<n;i++)
#define rep(i,n) REP(i,0,n)

using namespace std;

typedef long long ll;
const int IINF = INT_MAX;
const ll LLINF = LLONG_MAX;

int main(){
  int n;
  cin >> n;
  string s;
  cin >> s;
  int cnt = 0,i;
  for(i=0;i<n;++i) {
    if( s[i] == 'x' ) {
      ++cnt;
      if( cnt == 2 ) break;
    } else {
      cnt = 0;
    }
  }
  cout << i << endl;
  return 0;
}

Measured memory_bytes: 3340
#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()

int main() {
   int n,a[100010];
   cin >> n;
   rep(i,n){
   int ai; cin >> ai;
   a[ai]=i+1;
   }
   rep(i,n)
   cout << a[i+1] << endl;
}

Measured memory_bytes: 1152
<?php
fscanf(STDIN,"%d %d",$N,$K);
$V = fgets(STDIN);
$arrayV = explode(" ",$V);
$max = 0;
//配列内で負数の要素数を求める
$minusMax = count(array_filter($arrayV,"minusCount"));

//必ず1つは取り出すのでKが1の時は最大値が0より小さい可能性があるため別処理
if($K === 1){
  echo max($arrayV[0],$arrayV[$N-1]);
}else{
  //左から取り出す数、回数制限･配列の要素数を超えない
  for($i=0; $i<=$K && $i<=$N; $i++){
    if($i !== 0){
      //最大を求めるので取り出すのが0以下で止まることはない
      if($arrayV[$i-1] <= 0){
        continue;
      }
    }
    //右から取り出す数、合計が回数制限･配列の要素数を超えない
    for($j=0; $j<=$K-$i && $j<=$N-$i; $j++){
      if($j !== 0){
        //最大を求めるので取り出すのが0以下で止まることはない
        if($arrayV[$N-$j] <= 0){
          continue;
        }
      }
      //削除する数･合計が回数制限を越えない、左右取出数より少ない、負数の最大を超えず削除
      for($m=0; $m<=$K-$i-$j && $m<$i+$j && $m<=$minusMax; $m++){
        $value = calculate($i,$j,$m,$arrayV,$N);
        //最大値更新
        if($value > $max){
          $max = $value;
        }
      }
    }
  }
  echo $max;
}

function calculate($left,$right,$delete,$array,$N){
  $arrayResult = array();
  for($i=0;$i<$left;$i++){
    $arrayResult[] = $array[$i];
  }
  for($i=0;$i<$right;$i++){
    $arrayResult[] = $array[$N-1-$i];
  }
  for($i=0;$i<$delete;$i++){
    //最小値を1つだけ配列から削除
    $mins = array_keys($arrayResult, min($arrayResult));
    unset($arrayResult[$mins[0]]);
  }
  //配列内の合計を返す
  return array_sum($arrayResult);
}

function minusCount($value){
  return $value < 0;
}


Measured memory_bytes: 3828
import java.util.*;

public class Main {

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

        String S = scanner.next();
        int ans = 0;
        for (int i = 0; i < S.length(); i++) {
            if (S.charAt(i) == '1') ans++;
        }

        System.out.println(ans);
    }
}


Measured memory_bytes: 21716
#include<bits/stdc++.h>
using namespace std;
#ifndef ONLINE_JUDGE
#define dbg(x...) do{cout << "\033[32;1m" << #x << "->" ; err(x);} while(0)
void err(){cout << "\033[39;0m" << endl;}
template<template<typename...> class T,typename t,typename... A>
void err(T<t> a,A... x){for (auto v:a) cout << v << ' '; err(x...);}
template<typename T,typename... A>
void err(T a,A... x){cout << a << ' '; err(x...);}
#else
#define dbg(...)
#endif
typedef long long ll;
typedef pair<int,int> pi;
typedef vector<int> vi;
template<class T> using vc=vector<T>;
template<class T> using vvc=vc<vc<T>>;
template<class T> void mkuni(vector<T>&v)
{
    sort(v.begin(),v.end());
    v.erase(unique(v.begin(),v.end()),v.end());
}
template<class T>
void print(T x,int suc=1)
{
    cout<<x;
    if(suc==1) cout<<'\n';
    else cout<<' ';
}
template<class T>
void print(const vector<T>&v,int suc=1)
{
    for(int i=0;i<v.size();i++)
        print(v[i],i==(int)(v.size())-1?suc:2);
}
const int INF=0x3f3f3f3f;
int main()
{
	ll n;
	cin>>n;
	if(n&1) cout<<0<<endl;
	else{
		ll ans=0;
		while(n)
		{
			ans+=n/10;
			n/=5;
		}
		cout<<ans<<endl;
	}

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N; cin>>N;
  vector<int>A(N);
  vector<int>B(N);
  for(int i=0;i<N;i++)cin>>A[i]>>B[i];
  sort(A.begin(),A.end());
  sort(B.begin(),B.end());
  if(N%2==1)cout<<B[N/2]-A[N/2]+1<<endl;
  else cout<<(B[N/2-1]+B[N/2])-(A[N/2-1]+A[N/2])+1<<endl;
}

Measured memory_bytes: 4840
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
typedef long long ll;
typedef long double lb;
#define int long long
#define double long double
#define endn "\n"
typedef pair<int,int> P;
template<class T> inline bool chmin(T& a, T b){if(a>b){a = b;return 1;}return 0;}
template<class T> inline bool chmax(T& a, T b){if(a<b){a = b;return 1;}return 0;}
const int MOD = 1000000007;
//const int MOD = 998244353;
template<class T> inline int add(T& a, T b, T M = MOD){a=(a+M)%M;b=(b+M)%M;a=(a+b)%M;return a;};
template<class T> inline int mul(T& a, T b, T M = MOD){if(a>=M)a%=M;if(b>=M)b%=M;a*=b;if(a>=M)a%=M;return a;};
const ll INF = 1e16;
const double EPS = 1e-10;
const double PI = 3.141592653589793;
const string abc="abcdefghijklmnopqrstuvwxyz";
const string ABC="ABCDEFGHIJKLMNOPQRSTUVWXYZ";
const pair<int,int> fd[] = {make_pair(1,0),make_pair(-1,0),make_pair(0,1),make_pair(0,-1)}; 

////////////////////////////////////////////////////////////////////
///////////////////////___modpow___////////////////////
ll modpow(ll a,  ll n, const ll &MOD = MOD){
  ll ret = n == 0 ? 1 : modpow(a, n/2, MOD);
  (ret *= ret) %= MOD;
  if(n%2)((ret *= a) %= MOD);
  return ret;
}
///////////////////////___modinv___////////////////////
ll modinv(ll d, const ll &MOD = MOD){
  return modpow(d, MOD-2, MOD);
}
////////////////////////////////////////////////////////////////////

signed main(){
  double r;
  cin>>r;
  cout << fixed << setprecision(10) << 2*PI*r << endl;
}


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

int n, a[100010];
int g1[100010]={0}, g2[100010]={0};
int main() {
    cin.tie(0); cin.sync_with_stdio(0);
    cin >> n;
    for (int i = 1; i <= n; i++) cin >> a[i];
    for (int i = 1; i <= n; i++) g1[i] = __gcd(a[i], g1[i - 1]);
    for (int i = n; i >= 1; i--) g2[i] = __gcd(a[i], g2[i + 1]);
    int best = 0;
    for (int i = 1; i <= n; i++) {
        best = max(best, __gcd(g1[i - 1], g2[i + 1]));
    }
    cout << best;
}

Measured memory_bytes: 1408
#pragma region
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <vector>
#include <map>
#include <queue> 
#include <stack>
#include <set>
#include <list>

using namespace std;
typedef long long ll;
//#define rep(i, s, e) for (int(i) = (s); (i) < (e); ++(i))
#define rep(i, e) for (int(i) = 0; (i) < (e); ++(i))
#define rrep(i, s) for (int(i) = (s) - 1; (i) >= 0; --(i))
#define all(x) x.begin(),x.end()
#pragma endregion


int main()
{
	int a, b; cin >> a >> b;
	int cnt = 0;
	for (int i = a; i <= b; ++i)
	{
		bool ok = true;
		string s = to_string(i);
		rep(j, s.size() / 2)if (s[j] != s[s.size() - j - 1])ok = false;
		if (ok)++cnt;
	}
	cout << cnt << endl;
}

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

int main(){
  int n,m,q; cin>>n>>m>>q;
  vector<vector<int>> x(n+1,vector<int>(n+1,0));
  for(int i=0;i<m;i++){
    int l,r; cin>>l>>r;
    x[l][r]++;
  }
  vector<vector<int>> sum(n+1,vector<int> (n+1,0));
  for(int i=1;i<=n;i++){
    for(int j=1;j<=n;j++){
      sum[i][j]=sum[i][j-1]+x[i][j];
    }
  }
  for(int i=0;i<q;i++){
    int a,b; cin>>a>>b;
    int ans=0;
    for(int j=a;j<=b;j++){
      ans+=sum[j][b]-sum[j][a-1];
    }
    cout<<ans<<endl;
  }
}

Measured memory_bytes: 2944
// AOJ 0023
#include<iostream>
#include<cmath>
#define REP(i,n) for(int i=0;i<(int)(n);i++)
using namespace std;

const long double EPS = 0;

long double sq(long double x) {
  return x * x;
}

long double abs(long double x) {
  return (x > 0 ? x : -x);
}
/*
bool eq(long double x, long double y) {
  return abs(x - y) < EPS;
}*/

long double dist(long double xa, long double ya, long double xb, long double yb) {
  return sq(xa - xb) + sq(ya - yb);
}

int main() {
  int n;
  cin >> n;
  REP(i, n) {
    long double xa, ya, ra, xb, yb, rb;
    cin >> xa >> ya >> ra >> xb >> yb >> rb;

    long double d = sqrt((xa-xb)*(xa-xb) + (ya-yb)*(ya-yb));
    
    if (ra - rb > d + EPS) {
      cout << 2 << endl;
    } else if (rb - ra > d + EPS) {
      cout << -2 << endl;
    } else if (d > ra + rb + EPS) {
      cout << 0 << endl;
    } else {
      cout << 1 << endl;
    }
  }
}

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

#define FOR(i,a,b) for (int i=(a);i<(b);++i)
#define REP(i,n) for (int i=0;i<(n);++i)
#define all(a) (a).begin(),(a).end()

int main(){
    int ans=0,n,B[101];
    cin>>n;
    REP(i,n-1) cin>>B[i];
    REP(i,n){
        if(i==0) ans+=B[0];
        else if(i==n-1) ans+=B[n-2];
        else ans+=min(B[i-1],B[i]);
    }

    cout<<ans<<endl;
}

Measured memory_bytes: 256
s = input()
t = input()

maxt = len(t)

for i in range(0,len(s) - len(t) +1):
    s_part = s[i:i+len(t)+1]
    n=0
    for tt,ss in zip(t,s_part):
        if tt==ss:
            n+=1
    maxt =min(maxt,len(t)-n)
print(maxt)

Measured memory_bytes: 67764
#include<stdio.h>
#include<string.h>

int main(void){
  char wt[3][10] = {"Sunny","Cloudy","Rainy"};
  char twt[10];
  scanf("%s",&twt[0]);
  
  if(!(strcmp(twt,"Sunny")))printf("Cloudy\n");
  if(!(strcmp(twt,"Cloudy")))printf("Rainy\n");
  if(!(strcmp(twt,"Rainy")))printf("Sunny\n");
  
  return(0);
}

Measured memory_bytes: 128
//  Copyright © 2020 Diego Garcia Rodriguez del Campo. All rights reserved.
#include<bits/stdc++.h>
#define MAX 200005
#define optimiza_io cin.tie(0); ios_base::sync_with_stdio(0);
#define what_is(x) cerr << #x << " is " << x << endl;
using namespace std;
typedef long long ll;

ll N, a[MAX], can[MAX], ans;

int main()
{
    optimiza_io
    cin >> N;
    for( ll i = 1; i <= N; i ++ ) {
        cin >> a[i];
        ll p = i - a[i] + 1;
        if( p >= 1 )
            can[p]++;
    }
    for( ll i = 1; i <= N; i ++ ) {
        ll p = i + a[i] + 1;
        if( p <= N )
            ans += can[p];
    }
    
    cout << ans;
    return 0;
}

// CHECAR LIMITES 

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

using namespace std;
#define int long long
const int MAX = 2001;
const int MOD = 1000000007;
//
int fac[MAX], finv[MAX], inv[MAX];

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

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


 
signed main(){
    COMinit();
    int n,k;
    cin>>n>>k;
    for(int i=1;i<=k;i++){
        cout<<(COM(n-k,i)+COM(n-k,i-1))*COM(k-1,i-1)%MOD<<endl;
    }
  
    
    return 0;
}

Measured memory_bytes: 256
#include<iomanip>
#include<limits>
#include<thread>
#include<utility>
#include<iostream>
#include<string>
#include<algorithm>
#include<set>
#include<map>
#include<vector>
#include<stack>
#include<queue>
#include<cmath>
#include<numeric>
#include<cassert>
#include<random>
#include<chrono>
#include<unordered_map>
#include<fstream>
#include<list>
#include<typeinfo>
#include<functional>
using namespace std;
typedef unsigned long long int ull;
typedef long long int ll;
typedef pair<ll,ll> pll;
typedef pair<int,int> pi;
typedef pair<double,double> pd;
typedef pair<double,ll> pdl;
#define F first
#define S second
const ll E=1e18+7;
const ll MOD=1000000007;

/*
 1 partition(A, p, r)
 2   x = A[r]
 3   i = p-1
 4   for j = p to r-1
 4     if A[j] <= x
 5       i = i+1
 6       A[i] と A[j] を交換
 7   A[i+1] と A[r] を交換
 8   return i+1
 */

struct P{
    ll a;
    char c;
    
    bool operator < (const P &p) const {return a<p.a;}
    
    bool operator <= (const P &p) const {return a<=p.a;}
    
    bool operator == (const P &p) const {return a==p.a && c==p.c;}
};

ll Part(vector<P> &A,ll p,ll r){
    const P &x=A[r];
    ll i=p-1;
    for(ll j=p;j<r;j++){
        if(A[j]<=x){swap(A[++i],A[j]);}
    }
    swap(A[i+1],A[r]);
    return i+1;
}

/*
 1 quicksort(A, p, r)
 2   if p < r
 3     q = partition(A, p, r)
 4     quickSort(A, p, q-1)
 5     quickSort(A, q+1, r)
 */

void quick(vector<P> &A,ll p,ll r){
    if(p<r){
        ll q=Part(A,p,r);
        quick(A,p,q-1);
        quick(A,q+1,r);
    }
}



int main(){
    ll n;
    cin>>n;
    vector<P> a(n);
    for(int i=0;i<n;i++){
        cin>>a[i].c>>a[i].a;
    }
    vector<P> b=a;
    quick(a,0,n-1);
    stable_sort(b.begin(),b.end(),less<P>());
    bool s=true;
    for(int i=0;i<n;i++){
        if(!(a[i]==b[i])){s=false;}
    }
    cout<<(s?"Stable":"Not stable")<<endl;
    for(int i=0;i<n;i++){
        cout<<a[i].c<<" "<<a[i].a<<endl;
    }
    
    return 0;
}



Measured memory_bytes: 6620
#include<bits/stdc++.h>
#define ll long long
#define ld long double
#define mod 1000000007
#define fi first
#define se second
#define pb push_back
#define IOS ios_base::sync_with_stdio(false);cout.tie(NULL);cin.tie(NULL);

using namespace std;

ll power(ll a, ll n)
{
    ll ans=1;
    while(n)
    {
        if(n%2) ans=(ans*a)%mod;
        a=(a*a)%mod;
        n>>=1;
    }
    return ans;
}

int main()
{
    IOS;
    ll n,m,k;
    cin>>n>>m>>k;
    ll ans=0;
    ll fac[300001];
    fac[0]=1;
    for(int i=1;i<300001;i++)
    {
        fac[i]=(fac[i-1]*i)%mod;
    }
    ll num=fac[n*m-2];
    ll den=(fac[n*m-k]*fac[k-2])%mod;
    ll val=(num*power(den,mod-2))%mod;
    //cout<<num<<" "<<den<<" "<<val<<endl;
    for(int i=1;i<n;i++)
    {
        ans=(ans+((i*(n-i))%mod*(m*m)%mod)%mod)%mod;
    }
    for(int i=1;i<m;i++)
    {
        ans=(ans+((i*(m-i))%mod*(n*n)%mod)%mod)%mod;
    }
    ans=(ans*val)%mod;
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 2560
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
typedef long long ll;

using namespace std;

int main()
{
	int a[4];
	int ans;
	char op[3];
	
	cin>>a[3];
	a[0]=a[3]/1000;
	a[3]%=1000;
	a[1]=a[3]/100;
	a[3]%=100;
	a[2]=a[3]/10;
	a[3]%=10;

	for(int bit=0;bit<8;bit++)
	{
		for(int i=0;i<3;i++)
		{
			if((bit&(int)pow(2,i))==pow(2,i))
			{
				op[i]='+';
			}else{
				op[i]='-';
			}
		}
		if(op[0]=='+')
		{
			ans=a[0]+a[1];
		}else{
			ans=a[0]-a[1];
		}
		for(int i=2;i<4;i++)
		{
			if(op[i-1]=='+')
			{
				ans+=a[i];
			}else{
				ans-=a[i];
			}
		}
		if(ans==7)
		{
			break;
		}
	}
	cout<<a[0]<<op[0]<<a[1]<<op[1]<<a[2]<<op[2]<<a[3]<<"=7"<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <regex>
#include "bits/stdc++.h"
#define FOR(i, s, e) for (int i = int(s); i < int(e); ++i)
#define REP(i, e) FOR(i, 0, e)
#define INF (INT_MAX / 2)
#define LINF (LLONG_MAX / 2)
#define EPS (1.0e-8)
const int MGN = 10;
const int ARY_SZ_MAX = (int)1e7;
using namespace std;
using ll = long long; using ull = unsigned long long;
using vi = vector<int>; using vvi = vector<vi>;
using vc = vector<char>; using vvc = vector<vc>;
using vb = vector<bool>; using vvb = vector<vb>;
using vl = vector<ll>; using vvl = vector<vl>;
using vd = vector<double>; using vs = vector<string>;
using pii = pair<int, int>; using pll = pair<ll, ll>; using psl = pair<string, ll>;


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


  int K,X; cin>>K>>X;

  string ans = K*500>=X ? "Yes" : "No";

  cout << ans << endl;


  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
    using namespace std;
 
    #define fast ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)
    #define mod 1000000007
    #define qmod 998244353
    #define M 1000001
    #define endl "\n"
    #define all(a) (a).begin(),(a).end()
    #define rep(i,a,b) for(int i=a;i<b;++i)
    #define repr(i,a,b) for(int i=a;i>=b;--i)
    #define F first
    #define S second
    #define pb push_back
    #define mp make_pair

    typedef long long ll;
    typedef pair<int,int> pii;
    typedef vector<int> vi;
    typedef vector<string> vs;
    typedef vector<pii> vii;
    typedef vector<vi> vvi; 

    int main(){
        
    /*#ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin); 
    freopen("output.txt","w",stdout);   
    #endif */ 
 
        fast;
        ll k,n;
        cin>>k>>n;
        ll a[n],mx=0;
        rep(i,0,n) cin>>a[i];
        ll dist[n];
        for(int i=0;i<n; i++){
        if(i!=n-1) dist[i] = a[i+1] - a[i];
        else dist[i] = k- a[i] + a[0];
        }
       // cout<<mx<<" "; 
        sort(dist,dist+n);
        ll ans=0;
        rep(i,0,n-1) ans+=dist[i];
        cout<<ans<<endl;
        return 0;  
    } 

Measured memory_bytes: 3328
#include <bits/stdc++.h>
#define rep(i, a) for (int i = 0; i < (a); ++i)
#define pb push_back
#define all(v) v.begin(),v.end()
#define sort_1(v) sort(v.begin(),v.end())
#define sort_2(v) sort(v.begin(),v.end(),greater<ll>())
#define reverse(v) reverse(v.begin(),v.end())
typedef long long ll;
typedef long double la;
using namespace std;

int main(){
	int A,B;
	cin >> A >> B;
	ll n = A;
	while(1){
		if(n%B == 0){
			cout << n << endl;
			return 0;
		}
		n += A;
	}
}

Measured memory_bytes: 3632
#include <stdio.h>

int a,b,c,aa=0,bb=0,cc=0;

void print(int num)
{
	printf("%d\n",num);
	
}

void printsp(int num)
{
	printf("%d ",num);
	
}


	

int main(void)
{

scanf("%d %d %d",&a,&b,&c);
if(a>b)aa++;
if(a<b)bb++;
if(a>c)aa++;
if(a<c)cc++;
if(b>c)bb++;
if(b<c)cc++;

if(aa==0)printsp(a);
if(bb==0)printsp(b);
if(cc==0)printsp(c);
if(aa==1)printsp(a);
if(bb==1)printsp(b);
if(cc==1)printsp(c);
if(aa==2)print(a);
if(bb==2)print(b);
if(cc==2)print(c);
return 0;
}

Measured memory_bytes: 596
#include <bits/stdc++.h>
#define ll long long

using namespace std;
const int N=3e3+55;
ll dp[N][N];
ll a[N];
int n;

ll bt(int l , int r , int t)
{
	if(l==r)
		return t*a[l];
	ll &ret=dp[l][r];
	if(ret!=-1)
		return ret;
	if(t==-1)
	ret=min(bt(l+1,r,1)-a[l],bt(l,r-1,1)-a[r]);
	else
	ret=max(bt(l+1,r,-1)+a[l],bt(l,r-1,-1)+a[r]);
	return ret;
}
	
	

int main()
{
	memset(dp,-1,sizeof dp);
	ios::sync_with_stdio(false);
	cin>>n;
	for(int i=0;i<n;i++)
	cin>>a[i];
	cout<<bt(0,n-1,+1)<<endl;
	return 0;
}


Measured memory_bytes: 73344
#include <bits/stdc++.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

using namespace std;

typedef long long int lli;

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;}

#ifdef LOCAL
	#define eprintf(...) printf(__VA_ARGS__)
#else 
	#define eprintf(...) 1
#endif

#define ROUNDUP(a, b) 		( ((a) + ((b) - 1) ) / b)
#define SET_ZERO(a)	 		( memset((a), 0, sizeof(a)))
#define SET_NUM_ARRAY(a,b)	( memset((a), b, sizeof(a)))

int main() {
	char S[1000*100+1];
	scanf("%s", S);
	int l = strlen(S);

	int min = l;
	for (int i = 0; i < l-1; i++) {
		if (S[i] != S[i+1]) {
			chmin(min, (i+1>l-i-1)?i+1:l-i-1);
		}
	}
	printf("%d\n", min);
}


Measured memory_bytes: 384
#include <stdio.h>
#include <bits/stdc++.h>
#include <iostream>

using namespace std;

int main()
{
  int n,m, ac=0, wa=0;
  scanf("%d %d", &n, &m);

  int p[m], flag[n][2];
  char s[m][3];

  for(int i=0;i<m;i++) {
    scanf("%d %s", &p[i], s[i]);
  }
  for(int i=0;i<n;i++) {
    flag[i][0] = 0; flag[i][1] = 0;
  }

  for(int i=0;i<m;i++) {
    if(flag[p[i]-1][0]==1) {
      continue;
    }

    if(strcmp(s[i], "WA")==0) {
      flag[p[i]-1][1]+=1;
    }
    if(strcmp(s[i], "AC")==0) {
      flag[p[i]-1][0]=1;
      wa+=flag[p[i]-1][1];
    }

  }

  for(int i=0;i<n;i++) {
    //printf("%d %d\n", flag[i][0], flag[i][1]); 
    if(flag[i][0]>=1){
      ac+=1;
    }
  }

  printf("%d %d\n", ac, wa); 

  return 0;
}

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

signed main() {
    int N, A[3];
    cin >> N >> A[0] >> A[1] >> A[2];

    vector<int> l(N);
    for (int& x : l) cin >> x;

    const int inf = 1LL<<62;
    int ans = inf;
    vector<bool> used(N);
    for (int a = 0; a < (1<<N); a++) {
        for (int b = 0; b < (1<<N); b++) {
            for (int c = 0; c < (1<<N); c++) {
                int sum[3] = {}, cnt[3] = {};
                for (int i = 0; i < N; i++) {
                    if ((a >> i) & 1) {
                        sum[0] += l[i];
                        cnt[0]++;
                    }
                    else if ((b >> i) & 1) {
                        sum[1] += l[i];
                        cnt[1]++;
                    }
                    else if ((c >> i) & 1) {
                        sum[2] += l[i];
                        cnt[2]++;
                    }
                }

                if (!cnt[0] || !cnt[1] || !cnt[2]) continue;

                int t = 0;
                for (int i = 0; i < 3; i++) {
                    t += abs(A[i] - sum[i]);
                    t += max(0LL, (int)(cnt[i] - 1) * 10);
                }
                ans = min(ans, t);
            }
        }
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
import sys
from bisect import bisect_left

INDATA = sys.stdin.read().split('\n')
idx = -1
def input():
    global idx
    idx += 1
    return INDATA[idx]

n, m, q = map(int, input().split())
LR = [0]*m
for i in range(m):
    LR[i] = list(map(int, input().split()))
P = [0]*q
Q = [0]*q
for i in range(q):
    P[i], Q[i] = map(int, input().split())
 
LR.sort(key=lambda x: (x[0], x[1]))
L = list(map(lambda x: x[0], LR))
#print(LR)
 
C = [[0]*(n+1) for _ in range(n+1)]
for i in range(1,n+1):
    l = bisect_left(L, i)
    r = bisect_left(L, i+1)-1
    R2 = list(map(lambda x: x[1], LR[l:r+1]))
    #print(l, r, R2)
    for j in range(i,n+1):
        C[i][j] = bisect_left(R2, j+1)
    #print(i, C[i])
 
for i in range(q):
    ans = 0
    for j in range(P[i], Q[i]+1):
        ans += C[j][Q[i]]
    print(ans)


Measured memory_bytes: 124904
#include<stdio.h>

void shaffle(int deck[], int p, int c);


int main(void){
	int deck[50];
	int n,r,p,c;
	int i;
	scanf("%d %d",&n, &r);
	while(!(n==0 && r==0)){
		for(i=0;i<n;i++){
			deck[n-i-1]=i+1;
		}
		for(i=0;i<r;i++){
			scanf("%d %d", &p, &c);
			shaffle(deck,p,c);
		}
		printf("%d\n",deck[0]);
		scanf("%d %d",&n,&r);		
	}
	return 0;				
}

void shaffle(int deck[], int p, int c){
	int tmp[50],i;
	for(i=0;i<p-1;i++){
		tmp[i]=deck[i];
	}
	for(i=0;i<c;i++){
		deck[i]=deck[i+p-1];
	}
	for(i=c;i<c+p-1;i++){
		deck[i]=tmp[i-c];
	}
}

Measured memory_bytes: 600
#include <stdio.h>

#define MAX 32
#define MIN 1

int main(){
	int array[MAX] = {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 in = 0;
	int out = 0;
	
	scanf("%d",&in);
	
	if((in>=MIN)&&(in<=MAX)){
		out = array[in-1];
		printf("%d",out);
	}
	return 0;
}



Measured memory_bytes: 128
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <cmath>
#include <sstream>
#include <iomanip>
using namespace std;
typedef long long int ll;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define yes cout << "yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl
#define no cout << "no" << endl

const int INF = 1001001001;
const int mod = 1000000007;
#define PI 3.14159265359;

void P(int x) {cout << x << endl;}
void P(long x) {cout << x << endl;}
void P(double x) {cout << x << endl;}
void P(ll x) {cout << x << endl;}
void P(string x) {cout << x << endl;}
void P(char x) {cout << x << endl;}

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() {
  string s;
  cin >> s;
  rep (i, s.size()) {
    if (i % 2 == 0) cout << s[i];
  }
  cout << endl;
  return 0;
}

Measured memory_bytes: 512
/**
 *    author:  tourist
 *    created: 26.11.2019 09:39:34       
**/
#include <bits/stdc++.h>

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n, m, k;
  cin >> n >> m >> k;
  vector<int> a(n);
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  vector<long long> dp(n);
  for (int i = 0; i < n; i++) {
    dp[i] = a[i];
  }
  for (int it = 1; it < k; it++) {
    vector<long long> new_dp(n);
    new_dp[0] = (long long) -1e18;
    vector<int> st;
    int ptr = 0;
    for (int i = 0; i < n - 1; i++) {
      while (ptr < (int) st.size() && st[ptr] <= i - m) {
        ++ptr;
      }
      while (ptr < (int) st.size() && dp[st.back()] <= dp[i]) {
        st.pop_back();
      }
      st.push_back(i);
      new_dp[i + 1] = dp[st[ptr]] + (it + 1LL) * a[i + 1];
    }
    swap(dp, new_dp);
  }
  cout << *max_element(dp.begin(), dp.end()) << '\n';
  return 0;
}


Measured memory_bytes: 3184
# 問題：https://atcoder.jp/contests/abc141/tasks/abc141_a

import sys

weather = ['Sunny', 'Cloudy', 'Rainy']
s = input()
if weather.count(s) < 1:
    sys.exit()
current_index = weather.index(s)
next_index = (current_index + 1) % 3
print(weather[next_index])



Measured memory_bytes: 9068
N = int(input())
n = 1#桁数
ans = ""
an = 0
alfabet = "abcdefghijklmnopqrstuvwxyz"
while(not (an<N and N<=an+26**n)):
    an = an + 26**n
    n = n+1
#桁数nを決める

mae = an
l = n-1

while(l>=0):
    k = 1
    while(mae+26**l*k < N):#l桁目を求める
        k +=1
    ans= ans+alfabet[k-1]
    if(k!=1):
        mae = mae +26**l*(k-1)
   
    l-=1
print(ans)


Measured memory_bytes: 9128
/* Bismillahirrahmanirrahim */
/* Author : Jehian Norman Saviero (@Reiva5) */
#include <bits/stdc++.h>

// MACROS SAMPAH
#define Jehian using
#define Norman namespace
#define Saviero std

Jehian Norman Saviero;

// MACROS TYPE
typedef long l;
typedef long long ll;
typedef unsigned long ul;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int,int> pi;
typedef pair<l,l> pl;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<l> vl;
typedef vector<ll> vll;

// MACROS FOR PRINT
#define nl printf("\n")
#define sp printf(" ")

// MACROS FOR ATTRIBUTE
#define fi first
#define se second

// MACROS FOR FUNCTION AND METHOD
#define eb emplace_back
#define mp make_pair
#define pb push_back
#define pf push_front
#define ppb pop_back
#define ppf pop_front
#define ALL(x) (x).begin(), (x).end()
#define ALLN(x,n) (x), (x)+(n)
#define CUBE(x) (SQR(x)*(x))
#define SET(x,y) for (int _qwe = sizeof(x)/sizeof(x[0]); _qwe; ) x[--_qwe] = (y)
#define SQR(x) ((x)*(x))
#define SSORT(x,sz) sort(ALLN(x,sz))
#define RESET(x) memset((x), 0, sizeof(x))
#define VSORT(x) sort(ALL(x))

// MACROS READ INPUT
#define sci(x) scanf("%d", &x)
#define scl(x) scanf("%ld", &x)
#define scll(x) scanf("%lld", &x)
#define scul(x) scl(x)
#define scull(x) scll(x)

int main() {
	int N, K;
	sci(N), sci(K);
	int tot = N-(K-1);
	printf("%d\n", K == 1 ? 0 : tot-1);
	return 0;
}

Measured memory_bytes: 256
#include<cstdio>
int main()
{
	int t;
	while (scanf("%d", &t) != EOF)
	{
		if (t == 1){ printf("Hello World\n"); }
		else {
			int a, b;
			scanf("%d%d", &a, &b);
			printf("%d\n", a + b);
		}
	}
}

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

bitset<1000009> bs;
vector<int> primes;

void sieve(int upper_bound) {
    bs.reset();
    bs.set(0);
    bs.set(1);

    for (int i = 2; i < upper_bound; i++) {
        if (bs.test(i)) {
            continue;
        }

        primes.push_back(i);
        for (long long j = 1ll * i * i; j < upper_bound; j += i) {
            bs.set(j);
        }
    }
}

int main() {
    sieve(1000009);
    long long n;
    cin >> n;
    
    vector<int> p;
    int i = 0;
    while (i < (int) primes.size() && n > 1) {
        int cnt = 0;
        while (n % primes[i] == 0) {
            n /= primes[i];
            cnt++;
        }

        if (cnt) {
            p.push_back(cnt);
        }
        i++;
    }

    if (n > 1) {
        n /= n;
        p.push_back(1);
    }

    int ans = 0;
    for (int i : p) {
        int t = 0;
        for (int j = 1; t + j <= i; j++) {
            t += j;
            ans += 1;
        }
    }

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


Measured memory_bytes: 3872
import sys

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60
MOD = 1000000007


def main():
    a, b, c = readline().split()

    ans = (a[0] + b[0] + c[0]).upper()
    print(ans)

    return


if __name__ == '__main__':
    main()


Measured memory_bytes: 9044
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <cfloat>
#include <stack>
#include <queue>
#include <vector>
typedef long long int ll;
#define BIG_NUM 2000000000
#define MOD 1000000007
#define EPS 0.000001
using namespace std;

#define NUM 2147483647

int N;
int* table;

void init(int first_N){
	while(N < first_N)N *= 2;
}

void update(int loc,int value){
	loc += N-1;

	table[loc] = value;

	if(N == 1)return;

	int parent = (loc-1)/2;

	while(true){
		table[parent] = min(table[2*parent+1],table[2*parent+2]);

		if(parent == 0)break;
		else{
			parent = (parent-1)/2;
		}
	}
}


int query(int search_left,int search_right,int node_id,int node_left,int node_right){

	if(search_right < node_left || search_left > node_right)return NUM;

	if(search_left <= node_left && search_right >= node_right){
		return table[node_id];
	}

	int left_min = query(search_left,search_right,2*node_id+1,node_left,(node_left+node_right)/2);
	int right_min = query(search_left,search_right,2*node_id+2,(node_left+node_right)/2+1,node_right);

	return min(left_min,right_min);
}


int main(){

	int first_N,Q,command,left,right;
	table = new int[1000000];
	N = 1;

	scanf("%d %d",&first_N,&Q);

	init(first_N);

	for(int i = 0; i <= 2*N-2; i++)table[i] = NUM;

	for(int i = 0; i < Q; i++){
		scanf("%d %d %d",&command,&left,&right);

		if(command == 0){
			update(left,right);
		}else{
			printf("%d\n",query(left,right,0,0,N-1));
		}
	}

	return 0;
}



Measured memory_bytes: 3784
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <cstring>
#include <deque>

#define rep0(i, n) for (i = 0; i < n; i++)
#define rep(s, i, n) for (i = s; i < n; i++)
using namespace std;

#define INF 1<<30

const int di[] = {-1, 0, 1, 0};
const int dj[] = {0, -1, 0, 1};

int main()
{
    int i,k;
    int h, w;
    cin >> h >> w;
    int ch, cw, dh, dw;
    cin >> ch >> cw >> dh >> dw;
    ch--;cw--;dh--;dw--;
    vector<string> s(h);
    rep0(i, h) cin >> s.at(i);
    vector< vector<int> > dist(h, vector<int>(w, INF));
    deque< pair<long long, long long> > q;
    dist.at(ch).at(cw) = 0;
    q.push_back(make_pair(ch, cw));
    while (!q.empty())
    {
        int i = q.front().first;
        int j = q.front().second;
        q.pop_front();
        int d = dist.at(i).at(j);
        rep0(k, 4)
        {
            int ni = i + di[k];
            int nj = j + dj[k];
            if (ni < 0 || ni >= h || nj < 0 || nj >= w)
                continue;
            if (s.at(ni).at(nj) == '#')
                continue;
            if (dist.at(ni).at(nj) <= d)
                continue;
            dist.at(ni).at(nj) = d;
            q.push_front(make_pair(ni, nj));
        }
        for (int mi = -2; mi <= 2; mi++)
        {
            for (int mj = -2; mj <= 2; mj++)
            {
                int ni = i + mi;
                int nj = j + mj;
                if (ni < 0 || ni >= h || nj < 0 || nj >= w)
                    continue;
                if (s.at(ni).at(nj) == '#')
                    continue;
                if (dist.at(ni).at(nj) <= d + 1)
                    continue;
                dist.at(ni).at(nj) = d + 1;
                q.push_back(make_pair(ni, nj));
            }
        }
    }
    int ans = dist.at(dh).at(dw);
    if (ans == INF)
        ans = -1;
    cout << ans << endl;
}

Measured memory_bytes: 9664
#include <bits/stdc++.h>
#define IOS ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define deci fixed<<showpoint<<setprecision //<<deci()<<
#define ll long long
#define mod 1000000007
double pi=acos(-1);
using namespace std;
int n;
int arr[100001];
int main()
{ IOS
    cin>>n;
 for(int i=0;i<n;i++){
   cin>>arr[i];}
 int mx=0;
 int cnt=0;
 for(int i=0;i<n-1;i++){
   if(arr[i+1]<=arr[i]){
     cnt++;}else{
     cnt=0;}
   if(cnt>mx)
     mx=cnt;}
cout<<mx;
    return 0;
}


Measured memory_bytes: 640
// Problem : D - joisino's travel
// Contest : AtCoder - AtCoder Beginner Contest 073
// URL : https://atcoder.jp/contests/abc073/tasks/abc073_d
// Memory Limit : 256 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

//#pragma GCC optimize("Ofast")
//#pragma GCC optimize ("unroll-loops")
//#pragma GCC target("avx,avx2,fma")
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define eb emplace_back
#define pb push_back
#define size(s) (int)s.size()
#define int long long
#define vi vector<int>
#define vs vector<string>
#define vv vector<vector<int>>
#define pii pair<int,int>
#define m_p(x,y) make_pair(x,y)
#define vp vector<pair<int,int>>
#define setbits(x) __builtin_popcountll(x)
#define f first
#define se second
#define inc(v,n,x) v.assign(n,x)
#define incd(v,n) v.resize(n)
#define iniz(n) memset(n,0,sizeof(n))
#define inin(n) memset(n,-1,sizeof(n))
#define inimi(n) memset(n,0xc0,sizeof(n))
#define inima(n) memset(n,0x3f,sizeof(n))
#define all(v) (v).begin(),(v).end()

using namespace std;

template<typename T1,typename T2>istream &operator>>(istream &is, vector<pair<T1,T2>> &v) { for (pair<T1,T2> &t : v) is >> t.f>>t.se; return is; }
template<typename T>istream &operator>>(istream &is, vector<T> &v) { for (T &t : v) is >> t; return is; }
template<typename T>ostream &operator<<(ostream &os, const vector<T> &v) { for (const T &t : v) {os << t <<" ";} os << '\n'; return os; }

const int N=200001;
double pi=acos(-1.0);
int md=1e9+7;
const int INF=1e15;
int dx1[]={0,0,-1,1};
int dy1[]={1,-1,0,0};

template<class T>
T abst(T a)
{return a<0?-a:a;}

template<class T>
T max2(T a,T b){return a>b?a:b;}
template<class T>
T min2(T a,T b){return a<b?a:b;}
vp v[201];
int dis[201][201];
vi r;
int dp[1000][10];
int fun(int mask,int i)
{
	if(setbits(mask)==size(r))return 0;
	if(dp[mask][i]!=-1)return dp[mask][i];
	int ans=INT_MAX;
	for(int j=0;j<size(r);j++)
	if(!((1<<j)&mask))
	ans=min2(ans,dis[r[i]][r[j]]+fun(mask|(1<<j),j));
	return dp[mask][i]=ans;
}
void solve()
{
	inin(dp);
int n,m,r1;cin>>n>>m>>r1;
inima(dis);
for(int i=1;i<=n;i++)
dis[i][i]=0;
incd(r,r1);cin>>r;
while(m--)
{
	int x,y,z;
	cin>>x>>y>>z;
	dis[x][y]=z;
	dis[y][x]=z;
}
for(int k=1;k<=n;k++)
{
	for(int i=1;i<=n;i++)
	{
		for(int j=1;j<=n;j++)
		dis[i][j]=min2(dis[i][k]+dis[k][j],dis[i][j]);
	}
}
int ans=INT_MAX;
for(int i=0;i<r1;i++)
ans=min2(ans,fun(1<<i,i));
cout<<ans;
}

int32_t main(){
ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);
int t=1;
//cin>>t;
for(int i=1;i<=t;i++)
{
    solve();
}
return 0;
}


Measured memory_bytes: 4044
N, K = map(int, input().split())
coin = [0.5**k for k in range(10**5)]
ans = 0
for i in range(1,N+1):
    x = 0
    while(True):
        if i*(2**x) >= K:
            ans += 1/N * coin[x]
            break
        else: x += 1

print(ans)

Measured memory_bytes: 6680
while (ln = gets.chomp) != "0 0"
  w,h = ln.split.map(&:to_i)
  s = h.times.map{gets.split.map(&:to_i)}
  
  cnts = Array.new(h).map{Array.new(w,0)}
  vis = Array.new(h).map{Array.new(w,0)}
  sel = Array.new(h).map{Array.new(w,0)}
  cnt = 1
  for i in 0..(h-1)
    for j in 0..(w-1)
      if s[i][j] == 1 && vis[i][j] == 0
        ln = [i]
        ro = [j]
        id = 0
        idmax = 0
        
        while id <= idmax
          x = ro[id]
          y = ln[id]
          cnts[y][x] = cnt
          vis[y][x] = 1
          xdir = [x,x-1,x+1]
          ydir = [y,y-1,y+1]
          xdir.each do |xd|
            ydir.each do |yd|
              if xd != x || yd != y
                if 0<=xd && xd<w && 0<=yd && yd<h && s[yd][xd]==1 && vis[yd][xd]==0 && sel[yd][xd]==0
                  sel[yd][xd] = 1
                  ln.push(yd)
                  ro.push(xd)
                  idmax += 1
                end
              end
            end
          end
          id += 1
        end
        
        cnt += 1
      end
    end
  end

  ans = 0
  for i in 0..(h-1)
    for j in 0..(w-1)
      ans = [ans,cnts[i][j]].max
    end
  end
  puts ans
end


Measured memory_bytes: 7268
#include <stdio.h>

void trace(int A[], int N){
  int i;
  for(i = 0; i < N; i ++){
    if(i > 0) printf(" ");  // 隣を1つの空白を出力
    printf("%d", A[i]);
  }
  printf("\n");
}

/* 挿入ソート */
void insertsort(int A[], int N){
  int j, i, tmp;
  for(i = 1; i < N; i++){
    tmp = A[i];
    j = i - 1;
    while(j >= 0 && A[j] > tmp){
      A[j + 1] = A[j];
      j--;
    }
    A[j + 1] = tmp;
    trace(A,N);
  }
}


int main(){
  int N, i, j;
  int A[1000];
  
  scanf("%d", &N);
  for(i = 0; i < N; i++){
    scanf("%d", &A[i]);
  }
  trace(A, N);
  insertsort(A, N);

  return 0;
}


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

int main() {
  int A, B, C, ans = 0; cin >> A >> B >> C;
  if(A%2==B%2 && A%2==C%2) ans = (3*max({A, B, C})-A-B-C)/2;
  else if(A%2==B%2) {
    A++;
    B++;
    ans = (3*max({A, B, C})-A-B-C)/2 + 1;
  }
  else if(B%2==C%2) {
    B++;
    C++;
    ans = (3*max({A, B, C})-A-B-C)/2 + 1;
  }
  else if(C%2==A%2) {
    C++;
    A++;
    ans = (3*max({A, B, C})-A-B-C)/2 + 1;
  }
  cout << ans << "\n";
}

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

public class Main {

    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        int n = in.nextInt();
        int k = in.nextInt();
        int[] a = new int[n];
        for (int i = 0; i < n; i++) {
            a[i] = in.nextInt();
        }
        int[] dp = new int[n];
        dp[0] = 0;
        for (int i = 1; i < n; i++) {
            dp[i] = Integer.MAX_VALUE;
            for (int j = 1; j <= k && (i - j) >= 0; j++) {
                dp[i] = Math.min(dp[i], dp[i - j] + Math.abs(a[i - j] - a[i]));
            }
        }
        out.println(dp[n-1]);
        out.close();
    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

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

    }
}


Measured memory_bytes: 35100
#include <stdio.h>
#include <string.h>

int main(void){
  char buf[4];
  
  scanf("%s",buf);
  if(buf[0]==buf[1] || buf[1]==buf[2] || buf[2]==buf[3]){
    printf("Bad\n");
  }
  else{
    printf("Good\n");
  }
  
  return 0;
      
}

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

enum ATGC{N,A,T,G,C};
UL f(ATGC a,ATGC b,ATGC c, ATGC d){
  return ((a*5+b)*5+c)*5+d;
}

void Solve(){
  ULL M = 1000000007;
  ULL dp[101][625] = {};
  dp[0][0] = 1;
  vector<UL> NGW = {
    f(A,G,C,A),
    f(A,G,C,T),
    f(A,G,C,G),
    f(A,G,C,C),
    f(G,A,C,A),
    f(G,A,C,T),
    f(G,A,C,G),
    f(G,A,C,C),
    f(A,C,G,A),
    f(A,C,G,T),
    f(A,C,G,G),
    f(A,C,G,C),
    f(A,G,A,C),
    f(A,G,T,C),
    f(A,G,G,C),
    f(A,A,G,C),
    f(T,A,G,C),
    f(G,A,G,C),
    f(C,A,G,C),
    f(A,T,G,C),
    f(A,G,G,C),
    f(A,C,G,C),
    f(A,G,A,C),
    f(T,G,A,C),
    f(G,G,A,C),
    f(C,G,A,C),
    f(A,A,C,G),
    f(T,A,C,G),
    f(C,A,C,G),
    f(N,A,G,C),
    f(N,A,C,G),
    f(N,G,A,C),
  };
  for(UL i = 1; i <= 100; i++){
    for(UL j = 0; j < 625; j++){
      dp[i][(j*5+1)%625] += dp[i-1][j];
      dp[i][(j*5+2)%625] += dp[i-1][j];
      dp[i][(j*5+3)%625] += dp[i-1][j];
      dp[i][(j*5+4)%625] += dp[i-1][j];
    }
    for(UL NG : NGW){
      dp[i][NG] = 0;
    }
    for(UL j = 0; j < 625; j++){
      dp[i][j] %= M;
    }
  }
  ULL ans = 0;
  UL N; cin >> N;
  for(UL j = 0; j < 625; j++){
    ans += dp[N][j];
  }
  cout << ans % M << endl;
}
int main(){
  Solve(); return 0;
}

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

using namespace std;
#define int long long
const int MOD = 1000000007;
vector<vector<int> > g;
int N, A, B;
int res = 0;
vector<int> path;
vector<int> depth;
vector<int> h;
bool found = false;
void dfs(int a, int p = -1) {
	h[a] = 1;
	if (!found) {
		path.push_back(a);
	}
	if (a == B) {
		found = true;
	}
	for (int i : g[a]) {
		if (i != p) {
			depth[i] = depth[a] + 1;
			dfs(i, a);
			h[a] = max(h[a], h[i] + 1);
		}
	}
	if (!found) {
		path.pop_back();
	}
}
signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	cin >> N >> B >> A;
	A--;
	B--;
	g.resize(N);
	h.resize(N);
	depth.resize(N);
	for (int i = 0; i < N - 1; i++) {
		int a, b;
		cin >> a >> b;
		a--;
		b--;
		g[a].push_back(b);
		g[b].push_back(a);
	}
	depth[A] = 0;
	dfs(A);
	int c = path[((int)path.size() + 1) / 2];
	// for (int i = 0; i < path.size(); i++) {
	// 	cerr << path[i] + 1 << " ";
	// }
	// cerr << endl;
	// cerr << c + 1 << endl;
	cout << h[c] + depth[c] - 2 << endl;
}

Measured memory_bytes: 12800