akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
int find(int ind,vector<vector<int>> &a,vector<int> &ans){
    int mx=0;
    for(auto x:a[ind]){
        if(ans[x]<0)ans[x]=find(x,a,ans);
        mx=max(mx,ans[x]+1);
    }
    return mx;
}
int main()
{
   int n,m;
   cin>>n>>m;
   vector<vector<int>> a(n+1);
   for(int i=0;i<m;i++)
   {
       int x,y;
       cin>>x>>y;
       a[x].push_back(y);
   }
   vector<int> ans(n+1,-1);
   for(int i=1;i<=n;i++){
       if(ans[i]<0)ans[i]=find(i,a,ans);
   }
   cout<<*max_element(ans.begin(),ans.end());
}

Measured memory_bytes: 9472
import sys
def input():
	return sys.stdin.readline().strip()

N = int(input())
S = list(map(int, input().split()))

S.sort(reverse=True)

max_S = S[0]
S2 = [S[0]]
for bit in range(N):
	i = 0
	loc = 0
	S2.sort(reverse=True)
	while i < 2**bit:
		if loc >= 2**N:
			print("No")
			exit()
		if S2[i] > S[loc]:
			S2.append(S[loc])
			S[loc] = max_S #検索対象から除外
			i += 1
		loc += 1
print("Yes")

Measured memory_bytes: 107496
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);
		String s = sc.nextLine();
		String s1 = s+s;
		char []s1str = s1.toCharArray();
		
		String p = sc.nextLine();
		char []pstr = p.toCharArray();
		boolean flag = false;
		
		String msg = "No";
		
		for (int i = 0; i < s.length(); i++){
		    for(int l = 0; l < p.length(); l++){
		        if (s1str[i+l] != pstr[l]){
		            flag = false;
		            break;
		        }
		        flag = true;
		    }
		    
		    if (flag == true){
		        msg = "Yes";
		        break;
		    } 
		} 
		
		System.out.println(msg);
	}
}


Measured memory_bytes: 26260
#include <stdio.h>
#include <iostream>

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

using namespace std;

int main(void){
    int r, D, x2000;

    scanf("%d %d %d", &r, &D, &x2000);

    int x = x2000;

    rep(i, 10){
        x = r * x - D;
        cout << x << endl;
    }

    return 0;
}

Measured memory_bytes: 256
import sys
input = sys.stdin.readline

n = int(input())
check = [10, 100, 1000, 10000, 100000]
ans = 0
if n in check:
    ans = 10
else:
    n = str(n)
    for i in range(len(n)):
        ans += int(n[i])
print(ans)


Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define repo(i,n) for(int i = 1; i < (int)(n); i++)
#define pb push_back
#define mp make_pair
#define np next_permutation
#define lb lower_bound
#define ub upper_bound
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()
#define mod 1000000007
#define pi acos(-1.0)
const ll INF = 1LL<<61;
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; }
ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; }
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }
ll jou(ll N, ll P){if(P==0) return 1;
  if(P%2==0){ll t = jou(N, P/2);return t*t % mod;
  }return (N * jou(N, P-1)) % mod;}  //jou(n,mod-2)で逆元
//intの最大値2147483647 ≒ 2×10^9
//long longの最大値9223372036854775807 ≒ 9×10^18
//'大文字'+=32;    で小文字に
//  cout << fixed << setprecision (20);   小数点以下2０桁まで
//実行時間制約2秒では２×10^8回くらいまで計算できる





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

  vector<vector<char>> p(n,vector<char>(m));
  vector<vector<bool>> q(n,vector<bool>(m,true));
  rep(i,n){
    bool atsu=true;
    rep(j,m){
      cin>>p[i][j];
      if(p[i][j]=='#') atsu=false;
    }
    if(atsu){
      rep(j,m){
        q[i][j]=false;
      }
    }
  }

  rep(j,m){
    bool atsu=true;
    rep(i,n){
      if(p[i][j]=='#') atsu=false;
    }
    if(atsu){
      rep(i,n){
        q[i][j]=false;
      }
    }
  }

  rep(i,n){
    rep(j,m){
      if(q[i][j]) cout << p[i][j];
    }
    cout << endl;
  }


}

Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
using namespace std;
const int maxn=1005;
int a[maxn];
int main()
{
    int n,k;
    scanf("%d%d",&n,&k);
    for(int i=1;i<=n;i++)
        scanf("%d",&a[i]);
    sort(a+1,a+n+1);
    int sum=0;
    for(int i=1;i<=k;i++)
        sum+=a[i];
    printf("%d\n",sum);
    return 0;
}


Measured memory_bytes: 1712
A=int(input())
B=int(input())
C=int(input())
X=int(input())

count=0
for i in range(A+1):
    if 500*i <= X:
        for j in range(B+1):
            if 100*j <= X-500*i:
                for k in range(C+1):
                    if 50*k == X-500*i-100*j:
                        count+=1
print(count)

Measured memory_bytes: 3064
N,M=map(int,input().split())
H=list(map(int,input().split()))
flg=[0]*N
T=[[] for _ in range(N)]

for m in range(M):
  a,b =map(int,input().split())
  T[a-1].append(b)
  T[b-1].append(a)

for n in range(N):
  if not T[n]:
    flg[n] =1
  else:
    MAX=max([H[t-1] for t in T[n]])
    if H[n]>MAX:
    	flg[n]=1

print(sum(flg))
    

Measured memory_bytes: 30732
import java.util.*

fun main(args: Array<String>) {
    val sc = Scanner(System.`in`)
    val n = sc.nextInt()
    println(problem173a(n))
}

fun problem173a(n: Int): Int {
    var ans = 1000 - (n % 1000)
    return if (ans == 1000) 0 else ans
}

Measured memory_bytes: 36432
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,l,r) for(long long i=(l);i<(r);++i)
#define REP(i,n) FOR(i,0,n)
#define REPS(i,n) FOR(i,1,n+1)
#define RFOR(i,l,r) for(long long i=(l);i>=(r);--i)
#define RREP(i,n) RFOR(i,n-1,0)
#define RREPS(i,n) RFOR(i,n,1)
#define int long long
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define SZ(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
template<class T = int> using V = vector<T>;
template<class T = int> using VV = V<V<T>>;
template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b; return true; }return false; }
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b; return true; }return false; }
inline void Yes(bool b = true) {cout << (b ? "Yes" : "No") << '\n';}
inline void YES(bool b = true) {cout << (b ? "YES" : "NO") << '\n';}
inline void err(){cout << -1 << '\n';}
const int INF = 1e18;

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int n; cin >> n;
    set<int> st;
    int sum = 0;
    int i = 1;
    while(sum < n){
        sum += i;
        st.insert(i);
        i++;
    }
    if(sum-n) st.erase(sum-n);
    for(auto v:st) cout << v << '\n';
}

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

