akhauriyash/Code-Regression huggingface dataset:
#include "bits/stdc++.h"
using namespace std;
#define int 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(int i=0; i<(n); i++)
#define RREP(i, n) for(int i=(n-1); i>=0; i--)
#define REP1(i, n) for(int i=1; i<=(n); i++)
#define RREP1(i, n) for(int i=(n); i>=1; i--)
#define ALL(a) (a).begin(),(a).end()
#define UNIQUE_SORT(l) sort(ALL(l)); l.erase(unique(ALL(l)), l.end());
#define CONTAIN(a, b) find(ALL(a), (b)) != (a).end()
#define out(...) printf(__VA_ARGS__)
#if DEBUG
#define debug(...) printf(__VA_ARGS__)
#else
#define debug(...) /* ... */
#endif
template<class T>bool chmax(T &a,const T &b){if(a<b){a=b;return true;}return false;}
template<class T>bool chmin(T &a,const T &b){if(b<a){a=b;return true;}return false;}
void _OUT() {}; template<class H, class... T> void _OUT(H &h, T &... t) { cout<<' '<<h; _OUT(t...); };
template<class H, class... T> void _P(H &h, T &... t) { cout<<h; _OUT(t...); };
#define _PN(...) _P(__VA_ARGS__); cout << endl;
#define EXEC(...) void exec() { (__VA_ARGS__ - 1) ? multi() : solve(0); }

void exec();
void solve(int t);
void multi() { int TT; cin>>TT; REP1(t,TT) solve(t); }
signed main()
{
#if DEBUG
    std::ifstream in("input.txt");
    std::cin.rdbuf(in.rdbuf());
#endif
    cin.tie(0);
    ios::sync_with_stdio(false);
    exec();
    return 0;
}

/*================================*/
#if DEBUG
#define SIZE 100
#else
#define SIZE 223450
#endif

int N,M;
string S;
void solve(int _t) {
    cin>>N>>S;
    int R=0,W=0;
    REP(i,N) {
        if (S[i]=='W') W++;
        else R++;
    }
    // Rの位置が切れ目
    int RW=0,RR=0;
    REP(i,R) {
        if (S[i]=='W') RW++;
    }
    FOR(i,R,N) {
        if (S[i]=='R') RR++;
    }
    _PN(RW);
}
EXEC(1)



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

int main(){
	int A, B, C, f = 0, temp[11] = {};
	
	cin>>A>>B>>C;
	temp[A]++,temp[B]++,temp[C]++;
	
	if(temp[7] == 1 && temp[5] == 2) f = 1;
	
	cout<<(f?"YES":"NO")<<endl;

  return 0;
}

Measured memory_bytes: 256
#define SUBMIT

#include <bits/stdc++.h>

using namespace std;

int main() {
#ifdef SUBMIT
    auto& in = cin;
#else
    stringstream in(R"(77 42 36
)");
#endif
    int A, B, C;
    in >> A >> B >> C;
    int k = 1;
    while (k * A < A * B) {
        if ((k * A) % B == C) {
            cout << "YES" << endl;
            exit(0);
        }
        k++;
    }
    cout << "NO" << endl;
    return 0;
}

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

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

const ll MOD = 1e9 + 7;
const ll inf = 1LL<<60;
const double eps = 1e-9;

const int dx[4] = { 1, 0, -1, 0 };
const int dy[4] = { 0, 1, 0, -1 };
 
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int main()
{
    string s, t;
    cin >> s >> t;
    vector <char> a, b;

    for (int i = 0; i < s.size(); i++) {
        a.push_back(s[i]);
    }
    for (int i = 0; i < t.size(); i++) {
        b.push_back(t[i]);
    }
    
    sort(a.begin(), a.end());
    sort(b.begin(), b.end(), greater<int>());

    s = "";
    t = "";

    for (int i = 0; i < a.size(); i++) {
        s += a[i];
    }
    for (int i = 0; i < b.size(); i++) {
        t += b[i];
    }
    //cout << s << " " << t << endl;

    if (s < t) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}



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

typedef long long ll;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<ll> vl;
const ll MOD = round(1e9+7);

int main() {
    ll N; cin >> N;
    string ans;
    ll m = 0;
    ll tmp = N;
    ll tmp2 = 26;
    ll cnt = 0;
    while(tmp > 0){
        N = tmp;
        tmp -= tmp2;
        tmp2 *= 26;
        cnt++;
    }
    rep(i,cnt) ans += 'a';
	N--;
    rep(i,cnt){
        ll tmp3 = N%26;
        ans[cnt-1-i] = ('a' + tmp3);
        N /= 26;
    }
    
    

    //reverse(ans.begin(), ans.end());
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3636
#include <iostream>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>

using namespace std;
#define ll long long

int main(){
  int N;
  cin >> N;
  int C[N], S[N], F[N];
  for(int i=1; i<N; i++)
    cin >> C[i] >> S[i] >> F[i];
  for(int i=1; i<=N; i++){
    if(i == N)
      cout << 0 << endl;
    else{
      int time = S[i];
      for(int j=i; j<N; j++){
        time = ceil(max(0, (time - S[j])) / (double)F[j]) * F[j] + S[j] + C[j];
      }
      cout << time << endl;
    }
  }
  return 0;
}


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

int main() {
  int n;
  ll k;
  cin >> n >> k;
  int a[n + 1];
  rep(i, n) cin >> a[i + 1];
  ll c[n + 1];
  rep(i, n) cin >> c[i + 1];
  ll anss= -1e18;

  rep(ddd, n) {
    ll point= 0, point2= 0;
    ll count2= 0;
    int r= ddd + 1; //現在地

    while(1) {
      count2++;
      r= a[r];
      point2+= c[r];
      if(ddd + 1 == r) break;
    }

    r= ddd + 1;

    rep(i, count2) {
      r= a[r];
      point+= c[r];
      if(i+1>k)break;
      if(point2>0){
      ll q= (k - i - 1) / count2;
      chmax(anss, point + point2 * q);}
      chmax(anss,point);
    }
  }
  cout << anss << endl;
}

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

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

    vector<string> vs;
    int n, m;
    cin >> n >> m;
    for(int i=0; i<n; i++){
        string s;
        cin >> s;
        vs.push_back(s);
    }
    sort(vs.begin(), vs.end());
    string res;
    for(string &cur:vs)
        res += cur;
    cout << res << endl;
    return 0;
}


