akhauriyash/Code-Regression huggingface dataset:
// template version 1.12
using namespace std;
#include <iostream>
#include <bits/stdc++.h>

// varibable settings
#define infile "../test/sample-1.in"
#define int long long //{{{
const int INF=1e18;
const int MOD=1e9+7; //}}}

// define basic macro {{{
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define _rrep(i,n) rrepi(i,0,n)
#define rrepi(i,a,b) for(int i=(int)((b)-1);i>=(int)(a);--i)
#define rrep(...) _overload3(__VA_ARGS__,rrepi,_rrep,)(__VA_ARGS__)
#define each(i,a) for (auto&& i : a)
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
#define pb(a) push_back(a)
#define mp(a, b) make_pair(a, b)
#define uni(x) sort(all(x));x.erase(unique(all(x)),x.end())
#define ub upper_bound
#define lb lower_bound
#define posl(A, x) (lower_bound(all(A), x)-A.begin())
#define posu(A, x) (upper_bound(all(A),x)-A.begin())
template<class T> inline void chmax(T &a, const T &b) { if((a) < (b)) (a) = (b); }
template<class T> inline void chmin(T &a, const T &b) { if((a) > (b)) (a) = (b); }

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef long double ld;
typedef pair<int,int> pii;
typedef tuple<int,int,int> iii;

template<typename T> using PQ = priority_queue<T, vector<T>, greater<T>>;
struct Fast { Fast(){ std::cin.tie(0); ios::sync_with_stdio(false); } } fast;

#if defined(PCM) || defined(LOCAL)
  #include "lib/dump.hpp"
#else
  #define dump(...) 42
  #define dump_1d(...) 42
  #define dump_2d(...) 42
#endif
//}}}

int solve(){
  int n;cin>>n;
  vi a(n), b(n);
  rep(i,n) cin>>a[i];

  priority_queue<pii> q;
  rep(i,n) {
    cin>>b[i];
    if (a[i]<b[i]) q.push(mp(b[i], i));
    if (a[i]>b[i]) {
      cout << -1 << endl;
      return 0;
    }
  }

  int cnt = 0;
  int prev, prei;
  while(!q.empty()){
    int v, i;
    tie(v, i) = q.top(); q.pop();

    if (prev==v && prei==i) assert(false);
    if (b[i]<=a[i]) assert(false);

    int d = b[(i+1)%n] + b[(i-1+n)%n];
    int num;

    int nv = max({b[(i+1)%n], b[(i-1+n)%n], a[i]});
    num = ((v-nv)+d-1)/d;
    b[i] -= num * d;
    cnt += num;

    if (b[i]<a[i]) {
      cout << -1 << endl;
      return 0;
    }
    else if (b[i]==a[i]){
    }
    else{
      q.push(mp(b[i], i));
    }
    prev = v;
    prei = i;
  }
  cout << cnt << endl;

  return 0;
}

signed main() { //{{{
#ifdef INPUT_FROM_FILE
  std::ifstream in(infile);
  std::cin.rdbuf(in.rdbuf());
#endif
  solve();
  return 0;
} //}}}


Measured memory_bytes: 9456
#include<iostream>
#include<cstring>
#include<cstdio>
#include<algorithm>
#include<stack>
#include<vector>
#include<map>
#include<queue>
#include<cmath>
#include<set>
#include<cstdlib>
#include<cctype>
#include<ctime>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const ll maxn = 2e5 + 5;
const ll maxm = 1e3 + 5;
template<class T>
inline T qread(T &IEE){
	register T x = 0, f = 1;
	register char ch = getchar();
	while(!isdigit(ch)){
		if(ch == '-'){
			f = -f;
		}
		ch = getchar();
	}
	while(isdigit(ch)){
		x = (x << 1) + (x << 3) + (ch ^ 48);
		ch = getchar();
	}
	return IEE = x * f;
}
template<class T>
inline void qwrite(T a){
	if(!a){
		putchar('0');
		return ;
	}
 	if(a < 0){
		putchar('-');
		a = -a;
	}
	if(a > 9) qwrite(a / 10);
	putchar(a % 10 + 48);
	return ;
}
template<class T>
inline T ab(T a){
	return (a > 0) ? a : -a;
}
template<class T>
inline void swa(T &a, T &b){
	a ^= b ^= a ^= b;
	return ;
}
ll p = 1, ans = 0, len;
char ch[maxn];
ll f[maxn], cnt[2020];
int main(){
//	freopen("1.in", "r", stdin);
//	freopen("1.out", "w", stdout);
	cin >> (ch + 1);
	len = strlen(ch + 1);
	for(int i = len;i >= 1;i--){
		f[i] = (f[i + 1] + (ch[i] - '0') * p) % 2019;
		p *= 10;
		p %= 2019;
		cnt[f[i]]++;
	}
	cnt[0]++;
	for(int i = 0;i <= 2019;i++){
		ans += (cnt[i] - 1) * cnt[i] / 2;
	}
	cout << ans << endl;
	return 0;
}


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

int main() {
  std::string in(3, ' ');
  std::string list[] = {"SUN", "MON", "TUE", "WED", "THU", "FRI", "SAT"};
  scanf("%s", &in[0], in.size());
  for (int i = 0; i < sizeof(list) / sizeof(list[0]); i++) {
    if (list[i] == in) {
      printf("%d", 7 - i);
      return 0;
    }
  }
}


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

int main()
{
    int n;
    scanf("%d", &n);
    vector<int> v(n);
    for(int i = 0; i < n; ++i){
        scanf("%d", &v[i]);
    }
    
    for(int i = 0; i < n; ++i){
        printf("node %d: key = %d, ", i + 1, v[i]);
        if(i != 0){
            printf("parent key = %d, ", v[(i-1)/2]);
        }
        if(2 * i + 1 < n){
            printf("left key = %d, ", v[(2 * i + 1)]);
        }
        
        if(2 * i + 2 < n){
            printf("right key = %d, ", v[(2 * i + 2)]);
        }
        puts("");
    }
    
}

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

// g++ -std=c++17 -O2 -Wall template.cpp -o template
int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);

    string s;
    cin >> s;
    int diff = INT_MAX;
    for (int i = 0; i < s.size() - 2; i++) {
        diff = min(diff, abs(stoi(s.substr(i, 3)) - 753));
    }
    cout << diff << endl;
    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
    // Solution
}


Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <unordered_map>
#include <vector>
#include <string.h>
#include <set>
#include <stack>

using namespace std;

#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl

