akhauriyash/Code-Regression huggingface dataset:
n=int(input())
temp=map(int,input().split())
A=list(temp)
count=0
odd_check=0
while odd_check==0:
    for s in A:
        if int(s)%2!=0:
            odd_check+=1
    if odd_check==0:
        count+=1
        for s in range(len(A)):
            A[s]=A[s]/2
print(count)

Measured memory_bytes: 3064
# -*- coding: utf-8 -*-
import bisect
import heapq
import math
import random
import sys
from collections import Counter, defaultdict, deque
from decimal import ROUND_CEILING, ROUND_HALF_UP, Decimal
from functools import lru_cache, reduce
from itertools import combinations, combinations_with_replacement, product, permutations
from operator import add, mul, sub

# sys.setrecursionlimit(100000)
input = sys.stdin.buffer.readline
INF = 2**62-1

def read_int():
    return int(input())


def read_int_n():
    return list(map(int, input().split()))


def read_float():
    return float(input())


def read_float_n():
    return list(map(float, input().split()))


def read_str():
    return input().strip()


def read_str_n():
    return list(map(str, input().split()))


def error_print(*args):
    print(*args, file=sys.stderr)


def mt(f):
    import time

    def wrap(*args, **kwargs):
        s = time.time()
        ret = f(*args, **kwargs)
        e = time.time()

        error_print(e - s, 'sec')
        return ret

    return wrap