int main(){
    int E,Y,o=0;
    cin>>E>>Y;
    if(E==0){
        if(Y<=1911){
            cout<<"M"<<Y-1867<<"\n";
        }
        if(1912<=Y&&Y<=1925){
            cout<<"T"<<Y-1911<<"\n";
        }
        if(1926<=Y&&Y<=1988){
            cout<<"S"<<Y-1925<<"\n";
        }
        if(1989<=Y){
            cout<<"H"<<Y-1988<<"\n";
        }
    }
    if(E==1){
        cout<<1867+Y<<"\n";
    }
    if(E==2){
        cout<<1911+Y<<"\n";
    }
    if(E==3){
        cout<<1925+Y<<"\n";
    }
    if(E==4){
        cout<<1988+Y<<"\n";
    }
    return(0);
}


Measured memory_bytes: 3112
#include <bit>
#include <bitset>
#include <assert.h>
#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <sstream>
#include <iostream>
#include <set>
#include <map>
#include <vector>
#include <math.h>
#include <stdlib.h>
#include <queue>
#include <stack>
#include <iomanip>

typedef long double ld;
typedef long long ll;

using namespace std;


/* TEMPLATE ENDS HERE */

int main() {
	cout << fixed << setprecision(12);	
	int ret = 0;
	int n;
	cin >> n;
	for (int i = 1; i <= n; i++) {
		int t;
		cin >> t;
		if ((t & 1) && (i & 1)) {
			ret++;
		}
	}
	cout << ret << endl;
	return 0;
}


ll MOD = ((ll)1e9 + 7);

struct mod {
	ll x;

	mod(ll tx = 0) {
		x = tx;
		x %= MOD;
	}
	
	mod& operator=(const ll & tx) {
		x = tx % MOD;
		return *this;
	}
	
	mod& operator=(const mod & m2) {
		x = m2.x;
		return *this;
	}

	mod operator+(const mod& m2) const {
		return mod((x + m2.x) % MOD);
	}

	mod& operator+=(const mod& m2) {
		x += m2.x;
		x %= MOD;
		return *this;
	}

	mod operator-(const mod & m2) const {
		return mod((x - m2.x + MOD) % MOD);
	}

	mod& operator-=(const mod & m2) {
		x -= m2.x;
		x = (x + MOD) % MOD;
		return *this;
	}

	mod operator*(const mod & m2) const {
		return mod((x * m2.x) % MOD);
	}

	mod& operator*=(const mod & m2) {
		x *= m2.x;
		x %= MOD;
		return *this;
	}

	mod mypow(ll k) const {
		mod ret = 1;
		mod cur = x;
		while (k) {
			if (k & 1) {
				ret *= cur;
			}
			cur *= cur;
			k >>= 1;
		}
		return ret;
	}

	mod inv() const {
		return mypow(MOD - 2);
	}

	mod operator/(const mod & m2) const {
		return (*this) * m2.inv();
	}

	mod& operator/=(const mod & m2) {
		x *= m2.inv().x;
		x %= MOD;
		return *this;
	}

	bool operator<(const mod & m2) const {
		return x < m2.x;
	}
};

ostream &operator<<(ostream & os, const mod & m) {
	return os << m.x;
}



Measured memory_bytes: 3600
#include <bits/stdc++.h>
using namespace std;
int main(){
    int A,B;
    cin >> A >> B;
    if(A<=5){
        cout << 0 << endl;
    }
    else if(A<=12){
        cout << B/2 << endl;
    }
    else{
        cout << B << endl;
    }
    return 0;
} 

Measured memory_bytes: 256
import java.util.Scanner;
import java.util.Arrays;

class Main {

    public static void main(String[] args)  {
	Scanner sc = new Scanner(System.in);

	int N = sc.nextInt();
	int v[] = new int[N];
	for (int i = 0; i < N; i++)
	    v[i] = sc.nextInt();

	Arrays.sort(v);
	double ave = ((double)(v[1] - v[0])) / 2 + v[0];
	for (int i = 2; i <= N - 1; i++)
	    ave = ((double)(ave - v[i])) / 2 + v[i];

	System.out.println(ave);
    }
}

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

#define MOD 1000000007LL

long long fac[1000001],finv[1000001],inv[1000001];

void COMinit(){
	fac[0]=fac[1]=1;
	finv[0]=finv[1]=1;
	inv[1]=1;
	for(int i=2;i<1000001;i++){
		fac[i]=fac[i-1]*i%MOD;
		inv[i]=MOD-inv[MOD%i]*(MOD/i)%MOD;
		finv[i]=finv[i-1]*inv[i]%MOD;
	}
}
 
long long COM(int n,int k){
	if(n<k)return 0;
	if(n<0 || k<0)return 0;
	return fac[n]*(finv[k]*finv[n-k]%MOD)%MOD;
}
 
long long MODpow(long long a,int b){
	if(b==0)return 1;
	if(b%2==0){
		long long t=MODpow(a,b/2);
		return (t*t)%MOD;
	}
	return (a*MODpow(a,b-1))%MOD;
}

