akhauriyash/Code-Regression huggingface dataset:
/* template.cpp [[[ */
#include <bits/stdc++.h>
using namespace std;
#define get_macro(a, b, c, d, name, ...) name
#define rep(...) get_macro(__VA_ARGS__, rep4, rep3, rep2, rep1)(__VA_ARGS__)
#define rrep(...) get_macro(__VA_ARGS__, rrep4, rrep3, rrep2, rrep1)(__VA_ARGS__)
#define rep1(n) rep2(i_, n)
#define rep2(i, n) rep3(i, 0, n)
#define rep3(i, a, b) rep4(i, a, b, 1)
#define rep4(i, a, b, s) for (ll i = (a); i < (ll)(b); i += (ll)s)
#define rrep1(n) rrep2(i_, n)
#define rrep2(i, n) rrep3(i, 0, n)
#define rrep3(i, a, b) rrep4(i, a, b, 1)
#define rrep4(i, a, b, s) for (ll i = (ll)(b) - 1; i >= (ll)(a); i -= (ll)s)
#define each(x, c) for (auto &&x : c)
#define fs first
#define sc second
#define all(c) begin(c), end(c)
using ui = unsigned;
using ll = long long;
using ul = unsigned long long;
using ld = long double;
const int inf = 1e9 + 10;
const ll inf_ll = 1e18 + 10;
const ll mod = 1e9 + 7;
const ll mod9 = 1e9 + 9;
const int dx[]{-1, 0, 1, 0, -1, 1, 1, -1};
const int dy[]{0, -1, 0, 1, -1, -1, 1, 1};
template<class T, class U> void chmin(T &x, const U &y){ x = min<T>(x, y); }
template<class T, class U> void chmax(T &x, const U &y){ x = max<T>(x, y); }
struct prepare_ { prepare_(){ cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(12); } } prepare__;
/* ]]] */

int n, m, k, s;
int p, q;
int x[100000];
ll c[100000];
vector<int> g[100000];
ll d[100000];

int main(){
  cin >> n >> m >> k >> s;
  cin >> p >> q;
  rep(i, k) cin >> x[i];
  rep(i, m){
    int a, b;
    cin >> a >> b;
    g[a - 1].push_back(b - 1);
    g[b - 1].push_back(a - 1);
  }

  fill_n(d, 100000, inf_ll);
  queue<int> qu;
  rep(i, k){
    d[x[i] - 1] = 0;
    qu.push(x[i] - 1);
  }
  while (qu.size()){
    int v = qu.front(); qu.pop();
    each(u, g[v]){
      if (d[u] == inf_ll){
        d[u] = d[v] + 1;
        qu.push(u);
      }
    }
  }

  rep(i, 1, n - 1){
    if (d[i] == 0) c[i] = inf_ll;
    else if (d[i] <= s) c[i] = q;
    else c[i] = p;
  }
  
  priority_queue<pair<ll, int>, vector<pair<ll, int>>, greater<pair<ll, int>>> pq;
  fill_n(d, 100000, inf_ll);
  d[0] = 0;
  pq.emplace(0, 0);
  while (pq.size()){
    ll sm; int v;
    tie(sm, v) = pq.top(); pq.pop();
    if (d[v] < sm) continue;
    each(u, g[v]){
      if (d[u] > sm + c[u]){
        d[u] = sm + c[u];
        pq.emplace(sm + c[u], u);
      }
    }
  }

  cout << d[n - 1] << endl;
}

Measured memory_bytes: 11268
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int> >;
#define rep(i, n)         for(int i = 0; i < (int)(n); i++)
#define brep(n)           for(int bit=0;bit<(1<<n);bit++)
#define erep(i,container) for (auto i : container)
#define irep(i, n)        for(int i = n-1; i >= (int)0; i--)
#define rrep(i,m,n) for(int i = m; i < (int)(n); i++)
#define reprep(i,j,h,w) rep(i,h)rep(j,w)
#define all(x) (x).begin(),(x).end()
#define aall(x,n) (x).begin(),(x).begin()+(n)
#define VEC(type,name,n) std::vector<type> name(n);rep(i,n)std::cin >> name[i];
#define pb push_back
#define pf push_front
#define lb lower_bound
#define ub upper_bound
#define fi first
#define se second
#define itn int
#define mp make_pair
#define sum accumulate
#define keta fixed<<setprecision
#define vvector(name,typ,m,n,a)vector<vector<typ> > name(m,vector<typ> (n,a))
#define vvvector(name,t,l,m,n,a) vector<vector<vector<t> > > name(l, vector<vector<t> >(m, vector<t>(n,a)));
#define vvvvector(name,t,k,l,m,n,a) vector<vector<vector<vector<t> > > > name(k,vector<vector<vector<t> > >(l, vector<vector<t> >(m, vector<t>(n,a)) ));
typedef long long ll;
const int INF = 2000000000;
const ll INF64 = 9223372036854775806ll;
const ll MOD = 1000000007LL;
/*メモ XOR問題のまとめ
性質 1「交換則、結合則が成り立つ」
　　 2「a xor a = 0」
　　 3「ある数xのb番目のビットが1である <=> x mod 2^(b+1) ≧ 2^b」
　　 4「0≦aのとき、4a, 4a+1, 4a+2, 4a+3のxor和は0」
方針 
!!!!!1「xor計算は各ビットで独立なので別々に計算」
　　 2「trieを使ったxorの最大最小探索がある解説」
・しゃくとり法は[ｌ,r)で考えるとわかりやすいよ！
*/
int main(){
    int n;
    std::cin >> n;
    VEC(int,a,n);
    int cnt=0;
    rep(i,n){
        if(a[i]%2)cnt++;
    }
    if(cnt%2)std::cout << "NO" << std::endl;
    else std::cout << "YES" << std::endl;
}

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

#define M_PI       3.14159265358979323846

using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; }
template<class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str(); }
inline int readInt() { int x; scanf("%d", &x); return x; }

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<int, PII> TIII;
typedef long long LL;
typedef unsigned long long ULL;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;

//container util

//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define SQ(a) ((a)*(a))
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(i,s,n) for(int i=s;i<(int)n;++i)
#define REP(i,n) FOR(i,0,n)
#define MOD 1000000007

#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define trav(a, x) for(auto& a : x)
#define all(x) x.begin(), x.end()
#define sz(x) (int)(x).size()
struct Edge {
    int to, cost;
    Edge(int to, int cost): to(to), cost(cost) {}
};

typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vector<Edge>> AdjList;
AdjList graph;

const int INF = 100000000;

