akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
// abc083 A

int main() {
	int a, b, c, d;
	cin >> a >> b >> c >> d;
	if(a+b == c+d) puts("Balanced");
	else if(a+b > c+d) puts("Left");
	else puts("Right");
}


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

using namespace std;

typedef long long ll;
#define int ll
typedef long double ld;

typedef pair<int,int> pii;
#define x first
#define y second

signed main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);

    int h1,m1,h2,m2,k;
    cin>>h1>>m1>>h2>>m2>>k;
    int t1=h1*60+m1,t2=h2*60+m2;
    cout<<max(0ll,t2-t1-k);
}


Measured memory_bytes: 3648
#DP E
n,W=map(int,input().split())
wv=[list(map(int,input().split())) for _ in range(n)]
m=0
for i in range(n):
    m+=wv[i][1]
inf=float("inf")
dp=[[inf]*(m+1) for _ in range(n+1)]
dp[0][0]=0
for i in range(n):
    w,v=wv[i]
    for j in range(m+1):
        if j<v:
            dp[i+1][j]=dp[i][j]
        else:
            dp[i+1][j]=min(dp[i][j],dp[i][j-v]+w)
ans=0
for i in range(m+1):
    if dp[n][i]<=W:
        ans=i
print(ans)

Measured memory_bytes: 307912
#define _CRT_SECURE_NO_WARNINGS
#include <bits/stdc++.h>
#include <random>
using namespace std;
#define rep(i, a, n) for (int i = a; i < n; i++)
#define per(i, a, n) for (int i = n - 1; i >= a; i--)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define fi first
#define se second
#define sz(x) ((int)(x).size())
typedef vector<int> vi;
typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef double db;
mt19937 mrand(random_device{}());
const ll mod = 1000000007;
int rnd(int x) { return mrand() % x; }
ll powmod(ll a, ll b)
{
	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;
}
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }

static uint MD = mod;
struct ModInt
{
	using M = ModInt;
	uint v;
	ModInt(ll _v = 0) { set_v(uint(_v % MD + MD)); }
	M &set_v(uint _v)
	{
		v = (_v < MD) ? _v : _v - MD;
		return *this;
	}
	explicit operator bool() const { return v != 0; }
	M operator-() const { return M() - *this; }
	M operator+(const M &r) const { return M().set_v(v + r.v); }
	M operator-(const M &r) const { return M().set_v(v + MD - r.v); }
	M operator*(const M &r) const { return M().set_v(uint(ull(v) * r.v % MD)); }
	M operator/(const M &r) const { return *this * r.inv(); }
	M &operator+=(const M &r) { return *this = *this + r; }
	M &operator-=(const M &r) { return *this = *this - r; }
	M &operator*=(const M &r) { return *this = *this * r; }
	M &operator/=(const M &r) { return *this = *this / r; }
	bool operator==(const M &r) const { return v == r.v; }
	M pow(ll n) const
	{
		M x = *this, r = 1;
		while (n)
		{
			if (n & 1)
				r *= x;
			x *= x;
			n >>= 1;
		}
		return r;
	}
	M inv() const { return pow(MD - 2); }
	friend ostream &operator<<(ostream &os, const M &r) { return os << r.v; }
};
using Mint = ModInt;
//head
// cin >> t;
// for (int cas = 1; cas <= t; ++cas)
// {
// 	cout << "Case #" << cas << ": ";
// }
int main()
{
	// freopen("input.txt", "r", stdin);
	// freopen("output.txt", "w", stdout);
	ios::sync_with_stdio(false);
	cin.tie(0);
	int a,b;
	int k;
	cin>>k;
	cin>>a>>b;
	bool fg = false;
	rep(i,a,b+1) {
		if(i%k==0) {
			fg=true;
			break;
		}
	}
	cout<<(fg?"OK":"NG")<<endl;
	return 0;
}


Measured memory_bytes: 3652
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
using namespace std;
using ll = long long;

#define REP(i, N) for (ll i = 0; i < N; ++i)
#define pll pair<ll, ll>
#define F first
#define S second

class UnionFind {
public:
    vector <ll> par; // 各元の親を表す配列
    vector <ll> siz; // 素集合のサイズを表す配列(1 で初期化)

    // Constructor
    UnionFind(ll sz_): par(sz_), siz(sz_, 1LL) {
        for (ll i = 0; i < sz_; ++i) par[i] = i; // 初期では親は自分自身
    }
    void init(ll sz_) {
        siz.assign(sz_, 1LL);  // assign: 再代入
        par.resize(sz_);  // resize: 再確保
        for (ll i = 0; i < sz_; ++i) par[i] = i; // 初期では親は自分自身
    }

    // Member Function
    // Find
    ll root(ll x) { // 根の検索
        while (par[x] != x) {
            x = par[x] = par[par[x]]; // x の親の親を x の親とする
        }
        return x;
    }

    // Union(Unite, Merge)
    bool merge(ll x, ll y) {
        x = root(x);
        y = root(y);
        if (x == y) return false;
        // merge technique（データ構造をマージするテク．小を大にくっつける）
        if (siz[x] < siz[y]) swap(x, y);
        siz[x] += siz[y];
        par[y] = x;
        return true;
    }

    bool issame(ll x, ll y) { // 連結判定
        return root(x) == root(y);
    }

    ll size(ll x) { // 素集合のサイズ
        return siz[root(x)];
    }
};

int main() {
    // input
    ll N, M;
    ll node1, node2;
    cin >> N >> M;
    vector<pll> A(M);
    for (ll i = 0; i < M; i++) {
        cin >> node1 >> node2; --node1, --node2;
        A[i].F = node1;
        A[i].S = node2;
    }

    // calculation
    vector<ll> ans(M);
    ans[M-1] = (N*(N-1))/2;  // 全ての頂点が孤立している状態

    UnionFind uf(N);
    for (ll i = M-1; i >= 1; --i) {
        node1 = A[i].F, node2 = A[i].S;
        if (uf.issame(node1, node2)) {
            ans[i-1] = ans[i];
        } else {
            // 根が異なるとき，それぞれのサイズの積（頂点の組み合わせ）を引く．
            ans[i-1] = ans[i] - (uf.size(node1) * uf.size(node2));
            uf.merge(node1, node2);
        }
    }

    REP(i, M) {
        cout << ans[i] << "\n";
    }

    return 0;
}

Measured memory_bytes: 5248
#include<stdio.h>

