akhauriyash/Code-Regression huggingface dataset:
sx, sy, tx, ty = map(int, input().split())
route = ""
dx, dy = tx - sx, ty - sy
path1 = "R" * dx + "U" * dy
path2 = "L" * dx + "D" * dy
dx, dy = dx + 1, dy + 1
path3 = "D" + "R" * dx + "U" * dy + "L"
path4 = "U" + "L" * dx + "D" * dy + "R"
ans =path1 + path2 + path3 + path4
print( ans)


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

using ll = long long;
#define REP(i,n) for(ll i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
string char_to_string(char val) {
  return string(1, val);
}
int char_to_int(char val) {
  return val - '0';
}

int main() {
  string s; cin >> s;
  int a = 0;
  int b = 0;

  REP(i, s.size()) {
    if(s[i] == 'A') {
      a = i;
      break;
    }
  }

  for(int i = s.size() - 1; i >= 0; --i) {
    if(s[i] == 'Z') {
      b = i;
      break;
    }
  }

  cout << b - a + 1 << endl;
}

Measured memory_bytes: 640
#include<cstdio>
#include<algorithm>
#include<iostream>
#include<cstring>
using namespace std;
#define rg register
void read(int &x){
    char ch;bool ok;
    for(ok=0,ch=getchar();!isdigit(ch);ch=getchar())if(ch=='-')ok=1;
    for(x=0;isdigit(ch);x=x*10+ch-'0',ch=getchar());if(ok)x=-x;
}
const int maxn=2010,mod=1e9+7,N=4e6;
int n,m,f[maxn][maxn],fac[maxn*maxn],inv[maxn*maxn];
int mul(int x,int y){return 1ll*x*y-1ll*x*y/mod*mod;}
int add(int x,int y){return x+y>=mod?x+y-mod:x+y;}
int del(int x,int y){return x-y<0?x-y+mod:x-y;}
int mi(int a,int b){int ans=1;while(b){if(b&1)ans=mul(ans,a);b>>=1,a=mul(a,a);}return ans;}
void prepare(){
    fac[0]=inv[0]=1;
    for(rg int i=1;i<=N;i++)fac[i]=mul(fac[i-1],i);
    inv[N]=mi(fac[N],mod-2);
    for(rg int i=N-1;i;i--)inv[i]=mul(inv[i+1],i+1);
}
int C(int n,int m){return mul(fac[n],mul(inv[m],inv[n-m]));}
int main(){
    read(n),read(m),prepare();
    if(m==1)return printf("1\n"),0;
    for(rg int i=1;i<=n;i++){
	f[i][0]=1;
	for(rg int j=1;j<=i;j++)
	    f[i][j]=add(f[i-1][j],mul(mul(f[i][j-1],n-j+1),C(n*m-(j-1)*(m-1)-i-1,m-2)));
    }
    printf("%d\n",f[n][n]);
}


