akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
/*
#define mod 7
typedef long long ll;

ll fact[1000006], inv[1000006];

ll fp(ll base, ll exp)
{
    if (exp == 0)
        return 1;
    ll ans = fp(base, exp / 2);
    ans = (ans * ans) % mod;
    if (exp % 2 != 0)
        ans = (ans * (base % mod)) % mod;
    return ans;
}

void calcFacAndInv(ll n)
{
    fact[0] = inv[0] = 1;
    for (ll i = 1; i <= n; i++)
    {
        fact[i] = (i * fact[i - 1]) % mod;
        inv[i] = fp(fact[i], mod - 2);
    }
}

ll ncr(ll n, ll r)
{
    return ((fact[n] * inv[r]) % mod * inv[n - r]) % mod;
}

ll npr(ll n, ll r)
{
    return (fact[n] * inv[n - r]) % mod;
}

int main()
{
    calcFacAndInv(100000);
     cout<<inv[3];
    return 0;
}
*/


// GCD

int gcd(long long a,long long b)
{
    if (b==0)
        return a;
    return gcd (b,a%b);
}
//prime factoriation
/*
set<int >s;
bool prime factorization (int x)
{
    for (int j=2; j*j<=x; ++j)
    {
        while (x%j==0)
        {
            s.insert(j);
            x/=j;
        }
    }
    if (x>1)
    {
        s.insert(x);
    }
    if (s.size()==2)
        return true ;
    else
        return false ;
}

#define ll long long
int a,b,q,p,n;
int countDivisorss(int x,int y)
{
    ll cnt = 0;
    for (int i = min(x,y); i <= sqrt(n); i++)
    {
        if (x % i == 0&&y%i==0)
        {
            if (x / i == i||y / i == i)
                cnt++;

            else
                cnt = cnt + 2;
        }
    }
    return cnt;
}
int countDivisors(int x)
{
    ll cnt = 0;
    int tmp=n;
    if (n-x>10000000)  tmp=sqrt(n);
    for (int i = x; i <= tmp; i++)
    {
        if (x % i == 0)
        {
         if (x/i==i)
            cnt++;
         else
            cnt = cnt + 2;
        }
    }
    return cnt;
}
*/

/*
        int s =n/2,e=n-1;
        while (s<=e&&e<=n-1)
        {
            int mid =s+e/2;

            if (arr[mid]==arr[n/2])
            {
                s=mid;
                num +=mid -s;
            }
            else
                e=mid-1;
        }
        */




const int N = 1e5 + 5;

vector<int> adj[N];
bool visited[N];
int nodesNum;
void dfs(int node)
{
   if (visited[node])
       return;
   visited[node] = true;
   for (int child: adj[node])
       dfs(child);
}

//fast power
/*
#define mod 1000000007
long long fp(long long  base, long long exp)
{
    if (exp == 0)
        return 1;
    long long  ans = fp(base, exp / 2);
    ans = (ans * ans);
    if (exp % 2 != 0)
        ans = (ans * (base )) ;
    return ans;
}
*/

int main()
{
   long long n,m;
   cin>>n>>m;
   long long  a=(n*(n-1))/(2);
   long long  b=(m*(m-1))/(2);
   long long      ans =(a+b);
    cout<<ans;
   return 0;
}




Measured memory_bytes: 2560
#include <iostream>

int main() {
  int n; std::cin >> n;
  bool ok = false;
  for (int i = 1; i <= 9; ++i) {
    if (n%i != 0) continue;
    int a = n/i;
    if (1 <= a && a <= 9) ok = true;
  }
  if (ok) std::cout << "Yes" << std::endl;
  else std::cout << "No" << std::endl;
  
  return 0;
}

Measured memory_bytes: 3612
N, M = list(map(int, input().split()))
a = [int(input()) for i in range(M)]
a.append(-1)
dp = [0, 1]
a_flag = 0

for i in range(1, N + 1):
    if i == a[a_flag]:
        dp.append(0)
        while a[a_flag] == i:
            a_flag += 1
        continue
    dp.append(dp[i - 1] + dp[i])

print(dp[N + 1] % 1000000007)


Measured memory_bytes: 460020
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N, a,b,sum=30;
  cin >> N;
  
  for(int i=0;i<N;i++){
    cin>> a;
    b=0;
    while(a%2==0){
      a/=2;
      b++;
    }
    if(b<sum)
      sum=b;
    
  }
  cout << sum << endl;
}

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

using namespace std;

typedef long long ll;

int main(){
	int N;
	cin >> N;
	std::vector<int> a(N);
	int alice = 0;
	int bob = 0;

	for (int i = 0; i < N; i++)
	{
		cin >> a[i];
	}
	sort(a.begin(),a.end(),greater<int>());
	for (int i = 0; i < N; i++)
	{
		if (i%2 == 0)
			alice += a[i];
		else bob += a[i];
	}

	cout << alice - bob << endl;

	return 0;
}

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


//namespace _5_A

class Program
{
    static void Main(string[] args)
    {
        while (true)
        {
            //???????????????3????????????????????????????????????
            string readData = Console.ReadLine();

            //???????????¨??????????????????????????????H,W???????????????????????????
            string[] readDataValues = readData.Split(' ');
            int H = int.Parse(readDataValues[0]);
            int W = int.Parse(readDataValues[1]);

            //H,W??¨??????0?????´???????????????
            if (H == 0 && W == 0)
            {
                break;
            }

            for (int num = 1; num <= H; ++num)
            {

                for (int digital = 1; digital < W; ++digital)
                {
                    Console.Write("#");
                }

                Console.WriteLine("#");
            }
            Console.WriteLine();
        }
    }
}

Measured memory_bytes: 8884
#include <bits/stdc++.h>
#define endl '\n'
#define fast ios::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define zy -2147382637
#define bql 2147483647
#define ll long long
#define ull unsigned long long
#define ld long double
#define il inline
#define sz(x) x.size()
#define maxn 100010
#define rp(i, l, r) for (int i = l; i <= r; i++)
#define rb(i, r, l) for (int i = r; i >= l; i--)
#define fi first
#define se second
#define pb push_back
#define mp make_pair

using namespace std;
ll max(ll a,ll b){if(a>b)return a;else return b;}
ll min(ll a,ll b){if(a<b)return a;else return b;}
ll lowbit(ll x){return x&(-x);}
ll prime(ll x){
   if(x<=1)return false;
   for(int i=2;i<=int(sqrt(x));i++){
	   if(x%i==0)return false;
   }return true;
}
bool cmp(ll a,ll b){return a>b;}
ll gcd(ll a,ll b){ll r;while(b>0){r=a%b;a=b;b=r;}return a;}
ll powmod(ll a,ll b,ll mod) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
inline ll read() {
	char c = getchar(); ll w = 1; ll x = 0;
	while (!isdigit(c))
		(c == '-') && (w = -w), c = getchar();
	while (isdigit(c))
		x = (x << 1) + (x << 3) + (c ^ '0'), c = getchar();
	x *= w;
}
void fl(){
	freopen(".in","r",stdin);
	freopen(".out","w",stdout);
}
const int dx[8] = {-1, 1, 0, 0, -1, 1, -1, 1},
		  dy[8] = {0, 0, -1, 1, -1, -1, 1, 1};