int main(){
	COMinit();
	int N,K;
	cin >> N >> K;
	vector<long long> A(N);
	for(auto &i:A)cin >> i;
	
	sort(A.begin(),A.end(),greater<long long>());
	
	long long ans=0;
	
	for(int i=0;i<=N-K;i++){
		ans+=COM(N-i-1,K-1)*A[i];
		ans+=MOD*MOD;
		ans%=MOD;
	}
	
	reverse(A.begin(),A.end());
	
	for(int i=0;i<=N-K;i++){
		ans-=COM(N-i-1,K-1)*A[i];
		ans+=MOD*MOD;
		ans%=MOD;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 24448
#include <iostream>
#include<vector>
#include<algorithm>
#include<utility>
using namespace std;

bool cmp(pair<int,int> a,pair<int,int> b){
    return a.second < b.second;
}

int main(){
    int n,m;
    cin  >> n >> m;
    vector <pair< int,int> > a;
    for(int i=0;i<n;i++){
        int tmp;
        cin >> tmp;
        a.push_back(make_pair(1,tmp));
    }
    for(int i=0;i<m;i++){
        int tmpb,tmpc;
        cin >> tmpb >>tmpc;
        a.push_back(make_pair(tmpb,tmpc));
    }
    sort(a.begin(),a.end(),cmp);
    reverse(a.begin(),a.end());
    long long ans = 0;
    long long count = 0;
    for(int i=0;i<n;i++){
        for(int j=0;j<a[i].first;j++){
            ans += a[i].second;
            count ++;
            if(count == n){
                break;
            }
        }

        if(count == n){
            break;
        }
    }
    cout << ans << endl;
    return 0;
}

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

int main(){
    int H, W;
    cin >> H >> W;
    while(H != 0 && W != 0){
        for(int i=0; i<H; i++){
            cout << "#";
            if(i == 0 || i == H-1){
                for(int i=0; i<W-2; i++){
                    cout << "#";
                }
            }else{
                for(int i=0; i<W-2; i++){
                    cout << ".";
                }
            }
            cout << "#" << endl;
        }
        cout << endl;
        cin >> H >> W;
    }
    return 0;
}


Measured memory_bytes: 3092
#include<iostream>
using namespace std;
int main(){
	int a,b,c;
	int i,n;
	cin>>n;
	a=100000;
	for(i=0;i<n;i++){
		b=a/20+a;
		if(b%1000!=0)b+=1000;
		b/=1000;
		b*=1000;
		a=b;
	}
	cout<<a<<endl;
	return 0;
}

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

vector<int> v,c;
int n, mx = 0;

int bf(int pos = 0, int x = 0, int y = 0){
	if(pos == n) return x - y;
	int w = 0;
	w = max(bf(pos + 1, x + v[pos], y + c[pos]), bf(pos + 1, x, y));
	return w;
}

int main() {
	cin >> n;
	v = c = vector<int>(n);
	for(int i = 0; i < n; i++) cin >> v[i];
	for(int i = 0; i < n; i++) cin >> c[i];
	cout << bf() << "\n";
	return 0;
}


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

using namespace std;

#define pb push_back
#define mk make_pair
#define mod 1000000007
#define ff first
#define ss second

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

ll modpow(ll a, ll b){

    ll ans=1;
    while(b){
        if(b&1){
            ans=(ans*a)%mod;
        }
        a=(a*a)%mod;
        b=b/2;
    }
    return ans;
}

int main(){

    string s;
    cin>>s;

    ll k;
    cin>>k;
    int n=s.length();
    for(int i=0;i<n-1;i++){
        ll req = (26-(s[i]-'a'))%26;
        if(req>k){
            continue;
        }
        else{
            s[i]='a';
            k-=req;
        }
    }

    k=k%26;

    int tmp = (s[n-1]-'a'+k)%26;
    char c = 'a'+tmp;
    s[n-1]=c;
    cout<<s<<endl;

}



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

const int MAX_N = 100 * 1000 + 10;
int a[MAX_N], n, l;

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

void solve() {
	int p = -1;
	for (int i = 0; i < n - 1; i++)
		if (a[i] + a[i + 1] >= l)
			p = i;
	if (p == -1)
		cout << "Impossible";
	else {
		cout << "Possible\n";
		for (int i = 0; i < p; i++)
			cout << i + 1 << endl;
		for (int i = n - 2; i > p; i--)
			cout << i + 1 << endl;
		cout << p + 1;
	}
}

int main() {
	ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
	read_input();
	solve();
}

Measured memory_bytes: 1280
#include <cstdlib>
#include <cctype>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <vector>
#include <string>
#include <iostream>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <fstream>
#include <numeric>
#include <iomanip>
#include <bitset>
#include <list>
#include <stdexcept>
#include <functional>
#include <utility>
#include <ctime>
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
#define MEM(a,b) memset((a),(b),sizeof(a))
const LL INF = 1e9 + 7;
const int N = 2e5 + 10;
vector<int> v[N];
LL val[N];
void dfs(int x, int fa = 0)
{
	val[x] += val[fa];
	for (auto& y : v[x])
	{
		if (y == fa) continue;
		dfs(y, x);
	}
}
int main()
{
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	int n, q;
	cin >> n >> q;
	for (int i = 1; i < n; i++)
	{
		int x, y;
		cin >> x >> y;
		v[x].push_back(y);
		v[y].push_back(x);
	}
	while (q--)
	{
		int x, y;
		cin >> x >> y;
		val[x] += y;
	}
	dfs(1);
	for (int i = 1; i <= n; i++)
	{
		printf("%lld%c", val[i], " \n"[i == n]);
	}
	return 0;
}

Measured memory_bytes: 24320
#include <bits/stdc++.h>
using namespace std;
 
int main() {
 int N, K, i, x = 1;
  cin >> N >> K;
  
  for (i = 0; i < N; i++) {
    if (x * 2 <= x + K) {
      x *= 2;
    }
    else if (x * 2 > x + K) {
      x += K;
    }
  }
    cout << x << endl;
}
  


Measured memory_bytes: 256
def gcd(x, y):
    while y != 0:
        x, y = y, x % y
    return x


def prime_factor(n):
    ret = {}
    p = 2
    while p*p <= n:
        while n % p == 0:
            ret[p] = ret.get(p, 0) + 1
            n //= p
        p += 1

    if n != 1: ret[n] = 1

    return ret


a, b = map(int, input().split())
g = gcd(a, b)

print( len(prime_factor(g)) + 1)


Measured memory_bytes: 3060
<?php
ini_set('memory_limit', '1024M');
$sc = new Scanner();
$N = $sc->nextInt();
$P = $sc->nextInt();
 
if ($N == 1) {
    echo $P . PHP_EOL;
    exit;
}
if ($P == 1) {
    echo 1 . PHP_EOL;
    exit;
}
 
$result = get_prime_factors($P);
$ans = 1;

foreach($result as $k => $v) {
    $ans *= pow($k, (int)($v/$N));
}
 
echo $ans . PHP_EOL;
 
class Scanner {
    private $arr = [];
    private $count = 0;
    private $pointer = 0;
    public function next() {
        if($this->pointer >= $this->count) {
            $str = trim(fgets(STDIN));
            $this->arr = explode(' ', $str);
            $this->count = count($this->arr);
            $this->pointer = 0;
        }
        $result = $this->arr[$this->pointer];
        $this->pointer++;
        return $result;
    }
    public function hasNext() {
        return $this->pointer < $this->count;
    }
    public function nextInt() {
        return (int)$this->next();
    }
    public function nextDouble() {
        return (double)$this->next();
    }
}

function get_prime_factors($N) {
    $result = [];
    
    for($i = 2; $i * $i <= $N; $i++) {
        if ($N % $i == 0) {
            while($N % $i == 0) {
                $result[$i]++;
                $N /= $i;
            }
        }
    }
    if ($N > 1) {
        $result[$N]++;
        $N /= $N;
    }
    return $result;
}


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

int main(void)
{
  int n, l;
  std::cin >> n >> l;

  std::vector<std::string> str;
  for (int i = 0; i < n; i++) {
    std::string s;
    std::cin >> s;
    str.push_back(s);
  }

  std::sort(str.begin(), str.end());

  for (auto i : str) {
    std::cout << i;
  }
  std::cout << std::endl;

  return 0;
}

Measured memory_bytes: 3560
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (n); i++)
#define all(a) a.begin(), a.end()
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
using namespace std;

int main(){

    int N, M, K, A;
    cin >> N >> M;

    vector<int> fav(M, 0);
    rep(i, N){
        cin >> K;
        rep(j, K){
            cin >> A;
            fav[A - 1]++;
        }
    }

    int ans = 0;
    rep(i, M)if(fav[i] == N)ans++;
    cout << ans << endl;
    
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#define PI 3.14159265358979323
 
//int calc1(float a,float b,float c,float d,float e,float f,float *x,float *y);
//void quick(int *,long long,long long);
//int comp(char *a,char *b);
//int make(int *a,int n,int b,char *c[4],char *buf);

int x[1001][1000];
int y[1001][1000];

int main(){
     
	int w,n,i,j,max,r,l;
	int maxn[1000];
	int omosa[1000];
	int kati[1000];
	int z[1000];

	l=1;
	while(1){
		scanf("%d",&w);
		if(w==0)
			break;
		scanf("%d",&n);
		for(i=0;i<n;i++)
			scanf("%d,%d",kati+i,omosa+i);
		for(i=0;i<=w;i++){
			max=0;
			r=0;
			if(omosa[0]>i){
				x[i][0]=0;
				y[i][0]=0;
			}else{
				x[i][0]=kati[0];
				y[i][0]=omosa[0];
				max=kati[0];
				r=omosa[0];
			}
			for(j=1;j<n;j++){
				if(omosa[j]>i){
					x[i][j]=max;
					y[i][j]=r;
				}else{
					if(r+omosa[j]<=i){
						x[i][j]=max+kati[j];
						max=x[i][j];
						r=r+omosa[j];
						y[i][j]=r;
					}else{
						if(x[ i-omosa[j] ][j-1]+kati[j]>max||  x[ i-omosa[j] ][j-1]+kati[j]==max&&y[ i-omosa[j] ][j-1]+omosa[j]<r  ){
							x[i][j]=x[ i-omosa[j] ][j-1]+kati[j];
							max=x[i][j];
							r=y[ i-omosa[j] ][j-1]+omosa[j];
							y[i][j]=r;
						}else{
							x[i][j]=max;
							y[i][j]=r;
						}
					}
				}
			}
		}
		printf("Case %d:\n",l);
		printf("%d\n%d\n",x[w][n-1],y[w][n-1]);
		l++;
	}
    return 0;
}

Measured memory_bytes: 8424
s = input()
L = []
i = 0
pre = ''
while i < len(s):
    c = s[i]
    if c == pre:
        if i == len(s) - 1:
            break
        c += s[i+1]
        i += 1
    L.append(c)
    pre = c
    i += 1
print(len(L))


Measured memory_bytes: 8296
#include <algorithm>
#include <cmath>
#include <deque>
#include <iostream>
#include <numeric>
#include <queue>
#include <sstream>
#include <string>
#include <string.h>
#include <tuple>
#include <vector>

#define REP(i,x) for(int i{ 0 }; i < (int)(x); i++)
#define REPC(i,x) for(int i{ 0 }; i <= (int)(x); i++)
#define RREP(i,x) for(int i{ (int)(x) - 1 }; i >= 0 ;i--)
#define RREPC(i,x) for(int i{ (int)(x)}; i >= 0; i--)
#define REP1O(i,x) for(int i{ 1 }; i < (int)(x); i++)
#define REP1C(i,x) for(int i{ 1 }; i <= (int)(x); i++)

#define PB push_back
#define MP make_pair
#define F first
#define S second
#define SZ(x) ((int)(x).size())
#define ALL(x) (x).begin(),(x).end()

using namespace std;

typedef int64_t ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vector<int>> vvi;
typedef vector<vector<ll>> vvll;
typedef pair<int, int> pii;
typedef tuple<int, int, int> tupiii;
typedef tuple<ll, ll, ll> tuplll;

const int INTMAX = 2147483647;
const ll LLMAX = 9223372036854775807;
const int MOD = 1000000007;

template<class T> inline bool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }
void inline swap(ll& a, ll& b) { a ^= b; b ^= a; a ^= b; }
void inline swap(int& a, int& b) { a ^= b; b ^= a; a ^= b; }



int main()
{
	int n;
	int ma = -INTMAX;
	int mi = INTMAX;

	cin >> n;

	REP(i, n)
	{
		int a;
		cin >> a;
		chmax(ma, a);
		chmin(mi, a);

	}

	cout << ma - mi << endl;
}


Measured memory_bytes: 256
// https://atcoder.jp/contests/abc132/tasks/abc132_c

#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <string>
#include <tuple>
#include <vector>
using namespace std;

typedef long long ll;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;
#define INF (1e9)
#define MOD (1000000007)
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOREACH(x, a) for (auto &(x) : (a))
#define ALL(obj) (obj).begin(), (obj).end()
#define ALLR(obj) (obj).rbegin(), (obj).rend()
#define LEN(x) (sizeof(x) / sizeof(*(x)))
ll gcd(long a, long b) { return b ? gcd(b, a % b) : a; }
ll lcm(long a, long b) { return a * b / gcd(a, b); }

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    vector<int> v(n);
    for (int i = 0; i < n; i++) {
        cin >> v[i];
    }
    sort(ALL(v));
    cout << v[v.size() / 2] - v[v.size() / 2 - 1] << endl;

    return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define INF 999999999999999
using namespace std;

typedef long long ll;

int main(){
	ll n, c;
	cin >> n >> c;
	ll v[n]; ll x[n];
	ll ans = 0;
	ll ri[n+1]; ll rit[n+1];
	ll op[n+1]; ll opt[n+1];
	ri[0]=0; rit[0]=0;
	op[0]=0; opt[0]=0;
	ll risum=0; ll ritsum=0;
	for(ll i = 0; i < n; i++){
		cin >> x[i] >> v[i];
		if(i)risum += v[i]-(x[i]-x[i-1]), ri[i+1] = max(ri[i], risum), ritsum += v[i]-(x[i]-x[i-1])*2, rit[i+1] = max(rit[i], ritsum);
		else risum = ri[i]+v[i]-x[i], ri[i+1] = max(ri[i], risum), ritsum = rit[i]+v[i]-x[i]*2, rit[i+1] = max(rit[i], ritsum);
	}
	ll opsum=0;
	ll optsum=0;
	for(ll i = 0; i < n; i++){
		if(i)opsum += v[n-i-1]-(x[n-i]-x[n-i-1]), op[i+1] = max(op[i], opsum), optsum += v[n-i-1]-(x[n-i]-x[n-i-1])*2, opt[i+1] = max(opt[i], optsum);
		else opsum = op[i]+v[n-i-1]-(c-x[n-i-1]), op[i+1] = max(op[i], opsum), optsum = opt[i]+v[n-i-1]-(c-x[n-i-1])*2, opt[i+1] = max(opt[i], optsum);
	}
	for(ll i = 0; i <= n; i++){
		ans = max(ans, max(ri[i]+opt[n-i], rit[i]+op[n-i]));
	}
	cout << ans << endl;
    return 0;
}

Measured memory_bytes: 4992
// C.

#include <iostream>
#include <cstdio>

using namespace std;

int main(int argc, char *argv[]) {
	int a, b, c, d, e, f, t = 0, s = 0;
	cin >> a >> b >> c >> d >> e >> f;
	for (int i = 0; i <= 30; i += a) {
		for (int j = 0; i + j <= 30; j += b) {
			int k = i + j;
			int r = min(e * k, f - k * 100);
			if (r > 0) {
				int x = 0;
				for (int l = 0; l <= r; l += c) {
					for (int m = 0; l + m <= r; m += d) {
						x = max(x, l + m);
					}
				}
				if (t == 0 || x * t > s * k) {
					t = k;
					s = x;
				}
			}
		}
	}
	cout << (t * 100 + s) << " " << s << endl;
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<cmath>
#include<string>
#include<cstring>
#include<vector>
#include<list>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<stack>
using namespace std;
typedef long long ll;
#define fi first
#define se second
#define mp make_pair
#define mt make_tuple
#define pqueue priority_queue
const int inf=1e9+7;
const ll mod=1e9+7;
const ll mod1=998244353;
const ll big=1e18;
const double PI=2*asin(1);

int main() {
  int N;
  cin>>N;
  int T[N];
  int ans = 0;
  for(int i=0;i<N;++i) {
    cin>>T[i];
    ans += T[i];
  }
  int M;
  cin>>M;
  int P[M], X[M];
  for(int i=0;i<M;++i) {
    cin>>P[i]>>X[i];
    P[i]--;
  }
  vector<int> arr(M);
  for(int i=0;i<M;++i) {
    cout<<ans-(T[P[i]]-X[i])<<endl;
  }
}



Measured memory_bytes: 3628
#include <iostream>
#include <string>
#include <utility>
#include <map>
#include <vector>
#include <functional>
#include <algorithm>

using namespace std;
using ll = long long;

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

int main()
{
    ll q,h,s,d,n;
    cin >> q >> h >> s >> d >> n;
    q *= 4;
    h *= 2;
    ll ans = 0;
    ll min_n = q;
    if(min_n > h) min_n = h;
    if(min_n > s) min_n = s;

    if(min_n * 2 >= d){//
        if((n - n%2)/2){
            ans = (n-n%2)/2 * d;
        }
        if(n % 2 == 1){
            ans += min_n;
        }
    }else{
        ans += min_n * n;
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<string>
#include<algorithm>
#include<cstring>
#include<vector>
#include<cmath>
#include<queue>
#include<stack>
using namespace std;
#define INT(x) int x; scanf("%d",&x)
#define INPUT(x) scanf("%d",&x)
#define REP1(x,n) for(int x = 0; x < n; x++)
#define REP2(x,s,e) for(int x = s; x <= e; x++)
#define RREP1(x,n) for(int x = n-1; x >= 0; x--)
#define RREP2(x,s,e) for(int x = s; x >= e; x--)
#define BR printf("\n")
#define INF 2000000000

typedef long long ll;

char S[100001];

void rec(int K){
    int len = strlen(S);
    REP1(i,len){
        if((26-(S[i]-'a'))%26 <= K){
            K -= (26-(S[i]-'a'))%26;
            S[i] = 'a';
        }
    }
    if (K == 0) {
        cout << S;
        return;
    }else{
        K = K%26;
        S[len-1] += K;
        cout << S;
    }
    cout << endl;
}

int main(){
    cin >> S;
    INT(K);
    rec(K);
    return 0;
}

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

#define int long long

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REPS(i,n) for(int i=1, i##_len=(n); i<=i##_len; ++i)

#define INF (3e9)

using namespace std;

int N;
int A[100003];

signed main()
{
    cin >> N;
    REP(i, N) cin >> A[i];

    sort(A, A+N);

    int a1 = 0;
    int a2 = 0;
    for (int i = N-1; i > 0; --i)
    {
        if (A[i] == A[i-1])
        {
            if (a1 == 0)
            {
                a1 = A[i];
            }
            else
            {
                a2 = A[i];
                break;
            }
            --i;
        }
    }
    cout << a1 * a2 << endl;

    return 0;
}

Measured memory_bytes: 1024
#include "cstdio"
#include "algorithm"
#include<cstdlib>
#include<ctime>
#define ri register int 
using namespace std;
int l[123],len[123],per[123];
int a,b,c,n;
int now;
void dfs(int f,int to,int obj,int p,int mon,int flag)
{
	if(!flag) p=l[f];
	else p+=l[f];
	if(obj==p)
	{
		now=min(now,mon);
		return;
	}
	now=min(now,mon+abs(obj-p));
	for(ri i=f+1;i<=to;i++)
	{
		dfs(i,to,obj,p,mon+10,1);
		dfs(i,to,obj,p,mon,0);
	}
}
int main()
{
//	srand(time(0));
	scanf("%d %d %d %d",&n,&a,&b,&c);
	int T=1;
	for(ri i=1;i<=n;i++)	
	{
		T*=i;
		scanf("%d",&len[i]);
		per[i]=i;
	}
	
	ri ans=1e9+11;
	ri cnt=0;
	while(T--)
	{
		for(ri i=1;i<=n;i++)
			l[i]=len[per[i]];
			
		for(ri i=1;i<=n-2;i++)
		{
			for(ri j=i+1;j<=n-1;j++)
				for(ri k=j+1;k<=n;k++)
				{
					now=1e9+11;
					dfs(1,i,a,0,0,0);
					int ap=now;
					now=1e9+11;
					dfs(j,k-1,b,0,0,0);
					int bp=now;
					now=1e9+11;
					dfs(k,n,c,0,0,0);
					int cp=now;
					if(ap+bp+cp<ans)
					{
						ans=ap+bp+cp;
						cnt=0;
					}
					cnt++;
				}
		}
		next_permutation(per+1,per+n+1);
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define ll long long 
#define MOD 1000000007
ll fact[200005];
#define eps 1e-9
#define INF 1e17
#define N 200005
inline ll mul(ll a,ll b){
  a=(a+MOD)%MOD;
  b=(b+MOD)%MOD;
  ll c=a*b;
  c=(c+MOD)%MOD;
  return c;
}
ll power(ll a,ll b,ll c){
  ll ans=1;
  while(b){
    if(b&1){
      ans=mul(ans,a);
    }
    a=mul(a,a);
    b=b/2;
  }
  return ans;
 }
ll min(ll a,ll b){return a<b?a:b;}
ll max(ll a,ll b){return a>b?a:b;}
int main() {
        ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
        ll x; cin>>x;
        map<ll,int> mm;
        mm[1]=1;
        mm[-1]=-1;
        ll pp[1001];
        pp[1]=1;
        for(int i=2;i<=1000;++i){
            ll f=i;
            f=(f*f*f*f*f);
            mm[f]=i;
            mm[-f]=-i;
            pp[i]=f;
        }
        if(mm[x]){
            cout<<mm[x]<<" "<<0;
            return 0;
        }
        for(int i=1;i<=1000;++i){
            ll zz=pp[i];
            zz-=x;
            if(mm[zz]){
                cout<<mm[pp[i]]<<" "<<mm[zz]<<endl;
                return 0;
            }
            zz=pp[i];
            zz+=x;
            if(mm[zz]){
                cout<<mm[zz]<<" "<<mm[pp[i]];
                return 0;
            }
        }
        return 0;
}


Measured memory_bytes: 3792
import java.util.*;
class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] a = new int[n];
        Set<Integer> as = new HashSet<Integer>();
        String ans = "YES";
        for(int i = 0 ;i<a.length;i++){
            a[i] = sc.nextInt();
            as.add(a[i]);
        }
        if(a.length!=as.size()){
            ans = "NO";
        }
        System.out.println(ans);
    }
}

Measured memory_bytes: 104668
#include <bits/stdc++.h>
using namespace std;
#define repd(i,a,b) for(int i=a;i<b;i++)
#define repds(i,a,b) for(int i=a+1;i<=b;i++)
#define rep(i,N) repd(i,0,N)
#define reps(i,N) repds(i,0,N)
#define debug(x) cout<<#x<<"="<<x<<endl
#define debugarr(arr,N,M){rep(i,N){rep(j,M){if(arr[i][j]==INF)printf(" INF");\
	else printf(" %3d",arr[i][j]);} cout<<endl;}}
#define debugarrs(arr,N,M){reps(i,N){reps(j,M){if(arr[i][j]==INF)printf(" INF");\
	else printf(" %3d",arr[i][j]);} cout<<endl;}}
