akhauriyash/Code-Regression huggingface dataset:
import sys
from bisect import bisect_right as bsr
from collections import Counter as cnt
from collections import defaultdict as dd
from collections import deque
from fractions import gcd
from itertools import permutations as perm
from math import ceil, factorial, floor
from operator import itemgetter as ig

sys.setrecursionlimit(1000000)

# お約束
args = None
INF = float("inf")
MOD = int(1e9 + 7)


def input(*ps):
    if type(ps[0]) is list:
        return [input(*ps[0][:-1]) for _ in range(ps[0][-1])]
    elif len(ps) == 1:
        return ps[0](next(args))
    else:
        return [p(next(args)) for p in ps]


def yesno(v, yes="Yes", no="No", upper=False):
    if upper:
        print([yes.upper(), no.upper()][not v])
    else:
        print([yes, no][not v])


def main():
    """エントリーポイント"""
    N = input(int)
    S = input(str)
    a = ord("A")
    ans = ""
    for s in S:
        ans += chr((ord(s) - a + N) % 26 + a)
    print(ans)


if __name__ == '__main__':
    args = iter(sys.stdin.read().split())
    main()


Measured memory_bytes: 5424
#pragma GCC optimize(2)
#pragma GCC optimize(3)
#include <bits/stdc++.h>
using namespace std;
#define IO std::ios::sync_with_stdio(false); cin.tie(0)
#define int long long
#define ull unsigned long long
#define SZ(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define rep(i, l, r) for (int i = l; i <= r; i++)
#define per(i, l, r) for (int i = l; i >= r; i--)
#define mset(s, _) memset(s, _, sizeof(s))
#define pb push_back
#define pii pair <int, int>
#define mp(a, b) make_pair(a, b)
#define INF 0x3f3f3f3f

inline int read() {
  int x = 0, neg = 1; char op = getchar();
  while (!isdigit(op)) { if (op == '-') neg = -1; op = getchar(); }
  while (isdigit(op)) { x = 10 * x + op - '0'; op = getchar(); }
  return neg * x;
}
inline void print(int x) {
  if (x < 0) { putchar('-'); x = -x; }
  if (x >= 10) print(x / 10);
  putchar(x % 10 + '0');
}


const int mod = 1e9 + 7;
const int maxn = 2010;
int s,a[maxn],dp[100010];
signed main() {
  IO;
  cin >> s;
  int n = s - 2;
  rep(i,1,n) a[i] = i + 2;
  mset(dp, 0);
  dp[0] = 1;
  for (int i = 0; i <= s; i++) {
    rep(j, 1, n) if (i + a[j] <= s) dp[i + a[j]] = (dp[i + a[j]] + dp[i]) % mod;
  }
  cout << dp[s] % mod << '\n';
  return 0;
}

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

using namespace std;
int main()
{
	int n;
	cin>>n;
	set<string>ans;
	for(int i=0;i<n;i++)
	{
		string q;
		cin>>q;
		ans.insert(q);
	}
	cout<<ans.size()<<endl;
}

Measured memory_bytes: 19260
#include <stdio.h>

int main(void)
{
	int n, s, i, f;
	int count = 0;

	scanf("%d", &n);

	for (s = 0; s <= n; s++){
		i = 0;
		f = s;
		//桁数を調べる
		while (f > 0) {
			f = f / 10;
			i++;
		}
		//奇数ならカウント
		if (i % 2 == 1) {
			count++;
		}
	}

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

	return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1e9+7
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define all(x) (x).begin(),(x).end()
ll min(ll a,ll b){
  if(a>b){
    return b;
    }
      else{
        return a;
      }
  }
  
  ll max(ll a,ll b){
    if(a>b){
      return a;
    }
    else{
      return b;
    }
  }

ll power(ll a,ll b){
 ll ans=1;
 for(ll i=1;i<=b;i++){
ans*=a;
  }
  return ans;
}

 long long int gcd(long long int m,long long int n){
 	if(n==0){
       return m;
     }
   return gcd(n,m%n);
 }
long long int lcm(long long int number1,long long int number2){
	return number1 * number2 / gcd(number1,number2);	

}
int main(){
  ll N;
  cin>>N;
  
  vector<ll>A(N);
  vector<ll>B(N);
  
  rep(i,N){
cin>>A[i];
  }
  sort(all(A));
  reverse(all(A));
 
  ll num=1;
 for(ll i=1;i<N;i++){
 if(A[i]==A[i-1]){
   num++;
 }
else{
  
  for(ll j=0;j<num/2;j++){
    B.push_back(A[i-1]);
  }
  num=1;
}

  if(i==N-1){
     for(ll j=0;j<num/2;j++){
    B.push_back(A[i]);
  }
    
    
  }
   
  }
  
  sort(all(B));
  reverse(all(B));
  
if(B.size()<2){
  cout<<0<<endl;
}
  else{
cout<<B[0]*B[1]<<endl;
  }
  
}

  

Measured memory_bytes: 2560
# kurimu_usamaro様のメソッドを拝借しています。
class Combi():
    def __init__(self, N, mod):
        self.power = [1 for _ in range(N+1)]
        self.rev = [1 for _ in range(N+1)]
        self.mod = mod
        for i in range(2, N+1):
            self.power[i] = (self.power[i-1]*i) % self.mod
        self.rev[N] = pow(self.power[N], self.mod-2, self.mod)
        for j in range(N, 0, -1):
            self.rev[j-1] = (self.rev[j]*j) % self.mod
 
    def com(self, K, R):
        if K < R:
            return 0
        else:
            return ((self.power[K])*(self.rev[K-R])*(self.rev[R])) % self.mod
 
    def pom(self, K, R):
        if K < R:
            return 0
        else:
            return (self.power[K])*(self.rev[K-R]) % self.mod
 
def main():
  mod = 10**9+7
  N,K = map(int,input().split())
  A = list(map(int,input().split()))
  A.sort()
  c = Combi(N,mod)

  ans = 0
  if K == 1:
    print(0)
  else:
    for i, a in enumerate(A):
      ans += c.com(i, K-1)*a
      ans -= c.com(N-1-i, K-1)*a
      ans %= mod
    print(ans%mod)

if __name__ == "__main__":
    main()

Measured memory_bytes: 21204
#include <bits/stdc++.h>
#define endl "\n"
using namespace std;
typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
template<class T>
inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}

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

const long long INF = 1e18;
const ll mod = 1000000007;
ll N;
vector<ll> edges[6000];
vector<ll> dp[5005][2];
vector<ll> B[2];
ll A[6000];