Measured memory_bytes: 256
#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;

bool isGumoji (string s) {
	int n = s.size();
	bool res = true;
	rep(i, n/2) {
		if(s[i] != s[i+n/2]) res = false;
	}
	return res;
}

int main() {
	string s;
	cin >> s;
	int ans = 0;
	int n = s.size();
	for(int i = n-1; i > 0; i--) {
		if( isGumoji(s.substr(0, i)) ) {
			ans = i-1;
			break;
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int n,a[100005],cnt;

bool check(int x) {
    if (x == 1) return false;
    for(int i = 2; i <= (int)sqrt(x); i++)
        if (x%i == 0)
            return false;
    return true;
}
int main() {
    cnt = 0;
    cin >> n;
    for(int i = 0; i < n; i++) cin >> a[i];
    for(int i = 0; i < n; i++) {
        if (check(a[i])) cnt++;
    }
    cout << cnt << '\n';
}



Measured memory_bytes: 3108
#include<bits/stdc++.h>
#define f(a,j,k) for(int i = a ; i < j ; i += k)
#define f1(a,j,k) for(int i = a ; i > j ; i -= k)
using namespace std;
typedef long long ll;
typedef vector<long long> vl;
typedef vector<int> vi;
typedef pair<int,int> pri;
typedef pair<long long,long long> prl;
int flag[1000001] = {0};
ll num[1000001];
vector<prl> getfactors(ll x){
	vector<prl> ans;
	int sqr = sqrt(x);
	f(1,sqr+1,1) if(x%i==0) ans.push_back({i,x/i});
	return ans;
}
int main() {
	std::ios::sync_with_stdio(false);
  ll x , k;
	cin >> x >> k;
	if(x <= k) cout << min(x,k-x) << endl;
	else{
		ll ans = (x - k) % k;
		cout << min(ans,k-ans) << endl;
	}

	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(){
	char c[2][3];
	for (int i=0;i<2;i++) for (int j=0;j<3;j++) scanf(" %c",&c[i][j]);
	for (int i=0;i<3;i++){
		if (c[0][i]!=c[1][2-i]){
			printf("NO\n");
			return 0;
		}
	}
	printf("YES\n");
	return 0;
}

Measured memory_bytes: 128
import java.util.ArrayList;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int x = sc.nextInt();
        int n = sc.nextInt();
        ArrayList<Integer> list = new ArrayList<>();
        for (int i = 0; i < n; i++) {
            list.add(sc.nextInt());
        }
        if(x == 0) {
            System.out.println(x);
            return;
        }
        int min = Integer.MAX_VALUE;
        int ans1 = 0;
        for (int i = -101; i <= 101; i++) {
            if(!list.contains(i)) {
                if(min > Math.abs(i - x)) {
                    min = Math.abs(i - x);
                    ans1 = i;
                }
            }
        }
        int ans2 = 0;
        min = Integer.MAX_VALUE;
        for (int i = 101; i >= -101; i--) {
            if(!list.contains(i)) {
                if(min > Math.abs(i - x)) {
                    min = Math.abs(i - x);
                    ans2 = i;
                }
            }
        }
        System.out.println(Math.min(ans1, ans2));
    }
}

Measured memory_bytes: 35936
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define fip ios_base::sync_with_stdio(false); cin.tie(NULL) 
#define reptUsual(b) for(i=0; i<b; ++i)
#define reptArIn(i,a,b,ar) for( i=a; i<b; ++i) cin>>ar[i];
#define rept(i,a,b) for(i=a; i<b; ++i)
#define all(a)  a.begin(), a.end()
#define maX(a,b)    ( (a) > (b) ? (a) : (b))
#define miN(a,b)    ( (a) < (b) ? (a) : (b))
#define sz(a) ((int)(a.size()))
#define pb(a) push_back(a)
#define ins(a) insert(a)
#define mp make_pair
#define newln cout<<"\n";
#define bigPrime 1000000007
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef pair<int,int> pii;
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
using namespace __gnu_pbds; 
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>  new_data_set;  

int main()
{  
    fip;
    int i;
    string s;
    cin>>s;
    set <char> st;
    reptUsual(4)
    {
        st.insert(s[i]);
    }
    if(sz(st)==2)
        cout<<"Yes\n";
    else
        cout<<"No\n";
    
    return 0;
    
}

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

#define REP(i,n) for(int i=0;i<(n);++i)
#define ll long long
const long long INF = 1LL<<60;
const long long mod = 1e9 + 7;

int main(){
    int N;
    cin >> N;
    for(int i = 1; i < 10; ++i){
        int a = 100 * i + 10 * i + i;
        if(N > a) continue;
        else{
            cout << a << endl;
            break;
        }
    }
    return 0;
}

Measured memory_bytes: 256
import { readFileSync } from "fs";

const read = () =>
  readFileSync(0, "utf8")
    .split("\n")
    .map((line) => line.split(" "));

const main = (input: string[][]) => {
  const X = BigInt(input[0][0]);

  let deposit = 100n;
  let years = 0;

  while (true) {
    deposit += deposit / 100n;
    years += 1;

    if (deposit >= X) {
      return years;
    }
  }
};

console.log(main(read()));


Measured memory_bytes: 29788
n,m=list(map(int,input().split()))
h=list(map(int,input().split()))
b=[[]for i in range(n)]
for i in range(m):
  a=list(map(lambda x:int(x)-1,input().split()))
  b[a[0]].append(a[1])
  b[a[1]].append(a[0])
s=0
for i in range(n):
  f=1
  for j in b[i]:
    if h[i]<=h[j]:
      f=0
      break
  if f:
    s+=1
print(s)

Measured memory_bytes: 29436
#include<iostream>
#include<algorithm>
#include<iomanip>
#include<limits>
#include<deque>
#include<string>
#include<map>
#include<set>
#include <unordered_set>
#include<vector>
#include<cmath>

using namespace std;

int main(){
	int n; cin >> n;
	long long int G = 1;
	long long int sum[1000] = {};
	int i;


	while (n > 1) {
		int N = n;
		while (N > 1) {
			for (i = 2; i <= ceil(sqrt(N)); i++) {
				while (N%i == 0) { sum[i] ++; N = N / i; }
			}
			if (i == ceil(sqrt(N)) + 1) { sum[N]++; N = 0; }
		}
		n--;
	}

	for (i = 1; i < 1000; i++) {
		if (sum[i] > 0) { G = (G*(sum[i] + 1)) % 1000000007; }
	}

	cout << G << endl;

	return 0;
}

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

using namespace std;

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



signed main(){

	int T, X;
	cin >> T >> X;

	cout << (double)T / X << endl;

	return 0;
}

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

int main() {
    int N;
    cin >> N;

    int a;
    int count = 0;
    for (int i = 1; i <= N; i++) {
        cin >> a;
        if (i % 2 != 0 && a % 2 != 0)
            count++;
    }
    cout << count << endl;
}

Measured memory_bytes: 3620
#include <bits/stdc++.h>
#pragma GCC optimize("O3")

#define fi first
#define se second
#define em emplace
#define eb emplace_back
#define mp make_pair
#define pi pair<int,int>
#define vi vector<int>
#define vpi vector<pair<int,int>>
#define vll vector<ll>
#define vpll vector<pair<ll,ll>>
#define endl '\n'

#define si(v) int((v).size())
#define all(v) (v).begin(), (v).end()
#define rep(i, n) for (ll i = 0; i < (ll)(n); ++i) 
#define rep2(i, n, m) for (ll i = n; i <= (ll)(m); ++i)
#define rep3(i, n, m) for (ll i = n; i >= (ll)(m); --i)

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

using ll = long long;
using ld = long double;
using namespace std;

constexpr ll MOD = 1000000007;

int mat[600][600];

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

  int n, m, q; cin >> n >> m >> q;
  rep(i, m) {
    int l, r; cin >> l >> r;
    ++mat[r][l];
  }

  rep(i, n+1) rep(j, n+1) mat[i][j+1] += mat[i][j];

  rep(i, q) {
    int l, r; cin >> l >> r;
    int ans = 0;
    rep(i, r+1) ans += mat[i][n] - mat[i][l-1];
    cout << ans << endl;
  }

  return (0);
}


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

using namespace std;
using ll = long long;
using P = pair<int,int>;
using Pl = pair<ll,ll>;
#define REP(i,n) for(ll i = 0;i < (ll)n;i++)
#define REPD(i,n) for(ll i = (ll)n - 1;i >= 0;i--)
#define ALL(x) (x).begin(),(x).end()
#define FILLl(n,first_dimension_size,value) fill((ll*)n,(ll*)(n+first_dimension_size),value)
#define FILL(n,first_dimension_size,value) fill((int*)n,(int*)(n+first_dimension_size),value)
#define INF (1 << 29)
#define MOD 1000000007
//int dx[4] = {1,0,0,-1};
//int dy[4] = {0,1,-1,0};


int main(){

  
  string s;
  cin >> s;
  string t = "";
  REP(i,s.size())if(!(i & 1))t += s[i];
  cout << t << endl;


  return 0;
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
#define endl "\n"
#define FIO ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define ll long long
#define vi vector<ll>
#define pb push_back
#define F first
#define S second
#define all(v) (v).begin(),(v).end()
#define pii pair<ll,ll>
#define vii vector<pii>
#define MOD 1000000007LL
#define mod2 10000007LL
#define calc_fact(n) tgamma(n+1)


signed main()
{
    FIO;
    ll t;
    cin>>t;
    vi v(4,0);
    while(t--)
    {
        string s;
        cin>>s;
        if(s=="AC")
        v[0]++;
        else if(s=="WA")
        v[1]++;
        else if(s=="TLE")
        v[2]++;
        else
        v[3]++;
    }
    for(ll i=0;i<v.size();i++)
    {
        if(i==0)
        cout<<"AC x ";
        else if(i==1)
        cout<<"WA x ";
        else if(i==2)
        cout<<"TLE x ";
        else
        cout<<"RE x ";
        cout<<v[i]<<endl;
    }
}

Measured memory_bytes: 3644
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
using namespace std;
using ll = long long;
#define rep(i, j, n) for(int i = (j); i < (n); ++i)
#define rrep(i, j, n) for(int i = (n) - 1; (j) <= i; --i)


constexpr ll MOD = 1000000007;
constexpr ll INF = 1LL << 60;


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

	int n; cin >> n;
	cout << (n + 999) / 1000 * 1000 - n;
	return 0;
}

Measured memory_bytes: 3644
#include<bits/stdc++.h>
using namespace std;
int main(){
 string str;
  cin>>str;
  int ans=0;
  for(int i=0;i<str.size();i++){
    if(str.at(i)=='1'){
      ans++;
    }
  }
  cout<<ans<<endl;
 return 0;
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.Random;
import java.util.StringTokenizer;

/*
1
4
0011
 */
public class Main{

    public static void main(String[] args) {
        FastScanner fs=new FastScanner();
        int T=fs.nextInt();
        long D=fs.nextLong();
        int ans=0;
//        PrintWriter out=new PrintWriter(System.out);
        for (int tt=0; tt<T; tt++) {
            //solve
            long x=fs.nextLong();
            long y=fs.nextLong();
            long distance=x*x+y*y;
            if(distance<=D*D){
                ans++;
            }
        }
        System.out.println(ans);


    }

    static final Random random=new Random();

    static void ruffleSort(int[] a) {
        int n=a.length;//shuffle, then sort
        for (int i=0; i<n; i++) {
            int oi=random.nextInt(n), temp=a[oi];
            a[oi]=a[i]; a[i]=temp;
        }
        Arrays.sort(a);
    }

    static class FastScanner {
        BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
        StringTokenizer st=new StringTokenizer("");
        String next() {
            while (!st.hasMoreTokens())
                try {
                    st=new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            return st.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }
        int[] nextArray(int n) {
            int[] a=new int[n];
            for (int i=0; i<n; i++) a[i]=nextInt();
            return a;
        }
        long nextLong() {
            return Long.parseLong(next());
        }
    }


}

Measured memory_bytes: 55532
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,a) for(int i=0;i<(a);i++)
const ll MOD=1000000007;
//const ll MOD=998244353;

int main(){
  int N,K; cin>>N>>K;
  ll R,S,P; cin>>R>>S>>P;
  string T; cin>>T;
  int tt=T.length();
  ll ans=0;
  for(int i=0;i<K;i++){
    if(i>=tt) break;
    ll to[3]={},from[3]={};
    for(int j=0;i+j<tt;j+=K){
      for(int k=0;k<3;k++){
        to[k]=max(from[(k+1)%3],from[(k+2)%3]);
        if(T[i+j]=='r'&&k==2) to[k]+=P;
        if(T[i+j]=='s'&&k==0) to[k]+=R;
        if(T[i+j]=='p'&&k==1) to[k]+=S;
      }
      swap(to,from);
    }
    ans+=max({from[0],from[1],from[2]});
  }
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 512
#include <iostream>//cin/cout/wcin/wcout/left/right/internal/dec/hex/oct/fixed/scientific
#include <string>//stoi/stol/stoul/stoll/stoull/stof/stod/stold/to_string/getline

using namespace std;

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

    a = (a+11)%13;
    b = (b+11)%13;

    if (a  > b) { cout << "Alice\n"; }
    if (a  < b) { cout << "Bob\n"; }
    if (a == b) { cout << "Draw\n"; }

    return 0;
}


Measured memory_bytes: 256
from collections import defaultdict,deque
import sys,heapq,bisect,math,itertools,string,queue,datetime
sys.setrecursionlimit(10**8)
INF = float('inf')
mod = 10**9+7
eps = 10**-7
def inp(): return int(input())
def inpl(): return list(map(int, input().split()))
def inpls(): return list(input().split())

L = int(input())
N = L.bit_length()

Lines = []
for i in range(1,N):
	Lines.append([i,i+1,0])
	Lines.append([i,i+1,1<<(N-i-1)])

tmp = 1<<(N-1)
for k in reversed(range(N-1)):
	if L>>k & 1:
		Lines.append([1,N-k,tmp])
		tmp += 1<<k

print(N,len(Lines))
for a,zu,nyan in Lines:
	print(a,zu,nyan)


Measured memory_bytes: 4452
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp>
// using namespace __gnu_pbds;
// gp_hash_table<int, int> mapka;

using namespace std;
#define PB push_back
#define MP make_pair
#define LL long long
#define int LL
#define FOR(i,a,b) for(int i = (a); i <= (b); i++)
#define RE(i,n) FOR(i,1,n)
#define REP(i,n) FOR(i,0,(int)(n)-1)
#define R(i,n) REP(i,n)
#define VI vector<int>
#define PII pair<int,int>
#define LD long double
#define FI first
#define SE second
#define st FI
#define nd SE
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size())

template<class C> void mini(C &a4, C b4) { a4 = min(a4, b4); }
template<class C> void maxi(C &a4, C b4) { a4 = max(a4, b4); }

template<class TH> void _dbg(const char *sdbg, TH h){ cerr<<sdbg<<'='<<h<<endl; }
template<class TH, class... TA> void _dbg(const char *sdbg, TH h, TA... a) {
  while(*sdbg!=',')cerr<<*sdbg++;
  cerr<<'='<<h<<','; _dbg(sdbg+1, a...);
}

template<class T> ostream &operator<<(ostream& os, vector<T> V) {
  os << "["; for (auto vv : V) os << vv << ","; return os << "]";
}
template<class L, class R> ostream &operator<<(ostream &os, pair<L,R> P) {
  return os << "(" << P.st << "," << P.nd << ")";
}

#ifdef LOCAL
#define debug(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
#else
#define debug(...) (__VA_ARGS__)
#define cerr if(0)cout
#endif

const int P = 998244353;
const int MAX = 401;

int mul(int a,int b){
  return a * b % P;
}

void add(int &a,int b){
  a += b;
  if(a >= P)
    a -= P;
}
void sub(int &a,int b){
  a -= b;
  if(a < 0)
    a += P;
}

int pot(int a,int w){
  int r = 1;
  while(w){
    if(w&1)
      r = r * a % P;
    w/=2;
    a = a * a % P;
  }
  return r;
}

int n;
int sil[MAX];
int odw[MAX];

int32_t main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout << fixed << setprecision(11);
  cerr << fixed << setprecision(6);
  sil[0] = 1;
  R(i,MAX-1){
    sil[i+1] = mul(sil[i], i+1);
  }
  R(i,MAX){
    odw[i] = pot(sil[i], P-2);
  }
  cin >> n;
  vector<vector<int>> dp(MAX,vector<int>(MAX));
  dp[0][0] = P - 1;
  int alla = 0;
  R(i,n){
    int a,b;
    cin >> a >> b;
    alla += a;
    vector<vector<int>> ak = dp;
    int mn = 1;
    R(j,b){
      R(aa,MAX)R(jj,MAX)if(dp[aa][jj]){
        sub(ak[aa + a][jj + j], mul(dp[aa][jj], mul(mn, odw[j])));
      }
      mn = mul(a,mn);
    }
    swap(ak, dp);
  }
  int res = 0;
  R(aa,MAX)R(jj,MAX)if(dp[aa][jj]){
    debug(aa,jj,dp[aa][jj],mul(mul(dp[aa][jj],sil[jj]),pot(aa, (P-2) * (jj+1))));
    
    add(res, mul(mul(dp[aa][jj],sil[jj]),pot(aa, (P-2) * (jj+1))));
  }
  debug(alla);
  cout << mul(res,alla) << "\n";
  
}


