akhauriyash/Code-Regression huggingface dataset:
//
//AtCoder Beginner Contest XXX
//X - XXXX
//

#include <iostream>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
#include <ctime>
#include <queue>
#include <map>
#include <set>
#include <tuple>
#include <functional>
#include <cassert>

using namespace std;

#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
#define ALL(x) (x).begin(),(x).end()
#define RALL(x) (x).rbegin(),(x).rend()
#define SIZE(x) (int)(x).size()
#define SIZEL(x) (ll)(x).size()
#define MSG(a) cout << #a << " " << a << endl;

using ll = long long;
using ld = long double;

const double PI = 3.14159265358979323846;

ll gcd(ll x, ll y) { return (x % y)? gcd(y, x % y): y; }    //最大公約数
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }            //最小公倍数

int main()
{
    int a, b;
    cin >> a >> b;
    int ans=0;
    if (a>12) ans=b;
    else if(6<=a && a<=12) ans=b/2;
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3628
N, M = map(int,input().split())
vote = list(map(int,input().split()))

#vote内の合計
sum = 0
for i in range(len(vote)):
    sum  = sum + vote[i]

#基準
j = sum/(4*M)

#基準を満たす品物の合計
num = 0
for i in range(len(vote)):
    if vote[i] >= j:
        num = num + 1
    else: continue

#出力
if num >= M:
    print("Yes")
else: print("No")


Measured memory_bytes: 3060
#include <bits/stdc++.h>
#include <cstdlib>  // abs() for integer 絶対値求めやつ
#include <cmath>    // abs() for float, and fabs()
#include <algorithm>
#include <vector>
#include <string>
#define rep(i,n) for(int i = 0; i < (n);i++)
#define SORT(a) sort((a).begin(),(a).end())
#define REV(a) reverse((a).begin(),(a).end())
using namespace std;
#define INF 2000000000
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
#define che(a,string) cout<<"//"<<string <<"=="<<(a)<<"//" <<endl;
//入力
int H , W;

int main(){
	cin >> H >> W;
	vector<vector<char>> A(H,vector<char>(W));
	rep(i,H){
		rep(j,W){
			cin>>A[i][j];
			if(A[i][j]=='.'){
				A[i][j]='0';
			}
		}
	}	//回りにある#の数を求める。(int)次にstring型に変換して、stringの0文字目をcharに入れる。って感じですれば変換可能！！
/*	rep(i,H){
		rep(j,W){
			if(A[i][j]!= -1){
				for(int x = i-1; x<=i+1 ; x++){
					for(int y = j-1; y<=j+1 ; j++){
						*/

	rep(i,H){
		rep(j,W){
			if(A[i][j]=='#'){//#じゃない、回りにあるやつをintに変換してから+1してstringに戻す
				for(int x = i-1; x<=i+1 ; x++){
					for(int y = j-1 ; y<=j+1 ; y++){
						if(x>=0&&y>=0&&!(x==i&&y==j)){//範囲外じゃなければ操作できる
							//数値だったら＋1の処理をする。つまり#じゃなければいい
						if(x>=0&&x<H&&y>=0&&y<W){
							if(A[x][y]!='#'){
								//まずはcharをintにする
								int lol =A[x][y]-'0';
								lol ++;
								string b = to_string(lol);
								char c = b.at(0);
								A[x][y] =c;
							}
						}
						}
					}
				}
			}
		}
	}
	
	rep(i,H) {
		rep(j,W){
			cout<<A[i][j];
			if(j==W-1)cout<<endl;
		}
	}
}



Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
  int n,l,moto=0,tmp_r,min_r,min_abs=10000000;
  cin >> n>>l;
  for(int i=0;i<n;i++){
    moto+=l+i;
  }
  for(int i=0;i<n;i++){
    tmp_r=moto -(l+i);
    tmp_r=abs(moto-tmp_r);
    if(min_abs>tmp_r){
      min_abs=tmp_r;
      min_r=moto-(l+i);
    }
  }
  cout << min_r<<endl;
}


Measured memory_bytes: 256
import java.io.IOException;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws IOException {
		Scanner sn = new Scanner(System.in);
		
		int n = sn.nextInt();
		int len = String.valueOf(n).length();
		
		switch (len) {
		case 1:
			System.out.println(n);
			break;
		case 2:
			System.out.println(9);
			break;
		case 3:
			System.out.println(n - 90);
			break;
		case 4:
			System.out.println(900 + 9);
			break;
		case 5:
			System.out.println(n - (9000 + 90));
			break;
		case 6:
			System.out.println(90000 + 900 + 9);
			break;
		}
	}
	
}


Measured memory_bytes: 21972
from sys import stdin

def main():

    input = stdin.readline

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

    judge = "APPROVED"
    for n in N:
        if(n%2==0) and (n%5!=0) and (n%3!=0):
            print("DENIED")
            break
    else:
        print(judge)


if __name__ == "__main__":
    main()

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i,n) for(int i=0;i<(n);++i)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define all(x) (x).begin(), (x).end()
#define PI 3.14159265358979323846264338327950L
using namespace std;
typedef long long ll;
typedef long double ld;
int main() {
    int n,k,r,s,p;
    string t;
    cin>>n>>k>>r>>s>>p>>t;
    int ans=0;
    rep(i,n){
        if(i>=k&&t[i]==t[i-k]){
            t[i]='a';
            continue;
        }
        if(t[i]=='r') ans+=p;
        else if(t[i]=='s') ans+=r;
        else if(t[i]=='p') ans+=s;
    }
    cout<<ans;
}

Measured memory_bytes: 3764
#cやり直し
import numpy
n = int(input())
a = list(map(int, input().split()))
ans = 0
mod = 10**9 +7

before = a[-1]
for i in range(n-1,0,-1):
    
    ans += (a[i-1]*before)%mod
    before += a[i-1]
    
print(ans%mod)

Measured memory_bytes: 50064
#include <iostream>
#include <sstream>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <set>
#include <queue>
#include <map>
#include <numeric>
#include <functional>
#include <math.h>

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;

#define INF ((int)1e9)
#define INFLL ((ll)1e18)
#define MOD (1000000007LL)


int main(int argc, const char * argv[]) {
    ios_base::sync_with_stdio(false);
    int N, K;
    cin >> N >> K;
    vector<ll> H(N+1, 0);
    for (int n = 1; n <= N; ++n) cin >> H[n];
    
    if (N == K) {
        cout << 0 << endl;
        return 0;
    }
    
    vector<vector<ll>> DP(N+1, vector<ll>(N+1, INFLL));
    DP[0][0] = 0LL;
    for (int n = 1; n <= N; ++n) {
        for (int s = 1; s <= n; ++s) {
            ll Min = INFLL;
            for (int m = 0; m < n; ++m) {
                ll Tmp = DP[m][s-1] + max(H[n]-H[m], 0LL);
                if (Tmp < Min) Min = Tmp;
            }
            DP[n][s] = Min;
        }
    }
    ll Res = INFLL;
    for (int n = 1; n <= N; ++n) {
        ll Tmp = DP[n][N-K];
        if (Tmp < Res) Res = Tmp;
    }
    cout << Res << endl;

    return 0;
}