Measured memory_bytes: 47488
#include <bits/stdc++.h>
using namespace std;
using Int = long long;
int main()
{
    int L, R; cin >> L >> R;
    int I[2019] = {0};
    for (int i = L; i < min(L+2019, R+1); i++) {
        I[i%2019]++;
    }
    int ans = 2019;
    for (int i = 0; i < 2019; i++) {
        for (int j = 0; j < 2019; j++) {
            if (I[i] && I[j] && i != j) {
                ans = min(ans, i * j % 2019);
            }
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
using namespace std;
int main() {
	int A, B, C;
	scanf("%d%d%d", &A, &B, &C);
	if( A > C ) swap(A, C);
	if( B > C ) swap(B, C);
	if( A > B ) swap(A, B);
	int K1 = C - A, K2 = C - B;
	int ans = K2;K1 -= K2;
	if( K1 % 2 == 0 ) printf("%d\n", ans + K1/2);
	else printf("%d\n", ans + K1/2 + 2);
}

Measured memory_bytes: 128
N, M = map(int, input().split())
ac = 0
is_AC = [False] * (N + 1)
WA_cnt = [0] * (N + 1)
for i in range(M):
    p, s = input().split()
    p = int(p)
    if s == 'WA':
        if is_AC[p]:
            continue
        else:
            WA_cnt[p] += 1
    else:
        if is_AC[p]:
            continue
        else:
            is_AC[p] = True
            ac += 1

wa = 0
for i in range(N + 1):
    if is_AC[i]:
        wa += WA_cnt[i]
print(ac, wa)
'''
うまくいかなかったパターン
1 4
1 WA
1 WA
1 WA
1 WA
'''


Measured memory_bytes: 10392
//By : BebekJK
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;

#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
//Declare -> ordered_set NAMA;
//Nth smallest integer -> find_by_order(N-1)
//Number of elements less than N -> order_of_key(N)
//Delete N from the set -> erase(N)

#define endl '\n'
#define MOD 1000000007
#define PI 3.141592653
#define fi first
#define sc second
#define pb push_back
#define pbb pop_back

//#pragma GCC optimize("Ofast")
//#pragma GCC target ("string"...)
//#pragma GCC push_options
//#pragma GCC pop_options
//#pragma GCC reset_options
//#pragma GCC optimize ("O3")

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

void BOOST(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);cout.tie(0);
}
void fcin(int &x){
	bool neg = false;
	register int c;
	x = 0;
	c = getchar();
	if(c=='-'){
		neg = true;
		c = getchar();
	}
	for(;(c>47 && c<58);c=getchar())x = (x<<1)+(x<<3)+c-48;
	if(neg)x*=-1;
}
ll pmod(ll a , ll b){
	if(b==0)return 1;
	ll temp = pmod(a , b/2);
	if(b%2==0)return(temp*temp)%MOD;
	return (((temp*temp)%MOD)*a)%MOD;
}
int N , X , T;
int main(){
	cin>>N>>X>>T;
	cout<<((N+X-1)/X)*T<<endl;
}







Measured memory_bytes: 3644
#include <bits/stdc++.h>
 
using namespace std;
int main(){
  string S;
  char p=' ';
  int cnt = 0;
  
  cin >> S;

  for(int i = 0; i < S.size();i++){
    if(p == S[i]){
        p = 0;
    }else if(p==0){
        cnt++;
        p = ' ';
    }else{
        p=S[i];
        cnt++;
    }
  }
  cout << cnt << endl;
}

Measured memory_bytes: 640
#define _CRT_SECURE_NO_DEPRECATE
//#include <bits/stdc++.h>
#include <iostream>
#include <algorithm>
#include <numeric>
#include <vector>
#include <unordered_set>
#include <unordered_map>
using namespace std;
#define ll  long long
 
int main() {
	//freopen("test.txt", "r", stdin);
	ll a,b; cin>>a>>b;
	if(a==1 || b==1) {cout<<1<<endl; return 0;}
	ll c = a*b;
	if(c%2!=0) c++;
	cout<<c/2<<endl;
	return 0;
}

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

int main()
{
  typedef long long ll;
  ll N, T;
  cin >> N >> T;
  ll sum = N*T;
  ll t_prev;
  cin >> t_prev;
  for (ll i = 1; i < N; ++i)
  {
    ll t;
    cin >> t;
    if (t - t_prev < T)
      sum -= (T - (t - t_prev));
    t_prev = t;
  }
  cout << sum;
  return 0;
}


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

int main() {
  int N, A;
  
  cin >> N >> A;

  if (N % 500 == 0) {
    cout << "Yes" << endl;
  }
  else if (N % 500 < A) {
    cout << "Yes" << endl;
  }
  else if (N % 500 > A) {
    cout << "No" << endl;
  }
 
  // ここにプログラムを追記
}

Measured memory_bytes: 3620
import java.io.{BufferedOutputStream, BufferedReader, InputStreamReader, PrintWriter}

import scala.annotation.tailrec

object Main {
  def main(args: Array[String]): Unit = {
    val in = new BufferedReader(new InputStreamReader(System.in))
    val out = new PrintWriter(new BufferedOutputStream(System.out))
    val _ = in.readLine().toInt
    val xs = in.readLine().split("\\s+").map(_.toInt)

    out.println(
      (1 to 100).map { p =>
        xs.map { x => (x - p) * (x - p) }.sum
      }.min
    )

    out.flush()
  }
}


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


Measured memory_bytes: 2104
import sys

import numpy as np

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline


def main():
    N, H = map(int, readline().split())
    m = map(int, read().split())
    AB = np.array(list(zip(m, m)))

    A_max = np.max(AB[:, 0])
    B = AB[:, 1]
    B = np.sort(B)[::-1]
    B = B[B > A_max]
    cnt = 0
    d = 0
    for b in B:
        d += b
        cnt += 1
        if H <= d:
            print(cnt)
            sys.exit()

    ans = (H - d) / A_max + cnt
    if ans % 1 != 0:
        ans = int(ans) + 1

    print(int(ans))


main()


Measured memory_bytes: 36584
#include "bits/stdc++.h"
using namespace std;
long long INF = 1e18;
int main() {
	int A, B,Q;
	cin >> A >> B >> Q;
	vector<long long>S(A);
	for (int n = 0;n<A;++n) {
		cin >> S[n];
	}
	vector<long long>T(B);
	for (int n = 0;n<B;++n) {
		cin >> T[n];
	}
	S.push_back(INF); 
	S.push_back(-INF);	
	T.push_back(INF);
	T.push_back(-INF);
	sort(S.begin(),S.end()); 
	sort(T.begin(), T.end());
	for (int n = 0;n<Q;++n) {
		long long x;
		cin >> x;
		long long ans = INF;
		long long first;
		long long secound;
		for (int i = 0;i<2;++i) {
			int  l = upper_bound(S.begin(), S.end(), x) - S.begin();
			first = S[l - i]; 
			for (int j = 0;j<2;++j) {
				if (INF != abs(first)) {
					int  m = upper_bound(T.begin(), T.end(), first) - T.begin();
					secound = T[m - j];
					if (INF != abs(secound) ){
						ans = min(ans, abs(first - x) + abs(secound - first));
					}
				}
			}
		}
		for (int i = 0; i < 2; ++i) {
			int  l = upper_bound(T.begin(), T.end(), x) - T.begin();
			first = T[l - i];
			for (int j = 0; j < 2; ++j) {
				if (INF != abs(first)) {
					int  m = upper_bound(S.begin(), S.end(), first) - S.begin();
					secound = S[m - j];
					if(INF != abs(secound)) {
						ans = min(ans, abs(first - x) + abs(secound - first));
					}
				}
			}
		}
		cout << ans << endl;
	}
}


Measured memory_bytes: 5548
#define _CRT_SECURE_NO_WARNINGS
//#include <stdafx.h>
//#include "targetver.h"
#include <stdio.h>
//#include <tchar.h>
#include <iostream>
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

#if __cplusplus >= 201103L
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#endif>

#define LL long long
#define MOD 1000000007
#define INF 1000000000
#define LINF 1000000000000000000

using namespace std;

const int N = 1e5 + 10;
int a[N];
int dp[N];
int visited[N];
vector<int>vec[N];
vector<int>vec2;
void dfs(int n) {

	visited[n] = 1;
 	//printf("%d\n", n);
	for (auto x : vec[n]) {
		dp[x] = max(dp[x], dp[n] + 1);
		a[x]--;

		if (a[x] == 0)
			dfs(x);
	}


}
int main()
{
	int n, m;
	scanf("%d%d", &n, &m);
	for (int i = 0; i < m; i++) {
		
		int u, v;
		scanf("%d%d", &u, &v);
		a[v]++;
		vec[u].push_back(v);
	}
	//for (int i = 1; i <= n; i++)
		//if (a[i] == 0)
			//vec2.push_back(i);

	for (int i = 1; i <= n; i++)
		if(!visited[i]&&a[i]==0)
			dfs(i);
	
	int ans = 0;
	for (int i = 1; i <= n; i++)
		ans = max(ans, dp[i]);

	printf("%d", ans);
	//cin >> ans;
}



Measured memory_bytes: 9984
mod = 10**9+7
n, a, b = map(int,input().split())
N = max(a,b)
fact = [None for i in range(N+1)]
fact[0] = 1
for i in range(1, N+1):
    fact[i] = (fact[i-1]*i) % mod
finv = [None for i in range(N+1)]
def inv(x):
    ret = 1
    k = mod - 2
    y = x
    while k:
        if (k & 1):
            ret = (ret * y) % mod
        y = (y * y) % mod
        k //= 2
    return ret
finv[N] = inv(fact[N])
for i in range(N, 0, -1):
    finv[i-1] = (finv[i]*i) % mod
def binpow(x, n, mod=None):
    ret = 1
    while n > 0:
        if n % 2 == 1:
            ret = (ret * x) % mod
        x = (x * x) % mod
        n >>= 1
    return ret
def comb(n,k):
    tmp = 1
    for i in range(k):
        tmp = (tmp*(n-i)) % mod
    return (tmp * finv[k]) % mod
print((binpow(2,n,mod=mod)-1-comb(n,a)-comb(n,b))%mod)

Measured memory_bytes: 18968
#include<stdio.h>

int main(){
  int N;
  scanf("%d\n", &N);
  
  char s[100001];
  scanf("%s", s);
  for(int i = 0; s[i] != '\0'; i++){
    if(s[i] + N >= 91){
      s[i] -= 26;
    }
    printf("%c", (char)(s[i] + N));
  }
  
  return 0;
}

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

const int D = 60;
const int MAX_N = 200005;
int to[D][MAX_N];

int main() {
	int n; ll k;
	cin >> n >> k;
	rep(i, n) {
		cin >> to[0][i];
		to[0][i]--;
	}
	rep(i, D - 1) rep(j, n) {
		to[i + 1][j] = to[i][to[i][j]];
	}

	int v = 0;
	for (int i = D - 1; i >= 0; --i) {
		ll l = 1ll << i;
		if (l <= k) {
			v = to[i][v];
			k -= l;
		}
	}
	cout << v + 1 << endl;
	return 0;
}

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

using namespace std;

#define ok1 printf("ok1\n");
#define ok2 printf("ok2\n");
#define M 1000000000000000000LL
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,k,n)　for(int i=(k);i<(n);i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define REPR(i,s,n) for(int i=(s);i>=(n);i--)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define pb push_back
#define pf push_front
#define MIN(a,b) a=min((a),(b))
#define MAX(a,b) a=max((a),(b))
#define SIZE(v) (int)v.size()
#define Eunique(v) v.erace(unique(all(v)),v.end())
#define pvec(v)　rep(i,v.size()){cout << v[i] << " ";}
#define INF 0x3f3f3f3f
#define mset(m,v) memset(m,v,sezeof(m))
#define mod 1e9 +7;

const double pi = acos(-1.0);

typedef string ss;
typedef vector<int> vi;
typedef vector<string> vs;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef deque<ll> dll;
typedef pair<ll,ll> P;
ll dx[4] = {1,0,-1,0},dy[4] = {0,1,0,-1};

ll gcd(ll x,ll y)
{
    ll r;
    while((r = x % y) != 0)
    {
        x = y;
        y = r;
    }
    return y;
}

ll lcm(ll x,ll y)
{
    x /= gcd(x,y);
    return (x*y);
}

#define WA printf("WA\n");
int main()
{
    ss s,t;
    cin >> s >> t;

    rep(i,SIZE(s)){
        ll count=0;
        rep(j,SIZE(s)-i){
            if(s[j+i] == t[j])count++;
            //cout << t[j];
        }
        rep(j,i){
            if(s[j] == t[SIZE(s)-i+j])count++;
            //cout << t[SIZE(s)-i+j] ;
        }

        //cout << endl;
        if(count == SIZE(s)){
            cout << "Yes" << endl;
            return 0;
        }
    }

    cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

class Program
{
    static void Main(string[] args)
    {
        int n = int.Parse(Console.ReadLine());
        string[] str = Console.ReadLine().Split(' ');
        int moveCount = 0;
        int maxCount = 0;
        for (int i = 0; i < n -1; i++)
        {
            if (int.Parse(str[i + 1]) <= int.Parse(str[i]))
            {
                moveCount++;
            }
            else
            {
                if (maxCount < moveCount)
                {
                    maxCount = moveCount;
                }
                moveCount = 0;
            }
        }
        if (maxCount < moveCount)
        {
            maxCount = moveCount;
        }
        Console.WriteLine(maxCount);
    }
}


Measured memory_bytes: 24668
#include <cmath>
#include <complex>
#include <algorithm>
using namespace std;

typedef long double Real;
typedef complex<Real> Point;
#define PCR Point const &
#define X real()
#define Y imag()

const Real EPS = 1e-10;
const Real INF = 1e100;
const Real PI = acos(-1);

struct Segment {
    Point p[2];
    Segment (PCR a = Point(), PCR b = Point()){
        p[0] = a, p[1] = b;
    }
    Point & operator [] (int k) { return p[k]; }
    Point const & operator [] (int k) const { return p[k]; }
};
typedef vector<Point> Polygon;
struct Circle { Real radius; Point center; };

Real dot(PCR a, PCR b){
    return a.X*b.X + a.Y*b.Y;
}
Real cross(PCR a, PCR b){
    return a.X*b.Y - a.Y*b.X;
}

Point pSP(Segment const & s, PCR p){
    Point base = s[1] - s[0];
    Real r = dot(p - s[0], base) / norm(base);
    return s[0] + base * r;
}

Point rSP(Segment const & s, PCR p){
    Point v = pSP(s,p) - p;
    return p + v * Real(2);
}

enum { LEFT = 1, RIGHT = -1, BACK = 2, FRONT = -2, ON = 0 };
// Includes end-points. Comment in to exclude.
int ccw(PCR x, PCR p, PCR q){
    Point a = p - x, b = q - x;
    if(cross(a,b) > EPS) return LEFT;
    if(cross(a,b) < -EPS) return RIGHT;
    if(/* abs(a) < EPS || */ dot(a,b) < -EPS) return BACK;
    if(/* abs(b) < EPS || */ norm(a) < norm(b)) return FRONT;
    return ON;
}

// bool iLL(Segment const & s, Segment const & t){

// }

#include <iostream>
#include <cstdio>

int main(){
    Segment s,t;
    Real x,y;
    int n; cin >> n;
    for(int i=0;i<n;i++){
        cin >> x >> y;
        s[0] = Point(x,y);
        cin >> x >> y;
        s[1] = Point(x,y);
        cin >> x >> y;
        t[0] = Point(x,y);
        cin >> x >> y;
        t[1] = Point(x,y);
        Real a = arg(s[1] - s[0]);
        Real b = arg(t[1] - t[0]);
        if(a < EPS) a += PI;
        if(b < EPS) b += PI;

        if(abs(a-b) < EPS) puts("2");
        else if(abs(abs(a-b)-PI/2) < EPS) puts("1");
        else puts("0");
    }
}

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

int main(){
  long n,x,m;
  cin >> n >> x >> m;
  long ai = x;
  long ans = 0;
  long rui[m+1];
  vector<vector<long>> flag(m+1);
  rep(i,m+1)rui[i] = 0;
  // rui[0] = ai;
  rui[0] = 0;
  long suma = INF,num = INF, t = 0;
  int f = 0;
  for(long i=1;i<=min(m,n);i++){
    rui[i] = rui[i-1] + ai;
    if(int(flag[ai].size())){
      suma = rui[i] - flag[ai][1];
      num = i - flag[ai][0];
      t = i;
      f = 1;
      break;
    }
    ans += ai;
    flag[ai].push_back(i);
    flag[ai].push_back(rui[i]);
    ai *= ai;
    ai %= m;
  }
  if(f)ans += ((n-t+1)/num) * suma;
  if(f){
    for(long i=0;i<(n-t+1)%num;i++){
    ans += ai;
    ai *= ai;
    ai %= m;
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 7952
n=int(input())
l=str(input())
#print(type(l))

ll=[]
leng=len(l)
#print('leng is %d'%leng)
for i in range(leng):
    t=l[i]
    tt=(ord(t)-ord('A')+1+n)%26
    if tt==0:
        tt+=26
    ttt=chr(tt+64)
    ll.append(ttt)
print(*ll,sep='')

Measured memory_bytes: 4724
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define mod 1000000007
#define fi first
#define sc second
#define rep(i,x) for(long long i=0;i<x;i++)
#define repn(i,x) for(long long i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())
vector<pair<string,P> >vec;
// vector<vector<int>> data(3, vector<int>(4));

void solve(string s, long long K){
	ll res = K;
	rep(i,s.length()-1) {
		// cout << i << " " << res << " " << ('z'-s[i]+1)%26 << " " << endl;
		if (res < ('z'-s[i]+1)%26) {
			continue;
		} else {
			res = res-('z'-s[i]+1)%26;
			s[i] = 'a';
		}
	}
	rep(i,s.length()-1) {
		cout << s[i];
	}
	cout << (char)((s[s.length()-1]-'a'+res)%26+'a') << endl;
}

int main(){	
	long long K;
	string s;
	cin >> s;
	scanf("%lld",&K);
	solve(s, K);
	return 0;
}



Measured memory_bytes: 512
#include <iostream>
using namespace std;
int main() {
    int  N, cnt=0;
    cin >> N;
    for (int i=0;i<N;i++){
        int a;
        cin >> a;
        for (;a%2==0;cnt++)
            a/=2;
    }
    cout << cnt;
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(void){

	int i;
	int x;
	int sum[100],mode=0;

	for(i=0;i<100;i++)
		sum[i] = 0;

	while(scanf("%d",&x)!=EOF){

		sum[x-1]++;
		if(sum[x-1] > mode)
			mode = sum[x-1];

	}

	for(i=0;i<100;i++){
		if(sum[i] == mode)
			printf("%d\n",i+1);
	}

	return 0;
}

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

using namespace std;
#define ll long long
#define FOR(i, a, b) for (ll i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define PRINT(item) cout << (item) << endl;
#define PRINT_VEC(V)                                                           \
    for (auto v : (V))                                                         \
        cout << v << ' ';
const int MOD = 1000000007;
/* cout << fixed << setprecision(10) << decimal << endl; */

int main() {
    /* code */
    int A, B, C, D;
    cin >> A >> B >> C >> D;
    bool isTakahashi = false;
    while (true) {
        C -= B;
        if (C <= 0) {
            isTakahashi = true;
            break;
        }
        A -= D;
        if (A <= 0) {
            break;
        }
    }
    if (isTakahashi) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
    return 0;
}

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

public class Main
{
    PrintWriter out = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out)));
    BufferedReader in = new BufferedReader(new InputStreamReader(System.in));

    public void go() throws IOException
    {
        StringTokenizer tok = new StringTokenizer(in.readLine());
        int n = Integer.parseInt(tok.nextToken());
        tok = new StringTokenizer(in.readLine());
        double sum = 0;
        for (int i = 0; i < n; i++)
        {
            double d = Integer.parseInt(tok.nextToken());
            d = 1/d;
            sum += d;
        }
        out.println(1 / sum);

        out.flush();
        in.close();
    }

    public static void main(String[] args) throws IOException
    {
        new Main().go();
    }
}


Measured memory_bytes: 21332
#include <bits/stdc++.h>
#define LL long long
#define FOR(i,a,b) for(int i=a; i<=b; i++)
#define FOD(i,a,b) for(int i=a; i>=b; i--)
#define pa pair<int,int>
#define fi first
#define se second
#define MOD xxx
#define getbit(n,i) ((n>>(i-1))&1)
#define offbit(n,i) ((n^(1<<(i-1))
#define onbit(n,i) (n|(1<<(i-1)))
#define cntone(x) (__builtin_popcount(x))
using namespace std;
const int N = 80+5;
const int P = 12800;
int m,n;
int A[N][N],B[N][N];
int F[N][N][N*N*4];
int tmp,ans(0);
int main()
{
    cin >> m >> n;
    FOR(i,1,m)
    FOR(j,1,n) cin >> A[i][j];
    FOR(i,1,m)
    FOR(j,1,n) cin >> B[i][j];
    tmp = A[1][1] - B[1][1];
    F[1][1][tmp +P] = F[1][1][-tmp +P] = 1;
    FOR(i,1,m)
    FOR(j,1,n)
    if(i+j!=2)
    {
        tmp = A[i][j] - B[i][j];
        FOR(k,0,2*P)
        if(F[i-1][j][k] || F[i][j-1][k])
        {
            F[i][j][k+tmp] = F[i][j][k-tmp] = 1;
        }
    }
    FOR(i,0,P)
    {
        if(F[m][n][i+P]==1)
        {
            ans = i;
            break;
        }
        if(F[m][n][i])
        ans = i-P;
    }
    cout << abs(ans);
	return 0;
}


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

int main()
{
    int array[] = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};

    int K;
    cin >> K;

    cout << array[K-1];

    return 0;
}

Measured memory_bytes: 888
sums = []

def digits(v)
  count = 1
  while v >= 10
    v /= 10
    count += 1
  end
  count
end

STDIN.each_line do |line|
  a, b = line.split(" ")
  a, b = a.to_i, b.to_i

  sums << a + b
end

sums.each do |sum|
  puts digits(sum)
end

Measured memory_bytes: 6076
#include<iostream>
#define ll long long
using namespace std;

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


Measured memory_bytes: 1792
#include <stdio.h>
int main(void){
int a,b,sum,time,minus;
  scanf("%d %d",&a,&b);
  sum=a+b;
  time=a*b;
  minus=a-b;
  if(sum>=time&&sum>=minus){printf("%d",sum); return 0;}
   if(time>=sum&&time>=minus){printf("%d",time);return 0;}
   if(minus>=time&&minus>=sum){printf("%d",minus);return 0;}
  
return 0;}

Measured memory_bytes: 128
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<math.h>
#include<string>
#include<string.h>
#include<stack>
#include<queue>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<stdlib.h>
#include<iomanip>

using namespace std;

#define ll long long
#define ld long double
#define EPS 0.0000000001
#define INF 1e9
#define MOD 1000000007
#define rep(i,n) for(i=0;i<n;i++)
#define loop(i,a,n) for(i=a;i<n;i++)
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)

typedef vector<int> vi;
typedef pair<int,int> pii;

int main(void) {
  int i,j;
  int n,k;
  cin>>n>>k;
  int ans=INF;
  rep(i,n+1){
    j=n-i;
    int tmp=1,p;
    rep(p,i)tmp*=2;
    ans=min(ans,tmp+j*k);
  }
  cout<<ans<<endl;

}


Measured memory_bytes: 256
N=int(input())
count=0
a=0
for i in range(N):
    D=list(map(int,input().split()))
    if D[0]==D[1]:
        count+=1
        if count>=3:
            a=1
            break
    else:
        count=0
if a==1:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 9132
from collections import deque
num_ver, num_edge = map(int,input().split())
edges_ls = [0] * num_edge
for i in range(num_edge):
    a,b = map(int,input().split())
    a -= 1
    b -= 1
    edges_ls[i] = [a,b]

num_bridge = 0
for ind_take_edge in range(num_edge):
    graph_ls = [[] for _ in range(num_ver)]
    # graph_lsを作る
    for ind_edge in range(num_edge):
        if ind_edge != ind_take_edge:
            a,b = edges_ls[ind_edge]
            graph_ls[a].append(b)
            graph_ls[b].append(a)
    
    # 0からdfsしてdone_lsを仕上げていく
    done_ls = [0] * num_ver
    queue = deque()
    queue.append(0)
    while queue:
        now = queue.pop()
        done_ls[now] = 1
        for nex in graph_ls[now]:
            if done_ls[nex] != 1:
                queue.append(nex)
    
    if sum(done_ls) != num_ver:
        num_bridge += 1

print(num_bridge)

    

            



Measured memory_bytes: 3316
n,k = map(int,input().split())
x = list(map(int,input().split()))
flag = True
for i in range(n+1):
    if i == n or x[i] > 0:
        x.insert(i,0)
        zahyou = i
        break
ans = 10**18
for i in range(k+1):
    flag = True
    if zahyou + i < n+1 and zahyou -k+i >= 0:
        mainasu = x[zahyou]-x[zahyou-k+i]
        purasu = x[zahyou+i]-x[zahyou]
        if mainasu != 0 and purasu != 0:
            purasu += min(mainasu,purasu)
        ans = min(ans,mainasu+purasu)
print(ans)


Measured memory_bytes: 14252
n=int(input())

#n+1つの街にそれぞれいるモンスターの数のリスト
mnsnum=[int(i) for i in input().split()]

#n人の勇者
brave=[int(i) for i in input().split()]

sumnum=0
for i in range(n):
    bravepower=brave[i]
    if bravepower<=mnsnum[i]:
        mnsnum[i]=mnsnum[i]-bravepower
        sumnum+=bravepower
    else:
        sumnum+=mnsnum[i]
        bravepower-=mnsnum[i]
        mnsnum[i]=0
        if mnsnum[i+1]<=bravepower:
            sumnum+=mnsnum[i+1]
            mnsnum[i+1]=0
        else:
            mnsnum[i+1]=mnsnum[i+1]-bravepower
            sumnum+=bravepower
        
        



print(sumnum)


Measured memory_bytes: 18436
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();

        if(a==b+c){
            System.out.println("Yes");
        }
        else if (b==a+c){
            System.out.println("Yes");
        }
        else if(c==a+b){
            System.out.println("Yes");
        }
        else{
            System.out.println("No");
        }

        sc.close();

    }

}


