akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#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, a, b) for (int i = a; i < b; ++i)
#define FORR(i, a, b) for (int i = b - 1; i >= a; --i)
#define SORT(v) sort(v.begin(), v.end())
#define SORTR(v) sort(v.rbegin(), v.rend())
#define REV(v) reverse(v.begin(), v.end())
#define ITER(itr, v) for (auto itr = v.begin(); itr != v.end(); ++itr)
#define LB(v, x) (lower_bound(v.begin(), v.end(), x) - v.begin())
#define UB(v, x) (upper_bound(v.begin(), v.end(), x) - v.begin())
#define SZ(v) (int)v.size()
using namespace std;
using ll = long long;
using P = pair<int, int>;

class Main {
    int N;
    vector<int> A, B;
    void input() {
        cin >> N;
        A.resize(N);
        B.resize(N);
        REP(i, N) { cin >> A[i]; }
        REP(i, N) { cin >> B[i]; }
    }
    void output() {
        int prev = -1;
        int j = 0;
        REP(i, N) {
            if (A[i] != prev) j = 0;
            if (A[i] == B[i]) {
                for (; j < N; ++j) {
                    if (A[i] != B[j] && A[j] != B[i]) {
                        swap(B[i], B[j]);
                        break;
                    }
                }
                if (A[i] == B[i]) {
                    cout << "No" << endl;
                    return;
                }
            }
            prev = A[i];
        }
        cout << "Yes" << endl;
        REP(i, N) { cout << B[i] << " "; }
        cout << endl;
    }

public:
    Main() {
        input();
        output();
    }
};

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

    Main();

    return 0;
}


Measured memory_bytes: 4780
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>

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

	long long A, B;
	std::cin >> A >> B;

	std::vector<long long> h(N);
	for (int i = 0; i < N; i++) {
		scanf("%lld", &h[i]);
	}

	long long ok = 1e9;
	long long ng = 0;
	while (ok - ng > 1) {
		long long mid = (ok + ng) / 2;

		long long cnt = 0;
		for (int i = 0; i < N; i++) {
			cnt += (std::max(0LL, h[i] - mid * B) + A - B - 1) / (A - B);
		}
		if (cnt <= mid) {
			ok = mid;
		} else {
			ng = mid;
		}
	}
	std::cout << ok << std::endl;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define IO_OP std::ios::sync_with_stdio(0); std::cin.tie(0);
#define F first
#define S second
#define V vector
#define PB push_back
#define MP make_pair
#define EB emplace_back
#define ALL(v) (v).begin(), (v).end()
#define debug(x) cerr << #x << " is " << x << endl

using namespace std;

typedef long long ll;
typedef pair<int, int> pi;
typedef V<int> vi;

const int INF = 1e9 + 7, N = 10;

char a[N][N];

signed main()
{
	IO_OP;
	
	int h, w, k;
	cin >> h >> w >> k;
	for(int i = 0; i < h; i++)
		for(int j = 0; j < w; j++)
			cin >> a[i][j];
	int ans = 0;
	for(int mask = 0; mask < (1 << (h + w)); mask++) {
		int cnt = 0;
		for(int i = 0; i < h; i++) {
			for(int j = 0; j < w; j++) {
				if(mask >> i & 1) continue;
				if(mask >> (h + j) & 1) continue;
				cnt += a[i][j] == '#';
			}
		}
		if(cnt == k) ans++;
	}
	cout << ans << endl;
}





Measured memory_bytes: 3644
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int n = Integer.parseInt(sc.next());
        double sum = 0;
        for (int i = 0; i < n; i++) {
            double num = Double.parseDouble(sc.next());
            String key = sc.next();
            if (key.equals("JPY")) {
                sum += num;
            } else {
                sum += num * 380000.0;
            }
        }
        System.out.println(sum);

    }
}

Measured memory_bytes: 21844
#include<bits/stdc++.h>
using namespace std;
int sumsen(int n);

int main(){
	// sengen
	int n;
	// nyuryoku
	cin >> n;
	// keisan
	int f=sumsen(n);
	if(n%f == 0){
		cout << "Yes" << endl;
	}else{
		cout << "No" << endl;
	}
}

