akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define FOR(i, begin, end) for(int i=(begin);i<(end);i++)
#define REP(i, n) FOR(i,0,n)
#define IFOR(i, begin, end) for(int i=(end)-1;i>=(begin);i--)
#define IREP(i, n) IFOR(i,0,n)
#define SORT(a) sort(a.begin(), a.end())
#define REVERSE(a) reverse(a.begin(), a.end())
#define Lower_bound(v, x) distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) distance(v.begin(), upper_bound(v.begin(), v.end(), x))
#define int long long
#define INF 1000000000000000000
using namespace std;

typedef vector<int> vec;
typedef vector<vec> mat;
typedef pair<int, int> Pii;

template<typename T>
void readv(vector<T> &a){ REP(i, a.size()) cin >> a[i]; }
void readi(vector<int> &a){ REP(i, a.size()){cin >> a[i]; a[i]--;} }

int mod = 1000000007;
int pow2[64];
int pow3[64];
map<Pii, bool> calced;
map<Pii, int> res;

int count_uv(int N, int d){
    if(calced[Pii(N, d)]) return res[Pii(N, d)];
    int ans = 0;
    if(d == -1){
        return 1;
    }
    REP(a, 3){
        int N0 = N - pow2[d] * a;
        if(N0 < 0) break;
        if(N0 >= 2 * (pow2[d] - 1)){
            ans += pow3[d];
            ans %= mod;
        }else{
            ans += count_uv(N0, d - 1);
            ans %= mod;
        }
    }
    calced[Pii(N, d)] = true;
    res[Pii(N, d)] = ans;
    return ans;
}

signed main(){

    int N; cin >> N;

    pow2[0] = 1;
    FOR(i, 1, 64) pow2[i] = 2 * pow2[i - 1];
    pow3[0] = 1;
    FOR(i, 1, 64) pow3[i] = (3 * pow3[i - 1]) % mod;


    int D;
    REP(i, 64) if(pow2[i] > N){
        D = i - 1;
        break;
    }
    //2^D<=N,2^(D+1)>N

    cout << count_uv(N, D);;
    
    return 0;
}

Measured memory_bytes: 384
#define _CRT_SECURE_NO_WARNINGS

#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <set>
#include <map>
#include <vector>
#include <math.h>
#include <cmath>
#include <queue>
#include <stack>
#include <list>
#include <functional>
#include <numeric>
#include <iostream>
#include <string>
#include <time.h>

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

ll N, M, a[112345], fib[112345];

int main() {

	scanf("%lld%lld", &N, &M);
	a[0] = -1;
	rep(i, M) scanf("%lld", &a[i + 1]);

	rep(i, M) {
		if (a[i] + 1 == a[i + 1]) {
			printf("0\n");
			return 0;
		}
	}

	fib[0] = 1;
	fib[1] = 1;
	rep(i, N + 123) {
		fib[i + 2] = (fib[i] + fib[i + 1]) % 1000000007;
	}

	ll ans = 1;


	rep(i, M) {
		if (a[i + 1] != a[i]) {
			ans *= fib[a[i + 1] - a[i] - 2];
			ans %= 1000000007;
		}
	}
	ans *= fib[N + 1 - a[M] - 2];
	ans %= 1000000007;


	printf("%lld\n", ans);

	return 0;
}


Measured memory_bytes: 1408
s = input()
ans=1

for i in range(len(s)):
    s = s[0:-1]
    if len(s) % 2 != 0:
        continue
    else:
        half = len(s) // 2
        if s[0:half-1] == s[half:-1]:
            ans=len(s)
            break
print(ans)

Measured memory_bytes: 3060
#include <cstdio>
#include <iostream>
#include <string>

using namespace std;



int main(void) {

	int A, B, C;

	cin >> A;
	cin >> B;
	cin >> C;

	if ((A <= C) && (B >= C))
		cout << "Yes" << endl;
	else
		cout << "No" << endl;
	


	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define pb push_back
#define mp make_pair
#define sz(a) (ll)(a.size())
#define pll pair<ll,ll>

string f1(string x, string y)
{
	if(sz(x)==0 || sz(y)==0)
		return "";
	if(x[0]==y[0])
		return x[0]+f1(x.substr(1,sz(x)-1),y.substr(1,sz(y)-1));
	else
	{
		string tp = f1(x,y.substr(1,sz(y)-1)); 
		string tp1 = f1(x.substr(1,sz(x)-1),y);
		if(sz(tp)>sz(tp1))
			return tp;
		else 
			return tp1;
	}
}

ll dp[3005][3005];
ll done[3005];
ll done1[3005];

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	ll i,n,m,j;
	string s;
	string t;
	cin>>s;
	cin>>t;
	n = sz(s);
	m = sz(t);
	string final = "";
	for(i=0;i<n;i++)
	{
		ll flag = 0;
		for(j=0;j<m;j++)
		{
			if(s[i]==t[j])
			{
				if(i<1 || j<1)
					dp[i][j]=1;
				else	
					dp[i][j] = 1+dp[i-1][j-1];
			}
			else
			{ 
				if(i<1 && j<1)
					dp[i][j]=0;
				if(i<1 && j>=1)
					dp[i][j] = dp[i][j-1];
				if(i>=1 && j<1)
					dp[i][j] = dp[i-1][j];
				if(i>=1 && j>=1)
					dp[i][j] = max(dp[i-1][j],dp[i][j-1]);
			}
		}
	}
	i = n-1;
	j = m-1;
	while(i>=0 && j>=0)
	{
		if(s[i]==t[j])
		{
			final+=s[i];
			i--;
			j--;
		}
		else
		{
			if(i<1 && j<1)
			{
				i--;
				j--;
			}
			else if(i<1 && j>1)
				j--;
			else if(i>1 && j<1)
				i--;
			else if(dp[i-1][j] > dp[i][j-1])
				i--;
			else 
				j--;
		}
	}
	reverse(final.begin(),final.end());
	cout<<final<<endl;
	return 0;
}

Measured memory_bytes: 70784
#!/usr/bin/env python3

def II(): return int(input())
def MII(): return map(int, input().split())
def LII(): return list(map(int, input().split()))

def main():
    S = input()
    S = S[::-1]
    d = ['maerd', 'remaerd', 'esare', 'resare']

    f = False
    while True:
        for di in d:
            if S.startswith(di):
                f = False
                S = S.replace(di, '', 1)

        if f:
            break
        f = True


    if len(S) == 0:
        print('YES')
    else:
        print('NO')


if __name__ == '__main__':
    main()


Measured memory_bytes: 9184
import java.util.*;