int main(void)
{
	long int n,a;
	int k;
	int i=1;
	
	scanf("%ld%d",&n,&k);
	
	a=k;
	
	while(a<n){
		a=a*k;
		i++;
		if(a==n)
			i++;
	}
	
	printf("%d",i);
	return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <string>
#include <vector>

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

using std::cin;
using std::cout;
using std::endl;
using std::string;
using std::vector;

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

  int prob = 1 << M;
  cout << (100 * (N-M) + 1900 * M) * prob << endl;

  return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main{
	private static final Scanner scan = new Scanner(System.in);

	public static void main(String[] args){
		double r = scan.nextDouble();
		double area = r * r * Math.PI;
		double cir = 2 * r * Math.PI;
		System.out.printf("%f %f\n", area, cir);
	}
}

Measured memory_bytes: 28332
#include<bits/stdc++.h>
using namespace std;
#define ll long long                                    // long long省略
#define pb push_back                                    // push_back省略
#define mp make_pair                                    // make_pair省略
#define fi first                                        // first省略
#define se second                                       // second省略
#define itn int                                         // int誤字保険                                   // cout誤字保険
#define vecotr vector                                   // vector誤字保険
#define ednl endl                                       // endl誤字保険
#define opt() cin.tie(0); ios::sync_with_stdio(false)   // 入出力速度改善

#define rep(i,l,r) for(ll i=(l);i<(r);i++)               // 範囲[l, r)で刻み1のfor文(順方向)
#define repp(i,l,r,k) for(ll i=(l);i<(r);i+=(k))         // 範囲[l, r)で刻みkのfor文(順方向)
#define rrep(i,l,r) for(ll i=(r-1);i>=(l);i--)           // 範囲[l, r)で刻み1のfor文(逆方向)
#define rrepp(i,l,r,k) for(ll i=(r-1);i>=(l);i-=(k))     // 範囲[l, r)で刻みkのfor文(逆方向)
#define all(x) (x).begin(), (x).end()                   // vectorのポインタ位置指定用
#define max(p,q)((p)>(q)?(p):(q))                       // max拡張
#define min(p,q)((p)<(q)?(p):(q))                       // min拡張
#define bit(n,m)(((n)>>(m))&1)                          // 変数nのm番目のbitを取り出す

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 (b<a) { a=b; return 1; } return 0; }

int dy[]={0, 1, 0, -1};                                 // 4方向近傍
int dx[]={1, 0, -1, 0};                                 // 4方向近傍

#define INF ((1LL<<62)-(1LL<<31))
//#define MOD 998244353
#define MOD 1000000007
#define invp(a,p) pom(a,p-2,p)

////////////////////////////////////////////////////////////////////////////////////////
int main(){
    int n; cin >> n;
    string s, t; cin >> s >> t;
    rep(i,0,n){
        cout << s[i] << t[i];
    }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    cin >> n;
    n=n%10;
    //cout<<n<<endl;
    if( n==2||n==4||n==5||n==7||n==9 )cout<<"hon"<<endl;
    else if( n==0||n==1||n==6||n==8 )cout<<"pon"<<endl;
    else cout << "bon"<<endl;
}


Measured memory_bytes: 3632
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <cstdio>
using namespace std;

int main(){
	char in1, in2, now = 'A';
	while (scanf("%c,%c", &in1, &in2) != EOF){
		if (in1 == now)			now = in2;
		else if (in2 == now)	now = in1;
	}
	cout << now << endl;

	return 0;
}

Measured memory_bytes: 1152
import java.util.Scanner;
public class Main {

    public static void main(String[] args){
    	Scanner sc = new Scanner(System.in);
    	// 入力
    	int n = sc.nextInt();
    	int d = sc.nextInt();

    	int d2 = d + 1 + d;
    	int ans = n / d2;
    	if (n % d2 > 0){
    		ans++;
    	}


    	// 出力
    	System.out.println(ans);
    }
}

Measured memory_bytes: 23636
//Utkarsh.25dec
#include <bits/stdc++.h>
#include <chrono>
#include <random>
#define ll long long int
#define ull unsigned long long int
#define pb push_back
#define mp make_pair
#define mod 1000000007
#define rep(i,n) for(ll i=0;i<n;i++)
#define loop(i,a,b) for(ll i=a;i<=b;i++)
#define vi vector <int>
#define vs vector <string>
#define vc vector <char>
#define vl vector <ll>
#define all(c) (c).begin(),(c).end()
#define max3(a,b,c) max(max(a,b),c)
#define min3(a,b,c) min(min(a,b),c)
#define deb(x) cerr<<#x<<' '<<'='<<' '<<x<<'\n'
using namespace std;
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
// ordered_set s ; s.order_of_key(val)  no. of elements strictly less than val
// s.find_by_order(i)  itertor to ith element (0 indexed)
typedef vector<vector<ll>> matrix;
ll power(ll a,ll b) {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;}
ll modInverse(ll a){return power(a,mod-2);}
const int N=1000023;
bool vis[N];
vector <int> adj[N];
ll cnt[N]={0};
ll bad[N]={0};
void solve()
{
    ll n;
    cin>>n;
    vl v;
    rep(i,n)
    {
        ll c;
        cin>>c;
        v.pb(c);
    }
    for(int i=0;i<n;i++)
    {
        cnt[v[i]]++;
        if(cnt[v[i]]>1)
            continue;
        for(int j=2*v[i];j<=1000000;j+=v[i])
            bad[j]=1;
    }
    ll ans=0;
    for(int i=0;i<n;i++)
    {
        if(cnt[v[i]]>1)
            continue;
        if(bad[v[i]]==1)
            continue;
        ans++;
    }
    cout<<ans;
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int T=1;
    //cin>>T;
    int t=0;
    while(t++<T)
    {
        //cout<<"Case #"<<t<<":"<<' ';
        solve();
        //cout<<'\n';
    }
    cerr << "Time : " << 1000 * ((double)clock()) / (double)CLOCKS_PER_SEC << "ms\n";
}

Measured memory_bytes: 43976
#include <vector>
#include <iostream>
#include <stack>
#include <string>
#include <algorithm>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <map>
#include <set>
#include <iomanip>
#include <limits>
#include <cmath>

using namespace std;
typedef long long ll;
typedef vector<int> VI;
typedef pair<ll, ll> P;

#define rep(a,n) for(int a = 0;a < n;a++)

vector<vector<ll>> graph;
vector<vector<ll>> dist;
const ll LARGE = (ll)1e15;