Measured memory_bytes: 10192
N = int(input())
s = []
for i in range(N):
    s.append(input())
inc = []
dec = []
total = 0
for i in s:
    cn = 0
    mn = 0
    for j in i:
        if j=="(":
            cn+=1
        else:
            cn-=1
        mn = min(cn,mn)
    total += cn
    if cn>=0:
        inc.append([mn,cn])
    else:
        dec.append([mn-cn,-cn])

inc.sort(reverse=True,key=lambda x:x[0])
dec.sort(reverse=True,key=lambda x:x[0])

def check(lis):
    hi = 0
    for i in lis:
        if hi+i[0]<0:
            return False
        else:
            hi+=i[1]
    return True

if check(inc) and check(dec) and total==0:
    print("Yes")
else:
    print("No")


Measured memory_bytes: 257940
n = int(input())
a = list(map(int,input().split()))
b = list(map(int,input().split()))
c = list(map(int,input().split()))
ans = 0
for i in range(n):
  ans += b[a[i]-1]
  if(i > 0) and  (a[i-1]+1 == a[i]):
    ans += c[a[i-1]-1]
print(ans)
  

Measured memory_bytes: 3316
package main

import (
	"bufio"
	"fmt"
	"io"
	"math"
	"os"
	"strconv"
	"strings"

)


