akhauriyash/Code-Regression huggingface dataset:
use std::cmp;
use std::error::Error;
use std::io;
use std::process;

fn main() {
    if let Err(e) = run() {
        println!("{}", e);
        process::exit(1);
    }
}

fn run() -> Result<(), Box<Error>> {
    io::stdin().read_line(&mut (String::new()))?;
    let mut a = String::new();
    io::stdin().read_line(&mut a)?;
    let a: Vec<i64> = a.trim().split(" ").map(|x| x.parse().expect("")).collect();
    let sum: i64 = a.iter().sum();
    let mut ans = 0;
    let mut x: i64 = 0;
    let mut y: i64 = sum;
    for (i, z) in a.iter().enumerate() {
        if i == a.len() - 1 {
            break;
        }
        x += *z;
        y -= *z;
        if i == 0 {
            ans = (x - y).abs();
        } else {
            ans = cmp::min(ans, (x - y).abs());
        }

    }
    println!("{}", ans);
    Ok(())
}


Measured memory_bytes: 10492
#include <iostream>
//#include <bits/stdc++.h>
#include <cstdio>
#include <list>
#include <vector>
#include <stack>
#include <queue>
#include <cstring>
#include <limits.h>
#include <cmath>
#include <algorithm>
#include <string>
#include <map>
#include <utility>
#define all(x) (x).begin(), (x).end() 
#define ull unsigned long long int
#define ll long long int 
#define ld long double
#define pb push_back
#define ep emplace_back
#define mp make_pair
#define pcc pair<char,char>
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pq priority_queue <ll> 
#define ppq priority_queue <pll>
#define vi vector <int>
#define vb vector <bool>
#define vl vector <ll>
#define vpl vector <pll>
#define vc vector <char>
#define mmi multimap<int,int>
#define mml multimap<ll,ll>
#define mmc multimap<char,char>
#define mi map<int,int>
#define ml map<ll,ll>
#define mc map<char,char>
#define clr(a) memset(a,0,sizeof(a))
#define mod 1000000007
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL)
#define endl "\n"
#define INF 1e+18
using namespace std;
bool primecheck(ll a)
{
    bool check  = true;

    for(ll i=2;i<=sqrt(a);i++)
    {
        if(a%i==0){
            check = false;
            break;
        }
    }

    return(check);
}
vl printDivisors(ll n) 
{ 
    // Note that this loop runs till square root 
    vl sol;
    for (ll i=1; i<=sqrt(n); i++) 
    { 
        if (n%i == 0) 
        { 
            // If divisors are equal, print only one 
            if (n/i == i){ 
                //printf("%d ", i);
               sol.pb(i); 
                 }
  
            else {
                sol.pb(i);
                sol.pb(n/i);
            }// Otherwise print both 
                //printf("%d %d ", i, n/i); 
        } 
    } 
    return(sol);
} 
ll digits(ll a)
{
    return(floor(log10(a))+1);
}
ll bits(ll a)
{
    return(floor(log2(a))+1);
}
long long binpow(long long a, long long b, long long m) {
    a %= m;
    long long res = 1;
    while (b > 0) {
        if (b & 1)
            res = res * a % m;
        a = a * a % m;
        b >>= 1;
    }
    return res;
}
int gcd(int a, int b) 
{ 
    // Everything divides 0  
    if (a == 0) 
       return b; 
    if (b == 0) 
       return a; 
   
    // base case 
    if (a == b) 
        return a; 
   
    // a is greater 
    if (a > b) 
        return gcd(a-b, b); 
    return gcd(a, b-a); 
}
ll lcm(ll a, ll b)  
 {  
    return (a*b)/gcd(a, b);  
 }
 void addEdge(vl adj[],ll u, ll v)
 {
    adj[u].pb(v);
    adj[v].pb(u);
 }
 vl path;
 void dfs(ll u, vl adj[], vb &visited, ll parent = -1)
 {
    visited[u] = true;
    path[u] = parent;
    // count<<u<<endl;
    for(ll i=0;i<adj[u].size();i++)
    {
        if(visited[adj[u][i]]==false)
        {
            dfs(adj[u][i],adj,visited,u);
        }
    }
 }
 /*
unique(all(vec)); will remove all duplicate elements from the vector
 */

int main()
{
    fastio;

    ll a,b,c,i,j,k,l,m,n,t;

    cin>>a>>b;

    ll sum = a*(a-1) + b*(b-1);

    cout<<sum/2<<endl;
    
}

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

using namespace std;

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

    vector<int> i(N);
    for(int j = 0; j < N; j++){
        int a;
        cin >> a;
        i[a-1] = j+1;
    }

    for(int j = 0; j < N; j++){
        cout << i[j];
        if (j+1 != N)
            cout << " ";
        else
            cout << endl;
    }
}

Measured memory_bytes: 1152
#include <iostream>

int main() {
  int a, b;
  std::cin >> a >> b;
  if (a < b) {
    std::cout << "a < b" << std::endl;
  } else if (a == b) {
    std::cout << "a == b" << std::endl;
  } else {
    std::cout << "a > b" << std::endl;
  }
}

Measured memory_bytes: 3064
#include <iostream>
#include <string>
#include <queue>
#include <stack>
#include <algorithm>
#include <list>
#include <vector>
#include <complex>
#include <utility>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <bitset>
#include <ctime>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <cassert>
#include <cstddef>
#include <iomanip>
#include <numeric>
#include <tuple>
#include <sstream>
#include <fstream>

using namespace std;
#define REP(i, n) for (int (i) = 0; (i) < (n); (i)++)
#define FOR(i, a, b) for (int (i) = (a); (i) < (b); (i)++)
#define RREP(i, a) for(int (i) = (a) - 1; (i) >= 0; (i)--)
#define FORR(i, a, b) for(int (i) = (a) - 1; (i) >= (b); (i)--)
#define DEBUG(C) cerr << #C << " = " << C << endl;
using LL = long long;
using VI = vector<int>;
using VVI = vector<VI>;
using VL = vector<LL>;
using VVL = vector<VL>;
using VD = vector<double>;
using VVD = vector<VD>;
using PII = pair<int, int>;
using PDD = pair<double, double>;
using PLL = pair<LL, LL>;
using VPII = vector<PII>;
template<typename T> using VT = vector<T>;
#define ALL(a) begin((a)), end((a))
#define RALL(a) rbegin((a)), rend((a))
#define SORT(a) sort(ALL((a)))
#define RSORT(a) sort(RALL((a)))
#define REVERSE(a) reverse(ALL((a)))
#define MP make_pair
#define FORE(a, b) for (auto &&a : (b))
#define FIND(s, e) ((s).find(e) != (s).end())
#define EB emplace_back
template<typename T> inline bool chmax(T &a, T b){if (a < b){a = b;return true;}return false;}
template<typename T> inline bool chmin(T &a, T b){if (a > b){a = b;return true;}return false;}

