akhauriyash/Code-Regression huggingface dataset:
#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 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(n) begin(n), end(n)
using ll = long long;
using namespace std;

int main(){
	int n, k, q;
	cin >> n >> k >> q;
	vector<int> t(n, 0);
	rep(i, q){
		int in;
		cin >> in;
		in--;
		t.at(in)++;
	}

	rep(i, n){
		string ans;
		if(k - q + t.at(i) > 0) ans = "Yes";
		else ans = "No";
		cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 1024
import itertools

N, M = map(int, input().split())
patterns = list(itertools.permutations(range(2, N+1)))
path = [[0]*(N+1) for _ in range(N+1)]
for _ in range(M):
    a, b = map(int, input().split())
    path[a][b] = 1
    path[b][a] = 1

ans = 0
for pattern in patterns:
    p = 1
    ok = True
    for x in pattern:
        if path[p][x] == 0:
            ok = False
            break
        p = x
    if ok:
        ans += 1
print(ans)


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

using namespace std;
using ll = long long;

const ll mod = 1e9 + 7;

int h, w;
vector<vector<int>> arr, dp;

int main(){
    cin>>h>>w;
    arr.resize(h+1, vector<int>(w+1)), dp.resize(h+1, vector<int>(w+1));
    dp[1][1] = 1;
    string tmp;
    for(int i = 1; i <= h; i++){
        cin>>tmp;
        for(int j = 0; j < w; j++){
            if(tmp[j] == '.'){
                arr[i][j+1] = 0;
            }else{
                arr[i][j+1] = 1;
            }
        }
    }
    // for(int i = 1; i <= h; i++){
    //     for(int j = 1; j <= w; j++){
    //         cout<<arr[i][j]<<" ";
    //     }
    //     cout<<endl;
    // }
    for(int i = 1; i <= h; i++){
        for(int j = 1; j <= w; j++){
            if(arr[i][j] || (i == 1 && j == 1)) continue;
            dp[i][j] = ( (ll) dp[i-1][j] + dp[i][j-1]) % mod;
        }
    }
    int res = dp[h][w];
    cout<<res<<endl;
    return 0;
}

Measured memory_bytes: 8192
N, M = map(int, input().split())

pref = []
for i in range(M):
    pp, yy = map(int, input().split())
    pref.append((yy, pp, i))

pref.sort(key=lambda tup:tup[0])

count = [0]*(N+1)
names = ['']*(M+1)
for i in range(M):
    yy, pp, id = pref[i]
    count[pp] += 1
    names[id] = '{:06d}{:06d}'.format(pp, count[pp])

for id in range(M):
    print(names[id])


Measured memory_bytes: 33380
from collections import defaultdict

def main():
    n, m = map(int, input().split())

    d = defaultdict(lambda: list())
    for _ in range(m):
        a, b = map(int, input().split())
        d[a].append(b)

    flag = 1
    for i in d[1]:
        if n in d[i]:
            print("POSSIBLE")
            flag = 0
            break

    if flag: print("IMPOSSIBLE")
    

if __name__ == "__main__":
    main()

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

int main(){
  int K; cin >> K;
  vector<long long> lun;
  for(int i=1; i<10; i++){
    lun.push_back(i);
  }
  
  int ind=9;
  int nind=0;
  for(int i=0; i<9; i++){
      int c=0;
    for(int j=nind; j<ind; j++){
      string base=to_string(lun[j]);
      int a=base[i]-'0';
      if(a!=0){
        lun.push_back(stoll(base+to_string(a-1)));
        c++;
      }
      lun.push_back(stoll(base+to_string(a)));
      c++;
      if(a!=9){
        lun.push_back(stoll(base+to_string(a+1)));
        c++;
      }
    }
    nind=ind;
    ind+=c;
  }
  sort(lun.begin(),lun.end());
  cout << lun[K-1] << endl;
}

Measured memory_bytes: 2420
#include <bits/stdc++.h>
using namespace std;
constexpr long long MOD = 1000000007;
using ll = long long;
int main() {
map<ll,ll>mp;
ll a[1000000];
ll s;
cin >> s;
a[0]=s;
mp[s]++;
for(ll i=0;i<999999;i++){
    if(a[i]%2==0)a[i+1]=a[i]/2;
    else a[i+1]=3*a[i]+1;
mp[a[i+1]]++;
if(mp[a[i+1]] != 1){cout << i+2 << endl;
break;
}

}
}


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

typedef long long ll;
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define each(itr,c) for(__typeof(c.begin()) itr=c.begin(); itr!=c.end(); ++itr)
#define all(x) (x).begin(),(x).end()
#define mp make_pair
#define pb push_back
#define fi first
#define se second

vector<int> G[5000];

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

    map<string,int> f;
    vector<int> c(n);

    rep(i,n)
    {
        string a;
        int x;
        cin >>a >>x;
        f[a]=i;
        c[i]=x;
    }

    cin >>m;
    rep(i,m)
    {
        string s,t;
        cin >>s >>t;

        int x=f[s], y=f[t];
        G[x].pb(y);
        G[y].pb(x);
    }

    int ans=0;

    int vis[5000]={0};

    rep(i,n)
    {
        if(vis[i]) continue;

        int tv[5000]={0};

        queue<int> que;
        que.push(i);
        tv[i]=1;
        while(!que.empty())
        {
            int v=que.front();
            que.pop();
            rep(j,G[v].size())
            {
                int nx=G[v][j];
                if(!tv[nx])
                {
                    tv[nx]=1;
                    que.push(nx);
                }
            }
        }

        int add=1234;
        int ct=0;
        rep(j,n)
        {
            if(tv[j])
            {
                add=min(add,c[j]);
                ++ct;
            }
        }
        ans+=add*ct;

        rep(j,n) vis[j]|=tv[j];
    }

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

Measured memory_bytes: 3968
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> pii;

int main()
{
	int n,m,p,q,a[100005]={},sum=0;
	cin>>n>>m;
	for(int i=0;i<m;i++)
	{
		cin>>p>>q;
		a[p]++;
		a[q+1]--;
	}
	for(int i=1;i<=n+1;i++)
	{
		a[i]+=a[i-1];
	}
	for(int i=1;i<=n;i++)
	{
		if(a[i]==m)sum++;
	}
	cout<<sum<<endl;
	return 0;
}

Measured memory_bytes: 640
// AOJ 0537: Bingo
// 2017.11.28 bal4u@uu

#include <stdio.h>
#include <string.h>

int dp[65][3001];

int main()
{
	int N, M, S, n, i, j, k;

	while (scanf("%d%d%d", &N, &M, &S) && N > 0) {
		memset(dp, 0, sizeof(dp));
		n = N*N;
		dp[0][0] = 1;
		for (i = 1; i <= M; i++) {
			for (j = n-1; j >= 0; j--) {
				for (k = 0; k < S+1-i; k++) {
					dp[j+1][k+i] += dp[j][k];
					dp[j+1][k+i] %= 100000;
				}
			}
		}
		printf("%d\n", dp[n][S]);
	}
    return 0;
}

Measured memory_bytes: 2464
#![allow(unused_imports)]
#![allow(non_snake_case)]
use std::cmp::*;
use std::collections::*;
use std::io::Write;

#[allow(unused_macros)]
macro_rules! debug {
    ($($e:expr),*) => {
        #[cfg(debug_assertions)]
        $({
            let (e, mut err) = (stringify!($e), std::io::stderr());
            writeln!(err, "{} = {:?}", e, $e).unwrap()
        })*
    };
}

fn dfs(n: usize, cur: &mut Vec<usize>, end: usize) {
    if cur.len() == n {
        for &e in cur.iter() {
            print!("{}", std::char::from_digit(e as u32 + 10, 36).unwrap());
        }
        println!("");
        return;
    }
    for i in 0..end {
        cur.push(i);
        dfs(n, cur, end);
        cur.pop();
    }
    cur.push(end);
    dfs(n, cur, end + 1);
    cur.pop();
}

fn main() {
    let n = read::<usize>();
    let mut cur = vec![0];
    dfs(n, &mut cur, 1);
}

fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}


Measured memory_bytes: 5500
using System.Collections.Generic;
using static System.Math;
using System.Linq;
using System;

public class P
{
    public int t { get; set; }
    public string s { get; set; }
    public int a { get; set; }
}

public class Hello
{
    public static void Main()
    {
        var w = int.Parse(Console.ReadLine().Trim());
        var n = (int)(Log10(w * 2 + 1) / Log10(3));
        var a = new int[n + 1];
        a[0] = 1;
        for (int i = 1; i <= n; i++) a[i] = a[i - 1] * 3;
        var ans = getAns(a, w);
        Console.WriteLine(ans);

    }
    static string getAns(int[] a, int w)
    {
        if (w == 1) return "+";
        var n = a.Length;
        var st = new Stack<P>();
        st.Push(new P { t = 0, s = "", a = 0 });
        while (st.Count() > 0)
        {
            var b = st.Pop();
            if (b.t == n)
                if (b.a == w) return b.s;
                else continue;
            st.Push(new P { t = b.t + 1, a = b.a + a[b.t], s = "+" + b.s });
            st.Push(new P { t = b.t + 1, a = b.a - a[b.t], s = "-" + b.s });
            st.Push(new P { t = b.t + 1, a = b.a, s = "0" + b.s });
        }
        return "";
    }
}


Measured memory_bytes: 20572
#include<stdio.h>
#include<vector>
#include<algorithm>
using namespace std;
typedef long long ll;
ll mod = 998244353;
int LOG;
class Hadamard
{
public:
	ll d[2][1 << 19];
	vector<ll>conv(vector<ll>v)
	{
		for (int i = 0; i < v.size(); i++)d[0][i] = v[i];
		int cur = 0;
		for (int i = 0; i < LOG; i++)
		{
			for (int j = 0; j < (1 << LOG); j += (1 << (LOG - i)))
			{
				int s = 1 << (LOG - i - 1);
				for (int k = 0; k < s; k++)d[1 - cur][j + k] = (d[cur][j + k] + d[cur][j + s + k]) % mod, d[1 - cur][j + s + k] = d[cur][j + s + k];
			}
			cur = 1 - cur;
		}
		for (int i = LOG - 1; i >= 0; i--)
		{
			for (int j = 0; j < (1 << LOG); j += (1 << (LOG - i)))
			{
				int s = 1 << (LOG - i - 1);
				for (int k = 0; k < s; k++)d[1 - cur][j + k] = d[cur][j + k], d[1 - cur][j + s + k] = (d[cur][j + k] + mod + mod - d[cur][j + s + k] * 2) % mod;
			}
			cur = 1 - cur;
		}
		vector<ll>r;
		for (int i = 0; i < (1 << LOG); i++)r.push_back(d[cur][i]);
		return r;
	}
};
Hadamard had;
ll po(ll a, ll b)
{
	if (b == 0)return 1;
	ll z = po(a, b / 2);
	z = z*z%mod;
	if (b & 1)z = z*a%mod;
	return z;
}
ll inv(ll a)
{
	return po(a, mod - 2);
}
int main()
{
	int num;
	scanf("%d", &num);
	LOG = num;
	vector<ll>a;
	ll s = 0;
	for (int i = 0; i < (1 << num); i++)
	{
		int z;
		scanf("%d", &z);
		a.push_back(z);
		s += z;
	}
	ll iv = inv(s);
	for (int i = 0; i < (1 << num); i++)a[i] = a[i] * iv%mod;
	a = had.conv(a);
	for (int i = 1; i < (1 << num); i++)a[i] = inv(1 + mod - a[i]);
	a[0] = 0;
	a = had.conv(a);
	for (int i = 0; i < (1 << num); i++)printf("%lld\n", (a[0] + mod - a[i]) % mod);
}

Measured memory_bytes: 17124
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;

#define REP(i,n) for(long long i = 0; i < (n); i++)
#define FOR(i, m, n) for(long long i = (m);i < (n); ++i)
#define ALL(obj) (obj).begin(),(obj).end()
#define SPEED cin.tie(0);ios::sync_with_stdio(false);

template<class T> using V = vector<T>;
template<class T, class U> using P = pair<T, U>;
template<class T> using PQ = priority_queue<T>;
template<class T> using PQR = priority_queue<T,vector<T>,greater<T>>;

constexpr long long MOD = (long long)1e9 + 7;
constexpr long long MOD2 = 998244353;
constexpr long long HIGHINF = (long long)1e18;
constexpr long long LOWINF = (long long)1e15;
constexpr long double PI = 3.1415926535897932384626433;

template <class T> vector<T> make_v(size_t N,T init){return vector<T>(N,init);}
template <class... T> auto make_v(size_t N,T... t){return vector<decltype(make_v(t...))>(N,make_v(t...));}
template <class T> void corner(bool flg, T hoge) {if (flg) {cout << hoge << endl; exit(0);}}
template <class T, class U>ostream &operator<<(ostream &o, const map<T, U>&obj) {o << "{"; for (auto &x : obj) o << " {" << x.first << " : " << x.second << "}" << ","; o << " }"; return o;}
template <class T>ostream &operator<<(ostream &o, const set<T>&obj) {o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr) o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;}
template <class T>ostream &operator<<(ostream &o, const multiset<T>&obj) {o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr) o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;}
template <class T>ostream &operator<<(ostream &o, const vector<T>&obj) {o << "{"; for (int i = 0; i < (int)obj.size(); ++i)o << (i > 0 ? ", " : "") << obj[i]; o << "}"; return o;}
template <class T, class U>ostream &operator<<(ostream &o, const pair<T, U>&obj) {o << "{" << obj.first << ", " << obj.second << "}"; return o;}
template <template <class tmp>  class T, class U> ostream &operator<<(ostream &o, const T<U> &obj) {o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr)o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;}
void print(void) {cout << endl;}
template <class Head> void print(Head&& head) {cout << head;print();}
template <class Head, class... Tail> void print(Head&& head, Tail&&... tail) {cout << head << " ";print(forward<Tail>(tail)...);}
template <class T> void chmax(T& a, const T b){a=max(a,b);}
template <class T> void chmin(T& a, const T b){a=min(a,b);}
void YN(bool flg) {cout << (flg ? "YES" : "NO") << endl;}
void Yn(bool flg) {cout << (flg ? "Yes" : "No") << endl;}
void yn(bool flg) {cout << (flg ? "yes" : "no") << endl;}