func main() {
	solve(os.Stdin, os.Stdout)
}

type ReaderEx struct {
	baseScanner *bufio.Scanner
	words       []string
	nextWordIdx func() int
	initWordIdx func(int)
}

func NewScannerEx(stdin io.Reader) *ReaderEx {
	var this ReaderEx
	var idx int
	var wordsCnt int
	this.baseScanner = bufio.NewScanner(stdin)
	this.baseScanner.Buffer(make([]byte, 0), 1E+11)
	this.nextWordIdx = func() int {
		cur := idx
		idx = (idx + 1) % wordsCnt
		return cur
	}
	this.initWordIdx = func(wc int) {
		idx = 0
		wordsCnt = wc
	}
	return &this
}

func (me *ReaderEx) Scan(doSplit bool) (isScanned bool) {
	isScanned = me.baseScanner.Scan()
	if doSplit {
		me.words = strings.Fields(me.baseScanner.Text())
	} else {
		me.words = []string{me.baseScanner.Text()}
	}
	me.initWordIdx(len(me.words))
	return
}

func (me *ReaderEx) nextBytes() []byte {
	return []byte(me.words[me.nextWordIdx()])
}
func (me *ReaderEx) nextString() string {
	return me.words[me.nextWordIdx()]
}

type StringArray []string