template<class T> void printvec(const vector<T>& v) {
  for (auto x : v) { cout << x << " "; }
  cout << endl;
}
template<class T> void printtree(const vector< vector<T> >& tree) {
  for (long long i = 0; i < tree.size(); ++i) {
    cout << i + 1 << ": "; printvec(tree[i]);
  }
}
template<class T, class U> void printmap(const map<T, U>& mp) {
  for (auto x : mp) { cout << x.first << "=>" << x.second << endl; }
}

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

#define rep(i, n) for(ll i = 0; i < n; ++i)
#define all(s) s.begin(), s.end()
#define sz(x) (ll)(x).size()
#define fr first
#define sc second
#define mp make_pair
#define pb push_back
#define eb emplace_back

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef tuple<ll, ll, ll> triple;
typedef double D;
typedef vector<ll> vl;
typedef vector<P> vp;

const ll INF = 1e9;
const ll MOD = 1000000007;  // 1e9 + 7

int main(int argc, char** argv) {
  cin.tie(NULL);
  cout.tie(NULL);
  ios_base::sync_with_stdio(false);
  //cout << setprecision(10) << fixed;

  ll n;
  cin >> n;
  map<string,ll> cnt;
  rep(i,n) {
    string s;
    cin >> s;
    ++cnt[s];
  }
  vector<string> words = { "AC", "WA", "TLE", "RE" };
  for (const string& word : words) {
    cout << word << " x " << cnt[word] << endl;
  }
}


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

using namespace std;

#define INF 0x3f3f3f3f
#define endl "\n"
#define MAXN 100010
#define F first
#define S second
#define abs(a, b) ((a > b) ? a-b : b-a)
#define rep(i, a, b) for(int i = (a); i <= (b); i++)

typedef long long int ll;

int main() {
	cin.tie(NULL);
	ios_base::sync_with_stdio(false);
	
	int n, m; cin >> n >> m;

	int res = n*(n-1)/2 + m*(m-1)/2;
	cout << res << endl;
	

	return 0;
}


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

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        abc145_a solver = new abc145_a();
        solver.solve(1, in, out);
        out.close();
    }

    static class abc145_a {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int r = in.nextInt();

            out.println(r * r);
        }

    }
}



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

using namespace std;
const int maxn = 1e5 + 10;
int cnt[maxn];
typedef long long ll;
ll qsm(ll a, ll b, ll mod)
{
    ll ans = 1;
    while (b)
    {
        if (b & 1)
            ans = ans * a % mod;
        b /= 2;
        a = a * a % mod;
    }
    return ans;
}
struct node
{
    int l, r, k, id;
} ;
int cmp1(node a, node b)
{
    return abs(a.l - a.r) > abs(b.l - b.r);
}
int main()
{
    int T;
    cin >> T;
    while (T--)
    {
        int n;
        cin >> n;
        vector<node> a;
        vector<node> b;
        set<int> q;
        for (int i = 1; i <= n; i++)
        {
            q.insert(i);
            node temp;
            cin >> temp.k >> temp.l >> temp.r;
            temp.id = i;
            if (temp.l >= temp.r)
            {
                a.push_back(temp);
            }
            else
                b.push_back(temp);
        }
        sort(a.begin(), a.end(), cmp1);
        sort(b.begin(), b.end(), cmp1);
        ll ans = 0;
        for (int i = 0; i < a.size(); i++)
        {
            auto g = q.upper_bound(a[i].k);
            if (g == q.begin())
            {
                ans += a[i].r;
            }
            else
            {
                ans += a[i].l;
                g--;
                q.erase(g);
            }
        }
        q.clear();
        for (int i = a.size() + 1; i <= n; i++)
        {
            q.insert(i);
        }
        for (int i = 0; i < b.size(); i++)
        {
            auto g = q.upper_bound(b[i].k);
            if (g == q.end())
            {
                ans += b[i].l;
            }
            else
            {
                ans += b[i].r;
                q.erase(g);
            }
        }
        cout << ans << endl;
    }
    // system("pause");
}

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

using namespace std;

const int INF = 1e9;

int main() {
  int n, k;
  cin >> n >> k;
  vector<int> s(n), dp(n, INF);
  for (int &x : s)
    cin >> x;
  dp[0] = 0;
  for (int i=0; i<n; ++i)
    for (int j=i; j<=i+k; ++j)
      if (j<n)
        dp[j] = min(dp[j], dp[i] + abs(s[i] - s[j]));
  cout << dp[n-1] << "\n";
  return 0;
}



Measured memory_bytes: 1024
import java.util.regex.Pattern;
import java.util.*;
public class Main {
    public static void main(String[] args){
        Scanner s = new Scanner(System.in);
        String S = s.next();
      	String T = s.next();
		Pattern p = Pattern.compile(S + "[a-z]$");
		System.out.println(p.matcher(T).find() ? "Yes" : "No");
    }
}

Measured memory_bytes: 38616
import java.util.Scanner;
public class Main {
    public static void main(String[] args){
        Scanner sc =new Scanner(System.in);
        int[] ans = new int[1000];
        int[] data =new int[100];
        int min,max;
        min=1000;
        max=0;
        int sum=0;
        int k=0;
        int n=100;
        while(n!=0){
            n=sc.nextInt();
            for(int i=0;i<n;i++){
                data[i]=sc.nextInt();
                if(data[i]<min)min=data[i];
                if(data[i]>max)max=data[i];
                sum = sum+data[i];
            }
            sum=sum-max-min;
            ans[k]=sum/(n-2);
            sum=0;
            min = 1000;
            max=0;
            k++;
            
        }
        for(int i=0;i<k-1;i++){
            System.out.println(ans[i]);
        }
    }
}


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