LL N, M;
LL arr[100010]={0};
LL a[100010];
int main() {
    //cout << fixed << setprecision(15);

    int X, A; cin >> X >> A;

    if(X<A) cout << 0 << endl;
    else cout << 10 << endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#define ll long long int

ll X[100];
ll Y[100];
int N;
int K;

int InRange(ll t, ll l, ll r){
	return l <= t && t <= r; // inclusive;
}

ll min (ll a, ll b){
	return a < b ? a : b;
}

ll minRange(ll a, ll b, ll c, ll d){
	ll ret = a;
	ret = min(ret, b);
	ret = min(ret, c);
	ret = min(ret, d);
	return ret;
}
ll max (ll a, ll b){
	return a > b ? a : b;
}

ll maxRange(ll a, ll b, ll c, ll d){
	ll ret = a;
	ret = max(ret, b);
	ret = max(ret, c);
	ret = max(ret, d);
	return ret;
}

int main(){
	
	int i,j,k,l,m;
	scanf("%d%d",&N, &K);
	for(i=0;i<N;i++) scanf("%lld%lld",&X[i], &Y[i]);
	
	ll w0,w1,h0,h1;
	ll ar;
	
	ll ans = (ll)4e18;
	for(i=0;i<N;i++){
		for(j=i;j<N;j++){
			for(k=j;k<N;k++){
				for(l=k;l<N;l++){
				
					w0 = minRange(X[i],X[j],X[k],X[l]);
					w1 = maxRange(X[i],X[j],X[k],X[l]);
					h0 = minRange(Y[i],Y[j],Y[k],Y[l]);
					h1 = maxRange(Y[i],Y[j],Y[k],Y[l]);
					
					ar = (w1 - w0) * (h1 - h0);
					if(ar == 0) continue; // 無いはず
					
					int cnt = 0;
					for(m=0;m<N;m++){
						if(InRange(X[m], w0, w1) && InRange(Y[m], h0, h1)) cnt++;
					}
					if(cnt >= K){
						ans = min(ans, ar);
					}
					
				}
			}
		}
	}
	
	printf("%lld\n",ans);
	
	
	
	
	return 0;
}




Measured memory_bytes: 128
#include <iostream>
#include <stdio.h>
#include <algorithm>
using namespace std;
/*

*/
int main()
{
    int a, b,c,d;
    cin >> a >> b >> c >> d;
    //割って同じなら前者の負け、違うなら大きい方が勝ち
    //前者の耐久ターン数が後者「以下」なら負け
    //
    while(true){
        if(c <= 0){
            cout << "Yes" << endl;
            break;
        }else if (a <= 0){
            cout << "No" << endl;
            break;
        }else{
            c -= b;
            a -= d;
        }
    }

    
    return 0;
}

Measured memory_bytes: 3108
/*
* be kind, work hard
*/
/******************************************************************************/
/**///#include <boost/multiprecision/cpp_int.hpp>
/**/#include <bits/stdc++.h>                                                
/**/
/**/#define endl            "\n"
/**/#define pb              push_back
/**/#define X               first
/**/#define Y               second
/**/#define setZero(array)  memset((array), 0, sizeof (array))
/**/#define setOne(array)   memset((array), 1, sizeof (array))
/**/#define setTrue(array)  memset((array), true, sizeof (array))
/**/#define setFalse(array) memset((array), false, sizeof (array))
/**/#define HAYAKU          ios_base::sync_with_stdio(false);cin.tie(NULL);
/**/#define int             long long
/**/#define LIVE            return
/**/#define FREE            1
/**/#define OR              and
/**/#define DIE             0
/******************************************************************************/
/*
using boost::multiprecision::cpp_int;
*/

typedef long long ll;

using namespace std;

const int MOD = 1e9 + 7;
const int N   = 1e5;

void preprocess(){
    return;
}

int inline solve(){
    int n, i;
    string s, t;
    cin >> s
        >> t;
    
    for(i=0, n=0; i<s.length(); ++i){
        n += (s[i] != t[i]);
    }
    
    cout << n ;
    return 0;
}

signed main(){
    HAYAKU
    
    preprocess();
    
    int t = 1;
    
//    cin >> t;
    
    for(int i=1; i<=t; ++i){
//        cout << "Case #" << i << ": ";
//        cout << 
            solve();
//        cout << endl;
    }
    
    LIVE FREE OR DIE;
}

Measured memory_bytes: 3800
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int x = sc.nextInt();
		int y = sc.nextInt();
		if((4*x-y)%2==0 && 4*x>=y && (y-2*x)%2==0 && y>=2*x) {
			System.out.println("Yes");
		}
		else {
			System.out.println("No");
		}
	}
}


Measured memory_bytes: 35712
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int n = in.nextInt();
		Map<String, Long> map = new HashMap<>();
		long total = 0;
		for ( int i = 0; i < n; i++ ) {
			char[] s = in.next().toCharArray();
			Arrays.sort(s);
			String key = new String(s);
			Long cnt = (map.containsKey(key) ? map.get(key) + 1 : 1);
			map.put(key, cnt);
		}

		for ( Entry<String, Long> en : map.entrySet() ) {
			Long v = en.getValue();
			total += v * (v - 1) / 2;
		}

		System.out.println(total);
		in.close();
	}
}

Measured memory_bytes: 52476
#define _AOJ_
#include "bits/stdc++.h"
using namespace std;
typedef long long i64;
#define rep(i,n) for(int i=0;i<n;++i)
#define REP(i,a,b) for(int i=a;i<b;++i)
#define all(c) c.begin(),c.end()

//define pfs,bellmanford,etc.

int main(){
	i64 a,b;cin>>a>>b;
	cout<<(b+a-1)/a<<endl;
}

//sub-EOF


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

bool isprime(int n) {
    if (n == 2) return true;
    if (n < 1 || n % 2 == 0) return false;
    for (int i = 3; i <= sqrt(n); i += 2)
      if (n % i == 0) return false;
    return true;
}

int main()
{
    int a, n, count = 0;
    
    cin >> n;
    for (int i = 0; i < n; i++) {
        cin >> a;
        if (isprime(a)) count++;
    }
    cout << count << endl;

    return 0; 
}


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

typedef long long int ll;
typedef pair<ll, ll> p_ll;
typedef vector<pair<ll, ll>> vec_p; //vector<pair<ll, ll>> pairs(n) ,pairs.at(i) = make_pair(i*i, i)

#define ture ture
#define flase false
#define falg flag

#define REP(i, x) for (ll i = 0; i < (ll)(x); i++)
#define REPS(i, x) for (ll i = 1; i <= (ll)(x); i++)
#define RREP(i, x) for (ll i = ((ll)(x)-1); i >= 0; i--)
#define RREPS(i, x) for (ll i = ((ll)(x)); i > 0; i--)
#define all(x) (x).begin(), (x).end()

const ll MOD = pow(10, 9) + 7;
const ll LLINF = pow(2, 61) - 1;//llの最大9*10^18
const int INF = pow(2, 30) - 1;

ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }

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

    ll L,R,d;
    string S;
    cin >> L>>R>>d;

    cout << R / d - (L - 1) / d << endl;

}