int main(void)
{
	ll n, m, l;
	cin >> n >> m >> l;
	graph.resize(n, vector<ll>(n, LARGE));
	rep(i, m) {
		ll a, b, c;
		cin >> a >> b >> c;
		a--;
		b--;
		graph[a][b] = c;
		graph[b][a] = c;
	}
	rep(i, n) graph[i][i] = 0;
	int q;
	cin >> q;
	vector<P> qs;
	rep(i, q) {
		int s, t;
		cin >> s >> t;
		s--; t--;
		qs.emplace_back(s, t);
	}

	for (int k = 0; k < n; k++) {
		for (int i = 0; i < n; i++) {
			for (int j = 0; j < n; j++) {
				graph[i][j] = min(graph[i][j], graph[i][k] + graph[k][j]);
			}
		}
	}
	dist.resize(n, vector<ll>(n, LARGE));
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < n; j++) {
			if (graph[i][j] <= l) dist[i][j] = 1;
		}
	}
	for (int k = 0; k < n; k++) {
		for (int i = 0; i < n; i++) {
			for (int j = 0; j < n; j++) {
				dist[i][j] = min(dist[i][j], dist[i][k] + dist[k][j]);
			}
		}
	}
	for (auto e : qs) {
		auto d = dist[e.first][e.second];
		if (d == LARGE) {
			cout << -1 << endl;
		}
		else {
			cout << d - 1 << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 3320
#include <bits/stdc++.h>
using namespace std;
//make_tuple emplace_back next_permutation push_back make_pair second first

#if MYDEBUG
#define DBG(...) {string dst__=#__VA_ARGS__;dbgsplit(dst__);stringstream dss__; dss__<<dst__; debug(dss__,__VA_ARGS__);}
#else
#define DBG(...)
#endif
void debug(stringstream& ds){cerr<<endl;return;}
template<typename F, typename... R>void debug(stringstream& ds,const F& f, const R&... r){string n; ds>>n; cerr<< n <<'='<<f<<' '; debug(ds,r...);}
void dbgsplit(string &s){int l=s.length(),n=0;for(int i=0; i<l; ++i){if(s[i]=='(')++n;if(s[i]==')')--n;if(s[i]==','&&!n)s[i]=' ';}}
using LL = long long;
constexpr long long LINF=334ll<<53; constexpr int INF=15<<26; constexpr long long MOD=1E9+7;
long long gcd(long long a, long long b){
    while(b){a%=b;swap(a,b);}
    return a;
}
bool dfs(vector<long long> &a){
    int even=0,odd=0,odd_id,g=0;
    for(int i=0; i<(int)a.size(); ++i){
        if(a[i]%2==0)even++;
        else {odd++; odd_id=i;}
    }
    if(even%2==1)return true;
    if(odd>1)return false;
    if(a[odd_id]==1)return false;
    a[odd_id]--;
    for(int i=0; i<(int)a.size(); ++i){
        g=gcd(g,a[i]);
    }
    for(int i=0; i<(int)a.size(); ++i){
        a[i]/=g;
    }
    return !dfs(a);
}


int main(){
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    int n;
    cin >> n;
    vector<LL> a(n);
    for(int i=0; i<n; ++i){
        cin >> a[i];
    }
    cout << (dfs(a)?"First":"Second") <<"\n";


    return 0;
}




Measured memory_bytes: 1152
from collections import defaultdict
import sys
# Binary Indexed Tree (Fenwick Tree)
class BIT():
    def __init__(self, n):
        '''
        n = 要素数
        要素の添字iは 0 <= i < n となる
        '''
        self.n = n
        self.bit = [0] * (n + 1)

    def add(self, i, value):
        '''i番目の要素にvalueを加算する O(logN)'''
        i = i + 1
        while i <= self.n:
            self.bit[i] += value
            i += i & -i

    def _sum(self, i):
        s = 0
        while i > 0:
            s += self.bit[i]
            i -= i & -i
        return s

    def sum(self, l, r):
        '''区間[l, r)の和を求める O(logN)'''
        return self._sum(r) - self._sum(l)


input = sys.stdin.readline
N, Q = map(int, input().split())
C = list(map(int, input().split()))
LR = [tuple(map(int, input().split())) for _ in range(Q)]
query = [[] for _ in range(N)]
for i, (l, r) in enumerate(LR):
    query[l-1].append((i, r-1))

hist = defaultdict(lambda: -1)
nx = [-1] * N
for i in range(N-1, -1, -1):
    nx[i] = hist[C[i]]
    hist[C[i]] = i

bit = BIT(N)
ans = [None]*Q
for l in range(N-1,-1,-1):
    if nx[l] != -1:
        bit.add(nx[l],-1)
    for i,r in query[l]:
        ans[i] = (r-l+1) + bit.sum(l,r+1)

print(*ans,sep = '\n')

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

#define EPS (1e-10)
#define rep(i, a, b) for (int i = a; i < (int)(b); ++i)
#define rrep(i, a, b) for (int i = b - 1; i >= (int)(a); --i)

using namespace std;
using ll = long long;
using vi = vector<int>;
using vll = vector<ll>;
using vd = vector<double>;
using vvi = vector<vi>;

constexpr int MOD = 1000000007;

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

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

    vector<bool> s(n, true);
    rep(i, 0, n) {
        char c;
        cin >> c;
        if (c == 'x') { s[i] = false; }
    }

    vvi dp(n, vi(2, 0));
    int cnt = 1, next = 0;

    rep(i, 0, n) {
        if (s[i] && i >= next) {
            dp[i][0] = cnt++;
            next = i + c + 1;
        }
    }

    cnt = 1, next = n - 1;
    rrep(i, 0, n) {
        if (s[i] && i <= next) {
            dp[i][1] = cnt++;
            next = i - c - 1;
        }
    }

    if (cnt > k + 1 || cnt < k) { return 0; }

    rep(i, 0, n) {
        if ((dp[i][0] != 0) && (dp[i][1] != 0)) { cout << i + 1 << endl; }
    }

    return 0;
}

Measured memory_bytes: 12544
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
	int n;
	cin>>n;
	long long A[n][3];
	for(int i=0;i<n;i++)
	{
		cin>>A[i][0]>>A[i][1]>>A[i][2];
	}
	ll dp[n][3];
	ll ans;
	
	dp[0][0]=A[0][0];
	dp[0][1]=A[0][1];
	dp[0][2]=A[0][2];
	for(int i=1;i<n;i++)
	{
		dp[i][0]=max(dp[i-1][1],dp[i-1][2])+A[i][0];
		dp[i][1]=max(dp[i-1][0],dp[i-1][2])+A[i][1];
		dp[i][2]=max(dp[i-1][1],dp[i-1][0])+A[i][2];
	}
	ans=max(dp[n-1][0],max(dp[n-1][1],dp[n-1][2]));
	cout<<ans;
	
	return 0;
}


Measured memory_bytes: 4864
#include<bits/stdc++.h>     //11monme
using namespace std;
long long LCM(long long a,long long b);
signed main(){
    int n;
    cin>>n;
    long long t[n+2];
    for(int i=0;i<n;i++){
        cin>>t[i];
    }
    long long sum=t[0];
    for(int i=0;i<n;i++){
        sum=LCM(sum,t[i]);
    }
    cout<<sum<<"\n";
    return(0);
}
long long LCM(long long a,long long b){
    return(a/__gcd(a,b)*b);
}

Measured memory_bytes: 3636
#include<stdio.h>

int main()
{
	int n,m,l;
	scanf("%d", &n);
	m = n / 10;
	l = n % 10;
	if (m == 9 || l == 9) {
		printf("Yes");
	}
	else {
		printf("No");
	}
    return 0;
}

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

