akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<tuple>
using namespace std;
typedef long long ll;
typedef unsigned int ui;
const ll mod = 1000000007;
const ll INF = (ll)1000000007 * 1000000007;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define Per(i,sta,n) for(int i=n-1;i>=sta;i--)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef long double ld;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<ll, ll> LP;
int dx[4]={1,-1,0,0};
int dy[4]={0,0,1,-1};

int n;
ll k;
ll num=0;
int a[200010];
bool visited[200010];
vector<int> cycle={};
int ans=-1;

void dfs(int s){
    //cout << s << " " << num << endl;
    if(visited[s]){
       int now=s;
       while(cycle.empty() || now!=s){
           //cout << now << endl;
           cycle.push_back(now);
           now=a[now];
       }
       return;
    }
    visited[s]=true;
    num+=1;
    if(k==num) ans=a[s];
    dfs(a[s]);
}

void solve(){
    cin >> n >> k;
    rep(i,n){
        cin >> a[i];a[i]--;
    }
    dfs(0);
    // for(int c:cycle){
    //     cout << c << endl;
    // }
    ll siz=cycle.size();
    if(ans==-1){
        cout << cycle[(k-num)%siz]+1 << endl;
    }
    else cout << ans+1 << endl;
}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(50);
    solve();
}

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

int main()
{
    int n,m,j,k,p;
    while(~scanf("%d %d %d %d",&n,&m,&j,&k))
    {
        if(n*m>=k*j)
        {
            printf("%d\n",n*m);
        }
        else
        {
            printf("%d\n",k*j);
        }
    }
    return 0;
}


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

using namespace std;


int main(){
    
    int N;
    cin >> N;
    pair<int, int> red[N];
    pair<int, int> bleue[N];
    
    for (int i = 0; i < N; i++) {
        cin >> red[i].first >> red[i].second;
    }
    for (int i = 0; i < N; i++) {
        cin >> bleue[i].first >> bleue[i].second;
    }
    
    sort(red, red+N);
    sort(bleue, bleue+N);
    int ans = 0;
    
    for (int i = 0; i < N; i++) {
        int ix = -1;
        int iymax = -1;
        for (int j = 0; j < N; j++) {
            if (bleue[i].first > red[j].first && red[j].first != -1 && bleue[i].second > red[j].second && iymax < red[j].second) {
                    iymax = red[j].second;
                    ix = j;
            }
        }
        if (ix != -1) {
            ans += 1;
            red[ix].first = -1;
        }
    }
    
    cout << ans << endl;
    
}


Measured memory_bytes: 256
a, b = map(int, input().split())
for i in range(a + 1):
    for y in range(a - i + 1):
        if i * 10000 + y * 5000 + (a - i - y) * 1000 == b:
            print(i, y, a - i - y)
            exit()
print("-1 -1 -1")

Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int S1,S2,S3,N;
  cin >> N;
  S3=N%10;
  S2=(N-S3)%100/10;
  S1=N/100;
  cout << S1+S2+S3 << endl;
}

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

int main() {
    int n, k;
    cin >> n >> k;
    vector<int> vec(n);
    for ( int i = 0; i < n; ++i) {
        cin >> vec.at(i);
    }

    long long count1 = 0;
    for ( int i = 0; i < n; ++i) {
        for ( int j = i+1; j < n; ++j) {
            if ( vec.at(i) > vec.at(j)) {
                count1++;
            }
        }
    }

    long long count2 = 0;
    for ( int i = 0; i < n; ++i ) {
        for (int j = 0; j < n; ++j ) {
            if ( i != j && vec.at(i) > vec.at(j)) {
                count2++;
            }
        }
    }

    count2 *= k;
    count2 %= 1000000007;
    count2 *= (k-1);
    count2 %= 1000000007;
    count2 *= 500000004; // /=2
    count2 %= 1000000007;

    long long ans = count1 * k;
    ans %= 1000000007;
    ans += count2;
    ans %= 1000000007;

    cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int N = 2e5+1;
int n, q, sub[N], ans[N];
vector<int> adj[N];
void DFS(int u, int p, int cur)
{
	cur += sub[u];
	ans[u] = cur;
	for(int i=0; i<adj[u].size(); i++)
	{
		int v = adj[u][i];
		if(p != v) DFS(v, u, cur);
	}
}
int main()
{
	cin >> n >> q;
	for(int i=0, x, y; i<n-1; i++) cin >> x >> y, adj[x].push_back(y), adj[y].push_back(x);
	for(int i=0, x, y; i<q; i++) cin >> x >> y, sub[x] += y;
	DFS(1, 0, 0);
	for(int i=1; i<=n; i++) cout << ans[i] << " ";
	cout << endl;
}
	


Measured memory_bytes: 27264
#include <cstdio>
#include <algorithm>
#include <iostream>
#include <vector>
#include <map>
#include <unordered_map>
#include <cmath>

using namespace std;
typedef long long ll;
#define INF (1e9)
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define each(i, mp) for(auto i:mp)
#define FOR(i, m, n) for(int i = m;i < n;i++)

const int MAX_N = (int) 1e5;
int N, K, X[MAX_N];

void solve() {
    int ans = INF;
    rep(i, N - K + 1) {
        int small = X[i], big = X[i + K - 1];
        ans = min(ans, min(abs(small) + abs(big - small), abs(big) + abs(big - small)));
    }
    cout << ans << endl;
}

int main() {
    cin >> N >> K;
    rep(i, N) cin >> X[i];
    solve();
    return 0;
}

Measured memory_bytes: 640
#include <iostream>

using namespace std;

int main(){
    long N, K;
    long x[100000];
    long min = __LONG_MAX__;
    cin >> N >> K;
    for(int i = 0; i < N; i++){
        cin >> x[i];
    }
    for(int i = 0; i <= N-K; i++){
        long tmp;
        if(abs(x[i]) < abs(x[i+K-1])){
            tmp = abs(x[i]) + x[i+K-1] - x[i];
        }else{
            tmp = abs(x[i+K-1]) + x[i+K-1] - x[i];
        }
        if(tmp < min) min = tmp;
    }
    cout << min << endl;
}

Measured memory_bytes: 1024
#include <stdio.h>

int main(void) {
	char input[400];
	int K,U,P,C;
	int result;
	char* now;
	scanf("%s",input);
	K=U=P=C=0;
	for(now=input;*now;now++) {
		if(*now=='K')K++;
		else if(*now=='U')U++;
		else if(*now=='P')P++;
		else if(*now=='C')C++;
	}
	result=K;
	if(U<result)result=U;
	if(P<result)result=P;
	if(C<result)result=C;
	printf("%d\n",result);
	return 0;
}

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

char s[200010];

int main(){
        long long len, i;
        int sum=0;
        scanf("%s", s);
        len=strlen(s);
        for(i=0; i<len; i++){
                sum+=s[i]-'0';
        }
        if(sum%9==0){
                printf("Yes");
        }else{
                printf("No");
        }

        return 0;
}


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

int main() {
 int a;
 int b;
  cin >> a >> b;
    if(a%2==0 || b%2==0) {cout << "Even" << endl;}
  else if(a%2==1 && b%2==1)  {cout <<"Odd" << endl;}
  

}


Measured memory_bytes: 256
n = int(input())
a = [int(input()) for i in range(n)]
# print(a)
maxv = -2*10**9
minv = 10000000000
for i in range(n):
  maxv = max(maxv,a[i]-minv)
  minv = min(a[i],minv)

print(maxv)


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

using namespace std;
using ll = long long;
#define int ll
using VI = vector<int>;
using VVI = vector<VI>;
using PII = pair<int, int>;

#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
#define PB push_back

const ll LLINF = (1LL<<60);
const int INF = (1LL<<30);
const int MOD = 1000000007;

template <typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template <typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }
template <typename T> bool IN(T a, T b, T x) { return a<=x&&x<b; }
template<typename T> T ceil(T a, T b) { return a/b + !!(a%b); }
template<class S,class T>
ostream &operator <<(ostream& out,const pair<S,T>& a){
  out<<'('<<a.first<<','<<a.second<<')';
  return out;
}
template<class T>
ostream &operator <<(ostream& out,const vector<T>& a){
  out<<'[';
  REP(i, a.size()) {out<<a[i];if(i!=a.size()-1)out<<',';}
  out<<']';
  return out;
}

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

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

  int d, n;
  cin >> d >> n;
  if(d == 0 && n == 100) cout << 101 << endl;
  else if(d == 1 && n == 100) cout << 10100 << endl;
  else if(d == 2 && n == 100) cout << 1010000 << endl;
  else cout << to_string(n) + string(2*d, '0') << endl;

  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main(){
   int d,n;
   cin>>d>>n;
   if(d==0)cout<<n+(n==100);
   else
     if(d==1)cout<<(n+(n==100))*100;
     else cout<<(n+(n==100))*10000;


	return 0;
}