Measured memory_bytes: 1024
// God put a smile upon your face <3

#include <bits/stdc++.h>`

#define slld(longvalue) scanf("%d", &longvalue)

#define ll int
#define ull unsigned long long
#define pll pair < long long, long long >

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

#define pb push_back

#define bug printf("BUG\n")

#define mxlld LLONG_MAX
#define mnlld -LLONG_MAX

#define mxd 2e8
#define mnd -2e8

#define pi 3.14159265359

#define mod 958585860497

#define base 2001487

using namespace std;

bool check(ll n, ll pos)
{
	return n & (1LL << pos);
}

ll Set(ll n, ll pos)
{
	return n = n | (1LL << pos);
}


const ll maxn  = 5000;
vector < ll > primes;
bool vis[maxn+10];

void sieve()
{
    vis[0] = 1;
    vis[1] = 1;

    for(ll i = 4; i <= maxn; i += 2)
    {
        vis[i] = 1;
    }

    for(ll i = 3; i * i <= maxn; i += 2)
    {
        if(vis[i] == 0)
        for(ll j = i * i; j <= maxn; j += i)
        {
            vis[j] = 1;
        }
    }

    for(ll i = 2; i <= maxn; i++)
    {
        if(vis[i] == false)
        primes.pb(i);
    }

}

vector < ll > vec;
map < ll, ll > mp2;
ll mp[1000005];

int main()
{
    ll i, j, k, l, m, n, o, r, q;
    ll testcase;
    ll input, flag, tag, ans;

//    freopen("input.txt", "r", stdin);

//    freopen("output.txt", "w", stdout);

    sieve();

    while(cin >> n)
    {
		vec.clear();
		memset(mp,0,sizeof mp);
		mp2.clear();

		for(i = 0; i < n; i++)
		{
			slld(input);
			vec.push_back(input);
			mp2[input]++;
		}

		sort(vec.begin(),vec.end());

		ans = 0;

		for(auto it: vec)
		{
			if(mp2[it] > 1)
			{
				mp[it]++;
				continue;
			}

			bool no = 1;

			for(i = 1; i * i <= it; i++)
			{
				if(it % i) continue;

				ll x = it / i;
				ll y = i;

				if(mp[y]) no = 0;
				if(mp[x]) no = 0;
			}

//			cout << it << " " << no << endl;
			if(no) ans++;

			mp[it]++;
		}

		cout << ans << '\n';
    }


}