int main(){
	fast;
	string s;
	cin>>s;
	ll sum=0;
	ll i=0,j=s.size()-1;
	for(int i=0;i<s.size()/2;i++){
		if(s[i]!=s[s.size()-1-i])sum++;
	}
	cout<<sum<<endl;
}/*『你强归你强，我永不示弱』*/




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

typedef long long int ll;
typedef long double ld;
#define fastio ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define MOD (ll)(1e9 + 7)
#define vi vector<int>
#define vii vector<vector<int> >
#define vl vector<ll>
#define vll vector<vector<ll> >
#define vc(T, nm) vector<T> nm
#define pb push_back
#define popb pop_back
#define si set<int>
#define sl set<ll>
#define F first
#define S second
#define pii pair<int, int>
#define mp make_pair
#define ins insert
#define ers erase
#define endl "\n"
#define mul(a, b) ((a % MOD) * (b % MOD)) % MOD
#define adr(a, b) ((a % MOD) + (b % MOD)) % MOD
#define FORA(x, s, e, inc) for(ll x = s; x != e; x += inc)
#define ROFA(x, s, e, inc) for(ll x = s; x != e; x -= inc)
#define FOR(x, s, e) FORA(x, s, e, 1)
#define ROF(x, s, e) ROFA(x, s, e, 1)
#define loop(x, n) FOR(x, 0, n)
#define rd1(t, a) 					t a; cin >> a;
#define rd2(t, a, b) 				rd1(t, a); rd1(t, b); 
#define rd3(t, a, b, c) 			rd2(t, a, b); rd1(t, c);
#define rd4(t, a, b, c, d) 			rd3(t, a, b, c); rd1(t, d);
#define rd5(t, a, b, c, d, e) 		rd4(t, a, b, c, d); rd1(t, e);
#define rd6(t, a, b, c, d, e, f) 	rd5(t, a, b, c, d, e); rd1(t, f);
#define rdA(t, nm, len)				t nm[len]; loop(i, len) {cin >> nm[i];}
#ifdef DEBUG
	#define deb(v) cout << endl << #v << ": " << v << endl
	#define db1(v) cout << endl << #v << ": " << "[ "; for(auto x: v) {cout << x << " ";}; cout << "]" << endl;
	#define db2(v) cout << endl << #v << ": " << endl; for(auto r: v) {cout << "[ "; for(auto x: r) {cout << x << " ";}; cout << "]" << endl;};
	#define dbl cout << "-------------------------------" << endl
#else
	#define deb(v)
	#define db1(v)
	#define db2(v)
	#define dbl
#endif

ll cmp(string s, string t) {
    int ct = 0;
    for(int i = 0; i < s.size(); i++) {
        if(s[i] != t[i])
            ct++;
    }
    
    return ct;
}

void solve() {
    ll ans = INT_MAX;
    rd2(string, s, t);
    ll n = s.size(), m = t.size();
    int l = 0, r = m - 1;
    
    while(r < n) {
        string curr = s.substr(l, r - l + 1);
        ll avn = cmp(curr, t);
        ans = min(ans, avn);
        
        l++;
        r++;
    }
    
    cout << ans;
}


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


	return 0;
}


Measured memory_bytes: 3676
#include <iostream>
#include <sstream>
#include <string>
#include <cmath>
#include <climits>
#include <cstdio>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <functional>
#include <numeric>
#include <iomanip>


using namespace std;
typedef unsigned int uint;
typedef long long ll;
typedef unsigned long long ull;

#define REP(i,n) for(int i = 0; i < (int)(n); ++i)
#define FOR(i,a,b) for(int i = (a); i < (int)(b); ++i)
#define ALL(c) (c).begin(), (c).end()
#define SIZE(v) ((int)v.size())

#define pb push_back
#define mp make_pair
#define mt make_tuple