int main() {
    string S; cin >> S;
    if(S=="Sunny") cout << "Cloudy" << endl;
    if(S=="Cloudy") cout << "Rainy" << endl;
    if(S=="Rainy") cout << "Sunny" << endl;


	return 0;
}


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

int main() {
  string S;
  cin >> S;
  int i,j,p=0,q=1;
  ll r=0;
  
  for(i=0; i<pow(2,S.size()-1); i++) {
    bitset<9> b(i);
    string t = b.to_string();
    for(j=8; j>=10-S.size(); j--) {
      if(j<0)
        break;
      if(t.at(j)=='1') {
        r+=stoll(S.substr(p,q));
        p+=q; q=1;
      } else
        q++;
    }
    r+=stoll(S.substr(p));
    p=0, q=1;
  }
  
  cout << r << endl;
}

Measured memory_bytes: 256
//config = { input: 'tmp', newline: '\r\n' }; // win
config = { input: '/dev/stdin', newline: '\n' }; // linux

line = require('fs').readFileSync(config.input, 'ascii')
  .trim()
  .split(config.newline);
n = Number(line.shift());
adj = {};
function add(obj, u, v, c) {
  if (!obj.hasOwnProperty(u)) obj[u] = {};
  obj[u][v] = c;
}
for (i in line) {
  ary = line[i].split(' ').map(Number);
  u = ary[0];
  for (j = 2; j < ary.length; j += 2)
    add(adj, u, ary[j], ary[j+1]);
}