Measured memory_bytes: 3604
using System;
using System.Collections.Generic;

namespace test
{
	class MainClass
	{
		public static void Main (string[] args)
		{
			Dictionary<string,int> dict = new Dictionary<string, int> ();
			dict.Add ("A", 0);
			dict.Add ("B", 1);
			dict.Add ("C", 2);

			bool[] cup = new bool[3];
			cup [0] = true;

			string input;
			while ((input = Console.ReadLine())!=null) {
				string[] array = input.Split (',');
				bool tmp = cup [dict[array[0]]];
				cup [dict[array[0]]] = cup [dict[array[1]]];
				cup [dict[array[1]]] = tmp;

			}

			for (int i=0; i<3; i++) {
				if (cup [i]) {
					switch (i) {
					case 0:
						Console.WriteLine ("A");
						break;
					case 1:
						Console.WriteLine ("B");
						break;
					case 2:
						Console.WriteLine ("C");
						break;
					}
				}
			}


		}

	}


}

Measured memory_bytes: 5416
#include<iostream>
#include<vector>
#include<map>
#include<set>
#include<string>
#include<algorithm>
#include<numeric>
#include<cmath>
#include<queue>
#include<stack>
#include<list>
#include<unordered_map>
#include<unordered_set>
#include<cctype>
#include<iomanip>
#include<limits>
#include<bitset>

using namespace std;
typedef long long int ll; typedef pair<int, int> P; typedef unsigned long long int ull;
const ll mod = 1000000007;
const int inf = 1e9 + 7;
const ll linf = 1LL << 60;
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define REP(i,m,n) for(int i=(m);i<(int)n;i++)
#define all(a) (a).begin(),(a).end()
#define allg(a) (a).begin(),(a).end(),greater<>()
#define SUM(a) accumulate((a).begin(),(a).end(),0)
#define d10 std::setprecision(10)
#define d20 std::setprecision(20)
#define vec vector<int>
#define vecb vector<bool>
#define vecd vector<double>
using str = string;
const double PI = 3.14159265359;
ll gcd(ll a, ll b) { ll t; while (b != 0) { t = a % b; a = b; b = t; }return a; }
int gcd(int a, int b) { int t; while (b != 0) { t = a % b; a = b; b = t; }return a; }
ll recfact(ll start, ll n) {
	ll i;
	if (n <= 16) {
		ll r = start;
		for (i = start + 1; i < start + n; i++) r = r * i % mod;
		return r % mod;
	}
	i = n / 2;
	return recfact(start, i) % mod * recfact(start + i, n - i) % mod;
}
ll lcm(ll a, ll b) {
	return a * b / gcd(a, b);
}
ll fct(ll n) { return recfact(1, n); }
ll ncm(ll n, ll m) {
	if (n < m)return 0;
	ll x = (fct(n) % mod / (fct(m) * fct(n - m)) % mod) % mod;
	return x;
}
std::string sreverse(string str, int firstItr, int secondItr) {
	if (firstItr < 0 || secondItr>int(str.size() - 1))return str;
	while (firstItr < secondItr) {
		swap(str[firstItr], str[secondItr]);
		firstItr++; secondItr--;
	}
	return str;
}
std::string RunLengthEncoding(std::string str) {
	int itr = 0; std::string res;
	while (itr < int(str.size())) {
		char tmp = str[itr++];
		int length = 1;
		while (itr <int(str.size()) && str[itr] == tmp) { ++itr; ++length; }
		res.push_back(tmp);
		res += to_string(length);
	}
	return res;
}
std::string split(std::string str, size_t first_itr, size_t second_itr) {
	std::string tmp;
	for (size_t i = first_itr; i < second_itr + 1; i++) {
		tmp.push_back(str.at(i));
	}
	return tmp;
}
ll max(ll a, ll b) {
	return a > b ? a : b;
}
ll min(ll a, ll b) {
	return a < b ? a : b;
}


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



	return 0;
}

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

typedef long long int ll;
typedef vector<int> vi;
typedef vector<vector<int>>vii;
typedef vector<ll> vl;
typedef vector<vector<ll>>vll;
typedef pair <int, int> pii;
typedef pair<ll, ll> pll;


void solve(){
     
    return ;
}

int main(){
    long double a, b;
    cin>>a>>b;
    long double res =1.0*a*b;
    cout<<(ll)res<<endl;
    // cout<<prod<<endl;
    return 0;
}

Measured memory_bytes: 3792
#include <cstdio>
#include <vector>
#include <algorithm>
#include <cstring>
#include <string>
#include <cctype>
#include <sstream>
#include <functional>

using namespace std;

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

typedef vector<int> vi;

int main()
{
	int n;
	scanf("%d", &n);
	long long a = n;

	reep(i, 2, n)
		a *= i;
	printf("%lld\n", a);
}

Measured memory_bytes: 0
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <stdio.h>
#include <queue>
#include <climits>
#include <map>
#include <set>
const int mod = 1e9 + 7;
const int inf = 1 << 20;
const long long INF = 1LL << 60;
using namespace std;
typedef long long ll;
typedef pair<int, int> P;