int main(void)
{
    cin.sync_with_stdio(false);
    ll N, A, B;
    cin >> N >> A >> B;
    vector<ll> Xs(N);
    REP(n,N) {
        cin >> Xs[n];
    }

    ll pos = 0;
    ll ans = 0;
    REP(n,N) {
        if (n != 0) {
            ans += min((Xs[n] - pos) * A, B);
        }
        pos = Xs[n];
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 1152
#include <bits/stdc++.h>
#define ll long long
#define MOD 1000000007
using namespace std;
ll n,w;
ll A[102][2];
ll dp[102][1000004];
ll solve(ll i,ll d){
    if(d < 0){
        return INT_MIN;
    }
    if(i >= n || d == 0){
        return 0;
    }
    if(dp[i][d] != -1){
            return dp[i][d];
    }
    
    ll a1 = A[i][1]+solve(i+1,d - A[i][0]);
    ll a2 = solve(i+1,d);
    return dp[i][d] = max(a1,a2);
}
int main(){
    memset(dp,-1,sizeof dp);
    cin>>n>>w;
    for(ll i = 0; i < n; i++){
        cin>>A[i][0]>>A[i][1];
    }

    cout<<solve(0,w);
    return 0;
}




//freopen("input.in","r",stdin);
//freopen("output.out","w",stdout);
//ios::sync_with_stdio(0);cin.tie(0);


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

using namespace std;

int main(){
    int n;
    int k;
    cin >> n;
    cin >> k;
    vector<int> x(n);
    for(int i = 0; i < n; i++){
        cin >> x[i];
    }
    int result = 0;
    for(int i = 0; i < n; i++){
        result += min(x[i], k - x[i]) * 2;
    }
    cout << result << endl;
}

Measured memory_bytes: 256
from collections import deque
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**6)

N, Q = map(int, input().split())

g = [[] for _ in range(N+1)]
for i in range(N-1):
    a, b = map(int, input().split())
    g[a].append(b)
    g[b].append(a)

cnt = [0] * (N+1)
for i in range(Q):
    p, x = map(int, input().split())
    cnt[p] += x

def bfs(): 
    q = deque()
    q.append((1, 0))
    while q:
        v, p = q.popleft()
        cnt[v] += cnt[p]
        for nv in g[v]:
            if nv == p:
                continue
            q.append((nv, v))
    ret = ' '.join(map(str, cnt[1:]))
    return ret

ans = bfs()
print(ans)

Measured memory_bytes: 65636
#include<iostream>
#include<cstdlib>
#include<cstring>
#include<stack>
#include<queue>
#include<algorithm>
#include<vector>
#include<math.h>
#include<bitset>
#include<iomanip>
#include<numeric>
#include<list>
using namespace std;

typedef stack<int> IntStack;
typedef queue<int> IntQueue;

const double pi = 3.141592653589793;


//最大公約数
template<class T> T gcd(T a, T b)
{
	while (true)
	{
		T r;
		if (a%b == 0) return b;
		else
		{
			r = a % b;
			a = b;
			b = r;
		}
	}
}
//最小公倍数
template<class T> T lcm(T a, T b)
{
	return a / gcd(a, b)*b;
}
//文字0~9をint型0~9に変換
int char_to_int(char c)
{
	if (c == '0') return 0;
	if (c == '1') return 1;
	if (c == '2') return 2;
	if (c == '3') return 3;
	if (c == '4') return 4;
	if (c == '5') return 5;
	if (c == '6') return 6;
	if (c == '7') return 7;
	if (c == '8') return 8;
	if (c == '9') return 9;
	else return -1;
}
//int型0~9を文字0~9に変換
char int_to_char(int c) {
	if (c == 0) return '0';
	if (c == 1) return '1';
	if (c == 2) return '2';
	if (c == 3) return '3';
	if (c == 4) return '4';
	if (c == 5) return '5';
	if (c == 6) return '6';
	if (c == 7) return '7';
	if (c == 8) return '8';
	if (c == 9) return '9';
	else return'x';
}
//a^b mod MODを計算
long long int ModPower(long long int a, long long int b, long long int MOD)
{
	if (b == 0) return 1;
	else if (b % 2 == 0)
	{
		long long int d = ModPower(a, b / 2, MOD);
		return (d*d) % MOD;
	}
	else
	{
		return (a*ModPower(a, b - 1, MOD)) % MOD;
	}
}
//nCr mod MODを計算
long long int ModCombi(long long int n, long long int r, long long int MOD)
{
	if (n == 0 || r == 0) return 1;

	long long int Kn = 1, Kr = 1, Knr = 1;

	long long int temp = 1;
	for (long long int i = 1; i <= n; i++)
	{
		temp *= i;
		temp %= MOD;
		if (i == n) Kn = temp;
		if (i == r) Kr = temp;
		if (i == n - r) Knr = temp;
	}

	long long int x = ModPower(Kr, MOD - 2, MOD);
	long long int y = ModPower(Knr, MOD - 2, MOD);

	long long int ans;
	ans = Kn * x;
	ans %= MOD;
	ans *= y;
	ans %= MOD;

	return ans;
}
//int型10進数をord桁のstring型2進数に変換する
string binary(int x, int ord)
{
	int y;
	string ans = "";
	for (int i = 0; i < ord; i++)
	{
		y = x / (int)pow(2, ord - 1 - i);
		y %= 2;
		if (y == 0) ans += "0";
		else ans += "1";
	}

	return ans;
}
//ord桁のstring型2進数をint型10進数に変換する
int rep_binary(string x, int ord)
{
	int res = 0;
	for (int i = 0; i < ord; i++)
	{
		if (x[i] == '1') res += (int)pow(2, ord - 1 - i);
	}
	return res;
}
//xとyのビットごとの排他的論理和
template<class T> T XOR(T x, T y)
{
	T n = 0;
	while (max(x, y) > pow(2, n)) n++;
	T ans=0;
	for (int i = 0; i <= n; i++)
	{
		T x1 = (x % (T)pow(2, i + 1)) / (T)pow(2, i);
		T y1 = (y % (T)pow(2, i + 1)) / (T)pow(2, i);
		if (x1 != y1) ans += (T)pow(2, i);
	}
	return ans;
}

/*ここまでテンプレ*//*ここまでテンプレ*//*ここまでテンプレ*//*ここまでテンプレ*/


int main()
{
	string S, T, U;
	int A, B;
	cin >> S >> T >> A >> B >> U;
	if (S == U) A--;
	else B--;
	cout << A << " " << B << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef set<int> si;
typedef pair<int,int> pii;
#define rep(i,a,b) for(int i=(a); i<(b); ++i)
#define per(i,a,b) for(int i=(b)-1; i>=(a); --i)
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define F first
#define S second
const int INF = 987654321;
const ll MOD = 1000000007;

int n;
vi c;
set<int> r[200050];

int main(void) {
  ios_base::sync_with_stdio(false); 
  cin.tie(NULL); 
  cout.tie(NULL);
  //freopen("in.txt", "r", stdin);
  cin >> n;
  c.resize(n);
  rep(i,0,n) {
    cin >> c[i];
  }

  ll dp[200050];
  rep(i,0,200050) dp[i] = 0;

  per(i,0,n) {
    r[c[i]].insert(i);
    auto it = r[c[i]].upper_bound(i);
    if(it == r[c[i]].end() || *it == i+1) {
      dp[i] = dp[i+1];
    } else {
      int j = *it;
      dp[i] += dp[j]+1;
      dp[i] += dp[i+1];
      dp[i] %= MOD;
    }
  }

  cout << (dp[0]+1)%MOD << endl;
  return 0;
}

Measured memory_bytes: 21376
#include <bits/stdc++.h>
#define rep(i, a, b) for(int i = int(a); i < int(b); i++)
#define rer(i, a, b) for(int i = int(a) - 1; i >= int(b); i--)
#define sz(v) (int)(v).size()
#define pb push_back
#define sc second
#define fr first
#define sor(v) sort(v.begin(),v.end())
#define rev(s) reverse(s.begin(),s.end())
#define lb(vec,a) lower_bound(vec.begin(),vec.end(),a)
#define ub(vec,a) upper_bound(vec.begin(),vec.end(),a)
#define uniq(vec) vec.erase(unique(vec.begin(),vec.end()),vec.end())
using namespace std;
typedef long long int ll;
typedef pair <int, int> P;
const ll INF=1e15;
int N;
ll a[16][16];
ll dp[1<<16];
void dfs(int x){
    ll ans=0;
    rep(i,0,N){
        rep(j,i+1,N){
            if(x&(1<<i)&&x&(1<<j)) ans+=a[i][j];
        }
    }
    rep(i,1,x){
        if((i|x)==x){
            if(dp[i]==INF) dfs(i);
            if(dp[x-i]==INF) dfs(x-i);
            ans=max(dp[i]+dp[x-i],ans);
        }
    }
    dp[x]=ans;
}
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cin>>N;
    rep(i,0,N){
        rep(j,0,N){
            cin>>a[i][j];
        }
    }
    fill(dp,dp+(1<<N),INF);
    rep(i,0,N){
        dp[1<<i]=0;
    }
    dfs((1<<N)-1);
    cout <<dp[(1<<N)-1]<<"\n";
}

Measured memory_bytes: 768
import java.util.*;

class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		Map<String,Integer> map = new TreeMap<String,Integer>();
		for (int i = 0; i < N; i++){
			String str = sc.next();
			if (map.containsKey(str)){
				map.put(str, map.get(str) + 1);
			}else{
				map.put(str,0);
			}
		}
      	List<Integer> hoge = new ArrayList<Integer>();
        int temp = -1;
		for(Map.Entry<String,Integer> entry : map.entrySet()){
			if ( temp < entry.getValue()){
             	temp = entry.getValue();
            }
		}
      	for(Map.Entry<String,Integer> entry : map.entrySet()){
			if ( temp == entry.getValue()){
             	System.out.println(entry.getKey());
            }
		}
	}
}