func (me *ReaderEx) nextStringArray() StringArray {
	return me.words[me.nextWordIdx():]
}

func (me StringArray) toStrings() []string {
	return me
}

func (me StringArray) toInts() []int {
	strValues := me.toStrings()
	values := make([]int, len(strValues))
	for i, v := range strValues {
		n, err := strconv.Atoi(v)
		if err != nil {
			panic(err)
		}
		values[i] = n
	}
	return values
}
func (me *ReaderEx) nextInt() int {
	n, err := strconv.Atoi(me.words[me.nextWordIdx()])

	defer func() {
		if err != nil {
			panic(fmt.Sprintf("getInt(%d)", n))
		}
	}()
	return n
}

func pow(x, y, mod int) (ans int) {

	ans = 1
	for bit := 1 << uint(math.Floor(math.Log2(float64(y)))); ; bit >>= 1 {
		if y&bit != 0 {
			ans *= x
			if mod > 0 {
				ans %= mod
			}
		}
		if bit <= 1 {
			return
		}
		ans *= ans
		if mod > 0 {
			ans %= mod
		}
	}
}

type factType struct {
	prime int
	count int
}

func fact(n int) (facts []*factType) {

	for i := 2; i*i <= n; i++ {
		if n%i == 0 {
			fa := factType{prime: i}
			for n%fa.prime == 0 {
				n /= fa.prime
				fa.count++
			}
			facts = append(facts, &fa)
		}
	}
	if n > 1 {
		facts = append(facts, &factType{prime: n, count: 1})
	}
	return facts
}
func dec2bin(n int) (ret []bool) {
	for bit := 1 << uint(math.Floor(math.Log2(float64(n)))); ; bit >>= 1 {
		ret = append(ret, n&bit != 0)

		if bit <= 1 {
			return
		}
	}

}