public class Main{
  static long cal_5(long n){
    long aa =0;
    int i= 1;
    while(n/((long)Math.pow(5,i)*2)!=0){
      aa += n/((long)Math.pow(5,i)*2);
      i += 1;
    }
    return aa;
  }




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

    long n = sc.nextLong();


    if(n%2==0){
      System.out.println(cal_5(n));
    }else{
      System.out.println(0);
    }
  }
}

Measured memory_bytes: 21844
#include <iostream>
#include <deque>
using namespace std;
int main() {
    int N;
    cin >> N;
    int ans = 0, total = 0;
    deque<int> di;
    for (int i = 0, d; i < N; i++) {
        cin >> d;
        di.push_back(d);
        total += d;        
    }
    for (int i = 0; i < N - 1; i++) {
        int t = di.front();
        di.pop_front();
        total -= t;
        ans += t * total;
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <stdio.h>

int head,n,Stack[100000];
int color[100000],Graph[100000][250];

int Empty(){
  if(head==0)//empty
    return 1;
  else
    return 0;
}

int element(int id){
  //search number of empty node
  int i;
  for(i=0;i<250;i++)
    if(Graph[id][i]==-1)
      return i;
}


int pop(void){
  head--;
  return Stack[head+1];
}
void push(int id){
  head++;
  Stack[head]=id;
}

void Dfs_set(int id,int depth){
  int id_top,i;
  color[id]=depth;
  push(id);

  while(Empty()!=1){
    id_top=pop();

    for(i=0;i<element(id_top);i++){
      if(color[Graph[id_top][i]]==-1){
	color[Graph[id_top][i]]=depth;
	push(Graph[id_top][i]);
      }
    }
    
  }
}

void assignColor(){
  int i,depth;
  for(i=0;i<n;i++)
    color[i]=-1;
  for(i=0,depth=1;i<n;i++)
    if(color[i]==-1)
      Dfs_set(i,depth++);
}


void Initialization(){
  int i,j;
  head=0;
  for(i=0;i<n;i++)
    for(j=0;j<250;j++)
      Graph[i][j]=-1;
}

int main(){
  int i,m,id1,id2;
  scanf("%d%d",&n,&m);
  Initialization();

  for(i=0;i<m;i++){
    scanf("%d%d",&id1,&id2);
    Graph[id1][element(id1)]=id2;
    Graph[id2][element(id2)]=id1;
  }


  assignColor();

  scanf("%d",&m);
  for(i=0;i<m;i++){
    scanf("%d%d",&id1,&id2);
    if(color[id1]==color[id2])
      printf("yes\n");
    else
      printf("no\n");
  }
  return 0;
}


Measured memory_bytes: 99748
import math
import random
from operator import itemgetter
import re
import sys
from itertools import accumulate
from collections import defaultdict
from collections import deque
from bisect import bisect_left,bisect
from heapq import heappop,heappush
from fractions import gcd
from copy import deepcopy
input = sys.stdin.readline
N = float(input())
M = (100*N/108)//1
if M*1.08//1 == N:
    print(int(M))
elif (M+1)*1.08//1 ==N:
    print(int(M+1))
else:
    print(":(")

Measured memory_bytes: 66540
#include <bits/stdc++.h>
using namespace std;
#define mod 1000000007
#define pi 3.14159265358979323846264
#define pii pair <int, int>
#define pb push_back
#define mp make_pair
#define vi vector <int>
#define vl vector <long long>
#define vpii vector <pair <int, int> >
#define ll long long
#define fi first
#define se second
int n, k, cnt, a[10], sum;
int main() {
    scanf("%d", &n);
    for (int i=0;i<n;i++) {
        scanf("%d", &k);
        if (k<=399) a[0]++;
        else if (k<=799) a[1]++;
        else if (k<=1199) a[2]++;
        else if (k<=1599) a[3]++;
        else if (k<=1999) a[4]++;
        else if (k<=2399) a[5]++;
        else if (k<=2799) a[6]++;
        else if (k<=3199) a[7]++;
        else cnt++;
    }
    for (int i=0;i<=7;i++) if (a[i]) sum++;
    printf("%d %d\n", max(1, sum), sum+cnt);
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <string>
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <bitset>
typedef long long ll;
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
 
const int mod = 1000000007;
//const int mod = 998244353;
 
 
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
  mint operator+(const mint a) const { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= a;}
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }
 
  // for prime mod
  mint inv() const { return pow(mod-2);}
  mint& operator/=(const mint a) { return *this *= a.inv();}
  mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}
 
 
struct combination {
  vector<mint> fact, ifact;
  combination(int n):fact(n+1),ifact(n+1) {
    assert(n < mod);
    fact[0] = 1;
    for (int i = 1; i <= n; ++i) fact[i] = fact[i-1]*i;
    ifact[n] = fact[n].inv();
    for (int i = n; i >= 1; --i) ifact[i-1] = ifact[i]*i;
  }
  mint operator()(int n, int k) {
    if (k < 0 || k > n) return 0;
    return fact[n]*ifact[k]*ifact[n-k];
  }
} c(200005);
 
vector<pair<long long, long long> > prime_factorize(long long N) {
    vector<pair<long long, long long> > res;
    for (long long a = 2; a * a <= N; ++a) {
        if (N % a != 0) continue;
        long long ex = 0; // 指数
 
        // 割れる限り割り続ける
        while (N % a == 0) {
            ++ex;
            N /= a;
        }
 
        // その結果を push
        res.push_back({a, ex});
    }
 
    // 最後に残った数について
    if (N != 1) res.push_back({N, 1});
    return res;
}
vector<long long> enum_divisors(long long N) {
    vector<long long> res;
    for (long long i = 1; i * i <= N; ++i) {
        if (N % i == 0) {
            res.push_back(i);
            // 重複しないならば i の相方である N/i も push
            if (N/i != i) res.push_back(N/i);
        }
    }
    // 小さい順に並び替える
    sort(res.begin(), res.end());
    return res;
}
 
int main(int argc, const char * argv[]) {
    
    ll N; cin >> N;
    ll sum =0;
    map<ll,ll> MAP;
    for(ll i=0;i<N;i++){
        ll temp; cin >> temp;
        sum += temp;
        MAP[temp]+=1;
    }
    ll Q; cin >> Q;
    for(ll i=0;i<Q;i++){
        ll B,C; cin >> B >> C;
        sum += (C-B)*MAP[B];
        cout << sum << endl;
        MAP[C]+=MAP[B];
        MAP[B]=0;
    }
    
    
    return 0;
}


Measured memory_bytes: 12116
// need
#include <iostream>
#include <algorithm>
// data structure
#include <bitset>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <complex>
//#include <deque>
#include <valarray>
#include <unordered_map>
#include <array>
// stream
//#include <istream>
#include <sstream>
//#include <ostream>
#include <fstream>
// etc
#include <cassert>
#include <cmath>
#include <functional>
#include <iomanip>
//#include <chrono>
#include <random>
#include <numeric>
using namespace std;

int main()
{
  int N, H, W;
  int h, w;
  cin >> N >> H >> W;
  
  h = N - H + 1;
  w = N - W + 1;
  if(h < 0 || w < 0){
    h = 0;
    w = 0;
  }
  cout << h*w << endl;
  
  return 0;
}

Measured memory_bytes: 256
a,b,c,d=input()
if a=='0'and b!='0'or a=='1'and b in['0','1','2']:
    if c=='0'and d!='0'or c=='1'and d in['0','1','2']:
        print('AMBIGUOUS')
    else:
        print('MMYY')
elif c=='0'and d!='0'or c=='1'and d in['0','1','2']:
    print('YYMM')
else:
    print('NA')

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

#define rep(i, b) for( int i = 0; i < b; i++ )
#define repi(i, a, b) for( int i = a; i < b; i++ )
#define MAX 100000
typedef vector<int> vec;

int prime[MAX];
vec v;

void pcalc(){
    rep(i, MAX){
        prime[i] = true;
    }
    prime[0] = false;
    prime[1] = false;
    repi(i, 2, MAX/2){
        if( prime[i] ){
            v.push_back(i);
            for( int j = i*2; j < MAX/2; j += i ){
                prime[j] = false;
            }
        }
    }
}

int main(){
    pcalc();
    int m, a, b;
    while( cin >> m >> a >> b, m ){
        int w, h, max = 0;
        for( int i = 0; v.size() && v[i] * v[i] <= m; i++ ){
            for( int j = i; v.size() && v[i] * v[j] <= m; j++ ){
                int p = v[i], q = v[j];
                if( p*b >= a*q && p*q > max ){
                    max = p*q;
                    w = p;
                    h = q;
                }
            }
        }
        /*
        rep(i, v.size()){
            if( v[i].first * v[i].second > ans.first * ans.second ){
                ans = make_pair(v[i].first, v[i].second);
            }
        }
        */
        cout << w << ' ' << h << endl;
    }
}

Measured memory_bytes: 1660
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
using namespace std;
int main() {
	int n; cin >> n;
	vector<int> b(n-1);
	for (auto& e : b)cin >> e;

	int ans = 0;
	for (int i = 0; i < n; ++i) {
		if (i == 0)ans += b[i];
		if (i == n-2) {
			ans += b[i];
			break;
		}
		ans += min(b[i], b[i+1]);
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

char s[120];
int k;

int main()
{
    scanf("%d",&k);
    scanf("%s",s);
    for(int i=0;i<k;i++)
    {
        if(s[i]=='\0')
        {
            printf("\n");
            return 0;
        }
        printf("%c",s[i]);
    }
    if(s[k]=='\0')printf("\n");
    else printf("...\n");
}

Measured memory_bytes: 1660
//

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
// const int INF = 2147483647;
// const ll INF = 9223372036854775807;
// const int MOD = 1e9 + 7;

int A[200000];

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

	for (int i=0; i<N; i++) {
		cin >> A[i];
	}

	sort(A, A+N);

	string ans = "YES";
	for (int i=1; i<N; i++) {
		if (A[i-1] == A[i]) ans = "NO";
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
int main() {
  int N, X;
  cin >> N >> X;
  int Y = 0;
  int ans = 0;
  for (int i = 0; i <= N; i++) {
    if (Y > X) {
      break;
    }
    int L;
    cin >> L;
    ans++;
    Y += L;
  }
  cout << ans << endl;
}

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


namespace StartFinish
{
 
    class Program
    {
        static void Main(string[] args)
        {
            while (true)
            {
                string[] aopb = Console.ReadLine().Split(' ').ToArray();

                if (aopb[1] == "?")
                {
                    break;
                }
                if (aopb[1] == "+")
                {
                    Console.WriteLine("{0}", int.Parse(aopb[0]) + int.Parse(aopb[2]));
                }
                if (aopb[1] == "-")
                {
                    Console.WriteLine("{0}", int.Parse(aopb[0]) - int.Parse(aopb[2]));
                }
                if (aopb[1] == "*")
                {
                    Console.WriteLine("{0}", int.Parse(aopb[0]) * int.Parse(aopb[2]));
                }
                if (aopb[1] == "/")
                {
                    Console.WriteLine("{0}", int.Parse(aopb[0]) / int.Parse(aopb[2]));
                }

            }
        }
    }
}

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

const int INF = 1 << 25;
pair<string, string> cross[1000];
int dist[200][200];
int wf[200][200];
int same[200][200];

int main() {
	int n, m;
	while(cin >> n, n) {
		int sn = 0;
		map<string, int> indexer;
		for(int i = 0; i < n; i++) {
			string s, s1, s2;
			cin >> s;
			int pos = s.find('-');
			s1 = s.substr(0, pos);
			s2 = s.substr(pos + 1, s.size() - (pos + 1));
			cross[i].first = s1;
			cross[i].second = s2;
			if(indexer.count(s1) == 0) {
				indexer[s1] = sn++;
			}
			if(indexer.count(s2) == 0) {
				indexer[s2] = sn++;
			}
		}

		cout << sn << endl;

		for(int i = 0; i < sn; i++) {
			for(int j = 0; j < sn; j++) {
				dist[i][j] = (i == j) ? 0 : INF;
				wf[i][j] = (i == j) ? 0 : INF;
				same[i][j] = i == j;
			}
		}
		for(int i = 0; i < n; i++) {
			int v1 = indexer[cross[i].first], v2 = indexer[cross[i].second];
			dist[v1][v2] = dist[v2][v1] = 1;
			wf[v1][v2] = 1;
		}

		for(int i = 0; i < sn; i++) {
			for(int j = i + 1; j < sn; j++) {
				bool flag1 = false, flag2 = true;
				for(int k = 0; k < sn; k++) {
					if(wf[i][k] != INF && wf[j][k] != INF) flag1 = true;
					if(wf[k][i] != INF && wf[k][j] != INF) flag1 = true;
					if(wf[i][k] != INF && wf[k][j] != INF) flag2 = false;
					if(wf[j][k] != INF && wf[k][i] != INF) flag2 = false;
				}
				same[i][j] = same[j][i] = flag1 && flag2;
			}
		}

		for(int i = 0; i < sn; i++) {
			for(int j = 0; j < sn; j++) {
				if(same[i][j]) wf[i][j] = 1;
			}
		}
		for(int k = 0; k < sn; k++) {
			for(int i = 0; i < sn; i++) {
				for(int j = 0; j < sn; j++) {
					dist[i][j] = min(dist[i][j], dist[i][k] + dist[k][j]);
					wf[i][j] = min(wf[i][j], wf[i][k] + wf[k][j]);
				}
			}
		}

		cin >> m;
		for(int i = 0; i < m; i++) {
			string s, s1, s2;
			cin >> s;
			int pos = s.find('-');
			s1 = s.substr(0, pos);
			s2 = s.substr(pos + 1, s.size() - (pos + 1));
			if(indexer.count(s1) == 0 || indexer.count(s2) == 0) {
				cout << "NO" << endl;
				continue;
			}
			int v1 = indexer[s1], v2 = indexer[s2];
			int d = dist[v1][v2];
			if(d != INF && d % 2 && wf[v1][v2] != INF) {
				cout << "YES" << endl;
			}
			else {
				cout << "NO" << endl;
			}
		}
	}

}

Measured memory_bytes: 3596
while true do
    n, r = gets.split(" ").map(&:to_i)
    if n == 0 && r == 0
        break
    end
    arr = (1..n).to_a.reverse
    r.times do
        p, c = gets.split(" ").map(&:to_i)
        p -= 1
        ta = arr[p...p+c] + arr[0...p] + arr[p+c..n]
        arr = ta
    end
    puts arr[0]
end

Measured memory_bytes: 9148
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)

h, w = map(int, input().split())
ch, cw = map(int, input().split())
dh, dw = map(int, input().split())
graph = [0] + [0] * h
dist = [0] + [0] * h
for i in range(h):
    graph[i + 1] = [0] + list(input().strip())
    dist[i + 1] = [0] + [-1] * w

from collections import deque

def can_move(graph, dist, next_h, next_w):
    if not ((1 <= next_h <= h) and (1 <= next_w <= w)):
        return False
    if graph[next_h][next_w] == '#':
        return False
    return True

# FYI: https://betrue12.hateblo.jp/entry/2018/12/08/000020
def bfs(graph, queue, dist):
    part = set()
    while queue:
        current_h, current_w = queue.popleft()

        # cost 0
        for dh, dw in ((-1, 0), (1, 0), (0, -1), (0, 1)):
            next_h, next_w = current_h + dh, current_w + dw
            if not can_move(graph, dist, next_h, next_w):
                continue
            # https://atcoder.jp/contests/abc176/editorial/65
            # 解説のとおり、先にワープして到達している場合でも短くなるのであれば上書きする
            # Dijkstraみたいに考える
            if dist[next_h][next_w] == -1 or dist[next_h][next_w] > dist[current_h][current_w]:
                dist[next_h][next_w] = dist[current_h][current_w]
                queue.appendleft((next_h, next_w))

        # cost 1
        for dh in range(-2, 3):
            for dw in range(-2, 3):
                next_h, next_w = current_h + dh, current_w + dw
                if not can_move(graph, dist, next_h, next_w):
                    continue
                if dist[next_h][next_w] != -1:
                    continue
                dist[next_h][next_w] = dist[current_h][current_w] + 1
                queue.append((next_h, next_w))

queue = deque([(ch, cw)])
dist[ch][cw] = 0
bfs(graph, queue, dist)
print(dist[dh][dw])

Measured memory_bytes: 170124
object Main extends App{
  import scala.io.StdIn._
  val s=readLine().toString
  var flag:Boolean=true
  val leng=s.length
  val a=s.take((leng-1)/2)
  val b=s.takeRight((leng-1)/2)
  if(s==s.reverse&&a==a.reverse&&b==b.reverse){
    println("Yes")
  }else{
    println("No")
  }
}

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

int main() {
    ll N, K; cin >> N >> K;
    if (N == K) cout << 0 << endl;
    else if (N < K) {
        cout << min(N, K-N) << endl;
    }
    else {
        long double x = N/K;
        long double y = floor(x-1);
        N = N-(K*y);
        if (N == K) {
            cout << 0 << endl;
            return 0;
        }
        if (N < K) {
            cout << min(N, K-N) << endl;
            return 0;
        }
        while(N > K) {
            N = N-K;
            if (N < K) {
                cout << min(N, K-N) << endl;
                return 0;
            }
        }
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <complex>
#include <queue>
#include <map>
#include <set>
#include <cstring>
#include <cstdlib>
#include <string>
#include <cmath>
using namespace std;

#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
const int INF = 1<<29;

int main() {
  int n;
  while(cin >> n, n>=0) {
    bool mirror[8][8][4];            // mirror[x][y][d] d:@0 ã, 1 E, 2 º, 3 ¶
    memset(mirror,0,sizeof(mirror));
    REP(i,n) {
      char d;
      int x,y;
      cin>>d>>x>>y;
      if (d=='x'){
        if (y>0) mirror[x][y-1][0] = 1;
        mirror[x][y][2] = 1;
      } else {
        if (x>0) mirror[x-1][y][1] = 1;
        mirror[x][y][3] = 1;
      }
    }
    int x = 0, y = 0;           // »ÝÌê
    int pred = 2;               // ÇÌûü©çüÁÄ«½©
    int nowd = 1;               // ÇÌûüÉ²¯é©
    const int dx[] = {0,1,0,-1};
    const int dy[] = {1,0,-1,0};
    int ansx, ansy;
    while(1) {
      //cout << x << " " << y<< " " << pred << " " <<nowd << endl;
      if (mirror[x][y][nowd]) {
        int tmp = pred;
        pred = nowd;
        nowd = (tmp+2)%4;
      } else {
        x += dx[nowd];
        y += dy[nowd];

        int tmp = pred;
        pred = (nowd+2)%4;
        nowd = (tmp+2)%4;
      }
      if (x<0) {
        ansx=0;ansy=y*100+50;
        break;
      } else if (x>=8) {
        ansx=800;ansy=y*100+50;
        break;
      } else if (y<0) {
        ansy=0;ansx=x*100+50;
        break;
      } else if (y>=8) {
        ansy=800; ansx=x*100+50;
        break;
      }
      if (x==0 && y==0 && (pred==1&&nowd==2 || pred==2&&nowd==1)) {
        ansx=75;ansy=25;
        break;
      }
    }
    cout << ansx << " " << ansy << endl;
    
  }
}

Measured memory_bytes: 0
main(){
  int a,b,y,c;
  while(scanf("%d %d",&a,&b)!=-1)
    {
      c=0;
      y=a+b;
      while(y>0){
	y=y/10;
	c++;
      }
      printf("%d\n",c);
    }
  return 0;
}

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

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; }

using ll = long long;
using lb = long double;
using P = pair<ll,ll>;
using graph = vector<vector<ll>>;

const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const ll INF = 1LL<<60;
const ll mod = 1000000007LL;

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

int main() {
  ll N;
  cin>>N;
  vector<ll> v(N);
  rep(i,N) cin>>v[i];
  ll A = 0;
  rep(i,N) A ^= v[i];
  rep(i,N) cout<<(A^v[i])<<" ";
  cout<<endl;
}

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

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define FOR(i,n,m) for(int i=(int)(n); i<=(int)(m); i++)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define RITR(x,c) for(__typeof(c.rbegin()) x=c.rbegin();x!=c.rend();x++)
#define setp(n) fixed << setprecision(n)

#define ld long double
#define ll long long
#define vll vector<ll>
#define vi vector<int>
#define pll pair<ll,ll>
#define pi pair<int,int>

#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define ins insert

using namespace std;

/* Some Libraries */

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

int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int a,b; cin>>a>>b;
    if (a!=b){
        rep(i,max(a,b)) cout<<min(a,b);
        cout<<endl;
    }else{
        rep(i,a) cout<<a;
        cout<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;double wa=0;cin>>N;
  for(int i=0;i<N;i++){
    double a;cin>>a;
    wa+=1.0/a;
  }
  wa=1.0/wa;
  cout<<fixed<<setprecision(10);
  cout<< wa <<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<string> vs;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<int,P> pip;
typedef vector<pip> vip;
const int inf=1<<30;
const ll INF=1ll<<60;
const double pi=acos(-1);
const double eps=1e-9;
const ll mod=1e9+7;
const int dx[4]={0,1,0,-1},dy[4]={1,0,-1,0};

void f(int t){
	string s=to_string(t);
	while(s.size()<6){
		string t="0"+s;
		s=t;
	}
	cout<<s;
}

int n,m;
vvp a;

int main(){
	cin>>n>>m;
	a=vvp(n+1);
	for(int i=0;i<m;i++){
		int p,y;
		cin>>p>>y;
		a[p].push_back({y,i});
	}
	vi b(m),c(m);
	for(int i=0;i<=n;i++){
		sort(a[i].begin(),a[i].end());
		for(int j=0;j<a[i].size();j++){
			int I=a[i][j].second;
			b[I]=i;c[I]=j+1;
		}
	}
	for(int i=0;i<m;i++){
		f(b[i]);f(c[i]);
		cout<<endl;
	}
}

Measured memory_bytes: 7808
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
//const ll mod = 1000000007;
int sum[55];
int penalty[55][15];
int accepted[55];

int main() {
    //cout.precision(10);
    cin.tie(0);
    ios::sync_with_stdio(false);
    while(true) {
        int M, T, P, R;
        cin >> M >> T >> P >> R;
        if(M == 0) break;
        for(int i = 0; i <= T; i++) {
            sum[i] = 0;
            accepted[i] = 0;
            for(int j = 0; j <= 10; j++) penalty[i][j] = 0;
        }
        while(R--) {
            int m, t, p, j;
            cin >> m >> t >> p >> j;
            if(j != 0) {
                penalty[t][p]++;
            } else {
                accepted[t]++;
                sum[t] += m + 20 * penalty[t][p];
            }
        }
        vector<i_i> ans;
        for(int i = 1; i <= T; i++) {
            ans.push_back({accepted[i] * 1e7 - sum[i], i});
        }
        sort(ans.begin(), ans.end(), greater<i_i>());
        cout << ans[0].second;
        for(int i = 1; i < ans.size(); i++) {
            if(ans[i].first == ans[i-1].first) {
                cout << "=" << ans[i].second;
            } else cout << "," << ans[i].second;
        }
        cout << endl;
    }
    return 0;
}


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

MAX = 10000

def makeMap(H, bits):
    M = [0]*H

    m = 0
    for i in range(H):
        M[i] = m

        if bits & 1:
            m += 1

        bits >>= 1

    return M


def getCounts(H,S,M,w):
    C = [0]*(M[-1]+1)

    for h in range(H):
        if S[h][w] == '1':
            C[M[h]] += 1

    return C


def f(H,W,K,S,bits):
    M = makeMap(H, bits)
    N = M[-1] + 1
    X = [0]*N
    ans = 0
    
#    print("M", M)

    for w in range(W):
        C = getCounts(H,S,M,w)
        for i in range(N):
            if C[i] > K:
                return MAX

            X[i] += C[i]
            if X[i] > K:
                ans += 1
                X = C
                break
#        print("X", X, ans)

#    print("ans", ans, ans + N - 1)
    return ans + N - 1
            
    
H,W,K = map(int, input().split())
S = [input() for _ in range(H)]

# print(S)

ans = MAX

for bits in range(2**(H-1)):
    ans = min(ans, f(H,W,K,S,bits))

print(ans)


Measured memory_bytes: 3064
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES 
#include<iomanip> 
#include<cmath>  
#include<iostream>
#include<fstream>
#include<vector>
#include<algorithm>
#include<numeric>
#include<bitset>
#include<map>
// #include<unordered_map>
#include<set>
// #include<unordered_set>
#include<queue>
#include<deque>
#include<stack>
#include<functional>
using namespace std;
typedef long long ll;
#define repi(i,a,b) for(ll i = (ll)(a) ; i < (ll)(b) ; i++)
#define repd(i,a,b) for(ll i = (ll)(a) ; i > (ll)(b) ; i--)
#define rd(x) cin >> x
#define wr(x)  cout << x
#define wrln(x) cout << x << endl
#define wl() cout << endl
const ll MAX_10p5 = 100010;
const ll MAX_10p9 = 1000000010;
const ll MAX_10p18 = 1000000000000000010;
const ll MOD = 1000000007;
const ll m4x[4] = { 1,0,-1,0 };
const ll m4y[4] = { 0,1,0,-1 };
const ll m8x[8] = { 1,1,0,-1,-1,-1,0,1 };
const ll m8y[8] = { 0,1,1,1,0,-1,-1,-1 };
const ll m9x[9] = { 1,1,0,-1,-1,-1,0,1,0 };
const ll m9y[9] = { 0,1,1,1,0,-1,-1,-1,0 };

struct edge {
	ll from, to, cost;
	bool operator<(const edge& right) const {
		return cost < right.cost;
	}
};
struct point {
	ll x, y, idx;
	bool operator<(const point& right) const {
		return x == right.x ? y < right.y : x < right.x;
	}
};

template<typename T>
T minT(T a, T b) {
	if (a < b) return a;
	else return b;
}

template<typename T>
T maxT(T a, T b) {
	if (a > b) return a;
	else return b;
}

template<typename T>
T absT(T a) {
	if (a < 0) a *= -1;
	return a;
}

template<typename T>
T powT(T a, T x) {
	T res = 1;
	while (x > 0) {
		if (x & 1) res = res * a;
		a = a * a;
		x >>= 1;
	}
	return res;
}

ll StoLL(string str) {
	ll ret = 0, ini = 0;
	if (str[0] == '-') ini = 1;
	repi(i, ini, str.length()) {
		ret *= 10;
		ret += (ll)(str[i] - '0');
	}
	if (ini) ret *= -1;
	return ret;
}

///////////////////////////////////////////////////////////////////////////////////////



int main() {
	string s;
	cin >> s;
	if (s.substr(0, 4) == "YAKI") wrln("Yes");
	else wrln("No");
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long lint;
using namespace std;
const int MAXN = 3001;
const int INF = 1e9 + 7;
string s,t,ans;
vector<vector<int> > dp;
void solve(int l, int r) {
	if (l == 0 || r == 0) {
		if (dp[l][r]) {
			if (l == 0) ans = s[0] + ans;
			else ans = t[0] + ans;
		}
		return;
	}
	if (s[l]==t[r] && dp[l][r] == dp[l - 1][r - 1] + 1) {
		solve(l - 1, r - 1);
		ans = ans + s[l];
	}
	else if (dp[l][r] == dp[l][r - 1]) {
		solve(l, r - 1);
	}
	else solve(l - 1, r);
}
int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cin >> s >> t;
	dp.resize(s.length() + 1, vector<int>(t.length() + 1,0));
	dp[0][0] = (int)(s[0] == t[0]);
	for (int i = 1; i < s.length(); ++i) {
		dp[i][0] = max(dp[i-1][0],(int)(s[i] == t[0]));
	}
	for (int i = 1; i < t.length(); ++i) {
		dp[0][i] = max(dp[0][i - 1], (int)(s[0] == t[i]));
	}
	for (int i = 1; i < s.length(); ++i) {
		for (int j = 1; j < t.length(); ++j) {
			dp[i][j] = max(dp[i - 1][j], dp[i][j - 1]);
			if (s[i] == t[j]) dp[i][j] = max(dp[i][j], dp[i - 1][j - 1] + 1);
		}
	}
	ans = "";
	solve(s.length() - 1, t.length() - 1);
	cout << ans << '\n';
	return 0;
}

Measured memory_bytes: 39276
def main():
    input()
    array_a = list(map(int, input().split()))
    input()
    array_q = map(int, input().split())

    def can_construct_q (q, i, sum_sofar):
        if sum_sofar == q or sum_sofar + array_a[i] == q:
            return True
        elif sum_sofar > q or i >= len (array_a) - 1:
            return False
        if can_construct_q(q, i + 1, sum_sofar + array_a[i]):
            return True
        if can_construct_q(q, i + 1, sum_sofar):
            return True
    sum_array_a = sum(array_a)
    for q in array_q:
        #print(q)
        if sum_array_a < q:
            print('no')
        elif can_construct_q(q, 0, 0):
            print('yes')
        else:
            print('no')
    return


main()


Measured memory_bytes: 5624
#include<cmath>
#include<cstdio>
#include<algorithm>

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

using namespace std;

const double EPS=1e-9;
const double INF=1e77;
const double PI=acos(-1);

template<class T> struct interval{
	T a,b;
	bool operator<(const interval &I)const{ return a<I.a; }
};

int main(){
	int n,k; scanf("%d%d",&n,&k);
	interval<double> I[1500];
	rep(i,n){
		double x,y,r; scanf("%lf%lf%lf",&x,&y,&r);
		double theta=asin(r/sqrt(x*x+y*y));
		double phi=atan2(y,x);
		I[i].a=phi-theta;
		I[i].b=phi+theta;
		if(I[i].a<-PI-EPS){
			I[i].a+=2*PI;
			I[i].b+=2*PI;
		}
		I[i].a=max(I[i].a,0.);
		I[i].b=min(I[i].b,PI);
		if(I[i].a+EPS>I[i].b) i--, n--;
	}

	rep(i,n){
		bool cov=false;
		rep(j,n) if(i!=j && I[j].a<I[i].a+EPS && I[i].b<I[j].b+EPS) cov=true;
		if(cov){
			swap(I[i],I[n-1]);
			i--;
			n--;
		}
	}
	sort(I,I+n);

	int pre[1500];
	rep(i,n){
		pre[i]=-1;
		rep(j,i) if(I[i].a+EPS<I[j].b) { pre[i]=j; break; }
	}

	static double dp1[1501][1501];
	static double dp2[1501][1501];
	rep(i,n+1) rep(j,k+1) {
		dp1[i][j]=-INF;
		dp2[i][j]=-INF;
	}
	dp1[0][0]=dp2[0][0]=0;
	rep(i,n){
		rep(j,k+1){
			dp1[i+1][j]=max(dp1[i+1][j],dp1[i][j]);

			if(j>0){
				int l;
				double w;
				if(~pre[i]){
					l=pre[i];
					w=I[i].b-I[l].b;
					dp1[i+1][j]=max(dp1[i+1][j],dp2[l+1][j-1]+w);
					dp2[i+1][j]=max(dp2[i+1][j],dp2[l+1][j-1]+w);
				}

				l=(~pre[i]?pre[i]-1:i-1);
				w=I[i].b-I[i].a;
				dp1[i+1][j]=max(dp1[i+1][j],dp1[l+1][j-1]+w);
				dp2[i+1][j]=max(dp2[i+1][j],dp1[l+1][j-1]+w);
			}
		}
	}
	printf("%.15f\n",*max_element(dp1[n],dp1[n]+k+1)/PI);

	return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
#define int long long
#define ll long long 
#define rep(i,a,b) for(signed i=a;i<(b);++i)
#define erep(i,a,b) for(signed i=a;i<=(b);++i)
#define per(i,a,b) for(signed i=(a);i>(b);--i)
#define eper(i,a,b) for(signed i=(a);i>=b;--i)
#define fore(i, x, a) for(auto &&x:a) 
#define ITR(i,b,e) for(auto i=(b);i!=(e);++i)
#define endl "\n";
#define pb push_back
#define mp make_pair
#define ALL(x) begin(x),end(x)
#define F first
#define S second
#define debug(x)  cout << #x << ": " << (x) << '\n';
const long long INF=1001001001001001001;
const int MOD=(int)1e9 + 7;
const double EPS=1e-9;
using namespace std;
using Pii = pair<int,int>;
using vii = vector<int>;
template<class T>using  PS_queue = priority_queue<T, vector<T>, greater<T> >;
template<class T>using vv = vector<T>;
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 A, size_t N, typename T> void Fill(A (&array)[N], const T &val){fill( (T*)array, (T*)(array+N), val );}
template<class T> ostream& operator<<(ostream &os,const vector<T> &v) {
    ITR(i,begin(v),end(v))os<<*i<<(i==end(v)-1?"":" ");return os;}
template<class T> ostream& operator<<(ostream &os,const vector<vector<T> > &v) {
    ITR(u,begin(v),end(v))ITR(w,begin(*u),end(*u))os<<*w<<(w==end(*u)-1?"\n":" ");return os;}
template<class T> istream& operator>>(istream &is,vector<T> &v) {
    ITR(i,begin(v),end(v)) is>>*i;return is;}
template<class T,class U> istream& operator>>(istream &is, pair<T,U> &p) {
    is>>p.first>>p.second;return is;}
template<class T>T gcd(T a, T b){ return b ? gcd(b, a % b) : a; }
template<class T>T lcm(T a, T b){ return a / gcd(a, b) * b; }
struct edge { int from, to, cost; };
int dy[]={0, 1, -1, 0}; int dx[]={1, 0, 0, -1};
// cout << fixed << setprecision(10) << val;

int n;
signed main() {
 cin.tie(0);
 ios::sync_with_stdio(false);
  cin >> n;
  vii b(n-1);
  cin >> b;
  int ans = b[0] + b[n-2];
  rep(i, 0, n-2) {
    ans += min(b[i], b[i+1]);
  }
  cout << ans << endl;
  return 0;
}




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

int main() {
  int A, B;
  cin >> A >> B;
  bool flag = false;
  for(int i = min(A,B); i<= max(A,B); i++){
    if(abs(A-i) == abs(B-i)){
      flag = true;
      cout << i << endl;
      break;
    }
  }
  if(!(flag)) cout << "IMPOSSIBLE" << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<boost/algorithm/string/replace.hpp>
#include<boost/multiprecision/cpp_int.hpp>
using namespace std;
using namespace boost::algorithm;
using namespace boost::multiprecision;
 
#define rep(i,n) for(int i=0 ; i<(n) ; i++)
#define repr(i,n) for(int i=(n) ; i>=0 ; i--)
#define ALL(x) (x).begin(),(x).end()

typedef long long ll;
typedef unsigned long long ull;
 
const ll INF = 1LL<<60;
const int MOD = 1e9+7;

template<typename T> bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<typename T> bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
//C++17以上
template<typename T>
T GCD(T a,T b){ return b ? GCD(b,a%b) : a ;}
template<typename T>
T LCM(T a,T b){ return a*b / GCD(a,b) ;}

template<typename T>//文字列の置換/Boost:replace_all()
T replace_str(T str, string target, string str_to) {
    string::size_type pos = 0;
    while (pos = str.find(target, pos), pos != string::npos) {
        str.replace(pos, target.length(), str_to);
        pos += str_to.length();
    }
    return str;
}

int main() {
    int n;cin >> n;
    vector<ll> h(n);
    rep(i,n)cin >> h[i];
    int tmp = h[0];    
    for(int i=1;i<n;i++){
        if(h[i]<tmp){
            cout << "No" << endl;
            return 0;
        }
        if(h[i-1]>h[i]){
            if(h[i-1]-h[i]<=1){
                tmp = h[i];
            }else{
                cout << "No" << endl;
                return 0;
            }
        }

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

Measured memory_bytes: 1024
import math
a, b, h, m = map(int,input().split())
m_rad = m/60 * 360
h_rad = (h/12 * 360) + (m/60 * 360/12)
rad = abs(m_rad - h_rad)
ans = (a**2 + b**2) - (2 * a * b * math.cos(math.radians(rad)))
print(math.sqrt(ans))

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

bool plus_exist(ll bit, ll i) {
  if (bit & (1 << i)) {
    return true;
  }
  else {
    return false;
  }
}

ll s_to_num(string s) {
  ll n = s.size(), ans = 0;

  for (ll i = 0; i < n; i++) {
    ans *= 10;
    ans += s[i] - '0';
  }

  return ans;
}

void abc045c(string s) {
  ll n = s.size(), ans = s_to_num(s);

  for (ll bit = 1; bit < (1 << n - 1); bit++) {
    ll num = s[0] - '0';

    for (ll i = 0; i < n - 1; i++) {
      if (plus_exist(bit, i)) {
        ans += num;
        num = s[i + 1] - '0';
      }
      else {
        num = 10 * num + (s[i + 1] - '0');
      }
    }
    ans += num;
  }

  cout << ans << '\n';

  return;
}

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

  abc045c(s);

  return 0;
}

Measured memory_bytes: 256
//#include <bits/stdc++.h>
#include <iostream> // cout, endl, cin
#include <cmath> //sqrt pow
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
 
#define _GLIBCXX_DEBUG
#define rep(i,n) for(int i = 0; i < n; i++)
#define SORT(a) sort(a.begin(), a.end()) //reverse()で反転
#define lower(a, n) lower_bound(a.begin(), a.end(), n);
#define upper(a, n) upper_bount(a.begin(), a.end(), n);
#define vi vector<int>
#define vvi vector<vi>
#define pii pair<int, int>
#define mod 1000000007
using ll = long long;
using namespace std;
int sum(int a){
  if(a == 0) return 0;
  return sum(a - 1) + a;
}
int gcd(int a, int b){ //最大公約数
  if(a % b == 0) return b;
  return gcd(b, a % b);
}
int lcm(int a, int b){ //最小公倍数
  return a / gcd(a, b) * b;
}
int main(){
  int n;
  cin >> n;
  map<int, int> a;
  for(int i = 2; i <= n; i++){
    int temp = i;
    for(int x = 2; x <= i; x++){
      while(true){
        if(temp % x == 0){
          temp /= x;
          a[x]++;
        }else break;
      }
    }
  }
  ll ans = 1;
  for(pii i : a){
    ans *= i.second + 1;
    ans %= mod;
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <string>
#include <vector>
#include <utility>
#include <algorithm>
#include <queue>
#include <list>
#include <stack>
#include <math.h>
#include <map>
#include <unordered_map>
#include <set>
using namespace std;

#define ll long long
#define ull unsigned long long

#define	max	1000000007

ll gcd(ll a, ll b) {
	if (a < b)
		swap(a, b);
	while (ll r = a % b)
		a = b, b = r;
	return b;
}

class mod
{
public:
	ll val;

	mod(ll v)
	{
		val = v % max;
	}

	mod()
	{
		val = 0;
	}

	void operator -=(const mod &v)
	{
		val -= v.val;

		if (val < 0)
			val += max;
	}

	void operator +=(const mod &v)
	{
		if (val + v.val >= max)
			val -= max;
		val += v.val;
	}

	void operator +=(ll &v)
	{
		if (val + v >= max)
			val -= max;
		val += v;
	}

	void operator *=(const mod &v)
	{
		val *= v.val;
		val %= max;
	}

	void operator *=(ll &v)
	{
		val *= v;
		val %= max;
	}

	ll modinv(ll a)
	{
		ll b = max, u = 1, v = 0;
		while (b)
		{
			ll t = a / b;
			a -= t * b; swap(a, b);
			u -= t * v; swap(u, v);
		}
		u %= max;
		if (u < 0)
			u += max;
		return u;
	}

	void operator /=(const mod &v)
	{
		val *= modinv(v.val);
		val %= max;
	}

	void operator /=(ll &v)
	{
		val *= modinv(v);
		val %= max;
	}
};

struct p
{
	ll a;
	int b;
	int c;
};

int main()
{
	string s;
	cin >> s;
	int q;
	cin >> q;
	stack<char> head, tail;
	bool mode = true;	//	normal

	for (int i = 0; i < q; i++)
	{
		int k;
		cin >> k;
		if (k == 1)
		{
			mode = !mode;
			continue;
		}
		int f;
		char c;
		cin >> f >> c;
		if (mode)
		{
			if (f == 1)
				head.push(c);
			else
				tail.push(c);
		}
		else
		{
			if (f == 2)
				head.push(c);
			else
				tail.push(c);
		}
	}

	if (mode)
	{
		while (!head.empty())
		{
			printf("%c", head.top());
			head.pop();
		}
		for(int i = 0; i < s.length(); i++)
			printf("%c", s[i]);
		while (!tail.empty())
		{
			head.push(tail.top());
			tail.pop();
		}
		while (!head.empty())
		{
			printf("%c", head.top());
			head.pop();
		}
	}
	else
	{
		while (!tail.empty())
		{
			printf("%c", tail.top());
			tail.pop();
		}
		for (int i = s.length() - 1; i >= 0; i--)
			printf("%c", s[i]);
		while (!head.empty())
		{
			tail.push(head.top());
			head.pop();
		}
		while (!tail.empty())
		{
			printf("%c", tail.top());
			tail.pop();
		}
	}

	return 0;
}


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

using namespace std;

//typedef pair<int, int> P;
#define int long long
#define ll long long
#define mod 1000000007
#define INF (1LL<<60)


signed main(){

	int a[3];
	cin >> a[0] >> a[1] >> a[2];
	sort(a, a + 3);
	cout << abs(a[1] - a[0]) + abs(a[2] - a[1]) << endl;
	
	return 0;
}


Measured memory_bytes: 768
#include <bits/stdc++.h>
#define INF 2147483647
#define INF_LL 9223372036854775807
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;

int main() {
	int N, M;
	cin >> N >> M;
	vector<int> ball(N, 1);
	vector<bool> ball_f(N, false);
	ball_f[0] = 1;
	for (int i = 0; i < M; i++) {
		int x, y;
		cin >> x >> y;
		x--; y--;
		ball[x]--; ball[y]++;
		if (ball_f[x] == true)ball_f[y] = true;
		if (ball[x] == 0)ball_f[x] = false;
	}
	int ans = 0;
	for (int i = 0; i < N; i++) {
		if (ball_f[i] && ball[i] != 0) ans++;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 640
from copy import deepcopy

N, M, Q = [int(elem) for elem in input().split(' ')]
lines = [[int(elem) for elem in input().split(' ')] for _ in range(M)]
queries = [[int(elem) for elem in input().split(' ')] for _ in range(Q)]


def cuml_1d(N, lines, queries):
    coords = [[0] * N for _ in range(N)]
    for l, r in lines:
        coords[l - 1][r - 1] += 1

    cuml_coords = deepcopy(coords)
    for l in range(N):
        for r in range(1, N):
            cuml_coords[l][r] = cuml_coords[l][r - 1] + coords[l][r]

    for query in queries:
        p, q = query[0] - 1, query[1] - 1
        num_lines = 0
        for l in range(p, max(q + 1, N)):
            if p == 0:
                num_lines += cuml_coords[l][q]
            else:
                num_lines += cuml_coords[l][q] - cuml_coords[l][p - 1]
        print(num_lines)

#cuml_1d(N, lines, queries)


def cuml_2d(N, lines, queries):
    coords = [[0] * N for _ in range(N)]
    for l, r in lines:
        coords[l - 1][r - 1] += 1
    cuml_l = deepcopy(coords)
    for r in range(N):
        for l in range(1, N):
            cuml_l[l][r] = cuml_l[l - 1][r] + coords[l][r]
    cuml_2d = deepcopy(cuml_l)
    for l in range(N):
        for r in range(1, N):
            cuml_2d[l][r] = cuml_2d[l][r - 1] + cuml_l[l][r]
    
    for query in queries:
        p, q = query[0] - 1, query[1] - 1
        if p != 0:
            num_lines = cuml_2d[q][q] - cuml_2d[q][p-1] - cuml_2d[p-1][q] + cuml_2d[p-1][p-1]
        else:
            num_lines = cuml_2d[q][q]
        print(num_lines)

cuml_2d(N, lines, queries)


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

int main () {
  string s;
  cin >>s;
  for (int i=0;i<s.size();i++){
    if(i%2 ==0){
      if( s[i] =='L'){
        cout <<"No"<<endl;
        return 0;
      }
    }else {
      if( s[i]== 'R'){
        cout <<"No"<<endl;
        return 0;
      }
    }
  }
  cout <<"Yes"<<endl;
  return 0;
}




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

using namespace std;

vector<long long> fac(long long n) {
    vector<long long> lst;
    for (long long i = 2; i <= ceil(sqrt(n)); i++) {
        long long cnt = 0;
        while (n % i == 0) {
            n /= i;
            cnt++;
        }
        if (cnt == 0) continue;
        lst.push_back(cnt);
    }
    if (n > 1) lst.push_back(1);
    return lst;
}

int main() {
    long long n; scanf("%lld", &n);
    vector<long long> lst = fac(n);
    long long ans = 0;
    for (long long x : lst) {
        long long sum = 0;
        for (long long i = 1; i <= x; i++) {
            sum += i;
            if (sum > x) break;
            ans++;
        }
    }
    printf("%lld", ans);
}

Measured memory_bytes: 3852