void merge(int a, int b) {
    B[0].clear();
    B[1].clear();
    for(int i = 0; i < 2; i++) {
        for(int j = 0; j < 2; j++) {
            int k = (i ^ j);
            int sz = ((int)dp[a][i].size() + dp[b][j].size() - 1);
            if(B[k].size() < sz) B[k].resize(sz);
            for(int l = 0; l < dp[a][i].size(); l++) {
                for(int m = 0; m < dp[b][j].size(); m++) {
                    B[k][l+m] += dp[a][i][l] * dp[b][j][m];
                    B[k][l+m] %= mod;
                }
            }
        }
    }
    swap(dp[a], B);
}

void f(int a) {
    for(int i = 0; i < 2; i++) {
        for(int j = 2; j < dp[a][i].size(); j += 2) {
            dp[a][1^i][0] += A[j] * dp[a][i][j];
            dp[a][1^i][0] %= mod;
        }
    }
}

void print(vector<ll> v) {
    cerr << "{";
    for(int i = 0; i < v.size(); i++) {
        if(i != 0) cerr << ", ";
        cerr << v[i];
    }
    cerr << "}" << endl;
}

void dfs(int now, int from) {
    vector<int> children;
    for(auto to : edges[now]) {
        if(to == from) continue;
        dfs(to, now);
        children.push_back(to);
    }
    dp[now][0].push_back(0);
    dp[now][0].push_back(1);
    dp[now][1].push_back(0);
    for(auto to : children) {
        merge(now, to);
    }
    f(now);
    /*
    cerr << "---------" << now << "-----------" << endl;
    for(int i = 0; i < 2; i++) {
        print(dp[now][i]);
    }
    */
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    A[0] = 1;
    for(ll i = 2; i <= 5000; i += 2) {
        A[i] = A[i-2] * (i - 1) % mod;
    }
    cin >> N;
    for(int i = 0; i < N - 1; i++) {
        ll a, b;
        cin >> a >> b;
        a--;
        b--;
        edges[a].push_back(b);
        edges[b].push_back(a);
    }
    dfs(0, -1);
    ll ans = dp[0][1][0] - dp[0][0][0] + mod;
    ans %= mod;
    cout << ans << endl;
    return 0;
}

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

#define REP(i,n) for(int i=0;i<(n);++i)
const long long INF = 1LL<<60;
const long long mod=1e9+7;

int main(){
    int N;
    cin >> N;
    vector<int> d(N);
    REP(i,N) cin >> d[i];
    sort(d.begin(), d.end());
    int ans = d[N/2] - d[N/2-1];
    cout << ans << endl;
}

Measured memory_bytes: 640
import collections
import math
import re
import numpy
def ai():return input()#s
def a():return int(input())#a,n or k
def ma():return map(int, input().split())#a,b,c,d or n,k
def ms():return map(str, input().split())#,a,b,c,d
def lma():return list(map(int, input().split()))#x or y
def lms():return list(map(str, input().split()))#x or y
def say(i):return print("Yes" if i == 0 else "No")
def Say(i):return print("YES" if i == 0 else "NO")
k= [0]
l = []
f = 0
s=0
c=0
e =1
k[0] =a()
for i in range(0,1000001):
    if k[i] in k[:i]:
        c=i
        break
    if k[i]%2==0:
        k.append(k[i]//2)
    else:k.append(k[i]*3+1)
print(c+1)

Measured memory_bytes: 21388
A,B,M=map(int, input().split())
a=list(map(int, input().split()))
b=list(map(int, input().split()))
x = [0] * M
y = [0] * M
c = [0] * M
for i in range(M):
    x[i],y[i],c[i]=map(int, input().split())

ans = min(a) + min(b)
for i in range(M):
    ans = min(ans,(a[x[i]-1]+b[y[i]-1]-c[i]))

print(ans)

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

#define REP(i, n) for (int i = 0; i < (n); i++)
#define FOR(i, init, n) for(int i = init; i < (n); i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define fi first
#define se second

using namespace std;
using ll = long long int;
using P = pair<int, int>;
using T = tuple<int, int, int>;
using edge = struct
{
    int to, cost;
};

const int MOD = 1e9 + 7;
const int iINF = 1e9;
const long long int llINF = 1e18;
const double PI = acos(-1.0);

const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

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

    int h, m, s, ah, am, as;

    REP(i, 3)
    {
        cin >> h >> m >> s >> ah >> am >> as;

        int sum = h * 3600 + m * 60 + s;
        int asum = ah * 3600 + am * 60 + as;

        int res = asum - sum;

        cout << res / 3600 << " ";
        res %= 3600;
        cout << res / 60 << " ";
        res %= 60;
        cout << res << endl;
    }

    return 0;
}


Measured memory_bytes: 3124
import java.util.*;
import java.io.*;
import java.lang.*;

public class Main {
	public static void main (String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int AC = 0; int WA = 0; int TLE = 0; int RE = 0;
		while (n-- > 0) {
			String s = sc.next();
			if (s.equals("AC")) 
				AC++;
			else if (s.equals("WA"))
				WA++;
			else if (s.equals("TLE"))
				TLE++;
			else if (s.equals("RE"))
				RE++;
		}

		System.out.println("AC x " + AC);
		System.out.println("WA x " + WA);
		System.out.println("TLE x " + TLE);
		System.out.println("RE x " + RE);

	}
}


Measured memory_bytes: 58436
#include<bits/stdc++.h>
using namespace std;
#define mp make_pair
typedef long long ll;
const int N=40;
int n;
char s[N];
ll ans;
map<pair<string,string>,int>Map;
int main(){
	scanf("%d",&n);
	scanf("%s",s+1);
	for (int S=0;S<1<<n;S++){
		string R="",B="";
		for (int i=0;i<n;i++)
			if (S&(1<<i))R+=s[i+1];
			else B+=s[i+1];
		Map[mp(R,B)]++;
	}
	for (int S=0;S<1<<n;S++){
		string R="",B="";
		for (int i=0;i<n;i++)
			if (S&(1<<i))R+=s[2*n-i];
			else B+=s[2*n-i];
		ans+=Map[mp(R,B)];
	}
	printf("%lld\n",ans);
}


Measured memory_bytes: 91904
#include <stdio.h>

int H,W;
char a[501][501];
char red[501][501];
char blue[501][501];

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

    for(int h=0;h<H;h++){
        if(h%2==0){
            for(int w=0;w<W-1;w++){
                red[h][w]='#';
            }
            red[h][W-1]='.';
        }else{
            for(int w=1;w<W;w++){
                red[h][w]='.';
            }
            red[h][0]='#';
        }
        red[h][W]='\0';
    }

    for(int h=0;h<H;h++){
        if(h%2==1){
            for(int w=1;w<W;w++){
                blue[h][w]='#';
            }
            blue[h][0]='.';
        }else{
            for(int w=0;w<W-1;w++){
                blue[h][w]='.';
            }
            blue[h][W-1]='#';
        }
        blue[h][W]='\0';
    }

    for (int h = 0; h < H; ++h) {
        for (int w = 0; w < W; ++w) {
            if(a[h][w]=='#'){
                if(h%2==0){
                    blue[h][w]='#';
                }else{
                    red[h][w]='#';
                }
            }
        }
    }

    for(int h=0;h<H;h++){
        printf("%s\n", red[h]);
    }
    printf("\n");
    for(int h=0;h<H;h++){
        printf("%s\n", blue[h]);
    }

    return 0;
}

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