func abs(v int) int {
	if v < 0 {
		v = -v
	}
	return v
}

func b2i(b bool) (i int) {
	if b {
		i = 1
	} else {
		i = 0
	}
	return
}

func solve(stdin io.Reader, stdout io.Writer) {

	r := NewScannerEx(stdin)
	r.Scan(true)
	n := r.nextInt()
	r.Scan(true)
	a:=r.nextStringArray().toInts()

	MOD:=uint(pow(10,9,0)+7)

	cnt := make([]uint, 61)
	for _,ai:=range a{
		for i:=uint(0);i<=60;i++{
			cnt[i] +=(uint(ai) >> i)&1
		}
	}

	ans :=uint(0)
	for i, v:=range cnt{
		w:= (v * uint(n-1)) %MOD
		w = (w + (MOD- (v * uint(v-1)%MOD)%MOD) %MOD) % MOD
		ans = (ans + (w * (uint(pow(2, i,0))%MOD)) %MOD)%MOD
	}
	
	fmt.Fprintln(stdout, ans)
}


Measured memory_bytes: 26112
N = int(input())
s = input()
dic = ['SS','SW','WS','WW']
for i in range(4):
  ans = dic[i]
  state = ans[-1]
  for j in range(1,N):
    if state=='S':
      if s[j]=='o':
        ans += ans[j-1]
      else:
        if ans[j-1]=='S':
          ans += 'W'
        else:
          ans += 'S'
    else:
      if s[j]=='o':
        if ans[j-1]=='S':
          ans += 'W'
        else:
          ans += 'S'
      else:
        ans += ans[j-1]
    state = ans[-1]
  if ans[0]==ans[-1]:
    ans = ans[:-1]
    if state=='S':
      if s[0]=='o':
        if ans[1]==ans[-1]:
          print(ans)
          break
      else:
        if ans[1]!=ans[-1]:
          print(ans)
          break
    else:
      if s[0]=='o':
        if ans[1]!=ans[-1]:
          print(ans)
          break
      else:
        if ans[1]==ans[-1]:
          print(ans)
          break
else:
  print(-1)

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

int main()
{
   int N ;
   cin >> N;
   bool is_ok = 0;
   for (int i = 1 ; i <= 9 ; ++i){
      if ((N%i==0) && (N/i <= 9)){
         is_ok = 1;
         break ;
      }
   }
   if (is_ok){
      cout << "Yes" << endl;
   }
   else
   {
      cout << "No" << endl;
   }
}

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


int main() {
  ll q,h,s,d;cin >> q >> h >> s >> d;
  q *= 4;
  h *= 2;
  s = min(s,min(q,h));
  ll n;cin >> n;
  ll ans = 0;
  if( 2*s > d ){
    ans += n/2*d;
    if( n%2 != 0 ) ans += s;
  }else{
    ans = n*s;
  }
  cout << ans << endl;


  return 0;
}

Measured memory_bytes: 3648
#include <bits/stdc++.h>
#define INF 2000000000
using namespace std;
typedef long long ll;
int read(){
    int f = 1, x = 0;
    char c = getchar();
    while(c < '0' || c > '9'){if(c == '-') f = -f; c = getchar();}
    while(c >= '0' && c <= '9')x = x * 10 + c - '0', c = getchar();
    return f * x; 
}
void init(){
}
void solve(){
    int a, b, c;
    cin >> a >> b >> c;
    for (int i = b; i <= c; ++i)    
        if (i % a == 0){
            printf("OK\n");
            return ;
        }
    printf("NG\n");
}
int main(){
    init();
    solve();
    return 0;
}

Measured memory_bytes: 3624
#include<iostream>
#include<string>
using namespace std;
#define rep(i,n) for(int i = 0;i < n;i++)
typedef long long ll;
ll sum= 0, ans = 0;
int main() {
    string s; cin >> s;
    rep(i, s.size()) {
        if (s[i] == 'A') sum++;
        else if (s.substr(i, 2) == "BC") {
            i++; ans += sum;
        }
        else sum = 0;
    }cout << ans << endl;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
//登録しよう！→ https://www.youtube.com/channel/UCRXsI3FL_kvaVL9zoolBfbQ
using namespace std;
using ll = long long;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}//a,bの最大公約数(gcd)を求める
ll lcm(ll a,ll b){return abs(a*b)/gcd(a,b);}//a,bの最小公倍数(lcm)を求める
vector<ll> enum_div(ll n){vector<ll> ret;for(int i=1 ; i*i<=n ; i++){if(n%i == 0){ret.push_back(i);if(i!=1 && i*i!=n)ret.push_back(n/i);}}ret.push_back(n);return ret;}
//↑nの約数を求める
vector<bool> IsPrime; void sieve(size_t max){if(max+1 > IsPrime.size())IsPrime.resize(max+1,true);IsPrime[0] = false;IsPrime[1] = false;for(size_t i=2; i*i<=max; ++i)if(IsPrime[i])for(size_t j=2; i*j<=max; ++j)IsPrime[i*j] = false;}
//↑エラトステネスの篩で素数を求める
#define roundup(divisor,dividend) (divisor + (dividend - 1)) / dividend //切り上げ割り算
#define all(x) (x).begin(),(x).end() //xの初めから終わりまでのポインタ
#define size_t ll //size_tは自動でllに変換される
#define pb(x) push_back(x)
#define gre greater //sortを降順にする
#define pri_queue priority_queue //優先度付きキュー
#define syo(x) fixed << setprecision(x) //iostreamで小数をx桁表示

void solve(std::string S){
  int ans = 700;
  for (int i = 0; i < 3; i++) {
    if(S[i] == 'o'){
      ans += 100;
    }
  }
  cout << ans << endl;
}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    std::string S;
    std::cin >> S;
    solve(S);
}


Measured memory_bytes: 256
#include <stdio.h>
#include <string>
#include <vector>
#include <iostream>
#include <map>
#include <algorithm>
#include <queue>

using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define MOD 1000000007
#define N_MAX 100005
#define INF 1001001001
int main()
{
	int N, M;
  	cin >> N >> M;
  	vector<int> G[N];
  	int dist[N_MAX][3];
  	for(int i = 0; i < N; i++){
    	for(int j = 0; j < 3; j++){
        	dist[i][j] = INF;
        }
    }
  
  	for(int i = 0; i < M; i++){
    	int u,v;
      	cin >> u >> v;
      	u--;
      	v--;
      	G[u].push_back(v);
    }
  	int S, T;
  	cin >> S >> T;
  	S--;
  	T--;
  	queue<P> que;
 	dist[S][0] = 0;
  	que.push(P(S, 0));
  	while(!que.empty()){
    	P p = que.front();
      	que.pop();
      	int v = p.first;
      	int l = p.second;
      	for(int i = 0; i < G[v].size(); i++){
    		int nl = (l+1)%3;
      		int to = G[v][i];
          	if(dist[to][nl] == INF){
          		dist[to][nl] = dist[v][l] + 1;
              	que.push(P(to, nl));
            }
        }
    }
  	int ans = dist[T][0];
  	if(ans == INF) ans = -1;
  	else ans /= 3;
  	cout << ans << endl;
}

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