Measured memory_bytes: 17316
#include<cstdio>
#include <algorithm>
#include <vector>
#include <iostream>
#include <string>
using namespace std;
int main(){
  string s1,s2,s3,s4,s5,s6;
  cin>>s1>>s2>>s3;
  s4=toupper(s1[0]);
  s5=toupper(s2[0]);
  s6=toupper(s3[0]);
  cout<<s4<<s5<<s6;
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdint>
#include<unordered_map>
using namespace std;
unordered_map<uint64_t,uint64_t> um;
void search(uint64_t n){
    if(um.find(n)!=um.end())return;
    search(n/2);
    um.insert(pair<uint64_t,uint64_t>(n,1+um[n/2]*2));
}
int main(){
    uint64_t h;
    cin>>h;
    um.insert(pair<uint64_t,uint64_t>(1,1));
    search(h);
    cout<<um[h]<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define Rep(i,a,b) for(int i=a;i<b;i++)
#define REP(i,a,b) for(int i=a;i<=b;i++)
#define rev(i,n) for(int i=n-1;i>=0;i--)
#define vi vector<int>
#define pb push_back
#define pi pair<int,int>
#define vp vector<pair<int,int> >
#define mp make_pair
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define inf 1000000000000000000

using namespace std;

signed main(){
    int n;
    cin>>n;
    int ans=0;
    for(int i=1;i<=n;i+=2){
        int c=0;
        for(int j=1;j<=i;j++){
            if(i%j==0)c++;
        }
        if(c==8)ans++;
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <cassert>
#include <string>
#include <vector>
#include <utility>
#include <complex>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <deque>
#include <tuple>
#include <bitset>
#include <limits>
#include <algorithm>
#include <array>
#include <random>
#include <complex>
#include <regex>
#include <iomanip>
using namespace std;
typedef long double ld;
typedef long long ll;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define fcout cout << fixed << setprecision(10)
#define rep(i,n)    for(int i=0; i<(int)n; i++)
#define mp(a,b) make_pair(a,b)
#define pb push_back
#define all(x) x.begin(), x.end()
#define F first
#define S second
const ll inf = 1e18;
const ll mod = 1e9 + 7;

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

// mod.m での a の逆元 a^(-1) を計算する。
ll modinv(ll a, ll m) {
    ll b = m, u = 1, v = 0;
    while(b){
        ll t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}

ll modpow(ll a, ll n){
    ll res = 1;
    while(n>0){
        if(n&1){
            res = res * a % mod;
        }
        a = a * a % mod;
        n >>=1;
    }
    return res;
}


int main(){
    int n;
    cin >> n;
    vint a(n);
    rep(i,n) cin >> a[i];
    ll money = 1000;
    int idx=0;
int min_value=a[0];
    while(idx < n){
        if(min_value < a[idx]){
            money += (a[idx]-min_value)*(money/min_value);
            min_value = a[idx];
        }else{
            min_value = a[idx];
        }
        idx++;
    }
    cout << money << endl;
}



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

using ll = long long;
using vi = vector<int>;
using vll = vector<long long>;

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

constexpr long long mod = 1000000007;

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

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

    long n, k;
    cin >> n >> k;

    vll a(n + 1, 0);
    for (int i = 1; i <= n; i++) {
        a[i + 1] = a[i] + i;
    }

    ll cnt = 0;
    for (int i = k; i <= n + 1; i++) {
        cnt += a[n + 1] - a[n + 1 - i ] - a[i] + 1;

        cnt %= mod;
    }

    cout << cnt << endl;
}

Measured memory_bytes: 4744
#include<bits/stdc++.h>
  #pragma GCC optimize ("-O3")
  using namespace std;
  #define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
  #define endl "\n"
  #define int long long
  #define double long double
  #define all(v) v.begin(),v.end()
  #define rep(i,a,b) for(int i = a; i <=b; i++)
  #define rep2(i,a,b) for(int i = a; i>=b; i--)
  #define f first
  #define s second
  #define PB push_back
  #define MP make_pair
  #define db long double
  #define trace1(x)                cerr<<#x<<": "<<x<<endl
  #define trace2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
  #define trace3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
  #define trace4(a, b, c, d)       cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
  #define trace5(a, b, c, d, e)    cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
  #define trace6(a, b, c, d, e, f) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl
  #define cases int testcases;cin>>testcases; while(testcases--)
  const int N=1e6+5; 


  int table[300005][64];

  int mod = 1e9+7;
int modexpo(int x,int p){
    int res = 1;
    x = x%mod;
    while(p){
        if(p%2)
            res = res * x;
        p >>= 1;
        x = x*x % mod;
        res %= mod;
    }
    return res;
}


int32_t main()
{
       


    int n;
    cin >> n;
    int arr[n+1];


    rep(i,1,n)
    {
      cin >> arr[i];

    }

    int ans =0;
    rep(bit,0,63)
    {
      int a =0,b = 0;

      rep(i,1,n)
      {
        if(arr[i] &(1LL<<bit))
        {
          a++;
        }
        else
        {
          b++;
        }
      }

    

      ans = (ans + ((((a%mod) *(b%mod)))%mod)*(modexpo(2,bit))%mod)%mod;
    }

    ans %=mod;


    cout << ans;    
  
   return 0;
}       


Measured memory_bytes: 2560
#include <bits/stdc++.h>
using namespace std;
int main(void){
  int i;
  int N,M,X,Y;
  cin>>N>>M>>X>>Y;
  int x[1001], y[1001];
  for(i=0;i<N;i++){
    cin>>x[i];
  }
  x[N]=X;
  for(i=0;i<M;i++){
    cin>>y[i];
  }
  y[M]=Y;
  sort(x,x+(N+1));
  sort(y,y+(M+1));
  if (x[N]<y[0])  cout<<"No War";
  else  cout<<"War";
}


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

int main() {
  int H, W, K;
  cin >> H >> W >> K;
  vector<vector<char>> c(H, vector<char> (W));
  int ans = 0;
  int black = 0;
  for (int i = 0; i < H; i++) {
    for (int j = 0; j < W; j++) {
      cin >> c[i][j];
      if (c[i][j] == '#') black++;
    }
  }
  vector<vector<char>> d = c;

  for (int i = 0; i < (1 << H); i++) {
    c = d;
    int num = 0;
    for (int j = 0; j < H; j++) {
      if (i & (1 << j)) {
        for (int k = 0; k < W; k++) {
          if (c[j][k] == '#') {
            num ++;
            c[j][k] = '.';
          }
        }
      }
    }
    vector<vector<char>> e;
    for (int l = 0; l < (1 << W); l++) {
      int num2 = num;
      for (int m = 0; m < W; m++) {
        if (l & (1 << m)) {
          for (int n = 0; n < H; n++) {
            if (c[n][m] == '#') {
               num2++;
            }
          }
        }
      }
      if (black-num2 == K) ans++;
    }
  }
  cout << ans << endl;
}

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

using namespace std;
const int N=1e5+5;
string s,t;
int n,m,cnt[N][3];

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cin>>s>>t;
    n=s.size();
    m=t.size();
    s=" "+s;
    t=" "+t;
    for(int i=1;i<=n;i++)
    {
        cnt[i][1]=cnt[i-1][1]+(s[i]=='B');
    }
    for(int i=1;i<=n;i++)
    {
        cnt[i][2]=cnt[i-1][2]+(t[i]=='B');
    }
    int q;
    cin>>q;
    while(q--)
    {
        int a,b,c,d;
        cin>>a>>b>>c>>d;
        int len1=b-a+1;
        int len2=d-c+1;
        int numB_s=cnt[b][1]-cnt[a-1][1];
        int numB_t=cnt[d][2]-cnt[c-1][2];
        int numA_s=len1-numB_s;
        int numA_t=len2-numB_t;
        if(s[a]=='A')
        {
            numB_s+=2;
            numA_s--;
        }
        numB_s-=numB_t;
        numB_s+=numA_t;
        numB_s+=2*numA_s;
        //cout<<numB_s<<' ';
        if(numB_s%3==0) cout<<"YES";
        else cout<<"NO";
        cout<<'\n';
    }
}


Measured memory_bytes: 2156
//#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define trav(x,a) for (const auto& x: a)
#define sz(x) (int)(x).size()
#define mem(a,v) memset((a), (v), sizeof (a))
#define enl printf("\n")
#define case(t) printf("Case #%d: ", (t))
#define ni(n) scanf("%d", &(n))
#define nl(n) scanf("%lld", &(n))
#define nai(a, n) for (int _i = 0; _i < (n); _i++) ni(a[_i])
#define nal(a, n) for (int _i = 0; _i < (n); _i++) nl(a[_i])
#define pri(n) printf("%d\n", (n))
#define prl(n) printf("%lld\n", (n))
#define pii pair<int, int>
#define pll pair<long long, long long>
#define vii vector<pii>
#define vll vector<pll>
#define vi vector<int>
#define vl vector<long long>
#define pb push_back
#define mp make_pair
#define st first
#define nd second
using namespace std;
using namespace __gnu_pbds;
typedef long long ll;
typedef cc_hash_table<int,int,hash<int>> ht;
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> oset;
const double pi = acos(-1);
const int mod = 1e9 + 7;
const int inf = 1e9 + 7;
const int N = 2e6 + 5;
const double eps = 1e-9;
int a[N];
char s[N];

void print(vi& ar) {
  trav(x, ar) cerr << x << " ";
  cerr << endl;
}

int main() {
  int n; ni(n); scanf("%s", s);
  for (int i = 0; i < n; i++) a[i] = s[i]-'1';
  vi ttmp(n);
  for (int i = 0; i < n; i++)
    ttmp[i] = a[i];
  while (sz(ttmp) > 1) {
    int i = 22;
    while (i > 0 && (((sz(ttmp)-1)>>i)&1) == 0)
      i--;
    if (sz(ttmp) > n-10)
      i = 0;
    // i = 1;
    // cerr << "jump: " << (1<<i) << " steps\n";
    vi nx;
    for (int j = 0; j+(1<<i) < sz(ttmp); j++)
      nx.pb(abs(ttmp[j]-ttmp[j+(1<<i)]));
    swap(ttmp, nx);
    // print(ttmp);
    // break;
  }
  printf("%d\n", ttmp[0]);
  // vi tmp(n);
  // for (int i = 0; i < n; i++) {
  //   tmp[i] = a[i];
  // }
  // for (int i = 1; i < n; i++) {
  //   vi nx(sz(tmp)-1);
  //   for (int j = 0; j+1 < sz(tmp); j++)
  //     nx[j] = abs(tmp[j] - tmp[j+1]);
  //   // print(nx);
  //   swap(tmp, nx);
  // }
  // cerr << tmp[0] << endl;
  return 0;
}


Measured memory_bytes: 17696
#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
const int MAX = 100000;

vector<int> abc[3], DP[3];

int max_happy(int i, int j){
    int happy=0;
    for(int k=0; k<3; k++){
        if(k==j) continue;
        if(DP[k][i-1]+abc[j][i]>happy) happy=DP[k][i-1]+abc[j][i];
    }
    return happy;
}

int main(){
    int N; cin >> N;
    int a, b, c;
    for(int i=0; i<N; i++){
        cin >> a >> b >> c;
        abc[0].push_back(a);
        abc[1].push_back(b);
        abc[2].push_back(c);
    }
    for(int i=0; i<3; i++) DP[i].push_back(abc[i][0]);
    for(int i=1; i<N; i++){
        for(int j=0; j<3; j++){
            DP[j].push_back(max_happy(i,j));
        }
    }/*
    cout << endl << "DP" << endl;
    for(int i=0; i<3; i++){
        for(auto e: DP[i]) {
            cout << e << ", ";
        }
        cout << endl;
    }*/
    cout << max({DP[0][N-1], DP[1][N-1], DP[2][N-1]}) << endl;
}

Measured memory_bytes: 2924
#include <bits/stdc++.h>
using namespace std;
using ll = int_fast64_t;
using ld = long double;
#define dump(x) cout << #x << " = " << x << "\n";
#define SELECTOR(_1, _2, _3, SELECT, ...) SELECT
#define rep(...) SELECTOR(__VA_ARGS__, _rep1, _rep0)(__VA_ARGS__)
#define _rep0(i, n) for (ll i = 0; i < n; ++i)
#define _rep1(i, k, n) for (ll i = k; i < n; ++i)
template <typename T> void vecout(const T &v) {
  for(auto it=v.begin();it!=v.end();++it,cout<<(it!=v.end()?" ":"\n")) {
    cout << *it;
  }
}

void solve() {
  // main coding
  ll n; cin>>n; // n:odd
  vector<ld> p(n+1);
  rep(i,n) cin>>p.at(i+1); // 1-indexed
  // dp[i][j]: j枚まで投げてi枚が表の確率
  vector<vector<ld>> dp(n+1,vector<ld>(n+1,0));
  dp[0][0]=1;
  rep(i,n+1) rep(j,n+1) {
    if(i+1<=n && j+1<=n) {
      dp.at(i+1).at(j+1)+=dp.at(i).at(j)*p.at(j+1);
      dp.at(i).at(j+1)+=dp.at(i).at(j)*(1-p.at(j+1));
    }
  }
  ld ans=0;
  rep(i,0,n+1) if(2*i>n) ans+=dp.at(i).at(n);
  cout<<ans<<"\n";
}

int main() {
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  solve();
  return 0;
}


Measured memory_bytes: 141056
#include <stdio.h>
int main(){
	int a,b,c;
	scanf("%d %d %d",&a,&b,&c);
	c=c+b;
	a=c-a;
	if(a<=0){
		printf("0");
	}else{
		printf("%d",a);
		}
	return 0;
}



Measured memory_bytes: 128
#include <iostream>
using namespace std;
int n,m;
int a[101],b[101][101],p[101];
int main(){
cin >> n >> m;
for(int i=1;i<=m;i++){
cin >> a[i];
}
for(int i=1;i<=m;i++){
for(int j=1;j<=n;j++){
cin >> b[i][j];
}
}
for(int i=1;i<=m;i++){
for(int j=1;j<=n;j++){
if(a[i] == b[i][j]){
p[j]+=1;
}
else{ p[a[i]]+=1;}
}}
for(int j=1;j<=n;j++){
cout << p[j] << endl;
}
return 0;
}

Measured memory_bytes: 1200
#include <algorithm>
#include <bitset>
#include <cmath>
#include <complex>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <regex>
#include <set>
#include <stack>
#include <string>
#include <vector>

const int MOD = 1e9 + 7;
const int iINF = 2147483647 / 2;
const long long int llINF = 9223372036854775807 / 2;

using namespace std;
using ll = long long int;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
using vvvl = vector<vector<vector<ll>>>;

typedef pair<ll, ll> pll;
bool paircomp(const pll &a, const pll &b) {
  if (a.first == b.first)
    return a.second < b.second;
  return a.first < b.first;
}

#define REP(i, n) for (ll i = 0; i < (n); i++)
#define RREP(i, n) for (ll i = (n)-1; i >= 0; i--)
#define FOR(i, a, b) for (ll i = (a); i < (b); i++)
#define AUTO(i, m) for (auto &i : m)
#define ALL(a) (a).begin(), (a).end()
#define MAX(vec) *std::max_element(vec.begin(), vec.end())
#define MIN(vec) *std::min_element(vec.begin(), vec.end())
#define ARGMAX(vec)                                                            \
  std::distance(vec.begin(), std::max_element(vec.begin(), vec.end()))
#define ARGMIN(vec)                                                            \
  std::distance(vec.begin(), std::min_element(vec.begin(), vec.end()))
#define REV(T) greater<T>()
#define PQ(T) priority_queue<T, vector<T>, greater<T>>
#define VVL(a, b, c) vector<vector<ll>>(a, vector<ll>(b, c))
#define VVVL(a, b, c, d)                                                       \
  vector<vector<vector<ll>>>(a, vector<vector<ll>>(b, vector<ll>(c, d)))
#define SP(a) setprecision(a)
#define SQRT(a) sqrt((long double)(a))
#define DPOW(a, b) pow((long double)(a), (long double)(b))
#define UNIQUE(vec)                                                            \
  do {                                                                         \
    sort(ALL((vec)));                                                          \
    (vec).erase(std::unique(ALL((vec))), (vec).end());                         \
  } while (0)

ll POW(ll n, ll m) {
  if (m == 0) {
    return 1;
  } else if (m % 2 == 0) {
    ll tmp = POW(n, m / 2);
    return (tmp * tmp);
  } else {
    return (n * POW(n, m - 1));
  }
}

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

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  ll N, M;
  cin >> N >> M;
  vl A(N, 0);
  REP(i, M) {
    ll a, b;
    cin >> a >> b;
    A[a - 1]++;
    A[b - 1]++;
  }
  bool ok = true;
  REP(i, N) if (A[i] % 2 != 0) ok = false;
  if (ok)
    cout << "YES" << endl;
  else
    cout << "NO" << endl;
  return 0;
}


Measured memory_bytes: 1024
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>

#include <iostream>
#include <complex>
#include <string>
#include <algorithm>
#include <numeric>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>

#include <functional>
#include <cassert>

typedef long long ll;
using namespace std;

#ifndef LOCAL
#define debug(x) ;
#else
#define debug(x) cerr << __LINE__ << " : " << #x << " = " << (x) << endl;

template <typename T1, typename T2>
ostream &operator<<(ostream &out, const pair<T1, T2> &p) {
  out << "{" << p.first << ", " << p.second << "}";
  return out;
}

template <typename T>
ostream &operator<<(ostream &out, const vector<T> &v) {
  out << '{';
  for (const T &item : v) out << item << ", ";
  out << "\b\b}";
  return out;
}
#endif

#define mod 1000000007 //1e9+7(prime number)
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define SIZE 200010


int main(){
  int N;
  string S;

  cin >> N >> S;

  for (char c : S) {
    c = ((int)(c - 'A') + N) % 26 + 'A';

    printf("%c", c);
  }

  puts("");

  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
vector<int> edge[300050];
int N = 100010;
int f,t;
int main(){
  int n,m;
  cin>>n>>m;
  for(int i=0;i<m;++i){
    cin>>f>>t;
    edge[f].push_back( t + N );
    edge[f + N].push_back( t + 2*N);
    edge[f + 2*N].push_back(t);
  }
  cin>>f>>t;
  int step = 0;
  set<int> past;
  past.insert(f);
  
  set<int> last;
  last.insert(f);
  
  int result = -1;
  while(last.size()>0){
    if(last.find(t)!=last.end()){
      result = step/3;
      break;
    }
    set<int> curr;
    for(auto i:last){
      for(auto j:edge[i]){
        if(past.find(j)==past.end()){
          curr.insert(j);
          past.insert(j);
        }
      }
    }
    
    step++;
    last = curr;
  }
  cout<<result<<endl;
  return 0;
}


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

int main() {
	int n, m;
	cin >> n >> m;
	vector<int> l(m), r(m);
	rep(i, m) cin >> l[i] >> r[i];
	int left = 0, right = 1001001001;
	rep(i, m) {
		left = max(left, l[i]);
		right = min(right, r[i]);
	}
	cout << max(0, right-left+1) << endl;
	return 0;
}

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

using ll = long long;

#define for_(i,a,b) for(int i = (a);i < (b);i++)
#define rfor_(i,a,b) for(int i = (b)-1;i >= (a);i--)
#define rep(i,n) for_(i,0,(n))
#define rrep(i,n) rfor_(i,0,(n))

char S[102];

ll K;

int main(){
	cin.tie(0);
	
	cin>>S>>K;
	K--;
	
	int i=0;
	while(S[i]=='1')i++;
	
	if(K<i)cout<<S[K]<<endl;
	else cout<<(S[i]=='\0'?'1':S[i])<<endl;
	
	return 0;
}


Measured memory_bytes: 256
n, m = map(int, input().split())
MOD = 1000000007
def comb(x, y):
    ret = 1
    for a in range(x, x - y, -1):
        ret = ret * a % MOD
    ret = ret * inverse(fact(y)) % MOD
    return ret

def fact(x):
    if x == 0:
        return 1
    return x * fact(x - 1) % MOD


def inverse(x):
    return pow(x, MOD - 2, MOD)
ans = 1
for i in range(2, 100000):
    if i > m:break
    cnt = 0
    while m % i == 0:
        cnt += 1
        m //= i
    ans = ans * comb(cnt + n - 1, cnt) % MOD
if m != 1:
    ans = ans * comb(n, 1) % MOD

print(ans)

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

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

  vector<int> a(100);
  for(int i = 0; i < m; i ++){
    cin >> a.at(i);
  }

  int count1 = 0, count2 = 0;

  for(int i = x; i <= n; i ++){
    for(int j = 0; j < m; j ++){
      if(i == a.at(j))
        count1 ++;
    }
  }
  for(int i = x; i >= 0; i --){
    for(int j = 0; j < m; j ++){
      if(i == a.at(j)) count2 ++;
    }
  }

  cout << min(count1, count2) << endl;

  return 0;
  }


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  double d, t, s, ans;
  cin >> d >> t >> s;
  ans = d / s;
  if( ans <= t ){  
    cout << "Yes" << endl; 
  }else{
    cout << "No" << endl; 
  }
  return 0;
} 

Measured memory_bytes: 3720
using System;
using System.Collections.Generic;
using System.Linq;

namespace AOJ
{
  class Problem0029
  {
    static void Main()
    {
      var dict = new Dictionary<string, int>();
      foreach (var word in Console.ReadLine().Split(' '))
      {
        if (dict.ContainsKey(word))
          ++dict[word];
        else
          dict[word] = 1;
      }
      Console.WriteLine("{0} {1}", dict.OrderByDescending(kv => kv.Value).First().Key, dict.OrderByDescending(kv => kv.Key.Length).First().Key);
    }
  }
}

Measured memory_bytes: 18564
#include <iostream>
#include <vector>
#include <math.h>
#include <algorithm>
using namespace std;
int main(void){
    long long N;
    cin >> N;
    vector<long long> L, R;
    L.resize(N+1); R.resize(N+1);
    L[0] = 0; R[0] = 0;
    for(long long i=1; i<N+1; ++i) cin >> L[i] >> R[i];
    sort(L.begin(), L.end(), greater<long long>());
    sort(R.begin(), R.end());
    long long ans = 0;
    for(long long i=0; i<N+1; ++i){
        ans += 2 * max(0LL, L[i]-R[i]);
    }
    cout << ans << endl;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define sz(c)       int(c.size())
#define rep(i,a,b)  for (int i=a; i<(b); ++i)
#define per(i,a,b)  for (int i=(b)-1; i>=(a); --i)
#define fore(c,...) for (auto __VA_ARGS__:(c))
using namespace std;
typedef long long ll;

struct DSU {
	vector<int> r;
	DSU(int n):r(n,-1) {}
	int get(int x) {
		return r[x]<0 ? x : r[x]=get(r[x]);
	}
	int size(int x) {
		return -r[get(x)];
	}
	bool join(int x,int y) {
		x=get(x);
		y=get(y);
		if (x==y) return false;
		if (r[x]>r[y]) swap(x,y);
		r[x]+=r[y];
		r[y]=x;
		return true;
	}
};

int main() {
	cin.tie(0);
	ios_base::sync_with_stdio(0);
	cout<<fixed<<setprecision(10);

	int N,M,K;
	cin>>N>>M>>K;
	vector<unordered_set<int>> adj(N);
	DSU dsu(N);
	rep(i,0,M) {
		int x,y;
		cin>>x>>y;
		x--,y--;
		dsu.join(x,y);
		adj[x].insert(y);
		adj[y].insert(x);
	}
	vector<unordered_set<int>> blk(N);
	rep(i,0,K) {
		int x,y;
		cin>>x>>y;
		x--,y--;
		blk[x].insert(y);
		blk[y].insert(x);
	}

	rep(i,0,N) {
		int c=dsu.get(i);
		int s=dsu.size(c)-1-sz(adj[i]);
		fore(blk[i],j) if (dsu.get(j)==c) s--;
		cout<<s<<" ";
	}
	cout<<'\n';
}


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

using namespace std;
#define _for(i,j,N) for(int i = (j);i < (N);i++)
#define _rep(i,j,N) for(int i = (j);i <= (N);i++)
#define _dec(i,N,j) for(int i = (N-1);i >= (j);i--)
#define _rec(i,N,j) for(int i = (N);i >=(j);i--)
#define ALL(x) x.begin(),x.end()
#define MEM(a,n) memset(a,n,sizeof(a))
#define fst first
#define scd second
#define PB push_back
#define MP make_pair

typedef long long LL;
typedef long double LD;
typedef pair<int,int> pii;
typedef pair<LL,LL> pll;

int get_int(){int x;scanf("%d",&x);return x;}
LL get_ll(){LL x;scanf("%lld",&x);return x;}
double get_db(){double x;scanf("%lf",&x);return x;}

template<typename T> int chmin(T &a,T b){if(a > b){a = b;return 1;}else return 0;}
template<typename T> int chmax(T &a,T b){if(a < b){a = b;return 1;}else return 0;}
template<typename T>
ostream& operator<<(ostream& os,const vector<T>& v) {_for(i,0,v.size()) os << v[i] << " ";return os;}
template<typename T>
ostream& operator<<(ostream& os,const set<T>& v){for(auto a:v) os << a <<" ";return os;}
template<typename T1,typename T2>
ostream& operator<<(ostream& os,const pair<T1,T2>& v){os << v.fst <<" "<<v.scd << " ";return os;}
template<typename T1,typename T2>
ostream& operator<<(ostream& os,const map<T1,T2>& v){for(auto a:v) cout << a << endl;return os;}

static const int dx[8] = { 1,  0, -1,  0,  1, -1,  1, -1};
static const int dy[8] = { 0,  1,  0, -1,  1, -1, -1,  1};
const double pi  = acos(-1.0);
const double eps = 1e-8;
const LL  INF  = 0x3f3f3f3f3f3f3f3f;
const int inf  = 0x3f3f3f3f;
const int mod = 1e9+7;


const int maxn = 1e3+5;
LD d[maxn][maxn];

struct circle{
    LL x,y,r;
    circle(LL x = 0,LL y = 0,LL r = 0):x(x),y(y),r(r){;}
    LD dis(circle & c){
        LL xx = abs(x - c.x);
        LL yy = abs(y - c.y);
        LD d = sqrtl(xx*xx + yy*yy);
        if(d <= r + c.r) return 0;
        else return d - r - c.r;
    }
};

struct HeapNode{
    int u;
    LD dis;
    bool operator<(const HeapNode &p)const{
        return dis > p.dis;
    }
};

circle cc[maxn];
int vis[maxn];
LD dd[maxn];

int N;
int main(){
    LL xs,ys,xt,yt;
    cin >> xs >> ys >> xt >> yt >> N;
    cc[0] = circle(xs,ys,0);
    cc[N+1] = circle(xt,yt,0);
    _rep(i,1,N){
        int x,y,r;
        cin >> x >> y >> r;
        cc[i] = circle(x,y,r);
    }
    _rep(i,0,N+1){
        dd[i] = 1e15;
        _rep(j,0,N+1){
            d[i][j] = cc[i].dis(cc[j]);
        }
    }
    HeapNode a{0,0};
    dd[0] = 0;
    priority_queue<HeapNode> pq;
    pq.push(a);

    while(!vis[N+1]){
        HeapNode now = pq.top();pq.pop();
        int u = now.u;
        //cout << pq.size() << endl;
        if(vis[u]) continue;
        vis[u] = 1;
        _rep(i,1,N+1){
            if(!vis[i] && dd[i] > dd[u] + d[i][u]){
                pq.push(HeapNode{i,dd[u] + d[i][u]});
                dd[i] = dd[u] + d[i][u];
                //cout << dd[i] <<endl;
            }
        }
    }
    printf("%.10Lf\n",dd[N+1]);

}

Measured memory_bytes: 26092
#include <bits/stdc++.h>
 
using namespace std;
 
template <class T>
using lim = numeric_limits<T>;
 
typedef long long ll;
typedef long double ld;
 
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	
	int n; cin >> n;
	ll a[n];
	
	int count = 0;
	ll total = 0;
	for(int i = 0; i < n; i ++){
		cin >> a[i];
		if (a[i] < 0){
			count++;
		}
		a[i] = abs(a[i]);
		total += a[i];
	}
	
	if (count%2){
		ll small = lim<ll>::max();
		for (int i = 0; i < n; i++){
			if (a[i] < small) small = a[i];
		}
		
		total -= 2*small;
	}
	
	cout << total << endl;
}


Measured memory_bytes: 1024
//#define _GLIBCXX_DEBUG
#include <cstdio>
#include <cstdint>
#define rep(i, n) for(int i=0; i<n; ++i)
using namespace std;

const unsigned int mod = 998244353;

struct mint {
  unsigned int x;
  mint():x(0) {}
  mint(int64_t x_) {
    int64_t v = int64_t(x_ % mod);
    if(v < 0) v += mod;
    x = (unsigned int)v;
  }
  static mint row(int v) {
    mint v_;
    v_.x = v;
    return v_;
  }
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) {
    uint64_t z = x;
    z *= a.x;
    x = (unsigned int)(z % mod);
    return *this;
  }
  mint operator+(const mint a) const { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= a;}
  friend bool operator==(const mint &a, const mint &b) {return a.x == b.x;}
  friend bool operator!=(const mint &a, const mint &b) {return a.x != b.x;}
  mint &operator++() {
    x++;
    if(x == mod) x = 0;
    return *this;
  }
  mint &operator--() {
    if(x == 0) x = mod;
    x--;
    return *this;
  }
  mint operator++(int) {
    mint result = *this;
    ++*this;
    return result;
  }
  mint operator--(int) {
    mint result = *this;
    --*this;
    return result;
  }
  mint pow(int64_t t) const {
    mint x_ = *this, r = 1;
    while(t) {
      if(t&1) r *= x_;
      x_ *= x_;
      t >>= 1;
    }
    return r;
  }
  //for prime mod
  mint inv() const { return pow(mod-2);}
  mint& operator/=(const mint a) { return *this *= a.inv();}
  mint operator/(const mint a) {return mint(*this) /= a;}
};