int main(){
    int E,Y;
    cin >> E >> Y;
    
    switch(E+1){
        case 1:
        if(1868<=Y&&Y<=1911){
            cout << 'M' << Y-1868+1 << endl;
        }
        else if(1912<=Y&&Y<=1925){
            cout << 'T' << Y-1912+1 << endl;
        }
        else if(1926<=Y&&Y<=1988){
            cout << 'S' << Y-1926+1 << endl;
        }
        else if(1989<=Y&&Y<=2016){
            cout << 'H' << Y-1989+1 << endl;
        }
        break;

        case 2:
        cout << 1868+Y-1 << endl;

        break;

        case 3:
        cout << 1912+Y-1 << endl;

        break;

        case 4:
        cout << 1926+Y-1 << endl;

        break;
        
        case 5:
        cout << 1989+Y-1 << endl;

        break;
    }

    return 0;
}


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

int main(){
	int a[4], b[4];
	int hit, blow;

	while (cin >> a[0] >> a[1] >> a[2] >> a[3]){
		cin >> b[0] >> b[1] >> b[2] >> b[3];
		hit = 0;
		blow = 0;

		for (int i = 0; i < 4; i++){
			if (a[i] == b[i]) hit++;
		}

		for (int i = 0; i < 4; i++){
			for (int j = 0; j < 4; j++){
				if (a[i] == b[j]) blow++;
			}
		}
		blow -= hit;

		cout << hit << " " << blow << endl;
	}
	
	return 0;
}

Measured memory_bytes: 1160
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n;
	cin>>n;
	int a[500];
	for(int i=1;i<=n;i++)
		cin>>a[i];
		int t=0;
	for(int j=1;j<=n;j++){
		if(a[j]!=j){
			t++;
		}
	}

	if(t==2||t==0)
	cout<<"YES";
	else
	cout<<"NO";
}

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

int main(){
  int H,W;
  cin >> H >> W;
  vector<string> field(H);
  for(int i = 0; i < H; i++) cin >> field.at(i);

  queue<pair<int,int>> que;
  vector<vector<int>> dist(H,vector<int>(W,-1));

  vector<int> dx = {0,-1,0,1};
  vector<int> dy = {1,0,-1,0};

  //白面の数を求める。
  int whitenum = 0;
  for(int i = 0; i < H; i++){
    for(int j = 0; j < W; j++){
      if(field.at(i).at(j)=='.') whitenum++;
    }
  }

  dist.at(0).at(0) = 0;
  pair<int,int> tmp = make_pair(0,0);
  que.push(tmp);
  
  while(!que.empty()){
    pair<int,int> v = que.front();  
    que.pop();
    int y,x;
    tie(y,x) = v;
  
    for(int dir = 0; dir < 4; dir++){
      int nx,ny;
      nx = x + dx.at(dir);
      ny = y + dy.at(dir);

      if(nx<0||ny<0||nx>W-1||ny>H-1)continue;
      if(field.at(ny).at(nx)=='#')continue;
      if(dist.at(ny).at(nx)!=-1)continue;

      dist.at(ny).at(nx) = dist.at(y).at(x) + 1;
      pair<int,int> tmp1 = make_pair(ny,nx);  
      que.push(tmp1);
    }
  }
  if(dist.at(H-1).at(W-1)==-1){
    cout << -1 << endl;
  }else{
    cout << whitenum - dist.at(H-1).at(W-1) - 1 << endl;
  }
}

Measured memory_bytes: 256
// B - FizzBuzz Sum
import { readFileSync } from "fs";
const n = ~~readFileSync("/dev/stdin", "utf8");

let ans = 0

for (let i = 1; i <= n; i++) {
    if (i % 3 != 0 && i % 5 != 0) ans += i;
}

console.log(ans)

Measured memory_bytes: 35172
#include<iostream>
#include <math.h>
using namespace std;
int main(){
    int x;
    cin >> x;
    int max,be,max1;
    max=2;
    max1=0;
    be=2;
    
    for(int i=2;i<=31;i++){
        for(int j=2;j<=9;j++){
            max1 = pow(i,j);
            if(max1<=x && max<=max1){
                max = max1;
            }
        }

    }
    if(x==1){
        max=1;
    }
    cout << max << endl;
    return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
#include <iterator>
using namespace std;
struct Fast {Fast(){std::cin.tie(0);ios::sync_with_stdio(false);}} fast;
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define ALL(v) begin(v), end(v)
#define rreps(i, a, n) for (ll i = (a); i <= (ll)(n); ++i)
#define rrep(i, n) rreps(i, 0, n)
#define reps(i, a, n) for (ll i = (a); i < (ll)(n); ++i)
#define rep(i, n) reps(i, 0, n)
#define each(i, n) for (auto&& i : n)
#define fill(x, y) memset(x,y,sizeof(x))
#define debug(x) cerr << x << " " << "(L:" << __LINE__ << ")" << '\n';
using ll = long long;
using ull = unsigned long long;
using vi = vector<int>;
using vvi = vector<vi>;
using pii = pair<int, int>;
using D = double;
using P = complex<D>;
using vs = vector<string>;
template <typename T> using PQ = priority_queue<T>;
template <typename T> using minPQ = priority_queue<T, vector<T>, greater<T>>;
const int INF = 1001001001;
const ll LINF = 1001001001001001001ll;
const int MOD = 1e9 + 7;
const D EPS = 1e-9;
const int dx[] = {0, 1, 0, -1, 1, -1, 1, -1}, dy[] = {1, 0, -1, 0, 1, -1, -1, 1};
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 (b<a) { a=b; return 1; } return 0; }
template <typename T> inline void print(const T& x) {cout << x << '\n';}

signed main()
{ 
  int n;
  vs ans;
  while(cin>>n, n)
  {
    vi x(n);
    vi y(n);
    rep(i,n) cin>>x[i]>>y[i];
    int m; cin>>m;
    int nx=10, ny=10;
    rep(i,m)
    {
      char d;
      int l; 
      cin>>d>>l;
      if(d=='N')
      {
        rep(j,l)
        {
          ny++;
          rep(k,n)
          {
            if(nx==x[k]&&ny==y[k])
            {
              x[k]=-1, y[k]=-1;
            }
          }
        }
      } 
      else if(d=='S')
      {
        rep(j,l)
        {
          ny--;
          rep(k,n)
          {
            if(nx==x[k]&&ny==y[k])
            {
              x[k]=-1, y[k]=-1;
            }
          }
        }
      }
      else if(d=='E')
      {
        rep(j,l)
        {
          nx++;
          rep(k,n)
          {
            if(nx==x[k]&&ny==y[k])
            {
              x[k]=-1, y[k]=-1;
            }
          }
        }
      }
      else
      {
        rep(j,l)
        {
          nx--;
          rep(k,n)
          {
            if(nx==x[k]&&ny==y[k])
            {
              x[k]=-1, y[k]=-1;
            }
          }
        }
      }
    }
    bool c=true;
    rep(i,n)
    {
      if(!(x[i]==-1&&y[i]==-1)) c=false;
    }
    c?ans.pb("Yes"):ans.pb("No");
  }
  each(v,ans) print(v);

  return 0;
}



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