int main() {
	int a, b;
	char op;

	while (1) {
		cin >> a >> op >> b;

		if (op == '+')
			cout << a + b << endl;
		
		else if (op == '-')
			cout << a - b << endl;
		
		else if (op == '*') 
			cout << a * b << endl;
		
		else if (op == '/') 
			cout << a / b << endl;
		
		else
			break;//break??????????????????
		
	}

	return 0;
}

Measured memory_bytes: 3072
#include<bits/stdc++.h>
#include<unordered_set>
#include<unordered_map>
#include <algorithm> 
#include <iostream>
#include <string>
#include <cmath>
using namespace std;
#define ll long long
#define rep(i,n) for (ll i = 0; i < (n); i++)
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define FORR(i,a,b)for(ll i=(a);i<=(b);i++)
#define repR(i,n) for(ll i=n;i>=0;i--)
#define all(v)(v).begin(),(v).end()
#define rall(v)(v).rbegin(),(v).rend()
#define F first
#define S second
#define pb push_back
#define pu push
#define COUT(x) cout<<(x)<<"\n"
#define PQ priority_queue<ll>
#define PQR priority_queue<ll,vector<ll>,greater<ll>>
#define YES(n) cout << ((n) ? "YES\n" : "NO\n"  )
#define Yes(n) cout << ((n) ? "Yes\n" : "No\n"  )
#define mp make_pair
#define sz(x) (ll)(x).size()
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const ll MOD = 1000000007LL;
const ll INF = 1LL << 60;
using vll = vector<ll>;
using vb = vector<bool>;
using vvb = vector<vb>;
using vvll = vector<vll>;
using vstr = vector<string>;
using vc = vector<char>;
using vvc = vector<vc>;
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; 
}
ll dx[4]={0,1,0,-1};
ll dy[4]={1,0,-1,0};
int main(){
  string s;
  cin>>s;
  ll ans=0;
  rep(i,sz(s)){
    if(s[i]=='R'){
      ans++;
    }
  }
  if(ans==2&&s[1]=='S') ans=1;
  COUT(ans);
}


Measured memory_bytes: 3572
import sys

def main():
    n, *p = map(int, sys.stdin.read().split())
    p = [None] + p
    cnt = 0
    i = 1
    while i <= n:
        if p[i] == i:
            cnt += 1
            if i == n:
                break
            if p[i+1] == i+1:
                i += 1
        i += 1
        
    print(cnt)

if __name__ == '__main__':
    main()


Measured memory_bytes: 14068
import sys
sys.setrecursionlimit(100000)
N,M=map(int,input().split())
AB=[list(map(int,input().split())) for _ in range(M)]
AB.reverse()
par=list(range(1,N+1))
size=[1]*N