#define pb push_back
#define pob pop_back
#define cint(a) int a;cin>>a
#define cint2(a,b) int a,b;cin>>a>>b
#define cint3(a,b,c) int a,b,c;cin>>a>>b>>c
typedef long long ll;
typedef pair<int,int> P;
const int INF=100000000;
const int dx[4]={ 0, 1, 0,-1};
const int dy[4]={ 1, 0,-1, 0};
//--------------------------------------//
int N,M,Q;

int dp[501][501];

int main(){
	cin>>N>>M>>Q;
	rep(i,M) {
		int l,r;
		cin>>l>>r;
		dp[l][r]++;
	}
	//debugarrs(dp,N,N);
	for(int i=N;i>=1;i--){
		int c=0;
		repds(j,i-1,N){
			if(j==N)dp[i][j]+=dp[i+1][j]+c;
			else {
				int _c=dp[i][j];
				dp[i][j]+=dp[i+1][j]+c;
				c+=_c;
			}
		}
	}
	//debugarrs(dp,N,N);
	rep(i,Q) {
		int p,q;
		cin>>p>>q;
		cout<<dp[p][q]<<endl;
	}
	return 0;
}


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

using namespace std;

int main(){

	long long int Q, H, S, D, N;
	cin >> Q >> H >> S >> D >> N;
	long long int ans = 0;
	H = min(H, Q * 2);
	S = min(S, H * 2);
	D = min(D, S * 2);
	N *= 4;
	long long int P = N / 8;
	N -= P * 8;
	ans += D * P;
	P = N / 4;
	N -= P * 4;
	ans += S * P;
	P = N / 2;
	N -= P * 2;
	ans += H * P;
	P = N;
	N -= P;
	ans += Q * P;
	cout << ans << endl;
	return 0;
}