Measured memory_bytes: 85512
#include<bits/stdc++.h>
using namespace std;
int arr[200005];

int main()
{
   int n,k;
   scanf("%d",&k);
   scanf("%d",&n);
   for(int i=0;i<n;i++){
    scanf("%d",&arr[i]);
   }
   int x=arr[n-1]-arr[0];
   int y=arr[0]+(k-arr[1]);
   x=min(x,y);
   int d=(k-arr[n-1])+arr[n-2];
   int mini=min(x,d);
   for(int i=1;i<n-1;i++){
    int p=(k-arr[i])+arr[i-1];
    int q=arr[i]+(k-arr[i+1]);
    int mini2=min(p,q);
    mini=min(mini,mini2);
   }
   cout<<mini;
}


Measured memory_bytes: 1024
#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<string>
#include<stack>
#include<queue>
#include<vector>
#include<algorithm>
#include<iomanip>
#include<utility>
#include<set>
typedef long long int ll;
using namespace std;
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define REP(i,n) for (int i=0;i<signed(n);i++)
#define EREP(i,n) for (int i=1;i<=(n);i++)
#define ALL(a) (a).begin(),(a).end()
//#define EVEL 1

#ifdef EVEL
#define DEB(X) cout << #X << ":" <<X<<" " ;
#define TF(f) f ? cout<<"true  " : cout<<"false ";
#define END cout<<"\n";
#else
#define DEB(X) {}
#define TF(f) {}
#define END {}
#endif
const int MOD = 1000000007;
const ll INF = 20000000000;
struct edge {int to,cost;};
#define VMAX 51
//typedef std::pair<int,int> P;

    int A,B,C,D;
    int X,Y;