Measured memory_bytes: 2868
a, b = map(int, input().split())
s = input()

ans = True

for (i, char) in enumerate(s):
    if i == a:
        if char == '-':
            ans = True
        else:
            ans = False
            break
    else:
        try:
            ans = type(int(char)) is int
        except:
            ans = False
            break

if ans:
    print('Yes')
else:
    print('No')


Measured memory_bytes: 9092
#include <bits/stdc++.h>
#define REP(i, n) for (int i=0, i##_lim=(n); i<i##_lim; ++i)
#define FOR(i, a, b) for (int i=(a), i##_lim=(b); i<i##_lim; ++i)
#define mp make_pair
#define pb push_back
using namespace std;
using ll = long long;
using pi = pair<int, int>;

int main()
{
    int N;
    cin >> N;
    string S[N];
    REP(i, N) cin >> S[i];

    int ret = 0;
    REP(i, N)
    {
        auto ab = S[i].find("AB");
        while (ab != string::npos)
        {
            S[i].replace(ab, 2, "##");
            ab = S[i].find("AB");
            ++ret;
        }
    }

    int e = 0;
    int a = 0;
    int b = 0;
    REP(i, N)
    {
        bool is_a = S[i][S[i].length()-1] == 'A';
        bool is_b = S[i][0] == 'B';

        if (is_a && is_b) ++e;
        else if (is_a) ++a;
        else if (is_b) ++b;
    }

    if (e != 0 || a != 0 || b != 0)
        ret += min(a, b) == 0 ? e-1+min(1, max(a, b)) : e+min(a, b);
    cout << ret << endl;
    return 0;
}