int main(){
  int N;
  cin>>N;
  vector<vector<int>> A(2,vector<int>(N)),B(2,vector<int>(N));
  for(int i=0;i<N;i++){
    cin>>A.at(0).at(i);
    if(i!=0){
      B.at(0).at(i)=B.at(0).at(i-1)+A.at(0).at(i);
    }else{
      B.at(0).at(i)=A.at(0).at(i);
    }
  }
  for(int i=0;i<N;i++){
    cin>>A.at(1).at(i);
    if(i!=0){
      B.at(1).at(i)=max(B.at(1).at(i-1)+A.at(1).at(i),B.at(0).at(i)+A.at(1).at(i));
    }else{
      B.at(1).at(i)=A.at(0).at(i)+A.at(1).at(i);
    }
  }
  cout<<B.at(1).at(N-1)<<endl;
  
  
}

Measured memory_bytes: 256
n = int(input())
a = list(map(int, input().split()))
q = int(input())
q = list(map(int, input().split()))
dp = [[False]*2001 for i in range(n+1)]
for i in range(n+1):
    dp[i][0] = True
for i in range(n):
    for j in range(2001):
        if j+a[i] <= 2000:
            dp[i+1][j+a[i]] = dp[i+1][j+a[i]] | dp[i][j]
        dp[i+1][j] = dp[i][j] | dp[i+1][j]
for query in q:
    if dp[n][query]:
        print("yes")
    else:
        print("no")



Measured memory_bytes: 5944
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text.RegularExpressions;
using Console = System.Console;

namespace Atcoder
{
    class Program
    {
        static void Main(string[] args)
        {
            var N = int.Parse(Console.ReadLine());
            var S = Console.ReadLine();
            int ret = 0;
            for (int i = 0; i < N - 2; i++)
            {
                if (S[i] == 'A' && S[i + 1] == 'B' && S[i + 2] == 'C')
                {
                    ret++;
                }
            }
            Console.WriteLine(ret);
        }
        
    }
}

Measured memory_bytes: 11092
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector<vi>;
using vvl = vector<vl>;
const ll INF = 1LL << 60;
const ll MOD = 1000000007;
template <class T>
bool chmax(T &a, const T &b) {
    return (a < b) ? (a = b, 1) : 0;
}
template <class T>
bool chmin(T &a, const T &b) {
    return (b < a) ? (a = b, 1) : 0;
}
template <class C>
void print(const C &c, std::ostream &os = std::cout) {
    std::copy(std::begin(c), std::end(c), std::ostream_iterator<typename C::value_type>(os, " "));
    os << std::endl;
}

int main() {
    int a, b;
    cin >> a >> b;
    int ret = a + b;
    chmax(ret, a - b);
    chmax(ret, a * b);
    cout << ret << "\n";
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, a, n) for(ll i = ((ll) a); i < ((ll) n); i++)
#define INF (1LL << 60)
using namespace std;
typedef long long ll;

struct input { ll u, v, d, c; };

struct edge { ll to, cap, rev; };

vector<edge> G[1000];
bool used[1000];

void add_edge(ll from, ll to, ll cap) {
  G[from].push_back((edge) { to, cap, (ll) G[to].size() });
  G[to].push_back((edge) { from, 0, (ll) G[from].size() - 1 }); // Directed Graph
}

ll dfs(ll v, ll t, ll f) {
  if(v == t) return f;
  used[v] = true;
  REP(i, 0, G[v].size()) {
    edge &e = G[v][i];
    if(!used[e.to] && e.cap > 0) {
      ll d = dfs(e.to, t, min(f, e.cap));
      if(d > 0) {
        e.cap -= d;
        G[e.to][e.rev].cap += d;
        return d;
      }
    }
  }
  return 0;
}

ll max_flow(ll s, ll t) {
  ll flow = 0;
  while(1) {
    memset(used, 0, sizeof(used));
    ll f = dfs(s, t, INF);
    if(f == 0 || f == INF) break;
    flow += f;
  }
  return flow;
}

int main(void) {
  ll N, M, S, T; cin >> N >> M >> S >> T; S--; T--;
  vector<input> edges(M);
  REP(i, 0, M) {
    ll U, V, D, C; cin >> U >> V >> D >> C; U--; V--;
    edges[i] = (input) { U, V, D, C };
  }

  vector< vector<ll> > dist(N, vector<ll>(N, INF));
  REP(i, 0, N) dist[i][i] = 0;
  for(input &e : edges) dist[e.u][e.v] = min(dist[e.u][e.v], e.d);
  REP(k, 0, N) REP(i, 0, N) REP(j, 0, N) dist[i][j] = min(dist[i][j], dist[i][k] + dist[k][j]);

  for(input &e : edges) {
    if(dist[S][e.u] + e.d + dist[e.v][T] == dist[S][T]) {
      add_edge(e.u, e.v, e.c);
    }
  }
  cout << max_flow(S, T) << endl;
}



Measured memory_bytes: 3316
import sys
 
def insertionSort( nums, n, g ):
    cnt = 0
    i = g
    while i < n:
        v = nums[i]
        j = i - g
        while 0 <= j and v < nums[j]:
            nums[ j+g ] = nums[j]
            j -= g
            cnt += 1
        nums[ j+g ] = v
        i += 1
    return cnt
         
def shellSort( nums, n ):
    g = []
    val = 1
    while val <= n:
        g.append( val )
        val = 3*val+1
     
    g.reverse( )
    m = len( g )
    print( m )
    print( " ".join( map( str, g ) ) )
    cnt = 0
    for i in range( m ):
        cnt += insertionSort( nums, n, g[i] )
    print( cnt )
     
n = int( sys.stdin.readline( ) )
nums = []
for i in range( n ):
    nums.append( int( sys.stdin.readline( ) ) )
 
shellSort( nums, n )
print( "\n".join( map( str, nums ) ) )

Measured memory_bytes: 189888
#include<bits/stdc++.h>
using namespace std;
int main(){
char a,b;
cin >> a >> b;
if(a == 'D' && b == 'D'){
	cout << 'H' << endl;
}
else if(a == 'D' && b == 'H'){
	cout << 'D' << endl;
}
else if(a == 'H'){
	cout << b << endl;
}
}