#define N 200100

//head

int n, k;
int p[N];
mint u[N], _u[N];
mint ans;
mint bit1[N], bit2[N];
void add(int i, mint x, mint *bit) {
  while(i <= n) {
    bit[i] += x;
    i += i&-i;
  }
}
mint sum(int i, mint *bit) {
  mint res;
  while(i) {
    res += bit[i];
    i &= i-1;
  }
  return res;
}

int main() {
  scanf("%d%d", &n, &k);
  rep(i, n) scanf("%d", p+i);
  const mint g = mint(k-1)/k, _g = g.inv(), gg = mint(2).inv();
  u[0] = _u[0] = 1;
  rep(i, n-1) {
    if(i < k-1) {
      u[i+1] = u[i];
      _u[i+1] = _u[i];
    }
    else {
      u[i+1] = u[i]*g;
      _u[i+1] = _u[i]*_g;
    }
  }
  rep(i, n) {
    ans += sum(p[i], bit1)*gg*u[i];
    ans -= sum(p[i], bit2)-i;
    ans -= (sum(n, bit1)-sum(p[i], bit1))*gg*u[i];
    add(p[i], _u[i], bit1);
    add(p[i], 1, bit2);
  }
  printf("%d\n", ans.x);
}

Measured memory_bytes: 5616
#include <stdio.h>

