akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

#include <unistd.h>
 
using namespace std;
 
#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cerr<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" "<<v[i]; cerr<<endl
#define DEBUG_MAT(v) cerr<<#v<<endl;for(int i=0;i<v.size();i++){for(int j=0;j<v[i].size();j++) {cerr<<v[i][j]<<" ";}cerr<<endl;}
 
 
typedef long long ll;
//#define int ll
 
#define vi vector<int>
#define vl vector<ll>
#define vii vector< vector<int> >
#define vll vector< vector<ll> >
#define vs vector<string>
#define pii pair<int,int>
#define pis pair<int,string>
#define psi pair<string,int>
#define pll pair<ll,ll>
template<class S, class T> pair<S, T> operator+(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first + t.first, s.second + t.second); }
template<class S, class T> pair<S, T> operator-(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first - t.first, s.second - t.second); }
template<class S, class T> ostream& operator<<(ostream& os, pair<S, T> p) { os << "(" << p.first << ", " << p.second << ")"; return os; }
#define X first
#define Y second
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define rrep(i,n) for(int i=(n)-1;i>=0;i--)
#define rrep1(i,n) for(int i=(n);i>0;i--)
#define REP(i,a,b) for(int i=a;i<b;i++)
#define in(x, a, b) (a <= x && x < b)
#define all(c) c.begin(),c.end()
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a = b; return 1; } return 0; }
#define UNIQUE(v) v.erase(std::unique(v.begin(), v.end()), v.end());
const ll inf = 1000000001;
const ll INF = (ll)1e18 + 1;
const ll MOD = 1000000007;
//const ll MOD = 998244353;
const double pi = 3.14159265358979323846;
#define Sp(p) cout<<setprecision(15)<< fixed<<p<<endl;
int dx_ori[4] = { -1,0, 1,0 }, dy_ori[4] = { 0,1,0,-1 };
int dx[4] = {0, 0, 0, 0}, dy[4] = {0, 0, 0, 0};
int dx2[8] = { 1,1,0,-1,-1,-1,0,1 }, dy2[8] = { 0,1,1,1,0,-1,-1,-1 };
#define fio() cin.tie(0); ios::sync_with_stdio(false);
// #define mp make_pair
//#define endl '\n'

int a[5000][5000];
int sum[5001][5001];

int area(int i0, int j0, int i1, int j1) {
  return sum[i1][j1] - sum[i0][j1] - sum[i1][j0] + sum[i0][j0];
}

signed main() {
  string s;
  cin >> s;
  int ans;
  if (s == "SUN") {
    ans = 7;
  }
  else if (s == "MON") ans = 6;
  else if (s == "TUE") ans = 5;
  else if (s == "WED") ans = 4;
  else if (s == "THU") ans = 3;
  else if (s == "FRI") ans = 2;
  else ans = 1;
  cout << ans << endl;

}


Measured memory_bytes: 256
s = gets.chomp.split("")


def switch_tile(n)
    n == 0 ? 1 : 0
end

def diff_cnt(left_array, right_array)
    unmatch = 0
    match = 0
    left_array.each_with_index do |i, idx|
        if left_array[idx] != right_array[idx]
          unmatch +=1
        else
          match+=1
        end
    end
    return match, unmatch
end

def generate_tiles(l, first_zero = true)
    current = 1
    current = 0 if first_zero
    res = ""
    l.times do 
        res += current.to_s
        current = switch_tile(current)
    end
    return res
end

cand_a = generate_tiles(s.size, false).split("")

match, unmatch = diff_cnt(cand_a, s)

puts [match, unmatch].min


Measured memory_bytes: 92776
import java.util.Scanner;

public class Main {

	static Scanner scanner;

	public static void main(String[] args) {
	    scanner = new Scanner(System.in);

	    int N=gi();
	    long[] m=new long[5];
	    String march="MARCH";

	    for (int i=0; i<N; i++) {
	    	String s=gs();
	    	for (int j=0; j<5; j++) {
                char c=march.charAt(j);
                if(s.charAt(0)==c)m[j]++;
	    	}
	    }
	    
	    long sum=0;
	    for (int i=0; i<5; i++) {
	    	for (int j=i+1; j<5; j++) {
	    		for (int k=j+1; k<5; k++) {
	                sum+=m[i]*m[j]*m[k];
		    	}
	    	}
	    }

	    System.out.println(sum);
//        if (f) {
//    	    String a=Sq.substring(0, S.lastIndexOf(T)) + T + Sq.substring(S.lastIndexOf(T)+T.length());
//    	    System.out.print(a.replaceAll("\\?", "a"));
//        }else {
//        	System.out.print("UNRESTORABLE");
//        }
	}

	// 文字列として入力を取得
	public static String gs() {
		return scanner.next();
	}

	// intとして入力を取得
	public static int gi() {
		return Integer.parseInt(scanner.next());
	}

	// longとして入力を取得
	public static long gl() {
		return Long.parseLong(scanner.next());
	}

	// doubleとして入力を取得
	public static double gd() {
		return Double.parseDouble(scanner.next());
	}
}