d = new Array(n);
pi = new Array(n);

function initializeSingleSource(s) {
  var i;
  for (i = 0; i < n; i++) {
    d[i] = Number.POSITIVE_INFINITY;
    pi[i] = null;
  }
  d[s] = 0;
}

function relax(u, v, w) {
  if (d[v] > d[u] + w) {
    d[v] = d[u] + w;
    pi[v] = u;
  }
}

function bellmanFord(adj, s) {
  initializeSingleSource(s);
  for (i = 1; i < n; i++) {
    for (u in adj) {
      for (v in adj[u]) {
        relax(u, v, adj[u][v]);
      }
    }
  }
  for (u in adj) {
    for (v in adj[v]) {
      if (d[v] > d[u] + adj[u][v])
        return false;
    }
  }
  return true;
}

bellmanFord(adj, 0);
for (i in d) console.log("%s %d", i, d[i]);

Measured memory_bytes: 20052
# import bisect
# import copy
# import fractions
# import math
# import numpy as np
# from collections import Counter, deque
# from itertools import accumulate,permutations, combinations,combinations_with_replacement,product

def resolve():
    n,x=map(int,input().split())
    M=[int(input()) for i in range(n)]
    val=x//sum(M)
    y=x-sum(M)
    print(n+(y//min(M)) if val>0 else 0)
resolve()

Measured memory_bytes: 3060
def main ():
  count = int(input())
  c = list(map(int,input().split()))

  if 0 in c:
    print(0)
    return

  result = 1
  for a in c:
    result *= a
    if result > 1000000000000000000:
      print(-1)
      return

  print(result)

main()

Measured memory_bytes: 21648
from itertools import product

def ans():
  N = int(input())
  cnt = 0
  for i in range(3, 11):
    for p in product(["3", "5", "7"], repeat = i):
      if("3" in p and "5" in p and "7" in p):
        p = int("".join(p))
        if(p <= N):
          cnt += 1
  print(cnt)
ans()

Measured memory_bytes: 3060
#!/usr/bin/env python3

from sys import stdin, stdout

n = int(input())
arr = [int(x) for x in stdin.readline().split()]
store = dict()
store_grp = dict()
total = 0

for i in arr:
    try:
        if (store[i]):
            store[i] += 1
    except KeyError:
        store[i] = 1

for i,j in store.items():
    n = (j-1)
    value = int(((n)*(n+1))/2)
    store_grp[i] = value
    total += value

for i in arr:
    n = store[i]-2
    value = int(((n)*(n+1))/2)
    value = store_grp[i] - value
    print (total-value)


Measured memory_bytes: 32116
import sys

readline = sys.stdin.readline
readall = sys.stdin.read
ns = lambda: readline().rstrip()
ni = lambda: int(readline().rstrip())
nm = lambda: map(int, readline().split())
nl = lambda: list(map(int, readline().split()))
prn = lambda x: print(*x, sep='\n')

def solve():
    n = ni()
    f, s, *a = nm()
    x = 0
    for c in a: x ^= c
    if (f + s - x) % 2 or ((f + s - x) // 2) & x:
        print(-1)
        return
    y = (f + s - x) // 2
    for i in range(40, -1, -1):
        if x & (1 << i) and y | (1 << i) < f:
            y |= 1 << i
    print(f - y if f >= y > 0 else -1)
    return

solve()


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

ll fast_pow(ll n,ll a,ll mod){
    ll res=1;
    while(a>0){
        if(a&1) res=res*n%mod;
        n=n*n%mod;
        a>>=1;
    }
    return res;
}

int main() {
  ll N; cin >> N;
  ll ans = fast_pow(10,N,MOD) - fast_pow(9,N,MOD) - fast_pow(9,N,MOD) + fast_pow(8,N,MOD);
  if (ans <0) ans += MOD;
  if (ans <0) ans += MOD;
  cout << ans << endl;
}

Measured memory_bytes: 3636
#include<bits/stdc++.h>
#define ll long long
#define ld long double
#define pint pair<int,int>
#define mk(x,y) make_pair(x,y)
#define fir first
#define sec second
#define Rep(x,y,z) for(int x=y;x<=z;++x)
#define Red(x,y,z) for(int x=y;x>=z;--x)
using namespace std;
char buf[1<<12],*p1=buf,*p2=buf,nc;int ny;
inline char gc() {return p1==p2&&(p2=(p1=buf)+fread(buf,1,1<<12,stdin),p1==p2)?EOF:*p1++;}
//inline char gc(){return getchar();}
inline int read(){
	int x=0;ny=1;while(nc=gc(),(nc<48||nc>57)&&nc!=EOF)if(nc==45)ny=-1;if(nc<0)return nc;
	x=nc-48;while(nc=gc(),47<nc&&nc<58&&nc!=EOF)x=(x<<3)+(x<<1)+(nc^48);return x*ny;
}
int main(){
//	freopen("std.in","r",stdin);
//	freopen("std.out","w",stdout);
	int ans=0;
	for(int n=read(),d=read(),a,b;n--;){
		a=read(),b=read();if(1ll*a*a+1ll*b*b<=1ll*d*d)ans++;
	}cout<<ans<<"\n";
	return 0;
}



Measured memory_bytes: 3640
#include<iostream>
#include<string.h>
#include<string>
#include<cstdio>
#include<algorithm>
#include<stack>
#include<queue>
#include<vector>
#include<cmath>
#include<utility>
#include<set>
#define ll long long int
#define ld long double
#define INF 1000000000
#define EPS 0.0000000001
#define rep(i,n) for(i=0;i<n;i++)
using namespace std;
typedef pair<int, int> pii;

int main()
{
  int n;
  int i,j;
  char s[105]={};
  char t[105]={};

  cin>>n;
  cin>>s;
  cin>>t;
  int slen=strlen(s);
  int tlen=strlen(t);
  int start=max(0,slen-tlen);

  for(i=start;i<slen;i++)
    if(strncmp(s+i,t,slen-i)==0)break;
   
  cout<<i+tlen<<endl;
}


Measured memory_bytes: 256
import sys
import os
import math

ii = lambda: int(sys.stdin.buffer.readline().rstrip())
il = lambda: list(map(int, sys.stdin.buffer.readline().split()))
iln = lambda n: [int(sys.stdin.buffer.readline().rstrip()) for _ in range(n)]

iss = lambda: sys.stdin.buffer.readline().decode().rstrip()
isn = lambda n: [sys.stdin.buffer.readline().decode().rstrip() for _ in range(n)]


def main():
    if os.getenv("LOCAL"):
        sys.stdin = open("input.txt", "r")

    S = iss()
    S = list(S)
    print('Yes'if S[2] == S[3] and S[4] == S[5] else'No')



if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
t_hp, t_atk, a_hp, a_atk = map(int, input().split())
while (1):
    a_hp -= t_atk
    if a_hp <= 0:
        ans = "Yes"
        break
    t_hp -= a_atk
    if t_hp <= 0:
        ans = "No"
        break
    
print(ans)

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

using namespace std;

int main() {
  int A, B;
  char op;
  scanf("%d %c %d", &A, &op, &B);
  if (op == '+') {
    cout << A + B;
  } else {
    cout << A - B;
  }
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
struct vl{int a,b,c,d;};
int n,m,q,ans;
vector<vl>Q;
vector<int>a;
int calculate(){
    int res=0;
    for(vl u:Q){
        if(a[u.b-1]-a[u.a-1]==u.c)res+=u.d;
    }
    return res;
}
void xuanbachtrach(){
    if(a.size()==n){ans=max(ans,calculate());return;}
    for(int i=a.empty()?1:a.back();i<=m;i++){
        a.push_back(i);
        xuanbachtrach();
        a.pop_back();
    }
}
signed main(){
    cin>>n>>m>>q;
    while(q--){
        int a,b,c,d;
        cin>>a>>b>>c>>d;
        Q.push_back({a,b,c,d});
    }
    xuanbachtrach();
    cout<<ans;
}

Measured memory_bytes: 3652
#include<bits/stdc++.h>
using namespace std;
#define llong long long

// vector<tuple<long,long>> items; // (value, weight)
// auto item = items[i];
// long v = get<0>(item);
// long w = get<1>(item);
// long v, w;
//   for( int i = 0; i < N; i++ ){
//     cin >> v >> w;
//     items.push_back( make_tuple(v, w) ); // item : (value, weight)
//   }

// 無限大の値
const long long INF = 1LL << 60;
// i-1個までの品物の中で総重量wの時の価値の総和の最大値
llong dp[101][100001] = {0};

int main(){
    int N, W;
    vector< tuple<llong, llong> > items;

    cin >> N >> W;
    llong w, v;
    for(int i = 0; i < N; i++){
        cin >> w >> v;
        items.push_back( make_tuple(w, v) ); // (weight, value)
    }

    for(int i=0; i<N; i++){
        auto w = get<0>(items[i]);
        auto v = get<1>(items[i]);
        for(int j=0; j<W+1; j++){
            if( j >= w ) dp[i+1][j] = max( dp[i][j-w] + v, dp[i][j] );
            else dp[i+1][j] = dp[i][j];
        }
    }

    llong res = 0;
    for(int j=0; j<W+1; j++){
        res = max(res, dp[N][j]);
    }

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

Measured memory_bytes: 78336
n, k = map(int, input().split())
x = list(map(int, input().split()))

ans = []
for i in range(n-k+1):
    ans.append(abs(x[i]) + abs(x[i] - x[i+k-1]))
    ans.append(abs(x[i+k-1]) + abs(x[i+k-1] - x[i]))
print(min(ans))

Measured memory_bytes: 14252
/*
このコード、と～おれ!
Be accepted!
∧＿∧　
（｡･ω･｡)つ━☆・*。
⊂　　 ノ 　　　・゜+.
　しーＪ　　　°。+ *´¨)
 　　　　　　　　　.· ´¸.·*´¨) ¸.·*¨)
		  　　　　　　　　　　(¸.·´ (¸.·'* ☆
*/

#include <cstdio>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstring>
#include <vector>
#include <numeric>
#include <iostream>
#include <random>
#include <map>
#include <unordered_map>
#include <queue>
#include <regex>
#include <functional>
#include <complex>
#include <list>
#include <cassert>
#include <iomanip>
#include <set>
#include <stack>
#include <bitset>
/*多倍長整数/cpp_intで宣言
#include <boost/multiprecision/cpp_int.hpp>
using namespace boost::multiprecision;
*/

//#pragma gcc target ("avx2")
//#pragma gcc optimization ("o3")
//#pragma gcc optimization ("unroll-loops")
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define rep1(i, n) for(int i = 1; i <= (n); ++i)
#define rep2(i, n) for(int i = 2; i < (n); ++i)
#define repr(i, n) for(int i = n; i >= 0; --i)
#define reprm(i, n) for(int i = n - 1; i >= 0; --i)
#define printynl(a) printf(a ? "yes\n" : "no\n")
#define printyn(a) printf(a ? "Yes\n" : "No\n")
#define printYN(a) printf(a ? "YES\n" : "NO\n")
#define printim(a) printf(a ? "possible\n" : "imposible\n")
#define printdb(a) printf("%.50lf\n", a) //少数出力
#define printLdb(a) printf("%.50Lf\n", a) //少数出力
#define printdbd(a) printf("%.16lf\n", a) //少数出力(桁少なめ)
#define prints(s) printf("%s\n", s.c_str()) //string出力
#define all(x) (x).begin(), (x).end()
#define allsum(a, b, c) ((a + b) * c / 2LL) //等差数列の和、初項,末項,項数
#define pb push_back
#define rpriq priq<int, vector<int>, greater<int>>
#define deg_to_rad(deg) (((deg)/360.0L)*2.0L*PI)
#define rad_to_deg(rad) (((rad)/2.0L/PI)*360.0L)
#define Please return
#define AC 0
#define manhattan_dist(a, b, c, d) (abs(a - c) + abs(b - d)) /*(a, b) から (c, d) のマンハッタン距離 */


using ll = long long;

constexpr int INF = 1073741823;
constexpr int MINF = -1073741823;
constexpr ll LINF = ll(4661686018427387903);
constexpr ll MOD = 1000000007;
const long double PI = acosl(-1.0L);

using namespace std;

void scans(string& str) {
	char c;
	str = "";
	scanf("%c", &c);
	if (c == '\n')scanf("%c", &c);
	while (c != '\n' && c != -1 && c != ' ') {
		str += c;
		scanf("%c", &c);
	}
}

void scanc(char& str) {
	char c;
	scanf("%c", &c);
	if (c == -1)return;
	while (c == '\n') {
		scanf("%c", &c);
	}
	str = c;
}

double acot(double x) {
	return PI / 2 - atan(x);
}

ll LSB(ll n) { return (n & (-n)); }

/*-----------------------------------------ここからコード-----------------------------------------*/



int main() {

	int n;
	scanf("%d", &n);
	vector<int> c(n - 1), s(n - 1), f(n - 1);
	rep(i, n - 1) scanf("%d%d%d", &c[i], &s[i], &f[i]);
	rep(i, n) {
		int ans = 0;
		for (int j = i; j < n - 1; ++j) {
			ans = max(ans, s[j]);
			int tmp = s[j];
			while (tmp < ans)tmp += f[j];
			ans = tmp;
			ans += c[j];
		}
		printf("%d\n", ans);
	}

	Please AC;
}


Measured memory_bytes: 256
public class Main {
public static void main(String[] args){
	
	String[] input = new java.util.Scanner ( System.in ). nextLine().split(" ");
	int a = Integer.parseInt(input[0]);
	int b = Integer.parseInt(input[1]);
	if (a < b)
		System.out.println("a" + " < " + "b");
	else if (a > b)
		System.out.println("a" + " > " + "b");
	else if (a == b)
		System.out.println("a" + " == " + "b");
	
	
}
}

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

#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 
  
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> 
 
#define FS              ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ll              long long int
#define ld              long double
#define pb              push_back
#define bp              __builtin_popcount
#define sz              size()
#define ff              first
#define ss              second
#define vll             vector<ll>
#define vbool           vector<bool>
#define vpll            vector<pair<ll,ll>>
#define pll             pair<ll,ll>
#define vllv            vector<vector<ll>>
#define setpri(x)       cout<<setprecision(x)<<fixed;
#define all(v)          v.begin(),v.end()
#define allr(v)         v.rbegin(),v.rend()
#define yesr {cout<<"YES"<<endl;return;}
#define nor {cout<<"NO"<<endl;return;}
// getline (std::cin,name);
ll MOD=1e9+7;
ll ceil1(ll n,ll x){return (n-1)/x+(n>0);}

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

ll pow1(ll n,ll m ,ll mod=MOD );
ll pow2(ll n,ll k);

ll modinv(ll n,ll mod){  return pow1(n,mod-2,mod);}

bool func(pair<ll,ll> &a,pair<ll,ll> &b ){
        if(a.ff != b.ff)return a.ff < b.ff;
        return a.ss > b.ss;
}
ll const N=(ll)2e5+111;
ll const LG=(ll)log2(N)+1;



void solve(){
        ll i,j,k,l,n,m,x,y,z,r;
        
        cin>>n;
        vll a(n);
        x=0;
        for(i=0;i<n;i++){
                cin>>a[i];
                x^=a[i];
        }
        // cout<<x<<endl;
        vll ans(n);
        
        for(i=0;i<n;i++){
                ans[i]=x^a[i];
                cout<<ans[i]<<" ";
        }
        
}       
int main(){
        FS;
        
        ll i,j,k,n,m,x,y,z,q;
        q=1;
        // cin>>q;
        while(q--){
                solve();
        }
        return 0;
}


ll pow1(ll n,ll m,ll mod){
        if(m==0)return 1;
        
        if(m%2==0)return pow1((n*n)%mod,m/2,mod);
    	
    	return (pow1((n*n)%mod,m/2,mod)*n)%mod;
}

ll pow2(ll n,ll k){
        ll ans=1;
            while(k>0){
                if(k%2==1)ans=ans*n;
                n=n*n;
                k/=2;
            }
            return ans;
}


Measured memory_bytes: 6312
#!/usr/bin/env python3
import sys

def solve(N: int, S: "List[str]"):
    print(len(set(S)))
    return


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    S = [next(tokens) for _ in range(N)]  # type: "List[str]"
    solve(N, S)

if __name__ == '__main__':
    main()


Measured memory_bytes: 35716
#include<stdio.h>
#define M(a,b)a<b?b:a
int w[100],v[100],n,W,i,j,dp[10005];
int main()
{
	scanf("%d%d",&n,&W);
	for(i=0;i<n;i++)
		scanf("%d%d",&v[i],&w[i]);
	for(i=0;i<n;i++)
		for(j=W;j>=0;j--)
			if(j>=w[i])
				dp[j]=M(dp[j],dp[j-w[i]]+v[i]);
	printf("%d\n",dp[W]);
	return 0;
}

Measured memory_bytes: 636
n = int(input())
arr = list(map(int, input().split()))
flag = [-1] * n
ans = []

for i in range(n-1, -1, -1):
    cnt = 0
    for j in range(i, n, i + 1):
        if j == i:
            continue
        else:
            if flag[j] == 1:
                cnt += 1
    if (arr[i]+cnt) % 2 == 0:
        flag[i] = 0
    else:
        flag[i] = 1
        ans.append(i + 1)
num = len(ans)
if num == 0:
    print(0)
else:
    print(num)
    print(*ans)



Measured memory_bytes: 14096
#include <iostream>

using std::cin;
using std::cout;
using std::endl;


void TorT()
{
  int n, a, b;
  cin >> n >> a >> b;
  if (n * a > b) cout << b << endl;
  else           cout << n * a << endl;
}


void cross9_9()
{
  int a, b;

  cin >> a >> b;
  if (a > 0 && a < 10 && b > 0 && b < 10) cout << a * b << endl;
  else cout << -1 << endl;
}


void calculate_circle()
{
  int r;

  cin >> r;
  cout << r * r << endl;
}


void SvsM()
{
  int hp, a;
  int atk_cnt, rest;

  cin >> hp >> a;
  atk_cnt = hp / a;
  if (hp % a) atk_cnt++;
  cout << atk_cnt << endl;
}


void Poor3()
{
  int a, b, c;
  cin >> a >> b >> c;
  if (a == b && b != c) cout << "Yes" << endl;
  else if (b == c && c != a) cout << "Yes" << endl;
  else if (c == a && a != b) cout << "Yes" << endl;
  else cout << "No" << endl;
}
int main()
{
  //TorT();
  //cross9_9();
  //calculate_circle();
  //SvsM();
  Poor3();
}

Measured memory_bytes: 256
//#include <tourist>
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int INF = 1e9;
const ll LINF = ll(1e18);
const int MOD = 1000000007;
const int dx[4] = {0, 1, 0, -1}, dy[4] = {-1, 0, 1, 0};
const int Dx[8] = {0, 1, 1, 1, 0, -1, -1, -1}, Dy[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl
#define rep(i, n) for (int i = 0; i < n; i++)
#define ALL(v) v.begin(), v.end()
#define debug(v)          \
    cout << #v << ":";    \
    for (auto x : v)      \
    {                     \
        cout << x << ' '; \
    }                     \
    cout << endl;
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;
}
//cout<<fixed<<setprecision(15);有効数字15桁
//-std=c++14
//-std=gnu++17
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; }
ll n, k;
vector<ll> a;
ll check(ll h)
{
    ll count = 0;
    rep(i, n)
    {
        count+=(a[i]+h-1)/h;
        count--;
    }
    //cout << h << " " << count << "\n";
    return count;
}
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> n >> k;
    a.resize(n);
    rep(i, n) cin >> a[i];
    ll l = 0;
    ll r = LINF;
    while (r - l > 1)
    {
        ll mid = (r + l) / 2;
        if (check(mid) > k)
        {
            l = mid;
        }
        else
        {
            r = mid;
        }
    }
    cout << r << "\n";
}


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

#define ll long long
#define ar array

const int mxN=2e5;
int n;
ll d, a, ans, c[mxN+1];
ar<int, 2> b[mxN];

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

	cin >> n >> d >> a;
	for(int i=0; i<n; ++i) {
		cin >> b[i][0] >> b[i][1];
	}
	sort(b, b+n);
	for(int i=0, j=0; i<n; ++i) {
		while(j<n&&b[j][0]<=b[i][0]+2*d)
			++j;
		ll need=max((b[i][1]-c[i]*a+a-1)/a, 0ll);
		ans+=need;
		c[i]+=need;
		c[j]-=need;
		c[i+1]+=c[i];
	}
	cout << ans;
}


Measured memory_bytes: 3328
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <queue>
#include <map>

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

#define debug(vec) for(auto v : vec) cout << v << " "; cout << endl;

#define debug2D(vec2D) for(auto vec : vec2D) { for (auto v : vec) cout << v << " "; cout << endl; } 

using namespace std;

typedef long long ll;

const long long int INF = 1 << 29; //<10^10
//const ll MOD = 998244353;
const ll MOD = 1000000007;

void color(vector<vector<pair<int, int>>>& g,vector<int> &vcol, vector<bool> used,int c, int v){
	if (used[v]) return;
	else {
		vcol[v] = c;
		used[v] = true;
	  for(auto vw : g[v]) color(g, vcol, used, (c + vw.second) % 2, vw.first);
  }
}

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

	vector<vector<pair<int,int>>> graph(n, vector<pair<int,int>>());
	rep(i,n-1) { 
	  int u, v, w;
		cin >> u >> v >> w;
	  graph[u-1].push_back({v-1,w % 2});
		graph[v-1].push_back({u-1,w % 2});
	}
	vector<int> vcol(n,-1);
	vector<bool> used(n,false);
	color(graph, vcol, used, 0, 0);

	rep(i,n) cout << vcol[i] << endl;
}


Measured memory_bytes: 580480
a,b,c,x = [int(input()) for _ in range(4)]

x = x // 50
if 10 * a + 2 * b + c < x:
    print(0)
    quit()

n = 0
for i in range(x // 10, -1, -1):
    if i <= a:
        x1 = x - 10 * i
        for j in range(x1 // 2, -1, -1):
            if j <= b and x1 - 2 * j <= c:
                n += 1
print(n)

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

using namespace std;

int n, w, values[101], weights[101];
long long memo[101][100001] = {};
long long dp(int item, int value)
{
    if (item == n)
    {
        if (value > 0)
            return 1000000001;
        else
            return 0;
    }
    if (value - values[item] < 0)
        return dp(item + 1, value);
    if (memo[item][value] > 0)
        return memo[item][value];
    long long best;
    best = min(weights[item] + dp(item + 1, value - values[item]), dp(item + 1, value));
    memo[item][value] = best;
    return best;
}

int main(void)
{
    scanf("%d %d", &n, &w);
    for (int i = 0; i < n; i++)
    {
        scanf("%d", &weights[i]);
        scanf("%d", &values[i]);
    }
    long long res = 1000000002;
    for (int i = 1; i <= 100000; i++)
    {
        if (dp(0, i) <= w)
            res = i;
    }
    printf("%lld\n", res);    
}

Measured memory_bytes: 81792
//import java.lang.Math;
import java.util.*;
import java.util.Map.Entry;
//import java.util.ListIterator;
//import java.util.Iterator;
//import java.util.LinkedList;
 
public class Main{
	

	public static void main(String[] arg) {
               Scanner sc =new Scanner(System.in);
               TreeSet<Integer> ts= new TreeSet<Integer>();
               TreeSet<Integer> set1= new TreeSet<Integer>();
               int cnt=sc.nextInt();

               for(int i=0;i<cnt;i++){
            	  
                  set1.add(sc.nextInt());
                 }
               TreeSet<Integer> set2= new TreeSet<Integer>();
               int cnt2=sc.nextInt();

               for(int i=0;i<cnt2;i++){
                  set2.add(sc.nextInt());
                 }
                  
              ts.clear();
              ts.addAll(set1);
              ts.retainAll(set2);
             
               for(Iterator<Integer> it=ts.iterator();it.hasNext();){
               int xx=it.next();
               System.out.println(xx);
               }
	}
	}


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

int main(void)
{
    int n, m, x;
    cin >> n >> m >> x;
    vector<vector<int>> a(n, vector<int>(m, 0));
    vector<int> b(m);
    int cnt = 0;
    for (int i = 0; i < m; i++){
        cin >> b.at(i);
    }
    for (int i = 0; i < n; i++){
        int sum = 0;
        for (int j = 0; j < m; j++)
        {
            cin >> a.at(i).at(j);
            sum += a.at(i).at(j) * b.at(j);
        }
        sum += x;
        if (sum > 0)
            cnt++;
    }
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;

class Program
{
    static void Main(string[] args)
    {
        var AB = ReadLine().Split(' ').Select(s => int.Parse(s)).ToArray();
        var (A, B) = (AB[0], AB[1]);

        var AStr = new String(A.ToString()[0], B);
        var BStr = new String(B.ToString()[0], A);

        if (AStr.CompareTo(BStr) < 0)
            WriteLine(AStr);
        else
            WriteLine(BStr);
    }
}


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


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

    string s;
    cin >> s;
    vector<int> a;
    for(int i=0; i<s.size(); i++){
        a.push_back(s[i] - '0');
    }

    long long ans = 0;

    int j = 1 << s.size() - 1;
    for(int i=0; i < j; i++){
        long long fac = 1;
        for(int k = a.size() - 1; k>=0; k--){
            ans += fac * a[k];
            if( (i >> (a.size() - 1 - k)) & 1 ) fac = 1;
            else fac *= 10;
        }
    }
    cout << ans << endl;

	return 0;
}


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

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

#define p_ary(ary,a,b,i) do { cout << "["; for (int (i) = (a);(i) < (b);++(i)) cout << ary[(i)] << ((b)-1 == (i) ? "" : ", "); cout << "]\n"; } while(0)
#define p_map(map,it) do {cout << "{";for (auto (it) = map.begin();;++(it)) {if ((it) == map.end()) {cout << "}\n";break;}else cout << "" << (it)->first << "=>" << (it)->second << ", ";}}while(0)

int main() {
	int n,k;
	cin >> n >> k;
	k = (k<<1)^1;
	vector<int> a(n),b(n);
	for (int i = 0;i < n;++i) cin >> a[i] >> b[i];
	vector<ll> ans(31,0);
	for (int i = 0;i < n;++i) {
		a[i] <<= 1;
		for (int j = 30;j >= 0;--j) {
			if ((k>>j)&1 && !((a[i]>>j)&1)) ans[j] += b[i];
			else if (!((k>>j)&1) && ((a[i]>>j)&1)) break;
		}
	}
	// p_ary(ans,0,31,i);
	cout << *max_element(ans.begin(),ans.end()) << endl;
	return 0;
}

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

#define rep(i,n) for(ll i = 0; i < (n); i++)
#define REP(i,n) for(ll i = 1; i < (n); i++)
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define yesorno(a) printf(a ? "yes\n" : "no\n")
#define YesorNo(a) printf(a ? "Yes\n" : "No\n")
#define YESorNO(a) printf(a ? "YES\n" : "NO\n")
#define endl "\n"

using ll = long long;
using P = pair<int,int>;
using Pll = pair<ll,ll>;
using vi = vector<int>;
using vii = vector<vi>;
using vl = vector<ll>;
using vll = vector<vl>;

const int dx[] = {0,1,0,-1,1,1,-1,-1};
const int dy[] = {1,0,-1,0,1,-1,-1,1};
const int inf = (1<<30)-1;
const ll infll = (1LL<<62)-1; 


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

  int n;
  cin >> n;
  map<int, int> mp;
  rep(i,n){
    int a;
    cin >> a;
    mp[a]++;
  }
  int ans = 0;
  for(auto it = mp.begin(); it != mp.end(); it++){
    if((*it).first <= (*it).second) ans += (*it).second - (*it).first;
    else ans += (*it).second;
  }
  cout << ans << endl;

}

Measured memory_bytes: 4736
#include <bits/stdc++.h>
using namespace std;
#define gc getchar_unlocked
#define fo(i,n) for(i=0;i<n;i++)
#define Fo(i,k,n) for(i=k;k<n?i<n:i>n;k<n?i+=1:i-=1)
#define int long long int
#define si(x)   scanf("%d",&x)
#define sl(x)   scanf("%lld",&x)
#define ss(s)   scanf("%s",s)
#define pi(x)   printf("%d\n",x)
#define pl(x)   printf("%lld\n",x)
#define ps(s)   printf("%s\n",s)
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define all(x) x.begin(), x.end()
#define clr(x) memset(x, 0, sizeof(x))
#define sortall(x) sort(all(x))
#define tr(it, a) for(auto it = a.begin(); it != a.end(); it++)
#define PI 3.1415926535897932384626
#define INF 1e9+7
typedef pair<int, int>  pii;
typedef vector<int>     vi;
typedef vector<pii>     vpii;
typedef vector<vi>      vvi;
int mpow(int base, int exp);
void ipgraph(int m);
int dx[] = {-1, 0, 1, 0};
int dy[] = {0, 1, 0, -1};
const int mod = 1e9 + 7;
//const int N = 2e5+5, M = N;
//=========================================

// This problem is a variation of Longest Increasing Subsequence
// so we optimize the complexity using fenwick tree

const int MAXN = 2e5 + 10;
int N;
int dp[MAXN], h[MAXN], a[MAXN];
int bit[MAXN];

// update the fenwick tree
void update(int idx, int val){
    while(idx <= N){
        bit[idx] = max(bit[idx], val);
        idx += (idx & -idx);
    }
}

// answer the query for idx
int query(int idx){
    int result = 0;
    while(idx > 0){
        result = max(result, bit[idx]);
        idx -= (idx & -idx);
    }
    return result;
}

int32_t main() {

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

    cin >> N;

    for(int i = 1; i <= N; ++i)
        cin >> h[i];

    for(int i = 1; i <= N; ++i)
        cin >> a[i];

    for(int i = 1; i <= N; ++i){
        // dp[i] --> stores the max total beauty if the increasing sequence
        // ended at a flower of height i.

        // query(h[i] - 1) --> returns the maximum value of beauty of an increasing sequence in range [0, h[i] - 1].
        dp[i] = query(h[i] - 1) + a[i]; // add beauty of the current flower to the max sequence

        // update the max beauty value at index h[i] i.e, the value for increasing sequence ending at this flower.
        update(h[i], dp[i]);
    }

    int best = 0;
    for(int i = 1; i <= N; ++i){
        // find the max value by traversing through total beauty values
        // of each flower height.
        best = max(best, dp[i]);
    }

    // Print the max possible answer.
    cout << best << "\n";

    return 0;
}


Measured memory_bytes: 9928
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<iostream>
const int M = 5001 ;
using namespace std;
char s[M];
int n,k;
string p[M*2500];
int tot,cnt;
int main(){
	scanf("%s",s+1);
	cin>>k;
	n=strlen(s+1);
	string now="";
	for(int i=1;i<=n;i++){
		now=s[i];
		p[++tot]=now;
	    for(int j=i+1;j<=min(i+k,n);j++){
	    	now+=s[j];
	    	p[++tot]=now;
		}
	}
    sort(p+1,p+tot+1);
    for(int i=1;i<=tot;i++)
      if(p[i]!=p[i-1]){
      	cnt++;
      	if(cnt==k){
      	  cout<<p[i]<<endl;
			return 0;	
		}
	  }
}

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

public class Coffee{
    public static void Main(){
        var input = Console.ReadLine();
        var ans = "";
        if(input[2] == input[3] && input[4] == input[5]){
            ans = "Yes";
        }else{
            ans = "No";
        }
        
        Console.WriteLine(ans);
    }
}

Measured memory_bytes: 11092
using System;
class Program
{
    static void Main(string[] args)
    {
        var line = Console.ReadLine();

        if (line[0] == line[1] & line[0] == line[2]) Console.WriteLine("Yes");
        else if (line[1] == line[2] & line[1] == line[3]) Console.WriteLine("Yes");
        else Console.WriteLine("No");
    }
}


Measured memory_bytes: 11092
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <cmath>
using namespace std;
using ll = long long;

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

    int n;
    cin >> n;

    int b = 0;
    for (int i = 0; i < n; i++) {
        int a;
        cin >> a;
        if (a % 2) b = 1;
    }

    cout << (b ? "first" : "second") << endl;

    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#define DIV 1000000007

int main(void){
    int n,m,i,j,k,l,z;
    long long int sum=0,sumi=0,sumj=0;
    scanf("%d %d",&n,&m);
    long long int xarr[n];
    long long int yarr[m];
    long long int Sxarr[n];
    long long int Syarr[m];
    
    for(i=0;i<n;i++){
        scanf("%lld",&xarr[i]);
    }
    for(i=0;i<m;i++){
        scanf("%lld",&yarr[i]);
    }
    for(i=n-2;i>=0;i--){
        if(i==n-2){
            Sxarr[i]=xarr[i+1];
        }
        else{
            Sxarr[i]=Sxarr[i+1]+xarr[i+1];
        }
    }
    for(j=m-2;j>=0;j--){
        if(j==m-2){
            Syarr[j]=yarr[j+1];
        }
        else{
            Syarr[j]=Syarr[j+1]+yarr[j+1];
        }
    }
  
    for(i=0;i<n-1;i++){
        int K=n-i-1;
        sumi+=(Sxarr[i]-K*xarr[i])%DIV;
    }
    sumi%=DIV;

    for(j=0;j<m-1;j++){
        int L=m-j-1;
        sumj+=(Syarr[j]-L*yarr[j])%DIV;
    }
    sumj%=DIV;

    sum=sumi*sumj%DIV;
    printf("%lld",sum);
}

Measured memory_bytes: 3328
coins = [500,100,50,10,5,1]

ans' [] _ = 0

ans' (c:cs) n =
  let d = n `div` c 
      m = n `mod` c
  in
    d + (ans' cs m)

ans n =
  let r = 1000 - n
  in
    ans' coins r 

main = do
  c <- getContents
  let i = takeWhile (/= 0) $ map read $ lines c :: [Int]
      o = map ans i
  mapM_ print o

Measured memory_bytes: 3608
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
void fastIO(){
  ios_base::sync_with_stdio(0); cin.tie(0);
}


int main(){
  fastIO();
  string a,b,c;
  cin>>a>>b>>c;
  char turn = 'a';
  char ans = 'A';
  while(1){
  	if(turn=='a'){
  		if(a==""){
  			break;
  		}
  		turn=a[0];
  		a.erase(a.begin());
  	}else if(turn=='b'){
  		if(b==""){
  			ans='B';
  			break;
  		}
  		turn=b[0];
  		b.erase(b.begin());
  	}else{
  		if(c==""){
  			ans='C';
  			break;
  		}
  		turn=c[0];
  		c.erase(c.begin());
  	}
  }
  cout<<ans<<endl;
}








Measured memory_bytes: 256
M=998244353;N=gets.to_i;v=$<.map{|e|Complex(*e.split.map(&:to_i))};h={};r=2**N+~N;[*0...N].combination(2){|i,j|h[x=[i,j]]||((j+1...N).map{|k|((v[j]-v[k]).conj*(v[i]-v[k])).imag.abs<1e-9&&x<<k};r-=2**(l=x.size)+~l;x.combination(2){|e|h[e]=1})};p r%M

Measured memory_bytes: 5116
h,w = map(int,input().split())
lst = [input() for _ in range(h)]

L = [[0]*w for _ in range(h)]
R = [[0]*w for _ in range(h)]
D = [[0]*w for _ in range(h)]
U = [[0]*w for _ in range(h)]

for i in range(h):
    cnt_L = 1
    for j in range(w):
        if (lst[i][j] == '#'):
            cnt_L =1
        else:
            L[i][j] = cnt_L
            cnt_L += 1
            
    cnt_R = 1
    for k in range(w)[::-1]:
        if (lst[i][k] == '#'):
            cnt_R = 1
        else:
            R[i][k] = cnt_R
            cnt_R += 1

for i in range(w):
    cnt_U = 1
    for j in range(h):
        if (lst[j][i] == '#'):
            cnt_U = 1
        else:
            U[j][i] = cnt_U
            cnt_U += 1
    
    cnt_D = 1
    for k in range(h)[::-1]:
        if (lst[k][i] == '#'):
            cnt_D = 1
        else:
            D[k][i] = cnt_D
            cnt_D += 1

ans = 0
for i in range(h):
    for j in range(w):
        tmp = L[i][j] + R[i][j] + D[i][j] + U[i][j] - 3
        if tmp > ans:
            ans = tmp
print(ans)

Measured memory_bytes: 179460