const int INF = 1e9;
const int MOD = INF + 7;
const LL LLINF = 1e18;

const int MAX = 55;
int N, M;
int cnt[MAX];

int main(void) {
    cin >> N >> M;
    REP(i, M) {
        int a, b;
        cin >> a >> b;
        cnt[a - 1]++;
        cnt[b - 1]++;
    }
    REP(i, N) {
        cout << cnt[i] << endl;
    }
}


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

#define pii pair<int,int>
#define fi first
#define se second
#define PB push_back
#define MP make_pair
#define PH push

const int MOD=1e9+7;

string s;
int k;
int f[305][305][305];
int ans=0;

int main()
{
	cin>>s>>k;
	for(int i=s.size()-1;i>=0;i--)
	{
		for(int j=i;j<s.size();j++)
		{
			for(int ch=0;ch<=k;ch++)
			{
				if(i==j) f[i][j][ch]=1;
				else if(i+1==j) f[i][j][ch]=((ch>0)?2:1+(s[i]==s[j]));
				else 
				{
					
					f[i][j][ch]=max(f[i+1][j][ch],f[i][j-1][ch]);
					if(s[i]==s[j]) f[i][j][ch]=max(f[i+1][j-1][ch]+2,f[i][j][ch]);
					if(ch>0) f[i][j][ch]=max(f[i+1][j-1][ch-1]+2,f[i][j][ch]);
				}
			//	printf("i=%d j=%d ch=%d res=%d\n",i,j,ch,f[i][j][ch]);
				ans=max(ans,f[i][j][ch]);
			}
		}
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 110848
/* imports all std modules {{{*/
import
  std.algorithm,
  std.array,
  std.ascii,
  std.base64,
  std.bigint,
  std.bitmanip,
  std.compiler,
  std.complex,
  std.concurrency,
  std.container,
  std.conv,
  std.csv,
  std.datetime,
  std.demangle,
  std.encoding,
  std.exception,
  std.file,
  std.format,
  std.functional,
  std.getopt,
  std.json,
  std.math,
  std.mathspecial,
  std.meta,
  std.mmfile,
  std.net.curl,
  std.net.isemail,
  std.numeric,
  std.parallelism,
  std.path,
  std.process,
  std.random,
  std.range,
  std.regex,
  std.signals,
  std.socket,
  std.stdint,
  std.stdio,
  std.string,
  std.system,
  std.traits,
  std.typecons,
  std.uni,
  std.uri,
  std.utf,
  std.uuid,
  std.variant,
  std.zip,
  std.zlib;
/*}}}*/

/* libnum {{{*/
void amax(N, Args...)(ref N x, Args y) if (isNumeric!N) {
  x = x.max(y);
}
void amin(N, Args...)(ref N x, Args y) if (isNumeric!N) {
  x = x.min(y);
}
/*}}}*/

/+---test
2 60
10 10
100 100
---+/
/+---test
3 60
10 10
10 20
10 30
---+/
/+---test
3 60
30 10
30 20
30 30
---+/

void main(string[] args) {
  int N, T;
  readf(" %d %d ", &N, &T);

  struct Item { long c, v; }
  auto items = new Item[N];
  foreach (ref item; items) readf(" %d %d ", &item.c, &item.v);

  auto dp0 = new long[T], dp1 = new long[T];
  foreach (i; 0..N) {
    foreach_reverse (t; 0..T) if (t + items[i].c < T) {
      dp1[t+items[i].c].amax(dp1[t] + items[i].v);
    }

    foreach (t; 0..T) dp1[t].amax(dp0[t] + items[i].v);

    foreach_reverse (t; 0..T) if (t + items[i].c < T) {
      dp0[t+items[i].c].amax(dp0[t] + items[i].v);
    }
  }
  long ans;
  dp0.each!(x => ans.amax(x));
  dp1.each!(x => ans.amax(x));
  ans.writeln;
}


Measured memory_bytes: 2428
#include "bits/stdc++.h"
#define DEBUG(x) cout<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cout<<#v<<":";for(int i=0;i<v.size();i++) cout<<" "<<v[i]; cout<<endl
using namespace std;
#define vi vector<int>
#define vl vector<ll>
#define vii vector< vector<int> >
#define vll vector< vector<ll> >
#define vs vector<string>
#define pii pair<int,int>
#define pis pair<int,string>
#define psi pair<string,int>
#define pll pair<ll,ll>
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define MOD 1000000007
#define mod 1000000009
#define pi 3.14159265358979323846
#define Sp(p) cout<<setprecision(15)<< fixed<<p<<endl;
#define pb push_back
template<class T> void print(const T& x){cout << x << endl;}
int dx[4] = { 1,0,-1,0 }, dy[4] = { 0,1,0,-1 };
int dx2[8] = { 1,1,0,-1,-1,-1,0,1 }, dy2[8] = { 0,1,1,1,0,-1,-1,-1 };
typedef long long ll;
const int inf = 1000000001;
const ll INF = 1e18 * 4;

int main(){
    int N; cin >> N;
    vi a(N, 0);
    vi b(N, 0);
    rep(i, 0, N) cin >> a[i];
    rep(i, 0, N) cin >> b[i];
    vi a_ika(N, 1);
    vi b_ika(N, 1);
    a_ika[0] = 0;
    b_ika[N-1] = 0;
    rep(i, 1, N){
        if(a[i] != a[i-1]) a_ika[i] = 0;
    }
    for(int j=N-2; j >= 0; j--){
        if(b[j] != b[j+1]) b_ika[j] = 0;
    }
    ll cnt = 1;
    rep(i, 0, N){
        if(a[i] == b[i]){
            if(a_ika[i] == 0 || b_ika[i] == 0) cnt *= 1;
            else cnt *= a[i];
        } else {
            if(a_ika[i] == 0 && b_ika[i] == 0) cnt *= 0;
            else if(a_ika[i] == 1 && b_ika[i] == 1) cnt *= min(a[i], b[i]);
            else if(a_ika[i] == 0 && b_ika[i] == 1){
                if(a[i] <= b[i]) cnt *= 1;
                else cnt *= 0;
            } else {
                if(b[i] <= a[i]) cnt *= 1;
                else cnt *= 0;
            }
        }
        cnt %= MOD;
    }
    cout << cnt << endl;
    return 0;
}




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

int main() {
    int n,ans=1;
    cin>>n;
    string s[n];
    rep(i,n)cin>>s[i];
    sort(s,s+n);
    rep(i,n-1){
        if(s[i]!=s[i+1])ans++;
    }
    cout << ans <<endl;
}

Measured memory_bytes: 9884
#include<bits/stdc++.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define HUGE_NUM 1000000000000000000
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;



#define SIZE 100005

ll N;
ll table[SIZE];



int main(){

	scanf("%lld",&N);

	ll sum = 0;

	for(int i = 0; i < N; i++){

		scanf("%lld",&table[i]);
		sum += table[i];
	}

	sum /= 2;

	ll minus = 0;

	for(int i = 1; i < N; i += 2){

		minus += table[i];
	}

	ll tmp = sum-minus;
	printf("%lld",2*tmp);

	ll pre = tmp;
	for(int i = 0; i < N-1; i++){

		tmp = table[i]-pre;
		printf(" %lld",2*tmp);
		pre = tmp;
	}
	printf("\n");

	return 0;
}


Measured memory_bytes: 2048
sx,sy,tx,ty=map(int,input().split())
ans=[]

for i in range(ty-sy):
    ans.append("U")
for i in range(tx-sx):
    ans.append("R")
for i in range(abs(sy-ty)):
    ans.append("D")
for i in range(abs(sx-tx)):
    ans.append("L")

ans.append("L")
for i in range(ty-sy+1):
    ans.append("U")
for i in range(tx-sx+1):
    ans.append("R")
ans.append("D")
ans.append("R")
for i in range(abs(sy-ty)+1):
    ans.append("D")
for i in range(abs(sx-tx)+1):
    ans.append("L")
ans.append("U")

print("".join(ans))

Measured memory_bytes: 40176
#include <iostream>
#include <cstdio>
#include <cmath>
#include <ctime>
#include <cstdlib>
#include <cassert>
#include <vector>
#include <list>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <string>
#include <algorithm>
#include <utility>
#define llint long long
#define inf 1e18
#define rep(x, s, t) for(llint (x) = (s); (x) < (t); (x)++)
#define Rep(x, s, t) for(llint (x) = (s); (x) <= (t); (x)++)
#define chmin(x, y) (x) = min((x), (y))
#define chmax(x, y) (x) = max((x), (y))

using namespace std;
typedef pair<llint, llint> P;

string s, t;

int main(void)
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	cin >> s >> t;
	llint ans = 0;
	for(int i = 0; i < s.size(); i++){
		if(s[i] != t[i]) ans++;
	}
	cout<<ans << endl;
	
	return 0;
}

Measured memory_bytes: 3776
#include<iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <tuple>
#include <cmath>
#include <queue>
#include <vector>
#include <map>
using namespace std;

#define ll int64_t
const long MOD = 1e9 + 7;


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

ll lcm( ll m, ll n )//最小公倍数
{
  return ((m / gcd(m, n)) * n); // lcm = m * n / gcd(m,n)
}//lcm


int main()
{
  ll n,k;
  cin  >> n>> k;
  ll ans=0; 
  ans = k*pow(k-1,n-1);

  cout << ans << endl;

  return 0;
}


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

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


int main() {

  long long dp[100010][3];

  int n; cin >> n;

  long long r[100010][3];
  rep(i,n)rep(j,3)cin >> r[i][j];

rep(i,n){
  rep(j,3){
    rep(k,3) {  
      if(j==k) continue;
      chmax(dp[i+1][k], dp[i][j]+r[i][k]);
  }}}

long long ans = 0;
rep(i,3) chmax(ans,dp[n][i]);

  cout << ans << endl;

  return 0;

}


Measured memory_bytes: 4992
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double ld;
typedef vector<ll> vl;
typedef vector<bool> vb;
typedef vector<string> vs;
typedef vector<char> vc;
typedef queue<ll> ql;
typedef deque<ll> dql;
typedef priority_queue<ll/*, vl, greater<ll>*/> pql; //降順(/*昇順*/)
typedef set<ll> sl;
typedef pair<ll, ll> pl;
typedef vector<vl> vvl;
typedef vector<pl> vpl;
#define rep(i, n) for(ll i = 0; i < ll(n); i++)
#define rep2(i, k, n) for(ll i = ll(k); i <= ll(n); i++)
#define rep3(i, n, k) for(ll i = ll(n); i >= ll(k); i--)
#define all(v) (v).begin(), (v).end()
ll mod(ll a, ll b) {if(b == 0) return 0; return (a % b + b) % b;}
bool chmin(ll &a, ll b) {if(b < a) {a = b; return 1;} return 0;}
bool chmax(ll &a, ll b) {if(b > a) {a = b; return 1;} return 0;}
const ll INF = 1LL << 60;
const ll MOD = 1e9 + 7;
//const ll MOD = 998244353;
const ll MAX = 1e9;
const char newl = '\n';

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

  ll d, t, s;
  cin >> d >> t >> s;
  cout << (d<=t*s ? "Yes" : "No") << newl;
  return 0;
}

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