int main()
{
    int n; cin >> n;
    int p[n];
    int s[n];
    int tmp;
    for(int i = 0; i < n; i++){
        cin >> tmp;
        p[i] = tmp;
        s[i] = tmp;
    }
    sort(s,s+n);
    int diff = 0;
    for(int i = 0; i < n; i++){
        if(p[i] != s[i]){
            diff++;
        }
    }
    if(diff == 0 || diff == 2){
        cout << "YES";
    }else{
        cout << "NO";
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long int
using namespace std;
const int MAX=1e5;
int n,w;
vector<vector<ll>> dp(100,vector<ll>(MAX+1));
vector<int> wi(100);
vector<int> vi(100);

ll calc(int index,int weight){
    if(index==n){
        return 0;
    }
    if(dp[index][weight]!=-1){
        return dp[index][weight];
    }
    ll ans;
    if(wi[index]>w-weight){
        ans=calc(index+1,weight);
    }
    else{
        ans=max(vi[index]+calc(index+1,weight+wi[index]),calc(index+1,weight));
    }
    return dp[index][weight]=ans;
}
void solve(){
    cin>>n>>w;
    for(int i=0;i<n;i++){
        cin>>wi[i]>>vi[i];
        for(int j=0;j<=w;j++){
            dp[i][j]=-1;
        }
    }
    ll max_happ=calc(0,0);
    cout<<max_happ<<'\n';
}

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


Measured memory_bytes: 79360
package main

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

var sc = bufio.NewScanner(os.Stdin)
var out = bufio.NewWriter(os.Stdout)

func main() {
	buf := make([]byte, 1024*1024)
	sc.Buffer(buf, bufio.MaxScanTokenSize)
	sc.Split(bufio.ScanWords)
	defer out.Flush() // !!!!caution!!!! you must use Fprint(out, ) not Print()
	/* --- code --- */
	a, b := nextInt(), nextInt()
	c := 4*a -b
	if c < 0 || c%2 != 0 || c/2 > a {
		fmt.Fprintln(out, "No")
	}else{
		fmt.Fprintln(out, "Yes")
	}
}

// -*-*-*-*-*-*-*-*-
// * I/O utilities *
// -*-*-*-*-*-*-*-*-

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

func nextInt() int {
	a, _ := strconv.Atoi(next())
	return a
}

func nextFloat64() float64 {
	a, _ := strconv.ParseFloat(next(), 64)
	return a
}

func nextInts(n int) []int {
	ret := make([]int, n)
	for i := 0; i < n; i++ {
		ret[i] = nextInt()
	}
	return ret
}
func nextFloats(n int) []float64 {
	ret := make([]float64, n)
	for i := 0; i < n; i++ {
		ret[i] = nextFloat64()
	}
	return ret
}
func nextStrings(n int) []string {
	ret := make([]string, n)
	for i := 0; i < n; i++ {
		ret[i] = next()
	}
	return ret
}

func chars(s string) []string {
	ret := make([]string, len([]rune(s)))
	for i, v := range []rune(s) {
		ret[i] = string(v)
	}
	return ret
}

// PrintOut with util device
func PrintOut(src interface{}, joinner string) {
	switch reflect.TypeOf(src).Kind() {
	case reflect.Slice:
		s := reflect.ValueOf(src)
		for idx := 0; idx < s.Len(); idx++ {
			fmt.Fprintf(out, "%v", s.Index(idx))
			if idx < s.Len()-1 {
				fmt.Fprintf(out, "%s", joinner)
			} else {
				fmt.Fprintln(out)
			}
		}
	default:
		fmt.Fprintln(out, "fuck")
	}
}


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

typedef long long ll;

ll gcd(ll x, ll y) {
    if (y == 0) return x;
    return gcd(y, x % y);
}

int main() {
    ll N, A, ans;
    cin >> N >> ans;
    rep(i, N - 1) {
        cin >> A;
        ans = gcd(ans, A);
    }
    cout << ans << "\n";
}

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

using namespace std;

int main() {
  int n;
  cin >> n;
  priority_queue<int, vector<int>, greater<int>> q;
  int b = -1;
  for (int i = 0; i < n; ++i) {
    int a;
    cin >> a;
    if (b + 1 == a) q.push(b);
    b = a;
  }

  int sum = 0;
  for (int i = 0; i < n; ++i) {
    int B;
    cin >> B;
    sum += B;
  }
  for (int i = 1; i < n && !q.empty(); ++i) {
    int c;
    cin >> c;
    if (q.top() == i) {
      sum += c;
      q.pop();
    }
  }
  cout << sum << endl;
}


Measured memory_bytes: 256
def getN():
    return int(input())
def getNM():
    return map(int, input().split())
def getList():
    return list(map(int, input().split()))
def getArray(intn):
    return [int(input()) for i in range(intn)]
def input():
    return sys.stdin.readline().rstrip()
def rand_N(ran1, ran2):
    return random.randint(ran1, ran2)
def rand_List(ran1, ran2, rantime):
    return [random.randint(ran1, ran2) for i in range(rantime)]
def rand_ints_nodup(ran1, ran2, rantime):
  ns = []
  while len(ns) < rantime:
    n = random.randint(ran1, ran2)
    if not n in ns:
      ns.append(n)
  return sorted(ns)

def rand_query(ran1, ran2, rantime):
  r_query = []
  while len(r_query) < rantime:
    n_q = rand_ints_nodup(ran1, ran2, 2)
    if not n_q in r_query:
      r_query.append(n_q)
  return sorted(r_query)

from collections import defaultdict, deque, Counter
from sys import exit
from decimal import *
import heapq
import math
from fractions import gcd
import random
import string
import copy
from itertools import combinations, permutations, product
from operator import mul, itemgetter
from functools import reduce
from bisect import bisect_left, bisect_right

import sys
sys.setrecursionlimit(1000000000)
mod = 10 ** 9 + 7

#############
# Main Code #
#############

N, S = getNM()
A = getList()
MOD = 998244353

dp = [[0] * (S + 1) for i in range(N + 1)]
dp[0][0] = 1

# [3 1 ④] 1 5 [⑨ ② 6] 5 [3]みたいな感じで数えあげる
for i in range(N):
    for j in range(S + 1):
        # Tに含める通りと含めない通り
        dp[i + 1][j] += dp[i][j] * 2
        dp[i + 1][j] %= MOD
        if j - A[i] >= 0:
            # Tに含める通りかつUに含める通り
            dp[i + 1][j] += dp[i][j - A[i]]
            dp[i + 1][j] %= MOD
print(dp[N][S] % MOD)

Measured memory_bytes: 151808
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using db = double;
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define all(v) (v).begin(),(v).end()
#define siz(v) (ll)(v).size()
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define repi(i,x,n) for(ll i=x;i<(ll)(n);i++)
#define lb lower_bound
#define ub upper_bound
typedef pair<ll,ll> P;
typedef pair<ll,ll> PL;
const ll mod = 1000000007;
const ll INF = 1000000099;
vector<ll> dx={-1,1,0,0},dy={0,0,-1,1};
//cin.tie(0);ios::sync_with_stdio(false);


signed main(){
    ll n,ans=0;cin>>n;
    vector<ll> ev((n+1)/2),od(n/2),v(n),u;
    rep(i,n){
        if(i%2==0){
            cin>>ev[i/2];
        }else{
            cin>>od[i/2];
        }
    }

    sort(all(od));
    sort(all(ev));

    rep(i,n){
        if(i%2==0){
            v[i]=ev[i/2];
        }else{
            v[i]=od[i/2];
        }
    }

    u=v;
    sort(all(u));

    
    rep(i,n){
        ll x=lb(all(u),v[i])-u.begin();//座圧
        if(i%2 != x%2){
            ans++;
        }
    }

    cout<<ans/2<<endl;
    
}

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

typedef long long ll;
typedef long double ld;

int main() {
    ios_base::sync_with_stdio(0); cin.tie(0);
    ll v[4]; for (auto &x : v) cin >> x;
    ll res = LLONG_MIN;
    res = max(res, v[0] * v[3]);
    res = max(res, v[0] * v[2]);
    res = max(res, v[1] * v[3]);
    res = max(res, v[1] * v[2]);
    cout << res << endl;

}
/*



*/


Measured memory_bytes: 3652
import java.util.Scanner;
public class Main {
	public static void main(String[] args){
		Scanner scan=new Scanner(System.in);
		String s=scan.nextLine();
		for(int i=0;i<s.length();i++){
			if(65<=(s.charAt(i))&&(s.charAt(i))<=90){
				System.out.print((char)(s.charAt(i)+32));
			}else if(97<=(s.charAt(i))&&(s.charAt(i))<=122){
				System.out.print((char)(s.charAt(i)-32));
			}else{
				System.out.print(s.charAt(i));
			}
		}
		System.out.println();
		scan.close();
	}
}

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

int main(){
  int n;
  cin >> n;
  char s[n];
  string ans = "Three";
  for(int i = 0; i < n; i++){
    cin >> s[i];
    if(s[i] == 'Y') ans = "Four";
  }

  cout << ans << endl;
}


Measured memory_bytes: 256
k,a,b=map(int,input().split(" "))
x=1
count=0
if a>b or b-a<2:
  print(k+1)
  exit()
if x<a and k-count>=a-x:
  count+=a-x
  x=a
c,ex=divmod((k-count),2)
x+=(b-a)*c
if ex==1:
  x+=1
print(int(x))


Measured memory_bytes: 3060
#include <bits/stdc++.h>
 
using namespace std;
typedef long long ll;
typedef vector<int> VI;
ll mm=1000000000;ll MM=mm+7;
#define rep(i, n) for(int i=0;i<n;i++)
#define PI 3.141592653589793




int main(){
  int a,b,c;
  cin >> a >> b >> c;
  if(c<=(a+b))cout << b+c << endl;
  else{
      cout << a+2*b+1 << endl;
  }
}



    
   


Measured memory_bytes: 3628
#include <cstdio>
#include <iostream>
#include <string>
#include <vector>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <typeinfo>
#include <numeric>
#include <functional>
#include <unordered_map>
#include <bitset>
#include <stack>

using namespace std;
using ll = long long;
using ull = unsigned long long;

const ll INF = 1e16;
const ll MOD = 1e9 + 7;

#define REP(i, n) for(ll i = 0; i < n; i++)
#define Yes(condition) if(condition){ cout << "Yes" << '\n'; }else{ cout << "No" << '\n'; }
#define YES(condition) if(condition){ cout << "YES" << '\n'; }else{ cout << "NO" << '\n'; }
#define yes(condition) if(condition){ cout << "yes" << '\n'; }else{ cout << "no" << '\n'; }





int main() {
    ll n;
    cin >> n;
    vector<string> s(n);
    REP(i, n){
        cin >> s[i];
    }
    string t;
    cin >> t;
    
    ll front = 0, back = 0;
    REP(i, n){
        bool f = false, b = false;
        ll j;
        for(j = 0; j < min(s[i].size(), t.size()); j++){
            if(s[i][j] != '?'){
                if(t[j] < s[i][j]){
                    if(!b) back++;
                    break;
                }
                else if(t[j] > s[i][j]){
                    if(!f) front++;
                    break;
                }
            }
            else{
                if(t[j] != 'a' && t[j] != 'z'){
                    break;
                }
            }
        }
        if(j == min(s[i].size(), t.size())){
            if(t.size() < s[i].size()){
                if(!b) back++;
            }
            else if(t.size() > s[i].size()){
                if(!f) front++;
            }
        }
    }
    
    vector<ll> ans;
    for(ll i = front; i <= n - back; i++){
        ans.push_back(i + 1);
    }
    REP(i, ans.size()){
        cout << ans[i] << " \n"[i + 1 == ans.size()];
    }
}


Measured memory_bytes: 896
#include <iostream>
#include <math.h>
#include <algorithm>
#include <string>
#include <map>

using namespace std;

void b_one_clue(void) {
	int k, x;
	cin >> k >> x;

	int start = x - k + 1;
	int end = x + k - 1;

	for (int i = start; i <= end; i++) {
		cout << i << " ";
	}
	cout << endl;
}

int main()
{
    b_one_clue();

    return 0;
}

Measured memory_bytes: 3632
# coding: utf-8
n = int(input())
x = list(map(int, input().split()))

isOK = "APPROVED"

for n in x:
    if (n % 2 == 0):
        if (n % 3 != 0 and n % 5 != 0):
            isOK = "DENIED"

print(isOK)


Measured memory_bytes: 2940
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<functional>
#include<iomanip>
#include<iostream>
#include<numeric>
#include<map>
#include<queue>
#include<set>
#include<string>
#include<utility>
#include<vector>

using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const ll mod = 1000000007;
#define rep(i,n) for(int i=0;i<n;i++)
#define repl(i,s,e) for(int i=s;i<e;i++)
#define reple(i,s,e) for(int i=s;i<=e;i++)
#define revrep(i,n) for(int i=n-1;i>=0;i--)
#define all(x) (x).begin(),(x).end()

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

	vector<int> p(N, 0);
	rep(i, N) cin >> p[i];

	vector<double> exp(N, 0);
	rep(i, N)
	{
		exp[i] = ((double)p[i] + 1) / 2;
	}


	double max_exp = 0;
	rep(i, K)
	{
		max_exp += exp[i];
	}

	//しゃくとり法
	double tmp = max_exp;

	repl(i, K, N)
	{
		tmp = tmp - exp[i - K] + exp[i];

		if (max_exp < tmp) max_exp = tmp;
	}

	cout << setprecision(10) << max_exp << endl;

	return 0;
}

Measured memory_bytes: 2560
#include <bits/stdc++.h>
#define clr(x) memset(x,0,sizeof x)
#define For(i,a,b) for (int i=(a);i<=(b);i++)
#define Fod(i,b,a) for (int i=(b);i>=(a);i--)
#define fi first
#define se second
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)
#define outval(x) cerr<<#x" = "<<x<<endl
#define outtag(x) cerr<<"---------------"#x"---------------"<<endl
#define outarr(a,L,R) cerr<<#a"["<<L<<".."<<R<<"] = ";\
						For(_x,L,R)cerr<<a[_x]<<" ";cerr<<endl;