Measured memory_bytes: 256
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))

ans = 0

for i in range(N):
    ans += B[A[i]-1]
    # print(ans)
    # print('-')
    if i > 0:
        if A[i] - A[i-1] == 1:
            ans += C[A[i-1]-1]
    # print(ans)
    # print('--')

print(ans)

Measured memory_bytes: 3064
#include<iostream>
#include<string>

using namespace std;

int main(){
    int n; cin >> n;
    bool flag = false;
    for(int i = 0; i <= n / 4; i++){
        for(int j = 0; j <= n / 7; j++){
            if(4 * i + 7 * j == n){
                flag = true;
                cout << "Yes" << endl;
                return 0;
            }
        }
    }
    if(flag == false) cout << "No" << endl;

}

Measured memory_bytes: 256
#[allow(unused_macros)]
macro_rules! input {
    ( source = $ s : expr , $ ( $ r : tt ) * ) => { let mut iter = $ s . split_whitespace ( ) ; let mut next = || { iter . next ( ) . unwrap ( ) } ; input_inner ! { next , $ ( $ r ) * } };
    ( $ ( $ r : tt ) * ) => { let stdin = std :: io :: stdin ( ) ; let mut bytes = std :: io :: Read :: bytes ( std :: io :: BufReader :: new ( stdin . lock ( ) ) ) ; let mut next = move || -> String { bytes . by_ref ( ) . map ( | r | r . unwrap ( ) as char ) . skip_while ( | c | c . is_whitespace ( ) ) . take_while ( | c |! c . is_whitespace ( ) ) . collect ( ) } ; input_inner ! { next , $ ( $ r ) * } };
}
#[allow(unused_macros)]
macro_rules! input_inner {
    ( $ next : expr ) => { };
    ( $ next : expr , ) => { };
    ( $ next : expr , $ var : ident : $ t : tt $ ( $ r : tt ) * ) => { let $ var = read_value ! ( $ next , $ t ) ; input_inner ! { $ next $ ( $ r ) * } };
}
#[allow(unused_macros)]
macro_rules! read_value {
    ( $ next : expr , ( $ ( $ t : tt ) ,* ) ) => { ( $ ( read_value ! ( $ next , $ t ) ) ,* ) };
    ( $ next : expr , [ $ t : tt ; $ len : expr ] ) => { ( 0 ..$ len ) . map ( | _ | read_value ! ( $ next , $ t ) ) . collect ::< Vec < _ >> ( ) };
    ( $ next : expr , chars ) => { read_value ! ( $ next , String ) . chars ( ) . collect ::< Vec < char >> ( ) };
    ( $ next : expr , usize1 ) => { read_value ! ( $ next , usize ) - 1 };
    ( $ next : expr , $ t : ty ) => { $ next ( ) . parse ::<$ t > ( ) . expect ( "Parse error" ) };
}

#[allow(unused_macros)]
macro_rules! vec_md {
    ( $ init : expr ; $ ( $ dim : expr ) ;* ) => { vec_md ! ( $ ( $ dim ) ;* => $ init ) };
    ( $ head : expr ; $ ( $ tail : expr ) ;* => $ init : expr ) => { vec ! [ vec_md ! ( $ ( $ tail ) ;* => $ init ) ; $ head ] };
    ( $ head : expr => $ init : expr ) => { vec ! [ $ init ; $ head ] };
}

#[allow(unused_macros)]
macro_rules! chmax {
    ( $ x : expr , $ y : expr ) => { if $ x < $ y { $ x = $ y ; true } else { false } };
}

fn main() {
    input! {
        s: chars,
        t: chars
    }

    let mut dp = vec_md![0u64;s.len()+1;t.len()+1];
    for i in 0..s.len()+1 {
        for j in 0..t.len()+1 {
            if i < s.len() && j < t.len() && s[i] == t[j] {
                dp[i+1][j+1] = dp[i][j] + 1;
            } else {
                if i < s.len() {
                    chmax!(dp[i+1][j], dp[i][j]);
                }
                if j < t.len() {
                    chmax!(dp[i][j+1], dp[i][j]);
                }
            }
        }
    }

    let mut y = s.len();
    let mut x = t.len();
    let mut chars = vec![];
    while y != 0 && x != 0 {
        if dp[y-1][x] == dp[y][x] {
            y -= 1;
        } else if dp[y][x-1] == dp[y][x] {
            x -= 1;
        } else {
            chars.push(s[y-1]);
            x -= 1;
            y -= 1;
        }
    }
    chars.reverse();
    println!("{}", chars.iter().cloned().collect::<String>());
}


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