#define all(x) x.begin(),x.end()
#define pb(x) emplace_back(x)
#define forn(i,N) for(int i=0;i<N;i++)

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

//Uradi: https://codeforces.com/problemset/problem/1345/B
//I ovaj je zanimljiv: https://codeforces.com/contest/214/problem/B

int main() {
//freopen("input.txt","rt",stdin);
ios::sync_with_stdio(false);
cin.tie(nullptr);

int X,N,val=-1,mn=INT_MAX;
cin>>X>>N;
vector<int> u(105);
forn(i,N) {
  int x;
  cin>>x;
  u[x]=1;
}
for(int i=0;i<=105;i++) {
  if(!u[i] and abs(i-X)<mn) {
    mn=abs(i-X);
    val=i;
  }
}
cout<<val<<endl;
return 0;
}


Measured memory_bytes: 3616
#define SORT(v) sort(v.begin(), v.end())
#include "iostream"
#include "map"
#include "vector"
#include <stack>
#include "cstdlib"
#include <algorithm>
#include <cstdarg>
// #include "ane.cpp"

#define INF (int)1e9
#define NMAX 200
#define MMAX 200
#define MOD 100000
using namespace std;

// コメントアウトするとdb_printf()を実行しない
#define DEBUG
// デバッグ用printf
void db_printf(const char* format, ...){
    #ifndef DEBUG
    return;
    #endif
    va_list arg;
    va_start(arg, format);
    vprintf(format, arg);  // コンソールに出力
    va_end(arg);
}
// n次元配列の初期化。第２引数の型のサイズごとに初期化していく。
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}
typedef pair<int, int> P;

int N,M,dp[NMAX][MMAX] = {};
int S,K;

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

int ans = 0;

void solve(){
    // 解答アルゴリズム
    for (int x = 0; x < K+1; ++x)
    {
        if (x > S) break;
        for (int y = 0; y < K+1; ++y)
        {
            int z = S - x - y;
            if (x+y > S || z > K)
            {
                continue;
            }
            ans++;
        }
    }
}
void debug(){
    // デバッグ用出力
}
void answer(){
    // 解答出力
    cout << ans << endl;
}
int main(int argc, char const *argv[])
{
    // 入力の読み込み，番兵法
    ios::sync_with_stdio(false);

    Fill(dp, -1);

    cin >> K >> S;
    solve();
    #ifdef DEBUG
    debug();
    #endif
    answer();

    return 0;
}

