akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
using namespace std;

int main() {
    int N, M;
    cin >> N >> M;
    vector<string> A(N);
    vector<string> B(M);
    for(int i = 0; i < N; i++){
        cin >> A.at(i); 
    }
    for(int i = 0; i < M; i++){
        cin >> B.at(i);
    }
    bool ans = false; 
    for(int i = 0; i < N-M+1; i++){
        for (int j = 0; j < N-M+1; j++){
            for (int k = 0; k < M; k++){
                bool flag = true;
                for (int l = 0; l < M; l++){
                    if (A.at(i+k)[j+l] != B.at(k)[l]){
                        flag = false;
                        break;
                    }
                    if (k == M-1 && l == M-1) {
                        ans = true;
                    }
                }  
                if (flag == false) break;
            }
        }
    }
    if (ans) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0; 
}




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


int main(){
  string S;
  cin >> S;
  for(int ii=0; ii<S.size()-1; ii++){
    if(S[ii]=='A'&&S[ii+1]=='C'){
      cout << "Yes" << endl;
      return 0;
    }
  }
  cout << "No" << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
///////////////////////////////////////////
const long long int INF = 1LL<<60;
const long long int Mod = 1000000007;
using ll = long long int; using ci = const int;
using vi = vector<int>;  using Vi = vector<long long int>;
using P = pair<int, int>;  using PLL = pair<ll, ll>;
using matrix = vector<vector<ll>>;
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)
#define all(x) (x).begin(),(x).end()
#define rp(i,N) for(ll i = 0; i < (ll)N; i++)
#define repi(i,a,b) for(ll i = ll(a); i < ll(b); ++i)
template<class T>bool chmax(T &former, const T &b) { if (former<b) { former=b; return true; } return false; }
template<class T>bool chmin(T &former, const T &b) { if (b<former) { former=b; return true; } return false; }
template<class T>T sqar(T x){ return x*x; }//sqrt(x)は平方根;
#define Sort(v) std::sort(v.begin(), v.end(), std::greater<decltype(v[0])>()) //降順でVをソート
#define p_queue(v) priority_queue<v, vector<v>, greater<v> >
template<class T> inline void princ(T x){cout<<x<<" ";}; 
template<class T> inline void print(T x){cout<<x<<"\n";};
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
template<class T> inline void YES(T condition){ if(condition) cout << "YES" << endl; else cout << "NO" << endl; }
///////////////////////////////////////////////////////////////////////////////////

void solve(){
    ll x,k,d;
    cin >> x >> k >> d;
    if(x<0) x=-x;
    if(x/k>=d) print(x-k*d);
    else{
        if(k&1){
            print(min((x+d)%(2*d),2*d-(x+d)%(2*d)));
        }
        else print(min(x%(2*d),2*d-x%(2*d)));
    }
    return;
}
int main(){
    cin.tie(0);ios::sync_with_stdio(false);
    std::cout<<std::fixed<<std::setprecision(30);
    solve();
    return 0;
}

Measured memory_bytes: 3612
#include <algorithm>
#include <cassert>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
using namespace std;
typedef long long ll;

#define rep(i, n) for(ll i = 0; i < n; i++)
#define REP(i, n) for(ll i = 1; i < n + 1; i++)
#define PI 3.14159265359
#define EPS 0.0000000001
#define MOD 1000000007
//cout << std::fixed << std::setprecision(15) << y << endl;



int main(){
    string S;
    cin >> S;

    ll l = 0, r = S.size() - 1;
    ll ans = 0;
    while(l < r){
        if(S[l] != S[r]){
            ans++;
        }
        l++;
        r--;
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3628
A = sorted(map(int, input().split()))

x = 0

while A[0] < A[2] - 1:
    A[0] += 2
    x += 1

while A[1] < A[2] - 1:
    A[1] += 2
    x += 1

if A[0] == A[1] == A[2]:
    x = x

elif A[0] == A[1]:
    x = x + 1

else:
    x = x + 2

print(x)

Measured memory_bytes: 3060
#include<iostream>
#include<vector>
#include<map>
#include<utility>
#include<algorithm>
#include<queue>
#include<stack>
#include<string>
#include<stdlib.h>
#include<stdio.h>
#include<cmath>
#include<cstdlib>
#include<typeinfo>
#include<sstream>
#include<list>
#include<set>
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define fori(i,k,n) for(int i=k;i<(int)n;i++)
using namespace std;
int in()
{
    int x;cin>>x;
    return x;
}
int stringInt(string a)
{
    return atoi(a.c_str());
}
string intString(int a)
{
    stringstream ss;
    ss<<a;
    return ss.str();
}
vector<int> SieveOfEratosthenes(int x)
{
    vector<int> a;
    vector<int> b(x+1,0);
    for(int i=2;i<=x;i++)
    {
        if(b[i]==0)
        {
            a.push_back(i);
            for(int l=i;l<=x;l+=i)
            {
                b[l]=1;
            }
        }
    }
    return a;
}
 
struct Node
{
    int k;
    Node *p,*r,*l;
};
Node *root,*NIL;
 
void ins(int k)
{
    Node *y,*x,*z;
    z=(Node*)malloc(sizeof(Node));
    z->k=k;
    z->l=z->r=NIL;
    y=NIL;
    x=root;
    while(x!=NIL)
    {
        y=x;
        if(x->k > k)
        {
            x=x->l;
        }
        else
        {
            x=x->r;
        }
    }
    z->p=y;
    if(y==NIL)
    {
        root=z;
    }
    else if(z->k < y->k)
    {
        y->l=z;
    }
    else
    {
        y->r=z;
    }
    return ;
}
void ino(Node* root)
{
    if(root==NIL)return ;
    ino(root->l);
    cout<<" "<<root->k;
    ino(root->r);
    return ;
}
void pre(Node* root)
{
    if(root==NIL)return ;
    cout<<" "<<root->k;
    pre(root->l);
    pre(root->r);
    return ;
}
bool fin(Node* root,int x)
{
    if(root->k!=x)
    {
        if(root->k>x&&root->l==NIL)return false;
        if(root->k<x&&root->r==NIL)return false;
    }
 
    if(root->k==x)return true;
 
    else if(root->k > x)
    {
        return fin(root->l,x);
    }
    else return fin(root->r,x);
    return false;
 
}
int main()
{
    int n;
    root=NIL;
    cin>>n;
    rep(i,n)
    {
        string a;
        cin>>a;
        switch(a[0])
        {
        case'i':
            int x;
            cin>>x;
            ins(x);
            break;
        case'p':
 
            ino(root);
            cout<<endl;
 
            pre(root);
            cout<<endl;
            break;
        case'f':
            if(fin(root,in()))cout<<"yes"<<endl;
            else cout<<"no"<<endl;
            break;
        case'd':
            break;
        }
    }
    return 0;
}


Measured memory_bytes: 21944
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define LEN 100005

typedef struct pp{
    char name[100];
    int t;
} p;

p Q[LEN];
int head, tail, n;

void enqueue(p x){
    Q[tail] = x;
    tail = (tail + 1) % LEN;
}

p dequeue(){
    p x = Q[head];
    head = (head + 1) % LEN;
    return x;
}

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

int main()
{
    int elaps = 0, c;
    int i, q;
    p u;
    scanf("%d %d", &n, &q);

    for( i = 1; i <= n; i++){
        scanf("%s", Q[i].name);
        scanf("%d", &Q[i].t);
    }
    head = 1; tail = n + 1;

    while(head != tail){
        u = dequeue();
        c = min(q,u.t);
        u.t -= c;
        elaps += c;
        if( u.t > 0) enqueue(u);
        else{
            printf("%s %d\n", u.name, elaps);
        }
    }


    return 0;
}



Measured memory_bytes: 11880
import java.util.*;
 
public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        int max = 0;
        for(int i = 0; i < s.length(); i++){
        	int count = 0;
            for(int x = i; x < s.length(); x++){
                if(s.charAt(x) == 'A' || s.charAt(x) == 'C' || s.charAt(x) == 'G' || s.charAt(x) == 'T'){
                	count++;
                }else{
                	break;
                }
            }
            if(max < count){
            	max = count;
            }
        }
        System.out.println(max);
    }
}