class Combination:
    def __init__(self, n, mod):

        g1 = [1, 1]
        g2 = [1, 1]
        inverse = [0, 1]
        for i in range(2, n + 1):
            g1.append((g1[-1] * i) % mod)
            inverse.append((-inverse[mod % i] * (mod//i)) % mod)
            g2.append((g2[-1] * inverse[-1]) % mod)
        self.MOD = mod
        self.N = n
        self.g1 = g1
        self.g2 = g2
        self.inverse = inverse

    def __call__(self, n, r):
        if (r < 0 or r > n):
            return 0
        r = min(r, n-r)
        return self.g1[n] * self.g2[r] * self.g2[n-r] % self.MOD



@mt
def slv(N, K):
    ans = 0
    M = 10**9 + 7
    for i in range(K, N+2):
        a = i*(i-1)//2 - 1
        b = i*(2*(N-i+1) + i-1) // 2
        ans += b - a
        ans %= M
    return ans


def main():
    N, K = read_int_n()
    print(slv(N, K))


if __name__ == '__main__':
    main()


Measured memory_bytes: 10416
import java.util.*;

class Main {
	  static long mod=1_000_000_007;
  public static void main(String[] args) {
	  int flg = 0;
	  Scanner sc = new Scanner(System.in);
      String S = sc.next();
      for(int i=0;i<S.length();i++) {
    	  if(i%2==0) {
    		  if(S.substring(i, i+1).equals("L")) {
    			  flg=1;
    		  }
    	  } else {
    		  if(S.substring(i, i+1).equals("R")) {
    			  flg=1;
    		  }    		  
    	  }
      }
      if(flg==1) {
    	  System.out.println("No");    	  
      } else {
    	  System.out.println("Yes"); 
      }
      
  }
  
 
}

Measured memory_bytes: 23892
#include<bits/stdc++.h>
using namespace std;
#define int long
signed main(){
    int x;
    cin >> x;
    for (int p = x;;++p){
        bool isp = true;
        for (int i = 2; isp&&i * i <= p; ++i)
            if (p % i == 0) isp = false;
        if (isp) return cout << p, 0;
    }
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
int main(){
    int n;
    scanf("%d", &n);
    int f[n+2];
    f[0] = 1;
    f[1] = 1;
    for(int i = 2; i <= n; i++) f[i] = f[i-1] + f[i-2];
    printf("%d\n", f[n]);
    return 0;
}


Measured memory_bytes: 2732
import java.util.*;
import java.util.Collections;
import java.util.ArrayList;

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

        ArrayList<Integer> list = new ArrayList<Integer>();

        for(int i=0; i<3; i++){
            list.add(sc.nextInt());
        }

        Collections.sort(list);

        System.out.println(list.get(2) - list.get(0));
    }
}

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

int main() {
  string s;
  cin >> s;
  if (s[2] == s[3] && s[4] == s[5]) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
  return 0;
}


Measured memory_bytes: 3624
/*input
3
6 10 16
*/

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

const int A = 1000005;

// antbook p108
int gcd(int a, int b) {
    if (b == 0) return abs(a);
    return gcd(b, a%b);
}

int main() {
    int n;
    cin >> n;
    vector<int> a(n);
    vector<int> c(A);
    rep(i, n) {
        cin >> a[i];
        c[a[i]]++;
    }

    bool pairwise = true;
    for (int i = 2; i < A; i++) {
        int cnt = 0;
        for (int j = i; j < A; j += i) {
            cnt += c[j];
        }
        if (cnt > 1) {
            pairwise = false;
            break;
        }
    }
    if (pairwise) {
        puts("pairwise coprime");
        return 0;
    }

    int g = 0;
    rep(i, n) g = gcd(g, a[i]);
    if (g == 1) {
        puts("setwise coprime");
        return 0;
    }
    puts("not coprime");
}

Measured memory_bytes: 11160
#include <stdio.h>

int main(){
    int n, i, j, cnt=0, min;
    char s[300001];

    scanf("%d", &n);
    scanf("%s", s);

    for(i=1; i<n; i++){
        if(s[i] == 'E')
            cnt++;
    }    

    min = cnt;

    for(i=1; i<n; i++){
        if(s[i] == 'E')
            cnt--;
        if(s[i-1] == 'W')
            cnt++;
        if(min > cnt)
            min = cnt;
    }

    printf("%d\n", min);

    return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0;i<(int)(n);++i)
#define REPR(i,n) for (int i=(int)(n)-1;i>=0;--i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
#define valid(y,x,h,w) (0<=y&&y<h&&0<=x&&x<w)
#define tpl(...) make_tuple(__VA_ARGS__)
const int INF = 0x3f3f3f3f;
const double EPS = 1e-8;
const double PI = acos(-1);
const int dy[] = {-1,0,1,0};
const int dx[] = {0,1,0,-1};
typedef long long ll;
typedef pair<int,int> pii;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
template<typename Ch,typename Tr,typename C,typename=decltype(begin(C()))>basic_ostream<Ch,Tr>& operator<<(basic_ostream<Ch,Tr>&os,
const C& c){os<<'[';for(auto i=begin(c);i!=end(c);++i)os<<(i==begin(c)?"":" ")<<*i;return os<<']';}
template<class S,class T>ostream&operator<<(ostream &o,const pair<S,T>&t){return o<<'('<<t.first<<','<<t.second<<')';}
template<int N,class Tp>void output(ostream&,const Tp&){}
template<int N,class Tp,class,class ...Ts>void output(ostream &o,const Tp&t){if(N)o<<',';o<<get<N>(t);output<N+1,Tp,Ts...>(o,t);}
template<class ...Ts>ostream&operator<<(ostream&o,const tuple<Ts...>&t){o<<'(';output<0,tuple<Ts...>,Ts...>(o,t);return o<<')';}
template<class T>void output(T t,char z=10){if(t<0)t=-t,putchar(45);int c[20];
int k=0;while(t)c[k++]=t%10,t/=10;for(k||(c[k++]=0);k;)putchar(c[--k]^48);putchar(z);}
template<class T>void outputs(T t){output(t);}
template<class S,class ...T>void outputs(S a,T...t){output(a,32);outputs(t...);}
template<class T>void output(T *a,int n){REP(i,n)cout<<a[i]<<(i!=n-1?',':'\n');}
template<class T>void output(T *a,int n,int m){REP(i,n)output(a[i],m);}
template<class T>bool input(T &t){int n=1,c;for(t=0;!isdigit(c=getchar())&&~c&&c-45;);
if(!~c)return 0;for(c-45&&(n=0,t=c^48);isdigit(c=getchar());)t=10*t+c-48;t=n?-t:t;return 1;}
template<class S,class ...T>bool input(S&a,T&...t){input(a);return input(t...);}
template<class T>bool inputs(T *a, int n) { REP(i,n) if(!input(a[i])) return 0; return 1;}

struct P {
  int a, num, id;
  bool operator<(const P &rhs) const {
    return num != rhs.num ? num < rhs.num :
      a > rhs.a;
  }
};

int cur[1000001];
int num[1000001];

int main() {
  int n,q;
  while(input(n,q)) {
    priority_queue<P> Q;
    memset(cur,0,sizeof(cur));
    memset(num,0,sizeof(num));
    REP(i,q) {
      int a,v;
      input(a,v);
      num[a] += v;
      Q.push((P){a,num[a],++cur[a]});
      while(1) {
        P p = Q.top();
        if (cur[p.a] != p.id) {
          Q.pop();
          continue;
        }
        outputs(p.a, p.num);
        break;
      }
    }
  }
}

Measured memory_bytes: 10496
#include <bits/stdc++.h>
using namespace std;
 
int main() {
	int n, m, ans = 0;
	cin >> n >> m;

	vector<int> food(m, 0);
	for(int i=0;i<n;i++){
		int k;
		cin >> k;
		for(int j=0;j<k;j++){
			int a;
			cin >> a;
			a--;
			food.at(a)++;
		}
	}
	for(int i=0;i<m;i++)
		if(food.at(i)==n) ans++;
	cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
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 = 0;
    if (k <= a)
    {
        ans += k;
    }
    else if (k <= a + b)
    {
        ans += a;
    }
    else
    {
        ans = a - (k - a - b);
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
#define rep(i,n)for(long long i=0;i<(long long)(n);++i)
#define all(a) a.begin(), a.end()
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
 
const ll MOD=1e9+7;
const ll INF=1e18;
const int MAX=510000;
const double pi=acos(-1);
int dx[8] = {1,0,-1,0,1,1,-1,-1};
int dy[8] = {0,1,0,-1,-1,1,1,-1};
// int d[13]={0,31,28,31,30,31,30,31,31,30,31,30,31};
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;
}
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false); 
  
  int n;
  ll k;
  cin >> n >> k;
  vector<ll>a(n);
  rep(i,n) cin >> a[i];
  ll left = 0, right = *max_element(a.begin(),a.end())+1;
  while(abs(right-left)>1){
    int cnt = 0;
    ll m=(left+right)/2;
    rep(i,n){
      if(a[i]<=m)continue;
      if(a[i]%m==0)cnt+=a[i]/m-1;
      else cnt+=a[i]/m;
    }
    if(cnt>k){
      left=m;
    }
    else right = m;
  }
  cout << left+1 << endl;
      
  
  return 0;
}


Measured memory_bytes: 4748
import java.util.*;
public class Main {

  public static void main(String[] args) { 
      Scanner sc = new Scanner(System.in);
      int n = sc.nextInt();
      String s = sc.next();
      Deque<Character> queue = new LinkedList<>();
      int openCnt = 0;
      for(char c : s.toCharArray()) {
        if(c == '(') {
          openCnt++;
          queue.offer(c);
        } else {
          if(openCnt > 0) {
            openCnt--;
            queue.offer(c);
          } else {
            queue.addFirst('(');
            queue.offer(c);
          }
        }
      }
      StringBuilder sb = new StringBuilder();
      while(!queue.isEmpty()) {
        char c = queue.pop();
        sb.append(c);
      }
      while(openCnt-- > 0) {
          sb.append(')');
      }
      System.out.println(sb.toString());
  }
}

Measured memory_bytes: 21844
n = int(input())
a = [tuple(map(int,input().split())) for i in range(n)]
ans = 0
m = dict()
for i in range(n):
    for j in range(n):
        if i != j:
            x = a[i][0] - a[j][0]
            y = a[i][1] - a[j][1]
            p = (x,y)
            if p not in m:
                m[p] = 0
            m[p] += 1
            ans = max(ans, m[p])
print(n - ans)



Measured memory_bytes: 3444
k = int(input())
a = [0] * (10**6+1)
a[1] = 7 % k
for i in range(2, k+1):
    a[i] = (a[i-1]*10+7) % k
for i in range(1, k+1):
    if a[i] == 0:
        print(i)
        break
else:
    print(-1)


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

int main() {
	double a, b, c, angle;
	cin >> a >> b >> c;
	angle = c/180*M_PI;

	cout.precision(6);
	cout << fixed << a*(b*sin(angle))/2 << endl;
	cout << fixed << a+b+sqrt(pow(a, 2)+pow(b, 2)-2*a*b*cos(angle)) << endl;
	cout << fixed << b*sin(angle) << endl;

	return 0;
}


Measured memory_bytes: 3504
# @oj: atcoder
# @id: hitwanyang
# @email: 296866643@qq.com
# @date: 2020-05-10 20:11
# @url:https://atcoder.jp/contests/abc167/tasks/abc167_c
import sys,os
from io import BytesIO, IOBase
import collections,itertools,bisect,heapq,math,string
# region fastio

BUFSIZE = 8192

BUFSIZE = 8192

class FastIO(IOBase):
    newlines = 0

    def __init__(self, file):
        self._fd = file.fileno()
        self.buffer = BytesIO()
        self.writable = "x" in file.mode or "r" not in file.mode
        self.write = self.buffer.write if self.writable else None

    def read(self):
        while True:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            if not b:
                break
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines = 0
        return self.buffer.read()

    def readline(self):
        while self.newlines == 0:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            self.newlines = b.count(b"\n") + (not b)
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines -= 1
        return self.buffer.readline()

    def flush(self):
        if self.writable:
            os.write(self._fd, self.buffer.getvalue())
            self.buffer.truncate(0), self.buffer.seek(0)


class IOWrapper(IOBase):
    def __init__(self, file):
        self.buffer = FastIO(file)
        self.flush = self.buffer.flush
        self.writable = self.buffer.writable
        self.write = lambda s: self.buffer.write(s.encode("ascii"))
        self.read = lambda: self.buffer.read().decode("ascii")
        self.readline = lambda: self.buffer.readline().decode("ascii")


sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)
input = lambda: sys.stdin.readline().rstrip("\r\n")
# ------------------------------
def main():
    nmx=list(map(int,input().split()))
    n,m,x=nmx[0],nmx[1],nmx[2]
    nums=[]
    c=[]
    for i in range(n):
        temp=list(map(int,input().split()))
        c.append(temp[0])
        nums.append(temp[1:])
    # print (c)
    # print (nums)
    combin=[]
    for i in range (1,n+1):
        combin.extend(list(itertools.combinations(range(n),i)))
    mn=[]
    for b in combin:
        temp,cost=[0]*m,0
        for y in b:
            for i in range(len(nums[y])):
                temp[i]+=nums[y][i]
            cost+=c[y]
        # print (temp,cost)
        flag=True
        for j in range(m):
            if temp[j]<x:
                flag=False
                break
        if flag:
            mn.append(cost)
    # print (mn)
    print (min(mn) if len(mn)>0 else -1)