using namespace std;

vector< int64_t > divisor(int64_t n) {
    vector< int64_t > ret;
    for(int64_t i = 1; i * i <= n; i++) {
        if(n % i == 0) {
        ret.push_back(i);
        if(i * i != n) ret.push_back(n / i);
        }
    }
    return (ret);
}

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

    int64_t ans = divisor(N-1).size() - 1;
    for(auto e: divisor(N)) {
        if(e == 1) continue;
        int64_t copy = N;
        while(copy % e == 0) {
            copy /= e;
        }
        if(copy % e == 1) ++ans;
    }

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


Measured memory_bytes: 384
package main

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

func main() {
	var len, tmp, changeTime int
	var err error
	bc := bufio.NewScanner(os.Stdin)

	bc.Scan()
	len, err = strconv.Atoi(bc.Text())
	if err != nil {
		fmt.Println("err:", err)
		os.Exit(1)
	}

	bc.Scan()
	arrayStr := strings.Fields(bc.Text())
	var arrayInt []int
	for _, elem := range arrayStr {
		newElem, err := strconv.Atoi(elem)
		if err != nil {
			fmt.Println("err:", err)
		}
		arrayInt = append(arrayInt, newElem)
	}

	for i := len; 0 < i; i-- {
		for j := 0; j < i-1; j++ {
			if arrayInt[j] > arrayInt[j+1] {
				tmp = arrayInt[j]
				arrayInt[j] = arrayInt[j+1]
				arrayInt[j+1] = tmp
				changeTime++
			}
		}
	}

	for i, elem := range arrayInt {
		if i != len-1 {
			fmt.Printf("%d ", elem)
		} else {
			fmt.Printf("%d\n", elem)
		}
	}
	fmt.Println(changeTime)
}


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

signed main() {
  int n,a,b;
  cin>>n>>a>>b;
  int c=0;
  int f;
  int k;
  for(int i=1;i<n+1;i++){
    f=i;
    k=0;
    for(;f>0;f/=10){
      k+=f%10;
    }
    if(a<=k&&k<=b)c+=i;
  }
  cout<<c<<endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define pi 3.14159265359
#define int long long
#define pii pair<int,int>
const int mod=1e9+7;

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




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

  

  int n,m;
  cin>>n>>m;
  vector<int>v(n);
  for(int i=0;i<n;i++)
  {
    cin>>v[i];
  }
  sort(v.begin(),v.end());
  vector<int>x;
  vector<pii>b(m);
  for(int i=0;i<m;i++)
  {
    cin>>b[i].second>>b[i].first;
  }
  sort(b.rbegin(),b.rend());
  
  int in=0;
  int cnt=0;
  while(x.size()<n&&in<m)
  {
    x.push_back(b[in].first);
    cnt++;
    if(cnt==b[in].second)
    {
      cnt=0; in++;
    }
  }
  while(x.size()<n)
  {
    x.push_back(0);
  }
  int sum=0;

  for(int i=0;i<n;i++)
  {
    sum+=max(v[i],x[i]);
  }
  cout<<sum<<"\n";



  
}



Measured memory_bytes: 3832
S = list(input())
W = 0 #最初が白の時
B = 0 #最初が黒の時

for i in range(len(S)):
    if i%2 == 0:
        if S[i] == '0': #偶数番目が黒色のとき
            W += 1
        else:
            B += 1
    else:
        if S[i] == '1': #偶数番目が黒色のとき
            W += 1
        else:
            B += 1

print (min(W, B))

Measured memory_bytes: 3956
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
using T = tuple<ll,int,int>;
const ll inf = numeric_limits<ll>::max()/3;
const ll mod = 1e9 + 7;

int main(void){
  string s;
  cin >> s;
  map<char,int> m;
  for(int i = 0;i < s.size();++i){
    m[s[i]]++;
  }
  if(m.size() != 2){
    puts("No");
    return 0;
  }
  for(auto p : m){
    if(p.second != 2){
      puts("No");
      return 0;
    }
  }
  puts("Yes");
  return 0;
}


Measured memory_bytes: 256
using System;
namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] str0 = Console.ReadLine().Split(' ');
            int N = int.Parse(str0[0]);
            int M = int.Parse(str0[1]);

            int[] arrA = new int[M];
            int[] arrB = new int[M];
            int[] arrReault = new int[N];

            for (int i = 0; i < M; i++)
            {
                string[] str = Console.ReadLine().Split(' ');

                int a = int.Parse(str[0]);
                int b = int.Parse(str[1]);
                arrA[i] = a;
                arrB[i] = b;
            }

            for (int i = 0; i < M; i++)
            {
                arrReault[arrA[i] - 1] += 1;
                arrReault[arrB[i] - 1] += 1;
            }

            for (int i = 0; i < N; i++)
            {
                Console.WriteLine(arrReault[i]);
            }

            Console.ReadKey();
        }
    }
}

Measured memory_bytes: 11092
#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
#define ALL(V) (V).begin(), (V).end()
#define ALLR(V) (V).rbegin(), (V).rend()
// #define DEBUGGING

template <typename T> using V = vector<T>;
template <typename T> using VV = V<V<T>>;
template <typename T, typename U> using P = pair<T, U>;
using ll = int64_t;
using PLL = P<ll, ll>;

template <typename T> const T& var_min(const T &t) { return t; }
template <typename T> const T& var_max(const T &t) { return t; }
template <typename Head, typename... Tail> const Head& var_min(const Head &head, const Tail&... tail) { return min(head, var_min(tail...)); }
template <typename Head, typename... Tail> const Head& var_max(const Head &head, const Tail&... tail) { return max(head, var_max(tail...)); }
template <typename T, typename... Tail> void chmin(T &t, const Tail&... tail) { t = var_min(t, tail...); }
template <typename T, typename... Tail> void chmax(T &t, const Tail&... tail) { t = var_max(t, tail...); }

namespace __init {

struct InitIO {
    InitIO() {
        cin.tie(nullptr);
        ios_base::sync_with_stdio(false);
        cout << fixed << setprecision(30);
    }
} init_io;

}

#ifdef DEBUGGING
#include "../debug.cpp"
#else
#define DEBUG(...) 0
#endif

template <typename T>
T make_v(T init) { return init; }