int main(){
    ios_base::sync_with_stdio(false);
    cin>>A>>B>>C>>D;
    X=C-A;Y=D-B;
    REP(i,X)cout<<"R";
    REP(i,Y)cout<<"U";
    cout<<"L";REP(i,Y-1)cout<<"D";
    REP(i,X-1)cout<<"L";cout<<"D";
    cout<<"L";REP(i,Y+1)cout<<"U";
    REP(i,X+1)cout<<"R";cout<<"D";
    cout<<"R";REP(i,Y+1)cout<<"D";
    REP(i,X+1)cout<<"L";cout<<"U";

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

Measured memory_bytes: 256
let n = Scanf.scanf " %d" (+) 0
let hs = Array.init n @@ fun _ -> Scanf.scanf " %d" (+) 0
let p = ref @@ hs.(0) - 1
let _ = for i = 1 to n - 1 do if !p > hs.(i) then (print_endline "No"; exit 0); p := hs.(i) - if !p < hs.(i) then 1 else 0 done; print_endline "Yes"

Measured memory_bytes: 5120
package main

import (
	"bufio"
	"fmt"
	"io"
	"math"
	"os"
	"sort"
	"strconv"
)

func main() {
	resolve(parseProblem(os.Stdin))
}

func parseProblem(r io.Reader) (int, []int, *graph) {
	const (
		initialBufSize = 100000
		maxBufSize     = 1000000
	)
	buf := make([]byte, initialBufSize)

	sc := bufio.NewScanner(r)
	sc.Buffer(buf, maxBufSize)
	sc.Split(bufio.ScanWords) // bufio.ScanLines
	n := scanInt(sc)
	nums := make([]int, n)
	for i := 0; i < n; i++ {
		nums[i] = scanInt(sc)
	}
	g := scanGraph(n, n-1, sc)
	return n, nums, g
}

func resolve(n int, nums []int, g *graph) {
	s := status{
		nums:    nums,
		parents: make([]int, n),
		dp:      make([]int, n),
		line:    make([]int, n),
		ans:     make([]int, n),
	}
	for i := 0; i < n; i++ {
		s.line[i] = inf
	}
	s.parents[0] = -1
	s.dfs(0, g)
	for _, v := range s.ans {
		fmt.Println(v)
	}
}

type status struct {
	parents []int
	dp      []int
	line    []int
	nums    []int
	ans     []int
}

func (s *status) dfs(c int, g *graph) {
	idx := lowerBound(len(s.nums), func(i int) bool {
		return s.line[i] >= s.nums[c]
	})
	old := s.line[idx]
	s.line[idx] = s.nums[c]
	s.ans[c] = lowerBound(len(s.nums), func(i int) bool {
		return s.line[i] >= inf
	})
	defer func() {
		s.line[idx] = old
	}()
	for _, t := range g.edges[c].members() {
		if s.parents[c] == t {
			continue
		}
		s.parents[t] = c
		s.dfs(t, g)
	}
}

const (
	inf = math.MaxInt32
)

func changeToMin(v *int, cand int) (updated bool) {
	if *v > cand {
		*v = cand
		updated = true
	}
	return updated
}

func changeToMax(v *int, cand int) (updated bool) {
	if *v < cand {
		*v = cand
		updated = true
	}
	return updated
}

func lowerBound(n int, f func(i int) bool) int {
	return sort.Search(n, f)
}

func upperBoundOfLowSide(n int, f func(i int) bool) int {
	return sort.Search(n, func(i int) bool { return !f(i) }) - 1
}

type graph struct {
	size  int
	edges []nodeSet
}

func newGraph(n int) *graph {
	g := &graph{
		size:  n,
		edges: make([]nodeSet, n),
	}
	for i := 0; i < n; i++ {
		g.edges[i] = newSet()
	}
	return g
}

func scanGraph(n, m int, sc *bufio.Scanner) *graph {
	g := newGraph(n)
	for i := 0; i < m; i++ {
		x, y := scanInt(sc), scanInt(sc)
		// 0-indexed
		x--
		y--
		g.addEdge(x, y)
	}
	return g
}

func (g *graph) addEdge(x, y int) {
	g.edges[x].add(y)
	g.edges[y].add(x)
}

func (g *graph) addDirectedEdge(x, y int) {
	g.edges[x].add(y)
}

func (g *graph) exists(x, y int) bool {
	return g.edges[x].doesContain(y)
}

type nodeSet map[int]none

func newSet() nodeSet {
	return make(map[int]none)
}

func (s nodeSet) add(item int) {
	s[item] = mark
}

func (s nodeSet) doesContain(item int) bool {
	_, ok := s[item]
	return ok
}

func (s nodeSet) size() int {
	return len(s)
}

func (s nodeSet) members() (l []int) {
	for k := range s {
		l = append(l, k)
	}
	return l
}

var mark none

type none struct{}

// snip-scan-funcs
func scanInt(sc *bufio.Scanner) int {
	sc.Scan()
	i, _ := strconv.Atoi(sc.Text())
	return int(i)
}
func scanString(sc *bufio.Scanner) string {
	sc.Scan()
	return sc.Text()
}


Measured memory_bytes: 103716
#include <stdio.h>
#include <algorithm>
#include <string>
#include <vector>
#include <numeric>

const int mod = 1000000007;
int main() {
	int A,B;
	scanf("%d %d", &A, &B);
	char *S = new char[A + B + 2];
	scanf("%s", S);
	bool yes = true;
	for (int i = 0; i < A + B + 1; i++) {
		if (i == A) {
			if (S[i] != '-') {
				yes = false;;
				break;
			}
		}
		else {
			if (S[i] == '-') {
				yes = false;
				break;
			}
		}
	}
	printf(yes ? "Yes" : "No");
}





Measured memory_bytes: 256
import bisect

N, M = map(int, input().split())  # 県数, 市数
birth_list = []  # 県番号, 誕生年のペア
pref_year_list = {}
for i in range(M):
    pi, yi = map(int, input().split())  # 市の県番号, 市の誕生年
    birth_list.append((pi, yi))
    if pi in pref_year_list:
        pref_year_list[pi].append(yi)
    else:
        pref_year_list[pi] = [yi]
for k in pref_year_list.keys():
    pref_year_list[k] = list(sorted(pref_year_list[k]))


for pi, yi in birth_list:
    # 県番号,年から登録順を逆引き
    year_list = pref_year_list[pi]
    i = bisect.bisect(year_list, yi)
    print("%06d%06d" % (pi, i))


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

int main(){
  int N;
  cin >> N;
  vector<int> P(N);
  
  for(int i=0; i<N; i++){
    cin >> P.at(i);
  }
  sort(P.begin(),P.end());
  int median ;
  int ans;
  median = (int)N/2;
  if(P.at(median)==P.at(median-1)){
    cout << "0" << endl;
    return 0;
  }else{
    cout << P.at(median)-P.at(median-1);
  }
}

Measured memory_bytes: 640
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <cmath>
#include <numeric>
#include <iomanip>
#include <stack>
#include <complex>
#include <functional>
#include <tuple>

using namespace std;

#define Rep(i,a,b) for(ll i = a; i < b; ++i)
#define rep(i,b) Rep(i,0,b)
#define allof(a) (a).begin(), (a).end()

#define Yes(q) ((q) ? "Yes" : "No")
#define YES(q) ((q) ? "YES" : "NO")
#define Possible(q) ((q) ? "Possible" : "Impossible")
#define POSSIBLE(q) ((q) ? "POSSIBLE" : "IMPOSSIBLE")

using ll = long long;

constexpr int inf = 1e9 + 7;
constexpr ll infll = 1ll << 60ll;
constexpr ll mod = 1e9 + 7;
// 0~3までは右下左上 4~7までは斜め
constexpr int dx[] = { 1, 0, -1, 0, 1, -1 };
constexpr int dy[] = { 0, 1, 0, -1, 1, 1 };

namespace {
    template<typename T> bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
    template<typename T> bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

    void Cout(long long x, const char* end = "\n") { std::cout << x << end; }
    template <typename T> void Cout(const T& x, const char* end = "\n") { std::cout << x << end; }
    template <typename T> void Cout(const std::vector<T>& x, const char* sep = " ", const char* end = "\n") { for (std::size_t i = 0, sz = x.size(); i < sz; ++i) { std::cout << x[i] << (i == sz - 1 ? end : sep); } }

    // 標準入出力
    struct inp {
        std::size_t szi, szj;
        inp(std::size_t _szi = 1, std::size_t _szj = 1) : szi(_szi), szj(_szj) {}
        template <typename T> operator T () const { T a; std::cin >> a; return a; }
        template <typename T> operator std::vector<T>() const { std::vector<T> a(szi); for (std::size_t i = 0; i < szi; ++i) std::cin >> a[i]; return a; }
        template <typename T> operator std::vector<std::vector<T>>() const {
            std::vector<std::vector<T>> a(szi, std::vector<T>(szj));
            for (std::size_t i = 0; i < szi; ++i) for (std::size_t j = 0; j < szj; ++j) cin >> a[i][j]; return a;
        }
    };
    inp inp1;

    //int score_down[26]; // 満足度の下がりやすさ
    //int score_up[365][26]; // 満足度の増加数
    //int contest[365]; // コンテストのタイプ
    //int last[26];

    int d = 365;

    int CalcScore(vector<int>& score_down, vector<vector<int>>& score_up, vector<int>& contest) {
        int score = 0;
        vector<int> last(26, -1);
        rep(i, d) {
            int type = contest[i] - 1;
            // 満足度の増加
            score += score_up[i][type];
            last[type] = i;
            // 時間による満足度の低下
            rep(j, 26) {
                score -= score_down[j] * (i - last[j]);
            }
        }
        return score;
    }
}

int main() {
    srand((unsigned)time(NULL));

    cin >> d;
    vector<int> score_down = inp(26);
    vector<vector<int>> score_up = inp(d, 26);
    vector<int> contest(d, 1);

    rep(i, d) {
        contest[i] = rand() % 26 + 1;
    }

    Cout(contest, "\n");

    return 0;
}


Measured memory_bytes: 3680
#include <bits/stdc++.h>
using i64 = long long;

int main() {
    constexpr i64 mod = 1000000007;
    int n;
    std::cin >> n;
    std::vector<int> c { 0 };
    for (int i = 1; i <= n; i++) {
        int x;
        std::cin >> x;
        if (!c.empty() && c.back() == x) continue;
        c.push_back(x);
    }
    n = c.size();
    std::vector<i64> dp(n + 10), sum(202020);
    dp[0] = 1;
    for (int i = 1; i < n; i++) {
        int v = c[i];
        dp[i] = (dp[i - 1] + sum[v]) % mod;
        sum[v] = (sum[v] + dp[i - 1]) % mod;
    }
    std::cout << dp[n - 1] << std::endl;

    return 0;
}


Measured memory_bytes: 4468
Scanf.scanf "%d %s" (fun n s ->
    print_endline @@
        if n mod 2 = 0 then (
            let m = n / 2 in
            let rec loop i =
                if i = m then "Yes" else
                    if s.[i] <> s.[i + m] then "No" else loop (i + 1)
            in
            loop 0
        ) else "No"
)

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

int n, q, x, y, t;
int a[100000];

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

	memset(a, 0, sizeof(a));

	for (int i = 0; i < q; i++) {
		cin >> t;

		if (t == 0) {
			cin >> x >> y;
			a[x] += y;
		}
		else if (t == 1) {
			cin >> x >> y;

			int m = 0;
			for (int j = x; j <= y; j++)
				m += a[j];
			
			cout << m << endl;
		}
	}

	return 0;
}