Measured memory_bytes: 256
program main
    use,intrinsic :: iso_fortran_env
    implicit none
    integer(int64):: n,i,ans=0
    integer(int64), allocatable:: a(:)

    read*, n
    allocate(a(n))
    do i=1,n; read*, a(i); end do
    
    ans = sum(a)
    do i=1,n-1
        if (btest(a(i),0_8)) then
            if (a(i+1)==0) then
                ans=ans-1
            else
                a(i+1)=a(i+1)-1
            end if
        end if
    end do
    print'(i0)', ans/2
end program main

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

int main()
{
    string s, t;
    cin >> s >> t;

    sort(s.begin(), s.end());
    sort(t.begin(), t.end(), greater<char>());
    
    cout << (s < t ? "Yes" : "No") << endl;
    return 0;
}

Measured memory_bytes: 3588
#include<cstdio>
#include<vector>
#include<algorithm>
#include<utility>
#include<numeric>
#include<iostream>
#include<array>
#include<string>
#include<sstream>
#include<stack>
#include<queue>
#include<list>
#define _USE_MATH_DEFINES

#include<math.h>
#include<map>

#define SENTINEL 1000000001

#define min(a,b) (a)>(b)?(b):(a)
#define max(a,b) (a)>(b)?(a):(b)

using namespace std;