template <typename T, typename... Tail>
auto make_v(T init, size_t s, Tail... tail) {
#define rec make_v(init, tail...)
    return V<decltype(rec)>(s, rec);
#undef rec
}

map<char, ll> c2ll = {
    { 'U', 0 },
    { 'D', 1 },
    { 'L', 2 },
    { 'R', 3 },
};

ll rev(ll a) {
    if(a == 0 || a == 2) return a + 1;
    else return a - 1;
}

bool solve() {
    ll H, W, N;
    cin >> H >> W >> N;
    ll sh, sw;
    cin >> sh >> sw;
    sh--;
    sw--;
    string S, T;
    cin >> S >> T;
    ll u = 0, d = H - 1, l = 0, r = W - 1;
    for(ll i = N - 1; i >= 0; i--) {
        if(T[i] == 'U') d = min(d + 1, H - 1);
        if(T[i] == 'D') u = max(u - 1, (ll)0); 
        if(T[i] == 'L') r = min(r + 1, W - 1);
        if(T[i] == 'R') l = max(l - 1, (ll)0);
        if(S[i] == 'U') u++;
        if(S[i] == 'D') d--;
        if(S[i] == 'L') l++;
        if(S[i] == 'R') r--;
        DEBUG(u, d, l, r);
        if(!(0 <= u && u <= d && d < H &&
             0 <= l && l <= r && r < W)) return false;
    }
    return (u <= sh && sh <= d && l <= sw && sw <= r);
}

int main() {
    cout << (solve() ? "YES\n" : "NO\n");
    return 0;
}


Measured memory_bytes: 920
#include <iostream>
#include <algorithm>

using namespace std;

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

    int n, k;
    cin >> n >> k;
    int h[n];
    for (int i = 0; i < n; i++) {
        cin >> h[i];
    }
    sort(h, h+n);
    reverse(h, h+n);

    long long ans = 0;
    for (int i = k; i < n; i++) {
        ans += h[i];
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 1024
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		int a = scanner.nextInt();
		int b = scanner.nextInt();
		int d = a / b;
		int r = a % b;
		double f = (double) a / (double) b;
		System.out.printf( "%d %d %.5f", d, r, f ) ;

	}

}


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

typedef long long ll;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n;
    ll ans = 0;
    ll x;
    ll prev;
    cin >> n;
    cin >> prev;
    for (int i = 1; i < n; i++)
    {
        cin >> x;
        if (x < prev)
        {
            ans += (prev - x);
            x = prev;
        }
        prev = x;
    }
    cout << ans;
    return 0;
}

Measured memory_bytes: 3612
(defun takoyaki ()
  (let* ((n (read))
        (d (make-array n))
        (sum 0))
    (dotimes (i n)
      (setf (elt d i) (read)))
    (dotimes (k (1- n))
      (do ((x k (1+ x)))
          ((>= x n))
          (if (= x k) (incf x))
          (incf sum (* (elt d k) (elt d x)))))
    (format t "~a" sum)))

(takoyaki)

Measured memory_bytes: 16736
s = list(input())
n = len(s)

pattern = []
for i in range(2 ** (n - 1)):
    temp = [0] * (n - 1)
    for j in range(n - 1):
        if (i >> j) & 1:
            temp[j] = 1
    pattern.append(temp)

ans = 0
for p in pattern:
    sum = s[0]
    for i in range(n - 1):
        if p[i]:
            sum += '+'
        sum += s[i + 1]
    ans += eval(sum)

print(ans)


Measured memory_bytes: 3064
#include <stdio.h>

int main(){
int w,n,a[31],i;
scanf("%d%d",&w,&n);
for(i=1;i <= w;i++) a[i] = i;
while(n--){
int p,q,t;
scanf("%d,%d",&p,&q);
t = a[p];a[p] = a[q];a[q] = t;
}

for(i=1;i <= w;i++) printf("%d\n",a[i]);

return 0;
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
#define int long long
using namespace std;
constexpr int mod=1e9+7;
signed main(){
    int n,k,a[100000],ans=0,sum=0;
    while(cin>>n>>k,n||k){
    ans=0,sum=0;
    for(int i=0;i<n;i++){
        cin>>a[i];
        sum+=a[i];
        if(i>=k)
            sum-=a[i-k];
        if(i>=k-1)
            ans=max(ans,sum);
    }
    cout<<ans<<endl;}
}



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

int main(){
  string s,t;
  cin >> s >> t;
  ll n = s.length(),m= t.length();
  vector< vector<ll> > dp(n+1,vector<ll>(m+1,0));
  for(int i=1;i<=n;i++){
    for(int j=1;j<=m;j++){
      if(s[i-1]==t[j-1]){
        dp[i][j] = dp[i-1][j-1] + 1;
      }
      else{
        dp[i][j] = max(dp[i-1][j],dp[i][j-1]);
      }
    }
  }
  ll h=n,k=m;
  string p="";
  while(h!=0 and k!=0){
    if(s[h-1]==t[k-1]){
      p += s[h-1];
      h--;
      k--;
    }
    else{
      if(dp[h][k]==dp[h-1][k]){
        h--;
      }
      else{
        k--;
      }
    }
  }
  reverse(p.begin(),p.end());
  cout << p << endl;
}

Measured memory_bytes: 73736
from collections import defaultdict
N, W = list(map(int, input().split()))

values = []
weights = []

max_w = 0
weight_value_dict = defaultdict(int)
for i in range(N):
    v, w = list(map(int, input().split()))
    weight_value_dict[w] = max(v, weight_value_dict[w])
    values.append(v)
    weights.append(w)
# import IPython;IPython.embed()

dp = [0 for i in range(W+1)]

for j in range(1, W+1):
    for weight, val in weight_value_dict.items():
        if j < weight:
            continue
        else:
            dp[j] = max(dp[j], dp[j-weight] + val)
print(dp[W])


Measured memory_bytes: 6388
N = int(input())
a = list(map(int,input().split()))
c = []
d = []
for j in range(N):
  for i in range(0,8):
    if 400*(i) <= a[j] < 400*(i+1):
       if i not in c:
           c.append(i)
  if a[j] >= 3200:
        d.append(a[j])
if len(c) ==0:
    print(1,len(d))
else:
    print(len(c),len(c)+len(d))

Measured memory_bytes: 3188
#pragma GCC optimize("O3")
#include<bits/stdc++.h> 
using namespace std;
using ll=long long;
using P=pair<ll,ll>;
template<class T> using V=vector<T>; 
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
const ll inf=(1e18);
//const ll mod=998244353;
const ll mod=1000000007;
ll GCD(ll a,ll b) {return b ? GCD(b,a%b):a;}
ll LCM(ll c,ll d){return c/GCD(c,d)*d;}
struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}} __init;
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
int main(){
  ll n;
  cin>>n;
  string s;cin>>s;
  ll t=0;
  for(int i=0;i<s.size();i++){
    if(s[i]=='.')continue;
    t*=10;t+=ll(s[i]-'0');
  }
  n*=t;
  cout<<n/100<<"\n";
}