Measured memory_bytes: 768
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (n);i++)
#define sz(x) int(x.size())
typedef long long ll;
typedef pair<int,int> P;
using Graph = vector<vector<P>>;
const ll INF = 1e18;
int main(){
  int n, m;
  cin >> n >> m;
  Graph G(n);
  /*コスト０の逆辺 */
  for (int i = n-1; i > 0; i--) {
    G[i].push_back({0,i-1});
  }
  rep(i,m) {
    int l, r, c;
    cin >> l >> r >> c;
    l--; r--;
    G[l].push_back({c,r});
  }

  auto dijkstra = [&] {
    priority_queue<pair<ll,int>,vector<pair<ll,int>>, greater<pair<ll,int>>> que;
    vector<ll> d(n,INF);
    d[0] = 0;
    que.push({0,0});
    while (!que.empty()) {
      auto p = que.top();
      que.pop();
      if (d[p.second] < p.first) continue;
      for (auto v : G[p.second]) {
        if (d[v.second] <= d[p.second] + v.first) continue;
        que.push({d[p.second] + v.first, v.second});
        d[v.second] = d[p.second] + v.first;
      }
    }
    return d[n-1];
  };
  ll res = dijkstra();
  cout << (res == INF ? -1 : res) << endl;
  return 0;
} 