/*int find(int x) 
{
	if (x == parent[x])return x;
	else 
	{
		return parent[x] = find(parent[x]);
	}
}

bool isSame(int x, int y)
{
	return find(x) == find(y);
}

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

	if (x == y)return;

	if (Rank[x] < Rank[y]) 
	{
		parent[x] = y;
	}
	else
	{
		parent[y] = x;
		if (Rank[x] == Rank[y])Rank[x]++;
	}
}*/

struct UnionFind
{
	vector<int> parent;
	vector<int> rank;

	UnionFind(int n) :parent(n), rank(n, 0)
	{
		for (int i = 0; i < n; i++)
		{
			parent[i] = i;
		}
	}

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

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

		if (x == y)
		{
			return;
		}

		if (rank[x] < rank[y])
		{
			parent[x] = y;
		}
		else
		{
			parent[y] = x;
			if (rank[x] == rank[y])
			{
				rank[x]++;
			}
		}
	}

	bool same(int x, int y)
	{
		return find(x) == find(y);
	}
};

struct Edge
{
	int v1, v2, cost;
	Edge(int v1, int v2, int cost) :v1(v1), v2(v2), cost(cost){}
	bool operator<(const Edge& e)const
	{
		return cost < e.cost;
	}
};

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

	vector<Edge> e;
	UnionFind uf(n);

	for (int i = 0; i < n; i++)
	{
		for (int j = 0; j < n; j++)
		{
			int c;
			cin >> c;
			if (c != -1)
			{
				e.push_back(Edge(i, j, c));
			}
		}
	}

	sort(e.begin(), e.end());

	int cost = 0;
	for(auto& te:e)
	{
		if (!uf.same(te.v1, te.v2))
		{
			uf.unite(te.v1, te.v2);
			cost += te.cost;
		}
	}

	cout << cost << endl;

	return 0;
}


