akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define ll long long
#define ld long double
#define pb push_back
#define ip pair<ll,ll>
#define vii vector<ll>
#define vpp vector<ip>
#define vdd vector<ld>
#define vb vector<bool>
#define pi  pair<ll,ip>
#define sc(x) scanf("%lli",&x)
#define c(x) cin >> x
#define fo(i,k,n) for( int i=k;i<n;i++)
#define hu 200010
#define pq priotity_queue<ll>
#define pqs priority_queue<ll,vii,greater<ll>>
#define ppq priority_queue<ip,vpp,greater<ip>>
#define INF INT_MAX
#define ff first
#define ss second
using namespace std;
const ll M = 1000000000+7;
//Grid Movement
ll dx[] = {-1, 0, 1, 0};
ll dy[] = {0, -1, 0, 1};

ld Pi= acos(-1);

ll lcm(ll a,ll b)
{
    return (a*b)/(__gcd(a,b));
}

ll mex(ll x, ll y) 
{ 
	ll res = 1;	  
	x = x % M; 
	if (x == 0) return 0; 
	while (y > 0) 
	{ 
		if (y & 1) 
		res = (res*x) % M; 
		y = y>>1; 
		x = (x*x) % M; 
	} 
	return res; 
} 

bool comp(ll comp1,ll comp2)
{
    return comp1>comp2;
}

void yes()
{
    printf("YES\n");
}

void no()
{
    printf("NO\n");
}

ll inv(ll a, ll m)
{
    ll m0 = m;
    ll y = 0, x = 1;
 
    if (m == 1)
      return 0;
 
    while (a > 1)
    {
        int q = a / m;
        int t = m;
        m = a % m, a = t;
        t = y;
        y = x - q * y;
        x = t;
    }
 
    if (x < 0)
       x += m0;
 
    return x;
}

void sieve(ll n)
{
    vii primes(n+1);
    vb is_prime(n+1);
	is_prime.resize(n+1);
	primes.resize(n+1);
 
	is_prime[0] = is_prime[1] = false;
	for(int i = 2; i<=n; i++)
	{
	    if(is_prime[i])
	    {
	    	primes.pb(i);
	        for (int j = i*i; j<=n; j+=i)
	            is_prime[j] = false;
	    }
	}
}

void solve()
{
    ll n;
    sc(n);
    if(n%7==0)n/=7;
    n*=9;
    ll res =1,p=1;
    while(p<n+3)
    {
        res = (res*10)%n;
        if(res==1)
        {
            printf("%lli\n",p);
            return;
        }
        p++;
    }
    
    printf("-1\n");
}

int main()
{
    ll t=1;
   // sc(t);
    while(t--) solve();
}





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

#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for (int i = x; i < n; i++)
#define OP(m) cout << m << endl
typedef long long ll;
typedef unsigned long long ull;

const int MAX = 500000;
int L[MAX / 2 + 2], R[MAX / 2 + 2];
int a[MAX];
int cnt = 0;

void merge(int a[], int left, int mid, int right)
{
    int n1 = mid - left;
    int n2 = right - mid;
    rep(i, n1) L[i] = a[left + i];
    rep(i, n2) R[i] = a[mid + i];
    L[n1] = R[n2] = 1e9 + 1;
    int i = 0, j = 0;
    for (int k = left; k < right; k++)
    {
        cnt++;
        a[k] = (L[i] <= R[j] ? L[i++] : R[j++]);
    }
}

void mergesort(int a[], int left, int right)
{
    if (left + 1 < right)
    {
        int mid = (left + right) / 2;
        mergesort(a, left, mid);
        mergesort(a, mid, right);
        merge(a, left, mid, right);
    }
}

int main()
{
    int n;
    cin >> n;
    rep(i, n) cin >> a[i];
    mergesort(a, 0, n);
    rep(i, n)
    {
        if (i)
            cout << " ";
        cout << a[i];
    }
    cout << endl;
    OP(cnt);
    return 0;
}


Measured memory_bytes: 6916
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define rrep(ri,n) for(int ri = (int)(n-1); ri >= 0; ri--)
#define rep2(i,x,n) for(int i = (int)(x); i < (int)(n); i++)
#define rrep2(ri,x,n) for(int ri = (int)(n-1); ri >= (int)(x); ri--)
#define repit(itr,x) for(auto itr = x.begin(); itr != x.end(); itr++)
#define rrepit(ritr,x) for(auto ritr = x.rbegin(); ritr != x.rend(); ritr++)
#define ALL(x) x.begin(), x.end()
using ll = long long;
using namespace std;

int main(){
  string s;
  cin >> s;
  map<string, string> mp;
  mp["Sunny"] = "Cloudy";
  mp["Cloudy"] = "Rainy";
  mp["Rainy"] = "Sunny";
  cout << mp[s] << endl;
  return 0;
}

Measured memory_bytes: 3560
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;

public class Main {

    static BufferedReader in;
    static PrintWriter out;
    static StringTokenizer tok;

    void solve() throws IOException {
        int n = ni();
        out.println(n * n * n);
    }

    String ns() throws IOException {
        while (!tok.hasMoreTokens()) {
            tok = new StringTokenizer(in.readLine(), " ");
        }
        return tok.nextToken();
    }

    int ni() throws IOException {
        return Integer.parseInt(ns());
    }

    long nl() throws IOException {
        return Long.parseLong(ns());
    }

    double nd() throws IOException {
        return Double.parseDouble(ns());
    }

    String[] nsa(int n) throws IOException {
        String[] res = new String[n];
        for (int i = 0; i < n; i++) {
            res[i] = ns();
        }
        return res;
    }

    int[] nia(int n) throws IOException {
        int[] res = new int[n];
        for (int i = 0; i < n; i++) {
            res[i] = ni();
        }
        return res;
    }

    long[] nla(int n) throws IOException {
        long[] res = new long[n];
        for (int i = 0; i < n; i++) {
            res[i] = nl();
        }
        return res;
    }

    public static void main(String[] args) throws IOException {
        in = new BufferedReader(new InputStreamReader(System.in));
        out = new PrintWriter(System.out);
        tok = new StringTokenizer("");
        Main main = new Main();
        main.solve();
        out.close();
    }
}

Measured memory_bytes: 24096
#include <stdlib.h>
#include <stdio.h>
int main(void){
	int n;
	scanf("%d", &n);

	int ans = 0;

	while(n>=0){
		if(n%4==0){
			ans = 1;
			break;
		}
		else{
			n = n - 7;
		}
	}

	if(ans==0){
		printf("No\n");
	}
	else{
		printf("Yes\n");
	}

	return 0;
}