Measured memory_bytes: 256
//
//  main.cpp
//

#include <algorithm>
#include <array>
#include <assert.h>
#include <functional>
#include <iostream>
#include <limits>
#include <map>
#include <math.h>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <vector>

using namespace std;

using ll = long long;
using ull = unsigned long long;

int main(int argc, char* argv[]) {
    int N;
    cin >> N;
    vector<ll> Ais;
    ll total = 0;
    ll sum_even = 0;
    for (int i = 0; i < N; i++) {
        ll Ai;
        cin >> Ai;
        Ais.push_back(Ai);
        total += Ai;
        if (i % 2 == 0 && i != N-1) {
            sum_even += Ai;
        }
    }
    total = total / 2;
    ll last = total - sum_even;
    vector<ll> ans;
    ans.resize(N, 0);
    ans[N-1] = last;
    for (int i = N-2; i >= 0; i--) {
        ans[i] = Ais[i] - ans[i+1];
    }
    for (int i = 0; i < N; i++) {
        cout << 2 * ans[i];
        if (i < N-1) {
            cout << " ";
        }
    }
    cout << endl;
    return 0;
}



Measured memory_bytes: 3060
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define PI  3.14159265358979323846
#define M   1000000007
ll gcd(ll a,ll b)
{
    if(a==0)
        return b;
    else
        return gcd(b%a,a);
}
ll fast(ll n,ll a,ll m)
{
    if(n==0)
        return 1;
    else if(n==1)
        return a;
    else
    {
        ll res=fast(n/2,a,m)%m;
        if(n%2==0)
            return (((res%m)*(res%m))%m);
        else
            return (((((res%m)*a)%m)*res)%m);
    }
}
ll lcm(ll a,ll b)
{
    ll p=a*b;
    p/=gcd(a,b);
    return p;
}
ll isprime(ll N)
{
    if(N==2||N==3)
    {
        return 1;
    }
    if(N%2==0||N%3==0)
    {
        return 0;
    }
    for(ll i=5;i*i<=N;i+=6)
    {
        if(N%i==0||N%(i+6)==0)
            return 0;
    }
    return 1;
}

int main()
{
   int H,A;
   cin>>H>>A;
   int y=H/A;
   if(H%A==0)
    cout<<y;
   else
    cout<<y+1;

}


Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <cmath>
#include <iostream>
#include <sstream>
#include <algorithm>
#include <numeric>
#include <functional>
#include <vector>
#include <queue>
#include <string>
#include <complex>
#include <stack>
#include <set>
#include <map>

#define REP(i,n) for (int i = 0; i < (n); i++)
#define RREP(i,n) for (int i = (n)-1; i >= 0; i--)
#define FOR(i,s,n) for (int i = (s); i < (n); i++)
#define allof(c) c.begin(), c.end()
#define partof(c,i,n) c.begin() + (i), c.begin() + (i) + (n)
#define EPS 1e-9
#define INF 1000000000
using namespace std;

typedef complex<int> POINT;
template <class T>
class vevector : public vector<vector<T>>
{
public:
	using vector<vector<T>>::operator []; 
	T& operator [](const POINT &index) { return (*this)[index.real()][index.imag()]; }
};

template <class T> T read() { T t; cin >> t; return t; }
template <> POINT read<POINT>() { int x, y; cin >> x >> y; return POINT(x, y); }
template <class T> vector<T> read(int n) { vector<T> v; REP(i,n) { v.push_back(read<T>()); } return v; }
template <class T> vevector<T> read(int n, int m) { vevector<T> v; REP(i,n) v.push_back(read<T>(m)); return v; }
template <class T> vevector<T> readjag(int n) { vevector<T> v; REP(i,n) v.push_back(read<T>(read<int>())); return v; }
template <class T> void write(const T &t) { cout << t << endl; }
template <class T> void write(const T &t, const T &t2) { cout << t << ' ' << t2 << endl; }

template <class T> void write(const vector<T> &v)
{
	ostringstream ss; 
	for (auto x : v) ss << x << ' ';
	auto s = ss.str();
	cout << s.substr(0, s.length() - 1) << endl;
}

template <class T> string toString(const T &t) { stringstream ss; ss << t; return ss.str(); }

struct _Reader { template <class T> _Reader operator ,(T &rhs) { cin >> rhs; return *this; } };
#define READ(t,...) t __VA_ARGS__; _Reader(), __VA_ARGS__
#define countof(a) (sizeof(a)/sizeof(a[0]))
#define COMPARISON(t,a,b) [](const t & a, const t & b) -> bool

// primes //
vector<unsigned char> isPrime;
vector<int> primes;
void initPrimes(int n)
{
	isPrime = vector<unsigned char>(n + 1, true);
	isPrime[0] = isPrime[1] = false;
	FOR(i, 2, n + 1)
	{
		if (!isPrime[i]) continue;
		primes.push_back(i);
		for (int j = i * 2; j <= n; j += i)
			isPrime[j] = false;
	}
}

// iota iterator //
struct iotait
{
	int n;
	iotait(int n = 0) : n(n) { }
	iotait &operator ++() { ++n; return *this; }
	int operator *() { return n; }
};

// start up //
void solve();
int main() { solve(); return 0; }


/// template end ///

void solve()
{
	initPrimes(1299709);
	REP (testcase, INF)
	{
		READ(int, k);
		if (!(k)) { break; }
		int l = *(upper_bound(allof(primes), k) - 1);
		int u = *lower_bound(allof(primes), k);
		write(u - l);
	}
}

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

#define mp make_pair
#define ff first
#define ss second
#define pii pair <int,int>
#define pb push_back
#define debug(x)  cerr << #x << " = " << x << endl
using namespace std ;
typedef long long ll ;
const int maxn = 100000+5 ;
int h[maxn] ;
ll dp[maxn] ;

int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	int n;
	cin >> n ;
	for(int i =1 ; i <= n ;i++){
		cin >> h[i] ;
		
	}
	dp[1]=0 ;
	dp[2]=abs(h[1]-h[2]) ;
	for(int i =3; i<= n ;i++){
		ll a = (dp[i-2]+abs(h[i-2]-h[i])) ;
		ll b = (dp[i-1]+abs(h[i-1]-h[i])) ;
		dp[i] = (ll)min((ll)a,(ll)b) ;
	}
	cout << dp[n] ;
	return 0 ;
}


Measured memory_bytes: 1408
import math

N = int(input())
D = list(map(int, input().split()))

if D[0] != 0:
    print(0)
    exit()

dict = {}

for i in range(len(D)):
    if D[i] not in dict:
        dict[D[i]] = 1
    else:
        dict[D[i]] += 1

for i in range(max(D)):
    if i not in dict:
        dict[i] = 0
    