#define ll long long


vector<ll> prefix;

ll  dp[401][401];


ll minCost(vector<ll int> a,int i,int j){

    if(i>=j){
        return 0;
    }

    if(dp[i][j]!=-1){
        return dp[i][j];

    }

     ll sum=0;


    if(i>0){
        sum=prefix[j]-prefix[i-1];
    }else{
        sum=prefix[j];

    }



     ll ans=LLONG_MAX;

    for(int k=i;k<j;k++){
       ll int temp=sum+minCost(a,i,k)+minCost(a,k+1,j);
       ans=min(ans,temp);

    }

    return dp[i][j]=ans;

}


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

  vector<ll int> a(n);

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

    prefix.resize(n);
    prefix[0]=a[0];

  for(int i=1;i<n;i++){

      prefix[i]=a[i]+prefix[i-1];
  }

 


    memset(dp,-1,sizeof(dp));


  cout<<minCost(a,0,n-1)<<endl;


   
  

}


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

ll k, a, b, ans;

int main() {
    cin >> k >> a >> b;
    k++;
    // 交換しない場合
    if (k < a + 2 || a + 2 >= b) {
        cout << k << endl;
        return 0;
    }
    // 交換する場合
    // 初回
    k -= a + 2;
    ll diff = b - a;
    ans = b;
    // 2回目以降
    ll multi = k / 2;
    ans += diff * multi;
    if (k % 2 == 1) ans++;
    cout << ans << endl;

    return 0;
}

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


ll N;

/*
	移動後のベクトルをvとする。
	vがわかっているなら、vとの内積がプラスになるエンジンを全て足せばよい。
	
	
	

*/

struct vect {
	double x;
	double y;
	double angle;
};


int main(){
	cin >> N;
	
	vector<vect> v(N*3);
	for ( int i = 0; i < N; i++ ){
		cin >> v[i].x >> v[i].y;
		v[i].angle = atan2(v[i].y, v[i].x);
	}
	
	sort(v.begin(), v.begin()+N, [](const vect &l, const vect &r){return l.angle<r.angle;});
	for ( int i = 0; i < N; i++ ){
		v[N+i  ] = { v[i].x, v[i].y, v[i].angle+M_PI*2 };
		v[N*2+i] = { v[i].x, v[i].y, v[i].angle+M_PI*4 };
		//cout << v[i].x << " " << v[i].y << " " << v[i].angle << endl;
	}
	
	int i0 = 0, i1 = 0;
	vect vsum = { 0.0, 0.0, 0.0 };
	double r2max = 0.0;
	for ( i1 = 0; i1 < N && v[i1].angle < v[i0].angle+M_PI; i1++ ){
		vsum.x += v[i1].x;
		vsum.y += v[i1].y;
	}
	r2max = vsum.x*vsum.x + vsum.y*vsum.y;
	
	
	// v[i]  (i0 <= i < i1) を全て足したものが vsum である。
	// v[i0].angle + PI <= v[i1].angle を保ったまま少しずつ i0, i1 を変えてvsumがどうなるか調べる
	
	while ( i0 < N ){
		if ( i1 < i0+N && v[i1].angle < v[i0].angle + M_PI ){
			vsum.x += v[i1].x;
			vsum.y += v[i1].y;
			i1++;
		}
		else {
			vsum.x -= v[i0].x;
			vsum.y -= v[i0].y;
			i0++;
		}
		r2max = max( r2max, vsum.x*vsum.x + vsum.y*vsum.y );
	}
	
	
	cout << setprecision(15) << sqrt(r2max) << endl;
	
	return 0;
}


Measured memory_bytes: 256
import sys
read = sys.stdin.buffer.read
input = sys.stdin.buffer.readline
inputs= sys.stdin.buffer.readlines
#rstrip().decode('utf-8')

import math
#import numpy as np
#import operator
#from heapq import heapify,heappop,heappush
#from math import gcd
#from fractions import gcd
#from collections import deque
#from collections import defaultdict
#from collections import Counter
#from itertools import accumulate
#from itertools import groupby
#from itertools import permutations
#from itertools import combinations
#from scipy.sparse import csr_matrix
#from scipy.sparse.csgraph import floyd_warshall
#from scipy.sparse.csgraph import csgraph_from_dense
#from scipy.sparse.csgraph import dijkstra
#sys.setrecursionlimit(10**7)

#map(int,input().split())

def main():

	a,b,x=map(int,input().split())
	if 0<=x<=(a**2)*b/2:
		ans=math.atan(((b**2)*a)/(2*x))
	else:
		ans=math.atan((2/a)*(b-(x/a**2)))
	print(math.degrees(ans))






	




if __name__ == '__main__':
	main()

Measured memory_bytes: 3060
fun main(args: Array<String>) {
    val s = readLine()!!
    val k = readLine()!!.toInt()
    val ss = sortedSetOf<String>()
    for (i in 0 until s.length) {
        for (j in i + 1..Math.min(i + k, s.length)) {
            ss += s.substring(i, j)
        }
    }
    var i = 1
    for (x in ss) {
        if (i++ != k) continue
        println(x)
        break
    }
}


Measured memory_bytes: 38140
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int n = in.nextInt();
		int k = in.nextInt()-1;
		int[] trees = new int[n];
		for( int i = 0; i < n; i++ ) {
			trees[i] = in.nextInt();
		}
		Arrays.sort(trees);
		int minDiff = Integer.MAX_VALUE;
		for( int i = 0; i < n-k; i++ ) {
			minDiff = Math.min(minDiff,trees[i+k]-trees[i]);
		}
		System.out.println(minDiff);
	}
}

Measured memory_bytes: 50712
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        long n = Long.parseLong(sc.next());
        if (n % 2 != 0) {
            System.out.println(0);
            return;
        }
        long ans = 0;
        n /= 2;
        while (n != 0) {
            ans += n / 5;
            n /= 5;
        }
        System.out.println(ans);
    }
}

Measured memory_bytes: 22996
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <deque>
#include <queue>
#include <stack>
#include <cstdio>
#include <string>
#include <vector>
#include <complex>
#include <cstdlib>
#include <cstring>
#include <iomanip>
#include <numeric>
#include <utility>
#include <iostream>
#include <algorithm>
#include <functional>

using namespace std;

#define INF (1 << 30)
#define INFL (1LL << 62)
#define MOD7 1000000007
#define MOD9 1000000009
#define EPS 1e-10

#define ll long long
#define ull unsigned long long
#define pii pair<int, int>
#define pll pair<ll, ll>
#define pul pair<ull, ull>
#define all(a) (a).begin(), (a).end()
#define FOR(i,a,b) for (int i=(a);i<(b);++i)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);--i)
#define REP(i,n) for (int i=0;i<(n);++i)
#define RREP(i,n) for (int i=(n)-1;i>=0;--i)