Measured memory_bytes: 3468
n=int(input())
a=[0]*n
for i in range(n):
    a[i]=int(input())

ans=0
for i in range(n):
    pea=a[i]//2
    ans+=pea
    if i+1<n:
        if a[i]%2==1 and a[i+1]>=1:
            a[i+1]-=1
            ans+=1

print(ans)

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

int main(){
  int n,k;
  cin >> n >> k;
  vector<int> a(n);
  for(int i=0;i<n;i++) cin >> a[i];
  
  for(int i=k;i<n;i++){
    if(a[i-k]<a[i]) cout << "Yes" << endl;
    else cout << "No" << endl;
  }
}

Measured memory_bytes: 4048
object Main extends App {
  var get = readLine
  var sum,sum2 = 0
  var white = '0'
  var black = '1'
  for(i <- 0 until get.size){
    if(white != get(i))
    	sum = sum + 1
    if(black != get(i))
    	sum2 = sum2 + 1
    if(white=='0') {
      white='1'
      black='0'
    }
    else {
      black='1'
      white='0'
    }
  }
  println(math.min(sum,sum2))
}

Measured memory_bytes: 29308
n, t = map(int, input().split())
arr = [list(map(int, list(input().split()))) for i in range(n)]
min = -1
for i in range(n):
    if arr[i][1] <= t:
        if min == -1 or arr[i][0] < min:
            min = arr[i][0]
if min == -1:
    print("TLE")
else:
    print(min)


Measured memory_bytes: 3060
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
const long long mod = 1e9 + 7;

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



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

	if (n == m) {
		cout << "Yes" << endl;
	} else {
		cout << "No" << endl;
	}

	
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <chrono>
using namespace std;
using ll = long long;
using ld = long double;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repl(i, n) for (ll i = 0; i < (ll)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define rep2l(i, s, n) for (ll i = (ll)(s); i < (ll)n; i++)

int main() {
    int N, Q;
    cin >> N;
    map<int, int> A;
    ll sum = 0;
    rep(i, N) {
        int a;
        cin >> a;
        if(A.count(a)) {
            A[a]++;
        }
        else {
            A[a] = 1;
        }
        sum += a;
    }
    cin >> Q;
    rep(i, Q) {
        int B, C;
        cin >> B >> C;
        if(!A.count(B)) {
            cout << sum << endl;
            continue;
        }
        if(!A.count(C)) {
            sum = sum+(C-B)*A[B];
            A[C] = A[B];
            A.erase(B);
        }
        if(A.count(C)) {
            sum = sum+(C-B)*A[B];
            A[C] += A[B];
            A.erase(B);
        }
        cout << sum << endl;
    }
}

Measured memory_bytes: 6556
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		String s = sc.next();
		int b = sc.nextInt();
		System.out.println(s.equals("+") ? a + b : a - b);
	}
}


Measured memory_bytes: 21844
import sys
file_input = sys.stdin
n = file_input.readline()

EP = []
l = -1000000001
u = 1000000001
vs_x = set()
h_num = 0

for line in file_input:
  x1, y1, x2, y2 = map(int, line.split())
  if x1 == x2:
    if y1 < y2:
      EP.append((y1, l, x1))
      EP.append((y2, u, x1))
    else:
      EP.append((y1, u, x1))
      EP.append((y2, l, x1))
    vs_x.add(x1)
  else:
    if x1 < x2:
      EP.append((y1, x1, x2))
    else:
      EP.append((y1, x2, x1))
    h_num += 1

class BinaryIndexedTree:
  def __init__(self, n):
    self.data = [0] *(n+1)
    self.num = n

  def switch(self, i, d):
    while  i <= self.num:
      self.data[i] += d
      i += i & -i

  def sum(self, i):
    s = 0
    while  i:
      s += self.data[i]
      i -= i & -i
    return s

  def seg_sum(self, a, b):
    return self.sum(b) - self.sum(a- 1)

import bisect

EP.sort()
BIT = BinaryIndexedTree(len(vs_x))
vs_x = [l] + sorted(vs_x)
d_vs_x = {e:i for i, e in enumerate(vs_x)}

cnt = 0

for p in EP:
  e = p[1]
  if e== l:
    BIT.switch(d_vs_x[p[2]], 1)
  elif e==u:
    BIT.switch(d_vs_x[p[2]], -1)
  else:
    l_x = bisect.bisect_left(vs_x, e)
    r_x = bisect.bisect(vs_x, p[2]) -1
    cnt += BIT.seg_sum(l_x,r_x)
    h_num -= 1
  if h_num ==0:
    break
print(cnt)


#一言：平面操作でユーグリッド空間上の線分交点を求める
#処理の流れ：入力された線分端点をyを基準に昇順にリストに入れる。→順番に取り出す。→下恥ならBSTに挿入。・上端ならBSTから削除。入れたものがx軸と交差したらそこで探索を開始する。
#計算量：O(nlogn+k)（二分木探索の計算量nlogn+交点k）



Measured memory_bytes: 32268
n, m = map(int, input().split())
ab = []
for i in range(n):
    ab.append(list(map(int, input().split())))
cd = []
for j in range(m):
    cd.append(list(map(int, input().split())))
for i in range(n):
    a, b = ab[i]
    min_d = 10**10
    for j in range(m):
        c, d = cd[j]
        if min_d > abs(a - c) + abs(b - d):
            min_d = abs(a - c) + abs(b - d)
            check = j+1
    print(check)


Measured memory_bytes: 39536
#include <algorithm>
#include <bitset>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <cctype>
#include <assert.h>
#include <stdlib.h>
#include <stdio.h>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <limits>
#include <map>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
using namespace std;
using ll=long long;
using ld=long double;
//#define int long long
#define _CRT_SECURE_NO_WARNINGS
#define rep(i, n) for (int i = 0; i < n; i++)
#define _GLIBCXX_DEBUG
#define ALL(x) (x).begin(), (x).end()
const int MOD = 1e9 + 7;
const int INF = 1e18 + 9;
constexpr long double pi = 3.141592653589793238462643383279;
int fact(int i) {
    if (i == 0) return 1;
    return (fact(i - 1)) * i;
}
int gcd(int a, int b) {
    if (b == 0) return a;
    return gcd(b, a % b);
}
int lcm(int a, int b) {
    return a * b / gcd(a, b);
}
int keta(int n) {
    if (n == 0) return 1;
    int count = 0;
    while (n != 0) {
        n /= 10;
        count++;
    }
    return count;
}
int ketasum(int n) {
    int sum = 0;
    while (n != 0) {
        sum += n % 10;
        n /= 10;
    }
    return sum;
}
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;
}
char toSmall(char c) { // 大文字を小文字へ
    return (c + 0x20);
}
char toLarge(char c) { // 小文字を大文字へ
    return (c - 0x20);
}
float myPower(int a, int n) { // aのn乗の計算
    float x = 1;
    while (n > 0) { // 全てのbitが捨てられるまで
        if (n & 1) { // 一番右のbitが１のとき
            x *= a;
        }
        a *= a;
        n >>= 1; // bit全体を右に1つシフトして一番右を捨てる
    }
    return x;
}
bool is_prime(const unsigned n) {
    switch (n) {
    case 0: // fall-through
    case 1: return false;
    case 2: // fall-through
    case 3: return true;
    } // n > 3 が保証された

    if (n % 2 == 0 || n % 3 == 0) return false;
    // n は 2 と 3 のいずれの倍数でもないことが保証された
    // これより n は (6の倍数)-1 か (6の倍数)+1 である
    // 6の倍数前後の数を使って試し割りをする
    for (unsigned i = 5; i * i <= n; i += 6) {
        if (n % i == 0) return false; // (6の倍数)-1
        if (n % (i + 2) == 0) return false; // (6の倍数)+1
    }

    return true;
}
int main(void) {
    int D, N; cin >> D >> N;

    int S = 1; for (int i = 0; i < D; i++) S *= 100;
    if (N <= 99) {
        cout << S * N << endl;
    }
    else {
        cout << S * 101 << endl;
    }
    return 0;
}

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

