akhauriyash/Code-Regression huggingface dataset:
#include<iostream>

using namespace std;
int main()
{
	int l;
	while (cin >> l&&l) {
		int m[12] = {};
		int n[12] = {};
		int cho = 0;
		int tuki = 0;
		for (int i = 0; i < 12;i++) {
			cin >> m[i] >> n[i];
		}
		for (int i = 0; i < 12; i++) {
			cho += m[i] - n[i];
			if (cho >= l) {
				tuki = i+1;
				break;
			}
		}
		if (tuki == 0) {
			cout << "NA" << endl;
		}
		else {
			cout << tuki << endl;
		}
	}

	return 0;
	
}

Measured memory_bytes: 3064
#include <cstdio>
#include <vector>
#include <iostream>

using namespace std;

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

typedef long long ll;

void solve1()
{
    int n, m; cin >> n >> m;
    vector<int> k(m);
    vector<vector<int>> s(m);
    vector<int> p(m);
    for(int i = 0; i < m; i++) {
        cin >> k[i];
        for(int j = 0; j < k[i]; j++) {
            int in; cin >> in;
            s[i].push_back(in);
        }
    }
    
    for(int i = 0; i < m; i++) {
        cin >> p[i];
    }

    int ans = 0;
   
    for(int i = 0; i < (1 << n); i++) {
        vector<int> ss;
        vector<bool> ps(n, false);
        int pos = 0;

        for(int j = 0; j < n; j++) {
            if(i & (1 << j)) {
                ps[j] = true;
            } 
        }

        for(int j = 0; j < m; j++) {
            int cnt = 0;
            for(int l = 0; l < k[j]; l++) {
                if(ps[s[j][l]-1]) {
                    cnt ++;
                }
            }

            if(cnt%2 == p[j]) {
                pos ++;
            }
        }

        if(pos == m) {
            ans ++;
        }
    }

    cout << ans << endl;


}

int main()
{
    solve1();
}


Measured memory_bytes: 3608
import math
a, b, C = map(float, input().split())
pi = math.pi
rad = C*pi/180
c= math.sqrt(a**2+b**2-2*a*b*math.cos(rad))
S = a*b*math.sin(rad)/2
L=2*S/a
print(S, a+b+c, L)



Measured memory_bytes: 5692
#include <iostream>
#include <cstring>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <iterator>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <array>
#include <cmath>
#include <random>
#include <climits>
using namespace std;
using lint=long long;

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int d,n;
  cin>>d>>n;
  lint kari=1;
  for(int i=1;i<=d;i++) kari*=100;
  cout<<((n<=99)? n*kari: 101*kari)<<endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n)for(int i=0;i<(n);i++)
#define MOD 1000000007
#define EPS (1e-10)
#define INF 0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3f
using namespace std;
typedef long long ll;
typedef pair<int,int>P;