int main() {
	int N, K, Z = 1;
	scanf("%d", &N);
	scanf("%d", &K);
	for (int i = 0; i < N; i++) {
		if (Z * 2 < Z + K) {
			Z *= 2;
		} else {
			Z += K;
		}
	}
	printf ("%d", Z);
	return 0;
}

Measured memory_bytes: 1684
n = int(input())
A = list(map(int,input().split()))
S = set(A)
D = {}
for i in S:
    D[str(i)]=0
for i in range(n):
    D[str(A[i])]=D[str(A[i])]+1

ans = 0
for key in D:
    value = D[key]
    ans += value*(value-1)//2
for i in range(n):
    print(ans-   (D[str(A[i])]-1)  )

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

using ll = long long;
using ull = unsigned long long;
using st = string;
using db = double;
using vll = vector<long long>;
using vvll = vector<vll>;
using vst = vector<st>;
using vchar = vector<char>;
using pll = pair<ll, ll>;
using vpll = vector<pll>;
using vvpll = vector<vpll>;
#define rep(i, m, n) for (int i = (int)(m); i < (int)(n); i++)
#define vrep(i, vec) for(auto& i : vec)
#define vin(vec) for(auto& i : vec) cin >> i
#define all(v) v.begin(), v.end()
ll mod = 1000000007;