#define FOR(i,l,r) for(int i = (l);i < (r);i++)
#define PB push_back
#define MP make_pair
#define ALL(x) (x).begin(),(x).end()
typedef long long ll;

string S;
vector<int> v;

int main()
{
	cin >> S;
	FOR(i,0,S.size()){
		if(S [i] == '0'){
			v.PB(0);
		}
		else if(S [i] == '1'){
			v.PB(1);
		}
		else if(v.empty() == false){
			v.pop_back();
		}
	}

	FOR(i,0,v.size()){
		cout << v [i];
	}
	cout << endl;

	return 0;
}


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

const ll MOD = 1000000007;

int main() {
	int n; scanf("%lld", &n);

	int ans = 1;
	for (ll times = 1; times <= n; ++times) {
		ans = (ans * times) % MOD;
	}

	printf("%lld", ans);
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
string s;
main(){
	cin>>s;
	int f=0;
	for(int i=0;i<s.size();i++)
	{
		for(int j=i+1;j<s.size();j++)
		{
			f+=s[i]==s[j];
		}
	}
	cout<<(f?"no":"yes")<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <chrono>
#define watch(x) cout << (#x) << " is " << (x) << endl
#define eps 1e-9

typedef long long ll;

using namespace std;

const int mod = 1e9+7;
const int N = 1e5+5;
//int a[N];

int main()

{
    ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);

    int a, b;

    cin >> a >> b;

    if (b%a) cout << b-a;
    else cout << b+a;

    return 0;
}


Measured memory_bytes: 256
/**********************************************
 * author : deepak nayan
 * file   : e:/Solutions/atcoder/abc136_a.cpp
 * time   : Sat May  2 01:39:08 2020
 * quest  : A - Transfer
 *********************************************/
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
#include <cmath>

using namespace std;

int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  int a, b, c;
  cin >> a >> b >> c;
  cout << max(0, c - (a - b)) << "\n";
  return 0;
}


Measured memory_bytes: 256
import sys
input = sys.stdin.readline
def main():
    S = list(input().rstrip())
    T = list(input().rstrip())
    CNT = 0
    for i in range(len(S)):
        if S[i] != T[i]:
            CNT += 1
    print(CNT)


if __name__ == '__main__':
    main()

Measured memory_bytes: 12488
import itertools
import sys

import numpy as np

sys.setrecursionlimit(10000)
INF = float('inf')

N, K = list(map(int, next(sys.stdin).split()))
XY = np.array([list(map(int, next(sys.stdin).split())) for _ in range(N)])

X = XY[:, 0]
Y = XY[:, 1]
X = X[Y.argsort()]
Y = Y[Y.argsort()]

ans = INF
for xi, xj in itertools.combinations(range(N), r=2):
    L, r = min(X[xi], X[xj]), max(X[xi], X[xj])
    xconds = (L <= X) & (X <= r)

    yi = 0
    yj = 1
    while yj < N:
        if np.sum(xconds[yi:yj + 1]) >= K:
            b, u = min(Y[yi], Y[yj]), max(Y[yi], Y[yj])
            ans = min(ans, (r - L) * (u - b))
            yi += 1
        else:
            yj += 1
        if yi == yj:
            yj += 1
print(ans)


Measured memory_bytes: 21008
#include<stdio.h>
#include<stdlib.h>
int main(){
  int n,a,b,nb,pass;
  nb=0;pass=0;
  scanf("%d %d %d", &n, &a, &b);
  char *buff = (char*)calloc(n+1,sizeof(char));
  scanf("%s", buff);
  for (int i =0; i < n; ++i){
	  if(buff[i] == 'a'){
		  if(pass < a+b){
			  puts("Yes");
			  pass++;
		  }else
			  puts("No");
	  }else if(buff[i] == 'b'){
		  ++nb;
		  if(pass < a+b && nb <= b){
			  puts("Yes");
			  pass++;
		  }else
			  puts("No");
	  }else{
		  puts("No");
	  }
  }
  free(buff);
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;cin>>n;
  int s[n],sum=0;
  for(int i=0;i<n;i++){cin>>s[i];sum+=s[i];}
  sort(s,s+n);
  for(int i=0;i<n;i++){
    if(sum%10!=0)break;
    else if(s[i]%10!=0)sum-=s[i];
  }
  cout<<(sum%10==0?0:sum);
}
            

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <utility>
#include <queue>
#include <string>
#include <set>
#include <bitset>
#include <unordered_map>
#include <cmath>

using namespace std;
using ll = long long;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;
template <class T>
using Vvec = vector<vector<T> >;

template <class T>
void debug(T& v)
{
    for(auto& x: v) cout << x << " ";
    cout << endl;
}

void reset(vector<int>& v){
    for(auto& x: v) x = 0;
}

int main()
{
    int N, M;
    cin >> N >> M;
    Vvec<int> A(N, vector<int>(M));
    for(auto& v: A){
        for(auto& x: v){
            cin >> x; x--;
        }
    }

    int left = 0, right = N;
    vector<int> num(M);
    vector<int> index(N);
    vector<int> closed(M);
    while(right - left > 1){
        int mid = (left + right) / 2;
        bool ok;
        bool loop = true;
        reset(index);
        reset(closed);

        while(loop){
            ok = true;
            reset(num);
            for(int i=0; i<N; i++){
                num[A[i][index[i]]]++;
            }
            for(int i=0; i<M; i++){
                if(num[i] > mid){
                    ok = false;
                    closed[i] = true;
                }
            }
            if(ok) loop = false;
            for(int i=0; i<N; i++){
                while(index[i] < M && closed[A[i][index[i]]]) index[i]++;
                if(index[i] >= M) loop = false;
            }
        }

        if(ok) right = mid;
        else left = mid;
    }

    cout << right << endl;
}