Measured memory_bytes: 128
#pragma GCC optimize ("O3")
#include <bits/stdc++.h>

using namespace std;


int main() {
	#ifdef Fekete
		freopen("input.txt", "r", stdin);
		//freopen("output.txt", "w", stdout);
        //freopen("debuger.txt", "w", stderr);
    #endif // Fekete

	//	ios::sync_with_stdio(0); cin.tie(nullptr);


    int n, m;
    cin >> n >> m;
    cout << (((n - m) * 100 + m * 1900) << m);

}



Measured memory_bytes: 256
const lines: string[] = [];
const reader = require("readline").createInterface({
  input: process.stdin,
  output: process.stdout,
});
reader.on("line", function (line: string) {
  lines.push(line);
});

reader.on("close", function () {
  const input = Number(lines[0]);
  lines.shift();

  let res = new Set(lines);

  // let res = lines.filter((x, i, self) => {
  //   return self.indexOf(x) === i;
  // });

  console.log(res.size);
});


Measured memory_bytes: 58220
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    if(n == 7 || n == 5 || n== 3){
      System.out.println("YES");
      return;
    }
    System.out.println("NO");
  }
}

Measured memory_bytes: 21972
# -*- coding: utf-8 -*-
import sys
import numpy as np
from itertools import combinations


def answer(l):
    results = []
    for i, j in combinations(l, 2):
        v_a = np.array(i)
        v_b = np.array(j)
        results.append(np.linalg.norm(v_a - v_b))
    return sum(float.is_integer(i) for i in results)


n, d = map(int, input().split())
coodinates = [[int(x) for x in input().split()] for _ in range(n)]
print(answer(coodinates))

Measured memory_bytes: 12472
from bisect import bisect_left, bisect_right
s = input()
t = input()
n_s = len(s)
n_t = len(t)


idx = [[] for _ in range(26)]
#print(ord("a"))
#print(ord("z"))

def a_idx(a):
    idx = ord(a)
    idx -= 97
    return idx


for i in range(n_s):
    idx[a_idx(s[i])].append(i)

t_syutugenkasyo = []
for i in range(n_t):
    t_syutugenkasyo.append(idx[a_idx(t[i])])
#print(t_syutugenkasyo)

now = -1
ans = 0
for i in range(n_t):
    if len(t_syutugenkasyo[i]) == 0:
        print(-1)
        exit()
    ni = bisect_right(t_syutugenkasyo[i], now)
    if ni >= len(t_syutugenkasyo[i]):
        ans += n_s
        now = t_syutugenkasyo[i][0]
    else:
        now = t_syutugenkasyo[i][ni]
ans += now+1
print(ans)

Measured memory_bytes: 85404
#include <bits/stdc++.h>	
#define pb push_back
typedef long long ll;
const int inf = 2e9;
using namespace std;
  
ll N[100006],D[100006],dp[100006];
ll ans=0,n,c;

int main(){
 
  scanf("%lld%lld",&n,&c);
  for (int i = 0; i < n; ++i){
  	scanf("%lld",&D[i]);
  	scanf("%lld",&N[i]);
  }
  
  ll nu=0,ma=0;
  for(int i=0; i<n; i++){
  	nu+=N[i];
  	ma=max(ma,nu-D[i]);
  	dp[i]=ma;
  }

  ans = max(ans,dp[n-1]);

  nu = 0,ma=0;
  for (int i = n-1; i > 0 ; --i)
  {
  	nu+=N[i];
  	ans=max(ans,dp[i-1]+nu-2*(c-D[i]));
  }



  nu=0,ma=0;
  for(int i=n-1; i>=0; i--){
  	nu+=N[i];
  	ma=max(ma,nu-(c-D[i]));
  	dp[i]=ma;
  }
  
  ans = max(ans,dp[0]);

  nu = 0,ma=0;

  for (int i = 0; i < n-1 ; ++i)
  {
  	nu+=N[i];
  	ans=max(ans,dp[i+1]+nu-2*D[i]);
  }
 
 
  return !printf("%lld\n",ans);
 
}

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

ll min(ll a,ll b){
    if(a<b)return a;
    else return b;
}
ll max(ll a,ll b){
    if(a>b)return a;
    else return b;
}

int main() {
    ll n,k;
    string s;
    cin>>n>>s>>k;
    for(ll i=0;i<s.size();i++){
        if(s[i]!=s[k-1]){
            s[i]='*';
        }
    }
    cout<<s<<endl;
    return 0;
}


Measured memory_bytes: 256
import bisect
anum, bnum, time= map(int, input().split(" "))
a = list(map(int, input().split(" ")))
b = list(map(int, input().split(" ")))
tempa = [0]
tempb = [0]
total = 0
for i in range(anum):
    tempa.append(tempa[-1] + a[i])
    if total > time:
        break
for i in range(bnum):
    tempb.append(tempb[-1] + b[i])
    if total > time:
        break
maxi = 0
starta = bisect.bisect_right(tempa, time) - 1
for i in range(starta, -1, -1):
    startb = bisect.bisect_right(tempb, time - tempa[i]) - 1
    if i + startb > maxi:
        maxi = i + startb
print(maxi)

Measured memory_bytes: 123188
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> P;
typedef pair<int,int> Pi;
#define rep(i,n) for(ll i=0;i<n;i++)
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define fi first
#define se second
#define endl "\n"

template<typename T> inline bool chmax(T &a, T b){if(a<b){a=b;return true;}return false;}
template<typename T> inline bool chmin(T &a, T b){if(a>b){a=b;return true;}return false;}
template<typename T> ostream& operator<<(ostream& s,const complex<T>& d) {return s<<"("<<d.real()<<", "<<d.imag()<< ")";}
template<typename T1, typename T2> ostream& operator<<(ostream& s,const pair<T1,T2>& d) {return s<<"("<<d.first<<", "<<d.second<<")";}
template<typename T> ostream& operator<<(ostream& s, const vector<T>& d){int len=d.size();rep(i,len){s<<d[i];if(i<len-1) s<<" ";}return s;}
template<typename T> ostream& operator<<(ostream& s,const vector<vector<T>>& d){int len=d.size();rep(i,len){s<<d[i]<<endl;}return s;}
template<typename T> ostream& operator<<(ostream& s,const set<T>& v){s<<"{ ";for(auto itr=v.begin();itr!=v.end();++itr) {if (itr!=v.begin()) {s<< ", ";}s<<(*itr);}s<<" }";return s;}
template<typename T1, typename T2> ostream& operator<<(ostream& s,const map<T1,T2>& m){s<<"{"<<endl;for(auto itr=m.begin();itr!=m.end();++itr){s<<" "<<(*itr).first<<" : "<<(*itr).second<<endl;}s<<"}"<<endl;return s;}