int main(){
  ll n, m;
  cin >> n >> m;
  vvll graph(n);
  rep(i, 0, m){
    ll a, b;
    cin >> a >> b;
    a--; b--;
    graph.at(a).push_back(b);
    graph.at(b).push_back(a);
  }
  vrep(i, graph) sort(all(i));
  vll order(n - 1);
  iota(all(order), 1);
  ll ans = 0;
  do{
    bool check = true;
    rep(i, 0, n - 2) if(find(all(graph[order[i]]), order[i + 1]) == graph[order[i]].end()) check = false;
    if(find(all(graph[0]), order[0]) == graph[0].end()) check = false;
    if(check) ans++;
  }while(next_permutation(all(order)));
  cout << ans << endl;
}

Measured memory_bytes: 256
def gcd(a,b):
    if b == 0:
        return a
    return gcd(b,a%b)

def solve(n,x):
    res = 3 * (n - gcd(n,x))
    return res



if __name__ == '__main__':
    n,x = map(int,input().split())
    print(solve(n,x))

Measured memory_bytes: 61848
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main()
{
	int n;
	cin >> n;
	
	vector<int> a(n);
	for(int i = 0; i < n; i++)
	{
		cin >> a[i];
	}
	
	sort(a.begin(), a.end(), [](const int& x, const int& y){return x > y;});
	
	int alice = 0;
	int bob = 0;
	for(int i = 0; i < n; i++)
	{
		if(i % 2 == 0)
		{
			alice += a[i];
		}
		else
		{
			bob += a[i];
		}
	}
	
	cout << alice - bob << endl;
	return 0;
}

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