Measured memory_bytes: 1016
main = do
    [n,a,b] <- map read . words <$> getLine :: IO [Int]
    if (n `mod` (a+b)) > a
        then print $ ((n `div` (a+b))*a) + a
        else print $ ((n `div` (a+b))*a) + (n `mod` (a+b))


Measured memory_bytes: 3900
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <functional>

using namespace std;

int k[1000];
pair<int,int> kw[1000];

int main()
{
	while(1)
	{
		int n,m;
		scanf("%d %d",&n,&m);
		if(n == 0)
		{
			break;
		}
		for(int i = 0; i < m; i++)
		{
			k[i] = 0;
		}
		for(int i = 0; i < n; i++)
		{
			for(int j = 0; j < m; j++)
			{
				int w;
				scanf("%d",&w);
				k[j] += w;
			}
		}
		for(int i = 0; i < m; i++)
		{
			kw[i] = make_pair(k[i],m - 1 - i);
		}
		sort(kw,kw + m,greater<pair<int,int> >());
		for(int i = 0; i < m - 1; i++)
		{
			printf("%d ",m - kw[i].second);
		}
		printf("%d\n",m - kw[m - 1].second);
	}
	return 0;
}

Measured memory_bytes: 1196
#pragma region template
#include <bits/stdc++.h>
#define all(a) (a).begin(),(a).end()
#define rep(i,n) for(ll i=0,i##_len=(n);i<i##_len;i++)
#define rep2(i,a,b) for(ll i=(a),i##_len=(b);i<=i##_len;i++)
#define rrep(i,n) ll i=(n);ll now=-1;while(i--&&(now++||1))
#define Yes(n) cout<<((n)?Yes:No)
#define vint vector<int>
#define vll vector<ll>
#define vstr vector<string>
#define vbl vector<bool>
#define pb push_back
using namespace std;
using ll = long long;

static inline void ignore_ret(int x) {x++;}
template<class T> inline bool chmax(T&a,const T&b){if(a<b){a=b;return true;}return false;}
template<class T> inline bool chmin(T&a,const T&b){if(a>b){a=b;return true;}return false;}
template<class T> inline T gcd_vec(vector<T>v){T r=v.at(0);for(T i=1;i<v.size();i++)r=gcd(r,v.at(i));return r;}
template<class T> inline T lcm_vec(vector<T>v){T r=v.at(0);for(T i=1;i<v.size();i++)r=lcm(r,v.at(i));return r;}
template<class T> inline T factorial(T n){if(n==0)return 1;T r=1;for(T i=2;i<=n;i++)r*=i;return r;}
template<class T> inline T nCr(T n,T k){if(n<k||n<0||k<0)return 0;T r=1;k=min(k,n-k);for(T i=n-k+1;i<=n;i++)r*=i;return r/factorial(k);}
template<class T> inline T dot_product(vector<T>u,vector<T>v){T r=0;for(T i=0;i<u.size();i++)r+=u.at(i)*v.at(i);return r;}
template<class T> inline T sum(vector<T>v){return reduce(all(v),0LL);}
#pragma endregion template

void solve(ll A, ll B, ll K) {
  vll ans(2 * K, 0);
  rep(i, K) ans.at(i) = A + i;
  rep(i, K) ans.at(i + K) = B - i;
  sort(all(ans));
  ans.erase(unique(all(ans)), ans.end());

  for (auto x: ans) if(A <= x && x <= B) cout << x << "\n";
}

int main() {
  ll A;
  ignore_ret(scanf("%lld",&A));
  ll B;
  ignore_ret(scanf("%lld",&B));
  ll K;
  ignore_ret(scanf("%lld",&K));
  solve(A, B, K);
  return 0;
}

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

#define rep(i, n) for (int i = 0; i < int(n); i++)
#define rrep(i, n) for (int i = int(n) - 1; i >= 0; i--)
#define reps(i, n) for (int i = 1; i <= int(n); i++)
#define rreps(i, n) for (int i = int(n); i >= 1; i--)
#define repc(i, n) for (int i = 0; i <= int(n); i++)
#define rrepc(i, n) for (int i = int(n); i >= 0; i--)
#define repi(i, a, b) for (int i = int(a); i < int(b); i++)
#define repic(i, a, b) for (int i = int(a); i <= int(b); i++)
#define each(x, y) for (auto &x : y)
#define all(a) (a).begin(), (a).end()
#define bit32(x) (1 << (x))
#define bit64(x) (1ll << (x))

using namespace std;

using i32 = int;
using i64 = long long;
using u64 = unsigned long long;
using f80 = long double;
using vi32 = vector<i32>;
using vi64 = vector<i64>;
using vu64 = vector<u64>;
using vf80 = vector<f80>;
using vstr = vector<string>;

inline void yes() { cout << "Yes" << '\n'; exit(0); }
inline void no() { cout << "No" << '\n'; exit(0); }
inline i64 gcd(i64 a, i64 b) { if (min(a, b) == 0) return max(a, b); if (a % b == 0) return b; return gcd(b, a % b); }
inline i64 lcm(i64 a, i64 b) { if (min(a, b) == 0) return max(a, b); return a / gcd(a, b) * b; }
inline u64 xorshift() { static u64 x = 88172645463325252ull; x = x ^ (x << 7); return x = x ^ (x >> 9); }
template <typename T> class pqasc : public priority_queue<T, vector<T>, greater<T>> {};
template <typename T> class pqdesc : public priority_queue<T, vector<T>, less<T>> {};
template <typename T> inline void amax(T &x, T y) { if (x < y) x = y; }
template <typename T> inline void amin(T &x, T y) { if (x > y) x = y; }
template <typename T> inline T exp(T x, i64 n, T e = 1) { T r = e; while (n > 0) { if (n & 1) r *= x; x *= x; n >>= 1; } return r; }
template <typename T> inline T bis(T ok, T ng, function<bool(T)> f, T eps = 1) { while (abs(ok - ng) > eps) { T mi = (ok + ng) / 2; (f(mi) ? ok : ng) = mi; } return ok; }
template <typename T> istream& operator>>(istream &is, vector<T> &v) { each(x, v) is >> x; return is; }
template <typename T> ostream& operator<<(ostream &os, vector<T> &v) { rep(i, v.size()) { if (i) os << ' '; os << v[i]; } return os; }
void solve(); int main() { ios::sync_with_stdio(0); cin.tie(0); cout << fixed << setprecision(16); solve(); return 0; }