ans=[(N-1)*N//2]*M

def spar(n):
  if par[n-1]==n:
    return n
  else:
    par[n-1]=spar(par[n-1])
    return par[n-1]

for i in range(0,M-1):
  A,B=AB[i]
  pa,pb=spar(par[A-1]),spar(par[B-1])
  if pa==pb:
    ans[i+1]=ans[i]
  else:
    ans[i+1]=ans[i]-size[pa-1]*size[pb-1]
    sa,sb=size[pa-1],size[pb-1]
    size[pa-1]+=sb
    size[pb-1]+=sa
  par[pa-1]=pa
  par[pb-1]=pa
  
for i in reversed(ans):
  print(i)

Measured memory_bytes: 47320
import math

a, b, rC = map(int, input().split())

#残り1辺
c = math.sqrt((a ** 2) + (b ** 2) - a * b * 2 * math.cos(math.radians(rC)))
#面積
S = (a * b) / 2 * math.sin(math.radians(rC))
#周
L = a + b + c
#高さ
H = b * math.sin(math.radians(rC))

print(S)
print(L)
print(H)


Measured memory_bytes: 5712
a,b,c=map(int,input().split())
l=sorted([a,b,c])
a,b,c=l[0],l[1],l[2]
if (c-a)%2==0 and (c-b)%2==0:
  print((c-a)//2+(c-b)//2)
elif (c-a)%2==1 and (c-b)%2==1:
  a+=1
  b+=1
  print((c-a)//2+(c-b)//2+1)
else:
  if (c-a)%2==1:
    c+=1
    b+=1
    print((c-a)//2+(c-b)//2+1)
  else:
    c+=1
    a+=1
    print((c-a)//2+(c-b)//2+1)


Measured memory_bytes: 3064
#include<iostream>
#include<stdio.h>
#include<string>
using namespace std;
int main()
{
    string s;
    while(getline(cin,s))
        {
        printf("%c%d%c\n",s[0],s.size()-2,s[s.size()-1]);
        s.clear();
        }
        return 0;
}


Measured memory_bytes: 256
N, x = map(int, input().split())
a=list(map(int, input().split()))

count=0
for i in range(1, N):
    if a[i]+a[i-1] > x:
        count += min(a[i] + a[i - 1] - x, a[i])
        a[i]=max(0, x-a[i-1])
if a[0]+a[1] > x:
    count+=a[0]-x
    a[0]=x
#print(a)
print(count)



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

using namespace std;

#define DUMP(x) std::cerr << (#x) << " = " << (x) << "\n"
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define REP(i, k, n) for (int i = (k); i < (int)(n); ++i)
#define ALL(r) r.begin(), r.end()
#define YES puts("YES")
#define Yes puts("Yes")
#define NO puts("NO")
#define No puts("No")
#define IMP puts("IMPOSSIBLE")
#define Imp puts("Impossible")
#define imp puts("impossible")
#define M1 puts("-1")
#define pb push_back

template <typename T>
T dup(T x, T y)
{
    return (x + y - 1) / y;
};
template <typename A, size_t N, typename T>
inline void arrayFill(A (&array)[N], const T &val) { std::fill((T *)array, (T *)(array + N), val); }

using ll = int64_t;
using vint = vector<int32_t>;
using vvint = vector<vint>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vstr = vector<string>;
using pint = pair<int32_t, int32_t>;
using pll = pair<ll, ll>;
using setint = set<int32_t>;
using setstr = set<string>;
using qint = queue<int32_t>;
using qpint = queue<pint>;

constexpr std::int32_t INF = 1001001001;
constexpr std::int64_t LINF = 1001001001001001001;

void Main()
{
    int a, b, c;
    cin >> a >> b >> c;
    int m = max({a, b, c});
    int s = a + b + c;
    if (m * 3 % 2 != s % 2)
    {
        ++m;
    }
    cout << (m * 3 - s) / 2 << endl;
}

int main()
{
    std::cin.tie(nullptr);
    std::ios_base::sync_with_stdio(false);
    std::cout << std::fixed << std::setprecision(15);
    Main();
    return 0;
}


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 n;
    cin >> n;
    ll i = 1;
    ll ans = 0;
    while(i*i <= n){
        ans = i*i;
        i++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(void)
{
    int N,play,target[101],member[101][101],toku[101],a;
    cin>>N>>play;
    for(int i=0;i<N;i++){
        toku[i]=0;
    }
    for(int i=0;i<play;i++){
        cin>>target[i];
    }
    for(int i=0;i<play;i++){
    a=target[i]-1;
    //cout<<a<<endl;
        for(int j=0;j<N;j++){
            cin>>member[i][j];
            if(target[i]==member[i][j]){toku[j]+=1;}
            else toku[a]+=1;
          //  cout<<toku[j]<<endl;
        }
    }
    for(int i=0;i<N;i++){
        cout<<toku[i]<<endl;
    }
}

Measured memory_bytes: 1200
gusu,kisu=map(int,input().split())
count=0
S=[]
for i in range(gusu):
    S.append(2)
for i in range(kisu):
    S.append(1)

for i in range(len(S)):
    for j in range(len(S)):
        if i!=j and i>j:
            if (S[i]+S[j])%2==0:
                count+=1

print(count)

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

public class Main {	
	private static void solve(){
		//Implement solution here.
		int H = ni();
		int N = ni();
		int[] A = new int[N];
		int[] B = new int[N];
		double maxe = 0;
		int maxidx = -1;
		
		for(int i = 0; i < N; i++) {
			A[i] = ni();
			B[i] = ni();
		}
		
		int[] dp = new int[H + 1];
		dp[0] = 0;
		
		for(int i = 0; i <= H; i ++) {
			if(i > 0 && dp[i] == 0)continue;
			for(int j = 0; j < N; j++) {
				int next = i + A[j];
				if(next > H) next = H;
				dp[next] = dp[next] == 0 ? dp[i] + B[j] : Math.min(dp[next], dp[i] + B[j]);
			}
		}
		System.out.println(dp[H]);
	}
	
	//Switch input source (stdin/file)
	private static BufferedReader br;
	public static void main(String[] args){
		br = new BufferedReader(new InputStreamReader(System.in));
		String debugDataPath = System.getenv("DD_PATH");        
		if(debugDataPath != null){
			try{
				br = new BufferedReader(new InputStreamReader(new FileInputStream(new File(debugDataPath))));
			}catch(Exception e){
				throw new RuntimeException(e);
			}
		}
		solve();
	}

	//Input read utility
	private static StringTokenizer tokenizer = null;
	public static String next() {
		while (tokenizer == null || !tokenizer.hasMoreTokens()) {
			try {
				tokenizer = new StringTokenizer(br.readLine());
			} catch (Exception e) {
				throw new RuntimeException(e);
			}
		}
		return tokenizer.nextToken();
	}
	//Get next single int
	private static int ni() {
		return Integer.parseInt(next());
	}
	//Get next single long
	private static long nl() {
		return Long.parseLong(next());
	}
	//Get next single double
	private static double nd() {
		return Double.parseDouble(next());
	}
	//Get next int array from one line
	private static int[] na(int n) {
		int[] a = new int[n];
		for (int i = 0; i < n; i++)
			a[i] = ni();
		return a;
	}
	//Get next char array from one line
	private static char[] ns() {
		return next().toCharArray();
	}
	//Get next long array from one line
	private static long[] nal(int n) {
		long[] a = new long[n];
		for (int i = 0; i < n; i++)
			a[i] = nl();
		return a;
	}
}


Measured memory_bytes: 21844
<?php
  $n = trim(fgets(STDIN));
  $a1 = explode(" ",trim(fgets(STDIN)));
  $a2 = explode(" ",trim(fgets(STDIN)));
  $max = 0;
  for($i=0; $i<$n; $i++){
      $ame = 0;
      for($k=0; $k<=$i; $k++){
          $ame += $a1[$k];
      }
      for($j=$i; $j<$n; $j++){
          $ame += $a2[$j];
      }
      $max = max($max, $ame);
  }
  echo $max;

Measured memory_bytes: 4604
#include <stdio.h>
#include <stdlib.h>
#include <iostream>
#include <string>

int main() {
  int N, K, Q;
  scanf("%d %d %d", &N, &K, &Q);
  int A[N+1] = {};
  for (int i = 0; i < Q; ++i) {
    int a;
    scanf("%d", &a);
    ++A[a];
  }
  for (int i = 1; i <= N; ++i)
    printf("%s\n", (K - (Q - A[i]) <= 0) ? "No" : "Yes");
  return 0;
}


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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

#define INF 1<<30
#define LINF 1ll<<60ll
#define MOD 1000000007
#define pb(a) push_back(a)

#define _overload3(_1,_2,_3,_4,name,...) name
#define _rep(i,n) _repi(i,0,n)
#define _repi(i,a,b) for(int i=a, i##_len=(b); i<i##_len; ++i)
#define _repis(i,a,b,s) for(int i=a, i##_len(b); i<i##_len; i+=s)
#define REP(...) _overload3(__VA_ARGS__,_repis,_repi,_rep,)(__VA_ARGS__)

#define REPR(i, n) for(int i = n;i >= 0;--i)
#define REPARR(i, v) for(int i = 0;i < sz(v);++i)

#define all(vec) (vec.begin()),(vec.end())
#define sz(x) ((int)(x).size())
#define bit(n) (1ll<<(n))

template<class T>bool chmax(T &a,const T &b){if(a<b){a=b;return true;}return false;}
template<class T>bool chmin(T &a,const T &b){if(a>b){a=b;return true;}return false;}

#define YES(n) cout<<((n)?"YES":"NO")<<endl
#define Yes(n) cout<<((n)?"Yes":"No")<<endl
#define yes(n) cout<<((n)?"yes":"no")<<endl
#define poss(n) cout<<((n)?"possible":"impossible")<<endl
#define Poss(n) cout<<((n)?"Possible":"Impossible")<<endl
#define POSS(n) cout<<((n)?"POSSIBLE":"IMPOSSIBLE")<<endl



int main(){
    string s;
    int w;
    cin>>s>>w;
    REPARR(i,s){
        if(i%w==0){
            cout<<s[i];
        }
    }cout<<endl;
    return 0;
}

Measured memory_bytes: 256