Measured memory_bytes: 35612
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <math.h>
#include <complex>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <bitset>
#include <functional>
#include <assert.h>
#define int long
#define ll long long
#define rep(i, n) for(int i = 0; i < n; i++)
#define pb push_back
#define fi first
#define se second
const int INF = 1e9;
using namespace std;

struct UnionFind{
   vector<int> par;
   UnionFind(int n):par(n,-1){}
   int find(int x){
       if(par[x]<0)return x;
       return par[x]=find(par[x]);
   }
   bool unite(int x,int y){
       x=find(x);
       y=find(y);
       if(x==y)return false;
        par[x]+=par[y];
        par[y]=x;
       return true;
   }

   bool same(int x,int y){
       return find(x)==find(y);
   }
   int size(int x){
       return -par[find(x)];
   }
};

signed main() {
    int N,M; cin >> N >> M;
    bool R[N];
    rep(i,N) R[i] = false;
    R[0] = true;
    vector<int> v(N,1);
    rep(i,M){
        int a,b; cin >> a >> b;
        a--; b--;
        if(R[a]) R[b] = true;
        v[a]--; v[b]++;
        if(v[a]==0) R[a] = false;
    }
    int ans=0;
    rep(i,N){
        if(R[i]) ans++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 1152
W, H, N = map(int, input().split())
x0, x1, y0, y1 = 0, W, 0, H
for i in range(N):
    x, y, a = map(int, input().split())
    if a == 1:
        x0 = max(x0, x)
    if a == 2:
        x1 = min(x1, x)
    if a == 3:
        y0 = max(y0, y)
    if a == 4:
        y1 = min(y1, y)

if x1 > x0 and y1 > y0:
    print((x1 - x0) * (y1 - y0))
else:
    print(0)

Measured memory_bytes: 3064
//
//  main.cpp
//  Study
//
//  Created by 佐々木勇星 on 2020/03/12.
//  Copyright © 2020 佐々木勇星. All rights reserved.
//

#include <iostream>
#include <vector>
#include <cmath>
#include <sstream>
#include <iomanip>
#include <algorithm>
#include <map>

using namespace std;


int main(int argc, const char * argv[]) {


    int n;
    cin >> n;
    
    string s;
    cin >> s;
    
    long long r=0, g=0, b=0;
    
    for(int i=0; i<n; i++)
    {
        if(s[i] == 'R') r++;
        else if(s[i] == 'G') g++;
        else if(s[i] == 'B') b++;
    }
    
    // すべての組み合わせの数
    long long con1 = r * g * b;
    
    for(int i=0; i<n; i++)
    {
        for(int j=1; i+j+j<n; j++)
        {
            if(s[i] != s[i+j] && s[i+j] != s[i+j+j] && s[i] != s[i+j+j]) con1--;
        }
    }
    
    cout << con1 << endl;
    
    return 0;
}


Measured memory_bytes: 3604
n=int(input())
s=input()
wcou=0
answer=0

for i in range(n):
    if s[i]=='E':
        wcou+=1

answer=wcou
if s[0]=='E':
    answer-=1

now=answer
#print(answer)

for i in range(n-1):
    if s[i]=='W':
        now+=1
    if s[i+1]=='E':
        now-=1
    if now<=answer:
        answer=now
    #print(now)

print(answer)

Measured memory_bytes: 3828
import java.util.*;
public class Main{
	public static void main(String[] args){
    	Scanner sc = new Scanner(System.in);
      int n = sc.nextInt();
      int m = sc.nextInt();
      int c = sc.nextInt();
      int[] b = new int[m];
      int[][] a = new int[n][m];
      int[] sum = new int[n];
      for(int i = 0;i < m;i++){
      	b[i] = sc.nextInt();
      }
      for(int i = 0;i < n;i++){
      	for(int j = 0;j < m;j++){
        	a[i][j] = sc.nextInt();
        }
      }
      int count = 0;
      for(int i = 0;i < n;i++){
      	for(int j = 0;j < m;j++){
        	sum[i] += a[i][j]*b[j];
        }
        if(sum[i]+c > 0){
        	count++;
        }
      }
      System.out.println(count);
    }
}

Measured memory_bytes: 23892
#include <bits/stdc++.h>
using namespace std;
#define vsort(vec) sort(vec.begin(), vec.end())
#define vreverse(vec) reverse(vec.begin(), vec.end())
using ll =long long;
const ll INF =1001001001;

//最大公約数
ll gcd(ll a, ll b){
   if (a%b==0){
       return(b);
   }else{
       return(gcd(b,a%b));
   }
}
//最小公倍数
ll lcm(ll a, ll b){
   return a*b/gcd(a,b);
}

//素数判定
ll isprime(ll n){
  bool prime=true;
  for(int i=2;i<n;i++){
    if(n%i==0){
      prime=false; break;
    }
  }
if(prime){cout<<n<<" is prime"<<endl;
         }else{cout<<n<<" is not prime"<<endl;}

}
//階乗　20くらいが限界
ll factorial(ll n){
  ll a=1;ll b=n;
  for(int i=0;i<n;i++){
    a*=b;
    b--;
  }
  return a;
}

//組み合わせ　nCr
ll comb(ll a,ll b){
  ll c;
  c=factorial(a)/(factorial(a-b)*factorial(b));
  return c; 
}




/*10億7。　　　100000007
2*2行列 H*W
vector<vector<int>> vec(H,vector<int>(W));
for(int i=0;i<H;i++){
for(int j=0;j<W;j++){
cin>>vec[i][j];
  }
}

文字列→数列
string S;int A=atoi(S.c_str());
数列→文字列
int A;string S=to_string(A);
数字判定　isdigit(a)
pair宣言　pair<int,int> p(5,7);
ソート　sort(vec.begin(),vec.end());
*/

int main(){
cout<<fixed<<setprecision(10);

int N,M,X;cin>>N>>M>>X;
  vector<int> vec(M);
  for(int i=0;i<M;i++){
    cin>>vec[i];
  }
  int counter=0;
  for(int i=0;i<M;i++){
    if(vec[i]<X){
      counter++;
    }
  }
  int m=min(counter,M-counter);
  cout<<m<<endl;
      
}




Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#define N 200

int main(void){
	int A[N]={0},B[N],max,i,n,k;
	char str[N];

	for( ;fgets(str,sizeof(str),stdin)!=NULL; ){
		sscanf(str,"%d",&n);
		A[n]+=1;
	}
	k=1; max=0;
	for(i=1;i<=100;i++){
		if(A[i]>max){
			B[0]=i;
			max=A[i];}
	}
	for(i=1;i<=100;i++){
		if(i==B[0])
			continue;
		if(A[i]==max)
			B[k++]=i;
	}
	for(i=0;i<k;i++){
		printf("%d\n",B[i]);
	}
	return 0;			
}

Measured memory_bytes: 604
n,l=map(int,input().split())
ans=0
for i in range(n-1):
    if l>=0:
        ans+=l+(i+1)
    elif l+n<0:
        ans+=l+i
    else:
        if l+i<0:
            ans+=l+i
        else:
            ans+=l+(i+1)
print(ans)

Measured memory_bytes: 3064
#!/usr/bin/env python3
import sys, math, itertools, collections, bisect
input = lambda: sys.stdin.buffer.readline().rstrip().decode('utf-8')
inf = float('inf') ;mod = 10**9+7
mans = inf ;ans = 0 ;count = 0 ;pro = 1

class InverseTable:
    __slots__ = ['In', 'fac', 'Ifac']

    def __init__(self, mod, maxnum):
        self.In = [0, 1]; self.fac = [1, 1]; self.Ifac = [1, 1]
        for i in range( 2, maxnum + 1 ):
            self.In.append( ( -self.In[mod % i] * (mod//i) ) % mod )
            self.fac.append( ( self.fac[-1] * i ) % mod )
            self.Ifac.append( (self.Ifac[-1] * self.In[-1]) % mod )
        
    def cmb(self, n, r):
        if ( r<0 or r>n ): return 0
        r = min(r, n-r)
        return self.fac[n] * self.Ifac[r] * self.Ifac[n-r] % mod
    
    def per(self, n, r):
        if ( r<0 or r>n ): return 0
        return self.fac[n] * self.Ifac[n-r] % mod

IT = InverseTable(mod, 10**6)
# maxnum=10**6だとテーブル生成に200ms程かかるので（Pythonだと1000msほど）
# 最大生成領域は問題ごとに要検討

n,m,k=map(int,input().split())
N0=n*m
for i in range(n):
  for j in range(m):
    ans += IT.cmb(N0-2,k-2)*\
      (((n-(i+1))*(n-(i+1)+1)+i*(i+1))//2*m+\
        ((m-(j+1))*(m-(j+1)+1)+j*(j+1))//2*n)
    ans %= mod
print(ans*IT.In[2]%mod)
# print(4*IT.Ifac[3]*9%mod)

Measured memory_bytes: 127556
import math
import fractions

def makeDivisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    # divisors.sort()
    return divisors

def bitlist(x,digit):
    res = [0 for i in range(digit)]
    now = x
    for i in range(digit):
        res[i]=now%2
        now = now >> 1
    return res

def makeNeighbor(es,n):
    nlist = [[] for i in range(n+1)]
    for i in es:
        nlist[i[0]].append(i[1])
        nlist[i[1]].append(i[0])
    return nlist
    
#a = list(map(int, input().split()))
# --------------------------------------------

a,b,x = list(map(int, input().split()))

if(x<=a*a*b/2):
    theta = math.atan(x/(a*b/2)/b)
    print(90.0 - theta*(180/math.pi))
else:
    theta = math.atan((a*a*b-x)/(a*a/2)/a)
    print(theta*(180/math.pi))

Measured memory_bytes: 64620
#include <bits/stdc++.h>
#include <algorithm>
#define rep(i, n) for (int i=0; i<n; ++i)
#define all(obj) (obj).begin(),(obj).end()
using namespace std;
typedef long long ll;

int main(){
    int N, K;
    cin >> N >> K;
    vector<int>A(N, 0);
    rep(i, K){
        int d, a;
        cin >> d;
        rep(i, d){
            cin >> a;
            A[a-1]++;
        }
    }
    int cnt= 0;
    rep(i, N){
        if(A[i]==0) cnt++;
    }
    cout << cnt << endl;
    return 0;
}




Measured memory_bytes: 3624
n, m = map(int, input().split())
a = list(map(int, input().split()))
a.sort(reverse=True)
sum_val = sum(a)

flag = True
for i in range(m):
  if a[i] < sum_val / (4 * m):
    flag = False

if flag:
  print("Yes")
else:
  print("No")

Measured memory_bytes: 3060
import sys
# from functools import lru_cache, cmp_to_key
# from heapq import merge, heapify, heappop, heappush
from math import sqrt, sin, cos, pi
from collections import defaultdict as dd, deque, Counter as C
# from itertools import combinations as comb, permutations as perm
# from bisect import bisect_left as bl, bisect_right as br, bisect
# from time import perf_counter
# from fractions import Fraction

# sys.setrecursionlimit(pow(10, 6))
# sys.stdin = open("input.txt", "r")
# sys.stdout = open("output.txt", "w")
mod = pow(10, 9) + 7
mod2 = 998244353


def data(): return sys.stdin.readline().strip()


def out(*var, end="\n"): sys.stdout.write(' '.join(map(str, var)) + end)


def l(): return list(sp())


def sl(): return list(ssp())


def sp(): return map(int, data().split())


def ssp(): return map(str, data().split())


def l1d(n, val=0): return [val for i in range(n)]


def l2d(n, m, val=0): return [l1d(n, val) for j in range(m)]


def calcAngle():
    global h, m
    if h == 12:
        h = 0
    if m == 60:
        m = 0
    hour_angle = 0.5 * (h * 60 + m)
    minute_angle = 6 * m
    angle = abs(hour_angle - minute_angle)
    return min(360 - angle, angle)


a, b, h, m = sp()
temp = calcAngle()
temp = (pi * temp) / 180
answer = sqrt(pow(a, 2) + pow(b, 2) - 2 * a * b * cos(temp))
out(answer)


Measured memory_bytes: 65776
def Palindrome_philia():  
    S = input()
    length = len(S)//2
    count = 0
    for i in range(1,length+1, 1):
        if S[i-1] != S[-i]:
            count += 1
    print(count)


if __name__ == "__main__":
    Palindrome_philia()

Measured memory_bytes: 2940
#include<iostream>
#include<string>
#include<algorithm>    
#include<cmath>
#include<map>
#include<vector>
#include<math.h>
#include<stdio.h>
#include<stack>
#include<queue>
#include<tuple>
#include<cassert>
#include<set>
//#include<bits/stdc++.h>
using ll = long long;
using namespace std;
const ll INF = 10000000000000000;
const ll mod = 1000000007;
//printf("%.10f\n", n);
signed main() {
	ll n = 0, m, a = 0, b = 0, cnt = 0, ans = 0; string s; cin >> s;
    n = s.size() - 1;
    for (int i = 0; i <= (1 << n); i++) {
        vector<ll> sep = { }; cnt = 0; a = 0;
        for (int j = 0; j <= n - 1; j++) {
            if ((i & (1 << j)) > 0) {
                sep.push_back(j);
            }
        }
        sep.push_back(n);
        if (i == 0) { continue; }
        for (int h = 0; h <= n; h++) {
            cnt *= 10; cnt += (s[h] - '0');
            if (h == sep[a]) { a++; ans += cnt; cnt = 0; }
        }
    }
    cout << ans << endl;
	cin >> n; return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using V = vector<int>;
using Vll = vector<ll>;
using Vld = vector<ld>;
using Vbo = vector<bool>;
using VV = vector<V>;
using VVll = vector<Vll>;
using VVld = vector<Vld>;
using VVbo = vector<Vbo>;
using P = pair<int, int>;
using Pll = pair<ll, ll>;
using Pld = pair<ld, ld>;
#define rep2(i, m, n) for(ll i=int(m); i<int(n); ++i)
#define drep2(i, m, n) for(ll i=int(m)-1; i>=int(n); --i)
#define rep(i, n) rep2(i, 0, n)
#define drep(i, n) drep2(i, n, 0)
#define all(a) a.begin(), a.end()
struct fast_ios { fast_ios(){ cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;
template<typename T> inline bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; }
template<typename T> inline bool chmax(T &a, T b) { if (a < b) { a = b; return true; } return false; }
template<typename T1, typename T2> istream &operator>>(istream &is, pair<T1, T2> &p) { is >> p.first >> p.second; return is; }
template<typename T1, typename T2> ostream &operator<<(ostream &os, const pair<T1, T2> &p) { os << "(" << p.first << ", " << p.second << ")"; return os; }
template<typename T> istream &operator>>(istream &is, vector<T> &v) { for (auto &e : v) is >> e; return is; }
template<typename T> ostream &operator<<(ostream &os, const vector<T> &v) { for (auto &e : v) os << e << " "; return os; }
template<typename T> inline int count_between(vector<T> &a, T l, T r) { return lower_bound(all(a), r) - lower_bound(all(a), l); } // [l, r)
inline int Log2(ll x) { int k; for (k = 0; x > 0; ++k) x >>= 1; return k; } // number of binary digits
const int INF  = 1<<30;
const ll INFll = 1ll<<62;
const ld EPS   = 1e-10;
const int MOD  = int(1e9)+7;


int main() {
  ll a, b, c, k; cin >> a >> b >> c >> k;

  ll ans = 0;
  if (k < a) ans = k;
  else if (k <= a + b) ans = a;
  else ans = a - (k - (a+b));

  cout << ans << "\n";
  return 0;
}


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

int main(){
    string S;
    cin >> S;
    string ans = "AC";
    int L = S.size();
    if(S[0] != 'A'){
        ans = "WA";
    }
    int cnt = 0;
    for(int i = 1; i < L; ++i){
        if(isupper(S[i])){
            if(i == 1 || i == L - 1 || S[i] != 'C'){
                ans = "WA";
            }
            ++ cnt;
        }
    }
    if(cnt != 1){
        ans = "WA";
    }
    cout << ans << endl;
}

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

string toString(int n){
  string ret = "";
  while(n){
    ret += (n % 10) + '0';
    n /= 10;
  }
  while(ret.size() < 4) ret += "0";
  reverse(ret.begin(), ret.end());
  return ret;
}

int main(){
  string s;

  while(cin >> s){
    if(s == "0000") break;    
    
    if(s[0] == s[1] && s[1] == s[2] && s[2] == s[3]){
      cout << "NA" << endl;
      continue;
    }
    
    int cnt = 0;
    while(s != "6174"){
      string L = s, S = s;
      sort(L.rbegin(), L.rend());
      sort(S.begin(), S.end());
      int nex = atoi(L.c_str()) - atoi(S.c_str());
      s = toString(nex);
      cnt++;
    }
    cout << cnt << endl;
  }
  return 0;
}

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

#define ll long long

#define fr(i,a,b) for (ll i = (a), _b = (b); i <= _b; i++)
#define frr(i,a,b) for (ll i = (a), _b = (b); i >= _b; i--)
#define rep(i,n) for (ll i = 0, _n = (n); i < _n; i++)
#define repr(i,n) for (ll i = n - 1; i >= 0; i--)
#define fill(ar,val) memset(ar, val, sizeof(ar))
#define fill0(ar) fill((ar), 0)
#define debug(x) cout<<#x<<": "<<x<<endl

#define ld long double
#define pb push_back
#define mp make_pair
#define ff first
#define ss second

typedef pair<int, int> ii;
typedef pair<ii, int> iii;
typedef vector<ii> vii;
typedef vector<int> vi;

#define INF 1000000000000000000
#define PI 3.14159265358979323846L

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

    ll n;
    cin >> n;

    string s;
    cin >> s;

    ll pre[n+1];
    pre[0] = 0;

    rep(i,n)
    {
    	pre[i+1] = pre[i];
    	if(s[i]=='.')
    		pre[i+1]++;
    	// cout << pre[i+1] << endl;
    }

    ll ans = INF;
    ans = pre[n] - pre[0];

    // cout << ans << endl;
    ll x = 0;

    rep(i,n)
    {
    	if(s[i]=='#')
    	{
    		x++;
    		// ans = min(ans, x+pre[n]-pre[i]);
    	}
    	ans = min(ans,x+pre[n]-pre[i+1]);
    }

    cout << ans << endl;

}


Measured memory_bytes: 2196
N = int(input())
A, B, C = [0]*N, [0]*N, [0]*N 
for i in range(N):
    A[i], B[i], C[i] = [int(j) for j in input().split()]

ABC = [A, B, C]
dp = [[0]*3 for _ in range(N+1)]

for i in range(N):
    for j in range(3):
        dp[i+1][j] = max(dp[i][j-1], dp[i][j-2]) + ABC[j][i]

print(max(dp[-1]))

Measured memory_bytes: 34656
n, m = map(int, input().split())
info = [list(map(int, input().split())) for i in range(m)]

min_i = 100000000000
max_i = 0
for i in range(m):
    min_i = min(min_i, info[i][1])
    max_i = max(max_i, info[i][0])


print(max(min_i - max_i + 1, 0))

Measured memory_bytes: 27332
#include<bits/stdc++.h>
#define N 3010
using namespace std;
const int MOD=1e9+7;
long long dp[N][N][2];
int n,m;
int ans;
int main(){
	scanf("%d%d",&n,&m);
	for(int i=0;i<n;i++) dp[0][i][0]=1;
	dp[0][n][1]=1;
	for(int i=1;i<=m;i++){
		for(int j=0;j<=n;j++){
			for(int l=(j==n?1:0);l<2;l++){
				if(j==0)       dp[i][j][l]=dp[i-1][j][l]  +dp[i-1][j+1][l];
				else if(j==n)  dp[i][j][1]=dp[i-1][j][1]  +dp[i-1][j-1][1]+dp[i-1][j-1][0];
				else           dp[i][j][l]=dp[i-1][j-1][l]+dp[i-1][j+1][l]+dp[i-1][j][l]*2;
				if(j==n-1)     dp[i][j][l]+=(l*2-1)*dp[i-1][j][0];
				dp[i][j][l]%=MOD;
			}
			ans+=dp[m][j][1],ans%=MOD;
		}
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 141568
#include <iostream>
#include <string>
using namespace std;
int main(int argc, char const *argv[]) {
  int n;
  string s;
  cin>>n>>s;
  int max=0;
  for(int i=1;i<n;i++){
    int x[26]={};
    int y[26]={};
    for(int j=0;j<i;j++){
      char c=s[j];
      int d=c-'a';
      x[d]+=1;
      // printf("x:%c %d\n",c,d);
      // cout<<d<<" "<<x[d]<<endl;
    }
    for(int j=i;j<n;j++){
      char c=s[j];
      int d=c-'a';
      y[d]+=1;
      // printf("y:%c %d\n",c,d);
      // cout<<d<<" "<<x[d]<<endl;
    }
    int count=0;
    for(int k=0;k<26;k++){
      if(x[k]>0&&y[k]>0)  count++;
    }
    if(max<count) max=count;
  }
  cout<<max<<endl;
  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(void){
  int n,m,add,i,j,sum=0,cnt=0;
  scanf("%d %d %d",&n,&m,&add);
  int a[n][m],kake[m];
  for(i=0;i<m;i++){
    scanf("%d",&kake[i]);
  }
  for(i=0;i<n;i++){
    sum=0;
    for(j=0;j<m;j++){
      scanf("%d",&a[i][j]);
      a[i][j]*=kake[j];
      sum+=a[i][j];
    }
    sum+=add;
    if(sum>0){
      cnt++;
    }
  }
  printf("%d",cnt);
  return 0;
}

Measured memory_bytes: 128
#include<stdio.h>

int main(){
   int a[10000];
   int n,m;
   int x = 0;
   scanf("%d %d", &n, &m);

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

   for(int i = 0; i < m; i++){
      x += a[i];
   }
   if(x > n){
      printf("-1\n");
   }else{
      printf("%d\n", n-x);
   }
   return 0;
}


Measured memory_bytes: 1716
import sys
import math
x = int(input())
if x == 2:
     print(2)
     sys.exit()
a = [i for i in range(2*x+1)]
for i in range(2,int(math.sqrt(2*x)) + 1):
     if a[i] != 0:
          for j in range(1,2*x // i + 1):
               a[i*j] = 0

for i in range(x):
     if a[x + i] != 0:
          print(a[x + i])
          break

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

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


Measured memory_bytes: 3112
#include "bits/stdc++.h"

using namespace std;

void drop(vector<vector<int>>& c) {
    int H = c.size();
    int W = c.front().size();
    for (int j = 0; j < W; ++j) {
        vector<int> temp;
        for (int i = 0; i < H; ++i) {
            if (c[i][j] > 0) {
                temp.push_back(c[i][j]);
            }
        }
        for (int i = 0; i < H; ++i) {
            if (i < H - temp.size()) {
                c[i][j] = 0;
            }
            else {
                c[i][j] = temp[i - (H - temp.size())];
            }
        }
    }
}

void logging(const vector<vector<int>>& c) {
    int H = c.size();
    int W = c.front().size();
    for (int i = 0; i < H; ++i) {
        for (int j = 0; j < W; ++j) {
            if (j > 0) {
                cout << " ";
            }
            cout << c[i][j];
        }
        cout << endl;
    }

}

int solve(int row, int col, int K, vector<vector<int>> c) {
    int H = c.size();
    int W = c.front().size();

    c[row][col] = 0;
    drop(c);

    bool erased = true;
    int mult = 1;
    int ans = 0;
    while (erased) {
        bool e = false;
        for (int i = 0; i < H; ++i) {
            int curr = c[i][0];
            int start = 0;
            int continuous = 1;
            set<int> targets;
            for (int j = 1; j < W; ++j) {
                if (curr > 0 && curr == c[i][j]) {
                    ++continuous;
                }
                else {
                    continuous = 1;
                    if (j - start >= K) {
                        for (int k = start; k < j; ++k) {
                            targets.insert(k);
                        }
                    }
                    start = j;
                }
                curr = c[i][j];
            }
            if (W - start >= K) {
                for (int k = start; k < W; ++k) {
                    targets.insert(k);
                }
            }
            int sum = 0;
            for (int t : targets) {
                sum += c[i][t];
                c[i][t] = 0;
                e = true;
            }
            ans += mult * sum;
        }
        erased = e;
        drop(c);
        mult *= 2;
    }
    return ans;
}

void Main() {
    int H, W, K;
    cin >> H >> W >> K;
    vector<vector<int>> c(H, vector<int>(W, 0));
    for (int i = 0; i < H; ++i) {
        string s;
        cin >> s;
        for (int j = 0; j < W; ++j) {
            c[i][j] = s[j] - '0';
        }
    }

    int ans = 0;
    for (int i = 0; i < H; ++i) {
        for (int j = 0; j < W; ++j) {
            ans = max(ans, solve(i, j, K, c));
        }
    }
    cout << ans << endl;
}

int main() {
    std::cout << std::fixed << std::setprecision(15);
    Main();
    return 0;
}


Measured memory_bytes: 3568
def main():
    a,v=map(int,input().split())
    b,w=map(int,input().split())
    t=int(input())
    distance=abs(a-b) if a>=b else abs(b-a)
    ve=v-w
    if ve<=0:
        print("NO")
        return
    if distance<=ve*t:
        print("YES")
        return
    else:
        print ( "NO" )
        return



main()

Measured memory_bytes: 8980
import java.util.*;
import static java.lang.System.*;
import static java.lang.Math.*;
public class Main {
public static void main(String[] args){
Scanner sc = new Scanner(in);

int H = Integer.parseInt(sc.next());
int W = Integer.parseInt(sc.next());
char[][] a=new char[H][W];
    for (int i = 0; i < H; i++) {
        String p=sc.next();
        for (int j = 0; j < W; j++) {
            a[i][j]=p.charAt(j);
        }
    }
    for (int i = 0; i < H; i++) {
        int c=0;
        for (int j = 0; j <W ; j++) {
            if(a[i][j]=='.')c++;
        }
        if(c==W){
            for (int j = 0; j < W; j++) {
                a[i][j]='-';
            }
        }
    }
    for (int i = 0; i < W; i++) {
        int c=0;
        for (int j = 0; j < H; j++) {
            if(a[j][i]=='.'||a[j][i]=='-')c++;
        }
        if(c==H){
            for (int j = 0; j < H; j++) {
                a[j][i]='-';
            }
        }
    }
    String[] s=new String[H];
    for (int i = 0; i < H; i++) {
        s[i]="";
        for (int j = 0; j < W; j++) {
            s[i]+=Character.toString(a[i][j]);
        }
    }
    for (int i = 0; i <H; i++) {
        s[i]=s[i].replaceAll("-","");
    }
    for (int i = 0; i < H; i++) {
        if(s[i].contains(".")||s[i].contains("#"))out.println(s[i]);
    }
}}

Measured memory_bytes: 32068
n,x=map(int,input().split())

a,p=[1],[1]
for i in range(n):
    a.append(2*a[i]+3)
    p.append(2*p[i]+1)

def F(N,X):
    if N==0:
        return 0 if X<=0 else 1

    elif X==1:
        return 0
    
    elif 1<X<=1+a[N-1]:
        return F(N-1,X-1)

    elif X==2+a[N-1]:
        return p[N-1]+1

    elif 2+a[N-1]<X<=a[N]-1:
        return F(N-1,X-(2+a[N-1]))+p[N-1]+1

    elif X==a[N]:
        return 2*p[N-1]+1

print(F(n,x))

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define ll long long 
#define endl "\n"
#define pb push_back
#define f(i,n) for(i=0;i<n;i++)
#define F(i,a,b) for(i=a;a<=b;i++)
#define arr(a,n) for( i=0;i<n;i++)cin>>a[i];
#define fi first
#define se second
#define mp make_pair
#define mod 1000000007
#define YES cout<<"YES"<<endl;
#define Yes cout<<"Yes"<<endl;
#define NO cout<<"NO"<<endl;
#define No cout<<"No"<<endl;
#define yes cout<<"yes"<<endl;
#define no cout<<"no"<<endl;
#define vi vector<ll>
#define ed end()
#define bg begin()
#define sz size()
#define ln length()
#define s() sort(a,a+n);
#define sr() sort(a,a+n,greater<ll>());
#define v()  sort(v.begin(),v.end());
#define vr() sort(v.begin(),v.end(),greater<ll>());
#define mod 1000000007
#define fast() ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
ll gcd(ll a, ll b){if(!b)return a;return gcd(b, a % b);}
ll power(ll x,ll y,ll p){ll res=1;x%=p;while(y>0){if(y&1)res=(res*x)%p;y=y>>1;x=(x*x)%p;}return res;}
int main() {
    /*#ifndef ONLINE_JUDGE
        // for getting input from input.txt
        freopen("input.txt", "r", stdin);
        // for writing output to output.txt
        freopen("output.txt", "w", stdout);
    #endif*/
        /* 
        Ofcourse it's Hard.
        It's supposed to be Hard.
        If it's easy everyone would do it.
        HARD IS WHAT MAKES IT GREAT

        YESTERDAY U SAID TOMORROW

        SLOWLY BECOMING THE PERSON I 
        SHOULD HAVE BEEN A LONG TIME AGO

        SAME TASK CAN'T BE FOUND DIFFICULT TWICE

        BTBHWSITW

        SPRH TU KAB P

        CP IS ALL ABOUT THINKING 
        YOU HAVE MUCH MORE POTENTIAL THAN U THINK

        AJIT SHIDDAT 10

        UR DAILY ROUTINE 


        */

fast();
//ll t;cin>>t;while(t--)
{
    ll h,c=0;
    cin>>h;
   /* while(h>0)
    {
        h/=2;
        c++;
    }b
   */
    if(h==1)
        cout<<1<<endl;
    else
    {
       // cerr<<(log(h)/(log(2)))<<endl;
     c=(log(h)/(log(2)));
    //cerr<<c<<endl;
    ll pw=1ll*pow(1ll*2,c+1);
    cout<<pw-1<<endl;
}
   //ll ans=-1ll*(1ll-pow(1ll*2,(c+1)));
   //cout<<ans<<endl;
}
return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#include <math.h>
#include <iomanip>
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; }
const int INF=1001001001;
const int mod = 1000000007;

int main() {
  int64_t x;
  cin>>x;
  int64_t ans=0;
  ans+=x/11;
  ans*=2;
  if(x%11!=0){
    if(x%11>=7){ans+=2;}
    else  {ans++;}
  }
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 3604
# It took me about 40 minutes to finsih this assignment.
# The task itself is relatively simple, since we have sample code on handouts.
# One problem I met was that in case 22, I had a "RecursionError" (maximum recursion depth exceeded in comparison).
# The solution was simple: import sys, and add a line "sys.setrecursionlimit(100000)".

import sys

line = input().split()
n = int(line[0])
q = int(line[1])
mat = [0]*n
for i in range(n):
	mat[i]=i
sys.setrecursionlimit(100000)

def root(a):
	if mat[a]==a:
		return a
	else:
		mat[a] = root(mat[a])
		return mat[a]

def union(a, b):
	mat[root(a)]=root(b)

def is_same(a,b):
	if root(a) == root(b):
		return 1
	else:
		return 0

for i in range(q):
	line = input().split()
	a = int(line[0])
	line[1]=int(line[1])-1
	line[2]=int(line[2])-1
	if a==0:
		union(mat[line[1]],mat[line[2]])
	if a==1:
		print(is_same(mat[line[1]],mat[line[2]]))

Measured memory_bytes: 13120
#include <cstdio>
#include <string>
#include <iostream>
#include <cmath>
#include <vector>
#include <stack>
#include <algorithm>

using namespace std;

int main(void) {
	int N, tmp;
	int sum = 0;

	cin >> N;
	tmp = N;

	while (tmp > 0) {
		sum += tmp % 10;
		tmp /= 10;
	}

	if (N % sum == 0) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
}

Measured memory_bytes: 256
#pragma warning(disable : 4996)
#include <bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> pll;
typedef pair<ld, ld> pld;
// https://atcoder.jp/contests/abc166/tasks/abc166_a
int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    string s;
    cin >> s;
    if(s == "ARC"){
        cout << "ABC";
    }
    else{
        cout << "ARC";
    }

	return 0;
}

Measured memory_bytes: 3640
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<set>
#include<queue>
#include<stack>
#include<bitset>
#include<functional>
#include<map>
#include<unordered_set>
using namespace std;
//int p = 998244353;
int p = 1000000007;
#define vel vector<int>
#define vvel vector<vel>
#define rep(i,n) for(int i=0;i<n;i++)
#define sor(v) sort(v.begin(),v.end())
#define mmax(a,b) a=max(a,b)
#define mmin(a,b) a=min(a,b)
#define mkp make_pair
#define pin pair<int,int>
#define qin pair<int,pin>
#define V vector
#define Endl endl
#define veb vector<bool>
#define rev(s) reverse(s.begin(),s.end())
int max_kai = 150000;
vel kai(max_kai, 1);
vel inv_kai;
int rui(int a, int n) {
	if (n == 0) { return 1; }
	int x = rui(a, n / 2);
	x *= x; x %= p;
	if (n % 2 == 1) { x *= a; x %= p; }
	return x;
}
int inv(int a) { return rui(a, p - 2); }
void make_kai() {
	for (int i = 1; i < max_kai; i++) { kai[i] = kai[i - 1] * i; kai[i] %= p; }
	inv_kai = kai;
	rep(i, max_kai) { inv_kai[i] = inv(kai[i]); }
}
int nCr(int n, int r) {
	int a = kai[n] * inv_kai[r]; a %= p;
	a *= inv_kai[n - r]; a %= p;
	return a;
}
vel pa;
int root(int x) {
	if (pa[x] == -1) { return x; }
	int ans = root(pa[x]); pa[x] = ans;
	return ans;
}
void marge(int x, int y) {
	x = root(x);
	y = root(y);
	if (x != y) {pa[x] = y;}
}
#define lower(h,val) lower_bound(h.begin(),h.end(),val)-h.begin()
#define upper(h,val) upper_bound(h.begin(),h.end(),val)-h.begin()
int num_lp(int a, vel &nex) {
	unordered_set<int> se;
	int ans = 0;
	while (true) {
		if (se.find(a) != se.end()) {
			break;
		}
		se.insert(a);
		a = nex[a];
		ans++;
	}
	return ans;
}
int find_cr(int a, vel &nex) {
	unordered_set<int> se;
	while (true) {
		if (se.find(a) != se.end()) {break;}
		se.insert(a);
		a = nex[a];
	}
	return num_lp(a, nex);
}
int inf = 2000000000;
vvel dp;
int solve(vvel &sum, int i, int j, bool is_f) {
	int h = sum.size(); h--;
	int w = sum[0].size();
	if (i == h || j == w) { return 0; }
	if (dp[i][j] == inf) {
		int ans1 = solve(sum, i + 1, j, !is_f);
		int ans2 = solve(sum, i, j + 1, !is_f);
		ans2 += sum[i][j];
		if (is_f) {
			dp[i][j] = min(ans1, ans2);
		}
		else {
			dp[i][j] = max(ans1, ans2);
		}
	}
	return dp[i][j];
}
int rui10(int a) {
	if (a == 0) { return 1; }
	return 10 * rui10(a - 1);
}
int gcd(int a, int b) {
	if (a < b) { swap(a, b); }
	if (b == 0) { return a; }
	return gcd(b, a%b);
}
signed main(){
	int w, h; cin >> w >> h;
	string t;
	t = "|";
	rep(i, w-2) { t += "."; }
	t += '|';
	V<string> s(h,t);
	t = "+";
	rep(i, w-2) { t += "-"; }
	t += '+';
	s[0] = t; s[h - 1] = t;
	cin >> s[(h - 1) / 2][(w - 1) / 2];
	rep(i,h) {
		cout << s[i]<<endl;
	}
	return 0;
}


Measured memory_bytes: 3200
#include <iostream>
#include <set>
#include <string>

using namespace std;

int main(int argc, char* argv[]) {
  string s;
  cin >> s;

  set<char> pasts;
  for (int i = 0; i < s.size(); ++i) {
    if (pasts.find(s[i]) == pasts.end())
      pasts.insert(s[i]);
    else {
      cout << "no" << endl;
      return 0;
    }
  }

  cout << "yes" << endl;

  return 0;
}

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

int main(){
  int n,m,a[100],b[100],tres,hres;

  for(;;){
    cin >> n >> m;
    if(n==0 && m==0)break;

    for(int i=0;i<n;i++)cin >> a[i];
    for(int i=0;i<m;i++)cin >> b[i];
    tres = hres = -1;

    for(int i=0;i<n;i++){
      for(int j=0;j<m;j++){
	swap(a[i],b[j]);
	int t=0, h=0;
	for(int k=0;k<n;k++)t += a[k];
	for(int k=0;k<m;k++)h += b[k];
	swap(a[i],b[j]);

	if(t==h){
	  if(tres<0 || tres+hres > a[i]+b[j]){
	    tres = a[i]; hres = b[j];
	  }
	}
      }
    }

    if(tres<0)cout << tres << endl;
    else cout << tres << " " << hres << endl;
  }
}

Measured memory_bytes: 1164
///******* In the name of Allah *******///

#include <bits/stdc++.h>
using namespace std;

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

void Ok()
{
    long int a[1013],b,c,d,e,f,g,h,t,s,i,j,k,l1,l2,m,n,r,sum = 0,ans_1,ans_2,ans_3,cnt = 0,Max,Min,flag,div,rcv,temp;
    double aa,bb,cc,dd,ee,tot;
    char aaa[3013],bbb[1013],ccc[1013],num;

    for(i=1;i<=3;i++)
    {
        cin>>a[i];
    }
    sort(a+1,a+3+1);
    if(a[1]==a[2] && a[2]==a[3]) cout<<"No"<<endl;

    else if(a[1]!=a[2] && a[2]!=a[3] && a[3]!=a[1]) cout<<"No"<<endl;

    else cout<<"Yes"<<endl;

    return;
}

int main()
{
    Ok();

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
long long a,b,c,d,e,i,j,ii,jj,zx,xc;
string s,h;
int main(){
	ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);
	cin>>a;
	cout<<a+a*a+a*a*a;
	return 0;
}

Measured memory_bytes: 3612
#include <bits/stdc++.h>
#define DUMP(x)  cout << #x << " = " << (x) << endl;
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define IFOR(i, m, n) for(int i = n - 1; i >= m; i-- )
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
#define FOREACH(x,a) for(auto& (x) : (a) )
#define ALL(v) (v).begin(), (v).end()
using namespace std;
typedef long long ll;
const ll INF = 1e18;
/* テンプレートここまで */
void yes(){
  cout << "Yes" << endl;
  exit(0);
}

void no(){
  cout << "No" << endl;
  exit(0);
}
int main() {
  string s; cin >> s;
  if(s[0] == s[2]) yes();
  else no();
} 

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <functional>
#include <numeric>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <utility>
#include <sstream>
#include <complex>
#include <fstream>
#include <bitset>
#include <time.h>
#include <tuple>
#include <iomanip>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef complex<double> Point;

#define PI acos(-1.0)
#define EPS 1e-10
const ll INF = 1e12;
const ll MOD = 1e9 + 7;

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define rep(i,N) for(int i=0;i<(N);i++)
#define ALL(s) (s).begin(),(s).end()
#define EQ(a,b) (abs((a)-(b))<EPS)
#define EQV(a,b) ( EQ((a).real(), (b).real()) && EQ((a).imag(), (b).imag()) )
#define fi first
#define se second
#define N_SIZE (1LL << 20)
#define NIL -1

ll sq(ll num) { return num*num; }
ll mod_pow(ll x, ll n) {
	if (n == 0)return 1;
	if (n == 1)return x%MOD;
	ll res = sq(mod_pow(x, n / 2));
	res %= MOD;
	if (n % 2 == 1) {
		res *= x;
		res %= MOD;
	}
	return res;
}
ll mod_add(ll a, ll b) { return (a + b) % MOD; }
ll mod_sub(ll a, ll b) { return (a - b + MOD) % MOD; }
ll mod_mul(ll a, ll b) { return a*b % MOD; }

ll n;

class DK{
public:
	struct edge{
		int to;
		ll cost;
        edge(int _to,ll _cost):to(_to),cost(_cost){}
	};

	ll d[100010];
	vector<edge> G[100010];

	void dijkstra(int start){
		fill(d, d + 100010, INF);
		d[start] = 0;

		priority_queue<P, vector<P>, greater<P> > que;
		que.push(P(0, start));

		while (!que.empty()){
			P p = que.top();
			que.pop();
			int v = p.second;
			if (d[v] < p.first)continue;
			for (int i = 0; i < G[v].size(); i++){
				edge e = G[v][i];
				if (d[e.to] > d[v] + e.cost){
					d[e.to] = d[v] + e.cost;
					que.push(P(d[e.to], e.to));
				}
			}
		}
	}

	void clear(){
		rep(i,100010)G[i].clear();
	}
};

DK dk;
set<ll> sl;

int main(){
    while(cin >> n&&n){
		sl.clear();
		dk.clear();
        ll p[800],d[800];
        ll sum = 0;
        rep(i,n-1)cin >> p[i];
        rep(i,n-1)cin >> d[i];
        rep(i,n-1){
            dk.G[i+1].push_back(DK::edge(p[i]-1,d[i]));
            dk.G[p[i]-1].push_back(DK::edge(i+1,d[i]));
            sum += d[i];
        }
        rep(i,n){
            if(dk.G[i].size()==1)sl.insert(i);
        }
        rep(i,n-1){
            if(sl.find(i+1) == sl.end() && sl.find(p[i]-1) == sl.end()){
                sum += 2*d[i];
            }
        }
        ll MAX = 0;
        rep(i,n){
            if(sl.find(i)!=sl.end())continue;
            dk.dijkstra(i);
            rep(j,n){
				if(sl.find(j)!=sl.end())continue;
                if(dk.d[j]!=INF){
                    // cout << i << " " << j << " " << dk.d[j] << endl;
                    MAX = max(MAX,dk.d[j]);
                }
            }
        }
		// cout << sum << " " << MAX << endl;
        cout << sum-MAX << endl;
    }
}



Measured memory_bytes: 6348
object Main extends App {
  val in = new java.util.Scanner(System.in)
  val N = in.nextInt
  val S = "X" + in.next

  val cnts = (1 to N).scanLeft(S.count(_ == 'E')){(c, i) =>
    c + (if (S.charAt(i) == 'E') -1 else 0) + (if (S.charAt(i - 1) == 'W') 1 else 0)
  }
  println(cnts.min)
}

Measured memory_bytes: 62936
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.ArrayDeque;
import java.util.Arrays;
import java.util.StringTokenizer;
import java.util.stream.Collectors;

public class Main {

	public static void main(String args[]) {
		ConsoleScanner cin = new ConsoleScanner();
		PrintWriter cout = new PrintWriter(System.out);
		solve(cin, cout);
		cout.flush();
	}

	static long now() {
		return System.currentTimeMillis();
	}

	static void trace(Object... objects) {
		assert null != System.out.format("trace:%s\n", Arrays.deepToString(objects));
	}

	private static void solve(ConsoleScanner cin, PrintWriter cout) {
		// assert solve(1) == 1;

		int n = cin.nextInt();
		long[] t = new long[n];
		for (int i = 0; i < t.length; i++)
			t[i] = cin.nextLong();

		long start = now();

		long ans = solve(n, t);

		cout.println(ans);
		trace("elapsed", now() - start);
	}

	private static long solve(int n, long[] t) {
		ArrayDeque<Long> deq = new ArrayDeque<>();
		deq.addAll(Arrays.stream(t).boxed().collect(Collectors.toList()));
		while (deq.size() >= 2) {
			long a = deq.poll();
			long b = deq.poll();
			long gcd = gcd(a, b);
			long lcm = a / gcd * b;
			deq.add(lcm);
		}
		long ans = deq.poll();
		return ans;
	}

	private static long gcd(long a, long b) {
		if (a < b) {
			long t = a;
			a = b;
			b = t;
		}
		return a % b == 0 ? b : gcd(b, a % b);
	}

	static class ConsoleScanner {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		StringTokenizer st = new StringTokenizer("");

		String next() {
			try {
				while (!st.hasMoreElements())
					st = new StringTokenizer(br.readLine());
				return st.nextToken();
			} catch (IOException e) {
				throw new AssertionError(e);
			}
		}

		int nextInt() {
			return Integer.parseInt(next());
		}

		long nextLong() {
			return Long.parseLong(next());
		}
	}

}


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

int main()
{
    int A, B, C;
    std::cin >> A >> B >> C;

    int r = std::max({A, B, C});
    int l = std::min({A, B, C});

    std::cout << (r-l) << std::endl;



    return 0;
}

Measured memory_bytes: 256
import bisect
import sys

s = input()
t = input()
ss = s + s
n = len(s)

az_pos = [[] for i in range(ord("z") - ord("a") + 1)]
for i, si in enumerate(s):
    az_pos[ord(si) - ord("a")].append(i)

ans = 0

past = 0
for ti in t:
    char = ord(ti) - ord("a")
    if len(az_pos[char]) == 0:
        print(-1)
        sys.exit()

    r = bisect.bisect_left(az_pos[char], past)
    if r >= len(az_pos[char]):
        ans += n
        r = bisect.bisect_left(az_pos[char], 0)
    past = az_pos[char][r] + 1

print(ans + past)


Measured memory_bytes: 7796
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <iomanip>

#define PI 3.14159265358979323846
using namespace std;

int main() {
    string s, t;
    cin >> s >> t;
    int u = s.size();
    string v = t.substr(0, u);
    if (t.size() == u + 1 && s == v) {
        cout << "Yes" << endl;
    }
    else {
        cout << "No" << endl;
    }

}

Measured memory_bytes: 3576
#include<cstdio>
#include<iostream>
#include<ctype.h>
#include<string>
using namespace std;
int main(){
	int N, maxA, minB;
	cin >> N;
	int A[N], B[N];
	for(int i = 0; i < N; i++){
		cin >> A[i] >> B[i];
	}
	maxA = A[0];
	for(int i = 1; i < N; i++){
		if(A[i] > maxA){
			maxA  = A[i];
		}
	}
	minB = B[0];
	for(int i = 1; i < N; i++){
		if(B[i] < minB){
			minB  = B[i];
		}
	}
	cout << maxA +  minB << endl;
	return 0;
}

Measured memory_bytes: 1532