int sumsen(int n){
	int sum=0;
	while(n>0){
		sum += n%10;
		n /= 10;
	}
	return sum;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <boost/range/algorithm.hpp>
#include <boost/range/numeric.hpp>
#include <boost/range/irange.hpp>
#include <boost/range/adaptor/indexed.hpp>

using namespace std;
using namespace boost::adaptors;
using ll = int64_t;
using vecint = vector<int>;
using vecll = vector<ll>;
using boost::irange;

constexpr ll MOD = 998244353;

int main()
{
  ll n;
  cin>>n;
  string s;
  cin>>s;
  if (n == 1) {
    ll ans = 2;
    if (s[0] == '1') ans=4;
    cout<<ans<<endl;
    return 0;
  }
  ll n2 = n*2;
  string t = s;
  reverse(begin(t),end(t));
  bitset<400000> bs(t);
  vecll p2(n2+3);
  p2[0] = 1;
  for(ll i:irange(1l,n2+1)) {
    p2[i] = 2 * p2[i-1];
    p2[i] %= MOD;
  }
  map<ll,ll> dp;
  dp[1] = 0;
  vecll divs;
  for(ll d:irange(2l,n)) {
    if ((n2%d) != 0) continue;
    if ((d%2) != 0) continue;
    if ((n%d) == 0) continue;
    ll dh = d/2;
    ll sum = 0;
    ll mx = n;
    ll mn = n;
    vecll tmp(d+1, n);
    vecll tmp2(d+1, n);
    for (ll i:irange(0l,n)) {
      if (!bs.test(i)) {
        tmp[i%d] = min(tmp[i%d], i);
      } else {
        tmp2[i%d] = min(tmp2[i%d], i);
      }
    }
    for (ll i:irange(0l,dh)) {
      if (s[i] == '1') {
        sum += p2[dh-i-1];
        sum %= MOD;
        mx = min(mx, tmp[i]);
        mn = min(mn, tmp2[i+dh]);
      } else {
        mx = min(mx, tmp[i+dh]);
        mn = min(mn, tmp2[i]);
      }
    }
    if (mx >= mn) {
      ++sum;
      sum %= MOD;
    }
    ll sub = 0;
    for (ll e:divs) {
      if ((e%2) != 0) continue;
      ll eh = e/2;
      if ((dh%eh) != 0) continue;
      ll div = dh/eh;
      if ((div%2) != 0) {
        sub += dp[e];
        sub %= MOD;
      }
    }
    dp[d] = (MOD + sum - sub) % MOD;
    divs.push_back(d);
  }
  ll sum = 1;
  for (ll i:irange(0l,n)) {
    if (s[i] == '1') {
      sum += p2[n-i-1];
      sum %= MOD;
    }
  }
  ll sub = 0;
  for (ll e:divs) {
    if ((e%2) != 0) continue;
    ll eh = e/2;
    if (e >= n) continue;
    if ((n%eh) != 0) continue;
    ll div = n/eh;
    if ((div%2) != 0) {
      sub += dp[e];
      sub %= MOD;
    }
  }
  dp[n2] = (MOD + sum - sub) % MOD;
  ll ans = 0;
  for(auto& p : dp) {
    ans += p.second * p.first;
    ans %= MOD;
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 6112
package main

import "fmt"

func main() {
	var a, b int
	fmt.Scan(&a, &b)
	min := a * 2
	max := a * 4
	if b < min || b > max {
		fmt.Print("No")
		return
	}
	if (b-min)%2 != 0 {
		fmt.Print("No")
	} else {
		fmt.Print("Yes")
	}
}


Measured memory_bytes: 1816
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <algorithm>
#include <cctype>
#include <cmath>
#include <queue>
#include <map>
#include <numeric>
#include <unordered_map>
#include <iomanip>
#include <functional>
#include <bitset>
#include <complex>
#include <stack>
#include <cstdint>



#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define rrep(i, n) for(ll i = (ll)(n-1); i >= 0; i--)
#define repi(i,a,b) for(ll i=(ll)(a);i<(ll)(b);i++)
#define rrepi(i,a,b) for(ll i=(ll)(b);i>=(ll)(a);i--)

#define all(x) (x).begin(),(x).end()

template<class T>inline bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>inline bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

typedef long long ll;

using namespace std;


template <class Monoid>
class SegmentTree
{
public:
  using Func = function<Monoid(Monoid, Monoid)>;
  const Func F;
  const Monoid M1;
  int sz;
  vector<Monoid> seg;

  SegmentTree(int n,const Func fu, const Monoid &m1): F(fu) , M1(m1) {init(n);}
  void init(int n)
  {
      sz= 1;
      while (sz <= n) sz *= 2;
      seg.assign(sz * 2, M1);
  }
  void update(int k,const Monoid &x)
  {
    k+=sz;
    seg[k]=x;
    while(k>>=1)
    {
      seg[k]=F(seg[k*2],seg[k*2+1]);
    }
  }
  Monoid query(int l,int r)
  {
    Monoid L=M1,R=M1;
    l+=sz;r+=sz;
    for(;l<r;l>>=1,r>>=1)
    {
      if(l&1)L=F(L,seg[l++]);
      if(r&1)R=F(seg[--r],R);
    }
    return F(L,R);
  }
};

int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll n;cin>>n;
  vector<vector<ll>>ed(n);
  rep(i,n-1){
    ll a,b;cin>>a>>b;
    a--;b--;
    ed[a].push_back(b);
    ed[b].push_back(a);
  }
  using pll=pair<ll,ll>;
  auto f=[](pll a,pll b){return min(a,b);};
  SegmentTree<pll>st(n,f,{1e9,1e9});
  rep(i,n){
    st.update(i,{ed[i].size(),i});
  }
  vector<ll>c(n);
  rep(i,n)cin>>c[i];
  sort(all(c));
  vector<ll>res(n,-1);
  ll m=0;
  ll i=0;
  while(1){
    auto tp=st.query(0,n);
    ll id=tp.second;
    st.update(id,{1e9,n});
    res[id]=c[i++];
    if(i==n)break;
    for(auto nn:ed[id]){
      auto ttp=st.query(nn,nn+1);
      if(res[nn]==-1)m+=c[i-1];
      st.update(nn,{ttp.first-1,ttp.second});
    }
    ed[id].assign(ed[id].size(),-1);
  }
  cout<<m<<endl;
  rep(i,n)cout<<res[i]<<" ";
  cout<<endl;


  return 0;

}


Measured memory_bytes: 1664
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LINF = 1e18;
inline ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
inline ll lcm(ll a, ll b) { return a / gcd(a, b)*b; }
template<class S,class T> ostream& operator << (ostream& out,const pair<S,T>& o){ out << "(" << o.first << "," << o.second << ")"; return out; }
template<class T> ostream& operator << (ostream& out,const vector<T> V){ for(int i = 0; i < V.size(); i++){ out << V[i]; if(i!=V.size()-1) out << " ";} return out; }
template<class T> ostream& operator << (ostream& out,const vector<vector<T> > Mat){ for(int i = 0; i < Mat.size(); i++) { if(i != 0) out << endl; out << Mat[i];} return out; }
template<class S,class T> ostream& operator << (ostream& out,const map<S,T> mp){ out << "{ "; for(auto it = mp.begin(); it != mp.end(); it++){ out << it->first << ":" << it->second; if(mp.size()-1 != distance(mp.begin(),it)) out << ", "; } out << " }"; return out; }

/*
 <url:https://atcoder.jp/contests/dp/tasks/dp_f>
 問題文============================================================
 =================================================================
 解説=============================================================
 
 ================================================================
 */

template<class Type>
Type solve(Type res = Type()){
    string s,t; cin >> s >> t;
    vector<vector<int>> dp(s.length()+1,vector<int>(t.length()+1));
    for(int i = 1; i <= s.length();i++){
        for(int j = 1; j <= t.length();j++){
            if(s[i-1] == t[j-1]){
                dp[i][j] = dp[i-1][j-1] + 1;
            }else{
                dp[i][j] = max(dp[i][j-1],dp[i-1][j]);
            }
        }
    }
    int nows = (int)s.length(),nowt = (int)t.length();
    while(nows!=0 && nowt !=0){
        if(s[nows-1]==t[nowt-1]){
            res += s[nows-1];
            nows--;
            nowt--;
        }else{
            if(dp[nows][nowt-1] > dp[nows-1][nowt]){
                nowt--;
            }else{
                nows--;
            }
        }
    }
    reverse(res.begin(),res.end());
    return res;
}
int main(void) {
    cin.tie(0); ios_base::sync_with_stdio(false);
    // solve(0);
    cout << fixed << setprecision(15) << solve<string>() << endl;
    return 0;
}


Measured memory_bytes: 35584
#![allow(non_snake_case)]

use std::io::{stdin, Read};
use std::str::FromStr;
fn read_option<T: FromStr>() -> Option<T> {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok()
}
fn read<T: FromStr>() -> T {
    let opt = read_option();
    opt.expect("failed to parse token")
}

fn main() {
    let N: i64 = read();
    let K: i64 = read();
    println!("{}", std::cmp::min(N % K, K - (N % K)));
}


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

struct Edge {
    int to, cost;
    Edge(int t, int c): to(t), cost(c) {}
};

vector<int> V(100001);

vector<vector<Edge>> G(100001, vector<Edge>());

void dfs(int num, int color) {
    if (V.at(num) != -1) return;

    V.at(num) = color;

    for (int i = 0; i < (int)G.at(num).size(); i++)
    {
        if (G.at(num).at(i).cost % 2 == 0) dfs(G.at(num).at(i).to, color);
        else dfs(G.at(num).at(i).to, color ^ 1);
    }
    return;
}

int main() {
    int n;
    cin >> n;
    int u, v, w;
    for (int i = 0; i < n; i++)
    {
        V.at(i + 1) = -1;
    }
    
    for (int i = 0; i < n - 1; i++)
    {
        cin >> u >> v >> w;
        G.at(u).push_back(Edge(v, w));
        G.at(v).push_back(Edge(u, w));
    }

    dfs(1, 0);

    for (int i = 1; i <= n; i++)
    {
        cout << V.at(i) << endl;
    }
    
}

Measured memory_bytes: 9216
#include<iostream>
#include<string>
#include<string.h>
#include<map>
#include<set>
#include<vector>
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<queue> 
using namespace std;
int main() 
{int x,y,j;
 cin>>x>>y;
 for (int i=0;i<=x;i++){
  for (int k=0;k<=x-i;k++){
  j=x-i-k;
   if (i*10000+k*5000+j*1000==y ){  
 cout<<i<<" "<<k<<" "<<j<<" ";
 system("pause");
 return 0;}}}
 cout<<-1<<" "<<-1<<" "<<-1;
 system("pause");
 return 0;
}        

Measured memory_bytes: 504
//ehhhhh...... i hate you......

/* optimizations and other useless stuff*/
#pragma warning(disable:4996)
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize ("-ffloat-store")
#include<bits/stdc++.h>
#define FastIO ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define MOD 1000000007
#define INF 1e14
#define ull unsigned long long int
using namespace std;
/* TYPE DEFINITIONS */
typedef     long long int   ll;
typedef     vector<ll>      vi;
typedef     pair<ll,ll>     pi;


/* Basic  Math!!! */
bool isPrime(ull n) 
{ 
    if (n <= 1)  return false; 
    if (n <= 3)  return true; 
    if (n%2 == 0 || n%3 == 0) return false; 
  
    for (ull i=5; i*i<=n; i=i+6) 
        if (n%i == 0 || n%(i+2) == 0) 
           return false; 
  
    return true; 
} 
ll ncr(int n, int k)  
{  
    ll res = 1;  
    if ( k > n - k )  
        k = n - k;  
    for (int i = 0; i < k; ++i)  
    {  
        res *= (n - i);  
        res /= (i + 1);  
    }  
  
    return res;  
} 

/* MACROS */
#define  all(A)         (A).begin() , (A).end()
#define  rall(A)        (A).rbegin() , (A).rend()
#define  sz(A)          (int)(A).size()
#define  pb             push_back
#define  ppb            pop_back
#define  mp             make_pair
#define  ln(X)          (int)(X).length()
#define  square(X)      ((X)*(X))
#define  cube(X)        ((X)*(X)*(X))
#define  forn(i, n)  for (int i = 0; i < int(n); i++)
#define  forr(i, n)  for (int i = int(n - 1); i >= 0; i--)
#define  fora(i, a, b)  for (int i = int(a); i <= int(b); i++)
#define  forb(i, a, b)  for (int i = int(a); i >= int(b); i--)
#define  fore(it, a)    for(__typeof((a).sbegin()) it = (a).begin(); it != (a).end(); it++)  
ll dp[1005][1005];
void solve()
{
    int n,m;
    cin>>n>>m;
    char grid[n][m];
    forn(i,n)forn(j,m)cin>>grid[i][j];
    dp[1][1]=1;
    for(int i=1;i<=n;i++)
    {
        for(int j=1;j<=m;j++)
        {
            if(grid[i-1][j-1]=='#')
            {
                dp[i][j]=0;
                continue;
            }
            dp[i][j]+=(dp[i-1][j]+dp[i][j-1])%MOD;
        }
    }
   /* forn(i,n)
    {
        forn(j,m)cout<<dp[i][j]<<" ";
        cout<<endl;
    }*/
    cout<<dp[n][m]<<endl;
}

int main()
{
    FastIO;
    ll c=0;
    ll t=1;
   // cin>>t;
    while(t--)
    {
        //cout<<"Case "<<++c<<": ";
        solve();
    }
    return 0;
}

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

int main() {
int N,K,S;
cin >>N>>K;
S=1;
rep(i,N){


if((S+K)<S*2){
S+=K;
}
else{
S*=2;
}
}
  cout<<S<<endl;
}


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

public class Main {
    public static void main(String[] args) throws IOException{
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();
        for(int i=0;i<3; i++){
            int x;
            if(a>b){
                x=a;
                a=b;
                b=x;
            }
            if(b>c){
                x=b;
                b=c;
                c=x;
            }
        }
        System.out.println(a+" "+b+" "+c);

    }
}

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

using namespace std;

int main(){
  vector<int> a(5);
  for(int i=0;i<5;i++){
    cin >> a[i];
  }
  int k; cin >> k;
  string s="Yay!";
  for(int i=0;i<5;i++){
    for(int j=i+1;j<5;j++){
      if(abs(a[i]-a[j])>k){
        s=":(";
      }
    }
  }
  cout << s << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
 
#define el '\n'
#define MOD 1000000007
int n, vis[100005], col[100005];
vector<int> adjList[100005];
map<pair<int,int>, int> mp;
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    cin >> n;
    for(int i=1;i<=n-1;i++){
        int a,b,c;
        cin >> a >> b >> c;
        if(mp.find(make_pair(min(a,b), max(a,b)))==mp.end()){
            mp[make_pair(min(a,b), max(a,b))]=c%2;
        }
        adjList[a].push_back(b);
        adjList[b].push_back(a);
    }

    queue<int> q;
    vis[1]=1;
    q.push(1);
    col[1]=1;
    while(!q.empty()){
        int fr = q.front();
        q.pop();
        for(auto x:adjList[fr]){
            if(!vis[x]){
                if(mp[make_pair(min(fr, x), max(fr, x))]==0){
                    col[x]=col[fr];
                } else {
                    col[x]=-1*col[fr];
                }
                vis[x]=1;
                q.push(x);
            }
        }
    }
    for(int i=1;i<=n;i++){
        if(col[i]==-1){
            cout << 0 << el;
        } else {
            cout << 1 << el;
        }
    }
    return 0;
}

Measured memory_bytes: 13056
#include <stdio.h>
#include <algorithm>
using namespace std;
using ll = long long;

int l, r, t[2019];
int count(int a) {
	return (r - a + 2019) / 2019 - (l - a - 1 + 2019) / 2019;
}
int main() {
	scanf("%d %d", &l, &r);
	for (int i = 0; i < 2019; i++)
		t[i] = count(i);
	int min_c = 1e9;
	for (int i = 0; i < 2019; i++) {
		if (!t[i])
			continue;
		if (2 <= t[i])
			min_c = min(min_c, i * i % 2019);
		for (int j = i + 1; j < 2019; j++)
			if (t[j])
				min_c = min(min_c, i * j % 2019);
	}
	printf("%d\n", min_c);
}

Measured memory_bytes: 128
#include <iostream>
#include <cstring>
#include <algorithm>
#include <vector>
#include <string>
#include <math.h>
#include <stdio.h>
#include <iomanip>
#include <limits>
#include <list>
#include <queue>
#include <tuple>
#include <map>
#include <sstream>
using namespace std;
#define MOD (long long int)(1e9+7)
#define ll long long int
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define reps(i,n) for(int i=1; i<=(int)(n); i++)
#define REP(i,n) for(int i=n-1; i>=0; i--)
#define REPS(i,n) for(int i=n; i>0; i--)
#define FOR(i,a,b) for(int i=a; i<(int)(b); i++)
#define ALL(x) (x).begin(),(x).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define SORT(c) sort(ALL(x))
#define CLR(a) memset((a), 0 ,sizeof(a))
#define PB push_back
#define MP make_pair
#define SP << " " <<
const int INF = 1001001001;
const ll LINF = 100100100100100100;
const double EPS = 1e-10;
const double PI  = acos(-1.0);
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector<VI> VVI;

template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

__attribute__((constructor))
void initial(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(15);
}
const int N = 100100;
vector<bool> flag(N);
VVI G(N); vector<ll> X(N); VI cnt(N);

void bfs(int now, int x){
  if(flag[now]) return;
  flag[now] = true;
  cnt[now] =  X[now] + x;
  rep(i, G[now].size()){
    int next = G[now][i];
    bfs(next, cnt[now]);
  }
}

signed main(){
	int n,q; cin>>n>>q;
  // VVI G; VI C;
  // vector<bool> flag(n);
  rep(i,n){
    VI g; G.PB(g);
  }
  rep(i,n-1){
    int a,b; cin>>a>>b;
    a--; b--;
    G[a].PB(b); G[b].PB(a);
    X.PB(0); flag.PB(false); cnt.PB(0);
  }
  X.PB(0); flag.PB(false); cnt.PB(0);
  rep(i,q){
    int p,x; cin>>p>>x; p--;
    X[p] += x;
  }
  // sort(ALL(C));

  bfs(0,0);
  rep(i,n) cout << cnt[i] << ' ';
  cout << endl;
  return 0;
}


Measured memory_bytes: 28132
import sys
input = sys.stdin.readline

def main():
  n,m,k = map(int, input().split())
  a = list(map(int, input().split()))
  b = list(map(int, input().split()))
  sa = [0] * (n+1)
  sb = [0] * (m+1)
  for i in range(n):
    sa[i+1] = sa[i] + a[i]
  for i in range(m):
    sb[i+1] = sb[i] + b[i]
  rx = 0
  rb = m
  for ra in range(0,n+1): 
    while (sb[rb] + sa[ra]) > k and rb>0 :
      rb-=1
    if (sb[rb] + sa[ra]) <= k:
      rx = max(rx,ra+rb)
  print(rx)

if __name__ == '__main__':
    main()

Measured memory_bytes: 47828
# import sys
# sys.setrecursionlimit
# from collections import defaultdict

geta = lambda fn: list(map(fn, input().split()))

a, b, c, k = geta(int)

if k <= a:
    print(k)
elif k <= a + b:
    print(a)
else:
    print(a - (k - a - b))


Measured memory_bytes: 61644
#include<iostream>
using namespace std;
int main(){
	int n;
  cin>>n;
  int freq[4];
  for(int i=0;i<4;i++)freq[i]=0;
  for(int i=0;i<n;i++){
  	string s;
    cin>>s;
    if(s=="AC")freq[0]++;
    else if(s=="WA")freq[1]++;
    else if(s=="TLE")freq[2]++;
    else freq[3]++;
  }
  cout<<"AC x "<<freq[0]<<endl;
  cout<<"WA x "<<freq[1]<<endl;
  cout<<"TLE x "<<freq[2]<<endl;
  cout<<"RE x "<<freq[3]<<endl;
  return 0;
}

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

int main(void)
{
    int n;
    cin >> n;
    vector<ll> R(n);
    rep(i, n)
    {
        cin >> R.at(i);
    }
    
    ll ma = -10000000000;
    ll mi = R.at(0);
    repd(i, 1, n)
    {
        ma = max(ma, R.at(i) - mi);
        mi = min(mi, R.at(i));
    }
    cout << ma << endl;
}



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

int w, h, ans;
int d[4][2] = { { 1, 0 }, { -1, 0 }, {0, 1}, {0, -1} };
char map[20][20];

void search_dfs(int x, int y){
	if( x < 0 || x >= w || y < 0 || y >= h ) return;
	if( map[y][x] != '.' ) return;
	ans ++;
	map[y][x] = '*';
	for(int i = 0; i < 4; i++)
		search_dfs( x + d[i][0], y + d[i][1] );
}

int main(void){

	while( 1 ) {
		cin >> w >> h;
		if( w == 0 && h == 0 ) break;
		ans = 0;

		for(int i = 0; i < h; i++)
			cin >> map[i];

		for(int i = 0; i < h; i++)
			for(int j = 0; j < w; j++)
				if( map[i][j] == '@' ) {
					map[i][j] = '.';
					search_dfs(j, i);
				}

		cout << ans << endl;
	}

	return 0;
}

Measured memory_bytes: 1164
N, M = map(int, input().split())
A = list(map(int, input().split()))
C = []
for i in range(M):
    b, c = map(int, input().split())
    C.append([c, b])
A.sort()
C.sort(reverse=True)
ans = 0
k = 0
c = C[k][0]
minC = min(C)
b = 1
flg = False
for i in range(N):
    if flg == True:
        ans += A[i]
    elif b <= C[k][1]:
        ans += max(A[i], c)
        b += 1
    else:
        if k < len(C) - 1:
            k += 1
            c = C[k][0]
            b = 1
            ans += max(A[i], c)
            b += 1
        else:
            flg = True
            ans += A[i]
print(ans)


Measured memory_bytes: 76824
#include <stdio.h>
#define N 100000
#define F 0
#define T 1

typedef struct {
  char c;
  int value;
  int id;
} cards;

cards A[N];

int partition(int p, int r) {
  int i, j, x;
  cards tmp;

  x = A[r].value;
  i = p-1;
  for (j = p; j < r; j++) {
    if(A[j].value <= x) {
      i++;
      tmp = A[i];
      A[i] = A[j];
      A[j] = tmp;
    }
  }
  tmp = A[i+1];
  A[i+1] = A[r];
  A[r] = tmp;
  return i+1;
}

void quickSort(int p, int r) {
  int q;
  if (p < r) {
    q = partition(p, r);
    quickSort(p, q-1);
    quickSort(q+1, r);
  }
}

int isStable(int n) {
  int i;
  for(i = 0; i < n-1; i++) {
    if(A[i].value == A[i+1].value && A[i].id > A[i+1].id) return F;
  }
  return T;
}


int main() {
  int n, i;

  scanf("%d", &n);
  for(i = 0; i < n; i++) {
    scanf("%s %d", &A[i].c, &A[i].value);
    A[i].id = i;
  }

  quickSort(0, n-1);

  if(isStable(n) == F) printf("Not stable\n");
  else printf("Stable\n");
  for (i = 0; i < n; i++ ){;
    printf("%c %d\n", A[i].c, A[i].value);
  }
  return 0;

}

Measured memory_bytes: 1784
//{{{
#include <bits/stdc++.h>
using namespace std;
#define repX(a,b,c,x,...) x
#define repN(a) repX a
#define rep(...) repN((__VA_ARGS__,rep3,rep2,loop))(__VA_ARGS__)
#define rrep(...) repN((__VA_ARGS__,rrep3,rrep2))(__VA_ARGS__)
#define loop(n) rep2(i_,n)
#define rep2(i,n) rep3(i,0,n)
#define rep3(i,begin,end) for(int i=(int)(begin),i##_end=(int)(end);i<i##_end;++i)
#define rrep2(i,n) rrep3(i,n,0)
#define rrep3(i,begin,end) for(int i=(int)(begin-1),i##_end=(int)(end);i>=i##_end;--i)
#define foreach(x,a) for(auto&x:a)
using ll=long long;
const ll mod=(ll)1e9+7;
//}}}

bool left_check(string &s, int Q, int N, int pos, vector<char> &t, vector<char> &d)
{
  char c = s[pos];
  rep(i, Q){
    if(t[i] == c){
      pos += d[i] == 'L' ? -1 : 1;
      if(pos < 0) return false;
      c = s[pos];
    }
  }
  return true;
}

bool right_check(string &s, int Q, int N, int pos, vector<char> &t, vector<char> &d)
{
  char c = s[pos];
  rep(i, Q){
    if(t[i] == c){
      pos += d[i] == 'L' ? -1 : 1;
      if(pos >= N) return false;
      c = s[pos];
    }
  }
  return true;
}

int main()
{
  int N, Q;
  string s;
  cin >> N >> Q;
  cin >> s;
  vector<char> t(Q);
  vector<char> d(Q);
  rep(i, Q){
    cin >> t[i] >> d[i];
  }
  int ans = N;
  {
    int ok = N;
    int ng = -1;
    while(ok - ng > 1){
      int mid = (ok + ng) / 2;
      (left_check(s, Q, N, mid, t, d) ? ok : ng) = mid;
    }
    ans -= ng + 1;
  }
  {
    int ok = -1;
    int ng = N;
    while(ng - ok > 1){
      int mid = (ok + ng) / 2;
      (right_check(s, Q, N, mid, t, d) ? ok : ng) = mid;
    }
    ans -= N - ng;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 900
#include <bits/stdc++.h>
#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define trav(a, x) for(auto& a : x)
#define all(x) x.begin(), x.end()
#define endl "\n"
#define sz(x) (int)(x).size()
using namespace std;
typedef long long int lli;
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;

int main() {
    int l;
    cin >> l;
    double x = l / 3.0;
    cout << fixed << setprecision(12) << x*x*x << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int D;
      // 最大 200 個なので余裕を持って 210 に --- 200 以上ならなんでもよいです

int main() {
    cin >> D;
    if(D==25){
        cout << "Christmas" << endl;
    }else if(D==24){
        cout << "Christmas Eve" << endl;
    }else if(D==23){
        cout << "Christmas Eve Eve" << endl;
    }else{
        cout << "Christmas Eve Eve Eve" << endl;
    }




}

Measured memory_bytes: 256
#include<stdio.h>

int main(void){
   int n,highest,i,ryokan=1;
   scanf("%d",&n);

   int h[n];
   for(i=0;i<n;i++)
      scanf("%d",&h[i]);

   highest=h[0];
   for(i=1;i<n;i++)
      if(h[i]>=highest){ryokan++; highest=h[i];}

   printf("%d\n",ryokan);
   return 0;
}

Measured memory_bytes: 128
#include <stdio.h>

int solve(int n) {
        if(n % 2 == 0) return 1 + solve(n / 2);
        else return 0;
}

int main() {
        int n, maxnth = 1, maxn = 0;
        scanf("%d", &n);
        for(int i = 1; i <= n; i++) {
                int k=solve(i);
                if(maxn < k) { maxn = k; maxnth = i; }
        }
        printf("%d\n", maxnth);
}

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

int main(){
  char S[3];
  scanf("%s", S);;
  
  if(strcmp(S,"SUN") == 0) printf("7");
  if(strcmp(S,"MON") == 0) printf("6");
  if(strcmp(S,"TUE") == 0) printf("5");
  if(strcmp(S,"WED") == 0) printf("4");
  if(strcmp(S,"THU") == 0) printf("3");
  if(strcmp(S,"FRI") == 0) printf("2");
  if(strcmp(S,"SAT") == 0) printf("1");
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
#define ll long long
const unsigned int M = 1000000007;
int main(){
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    char a[11],b[11],c[11];
    while(cin>>a>>b>>c){
        char s[4];
        s[0]=toupper(a[0]);
        s[1]=toupper(b[0]);
        s[2]=toupper(c[0]);
        s[3]='\0';
        cout<<s<<endl;
    }
}


Measured memory_bytes: 256
import java.util.*;
public class Main{
    public static void main(String[] args){
	new Main().run();
    }
    Scanner sc = new Scanner(System.in);

    void run(){
	while(sc.hasNext()){
	    String s = sc.nextLine();
	    char[] c = s.toCharArray();
	    int x = 'A' - 'a';
	    String ans = "";
	    for(int i=0; i<c.length; i++){
		if(c[i]-'a'>=0 && c[i]-'z'<=0)
		    c[i] = (char)(c[i]+x);
		ans += Character.toString(c[i]);
	    }
	    System.out.println(ans);
	}
    }
}
	 

Measured memory_bytes: 15388
using System;
using System.Linq;

namespace ABC064
{
    class D
    {
        static void Main(string[] args)
        {
            int N = int.Parse(Console.ReadLine());
            string S = Console.ReadLine();

            int need_left = 0;
            int need_right = 0;

            for (int i = 0; i < S.Length; i++)
            {
                if (S[i] == '(') need_right++;
                else
                {
                    if (0 < need_right) need_right--;
                    else need_left++;
                }
            }

            string res = "";
            for (int i = 0; i < need_left; i++) res += '(';
            res += S;
            for (int i = 0; i < need_right; i++) res += ')';

            Console.WriteLine(res);

        }
    }
}

Measured memory_bytes: 13140
import math
a,b,h,m=(int(x) for x in input().split())
hk=30*h+1/2*m
mk=6*m
kakudo=hk-mk
if kakudo>180:
    kakudo=360-kakudo
print((a**2+b**2-2*a*b*(math.cos(math.radians(kakudo))))**(1/2))


Measured memory_bytes: 9568
n=int(input())
a=[int(i) for i in input().split()]
check=[]
if n%2==0:
    for i in range(1,n,2):
        check+=[i,i]
else:
    check+=[0]
    for i in range(2,n,2):
        check+=[i,i]
if check==sorted(a):
    print((2**(n//2))%(10**9+7))
else:
    print(0)


Measured memory_bytes: 13880
/* atcoder */
#include "bits/stdc++.h"
using namespace std;

/* typedef */
/* long系 */
typedef long long ll;   // long long
typedef long double ld; // long double
/* vector系 */
typedef vector<int> vi;                    // intのvector
typedef vector<double> vd;                 // doubleのvector
typedef vector<ll> vll;                    // llのvector
typedef vector<ld> vld;                    // ldのvector
typedef vector<vector<int>> vvi;           // intの2次元vector
typedef vector<vector<double>> vvd;        // doubleの2次元vector
typedef vector<vector<ll>> vvll;           // llの2次元vector
typedef vector<vector<ld>> vvld;           // ldの2次元vector
typedef vector<pair<int, int>> vi_i;       // i_iのvector
typedef vector<pair<double, double>> vd_d; // d_dのvector
typedef vector<pair<ll, ll>> vl_l;         // l_lのvector
typedef vector<pair<ld, ld>> vld_ld;       // ld_ldのvector
typedef vector<string> vs;                 // stringのvector
/* pair系 */
typedef pair<int, int> i_i;       // int同士のpair
typedef pair<double, double> d_d; // double同士のpair
typedef pair<ll, ll> l_l;         // ll同士のpair
typedef pair<ld, ld> ld_ld;       // ld同士のpair

/* define */
#define all(v) v.begin(), v.end() // コンテナ全体
#define PI (acos(-1))             // 円周率pi

/* stringstream */
stringstream ss;
stringstream init_ss; // save default formatting

/* main */
void Main(void)
{
    while (true)
    {
        int n, x;
        cin >> n >> x;
        if (n == 0 && x == 0)
        {
            return;
        }
        int ans = 0;
        for (int i = 1; i <= n; i++)
        {
            for (int j = 1; j <= n; j++)
            {
                for (int k = 1; k <= n; k++)
                {
                    if (i == j || j == k || k == i)
                    {
                        continue;
                    }
                    else
                    {
                        if (i + j + k == x)
                        {
                            ans++;
                        }
                    }
                }
            }
        }
        cout << ans / 6 << endl;
    }
}

int main(int argc, char const *argv[])
{
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    Main();

    return 0;
}



Measured memory_bytes: 3192
#include "bits/stdc++.h"
using namespace std;

int main() {
	long long n, s;
	cin >> n >> s;
	if (n == s) {
		cout << n + 1 << endl;
		return 0;
	}
	for (int i = 2; i <= sqrt(n); ++i) {
		long long tmpn = n;
		long long tmps = 0;
		while (tmpn > 0) {
			tmps += tmpn % i;
			tmpn /= i;
		}
		if (tmps == s) {
			cout << i << endl;
			return 0;
		}
	}
	{
		for (int i = sqrt(n); i >= 1; --i) {
			if (0 != (n - s) % i) {
				continue;
			}
			long long b = (n - s) / i + 1;
			if ((0 == b) || (1 == b)) {
				continue;
			}
			if (n/b >= b) {
				continue;
			}
			if (s == (n / b + n % b)) {
				cout << b << endl;
				return 0;
			}
		}
	}
	cout << -1 << endl;
}


Measured memory_bytes: 3668
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++) //for文マクロ
using namespace std;

typedef unsigned long ul;
typedef long long ll;
typedef pair<ul, ul> P; //ペア　タイプでふ

int main()
{
    int a;
    cin >> a;
    if (a < 1000)
    {
        cout << "ABC";
    }else
    {
        cout << "ABD";
    }
    
}

Measured memory_bytes: 256
/*** author: yuji9511 ***/
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> lpair;
const ll MOD = 1e9 + 7;
const ll INF = 1e18;
#define rep(i,m,n) for(ll i = (m); i < (n); i++)
#define rrep(i,m,n) for(ll i = (m); i >= (n); i--)
#define print(x) cout << (x) << endl;
#define print2(x,y) cout << (x) << " " << (y) << endl;
#define printa(x,n) for(ll i = 0; i < n; i++){ cout << (x[i]) << " \n"[i==n-1];};
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N,K;
    cin >> N >> K;
    string S;
    cin >> S;
    vector<ll> v;
    ll cnt = 1;
    rep(i,0,N-1){
        if(S[i] != S[i+1]){
            v.push_back(cnt);
            cnt = 1;
        }else{
            cnt++;
        }
    }
    v.push_back(cnt);
    // printa(v, v.size());
    ll m = v.size();
    vector<ll> v2;
    cnt = 1;
    string T = S.substr(0,1);
    rep(i,0,N-1){
        if(S[i] != S[i+1]){
            v2.push_back(cnt);
            cnt = 1;
        }else{
            cnt++;
        }
        if(v2.size() % 2 == 1){
            if((v2.size() + 1) / 2 <= K){
                if(S[i+1] == 'L'){
                    T += 'R';
                }else{
                    T += 'L';
                }
            }else{
                T += S[i+1];
            }
        }else{
            T += S[i+1];
        }
    }
    ll ans = 0;
    rep(i,0,N){
        if(T[i] == 'L'){
            if(i != 0 && T[i-1] == 'L') ans++;
        }else{
            if(i != N-1 && T[i+1] == 'R') ans++;
        }
    }
    print(ans);


    
}

Measured memory_bytes: 3012
// D - Lucky PIN
#include <bits/stdc++.h>
using namespace std;

int main(){
	int N; string S; cin>>N>>S;
	int ans = 0;
	for(int i=0; i<1000; i++)
		for(int p=-1, d=100; d; d/=10){
			p = S.find(i/d%10+'0', p+1); if(p<0) break;
			if(d==1){ ans++; break; }
		}
	cout<< ans <<endl;
}

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

int main() {
  string a,b;
  cin>>a>>b;
  int c=0;
  for(int i=0;i<3;i++){
    if(a[i]==b[i]) c++;
  }
  cout<<c<<endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define f(i,n) for(ll i=0;i<n;i++)
ll gcdExtended(ll a, ll b, ll *x, ll *y); 
  
// Function to find modulo inverse of b. It returns 
// -1 when inverse doesn't 
ll modInverse(ll b, ll m) 
{ 
    ll x, y; // used in extended GCD algorithm 
    ll g = gcdExtended(b, m, &x, &y); 
  
    // Return -1 if b and m are not co-prime 
    if (g != 1) 
        return -1; 
  
    // m is added to handle negative x 
    return (x%m + m) % m; 
} 
  
// Function to compute a/b under modlo m 
ll modDivide(ll a, ll b, ll m) 
{ 
    a = a % m; 
    ll inv = modInverse(b, m);
    return  (inv * a) % m;
    // if (inv == -1) 
    //    cout << "Division not defined"; 
    // else
    //    cout << "Result of division is " <<  
} 
  
// C function for extended Euclidean Algorithm (used to 
// find modular inverse. 
ll gcdExtended(ll a, ll b, ll *x, ll *y) 
{ 
    // Base Case 
    if (a == 0) 
    { 
        *x = 0, *y = 1; 
        return b; 
    } 
  
    ll x1, y1; // To store results of recursive call 
    ll gcd = gcdExtended(b%a, a, &x1, &y1); 
  
    // Update x and y using results of recursive 
    // call 
    *x = y1 - (b/a) * x1; 
    *y = x1; 
  
    return gcd; 
}

ll binomial_coefficient(ll n, ll r) 
{ 
    ll m = 1000000007;
    ll res = 1; 
  	for(ll i=1;i<=n;i++)
  		res = (res*i)%m;
  	for(ll i=1;i<=r;i++)
  		res = modDivide(res,i,m);
  	for(ll i=1;i<=n-r;i++)
  		res= modDivide(res,i,m);
    	
    return res; 
  	
} 
  
int main(){
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll s;
    cin >> s;
    ll ans=0;
    for(ll i=1;i<=s;i++){
    	ll k = s - i*3;
    	if(k>=0)
    	{ll p = binomial_coefficient(k+i-1,i-1);
    	// cout << p << endl;
    	ans += p;
    	ans = ans%1000000007;}
    }
    cout << ans << endl;

	return 0;
}

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

int main()
{
  char str_s[100], str_p[100], str_s2[200];
  int i, j, flag;
  int s_len, p_len;

  gets(str_s);
  gets(str_p);

  s_len = strlen(str_s);
  p_len = strlen(str_p);
  sprintf(str_s2, "%s%s", str_s, str_s);

  for (i = 0; i < s_len; i++) {
    flag = 1;
    for (j = 0; j < p_len; j++) {
      if (str_s2[i + j] != str_p[j]) {
        flag  = 0;
        break;
      }
    }
    if (flag == 1) {
      break;
    }
  }

  if (flag == 1) {
    printf("Yes\n");
  } else {
    printf("No\n");
  }

  return 0;
}

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

#include <ext/pb_ds/assoc_container.hpp> //required
#include <ext/pb_ds/tree_policy.hpp> //required

using namespace __gnu_pbds; 
using namespace std;

template <typename T> using ordered_set =  tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>; 
typedef long long  ll;
typedef vector<ll> VL;
typedef pair<ll,ll> PLL;
#define pb push_back
#define F first
#define S second
#define ALL(a) a.begin(),a.end()
#define fr(i,x,y) for(ll i=x;i<y;i++)
#define frr(i,x,y) for(ll i=x-1;i>=y;i--)
#define inf 10000000000000000
const ll mod=998244353;
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}

void solve()
{
	ll k;
	cin>>k;
	queue<ll> q;
	fr(i,1,10)
	{
		q.push(i);
	}
	fr(i,0,k-1)
	{
		ll y=q.front();
		q.pop();
		if(y%10!=0)
		{
			q.push(10*y+(y%10)-1);

		}
		q.push(10*y+(y%10));
		if(y%10!=9)
		{
			q.push(10*y+(y%10)+1);

		}
	}
	cout<<q.front()<<endl;
	//cout<<"\n";
	//cout<<ct<<endl;
	return;
}
int main()
{
	ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
	solve();
	return 0;
}

Measured memory_bytes: 1792
n = int(input())
a,w,t,r = 0,0,0,0
for i in range(n):
  tmp = input()
  if tmp=='AC':
    a+=1
  elif tmp=='WA':
    w+=1
  elif tmp=='TLE':
    t+=1
  else:
    r+=1
print('AC x '+str(a))
print('WA x '+str(w))
print('TLE x '+str(t))
print('RE x '+str(r))

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

int main(){
	int n;
	scanf("%d",&n);
	char w[n][11];int i,j;
	for(i=0;i<n;i++)scanf("%s",w[i]);
	for(i=0;i<n;i++){
		for(j=i+1;j<n;j++){
			if(strcmp(&w[i][0],&w[j][0])==0){
				puts("No");
				return 0;
			}
		}
	}
	for(i=0;i<n-1;i++){
		j=0;
		while(w[i][j]!=0)j++;
		if(w[i][j-1]!=w[i+1][0]){
			puts("No");
			return 0;
		}
	}
	puts("Yes");
	return 0;
}

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

int main() {
	char a;
	int b = 0;
	rep(i, 4) {
		cin >> a;
		if (a == '+') {
			b++;
		}
		else {
			b--;
		}
	}
	cout << b << endl;
}

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

using namespace std;

using int64 = long long;
using pi = pair< int, int >;
const int64 INF = 1LL << 60;

int main() {
  int N;
  cin >> N;
  vector< pi > A;
  int64 latte = 0, malta = 0;
  for(int i = 0; i < N; i++) {
    int x, y;
    cin >> x >> y;
    A.emplace_back(x, i);
    A.emplace_back(y, i);
    latte += x;
    malta += y;
  }
  sort(begin(A), end(A));
  bool f = false;
  int used[100000] = {};
  int64 sum = 0;
  for(int i = 0; i < N; i++) {
    if(used[A[i].second]++ >= 1) f = true;
    sum += A[i].first;
  }
  int64 ret = f ? sum : INF;
  for(int i = 0; i < N; i++) {
    for(int j = N; j < N + 2; j++) {
      if(A[i].second == A[j].second) {
        if(i + 1 == N) {
          ret = min(ret, sum - A[N - 2].first + A[j].first);
        } else {
          ret = min(ret, sum - A[N - 1].first + A[j].first);
        }
        break;
      }
    }
  }
  cout << min(ret, min(latte, malta)) << endl;
}


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

int main() {
  int N,A,x;
  cin >> N >> A;
  x = N % 500 - A;
  if(x > 0){
    cout << "No" << endl;
  }
  else{
    cout << "Yes" << endl;
  }
}
   

Measured memory_bytes: 256
import java.util.*;
import java.awt.geom.*;
public class Main {
	
	class C{
		int x,y;

		public C(int x, int y) {
			this.x = x;
			this.y = y;
		}
		
	}
	
	//2310 start
	private void doit(){
		Scanner sc = new Scanner(System.in);
		while(true){
			int h = sc.nextInt();
			int w = sc.nextInt();
			
			if(w == 0 && h == 0) break;
			char [][] data = new char[h][w];
			for(int i = 0; i < h; i++){
				String s = sc.next();
				for(int j = 0 ; j < w; j++){
					data[i][j] = s.charAt(j);
				}
			}
			
			LinkedList<C> open = new LinkedList<C>();
			open.add(new C(0,0));
			boolean [][] close = new boolean[h][w];
			
			while(! open.isEmpty()){
				C now = open.removeFirst();
				if(close[now.y][now.x]){
					System.out.println("LOOP");
					break;
				}
				close[now.y][now.x] = true;
				switch(data[now.y][now.x]){
				case '>':
					open.add(new C(now.x + 1, now.y));
					break;
				case '<':
					open.add(new C(now.x -1, now.y));
					break;
				case 'v':
					open.add(new C(now.x, now.y + 1));
					break;
				case '^':
					open.add(new C(now.x, now.y - 1));
					break;
				case '.':
					System.out.println(now.x + " " + now.y);
					break;
				}
			}
		}
	}

	public static void main(String[] args) {
		Main obj = new Main();
		obj.doit();
	}
}

Measured memory_bytes: 12000
/*dismint|jjc*/
#include <bits/stdc++.h>
using namespace std;
#define forl(V, S, E) for(int V = S; V < E; V++)
#define ford(V, S, E) for(int V = S; V >= E; V--)
#define fore(E, X) for(auto &E:X)
#define println(X) cout << X << endl
#define printe(X) for(auto &E:X) cout << E << " "; cout << endl
typedef unordered_map<int, unordered_set<int>> graph;
typedef long long ll;

int a[100001], b[100001], c[100001], da[10001], db[100001], dc[100001];

int main() {
	int n; cin >> n;
	forl(i, 0, n) cin >> a[i] >> b[i] >> c[i];
	da[0] = a[0]; db[0] = b[0]; dc[0] = c[0];
	forl(i, 1, n) {
		da[i] = a[i] + max(db[i-1], dc[i-1]);
		db[i] = b[i] + max(da[i-1], dc[i-1]);
		dc[i] = c[i] + max(da[i-1], db[i-1]);
	}
	println(max(da[n-1], max(db[n-1], dc[n-1])));
}


Measured memory_bytes: 2176
"use strict";
    
const main = arg => {
    arg = arg.trim().split("\n");
    const A = parseInt(arg[0].split(" ")[0]);
    
    console.log(A + Math.pow(A, 2) + Math.pow(A, 3));
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 29684
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.List;

/**
 * 0004：Simultaneous Equation
 * 
 * @author Lyu
 * @version 2015/07/12
 */
public class Main {

    /** 区切り文字：スペース */
    protected static final String DELIMITER_SPACE = " ";

    /**
     * 連立方程式<br>
     * <p>
     * ax + by = c<br>
     * dx + ey = f
     * </p>
     * の解を出力する。
     * 
     * @param args
     * @throws IOException
     */
    public static void main(String[] args) throws IOException {

        List<String[]> dataSets = getInput();

        for (int i = 0; i < dataSets.size(); ++i) {
            BigDecimal[] dataSet = toBigDecimalArray(dataSets.get(i));

            System.out.println(getX(dataSet) + DELIMITER_SPACE + getY(dataSet));
        }
    }

    private static BigDecimal getX(BigDecimal[] dataSet) {
        return dataSet[1]
                .multiply(dataSet[5])
                .subtract(dataSet[2].multiply(dataSet[4]))
                .divide(dataSet[1].multiply(dataSet[3]).subtract(dataSet[0].multiply(dataSet[4])), 3,
                        BigDecimal.ROUND_HALF_UP);
    }

    private static BigDecimal getY(BigDecimal[] dataSet) {
        return dataSet[2]
                .multiply(dataSet[3])
                .subtract(dataSet[0].multiply(dataSet[5]))
                .divide(dataSet[1].multiply(dataSet[3]).subtract(dataSet[0].multiply(dataSet[4])), 3,
                        BigDecimal.ROUND_HALF_UP);
    }

    /**
     * String型の配列をBigDecimal型の配列に変換する。
     * 
     * @param stringArray
     *            変換対象のString型配列
     */
    private static BigDecimal[] toBigDecimalArray(String[] stringArray) {
        BigDecimal[] bigDecimalArray = new BigDecimal[stringArray.length];
        for (int i = 0; i < stringArray.length; ++i) {
            bigDecimalArray[i] = new BigDecimal(stringArray[i]);
        }
        return bigDecimalArray;
    }

    /**
     * 標準入力を読み取る。<br>
     * データセットの各行は、区切り文字により分割した配列としてリストに格納する。
     * 
     * @return データセットの各行を格納したリスト
     * @throws IOException
     */
    protected static List<String[]> getInput() throws IOException {
        // 入力読取り
        InputStreamReader streamReader = new InputStreamReader(System.in);
        BufferedReader bufferedReader = new BufferedReader(streamReader);

        List<String[]> dataSets = new ArrayList<String[]>();
        String line = null;

        try {
            while ((line = bufferedReader.readLine()) != null) {
                String[] dataSet = line.split(DELIMITER_SPACE);
                dataSets.add(dataSet);
            }
            return dataSets;
        } finally {
            bufferedReader.close();
            streamReader.close();
        }
    }
}

Measured memory_bytes: 16984
#include<iostream>
using namespace std;
int main()
{
int n;
cin>>n;
if(n%1000==0)
{
cout<<"0\n";
return 0;
}
else
{
int roundDown = ( (int) (n) /1000) * 1000;
int roundUp = roundDown + 1000;
cout<<roundUp-n<<"\n"; 
return 0;
}
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < n; i++)
#define reps(i,n) for(int i = 1; i <= n; i++)
#define rrep(i,n) for(int i = n-1; i >= 0; i--)
#define rreps(i,n) for(int i = n; i >= 1; i--)
#define mrep(i,from,n) for(int i = from; i < n; i++)
#define mreps(i,from,n) for(int i = from; i <= n; i++)
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
#define ERASE(x,val) x.erase(remove(ALL(x), val), x.end())
typedef long long ll;
typedef pair<ll, ll> P;
template<class T>inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; }return false; }
template<class T>inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; }return false; }
ll mod = 1000000007;

void solve()
{	
	int h, w;
	cin >> h >> w;
	vector<string> a(h);
	rep(i, h) cin >> a[i];
	int t = 0;
	rep(i, h)rep(j, w)
	{
		if(a[i][j]=='#')t++;
	}
	if(t==h+w-1)cout << "Possible" << endl;
 	else cout << "Impossible" << endl;
	return;
}

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


Measured memory_bytes: 256