if __name__ == "__main__":
    main()

Measured memory_bytes: 70564
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
typedef long double ld;
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	int n;
	cin >> n;
	int cnt = 0;
	map<pair<int, int>, int> mp;
	FOR(a,1,n+1){
		int l = a%10;
		if(l==0) continue;
		int h = a;
		while(h/10>0) h /= 10;
		mp[make_pair(h,l)]++;
	}
	FOR(i,1,10){
		FOR(j,i,10){
			if(mp[make_pair(i,j)]==0) continue;
			if(i==j) cnt += mp[make_pair(i,j)] * mp[make_pair(i,j)];
			else cnt += 2 * mp[make_pair(i,j)] * mp[make_pair(j,i)];
		}
	}
	cout << cnt << '\n';
	return 0;
}



Measured memory_bytes: 256
#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<cstring>
using namespace std;

int main(){
	int a,b,c;
  	cin>>a>>b>>c;
  int i=1;
  	while(true){
      if(a*i%b==c){
      	printf("YES");
        break;
      }
      i++;
      if(i>=10000000){
        printf("NO");
        break;
      }
    }
}


Measured memory_bytes: 3668
import math

n=int(input())
f=list()
p=list()
ans=-10**10
for i in range(n):
    f.append(list(map(int,input().split())))
for i in range(n):
    p.append(list(map(int,input().split())))
for i in range(1,1<<10):
    shop=list()
    cnt=[0]*n
    tmp=0
    for j in range(10):
        if i>>j&1:
            shop.append(j)
    for s in range(n):
        for k in shop:
            if(f[s][k]==1):
                cnt[s]+=1
        tmp+=p[s][cnt[s]]
    ans=max(ans,tmp)
print(ans)

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

using namespace std;