using namespace std;
typedef long long LL;
LL read(){
	LL x=0,f=0;
	char ch=getchar();
	while (!isdigit(ch))
		f|=ch=='-',ch=getchar();
	while (isdigit(ch))
		x=(x<<1)+(x<<3)+(ch^48),ch=getchar();
	return f?-x:x;
}
const int N=2005;
int n;
vector <int> e[N];
int v[N],sz[N],mi[N],sm[N];
char s[N];
void dfs(int x,int pre){
	sz[x]=v[x],sm[x]=mi[x]=0;
	int my=0;
	for (auto y : e[x])
		if (y!=pre){
			dfs(y,x);
			sz[x]+=sz[y];
			sm[x]+=sm[y]+sz[y];
			if (my==0||mi[y]+sz[y]>mi[my]+sz[my])
				my=y;
		}
	if (my){
		if (mi[my]+sz[my]<=sm[x]-sm[my]-sz[my])
			mi[x]=sm[x]&1;
		else
			mi[x]=mi[my]+sz[my]-(sm[x]-sm[my]-sz[my]);
	}
}
int main(){
	n=read();
	cin>>s+1;
	For(i,1,n-1){
		int x=read(),y=read();
		e[x].pb(y),e[y].pb(x);
	}
	For(i,1,n)
		v[i]=s[i]-'0';
	int ans=1e9;
	For(i,1,n){
		dfs(i,0);
		if (mi[i]==0)
			ans=min(ans,sm[i]/2);
	}
	if (ans>8e8)
		puts("-1");
	else
		cout<<ans<<endl;
	return 0;
}

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