void solve() {
  int n, k;
  cin >> n >> k;
  vi32 a(n);
  cin >> a;
  vi32 dp(100001, -1);
  function<int(int)> rec = [&](int x) {
    if (dp[x] != -1) return dp[x];
    bool lose = true;
    rep(i, n) {
      lose = lose && (x - a[i] < 0 || rec(x - a[i]));
    }
    return dp[x] = lose ? 0 : 1;
  };
  if (rec(k)) {
    cout << "First" << endl;
  } else {
    cout << "Second" << endl;
  }
}


Measured memory_bytes: 6912
gohyaku = int(input())
hyaku = int(input())
goju = int(input())
inp = int(input())
count = 0

for i in range(gohyaku+1):
	for k in range(hyaku+1):
		for j in range(goju+1):
			if i * 500+ k*100+j*50 == inp:
				count += 1
print(count)

Measured memory_bytes: 3064
#include <cstdio>
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <cmath>
#include <string>

using namespace std;

typedef long long ll;
typedef pair<int,int> ii;
typedef vector<ii> vii;

int n,t,a[100100],diff[100100],ans[100100];
map<int,int> pos;

int main()
{
	ios::sync_with_stdio(false);
	pos.clear();
	cin >> n >> t;
	cin >> a[0];
	pos[a[0]] = 0;
	ans[0] = 0;
	int maxx = 0;
	for(int i=1;i<n;i++) 
	{
		cin >> a[i];
		pos[a[i]] = i;
		diff[i] = a[i] - a[i-1];
		ans[i] = max(0,diff[i]+ans[i-1]);
		maxx = max(maxx,ans[i]);
		//cout << i << " " << ans[i] << "\n";
	}
	//cout << maxx << "\n";
	int haha = 0;
	for(int i=0;i<n;i++)
	{
		if(pos[a[i]+maxx]>i) haha++;
	}
	cout << haha << "\n";
	return 0;
}

Measured memory_bytes: 10752
#include <bits/stdc++.h>
#define ll long long
#define PB push_back
#define MP make_pair
#define ff first
#define ss second
#define pri 1000000007
using namespace std;
ll dsu[100001];
ll si[100001];
ll ro(ll f){
	if(dsu[f]==f)return f;
	else return dsu[f]=ro(dsu[f]);
}

void join(ll a,ll b){
	ll x1=ro(a);
	ll x2=ro(b);
	if(x1==x2)return;
	if(si[x1]>si[x2])swap(x1,x2);
	si[x2]+=si[x1];
	dsu[x1]=x2;
}

void run(){
	ll n,m;
	cin>>n>>m;
	for(ll i=0;i<=n;i++){
		dsu[i]=i;
		si[i]=1;
	}
	for(ll i=0;i<m;i++){
		ll x,y,z;
    	cin>>x>>y>>z;
		join(x,y);
	}
	set <ll> a;
	for(ll i=1;i<=n;i++){
		a.insert(ro(i));
	}
ll	e=a.size();
	cout<<e<<endl;
	
	
	
}
int main() {
	ll t=1;
	//cin>>t;
	for(ll j=0;j<t;j++)run();
	// your code goes here
	return 0;
}

Measured memory_bytes: 6528
s = input()
n = len(s)
s += "0"
def d():
    for i in range(n-1):
        if s[i] == s[i+1]:
            return str(i+1) + " " + str(i+2)
        elif s[i] == s[i+2]:
            return str(i+1) + " " + str(i+3)
    return "-1 -1"
print(d())

Measured memory_bytes: 39664
#include<iostream>
#include<algorithm>
#include<vector>
#include<stack>
#include <cmath>
#include <limits>
#include<set>
#include <iomanip>
#include <queue>
#include <string>
#pragma GCC optimize("Ofast")
using namespace std;
const long long INF=200000000;
//setprecision(2) <<

const int MOD = 1000000007;




long myPow(long long x, long long n, long long m=MOD){
  if(n == 0)
    return 1;
  if(n % 2 == 0)
    return myPow(x * x % m, n / 2, m);
  else
    return x * myPow(x, n - 1, m) % m;
}
class Ans{
public:
	long long x;
	long long y;
	long long x_;
	long long y_;
};