typedef long long ll;
typedef vector<ll> vll;
typedef pair<ll, ll> ii;
typedef vector<vector<ll>> vvll;
typedef vector<pair<ll, ll>> vii;
typedef long double ld;
typedef vector<ld> vld;
typedef vector<vector<ld>> vvld;
typedef vector<bool> vbl;
typedef vector<vbl> mbl;
const ll MOD = 1e9 + 7;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    int k;
    cin >> k;
    string s;
    cin >> s;
    if (s.length() <= k){
        cout << s << endl;
    }
    else{
        cout << s.substr(0, k);
        cout << "...\n";
    }
    return 0;
}

Measured memory_bytes: 3656
n, y = map(int, input().split())

ans = [-1, -1, -1]
for i in range(n+1):
    for j in range(n+1):
        if i*10000 + j*5000 + (n-i-j)*1000 == y and i+j <= n :
            ans = [i, j, (n-i-j)]
            
print(ans[0], ans[1], ans[2])

Measured memory_bytes: 3064
#include<stdio.h>
int main()
{
    char x[100];
    int i=0, len=0;

    gets(x);
    while(x[i]!='\0')
    {
        i++;
        len++;
    }
    for(i=0;i<len;i++)
    {
        if(x[i]>='A'&&x[i]<='Z')
        {
            
            printf("A");
        }
         else
             printf("a");
    }

    return 0;
}



Measured memory_bytes: 1960
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <iostream>
#include <algorithm>
#include <vector>
#include <stack>
#include <deque>
#include <queue>
#include <set>
#include <map>
#include <unordered_map>
#include <bitset>
#include <string>
#define pb push_back
#define sz(V) ((int)(V).size())
#define allv(V) ((V).begin()),((V).end())
#define befv(V) ((V)[(sz(V)-2)])
#define sorv(V) sort(allv(V))
#define revv(V) reverse(allv(V))
#define univ(V) (V).erase(unique(allv(V)),(V).end())
#define clv(V) (V).clear()
#define upmin(a,b) (a)=min((a),(b))
#define upmax(a,b) (a)=max((a),(b))
#define rb(x) ((x)&(-(x)))
#define INF (1100000099)
#define INFLL (1100000000000000099ll)
#define MAXN (105)
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<int, ll> pil;
typedef pair<ll, int> pli;

int d[MAXN][MAXN*3];
int A[MAXN], B[MAXN];
int N, W, Ans;

int main() {
	scanf("%d%d", &N, &W);
	for(int i = 1; i <= N; i++) scanf("%d%d", &A[i], &B[i]);
	for(int t = 1; t <= N; t++) {
		const int w = min(300, W - A[1]*t);
		if(w < 0) break;
		for(int i = 0; i <= N; i++) fill(d[i], d[i]+MAXN*3, 0);
		for(int i = 1; i <= N; i++) for(int j = t; j; j--) for(int k = w; ~k; k--) {
			int &ret = d[j][k]; if(k < A[i]-A[1]) break;
			upmax(ret, d[j-1][k - (A[i] - A[1])] + B[i]);
		}
		for(int i = 1; i <= t; i++) for(int j = 0; j <= w; j++) upmax(Ans, d[i][j]);
	}
	printf("%d\n", Ans);
	return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vint;
typedef pair<int,int> pint;
typedef vector<pint> vpint;
#define rep(i,n) for(int i=0;i<(n);i++)
#define REP(i,n) for(int i=n-1;i>=(0);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++)
#define all(v) (v).begin(),(v).end()
#define eall(v) unique(all(v), v.end())
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
const int MOD = 1e9 + 7;
const int INF = 1e9;
const ll INFF = 1e18;


int main(void) {
	int N, A; cin >> N >> A;
	printf("%d\n", N * N - A);
	return 0;
}

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

const ll INF = 1000000000000;
ll A,B,Q;
ll s[100002],t[100002],x[100000];

int main(void){
    cin >> A >> B >> Q;
    rep(i,A)cin >> s[i+1];
    rep(i,B)cin >> t[i+1];
    rep(i,Q)cin >> x[i];
    s[0] = s[A+1] = INF;
    t[0] = t[B+1] = INF;
    
    rep(i,Q){
        ll ps = lower_bound(s+1,s+A+2,x[i]) - s;
        ll pt = lower_bound(t+1,t+B+2,x[i]) - t;
        //cout << ps << " " << pt << endl;
        ll p[4] = {s[ps-1],s[ps],t[pt-1],t[pt]};
        ll m = INF;
        m = min(abs(x[i]-p[0])+abs(p[0]-p[2]),abs(x[i]-p[0])+abs(p[0]-p[3]));
        m = min(m,min(abs(x[i]-p[1])+abs(p[1]-p[2]),abs(x[i]-p[1])+abs(p[1]-p[3])));
        m = min(m,min(abs(x[i]-p[2])+abs(p[2]-p[1]),abs(x[i]-p[2])+abs(p[2]-p[0])));
        m = min(m,min(abs(x[i]-p[3])+abs(p[3]-p[1]),abs(x[i]-p[3])+abs(p[3]-p[0])));
        cout << m << endl;
    }
}


Measured memory_bytes: 3712
from collections import Counter,defaultdict,deque
from heapq import heappop,heappush,heapify
import sys,bisect,math,itertools,fractions,pprint
sys.setrecursionlimit(10**8)
mod = 10**9+7
INF = float('inf')
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))