int main() {
  int h,w;
  cin >> h >> w;
  vector<int>min(h,-1);
  vector<int>max(h,-1);
  for(int i = 0;i < h;i++){
    bool minf = true;
    for(int j = 0;j < w;j++){
      char a;
      cin >> a;
      if(a == '#'){
        if(minf){
          min[i] = j;
          minf = false;
        }
        max[i] = j;
      }
    }
  }
  if(min[0] == -1){
    cout << "Impossible" << endl;
    return 0;
  }
  for(int i = 1;i < h;i++){
    if(min[i] == -1){
      cout << "Impossible" << endl;
      return 0;
    }
    if(max[i-1] > min[i]){
      cout << "Impossible" << endl;
      return 0;
    }
  }
  cout << "Possible" << endl;
}


Measured memory_bytes: 256
import Control.Applicative ((<$>))
import Control.Monad (unless)

main :: IO ()
main = do
  b1 <- getLine
  unless (b1 == "0") $ do
    b2 <- getLine
    b3 <- getLine
    solve b1 b2 b3 >>= putStrLn
    main

solve :: String -> String -> String -> IO String
solve [b11, b12, b13] [b21, b22, b23] [b31, b32, b33] = return . maybe "NA" id . foldr g Nothing $ lst
  where f xs = and (zipWith (==) xs (tail xs)) && '+' `notElem` xs
        g xs r = if f xs then Just ([head xs]) else r
        lst = [[b11, b12, b13],
               [b21, b22, b23],
               [b31, b32, b33],
               [b11, b21, b31],
               [b12, b22, b32],
               [b13, b23, b33],
               [b11, b22, b33],
               [b13, b22, b31]]



Measured memory_bytes: 3484
#include <bits/stdc++.h>
using namespace std;
int main()
{
    double A, B, H, M ;
    cin >> A >> B >> H >> M ;

    long double pi = M_PI ; 

    long double Minu = H * 60 + M ;

    long double rad = pi * 11 * Minu / 360 ;

    long double pre_ans = A*A + B*B - 2 * A * B * static_cast<long double>(cos( rad )) ;
    long double ans = sqrt( static_cast<long double>( pre_ans ) ) ;
    cout << fixed << setprecision(15) << static_cast<long double>(ans) << endl  ;
}


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

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
//const ll mod = 1000000007;

int main() {
    //cout.precision(10);
    int n;
    cin >> n;
    ll x[1050];
    ll y[1050];
    for(int i = 1; i <= n; i++){
        cin >> x[i] >> y[i];
    }
    for(int i = 1; i < n; i++){
        if(abs((x[i] + y[i]) % 2) != (abs(x[i + 1] + y[i + 1]) % 2)){
            cout << -1 << endl;
            return 0;
        }
    }
    string last = "";
    ll beki[41];
    for(int i = 33; i <= 35; i++){
        beki[i] = 1;
    }
    for(int i = 32; i >= 0; i--){
        beki[i] = beki[i + 1] * 2;
    }
    int m = 33;
    bool checker = false;
    if(abs(x[1] + y[1]) % 2 == 0){
        m = 34;
        checker = true;
    }
    cout << m << endl;
    for(int i = 1; i <= m; i++){
        cout << beki[i];
        if(i < m){
            cout << " ";
        }
    }
    cout << endl;
    for(int i = 1; i <= n; i++){
        if(checker){
            x[i]++;
            last = "L";
        }
        ll u = x[i] + y[i];
        ll v = x[i] - y[i];
        for(int j = 1; j <= 33; j++){
            //cout << j << " " << beki[j] << " " << u << " " << v << endl;
            if((u > 0) && (v > 0)){
                cout << "R";
                u -= beki[j];
                v -= beki[j];
                continue;
            }
            if((u < 0) && (v > 0)){
                cout << "D";
                u += beki[j];
                v -= beki[j];
                continue;
            }
            if((u > 0) && (v < 0)){
                cout << "U";
                u -= beki[j];
                v += beki[j];
                continue;
            }
            cout << "L";
            u += beki[j];
            v += beki[j];
        }
        cout << last << endl;
    }
    return 0;
}

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

int ap[30];