Measured memory_bytes: 640
#include <iostream>
#include <vector>
#include <string>
#include <set>
#include <algorithm>
#define rep(i, a, b) for(int i = a; i < b; i++)
using namespace std;

int main() {
  string s, t;
  cin >> s >> t;
  if(s[0] == t[2] && s[1] == t[1] && s[2] == t[0]) cout << "YES\n";
  else cout << "NO\n";
}

Measured memory_bytes: 3620
import sys
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
read = sys.stdin.buffer.read
sys.setrecursionlimit(10 ** 7)

K = int(input())

import math
answer = 0
for i in range(1, K+1):
    for j in range(1, K+1):
        for k in range(1, K+1):
            gcd = math.gcd(math.gcd(i, j), k)
            answer += gcd

print(answer)

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

#define debug(x) cerr << #x << ": " << x << endl
#define debugArray(x, n)                                                       \
    for(long long hoge = 0; (hoge) < (n); ++(hoge))                            \
    cerr << #x << "[" << hoge << "]: " << x[hoge] << endl
using namespace std;

using ll = long long;
using ull = unsigned long long;
const ll INF = LLONG_MAX / 2;
const ll MOD = 1e9 + 7;

signed main() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    ll N, K;
    cin >> N >> K;
    ll A[N], F[N];
    for(int i = 0; i < N; i++) {
        cin >> A[i];
    }
    sort(A, A + N);
    for(int i = 0; i < N; i++) {
        cin >> F[i];
    }
    sort(F, F + N);
    ll low = -1, high = INF;
    while(high - low > 1) {
        ll mid = (high + low) / 2;
        ll k = K;
        bool isok = true;
        for(int i = 0; i < N; i++) {
            if(A[i] * F[N - i - 1] <= mid) {
                continue;
            }
            ll a = mid / F[N - i - 1];
            ll sub = A[i] - a;
            if(sub > k) {
                isok = false;
                break;
            }
            k -= sub;
        }
        if(isok) {
            high = mid;
        } else {
            low = mid;
        }
    }
    cout << high << endl;
    return 0;
}

Measured memory_bytes: 3328
H,W = map(int,input().split())
a = [input() for i in range(H)]

dp = [[0]*(W+1) for i in range(H+1)]
mod = 10**9+7

for i in range(1,H+1):
    for j in range(1,W+1):
        if a[i-1][j-1] == '.':
            dp[i][j] = (dp[i-1][j] + dp[i][j-1])%mod
        else:
            dp[i][j] = 0
            
        if i == 1 and j == 1:
            dp[i][j] = 1
            
print(dp[-1][-1])

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

#define vi vector<int>
#define vl vector<long>
#define vvi vector<vector<int>>
#define vvl vector<vector<long>>
#define pint pair<int, int>
#define plong pair<long, long>

struct UnionFind {
    vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2

    UnionFind(int N) : par(N) { //最初は全てが根であるとして初期化
        for(int i = 0; i < N; i++) par[i] = i;
    }

    int root(int x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
    if (par[x] == x) return x;
        return par[x] = root(par[x]);
    }

    void unite(int x, int y) { // xとyの木を併合
        int rx = root(x); //xの根をrx
        int ry = root(y); //yの根をry
        if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま
        par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
    }

    bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }
};

int main() {
    int N, M;
    cin>>N>>M;
    vi p(N);
    vector<pint> pair(M);
    REP(i, 0, N){
        int a;
        cin >> a;
        a--;
        p[i] = a;
    }
    REP(i, 0, M){
        int x, y;
        cin >> x >> y;
        x--; y--;
        pair[i] = {x, y};
    }
    UnionFind group(N);
    REP(i, 0, M){
        int p = pair[i].first, q = pair[i].second;
        group.unite(p, q);
    }
    int count = 0;
    REP(i, 0, N){
        if(group.same(i, p[i])) count++;
    }
    cout << count << endl;
}

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

int main() {
    int64_t k, a, b;
    cin >> k >> a >> b;
    int64_t ans = 0;
    if (b - a <= 1) {
        ans = k + 1;
    } else {
        if (k <= a - 1) {
            ans = k + 1;
        } else {
            ans = a;
            int64_t times = (k - a + 1) / 2;
            ans += (b - a) * times;
            if ((k - a + 1) % 2 == 1) {
                ans++;
            }
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <bitset>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <complex>
#include <deque>
#include <valarray>
#include <unordered_map>
#include <unordered_set>
#include <array>
#include <cassert>
#include <cmath>
#include <functional>
#include <iomanip>
#include <chrono>
#include <random>
#include <numeric>
using namespace std;
using ll = long long;
using ld = long double;
using str = string;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<char> vc;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<vs> vvs;
typedef vector<vc> vvc;
typedef vector<vb> vvb;
using P = pair<ll,ll>;
#define REP(i, n) for (ll i = 0; i < (int)(n); i++)
#define RREP(i, n) for (ll i = (int)(n)-1; i > -1 ; i--)
#define IN(T, x) T x;cin >> x;
#define AIN(T, a, n) vector<T> a(n);REP(i, n){cin >> a[i];}
#define A2IN(T1, a, T2, b, n) vector<T1> a(n);vector<T2> b(n);REP(i, n){cin >> a[i] >> b[i];}
#define ALL(a) (a).begin(),(a).end()
#define SORT(a) sort(ALL(a))
#define RSORT(a) SORT(a);reverse(ALL(a))
#define pb push_back
#define mp make_pair
#define PF first
#define PS second
template<class T>bool chmax(T &a,const T &b){if(a<b){a=b;return 1;}return 0;}
template<class T>bool chmin(T &a,const T &b){if(b<a){a=b;return 1;}return 0;}
template<typename A, size_t N, typename T>void Fill(A (&array)[N], const T &val){fill( (T*)array, (T*)(array+N), val );}
#define OUT(x) cout << x << endl;
#define OUTD(x) cout << fixed << x << endl;
#define BOUT(b) if(b){OUT("Yes");}else{OUT("No");}
const ll MOD = 1000000007;
const ll INF = 10e9;
#define PI 3.14159265369;
ll dx[4] = {1,-1,0,0};
ll dy[4] = {0,0,1,-1};
ll ddx[8] = {1,1,1,-1,-1,-1,0,0};
ll ddy[8] = {0,1,-1,0,1,-1,1,-1};

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  IN(ll,A);
  IN(ll,B);
  IN(ll,C);
  IN(ll,D);
  ll GCD = max(C,D);
  ll GCD2 = min(C,D);
  while(GCD2 != 0){
    ll G = GCD % GCD2;
    GCD = GCD2;
    GCD2 = G;
  }
  GCD = (C*D)/GCD;
  A--;
  ll A2 = A/C + A/D - A/GCD;
  ll B2 = B/C + B/D - B/GCD;
  A2 = A - A2;
  B2 = B - B2;
  OUT(B2 - A2);
}

Measured memory_bytes: 256