int main(){
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	long long N;
	cin>>N;
	long long ans=0;
	int d[N];
	for(int i=0;i<N;i++)cin>>d[i];
	
	for(int i=0;i<N;i++){
		for(int j=i+1;j<N;j++){
			ans+=d[i]*d[j];
		}
	}
	cout<<ans<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using ld=long double;
using ii=pair<ll,ll>;
using vi=vector<ll>;

#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define INF (ll)1e18
#define all(x) (x).begin(),(x).end()
#define print(a); for(auto x:a)cout<<x<<" "; cout<<"\n";
#define mset(a); memset(a,0,sizeof(a));

int main(){
	ios_base::sync_with_stdio(0);cin.tie(0);
	ll a,b;cin>>a>>b;
    ll s=a+b;
    s=max(s,a-b);
    s=max(s,a*b);
    cout<<s<<"\n";
}


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

int main(){
    char s1[1000],s2[1000],s3[1000];
    
    scanf("%s %s", s1, s2);
    
    strcpy(s3,s1);
    
    if(strstr(strcat(s1,s3),s2)==NULL) printf("No\n");
    else printf("Yes\n");
    
    return 0;
    
}


Measured memory_bytes: 2744
//Nipah!~☆
#include<bits/stdc++.h>
using namespace std;

const int maxn = 1e6 + 10;

string ANS[] = {"Second", "First"};

int n, t;
int a[maxn];
string ans;

void in();
int solve();
void fix();
void out();

int main(){
	ios::sync_with_stdio(false);
	cout.tie(0);
	cin.tie(0);
	in();
	ans = ANS[solve()];
	out();
}

void in(){
	cin >> n;
	for(int i = 0; i < n; i++)
		cin >> a[i];
}

int solve(){
	t = 0;
	int z = 0;
	for(int i = 0; i < n; i++){
		t += a[i] % 2;
		if(a[i] == 1)
			z++;
	}
	if(n == 1)
		return 0;
	if(n % 2 != t % 2)
		return 1;
	if(n % 2 == t % 2 && t % 2 == 0)
		return 0;
	else if(t != 1 || z)
		return 0;
	else{
		for(int i = 0; i < n; i++)
			if(a[i] % 2)
				a[i]--;
		fix();
		int b = solve();
		return 1 - b;
	}
}

void fix(){
	int gcd = 0;
	for(int i = 0; i < n; i++)
		gcd = __gcd(gcd, a[i]);
	for(int i = 0; i < n; i++)
		a[i] /= gcd;
}

void out(){
	cout << ans;
}

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

int main(void) {
    int n;cin>>n;
    int a[100000];
    for(int i=1;i<=n;i++) {
        cin>>a[i];
    }
    int ans=0,j=1;
    for(int i=1;i<=n;i++) {
        ans++;
        if(a[j]==2) {
            cout<<ans<<endl;
            return 0;
        }
        else j=a[j];
    }
    cout<<-1<<endl;
    return 0;
}


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

int main(){
	string st;
	while(getline(cin, st)){
		for(int i=0; i<st.size();i++){
			if(st[i]>='a'&&st[i]<='z'){
				st[i]=st[i]-32;
			}
	}
		cout<<st<<endl;
	}
}

Measured memory_bytes: 1172
// unolight {{{
#include <bits/stdc++.h>
#include <unistd.h>
#define SZ(x) ((int)(x).size())
#define ALL(c) begin(c),end(c)
#define REP(i,n) for ( int i=0; i<(int)(n); i++ )
#define REP1(i,a,b) for ( int i=(int)(a); i<=(int)(b); i++ )
#define FOR(it,c) for ( auto it=(c).begin(); it!=(c).end(); it++ )
#define MP make_pair
#define PB push_back
using namespace std;
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef long long LL;

void RI() {}

template<typename... T>
void RI( int& head, T&... tail ) {
    scanf("%d",&head);
    RI(tail...);
}

template<typename T>
void _dump( const char* s, T&& head ) { cerr<<s<<"="<<head<<endl; }

template<typename T, typename... Args>
void _dump( const char* s, T&& head, Args&&... tail ) {
    int c=0;
    while ( *s!=',' || c!=0 ) {
        if ( *s=='(' || *s=='[' || *s=='{' ) c++;
        if ( *s==')' || *s==']' || *s=='}' ) c--;
        cerr<<*s++;
    }
    cerr<<"="<<head<<", ";
    _dump(s+1,tail...);
}

#define dump(...) _dump(#__VA_ARGS__, __VA_ARGS__);

template<typename A, typename B>
ostream& operator <<( ostream &s, const pair<A,B> &p ) { return s<<"("<<p.first<<","<<p.second<<")"; }

template<typename Iter>
ostream& _out( ostream &s, Iter b, Iter e ) {
    s<<"[";
    for ( auto it=b; it!=e; it++ ) s<<(it==b?"":" ")<<*it;
    s<<"]";
    return s;
}

template<typename T>
ostream& operator <<( ostream &s, const vector<T> &c ) { return _out(s,ALL(c)); }
template<typename T>
ostream& operator <<( ostream &s, const set<T> &c ) { return _out(s,ALL(c)); }
template<typename A, typename B>
ostream& operator <<( ostream &s, const map<A,B> &c ) { return _out(s,ALL(c)); }

// }}}
const int MAX_N = 3000;
int n;
double p[MAX_N], dp[MAX_N][MAX_N];

void input() {
    RI(n);
    REP(i, n) scanf("%lf", &p[i]);
}

void solve() {
    dp[0][0]=1;
    for(int i=1; i<=n; i++) dp[i][0] = dp[i-1][0] * (1-p[i-1]);
    for(int k=1; k<=n; k++) {
        for(int i=1; i<=n; i++) {
            dp[i][k] = dp[i-1][k]*(1-p[i-1]) + dp[i-1][k-1] * p[i-1];
        }
    }

    // for(int i=0; i<=n; i++) {
    //     for(int j=0; j<=n; j++) {
    //         printf("%lf ", dp[j][i]);
    //     }
    //     printf("\n");
    // }

    double ans = 0;
    for(int i=(n+1)/2; i<=n; i++) {
        ans += dp[n][i];
    }
    printf("%.9lf\n", ans);
}

int main( int argc, char *argv[] ) {
    input();
    solve();
    return 0;
}


Measured memory_bytes: 70528
/*
ID: hafiz.i1
TASK: milk2
LANG: C++
*/
#include<bits/stdc++.h>

#define ll long long
#define debug(x) cout<<x<<"DE"<<endl;

using namespace std;



int main()
{
//    freopen("milk2.in", "r", stdin);
//    freopen("milk2.out", "w", stdout);
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n,m,s=0;
    cin>>n;
    ll l1[n+1];
    for(int i=1;i<=n;i++){
        cin>>l1[i];
        if(i==1)m=l1[i];
        else m=__gcd(m,l1[i]);
    }
    cout<<m;
}


Measured memory_bytes: 4416
N = int(input())
ans = N
for i in range(N // 9 + 1):
  cnti = 0
  _i = i
  while _i :
    cnti += _i % 9
    _i //= 9
  cntj = 0
  j = (N - 9 * i) // 6
  _j = j
  while _j:
    cntj += _j % 6
    _j //= 6
  ans = min(cnti + cntj + N - 9 * i - 6 * j, ans)
print(ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;
#define rep(i,n) for (ll i=0;i<(n);++i)
#define rep2(i,a,b) for (ll i=(a);i<(b);++i)
#define debug(x) cout << #x << '=' << x << endl
#define all(v) (v).begin(),(v).end()
const ll MOD=1e9+7;
//const ll MOD=998244353;
const ll INF=1e9;
const ll IINF=1e18;
const double EPS=1e-8;
const double pi=acos(-1);

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

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N;
    cin >> N;
    map<int,int> m;
    rep(i,N){
        int a; cin >> a;
        if (m[a]==1){
            cout << "NO" << endl;
            return 0;
        }
        ++m[a];
    }
    cout << "YES" << endl;
}

Measured memory_bytes: 9600
#include<bits/stdc++.h>
using namespace std;
bool f[19];

int main(){
  int n,k;
  cin>>n>>k;
  for(int i=0;i<k;i++){
    int a;
    cin>>a;
    f[a]=1;
  }
  int j=n;
  while(1){
    int temp=j,cnt=0;
    int t=10;
    while(temp){
      if(f[temp%10]==1)cnt++;
      temp/=10;
    }
    if(cnt==0){
      cout<<j<<endl;
      break;
    }
    j++;
  }
  return(0);
}


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

ll a[50];

int main() {
    ll K;
    cin >> K;
    for (int i = 0; i < 50; i++) {
        a[i] = i + K / 50;
    }
    for (int i = 0; i < (K % 50); i++) {
        a[i] += 50;
        for (int j = 1; j < 50; j++) {
            a[j]--;
        }
    }
    cout << 50 << endl;
    for (int i = 0; i < 50; i++) cout << a[i] << ' ';
    cout << endl;
    return 0;
}

Measured memory_bytes: 384
#include <iostream>

using namespace std;

int main()
{
    while(1)
    {
        int a,b;
        char op;
        cin >> a >> op >> b;

        switch(op)
        {
        case '+':
            a = a + b;
            break;
        case '-':
            a = a - b;
            break;
        case '*':
            a = a * b;
            break;
        case '/':
            a = a / b;
            break;
        default:
            return 0;
        }
        cout << a << endl;
    }
}

Measured memory_bytes: 1160
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}
fn main() {
    input! {
        n: usize,
        k: usize,
        l: [usize; n],
    }
    let mut l = l;
    l.sort();
    l.reverse();
    let mut m = 0;
    for i in 0..k {
        m+=l[i];
    }
    println!("{}", m);
}

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

using namespace std;

int n;
long long dp[102][100010];
long long v[111], w[111];


int main(void) {
    long long int W;
    cin>>n>>W;

    for(int i = 0; i < n; ++i) {
        cin>>w[i]>>v[i];
        for (int j = 0; j < 100010; ++j) {
            dp[i][j] = 1e14 + 1ll;
        }
    }
    long long int ans = 0;
    for (int i = 0; i < n; ++i) {
        for (long long int j = 0; j < 100010; ++j) {
            if (i == 0) {
                if (j == v[i]) {
                    dp[i][j] = min(dp[i][j], w[i]);
                    if (dp[i][j] <= W) ans = max(ans, j);
                }
            } else {
                dp[i][j] = dp[i-1][j];
                if (j >= v[i])  dp[i][j] = min(dp[i][j], dp[i-1][j-v[i]] + w[i]);
                if (j == v[i])  dp[i][j] = min(dp[i][j], w[i]);
                if (dp[i][j] <= W) ans = max(ans, j);
            }
        }
    }

    cout<<ans;

    

    return 0;
}

Measured memory_bytes: 78336
from heapq import heappush, heappop
class MinCostFlow:
    INF = 10**18

    def __init__(self, N):
        self.N = N
        self.G = [[] for i in range(N)]

    def add_edge(self, fr, to, cap, cost):
        G = self.G
        G[fr].append([to, cap, cost, len(G[to])])
        G[to].append([fr, 0, -cost, len(G[fr])-1])

    def flow(self, s, t, f):
        N = self.N; G = self.G
        INF = MinCostFlow.INF

        res = 0
        H = [0]*N
        prv_v = [0]*N
        prv_e = [0]*N

        while f:
            dist = [INF]*N
            dist[s] = 0
            que = [(0, s)]

            while que:
                c, v = heappop(que)
                if dist[v] < c:
                    continue
                for i, (w, cap, cost, rev) in enumerate(G[v]):
                    if cap > 0 and dist[w] > dist[v] + cost + H[v] - H[w]:
                        dist[w] = r = dist[v] + cost + H[v] - H[w]
                        prv_v[w] = v
                        prv_e[w] = i
                        heappush(que, (r, w))
            if dist[t] == INF:
                return -1

            for i in range(N):
                H[i] += dist[i]

            d = f; v = t
            while v != s:
                d = min(d, G[prv_v[v]][prv_e[v]][1])
                v = prv_v[v]
            f -= d
            res += d * H[t]
            v = t
            while v != s:
                e = G[prv_v[v]][prv_e[v]]
                e[1] -= d
                G[v][e[3]][1] += d
                v = prv_v[v]
        return res


import sys
readline = sys.stdin.readline
write = sys.stdout.write
N, M, F = map(int, readline().split())

mcf = MinCostFlow(N)
for i in range(M):
    u, v, c, d = map(int, readline().split())
    mcf.add_edge(u, v, c, d)
write("%d\n" % mcf.flow(0, N-1, F))


Measured memory_bytes: 5944
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG //GCC5.4.1で配列の範囲外アクセスをエラーにする

//cmdで g++ test.cpp とするとコンパイルできる
//制限1秒なら10^6は余裕 10^7は多分間に合う 10^8はよほど単純でないと厳しい

#define ALL(x) x.begin(),x.end()
#define get_tp(t,i) get<i>(t)
#define len(x) (ll)(x.size())
typedef long long ll; //long long
typedef pair<int,int> pii; //pair<int,int>
typedef pair<long long,long long> pllll; //pair<ll,ll>
typedef vector<int> vi; //vector<int>
typedef vector<vector<int>> vvi; //vector<vector<int>>
typedef vector<ll> vll; //vector<long long>
typedef vector<vector<ll>> vvll; //vector<vector<long long>>
typedef priority_queue<int, vector<int>, greater<int> > gpq; //逆順priority_queue
typedef priority_queue<int> pq;

//const int MOD=998244353;
const int MOD=1000000007; //10^9+7
const long double PI=3.1415926535897932;

int main(){
    int N;
    cin>>N;
    ll ans=0;
    for(int i=0;i<N;i++){
        int a;
        cin>>a;
        while(a%2==0){
            a/=2;ans++;
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 3608
#include <iostream>
#include <algorithm>
#include <bitset>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <complex>
#include <string.h>
#include <numeric>
using namespace std;

#define int long long
#define reps(i,s,n) for(int (i)=(s);(i)<(n);++(i))
#define rep(i,n) reps(i,0,n)
#define rept(i,n) rep(i,(n)+1)
#define repst(i,s,n) reps(i,s,(n)+1)
#define reprt(i,n,t) for(int (i)=(n);(i)>=(t);--(i))
#define repr(i,n) reprt(i,n,0)
#define each(i,v) for(auto &(i):(v))
#define eachr(i,v) for(auto &(i)=(v).rbegin();(i)!=(v).rend();(i)++)
#define all(c) (c).begin(),(c).end()
#define rall(c) (c).rbegin(),(c).rend()
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define tmax(x,y,z) max(x,max(y,z))
#define tmin(x,y,z) min(x,min(y,z))
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
#define ln '\n'
#define bln(i,n) (((i)==(n)-1)?'\n':' ')
#define dbg(x) cout<<#x" = "<<(x)<<ln<<flush
#define dbga(x,n) {cout<<#x" : ";for(int (i)=0;i<(n);++i){cout<<((x)[i])<<(i==((n)-1)?'\n':' ')<<flush;}}
#define zero(a) memset(a,0,sizeof(a))
#define unq(a) sort(all(a)),a.erase(unique(all(a)),a.end())
#define endl "\n"

//typedef complex<double> P;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<string> vst;
typedef vector<pii> vpii;
typedef vector<pll> vpll;
typedef vector<vector<int> > mat;

const ll inf = (ll)1e9+10;
const ll linf = (ll)1e18+10;
const ll mod = (ll)(1e9+7);
const int dx[] = {0, 1, 0, -1};
const int dy[] = {1, 0, -1, 0};
const int ddx[] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[] = {1, 1, 0, -1, -1, -1, 0, 1};
const double eps = 1e-10;

ll mop(ll a,ll b,ll m=mod) {ll r=1;a%=m;for(;b;b>>=1){if(b&1)r=r*a%m;a=a*a%m;}return r;}
ll gcd(ll a,ll b) {return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b) {return a/gcd(a,b)*b;}
bool ool(int x,int y,int h,int w) {return((x<0)||(h<=x)||(y<0)||(w<=y));}
bool deq(double a,double b) {return abs(a-b)<eps;}

struct oreno_initializer {
    oreno_initializer() {
        cin.tie(0);
        ios::sync_with_stdio(0);
    }
} oreno_initializer;



int n, d[100100], x, y, z;
vector<pair<int,int> > e[100100];

void rec(int v, int p, int s) {
    d[v] = s;
    each(i,e[v]) if (i.first!=p) rec(i.first, v, s+i.second);
}

signed main() {
    cin >> n;
    rep(i,n-1) {
        cin >> x >> y >> z;
        x--, y--;
        e[x].push_back({y,z}), e[y].push_back({x,z});
    }
    rec(0,-1,0);
    rep(i,n) cout << d[i]%2 << endl;
}


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

int int_sort(const void *a ,const void *b){
  if(*(int*)a < *(int*)b){
    return -1;
  }
  else
  if(*(int*)a == *(int*)b){
    return 0;
  }
  return 1;
}
int main(void){
  size_t data_cnt , i;
  int n;
  scanf("%d",&n);
  int d[n];

  data_cnt = sizeof(d)/sizeof(d[0]);
  for(i=0;i<data_cnt;i++){
    scanf("%d",&d[i]);
  }

/*  for(i=0;i<data_cnt;i++){
    printf("d[%d]=%d\n",i,d[i]);
  }*/
  qsort((void*)d,data_cnt,sizeof(d[0]),int_sort);
/*  for(i=0;i<data_cnt;i++){
    printf("d[%d]=%d\n",i,d[i]);
  }*/
  int cnt=0;
  for(i=0;i<data_cnt;i++){
    if(d[i]!=d[i+1]){
      cnt++;
    }
  }
  printf("%d",cnt);
  return 0;
}


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

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

  int rem;
  rem = (a * b) % 2;

  if (rem == 1) {
    cout << "Odd" << endl;
  }

  else {
    cout << "Even" << endl;
  }
}

Measured memory_bytes: 256
n,y = gets.chomp.split(" ").map(&:to_i)
(n+1).times do |i|
  (n-i+1).times do |j|
    sum = i * 10000 + j * 5000 + (n-i-j) * 1000
    if y == sum
      puts "#{i} #{j} #{n-i-j}"
      exit
    end
  end
end
puts "-1 -1 -1"

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

using namespace std;

bool digitsum(long n,long A,long B)
{
    int sum=0;
    while(n!=0)
    {
        sum=sum+(n%10);
        n=n/10;
    }
    if(sum>=A && sum<=B)
    {
        return true;
    }
    else
        return false;
}

int main()

{
    long  N, A, B;
    cin>>N>>A>>B;
    int ans=0;
    for(int i=1;i<=N;i++)
    {
        if(digitsum(i,A,B))
            ans=ans+i;
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#define _USE_MATH_DEFINES
#include "bits/stdc++.h"

using namespace std;

using u8 = uint8_t;
using u16 = uint16_t;
using u32 = uint32_t;
using u64 = uint64_t;
using i8 = int8_t;
using i16 = int16_t;
using i32 = int32_t;
using i64 = int64_t;

constexpr char newl = '\n';
constexpr double eps = 1e-10;

#define FOR(i,a,b) for (int i = (a); i < (b); i++)
#define F0R(i,b) FOR(i,0,b)
#define RFO(i,a,b) for (int i = ((b)-1); i >=(a); i--)
#define RF0(i,b) RFO(i,0,b)
#define fi first
#define se second
#define debug(x) cout << #x << ": " << x << '\n';
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()

template<typename T1, typename T2> inline void chmin(T1& a, T2 b) { if (a > b) a = b; }
template<typename T1, typename T2> inline void chmax(T1& a, T2 b) { if (a < b) a = b; }
template<class T> void Print(vector<T> v) {
  F0R(i, v.size()) {
    cout << v[i] << ' ';
  }
  cout << newl;
}

#if 1


// INSERT ABOVE HERE
signed main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);

  int k, x;
  cin >> k >> x;
  int l = x - k + 1, r = x + k - 1;
  for (int i = l; i <= r; i++) {
    cout << i << ' ';
  }
}
#endif


Measured memory_bytes: 3640
import java.util.*;
import java.lang.*;
import java.math.*;
import java.io.*;

import static java.lang.Math.*;
import static java.util.Arrays.*;

public class Main{

	Scanner sc=new Scanner(System.in);

	int INF=1<<28;
	double EPS=1e-9;

	void run(){
		for(;;){
			int n=sc.nextInt();
			int k=sc.nextInt();
			if((n|k)==0){
				break;
			}
			boolean[] bs=new boolean[n];
			boolean blank=false;
			for(int i=0; i<k; i++){
				int a=sc.nextInt();
				if(a==0){
					blank=true;
				}else{
					bs[a-1]=true;
				}
			}
			int c=0;
			ArrayList<Integer> list=new ArrayList<Integer>();
			for(int i=0; i<n; i++){
				if(bs[i]){
					if(c>=0){
						c++;
					}else{
						list.add(c);
						c=1;
					}
				}else{
					if(c<=0){
						c--;
					}else{
						list.add(c);
						c=-1;
					}
				}
			}
			list.add(c);
			// debug(bs);
			// debug(list.toArray());
			int max=0;
			for(int i=0; i<list.size(); i++){
				max=max(max, list.get(i));
				if(list.get(i)==-1&&blank){
					int a=1;
					if(i>0){
						a+=list.get(i-1);
					}
					if(i<list.size()-1){
						a+=list.get(i+1);
					}
					max=max(max, a);
				}
			}
			println(max+"");
		}
	}

	void debug(Object... os){
		System.err.println(Arrays.deepToString(os));
	}

	void print(String s){
		System.out.print(s);
	}

	void println(String s){
		System.out.println(s);
	}

	public static void main(String[] args){
		// System.setOut(new PrintStream(new BufferedOutputStream(System.out)));
		new Main().run();
	}
}

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

int main(){
  int n;
  cin >>n;
  int ans=n;
  vector<string>a(n);
  for(int i=0;i<n;i++){
    cin >>a.at(i);
  }
  sort(a.begin(),a.end());
  for(int i=0;i<n-1;i++){
    if(a.at(i)==a.at(i+1))ans--;
  }
  cout <<ans;
}

Measured memory_bytes: 9600
n = int(input())
xu = [list(input().split()) for _ in range(n)]

res = 0
for i in range(n):
    x, u = float(xu[i][0]), xu[i][1]
    if u == "JPY":
        res += x * 1
    else:
        res += x * 380000

print(res)


Measured memory_bytes: 2940
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(n);i++)
const int MOD=(int)1e9+7;
using namespace std;
int main(){
    string a,b,c;
    cin >>a>>b>>c;
    if(a[a.size()-1] == b[0] && b[b.size()-1] == c[0]) cout << "YES" << endl;
    else cout << "NO" << endl;
    
}

Measured memory_bytes: 256