signed main(){
	string s;cin>>s;
	int sum=0;
	for(char c:s)sum+=c-'0';
	if(stoi(s)%sum==0)puts("Yes");
	else puts("No");
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
 using namespace std;
int main()
{
vector<int> pairs;
int n;
int value;
cin >> n;
for(int i=0;i<n;i++)
{
cin >> value;
pairs.push_back(value);
}
int count =0;
for(int i=0;i<n;i++)
{
if(pairs[pairs[i]-1]==(i+1))
{
 count++;
}
}
cout << count/2;
return 0;
}

Measured memory_bytes: 892
#include <bits/stdc++.h>
using namespace std;
int main(){
  int P,Q,R;
  cin>>P>>Q>>R;
  vector<int> vec={P+Q,Q+R,R+P};
  sort(vec.begin(),vec.end());
  cout<<vec.at(0)<<endl;
  
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	string s;
	cin >> s;
	int ans = 0;
	if(s[0] == 'R' && s[1] == 'R' && s[2] == 'R')
		cout << "3\n";
	else if((s[0] == 'R' && s[1] == 'R') || (s[1] == 'R' && s[2] == 'R'))
		cout << "2\n";
	else if(s[0] == 'R' || s[1] == 'R' || s[2] == 'R')
		cout << "1\n";
	else
		cout << "0\n";
}


Measured memory_bytes: 3600
#include<bits/stdc++.h>
#define REP(i,n) for(long long i=0;i<n;++i)
#define FOR(i,a,b) for(long long i=a;i<b;++i)
#define F first
#define S second
using namespace std;
typedef pair< int,int > point;
int main(){
    int n;
    scanf("%d",&n);
    int x[n],y[n],t[n];
    bool flag=true;
    point now(0,0);
    REP(i,n) scanf("%d%d%d",&t[i],&x[i],&y[i]);
    int time=0;
    REP(i,n){
        int step=abs(now.F-x[i])+abs(now.S-y[i]);
        if(step==0) step=2;
        if((t[i]-time)%step!=0) flag=false;
        now=point(x[i],y[i]);
        time=t[i];
    }
    printf("%s\n",flag?"Yes":"No");
    return 0;
}



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

const int N = 3003, mod = 998244353;

int a[N], dp[N][N][3];

int f(int idx, int sum, int w) {
	if(idx == 0) return sum == 0;
	if(~dp[idx][sum][w]) return dp[idx][sum][w];
	int res = (f(idx - 1, sum, 0) + f(idx - 1, sum, 1)) % mod;
	if(sum >= a[idx]) res += f(idx - 1, sum - a[idx], 2);
	return dp[idx][sum][w] = res % mod;
}

int main() {
	ios_base :: sync_with_stdio(0); cin.tie(0); cout.tie(0);
	int n, s; cin >> n >> s;
	for(int i = 1; i <= n; i++) {
		cin >> a[i];
	}
	memset(dp, -1, sizeof dp);
	cout << f(n, s, 0) << endl;
}

Measured memory_bytes: 109452
trs = [1, 3, 6, 10, 15, 21, 28, 36, 45, 55, 66, 78, 91, 105, 120, 136, 153, 171,
       190, 210, 231, 253, 276, 300, 325, 351, 378, 406, 435,
       465, 496, 528, 561, 595, 630, 666, 703, 741, 780]

n = int(input())

if n == 1:
    print(0)
    exit()

D = {}

i = 2
while i * i <= n:
    # print(i, n)
    if n % i == 0:
        n = n // i
        if i in D:
            D[i] += 1
        else:
            D[i] = 1
    else:
        i += 1

if n in D:
    D[n] += 1
else:
    D[n] = 1

# print(D)

ans = 0
for one in D:
    for ntr, tr in enumerate(trs):
        if tr > D[one]:
            # print(D[one], tr)
            ans += ntr
            break

print(ans)


Measured memory_bytes: 63348
n = gets.chomp.to_i
as = gets.chomp.split(" ").map(&:to_i).sort.reverse

a = 0
b = 0
as.each_with_index {|item,index|
  if index % 2 == 0 then
    a = a + item
  else
    b = b + item
  end
}
puts (a - b)


Measured memory_bytes: 1788
# coding: utf-8
import sys

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

H, N = lr()
INF = 10 ** 15
limit = H + 100
dp = [INF] * limit
dp[0] = 0
for _ in range(N):
    a, b = lr()
    for i in range(H):
        index = i+a
        if index > limit - 1:
            index = limit - 1
        dp[index] = min(dp[index], dp[i] + b)

answer = min(dp[H:])
print(answer)


Measured memory_bytes: 42844
#define _CRT_SECURE_NO_WARNINGS
#include <bits/stdc++.h>
using namespace std;
#define IO ios::sync_with_stdio(false); cin.tie(0);
#define all(v) (v).begin(), (v).end()
#define fi first
#define se second
typedef long long ll;
typedef pair<int, int> ii;
typedef pair<ll, int> li;
const int INF = (int) 1e9;
const ll LINF = (ll) 1e18;
const int nmax = 110;
struct point {
    int x, y;
    int t;
};
int n;
point a[2 * nmax];
int cmp(point a, point b) {
    if (a.x != b.x) return a.x < b.x;
    return a.y < b.y;
}
int main() {
    IO;
 
    cin >> n;
    for (int i = 1; i <= n; i++) {
        cin >> a[i].x >> a[i].y;
        a[i].t = 0;
    }
    for (int i = n + 1; i <= 2 * n; i++) {
        cin >> a[i].x >> a[i].y;
        a[i].t = 1;
    }
    sort(a + 1, a + 1 + 2 * n, cmp);
    set <int> s;
    set <int> :: iterator it;
    int res = 0;
    for (int i = 1; i <= 2 * n; i++) {
        if (a[i].t == 0) s.insert(a[i].y);
        else {
            it = lower_bound(all(s), a[i].y);
            if (it == s.begin()) continue;
            it--;
            if (it != s.end()) {
                res++;
                s.erase(it);
            }
        }
        /*
        for (it = s.begin(); it != s.end(); it++)
                cout << *it << " ";
            cout << "\n";
        */
    }
    cout << res;
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<math.h>

int main()
{
	int x, a, b;
	scanf("%d %d %d", &x, &a, &b);
	
	int sa, sb;
	sa = abs(x - a);
	sb = abs(x - b);
	
	if (sa < sb)
	{
		printf("A\n");
	}
	
	else if (sa > sb)
	{
		printf("B\n");
	}
	
	return 0;
}

Measured memory_bytes: 1644
#include <stdio.h>
#include <string.h>

int main (void){
     
     int n;
     int buf[256];

     scanf("%d", &n);

     for(int i = 0; i < n; i++){        
        scanf("%d", buf+i);
     }

     int repeatnum = 0;
     int endflag = 1;
     while(endflag){
        for(int i = 0; i < n; i++){
               
              if(buf[i] % 2 == 0){
                buf[i] /= 2;
              }else{
                endflag = 0;
                goto end;
              }

        }
        repeatnum++;
     }

end: 
     printf("%d", repeatnum);
     return 0;    
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define int ll
#define rep(i,n) for(int i=0;i<n;i++)
#define all(in) in.begin(), in.end()
#define INF (sizeof(int) == 4 ? (int)1e9:(int)1e18)
#define EPS 0.0000000001
template<class T, class S> void cmin(T &a, const S &b) { if (a > b)a = b; }
template<class T, class S> void cmax(T &a, const S &b) { if (a < b)a = b; }
template<typename Head, typename Value> auto vectors(const Head &head, const Value &v) { return vector<Value>(head, v); }
template<typename Head, typename... Tail> auto vectors(Head x, Tail... tail) { auto inner = vectors(tail...); return vector<decltype(inner)>(x, inner); }
using ld  = long double;
using pii = pair<int,int>;
using piii = pair<int,pii>;
int W,H;
int dx[]={0,0,1,-1}, dy[]={1,-1,0,0};
bool valid(int x,int y){return (0<=x&&x<W)&&(0<=y&&y<H);}
void YN(bool f){ cout << (f ? "YES" : "NO");}
void yn(bool f){ cout << (f ? "yes" : "no");}
void YeNo(bool f) {cout << (f ? "Yes" : "No");}
signed main(){
    int K;
    cin >> K;
    if(K == 0){
        cout << 4 << endl << "3 3 3 3" << endl;
        return 0;
    }
    if(K == 1){
        cout << 2 << endl;
        cout << "0 3" << endl;
        return 0;
    }
    int N = min(50LL,K);
    vector<int>ans(N,0LL);
    int Mod = K % N;
    int val = K / N;
    ans[0] = (Mod == 0 ? N - 1 + val : N + val + N - Mod);
    int base = ans[0];
    cout << N << endl;
    if(Mod == 0){
        rep(_,N) {
            if(_) cout << " ";
            cout << base;
        }
    } else {
        rep(_,Mod){
            if(_) cout << " ";
            cout << base;
        }
        rep(_,N - Mod){
            cout << " ";
            cout << base - (N + 1);
        }
    }
    cout << endl;
}


Measured memory_bytes: 256
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools

sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**13
mod = 10**9+7
dd = [(-1,0),(0,1),(1,0),(0,-1)]
ddn = [(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)

def distance(x1, y1, x2, y2):
    return math.sqrt((x1-x2)**2 + (y1-y2)**2)

def intersection(a1, a2, b1, b2):
    x1,y1 = a1
    x2,y2 = a2
    x3,y3 = b1
    x4,y4 = b2

    ksi = (y4 - y3) * (x4 - x1) - (x4 - x3) * (y4 - y1)
    eta = (x2 - x1) * (y4 - y1) - (y2 - y1) * (x4 - x1)
    delta = (x2 - x1) * (y4 - y3) - (y2 - y1) * (x4 - x3)
    if delta == 0:
        return None
    ramda = ksi / delta;
    mu = eta / delta;
    if ramda >= 0 and ramda <= 1 and mu >= 0 and mu <= 1:
        return (x1 + ramda * (x2 - x1), y1 + ramda * (y2 - y1))

    return None

def circumcenters(a,b,c):
    t1 = [(a[0]+b[0])/2, (a[1]+b[1])/2]
    s1 = [t1[1]-a[1], a[0]-t1[0]]
    t2 = [(a[0]+c[0])/2, (a[1]+c[1])/2]
    s2 = [t2[1]-a[1], a[0]-t2[0]]
    p1 = [t1[0]+s1[0]*1e7, t1[1]+s1[1]*1e7]
    p2 = [t1[0]-s1[0]*1e7, t1[1]-s1[1]*1e7]
    p3 = [t2[0]+s2[0]*1e7, t2[1]+s2[1]*1e7]
    p4 = [t2[0]-s2[0]*1e7, t2[1]-s2[1]*1e7]
    return intersection(p1,p2,p3,p4)

def main():
    n = I()
    rr = []
    for _ in range(n):
        x1,y1,x2,y2,x3,y3 = LF()
        a = [x1,y1]
        b = [x2,y2]
        c = [x3,y3]
        t = circumcenters(a,b,c)
        rr.append('{:0.3f} {:0.3f} {:0.3f}'.format(t[0], t[1], distance(t[0],t[1],x1,y1)))

    return '\n'.join(rr)


print(main())



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

int main(void){
    int n;
    cin >> n;
    if(n == 1){
        cout << "Hello World"<< endl;
    }else{
        int a,b;
        cin >>a>>b;
        cout << a+b<<endl;
    }
    return 0;
}

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

int main(void)
{
    int64_t N, D;
    std::cin >> N >> D;

    int64_t X[N+1][D+1];

    for (int64_t n = 1; n <= N; ++n) {
        for (int64_t d = 1; d <= D; ++d) {
            std::cin >> X[n][d];
        }
    }

    int64_t count = 0;

    for (int64_t left = 1; left <= N-1; ++left) {
    for (int64_t right = left + 1; right <= N; ++right) {

        int64_t value = 0;
        for (int64_t d = 1; d <= D; ++d) {
            value += std::pow(X[left][d]-X[right][d], 2.0);
        }

        double sqrt_value = std::sqrt(value);
        int64_t integer = static_cast<int64_t>(sqrt_value);
        if (sqrt_value - integer == 0) count++;
    }
    }

    std::cout << count << std::endl;

    return 0;
}

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

int N;
int factor[105];

int f(int m) {
  int ret = 0;
  for (int i = 0; i < N; i++) {
    if (factor[i] >= m - 1) {
      ret++;
    }
  }
  return ret;
}

int main() {
  cin >> N;

  for (int i = 0; i <= N; i++) {
    factor[i] = 0;
  }

  for (int i = 2; i <= N; i++) {
    int n = i;
    for (int j = 2; j <= i; j++) {
      while (n % j == 0) {
        factor[j]++;
        n /= j;
      }
    }
  }

  int ans = f(75) + f(25) * (f(3) - 1) + f(15) * (f(5) - 1) +
            f(5) * (f(5) - 1) * (f(3) - 2) / 2;
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
import java.util.*;
import java.io.*;

public class Main {
	public static void main(String[]  args) {
		Scanner scanner = new Scanner(System.in);
		
		int H = scanner.nextInt();
		long[] heap = new long[H];
		for (int i = 0; i < heap.length; i ++) {
			heap[i] = scanner.nextLong();
		}
		
		scanner.close();
		
		buildMaxHeap(heap);
		
		for (int i = 0; i < heap.length; i ++) {
			System.out.print(" ");
			System.out.print(heap[i]);
		}
		System.out.println();
	}

	static int parent(int i) {
		return (i  - 1) / 2;
	}

	static int left(int i) {
		return i * 2 + 1;
	}

	static int right(int i) {
		return left(i) + 1;
	}
	
	static void maxheapify(long[] heap, int i) {
		int l = left(i);
		int r = right(i);
		int max = i;
		
		if (l < heap.length && heap[l] > heap[max]) {
			max = l;
		}
		if (r < heap.length && heap[r] > heap[max]) {
			max = r;
		}
		
		if (max != i) {
			long temp = heap[i];
			heap[i] = heap[max];
			heap[max] = temp;
			
			maxheapify(heap, max);
		}
	}
	
	static void buildMaxHeap(long[] heap) {
		for (int i = heap.length / 2 - 1; i >= 0; i --) {
			maxheapify(heap, i);
		}
	}
} 



Measured memory_bytes: 169992
#!/usr/local/bin/python3
# coding: utf-8
hairu = input()
koi = hairu.split(" ")
ne = input()
kak = ne.split()
ka = []
for ne in range(len(kak)):
    ka.append(int(kak[ne]))
ka.sort()
total = 0
for i in range(int(koi[1])):
    total += int(ka[i])
print(total)

Measured memory_bytes: 9240
import sys
N = int(input())
for h in range(1, 3501):
    Nh = N*h
    for n in range(1, 3501):
        Nn = N * n
        left = 4*h*n - Nn - Nh
        Nhn = N * n * h
        if left > 0 and Nhn % left == 0:
            print(h, n, Nhn // left)
            sys.exit()

Measured memory_bytes: 66672
#include <iostream>
using namespace std;
int main(int argc, char const *argv[])
{
    int a,b,c;
    cin >> a >> b >> c;
    if (a < b && b < c) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
    return 0;
}


Measured memory_bytes: 3104
//is there any case of -1 or any special corner cases ?
#include<bits/stdc++.h>
using namespace std;
#define int long long int 
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define vi vector<int>
#define pi pair<int,int>
#define all(v) v.begin(),v.end()
#define zeros(arr) memset(arr,0,sizeof(arr));
#define precise(num)  cout<<fixed; cout << std::setprecision(num)
#define nl cout<<"\n";
#define test int t;cin>>t;while(t--) 
const int maxx  = 3*1e5 , limit = 9*1e18 , MOD=1e9+7;

string binary(int n){bitset<60>b(n) ;string p =b.to_string();return p;}

int decimal(string n) { int dec_value = 0;  int base = 1;  for (int i = n.size() - 1; i >= 0; i--) { if (n[i] == '1') 
dec_value += base; base = base * 2; } return dec_value; } 

bool isPrime(int n){if (n <= 1) return false; if (n <= 3) return true;if (n % 2 == 0 || n % 3 == 0) return false;

for (int i = 5; i * i <= n; i = i + 6) if (n % i == 0 || n % (i + 2) == 0) return false; return true; }

int pow (int x, int n,int mod) {if (n == 0) return 1; int res = pow (x, n / 2,mod);res = (res * res) % mod;if (n % 2) res = (res * x ) % mod;return res;}
// int calcInverse(int a, int n = MOD){int t = 0, newt = 1;int r = n, newr = a;  while (newr != 0) {auto quotient = r /newr;tie(t, newt) = make_tuple(newt, t- quotient * newt);
// tie(r, newr) = make_tuple(newr, r - quotient * newr);}if (r > 1)throw runtime_error("a is not invertible");if (t < 0)t += n;t=t%n;    return t;}

#define boost  ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define endl '\n';

int32_t main(){
    boost;
    int n;
    
    cin>>n;
    vi v(n);
    for(int i =0 ; i < n ; i ++ ){
        cin>>v[i];
    }
    sort(v.rbegin(),v.rend());
    
    
    int ans ;
    if(n > 1)ans=v[0];
    else ans = 0;
    int cp =  0;
    int itr = 1;
    
    for(int i = 2 ; i < n ; i++ )
    {    ans+=v[itr];
        cp++;
        if(cp==2){
            cp=0;
            itr++;
        }
        
    }   
        
    cout<<ans<<endl;
    
}

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

int main()
{
  int n, m, i, j, x, y;
  vector<int> s_x, s_y, c_x, c_y;

  cin >> n >> m;

  for (i = 0; i < n; i++)
  {
    cin >> x;
    s_x.push_back(x);
    cin >> y;
    s_y.push_back(y);
  }
  for (i = 0; i < m; i++)
  {
    cin >> x;
    c_x.push_back(x);
    cin >> y;
    c_y.push_back(y);
  }
  int res, d;
  for (i = 0; i < n; i++)
  {
    d = 100000000;
    for (j = 0; j < m; j++)
    {
      int tmp;
      tmp = abs(s_x[i] - c_x[j]) + abs(s_y[i] - c_y[j]);
      if (j == 0) {
        d = tmp;
        res = j;
      }
      else if(tmp < d){
          d = tmp;
          res = j;
      }
      //cout << res << " " << d << endl;
    }
    cout << res + 1<< endl;
  }

  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>

int main(){
  
  int i,j,n;
  int Max[100][100];
  int data,x,v;
  
  scanf("%d",&n);
  
  for( i = 0;i<n; i++){
    for(j=0; j<n;j++) {

      Max[i][j]=0;
    }

    
  }
  for(i=0;i<n;i++){
    
  scanf("%d%d",&data,&x);
  data--;
  
  for( j= 0;j<x; j++){
    scanf("%d",&v);
    v--;
    Max[data][v]=1;
  }
}

  
for(i = 0; i<n;i++ ){
  for(j= 0;j <n; j++) {

    if(j){
      printf(" ");
    }
    
    printf("%d",Max[i][j]);
  }
  
  printf("\n");
}
 
return 0;
}



Measured memory_bytes: 2056
/*
 * src.cpp
 *
 *  Created on: 2016/09/24
 *      Author: joi
 */

#include <bits/stdc++.h>

using namespace std;

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

string s;

int main(){
	cin>>s;
	cout<<s.substr(0,4)<<" "<<s.substr(4,8)<<endl;
	return 0;
}




Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>
#include <array>
#include <vector>
#include <functional>
#include <unordered_map> 
#include <map> 
#include <numeric>
#include <limits>
#include <utility>
#include <queue>
#include <random>
#include <bitset>
using namespace std;
typedef long long LL;

int main() {
	int t, i, j, k;
	int a, b, c ,F;
	
	cin >> a >> b;

	if ((a*b) % 2 == 0) {
		F = 0;
	}
	else {
		F = 1;
	}

	if (F == 1) {
		cout << "Odd" << endl;
	}
	else {
		cout << "Even" << endl;
	}
	return 0;
}

Measured memory_bytes: 256
{-# LANGUAGE NamedFieldPuns #-}
import Control.Monad (replicateM_)
import Data.Foldable (traverse_)
import Data.Functor ((<$>))
import Numeric (showFFloat)

data Point = Point { x :: Double, y :: Double }

instance Show Point where
  show (Point{x, y}) = sf x ++ " " ++ sf y
     where
     sf x = showFFloat Nothing x $ ""

readLnPoint = do
  [x, y] <- map read . words <$> getLine
  return $ Point {x, y}

dot p1 p2 = x p1 * x p2 + y p1 * y p2
psub p1 p2 = Point { x = x p1 - x p2, y = y p1 - y p2 }
scale a (Point{x, y}) = Point { x = a * x, y = a * y }

reflection a b = scale (2 * dot a b / dot a a) a `psub` b

main = do
  (p1, p2) <- do
    [x1, y1, x2, y2] <- map read . words <$> getLine
    return ( Point {x = x1, y = y1}, Point {x = x2, y = y2} )
  q <- readLn
  let originP1   p = Point { x = x p - x p1, y = y p - y p1 }
      unOriginP1 p = Point { x = x p + x p1, y = y p + y p1 }
      a = p2 `psub` p1
  replicateM_ q $ readLnPoint >>= \p -> let b = originP1 p in print $ unOriginP1 $ reflection a b



Measured memory_bytes: 4512
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <string>
#include <cstring>
#include <utility>
#include <set>
#include <stack>
#include <climits>
#include <cmath>

#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
#define MEMSET(v, h) memset((v), h, sizeof(v))
typedef long long ll;
const char sp = ' ';
const int MAX = 5100000;
const int MOD = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];
using namespace std;

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



// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; 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;
}


int main(void){
    ll n, k;
    cin>>n>>k;
    COMinit();
    if(k>=n) cout<<COM(2*n-1, n)<<endl;
    else{
        ll tot=1;
        rep(i, k){
            tot+=COM(n, i+1)*COM(n-1, i+1);
            tot%=MOD;
        }
        cout<<tot%MOD<<endl;
    }
    
    return 0;
}


Measured memory_bytes: 119808
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const int maxN = 1e5+7;
const int maxM = 1e5+7;
const int maxV = 90010;
//const int INF = 1e9+9;
const ll INF = (1ll)<<60;
//const int INF = 2e9+9;
const int MOD = 1e9+7;

int n,k;
vector<int> v[maxN];
int vis[maxN];
int pre[maxN];
int c[maxN];
int main()
{
	scanf("%d %d",&n,&k);
	for(int i=1;i<n;i++)
	{
		int x,y;
		scanf("%d%d",&x,&y);
		v[x].push_back(y);
		v[y].push_back(x);
	}
	ll ans = k;
	queue<int> Q;
	Q.push(1);
	while(!Q.empty()) 
	{
		int x = Q.front();
		Q.pop();
		vis[x] = 1;
		for(auto y:v[x])
		{
			if(vis[y]) continue;
			pre[y] = x;
			if(pre[y] == 1)
			{
				ans = ans*(k-1-c[x])%MOD;
			}
			else
			{
				ans = ans*(k-2-c[x])%MOD;
			}
			c[x]++;
			Q.push(y);
		}
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 7292
n, m, k = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))

s = [0] * (n + 1)
t = [0] * (m + 1)
for i in range(n):
    s[i+1] = s[i] + a[i]
for i in range(m):
    t[i+1] = t[i] + b[i]

ans = 0
j = m
for i in range(n+1):
    if s[i] > k:
        break
    while s[i] + t[j] > k:
        j -= 1
    ans = max(ans, i + j)
print(ans)

Measured memory_bytes: 117764
#include <cstdio>
#include <stack>
#include <cstdlib>
#include <cstring>
using namespace std;


int main() {
    stack<int> S;
    char s[100];
    int a, b;
    while (scanf("%s", s) != EOF) {
        if (s[0] == '+') {
            a = S.top(); S.pop();
            b = S.top(); S.pop();
            S.push(a + b);
        }
        else if (s[0] == '-') {
            a = S.top(); S.pop();
            b = S.top(); S.pop();
            S.push(b - a);
        }
        else if (s[0] == '*') {
            a = S.top(); S.pop();
            b = S.top(); S.pop();
            S.push(a * b);
        }
        else {
            S.push(atoi(s));
        }
    }
    printf("%d\n", S.top());
}
       



Measured memory_bytes: 2768
// clang-format off
#include <bits/stdc++.h>

#define mp make_pair
#define fst first
#define snd second
#define forn(i,n) for (int i = 0; i < int(n); i++)
#define forn1(i,n) for (int i = 1; i <= int(n); i++)
#define popcnt __builtin_popcount
#define ffs __builtin_ffs
#define ctz __builtin_ctz
#define clz __builtin_clz
#define all(a) (a).begin(), (a).end()
 
using namespace std;

using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>;
using pli = pair<ll,int>;
using pil = pair<int,ll>;
using pll = pair<ll,ll>;
template <typename T> using vec = vector<T>;
using vi = vec<int>;
using vl = vec<ll>;
template <typename T> using que = queue<T>;
template <typename T> using deq = deque<T>;

template <typename T> T id(T b) {return b;};
template <typename T> void chmax(T &x, T y) {if (x < y) x = y;}
template <typename T> void chmin(T &x, T y) {if (x > y) x = y;}
template <typename S, typename K> bool contains(S &s, K k) { return s.find(k) != s.end(); }
void fastio() { ios_base::sync_with_stdio(false); cin.tie(nullptr); }
constexpr ll TEN(int n) { if (n == 0) return 1LL; else return 10LL*TEN(n-1); }
// clang-format on

int main() {
    fastio();

    char c;
    cin >> c;
    if ('a' <= c) {
        cout << 'a' << endl;
    } else {
        cout << 'A' << endl;
    }

    return 0;
}

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

int n,s,x;

int main(){
    scanf("%d",&n);
	for(int i=1;i<=n;i++){
		int a;scanf("%d",&a);
		s+=a;x=max(a,x);
	}
	printf("%d",s-(x>>1));
    return 0;
}

Measured memory_bytes: 256
import java.util.*;
import java.util.stream.*;
import java.io.*;
class Main {
  public static void main(String[] args) {
    try {
      BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
      int[] mt = new int[10];
      for (int i = 0; i < 10; i++) {
        mt[i] = Integer.parseInt(br.readLine());
      }
      Arrays.stream(mt)
        .parallel()
        .boxed()
        .sorted(Comparator.reverseOrder())
        .sequential()
        .limit(3)
        .forEach(System.out::println);
    } catch (IOException e) {

    }
  }
}

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

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

  string ans = "No";
  if (a < c && c < b) ans = "Yes";
  if (b < c && c < a) ans = "Yes";

  cout << ans << endl;
}

Measured memory_bytes: 256
import numpy as np
A = np.array([int(input()) for _ in range(5)]).reshape(-1,1)
A = np.array(A).reshape(-1,1)
A = np.c_[A, (10 - A % 10) * (A % 10 != 0)]
print(sum(A[:,0]+A[:,1])-max(A[:,1]))

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

long long DP[100005];



int main(){
	memset(DP,-1,sizeof DP);
	DP[0] = 0;
	int n,w,ww,vv;
	scanf("%d%d",&n,&w);
	for (int i= 0; i<n;i++){
		scanf("%d%d",&ww,&vv);
		for(int j = 100005;j>=0;j--){
			if(DP[j]!=-1){
				if(j+ww<=w){
					DP[j+ww] = max(DP[j+ww],DP[j]+vv);
				}
			}
		}
	}
	long long ans = 0;
	for (int i= w; i>=0;i--){
		ans = max(DP[i],ans);
	}
	printf("%lld\n",ans);
	return 0;
}

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

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

    int ans = 0;
    for (int i = 0; i < 3; i++)
    {
        if (S[i] == T[i])
        {
            ans++;
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
n, k = map(int,input().split())
A = [0 for i in range(n)]

hito = []
max = k*2
for i in range(k*2):
    a = list(map(int,input().split()))
    hito.append(a)

for i in range(k*2):
    if i % 2 == 1:
        h = hito[i]
        for j in h:
            A[j-1] += 1
ans = 0
for i in range(len(A)):
    if A[i] == 0:
        ans += 1
print(ans)


Measured memory_bytes: 9136
#include "stdio.h"
#include <stdlib.h>
#include <math.h>
 
int main (){
    int N, D;
    scanf("%d %d",&N, &D);
    //printf("N=%d, D=%d\n",N,D);

    int array[N][D];
    for (int i=0; i<N; i++){
        for (int j=0; j<D; j++){
            array[i][j] =0;
        }
    }

    for (int i=0; i<N; i++){
        for (int j=0; j<D; j++){
            //printf("pointer array[%d][%d]=%d\n",i,j,&array[i][j]);
        }
    }
    
    char input;

    for (int i=0; i<N; i++){
        for (int j=0; j<D; j++){
            scanf("%d",&array[i][j]);
            //printf("array[%d][%d]=%d\n",i,j,array[i][j]);
            //printf("aho=%d\n",array[0][0]);
        }
    }
    for (int i=0; i<N; i++){
        for (int j=0; j<D; j++){
            //printf("array[%d][%d]=%d\n",i,j,array[i][j]);
        }
    }

    int counter=0;
    for (int i=0; i<N; i++){
        for (int j=i+1; j<N; j++){
            double dist = 0.0;
            for (int k=0; k<D; k++){
                dist += pow(array[i][k]-array[j][k],2);
            }
            dist = sqrt(dist);
            if (ceil(dist)==floor(dist)){
                counter++;               
            }
        }
    }
    printf("%d\n",counter);
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main() {
int h,w,y[15][15],a[210][210],s=0,i,j,k;
cin>>h>>w;
for(i=0;i<10;i++)for(j=0;j<10;j++)cin>>y[i][j];
for(k=0;k<10;k++)for(i=0;i<10;i++)for(j=0;j<10;j++)y[i][j]=min(y[i][j],y[i][k]+y[k][j]);
for(i=1;i<=h;i++)for(j=1;j<=w;j++){
cin>>a[i][j];
if(a[i][j]>1||a[i][j]==0)s+=y[a[i][j]][1];
}
cout << s << endl;
}

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

using namespace std;
using ll = long long;
const ll mod = 1000000007;


int main()
{
    ll a[3];
    cin >> a[0] >> a[1] >> a[2];
    if(a[0] % 2 == 0 || a[1] % 2 == 0 || a[2] % 2 == 0){
        cout << 0 << endl;
    }else{
        sort(a, a+3);
        cout << a[0] * a[1] << endl;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
#define ll long long
#define vvi vector< vector<int> >
#define vi vector<int>
#define All(X) X.begin(),X.end()
#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define pb push_back
#define pii pair<int,int>
#define mp make_pair
#define pi 3.14159265359
#define shosu(X) fixed << setprecision(X)
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
 
int main(){
int n,m;
cin >> n >> m;
vector<string> ns,ms;
REP(i,n){
string tmp;
cin >> tmp;
ns.pb(tmp);
}
REP(i,m){
string tmp;
cin >> tmp;
ms.pb(tmp);
}
bool flg = false;
REP(i,n-m+1){
REP(j,n-m + 1){
bool ok = true;
FOR(k, i, i + m){
FOR(l, j, j + m){
if(ns[l][k] != ms[l-j][k-i]) ok = false; 
}
}
if(ok) flg = true;
}
}
cout << (flg ? "Yes" : "No") << endl;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define PB push_back
#define MP make_pair
#define REP(i,n) for(int i=0;i<(n);i++)
int main(){
    int n,m,a,b;
    cin>>n>>m;
    bool d[n][n];
    memset(d,false,sizeof(d));
    REP(i,m){
        cin>>a>>b;a--;b--;
        d[a][b]=d[b][a]=true;
    }
    vector<int> v;
    REP(i,n)v.PB(i);
    int ans=0;
    do{
        if(v[0]!=0)continue;
        bool f=true;
        for(int i=1;i<n;i++){
            if(!d[v[i]][v[i-1]])f=false;
        }
        if(f)ans++;
    }while(next_permutation(v.begin(),v.end()));
    cout<<ans<<endl;
}

Measured memory_bytes: 256
#include<stdio.h>
int main()
{
    int num;
    // 整数の入力
    scanf("%d", &num);
    
    int heights[20];
    //int ans[20];
    // 入力値の読み込み
    for(int i = 0; i < num; i ++) {
        scanf("%d", &heights[i]);
    }
    // 判定
    int j = 0;
    int t = 0;
    for(int i = 0; i < num; i ++) {
        if(t <= heights[i]) {
            t = heights[i];
            j++;
        }
    }
    // 出力
    printf("%d", j);
    return 0;
}


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

using namespace std;

int main(){
	string n;
	cin >> n;
	string s("CODEFESTIVAL2016");
	int cnt=0;
	for(int unsigned i=0;i<n.size();i++){
		if(s[i] != n[i]) cnt++;
	}
	cout << cnt << endl;
	
	return 0;
}

Measured memory_bytes: 764
#include <bits/stdc++.h>
using namespace std;
int main () {
	int N;
	cin >> N;
	string S;
	cin >> S;
	for (auto g: S) {
		g += N;
		if (g > 'Z') {
			g -= 26;
		}
		cout << g;
	}
	cout << endl;
}

Measured memory_bytes: 256
N = int(input())

h_list = list(map(int, input().split()))


cnt = 0
max_cnt = 0
for i in range(1, len(h_list)):

    if h_list[i] <= h_list[i-1]:
        cnt += 1
    else:
        max_cnt = max(cnt, max_cnt)
        cnt = 0

print(max(cnt, max_cnt))


Measured memory_bytes: 14252
#include<stdio.h>
#include<string.h>
#include<math.h>
#include <stdlib.h>
#include<ctype.h>

//qsort
int compare_int(const void *a, const void *b)
{
    return *(int*)a - *(int*)b;
}

//比較
int max(int a, int b){
	if (a>b) return a;
	else return b;
}

int min(int a,int b) {
	if(a>b) return b;
	else return a;
}


//main関数
int main() {
	char S[200001];
	char T[200001];
	scanf("%s",S);
	scanf("%s",T);
	int count = 0;
	for(int i=0; i<strlen(S);i++){
		if( S[i] != T[i] ) {
			count++;
		}
	}
	printf("%d",count);
}


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

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

    for(int i=0; i<t.size(); i++){
        if(s==t){
            cout << "Yes" << endl;
            return 0;
        }
        s = s[t.size()-1]+s.substr(0, t.size()-1);
    }

    if(s==t){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
}

Measured memory_bytes: 256
n = gets.chomp.to_i
tale_a = 0
head_b = 0
tale_a_and_head_b = 0
ans = 0
n.times do
    s = gets.chomp
    ans += s.scan("AB").length
    if s[-1] == "A" && s[0] == "B"
        tale_a_and_head_b += 1
    elsif s[-1] == "A"
        tale_a += 1
    elsif s[0] == "B"
        head_b += 1
    end
end

if tale_a_and_head_b == 0
    puts ans + [tale_a, head_b].min
else
    if tale_a + head_b > 0
        puts ans + tale_a_and_head_b + [tale_a, head_b].min
    else
        puts ans + tale_a_and_head_b - 1
    end
end

Measured memory_bytes: 3836
import java.io.BufferedReader; 
import java.io.*;
import java.io.InputStreamReader; 
import java.util.Scanner; 
import java.util.StringTokenizer; 
import java.util.*;
import java.math.*;
public class Main 
{ 
    static class FastReader 
    { 
        BufferedReader br; 
        StringTokenizer st; 
  
        public FastReader()
        { 
            br = new BufferedReader(new
                     InputStreamReader(System.in)); 
        } 
  
        String next()
        { 
            while (st == null || !st.hasMoreElements()) 
            { 
                try
                { 
                    st = new StringTokenizer(br.readLine()); 
                } 
                catch (IOException  e) 
                { 
                    e.printStackTrace(); 
                } 
            } 
            return st.nextToken(); 
        } 
  
        int nextInt() 
        { 
            return Integer.parseInt(next()); 
        } 
  
        long nextLong() 
        { 
            return Long.parseLong(next()); 
        } 
  
        double nextDouble() 
        { 
            return Double.parseDouble(next()); 
        } 
  
        String nextLine() 
        { 
            String str = ""; 
            try
            { 
                str = br.readLine();
            } 
            catch (IOException e) 
            { 
                e.printStackTrace(); 
            } 
            return str; 
        } 
    } 
   public static void main(String args[])
    {
        FastReader sc=new FastReader();
        PrintWriter pw=new PrintWriter(System.out);
        int t=1;//sc.nextInt();
        long ans=0,mod=1000000007;
        while(t-->0)
        {
         int n=sc.nextInt(),d=0;
         if(n>=30) pw.println("Yes");
         else pw.println("No");
        }
           pw.close();
    }
}
  

Measured memory_bytes: 32864
# -*- coding: utf-8 -*-

import sys
import math


debug = False

def log(text):
    if debug:
        print(text)

def parse_input(lines_as_string = None):

    global debug
    lines = []
    if lines_as_string is None:
        debug = False
        # for line in sys.stdin:
        #     lines.append(line)
        lines.append(input())
    else:
        debug = True
        lines = [e for e in lines_as_string.split("\n")][1:-1]

    c = lines[0]

    return (c, )


def solve(c):
    
    chars = 'abcdefghijklmnopqrstuvwxyz'
    idx = chars.index(c)
    result = chars[idx+1]
        
    return result
    


def main():
    # 出力
    result = solve(*parse_input())
    if isinstance(result, list):
        for r in result:
            print("%s" % r, sep='')
    else:
        print("%s" % result, sep='')

if __name__ == '__main__':

    main()
	

Measured memory_bytes: 3064
#include <iostream>
#include <sstream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <map>
#include <iomanip>
#include <stdio.h>

using namespace std;

//typedefリスト
typedef vector<long long int> vint;
typedef vector<vector<long long int>> vvint;
typedef vector<string> vstr;
typedef long long int llint;

llint gcd(llint x, llint y) {
	while (y != 0) {
		if (x > y) {
			llint r = x % y;
			x = y;
			y = r;
		}
		else {
			llint r = y % x;
			y = r;
		}
	}
	return x;
}

int main(void) {
	int a, b;
	cin >> a >> b;
	cout << (a + b) / 2 << endl;
}



Measured memory_bytes: 3136
#include <stdio.h>

int main()
{
  int a[31];
  int column, row;
  int i;
  int x1, x2, tmp;

  scanf("%d", &column);
  scanf("%d", &row);
  for(i=1; i<=column; i++) a[i]=i;
  for(i=0; i<row; i++){
    scanf("%d,%d", &x1, &x2);
    tmp=a[x1]; a[x1]=a[x2]; a[x2]=tmp;
  }
  for(i=1; i<=column; i++) printf("%d\n", a[i]);

  return 0;
}

Measured memory_bytes: 0
/*input
*/
#include <bits/stdc++.h>
using namespace std;
 
#define all(a) a.begin(), a.end()
#define ff first
#define ss second
#define pb push_back
 
using ll = long long;
using pii = pair<int, int>;
 
template<typename T> using V = vector<T>;

int main() {
	ios::sync_with_stdio(false);cin.tie(nullptr);
	ll n; cin >> n;
	--n;
	cout << (n*(n+1))/2;
}

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

//template
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(a);i>(b);i--)
#define ALL(v) (v).begin(),(v).end()
typedef long long int ll; const int inf = 0x3fffffff; const ll INF = 0x3fffffffffffffff;
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; }
//template end

class CHT{
    struct line{
        ll a,b;
        line(ll a,ll b):a(a),b(b){}
    };
    deque<line> deq;
    bool check(line &l1,line &l2,line &l3){
        return (l2.a-l1.a)*(l3.b-l2.b)>=(l2.b-l1.b)*(l3.a-l2.a);
    }
    ll f(line &l1,ll x){return l1.a*x+l1.b;}
public:
    void add(ll a,ll b){
        line l=line(a,b);
        while(deq.size()>=2&&check(deq[deq.size()-2],deq[deq.size()-1],l))deq.pop_back();
        deq.push_back(l);
    }
    ll query(ll x){
        while(deq.size()>=2&&f(deq[0],x)>=f(deq[1],x))deq.pop_front();
        return f(deq[0],x);
    }
};

int main(){
    int n; ll c; scanf("%d%lld",&n,&c);
    CHT cht;
    ll h,y; scanf("%lld",&h); cht.add(-2*h,h*h);
    rep(i,0,n-1){
        scanf("%lld",&h);
        y=h*h+cht.query(h)+c;
        cht.add(-2*h,y+h*h);
    }
    printf("%lld\n",y);
    return 0;
}

Measured memory_bytes: 2432
#include <bits/stdc++.h>
using namespace std;
#define mp make_pair
#define pb push_back
#define FIFO ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define MOD 1000000007
#define mods 1000000009
#define modhash1 1000000009
#define modhash2 1000000007
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<pii> vii;
typedef vector<pll> vll;
int TestMillerRabin[12] = {2,3,5,7,11,13,17,19,23,29,31,37};
ll mulmod(ll a, ll b, ll p){
	ll x = 0, y = a%p;
	while(b>0){
		if(b%2==1) x = (x+y)%p;
		y = (1LL*y*2)%p;
		b = b/2;
	}
	return x%p;
}
ll fastexp(ll x, ll y, ll p){
	ll ans = 1;
	while(y > 0){
		if(y&1) ans = (1LL*ans*x)%p;
		y = y>>1;
		x = (1LL*x*x)%p;
	}
	return ans%p;
}
ll fastexpp(ll x, ll y, ll p){
	ll ans = 1;
	while(y > 0){
		if(y&1) ans = mulmod(ans,x,p);
		y = y>>1;
		x = mulmod(x,x,p);
	}
	return ans%p;
}
ll invmod(ll x, ll p){
	return fastexp(x,p-2,p)%p;
}
bool check_composite(ll n, ll a, ll d, int s){
	ll x = fastexp(a,d,n);
	if(x == 1 || x == n-1) return false;
	for(int r=1; r<s; r++){
		x = (1LL*x*x)%n;
		if(x == n-1) return false;
	}
	return true;
}
bool isPrime(ll p){
	if(p<=1) return false;
	int r = 0;
	ll d = p-1;
	while(!(d&1)){
		d >>= 1;
		r++;
	}
	for(int i=0; i<12; i++){
		int value = TestMillerRabin[i];
		if(p == value) return true;
		if(check_composite(p,value,d,r)) return false;
	}
	return true;
}

int main(){
	string s;
	cin >> s;
	for(int i=0; i<s.size(); i++){
		if(s[i] == '?') s[i] = 'D';
	}
	cout << s;
	return 0;
}


Measured memory_bytes: 3760
import sys
sys.setrecursionlimit(10**7)
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x) - 1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def II(): return int(sys.stdin.readline())
def SI(): return sys.stdin.readline().strip()
INF = 10 ** 18
MOD = 10 ** 9 + 7

def main(): 
    N, W = LI()
    things = []
    for i in range(N):
        things.append(LI())

    knapsack_dp = [[0 for _ in range(W+1)] for _ in range(N)]

    for i, wv in enumerate(things):  # 10**2
        w, v = wv
        if i == 0:
            for weight in range(W+1):  # 10**5
                knapsack_dp[i][weight] = 0 if weight < w else v
        else:
            for weight in range(W+1):
                if weight-w < 0:
                    knapsack_dp[i][weight] = knapsack_dp[i-1][weight]
                else:
                    knapsack_dp[i][weight] = max(knapsack_dp[i-1][weight], knapsack_dp[i-1][weight-w]+v)

    print(knapsack_dp[N-1][W])

main()

Measured memory_bytes: 170988
#include<bits/stdc++.h>
typedef long long ll;
using namespace std;
int INF = 1LL << 30;
int MOD = 1e9+7;
main(){
    int N;
    cin >> N;
    vector<int> A(N+1);
    for(int i = 0;i < N;i++){
        cin >> A[i];
    }
    A[N] = N+1;
    int cnt = 0;
    for(int i = 0;i < N;i++){
        if(A[i] == i+1){
            swap(A[i],A[i+1]);
            cnt++;
        }
    }
    cout << cnt << endl;
}

Measured memory_bytes: 640
#include <stdio.h>
#include <stdlib.h>
#define M 2000001
#define VM 10000

int main(){

  unsigned short *a,*b;
  int d[VM+1];
  int n,i,j;

  scanf("%d",&n);

  a=malloc(sizeof(short)*n+1);
  b=malloc(sizeof(short)*n+1);

  for(i=0;i<=VM;i++)d[i]=0;

  for(j=0;j<n;j++){
    scanf("%u",&a[j+1]);
    d[a[j+1]]++;

  }
  for(i=1;i<=VM;i++)d[i]=d[i]+d[i-1];

  for(j=n;j>=1;j--){
    b[d[a[j]]]=a[j];
    d[a[j]]--;
  }

  for(i=1;i<=n;i++){
    printf("%u",b[i]);
    if(i<n)printf(" ");
  }
  printf("\n");



  return 0;
}



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



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

    int ans = 0;
    rep(i,3){
        if(s[i] == t[i]) ++ans;
    }

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

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> pii;
typedef pair<double,double> pdd;
#define MEM(a, b) memset(a, (b), sizeof(a))
#define SZ(i) ll(i.size())
#define FOR(i, j, k, in) for (ll i=j ; i<k ; i+=in)
#define RFOR(i, j, k, in) for (ll i=j ; i>=k ; i-=in)
#define REP(i, j) FOR(i, 0, j, 1)
#define REP1(i,j) FOR(i, 1, j+1, 1)
#define RREP(i, j) RFOR(i, j, 0, 1)
#define ALL(_a) _a.begin(),_a.end()
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define X first
#define Y second
#ifdef tmd
#define debug(...) do{\
    fprintf(stderr,"%s - %d (%s) = ",__PRETTY_FUNCTION__,__LINE__,#__VA_ARGS__);\
    _do(__VA_ARGS__);\
}while(0)
template<typename T>void _do(T &&_x){cerr<<_x<<endl;}
template<typename T,typename ...S> void _do(T &&_x,S &&..._t){cerr<<_x<<" ,";_do(_t...);}
template<typename _a,typename _b> ostream& operator << (ostream &_s,const pair<_a,_b> &_p){return _s<<"("<<_p.X<<","<<_p.Y<<")";}
template<typename It> ostream& _OUTC(ostream &_s,It _ita,It _itb)
{
    _s<<"{";
    for(It _it=_ita;_it!=_itb;_it++)
    {
        _s<<(_it==_ita?"":",")<<*_it;
    }
    _s<<"}";
    return _s;
}
template<typename _a> ostream &operator << (ostream &_s,vector<_a> &_c){return _OUTC(_s,ALL(_c));}
template<typename _a> ostream &operator << (ostream &_s,set<_a> &_c){return _OUTC(_s,ALL(_c));}
template<typename _a,typename _b> ostream &operator << (ostream &_s,map<_a,_b> &_c){return _OUTC(_s,ALL(_c));}
template<typename _t> void pary(_t _a,_t _b){_OUTC(cerr,_a,_b);cerr<<endl;}
#define IOS()
#else
#define debug(...)
#define pary(...)
#define endl '\n'
#define IOS() ios_base::sync_with_stdio(0);cin.tie(0)
#endif

template<class T> inline bool cmax(T &a, const T &b) { return b > a ? a = b, true : false; }
template<class T> inline bool cmin(T &a, const T &b) { return b < a ? a = b, true : false; }
template<class T> using MaxHeap = priority_queue<T>;
template<class T> using MinHeap = priority_queue<T, vector<T>, greater<T>>;

const ll MOD=1000000007;
const ll INF=0x3f3f3f3f3f3f3f3f;
const ll MAXN=2e5+5;
const ll MAXLG=__lg(MAXN)+2;

ll n,h[MAXN],v[MAXN],bit[MAXN];
ll query(ll pos) {
    ll ret = 0;
    for (;pos>=1;pos-=-pos&pos) {
        ret = max(bit[pos],ret);
    }
    return ret;
}

void change(ll pos,ll val) {
    for (;pos<=n;pos+=-pos&pos) {
        bit[pos] = max(bit[pos],val);
    }
}
/********** Good Luck :) **********/
int main()
{
    IOS();
    cin >> n;
    REP (i,n) {
        cin >> h[i];
    }

    REP (i,n) {
        cin >> v[i];
    }
    MEM(bit,0);

    ll ans = 0;
    REP (i,n) {
        ll cur = v[i] + query(h[i]-1);
        ans = max(ans,cur);
        change(h[i],cur);
    }

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


Measured memory_bytes: 4992
# -*- coding: utf-8 -*-
import sys
from collections import deque, defaultdict
from math import sqrt, factorial
# def input(): return sys.stdin.readline()[:-1] # warning not \n
# def input(): return sys.stdin.buffer.readline().strip() # warning bytes
# def input(): return sys.stdin.buffer.readline().decode('utf-8')


def solve():
    n = int(input())
    w = set()
    s = input()
    w.add(s)
    ans = 1
    for _ in range(n-1):
        c = input()
        if (s[-1] != c[0] or c in w): ans = 0
        w.add(c)
        s = c
    if ans:
        print("Yes")
    else:
        print("No")

t = 1
# t = int(input())
for case in range(1,t+1):
    ans = solve()




"""

4
1 2
2 4
1 3
3
2 2 4
4 5 6

6
1 2
2 3
3 4
4 5
4 6
3
3 5 6
2 17 31 5 11

"""





Measured memory_bytes: 9444
import numpy as np
C = np.array([[int(x) for x in input().split()] for _ in range(3)])
ans = 'Yes'
for i in range(2):
    if not(C[0,i+1]-C[0,i] == C[1,i+1]-C[1,i] == C[2,i+1]-C[2,i]):
        ans = 'No'
    if not(C[i+1,0]-C[i,0] == C[i+1,1]-C[i,1] == C[i+1,2]-C[i,2]):
        ans = 'No'
print(ans)


Measured memory_bytes: 27040
#include "bits/stdc++.h"
#define rep(i,n) for(int i = 0;i < n;i++)
#define mrep(p,mp) for(auto p : mp)
using namespace std;
using ll = long long;
using P = pair<int,int>;
 
int main(){
ll a,b,c,k;
cin >> a >> b >> c >> k;
ll ans;
ans = a - b;
if(k % 2 == 1) ans = -ans;
cout << ans << endl;
}

Measured memory_bytes: 256