n = inp()
a = [inpl() for _ in range(n)]
if n == 1:
    print(1)
    quit()
c = []
for i,(x,y) in enumerate(a):
    for j,(z,w) in enumerate(a):
        if i == j: continue
        c.append(((x-z), (y-w)))
h = Counter(c)
print(n-max(h.values()))


Measured memory_bytes: 10708
#include <iostream>
#include <iomanip>
#include <vector>
#include <array>
#include <map>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <string>
#include <algorithm>
#include <limits>
#include <iterator>
#include <cmath>
#include <numeric>
#include <stack>
#include <queue>
#include <cassert>
#include <forward_list>
#include <chrono>
#include <deque>
#include <list>
#include <random>
#include <cstdio>
#include <sstream>
#include <tuple>

using namespace std;

//最大公約数
template<class T>
inline T GCD(T m, T n)
{
	T temp;
	while (m % n != 0)
	{
		temp = n;
		n = m % n;
		m = temp;
	}
	return n;
}

//最小公倍数
template<class T>
inline T LCM(T m, T n)
{
	return m * n / GCD(m, n);
}

class Node
{
public:
	vector<Node*> node;
	int sum = 0;
};

int main()
{
	int n, q;
	cin >> n >> q;
	vector<Node> all(n+1);
	//-----input-----
	for (int i = 0; i < n-1; i++)
	{
		int a, b; cin >> a >> b;
		all[a].node.push_back(&all[b]);
	}

	for (int i = 0; i < q; i++)
	{
		int p, x; cin >> p >> x;
		all[p].sum += x;
	}
	//---------------
	
	for (int i = 1; i <= n; i++)
	{
		for (auto object : all[i].node)
		{
			object->sum += all[i].sum;
		}
	}

	for (int i = 1; i <= n; i++)
	{
		cout << all[i].sum << " ";
	}
	cout << endl;

	return 0;
}

Measured memory_bytes: 14848
n=int(input())
a=list(map(int,input().split()))

for i in range(n):
	v=a[i]
	j=i-1
	while j>=0 and a[j]>v:
		a[j+1]=a[j]
		j-=1
	a[j+1]=v
	print(' '.join(list(map(str,a))))
	


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

int main(){
  	int a;
  	int b;
  	int c;
  	int x;
  	int y;
  		cin>>a;
  		cin>>b;
  		cin>>c;
  		cin>>x;
  		for(int i = 0; i<=a;i++){
          	for(int j=0;j<=b;j++){
              	for(int k=0;k<=c;k++){
                  int g;
                  g =500*i+100*j+50*k;
                  		if(g==x){
                          	++y;
                        }
                }
            }
        }
  		cout<<y<<endl;
  		return 0;
	}

Measured memory_bytes: 256
#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() {
  int A,B,C,K;
  cin >> A >> B >> C >> K;
  if(A >= K) cout << K << endl;
  else if(A+B >= K) cout << A << endl;
  else cout << A - (K-(A+B)) << endl;
  return 0;
}

Measured memory_bytes: 3652
import os
import sys

if os.getenv("LOCAL"):
    sys.stdin = open("_in.txt", "r")

sys.setrecursionlimit(2147483647)
INF = float("inf")

N = int(sys.stdin.readline())
S = list(map(int, sys.stdin.readline().split()))


def count_max(diff):
    # 左右対称に diff 間隔でとるときの最大
    b = 0
    a = N - 1
    ret = 0
    cumsum = 0
    while diff < a and a != b and b - a != diff:
        cumsum += S[b] + S[a]
        ret = max(ret, cumsum)
        b += diff
        a -= diff
    return ret


ans = 0
for diff in range(1, N // 2 + 1):
    ans = max(ans, count_max(diff))
print(ans)


Measured memory_bytes: 59120
#include<bits/stdc++.h>
using namespace std;
int n,a[200010],b[200010],ans=1e9,x,y;
string s;
int main(){
  	cin>>n>>s;
    for (int i=0;i<n;i++){
        if (i!=0) a[i]=a[i-1];
        if (s[i]=='W') a[i]++;
        if (i!=0) b[i]=b[i-1];
        if (s[i]=='R') b[i]++;
    }
    a[n]=a[n-1];b[n]=b[n-1];
    for (int i=0;i<=n;i++) ans=min(ans,max(a[i],b[n]-b[i]));
    for (int i=0;i<n;i++) if (s[i]=='W') x++;
    if (x==0||x==n){
        cout<<0<<endl;
        return 0;
    }
  	for (int i=n-x;i<n;i++) if (s[i]=='R') y++;
    cout<<min(ans,y+max(0,x-y-y))<<endl;
    return 0;
}

Measured memory_bytes: 5248
S=input()
N=len(S)
ans=0
for i in range(2**(N-1)):
  formula=S[0]
  q="{:0>10b}".format(i)[::-1]
  for j in range(1,N):
    if int(q[j-1])&1:
      formula+="+"
    formula+=S[j]
  ans+=eval(formula)    
print(ans)

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

int main(){
  int N;
  cin >> N;
  vector<int>P(N),Q(N),v(N);

  for(int i=0;i<N;i++){
    cin >> P.at(i);
    v.at(i)=i+1;
  }
  for(int i=0;i<N;i++){
    cin >> Q.at(i);
  }
  int count=1;
  int p=0;
  int q=0;

  do {
    int count_p =0;
    int count_q =0;
    for (int i=0;i<N;i++){
      if(v.at(i)==P.at(i)){
        count_p++;
      }
      if(v.at(i)==Q.at(i)){
        count_q++;
      }
    }
    if(N==count_p){
      p=count;
    }
    if(N==count_q){
      q=count;
    }
    if(p!=0 && q!=0){
      break;
    }
    count++;
  } while (next_permutation(v.begin(), v.end()));
  if(p>=q){
    cout << p-q << endl;
  }
  else{
    cout << q-p << endl;
  }
}


Measured memory_bytes: 256