Measured memory_bytes: 3656
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <bitset>

using namespace std;
//using Graph = vector<vector<int>>;

//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}

//typedef
//------------------------------------------
typedef long long LL;

typedef vector<int> VI;
typedef vector<LL> VL;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<string, int> P;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

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

//constant
//--------------------------------------------
const double PI  = acos(-1.0);

//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
const LL MOD = 1e9+7; 
//vector <vector<int>> x(20, vector<int> (20)), y(20,vector<int> (20));
/*int counter_1 (int x) {
    if(x == 0) return 0;
    return counter_1(x >> 1) + (x & 1);
}*/

//int Counter(int x)
/*int factorial(int n) {
    if (n > 0) {
        return n * factorial(n - 1);
    } else {
        return 1;
    }
}*/
int factorial(int n) {
    if (n > 0) {
        return n * factorial(n - 1);
    } else {
        return 1;
    }
}
LL sum(LL a, LL b){
    LL cnt=0;
    cnt=(b-a+1)*(a+b)/2;
    return cnt;
}
/*LL yaku(int x){
    vector<pair<LL, LL> a=[];
    LL xh;
    if(x==1){
        pair<LL, LL> tmp;
        tmp=MP(1,1);
        return tmp;
    }
    else{
        FOR(i, 1, x/2+1){
            if(x%i==0){
                a.append(MP(i,x/i));
            }
        }
    }
    return a;

}*/
LL cul(int a, int b){
    LL f = pow(a,4)+pow(a,3)*b+pow(a,2)*pow(b,2)+a*pow(b,3)+pow(b,4);
    return f;
} 
int main(){
    int cnt = 1;
    while(true){
        int x;
        cin >> x;
        if(x==0) break;
        cout << "Case" << ' ' << cnt << ':' << ' ' << x << endl;
        cnt++;


    }
}
    





Measured memory_bytes: 3016
#include <stdio.h>

int main(void){
	int n,pkizi,ckizi,i,j,k,ans=0,pre=0;
	scanf("%d",&n);
	int ptop,ctop[n];
	scanf("%d %d %d",&pkizi,&ptop,&ckizi);
	for(i=0;i<n;i++){
		scanf("%d",&ctop[i]);
	}
	
	int temp;
	for(i=0;i<n-1;i++){
		for(j=i+1;j<n;j++){
			if(ctop[i]<ctop[j]){
				temp=ctop[i];
				ctop[i]=ctop[j];
				ctop[j]=temp;
			}
		}
	}
	

	int set[n+1],pri[n+1];
	for(i=0;i<=n;i++){
		set[i]=0;
		pri[i]=0;
	}
	set[0]=ckizi;
	pri[0]=pkizi;
	for(k=1;k<=n;k++){//???????????????????????°?????°
		for(i=0;i<k;i++){
			set[k]+=ctop[i];
			pri[k]+=ptop;
		}
		set[k]+=ckizi;
		pri[k]+=pkizi;
	}
	
	for(i=0;i<=n;i++){
		pre=set[i]/pri[i];
		if(ans<pre)ans=pre;
	}
	
	
	printf("%d\n",ans);
	return 0;
}

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

void printArray(int A[], int N) {
  for (int i=0; i<N; i++) {
    if (i > 0) cout << " ";
    cout << A[i];
  }
  cout << endl;
}

void bubbleSort(int A[], int N) {
  int flag = 1;
  int counter = 0;
  while (flag) {
    flag = 0;
    for (int j=N-1; j>0; j--) {
      if (A[j] < A[j-1]) {
        swap(A[j], A[j-1]);
        flag = 1;
        counter += 1;
      }
    }
  }
  printArray(A, N);
  cout << counter << endl;
}

int main() {
  int N;
  cin >> N;
  int A[N];

  for (int i=0; i<N; i++) cin >> A[i];
  bubbleSort(A, N);
}


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

using ll = long long;
using ld = long double;
using pii = pair<int, int>;

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
#define m0(x) memset(x,0,sizeof(x))

int dx4[4] = {1,0,-1,0}, dy4[4] = {0,1,0,-1};



int main()
{
    int n,h,ans=0;
    cin >>n>>h;
    vector<int> a(n),b(n);
    
    for(int i = 0; i < n; i++)
    {
        cin >> a[i] >> b[i];
    }
    
    sort(all(a));
    sort(all(b));

    int mx = a[n-1];
    
    for(int i = n - 1; i >= 0; i--)
    {
        if(h > 0 && b[i] > mx)
        {
            h-=b[i];
            ans++;
        }
        else
        {
            break;
        }
    }
    if(h>0)
    {
        ans += h/mx;
        if(h%mx>0) ans++;
    }
    cout << ans<<endl;

    return 0;
}

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

#define LL long long
#define Dl double
#define Pb push_back
#define Po pop_back
#define Mp make_pair
#define Ub upper_bound
#define Lb lower_bound
#define In insert
#define All(x) x.begin(), x.end()
#define mem(a, b) memset(a, b, sizeof(a))
#define fast ios_base::sync_with_stdio(0);cin.tie(0)

using namespace std;

typedef vector<LL> Vl;
typedef vector<Vl> VVl;
typedef pair<LL, LL> Pll;
typedef vector<Pll> Vpl;
typedef queue<LL> Ql;
typedef stack<LL> Sl;
#define X first
#define Y second

LL mod = 1e9 + 7;
LL fac[510000], finv[510000], inv[510000];

void COMinit()
{
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for(LL i = 2; i < 510000; i++){
        fac[i] = fac[i - 1] * i % mod;
        inv[i] = mod - inv[mod % i] * (mod / i) % mod;
        finv[i] = finv[i - 1] * inv[i] % mod;
    }
}

LL ncr(LL n, LL k)
{
    if(n < k)
        return 0;
    if(n < 0 || k < 0)
        return 0;

    return fac[n] * (finv[k] * finv[n - k] % mod) % mod;
}

int main()
{
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);

    COMinit();

    LL H, W, A, B;
    cin >> H >> W >> A >> B;

    LL h = H - A, w = W - B;

    LL ans = 0;

    for(LL i = 0; i < h; i++){
        ans = (ans + (ncr(i + B - 1, B - 1) * ncr(H - i + w - 2, w - 1)) % mod) % mod;
    }

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