int main()
{
	int a,b,c,ans=0;
	scanf("%d%d%d",&a,&b,&c);
	if(a>b)  swap(a,b);
	if(b>c)  swap(b,c);
	if(a>b)  swap(a,b);
	
	while(b<c)  a++,b++,ans++;
	while(a+2<=b+1)  a+=2,ans++;
	
	if(a==b-1)  ans+=2;
	else  if(a==b+1)  ans++;
	printf("%d",ans);
	return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <chrono>
#define _USE_MATH_DEFINES
#include <cmath>
#include <cstdio>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iostream>
#include <iterator>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <string>
#include <tuple>
#include <utility>
#include <vector>
using namespace std;

#define FOR(i,m,n) for(int i=(m);i<(n);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()

const int INF = 0x3f3f3f3f;
const long long LINF = 0x3f3f3f3f3f3f3f3fLL;
const double EPS = 1e-8;
const int MOD = 1000000007; // 998244353;
const int dy[] = {1, 0, -1, 0}, dx[] = {0, -1, 0, 1};
/*-------------------------------------------------*/
int main() {
  cin.tie(0); ios::sync_with_stdio(false);
  // freopen("input.txt", "r", stdin);

  int n, l; cin >> n >> l;
  vector<int> apple(n);
  REP(i, n) apple[i] = l + (i + 1) - 1;
  int mx = INF, idx = 0;
  REP(i, n) {
    if (abs(apple[i]) < mx) {
      idx = i;
      mx = abs(apple[i]);
    }
  }
  int sum = 0;
  REP(i, n) sum += apple[i];
  sum -= apple[idx];
  cout << sum << '\n';
  return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
	Scanner sc = new Scanner(System.in);
	private void doit(){
		while(true){
			String s = sc.next();
			if(s.equals("0000")) break;
			
			for(int i = 0;;i++){
				StringBuilder sb = new StringBuilder();
				for(int j = 0; s.length() + j < 4; j++){
					sb.append(0);
				}
				sb.append(s);
				s = sb.toString();
				if(s.toString().equals("6174")){
					System.out.println(i);
					break;
				}
				if(isNA(s.toString())){
					System.out.println("NA");
					break;
				}
				int [] res = create(s.toString());
				s = new String((res[1] - res[0]) + "");
			}
		}
	}

	private int[] create(String s) {
		char [] c = s.toCharArray();
		Arrays.sort(c);
		StringBuilder sb = new StringBuilder(new String(c));
		int [] res = new int[2];
		res[0] = Integer.parseInt(sb.toString());
		res[1] = Integer.parseInt(sb.reverse().toString());
		return res;
	}

	private boolean isNA(String s) {
		char c = s.charAt(0);
		for(int i = 1; i < s.length(); i++){
			if(c != s.charAt(i)) return false;
		}
		return true;
	}

	private void debug(Object... o) {
		System.out.println("debug = " + Arrays.deepToString(o));
	}

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

Measured memory_bytes: 57892
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end())
#define VRSORT(v) sort(v.rbegin(), v.rend())//vectorの降順ソート
#define ll long long
#define pb(a) push_back(a)
#define INF 1000000000
#define MOD 1000000007
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

typedef vector<unsigned int>vec;
typedef vector<vec> mat;
typedef tuple<ll, ll, ll> T;

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

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;cin>>n;
    vector<ll> a(n);
    ll sunuke=0,arai=0;
    ll ans=1e18;
    REP(i,n){
        cin>>a[i];
        arai+=a[i];
    }
    REP(i,n-1){
        arai -= a[i];
        sunuke += a[i];
        //cout<<sunuke<<":"<<arai<<endl;
        ans = min(ans,abs(sunuke-arai));
        
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 1792
#include <algorithm>
#include <bitset>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <cctype>
#include <assert.h>
#include <stdlib.h>
#include <stdio.h>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <limits>
#include <map>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
#include <math.h>
 
// ===============================================================
 
using namespace std;
using ll = long long;
using vl = vector<long long>;
using vll = vector<vector<long long>>;
using vs = vector<string>;
using vc = vector<char>;
using vcc = vector<vector<char>>;
using vm = vector<short>;
using vmm = vector<vector<short>>;
using pii = pair<int, int>;
using psi = pair<string, int>;
using ld = long double;
using ull = unsigned long long;
 
// ===============================================================
 
ll gcd(ll a, ll b) //最大公約数
{
	if (a % b == 0)
	{
		return(b);
	}
	else
	{
		return(gcd(b, a % b));
	}
}
 
ll lcm(ll a, ll b) //最小公倍数
{
	return a * b / gcd(a, b);
}
 
ll box(double a) //doubleの切り捨て
{
	ll b = a;
	return b;
}
 
ll fff(double a) //doubleの四捨五入
{
	ll b = a + 0.5;
	return b;
}
 
ll sum(ll n) { //整数sまでの合計
	if (n == 0) {
		return 0;
	}
 
	int s = sum(n - 1);
	return s + n;
}
 
bool prime(ll num)//素数判定、primeならtrue,違うならfalse
{
	if (num < 2) return false;
	else if (num == 2) return true;
	else if (num % 2 == 0) return false;
	double sqrtNum = sqrt(num);
	for (int i = 3; i <= sqrtNum; i += 2)
	{
		if (num % i == 0)
		{
			return false;
		}
	}
 
	// 素数である
	return true;
}
 
// ===============================================================
 
int main() {
	ll n;
	cin >> n;
	ll k;
	cin >> k;
	vl ans(n+1);
	for (int i = 0; i < k; i++) {
		ll a;
		cin >> a;
		for (int j = 0; j < a; j++) {
			ll b;
			cin >> b;
			ans[b]++;
		}
	}
	ll kotae = 0;
	for (int i = 1; i <= n; i++) {
		if (ans[i] == 0) {
			kotae++;
		}
	}
	cout << kotae << endl;
}

Measured memory_bytes: 3664
#include<bits/stdc++.h>
#include<cstring>
using namespace std;
//#define num 1000000007
#define num 998244353
#define REP(i,a,n) for(ll i=a;i<n;i++)
#define up(a,b) (((a)%(b)==0)?((a)/(b)):((a)/(b))+1)
#define inarr(i,a,n,A) for(ll i=a;i<n;i++) { cin>>A[i]; }
#define vll vector<long long>
#define pii pair <int,int>
#define pll pair<long long, long long>
#define vpii vector< pair <int,int>>
#define vpll vector< pair<long long, long long>>
#define max(a,b) ((a>b)?a:b)
#define min(a,b) ((a>b)?b:a)
#define max3(a,b,c) (a>b)?(a>c)?a:c:(b>c)?b:c
#define min3(a,b,c) (a<b)?(a<c)?a:c:(b<c)?b:c
#define avg(a,b) ((a)+(b))/2
#define push push_back
#define pop pop_back
#define mp make_pair
#define sf int flag=0     //Remember semicolon
#define assmin(a,b) if(b<=a) { a=b; }
#define assmax(a,b) if(b>=a) { a=b; }
#define f first
#define s second
#define fix(f,n) std::fixed<<std::setprecision(n)<<f
typedef long long ll;

ll mod(ll a, ll b)
{
	if(a%b<0)
	{
		return a%b + b;
	}
	return a%b;
}
 
 
ll mod_exp(ll a, ll b, ll c)
{
	ll res=1;
	a=a%c;
	while(b>0)
	{
		if(b%2==1)
		{
			res=(res*a)%c;
		}
		b/=2;
		a=(a*a)%c;
	}
	return res;
}
ll gcd(ll a, ll b)
{
    if(b==0)
    {
        return a;
    }
    return gcd(b, a%b);
}
bool prime[3001];
void SieveOfEratosthenes() 
{ 
    memset(prime, true, sizeof(prime)); 
    prime[1]=false;
    for (int p=2; p*p<=3000; p++) 
    { 
        if (prime[p] == true) 
        { 
            for (int i=p*p; i<=3000; i += p) 
                prime[i] = false; 
        } 
    } 
}
ll powe[20];
void power()
{
	powe[0]=1;
	REP(i,1,20)
	{
		powe[i]=(powe[i-1]*10)%num;
        if(powe[i]<0)
        powe[i]+=num;
	}
}

int main()
{
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
	string s,t;
	cin>>s>>t;
	pll dp[s.size()+1][t.size()+1];
	REP(i,0,t.size()+1)
	{
		dp[0][i].f=0;
		dp[0][i].s=0;
	}
	REP(i,0,s.size()+1)
	{
		dp[i][0].f=0;
		dp[i][0].s=1;
	}
	REP(i,1,s.size()+1)
	{
		REP(j,1,t.size()+1)
		{
			if(s[i-1]==t[j-1])
			{
				dp[i][j].f=1+dp[i-1][j-1].f;
				dp[i][j].s=2;
			}
			else
			{
				dp[i][j].f=max(dp[i-1][j].f,dp[i][j-1].f);
				dp[i][j].s=(dp[i-1][j]>dp[i][j-1])?1:0;
			}
		}
	}
	string ans="";
	ll x=s.size();
	ll y=t.size();
	while(x!=0 || y!=0)
	{
		if(dp[x][y].s==2)
		{
			ans+=s[x-1];
			x--;y--;	
		}
		else
		{
			if(dp[x][y].s==1 && x>0)
			{
				x--;
			}
			else
			{
				y--;
			}
		}
	}
	reverse(ans.begin(),ans.end());
	cout<<ans<<"\n";
	return 0;
}

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

int main () {
    long long x, k, d; cin >> x >> k >> d;

    if (x < 0)
        x = x * -1;

    if (x / d > k)
        cout << x - k * d;
    else {
        x = (x % d) - (((k - x / d) % 2) * d);
        cout << ((x > 0) ? x : x * -1);
    } 
}

Measured memory_bytes: 3572
#include <iostream>
#include <map>
using namespace std;
typedef pair< int, int> P;
int main(){
	while( 1 ){
		int n, m, a;
		cin >> n >> m >> a;
		if( n == 0 ) break;
		multimap< int, P > cross;
		while( m-- > 0 ){
			int h, p, q;
			cin >> h >> p >> q;
			cross.insert( pair<int, P>( h, P( p, q ) ) );
		}
		multimap< int, P >::iterator it = cross.end();
		it--;
		for( ; it != cross.begin(); it-- ){
			if( (*it).second.first == a ){
				a = (*it).second.second;
			}else if( (*it).second.second == a ){
				a = (*it).second.first;
			}
		}
		if( (*it).second.first == a ){
			a = (*it).second.second;
		}else if( (*it).second.second == a ){
			a = (*it).second.first;
		}
		cout << a << endl;
	}
}

Measured memory_bytes: 1252
/*
* @author:  codancer
*/
#include<bits/stdc++.h>

using namespace std;
typedef long long ll;
const ll mod = 1e9+7;
#define pb push_back
#define SZ(x) ((int)(x).size())
#define fi first
#define se second
#define rep(i,a,b) for(int i=(a);i<=(b);i++)
#define fep(i,a,b) for(int i=(a);i>=(b);i--)
typedef vector<int> VI;
typedef pair<int,int> pii;
char maze[20][3000];
int c[3000][20];//第j列的前i行的前缀和
int main(){
	int n,m,k;
	cin>>n>>m>>k;
	rep(i,1,n){
		rep(j,1,m){
			cin>>maze[i][j];
		}
	}
	rep(j,1,m){
		c[j][0]=0;
		rep(i,1,n){
			c[j][i]=c[j][i-1]+(maze[i][j]-'0');
		}
	}
	
	int ans=1e9;
	for(int i=0;i<(1<<(n-1));i++){
		vector<int> lc;
		int now=0;
		for(int j=0;j<(n-1);j++){
			if((i>>j)&1){
				lc.pb(j+1);
			}
		}
		int siz=(int)lc.size();
		now+=siz;
		
		vector<pair<int,int> > sq;//第i块的区间
				
		if(siz==0){//不切 
			sq.pb({1,n});
		}else{
			sq.pb({1,lc[0]});
			rep(j,1,siz-1){
				sq.pb({lc[j-1]+1,lc[j]});
			} 
			sq.pb({lc[siz-1]+1,n});
		}
		
		//先检验横着划分的可行性 
		bool flag=1;
		rep(j,1,m){
			rep(d,0,siz){
				int up=sq[d].first;
				int down=sq[d].second;
				if(c[j][down]-c[j][up-1]>k){
					flag=0;
					break;
				}
			}
		}
		if(flag==0) continue;
		
//		cout<<sq.size()<<' '<<now<<endl;
//		for(auto v:sq){
//			cout<<v.first<<"---"<<v.second<<endl;
//		}
		
		vector<int> tmp(siz+1,0);//第i块当前白色的数量 
		rep(j,1,m){
			bool ok=1;
			rep(d,0,siz){
				int up=sq[d].first;
				int down=sq[d].second;
				if(tmp[d]+c[j][down]-c[j][up-1]>k){
					ok=0;
					break;
				}
				tmp[d]+=(c[j][down]-c[j][up-1]);
			}
			if(ok==0){
				++now;
				rep(d,0,siz){
					int up=sq[d].first;
					int down=sq[d].second;
					tmp[d]=c[j][down]-c[j][up-1];
				}
			}
		}
		ans=min(ans,now);
	}
	
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define FOR(i,s,n) for(int i = s; i < (n); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(n) (n).begin(), (n).end()
#define RALL(n) (n).rbegin(), (n).rend()
#define ATYN(n) cout << ( (n) ? "Yes":"No") << '\n';
#define CFYN(n) cout << ( (n) ? "YES":"NO") << '\n';
#define OUT(n) cout << (n) << '\n';
using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>;
using pll = pair<ll,ll>;

int main(void)
{
    IOS
    int n, W;
    cin >> n >> W;
    vector<ll> w(n), v(n);
    REP(i,n) cin >> w[i] >> v[i];

    vector<vector<ll>> dp(n+1,vector<ll>(W+1));
    ll ans = 0;
    REP(i,n) {
        REP(j,W+1){
            dp[i+1][j] = dp[i][j];
            if (j - w[i] >= 0) {
                dp[i+1][j] = max(dp[i][j-w[i]]+v[i],dp[i+1][j]);
            }
        }
        //cerr << ans << endl;
    }

    cout << dp[n][W] << '\n';


    return 0;
}

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

using namespace std;

namespace {
    template<typename K, typename V>
    ostream& operator<<(ostream& os, const pair<K, V>& p) {
       return os << "(" << p.first << "," << p.second << ")";
    }
    /** output whole vector. ex) vector<int>{1, 2, 3} -> '1 2 3'. */
    template<typename T>
    ostream& operator<<(ostream& os, const vector<T>& xs) {
       if (xs.empty()) return os;
       os << xs[0];
       for (auto i = 1; i < xs.size(); i++) os << ' ' << xs[i];
       return os;
    }

    string s;
    int X, Y;
    void input() {
        cin >> s;
        cin >> X >> Y;
    }

    void solve() {
        vector<pair<char, int>> cmds;
        char prev = '?';
        int count = 0;
        for (int i = 0; i < s.size(); i++) {
            char c = s[i];
            if (c == prev) {
                count++;
            } else {
                if (prev != '?') cmds.emplace_back(prev, count);
                count = 1;
                prev = c;
            }
        }
        cmds.emplace_back(prev, count);
        //cout << cmds << endl;

        int index = 0;
        auto first_cmd = cmds[0];
        if (first_cmd.first == 'F') {
            index++;
            X -= first_cmd.second;
        }
        if (cmds.back().first == 'T') cmds.pop_back();

        if ((cmds.size() - index) == 0) {
            cout << (Y == 0 and X == 0 ? "Yes" : "No") << endl;
            return;
        }

        assert(cmds[index].first == 'T');
        assert(cmds.back().first == 'F');

        vector<int> lr, ud;
        const int LR = 0; //UD = 1;
        int cur_dir = LR;
        for (; index < cmds.size(); index += 2) {
            assert(cmds[index].first == 'T');
            int count = cmds[index].second;
            if (count % 2 != 0) {
                cur_dir = !cur_dir;
            }
            int forward = cmds[index + 1].second;
            (cur_dir == LR ? lr : ud).push_back(forward);
        }

        auto possible = [&](int target, const vector<int>& xs) {
            // targetをxsの部分集合の和として表せるか
            int N = xs.size();
            vector<set<int>> f(N + 1);
            f[0].insert(0);
            for (int i = 0; i < N; i++) {
                int x = xs[i];
                for (auto it = f[i].begin(); it != f[i].end(); it++) {
                    auto y = *it;
                    f[i + 1].insert(y + x);
                    f[i + 1].insert(y - x);
                }
            }
            return f[N].count(target);
        };

//cout << X << endl;
//cout << "[" << lr << endl;
//cout << possible(X, lr) << endl;
//cout << possible(Y, ud) << endl;
        cout << (possible(X, lr) and possible(Y, ud) ? "Yes" : "No") << endl;
    }
}


int main() {
    input(); solve();
    return 0;
}



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

using namespace std;

int main(void) {
    int k, a, b;
    cin >> k >> a >> b;
    for (int i = a; i <= b; ++i) {
        if (i % k == 0) {
            cout << "OK" << endl;
            return 0;
        }
    }
    cout << "NG" << endl;
}

Measured memory_bytes: 3632
const processData = (lines) => {
  const [a, b, c, k] = lines[0].split(' ').map(x => +x)
  const rest = Math.max(k-(a+b), 0)
  console.log(Math.min(a, k) - rest)
}

let i = ''
process.stdin.on('data', c => i += c)
process.stdin.on('end', () => {
  const {EOL} = require('os')
  const lines = i.split(EOL) /*your input text, split by lines*/
  processData(lines)
})


Measured memory_bytes: 30120
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cstdio>
#include <queue>
#include <stack>
#include <map>
#include <set>

#define rep(i, n) for(int i = 0; i < n; i++)
#define FOR(i, a, b) for(int i = a; i < b; i++)
#define all(v) (v).begin(), (v).end()
#define MP make_pair

using namespace std;


int main(){
	map<int, int> av;	// 参加者番号,匹数
	map<int, set<int> > va; // 匹数,番号

	va[0].insert(0);

	int n, q;

	cin >> n >> q;
	while(q--){
		int a, v;
		cin >> a >> v;
		set<int>::iterator it = va[av[a]].find(a);
		if(it != va[av[a]].end()){
			if(va[av[a]].size() == 1){
				map<int, set<int> >::iterator mit = va.find(av[a]);
				va.erase(mit++);
			}else{
				va[av[a]].erase(it++);
			}
		}

		av[a] += v;
		va[av[a]].insert(a);

		//cout << "*-*";
		cout << *((*va.rbegin()).second.begin()) << ' ' << (*va.rbegin()).first << endl;
	}


	return 0;
}

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

(n, m, x), cost = map(int, input().split()), sys.maxsize
s = [list(map(int, input().split())) for i in range(n)]
for i in range(1, 1 << n):
    k, y = [0 for i in range(m)], 0
    for j in range(n):
        if (i >> j) & 1:
            for ii in range(1, m + 1): k[ii-1] += s[j][ii]
            y += s[j][0]
    if all([k[j] >= x for j in range(m)]): cost = min(cost, y)
print(-1 if cost == sys.maxsize else cost)

Measured memory_bytes: 73880
N = int(input())
word = list(input())
ans = 0
for i in range(1,(N-1)//2+1):
    for j in range(N-2*i):
        if word[j] != word[j+i] and word[j] != word[j+2*i] and word[j+i] != word[j+2*i]:
            ans -= 1

RGB = {"R":0, "G":0, "B":0}
for i in range(N):
    RGB[word[i]] += 1
ans += RGB["R"]*RGB["G"]*RGB["B"]
print(ans)

Measured memory_bytes: 9196
from math import *

N = int(input())
name = ""

# Remove smaller names
size = 0
while 26**size <= N:
    N -= 26**size
    size += 1

for pos in range(size):
    rem = N % 26
    name = chr(ord('a') + rem) + name
    N //= 26

print(name)


Measured memory_bytes: 62044
#include <bits/stdc++.h>
using namespace std;
#define ull unsigned long long
#define MOD (int)(1e9+7)
#define ceil(x, y) (x%y==0? (x/y) : (x/y+1))
#define FOR(i, N) for(int i = 0; i < N; ++i)
#define FOR1(i, N) for(int i = 1; i <= N; ++i)
#define vi vector <int>
#define pii pair <int, int>
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define mset(a, v) memset(a, v, sizeof(a))
#define all(v) (v).begin(), (v).end()
#define INF 2e9
#define EPS 1e-9
#define int long long
/*#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
typedef cc_hash_table<int, int, hash<int>> ht; // while using, comment #define int long long  */

void __print(int x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define dbg(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define dbg(x...)
#endif
using namespace std;
#define MAX 3009
int32_t main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    #ifndef ONLINE_JUDGE
        freopen("in5.txt", "r", stdin);
        freopen("out.txt", "w", stdout);
    #endif
    int T=1;
    // cin >> T;
    FOR1(tt, T){
        // cout << "Case #" << tt << ": ";
        int n, x, t; cin >> n >> x >> t;
        cout << ceil(n, x)*t;
        cout << '\n';
    }
    return 0;
}


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

int main(){
    int h,w,x,y;
    cin >> h >> w >> x >> y;
    if(h*w%2==1 and (x+y)%2==1){
    	cout << "No" << endl;
    }else{
    	cout << "Yes" << endl;
    }
    return 0;
}



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

int main() {
    int n, r;
    cin >> n;
    vector<int> a(n);
    int sum = 0;
    for (int i = 0; i < n; ++i) {
        cin >> r;
        a[i] = r * 2;
        sum += r;
    }
    int sub = 0;
    for (int j = 1; j < n; j += 2) sub += a[j];
    vector<int> ans(n);
    int p = sum - sub;
    ans[0] = p;
    cout << p;
    for (int k = 0; k < n - 1; ++k) {
        ans[k + 1] = a[k] - ans[k];
         cout << " " << ans[k + 1];
    }
    cout << endl;
}


Measured memory_bytes: 2048
#include <bits/stdc++.h>
#define MOD 1000000007
#define INF 1061109567
#define int long long
#define pb push_back
#define in(s) freopen(s,"r",stdin);
#define out(s) freopen(s,"w",stdout);
#define fi first
#define se second
#define bw(i,r,l) for (int i=r-1;i>=l;i--)
#define fw(i,l,r) for (int i=l;i<r;i++)
#define fa(i,x) for (auto i:x)
using namespace std;
const int N=1e5+5;
typedef pair<int,int> ii;
typedef pair<int,ii> iii;
struct point {int x,y,id;} p[N];
priority_queue<iii,vector<iii>,greater<iii>> pq;
int n,par[N],sz[N];
bool cmp1(const point &a,const point &b) {return a.x<b.x;}
bool cmp2(const point &a,const point &b) {return a.y<b.y;}
int getp(int u) {return u==par[u]?u:par[u]=getp(par[u]);}
bool joint(int u,int v) {
	u=getp(u),v=getp(v);
	if (u==v) return false;
	if (sz[u]<sz[v]) swap(u,v);
	sz[u]+=sz[v];
	par[v]=u;
	return true;
}
int dist(point x,point y) {
	return min(abs(x.x-y.x),abs(x.y-y.y));
}
signed main() {
	//in("aome.inp");
	//in("PLANTREE.inp"); out("PLANTREE.out");
	ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	//Connect each point to 2 points nearest to it by either x or y. This is all we have to consider
	//for edges. MST easily after.
	cin>>n;
	fw (i,0,n) par[i]=i,sz[i]=1;
	fw (i,0,n) cin>>p[i].x>>p[i].y,p[i].id=i;
	sort(p,p+n,cmp1);
	fw (i,1,n) {
		//pq.push(edge(p[i].id,p[i-1].id,min(p[i].x-p[i-1].x,p[i].y-p[i-1].y)));
		pq.push(iii(dist(p[i],p[i-1]),ii(p[i].id,p[i-1].id)));
	}
	sort(p,p+n,cmp2);
	fw (i,1,n) {
		//pq.push(edge(p[i].id,p[i-1].id,min(p[i].x-p[i-1].x,p[i].y-p[i-1].y)));
		pq.push(iii(dist(p[i],p[i-1]),ii(p[i].id,p[i-1].id)));
	}
	int ans=0;
	while (!pq.empty()) {
		iii foo=pq.top(); pq.pop();
		int u=foo.se.fi,v=foo.se.se,w=foo.fi;
		if (joint(u,v)) {
			ans+=w;
		}
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 12272
#include <bits/stdc++.h>
using namespace std;
#define TRACE(x) x
#define WATCH(x) TRACE( cout << #x" = " << x << endl)
#define PRINT(x) TRACE(printf(x))
#define WATCHR(a, b) TRACE( for(auto c = a; c != b;) cout << *(c++) << " "; cout << endl)
#define WATCHC(V) TRACE({cout << #V" = "; WATCHR(V.begin(), V.end()); } )
#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 rall(x) (x).rbegin(), (x).rend()
#define sz(x) (int)(x).size()
#define mp make_pair
#define st first
#define nd second

using ll = long long;
using pii = pair<int, int>;
using vi = vector<int>;
using ld = long double;
using pll = pair<ll, ll>;
using vll = vector<ll>;
using pll = pair<ll, ll>;

void buff() { ios::sync_with_stdio( false ); cin.tie( nullptr ); }

constexpr ll MOD = 1e9 + 7;

inline ll pow_mod( ll a, ll b, ll mod = MOD) {
    ll res = 1; a %= mod; assert(b >= 0);
    for(;b;b>>=1) {
        if(b&1) res = (res * a) % mod;
        a = (a * a) % mod;
    }
    return res;
}
constexpr int ms = 2e6 + 13;
ll fat[ms], inv_fat[ms], pot25[ms], pot26[ms];

// End of template code!
int main() 
{
    buff();
    fat[0] = inv_fat[0] = pot25[0] = pot26[0] = 1ll;
    for(ll i = 1; i < ms - 10; ++i) {
        fat[i] = (fat[i - 1] * i) % MOD;
        inv_fat[i] = pow_mod(fat[i], MOD - 2);
        pot25[i] = (pot25[i - 1] * 25) % MOD;
        pot26[i] = (pot26[i - 1] * 26) % MOD;
    }

    auto nk = [&] (ll n, ll k) {
        ll ans = fat[n];
        ans = (ans * inv_fat[k]) % MOD;
        ans = (ans * inv_fat[n - k]) % MOD;
        return ans;
    };

    ll K;
    cin >> K;
    string s;
    cin >> s;
    ll L = (ll) sz(s);
    ll ans = 0;
    // vamos respeitar a substring
    for(ll fim = L; fim <= K + L; fim++)
    {
        ll free_pos = (K + L - fim);
        
        ll pos = nk((fim - 1), (L - 1));
        ll locked = (fim - 1 - (L - 1));
        ll per_config = pot25[locked];
        
        ll contrib_pref = (pos * per_config) % MOD;

        ll contrib_suff = pot26[free_pos];
        
        ll C = (contrib_pref * contrib_suff) % MOD;
        ans = (ans + C) % MOD;
    }
    cout << ans << '\n';
    return 0;
}



Measured memory_bytes: 66756
# -*- coding: utf-8 -*-


import sys

input = sys.stdin.readline

# 空白区切り2整数
n, q = list(map(int, input().split()))

# 1文字ずつのリスト
s = list(input())
s.append('Z')
count = []
cc = 0
count.append(0)
for i in range(1, len(s)):
    if s[i - 1] == 'A' and s[i] == 'C':
        cc += 1
    count.append(cc)
# print(count)

for i in range(q):
    l, r = list(map(int, input().split()))

    print(count[r - 1] - count[l - 1])


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

using namespace std;

typedef long long ll;

vector <int> e[105];
int fa[105],dep[105],maxd[105];

int dfs1(int x) {
  int ans=x;
  for(int i=0;i<e[x].size();i++)
    if (e[x][i]!=fa[x]) {
    	int u=e[x][i];
    	fa[u]=x;dep[u]=dep[x]+1;
    	int t=dfs1(u);
    	if (dep[t]>dep[ans]) ans=t;
	}
  return ans;
}

void dfs2(int x) {
  int s=0;
  for(int i=0;i<e[x].size();i++)
    if (e[x][i]!=fa[x]) {
    	s++;
    	int u=e[x][i];
    	fa[u]=x;dep[u]=dep[x]+1;
    	dfs2(u);
	}
  maxd[dep[x]]=max(maxd[dep[x]],s);
}

int main() {
  int n;
  scanf("%d",&n);
  for(int i=1;i<n;i++) {
  	int x,y;
  	scanf("%d%d",&x,&y);
  	e[x].push_back(y);
  	e[y].push_back(x);
  }
  dep[1]=1;fa[1]=0;
  int rt1=dfs1(1);
  dep[rt1]=1;fa[rt1]=0;
  int rt2=dfs1(rt1);
  int len=((dep[rt2]+1)>>1);
  printf("%d ",len);
  if (dep[rt2]&1) {
  	int mid=rt2;
  	for(int i=1;i<len;i++) mid=fa[mid];
  	memset(maxd,0,sizeof(maxd));
    dep[mid]=1;fa[mid]=0;
    dfs2(mid);
    ll s=1;
    for(int i=1;i<len;i++) s*=maxd[i];
    ll ans=s;
    for(int i=0;i<e[mid].size();i++) {
    	int u=e[mid][i];
    	memset(maxd,0,sizeof(maxd));
    	maxd[1]=2;
    	dep[u]=dep[mid]=2;
		fa[u]=mid;fa[mid]=u;
    	dfs2(u);
    	dfs2(mid);
    	s=1;
    	for(int j=1;j<=len;j++) s*=maxd[j];
    	ans=min(ans,s);
	}
	printf("%lld\n",ans);
  }
  else {
  	int u=rt2;
  	for(int i=1;i<len;i++) u=fa[u];
  	int v=fa[u];
  	memset(maxd,0,sizeof(maxd));
  	maxd[1]=2;
  	dep[u]=dep[v]=2;
	fa[u]=v;fa[v]=u;
	dfs2(u);
	dfs2(v);
	ll ans=1;
	for(int j=1;j<=len;j++) ans*=maxd[j];
	printf("%lld\n",ans);
  }
  return 0;
}

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

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

    string s;
    cin >> s;
    stack<char> st;
    int n = s.size();
    for (int i = 0; i < n; ++i)
        if (s[i] == 'B' && !st.empty())
            st.pop();
        else if (s[i] != 'B')
            st.push(s[i]);

    s = "";
    while (!st.empty())
    {
        s += st.top();
        st.pop();
    }
    reverse(s.begin(), s.end());
    cout << s;
}

Measured memory_bytes: 3596
package main

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

// 構造体の定義
type stack struct {
	st  [1000]int
	top int
}

// 構造体に、関数を組み込む
func (s *stack) push(x int) {
	s.st[s.top] = x
	s.top++
}

func (s *stack) pop() int {
	s.top--
	v := s.st[s.top]
	return v
}

var sc = bufio.NewScanner(os.Stdin)

func main() {
	sc.Split(bufio.ScanLines)
	var s string
	s = nextStr()
	a := strings.Split(s, " ")
	var stack stack
	for _, v := range a {
		//fmt.Println(stack.st[0:10])
		switch v {
		case "+":
			tmp1 := stack.pop()
			tmp2 := stack.pop()
			stack.push(tmp2 + tmp1)
		case "-":
			tmp1 := stack.pop()
			tmp2 := stack.pop()
			stack.push(tmp2 - tmp1)
		case "*":
			tmp1 := stack.pop()
			tmp2 := stack.pop()
			stack.push(tmp2 * tmp1)
		case "/":
			tmp1 := stack.pop()
			tmp2 := stack.pop()
			stack.push(tmp2 / tmp1)
		default:
			cv, _ := strconv.Atoi(v)
			stack.push(cv)
		}
	}
	fmt.Println(stack.pop())
}

func nextStr() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}



Measured memory_bytes: 1164
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
int main(){
    i64 a,b,c;
    cin>>a>>b>>c;
    if(a==5&&b==7&&c==5) cout<<"YES"<<endl;
    else if(a==7&&b==5&&c==5)cout<<"YES"<<endl;
    else if(a==5&&b==5&&c==7)cout<<"YES"<<endl;
    else cout<<"NO"<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <boost/optional.hpp>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <functional>
#include <iostream>
#include <limits>
#include <list>
#include <numeric>
#include <queue>
#include <sstream>
#include <string>
#include <tuple>
#include <type_traits>
#include <utility>
#include <vector>

#define REP(i, n) for(int i = 0, i##_MACRO = (n); i < i##_MACRO; i++)
#define RANGE(i, a, b) for(int i = (a), i##_MACRO = (b); i < i##_MACRO; i++)
#define EACH(e, a) for(auto&& e : a)
#define ALL(a) (a).begin(), (a).end()
#define AALL(a, n) (a), ((a) + (n))
#define FILL(a, n) memset((a), n, sizeof(a))
#define FILLZ(a) FILL(a, 0)
#define MODNUM (static_cast<int>(1e9 + 7))
#define MOD(x) ((x) % MODNUM)

using namespace std;

using ll = long long;
using VI = vector<int>;
using VI2D = vector<vector<int>>;

const int INF = 2e9;
const double EPS = 1e-10;
const double PI = acos(-1.0);

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

template <typename T>
int sign(T x) {
	return x < 0 ? -1 : x > 0 ? 1 : 0;
}

template <>
int sign(double x) {
	return x < -EPS ? -1 : x > EPS ? 1 : 0;
}

template <typename T>
T square(T x) {
	return x * x;
}

inline int toInt(string s) {
	int v;
	istringstream sin(s);
	sin >> v;
	return v;
}

void chmax(int& m, int n) {
	m = max(m, n);
}

int bfs(const VI2D& maze, int h, int w, pair<int, int> s) {
	VI2D distances(h, VI(w, INF));
	distances[s.first][s.second] = 0;
	int max_distance = 0;
	queue<pair<int, int>> que;
	que.push(s);
	while(!que.empty()) {
		auto p = que.front();
		que.pop();
		if(maze[p.first][p.second]) {
			continue;
		};
		int d = distances[p.first][p.second];
		chmax(max_distance, d);
		REP(i, 4) {
			if(distances[p.first + dy[i]][p.second + dx[i]] == INF) {
				distances[p.first + dy[i]][p.second + dx[i]] = d + 1;
				que.push(pair<int, int>(p.first + dy[i], p.second + dx[i]));
			}
		}
	}
	return max_distance;
}

int main() {
	int h, w;
	scanf("%d %d\n", &h, &w);
	VI2D maze(h + 2, VI(w + 2, 1));
	REP(i, h) {
		REP(j, w) {
			char c = getchar();
			if(c == '.') {
				maze[i + 1][j + 1] = 0;
			}
		}
		getchar();
	}

	int result = 0;
	REP(i, h) {
		REP(j, w) {
			chmax(result,
				  bfs(maze, h + 2, w + 2, pair<int, int>(i + 1, j + 1)));
		}
	}
	printf("%d\n", result);
	return 0;
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-

sx, sy, tx, ty = map(int, input().split())

# s to t 1回目
route_x = tx - sx
route_y = ty - sy
print('U' * route_y, end='') # ↑
print('R' * route_x, end='') # →

# t to s 1回目
print('D' * route_y, end='') # ↓
print('L' * route_x, end='') # ←

# s to t 2回目
print('L', end='') # ←
print('U' * (route_y + 1), end='') # ↑
print('R' * (route_x + 1), end='') # →
print('D', end='') # ↓

# t to s 2回目
print('R', end='') # →
print('D' * (route_y + 1), end='') # ↓
print('L' * (route_x + 1), end='') # ←
print('U', end='')

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

int main(){
    int k,x;
    cin >> k >> x;
    rep(i,2*k-1){
        cout << x-k+1+i << endl;
    }
    

    return 0;
}

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

using namespace std;

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

template <class T>
void cin_vec(T* vec, int n) {
    FOR(i, n) cin >> vec[i];
}

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

    int N;
    int V[100], C[100];

    cin >> N;
    cin_vec(V, N);
    cin_vec(C, N);

    int max_v = 0;

    FOR(i, N) {
        max_v += max(0, V[i] - C[i]);
    }
    cout << max_v << endl;

    return 0;
}


Measured memory_bytes: 632
#include <bits/stdc++.h>
#include <string>
#include <cmath>
#include <sstream>
//#include <unordered_map>
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define FORD(i, a, b) for(int i = (a-1); i >= (b); i--)
#define pb(a) push_back(a)
#define mp(a,b) make_pair(a,b)
#define ff first
#define ss second
typedef long long int ll;
using namespace std;
ll mod=1000000007;
//ll mod=67280421310721;
//ll mod=998244353;
int a[26];
ll INF=1e18;
ll po(ll a,ll b)
{
	ll re=1;
	while(b)
	{
		if(b%2==1)
		{
			re=(re*a);
			re%=mod;
		}
		a=(a*a);
		a%=mod;
		b>>=1;
	}
	return re;
}
int main()
{
//	#ifndef ONLINE_JUDGE
    // for getting input from input.txt
  ///  freopen("input.txt", "r", stdin);
    // for writing output to output.txt
  //  freopen("output.txt", "w", stdout);
//	#endif
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	float d,s,t;
	cin>>d>>t>>s;
	float c=d/s;
	if(t>=c){
		cout<<"Yes";
	}
	else{
		cout<<"No";
	}

}

Measured memory_bytes: 3732
#include<iostream>

int main(void){
  int n, m, max=0;
  int price[1000];

  for(int t=0; t<10000; t++){

    max = 0;
    std::cin >> n;
    std::cin >> m;
    if(n == 0 && m == 0){
      break;
    }

    for(int i=0; i<n; i++){
      std::cin >> price[i];
    }

    for(int j=0; j<n; j++){
      for(int s=0; s<n; s++){
	if(j == s){
	  break;
	}
	if(price[j] + price[s] > max && price[j] + price[s] <= m){
	  max = price[j] + price[s];
	}
      }
    }
    if(max > 0){
      std::cout << max << "\n";
    }else{
      std::cout << "NONE\n";
    }
  }
  return 0;
}



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

int main(){
  long N;
  cin >> N;
  
  long ans=0;
  for (long i=1; i<=N; i++){
    if ((i%3)*(i%5) != 0){
      ans += i;
    }
  }
  
  cout << ans << endl;
  
  return 0;
}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin >> N;
  vector <int> a(N);
  
  for (int i=0; i<N; i++){
    cin >> a.at(i);
  }
  
  int now, c;
  now=1, c=0;
  
  for (int i=0; i<N; i++){
    now = a.at(now-1);
    c++;
    
    if (now==2){
      cout << c << endl;
      break;
    }
  }
  if (now!=2){
    cout << -1 << endl;
  }
}

Measured memory_bytes: 768
#include"bits/stdc++.h"
//#include"atcoder.h"
#include<iostream>
using namespace std;
typedef long long ll;
#define rep(i, c) for(int i = 0; i < (int)c; i++)
const ll inf = ll(1e18) + 1;
const ll mod = 1000000007;

int main() {
	ll n;
	cin >> n;

	vector<ll> z(n + 5);
	vector<ll> w(n + 5);

	for (int i = 0; i < n; i++) {
		ll x, y;
		cin >> x >> y;
		z[i] = x + y;
		w[i] = x - y;
	}

	ll result = 0;
	ll z_max = z[0];
	ll z_min = z[0];
	ll w_max = w[0];
	ll w_min = w[0];

	for (int i = 1; i < n; i++) {
		if (z[i] >= z_max) {
			z_max = z[i];
		}
		else if (z[i] <= z_min) {
			z_min = z[i];
		}

		if (w[i] >= w_max) {
			w_max = w[i];
		}
		else if (w[i] <= w_min) {
			w_min = w[i];
		}
	}

	result = max(z_max-z_min, w_max - w_min);

	cout << result << endl;

	return 0;
}


Measured memory_bytes: 6372
import java.util.Scanner;

public class Main {

    public Main() {
    }

    private static Scanner sc;

    public static void main(String[] args) {
        sc = new Scanner(System.in);
        new Main().run();
    }

    private void run() {
        int x = sc.nextInt();
        if (x < 1200) {
            System.out.println("ABC");
        } else {
            System.out.println("ARC");
        }
    }
}


Measured memory_bytes: 10188