Measured memory_bytes: 3136
#include <iostream>
#include <set>
#include <queue>
#include <vector>
#include <algorithm>
#include <math.h>
#include <cmath>
#include <string>
#include <climits>
#include <sstream>
#include <iomanip>
#include <map>
#include <stack>
#include <tuple>
#include <numeric>
#include <functional>
#include <unordered_map>

using namespace std;

/*-----------------------------------------------------------------------------
　定義
 -------------------------------------------------------------------------------*/
#define ALL(a)			(a).begin(),(a).end()
#define REP(i, n)		for (int (i) = 0 ; (i) < (int)(n) ; ++(i))
#define REPN(i, m, n)	for (int (i) = m ; (i) < (int)(n) ; ++(i))
#define INF				(1000 * 1000 * 1000 * 2)
#define MOD				(1000 * 1000 * 1000 + 7)
#define Ceil(x, n)		(((((x))+((n)-1))/n))		/* Nの倍数に切り上げ割り算 */
#define CeilN(x, n)		(((((x))+((n)-1))/n)*n)		/* Nの倍数に切り上げ */
#define FloorN(x, n)	((x)-(x)%(n))				/* Nの倍数に切り下げ */
#define IsOdd(x)		(((x)&0x01UL) == 0x01UL)			
#define IsEven(x)		(!IsOdd((x)))						
#define M_PI			3.14159265358979323846
typedef long long		ll;
typedef pair<int, int>	P;

/*-----------------------------------------------------------------------------
　処理
 -------------------------------------------------------------------------------*/
// メイン
int main()
{
	int N, M;
	cin >> N >> M;
	cout << (1900 * M + 100 * (N - M)) * (1 << M) << endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <math.h>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
using namespace std;

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

int main(){
    ll a, b, c;
    cin >> a >> b >> c;
    if(c - a - b > 0 && 4*a*b < (c-a-b)*(c-a-b)){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    return 0;
}

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

int main() {
  int S, num;
  num = 0;
  cin >> S;
  
  if((S - 99) > 1){
    num = 1;
  }
  
  if((S - 100) >= 10){
    num = 1 + num;
  }else if(S < 101 && (S + 100) >= 110){
    num = 1 + num;
  }
  
  if((S % 2) == 1){
    num = 1 + num;
  }
  
  cout << num << endl;
}

Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10**9)

INF = 10**9 + 7


def to_graph(maze):
    H, W = len(maze), len(maze[0])

    g = [[INF] * (H * W) for _ in range(H * W)]

    for i, line in enumerate(maze):
        for j, s in enumerate(line):
            if i == j:
                g[i * W + j][i * W + j] = 0
            if s == '.':
                for neigh in [(-1, 0), (1, 0), (0, 1), (0, -1)]:
                    px, py = i + neigh[0], j + neigh[1]
                    if maze[px][py] == '.':
                        g[i * W + j][px * W + py] = 1

    return g


def main():
    H, W = map(int, input().split())
    maze = []
    maze.append(['#' for _ in range(W + 2)])
    for _ in range(H):
        maze.append(['#'] + list(input()) + ['#'])
    maze.append(['#' for _ in range(W + 2)])

    g = to_graph(maze)

    n = len(g)
    for k in range(n):
        for i in range(n):
            for j in range(n):
                g[i][j] = min(g[i][j], g[i][k] + g[k][j])

    current_max = 0
    for i, line in enumerate(g):
        for j, v in enumerate(line):
            if i != j and v < INF and v > current_max:
                current_max = v

    print(current_max)


if __name__ == '__main__':
    main()


Measured memory_bytes: 43740
#ifdef LOCAL
#define _GLIBCXX_DEBUG
#endif
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;++i)
#define rrep(i,n) for(int i=n-1;i>=0;--i)
#define reps(i,a,b) for(int i=a;i<b;++i)
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
using namespace std;
using ll = long long;
using P = pair<int, int>;
template<typename T> inline bool chmax(T &a,T b){if(a<b){a=b;return 1;}return 0;}
template<typename T> inline bool chmin(T &a,T b){if(b<a){a=b;return 1;}return 0;}
template<typename T> vector<T> make_vec(size_t a){return vector<T>(a);}
template<typename T,typename... Ts>
auto make_vec(size_t a,Ts... ts){return vector<decltype(make_vec<T>(ts...))>(a,make_vec<T>(ts...));}
template<typename T,typename U,typename... V>
typename enable_if<is_same<T,U>::value>::type fill_v(U &u,const V... v){u=U(v...);}
template<typename T,typename U,typename... V>
typename enable_if<!is_same<T,U>::value>::type fill_v(U &u,const V... v){for(auto &e:u)fill_v<T>(e,v...);}

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

    int q;
    cin >> q;
    set<int> st;
    while (q--) {
        int com, x;
        cin >> com >> x;
        if (com == 0) {
            st.insert(x);
            cout << st.size() << endl;
        } else {
            cout << st.count(x) << endl;
        }
    }
}



Measured memory_bytes: 12488
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rrep(i, n) for (int i = (int)(n - 1); i >= 0; i--)
#define all(x) (x).begin(), (x).end()
#define sz(x) int(x.size())
#define get_unique(x) x.erase(unique(all(x)), x.end());
typedef long long ll;
typedef complex<double> Complex;
const int INF = 1e9;
const ll MOD = 1e9 + 7;
const ll LINF = 1e18;
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 <class T>
vector<T> make_vec(size_t a) {
    return vector<T>(a);
}
template <class T, class... Ts>
auto make_vec(size_t a, Ts... ts) {
    return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}
template <typename T>
ostream& operator<<(ostream& os, vector<T> v) {
    for (int i = 0; i < sz(v); i++) {
        os << v[i];
        if (i < sz(v) - 1) os << " ";
    }
    return os;
}
template <typename T>
vector<T> Dijkstra(int s, vector<vector<pair<int, T>>>& g) {
    priority_queue<pair<T, int>, vector<pair<T, int>>, greater<pair<T, int>>>
        que;
    int n = sz(g);
    vector<T> d(n);
    rep(i, n) d[i] = LINF;
    d[s] = 0;
    que.push(make_pair(0LL, s));
    while (!que.empty()) {
        pair<T, int> p = que.top();
        que.pop();
        int v = p.second;
        if (d[v] < p.first) continue;
        for (auto e : g[v]) {
            if (chmin(d[e.first], d[v] + e.second)) {
                que.push(make_pair(d[e.first], e.first));
            }
        }
    }
    return d;
}
int main() {
    int n, m, s;
    cin >> n >> m >> s;
    chmin(s, 2999);
    auto id = [&](int i, int j) { return i * 3000 + j; };
    vector<vector<pair<int, ll>>> g(200200);
    rep(i, m) {
        int u, v;
        ll a, b;
        cin >> u >> v >> a >> b;
        u--;
        v--;
        rep(j, 3000) {
            if (j - a >= 0) {
                g[id(u, j)].emplace_back(id(v, j - a), b);
                g[id(v, j)].emplace_back(id(u, j - a), b);
            }
        }
    }
    rep(i, n) {
        ll c, d;
        cin >> c >> d;
        rep(j, 3000) {
            if (j + c < 3000) {
                g[id(i, j)].emplace_back(id(i, j + c), d);
            }
        }
    }

    auto d = Dijkstra(id(0, s), g);
    for (int i = 1; i < n; i++) {
        ll ans = LINF;
        rep(j, 3000) chmin(ans, d[id(i, j)]);
        cout << ans << endl;
    }
}