Measured memory_bytes: 56812
import bisect as bi
n=int(input())
ans=0
summ=[(i+2)*(i+1)//2 for i in range(100000)]
#summ[i]:=1~iの和
for divide in range(2,int(n**0.5)+1):
    if n==1:break
    cnt=0
    while n%divide==0:
        cnt+=1
        n//=divide
    if cnt==0:continue
    ans+=bi.bisect_right(summ,cnt)
print(ans+(n!=1))

Measured memory_bytes: 13212
#include <iostream>
#include <utility>
#include <map>
#include <vector>
#include <algorithm>
#include <queue>
#include <math.h>
#include <stack>
#include <set>
#include <deque>
#include <cmath>
#include <cassert>

using namespace std;
typedef long long ll;
ll mod = 1e9+7;
#define rep(i,n) for(int i = 0; i < (n); ++i)

int main() {
    int x;
    cin >> x;
    int num[180] = {0};
    int tmp_x = x;
    for (int i = 2; i * i <= x; ++i) {
        while(1) {
            if (tmp_x % i != 0) break;
            tmp_x /= i;
            ++num[i];
        }
    }
    if (tmp_x != 1) ++num[tmp_x];
    int tmp_num = 360;
    int mult_num = 1;
    rep(i, 180) {
        if (num[i] != 0) {
            rep(j, num[i]) {
                if (tmp_num % i != 0) {
                    mult_num *= i;
                }
                else {
                    tmp_num /= i;
                }
            }
        }
    }
    cout << 360 * mult_num / x << endl;
    return 0;
}


Measured memory_bytes: 3604
#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>
using namespace std;
#define int long long
#define _CRT_SECURE_NO_WARNINGS
#define rep(i, n) for (int i = 0; i < n; i++)
#define _GLIBCXX_DEBUG
const int MOD = 1e9 + 7;
const int INF = 1e18 + 9;
constexpr long double pi = 3.141592653589793238462643383279; //円周率
/*---------------------便利な関数--------------------------------------*/
int fact(int i) {       //階乗
    if (i == 0) return 1;
    return (fact(i - 1)) * i;
}

int gcd(int a, int b) {        //最大公約数
    if (b == 0) return a;
    return gcd(b, a % b);
}

int lcm(int a, int b) {      //最小公倍数
    return a * b / gcd(a, b);
}

int keta(int n) {        //桁数を求める
    if (n == 0) return 1;
    int count = 0;
    while (n != 0) {
        n /= 10;
        count++;
    }
    return count;
}

int ketasum(int n) {    //各桁の和
    int sum = 0;
    while (n != 0) {
        sum += n % 10;
        n /= 10;
    }
    return sum;
}
/*-------------ここまで---------------------------------------------*/

//C++(GCC9.2.1)

signed main() {
    //宣言
    int a[3][3];
    rep(i, 3) {
        rep(j, 3) cin >> a[i][j];
    }
    bool be[110];
    fill(be, be + 110, false);;
    int n;
    cin >> n;
    int b[15];
    rep(i, n) {
        cin >> b[i];
        be[b[i]] = true;
    }
    if (be[a[0][0]] && be[a[0][1]] && be[a[0][2]]) cout << "Yes" << endl;
    else if (be[a[1][0]] && be[a[1][1]] && be[a[1][2]]) cout << "Yes" << endl;
    else if (be[a[2][0]] && be[a[2][1]] && be[a[2][2]]) cout << "Yes" << endl;
    else if (be[a[0][0]] && be[a[1][0]] && be[a[2][0]]) cout << "Yes" << endl;
    else if (be[a[0][1]] && be[a[1][1]] && be[a[2][1]]) cout << "Yes" << endl;
    else if (be[a[0][2]] && be[a[1][2]] && be[a[2][2]]) cout << "Yes" << endl;
    else if (be[a[0][0]] && be[a[1][1]] && be[a[2][2]]) cout << "Yes" << endl;
    else if (be[a[0][2]] && be[a[1][1]] && be[a[2][0]]) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 3588
def get_H(Cx, Cy):
    for x, y, h in L:
        if h > 0:
            return abs(x - Cx) + abs(y - Cy) + h


def check_H(Cx, Cy, H):
    for x, y, h in L:
        if h != max(H - abs(x - Cx) - abs(y - Cy), 0):
            return False
    return True


N = int(input())

L = [(list(map(int, input().split()))) for _ in range(N)]

for Cx in range(101):
    for Cy in range(101):
        H = get_H(Cx, Cy)
        if check_H(Cx, Cy, H):
            print('{} {} {}'.format(Cx, Cy, H))
            exit(0)


Measured memory_bytes: 3064
#include <iostream>
#include <stdio.h>

#define MAX_M 10
#define MAX_N 10

using namespace std;

int B[MAX_M];

int main() {
  int N, M, C;
  cin >> N >> M >> C;
  for (int i = 0; i < M; ++i) {
    cin >> B[i];
  }

  int cnt;
  for (int i = 0; i < N; ++i) {
    int t = 0;
    for (int j = 0; j < M; ++j) {
      int a;
      cin >> a;
      t += B[j] * a;
    }
    cnt += t + C > 0;
  }
  printf("%d\n", cnt);
}

Measured memory_bytes: 3264
import sys
def LI():
    return list(map(int,sys.stdin.readline().rstrip().split()))  #空白あり

k,q = LI()
d = LI()

from itertools import accumulate

for _ in range(q):
    n,x,m = LI()
    e = [0] + [d[i] % m for i in range(k)]
    f = list(accumulate(e))
    g = [0] + [d[i] % m == 0 for i in range(k)]
    h = list(accumulate(g))
    p = (n-1) // k
    r = (n-1) % k
    print(n - 1 - p*h[k] - h[r] - (p*f[k] + f[r] + x % m) // m)


Measured memory_bytes: 185812
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define reps(i,n) for(int i=1;i<(int)(n);i++)

typedef long long ll;
using namespace std;

ll gcd(ll a, ll b) { //最大公約数
  if (b==0) return a;
  else return gcd(b, a%b);
}

ll lcm(ll a, ll b) { //最小公倍数
  return a * b / gcd(a, b);
}

ll digit_sum(ll a){ //10進桁和
  ll ans=0;
  while(a>0){
    ans+=a%10;
    a/=10;
  }
  return ans;
}



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

  cout<<a*b/2<<endl;

  return 0;
}


Measured memory_bytes: 3604
#include <stdio.h>

int main() {
    int a, b;
    while (1) {
        scanf("%d %d", &a, &b);
        if (a == 0 && b == 0) break;
        if (a < b) {
            printf("%d %d\n", a, b);
        } else if (a > b) {
            printf("%d %d\n", b, a);
        } else if (a == b) {
            printf("%d %d\n", b, a);
        }
    }

    return 0;
}


Measured memory_bytes: 2048
import math
A,B,C = map(int,input().split())
num = math.gcd(math.gcd(A,B),C)
A = A//num
B = B//num
C = C//num
for i in range(1,100000):
    if (A*i)%B == 1:
        print('YES')
        exit()
print('NO')

Measured memory_bytes: 63392
#include<iostream>
#include<cstdio>
#include<cstring>
using namespace std;
int main(){
	long long n,a[10],b[10];
	cin>>n;long long ans=1e17;
	for(int i=0;i<5;i++) cin>>a[i],ans=min(a[i],ans);
	if(n%ans) cout<<n/ans+5;
	else cout<<n/ans-1+5;
} 

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define INF 1000000000
#define MAX_V 1002
using namespace std;
struct edge {
	int to, cap, rev;
	edge(int to_, int cap_, int rev_) : to(to_), cap(cap_), rev(rev_) {};
};

int V;
vector<edge> G[MAX_V];
int level[MAX_V];
int iter[MAX_V];

int GCD(int a, int b) {
	return b ? GCD(b, a % b) : a;
}

void AddEdge(int from, int to, int cap) {
	G[from].push_back(edge(to, cap, G[to].size()));
	G[to].push_back(edge(from, 0, G[from].size() - 1));
}

void BFS(int s) {
	fill(level, level + V, -1);
	queue<int> que;
	level[s] = 0;
	que.push(s);
	while (!que.empty()) {
		int v = que.front(); que.pop();
		for (size_t i = 0; i < G[v].size(); i++) {
			edge &e = G[v][i];
			if (e.cap > 0 && level[e.to] < 0) {
				level[e.to] = level[v] + 1;
				que.push(e.to);
			}
		}
	}
}

int DFS(int v, int t, int f) {
	if (v == t) return f;
	for (int &i = iter[v]; i < G[v].size(); i++) {
		edge &e = G[v][i];
		if (e.cap > 0 && level[v] < level[e.to]) {
			int d = DFS(e.to, t, min(f, e.cap));
			if (d > 0) {
				e.cap -= d;
				G[e.to][e.rev].cap += d;
				return d;
			}
		}
	}
	return 0;
}

int Dinic(int s, int t) {
	int flow = 0;
	while (true) {
		BFS(s);
		if (level[t] < 0) return flow;
		fill(iter, iter + V, 0);
		int f;
		while ((f = DFS(s, t, INF)) > 0) {
			flow += f;
		}
	}
}

int main()
{
	int m, n;
	while (cin >> m >> n, m || n) {
		vector<int> b(m), r(n);
		V = m + n + 2;
		for (int i = 0; i < m; i++) {
			cin >> b[i];
			AddEdge(m + n, i, 1);
		}
		for (int i = 0; i < n; i++) {
			cin >> r[i];
			AddEdge(m + i, m + n + 1, 1);
		}
		for (int i = 0; i < m; i++) {
			for (int j = 0; j < n; j++) {
				if (GCD(b[i], r[j]) != 1) {
					AddEdge(i, m + j, 1);
				}
			}
		}
		cout << Dinic(m + n, m + n + 1) << endl;
		for (int i = 0; i < V; i++) {
			G[i].clear();
		}
	}
	return 0;
}

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

#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define endl "\n"
#define PI 3.14159265358979
#define MOD 1000000007 // = 10^9 + 7

using namespace std;
using ll = long long;

void solve()
{
	int n;
	cin >> n;
	vector<int> b(n);
	for(int i = 0; i < n - 1; ++i)
	{
		cin >> b[i];
	}

	int ans = b[0];
	for(int i = 1; i < n - 1; ++i)
	{
		ans += min(b[i - 1], b[i]);
	}
	ans += b[n - 2];

	cout << ans;
}

int main()
{
	fastio;
	solve();

	return 0;
}

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

int main() {
	string S;
	cin >> S;
	bool b0 = false;
	if (S[0] == S[S.size()-1]) {
		b0 = true;
	}
	bool b1 = false;
	if (0 == S.size()%2) {
		b1 = true;
	}
	if (b0 ==b1) {
		cout << "First" << endl;
	}
	else {
		cout << "Second" << endl;
	}
	return 0;
}


Measured memory_bytes: 3740
#include <iostream>
#include <vector>
#include <string>
#include <map>
#include <queue>
#include <algorithm>
#include <set>
#include <climits>

using namespace std;


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

	int n, k;
	cin >> n >> k;

	cout << n * n - k << endl;


	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<algorithm>
#define ll long long
#define P pair<ll,ll>
#define mp make_pair
#define fi first
#define se second
#define N 3010
#define M 1000000007
using namespace std;

ll m,n,k,dp[N],jc[200100];
P num[N];

inline ll po(ll u,ll v)
{
	ll res=1;
	for(;v;)
	{
		if(v&1) res=res*u%M;
		u=u*u%M;
		v>>=1;
	}
	return res;
}

inline ll C(ll u,ll v){return jc[u]*po(jc[v],M-2)%M*po(jc[u-v],M-2)%M;}
inline ll ask(P u,P v){if(u.fi>v.fi || u.se>v.se) return 0;return C(v.fi+v.se-u.fi-u.se,v.fi-u.fi);}

int main()
{
	ll i,j,p,q;
	cin>>m>>n>>k;
	jc[0]=1;for(i=1;i<=200000;i++) jc[i]=jc[i-1]*i%M;
	for(i=1;i<=k;i++)
	{
		scanf("%lld%lld",&p,&q);
		if(p==q&&q==1 || p==m&&q==n)
		{
			puts("0");
			return 0;
		}
		num[i]=mp(p,q);
	}
	k++;
	num[k]=mp(m,n);
	sort(num+1,num+k+1);

	for(i=1;i<=k;i++)
	{
		dp[i]=ask(mp(1,1),num[i]);
		for(j=1;j<i;j++)
		{
			dp[i]=(dp[i]-dp[j]*ask(num[j],num[i])%M+M)%M;
		}
	}
	cout<<dp[k];
}


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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
template<class T> inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template<class T> inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}
int ctoi(char c) {
  if (c >= '0' && c <= '9') {
    return c - '0';
  }
  return 0;
}
int64_t factorial(int64_t n) {
  if (n == 1) {
    return 1;
  }
  int64_t ans = factorial(n-1);
  return ans*n;
}

int main() {
  int64_t n;
  cin >> n;
  vector <int64_t> t(n+1, 0);
  vector <int64_t> x(n+1, 0);
  vector <int64_t> y(n+1, 0);
  rep(i, n) cin >> t.at(i+1) >> x.at(i+1) >> y.at(i+1);
  string ans = "Yes";
  rep(i, n) {
    int64_t time = t.at(i+1)-t.at(i), lenx = x.at(i+1)-x.at(i), leny = y.at(i+1)-y.at(i);
    if (time < lenx+leny) {
      ans = "No";
    } else if ((time-(lenx+leny))%2 != 0) {
      ans = "No";
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 2560
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>
#include <boost/range/adaptor/reversed.hpp>

using namespace std;
typedef long long int ll;

#define PI (acos(-1))
#define REP(i,n) for(ll (i)=0;(i)<(n);(i)++)

#define dump(x)  cerr << #x << " = " << (x) << endl;
#define dumparr(x) cerr << #x ; for(auto elem: x){cerr << " " << elem;} cerr << endl;
#define dumppairs(x) cerr << #x ; for(auto elem: x){cerr << "(" << elem.first << " " << elem.second << ") ";} cerr << endl;
#define dumpline cerr << "**********************" << endl;
#define dumpwline(x) cerr << "******** " << #x << "=" << (x) << " ********" << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
#define ARRAY_LENGTH(array) (sizeof(array) / sizeof(array[0]))

int main(void){
    ll a; ll b; ll c;
    cin >> a >> b >> c;
    if (a+b+c >= 22){
        cout << "bust" << endl;
    } else {
        cout << "win" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
using System;
class Program
{
    static void Main()
    {
        string[] NK = Console.ReadLine().Split(' ');
        int N = int.Parse(NK[0]);
        int K = int.Parse(NK[1]);
        Console.WriteLine((N - 1) % (K - 1) == 0 ? (N - 1) / (K - 1) : (N - 1) / (K - 1) + 1);
    }
}

Measured memory_bytes: 11092
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define FOR(i, s, n) for (int i = (s); i < (n); i++)
#define RFOR(i, s, n) for (int i = (n) - 1; i >= (s); i--)
#define REP(i, n) FOR(i, 0, n)
#define RREP(i, n) RFOR(i, 0, n)
#define ALL(a) a.begin(), a.end()
const long long MOD = 1000000007, INF = 1e18;
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;}
 
int dp[100010][130];
 
signed main(){
	string s;
	cin >> s;
	dp[0][0] = 1;
	REP(i,s.size()){
		REP(j,130){
			if(s[i] != '?'){
				(dp[i+1][(j*10+s[i]-'0')%13] += dp[i][j])%=MOD;
			}else{
				REP(k,10){
					(dp[i+1][(j*10+k)%13] += dp[i][j])%=MOD;
				}
			}
		}
	}
	cout<<dp[s.size()][5]%MOD<<endl;
}

Measured memory_bytes: 102016
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define ll int64_t
#define all(v) v.begin(), v.end()
#define bitrep(n) for(int bit=0;bit<(1<<n);bit++)
#define bitrep2(n) for(int bit2=0;bit2<(1<<n);bit2++)


int main() {

ll N; cin >> N;

vector<ll> A(N) ;

rep(i,N) cin >> A[i];
//input

sort(all(A));
reverse(all(A));
//降順

ll count=1;

ll ans = A[0];

for(ll i=1;count<N-1;i++){
  ans+=A[i]*2;
  if(count==N-2) ans-=A[i];
  count+=2;
  }


cout << ans << endl;

return 0;
}

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

int main() {
  int N; cin >> N;
  vector<pair<int ,int> > v(N);
  for(int i = 0; i < N; ++i) v[i].second = i;
  for(int i = 0; i < N * (N - 1) / 2; ++i) {
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    --a; --b;
    if(c > d) {
      v[a].first += 3;
    } else if(c < d) {
      v[b].first += 3;
    } else {
      v[a].first += 1;
      v[b].first += 1;
    }
  }
  sort(v.begin(), v.end(), greater<pair<int, int> >());
  vector<int> rank(N);
  for(int i = 0, k = 1; i < N; ++i) {
    if(i && v[i-1].first != v[i].first) k = i + 1;
    rank[v[i].second] = k;
  }
  for(int i = 0; i < N; ++i) {
    cout << rank[i] << endl;
  }
  return 0;
}

Measured memory_bytes: 1200
#include <cstdio>
#include <cmath>
#include <ctime>
#include <cstring>
#include <cstdlib>

#include <algorithm>
#include <iostream>
#include <numeric>
#include <limits>
#include <functional>
#include <stack>
#include <vector>
#include <set>
#include <map>
#include <queue>

#define LOG(FMT...) fprintf(stderr, FMT)

using namespace std;

typedef long long ll;

const int N = 200010;

int n, m;
set<int> obs[N];

int main() {
	ios::sync_with_stdio(false);
#ifdef CAI_WEI_HAN
	freopen("test.in", "r", stdin);
#endif

  int k;
  scanf("%d%d%d", &n, &m, &k);
  while (k--) {
    int x, y;
    scanf("%d%d", &x, &y);
    obs[y].insert(x);
  }
  for (int i = 1; i <= m; ++i) {
    obs[i].insert(n + 1);
  }
  int ans = *obs[1].begin(), cur = 1;
  for (int i = 2; i <= m; ++i) {
    ++cur;
    while (obs[i].count(cur) && cur <= ans)
      ++cur;
    if (cur > ans)
      break;
    ans = min(ans, *obs[i].lower_bound(cur));
  }
  printf("%d\n", ans - 1);

  return 0;
}



Measured memory_bytes: 28416
#include<bits/stdc++.h>
#define ll long long
#define p(x,y) pair<x,y>
#define pb push_back
#define fo(i,n) for(int i=0;i<(n);i++)
using namespace std;

int main()
{


string s,p;
cin>>s>>p;

ll u,v;
u=s.length();
v=p.length();

ll dp[u+1][v+1];


for(int i=0;i<=u;i++)
{
    for(int j=0;j<=v;j++)
    {
      if(i==0 || j==0 )
      {
          dp[i][j]=0;
      }

      else if(s[i-1]==p[j-1])
      {

          dp[i][j]=1+dp[i-1][j-1];
      }

      else
      {

          dp[i][j]=max(dp[i-1][j],dp[i][j-1]);
      }

    }
}


string ans="";

while(u!=0 && v!=0)
{


     if(dp[u][v]==dp[u][v-1])
    {
        v--;
    }

    else if(dp[u][v]==dp[u-1][v])
    {
        u--;
    }

    else
    {

        ans+=s[u-1];
        u--;
        v--;


    }



}


reverse(ans.begin(),ans.end());

cout<<ans<<endl;


}


Measured memory_bytes: 70656
N = int(input())
city = list(map(int, input().split()))
hero = list(map(int, input().split()))
ko = 0 

for i in range(0 ,N):
  if city [i] >= hero[i]:
    ko += hero[i]
  elif city [i] <= hero[i]:
    ko += city[i]
    extra = hero[i] - city[i]
    
    if extra >= city[i+1]:
      ko += city[i+1]
      city[i+1] = 0
    elif extra <= city[i+1]:
      ko += extra
      city[i+1] = city[i+1] - extra
print(ko)  




Measured memory_bytes: 18604
#include <bits/stdc++.h>
#define FI first
#define SE second
#define EPS 1e-9
#define ALL(a) a.begin(),a.end()
#define SZ(a) int((a).size())
#define MS(s, n) memset(s, n, sizeof(s))
#define FOR(i,a,b) for (int i = (a); i <= (b); i++)
#define FORE(i,a,b) for (int i = (a); i >= (b); i--)
#define FORALL(it, a) for (__typeof((a).begin()) it = (a).begin(); it != (a).end(); it++)
#define WHATIS(x) cout << #x << " is " << x << endl;
#define ERROR(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
//__builtin_ffs(x) return 1 + index of least significant 1-bit of x
//__builtin_clz(x) return number of leading zeros of x
//__builtin_ctz(x) return number of trailing zeros of x

using namespace std;
using ll = long long;
using ld = double;
typedef pair<int, int> II;
typedef pair<ll, II> III;
typedef complex<ld> cd;
typedef vector<cd> vcd;

void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
    cout << *it << " = " << a << endl;
    err(++it, args...);
}

const ll MODBASE = 1000000007LL;
const int MAXN = 100010;
const int MAXM = 110;
const int MAXK = 510;

int k, a[6], z[6];

int main() {
    ios::sync_with_stdio(0);
    cin.tie(nullptr);
    FOR(i,1,5) cin >> a[i];
    FOR(i,1,5) z[i] = i;
    int res = 1000000000;
    do {
        int t = 0;
        FOR(i,1,5) {
            if (t % 10) t = (t / 10 + 1) * 10;
            t += a[z[i]];
        }
        res = min(res, t);
    } while (next_permutation(z+1, z+6));
    cout << res;
    return 0;
}

Measured memory_bytes: 256
D = {'N': (0, 1), 'S': (0, -1), 'E': (1, 0), 'W': (-1, 0)}
while True:
    n = int(input())
    if n == 0:
        break
    f = [[False for x in range(21)] for y in range(21)]
    for i in range(n):
        x, y = map(int, input().split(' '))
        f[y][x] = True
    m = int(input())
    rx, ry = 10, 10
    p = 0
    if f[ry][rx]:
        f[ry][rx] = False
        p += 1
    for i in range(m):
        d, l = input().split(' ')
        dx, dy = D[d]
        for j in range(int(l)):
            rx += dx
            ry += dy
            if f[ry][rx]:
                f[ry][rx] = False
                p += 1
    print('Yes' if p == n else 'No')

Measured memory_bytes: 5624
#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstdlib>
#include<climits>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<stack>
#include<numeric>
#include<map>
#include<set>
#include<bitset>
using namespace std;
#define REP(i,m,n) for(int i = m; i < n; i++)
#define rep(i,n) REP(i,0,n)
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a)  (a).rbegin(),(a).rend()
#define PI 3.14159265359
typedef long long LL;

template<class T> inline void chmax(T& a, T b) { if (a < b) { a = b; } }
template<class T> inline void chmin(T& a, T b) { if (a > b) { a = b; } }
template<class T> void print_vector(vector<T> vec) {
	cout << "[ ";
	for (int i = 0; i < vec.size(); i++) {
		cout << vec[i] << " ";
	}
	cout << "]" << endl;
}
template<class T> void print_pair_vector(vector<pair<T, T> > vec) {
	cout << "[ ";
	for (int i = 0; i < vec.size(); i++) {
		cout << "(" << vec[i].first << "," << vec[i].second << ") ";
	}
	cout << "]" << endl;
}

const int INF = 1 << 30;

int main(void) {
	int A, B, C, D;
	cin >> A >> B >> C >> D;

	int count = 0;
	for (int i = 0; i <= 100; i++)
	{
		if (A < i && B >= i && C < i && D >= i) {
			count++;
		}
	}
	cout << count << endl;
	return 0;
}

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

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

    int N;
    cin >> N;
    vector<ll> L(N);
    REP(i, N) {
        cin >> L[i];
    }
    int res = 0;
    REP(i, N - 2) {
        FOR(j, i + 1, N - 1) {
            FOR(k, j + 1, N) {
                if (L[i] == L[j] || L[j] == L[k] || L[k] == L[i]) {
                    continue;
                }
                bool tmp = true;
                tmp = tmp && (L[i] < L[j] + L[k]);
                tmp = tmp && (L[j] < L[k] + L[i]);
                tmp = tmp && (L[k] < L[i] + L[j]);
                res += tmp;
            }
        }
    }
    cout << res << endl;

    return 0;
}


Measured memory_bytes: 3628
local function read_array(n,m)m=m or 1 r={}for i=1,m do r[i]={}end for i=1,n do for j=1,m do r[j][i]=io.read"*n"end end return unpack(r)end

N=io.read"*n"
A=read_array(N)

s=0
i=2
while(i<=N)do
if(A[i]==A[i-1])then s=s+1 i=i+1 end
i=i+1
end

print(s)

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

using namespace std;

typedef long long ll;

#define MOD 1000000007

// x^n
ll mod_pow(ll x, ll n) {
  if (n == 0) return 1;
  ll res = mod_pow(x * x % MOD, n / 2);
  if (n & 1) res = res * x % MOD;
  return res;
}

// x^{-1}
ll mod_inv(ll x) { return mod_pow(x, MOD - 2); }

vector<ll> fact;
vector<ll> fact_inv;

void init_fact(int n) {
  fact.resize(n + 1);
  fact_inv.resize(n + 1);
  fact[0] = fact_inv[0] = 1;
  for (int i = 0; i < n; ++i) {
    fact[i + 1] = fact[i] * (i + 1) % MOD;
    fact_inv[i + 1] = fact_inv[i] * mod_inv(i + 1) % MOD;
  }
}

ll nCr(ll n, ll r) {
  if (n < r || n < 0 || r < 0) return 0;
  return fact[n] * fact_inv[r] % MOD * fact_inv[n - r] % MOD;
}

ll nPr(ll n, ll r) { return nCr(n, r) * fact[r] % MOD; }

int main() {
  int n;
  cin >> n;
  vector<ll> c(n);
  for (int i = 0; i < n; ++i) {
    cin >> c[i];
  }
  sort(c.rbegin(), c.rend());
  init_fact(2 * n);
  ll ans = 0;
  for (int i = 0; i < n; ++i) {
    ll res = c[i];
    if (0 < i) {
      res = (res * mod_pow(2ll, i - 1)) % MOD;
      res = (res * (i + 2)) % MOD;
    }
    res = (res * mod_pow(2ll, n - 1 - i)) % MOD;
    ans = (ans + res) % MOD;
  }
  ans = (ans * mod_pow(2ll, n)) % MOD;
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 8064
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		try (Scanner scanner = new Scanner(System.in)) {
			int a = scanner.nextInt();
			int b = scanner.nextInt();
			String s = scanner.next();
			System.out.println(s.matches("[0-9]{" + a + "}-[0-9]{" + b + "}") ? "Yes" : "No");
		}
	}
}


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

int main() {
    ll n;
    cin >> n;
    vector<ll> l(n);
    rep(i,n) cin >> l[i];
    int ans = 0;
    for(int i = 0; i < n-2; ++i) {
        for(int j = i+1; j < n-1; ++j) {
            for(int k = j+1; k < n; ++k){
                int a = l[i];
                int b = l[j];
                int c = l[k];
                if((a + b > c) && (c + b > a) && (a + c > b)){
                    if(a!=b && a!=c && b!=c && c!=a){
                        ans++;

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

Measured memory_bytes: 3628
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
typedef long long ll;
using namespace std;

ll solve(ll H){
    //cout << H << endl;
    if(H == 1) return 1;
    else {
        ll tmp = solve(H / 2);
        return tmp * 2 + 1;
    }
}

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

    cout << solve(H) << endl;
    return 0;
}


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

int main() {
  int a, b, c;
  cin >> a >> b >> c;
  int ans = 0;
  
  if(a != b)
    ans++;
  if(b != c)
    ans++;
  if(c != a)
    ans++;
  if(a == b and b == c)
    ans++;
  
  cout << ans << endl;
}


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

using namespace std;
using ll=long long;
using ull=unsigned long long;
using pii=pair<int,int>;

#define INF LONG_MAX
#define MOD 1000000007
#define rng(a) a.begin(),a.end()
#define rrng(a) a.end(),a.begin()

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

int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  
  int N,K;
  cin>>N>>K;
  vector<int>A(N);
  for(int i=0;i<N;i++)cin>>A[i];
  int Max=*max_element(rng(A));
  int Gcd=0;
  for(auto it:A)Gcd=gcd(it,Gcd);
  if(K%Gcd==0&&K<=Max)cout<<"POSSIBLE"<<endl;
  else cout<<"IMPOSSIBLE"<<endl;
  return 0;
}


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

#define pb push_back
#define pf push_front
#define pp pop_back
#define sz(a) (int)(a.size())
#define mp make_pair
#define F first
#define S second
#define next _next
#define prev _prev
#define left _left
#define right _right
#define y1 _y1
#define all(x) x.begin(), x.end()
#define what_is(x) #x << " is " << (x)

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

const int N = (int)1e6 + 123;
const ll INF = (ll)1e18 + 123;                                                                                                          
const int inf = (int)1e9 + 123;
const int MOD = (int)1e9 + 7;

void megaRandom() {
	unsigned int FOR;
 	asm("rdtsc" : "=A"(FOR));
  srand(FOR);
}

ll n;
string s;

int main() {
	megaRandom();
	cin >> n;
	while(n > 0) {
		s += char((n % 10) + '0'), n /= 10;
	}
	reverse(all(s));
	//cout << s << "\n";	

	int res = (sz(s) - 1) * 9, pref = 0;
	for(int i = 0; i < sz(s); i ++) {
		if(s[i] != '0') {
			int left = sz(s) - i - 1;
			res = max(res, pref + left * 9 + (s[i] - '0' - 1));
		} 
		pref += s[i] - '0';		     
		res = max(res, pref);
	}
	cout << res;
	return 0;  
}


Measured memory_bytes: 256
#include <iostream>
#include <utility>
#include <map>
#include <vector>
#include <algorithm>
#include <queue>
#include <math.h>
#include <stack>
#include <set>
#include <deque>
#include <cmath>

using namespace std;
typedef long long ll;
ll mod = 1e9+7;
//ll mod = 998244353;
#define rep(i,n) for(int i = 0; i < (n); ++i)

int main() {
    int n;
    cin >> n;
    vector<int> a(n);
    bool allzero = true;
    bool zero = false;
    map<int ,int > mp;

    rep(i, n) {
        cin >> a[i];
        ++mp[a[i]];

        if (a[i]!=0) {
            allzero = false;
        }
        else {
            zero = true;
        }
    }

    bool ok = false;

    if (allzero) {
        cout << "Yes" << endl;
        return 0;
    }

    if (n % 3 == 0) {
        int num = n / 3;

        if (zero) {
            int x = -1;
            rep(i, n) {
                if (a[i] != 0) {
                    x = a[i];
                }
            }
            if (mp[x] == num * 2 && mp[0] == num) {
                ok = true;
            }
        }
        else {
            for (int i = 1; i < n; ++i) {
                if (a[i] != a[0]) {
                    int x = a[0], y = a[i], z = x ^ y;
                    if (mp.count(z)) {
                        if (mp[x] == num && mp[y] == num && mp[z] == num) {
                            ok = true;
                        }
                    }
                }
            }
        }
    }

    cout << ((ok) ? "Yes" : "No") << endl;
    return 0;
}


Measured memory_bytes: 7228
import java.util.*;

public class Main{
    public static void main(String[] args){
        Scanner scan=new Scanner(System.in);
        Double point1x,point1y,point2x,point2y;
        
        point1x=scan.nextDouble();
        point1y=scan.nextDouble();
        point2x=scan.nextDouble();
        point2y=scan.nextDouble();
        System.out.print(Math.hypot(point1x-point2x,point1y-point2y));
    }
}


Measured memory_bytes: 28096
eval"N,K,*A,D=#{`tr -! ,`}(0..255).map{[0]*101}"
D[0][0]=1
A.map{|a|N.times{|j|256.times{D[_1^a][i=N-j]+=D[_1][i-1]*i}}}
p D[K].sum.%10**9+7

Measured memory_bytes: 20048
#include <bits/stdc++.h>
using namespace std;
typedef long long       ll;
typedef pair<int,int>   ii;
typedef vector<int>     vi;
typedef vector<ii>      vii;
typedef set<int>        si;
typedef set<ii>         sii;

#define all(x) x.begin(),x.end()
#define clr(x,v) memset(x,v,sizeof x)
#define sz(x) (int)x.size()
#define re return


template<typename T> T sgn (T x)      {re x<0? -1:(x>0? 1:0); }
template<typename T> T gcd (T a, T b) {re a ? gcd (b % a, a) : b; }
template<typename T> T abs (T x)      {re x < 0 ? -x : x; }
template<typename T> T sqr (T x)      {re x*x;}

#define _ ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define pb push_back
#define ins insert
#define y second
#define x first
#define endl "\n"
#define MOD (int)1e9+7
#define N (int) 1e18

void solve(){
  int x, y,i , j=0;
  cin>>x>>y;
  for(i=0;i<=x;i++){
  	if((x-i)*2+i*4==y){
      cout<<"Yes"<<endl;
      j=1;
    }
  }
  if(j==0)cout<<"No" << endl;
}
int main(){_
    solve();
}

Measured memory_bytes: 3640
#include <stdio.h>
#include <math.h>
#include <stdlib.h>

typedef int data_t;
data_t numbers_p[9] = {0};
data_t numbers_q[9] = {0};
int factorial[8] = {0,1,2,6,24,120,720,5040};  //0, 1!, 2!, 3!, ...


int arrange(data_t numbers[9], int delete){
	//delete の示す数字のある場所を返し、消去する
	int index;
	for(int i = 0; i< 9; i++){
		if(numbers[i] != delete){index = i; continue;}
		if(numbers[i] == 0){numbers[i-1] = 0; break;}
			data_t temp = numbers[i];
			numbers[i] = numbers[i+1];
			numbers[i+1] = temp;
	}
	numbers[9] = 0;
	return index+1;
}

void printnumbers(data_t numbers[9]){
	printf("[");
	for(int i = 0; i < 9; i++){printf("%d, ", numbers[i]);}
	printf("]\n");
}

long int dict_order(int n, data_t numbers[9]){
	long int order = 0;
	int p, difference;
	for(int i = 0; i<n; i++){
		if(scanf("%d", &p)==EOF){return 0;}
		//printf("p[%d] = %d, numbers[0] = %d,  factorial[n-1-%d] = %d\n", i, p, numbers[0], i,  factorial[n-1-i]);
		difference = arrange(numbers, p);
		if(p > numbers[0]){
			order += factorial[n-1-i] * difference;
			//printf("+ %d * %d= %ld\n",factorial[n-1-i] ,  difference, order);
		}else{
			//printf("+ %d * 0 = %ld\n",factorial[n-1-i], order);
		}
			
			//printnumbers(numbers);
	}
	return order;
}


int main(){

	int n, p, q;
	if(scanf("%d", &n)==EOF){return 0;} 
	//int ps[n];
	//int qs[n];
	for(int i = 0; i < n ; i++){
		numbers_p[i] = (data_t)(i+1); 
		numbers_q[i] = (data_t)(i+1);
	}
	
	long int a = dict_order(n, numbers_p);
	long int b = dict_order(n, numbers_q);
	
	//printf("a=%ld, b=%ld, difference:%ld\n", a,b,labs(a-b));
	printf("%ld\n",labs(a-b));
	return 0;
	
}

Measured memory_bytes: 1732
L,R = gets.chomp.split(" ").map(&:to_i)
L_diff = L % 2019
R_diff = R % 2019


if (R<2019)
    mods = []
    L.upto(R-1) do |i|
        (i+1).upto(R) do |j|
            mods << (i*j)%2019
        end
    end
    puts mods.min
elsif (L>2019)
    if (L/2019) != (R/2019)
        puts 0
    else
        mods = []
        L_diff.upto(2019) do |i|
            (i+1).upto(R_diff) do |j|
                mods << (i*j)%2019
            end
        end
        puts mods.min
    end
elsif (R>2019)&&(L<2019)
    puts 0
elsif (R==2019)||(L==2019)
    puts 0
end


Measured memory_bytes: 18812
#include "bits/stdc++.h"
using namespace std;
#define repr(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repr(i,0,n)
#define reprrev(i,a,b) for(int i=(int)(b)-1;i>=(int)(a);i--)
#define reprev(i,n) reprrev(i,0,n)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define mp make_pair
#define mt make_tuple
#define MOD 1000000007
#define PI 3.1415926535
typedef long long ll;
typedef pair<int, int> Pi;
typedef pair<ll, ll> Pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<bool> vb;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<Pi> vPi;
typedef vector<Pll> vPll;
typedef vector<vector<int>> vvi;
typedef vector<vector<bool>> vvb;
typedef vector<vector<ll>> vvll;
typedef vector<vector<char>> vvc;
typedef vector<vector<string>> vvs;
typedef vector<vector<double>> vvd;
typedef vector<vector<Pi>> vvPi;
typedef priority_queue<int, vector<int>, greater<int>> pqli;
typedef priority_queue<ll, vector<ll>, greater<ll>> pqlll;
typedef priority_queue<Pi, vector<Pi>, greater<Pi>> pqlP;
string YN(bool y) { return (y?"YES":"NO"); }
string yn(bool y) { return (y?"Yes":"No"); }
string ON(bool y) { return (y?"OK":"NG"); }
int main(void)
{
	int a, b, c, x, y;

	cin>>a>>b>>c>>x>>y;

	if(x==y){
		int ans=(2*c*x<a*x+b*y)?(2*c*x):(a*x+b*y);
		cout<<ans<<endl;
	}else if(x>y){
		int ans=(2*c*y+a*(x-y)<a*x+b*y)?(2*c*y+a*(x-y)):(a*x+b*y);
		ans=(ans<2*c*x)?ans:(2*c*x);
		cout<<ans<<endl;
	}else{
		int ans=(2*c*x+b*(y-x)<a*x+b*y)?(2*c*x+b*(y-x)):(a*x+b*y);
		ans=(ans<2*c*y)?ans:(2*c*y);
		cout<<ans<<endl;
	}
}

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

int main(){
	int a,b,c,x;
	int ans=0;

	cin >>a >>b >>c >>x;
	for(int i=0;i<=a;i++){
		for(int j=0;j<=b;j++){
			for(int k=0;k<=c;k++){
				if(x==500*i+100*j+50*k)ans++;
			}
		}
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
s = list(input())
n = len(s)
k = ['R','U','D']
g = ['L','U','D']
count =0

for i in range(n):
    if i % 2 ==0:
        if s[i] in k:
            count +=1
    else:
        if s[i] in g:
            count += 1
       
if count == n:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
 
int main(){
    int N;
    cin >> N;
    unsigned long long A=1;
    bool check=1;
    
    for(int i=0; i<N; i++){
        unsigned long long a;
        cin >> a;
        
        if(a==0){
            A = 0;
            check = 1;
            break;
        }
        else if(1000000000000000000/a>=A){
            A = A*a;
        }
        else{
            A = A*a;
            check=0;
        }
    }
    if(check==0){
        cout << -1 << endl;
    }
    else{
        cout << A << endl;
    }
}

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

int main() {
  string S;
  int ans = 10000;
  cin >> S;
  rep(i,S.size()-2){
  string A = S.substr(i,3);
    int n = stoi(A);
    int a = abs(753-n);
    ans = min(ans,a);
  }
  cout << ans;
}

Measured memory_bytes: 256
#include<cstdio>
char s[200001];
int w[200001];
int main()
{
	int n,i,b=0,ans=2e9;
	scanf("%d%s",&n,s);
	for(i=n-1;i>=0;i--)w[i]=w[i+1]+(s[i]=='.');
	for(i=0;i<=n;b+=s[i++]=='#')if(b+w[i]<ans)ans=b+w[i];
	printf("%d\n",ans);
}

Measured memory_bytes: 1280
#define _CRT_SECURE_NO_WARNINGS

#include <iostream>
#include <stdio.h>
#include <string>
#include <string.h>
#include <queue>
#include <cmath>
#include <stack>
#include <map>
#include <vector>
#include <algorithm>

#define int64 long long int

using namespace std;

int main()
{
	int n, A, B, C, a, b, c, price, lowprice;
	
	while(1){
		cin >> n;
		if(n == 0) break;

		lowprice = 10000000;

		A = n / 200;
		B = n / 300;
		C = n / 500;

		for(a=0; a<=A; a++){
			for(b=0; b<=B; b++){
				for(c=0; c<=C; c++){
					if(a*200 + b*300 + c*500 != n) continue;
					price = 0;

					price += ((a/5)*5*380*80)/100 + (a%5)*380;
					price += ((b/4)*4*550*85)/100 + (b%4)*550;
					price += ((c/3)*3*850*88)/100 + (c%3)*850;

					if(price < lowprice) lowprice = price;
				}
			}
		}

		cout << lowprice << endl;
	}

	return 0;
}

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

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;

int main(){
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	cout<<setprecision(32);

	int n, X;
	cin>>n>>X;
	int ans = 0;
	for(int i = 0; i < n; i++){
		int x; cin>>x;
		ans = __gcd(ans, abs(x - X));
	}
	cout<<ans<<endl;

	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

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

	public void execute() {
		Scanner sc = new Scanner(System.in);
		final int N = sc.nextInt();
		long diff = Long.MAX_VALUE;
		long[] sum = new long[N];

		for (int i = 0; i < N; i++) {
			int ai = sc.nextInt();
			if (i == 0) {
				sum[i] = ai;
			} else {
				sum[i] = sum[i - 1] + ai;
			}
		}
		final long total = sum[N - 1];

		for (int i = 0; i < N - 1; i++) {
			long snk = sum[i];
			long arai = total - snk;
			diff = Math.min(diff, Math.abs(snk - arai));
		}

		System.out.println(diff);
		sc.close();
	}

}


Measured memory_bytes: 80336
#include <bits/stdc++.h>
#define all(c) c.begin(), c.end()
#define gmax(x,y) x=max(x,y)
#define gmin(x,y) x=min(x,y)
#define rep(i,a,b) for(int i = a;i < b; ++i)
using namespace std;

typedef pair<int,int> pii;
typedef long long ll;

int main(){
	cin.tie(0);	
	cout.tie(0);	
	ios_base::sync_with_stdio(0);
	string s,t;
	cin >> s >> t;
	cout << t + s << '\n';
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define reg register
typedef long long ll;
using namespace std;
const int MN=3e5+5;
int n,m,a[MN];
ll s[MN],f[MN],g[MN];
inline ll Y1(int i){return f[i]+s[i]+1ll*i*(i+1)/2;}
inline ll Y2(int i){return g[i]+s[i]+1ll*i*(i+1)/2;}
inline ll Y3(int i){return f[i]+s[i]+1ll*i*(i-1)/2;}
inline ll Y4(int i){return g[i]+s[i]+1ll*i*(i-1)/2;}
inline double slope1(int i,int j){
	return 1.*(Y1(i)-Y1(j))/(1.*(i-j));
}
inline double slope2(int i,int j){
	return 1.*(Y2(i)-Y2(j))/(1.*(i-j));
}
inline double slope3(int i,int j){
	return 1.*(Y3(i)-Y3(j))/(1.*(i-j));
}
inline double slope4(int i,int j){
	return 1.*(Y4(i)-Y4(j))/(1.*(i-j));
}
int stk[MN],top;
#define mid (l+r>>1)
ll h[MN],t[MN];
void solve(int l,int r){
	if(l==r){h[l]=max(h[l],f[l-1]+g[l+1]+1-a[l]);return;}
	solve(l,mid);solve(mid+1,r);
	s[l-1]=top=0;
	for(reg int i=l;i<=r;i++)s[i]=s[i-1]+a[i];
	for(reg int i=l-1;i<mid;i++){
		while(top>1&&slope3(stk[top-1],stk[top])<=slope3(stk[top-1],i))top--;
		stk[++top]=i;
	}
	for(reg int i=mid+1,j;i<=r;i++){
		while(top>1&&slope3(stk[top-1],stk[top])<=i)top--;
		j=stk[top];
		t[i]=f[j]+1ll*(i-j)*(i-j+1)/2-s[i]+s[j]+g[i+1];
	}
	reg ll res=-1e18;
	for(reg int i=r;i>mid;i--)
		res=max(res,t[i]),h[i]=max(h[i],res);
	s[r+1]=top=0;
	for(reg int i=r;i>=l;i--)s[i]=s[i+1]+a[i];
	for(reg int i=r+1;i>mid+1;i--){
		while(top>1&&slope4(stk[top-1],stk[top])>=slope4(stk[top-1],i))top--;
		stk[++top]=i;
	}
	for(reg int i=mid,j;i>=l;i--){
		while(top>1&&slope4(stk[top-1],stk[top])>=i)top--;
		j=stk[top];
		t[i]=g[j]+1ll*(j-i)*(j-i+1)/2-s[i]+s[j]+f[i-1];
	}
	res=-1e18;
	for(reg int i=l;i<=mid;i++)
		res=max(res,t[i]),h[i]=max(h[i],res);
}
int main(){
	scanf("%d",&n);
	for(reg int i=1;i<=n;i++)scanf("%d",a+i);
	for(reg int i=1;i<=n+1;i++)s[i]=s[i-1]+a[i];
	stk[top=1]=0;
	for(reg int i=1,j;i<=n+1;i++){
		while(top>1&&slope1(stk[top-1],stk[top])<=i)top--;
		j=stk[top];
		f[i]=max(f[i-1],f[j]+1ll*(i-j)*(i-j-1)/2-s[i-1]+s[j]);
		while(top>1&&slope1(stk[top-1],stk[top])<=slope1(stk[top-1],i))top--;
		stk[++top]=i;
	}
	reverse(a+1,a+1+n);
	for(reg int i=1;i<=n+1;i++)s[i]=s[i-1]+a[i];
	stk[top=1]=0;
	for(reg int i=1,j;i<=n+1;i++){
		while(top>1&&slope2(stk[top-1],stk[top])<=i)top--;
		j=stk[top];
		g[i]=max(g[i-1],g[j]+1ll*(i-j)*(i-j-1)/2-s[i-1]+s[j]);
		while(top>1&&slope2(stk[top-1],stk[top])<=slope2(stk[top-1],i))top--;
		stk[++top]=i;
	}
	reverse(a+1,a+1+n);
	reverse(g,g+2+n);
	memset(h,~0x3f,sizeof(h));
	solve(1,n);scanf("%d",&m);
	while(m--){
		static int x,y;scanf("%d%d",&x,&y);
		printf("%lld\n",max(f[x]+g[x],h[x]+a[x]-y));
	}
	return 0;
}

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

const long double EPS = 1e-10;
const long long INF = 1e18;
const int MOD = (int)1e9 + 7;
const long double PI = acos(-1.0L);

bool is_prime(long long N) {
  if (N == 1) return false;
  for (long long i = 2; i * i <= N; ++i) {
    if (N % i == 0) return false;
  }
  return true;
}

int main() {
  int x;
  cin >> x;
  while (!is_prime(x)) x++;
  cout << x << endl;

  return 0;
}

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

using namespace std;

signed main() {
    string s; cin >> s;
    int ans = 0, cnt = 0;
    for (int i = 0; i < (int)s.size(); ++i) {
        if (s[i] == 'R') ++cnt;
        else {
            ans = max(ans, cnt);
            cnt = 0;
        }
    }
    ans = max(ans, cnt);
    cout << ans << endl;
}


Measured memory_bytes: 3596
import sys

sys.setrecursionlimit(10**5)
n, u, v = map(int, input().split())
u -= 1
v -= 1
m_mat = [[] for i in range(n)]
for _ in range(n-1):
    a, b = map(int, input().split())
    a -= 1
    b -= 1
    m_mat[a].append(b)
    m_mat[b].append(a)
u_map = [-1]*n
v_map = [-1]*n
u_map[u] = 0
v_map[v] = 0


def dfs(current, depth, ma):
    for nex in m_mat[current]:
        if ma[nex] > -1:
            continue
        ma[nex] = depth
        dfs(nex, depth+1, ma)


dfs(u, 1, u_map)
dfs(v, 1, v_map)

ans = -1
for i in range(n):
    if u_map[i] < v_map[i] and v_map[i] > ans:
        ans = v_map[i]

print(ans-1)


Measured memory_bytes: 101036
n = gets.chomp.to_i
alist = gets.chomp.split.collect{ |item| item.to_i}
blist = gets.chomp.split.collect{ |item| item.to_i}
clist = gets.chomp.split.collect{ |item| item.to_i}

ans = 0
before = -2
n.times do |ni|
  a = alist[ni]
  ans += blist[a-1]
  ans += clist[before-1] if ((before+1) == a)
  before = a
end

puts ans


Measured memory_bytes: 1788