Measured memory_bytes: 8440
ABC=parse.(Int,split(readline()))
K=parse(Int,readline())
function solve(a,b,c,k)
    for i=1:k
        if a>=b
            b=2*b
        elseif b>=c
            c=2*c
        end
    end
    if a<b & b<c
        print("Yes")
    else
        print("No")
        end
    end
solve(ABC[1],ABC[2],ABC[3],K)

Measured memory_bytes: 171064
#include<bits/stdc++.h>
#define For(a,b,c) for(int a=b;a<=c;++a)
#define Dor(a,b,c) for(int a=b;a>=c;--a)
using namespace std;
const int N=100007;
char S[N]; 
int main() {
	int n;
	scanf("%d%s",&n,S+1);
	printf("%d",unique(S+1,S+1+n)-S-1);
	return 0;
}

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

template<typename T>
struct DiameterForEdge{
  using Edge = pair<int, T>;
  vector<T> dp;
  vector<vector<Edge> > G;
  DiameterForEdge(int n):dp(n),G(n){}
  void add_edge(int u,int v,T c){
    G[u].emplace_back(v,c);
    G[v].emplace_back(u,c);
  }
  void dfs(int v,int p,int &s){
    if(p<0) dp[v]=T(0);
    if(dp[s]<dp[v]) s=v; 
    for(Edge e:G[v]){
      int u=e.first;
      if(u==p) continue;
      dp[u]=dp[v]+e.second;      
      dfs(u,v,s);
    }
  }
  pair<int, int> endPoints(){
    int s=0;
    dfs(s,-1,s);
    int t=s;
    dfs(t,-1,t);
    return make_pair(s,t);
  }
  T build(){
    int t=endPoints().second;
    return dp[t];
  }
  vector<T> distance(int v){
    dfs(v,-1,v);
    return dp;
  }
  vector<T> farthest(){
    int t=endPoints().second;
    auto ds=dp;
    auto dt=distance(t);
    for(int i=0;i<(int)ds.size();i++)
      if(ds[i]<dt[i]) ds[i]=dt[i];
    return ds;
  }
};

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

  int n;
  while ( cin >> n, n ) {
    DiameterForEdge<int> tree(n);    
    const int INF = 1e9;

    vector<int> p(n-1);
    for ( int &e: p ) cin >> e;

    vector<int> deg(n, 0);
    vector<int> C(n, 0);
    int sum = 0;
    vector<int> c(n);    
    for ( int i = 0; i < n-1; i++ ) {
      cin >> c[i];      
      sum += c[i];
      p[i]--;      
      deg[i+1]++;
      deg[p[i]]++;
      C[i+1] = C[p[i]] = c[i];      
    }

    for ( int i = 0; i < n-1; i++ ) {
      if ( deg[i+1] > 1 && deg[p[i]] > 1 ) {
	tree.add_edge(i+1, p[i], c[i]);	
      } else {
	tree.add_edge(i+1, p[i], 0);	
      }
    }

    int leaf = 0;
    for ( int i = 0; i < n; i++ ) {
      if ( deg[i] == 1 ) leaf += C[i];
    }

    int d = tree.build();

    cout << leaf + d*2 + (sum-leaf-d)*3 << endl;    
  }
  
  return 0;
}



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

//const long double PIL = 3.141592653589793238462643383279502884L;
//const double PI = 3.14159265358979323846;

#define sz(a) int((a).size())
#define all(c) (c).begin(), (c).end()
#define what_is(x) cerr << #x << " is " << x << endl;

using ll = long long;
using ii = pair<int,int>;
using vi = vector<int>;
using vll = vector<long long>;
using vii = vector<pair<int,int>>;

int main() {
	//~ ios::sync_with_stdio(0);
	//~ cin.tie(0);
	int k;
	cin >> k;
	int x = k / 2;
	int y = k - x;
	int answer = x * y;
	cout << answer << endl;
}