Measured memory_bytes: 12160
#include <assert.h>
#include <ctype.h>
#include <errno.h>
#include <float.h>
#include <fstream>
#include <iomanip>
#include <iostream>
#include <set>
#include <queue>
#include <limits>
#include <deque>
#include <locale>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include <wchar.h>
#include <wctype.h>
#include <algorithm>
#include <bitset>
#include <map>
#include <iomanip>
#include <ios>
#include <iostream>
#include <vector>
#include <cwchar>
#include <cwctype>
#define mp make_pair
#define fs first
#define se second
#define memset(a,t) memset(a,t,sizeof(a))
#define all(v) v.begin(),v.end()
#define eprintf(...) fprintf(stderr, __VA_ARGS__),fflush(stderr)
#define MN 0LL
#define Mx 2000000005
#define Mn -Mx
#define MX 20000000000000005
using namespace std;
int readint(){
	char c;
	while(c=getchar(),(c<'0'||c>'9')&&c!='-');
	bool flag=(c=='-');
	if(flag)c=getchar();
	int x=0;
	while(c>='0'&&c<='9'){
		x=x*10+c-48;
		c=getchar();
	}
	return flag?-x:x;
}
inline string tos(int x){
	string s;
	while(x) s=(char)(x%10+'0')+s,x/=10;
	return s;
}
inline int pt(int a[],int l,int r){
	int p,i,j;
	p=a[l];
	i=l;
	j=r+1;
	for(;;){
		while(a[++i]<p) if(i>=r) break;
		while(a[--j]>p) if(j<=l) break;
		if(i>=j) break;
		else swap(a[i],a[j]);
	}
	if(j==l) return j;
	swap(a[l],a[j]);
	return j;
}
inline void q_sort(int a[],int l,int r){
	int q;
	if(r>l){
		q=pt(a,l,r);
		q_sort(a,l,q-1);
		q_sort(a,q+1,r);
	}
}
int k,dist[100005];
deque<int> dq;
int main(){
	cin>>k;
	int i,j,x,y,t;
	for(i=0;i<k;i++) dist[i]=Mx;
	dist[1]=1;
	dq.push_back(1);
	while(!dq.empty()){
		t=dq.front();
		dq.pop_front();
		if(dist[(t*10)%k]>dist[t]){
			dist[(t*10)%k]=dist[t];
			dq.push_front((t*10)%k);
		}
		if(dist[(t+1)%k]>dist[t]+1){
			dist[(t+1)%k]=dist[t]+1;
			dq.push_back((t+1)%k);
		}
	}
	cout<<dist[0];
	return 0;
}


Measured memory_bytes: 896
N = int(input())

S = []
for n in range(N):
    s = input()
    S.append(s)

print("AC x "+str(S.count("AC")))
print("WA x "+str(S.count("WA")))
print("TLE x "+str(S.count("TLE")))
print("RE x "+str(S.count("RE")))

Measured memory_bytes: 16084
n = int(input())
A = list(map(int, input().split()))
q = int(input())
m = list(map(int, input().split()))
M = [0] * q


def check(j, num):
    if m.count(num + A[j]) != 0:
        for k in range(q):
            if num + A[j] == m[k]:
                M[k] = 1
    if j < n - 1:
        check(j+1, num+A[j])
        check(j+1, num)


check(0, 0)
for i in range(q):
    if M[i] == 1:
        print("yes")
    else:
        print("no")



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

using namespace std;

int main() {

    long long a,b,c,d;

    cin>>a>>b>>c>>d;

     

    long long ans;

    ans=max(a*c, a*d);

    ans=max(ans, b*c);

    ans=max(ans, b*d);

    cout<<ans<<"\n";

     

    return 0;

}

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

int y = 700;
int counter = 0;
string s;

int main(){
  cin >> s;
  
  if (s[0] == 'o') ++counter;
  if (s[1] == 'o') ++counter;
  if (s[2] == 'o') ++counter;
  int topping = 100 * counter;
  
  cout << y + topping << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define Phuong_ ios_base::sync_with_stdio(0); cin.tie(0);

/// easy access -------------
using namespace std;
using ll = long long;
using ull = unsigned long long;
using ld = long double;
typedef pair<int,int> pi;
typedef tuple<int, int, int> tp;
///-------------------------

int main()
{
    Phuong_; /// <3333
    int n,m,vk;
    cin >> n >> m >> vk;
    char a[n][m];
    int sk=0;
    for(int i=0; i<n; ++i) {
        for(int j=0; j<m; ++j) {
            cin >> a[i][j];
            if (a[i][j]=='#') sk++;
        }
    }
    int ans=0;
    int maxn = (1<<(n));
    int maxm = (1<<(m));
    bitset<6> fn;
    bitset<6> fm;
    for(int ni =0 ; ni<maxn; ++ni){
        for(int nj =0; nj<maxm; ++nj){
            fn.reset();
            fm.reset();
            int k;
            int id=0;
            k=ni;
            while (k>0){
                if(k&1) fn[id]=1;
                k>>=1;
                id++;
            }
            k =nj;
            id=0;
            while (k>0){
                if (k&1) fm[id]=1;
                k>>=1;
                id++;
            }
            int s=sk;
            for(int i=0; i<n; ++i){
                for(int j=0; j<m; ++j){
                    if (fn[i] || fm[j]) {
                        if (a[i][j]=='#') s--;
                    }
                }
            }
            if (s==vk) ans++;
        }
    }
    cout << ans;
    return 0;
}


Measured memory_bytes: 3568
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n - 1; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i <= n; i++)
#define FORR(i, m, n) for(int i = m; i >= n; i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
 
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<ll, ll>;

int main(){
    ll n, k, a;
    while(1){
        cin >> n >> k;
        if(n == 0 && k == 0) return 0;
        vll st;
        REP(i, k){
            cin >> a;
            st.push_back(a);
        }
        ll len = st.size();
        VSORT(st);
        ll wild = 0;
        if(st[0] == 0) wild = 1;
        vll rec, dif2(n, 0);
        ll res = 1, tmp = 0;
        REP(i, len - 1){
            if(wild && !i) i++;

            if(st[i + 1] == st[i] + 1){
                res++;
                if(i == len - 2) rec.push_back(res);
            }
            else{
                rec.push_back(res);
                if(st[i + 1] == st[i] + 2) dif2[rec.size() - 1]++;
                res = 1;
            }
        }
        ll ans = 0;
        REP(i, rec.size()){
            ans = max(ans, rec[i]);
            if(wild && dif2[i]) ans = max(ans, rec[i] + rec[i + 1] + 1);
        }
        cout << ans << endl;
    }
    cout << endl;
    return 0;
}