void YES() { cout << "YES" << endl; }
void NO() { cout << "NO" << endl; }
void Yes() { cout << "Yes" << endl; }
void No() { cout << "No" << endl; }
void yes() { cout << "yes" << endl; }
void no() { cout << "no" << endl; }
void Taka() { cout << "Takahashi" << endl; }
void Aoki() { cout << "Aoki" << endl; }
void digit(int d) { cout << fixed << setprecision(d); }
void IOup() { cin.tie(0); ios::sync_with_stdio(false); }

int main() {
	int n, l, r, ans = 0;
	cin >> n;
	while (n--) {
		cin >> l >> r;
		ans += r - l + 1;
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
S=list(input())
count=0
for i in range(len(S)):
  c=i%2
  if c==0 and S[i]=="L":
    count +=1
    
  elif c==1 and S[i]=="R":
    count +=1
  
  else:
    next
if count==0:
  print("Yes")
else:
  print("No")

Measured memory_bytes: 3060
#include<cstdio>
#include<algorithm>
using namespace std;
typedef long long ll;
const int N=100100;
int i,j,k,n,m,En,ch,ff,x,y,Fg;
int h[N],d[N],A[N];
ll f[N];
struct edge { int s,n;} E[N<<1];
void R(int &x) {
	ff=x=0;ch=getchar();
	while (ch<'0' || '9'<ch) { if (ch=='-') ff=1;ch=getchar();}
	while ('0'<=ch && ch<='9') x=x*10+ch-'0',ch=getchar();
	if (ff) x-=x;
}
void E_add(int x,int y) {
	d[x]++;d[y]++;
	E[++En].s=y;E[En].n=h[x];h[x]=En;
	E[++En].s=x;E[En].n=h[y];h[y]=En;
}
void dfs(int x,int F) {
	ll sum=0,ma=0;
	int fg=0;
	for (int k=h[x];k;k=E[k].n) if (E[k].s!=F) {
		fg=1;
		dfs(E[k].s,x);
		if (Fg) return;
		sum+=f[E[k].s];
		ma=max(ma,f[E[k].s]);
	}
	if (!fg) f[x]=A[x];
	else {
		f[x]=2*A[x]-sum;
		if (f[x]<0) { Fg=1;return;}
		if (ma*2-sum>f[x] || f[x]>sum) { Fg=1;return;}
	}
}
int main() {
	R(n);
	for (i=1;i<=n;i++) R(A[i]);
	for (i=1;i<n;i++) {
		R(x);R(y);
		E_add(x,y);
	}
	if (n==2) {
		if (A[1]==A[2]) puts("YES");
		else puts("NO");
		return 0;
	}
	for (i=1;i<=n;i++) if (d[i]!=1) break;
	dfs(i,0);
	if (Fg || f[i]) puts("NO");
	else puts("YES");
}

Measured memory_bytes: 8960
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define all(V) V.begin(),V.end()
const ll MOD = 1000000007;

ll M[3010][3010];
ll A[3010][3010][4];

int main() {
	int R, C, K;
	cin >> R >> C >> K;
	int r, c, v;
	for (int i = 0;i <= R;i++) {
		for (int j = 0;j <= C;j++) {
			M[i][j] = 0;
		}
	}
	for (int i = 0;i < K;i++) {
		cin >> r >> c >> v;
		M[r][c] = v;
	}

	for (int i = 1;i <= R;i++) {
		for (int j = 1;j <= C;j++) {
			A[i][j][0] = max(A[i - 1][j][3], A[i][j - 1][0]);
			A[i][j][1] = max(A[i][j][0] + M[i][j], A[i][j - 1][1]);
			A[i][j][2] = max({ A[i][j][1],A[i][j - 1][1] + M[i][j], A[i][j - 1][2] });
			A[i][j][3] = max({ A[i][j][2],A[i][j - 1][2] + M[i][j], A[i][j - 1][3] });
		}
	}
	cout << A[R][C][3] << endl;
}

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

using namespace std;
using ll = long long;

const ll MOD = 1e9 + 7;

ll powmod(ll a, ll x) {
  // calculates a^x mod MOD in logarithmic time.
  ll res = 1;
  while (x > 0) {
    if (x % 2 != 0) {
      res = (res * a) % MOD;
    }
    a = (a * a) % MOD;
    x /= 2;
  }
  return res;
}

ll inversemod(ll a) {
  // calculates the modular multiplicative of a mod m.
  //(assuming MOD is prime).
  return powmod(a, MOD - 2);
}

ll ncr(ll n, ll k) {
  // calculates C(n,k) mod MOD (assuming MOD is prime).

  ll numerator = 1; // n * (n-1) * ... * (n-k+1)
  for (int i = 0; i < k; i++) {
    numerator = (numerator * (n - i)) % MOD;
  }

  ll denominator = 1; // k!
  for (int i = 1; i <= k; i++) {
    denominator = (denominator * i) % MOD;
  }

  // numerator / denominator mod MOD.
  return (numerator * inversemod(denominator)) % MOD;
}

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

  ll n, a, b;
  cin >> n >> a >> b;
  ll ans = powmod(2, n);
  ans--;
  if (ans < 0)
    ans += MOD;
  ans -= ncr(n, a);
  if (ans < 0)
    ans += MOD;
  ans -= ncr(n, b);
  if (ans < 0)
    ans += MOD;
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 3664
#include<bits/stdc++.h>
 
#define hell                         1000000007
#define hell2                        998244353
#define lcm(a,b)                     (a*b)/__gcd(a,b)
#define ll                           long long
#define vll                          vector<ll>
#define pll                          vector< pair<ll,ll> >
#define pb                           push_back
#define all(v)                       v.begin(),v.end()
#define F                            first
#define S                            second
#define rep(i,a,b)                   for(ll i=a;i<b;i++)
#define ret(x)                       return cout<<x,0;
#define endl                           '\n'
 
const ll MAX=1000005;
const ll SQN=330;
const ll LG=31;
const double PI=atan(1)*4;
using namespace std;
 
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);cout.tie(NULL);
 
    ll k;
    cin >> k;
    ll rem=0;
    rep(i,1,MAX) {
    	ll r=(10*rem+7)%k;
    	if(r==0) ret(i);
    	rem=r;
    }
    ret(-1);
 
 
}

Measured memory_bytes: 3656
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<stdbool.h>
#include<math.h>
#include<limits.h>
int main(){
    int N;
    scanf("%d",&N);
    int a[102];
    for(int i=1;i<=N;i++)
        scanf("%d",a+i);
    int ans = 0;
    for(int i=1;i<=N;i++){
        if(i%2 == 1 && a[i]%2 == 1)
            ans++;
    }
    printf("%d",ans);
}