Measured memory_bytes: 256
#include <set>
#include <map>
#include <list>
#include <queue>
#include <stack>
#include <cmath>
#include <ctime>
#include <cstdio>
#include <vector>
#include <string>
#include <bitset>
#include <cctype>
#include <cstdlib>
#include <cstring>
#include <utility>
#include <numeric>
#include <complex>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <cassert>
#include <iostream>
#include <iterator>
#include <algorithm>
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
typedef vector<int> vint;
typedef pair<int, int> pint;
#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for(int i = x; i < n; i++)
template<class T, class C> void chmax(T& a, C b){ a>b?:a=b; }
template<class T, class C> void chmin(T& a, C b){ a<b?:a=b; }
int main(int argc, char* argv[]) {
   int n;
   int h[100];
   int ans=0;
   int flag;
   cin >> n;
   rep(i,n){
       cin >> h[i];
   }
   for(int i = 1; i < n; i++){
       flag = 1;
       for(int j = 0; j<i; j++ ){
        if(h[i]<h[j]){
            flag = 0;
            }
       }
   if (flag)ans++;
   }

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


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <math.h>
#include <algorithm>
#include <map>
using namespace std;

int main() {
	double* v, sum = 0;
	int N;

	cin >> N;
	v = new double[N];

	for (int i = 0; i < N; i++) {
		cin >> v[i];
	}

	sort(v, v + N, less<double>());

	sum = v[0];

	for (int i = 1; i < N; i++) {
		sum = (v[i] + sum) / 2;
	}

	cout << sum;

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1e9;
const ll mod = 1e9 + 7;
const int dx[] = {1, 0, -1, 0}, dy[] = {0, 1, 0, -1};

int main() {
  ll n;
  cin >> n;
  ll ans = 0;
  vector<ll> sum(n+1);

  int cnt = 1;

  for (ll i = 1; i <= n; i++) {
      for (ll j = cnt; j <= n; j += cnt) {
          sum[j]++;
      }
      cnt++;
  }

  for (ll i = 1; i <= n; i++) {
      ans += sum[i] * i;
  }

  cout << ans << endl;
}



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

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<char, ll> pcl;

#define m0(x) memset(x, 0, sizeof(x))
#define all(x) x.begin(), x.end()
#define rep(i, n) for(int i = 0; i < (n); i++)
#define asort(x) sort(all(x));
#define dsort(x, t) sort(x.begin(), x.end(), greater<t>());
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end());
#define MINS(m, s) m.insert(mp(s, 1));
#define MFIN(m, s) m.find(s) != m.end()
#define mp make_pair
#define pb push_back
#define INF (1 << 29)
const int mod = 1000000007;

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

    vi c(n);
    int a[12][12];
    int ans = INF;
    rep(i, n) {
        cin >> c[i];
        rep(j, m) cin >> a[i][j];
    }

    rep(bit, 1 << n) {
        int cost = 0;
        vi alg(m);
        rep(i, n) {
            if(bit & (1 << i)) {
                cost += c[i];
                rep(j, m) alg[j] += a[i][j];
            }
        }
        bool ok = true;
        rep(j, m) {
            if(alg[j] < x)
                ok = false;
        }
        if(ok) {
            ans = min(ans, cost);
        }
    }

    if(ans == INF) {
        cout << "-1" << endl;
    } else {
        cout << ans << endl;
    }

    return 0;
}

Measured memory_bytes: 3580
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
 