Measured memory_bytes: 29132
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<stdio.h>
 
using namespace std;
 
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)   FOR(i,0,n)
#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define MIN(a, b) ((a) < (b) ? (a) : (b))
#define SWAP(a,b) (a += b,b = a - b,a -= b)
#define ll long long

const int MOD = 1e9 + 7;

int main() {
    int m, n;
    cin >> n >> m;
    char a[50][50], b[50][50];
    REP(i, n) cin >> a[i];
    REP(i, m) cin >> b[i];

    REP(i, n - m + 1) {
        REP(j, n - m + 1) {
            bool exist = true;
            REP(k, m) {
                bool match = true;
                REP(l, m) {
                    if(a[i+k][j+l] != b[k][l]) {
                        match = false;
                        break;
                    }
                }
                if(match == false) {
                    exist = false;
                    break;
                }
            }
            if(exist == true) {
                cout << "Yes" << endl;
                return 0;
            }
        }
    }
    cout << "No" << endl;
}

Measured memory_bytes: 256
// https://onlinejudge.u-aizu.ac.jp/courses/lesson/8/ITP2/3/ITP2_3_A
#include <iostream>
#include <vector>
#include <algorithm>

int main()
{
    std::vector<int> num(3, 0);

    for (auto &x : num)
    {
        std::cin >> x;
    }

    std::cout << *std::min_element(num.begin(), num.end()) << " "
              << *std::max_element(num.begin(), num.end()) << std::endl;
}


Measured memory_bytes: 3092
/*==============================================*\
Codeforces ID:    mdshihab
                                                  |
Name:     Md. Shihabul Minhaz                     |
Study:      CSE, JKKNIU                           |
Address:  Trishal, Mymensingh, Bangladesh         |
                                                  |
 mail:   mdshihabul20171@gmail.com                |
 FB  :   fb.com/mdshihabul.minhaz.7               |
 github: Shihabulminhaz                           |
stopstalk :  mdshihab                             |
                                                  |
@uthor   Md. Shihabul Minhaz (shihab)             |
\*===============================================*/


#include<bits/stdc++.h>
using namespace std;
#define fi(a) scanf("%d",&a);
#define fli(a) scanf("%ld",&a);
#define fll(a) scanf("%lld",&a);
#define pi(a) printf("%d\n",a);
#define ppi(i,a) printf("Case %d: %d\n",i,a);
#define ll long long
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
int shihab;
void FI()
{
#ifndef ONLINE_JUDGE
    freopen("C:\\Users\\SHIHAB\\Desktop\\input.in","r",stdin);
#endif // ONLINE_JUDGE
}

int main()
{
    fast
    FI(); /// skip this line for compile
    int n;
    cin >> n;
    cout << "ABC" << n << endl;
    return 0;
    //code end
}
//okbye


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

using namespace std;
#define rep(i,n) for(long long i=0; i<(long long)(n);i++)
//rep…「0からn-1まで」の繰り返し
#define rep2(i,s,n) for(long long i=s; i<=(long long)(n);i++)
//rep2…「sからnまで」の繰り返し
#define repr(i,s,n) for(long long i=s;i>=(long long)(n);i--)
//repr…「ｓからnまで」の降順の繰り返し

typedef long long ll;

const int inf = 1e9+7;
const int mod = 1e9+7;

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

    vector<int>a(n);
    rep(i,n)cin>>a[i];

    ll yen=1000;
    ll kabusu=0;

    rep(i,n){

        if(i==n-1){
            ll urine=kabusu*a[i];
            yen+=urine;
        }

        else if(a[i]<a[i+1]){
            ll kounyu=yen/a[i];
            kabusu+=kounyu;
            yen-=kounyu*a[i];
        }

        else if(a[i]>a[i+1]){
            ll urine=kabusu*a[i];
            yen+=urine;
            kabusu=0;
        }
    }

    cout<<yen<<endl;
}


Measured memory_bytes: 3620
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
#define INF 2100000000
#define MOD 1000000007

int main(){
  ll n,m;
  cin>>n>>m;
  vector<ll> x(n),y(m);
  for(int i=0;i<n;i++){
    cin>>x.at(i);
  }
  for(int i=0;i<m;i++){
    cin>>y.at(i);
  }
  ll X=0;
  ll Y=0;
  for(ll i=0;i<n-1;i++){
    X+=(i+1)*(n-i-1)%MOD*(x.at(i+1)-x.at(i))%MOD;
    X%=MOD;
  }
  for(ll i=0;i<m-1;i++){
    Y+=(i+1)*(m-i-1)%MOD*(y.at(i+1)-y.at(i))%MOD;
    Y%=MOD;
  }
  cout<<X*Y%MOD<<endl;
}


Measured memory_bytes: 1792
for e in iter(input,'0'):
 a=sorted([list(map(int,input().split()))for _ in[0]*int(e)],key=lambda x:x[0])
 b=sorted([list(map(int,input().split()))for _ in[0]*int(input())],key=lambda x:x[0])
 for s,t in b:
  u,v=a[0]
  x,y=s-u,t-v
  for u,v in a:
   if[u+x,v+y]not in b:break
  else:print(x,y)


Measured memory_bytes: 5900
let cosX a b c = a ** 2. +. b ** 2. -. c ** 2.
let sinX c = sqrt (1. -. c ** 2.)
let () =
  Scanf.scanf "%d %d %d\n"
    (fun a b c ->
       let af = float_of_int a in
       let bf = float_of_int b in
       let cf = float_of_int c in
       0.5 *. af *. bf *. sinX (cosX af bf cf))
  |> int_of_float |> print_int

Measured memory_bytes: 384
#include <iostream>

using namespace std;

int findSumOfDigits(int n){
    int sum = 0;
    while(n > 0){
        sum += n % 10;
        n /= 10;
    }
    return sum;
}

int main(){
    int N;
    cin >> N;
    int min = 1000000;
    int sum;

    for(int i=1; i < N; i++){
        sum = findSumOfDigits(i) + findSumOfDigits(N-i);
        if(sum < min) min = sum;
    }

    cout << min << endl;
}

Measured memory_bytes: 256