Measured memory_bytes: 1680
#include <bits/stdc++.h>
typedef long long ll;;
#define int long long 
using namespace std;
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPR(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
#define ALL(x) (x).begin(),(x).end() 
#define SIZE(x) ((ll)(x).size()) 
#define MAX(x) *max_element(ALL(x)) 
#define MIN(x) *min_element(ALL(x)) 
#define INF 1000000000000 
#define MOD 10000007 
#define MAXR 100000 
#define PI 3.14159265358979323846
using namespace std;

signed main(){
    
    string A ;
    cin >> A ;

    if(A == "ABC") cout << "ARC" <<endl ;
    else cout << "ABC" <<endl ;
    

    

    return 0;
}


Measured memory_bytes: 3596
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
// #include "prettyprint.hpp"

long long mod = 1000000007;

long long inv(long long a, long long MOD) {
  return a == 1 ? 1 : (long long)(MOD - MOD / a) * inv(MOD % a, MOD) % MOD;
}

int main() {
  long N, K;
  cin >> N >> K;
  long A[N];
  for (long i = 0; i < N; i++) {
    cin >> A[i];
  }

  long long C[N + 1];

  C[K - 1] = 1;
  for (int i = K; i <= N - 1; i++) {
    C[i] = C[i - 1] * i;
    C[i] %= mod;
    C[i] *= inv(i - K + 1, mod);
    C[i] %= mod;
  }

  sort(A, A + N, greater<long>());

  long long ans = 0;

  for (int i = 0; i < N - K + 1; i++) {
    ans += A[i] * C[N - i - 1];
    ans %= mod;
  }

  for (int i = N - 1; i >= K - 1; i--) {
    ans -= A[i] * C[i];
    ans %= mod;
  }

  ans = (ans + mod) % mod;

  cout << ans << endl;

  return 0;
}

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

int main()
{
	int x[4] = { 0,0,0,0 };

	for (int i = 0; i < 6; i++) {
		int y;

		cin >> y;

		x[y - 1]++;
	}

	int z = 0;

	for (int i = 0; i < 4; i++) {
		if (x[i] == 2) {
			z++;
		}
	}

	if (z == 2) {
		cout << "YES" << endl;
	}
	else {
		cout << "NO" << endl;
	}

	return 0;
}

Measured memory_bytes: 256
#include <cstddef>
#include <iostream>
#include <iomanip>
#include <string>
#include <sstream>
#include <vector>
#include <array>
#include <list>
#include <unordered_map>
#include <algorithm>
#include <numeric>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <bitset>
#include <valarray>
#include <utility>
#include <tuple>
#include <cmath>
#include <memory>
#include <random>
#include <fstream>
#include <locale>
#include <regex>
#include <complex>

using ll = long long;
using ull = unsigned long long;
using ld = long double;

//vector
template <class T>
using vec = std::vector<T>;

template <class T>
using vvec = vec<vec<T>>;

constexpr std::size_t operator""_sz(ull n) { return std::size_t(n); }

constexpr int N = 8;

std::pair<int, vvec<bool>> solve(vvec<bool> map, int y, int x, int queenCount, vec<bool> h, vec<bool> w, vec<bool> tr, vec<bool> br)
{
    ++queenCount;

    map[y][x] = true;
    h[y] = true;
    w[x] = true;
    tr[y + x] = true;
    br[7 - y + x] = true;

    if (queenCount == N)
    {
        return make_pair(queenCount, map);
    }

    for (int i = 0; i < N; ++i)
        for (int j = 0; j < N; ++j)
        {
            if (!h[i] && !w[j] && !tr[i + j] && !br[7 - i + j])
            {

                auto m = solve(map, i, j, queenCount, h, w, tr, br);

                if (m.first == N)
                {
                    queenCount = N;
                    map = m.second;
                    goto LOOP_END;
                }
            }
        }

LOOP_END:

    return make_pair(queenCount, map);
}

int main()
{
    using namespace std;
    // cerr.rdbuf(nullptr);

    int n;
    cin >> n;

    int ans{};

    vec<int> coins{ 25, 10 , 5, 1 };
    
    while (n > 0)
    {
        ++ans;
        for (auto c : coins)
        {
            if (n >= c)
            {
                n -= c;
                break;
            }
        }
    }

    cout << ans << endl;


    return 0;
}


Measured memory_bytes: 3112
n=int(input())
a,b=[],[]
for i in range(n):
    c=int(input())
    if c%10==0:
        a.append(c)
    else:
        b.append(c)
d=sum(a)+sum(b)
if len(b)!=0:
    if sum(b)%10==0:
        print(d-min(b))
    else:
        print(d)
else:
    print('0')

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

int main(){
    int n;

    while(cin >> n, n != 0){
        int matrix[100][100] = {0};
        int result[100][100] = {0};
        vector<int> riser;
        for(int i=0; i<n; i++){
            for(int j=0; j<n; j++){
                cin >> matrix[i][j];
            }
        }
        for(int i=0; i<n; i++){
            riser.clear();
            int min = matrix[i][0];
            for(int j=0; j<n; j++){
                if(matrix[i][j] < min){
                    riser.clear();
                    riser.push_back(j);
                    min = matrix[i][j];
                }
                else if(matrix[i][j] == min){
                    riser.push_back(j);
                }
            }
            vector<int>::iterator it = riser.begin();
            while(it != riser.end()){
                result[i][*it]++;
                it++;
            }
        }
        for(int j=0; j<n; j++){
            riser.clear();
            int max = matrix[0][j];
            for(int i=0; i<n; i++){
                if(matrix[i][j] > max){
                    riser.clear();
                    riser.push_back(i);
                    max = matrix[i][j];
                }
                else if(matrix[i][j] == max){
                    riser.push_back(i);
                }
            }
            vector<int>::iterator it = riser.begin();
            while(it != riser.end()){
                result[*it][j]++;
                it++;
            }
        }
        bool flug = false;
        for(int i=0; i<n; i++){
            for(int j=0; j<n; j++){
                if(result[i][j] == 2 && !flug){
                    cout << matrix[i][j] << endl;
                    flug = true;
                }
            }
        }
        if(!flug){
            cout << "0" << endl;
        }
    }
    return 0;
}

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

using namespace std;

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

ll l[1000000];
void solve() {
  int n;
  cin >> n;
  for(int i = 0; i < n; i++) cin >> l[i];
  ll tot = 0;
  for(int i = 0; i < n; i++) tot += l[i];
  ll ret = 1e18;
  ll curr = 0;
  for(int i = 0; i < n-1; i++) {
    curr += l[i];
    ret = min(ret, abs(2*curr - tot));
  }
  cout << ret << endl;
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  solve();
}


Measured memory_bytes: 1920
N = int(input())
s = input()

tmp1, tmp2 = s, s
tmp1 = tmp2.replace('()', '')

while not (tmp1 == tmp2):
	tmp2 = tmp1
	tmp1 = tmp2.replace('()', '')


left = tmp1.count(')')
right = tmp1.count('(')

print('('*left + s + ')'*right)


Measured memory_bytes: 3060
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <map>
#include <iomanip>	
#include <deque>
#include <set>
#define rep(i,a,b) for(int i=a;i<b;++i)
#define rrep(i,a,b) for(int i=a;i>=b;--i)
#define fore(i,a) for(auto &i:a)
#define INF INT_MAX/2;
typedef long long ll;
using namespace std;
using vi = vector<int>;
using vll = vector<ll>;
ll mod = 1e9 + 7;
//ll llmax = 10000000000000000000ll;
using namespace std;
using Graph = vector<vector<int>>;


int cnt_digit(ll N)
{
	int digit = 0;

	while (N > 0)
	{
		N /= 10;
		digit++;
	}
	return digit;
}


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

ll lcm(ll a, ll b)
{
	ll g = gcd(a, b);

	return a / g * b;
}

struct union_find
{
	vector<int> par, r;
	union_find(int n)
	{
		par.resize(n);
		r.resize(n);
		init(n);
	}


	void init(int n)
	{
		for (int i = 0; i < n; i++) par[i] = i;
		for (int i = 0; i < n; i++) r[i] = 0;
	}

	int find(int x)
	{
		if (par[x] == x)return x;
		else return find(par[x]);
	}

	void unite(int x, int y)
	{
		x = find(x);
		y = find(y);

		if (r[x] < r[y])
		{
			par[x] = y;
		}
		else
		{
			par[y] = x;
			if (r[x] == r[y])
			{
				r[x]++;
			}
		}
	}
};



int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n;
	cin >> n;
	vector<int> data(n+2);
	vector<int> ans(n+2);

	rep(i, 1, n+1) {
		cin >> data[i];
	}
	data[0] = data[n + 1] = 0;
	ans[0] = ans[n + 1] = 0;

	int orians = 0;
	rep(i, 0, n+1) {
		
		orians += abs(data[i + 1] - data[i]);
	}




	rep(i, 1, n+1) {
		
		ans[i] = orians - abs(data[i ] - data[i-1]) - abs(data[i + 1] - data[i]) + abs(data[i + 1] - data[i-1]);
	}

	rep(i, 1, n + 1) {

		cout << ans[i] << endl;
	}
	

	

 
}