for key in dict:
    if key == 0:
        if dict[key] != 1:
            print(0)
            exit()       
    if dict[key] == 0:
        print(0)
        exit()
sum = 1
n = 0

#dict = list(sorted(dict.items(), key=lambda x:x[0]))
dict_dm = sorted(dict)
#print(dict)
#print(dict_dm)
flg = 0
for i in range(len(dict_dm)):
    if i == 1:
        #print("check2")
        n = dict[i]
    elif i >=1:
        #print("check1")
        sum = (sum * n**dict[i])%998244353
        n = dict[i]

print(sum%998244353)

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

int main() {
  long n,lcm,ans=0,mod=1000000007;
  cin >> n;
  vector<long> a(n);
  map<long,long> aaa;
  vector<long> primenum;
  for(long i=0;i<n;i++) cin >> a[i];

  primenum.push_back(2);
  for(long i=3;i<1000;i+=2) {
    for(long j=0;true;j++) {
      if(primenum[j]*primenum[j]>i) {
        primenum.push_back(i);
        aaa[i]=0;
        break;
      }
      if(i%primenum[j]==0) break;
    }
  }

  for(long i=0;i<n;i++) {
    long x=a[i];
    for(long j=0;j<primenum.size();j++) {
      if(primenum[j]>1000) break;
      long y=0;
      for(;x%primenum[j]==0;y++) x/=primenum[j];
      aaa[primenum[j]]=max(aaa[primenum[j]],y);
    }
    if(x!=1) {
      if(!(aaa.count(x))) primenum.push_back(x);
      aaa[x]=1;
    }
  }
  lcm=1;
  for(long i=0;i<primenum.size();i++) {
    for(long j=0;j<aaa[primenum[i]];j++) {
      lcm*=primenum[i];
      lcm=lcm%mod;
    }
  }
  for(long i=0;i<n;i++) {
    long x=a[i];
    long y=1;
    for(long j=1;j<=(mod-2);j=j*2) {
      if((mod-2)/j%2==1) y=y*x%mod;
      x=x*x%mod;
    }
    ans+=lcm*y%mod;
    ans=ans%mod;
  }
  cout << ans << endl;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
using namespace std;
using ll = long long;
using P = pair<int,int>;
const int INF = 1001001001;
const int mod = 1000000007;

/*
 * 全部A, B円で買って，減らしていく
 */

string num_3(int num){
    if(num < 10){
        return "00" + to_string(num);
    }else if(num < 100){
        return "0" + to_string(num);
    }else{
        return to_string(num);
    }
}

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

    int cnt = 0;

    for(int i = 0; i < 1000; i++){
        string goal = num_3(i);
        int idx = -1;
        for(int j = 0; j < S.size(); j++){
            if(S[j] == goal[0]){
                idx = j;
                break;
            }
        }
        if(idx == -1){
            continue;
        }
        for(int j = idx + 1; j < S.size(); j++){
            idx = -1;
            if(S[j] == goal[1]){
                idx = j;
                break;
            }
        }
        if(idx == -1){
            continue;
        }
        for(int j = idx + 1; j < S.size(); j++){
            idx = -1;
            if(S[j] == goal[2]){
                cnt++;
                break;
            }
        }
    }
    cout << cnt << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main() {
    ll X,K; cin >> X >> K;
    if (X==0){
        cout << 0 << endl;
        return 0;
    }

    ll Y = X%K;
    ll ans = min(X,Y);
    ans = min(ans,abs(Y-K));
    cout << ans << endl;
    return 0;
}

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

#define debug(x) cerr << x << " " \
                      << "(L:" << __LINE__ << ")" << '\n'

typedef long long ll; //64bit型
using namespace std;

const long long INF = 1LL << 60; //無限大の値
static const int N = 100;

int main()
{
    queue<pair<string, int> > Q;
    int n, q;
    cin >> n >> q;
    for (int i = 0; i < n; i++)
    {
        string name;
        int time;
        cin >> name >> time;
        Q.push(make_pair(name,time));
    }

    pair<string,int> u;
    int elaps = 0, a;
    while (!Q.empty())
    {
        u = Q.front();
        Q.pop();
        a = min(u.second, q);
        u.second -= a;
        elaps += a;
        if(u.second>0){
            Q.push(u);


        }else{
            cout << u.first << ' ' << elaps << endl;
        }
    }

    return 0;
}



Measured memory_bytes: 6168
#include <bits/stdc++.h>
using namespace std;
int main() {
  int a,b;
  cin >> a >> b;
  int ans = 0;
  for (int i = 0; i < 2; i++){
    if (a>=b){
      ans += a;
      a--;
    }else{
      ans += b;
      b--;
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
#include <functional> // for less 
using namespace __gnu_pbds; 
#define mod 998244353 
#define int long long
#define ll long long
#define pb push_back
#define boost ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define inp(n) for(i=0;i<n;i++) cin>>A[i];
#define inz(A) memset(A,0,sizeof(A))
#define lb lower_bound
#define ub upper_bound
#define all(v) v.begin(),v.end()
#define T 1000005
#define F first
#define S second
#define pi pair<int,int>
#define vi vector<int>
#define mii map<int,int>
#define vp vector<pair< int,int> >
#define mpi map<pair<int,int> ,int>
#define PI M_PI
#define lower(s) transform(all(s),s.begin(),::tolower)
#define endl "\n"
typedef tree<int, null_type, less<int>, rb_tree_tag, 
         tree_order_statistics_node_update> pbds;
int add(int a, int b) {a=(a%mod + b%mod)%mod;return a;}
int sub(int a, int b) {a =(a%mod - b%mod + mod)%mod ;return a;}
int mul(int a, int b) {return (a%mod * b%mod) % mod;}


void solve()
{  
    int n;cin>>n;
    int A[n+5];
    for(int i=0;i<n;i++)cin >> A[i];
    sort(A,A+n);
    int ans=A[n-1];
    int cnt=n-2;
    for(int i=n-2;i>=0;i--)
    {
        if(cnt==0)break;
        ans+=min(2LL,cnt)*A[i];
        cnt-=min(2LL,cnt);
    }
    cout << ans;
}

signed main()
{ 
    boost
    int test=0,t;
    //cin >> t ;
    t=1;
    while(test++ <t){
	  //cout<<"Case #"<<test<<": ";
	   solve();}
  
}

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

using namespace std;

const int maxn = 1e5+10;
int n;
int a[maxn];

int diff(int i, int j) {
    return abs(a[i] - a[j]);
}

int main()
{
    int k, tmp;
    cin >> n >> k;
    int dp[n];
    for (int i = 0; i < n; i++)
        cin >> a[i];
    dp[0] = 0;
    for (int i = 1; i < n; i++) {
        tmp = dp[i-1] + diff(i, i-1);
        for (int j = 1; j <= min(k, i); j++) 
            tmp = min(tmp, dp[i-j] + diff(i, i-j));
        dp[i] = tmp;
    }
    cout << dp[n-1] << endl;
    
//    for (int i = 0; i < n ; i++)
//    	printf("dp[%d] = %d\n", i, dp[i]);
    return 0;
}

Measured memory_bytes: 1024
#include<iostream>
#include<string.h>
#include<ctype.h>
#include<string>
#include<math.h>
#define pi 3.141592653589
#include<iomanip>
using namespace std;
#include<algorithm>
#define rep(i,a,n) for(int i=a;i<n;i++)
 
 
 
int main(){
    
    int a,b,c;
    
    cin>>a>>b>>c;
    rep(i,1,b){
        if((a*i)%b==c){
            cout<<"YES"<<endl;
            return 0;
        }
    }
    cout<<"NO"<<endl;
    
    return 0;
}

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

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

  for(int i = 0; i < N; i++) {
    cin >> A;
    num = 0;

    while (A % 2 == 0) {
      A /= 2;
      num++;
    }

    if (i == 0 || min > num) {
      min = num;
    }
  }

  cout << min << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <sstream>
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <complex>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <cassert>
#include <climits>
#include <queue>
#include <set>
#include <map>
#include <valarray>
#include <bitset>
#include <stack>
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()
typedef long long ll;
typedef pair<int,int> pii;
const int INF = 1<<29;
const double PI = acos(-1);
const double EPS = 1e-8;

int dp[2001];
int main() {
  int n, K;
  cin >> n >> K;
  vector<int> v[10];
  REP(i, n) {
    int a, b;
    cin >> a >> b;
    b--;
    v[b].push_back(a);
  }
  REP(i, 10) {
    sort(ALL(v[i]), greater<int>());
    REP(j, v[i].size()-1) {
      v[i][j+1] += v[i][j] + 2*(j+1);
      //cout<< v[i][j] << " ";
    }
    //if (v[i].size()) cout << v[i][v[i].size()-1] << endl;
  }
  REP(i, 10) {
    for (int j=n; j>=0; --j) {
      for (int k=0; k<v[i].size() && j+k+1<n; ++k) {
        dp[j+k+1] = max(dp[j+k+1], dp[j] + v[i][k]);
      }
    }
    // REP(i, n)cout << dp[i] <<" ";
    // cout << endl;
  }
  cout << dp[K] << endl;
}

Measured memory_bytes: 0
#include <iostream>
#include <numeric>
#include <vector>
#include <math.h>
#include <map>
#include <algorithm>
#include <stdio.h>
using namespace std; 
int main(){
    string a,s; cin >> a >> s;
    int d,f; cin >> d >> f;
    string g; cin >> g;
    if (g==a) cout << d-1 << " " << f;
    else cout << d << " " << f-1;
}








Measured memory_bytes: 256
#include<map>
#include<cmath>
#include<stack>
#include<queue>
#include<cstdio>
#include<vector>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
typedef long long ll;
template<class AC>void r(AC &x){
    x=0;
    int f=0;
    char ch=getchar();
    while(ch<'0'||ch>'9'){
        f|=(ch=='-');
        ch=getchar();
    }
    while(ch>='0'&&ch<='9'){
        x=(x<<1)+(x<<3)+(ch^48);
        ch=getchar();
    }
    x=f?-x:x;
    return;
}
int x,y,z;
int main(){
	r(x);r(y);r(z);
	int sum=y/x;
	if(sum>z)printf("%d\n",z);
	else printf("%d\n",sum);
	return 0;
}

Measured memory_bytes: 256
import fractions

n,k=map(int,input().split())
A=list(map(int,input().split()))

M=A[0]
g=A[0]
for i in range(n-1):
    M=max(M,A[i+1])
    g=fractions.gcd(g,A[i+1])

if k<=M:
    if g==1:
        print("POSSIBLE")
    elif k%g==0:
            print("POSSIBLE")
    else:
        print("IMPOSSIBLE")
else:
    print("IMPOSSIBLE")

Measured memory_bytes: 16240
#include <stdio.h>
#include <string.h>
#define M 1000000
#define L 15
#define NIL -1
char H[M][L]; 
int find(char str[]);
  
int Key(char str[]);
int hen(char ch);
int h1(int key);
int h2(int key);

int insert(char str[]);

 

int main() {
  int i, n;
  char r[L], c[9];
  for (i = 0; i < M; i++) H[i][0] = '\0';
  scanf("%d", &n);
  for (i = 0; i < n; i++) {
    scanf("%s %s", c, r);
    if (c[0] == 'i') {
      insert(r);
    }
    else {
      if (find(r)) {
	printf("yes\n");
      }
      else {
	printf("no\n");
      }
    }
  }
  return 0;
}

int find(char str[]) {
  long long key, i = 0, h;
  key = Key(str);
  while (1) {
    h = (h1(key) + i * h2(key)) % M;
    i++;
    if (strcmp(H[h], str) == 0) return 1;
    else if (strlen(H[h]) == 0) return 0;
  }
  return 0;
}
int Key(char str[]) {
  int sum = 0, p = 1, i;
  for (i = 0; i < strlen(str); i++) {
    sum += p * (hen(str[i]));
    p *= 6;
  }	
  return sum;
} int hen(char ch) {
  if (ch == 'A') return 1;
  else if (ch == 'C') return 2;
  else if (ch == 'G') return 3;
  else if (ch == 'T') return 4;
}
int insert(char str[]) {
  long long key, i = 0, h;
  key = Key(str);
  while (1) {
    h = (h1(key) + i * h2(key)) % M;
    i++;
    if (strcmp(H[h], str) == 0) return 1;
    else if (strlen(H[h]) == 0) {
      strcpy(H[h], str);
      return 0;
    }
  }
  return 0;
}
int h1(int key) { return key % M ; }
int h2(int key) { return 1 + (key % (M - 1)); }


Measured memory_bytes: 16440
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <map>
using namespace std;
typedef long long ll;
#define rep(i,n) for (int i=0;i < (int)(n);i++)

int main(){
  ll n;
  cin >> n;
  vector<ll> v(n+1,1);

  for (ll i = 2;i <= n;i++){
    for (ll j = i;j <= n;j+=i) v[j]++;
  }
  //rep(i,n){
  //  cout << i+1 << ":" << v[i+1] << endl;
  //}
  ll ans = 0;
  for (int i = 1;i <= n;i++){
    ans += ll(i)*v[i];
  }
  cout << ans << endl;

}


Measured memory_bytes: 81380
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
using namespace std;
#define ll long long
#define rep(i,n) for(int i=0;i<(n);i++)
#define repp(i,n) for(int i=1;i<=n;i++)
typedef pair<int,int> P;
int d[100100][3]; //状態を作る
const int INF = 100100100;
int main(){
    int n,m;
    cin >> n >> m;
    vector<vector<int>> to(n);
    rep(i,m){
        int a,b;
        cin >> a >> b;
        a--; b--;
        to[a].push_back(b);
    }
    int s,t;
    cin >> s >> t;
    s--; t--;
    queue<P> q;
    q.push(P(s,0));
    rep(i,n)rep(j,3) d[i][j]=INF;
    d[s][0]=0;
    //BFS
    while(!q.empty()){
        int v = q.front().first;
        int lo = q.front().second;
        q.pop();
        for(auto u:to[v]){
            int a = (lo+1)%3;
            if(d[u][a] != INF) continue;
            d[u][a]=d[v][lo]+1;
            q.push(P(u,a));
        }
    }
    int ans = d[t][0];
    if(ans==INF) cout << -1 << endl;
    else cout << ans/3 << endl;
    
    
}


Measured memory_bytes: 6912
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>

#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>

#include <complex>

#include <functional>
#include <cassert>

typedef long long ll;
using namespace std;

#define debug(x) cerr << __LINE__ << " : " << #x << " = " << (x) << endl;


#define mod 1000000007 //1e9+7(prime number)
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define SIZE 200010

int main(){
  int n;
  ll a[SIZE] = {};

  scanf("%d", &n);

  for(int i=0;i<n;i++){
    scanf("%lld", a+i+1);
    a[i+1] += a[i];
  }

  ll ans = LLINF;
  
  for(int i=2;i<n-1;i++){
    ll p = LLINF, q = 0;

    int l=1,r=i-1;

    while(l < r){
      int mid = (l+r+1)/2;

      if(a[mid] <= a[i]/2) l = mid;
      else r = mid-1;
    }

    ll x1 = a[l], y1 = a[i]-a[l];
    ll x2 = a[i]-a[l+1], y2 = a[l+1];

    if(x1 > y1) swap(x1, y1);
    if(x2 > y2) swap(x2, y2);
    
    if(l+1 == i) x2 = 0, y2 = LLINF;
    
    p = min(p, max(x1,x2));
    q = max(q, min(y1,y2));
    
    l=i+1; r=n-1;

    while(l < r){
      int mid = (l+r+1)/2;

      if(a[mid]-a[i] <= (a[n]-a[i])/2) l = mid;
      else r = mid-1;
    }

    x1 = a[l]-a[i]; y1 = a[n]-a[l];
    x2 = a[n]-a[l+1]; y2 = a[l+1]-a[i];

    if(x1 > y1) swap(x1, y1);
    if(x2 > y2) swap(x2, y2);

    if(l+1 == r) x2 = 0, y2 = LLINF;
    
    p = min(p, max(x1,x2));
    q = max(q, min(y1,y2));
    
    ans = min(ans, q - p);
  }

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


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, a, b) for (int i = a; i < (int)(b); i++)
#define all(v) v.begin(), v.end()
const int MOD = 1e9 + 7;
const int INF = 1e9;
//'A' = 65, 'Z' = 90, 'a' = 97, 'z' = 122

int main() {
    int n;
    cin >> n;
    int cnt[4] = {};
    rep(i, 0, n) {
        string s;
        cin >> s;
        if (s == "AC") cnt[0]++;
        if (s == "WA") cnt[1]++;
        if (s == "TLE") cnt[2]++;
        if (s == "RE") cnt[3]++;
    }
    cout << "AC x " << cnt[0] << endl;
    cout << "WA x " << cnt[1] << endl;
    cout << "TLE x " << cnt[2] << endl;
    cout << "RE x " << cnt[3] << endl;
    return 0;
}


Measured memory_bytes: 3640
#include <iostream>

using namespace std;

int main()
{
    int a,b;
    cin>>a>>b;
    if(a>b)
    cout<<"a > b"<<endl;
    else if(a==b)
    cout<<"a == b"<<endl;
    else if(a<b) cout<<"a < b"<<endl;
    

    return 0;
}



Measured memory_bytes: 3096
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

//Unit Converter
public class Main{

	void run(){
		Map<String, Integer> ref = new HashMap<String, Integer>();
		ref.put("yotta", 24); ref.put("zetta", 21); ref.put("exa", 18); ref.put("peta", 15); ref.put("tera", 12);
		ref.put("giga", 9); ref.put("mega", 6); ref.put("kilo", 3); ref.put("hecto", 2); ref.put("deca", 1);
		ref.put("deci", -1); ref.put("centi", -2); ref.put("milli", -3); ref.put("micro", -6); ref.put("nano", -9);
		ref.put("pico", -12); ref.put("femto", -15); ref.put("ato", -18); ref.put("zepto", -21); ref.put("yocto", -24);
		Scanner sc = new Scanner(System.in);
		int T = sc.nextInt(); sc.nextLine();
		while(T--!=0){
			String[] t = sc.nextLine().split(" ");
			char[] s = null;
			int p = 0;
			String w = "";
			if(t[0].contains(".")){
				p = t[0].indexOf('.')-1;
				t[0] = t[0].substring(0, p+1)+t[0].substring(p+2);
				s = t[0].toCharArray();
			}
			else{
				p = t[0].length()-1;
				s = t[0].toCharArray();
			}
			if(t.length==2){
				w = t[1];
			}
			else{
				w = t[2]; p+=ref.get(t[1]);
			}
			int k = 0;
			while(s[k]=='0')k++;
			//Lø K
			int K = s.length-k;
			int exp = p-k;
			StringBuilder res = new StringBuilder();
			res.append(s[k]+"");
			if(K>1){
				res.append(".");
				for(int i=k+1;i<s.length;i++)res.append(s[i]);
			}
			System.out.println(res.toString()+" * 10^"+exp+" "+w);
		}
	}
	
	public static void main(String[] args) {
		new Main().run();
	}
}

Measured memory_bytes: 11000
#include <iostream>
#include<cmath>
#include<algorithm>
#include<vector>
#include<map>
using namespace std;

int main() {
	string S;
	cin >> S;
	int i = 0;
	for (char c : S) {
		i++;
		int a;
		if (i % 2 == 1) {
			if (c == 'L') {
				cout << "No";
				goto end;
			}
		}
		else {
			if (c == 'R') {
				cout << "No";
				goto end;
			}
		}
	}
	cout << "Yes" << endl;
	end:;
}

Measured memory_bytes: 256
/* Manish Pant - insider_pants */

#include <bits/stdc++.h>
using namespace std;
#ifndef ONLINE_JUDGE
    #include "debug.h"
#endif

#define F first
#define S second
#define endl "\n"
#define pb push_back
typedef long long ll;
typedef long double ldob;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

void fast()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
}

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

    if (k <= a)
    {
        cout << k << endl;
        return 0;
    }

    int diff = max(0, k - a - b);

    cout << a - diff  << endl;
}

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

#define INF 1e9
using namespace std;
typedef long long ll;

ll dp[1000010] = {};

int main() {

    ll x; cin >> x;

    dp[0] = 1;
    dp[100] = 1;
    dp[101] = 1;
    dp[102] = 1;
    dp[103] = 1;
    dp[104] = 1;
    dp[105] = 1;

    for (int i = 0; i < 1000010; ++i) {
        if (dp[i] == 1) {
            dp[i + 100] = 1;
            dp[i + 101] = 1;
            dp[i + 102] = 1;
            dp[i + 103] = 1;
            dp[i + 104] = 1;
            dp[i + 105] = 1;
        }
    }

    if (dp[x] == 1) {
        puts("1");
    } else {
        puts("0");
    }
}

Measured memory_bytes: 8064
N, M = map(int, input().split())
a = [0 for i in range(M)]
b = [0 for i in range(M)]
cnt = [0 for i in range(N)]

for i in range(M):
    a[i], b[i] = map(int, input().split())

for i in range(M):
    cnt[a[i]-1] += 1
    cnt[b[i]-1] += 1

for i in range(N):
    print(cnt[i])

Measured memory_bytes: 9160
#include "bits/stdc++.h"
using namespace std;

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

    bool flag = false;
    for (int i = 0; i <= 25; i++) {
        for (int j = 0; j < 16; j++) {
            if (4 * i + 7 * j == N) {
                flag = true;
            }
        }
    }

    if (flag) {
        cout << "Yes" << endl;
    }
    else {
        cout << "No" << endl;
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <cassert>
#include <iomanip>
#include <utility>
#include <cmath>
#include <numeric>
#include <vector>
#include <set>
#include <algorithm>
#include <queue>
#include <string>

using namespace std;

typedef long long ll;
typedef pair<int, int> p_i;

#define rep(i, n) for(int i = 0; i < n; i++)
#define repext(i, a, b) for (int i = a; i < b; i++)
#define reprev(i, n) for (int i = n - 1; i >= 0; i--)
#define repextrev(i, a, b) for (int i = b - 1; i >= a; i--)
#define vec_all(vec) vec.begin(), vec.end()

// vectorデバッグ
template<typename T>
void dump_vec(vector<T> vec) {
    rep(i, vec.size()) {
        cout << i << ": " << vec[i] << endl;
    }
}

template<typename T>
T mod_factorial(T n, T mod) {
    T ret = 1;
    rep(i, n) {
        ret *= (i + 1);
        ret %= mod;
    }

    return ret;
}

// --- notice ---
// intの和はllにしろ

int main() {
    ll n,m;
    cin >> n >> m;
    ll mod = 1000000000 + 7;

    if (abs(n - m) > 1) {
        cout << 0 << endl;
        return 0;
    }

    ll n_fact = mod_factorial<ll>(n, mod);
    ll m_fact = mod_factorial<ll>(m, mod);

    if (n == m) {
        cout << (2 * n_fact * m_fact) % mod << endl;
        return 0;
    }

    cout << (n_fact * m_fact) % mod << endl;

    return 0;
}

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

int main(){

  int x,y,s;
  int max;


  while(cin >> x >> y >> s){
    if(x==0 && y==0 && s==0){ break; }

    max = 0;

    for(int i=1; i<s; i++){
      for(int j=s; j>=i; j--){
	if((int)(i*(100+x)/100) + (int)(j*(100+x)/100) == s){

	  if((int)(i*(100+y)/100) + (int)(j*(100+y)/100) > max){
	    max = (int)(i*(100+y)/100) + (int)(j*(100+y)/100);
	  }
	}
      }
    }

    cout << max << endl;

  }

  return 0;
}

Measured memory_bytes: 1160
import java.util.Arrays;
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        @SuppressWarnings("resource")
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        Pair[] pairs = new Pair[n];
        for (int i = 0 ; i < n ; i++) {
            Pair p = new Pair();
            p.no = i + 1;
            p.town = sc.next();
            p.point = sc.nextInt();
            pairs[i] = p;
        }
        Arrays.sort(pairs);
        for (int i = 0 ; i < n ; i++) {
            System.out.println(pairs[i].no);
        }
    }

}

class Pair implements Comparable {
    int no;
    String town;
    int point;
    @Override
    public int compareTo(Object other) {
        Pair otherpair = (Pair) other;
        if (otherpair.town.equals(town)) {
            return otherpair.point - point;
        }
        return town.compareTo(otherpair.town);
    }
}

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

int main() {
	int n;
	cin >> n;
	int x[n], y[n];
	for(int i = 0; i < n; ++i){
		cin >> x[i];
	}
	for(int i = 0; i < n; ++i){
		cin >> y[i];
	}
	double d = 0.0;
	for(int i = 0; i < n; ++i){
		d += abs(x[i] - y[i]);
	}
	cout << setprecision(10) << d << endl;
	d = 0.0;
	for(int i = 0; i < n; ++i){
		d += (x[i] - y[i]) * (x[i] - y[i]);
	}
	cout << sqrt(d) << endl;
	d = 0.0;
	for(int i = 0; i < n; ++i){
		d += pow(abs(x[i] - y[i]), 3);
	}
	cout << cbrt(d) << endl;
	double m = 0.0;
	for(int i = 0; i < n; ++i){
		if(m < abs(x[i] - y[i])) m = abs(x[i] - y[i]);
	}
	cout << m << endl;
	return 0;
}

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

sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**15
mod = 10**9+7

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


def main():
    h,w = LI()
    a = [[c=='#' for c in S()] for _ in range(h)]

    def search():
        d = collections.defaultdict(lambda: inf)
        s = (0,0)
        d[s] = 1
        q = []
        heapq.heappush(q, (1, s))
        v = collections.defaultdict(bool)
        while len(q):
            k, u = heapq.heappop(q)
            if v[u]:
                continue
            v[u] = True

            for ni,nj in [(0,1),(0,-1),(1,0),(-1,0)]:
                ny = u[0] + ni
                nx = u[1] + nj
                if ny < 0 or ny >= h or nx < 0 or nx >= w:
                    continue
                if v[(ny,nx)] or a[ny][nx]:
                    continue
                uv = (ny,nx)
                vd = k + 1
                if d[uv] > vd:
                    d[uv] = vd
                    heapq.heappush(q, (vd, uv))

        return d

    d = search()
    r = d[(h-1,w-1)]
    if r == inf:
        return -1
    for ai in a:
        for aj in ai:
            if not aj:
                r -= 1

    return -r


print(main())




Measured memory_bytes: 5972