akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Collections.Generic;
using System.Linq;

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            input_iter = LazyLoadAllLines();
            //------------------------------------------------//
            var n = Read<long>();
            //var a = Read<long>();
            //var b = Read<long>();
            //var c = Read<long>();
            //var x = Read<long>();
            //var als = Read<long>(n);

            //als.Sort((l, r) => (int)(r - l));


            if (n == 1)
            {
                Console.WriteLine(1.0);
            }
            else
            {
                if(n % 2 == 1)
                {
                    Console.WriteLine(1.0 * ((n + 1) / 2) / n);
                }
                else
                {
                    Console.WriteLine(0.5);
                }
            }
            
        }



        static IEnumerator<string> input_iter;

        static _T Read<_T>() where _T : struct
        {
            input_iter.MoveNext();
            return (_T)Convert.ChangeType(input_iter.Current, typeof(_T));
        }
        static string Read()
        {
            input_iter.MoveNext();
            return input_iter.Current;
        }
        static List<_T> Read<_T>(long num) where _T : struct { return new List<_T>(Enumerate<_T>(num)); }


        static IEnumerable<_T> Enumerate<_T>(long num)
        {
            for (long i = 0; i < num; ++i)
            {
                input_iter.MoveNext();
                yield return (_T)Convert.ChangeType(input_iter.Current, typeof(_T));
            }
        }
        static IEnumerator<string> LazyLoadAllLines()
        {
            string line;
            do
            {
                line = Console.ReadLine();
                foreach (var s in line.Split(' '))
                    yield return s;
            } while (line != null);
        }
    }
}


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

int main() {
    int a, b, count =0;
    char s[10000] ={};
    std::cin >> a >> b;
    for (int i = a; i < b+1; i++) {
        sprintf(s,"%d",i);
        if(s[0] == s[4] && s[1] == s[3]) count++;
    }
    std::cout << count << std::endl;

    return 0;
}

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

public class Main {
	static long mod = (long) (1e9 + 7);

	public static long facn(long n, long x) {
		long ans = 1;
		for (int i = 1; i <= x; i++) {
			ans *= n;
			ans %= mod;
			n--;
		}
		long k = 1;
		long t = x;
		for (int i = 1; i <= t; i++) {
			k *= x;
			k %= mod;
			x--;
		}
//		BigInteger b = BigInteger.valueOf((k)).modInverse(BigInteger.valueOf((mod)));
		long b=modPow(k, mod-2, mod);
		return ((b%mod)*ans)%mod;

	}

	public static long modInverse(long a, long m) {
		a = a % m;
		for (int x = 1; x < m; x++)
			if ((a * x) % m == 1)
				return x;
		return 1;
	}

	static long modPow(long a, long e, long mod) // O(log e)
	{
		a %= mod;
		long res = 1;
		while (e > 0) {
			if ((e & 1) == 1)
				res = (res * a) % mod;
			a = (a * a) % mod;
			e >>= 1;
		}
		return res%mod;
	}

	public static void main(String[] args) throws IOException {
		Scanner sc = new Scanner(System.in);
		PrintWriter pw = new PrintWriter(System.out);
		// pw=new PrintWriter("C:\\Users\\Hp\\Desktop\\outt.txt");
		long n = sc.nextInt();
		long a = sc.nextInt();
		long b = sc.nextInt();

		pw.print(((modPow(2, n, mod) - 1 -( facn(n, a) + facn(n, b))%mod+100*mod) % mod));
		pw.close();
	}

	public static class Scanner {
		StringTokenizer st;
		BufferedReader br;

		public Scanner(InputStream s) {
			br = new BufferedReader(new InputStreamReader(s));
		}

		public String next() throws IOException {
			while (st == null || !st.hasMoreTokens())
				st = new StringTokenizer(br.readLine());
			return st.nextToken();
		}

		public int nextInt() throws IOException {
			return Integer.parseInt(next());
		}

		public long nextLong() throws IOException {
			return Long.parseLong(next());
		}

		public String nextLine() throws IOException {
			return br.readLine();
		}

		public double nextDouble() throws IOException {
			String x = next();
			StringBuilder sb = new StringBuilder("0");
			double res = 0, f = 1;
			boolean dec = false, neg = false;
			int start = 0;
			if (x.charAt(0) == '-') {
				neg = true;
				start++;
			}
			for (int i = start; i < x.length(); i++)
				if (x.charAt(i) == '.') {
					res = Long.parseLong(sb.toString());
					sb = new StringBuilder("0");
					dec = true;
				} else {
					sb.append(x.charAt(i));
					if (dec)
						f *= 10;
				}
			res += Long.parseLong(sb.toString()) / f;
			return res * (neg ? -1 : 1);
		}

		public boolean ready() throws IOException, IOException {
			return br.ready();
		}

	}
}