Measured memory_bytes: 2048
package main

import "fmt"

func pow(a, n int) (b int) {
	b = 1
	for n > 0 {
		b *= a
		n--
	}
	return
}

func main() {
	var N, M int
	fmt.Scan(&N, &M)
	fmt.Printf("%d\n", (1900*M+100*(N-M))*pow(2, M))
}


Measured memory_bytes: 512
#include<iostream>
#include<string>
#include<cstdio>
#include <cstring>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
using namespace std;
typedef long long ll;
typedef unsigned int ui;
const ll mod = 1000000007;
typedef long double ld;
const ll INF = 1e+14;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<ld, ld> LDP;
typedef pair<ll, ll> LP;
#define fr first
#define sc second
#define all(c) c.begin(),c.end()
#define pb push_back

void Yes(){
	cout<<"Yes"<<endl;
	exit(0);
}
 
void No(){
	cout<<"No"<<endl;
	exit(0);
}

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
    int A, B; cin >> A >> B;
    int C = A + B, D = A - B, E = A * B;
    int ans = max(C, D);
    ans = max(ans, E);
    cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
//writer：Sakura
//problem：
//id：
//from：

#include <cstdio>
#include <iostream>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <queue>
#include <stack>
#include <vector>
#include <set>
#include <map>
//#include <bits/stdc++.h>
using namespace std;

#define FOR(x,to) for(x=0;x<(to);x++)

typedef long long ll;

int N;
int pos[2][2020];
int L[2][2020][2020];
int dp[2020][2020];

/*
dp方程：
x<n dp[x+1][y]=min{dp[x+1][y],dp[x][y]} 
y<n dp[x][y+1]=min{dp[x][y+1],dp[x][y]}
*/ 

void DP() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>N;
	FOR(i,2*N) {
		cin>>s>>x;
		pos[s=="W"][x-1]=i;
	}
	
	FOR(i,2) {
		FOR(x,N) {
			for(y=x+1;y<N;y++) if(pos[i][y]<pos[i][x]) L[i][x][N]++;
			for(y=N-1;y>=0;y--) L[i][x][y]=L[i][x][y+1]+(pos[i^1][y]<pos[i][x]);
		}
	}
	
	FOR(x,N+2) FOR(y,N+2) dp[x][y]=1<<25;
	dp[0][0]=0;
	FOR(x,N+1) FOR(y,N+1) {
		if(x<N) dp[x+1][y]=min(dp[x+1][y],dp[x][y]+L[0][x][y]);
		if(y<N) dp[x][y+1]=min(dp[x][y+1],dp[x][y]+L[1][y][x]);
	}
	int ans=dp[N][N]; 
	printf("%d\n",ans);
}


int main(int argc,char** argv){
	//freopen(".in","r",stdin);
	//freopen(".out","w",stdout);
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	cout.tie(0); DP();
	return 0;
}



Measured memory_bytes: 48000
class Dice:
    def __init__(self,a,b,c,d,e,f):
        self.face1 = a
        self.face2 = b
        self.face3 = c
        self.face4 = d
        self.face5 = e
        self.face6 = f

    def above_face(self):
        return self.face1

    def roll(self, order):
        if order == 'N':
            tmp = self.face1
            self.face1 = self.face2
            self.face2 = self.face6
            self.face6 = self.face5
            self.face5 = tmp
        elif order == 'S':
            tmp = self.face1
            self.face1 = self.face5
            self.face5 = self.face6
            self.face6 = self.face2
            self.face2 = tmp
        elif order == 'W':
            tmp = self.face1
            self.face1 = self.face3
            self.face3 = self.face6
            self.face6 = self.face4
            self.face4 = tmp
        else:
            tmp = self.face1
            self.face1 = self.face4
            self.face4 = self.face6
            self.face6 = self.face3
            self.face3 = tmp

n = int(input())
dice_list = []
d_list = []
for i in range(n):
    a,b,c,d,e,f = map(int,input().split())
    dice_list.append(Dice(a,b,c,d,e,f))
    d_list.append(Dice(a,b,c,d,e,f))

flag = True
for k in range(n - 1):
    for j in range(k + 1,n):
        for i in 'NNNNWNNNWNNNENNNENNNWNNN':
            d_list[j].roll(i)
            if dice_list[k].face1 == d_list[j].face1 and dice_list[k].face2 == d_list[j].face2 and \
                    dice_list[k].face3 == d_list[j].face3 and dice_list[k].face4 == d_list[j].face4 and \
                    dice_list[k].face5 == d_list[j].face5 and dice_list[k].face6 == d_list[j].face6:
                flag = False
                break
        else:
            continue
        break
    else:
        continue
    break

if flag == True:
    print('Yes')
else:
    print('No')



Measured memory_bytes: 5612