Measured memory_bytes: 4412
#![allow(unused_imports)]

use proconio::{input, fastout};
use proconio::marker::*;

#[fastout]
fn main() {
    input! {
    n: usize
    }
    for x in 1..=n {
        if (100 * x + x * 8) / 100 == n {
            println!("{}", x);
            return;
        }
    }
    println!(":(")
}



Measured memory_bytes: 2144
#include <cstdio>
using namespace std;
int a,b,c,ans;
int A,B,C,A1,B1,C1;
int main() {
	scanf("%d %d %d",&a,&b,&c);
	ans=0;
	A=a; B=b; C=c;
	while (1) {
		if (A%2==1||B%2==1||C%2==1)
			break;
		ans++;
		A1=A; B1=B; C1=C;
		A=B1/2+C1/2;
		B=A1/2+C1/2;
		C1=A1/2+B1/2;
		if (A==a&&B==b&&C==c) {
			ans=-1;
			break;
		}
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <cstdio>
#include <cstring>
using namespace std;
typedef long long LL;
const int maxn = 200000, maxm = 2000, mod = 1E9 + 7;
const LL Mod = 1E9 + 7;
LL Pow(LL a, LL b) {
    LL c = 1;
    while (b) {
        if (b & 1) c = c * a % Mod;
        a = a * a % Mod;
        b >>= 1;
    }
    return c;
}
int n;
LL cnt = 0;
int a[maxn + 1], b[maxn + 1];
int Maxa = 0, Maxb = 0;
int f[maxm << 1 | 1][maxm << 1 | 1];
int c[maxm << 1 | 1][maxm << 1 | 1];
int main() {
    scanf("%d", &n);
    for (int i = 1; i <= n; ++i) {
        scanf("%d%d", &a[i], &b[i]);
        if (a[i] > Maxa) Maxa = a[i];
        if (b[i] > Maxb) Maxb = b[i];
    }
    c[0][0] = 1;
    for (int i = 1, t = Maxa << 1; i <= t; ++i)
        c[i][0] = 1;
    for (int i = 1, t = Maxb << 1; i <= t; ++i)
        c[0][i] = 1;
    for (int i = 1, t = Maxa << 1; i <= t; ++i)
        for (int j = 1, t = Maxb << 1; j <= t; ++j)
            c[i][j] = (c[i - 1][j] + c[i][j - 1]) % mod;
    for (int i = 1; i <= n; ++i)
        ++f[Maxa - a[i]][Maxb - b[i]];
    for (int i = 1, t = Maxa << 1; i <= t; ++i)
        f[i][0] += f[i - 1][0];
    for (int i = 1, t = Maxb << 1; i <= t; ++i)
        f[0][i] += f[0][i - 1];
    for (int i = 1, t = Maxa << 1; i <= t; ++i)
        for (int j = 1, t = Maxb << 1; j <= t; ++j)
            f[i][j] = (f[i][j] + f[i - 1][j] + f[i][j - 1]) % mod;
    for (int i = 1; i <= n; ++i)
        cnt = (cnt + f[Maxa + a[i]][Maxb + b[i]] - c[a[i] << 1][b[i] << 1]) % Mod;
    cnt = (cnt + Mod) % Mod * Pow(2, Mod - 2) % Mod;
    printf("%lld\n", cnt);
    return 0;
}

Measured memory_bytes: 126848
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N;
  cin >> N;
  string T;
  cout << "?";
  for (int i = 1; i <= N; i++){
    cout << ' ' << i;
  }
  cout << endl;
  cin >> T;
  int red, blue;
  if (T == "Red"){
    red = N;
    blue = 0;
  } else {
    red = 0;
    blue = N;
  }
  while (abs(red - blue) > 1){
    int mid = (red + blue) / 2;
    cout << "?";
    for (int i = 1; i <= mid; i++){
      cout << ' ' << i;
    }
    for (int i = N + mid + 1; i <= N * 2; i++){
      cout << ' ' << i;
    }
    cout << endl;
    cin >> T;
    if (T == "Red"){
      red = mid;
    } else {
      blue = mid;
    }
  }
  vector<bool> in_red(N * 2, false);
  for (int i = 0; i < red; i++){
    in_red[i] = true;
  }
  for (int i = N + red; i < N * 2; i++){
    in_red[i] = true;
  }
  vector<bool> in_blue(N * 2, false);
  for (int i = 0; i < blue; i++){
    in_blue[i] = true;
  }
  for (int i = N + blue; i < N * 2; i++){
    in_blue[i] = true;
  }
  vector<char> ans(N * 2);
  for (int i = 0; i < N * 2; i++){
    vector<int> A;
    if (in_red[i] && in_blue[i]){
      for (int j = 0; j < N * 2; j++){
        if (!in_red[j] && !in_blue[j] || i == j){
          A.push_back(j);
        }
      }
    } else {
      for (int j = 0; j < N * 2; j++){
        if (in_red[j] && in_blue[j] || i == j){
          A.push_back(j);
        }
      }
    }
    cout << '?';
    for (int j : A){
      cout << ' ' << j + 1;
    }
    cout << endl;
    cin >> T;
    ans[i] = T[0];
  }
  cout << "! ";
  for (int i = 0; i < N * 2; i++){
    cout << ans[i];
  }
  cout << endl;
}

Measured memory_bytes: 3856
N = int(input())
A = list(map(int, input().split()))
ans = float('inf')
l_sum = 0
r_sum = sum(A)
for i in range(N):
    l_sum += A[i]
    r_sum -= A[i]
    ans = min(ans, abs(r_sum - l_sum))

print(ans)

Measured memory_bytes: 88016
#include <bits/stdc++.h>
using namespace std;
using vi = vector<int>;
using vii = vector<vi>;
using vs = vector<string>;
using in6 = int64_t;
using ind = double;
using pii = pair<int,int>;
using psi = pair<string,int>;
using vpi = vector<pii>;
using vps = vector<psi>;
#define rep(i, n) for (in6 i = 0; i < (in6)(n); i++)
#define repa(i,a,n) for(in6 i = a; i < (in6)(n); i++)
#define repdown(i,n) for(in6 i = n; i > 0; i--)
#define kyun ios::sync_with_stdio(false)
#define hinata cout << "\n"
#define all(c) (c).begin(), (c).end()
#define pb push_back
#define inf 2147483647
#define dset(n) cout << fixed << setprecision(n)

void yes() {
  cout << "Yes";
}

void no() {
  cout << "No";
}

int main() {
  kyun;
  char a;
  cin >> a;
  if(65 <= a && a <= 90) cout << "A";
  else cout << "a";
}

Measured memory_bytes: 3572
n = int(input())
A = list(map(int, input().split()))

values = set({})
for num in range(1 << n):
    count = 0
    for k in range(n):
        if num & (1 << k) == 1 << k:
            count += A[k]
    # print(num, count)
    values.add(count)

m = int(input())
Q = list(map(int, input().split()))
for q in Q:
    if q in values:
        print("yes")
    else:
        print("no")


Measured memory_bytes: 5656
#include<bits/stdc++.h>
using namespace std;
int main(){
  string s;
  cin >> s;
  int const n = s.length();

  vector<int>num(n);
  int i;
  for(i=0;i<n;i++){
    num[i] = (int)(s[i]-'0');
  }
  long tmp = 1;
  long ans = 0;
  for(long bit = 0;bit < (1<<(n-1));bit++){
    tmp = 1;
    ans += num[n-1];
    for(i=0;i<n-1;i++){
      if(bit & (1<<i) )tmp = 1;
      else tmp *= 10;

      ans += tmp * num[n-2-i];
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
n = int(input())
a = [0]*n
for i in range(n):
    a[i] = int(input())
b = 1
count = 0
sw = 0
for i in range(n):
    b = a[b-1]
    count += 1
    if b == 2:
        sw = 1
        break
    elif count>=10**5:
        break
if sw == 1:
    print(count)
else:
    print(-1)

Measured memory_bytes: 7028
#include <iostream>

using namespace std;

int main () {
    int L;
    while (cin >> L, L) {
          int sum = 0, mon = 0;
          for (int i = 1; i <= 12; ++i) {
              int M, N;
              cin >> M >> N;
              if (!mon && (sum += M - N) >= L) mon = i;
          }
          if (mon) cout << mon << endl;
          else cout << "NA" << endl;
    }
}

Measured memory_bytes: 0
import bisect
import collections
import sys

sys.setrecursionlimit(100000000)
input = sys.stdin.readline
ACMOD = 1000000007
INF = 1 << 62


def lmi():
    return list(map(int, input().split()))


def llmi(n):
    return [lmi() for _ in range(n)]


N = int(input())

a = lmi()

adj = collections.defaultdict(set)
uv = llmi(N - 1)
for _u, _v in uv:
    u, v = _u - 1, _v - 1
    adj[u].add(v)
    adj[v].add(u)

trees = {}


class Tree:
    def __init__(self, index, parent_index=-1):
        self.val = a[index]
        self.index = index
        self.parent = parent_index
        self.adj = []
        for v in adj[index]:
            if v == parent_index:
                continue
            self.adj.append(Tree(v, parent_index=self.index))
        self.ans = -1
        trees[index] = self

    def __repr__(self):
        return '{}: {}'.format(self.index, [t.val for t in self.adj])

    def dp(self, current, diffs):
        v = bisect.bisect_left(current, self.val)
        if v >= len(current):
            diffs.append((v, -1))
            current.append(self.val)
        else:
            diffs.append((v, current[v]))
            current[v] = self.val
        self.ans = len(current)
        for child_tree in self.adj:
            diffs = child_tree.dp(current, diffs)
            index, val = diffs.pop()
            if val == -1:
                current.pop()
            else:
                current[index] = val


root = Tree(0)
# root.dp([], [])

current = []
diffs = []
self = root

v = bisect.bisect_left(current, self.val)
stack = [(True, root)]
while stack:
    is_start, self = stack.pop()
    if is_start:
        v = bisect.bisect_left(current, self.val)
        if v >= len(current):
            diffs.append((v, -1))
            current.append(self.val)
        else:
            diffs.append((v, current[v]))
            current[v] = self.val
        self.ans = len(current)
        for child_tree in self.adj:
            stack.append((False, child_tree))
            stack.append((True, child_tree))

            # diffs = child_tree.dp(current, diffs)
    else:
        index, val = diffs.pop()
        if val == -1:
            current.pop()
        else:
            current[index] = val

for i in range(N):
    print(trees[i].ans)


Measured memory_bytes: 705476
#include<iostream>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<utility>
#include<vector>
#include<cmath>
#include<cstring>
#include<cstdio>
#include<time.h>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define mp make_pair
#define all(in) in.begin(),in.end()
#define it vector<int>::iterator
const double PI=acos(-1);
const double EPS=1e-10;
const int inf=1e8;
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
using namespace std;

bool next_combination ( it first1 ,
  it last1 ,
  it first2 ,
  it last2 ){
  if (( first1 == last1 ) || ( first2 == last2 )) {
    return false ;
  }
  it m1 = last1 ;
  it m2 = last2 ; --m2;
  while (--m1 != first1 && !(*m1 < *m2 )){
  }
  bool result = (m1 == first1 ) && !(*first1 < *m2 );
  if (! result ) {
    while ( first2 != m2 && !(*m1 < *first2 )) {
      ++ first2 ;
    }
    first1 = m1;
    std :: iter_swap (first1 , first2 );
    ++ first1 ;
    ++ first2 ;
  }
  if (( first1 != last1 ) && ( first2 != last2 )) {
    m1 = last1 ; m2 = first2 ;
    while (( m1 != first1 ) && (m2 != last2 )) {
      std :: iter_swap (--m1 , m2 );
      ++ m2;
    }
    std :: reverse (first1 , m1 );
    std :: reverse (first1 , last1 );
    std :: reverse (m2 , last2 );
    std :: reverse (first2 , last2 );
  }
  return ! result ;
}
bool next_combination(it first,it middle,it last){
  return next_combination (first , middle , middle , last );
}
int main(){
	int n,s;
	vvi in(20,vi(500,-1));
	while(cin>>n>>s){
		if(in[n][s]>=0){
			cout<<in[n][s]<<endl;
			continue;
		}
		int sum=0;
		rep(i,n)sum+=(i+1)*(n-i-1);
		if(sum>s){
			cout<<0<<endl;
			in[n][s]=0;
			continue;
		}
		vi d(10);
		int co=0;
		rep(i,10)d[i]=i;
		do{
			do{
				int sum=0;
				rep(i,n)sum+=(i+1)*d[i];
				if(sum==s){
					co++;
				}
			}while(next_permutation(d.begin(),d.begin()+n));
		}while(next_combination(d.begin(),d.begin()+n,d.end()));
		cout<<co<<endl;
		in[n][s]=co;
	}
}

Measured memory_bytes: 1256