Measured memory_bytes: 21584
#include <stdio.h>
int main(){
	int i,n,h[20];
	scanf("%d",&n);
	for(i=0;i<n;i++)	scanf("%d",&h[i]);
	int max=0, ans=0;
	for(i=0;i<n;i++){
		if(max<=h[i]){
			ans++;
			max = h[i];
		}
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
const int inf = 2e9;
int n, mn = inf;

long long ans;

int main()
{
	scanf("%d",&n);
	bool flag = false;
	for(int i=1;i<=n;i++) {
		int A, B;
		scanf("%d%d",&A,&B);
		ans += A;
		if(A > B) {flag = 1; mn = min(mn, B);}
	}
	printf("%lld\n",(flag?ans-mn:0));
}


Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <algorithm>
using namespace std;
int n,l;
string s[110];
int main()
{
	scanf("%d%d",&n,&l);
	for(register int i=1; i<=n; i++) cin>>s[i];
	sort(s+1,s+n+1);
	for(register int i=1; i<=n; i++) cout<<s[i];
	printf("\n");
	return 0;
}

Measured memory_bytes: 256
// URL: https://atcoder.jp/contests/abc132/tasks/abc132_a

import std.algorithm, std.container, std.math, std.range, std.typecons, std.string;

version(unittest) {} else
void main()
{
  string s; io.get(s);
  io.putB(s[0] == s[1] && s[2] == s[3] && s[0] != s[2] ||
	  s[0] == s[2] && s[1] == s[3] && s[0] != s[1] ||
	  s[0] == s[3] && s[1] == s[2] && s[0] != s[1],
	  "Yes", "No");
}

auto io = IO();

struct IO
{
  import std.algorithm, std.conv, std.format, std.range, std.stdio, std.traits;

  dchar[] buf;
  auto sp = (new dchar[](0)).splitter;
  int precision = 10;
  string delimiter = " ";

  void nextLine()
  {
    stdin.readln(buf);
    sp = buf.splitter;
  }

  auto get(T)(ref T v)
  {
    if (sp.empty) nextLine();
    v = sp.front.to!T;
    sp.popFront();
  }

  auto getV(T...)(ref T v)
  {
    foreach (ref w; v) get(w);
  }

  auto getA(T)(size_t n, ref T v)
  {
    v = new T(n);
    foreach (ref w; v) get(w);
  }

  auto getC(T...)(size_t n, ref T v)
  {
    foreach (ref w; v)
      w = new typeof(w)(n);
    foreach (i; 0..n)
      foreach (ref w; v) get(w[i]);
  }

  auto getM(T)(size_t r, size_t c, T v)
  {
    v = new T(r, c);
    foreach (ref w; v) getA(c, w);
  }

  auto putA(T)(T v)
  {
    static if (isInputRange!T && hasLength!T && !isSomeString!T) {
      foreach (i, w; v) {
	putA(w);
	if (i < v.length - 1) write(delimiter);
      }
    } else if (isFloatingPoint!T) {
      writef(format("%%.%df", precision), v);
    } else {
      write(v);
    }
  }

  auto put(T...)(T v)
  {
    foreach (i, w; v) {
      putA(w);
      if (i < v.length - 1) write(delimiter);
    }
    writeln;
  }

  auto putB(S, T)(bool c, S t, T f)
  {
    if (c)
      put(t);
    else
      put(f);
  }

  auto dbg(T...)(T v)
  {
    stderr.writeln(v);
  }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define fi                first
#define se                 second
#define ll               long long
#define mod              1000000007
#define endl              "\n"
#define fast               ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define pb                push_back
#define all(v)             v.begin(),v.end()
#define inp(V,n)      for(int i=0;i<n;i++){cin >> V[i];}
#define oup(V,n)     {for(int i=0;i<n;i++){cout <<  V[i] << " "  ;} cout << endl;}
using namespace std;
ll factorial(ll n)
{
    return (n == 1 || n == 0) ? 1 : n * factorial(n - 1);
}
ll gcd(ll a, ll b)
{
    if (a == 0)
      return b;
    return gcd(b % a, a);
}
ll lcm(ll a, ll b)
{
   return (a*b)/gcd(a, b);
}
bool sortByVal(const pair<double,double> &a,
               const pair<double,double> &b)
{
    if(a.fi==b.fi)
    {
    return (a.se >b.se);
    }
    else
        return (a.fi<b.fi);
}
ll Powb(ll b,ll n)
{
    if(n==0) return 1LL;
    if(n==1) return b;
    ll temp = Powb(b,n/2);
    if(n%2==0){return (temp*temp)%mod;}
    else{return (b*((temp*temp)%mod))%mod;}
}
ll sumofdigit(ll n)
{
    ll c=0,d=0,sum=0,i;
    while(n>0)
    {
        c=n%10;
        sum+=c;
        n/=10;
    }
    return sum;
}
ll fact(ll n)
{
    ll c=1;
    for(ll i=1;i<=n;i++)
    {
        c*=i;
    }
    return c;
}
ll ks(vector<ll> &a,ll k,ll n)
{
     ll dp[n+1][k+1];
    for(ll i=0;i<n+1;i++)
    {
        for(ll j=0;j<k+1;j++)
        {
            if(i==0||j==0)
                dp[i][j]=0;
            else
            {
                if(a[i-1]>j)
                {
                    dp[i][j]=dp[i-1][j];
                }
                else
                {
                    if(dp[i][j-a[i-1]]!=0||j==a[i-1])
                    dp[i][j]=max(dp[i-1][j],(1+dp[i][j-a[i-1]]));
                    else
                    dp[i][j]=dp[i-1][j];
                }
            }
        }
    }
    return dp[n][k];
}
int main()
{
 fast;
     int t=1;
     //cin>>t;
     while(t--)
     {
        ll k=0,n,i=0,j=0,c=0,d=0,e=0,f=0,sum=0,g=0,h=0,maxi=0;
         cin>>n>>k>>c;
         for(i=n;i<=k;i++)
         {
             if(i%c==0)
             {
                 sum++;
             }
         }
         cout<<sum<<endl;

     }
}



Measured memory_bytes: 3600
N,A,B = map(int,input().split())

ans = 0

if abs(A-B)%2 == 0:
    ans = abs(A-B)//2
elif (A-1)>(N-B):##Aのほうが端っこより遠い
    ans = N-B+1+(B-A-1)//2
else:##Bのほうが端っこより遠い
    A = N-A+1
    B = N-B
    ans = N-B+1+(B-A-1)//2

print(int(ans))

Measured memory_bytes: 3064
#include<cstdio>
#include<algorithm>
#include<cstring>
using namespace std;
#define ll long long
ll y,ans;
int main()
{
	scanf("%lld",&y);
	ans=1000*(y/500);
	y=y%500;
	ans+=y/5*5;
	printf("%lld\n",ans);
	return 0;
}



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

import sys

def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def list4d(a, b, c, d, e): return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(N=None): return list(MAP()) if N is None else [INT() for i in range(N)]
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
INF = 10 ** 18
MOD = 10 ** 9 + 7

def build_grid(H, W, intv, _type, space=True, padding=False):
    # 入力がスペース区切りかどうか
    if space:
        _input = lambda: input().split()
    else:
        _input = lambda: input()
    _list = lambda: list(map(_type, _input()))
    # 余白の有無
    if padding:
        offset = 1
    else:
        offset = 0
    grid = list2d(H+offset*2, W+offset*2, intv)
    for i in range(offset, H+offset):
        row = _list()
        for j in range(offset, W+offset):
            grid[i][j] = row[j-offset]
    return grid

H, W, D = MAP()
grid = build_grid(H, W, 0, int)
HW = {}
for i in range(H):
    for j in range(W):
        HW[grid[i][j]-1] = (i, j)

# nxt[k][i] := iからスタートして、2^k回移動した後にいる位置
nxt = list2d(17, H*W, -1)
# cost[k][i] := iからスタートして、2^k回移動した時にかかるコスト
cost = list2d(17, H*W, INF)
for h in range(H):
    for w in range(W):
        cur = grid[h][w] - 1
        if cur + D < H * W:
            h2, w2 = HW[cur+D]
            # 1つ先の移動先とコストを記録
            nxt[0][cur] = cur + D
            cost[0][cur] = abs(h-h2) + abs(w-w2)

# ダブリングのテーブル構築
for k in range(1, 17):
    for i in range(H*W):
        if nxt[k-1][i] == -1:
            continue
        nxt[k][i] = nxt[k-1][nxt[k-1][i]]
        cost[k][i] = cost[k-1][i] + cost[k-1][nxt[k-1][i]]

for i in range(INT()):
    l, r = MAP()
    l -= 1; r -= 1
    cnt = (r - l) // D
    cur = l
    ans = 0
    # cnt回先に進む時のコストを確認
    for k in range(16, -1, -1):
        if cnt & 1<<k:
            ans += cost[k][cur]
            cur = nxt[k][cur]
    print(ans)


Measured memory_bytes: 90460
#include <bits/stdc++.h>
using namespace std;
int main(){
	int a[5];
	for(int i=0;i<5;i++) cin>>a[i];
	sort(a,a+5);
	for(int i=4;i>=0;i--) {
		if(i!=0) cout<<a[i]<<" ";
		else cout<<a[i]<<endl;
	}
	return 0;
}

Measured memory_bytes: 3076
import Data.Bool (bool)
import qualified Data.ByteString as B

main :: IO ()
main = putStr
  =<< solve <$> B.getLine <*> B.getLine

solve :: B.ByteString -> B.ByteString -> String
solve s t = bool "No" "Yes" $ (s `B.isInfixOf`) $ B.concat [t, t]
  


Measured memory_bytes: 380
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define all(c) c.begin(),c.end()
#define pb push_back
#define fs first
#define sc second
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
using namespace std;
template<class S,class T> ostream& operator<<(ostream& o,const pair<S,T> &p){
	return o<<"("<<p.fs<<","<<p.sc<<")";
}
template<class T> ostream& operator<<(ostream& o,const vector<T> &vc){
	o<<"{";
	for(const T& v:vc) o<<v<<",";
	o<<"}";
	return o;
}
using ll = long long;
template<class T> using V = vector<T>;
template<class T> using VV = vector<vector<T>>;
constexpr ll TEN(int n) { return (n == 0) ? 1 : 10 * TEN(n-1); }

#ifdef LOCAL
#define show(x) cerr << "LINE" << __LINE__ << " : " << #x << " = " << (x) << endl
#else
#define show(x) true
#endif

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);		//DON'T USE scanf/printf/puts !!
	cout << fixed << setprecision(20);
	
	ll s;
	cin >> s;
	ll X = TEN(9);
	ll a = (s+X-1)/X;
	ll b = a * X - s;
	cout << 0 << " " << 0 << " " << a << " " << b << " " << 1 << " " << X << endl;
}


Measured memory_bytes: 256
import heapq

N, M = list(map(int, input().split()))
A = list(map(int, input().split()))
for i in range(N):
    A[i] = -A[i]
heapq.heapify(A)

def calc(m):
    if m % 2 == 0:
        return m//2
    else:
        return m//2 + 1

m = heapq.heappop(A)
for _ in range(M-1):
    m = heapq.heappushpop(A, calc(m))

print(-sum(A)-calc(m))


Measured memory_bytes: 72812
//#include<bits/stdc++.h>
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<string>
#include<numeric>
#include<vector>
#include<set>
#include<map>
#include<queue>
using namespace std;


int main(){
  int n;
  cin >> n;
  float p;
  p = (n - n/2)/float(n);
  cout << p << endl;
  return 0;
}


Measured memory_bytes: 256
A, B , H, M = map(int, input().split())
import numpy as np
minute = np.array((B*np.cos(M/60*2*np.pi), B*np.sin(M/60*2*np.pi)))
hour = np.array((A*(np.cos((H/12+M/60/12)*2*np.pi)), A*(np.sin((H/12+M/60/12)*2*np.pi))))
vec = minute - hour
print(np.linalg.norm(vec))

Measured memory_bytes: 27268
import itertools

N=int(input())
P=tuple(map(int,input().split()))
Q=tuple(map(int,input().split()))

P_num=0
Q_num=0

li=[x for x in range(1,N+1)]
A=list(itertools.permutations(li))

for i in range(len(A)):
   if P==A[i]:
      P_num=i+1
   if Q==A[i]:
      Q_num=i+1

print(abs(P_num-Q_num))

Measured memory_bytes: 8052
import sys
input = sys.stdin.readline
import string

N, M = map(int, input().split(' '))
graph = [[] for _ in range(N)]
for _ in range(M):
    a, b = map(int, input().split(' '))
    graph[a-1].append(b-1)
    graph[b-1].append(a-1)
for i in range(N):
    print(len(graph[i]))

Measured memory_bytes: 3772
#include<stdio.h>
int main(void) {
	int W, H, C, z1, z2, z3, z4, G, X;
	scanf("%d %d %d", &W, &H, &C);
	z1 = W*H;
	G = H;
	X = W;
	if (X < G) {
		z2 = X;
		X = G;
		G = z2;
	}
	z3 = X%G;
	while (z3 != 0) {
		X = G;
		G = z3;
		z3 = X%G;
	}
	z4 = (W / G)*(H / G)*C;
	printf("%d\n", z4);
	return 0;
}


Measured memory_bytes: 2100
#include <bits/stdc++.h>
#define maxn 25
using namespace std;
int n, a[maxn],b[maxn],c[maxn];
int main()
{
    scanf("%d",&n);
    for(int i=1;i<=n;i++){
        scanf("%d",&a[i]);
    }
    for(int i=1;i<=n;i++){
        scanf("%d",&b[i]);
    }
    for(int i=1;i<n;i++){
        scanf("%d",&c[i]);
    }
    int res=0;
    for(int i=1;i<=n;i++){
        res+=b[a[i]];
        if(a[i+1]==a[i]+1&&(i+1)<=n){
            res+=c[a[i]];
        }
    }
    printf("%d\n",res);
    return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define rep1(i, s, n) for (int i = s; i <= n; i++)

#define max(a, b) ((a) > (b) ? (a) : (b))
#define min(a, b) ((a) < (b) ? (a) : (b))

int R[200000];

int main()
{
	int n;
	int Rmin, Vmax;

	cin >> n;
	rep(i, n) cin >> R[i];

	Rmin = R[0];
	Vmax = R[1] - R[0];

	rep(i, n - 1) {
		Rmin = min(Rmin, R[i]);
		Vmax = max(Vmax, R[i + 1] - Rmin);
	}

	cout << Vmax << endl;

	return 0;
}



Measured memory_bytes: 3880
#include<bits/stdc++.h>
#define pb push_back
#define int ll
using namespace std;
typedef long long ll;
int32_t main(){
	int n;
  cin >> n;
    vector<pair<int,int> > v;
  for (int i = 0;i < n;i++){
  	int a,b;
    cin >> a >> b;
    v.pb({a+b,b});
  }
  sort(v.rbegin(),v.rend());
	int s1 = 0,s2=  0;
  for (int i = 0;i < n;i++){
  	if (i %2)s2 += v[i].second;
    else s1 += v[i].first - v[i].second;
  }
  cout << s1 - s2 << endl;
}

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

int main(){
  int n,count=0;
  char s[30001];
  scanf("%d",&n);
  scanf("%s",s);

  for(int i=0;i<1000;i++){  
    int c[3]={i/100,(i/10)%10,i%10};
    int f=0;
    for(int j=0;j<n;j++){
      if(c[f]==(s[j]-'0')){
        f++;
        if(f==3){
          count++;
          break;
        }
      }
    }
  }
  printf("%d",count);
  return 0;
}


Measured memory_bytes: 384
def main():
    N, D = map(int, input().split())
    counter = 0
    D = D**2

    for i in range(N):
        X, Y = map(int, input().split())
        distance = X**2 + Y**2

        if D >= distance:
            counter += 1

    print(counter)


if __name__ == "__main__":
    main()

Measured memory_bytes: 9192
import sys
S=list(input())
a=S[0::2]
b=S[1::2]


A=['R','U','D']
B=['L','U','D']
for i in a:
    if i in A:
        continue
    else:
        print('No')
        sys.exit()
for i in b:
    if i in B:
        continue
    else:
        print('No')
        sys.exit()
else:
    print('Yes')

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

using namespace std; 

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef vector<PII> VPII;
typedef long long LL;
typedef priority_queue<int> PQ_DESC;
typedef priority_queue<int, vector<int>, greater<int>> PQ_ASC;
typedef priority_queue<PII> PQ_DESC_PII;
typedef priority_queue<PII, vector<PII>, greater<PII>> PQ_ASC_PII;

#define ALL(c) (c).begin(),(c).end()
#define PB push_back
#define MP make_pair
#define SORT_ASC(c) sort(ALL(c))
#define SORT_DESC(c) sort(ALL(c), greater<typeof(*((c).begin()))>())
#define SIZE(a) int((a).size())

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define ROF(i,a,b) for(int i=(b-1);i>=(a);--i)
#define REP(i,n) FOR(i,0,n)
#define REP(i,n) FOR(i,0,n)
#define PER(i,n) ROF(i,0,n)

const double EPS = 1e-10;
const double PI  = acos(-1.0);
const int LARGE_INT = 1e9+100;
const int INF = 2e9+100;

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

void Main()
{
	int a,b;
	cin >> a >> b;
	cout << max(0,a-2*b) << endl;

	return;
}

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

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main (){
  int n,m;
  cin >> n >> m;
  if(abs(n-m)>=2){
    cout<<"0"<<endl;
    return 0;
  }
  ll ans=1;
  for(int i=1;i<=n;i++){
    ans*=i;
    ans%=1000000007;
  }
  for(int i=1;i<=m;i++){
    ans*=i;
    ans%=1000000007;
  }
  if(n==m) ans *= 2;
  ans%=1000000007;
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

class Main {
    static Scanner IN = new Scanner(System.in);
    public static void main(String... args) {        
        int N = IN.nextInt();
        int K = IN.nextInt();
        int[] x = new int[N];
        for (int i = 0; i < N; i++) {
            x[i] = IN.nextInt();
        }
        int ans = Integer.MAX_VALUE;
        int j;
        int dist;
        for (int i = 0; i <= N - K; i++) {
            j = i + K - 1;
            if (x[j] <= 0) {
                ans = Math.min(ans, -x[i]);
            } else if (0 <= x[i]) {
                ans = Math.min(ans, x[j]);
            } else {
                dist = Math.min(Math.abs(x[i]), x[j]);
                ans = Math.min(ans, x[j] - x[i] + dist);
            }
        }
        System.out.println(ans);
    }
}

Measured memory_bytes: 49936
#include <iostream>
#include <vector>

using namespace std;
typedef pair<int, int> P;

void solve()
{
	int L;
	while(cin >> L, L)
	{
		vector<P> Vec(12);
		for(int i = 0; i < 12; ++i)
		{
			cin >> Vec[i].first >> Vec[i].second;			
		}
		int sum = 0;
		for(int i = 0; i < 12; ++i)
		{
			sum += Vec[i].first - Vec[i].second;
			if(sum >= L)
			{
				cout << i + 1 << endl;
				goto NEXT;
			}
		}
		cout << "NA" << endl;
NEXT:
		;
	}
}

int main()
{
	solve();
	return(0);
}

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

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

  for (int i=0; i<N; i++) {
      string col;
      cin >> col;

      if (col == "Y") {
          cout << "Four" << endl;
          break;
      }

      else if (i == N-1) {
          cout << "Three" << endl;
      }
   }
}

Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<cassert>
#include<math.h>
#include<complex>
#include<algorithm>
#include<utility>
#include<queue>
#include<string.h>
#include<string>
#include<set>
#include<map>
#include<unordered_map>
#include<functional>
#include<vector>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
const ll INF=2e18;
const ll MOD=1e9+7;

ll H,W;
unordered_map<char,ll> mp;
int main(){
    cin>>H>>W;
    for(ll i=0;i<H;i++){
        string s;
        cin>>s;
        for(auto c:s){
            mp[c]++;
        }
    }
    ll oneCnt=0;
    ll twoCnt=0;
    if(H%2==1)twoCnt+=W/2;
    if(W%2==1)twoCnt+=H/2;
    if(H%2==1 && W%2==1)oneCnt++;
    for(auto p:mp){
        ll n=p.second;
        if(n%4==2)twoCnt--;
        if(n%2==1)oneCnt--;
    }
    if(twoCnt>=0 && oneCnt >=0){
        cout<<"Yes";
        return 0;
    }
    cout<<"No";
    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <vector>
#include <algorithm>
#include <climits>

using namespace std;

// 最大公約数を求める (ユークリッドの互除法)  O(log n)
int gcd(int a, int b) {
    return b != 0 ? gcd(b, a % b) : a;
}

// 最小公倍数(LCM) O(log n)
int lcm(int a, int b) {
    return a * b / gcd(a, b);
}

int main(void)
{
    int n, x;
    cin >>n >>x;

    vector<int> cities;
    cities.push_back(x);
    for(int i = 0; i < n; i++){
        int tmp;
        cin >>tmp;
        cities.push_back(tmp);
    }

    sort(cities.begin(), cities.end());

    int mindiff = cities[1] - cities[0];
    for(int i = 0; i < n; i++){
        mindiff = gcd(mindiff, cities[i+1] - cities[i]);
    }

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

    return 0;
}

Measured memory_bytes: 892
#include <cstdio>
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#define rep(i, n) for(int i = 0; i < n; i++)
using namespace std;

typedef long long ll;

int table[15][15];

int main(void)
{
    rep(i, 15)
    {
        rep(j, 15)
        {
            table[i][j] = -1;
        }
    }

    int n;
    cin >> n;

    rep(i, n){
        int a;
        cin >> a;
        rep(j, a)
        {
            int x, y;
            cin >> x >> y;
            x--;
            table[i][x] = y;
        }
    }

    int ans = 0;

    rep(i, 1<<n)
    {
        bool flag = true;
        rep(j, n){
            if(i>>j&1)
            {
                rep(k, n){
                    if(table[j][k] == -1) continue;
                    if(table[j][k] != (i>>k&1)){
                        flag = false;
                        break;
                    }
                }
            }
        }
        if(flag) ans = max(ans, __builtin_popcount(i));
    }

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

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

using vvc = vector<vector<char>>;
using vpii = vector<pair<int, int>>;

vpii next_step(vpii const& step, vvc& a) {
    int const h = a.size(), w = a.front().size();
    int const d[][2] = { -1, 0, 1, 0, 0, -1, 0, 1 };
    vpii r;
    for (auto const& x : step) {
        for (auto const& y : d) {
            int i = x.first + y[0], j = x.second + y[1];
            if (a[i][j] == '.') {
                a[i][j] = '#';
                r.emplace_back(i, j);
            }
        }
    }
    return r;
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);

    int h, w;
    cin >> h >> w;
    vvc a(h + 2);
    vpii step;
    int i = 0;
    a[i].assign(w + 2, '#');
    for (i++; i <= h; i++) {
        a[i].assign(w + 2, '#');
        for (int j = 1; j <= w; j++) {
            cin >> a[i][j];
            if (a[i][j] == '#')
                step.emplace_back(i, j);
        }
    }
    a[i].assign(w + 2, '#');

    int n = h * w - step.size();
    int ans = 0;
    while (n > 0) {
        ans++;
        step = next_step(step, a);
        n -= step.size();
    }

    cout << ans << '\n';

    return 0;
}


Measured memory_bytes: 14824
def isp(s):
    t=s[::-1]
    if s==t:
        return 1
    return 0

s=input()
n=len(s)

if isp(s) and isp(s[:(n-1)//2]) and isp(s[(n+3)//2-1:]):
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3060
import java.io.*
import java.util.*
import java.lang.*
import java.lang.Math.*


fun solve() {
    val S = rd.readString()
    val N = S.length
    
    val zeroPos = ArrayList<Int>()
    if (S[0] == '<') zeroPos.add(0)
    var idx = S.indexOf("><")
    while (idx>=0) {
        zeroPos.add(idx+1)
        idx = S.indexOf("><", idx+1)
    }

    if (S[N-1] == '>') zeroPos.add(N)

    val A = LongArray(N+1){0}

    var v = 0L
    for (i in zeroPos.first() downTo 0) {
        A[i] = v++
    }
    for (i in 0 until zeroPos.size-1) {
        val l = zeroPos[i]
        val r = zeroPos[i+1]
        v = 1L
        for (j in l until r) {
            if (S[j] == '<') A[j+1] = v++
        }
        v = 1L
        for (j in r downTo l+1) {
            if (S[j-1] == '>' && v > A[j-1]) A[j-1] = v++
        }
    }
    v = 0L
    for (i in zeroPos.last() until N+1) {
        A[i] = v++
    }

    val ans = A.sum()
    println(ans)
}


//val rd = debug.Reader("agc", "040", "a", "sample-1")
val rd = Reader()


fun main(args: Array<String>) {
    try {
        var exception: Throwable? = null
        val sth = Thread(null, SolveThread(), "solveThread", 128 * 1024 * 1024)
        sth.setUncaughtExceptionHandler { _, e -> exception = e }
        sth.start(); sth.join()
        if (exception != null) throw exception!! }
    catch (e: Exception) { throw e }
    finally { rd.close() }
}
const val MOD = 1_000_000_007L; const val INF = Int.MAX_VALUE/2; const val LINF = Long.MAX_VALUE/2
data class IntPair(val first: Int, val second: Int)
val errPrintln: (Any) -> Unit = { msg -> System.err.println(msg) }
fun rAssert(exp: Boolean, lazyMsg: () -> String = {""}) {
    if (!exp) { val msg = lazyMsg(); errPrintln("EAssert Error: $msg"); throw Error(msg) }
}
fun tAssert(exp: Boolean, lazyMsg: () -> String = {""}) {
    if (!exp) { val msg = lazyMsg(); errPrintln("TAssert Error: $msg"); Thread.sleep(3000) }
}
class SolveThread : Runnable {
    override fun run() { solve() }
}
class Reader {
    private val br = BufferedReader(InputStreamReader(System.`in`))
    val readString: () -> String = { br.readLine() }
    val readInt: () -> Int = { br.readLine().toInt() }
    val readLong: () -> Long = { br.readLine().toLong() }
    val readIntArray: () -> IntArray = { br.readLine().split(' ').map { it.toInt() }.toIntArray() }
    val readLongArray: () -> LongArray = { br.readLine().split(' ').map { it.toLong() }.toLongArray() }
    val readListInt: () -> List<Int> = { br.readLine().split(' ').map { it.toInt() } }
    val readListLong: () -> List<Long> = { br.readLine().split(' ').map { it.toLong() } }
    val readListIntCol: (Int) -> List<Int> = { N -> (0 until N).map { readInt() } }
    val readListIntCols: (Int) -> List<List<Int>> = { N -> (0 until N).map { br.readLine().split(' ').map { it.toInt() } } }
    val readListLongCol: (Int) -> List<Long> = { N -> (0 until N).map { readLong() } }
    val readListLongCols: (Int) -> List<List<Long>> = { N -> (0 until N).map { br.readLine().split(' ').map { it.toLong() } } }
    val close: () -> Unit = { br.close() }
    protected fun finalize() { close() }
}


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

int cannot[110][110];
int main(){
	int H,W;
	cin >> H >> W;
	for(int i = 1 ; i <= H ; i++){
		for(int j = 1 ; j <= W ; j++){
			char c;
			cin >> c;
			if( c == 'o' ){
				cannot[i][j-1] = true;
				cannot[i][j] = true;
				cannot[i][j+1] = true;
			}else if( c == 'x'){
				cannot[i][j-1] = true;
				cannot[i][j] = true;
				cannot[i][j+1] = true;
				cannot[i-1][j-1] = true;
				cannot[i-1][j] = true;
				cannot[i-1][j+1] = true;
				cannot[i+1][j-1] = true;
				cannot[i+1][j] = true;
				cannot[i+1][j+1] = true;	
			}
		}
	}
	int cnt = 0;
	for(int i = 2 ; i <= H ; i++){
		for(int j = 1 ; j <= W ; j++){
			if( cannot[i][j] == false ){
				cnt++;
			}
		}
	}
	cout << cnt << endl;
}

Measured memory_bytes: 1208
#include<bits/stdc++.h>
using namespace std;
#define endl '\n'
#define f first
#define s second
#define int long long
#define pb push_back
#define pencho ios_base::sync_with_stdio(false);cin.tie(NULL);
#define N 100005

int dp[N] = {0};
vector<int>adj[N];


int solveDp(int x) {
       if (dp[x] != -1)  return dp[x];
       dp[x] = 0;
       for (auto i : adj[x])   dp[x] = max(1 + solveDp(i), dp[x]);
       return dp[x];
}


void solve() {
       pencho
       int n, m;     cin >> n >> m;
       memset(dp, -1, sizeof(dp));
       for (int i = 1; i <= m; i++) {
              int x, y;      cin >> x >> y;
              adj[x].pb(y);
       }
       for (int i = 1; i <= n; i++)       if (dp[i] == -1)  dp[i] = solveDp(i);
       int ans = 0;
       for (int i = 1; i <= n; i++)       ans = max(ans, dp[i]);
       cout << ans << endl;
}


signed main()
{
#ifndef ONLINE_JUDGE
       freopen("input.txt", "r", stdin);
       freopen("o.txt", "w", stdout);
#endif

       solve();
}

Measured memory_bytes: 11892
#include <iostream>

int main()
{
    bool flag = true;
    bool *ans_array;
    int size, i, count, j;
    std::cin >> size;

    int *array = new int[size];
    ans_array = new bool[size];

    for(i = 0;i < size;++i)
    {
        std::cin >> array[i];

        if((i + 1) != array[i])
        {
            /*
             * 一致していない
             */
            ans_array[i] = true;
        }else{
            ans_array[i] = false;
        }

    }

    for(i = 0, count = 0;i < size - 1;++i)
    {
        if(!ans_array[i] && !ans_array[i + 1])
        {
            ++count;
            ans_array[i] = true;
            ans_array[i + 1] = true;
        }
    }

    for(i = 0;i < size;++i)
    {
        if(!ans_array[i])
        {
            ++count;
        }
    }

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

    return 0;

}

Measured memory_bytes: 768
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include <numeric>
using namespace std;

#define rep(i, b, e) for(i = b; i < e; ++i)
#define ull unsigned long long int

int main() {

    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, k;
    cin >> n >> k;
    int i, h, ans = 0;
    rep (i, 0, n) {
      cin >> h;
      if (h >= k) ++ans;
    }

    cout << ans << endl;
    

    return 0;
}
 

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

int main() {

  int N, K; cin >> N >> K;
  string S; cin >> S;
  if (S.at(K-1) == 'A') {
    S.at(K-1) = 'a';
  }
  else if (S.at(K-1) == 'B') {
    S.at(K-1) = 'b';
  }
  else {
    S.at(K-1) = 'c';
  }
  cout << S <<endl;
    
}


Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include <bits/stdc++.h>
#include <random>
using namespace std;
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define sz(x) ((int)(x).size())
typedef vector<int> vi;
typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef double db;
mt19937 mrand(random_device{}());
const ll mod = 1000000007;
int rnd(int x) { return mrand() % x; }
ll powmod(ll a, ll b) { ll res = 1; a %= mod; assert(b >= 0); for (; b; b >>= 1) { if (b & 1)res = res * a % mod; a = a * a % mod; }return res; }
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }

static uint MD = mod;
struct ModInt {
	using M = ModInt;
	uint v;
	ModInt(ll _v = 0) { set_v(uint(_v % MD + MD)); }
	M& set_v(uint _v)
	{
        v = (_v < MD) ? _v : _v - MD;
        return *this;
	}
	explicit operator bool() const { return v != 0; }
	M operator-() const { return M() - *this; }
	M operator+(const M& r) const { return M().set_v(v + r.v); }
	M operator-(const M& r) const { return M().set_v(v + MD - r.v); }
	M operator*(const M& r) const { return M().set_v(uint(ull(v) * r.v % MD)); }
	M operator/(const M& r) const { return *this * r.inv(); }
	M& operator+=(const M& r) { return *this = *this + r; }
	M& operator-=(const M& r) { return *this = *this - r; }
	M& operator*=(const M& r) { return *this = *this * r; }
	M& operator/=(const M& r) { return *this = *this / r; }
	bool operator==(const M& r) const { return v == r.v; }
	M pow(ll n) const
    {
        M x = *this, r = 1;
        while (n) {
            if (n & 1) r *= x;
            x *= x;
            n >>= 1;
        }
        return r;
    }
	M inv() const { return pow(MD - 2); }
	friend ostream& operator<<(ostream& os, const M& r) { return os << r.v; }
};
using Mint = ModInt;
//head

int main()
{
    ios::sync_with_stdio(false);
#ifdef RG
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout); 
#endif
	ll n, k;
	cin >> n >> k;
	ll t = n % k;
	cout << (t < k - t ? t : k - t) << endl;
    return 0;
}


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

int main(void) {
    int a;
    int b;
    int c;
    int d;
    int ab;
    int bc;
    int ac;
    
    scanf("%d %d %d %d",&a, &b, &c, &d);

    ab = a-b;
    bc = b-c;
    ac = a-c;
    
    if ((abs(ab) <= d && abs(bc) <= d) || abs(ac) <= d) {
        printf("Yes");
    } else {
        printf("No");
    }
    
    return 0;
    
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
const ll mod = 1000000007;
const ll INF = 1001001001;
const ll LINF = 1001001001001001001;

void prvec(vector<ll> vec){
    ll n = vec.size();
    rep(i,n) cout << i << " " << vec.at(i) << "\n";
}

void pr2d(vector<vector<ll>> vvec){
    ll h = vvec.size();
    ll w = vvec.at(0).size();
    rep(i,h){
        rep(j,w){
            cout << vvec.at(i).at(j) << " ";
        }
        cout << "\n";
    }
}

ll n , k , sum;
vector<ll> a;

ll times(ll x){ //xが作りたい長さ
    ll ret = 0;
    rep(i,n){
        ret += a.at(i)/x;
        if(a.at(i)%x==0) ret--;
    }
    return ret;
}

int main(){
    cin >> n >> k;
    a.resize(n);
    sum = 0;
    rep(i,n){
        cin >> a.at(i);
        sum += a.at(i);
    }
    sort(a.begin(),a.end());

    ll left = 1, right = a.at(n-1); //left=1を作るために必要なcut回数がsat rightを作るために必要な回数は0

    ll sat = sum - n;
    if(k>=sat){
        cout << 1 << endl;
        return 0;
    }else if(k==0){
        cout << a.at(n-1) << endl;
        return 0;
    }

    //xを作るために必要なcut回数を計算し、Kとの大小を比較する
    ll c = (left+right)/2;
    while(right-left>1){
        if(times(c)>k){
            left = c;
        }else{
            right = c;
        }
        c = (left+right)/2;
      	//cout << left << " " << c << " " << right << endl;
    }

    cout << right << endl;
	return 0;
}

Measured memory_bytes: 4776
#include <iostream>
#include <queue>
#include <string>
using namespace std;
int main()
{
	int N,q;
	cin >> N >> q;
	queue<string> S;
	queue<int> A;
	string tempS;
	int tempA;
	for (int i = 0; i < N; ++i)
	{
		cin >> tempS >> tempA;
		S.push(tempS);
		A.push(tempA);
	}

	int time = 0; //現在の時間

	while(S.size() != 0)
	{
		if (A.front() <= q)
		{
			time += A.front();
			A.pop();
			cout << S.front() << " " << time << endl;
			S.pop();
		}
		else
		{
			time += q;
			A.push(A.front() - q);
			A.pop();
			S.push(S.front());
			S.pop();
		}
	}
	return 0;
}


Measured memory_bytes: 5860
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
using namespace std;

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

	int n;
	cin >> n;
	int gr = n / 3;
	cout << gr << "\n";
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;
const ll MOD = 1000000007;
const int IINF = INT_MAX;
const ll LLINF = LLONG_MAX;
const int MAX_N = int(1e5 + 5);
const double EPS = 1e-8;
const int di[] = {0, 1, 0, -1}, dj[] = {1, 0, -1, 0};
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define SORT(v) sort((v).begin(), (v).end())
#define ALL(v) (v).begin(), (v).end()

int main() {
    ll cnt=0, ans=0;
    string s;
    cin >> s;
    REP(i,s.size()-1){
        if(s[i]=='B' && s[i+1]=='W'){
            ans += i-cnt+1;
            cnt++;
            s[i+1]='B';
        }
        else if(s[i]=='W')cnt++;
    }
    cout << ans << endl;
    return 0;
}


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

using namespace std;
#define ll long long

#define rep(i, a) for (int i = 0; i < (int) (a); i++)
#define reps(i, a, b) for (int i = (int) (a); i < (int) (b); i++)
#define rrep(i, a) for (int i = (int) a-1; i >= 0; i--)
#define rreps(i, a, b) for (int i = (int) (a)-1; i >= (int) (b); i--)
#define MP(a, b) make_pair((a), (b))
#define PB(a) push_back((a))
#define all(v) (v).begin(), (v).end()
#define PRINT(f) if((f)){cout << (TRUE__) << endl;}else{cout << FALSE__ << endl;}
#define TRUE__ "Yes"
#define FALSE__ "No"
#define PERM(v) next_permutation(all(v))
#define UNIQUE(v) sort(all(v));(v).erase(unique(all(v)), v.end())
#define CIN(type, x) type x;cin >> x

#ifdef LOCAL
#define lcout(a) cout << a;
#define lcoutln(a) cout << a << endl;
#define lcerr(a) cerr << a;
#define lcerrln(a) cerr << a << endl;
#else
#define lcout(a) 
#define lcoutln(a) 
#define lcerr(a) 
#define lcerrln(a) 
#endif

ll sum[4][110];
ll val[4][110];
int cnt[4];
int N, W;
ll w1;

signed main()
{
	cin >> N >> W;
	CIN(int, a);
	CIN(int, b);
	val[0][0] = b;
	cnt[0]++;
	w1 = a;
	rep(i, N-1) {
		cin >> a >> b;
		val[a-w1][cnt[a-w1]] = b;
		cnt[a-w1]++;
	}
	sort(&val[0][0], &val[0][cnt[0]], greater<ll>());
	sort(&val[1][0], &val[1][cnt[1]], greater<ll>());
	sort(&val[2][0], &val[2][cnt[2]], greater<ll>());
	sort(&val[3][0], &val[3][cnt[3]], greater<ll>());
	rep(i, 4) {
		rep(j, cnt[i]) {
			sum[i][j+1] = sum[i][j] + val[i][j];
		}
	}
	ll res = 0;
	rep(i, cnt[0]+1) rep(j, cnt[1]+1) rep(k, cnt[2]+1) rep(l, cnt[3]+1) {
		if (i * w1 + j * (w1+1) + k * (w1+2) + l * (w1+3) <= W) {
			res = max(res, sum[0][i] + sum[1][j] + sum[2][k] + sum[3][l]);
		}
	}
	cout << res << endl;
}



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

namespace Practice
{
    class Program
    {
        static void Main(string[] args)
        {
            Solve();
        }
        private const long MOD = 1000000007;

        static void Solve()
        {
            string a = Console.ReadLine();
            string b = Console.ReadLine();
            string ans = null;
            if (a == b)
            {
                ans = "EQUAL";
            }
            else if (a.Length > b.Length)
            {
                ans = "GREATER";
            }
            else if (a.Length < b.Length)
            {
                ans = "LESS";
            }
            else
            {
                for(int i=0;i<a.Length;++i)
                {
                    if( a[i] > b[i])
                    {
                        ans = "GREATER";
                        break;
                    }else if( a[i] < b[i])
                    {
                        ans = "LESS";
                        break;
                    }
                }
            }
            Console.WriteLine(ans);
        }

        #region よく使う便利関数
        private static bool isPrime(long x)
        {
            if (x == 2) { return true; }
            if (x < 2 || x % 2 == 0) { return false; }
            long i = 3;
            while (i * i <= x)
            {
                if (x % i == 0) { return false; }
                i = i + 2;
            }
            return true;
        }
        private static long lcm(long x, long y)
        {
            return x / gcd(x, y) * y;
        }
        private static long gcd(long x, long y)
        {
            return y > 0 ? gcd(y, x % y) : x;
        }
        private static long pow(long x, long n)
        {
            if (n == 0) { return 1; }
            long res = pow(x * x % MOD, n / 2);
            if (n % 2 == 1)
            {
                res = res * x % MOD;
            }
            return res;
        }
        private static int ReadAndParseInt()
        {
            return int.Parse(Console.ReadLine());
        }
        private static int[] ReadAndParseIntArr()
        {
            return Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);
        }
        private static long ReadAndParseLong()
        {
            return long.Parse(Console.ReadLine());
        }
        private static long[] ReadAndParseLongArr()
        {
            return Array.ConvertAll(Console.ReadLine().Split(' '), long.Parse);
        }
        #endregion
    }
}

Measured memory_bytes: 11092
import sys

n, g, *pc = map(int, sys.stdin.read().split())
p, c = pc[::2], pc[1::2]

def main():
    res = float('inf')
    for i in range(1 << n):
        tot = 0
        cnt = 0
        for j in range(n):
            if i >> j & 1:
                cnt += p[j]
                tot += 100 * (j + 1) * p[j] + c[j]
            else:
                k = j
        if tot >= g: res = min(res, cnt); continue
        d = (g - tot + 100 * (k + 1) - 1) // (100 * (k + 1))
        if d < p[k]: res = min(res, cnt + d)
    print(res)

if __name__ ==  '__main__':
    main()

Measured memory_bytes: 3064
#include <iostream>

using namespace std;

int main()
{
    string s;

    cin >> s;

    string ans;

    for (int i = 0; i < s.length() - 1; i++)
    {
        if (s[i] == s[i + 1])
        {
            ans = "Bad";
            break;
        }
        else
        {
            ans = "Good";
        }
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
//http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=1167&lang=jp
//https://onlinejudge.u-aizu.ac.jp/problems/1167
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0;i<int(N);++i)
#define rep1(i,N) for(int i=1;i<int(N);++i)
#define all(a) (a).begin(),(a).end()
#define print(v) { cerr<<#v<<": [ "; for(auto _ : v) cerr<<_<<", "; cerr<<"]"<<endl; }
#define printpair(v) { cerr<<#v<<": [ "; for(auto _ : v) cerr<<"{"<<_.first<<","<<_.second<<"}"<<", "; cerr<<"]"<<endl; }
#define bit(k) (1LL<<(k))
typedef long long ll;

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 int INF = 1e9;
const ll INFLL = 1e18;
const ll MOD = 1e9+7;
const double PI = acos(-1.0);

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

/*------------------------------------/
for library*/

/*------------------------------------*/
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(20);
    vector<ll> dp(1000005,INF);
    vector<ll> dp2(1000005,INF);
    dp[0] = dp2[0] = 0;
    for(int i = 1; i <=1000000;i++){
        for(int j = 1;;j++){
            int num = (j * (j + 1) * (j + 2))/6;
            if(i-num < 0)break;
            chmin(dp[i],dp[i-num] + 1);
            if(num % 2 == 1){
                chmin(dp2[i],dp2[i-num] + 1);
            }
        }
    }
    while(1){
        int N;
        cin>>N;
        if(N == 0)break;
        cout<<dp[N]<<" "<<dp2[N]<<endl;
    }
    return 0;
}



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

int main() {
  int N;
  cin >> N;
  map<char,long long> mp;
  for (int i = 0;i < N; i++) {
    string s;
    cin >> s;
    char a = s.at(0);
    if ((a == 'M') || (a=='A') || (a=='R') || (a=='C') || (a=='H')) {
      mp[a]++;
    }
  }
  long long ans = 0;
  ans += mp['M']*mp['A']*mp['R'];
  ans += mp['M']*mp['A']*mp['C'];
  ans += mp['M']*mp['A']*mp['H'];
  ans += mp['M']*mp['R']*mp['C'];
  ans += mp['M']*mp['R']*mp['H'];
  ans += mp['M']*mp['C']*mp['H'];
  ans += mp['A']*mp['R']*mp['C'];
  ans += mp['A']*mp['R']*mp['H'];
  ans += mp['A']*mp['C']*mp['H'];
  ans += mp['R']*mp['C']*mp['H'];
  cout << ans << endl;

  
}


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

/************************** definations *******************************/
#define pi              2*acos(0.0)
#define ll              long long int
#define sc(a)           scanf("%d",&a)
#define scc(a,b)        scanf("%d %d",&a,&b)
#define sc1(a)          scanf("%lld",&a)
#define sc2(a,b)        scanf("%lld %lld",&a,&b)
#define pf1(a)          printf("%lld\n",a)
#define pf2(a,b)        printf("%lld %lld\n",a,b)
#define Case(a)         printf("Case %d: ",a)
#define Casel(a)        printf("Case %lld: ",a)
#define mem(a,x)        memset(a,x,sizeof(a))
#define INF             1e9
#define INFL            1e18
#define XX              first
#define YY              second
#define PB              push_back
#define MP              make_pair
#define NL              cout << endl;
#define DONE            cerr << "Done" << endl
#define PAUSE           system("pause")
#define DEBUG(x)        cerr << #x << " = " << x << endl
#define READ            freopen("alu.txt", "r", stdin)
#define WRITE           freopen("vorta.txt", "w", stdout)
#define FASTIO          ios_base::sync_with_stdio(false);cin.tie(NULL)
#define M               10000007
#define mod             100000007
#define Mod             1000000007
#define MAX             1001
/************************** definations *******************************/

/*int edg[MAX][MAX],color[MAX][MAX],cost[MAX][MAX],x,y;
int fx[]={-1,0,0,1};
int fy[]={0,-1,1,0};
char grid[40][100];
int vis[MAX][MAX];
void bfs(int s, int d){
    queue<int> q; int ux,uy,vx,vy,i;
    q.push(s); q.push(d);
    color[s][d] = 1;
    cost[s][d] = 0;
    while(!q.empty()){
        ux=q.front(); q.pop();
        uy=q.front(); q.pop();
        for(i=0;i<4;i++){
            vx = ux + fx[i];
            vy = uy + fy[i];
            if(vx>=0 && vx<=x && vy>=0 && vy<=y && !edg[vx][vy]){
                if(!color[vx][vy] && !cost[vx][vy]){
                    cost[vx][vy] = cost[ux][uy] + 1;
                    color[vx][vy] = 1;
                    q.push(vx); q.push(vy);
                }
            }
        }
    }
}

void dfs(int x, int y, char c){
    if(vis[x][y]) return;
    if(grid[x][y]=='X') return;
    vis[x][y] = 1;
    grid[x][y] = c;
    for(int i=0;i<4;i++) dfs(x+fx[i],y+fy[i],c);
}*/
//int a[110];
int main()
{
    int a,b;
    cin >> a;
    for(int i=1;i<10;i++){
        if(a%i==0) 
        {
            b = a/i;
            if(b<=9 && b>=1) {
                cout << "Yes";
                return 0;
            }
        } 
    }
    cout << "No";
}

Measured memory_bytes: 256