int main() {
 
  int A, B, C; cin >> A >> B >> C;
  
  bool can = 0;
  for(int i = 0; i < B; i++){
    if((i * A) % B == C) can = 1;
  }

  if(can) cout << "YES" << endl;
  else cout << "NO" << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main{
    public static void main(String[] args){
        int sum=0,i=0,j;
        String t;
        Scanner s = new Scanner(System.in);
        while(true){
            t = s.next();
            if(t.charAt(0) =='0'&&t.length()==1)break;
            for(i=0;i<t.length();i++){
                sum+=t.charAt(i)-'0';
            }
            System.out.println(sum);
            sum = 0;
        }
    }
}


Measured memory_bytes: 26384
#include<iostream>
#include<string>
using namespace std;
 
int main() {
	string buff;
	getline(cin, buff);
	int win = 0;
	for (int i = 0; i < buff.length(); ++i) {
		if (buff[i] == 'o') {
			++win;
		}
	}
	cout << (win + (15 - buff.length()) >= 8 ? "YES" : "NO") << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int N,r;
    cin>>N;
    cout<<endl;
    r=N%1000;
    if(r==0)
    {
        cout<<"0";
    }
    else
    {
        cout<<1000-r;
    }
    return 0;
}


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

int main(void) {
	string data;
	int company1[1000 + 1] = {};
	int company2[1000 + 1] = {};
	int c;
	int x;
	int p;
	
	while(getline(cin, data)) {
		if(data == "")   break;
		p = data.find(',');
		c = 0;
		x = 1;
		for(int i = p - 1; i >= 0; --i) {
			c += (data[i] - '0') * x;
			x *= 10;
		}
		++company1[c];
	}
	
	while(getline(cin, data)) {
		if(data == "")   break;
		p = data.find(',');
		c = 0;
		x = 1;
		for(int i = p - 1; i >= 0; --i) {
			c += (data[i] - '0') * x;
			x *= 10;
		}
		++company2[c];
	}
	
	for(int i = 0; i <= 1000; ++i) {
		if(company1[i] > 0 && company2[i] > 0) {
			cout << i << ' ' << company1[i] + company2[i] << endl;
		}
	}
	
	return 0;
}


Measured memory_bytes: 2996
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Scanner;
 

//result = Math.pow(num1, num3)
//StringBuffer str = new StringBuffer(hoge1);
//String hoge2 = str.reverse().toString();
//map.containsKey(A)

//Map<String, Integer> map = new HashMap<String, Integer>(n);
/*for ( キーのデータ型 key : マップの名前.keySet() ) {
	データのデータ型 data = マップの名前.get( key );
	
	// keyやdataを使った処理;
}*/
//int i = Integer.parseInt(s);

//ArrayList<String> cc = new ArrayList<>(n);
//Collections.sort(list);
//Array.sort(list);
//Arrays.asList(c).contains("a")
//list.set(1,"walk");
public class Main {
	private static Scanner sc = new Scanner(System.in);
	static void p(String ans) {System.out.println(ans);};
	static void p(int ans) {System.out.println(ans);};
	static void p(long ans) {System.out.println(ans);};
	static void p(double ans) {System.out.println(ans);};
	static String s;
	public static void main(String[] args) {
		String S=sc.next();
		
		if(S.charAt(0)==S.charAt(1)&&S.charAt(1)==S.charAt(2)) {
			p("Yes");
		}else
		if(S.charAt(1)==S.charAt(2)&&S.charAt(2)==S.charAt(3)) {
			p("Yes");
		}else {
			p("No");
		}
	}
	
	

	
	
	
}


Measured memory_bytes: 22868
#include <bits/stdc++.h>
typedef long long LL;
#define SORT(c) sort((c).begin(),(c).end())

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

using namespace std;

struct Unionfind {
  vector<int> size;
  vector<int> par;

  Unionfind( int n ) :  size(n, 1), par(n) {
    iota( par.begin() , par.end() , 0 );
  }

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

  bool unite( int x , int y ) {
    x = find(x);
    y = find(y);
    if ( x == y ) return false;

    //if ( size[y] < size[x] ) swap( x , y );
    //y is always_parent
    par[x] = y;
    size[y] += size[x];

    return true;
  }

  bool same( int x , int y ) {
    return find(x) == find(y);
  }
};
int main(void)
{
  for(;;){
    int n,q;
    cin >> n >> q;
    if(!n&&!q) return 0;
    vector<int> p(n+1);
    p[1]=1;
    FOR(i,2,n+1) cin >> p[i];
    vector<pair<string,int> > o(q);
    REP(i,q) cin >> o[i].first >> o[i].second;
    vector<int> m(n+1,0);
    m[1]=true;
    REP(i,q) if(o[i].first=="M") ++m[o[i].second];
    Unionfind t(n+1);
    FOR(i,1,n+1) if(!m[i]) t.unite(i,p[i]);
    LL answer=0;
    for(int i=o.size()-1;i>=0;--i){
      if(o[i].first=="M"){
	if(!--m[o[i].second])t.unite(o[i].second,p[o[i].second]);
      }
      else answer+=t.find(o[i].second);
    }
    cout << answer << endl;
  }
}

Measured memory_bytes: 10692
// -*- coding:utf-8-unix -*-

use proconio::input;

fn main() {
    input! {
        k: usize,
    }

    let v = [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];
    println!("{}", v[k - 1]);
}


Measured memory_bytes: 2136
#define  _CRT_SECURE_NO_WARNINGS
#pragma comment (linker, "/STACK:526000000")

#include "bits/stdc++.h"

using namespace std;
typedef string::const_iterator State;
#define eps 1e-11L
#define MAX_MOD 1000000007LL
#define GYAKU 500000004LL

#define MOD 998244353LL
#define seg_size 262144 * 4LL
#define pb push_back
#define mp make_pair
typedef long long ll;
#define REP(a,b) for(long long (a) = 0;(a) < (b);++(a))
#define ALL(x) (x).begin(),(x).end()

void init() {
    iostream::sync_with_stdio(false);
    cout << fixed << setprecision(20);
}


//#define int ll

unsigned long xor128() {
    static unsigned long x = 123456789, y = 362436069, z = 521288629, w = 88675123;
    unsigned long t = (x ^ (x << 11));
    x = y; y = z; z = w;
    return (w = (w ^ (w >> 19)) ^ (t ^ (t >> 8)));
}

void solve() {
    int n;
    cin >> n;
    vector<complex<long double>> inputs;
    REP(i, n) {
        long double a, b;
        cin >> a >> b;
        inputs.push_back(complex<long double>{a, b});
    }
    if (n % 2 == 1) {
        cout << "NA" << endl;
        return;
    }
    complex<long double> ans = (inputs[0] + inputs[n / 2]) / 2.0L;
    REP(i, n/2) {
        complex<long double> now = (inputs[i] + inputs[n / 2 + i]) / 2.0L;
        if (abs(now - ans) > eps) {
            cout << "NA" << endl;
            return;
        }
    }
    cout << ans.real() << " " << ans.imag() << endl;
}

#undef int
int main() {
    init();
    solve();
}



Measured memory_bytes: 3380
#include <iostream>
#include <math.h>
#include <numeric>
#include <vector>
#include <map>
#include <algorithm>
#include <set>
#include <queue>
#include <tuple>
#include <functional>
#include <cstring>

#define PI 3.14159265359
#define INF 1e9
#define LINF 1e18
#define IMOD 1000000007 
#define irep(i,n) for(int  i = 0; i < n; i++)
#define irep2(i,a,n) for(int i = a; i < n; i++)
#define lrep(i,n) for(long long  i = 0; i < n; i++)
#define lrep2(i,a,n) for(long long i = a; i < n; i++)

typedef long long ll;
typedef std::vector<int> v_int;
typedef std::vector<std::vector<int> > v2_int;
typedef std::vector<ll> v_ll;
typedef std::vector<std::vector<ll> > v2_ll;
typedef std::vector<std::string> v_string;
typedef std::vector<std::vector<std::string> > v2_string;
typedef std::vector<bool> v_bool;
typedef std::vector<std::vector<bool> > v2_bool;
typedef std::pair<ll, ll> pll;

using namespace std;

int main() 
{
    int n; 
    cin >> n;
    map<int, int> A;
    ll ans = 1;

    irep(i, n) {
        int tmp;
        cin >> tmp;
        A[tmp]++;
    }

    if(n == 1) { 
        cout << 1 << endl; 
        return 0; 
    }

    if(n%2 == 0) {
        if(A[0] > 0) { 
            cout << 0;
            return 0;
        }
        for(int i = 1; i < n; i+=2) {
            if(A[i] == 2) {
                ans *= 2;
                ans %= IMOD;
            } else {
                cout << 0;
                return 0;
            }
        }
        cout << ans << endl;
    } else {
        if(A[0] > 1) { 
            cout << 0;
            return 0;
        }
        for(int i = 2; i < n; i+=2) {
            if(A[i] == 2) {
                ans *= 2;
                ans %= IMOD;
            } else {
                cout << 0;
                return 0;
            }
        }
        cout << ans << endl;
    }
    return 0;
}


Measured memory_bytes: 3200
#include<iostream>
#include<algorithm>
#include<vector>
#include<string.h>
#include<cstdlib>
#include<map>
#include<fstream>
#include<string>
#include<sstream>
#include<iomanip>
#include<cmath>
#include<random>
#include<set>
#include<queue>

using namespace std;

long long dp[3][100100] = {};
const long long INF = 1LL << 60;
#define MOD 1000000007
#define Int int64_t
#define PI 3.14159265358979
#define dump(a) cout << a << endl; 

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

/**
* @fn
* 最大値を取ります.Vector<int>を渡すこと.
*/
long long int imax(vector<int> a) {
	int MAX = -10000000;
	for (int i = 0; i < a.size(); i++) {
		if (MAX < a.at(i)) MAX = a.at(i);
	}
	return MAX;
}

/**
* @fn
* 最小値を取ります.Vector<int>を渡すこと.
*/
long long int imin(vector<int> a) {
	int MIN = 1000000000;
	for (int i = 0; i < a.size(); i++) {
		if (MIN > a.at(i)) MIN = a.at(i);
	}
	return MIN;
}

/**
* @fn
* 自然数について、桁数を求める
*/
Int getDigit(Int num) {
	return (Int)(log10(num)) + 1;
}


int get2Digit(Int num) {
	int cnt = 0;
	while (num > 0) {
		if (num % 2 != 0) {
			return cnt;
		}
		cnt++;
		num /= 2;
	}
}

long long int absmin(vector<int> a, long long int b) {
	int mini = 100000000;
	int d = 0;
	for (int i = 0; i < a.size(); i++) {
		if (mini > abs(a.at(i) - b)) {
			mini = abs(a.at(i) - b);
			d = i;
		}
	}
	return d;
}


long long int absmax(vector<int> a, long long int b) {
	int max = -100000000;
	int d = 0;
	for (int i = 0; i < a.size(); i++) {
		if (max < abs(a.at(i) - b)) {
			max = abs(a.at(i) - b);
			d = i;
		}
	}
	return d;
}

int gcd(int a, int b)
{
	if (a < b) swap(a, b);
	if (b < 1) return -1;
	if (a % b == 0) return b;
	return gcd(b, a % b);
}

void haerobatya(int start, int end, char level) {
	if (start > end) swap(start, end);
	for (int i = start; i <= end; i++) {
		if (i < 100) {
			cout << "https://atcoder.jp/contests/abc0" << i << "/tasks/abc0" << i << "_" << level << endl;
		}
		else {
			cout << "https://atcoder.jp/contests/abc" << i << "/tasks/abc" << i << "_" << level << endl;
		}
	}
}

long long int cntmod(long long int warareru, long long int mod) {
	long long int i = 0;
	for (i = 0; true; i++) {
		if (warareru % mod == 0 && warareru >= mod) {
			warareru /= mod;
		}
		else {
			return i;
		}
	}
}

void ansYes(bool a) {
	if (a == true) cout << "Yes" << endl;
	else cout << "No" << endl;
}

void ansYES(bool a) {
	if (a == true) cout << "YES" << endl;
	else cout << "NO" << endl;
}


Int euclidean_gcd(Int a, Int b) {
	while (true) {
		if (a < b) swap(a, b);
		if (!b) break;
		a %= b;
	}
	return a;
}

typedef pair<int, int> pai;


//ここまでライブラリ
//ここから本文
int main() {
	int a, b;
	char c;
	cin >> a >> c >> b;
	if (c == '+') dump(a + b);
	if (c == '-') dump(a - b);
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int a,b;
  cin >> a >> b;
  if(a == b) cout << "Draw";
  else if(a == 1) cout << "Alice";
  else if(b == 1) cout << "Bob";
  else if(a < b) cout << "Bob";
  else cout << "Alice";
  cout << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(int)(n); i++)
int main() {
  int n;
  cin>>n;
  vector<int> a(n),b(n),c(n-1);
  rep(i,n){
    cin>>a.at(i);
  }
  rep(i,n){
    cin>>b.at(i);
  }
  rep(i,n-1){
    cin>>c.at(i);
  }
  int s=0;
  rep(i,n-1){
    s+=b.at(a.at(i)-1);
    if(a.at(i+1)==a.at(i)+1){
      s+=c.at(a.at(i)-1);
    }
  }
  if(n==1){
    cout<<b.at(0);
    return 0;
  }
  else{
    s+=b.at(a.at(n-1)-1);
    cout<<s;
  }
}

Measured memory_bytes: 256
// In The Name Of Allah
// Mehrkish Makuei

#include <bits/stdc++.h>

#define pb push_back
#define debug1(x) cerr << #x << " : " << x << endl;
#define debug2(x, y ) cerr << #x << " : " << x << "  " << #y << " : " << y << endl;

using namespace std;

typedef long long ll;
typedef long double ld;
typedef string str;
typedef vector <ll> vll;
typedef set <char> sch;
typedef set <ll> sll;

const ll MOD = 1e9 + 7;
const ll MAXN = 1e3 + 19;

str s1, s2, s3;

int main(){
	ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
	cin >> s1 >> s2 >> s3;
	str ans = "";
	ans += toupper(s1[0]);
	ans += toupper(s2[0]);
	ans += toupper(s3[0]);
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#pragma GCC optimize("unroll-loops,no-stack-protector")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
 
using namespace __gnu_pbds;
using namespace std;
 
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
 
typedef long long ll;
typedef long double ld;	

ll mod = 1e9+7;

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	ll n,l;
	cin >> n >> l;
	vector <ll> pre(n);
	vector <ll> suf(n);
	pre[0] = l;
	suf[n-1] = l+n-1;
	for (int z=1;z<n;z++){
		pre[z] = pre[z-1]+l+z;
	}
	for (int z=n-2;z>-1;z--){
		suf[z] = suf[z+1]+z+l;
	}
	ll ans = pre[n-2];
	ll sum = pre[n-1];
	ll mini = abs(sum-ans);
	if (abs(suf[1]-sum) < mini){
		mini = abs(suf[1]-sum);
		ans = suf[1];
	}
	for (int z=0;z<n-2;z++){
		if (abs((pre[z]+suf[z+2])-sum) < mini){
			mini = abs((pre[z]+suf[z+2])-sum);
			ans = pre[z]+suf[z+2];
		}
	}
	cout << ans << endl;
	cin >> n;
}

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

int main(){
  int N,K;cin>>N>>K;
  int x[N+10];for(int i=0;i<N;i++){
    cin>>x[i];
  }
  int res=1000000000;
  if(K==1)res=abs(x[0]);
  else
  for(int i=K-1;i<N;i++){
    int tmp;
      if(x[i]<0&&x[i-(K-1)]<0){
        tmp=abs(x[i-(K-1)]);
      }else if(0<=x[i]&&x[i-(K-1)]<0){
        tmp=min(abs(abs(x[i])*2+abs(x[i-(K-1)])),abs(abs(x[i-(K-1)])*2+abs(x[i])));
      }else if(0<=x[i]&&0<=x[i-(K-1)]){
        tmp=abs(x[i]);
      }
      res=min(res,tmp);
  }
  cout<<res<<endl;
}


Measured memory_bytes: 640