const ll mod=1e9+7;
const ll inf=1e17;
const int INF=1e9;
const double PI=acos(-1);
const double EPS=1e-10;

int main(){
	cin.tie(0);ios::sync_with_stdio(false);
	int n,k;
	cin>>n>>k;
	vector<int> cnt(n,0);
	rep(i,k){
		int d;
		cin>>d;
		rep(j,d){
			int a;
			cin>>a;
			a--;
			cnt[a]++;
		}
	}
	int ans=0;
	rep(i,n){
		if(cnt[i]==0) ans++;
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 3660
#include <iostream>
#include <string>
#include <cmath>
#include <sstream>

using namespace std;

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    string a;
    stringstream ss;
    int n;
    cin>>a;
    ss<<a;
    cin>>a;
    ss<<a;
    ss>>n;
    int i;
    for(i=0; i*i<n; i++);
    if(i*i==n) cout<<"Yes\n";
    else cout<<"No\n";

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const long long INF = 1e7 + 1;
const long long MOD = 1000000007;
const long double PI = 3.1415926;
#define FOR(i,r,n) for(ll i = (ll)(r); i < (ll)(n); i++)
#define RFOR(i,r,n) for(ll i=(ll)(n-1);i>=r;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define ALL(x) x.begin(),x.end()
#define RALL(x) x.rbegin(),x.rend()
typedef long long int ll;
typedef vector<ll> vi;
typedef vector < pair<ll, ll > > vp;
typedef vector <string> vs;
typedef vector <char> vc;
typedef list <ll> lst;

ll n, m, k, ans = 0, sum = 0, cnt = 0;
string s;
char c;

#define Endl endl

/*--------------------template--------------------*/


int main()
{
	cin >> s;
	REP(i, s.size() / 2)
	{
		if (s[i] != s[s.size() - 1 - i]) {
			cout << "No" << endl;
			return 0;
		}
	}
	cout << "Yes" << endl;
}

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

using namespace std;

int main()
{
    int n, l;
    vector<string> string_vector;
    string s;
    cin >> n >> l;
    for(int i = 0; i < n; i++){
       cin >> s;
       string_vector.push_back(s);

    }
    sort(string_vector.begin(),string_vector.end());
    for(int i = 0; i < n; i++){
        cout << string_vector[i];
    }
    return 0;
}


Measured memory_bytes: 256
# ABC 050 B
N =int(input())
Ts =[int(j) for j in input().split()]
M =int(input())
List=[[int(j) for j in input().split()] for i in range(M)]

for i in range(M):
    Ts_ = Ts.copy()
    Ts_[List[i][0]-1] = List[i][1]
    print(sum(Ts_))


Measured memory_bytes: 3060
#include <stdio.h>

int main(){
	int w,h;
	
	while(1){
		int flag = 1, flag2 = -1;
		scanf("%d", &h);
		scanf("%d", &w);
		
		if(w == 0 && h == 0)
			return 0;
		
		for(int i = 0; i < h; i++){
			for(int j = 0; j < w; j++){
				if(flag == 1)
					printf("#");
				else
					printf(".");
				flag *= (-1);
			}
			flag = flag2;
			flag2 *= (-1);
			printf("\n");
		}
		printf("\n");
	}
	return 0;
}

Measured memory_bytes: 1000
// AOJ 1501: Grid
// 2017.11.17 bal4u@uu

#include <stdio.h>

#define M 100000007
int tbl[1001][1001];

int combi(int n, int k)
{
	int ans;

	if (tbl[n][k]) return tbl[n][k];
	if ((k << 1) > n) k = n-k;
	if (k == 0) ans = 1;
	else if (k == 1) ans = n;
	else ans = combi(n-1, k) + combi(n-1, k-1);
	return tbl[n][k] = ans % M;
}

int main()
{
	int r, c, a1, b1, a2, b2, dr, dc, k, m;

	k = 0;
	scanf("%d%d%d%d%d%d", &r, &c, &a1, &a2, &b1, &b2);

	dr = a1-b1;
	if (dr < 0) dr = -dr;
	if (dr > r-dr) dr = r-dr;
	if ((dr << 1) == r) k++;

	dc = a2-b2;
	if (dc < 0) dc = -dc;
	if (dc > c-dc) dc = c-dc;
	if ((dc << 1) == c) k++;

	m = dc; if (dr < dc) m = dr;
	printf("%d\n", (combi(dr+dc, m) << k) % M);

	return 0;
}

Measured memory_bytes: 5696
#include<iostream>
#include<vector>
#include<cstring>
#include<cmath>
#include<set>
#include<queue>
#include<algorithm>
#include<climits>
#include<map>
#include<unordered_map>
#define ll long long

bool isPrime(ll n){
    if(n<=1)  return false;
    if(n<=3)  return true;
    if(n%2==0 || n%3==0) return false;
    for(ll i=5;i*i<=n;i=i+6)
        if(n%i==0||n%(i+2)==0)
           return false;
    return true;
}

#define w(t) ll t,tt=1;	cin>>t;		while(t--)
#define ps(x,y) fixed<<setprecision(y)<<x
#define setbits(x) __builtin_popcountll(x)
#define zrobits(x) __builtin_ctzll(x)
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define ff first
#define ss second
#define pb push_back
#define mp make_pair

#define vi vector<int>
#define vll vector<ll>
#define mii map<ll,ll>
#define umii unordered_map<ll,ll>
#define pi pair<int,int>
#define pll pair<ll,ll>
#define vpii vector<pair<int,int>>
#define vpll vector<pair<ll,ll>>

#define mod 1e9+7
#define inf 1e18

#define lln ll n; cin>>n
#define intn int n; cin>>n
#define YES cout<<"YES"
#define NO cout<<"NO"
#define strr    string str; cin>>str;
#define strn   n=str.length()
#define fr(a,n) for(ll i=a;i<n;i++)
#define loop for(ll i=0;i<n;i++)

using namespace std;

void solve (){
    intn;
    ll d;    cin>>d;
    d*=d;
    int ans=0;
    while(n--){
        ll x,y;
        cin>>x>>y;
        ll curr = (x*x)+(y*y);
        if(curr<=d){
            ++ans;
            //cout<<curr<<endl;
        }
    }
    cout<<ans;
}

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

Measured memory_bytes: 3644
for _ in[0]*int(input()):
 a,d,b,e,c,f=map(float,input().split())
 z=2*(b*f-c*e+c*d-a*f+a*e-b*d)
 x=((e-f)*(a**2+d**2)+(f-d)*(b**2+e**2)+(d-e)*(c**2+f**2))/z
 y=((c-b)*(a**2+d**2)+(a-c)*(b**2+e**2)+(b-a)*(c**2+f**2))/z
 print('{0:.3f} {1:.3f} {2:.3f}'.format(x,y,((a-x)**2+(d-y)**2)**0.5))

Measured memory_bytes: 7664
import java.util.Scanner;
import java.lang.Math; 

public class Main {

	public static boolean solution(int x) {
		for (int j = 2; j<=(int)Math.sqrt(x); j++) {
			if (x%j==0 && x != j){
				return false;
			}
		}
		return true;
	}
	
	public static void main(String[] Args) {
		Scanner in = new Scanner(System.in);
		int n = in.nextInt();
		int[] x = new int[n]; 
		for (int i = 0; i<n; i++) {
			x[i] = in.nextInt();
		}
		int count = 0;
		for (int i = 0; i<x.length; i++) {
			boolean out = solution(x[i]);
			if (out) {
				count += 1;
			}
		}
		System.out.println(count);
	}
}


Measured memory_bytes: 42284
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;

#define ff              first
#define ss              second
#define ll            long long

#define pb              push_back
#define mp              make_pair
#define pii             pair<int,int>
#define vi              vector<int>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define mod             1000000007
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define mk(arr,n,type)  type *arr=new type[n];
#define w(x)            int x; cin>>x; while(x--)
//mt19937                 rng(chrono::steady_clock::now().time_since_epoch().count());

typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;


void sb()
{
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
}
int main()
{
	//sb();

    string s,t;
    cin>>s>>t;
    int flag = 0;
    for(int i=0;i<s.size();i++){
        if(s[i]!=t[i]){
            flag = 1;
            break;
        }
    }
    if(flag==0 && s.size() == t.size()-1)
    cout<<"Yes";
    else
    cout<<"No";


return 0;
}



Measured memory_bytes: 3628
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <iomanip>
#include <cmath>
using namespace std;

#define DEBUG 0
#define REP(i, n) for (int i = 0; i < (n); i++) 
typedef long long ll;
typedef pair<int,int> pint;
static const ll MOD = 1000000007;
static const ll INF = 1000000000000000000LL;
using namespace std;

template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
//n個の宝箱(c[i],c[i])
//a[i]円でb[i]種類
//
int main() { 
    ll n,m;

    cin >> n >> m;
    //どの鍵を買うかのdpな気がする
    //Mのmaxは10^3なので、全bit探索はできない
    //NのbitをたててNについてのdp

    //c,c,cの組み合わせの最小をつくる??
    ll a[m],b[m];
    ll cnt[m] = {};
    REP(i,m)
    {
        cin >> a[i] >> b[i];
        
        ll tmp = 0;
        REP(j,b[i])
        {
            ll c;
            cin >> c;
            --c;
            tmp += (1 << c);
        }
        cnt[i] = tmp;
    }

 
    ll dp[1100][5000];
    
    //dp[i][N+N-1+N-2...+1]
    REP(i,1100)
    {
        REP(j,5000)
        {
            dp[i][j] = INF;
        }
    }

    dp[0][0] = 0;

    for(int i = 0; i < m; ++i)
    {
        for(int j = 0; j < (1 << n); ++j)
        {
            dp[i+1][j] = min(dp[i+1][j], dp[i][j]);

            dp[i+1][j | cnt[i]] = min(dp[i+1][j | cnt[i]], dp[i][j] + a[i]);
        }
    }

    ll res = dp[m][(1 << n)-1];

    if(res >= INF)res = -1;

    cout << res << endl;
 
    return 0;
}

Measured memory_bytes: 43264
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define pa(x,n) for(ll i=0;i<n;i++){cout<<(x[i])<<" \n"[i==n-1];};
#define pb push_back

using ll = long long;
using namespace std;
using pint = pair<int,int>;
using pll = pair<ll,ll>;
const int INFint = 1e9;
const ll INFll = 1e18;
ll MOD=1e9+7;

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

// aのn乗をMODで割りながら計算する
ll modpow(ll a, ll n) {
  long long res = 1;
  while (n > 0) {
    if (n & 1) res = res * a % MOD;
    a = a * a % MOD;
    n >>= 1; // right shift
  }
  return res;
}

// MODを法としたaの逆元を計算する
ll modinv(ll a) {
  return modpow(a, MOD - 2);
}

int main(){
  int N;
  cin>>N;
  int A[10][10] = {0};
  for (int i(1);i<=N;i++){
    string s = to_string(i);
    int keta = int(s.size());
    A[s[0]-'0'][s[keta-1]-'0']++;
  }
  ll ans(0);
  for(int i(0);i<=N;i++){
    string tmp = to_string(i);
    int keta_tmp = int(tmp.size());
    ans += A[tmp[keta_tmp-1]-'0'][tmp[0]-'0'];
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define int long long
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
#define endl "\n"
const int MAX= 100005 ;
const long long mod = 1.0e9+7;
int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int a,b;
    cin>>a>>b;
    cout<<max(a*b,max(a+b,a-b))<<endl;
}

Measured memory_bytes: 256
import java.util.Scanner;
 
public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int a = scanner.nextInt();
        int[][] array = new int[4][13];
        for (int i = 0; i < a; i++) {
            String b = scanner.next();
            int c = scanner.nextInt();
            if (b.equals("S"))
                array[0][c - 1] = 1;
            else if (b.equals("H"))
                array[1][c - 1] = 1;
            else if (b.equals("C"))
                array[2][c - 1] = 1;
            else
                array[3][c - 1] = 1;
        }
        for (int i = 0; i < 4; i++) {
            for (int j = 0; j < 13; j++) {
                if (array[i][j] == 0)
                    if (i == 0)
                        System.out.println("S " + (j + 1));
                    else if (i == 1)
                        System.out.println("H " + (j + 1));
                    else if (i == 2)
                        System.out.println("C " + (j + 1));
                    else
                        System.out.println("D " + (j + 1));
            }
        }
    }
}


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

namespace ConsoleApp2
{
	class Program
	{
		static void Main(string[] args)
		{
			var s = Console.ReadLine();
			var t = Console.ReadLine();

			var ans = 0;
			for (int i = 0; i < s.Length; i++)
			{
				if (s[i] != t[i]) ans++;
			}

			Console.WriteLine(ans);
		}
	}
}


Measured memory_bytes: 27448
#include<bits/stdc++.h>
#define speed_up ios_base::sync_with_stdio(false); cin.tie(NULL)
#define ll long long
#define ara(A,N) sort(A,A+N)
#define rev(A,N) sort(A,A+N,greater<long long>())
using namespace std;
int main()
{
  speed_up;
  ll a, b;
  cin>>a>>b;
  if(a == 1) a = 1 + 13;
  if(b == 1) b = 1 + 13;

  if(b == a) cout<<"Draw"<<endl;
  else if(a>b) cout<<"Alice"<<endl;
  else cout<<"Bob"<<endl;


return 0;
}



Measured memory_bytes: 3656
//Robs Code
/***********HEADER***************/
#include <iostream>
#include <bitset>
#include <deque>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <string>
#include <algorithm>
#include <list>
#include <vector>
#include <unordered_set>
#include <unordered_map>
#include <stack>
#include <set>
#include <queue>
#include <map>
/***********MACROS***************/
#define fri(l,k) for (i=l;i<=k;i++)
#define frj(l,k) for (j=l;j>=k;j--)
#define fij(a,b,l,k) for(i=a;i<=b;i++) for(j=l;j<=k;j++)
#define all(x) x.begin(),x.end()
#define allr(x) x.rbegin(),x.rend()
#define endl "\n"
#define pb push_back
#define _1 first
#define _2 second
#define mxsz 1e5+10
#define mod 1e9 + 7
#define pii pair<int,int>
using namespace std;
const int N = 1e5 + 1;
int n,m,i,j,l,t,k,x,y,cnt[3],sum[3];
/***********MAIN**************/
int dp[3001][3001];
vector<pii> v;
int brute(int i,int ai){
	if(i == n){
		return 0;
	}
	if(ai < 0.5){
		return ((int)(-2e10));
	}
	if(dp[i][ai] != -1){
		return dp[i][ai];
	}
	int ans = 0;
	int x = brute(i+1,ai - v[i]._1)+v[i]._2;
	int y = brute(i+1,ai);
	ans = max(x,y);
	dp[i][ai] = ans;
	return ans;
}
signed main(){
	ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
	cin>>n>>t;
	for(int i=0;i<n;i++){
		v.pb({0,0});
		cin>>v[i]._1>>v[i]._2;
	}
	sort(all(v));
	memset(dp,-1,sizeof dp);
	cout<<brute(0,t);
    return 0;
}
//.........

Measured memory_bytes: 36088
//
//  main.cpp
//  test130
//
//  Created by  on 2019/06/16.
//  Copyright © 2 All rights reserved.
//
//
//  main.cpp
//  new
//
//  Created on 2019/06/09.
//  Copyright  All rights reserved.
//

// C++ includes used for precompiling -*- C++ -*-

// Copyright (C) 2003-2013 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library.  This library is free
// software; you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3, or (at your option)
// any later version.

// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU General Public License for more details.

// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.

// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
// <http://www.gnu.org/licenses/>.

/** @file stdc++.h
 *  This is an implementation file for a precompiled header.
 */

// 17.4.1.2 Headers

// C
#ifndef _GLIBCXX_NO_ASSERT
#include <cassert>
#endif
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#if __cplusplus >= 201103L
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
#endif

// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

#if __cplusplus >= 201103L
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#endif

using namespace std;

int n,k,p,ans;

signed main(){
    cin>>n>>k;
    for (int i=0; i<n; i++) {
        cin>>p;
        if (p>=k) {
            ans++;
        }
    }
    cout<<ans<<endl;
}





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

using namespace std;

int main(){
  ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
  cout.setf(ios::fixed); cout.precision(11);

  int h, w;
  cin >> h >> w;
  vector<string> grid(h);
  for(int i = 0; i < h; i++){
    cin >> grid[i];
  }
  const int mod = 1e9 + 7;
  function<void(int&, int)> add = [&](int &a, int b){
    a += b;
    if(a >= mod) a -= mod;
  };
  vector<vector<int>> f(h, vector<int>(w,0));
  f[0][0] = 1;
  for(int i = 0; i < h; i++){
    for(int j = 0; j < w; j++){
      if(grid[i][j] == '#') continue;
      if(i - 1 >= 0 && grid[i-1][j] != '#') add(f[i][j], f[i-1][j]);
      if(j - 1 >= 0 && grid[i][j-1] != '#') add(f[i][j], f[i][j-1]);
    }
  }

  cout << f[h-1][w-1] << '\n';

  return 0;
}


Measured memory_bytes: 5248
// AOJ GRL_6_B: Network Flow - Minimum Cost Flow
#include <bits/stdc++.h>

using namespace std;

using ll = long long;
using Pi = pair<int, int>;
using Pl = pair<ll, ll>;
using Ti = tuple<int, int, int>;
using Tl = tuple<ll, ll, ll>;

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define mt make_tuple
#define F first
#define S second
#define Get(t, i) get<(i)>((t))
#define all(v) (v).begin(), (v).end()
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define reps(i, f, n) for(int i = (int)(f); i < (int)(n); i++)
#define each(a, b) for(auto& a : b)

const int inf = 1 << 25;
const ll INF = 1LL << 55;

struct edge
{
  int to, capacity, cost, rev;
  edge(){}
  edge(int to, int capacity, int cost, int rev):to(to), capacity(capacity), cost(cost), rev(rev){}
};

struct PrimalDual
{
  vector< vector<edge> > graph;
  vector<int> potential, mincost, prevv, preve;
  PrimalDual(int V):graph(V), potential(V), mincost(V), prevv(V), preve(V){}
  void add_edge(int from, int to, int capacity, int cost)
  {
    graph[from].push_back(edge(to, capacity, cost, (int)graph[to].size()));
    graph[to].push_back(edge(from, 0, -cost, (int)graph[from].size()-1));
  }
  int min_cost_flow(int source, int sink, int f)
  {
    int ret = 0;
    fill(potential.begin(), potential.end(), 0);
    fill(prevv.begin(), prevv.end(), -1);
    fill(preve.begin(), preve.end(), -1);

    while(f > 0) {
      priority_queue<Pi, vector<Pi>, greater<Pi> > que;
      fill(mincost.begin(), mincost.end(), inf);
      mincost[source] = 0;
      que.push(Pi(0, source));
      while(!que.empty()) {
	Pi p = que.top(); que.pop();
	int v = p.second;
	if(mincost[v] < p.first) continue;
	for(int i = 0; i < (int)graph[v].size(); i++) {
	  edge& e = graph[v][i];
	  int dual_cost = mincost[v] + e.cost + potential[v] - potential[e.to];
	  if(e.capacity > 0 && dual_cost < mincost[e.to]) {
	    mincost[e.to] = dual_cost;
	    prevv[e.to] = v; preve[e.to] = i;
	    que.push(Pi(mincost[e.to], e.to));
	  }
	}
      }

      if(mincost[sink] == inf) return -1;
      for(int v = 0; v < (int)graph.size(); v++) potential[v] += mincost[v];
      int d = f;
      for(int v = sink; v != source; v = prevv[v]) d = min(d, graph[prevv[v]][preve[v]].capacity);
      f -= d;
      ret += d * potential[sink];
      for(int v = sink; v != source; v = prevv[v]) {
	edge& e = graph[prevv[v]][preve[v]];
	e.capacity -= d;
	graph[v][e.rev].capacity += d;
      }
    }
    return ret;
  }
};


int main()
{
  int V, E, F;
  cin >> V >> E >> F;
  PrimalDual mnf(V);
  while(E--) {
    int u, v, c, d;
    cin >> u >> v >> c >> d;
    mnf.add_edge(u, v, c, d);
  }
  cout << mnf.min_cost_flow(0, V-1, F) << endl;
  return 0;
}

Measured memory_bytes: 3152
import sys
input = sys.stdin.readline
import heapq as hp

n,m = map(int,input().split())
a = list(map(lambda x: int(x)*(-1),input().split()))
hp.heapify(a)
tmp = 0

for i in range(m):
  tmp = hp.heappop(a)
  hp.heappush(a,(-tmp//2)*(-1))
#
print(-sum(a))


Measured memory_bytes: 68248
#include<iostream>
#include<iomanip>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<string>
#include<utility>
#include<numeric>
#include<algorithm>
#include<cmath>
#include<climits>
using namespace std;

using ll = long long;

class Stream{
public:
    Stream(){

    }
    //配列以外の入力を受け取る
    void read(){

    }
    template<typename First, typename... Rest>
    void read(First& first, Rest&... rest){
        cin >> first;
        read(rest...);
    }
    template<typename T>
    vector<T> read_vec(size_t n){
        vector<T> tmp(n);
        for(size_t i = 0; i < n; i++){
            cin >> tmp[i];
        }
        return tmp;
    }
    //配列を区切って出力する
    template<typename T>
    void write_vec(vector<T>& v, char divider){
        for(size_t i = 0; i < v.size(); i++){
            cout << v[i] << divider;
        }
    }
};

int main(){
    Stream io;

    ll N;
    io.read(N);
    auto A = io.read_vec<ll>(N);
    map<ll, ll> mp;
    ll m = 0;
    for(int i = 0; i < N; i++){
        mp[A[i]]++;
        m = max(m, A[i]);
    }
    
    ll ans = 0;
    for(auto itr = mp.begin(); itr != mp.end(); itr++){
        if(itr->second > 0){
            if(itr->second == 1) ans++;
            for(ll k = 2 * itr->first; k <= m; k += itr->first){
                mp[k] = 0;
            }
        }
    }
    cout << ans;
    return 0;
}

Measured memory_bytes: 67148
#include<cstdio>
using namespace std;
int main()
{
	int n,p,t=0;
	scanf("%d",&n);
	p=n;
	while(p)
	{
		t+=p%10;
		p/=10;
	}
	if (n%t) printf("No");
	else printf("Yes");
}

Measured memory_bytes: 128
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cassert>
#include <cctype>
#include <algorithm>
#include <set>
using namespace std;
typedef long long lint;
typedef unsigned int uint;
#define cout cerr
#define ni (next_num<int>())
template<class T>inline T next_num(){
	T i=0;char c;
	while(!isdigit(c=getchar())&&c!='-');
	bool flag=c=='-';
	flag?c=getchar():0;
	while(i=i*10-'0'+c,isdigit(c=getchar()));
	return flag?-i:i;
}
template<class T1,class T2>inline void apmax(T1 &a,const T2 &b){if(a<b)a=b;}
template<class T1,class T2>inline void apmin(T1 &a,const T2 &b){if(b<a)a=b;}
const int N=100010;
int a[N],b[N],c[N];
int lst[N];
inline bool bccmp(int x,int y){
	return b[x]-c[x]>b[y]-c[y];
}
struct bacmp{
	inline bool operator () (int x,int y){
		int v1=b[x]-a[x],v2=b[y]-a[y];
		return v1!=v2?v1<v2:x<y;
	}
};
struct cacmp{
	inline bool operator () (int x,int y){
		int v1=c[x]-a[x],v2=c[y]-a[y];
		return v1!=v2?v1<v2:x<y;
	}
};
set<int,bacmp>sb1,sb2;
set<int,cacmp>sc1,sc2;
lint ans=0;
template<class T>inline void ins(T &cur,T &bak,int ele,uint amt,int b[]){
	ans+=b[ele];
	cur.insert(ele);
	if(cur.size()>amt){
		int tmp=*cur.begin();
		cur.erase(cur.begin());
		ans+=a[tmp]-b[tmp];
		bak.insert(tmp);
	}
}
template<class T>inline void del(T &cur,T &bak,int ele,uint amt,int b[]){
	if(cur.find(ele)==cur.end()){
		bak.erase(ele);
		ans-=a[ele];
	}else{
		cur.erase(ele);
		ans-=b[ele];
		if(cur.size()<amt&&!bak.empty()){
			int tmp=*--bak.end();
			bak.erase(--bak.end());
			ans+=b[tmp]-a[tmp];
			cur.insert(tmp);
		}
	}
}
int main(){
	int x=ni,y=ni,z=ni,n=x+y+z;
	for(int i=1;i<=n;i++){
		a[i]=ni,b[i]=ni,c[i]=ni,lst[i]=i;
	}
	sort(lst+1,lst+n+1,bccmp);
	for(int i=1;i<=y;i++){
		ins(sb1,sb2,lst[i],y,b);
	}
	for(int i=y+1;i<=n;i++){
		ins(sc1,sc2,lst[i],z,c);
	}
	lint fin=ans;
	for(int i=y+1;i<=n-z;i++){
		del(sc1,sc2,lst[i],z,c);
		ins(sb1,sb2,lst[i],y,b);
		apmax(fin,ans);
	}
	printf("%lld\n",fin);
	return 0;
}

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

typedef long long ll;
const ll INF = 1e10;

int main(int argc, char* argv[])
{
  ll N;
  std::cin >> N;
  std::vector< std::vector<ll> > vopen(N, std::vector<ll>(10, 0LL));
  for (ll y = 0; y < N; y++) {
    for (ll x = 0; x < 10; x++) {
      std::cin >> vopen[y][x];
    }
  }
  std::vector< std::vector<ll> > vp(N, std::vector<ll>(11, 0LL));
  for (ll y = 0; y < N; y++) {
    for (ll x = 0; x < 11; x++) {
      std::cin >> vp[y][x];
    }
  }

  ll ans = -INF;
  for (ll S = 1; S < std::pow(2, 10); S++) {
    ll state = S;
    ll opened[10];
    ll i = 0;
    std::fill(opened, opened + 10, 0LL);
    while (state > 0) {
      opened[i] = state % 2;
      state /= 2;
      i++;
    }
    ll benefit = 0LL;
    for (ll y = 0; y < N; y++) {
      ll cnt = 0;
      for (ll x = 0; x < 10; x++) {
	if (opened[x] == 1 && vopen[y][x] == 1) {
	  cnt++;
	}
      }
      benefit += vp[y][cnt];
    }
    ans = std::max(ans, benefit);
  }

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


Measured memory_bytes: 256
#include <iostream>
#include<bits/stdc++.h>
using namespace std;
int dp[100005];
vector<int> gr[100005];
int solve(int src)
{

if(dp[src]!=-1)
{
    return dp[src];
}
bool leaf=1;
int bestchild=0;
for(auto nbr:gr[src])
{  leaf=0;
    bestchild=max(bestchild,solve(nbr));
}

return dp[src]=(leaf?0:1+bestchild);
}
int main() {
    int n,m;
    cin>>n>>m;

    memset(dp,-1,sizeof(dp));
     for(int i=0;i<m;i++)
     {  int x,y;
         cin>>x>>y;
         x--;
         y--;
         gr[x].push_back(y);
     }
     int ans=0;
     for(int i=0;i<n;i++)
     {
         ans=max(ans,solve(i));
         
     }
     cout<<ans;
}


Measured memory_bytes: 11296
//#include <fsociety>
#include <cmath>
#include <deque>
#include <algorithm>
#include <iterator>
#include <list>
#include <map>
#include <unordered_map>
#include <queue>
#include <set>
#include <unordered_set>
#include <stack>
#include <string>
#include <vector>
#include <iostream>
//end of libraries ;
#define INF 99999999999
#define N 200
#define F first
#define S second
#define pb push_back
#define ll long long
#define fcin ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);
using namespace std;
int n , m  , s , c;
string a;
bool ok = 1;
int main(){
fcin;
	cin>>n>>m;
	for(int i = 0 ; i < n ; i++) a+='X';
	while(m--){
		cin>>s>>c;
		if((a[s-1]!='X' && a[s-1]!=char(c+48)) || s > n) {ok = 0;}
		a[s-1] = char(c+48);
	}
	if(n!=1){
	if(a[0]=='0') ok = 0;
	if(a[0]=='X') a[0] = '1';
	for(int i = 1 ; i  < a.length() ; i++){
		if(a[i]=='X') a[i] = '0';
		}
	}
	else {
		if(a[0]=='X') a[0] = '0';
	}
	if(ok) cout<<a;
	else cout<<-1;
}

Measured memory_bytes: 256
//  ITP1-ITP1_5_D   Structured Program I - Structured Programming
//  2018_3_26

#include <iostream>
using namespace std;

void
call (int n)
{
  int i = 1;
  while (++i <= n){
    int x = i;
    if (x % 3 == 0){
      cout << " " << i;
    } else {
      do {
	if (x % 10 == 3){
	  cout << " " << i;
	  break;
	}
	x /= 10;
      } while (x);
    }
  }
  cout << endl;
}

int
main ()
{
  int n;
  cin >> n;
  call (n);
  return 0;
}



Measured memory_bytes: 3080
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define debug(x) cerr << "[(" << __LINE__ << ") " << #x << "]: " << (x) << endl;

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

    int h, w;
    cin >> h >> w;

    bool a[h][w];
    for (int i=0; i<h; i++) {
        for (int j=0; j<w; j++) {
            char c;
            cin >> c;
            a[i][j] = c == '.';
        }
    }
    constexpr ll MOD = 1e9+7;
    vector<vector<ll>> b(h, vector<ll>(w));
    b[0][0] = 1;
    for (int i=0; i<h; i++) {
        for (int j=0; j<w; j++) {
            if (!a[i][j])
                continue;
            if (i>0) b[i][j] += b[i-1][j];
            if (j>0) b[i][j] += b[i][j-1];
            b[i][j] %= MOD;
        }
    }
    cout << b[h-1][w-1] << "\n";
}


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

using namespace std;
#define ll long long

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int ans = 0;
    int k;
    cin >> k;
    for (int i = 1; i <= k; i++) for (int j = 1; j <= k; j++)
        for (int w = 1; w <= k; w++) ans += __gcd(i, __gcd(j, w));
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3652
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>

#include <iostream>
#include <string>

#include <algorithm>
#include <deque>
#include <map>
#include <queue>
#include <set>
#include <vector>

#define PB push_back
#define MP make_pair

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

#define ALL(v) (v).begin(),(v).end()

using namespace std;

typedef long long LL;
typedef unsigned long long ULL;

typedef pair<int, int> PII;

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef vector<PII> VPII;

const int MOD = 1000000007;
const int INF = 1e9;

const double EPS = 1e-9;
const double PI = acos(-1.0);

LL gcd(LL a, LL b) { return b ? gcd(b, a % b) : a; }
LL lcm(LL a, LL b) { return a / gcd(a, b) * b; }

string S;

int main() {
    cin >> S;
    VI ans(S.size(), 0);
    int acc = 0, acc2 = 0;
    REP (i, S.size()) {
        if (S[i] == 'R') {
            acc++;
        }
        else {
            ans[i - 1] += acc - acc / 2;
            ans[i] += acc / 2;
            acc = acc2 = 0;
        }
    }
    REP (i, S.size()) {
        if (S[S.size() - 1 - i] == 'L') {
            acc++;
        }
        else {
            ans[S.size() - 1 - i + 1] += acc - acc /2;
            ans[S.size() - 1 - i] += acc / 2;
            acc = 0;
        }
    }
    REP (i, S.size() - 1) {
        cout << ans[i] << ' ';
    }
    cout << ans[S.size() - 1] << endl;
    return 0;
}


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

using ll = long long int;

const int MAX = (int)(1e5 + 5);
const ll INF = (ll)(1e10 + 5);

ll n, x;

ll ans;

ll calc(ll cur_x, ll cur_length) {
  ll part = cur_length / cur_x;
  if (cur_length % cur_x == 0) { // just returned start point
    return (part * 2 - 1) * cur_x;
  }
  else { // did not return, spray more detailed ray
    ll next_x = cur_length % cur_x;
    ll next_length = cur_x;
    return (part * 2) * cur_x + calc(next_x, next_length);
  }
}

int main(void) {
  // Here your code !
  scanf("%lld %lld\n", &n, &x);

  if (n % 2 == 0 && x == (n / 2)) {
    ans = 3 * x;
  }
  else {
    ll cur_x = x;
    ll cur_length = n - x;
    ans = cur_x + cur_length + calc(cur_x, cur_length);
  }

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

  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vs = vector<string>;
using msi = map<string, int>;
using mii = map<int, int>;
using psi = pair<string, int>;
using pii = pair<int, int>;
using vlai = valarray<int>;
#define rep(i,n) for(int i=0;i<n;i++)
#define range(i,s,n) for(int i=s;i<n;i++)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define fs first
#define sc second
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define INF 1E9
#define EPS 1E-9
#define MOD (ll)(1E9+7)
#define PI 3.1415926535897932384

template <class T>ostream &operator<<(std::ostream &o, const vector<T> &v)
{
	rep(i, v.size()) {
		o << (i > 0 ? " " : "") << v[i];
	}
	return o;
}



int main() {
	int n, x;
	cin >> n >> x;
	vi v(n , 0);
	for (int i = 0; i < n; i++) {
		cin >> v[i];
	}
	v.push_back(x);
	sort(all(v));
	for (int i = 1; i < v.size(); i++) {
		v[i] -= v[0];
	}
	int r;
	for (int i = 2; i < v.size(); i++) {
		int a = v[i];
		int b = v[i - 1];
		r = a % b;
		while (r != 0) {
			a = b;
			b = r;
			r = a%b;
		}
		v[i] = b;
	}
	cout << v[v.size() - 1] << endl;;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define MAX 10005
#define MOD 1000000007
using namespace std;

typedef long long ll;

ll dp[MAX][105][2];
int d, lim;
vector<int> digit;

ll solve(int pos, int rem, int isSmall)
{
    if(pos == lim){
        if(!rem)    return 1;
        return 0;
    }

    if(dp[pos][rem][isSmall] != -1){
        return dp[pos][rem][isSmall];
    }

    int last = (isSmall) ? 9 : digit[pos];

    ll ret = 0;
    for(int i = 0; i <= last; i++){
        ret += solve(pos + 1, (rem + i) % d, isSmall | i < digit[pos]) % MOD;
    }

    dp[pos][rem][isSmall] = ret % MOD;

    return dp[pos][rem][isSmall] % MOD;
}

int main()
{
    char str[MAX];

    scanf("%s", str);
    scanf("%d", &d);

    int len = strlen(str);

    for(int i = 0; i < len; i++){
        digit.push_back(str[i] - 48);
    }
    lim = digit.size();

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

    ll result = solve(0, 0, 0);
    result--;
    if(result < 0)
        result += MOD;
    result = result % MOD;
    printf("%lld\n", result);

    return 0;
}


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

int main(){
    int r, g, b, sum;
    cin >> r >> g >> b;
    sum = 100 * r + 10 * g + b;
    if (sum%4 == 0) cout << "YES" << endl;
    else cout << "NO" << endl;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
 
using namespace std;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<VVI> VVVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef vector<PII> VPII;
typedef long long LL;
typedef priority_queue<int> PQ_DESC;
typedef priority_queue<int, vector<int>, greater<int>> PQ_ASC;
typedef priority_queue<PII> PQ_DESC_PII;
typedef priority_queue<PII, vector<PII>, greater<PII>> PQ_ASC_PII;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;
typedef vector<VVLL> VVVLL;

#define SORT_ASC(c) sort((c).begin(), (c).end())
#define SORT_DESC(c) sort((c).begin(), (c).end(), greater<typeof((c).begin())>())
 
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define FORL(i,a,b) for(LL i=(a);i<(b);++i)
#define REPL(i,n)  FORL(i,0,n)
#define SIZE(a) int((a).size())
#define ALL(a) (a).begin(),(a).end()
 
const double EPS = 1e-10;
const double PI  = acos(-1.0);
 
template <typename Iterator>
inline bool next_combination(const Iterator first, Iterator k, const Iterator last)
{
   /* Credits: Thomas Draper */
   if ((first == last) || (first == k) || (last == k))
      return false;
   Iterator itr1 = first;
   Iterator itr2 = last;
   ++itr1;
   if (last == itr1)
      return false;
   itr1 = last;
   --itr1;
   itr1 = k;
   --itr2;
   while (first != itr1)
   {
      if (*--itr1 < *itr2)
      {
         Iterator j = k;
         while (!(*itr1 < *j)) ++j;
         iter_swap(itr1,j);
         ++itr1;
         ++j;
         itr2 = k;
         rotate(itr1,j,last);
         while (last != j)
         {
            ++j;
            ++itr2;
         }
         rotate(k,itr2,last);
         return true;
      }
   }
   rotate(first,k,last);
   return false;
}

inline double get_time_sec(void){
    return static_cast<double>(chrono::duration_cast<chrono::nanoseconds>(chrono::steady_clock::now().time_since_epoch()).count())/1000000000;
}

template<typename T>
T gcd(T a, T b) {
    if(a > b) swap(a, b);
    if(a == 0) return b;
    else return gcd(b%a, a);
}

template<typename T>
T lcm(T a, T b) {
    return (a / gcd(a, b)) * b;
}

template<typename T>
map<T, T> prime_list(T n) {
    map<T, T> ret;
    for(T i = 2; i*i <= n; i++) {
        if(n % i == 0) {
            ret[i] = 0;
            while(n % i == 0) {
                n /= i;
                ret[i]++;
            }
        }
    }
    if(n != 1) ret[n]++;
    return ret;
}

#define MOD 1000000007

LL mypow(LL a, LL n) {
    if(n == 1) return a % MOD;
    if(n % 2 == 1) return (a * mypow(a, n-1)) % MOD;
    LL t = mypow(a, n/2);
    return (t * t) % MOD; 
}

int main(void) {
    int n;
    cin >> n;
    unsigned long long ans = 1;
    REP(i, n) {
        unsigned long long tmp;
        cin >> tmp;
        ans = lcm(ans, tmp);
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;
typedef pair<ll,ll> pll;
const ll mod=1e9+7;
//const ll mod=998244353;
const ll inf=1LL<<61;

int main() {
  ll n;
  cin >> n;
  mat a(n,vec(n));
  for(ll i=0;i<n;i++) {
    for(ll j=0;j<n;j++) {
      cin >> a[i][j];
    }
  }
  ll f=0;
  ll ans=0;
  for(ll i=0;i<n;i++) {
    for(ll j=0;j<n;j++) {
      ll tf=1;
      for(ll k=0;k<n;k++) {
        if(k==i||k==j) continue;
        if(a[i][j]>a[i][k]+a[k][j]) f=1;
        if(a[i][j]==a[i][k]+a[k][j]) tf=0;
      }
      if(tf) ans+=a[i][j];
    }
  }
  ans/=2;
  if(f) {
    ans=-1;
  }
  cout << ans << endl;
}

Measured memory_bytes: 4356