int main() {
	int n;char c;
  	long long ans = 1, mod = 1000000007;
  	scanf("%d\n",&n);
  	while(n--) {
    	c = getchar();
      	ap[c-'a']++;
    }
  	for(int i='a';i<='z';i++) {
    	ans = (ans * (ap[i-'a']+1)) % mod;
    }
  	printf("%lld\n",ans-1);
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <functional>
#include <vector>
#include <cstdio>
#include <string>
#include <cmath>
#include <cfloat>
#include <map>
using namespace std;
int main(){

	int n;
	int b,d1,d2;
	
	while(cin>>n,n!=0){
		int max,g=0;
		for(int i=0;i<n;i++){
			cin>>b>>d1>>d2;
			if(g<d1+d2){
				g=d1+d2;
				max=b;
			}
		}
		cout<<max<<" "<<g<<endl;
	}
}

Measured memory_bytes: 1160
N,M = map(int,input().split())
AB = [list(map(int,input().split())) for i in range(M)]
 
ans = [-1] * (N+1)
graph = [[] for _ in range(N+1)]
for a,b in AB:
    graph[a].append(b)
    graph[b].append(a)
    

from collections import deque
import sys
ans = [-1] * (N+1)
todo = deque([(1,0)])
while todo:
    x,parent = deque.popleft(todo)
    # ans[x] = parent
    for y in graph[x]:
        if y == parent:
            continue
        if ans[y] != -1:
            continue
        ans[y] = x
        todo.append((y,x))
        

for i in range(2,N+1):
    if ans[i] == -1:
        print('No')
        sys.exit()
        
print('Yes')
for i in range(2,N+1):
    print(ans[i])

Measured memory_bytes: 123168
#![allow(unused_imports)]
use proconio::{
   fastout, input,
   marker::{Bytes, Isize1, Usize1},
};

const MOD: usize = 1_000_000_007;

#[fastout]
fn main() {
   input! {
      s: Bytes,
   }
   let n = s.len();
   let mut dp = vec![vec![0; 4]; n + 1];
   dp[0][0] = 1;
   for i in 0..n {
      if s[i] == b'?' {
         dp[i + 1][0] = dp[i][0] * 3;
         dp[i + 1][0] %= MOD;
         for j in 1..=3 {
            dp[i + 1][j] = 3 * dp[i][j] + dp[i][j - 1];
            dp[i + 1][j] %= MOD;
         }
      } else {
         dp[i + 1][0] = dp[i][0];
         for j in 1..=3 {
            dp[i + 1][j] = dp[i][j];
         }
         let c = (s[i] - b'A') as usize;
         dp[i + 1][c + 1] += dp[i][c];
         dp[i + 1][c + 1] %= MOD;
      }
   }
   println!("{}", dp[n][3]);
}


Measured memory_bytes: 9116
#include <iostream>      // cout, endl, cin
#include <string>        // string, to_string, stoi
#include <vector>        // vector
#include <algorithm>     // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility>       // pair, make_pair
#include <tuple>         // tuple, make_tuple
#include <cstdint>       // int64_t, int*_t
#include <cstdio>        // printf
#include <map>           // map
#include <cmath>         // sqrt
#include <queue>         // queue, priority_queue
#include <set>           // set
#include <stack>         // stack
#include <deque>         // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset>        // bitset
#include <bits/stdc++.h> // isupper, islower, isdigit, toupper, tolower
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep2(i, a, n) for (int i = (a); i < (n); i++)
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> Pl;
typedef pair<int, int> P;
typedef tuple<ll, ll, string> Tlls;

// Greatest Common Divisor (最大公約数)
ll gcd(ll a, ll b)
{
  // Eucledean algorithm
  while (a)
  {
    if (a < b)
    {
      std::swap(a, b);
    }
    a %= b;
  }
  return b;
}

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

// key: value of prime factor素因数分解
// value: number of prime factor
map<ll, ll> prime_factorization(ll n)
{
  map<ll, ll> prime_factors;
  for (ll i = 2; i * i <= n; i++)
  {
    while (n % i == 0)
    {
      prime_factors[i]++;
      n /= i;
    }
  }
  if (n != 1)
    prime_factors[n] = 1;
  return prime_factors;
}

// 約数リスト約数の列挙
vector<ll> get_divisors(const ll n)
{
  vector<ll> divs;
  for (ll i = 1; i < (ll)sqrt((ld)n) + 1; i++)
  {
    if (n % i == 0)
    {
      divs.push_back(i);
      if (i != n / i)
      {
        divs.push_back(n / i);
      }
    }
  }

  // 必要に応じてソート
  // sort(divs.begin(), divs.end());

  return divs;
}

int main()
{
  string T;
  cin >> T;
  rep(i, T.length())
  {
    if (T.at(i) == '?')
    {
      cout << "D";
    }
    else
    {
      cout << T.at(i);
    }
  }
  cout << endl;
  return 0;
}


Measured memory_bytes: 3852
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using VI = vector<int>;
using VL = vector<ll>;
using loop = int;
template<class T> using PQ = priority_queue<T, vector<T>, greater<T>>;
#define FOR(i,a,n) for(loop (i)=(a);(i)<(n);++(i))
#define eFOR(i,a,n) for(loop (i)=(a);(i)<=(n);++(i))
#define rFOR(i,a,n) for(loop (i)=(n)-1;(i)>=(a);--(i))
#define erFOR(i,a,n) for(loop (i)=(n);(i)>=(a);--(i))
#define each(i, a) for(auto &i : a)
#define SORT(i) sort((i).begin(),(i).end())
#define rSORT(i,a) sort((i).begin(),(i).end(),(a))
#define all(i) (i).begin(),(i).end()
#define out(y,x) ((y) < 0 || h <= (y) || (x) < 0 || w <= (x))
#define line cout << "------------------------\n" 
#define ENDL(i,n) ((i) == (n) - 1 ? "\n" : " ")
#define stop system("pause") //comment out this on AOJ.
constexpr ll INF = 1000000000;
constexpr ll LLINF = 1LL << 60;
constexpr ll mod = 1000000007;
constexpr ll MOD = 998244353;
constexpr ld eps = 1e-10;
constexpr ld pi = 3.1415926535897932;
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; }
inline void init() { cin.tie(nullptr); cout.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(15); }
template<class T>inline istream& operator>>(istream& is, vector<T>& v) { for (auto& elemnt : v)is >> elemnt; return is; }
template<class T, class U>inline istream& operator>>(istream& is, pair<T, U>& p) { is >> p.first >> p.second; return is; }
template<class T>inline vector<T> vec(size_t a) { return vector<T>(a); }
template<class T>inline vector<T> defvec(T def, size_t a) { return vector<T>(a, def); }
template<class T, class... Ts>inline auto vec(size_t a, Ts... ts) { return vector<decltype(vec<T>(ts...))>(a, vec<T>(ts...)); }
template<class T, class... Ts>inline auto defvec(T def, size_t a, Ts... ts) { return vector<decltype(defvec<T>(def, ts...))>(a, defvec<T>(def, ts...)); }

int main() {
    init();

    int n, m; cin >> n >> m;
    VI c(n);
    FOR(i, 0, m) {
        int a, b; cin >> a >> b;
        --a, --b;
        ++c[a], ++c[b];
    }
    FOR(i, 0, n)cout << c[i] << "\n";
}

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

int main(){
    ll s;
    cin >> s;
    ll a = sqrt(s);
    if(a*a < s) a++;
    ll d = a;
    if(d*d-s > 1e9) d--;
    ll b = a*d-s;
    printf("0 0 %d 1 %d %d\n", a, b, d);
    return 0;
}


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

int main() {
	//入力
	int A, B;
	cin >> A >> B;

	//処理
	int ans = 0;
	//if(ans < A + A - 1) ans = A + A - 1;
	ans = max(ans, A + A - 1);
	ans = max(ans, A + B);
	ans = max(ans, B + B - 1);

	//出力
	cout << ans << endl;
}



Measured memory_bytes: 256
#include <stdio.h>

#define N 100000

int gcd(int, int);
int max(int, int);
int min(int, int);

int main(void) {
    int a[N], n, ans;

    scanf("%d", &n);

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

    ans = a[0];

    for(int i = 1; i < n; i++) {
        ans = gcd(max(ans, a[i]), min(ans, a[i]));
    }

    printf("%d\n", ans);

    return 0;
}

int gcd(int a, int b) {
    int c = a % b;
    
    if(c == 0) {
        return b; 
    } else {
        return gcd(b, c);
    }
}

int max(int a, int b) {
    if(a >= b) {
        return a;
    } else {
        return b;
    }
}