int main() {
    int H, N;
    cin >> H >> N;
    int sum = 0;
    for (int i = 0; i < N; i++){
        int c;
        cin >> c;
        sum += c;
    }
    if (sum >= H){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{

  int a,b;

  cin>>a>>b;

  int cnt=0;
  
  for(int i=a;i<=b;i++){
    stringstream ss;
    ss<<i;
    string str=ss.str();
    int k=str.length()-1;
    int j=0;
    while(str[j]==str[k]&&j<k){
      j++;
      k--;
    }
    if(j==str.length()/2){
      cnt++;
    }
  }

  cout<<cnt<<endl;
  return 0;
}


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

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

  int h, w;
  cin >> h >> w;
  string s;
  for (int i = 0; i < h; i++) {
    cin >> s;
    for (int i = 0; i < 2; i++) {cout << s << '\n';}
  }
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n)  for(int i=0;i<n;i++)
#define per(i,n)  for(int i=n-1;i>=0;i--)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
#define INF 2000000000
#define fast_io() ios_base::sync_with_stdio(false); cin.tie(NULL)

using namespace std;
typedef long long ll;
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef set<int> si;
typedef vector<ii> vii;


int main()
{       fast_io();
        int n, m;
        cin >> n >> m;
        if(m == 1) m = 0;
        int sum = 0;
    for (int i = m - 1; i > 0; i--){
        sum += i;
    }
cout << ( ((n - 1) * n) / 2 ) + sum;
        
    
        return 0;
}
     




Measured memory_bytes: 256
#include <stdio.h>
 
int main() {
  int a[101][101] = {0};
  int b[101] = {0};
  int d[101] = {0};
  int i,j,r,c;
  int x;
  int e = 0;
 
  scanf("%d %d" , &r,&c);
 
  for(j=0; j<r; j++) {
    for(i=0; i<c; i++) {
      scanf("%d",&x);
      a[j][i] = x;
    }
  }
 
  for(j=0; j<r; j++){
    for(i=0; i<c; i++) {
      b[i] += a[j][i];
    }
  }
 
  for(j=0; j<r; j++){
    for(i=0; i<c; i++){
      d[j] += a[j][i];
    }
  }
 
  for(j=0; j<r; j++) {
    for(i=0; i<c; i++) {
      printf("%d ",a[j][i]);
    }
    printf("%d\n", d[j]);
  }
  for(i =0; i<c; i++) {
    printf("%d " ,b[i]);
    e += b[i];
  }
  printf("%d\n", e);
 
  return 0;
}


Measured memory_bytes: 2056
#include "bits/stdc++.h"
#define ALL(x) x.begin(), x.end()
#define iostreamBooster() do{ cin.tie(nullptr); ios_base::sync_with_stdio(false); }while(0)
#define rep(i, s, n) for(int i(s); i < int(n); ++i)
using namespace std;
using i64 = long long;
using pii = pair<int, int>;
template<class A, class B>inline bool chmax(A &a, const B &b){return b>a ? a=b,1 : 0;}
template<class A, class B>inline bool chmin(A &a, const B &b){return b<a ? a=b,1 : 0;}
constexpr int INF  = 0x3f3f3f3f;
constexpr i64 LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr int MOD  = int(1e9) + 7;

signed main()
{
  string s; cin >> s;

  int l = 0;
  int r = s.length() - 1;

  int ans = 0;
  int len;
  while(len = (r - l + 1), len > 0) {
    if (s[l] == s[r]) {
      ++l, --r;
    } else {
      if (s[l] != 'x' && s[r] != 'x') {
        ans = -1;
        break;
      }
      else if (s[l] == 'x') {
        ++ans, ++l;
      }
      if (s[r] == 'x') {
        ++ans, --r;
      }
    }
  }

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



Measured memory_bytes: 512
N = int(input())
A = [int(i) for i in input().split()]
     
flg = [0,0,0,0,0,0,0,0,0]
for i in range(N):
    if   A[i] <  400: flg[0] = 1
    elif A[i] <  800: flg[1] = 1
    elif A[i] < 1200: flg[2] = 1
    elif A[i] < 1600: flg[3] = 1
    elif A[i] < 2000: flg[4] = 1
    elif A[i] < 2400: flg[5] = 1
    elif A[i] < 2800: flg[6] = 1
    elif A[i] < 3200: flg[7] = 1
    else:             flg[8] += 1
     
colmin = max(sum(flg[0:8]), 1)
colmax = sum(flg)
print(colmin, colmax)

Measured memory_bytes: 3064
/*author: hyperion_1724
  date: 
*/

//Optional FAST

//#pragma GCC optimize("Ofast")
//#pragma GCC optimize("unroll-loops")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,fma,abm,mmx,avx,avx2,tune=native")

//Required Libraries

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>

//Required namespaces

using namespace std;
using namespace __gnu_pbds;

//Required defines

#define endl '\n'

#define READ(X) cin>>X;
#define READV(X) long long X; cin>>X;
#define READAR(A,N) long long A[N]; for(long long i=0;i<N;i++) {cin>>A[i];}
#define rz(A,N) A.resize(N);
#define sz(X) (long long)(X.size())
#define pb push_back
#define pf push_front
#define fi first
#define se second
#define trav(x,A) for(auto &x:A)
#define FORI(a,b,c) for(long long a=b;a<c;a++)
#define FORD(a,b,c) for(long long a=b;a>c;a--)

//Required typedefs

typedef tree<long long,null_type,less<long long>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
typedef tree<long long,null_type,greater<long long>,rb_tree_tag,tree_order_statistics_node_update> ordered_set1;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<long long,long long> pll;
typedef vector<int> veci;
typedef vector<long long> vecl;

//Required Constants

const long long inf=(long long)1e18;
const long long MOD=(long long)(1e9+7);
const long long INIT=(long long)(1e6+1);

//Required Functions

ll power(ll x,ll y) 
{ 
    if (y == 0) 
        return 1; 
    ll p = power(x, y/2) % MOD; 
    p = (p * p) % MOD; 
  
    return (y%2 == 0)? p : (x * p) % MOD; 
}
ll modInverse(ll a) 
{ 
   return power(a,MOD-2); 
   
}

//Work

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

   
//-----------------------------------------------------------------------------------------------------------//

    READV(N);
    ll A[N];
    map<string,ll> Z;
    FORI(i,0,N)
    {
        string S;
        cin>>S;
        Z[S]=i;
        READ(A[i]);
    }
    string T;
    cin>>T;
    ll ans=0;
    FORI(i,Z[T]+1,N)
    {
        ans+=A[i];
    }
    cout<<ans<<endl;

//-----------------------------------------------------------------------------------------------------------//


   
    return 0;
}

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

using namespace std;

int ans[2020];

void solve() {
    int n, x, y; cin >> n >> x >> y;
    for (int v = 1; v <= n; v++) {
        for (int u = v + 1; u <= n; u++) {
            if (u - v <= abs(x - v) + abs(y - u) + 1)
                ans[u - v]++;
            else
                ans[abs(x - v) + abs(y - u) + 1]++;
        }
    }
    for (int k = 1; k <= n - 1; k++)
        cout << ans[k] << "\n";
}

int main() {
    ios::sync_with_stdio(NULL), cin.tie(0), cout.tie(0);
    cout.setf(ios::fixed), cout.precision(20);
    solve();
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cmath>
#include <limits>
#include <vector>
#include <cstdio>
#include <bits/stdc++.h>
#include <set>
#include <map>
#include <stdio.h>
#include <stack>
#include <queue>
#include <deque>
#include <numeric>
using namespace std;
using ll = long long;
map <int ,int> mpa,mpb;
typedef pair<ll, ll> P;
priority_queue<P, vector<P>, greater<P>> pque;

string S;
ll ans=0;

void solve(int a,ll b,ll c){
  if(!S[a]){
    ans+=b+c;
    return;
  }
  
  solve(a+1,b+c,S[a]-'0');
  if(a!=0){
  solve(a+1,b,c*10+(S[a]-'0'));
  }
  return;
}

int main(){
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  cin >> S;
  solve(0,0,0);
  cout << ans << endl;
  return 0;
}

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

int main() {
  ll N, sum = 0, border;
  cin >> N;
  vector<ll> A(N);
  for(ll i = 0; i < N; i++) {
    cin >> A.at(i);
    if(i == 0) border = A.at(0);
    else {
      if(A.at(i) < border) sum += border - A.at(i);
      else border = A.at(i);
    }
  }
  cout << sum << endl;
}

Measured memory_bytes: 4828
n, m = map(int, input().split())
if n >= 3 and m >= 3:
    print((n-2) * (m-2))
elif n == 2 or m == 2:
    print(0)
elif n == 1 and m == 1:
    print(1)
else:
    print(max(n, m) - 2)

Measured memory_bytes: 3060
n = int(input())
a = list(map(int, input().split()))
for i in range(1, n):
	a[i] = a[i] + a[i - 1]
ans = abs(a[-1] - 2 * a[0])
for i in range(1, n - 1):
	ans = min(ans, abs(a[-1] - 2 * a[i]))
print(ans)


Measured memory_bytes: 24832
#include <stdio.h>

int main() {
    int sum, h, r, m, rm, s;

    scanf("%d", &sum);

    h = sum / 3600;
    r = sum % 3600;
    m = r / 60;
    s = r % 60;

    printf("%d:%d:%d\n", h, m, s);


    return 0;
}


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

int main() {
  int N,K;
  cin >> N >> K;
  int x =1;
  for ( int i = 0 ; i < N ; i++) {
    if ( x < K ) {
      x *= 2;
    }
    else {
      x += K;
    }
      }
  cout << x << endl;
  // ここにプログラムを追記
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
/**Classes and Structs**/
struct custom_hash {
    static uint64_t splitmix64(uint64_t x) {
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }

    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};
/**End**/
                                       /**Definitions**/
                                       const long long int mod1=1000000007;
                                       const int MAX=100005;
                                       #define pb push_back
                                       #define fast ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
                                       typedef long long int ll;
                                       typedef unsigned long long int ull;
                                       typedef unordered_map<int,int,custom_hash> mii;
                                       typedef unordered_map<ll,int,custom_hash> mli;
                                       typedef unordered_map<int,ll,custom_hash> mil;
                                       typedef unordered_map<ll,ll,custom_hash> mll;
                                       /**End**/
/**Custom Functions**/
ll gcd(ll a,ll b){
    ll c;
     while(b){
        c=b;
        b=a%b;
        a=c;
     }
     return a;
}
ll power1(ll a,ll b){
     if(b==0) return 1;
     else if(b%2) return a*power1(a,b-1);
     else {
        ll temp=power1(a,b/2);
        return temp*temp;
     }
}
ll power2(ll a,ll b,ll m){
     if(b==0) return 1;
     else if(b%2) return (a*power2(a,b-1,m))%m;
     else{
        ll temp=power2(a,b/2,m);
        return (temp*temp)%m;
     }
}
/**End**/
int main()
{
fast;
ll t=1;
//cin>>t;
while(t--){
   ll n;
   cin>>n;
    int a[n];
    ll cnt=0;
    for(int i=0;i<n;i++){
        cin>>a[i];
        if(i>=2){
            vector<int>v;
            v.pb(a[i-2]);
            v.pb(a[i-1]);
            v.pb(a[i]);
            sort(v.begin(),v.end());
            if(a[i-1]==v[1]){cnt++;}
            else{}
        }
    }
    cout<<cnt;
}
}


Measured memory_bytes: 256
package main

import (
	"fmt"
)

func main() {
	var H, W int
	fmt.Scan(&H, &W)
	a := make([]string, H)
	for i := 0; i < H; i++ {
		fmt.Scan(&a[i])
	}

	row := make([]bool, H)
	col := make([]bool, W)
	for i := 0; i < H; i++ {
		for j := 0; j < W; j++ {
			if a[i][j] == '#' {
				row[i] = true
				col[j] = true
			}
		}
	}

	for i := 0; i < H; i++ {
		if row[i] {
			for j := 0; j < W; j++ {
				if col[j] {
					fmt.Print(string(a[i][j]))
				}
			}
			fmt.Println()
		}
	}
}


Measured memory_bytes: 768
#include<iostream>
#include<string>
#include<vector>
#include<queue>
using namespace std;
struct Point {int x,y;};
int main(){
  int w,h;
  cin >> w >> h;
  while(w!=0||h!=0){
    int bw[55][55]={{}};
    string str;
    int i,j,k;
    vector <Point> bs;
    vector <Point> ws;
    Point p,b;
    for(i=0;i<h;i++){
      cin >> str;
      for(j=0;j<w;j++){
	if(str[j]=='W') {
	  bw[j][i]=1;
	  p.x=j;p.y=i;
	  ws.push_back(p);
	}
	if(str[j]=='B') {
	  bw[j][i]=2;
	  p.x=j;p.y=i;
	  bs.push_back(p);
	}
      }
    }
    queue <Point> q;
    for(i=0;i<ws.size();i++){
      p.x = ws[i].x;p.y = ws[i].y;
      q.push(p);
      while(!q.empty()){
	p=q.front();
	q.pop();
	int xs[]={1,-1,0,0},ys[]={0,0,1,-1};
	for(j=0;j<4;j++){
	  b.x=p.x+xs[j];b.y=p.y+ys[j];
	  if(b.x<0||w<=b.x||b.y<0||h<=b.y){
	  }else{
	    if(bw[b.x][b.y]==0){
	      bw[b.x][b.y]=3;
	      q.push(b);
	    }
	  }
	}
      }
    }
    for(i=0;i<bs.size();i++){
      p.x = bs[i].x;p.y = bs[i].y;
      q.push(p);
      while(!q.empty()){
	p=q.front();
	q.pop();
	int xs[]={1,-1,0,0},ys[]={0,0,1,-1};
	for(j=0;j<4;j++){
	  b.x=p.x+xs[j];b.y=p.y+ys[j];
	  if(b.x<0||w<=b.x||b.y<0||h<=b.y) {
	  }else{
	    if(bw[b.x][b.y]==0){
	      bw[b.x][b.y]=4;
	      q.push(b);
	    }
	    if(bw[b.x][b.y]==3){
	      bw[b.x][b.y]=5;
	      q.push(b);
	    }
	  }
	}
      }
    }
    int wn=0,bn=0;
    for(i=0;i<h;i++){
      for(j=0;j<w;j++){
	if(bw[j][i]==3) wn++;
	if(bw[j][i]==4) bn++;
      }
    }
    cout << bn << " " << wn <<  endl;
    cin >> w >> h;
  }
  return 0;
}

Measured memory_bytes: 1304
/*ex4_1
ryo_1129*/
#include<stdio.h>

int main(void){
    int D,N,view,people;//変数宣言
    scanf("%d %d",&N,&D);//入力
    view = 2*D+1;//一人が見れる木の数
    //見る木に被りがない場合
    if(N%view==0){
        people = N/view;
    //見る木に被りがある場合一人以外被りがないようにして１を足す
    }else{
        people = N/view+1;
    }
    //出力
    printf("%d\n",people);
    return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
map<string,int> m;
int s2i(string s){
  stringstream ss(s);
  int x;ss>>x;
  return x;
}
string i2s(int x){
  stringstream ss;
  ss<<x;
  return ss.str();
}
int calc(string s){
  //cout << s << endl;
  int res=0,j;
  string key,n;
  for(int i=0;i<s.size();i++){
    //cout << i << endl;
    if(isdigit(s[i])){
      n=s[i];
      i++;
      while(i<s.size()&&isdigit(s[i])){
	n+=s[i];
	i++;
      }
      if(i<s.size()&&s[i]==','){
	//cout << n << endl;
	res+=s2i(n);
      }
      i--;
    }else if('A'<=s[i]&&s[i]<='Z'){
      key=s[i];
      j=i+1;
      if(j<s.size()&&'a'<=s[j]&&s[j]<='z'){
	key+=s[j];
	j++;
      }
      
      if(m[key]==0) return -1;
      //cout << key << ":" << m[key] << endl;;
      n="";
      while(j<s.size()&&isdigit(s[j])){
	n+=s[j];
	j++;
      }
      if(j<s.size()&&s[j]==','){
	res+=m[key];
      }else{
	if(n=="") res+=m[key];
	else res+=m[key]*s2i(n);
      }
    }
    //cout << res << endl;
  }
  return res;
}
int main(){
  string s,b,n;
  int x;
  int i,j,k;
  while(cin>>s,s!="END_OF_FIRST_PART"){
    cin >> x;
    m[s]=x;
  }
  while(cin>>s,s!="0"){
    //cout << s << endl;
    bool f=true;
    int ans=0;
    bool ff=true;
    while(ff){
      
      ff=false;
      int o=0,m=0;
      for(i=0;i<s.size();i++){
	if(s[i]=='(') o++;
	if(s[i]==')') o--;
	m=max(m,o);
      }
      if(m==0){
	ans=calc(s);
	f=true;
	break;
      }
      for(i=0;i<s.size();i++){
	if(s[i]=='(') o++;
	if(s[i]==')') o--;
	if(o==m){
	  b="";
	  j=i;
	  i++;
	  while(s[i]!=')'){
	    b+=s[i];
	    i++;
	  }
	  x=calc(b);
	  if(x==-1) {
	    f=false;
	    break;
	  }
	  //s.replace(j+1,i-j-1,i2s(calc(b)));
	  o--;
	  n="";
	  if(i+1<s.size()&&isdigit(s[i+1])) i++;
	  while(i<s.size()&&isdigit(s[i])){
	    n+=s[i];
	    i++;
	  }
	  //cout << calc(b) << endl;
	  //cout << x << endl;
	  if(n=="") s.replace(j,i-j,"."+i2s(x)+",");
	  else s.replace(j,i-j,"."+i2s(x*s2i(n))+",");
	  ff=true;
	  break;
	}
	if(!f) break;
      }
      //cout << s << endl;
      if(!f) break;
    }
    if(f&&ans>0) cout << ans << endl;
    else cout << "UNKNOWN" << endl;
  }
  return 0;
}

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

using namespace std;

int main() {
  int v;
  cin >> v;
  v |= v >> 1;
  v |= v >> 2;
  v |= v >> 4;
  v |= v >> 8;
  v |= v >> 16;
  v ^= (v >> 1);
  cout << v << endl;
  return 0;
}


Measured memory_bytes: 256
fun main(args: Array<String>) {
    val (x, y, c) = readLine()!!.split(" ").map { it.toInt() }
    val l = readLine()!!.split(" ").map { it.toInt() }

    println(
        Array(x) { readLine()!!.split(" ").map { it.toInt() } }
            .map { it.foldIndexed(c) { index, sum, value -> sum + (value * l[index]) } }
            .count { it > 0 }
    )
}

Measured memory_bytes: 37876
N = int(input())
A1 = list(map(int, input().split()))
A2 = list(map(int, input().split()))

S1 = [0] * (N + 1)
S2 = [0] * (N + 1)

for i in range(N):
    S1[i + 1] = S1[i] + A1[i]
    S2[i + 1] = S2[i] + A2[i]

ans = 0
for i in range(N):
    n = S1[i + 1] + (S2[N] - S2[i])
    ans = max(ans, n)

print(ans)


Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
int GA[2001][2001],ans[2001];
int main(){
	int n,x,y;
	cin>>n>>x>>y;
	for(int i=1;i<=n;i++)
		for(int j=i+1;j<=n;j++)
		    GA[i][j]=j-i;
	for(int i=1;i<=n-1;i++)
		for(int j=i+1;j<=n;j++){
			int xx=abs(j-y)+1+abs(i-x);
			int yy=abs(j-x)+1+abs(i-y);
			GA[i][j]=min(GA[i][j],min(xx,yy));
		}
	for(int i=1;i<=n-1;i++)
		for(int j=i+1;j<=n;j++)
		    ans[GA[i][j]]++;
	
	for(int i=1;i<=n-1;i++)
	    cout<<ans[i]<<endl;
	return 0;
}

Measured memory_bytes: 15360
#include <iostream>

using namespace std;

void countingSort(int *A, int n, int *B, int k){
    int i, j, C[k];

    for(i = 0; i <= k; i++) C[i] = 0;

    for(j = 1; j <= n; j++) C[A[j]]++;
    
    for(i = 1; i <= k; i++) C[i] += C[i-1];

    for(j = n; j >= 1; j--){
        B[C[A[j]]] = A[j];
        C[A[j]]--;
    }
    
}

int main(){
    int n, k = 0, i;
    cin >> n;
    int A[n+1], B[n+1];
    for(i = 1; i <= n; i++) {
        cin >> A[i];
        if(A[i] > k) k = A[i];
    }
    countingSort(A, n, B, k);
    for(i = 1; i < n; i++) cout << B[i] << " ";
    cout << B[i] << endl;
    return 0;
}


Measured memory_bytes: 18676
#include <bits/stdc++.h>
#include <boost/range/algorithm.hpp>
#include <boost/range/numeric.hpp>
#include <boost/range/irange.hpp>
#include <boost/range/adaptor/indexed.hpp>
#define FOR(i,k,n)  for(int i = (k);i < (n);++i)
#define REP(i,n)    FOR(i,0,n)
#define ALL(x) begin(x),end(x)

using namespace std;
using namespace boost::adaptors;
using namespace std::string_literals;
using ll = int64_t;
using vecint = vector<int>;
using vecll = vector<ll>;
using boost::irange;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  ll ai,ao,at,aj,al,as,az;
  cin>>ai>>ao>>at>>aj>>al>>as>>az;
  ll ans = 0;
  ans += ao;
  ll pj = aj % 2;
  ll pl = al % 2;
  ll pi = ai % 2;
  if (pj + pl + pi >= 2 && aj && al && ai) {
    ans += 3;
    --aj;
    --al;
    --ai;
  }
  ans += 2 * (aj / 2);
  ans += 2 * (al / 2);
  ans += 2 * (ai / 2);
  cout<<ans<<endl;
  return 0;
}


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

int main() {
    int n; cin >> n;
    vector<int> a(n);
    for (int i = 0;i < n; i++) cin >> a.at(i);
    int alice = 0 , bob = 0;
    sort(a.begin(), a.end());
    alice += a.at(0);
    for (int i = 1;i < n; i++) {
        if(i % 2 == 0) {
            alice += a.at(i);
        }
        else {
            bob += a.at(i);
        }
    }
    int ans = bob - alice;
    if (ans < 0) ans *= (-1);
    cout << ans << endl;
    return 0;
}

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

#define NDEBUG
#include <cassert>


typedef long long ll;
typedef long double Double;
typedef unsigned long long ull;
typedef pair<int,int> ii;
typedef pair<ll,ll> llll;
typedef pair<double,double> dd;

typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<ii> vii;
typedef vector<vector<ii>> vvii;
typedef vector<ll> vll;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<long double> vD;

#define sz(a)  int((a).size())
#define pb  push_back
#define eb  emplace_back
#define FOR(var,from,to) for(int var=(from);var<=(to);++var)
#define rep(var,n)  for(int var=0;var<(n);++var)
#define rep1(var,n)  for(int var=1;var<=(n);++var)
#define repC2(vari,varj,n)  for(int vari=0;vari<(n)-1;++vari)for(int varj=vari+1;varj<(n);++varj)
#define ALL(c)  (c).begin(),(c).end()
#define RALL(c)  (c).rbegin(),(c).rend()
#define tr(i,c)  for(auto i=(c).begin(); i!=(c).end(); ++i)
#define found(s,e)  ((s).find(e)!=(s).end())
#define mset(arr,val)  memset(arr,val,sizeof(arr))
#define mid(x,y) ((x)+((y)-(x))/2)
#define IN(x,a,b) ((a)<=(x)&&(x)<=(b))
#define cons make_pair

#define PQ(T) priority_queue<T>
#define RPQ(T) priority_queue<T,vector<T>,greater<T>>

template<class T> inline void amin(T & a, T const & b) { a = min(a, b); }
template<class T> inline void amax(T & a, T const & b) { a = max(a, b); }

inline ll square(ll x) { return x * x; }
inline ll gcd(ll a, ll b) { while(a) swap(a, b%=a); return b; }
template <typename T>
inline T mod(T a, T b) { return ((a % b) + b) % b; }


ll solve(ll N, ll A, ll B, ll C, ll D, ll E){
    ll t = 0;
    ll t1 = (N + A-1) / A; amax(t, 0+t1+4);
    ll t2 = (N + B-1) / B; amax(t, 1+t2+3);
    ll t3 = (N + C-1) / C; amax(t, 2+t3+2);
    ll t4 = (N + D-1) / D; amax(t, 3+t4+1);
    ll t5 = (N + E-1) / E; amax(t, 4+t5+0);
    return t;
}

int main() {
    ll N,A,B,C,D,E; cin >> N >> A >> B >> C >> D >> E;
    cout << solve(N,A,B,C,D,E) << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <cstring>
#include <queue>
#include <functional>
#include <set>
#include <map>
#include <string>
#include <cmath>
#include <cassert>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define repd(i, n) for (int i = n; i >= 1; i--)
#define mod 1000000007
#define MOD 998244353
#define inf 1e20
typedef long long int ll;
typedef pair<ll, ll> p;


int main() {
	int n, m;
	cin >> n >> m;
	vector<int> a(n);
	rep(i, n) {
		a[i] = 0;
	}
	rep(i, 2*m) {
		int put;
		cin >> put;
		a[put - 1]++;
	}
	rep(i, n) {
		cout << a[i] << endl;
	}
	return 0;
}

//Ctrl+Aを使わない

Measured memory_bytes: 256
n = int(input())
li = list(map(int,input().split()))
lia = [0]*n
sum1 = 0
for i in range(n):
    lia[li[i]-1] += 1
for i in range(n):
    if lia[i] >= 2:
        lia[i] -= 1
        sum1 += (lia[i]*(lia[i]+1)//2)
    else:
        if lia[i] == 1:
            lia[i] -= 1
for i in range(n):
    if lia[li[i]-1] >= 1:
        a = lia[li[i]-1]*(lia[li[i]-1]+1)//2
        b = (lia[li[i]-1]-1)*lia[li[i]-1]//2
        print(sum1-a+b)
    else:
        print(sum1)

Measured memory_bytes: 82640
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define repb(i, a, b) for(int i = a; i >= b; i--)
#define all(a) a.begin(), a.end()
#define int long long
using namespace std;
typedef pair<int, int> P;

signed main(){
    int n;
    cin >> n;
    int ans = 1;
    rep(i, 1, n + 1) ans *= i;
    cout << ans << endl;
}

Measured memory_bytes: 3012
#include<stdio.h>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<utility>
#include<memory>
#include<cmath>
 
#define ALL(g) (g).begin(),(g).end()
#define REP(i, x, n) for(int i = x; i < n; i++)
#define rep(i,n) REP(i,0,n)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define pb push_back

using namespace std;
 
typedef long long ll;
typedef pair<int,int> P;
const int mod=1e9+7,INF=1<<30;
const double EPS=1e-12,PI=3.1415926535897932384626;
const int MAX_T=100001;

int main(){
  int par[13]={-1,0,2,0,1,0,1,0,0,1,0,1,0};
  int x,y;
  cin >> x >> y ;
  if(par[x]==par[y])  cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}


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

int days400 = 365 * 400 + 97;
unsigned base;
unsigned acc_1[13] = {0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334, 365};
unsigned acc_2[13] = {0, 31, 60, 91, 121, 152, 182, 213, 244, 274, 305, 335, 366};
unsigned *acc[401];

bool isleap(int y){
	return y % 400 == 0 || y % 4 == 0 && y % 100 != 0;
}

unsigned sumdays(int y, int m, int d){
	int t = (y - 1) / 400;
	unsigned ret = t * days400;
	y -= t * 400;
	for(int i = 1; i < y; ++i){
		ret += acc[i][12];
	}

	ret += acc[y][m - 1] + d;
	return ret;
}

void chr(int b, int ka, int t, int w, int ki){
	unsigned s = (((b * 20u + ka) * 20u + t) * 18u + w) * 20u + ki + base;

	int y = 0, m = 0, d = 0;
	y = (s / days400) * 400;
	s %= days400;

	while(s > acc[(y + 1) % 400][12]){
		++y;
		s -= acc[y % 400][12];
	}

	++y;
	m = lower_bound(acc[y % 400], acc[y % 400] + 13, s) - acc[y % 400];
	d = s - acc[y % 400][m - 1];

	printf("%d.%d.%d\n", y, m, d);
}

void may(int y, int m, int d){
	unsigned s = sumdays(y, m, d) - base;
	int ki = s % 20;
	int w = s / 20 % 18;
	int t = s / 360 % 20;
	int ka = s / 7200 % 20;
	int b = s / 144000 % 13;

	printf("%d.%d.%d.%d.%d\n", b, ka, t, w, ki);
}

int main(){
	for(int i = 0; i <= 400; ++i){
		acc[i] = isleap(i) ? acc_2 : acc_1;
	}
	base = sumdays(2012, 12, 21);

	char buf[32];
	while(scanf(" %s", buf), buf[0] != '#'){
		int b, ka, t, w, ki, y, m, d;
		if(sscanf(buf, "%d.%d.%d.%d.%d", &b, &ka, &t, &w, &ki) == 5){
			chr(b, ka, t, w, ki);
		}
		else{
			sscanf(buf, "%d.%d.%d", &y, &m, &d);
			may(y, m, d);
		}
	}
}

Measured memory_bytes: 1036
#include<stdio.h>
#include<stdlib.h>
int main()
{
    long long int n,k,x,y,s;
    scanf("%lld%lld%lld%lld",&n,&k,&x,&y);
    if(n>k)
    {
        s=k*x;
    n=n-k;
    s=s+(n*y);
    }
    else
    {
        s=n*x;
    }
    printf("%lld\n",s);
}



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

using ll = long long;
const ll INF = 1e18;

const int MAX_N = 100010;
int par[MAX_N];
int rnk[MAX_N];
int siz[MAX_N];

void init(int n) {
    rep(i,n) {
        par[i] = i;
        rnk[i] = 0;
        siz[i] = 1;
    }
}

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

void unite(int x, int y) {
    x = find(x);
    y = find(y);
    if (x == y) return;
    int s = siz[x] + siz[y];
    if (rnk[x] < rnk[y]) {
        par[x] = y;
    } else {
        par[y] = x;
        if (rnk[x] == rnk[y]) rnk[x]++;
    }
    siz[find(x)] = s;
}

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

int size(int x) {
    return siz[find(x)];
}

int main() {
    int N, M, K, A, B, C, D;
    cin >> N >> M >> K;
    init(N);
    vector<vector<int>> friends(N), block(N);
    rep(i, M) {
        cin >> A >> B;
        unite(--A, --B);
        friends[A].push_back(B);
        friends[B].push_back(A);
    }
    rep(i, K) {
        cin >> C >> D;
        block[--C].push_back(--D);
        block[D].push_back(C);
    }
    rep(i, N) {
        int ans = size(i) - friends[i].size() - 1;
        rep(j, block[i].size()) {
            if (same(i, block[i][j])) ans--;
        }
        cout << ans;
        if (i == N - 1) cout <<  "\n";
        else cout << " ";
    }
    /*rep(i, N) {
        rep(j, friends[i].size()) {
            cout << friends[i][j] << " ";
        }
        cout << "\n";
    }*/
}

Measured memory_bytes: 13048
def main():
    N = int(input())

    Sn = [] #Square numbers
    i = 1
    while 1:
        if i ** 2 <= N:
            Sn.append(i ** 2)
            i += 1
        else:
            break

    print(Sn[-1])


if __name__ == "__main__":
    main()

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

int main() {
  int A;
  int B;
  cin >> A >> B ;
   if (A <= 5)
   { cout << 0 << endl; }
   else if ( 6<=A && A<=12 ) 
   { cout << B/2 << endl;}
   else
   { cout << B <<endl; } }


Measured memory_bytes: 256
#include <stdio.h>

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

    int min = l,max = l + n - 1,ans = (min + max) * n / 2;

    if (min < 0 && max < 0)
    {
        ans -= max;
    }
    else if (min > 0 && max > 0)
    {
        ans -= min;
    }
    
    printf("%d",ans);
}

Measured memory_bytes: 256
// IO library
#include <cstdio>
#include <iomanip>
#include <ios>
#include <iostream>

// algorithm library
#include <algorithm>
#include <cmath>
#include <numeric>

// container library
#include <deque>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>

// namespace
using namespace std;

// typedef
typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VL;
typedef vector<VL> VVL;
typedef vector<string> VS;
typedef vector<bool> VB;
typedef vector<VB> VVB;

// conversion
#define INT(c) static_cast<int>(c)
#define CHAR(n) static_cast<char>(n)
#define LL(n) static_cast<ll>(n)

// container
#define EACH(i, c) for (auto i = (c).begin(); i != (c).end(); i++)
#define SORT(c) sort((c).begin(), (c).end())
#define GSORT(c) sort((c).begin(), (c).end(), greater<decltype((c).front())>())
#define SZ(x) (INT((x).size()))
#define MEMSET(c, v) memset((c), v, sizeof(c))

// repetition
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define REP(i, n) FOR(i, 0, n)
#define NREP(i, n) FOR(i, 1, n + 1)
#define RFOR(i, a, b) for (int i = (a); i >= (b); i--)
#define RREP(i, n) RFOR(i, n, 0)
#define RNREP(i, n) RFOR(i, n, 1)

// constant
// const ll MOD = 1e9 + 7;
// const int INF = 1<<25;
// const ll INF = 1LL<<50;
// const int dx[4] = {0, -1, 1, 0};
// const int dy[4] = {-1, 0, 0, 1};
// const int dx[8] = {-1, 0, 1, -1, 1, -1, 0, 1};
// const int dy[8] = {-1, -1, -1, 0, 0, 1, 1, 1};

// debug
#define test(x) cout << #x << " = " << x << endl

// answer output
#define Yes(c) cout << ((c) ? "Yes" : "No") << endl;
#define YES(c) cout << ((c) ? "YES" : "NO") << endl;
#define yes(c) cout << ((c) ? "yes" : "no") << endl;

#define possible(c) cout << ((c) ? "possible" : "impossible") << endl;
#define POSSIBLE(c) cout << ((c) ? "POSSIBLE" : "INPOSSIBLE") << endl;


// --------------------------------------------------------


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

  int N, K;
  cin >> N >> K;

  VB hate(10, false);
  REP(i, K) {
    int D;
    cin >> D;
    hate[D] = true;
  }

  for (int ans = N; ans < 1000000; ans++) {
    int cpans = ans;
    while (cpans > 0) {
      if (!hate[cpans % 10]) {
        cpans /= 10;
      } else {
        break;
      }
    }
    if (cpans == 0) {
      cout << ans << endl;
      return 0;
    }
  }
  return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <fstream>
#include <sstream>
#include <set>
#include <map>
#include <vector>
#include <list>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <string>
#include <queue>
#include <bitset>     //UWAGA - w czasie kompilacji musi byc znany rozmiar wektora - nie mozna go zmienic
#include <cassert>
#include <iomanip>        //do setprecision
#include <ctime>
#include <complex>
using namespace std;

#define FOR(i,b,e) for(int i=(b);i<(e);++i)
#define FORQ(i,b,e) for(int i=(b);i<=(e);++i)
#define FORD(i,b,e) for(int i=(b)-1;i>=(e);--i)
#define REP(x, n) for(int x = 0; x < (n); ++x)

#define ST first
#define ND second
#define PB push_back
#define MP make_pair
#define LL long long
#define ULL unsigned LL
#define LD long double

const double pi = 3.141592653589793238462643383279502884197169399375105820974944592307816406286208998628034825342;
const int mod=1000000007;

int main(){
	int n,c=0;
	bitset<1012012012> b(0);
	cin>>n;
	FOR(i,0,n){
		int a;
		cin>>a;
		if(b[a]){
			b[a]=0;
			c--;
		}else{
			b[a]=1;
			c++;
		}
	}
	cout<<c<<endl;
    return 0;
}


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


int main () {
  long long tot = 0, n;
  cin >> n;

  for (long long i = 1; i < 1e6; i++) {
    long long m = n / i - 1;
    if (m == 0) continue;
    if (n / m == n % m) {
      tot += n / i - 1;
    }
  }

  cout << tot << '\n';
  return 0;
}

Measured memory_bytes: 256