int min(int a, int b) {
    if(a <= b) {
        return a;
    } else {
        return b;
    }
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
#define fst first
#define snd second
#define rep(n) for(lint I = 0; (I) < (lint)(n); ++(I))
#define repeat(i, n) for(lint i = 0; (i) < (lint)(n); ++(i))
#define repeat_to(i, n) for(lint i = 0; (i) <= (lint)(n); ++(i))
#define repeat_from(i, m, n) for(lint i = (m); (i) < (lint)(n); ++(i))
#define repeat_from_to(i, m, n) for(lint i = (m); (i) <= (lint)(n); ++(i))
#define repeat_reverse_from_to(i, m, n) for(lint i = (m); (i) >= (lint)(n); --(i))
#define el cout<<endl
#define dump(x) cout<<" "<<#x<<"="<<x
#define pdump(p) cout<<" "<<#p<<"=("<<p.fst<<","<<p.snd<<")"
#define vdump(v) for(size_t I=0; I<v.size(); ++I){cout<<" "<<#v<<"["<<I<<"]="<<v[I];} cout<<endl
using namespace std; using lint = long long; using ld = long double;
using pii = pair<int, int>; using pll = pair<lint, lint>;

int main(void) {
    int n, m;
    cin >> n >> m;
    map<char, int> mp {{'1', 2}, {'2', 5}, {'3', 5}, {'4', 4}, {'5', 5}, {'6', 6}, {'7', 3}, {'8', 7}, {'9', 6}};
    vector<string> dp(10000+1, "0");
    
    vector<char> v(10, '0');
    repeat (i, m) {
        char c;
        cin >> c;
        int stroke = mp[c];
        if (v[stroke] < c) {
            v[stroke] = c;
        }
    }
    //vdump(v);
    bool appear_first = false;
    repeat_from_to (stroke, 0, 9) {
        if (v[stroke] == '0' and (!appear_first)) {
            dp[stroke] = "";
        }
        else {
            dp[stroke] = v[stroke];
            appear_first = true;
        }
    }
    // vdump(dp);
    
    // dpテーブル更新
    repeat_from_to (i, 0, n) {
        if (dp[i] == "") continue;
        repeat_from_to (stroke, 0, 9) {
            if (v[stroke] == '0') continue;
            if (i - stroke < 0) continue;
            string s;
            if (dp[i-stroke] == "") s = "";
            else s = v[stroke] + dp[i-stroke];
            //dump(i); dump(dp[i]);  dump(s); dump(stroke); dump(v[stroke]); dump(dp[i-stroke]); el;
            
            // dp[i] と s の大小比較
            if (dp[i].length() > s.length()) dp[i] = dp[i];
            else if (dp[i].length() < s.length()) dp[i] = s;
            else dp[i] = max(dp[i], s);
            if (dp[i] == "0") dp[i] = "";
         }
    }
    //repeat_from_to (i, 0, 100) cout << dp[i] << endl;
    cout << dp[n] << endl;
    
}

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

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



int main(){
  int n;
  cin >> n;
  vector<int> a(n),left(n+1,0),right(n+1,0);

  rep(i,n) {
    cin >> a[i];
  }
  for (int i = 0; i < n; i++) {
    left[i+1] = gcd(a[i],left[i]);
  }
  for (int i = n-1; i >= 0; i--) {
    right[i] = gcd(a[i],right[i+1]);
  }
  ll res = 0;
  rep(i,n) {
    res = max(res,gcd(left[i],right[i+1]));
  }
  cout << res << endl;
  return 0;
}

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

int main() {
  int K, A, B;
  cin >> K;
  cin >> A >> B;
  int Largest = (B/K)*K;
  if (A <= Largest) cout << "OK" << endl;
  else cout << "NG" << endl;
  return 0;
}

Measured memory_bytes: 3640
#include <iostream>
#include<string.h>
using namespace std;

int main()
{
	char S[100];

	cin >> S;

	int n = strlen(S);

	bool i = false;

	for (int i = 0; i < n; i++)
	{
		if (i % 2 == 0)
		{
			if (S[i] == 'L')
			{
				cout << "No";
				i = true;
				return 0;
			}
		}

		else
		{
			if (S[i] == 'R')
			{
				cout << "No";
				i = true;
				return 0;
			}
		}
	}

	if (i == false) cout << "Yes";

}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
#define rep(i,m,n) for(int (i)=(m);(i)<(n);++(i))
#define rREP(i,m,n) for(int (i)=(n)-1;(i)>=(m);--(i))
#define all(x) (x).begin(),(x).end()
#define out(y,x,h,w) (y)<0||(x)<0||(y)>=(h)||(x)>=(w)
constexpr int INF = 1000000001;
constexpr ll mod = 1000000007;
constexpr double PI = 3.1415926535897932;
template<class T>inline bool chmin(T& a, T b) {
	if (a > b) {
		a = b;
		return true;
	}
	return false;
}
template<class T>inline bool chmax(T& a, T b) {
	if (a < b) {
		a = b;
		return true;
	}
	return false;
}
inline void init() {
	cin.tie(nullptr); cout.tie(nullptr);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(15);
}

int main() {
	init();

	ll N, K; cin >> N >> K;
	vector<ll>A(N);
	rep(i, 0, N)cin >> A[i];
	vector<ll>a(N, 0), b(N, 0);
	rep(i, 0, N) {
		rep(j, i + 1, N) {
			if (A[i] > A[j])a[i]++;
		}
		rep(j, 0, N) {
			if (A[i] > A[j])b[i]++;
		}
	}
	ll ans = 0, x = (((K - 1) * K) / 2) % mod;
	rep(i, 0, N) {
		ans += (a[i] * K) % mod + (b[i] * x) % mod;
		ans %= mod;
	}
	cout << ans << "\n";

	return 0;
}

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

#define ll long long

using namespace std;

int M[500][500];

int main(){
 
 int h,w;
 cin>>h>>w;

 for(int i=1;i<h-1;++i){
     if(i%2){
         for(int j=w-2;j>=1;j--){
             M[i][j]=1;
         }
     }else{
         if(i%4) M[i][w-2]=1;
         else M[i][1]=1; 
     }
 }

 char a;
 for(int i=0;i<h;++i){
     for(int j=0;j<w;++j){
         cin>>a;
         if(a=='#') M[i][j]=2;
     }
 }

 for(int i=0;i<h;++i){
   for(int j=0;j<w;++j){
      if(M[i][j]==0||M[i][j]==2) cout<<"#";
      else cout<<".";
      if(j==w-1) cout<<endl;
   }
 }
 cout<<endl;
  for(int i=0;i<h;++i){
   for(int j=0;j<w;++j){
      if(M[i][j]==1||M[i][j]==2) cout<<"#";
      else cout<<".";
      if(j==w-1) cout<<endl;
   }
 }
 
 return 0;
}


Measured memory_bytes: 1792