akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define rep(i,n)for(int i=0;i<n;i++)
using namespace std;

string dir[]{ "',.!?","abcABC","defDEF","ghiGHI","jklJKL","mnoMNO","pqrsPQRS","tuvTUV","wxyzWXYZ" };
int main() {
	string s;
	while (cin >> s) {
		int cnt = -1;
		string ans;
		rep(i, s.size()) {
			if (i&&s[i] == '0'&&s[i - 1] == '0')ans += ' ';
			if (i&&s[i] != s[i - 1]) {
				if (~cnt&&s[i - 1] != '0')
					ans += dir[s[i - 1] - '1'][cnt%dir[s[i - 1] - '1'].size()];
				cnt = -1;
			}
			if (s[i] != '0')cnt++;
		}
		if (~cnt)
			ans += dir[*s.rbegin() - '1'][cnt%dir[*s.rbegin() - '1'].size()];
		cout << ans << endl;
	}
}

Measured memory_bytes: 3124
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; i++)
#define rrep(i, n) for (int i = n - 1; i >= 0; i--)
using namespace std;
using Graph = vector<vector<int>>;
typedef long long ll;
typedef pair<long long,int> P;

int gcd(int a, int b) {
    if (b==0) return a;
    else return gcd(b, a%b);
}

int main(){
    int k;
    ll ans = 0;
    cin >> k;
    rep(i, k){
        rep(j, k){
            rep(l, k){
                ans += gcd(gcd(i+1,j+1), l+1);
            }
        }
    }
    cout << ans << endl;

    return 0;
}

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

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

    if(n%2!=0){
        cout<<0<<endl;
        return 0;
    }

    vector<int> d(n);
    for(int i=0; i<n; i++){
        cin>>d.at(i);
    }
    sort(d.begin(),d.end());

    if(d.at((n/2)-1)==d.at(n/2)){
        cout<<0<<endl;
        return 0;
    }

    else{
        cout<<d.at(n/2)-d.at((n/2)-1)<<endl;
    }

}


Measured memory_bytes: 640
m = list(map(int,input().split()))
l = [list(map(int,input().split())) for i in range(m[0])]

from itertools import combinations
import math

k =list(combinations(l,2))

c=0
for i in range(len(k)):
      dis = 0
      for x in range(m[1]):
          dis = dis + (k[i][0][x] - k[i][1][x])**2
      dis = math.sqrt(dis)
      if dis == int(dis):
          c=c+1
      else:
          c=c      
print(c)
          

Measured memory_bytes: 3064
#include<bits/stdc++.h>
#include<iostream>
#include<cstdio>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
using namespace std;
#define rep(i,x) for(ll i = 0; i < (ll)(x); i++)
#define pb push_back
#define eb emplace_back
#define debug(x) cerr << #x << ": " << (x) << "\n";
#define all(x) (x).begin(), (x).end()
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<ll,ll> Pll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef vector<vector<vector<ll>>> vvvl;
const ll INF = numeric_limits<ll>::max()/4;
const ll MOD = 1e9+7;
const int n_max = 1e5+10;

int main(){
    vector<ll> a(3);
    rep(i,3) cin >> a[i];
    sort(all(a));
    ll ans = 0;
    ll temp = a[2] * 2 - a[0] - a[1];
    if(temp%2 == 0)ans = temp/2;
    else ans = ans = temp/2 + 2;
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int dx[] = {1, 0, -1, 0}, dy[] = {0, 1, 0, -1};
using pii = pair<int, int>;
int main() {
  int k;
  cin >> k;

  // an+1 = 10an + 7 (mod k)

  int temp = 7;
  for (int i = 0; i < k; i++) {
    if (temp % k == 0) {
      cout << i + 1 << endl;
      return 0;
    }
    temp = (temp * 10 + 7) % k;
  }

  cout << -1 << endl;
}

Measured memory_bytes: 3592
#include <iostream>
#include <vector>
#include <bitset>
#include <string>
#include <array>
#include <random>
#include <chrono>
#include <algorithm>

std::vector<std::vector<int>> edges;
std::vector<int> idx;
std::vector<int64_t> cluster_size;
void set(int node, int i){
	if(idx[node] == i)return;
	idx[node] = i;
	for(int next : edges[node]){
		set(next, i);
	}
}
int main(void){
	int64_t n, m;
	std::cin >> n >> m;
	std::vector<int> a(m), b(m);
	edges.resize(n);
	idx.resize(n);
	cluster_size.resize(n);
	for(int i=0;i<n;i++){
		idx[i] = i;
		cluster_size[i] = 1;
	}
	for(int i=0;i<m;i++){
		std::cin >> a[i] >> b[i];
		a[i]--;b[i]--;
	}
	std::vector<int64_t> ans(m);
	ans[m-1] = n * (n-1)/2;
	for(int i=m-1;i>0;i--){
		int A = a[i], B = b[i];
		if(idx[A] == idx[B]){
			ans[i-1] = ans[i];
			continue;
		}
		else{
			int64_t s1 = cluster_size[idx[A]], s2 = cluster_size[idx[B]];
			if(s1 > s2){
				set(B, idx[A]);
				cluster_size[idx[A]] = s1 + s2;
			}
			else{
				set(A, idx[B]);
				cluster_size[idx[B]] = s1 + s2;
			}
			ans[i-1] = ans[i] - s1 * s2;
			//橋を追加
			edges[a[i]].push_back(b[i]);
			edges[b[i]].push_back(a[i]);
		}
	}
	for(int i=0;i<m;i++)std::cout << ans[i] << std::endl;
}

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

int search(int A[], int n, int key){
    int i = 0;
    A[n] = key;
    while(A[i] != key) i++;
    return i != n;
}

int main(){
    int n, s[10005], q, t;
    scanf("%d", &n);
    rep(i,n) scanf("%d", &s[i]);
    scanf("%d", &q);

    int ans = 0;
    rep(i,q){
        scanf("%d", &t);
        if(search(s, n, t)) ans++;
    }

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

    return 0;
}


Measured memory_bytes: 3212
// By Shreehari Bodas

#include <bits/stdc++.h>

#define PB push_back
#define MP make_pair
#define MT make_tuple

#define forn(i,n) for(int i=0;i<n;i++)
#define forsn(i,s,n) for(int i=s;i<n;i++)
#define rforn(i,n) for(int i=n;i>=0;i--)
#define rforsn(i,s,n) for(int i=n;i>=s;i--)
#define forstl(a,s) for(auto a:s)

using namespace std;

typedef long long LL;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> pii;
typedef vector<pii> vpii;

const int MOD=1e9+7;

LL pow(LL a, LL b){
	if(b==0) return 1;
	LL res=pow(a,b/2);
	if(b%2 ==1) return res*res*a;
	else if(b%2 ==0) return res*res;
}

int main(){

	int a,b,c,d; cin>>a>>b>>c>>d;
	int x,y;

	if(c % b==0) x=(c/b);
	else if(c % b!=0) x=(c/b)+1;

	if(a % d==0) y=(a/d);
	else if(a % d!=0) y=(a/d)+1;

	if(x<=y) cout<<"Yes"<<endl;
	else cout<<"No"<<endl;

	return 0;
} 

Measured memory_bytes: 3636
#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<algorithm>
using namespace std;
#include<queue>
#define ll long long
int main()
{
	int x;
	cin>>x;
	if(x>=1800)
	{
		cout<<"1";
	}
	else if(x>=1600)
	{
		cout<<"2";
	}
	else if(x>=1400)
	{
		cout<<"3";
	}
	else if(x>=1200)
	{
		cout<<"4";
	}
	else if(x>=1000)
	{
		cout<<"5";
	}
	else if(x>=800)
	{
		cout<<"6";
	}
	else if(x>=600)
	{
		cout<<"7";
	}
	else if(x>=400)
	{
		cout<<"8";
	}
	return 0;
}

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


int main(){
	char a,b,c,d;
	cin >> a >> b >> c >> d;
	if((a == b && b == c )|| (b == c && c == d)){
		cout << "Yes" << endl;
	}else{
		cout << "No" << endl;
	}
	
	return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {

    static int gcd (int a, int b) {return b>0?gcd(b,a%b):a;}
    static long mod = 1000000007;

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        long D = sc.nextLong();
        int ans = 0;

        for(int i=0;i<N;i++){
            long X = sc.nextLong();
            long Y = sc.nextLong();
            if(X*X + Y*Y <= D*D){
                ans++;
            }
        }
        System.out.println(ans);


    }

}




Measured memory_bytes: 60460
import sys
import math
from decimal import Decimal, ROUND_HALF_UP, ROUND_HALF_EVEN
from collections import deque
from bisect import bisect_left
from itertools import product
def I(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LI2(N): return [list(map(int, sys.stdin.readline().split())) for i in range(N)]
#文字列を一文字ずつ数字に変換、'5678'を[5,6,7,8]とできる
def LSI(): return list(map(int, list(sys.stdin.readline().rstrip())))
def LSI2(N): return [list(map(int, list(sys.stdin.readline().rstrip()))) for i in range(N)]
#文字列として取得
def ST(): return sys.stdin.readline().rstrip()
def LST(): return sys.stdin.readline().rstrip().split()
def LST2(N): return [sys.stdin.readline().rstrip().split() for i in range(N)]
def FILL(i,h): return [i for j in range(h)]
def FILL2(i,h,w): return [FILL(i,w) for j in range(h)]
def FILL3(i,h,w,d): return [FILL2(i,w,d) for j in range(h)]
def FILL4(i,h,w,d,d2): return [FILL3(i,w,d,d2) for j in range(h)]
def sisha(num,digit): return Decimal(str(num)).quantize(Decimal(digit),rounding=ROUND_HALF_UP)
#'0.01'や'1E1'などで指定、整数に戻すならintをかます
MOD = 1000000007
INF = float("inf")
sys.setrecursionlimit(10**6+10)

A,B = MI()
print(A*B)


Measured memory_bytes: 9960
import java.util.Scanner;
public class Main {
    public static void main(String[] args) {
    
    Scanner sc = new Scanner(System.in);

      int N = sc.nextInt();
      double []A = new double [N];
      double sum =0.0;
      
      //整数格納→1/整数→それを足す
      for(int i =0; i<N; i++){
      	A[i] = sc.nextInt();
        sum += 1.0/A[i];
      }
      //"１/逆数の和"を出力
      System.out.println(1.0/sum);
    }
}

Measured memory_bytes: 23764
#include <iostream>
#include <algorithm>
#include <limits.h>
#include <vector>
#include <map>
#include <string>
#include <tuple>
#include <math.h>
using namespace std;
typedef long long ll;

int main(void){
    int n, a[3005], sum = 0;
    cin >> n;
    for (int i = 0; i < n; i++) {
        cin >> a[i];
        sum += a[i] - 1;
    }
    
    cout << sum << endl;
}


Measured memory_bytes: 256
import sys
from collections import deque

import numpy as np

sys.setrecursionlimit(10000)
INF = float('inf')

H, W = list(map(int, input().split()))
S = [list(input()) for _ in range(H)]
S = np.array(S)

# distances[h, w]: (h, w) に行くまでに通る '.' の数
distances = np.empty((H, W), dtype=int)
distances.fill(-1)
que = deque()


def valid(h, w):
    return 0 <= h < H and 0 <= w < W and S[h][w] == '.' and distances[h][w] == -1


# 普通に BFS して通らなかった道を # で埋める
distances[0][0] = 1
que.append((0, 0, H - 1, W - 1))
while len(que) > 0 and distances[-1, -1] == -1:
    sh, sw, eh, ew = que.popleft()
    if valid(sh + 1, sw):
        distances[sh + 1, sw] = distances[sh, sw] + 1
        que.append((sh + 1, sw, eh, ew))
    if valid(sh - 1, sw):
        distances[sh - 1, sw] = distances[sh, sw] + 1
        que.append((sh - 1, sw, eh, ew))
    if valid(sh, sw + 1):
        distances[sh, sw + 1] = distances[sh, sw] + 1
        que.append((sh, sw + 1, eh, ew))
    if valid(sh, sw - 1):
        distances[sh, sw - 1] = distances[sh, sw] + 1
        que.append((sh, sw - 1, eh, ew))

d = distances[-1, -1]
if d == -1:
    print(-1)
else:
    print(H * W - list(S.flat).count('#') - d)


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

using namespace std;

int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n, k;
  cin >> n >> k;
  vector<int> a(n);
  for (int i = 0; i < n; i++)
  {
    cin >> a[i];
  }
  vector<int> b(n + 1);
  while (k--)
  {
    for (int i = 0; i <= n; i++)
    {
      b[i] = 0;
    }
    for (int i = 0; i < n; i++)
    {
      int from = max(i - a[i], 0);
      int to = min(i + a[i], n - 1);
      b[from] += 1;
      b[to + 1] -= 1;
    }
    bool changed = false;
    for (int i = 0; i < n; i++)
    {
      changed |= (a[i] != b[i]);
      a[i] = b[i];
      b[i + 1] += b[i];
    }
    if (!changed)
    {
      break;
    }
  }
  for (int i = 0; i < n; i++)
  {
    if (i > 0)
    {
      cout << " ";
    }
    cout << a[i];
  }
  cout << '\n';
  return 0;
}


Measured memory_bytes: 4752
#include<bits/stdc++.h>
#define rep(i, l, r) for(int i = (l), i##end = (r);i <= i##end;++i)
using std::cin; using std::cout;
const int maxn = 1000200;
int n, popc;
char s[maxn];
int a[maxn];
int main() {
	std::ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
	cin >> s; n = strlen(s); 
	rep(i, 1, n) a[i] = (s[n - i] & 15) * 9;
	rep(i, 1, n + 2) a[i + 1] += a[i] / 10, popc += a[i] %= 10;
	for(int k = 0;;++k) {
		if(popc <= k) return cout << (k + 8) / 9 << '\n', 0;
		for(int i = 1;++a[i] == 10;++i) popc -= 9, a[i] = 0;
		++ popc;
	}
}


Measured memory_bytes: 4608
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define se second
#define fi first
#define pb push_back
const int N = 2e5 +5;
int a[N], b[N], na[N], nb[N];

int main(){

//	freopen("in.txt","r",stdin);

	int n;
	scanf("%d",&n);
	for (int i=0; i<n; i++)scanf("%d", a +i);
	for (int i=0; i<n; i++)scanf("%d", b +i);

	int ans =0;
	for (int i=0; i<29; i++){

		for (int j=0; j<n; j++)na[j] = a[j] % (1 <<(i +1));
		for (int j=0; j<n; j++)nb[j] = b[j] % (1 <<(i +1));

		sort (nb, nb +n);

		int sum =0, d = (1 <<i);
		for (int j=0; j<n; j++){
			sum += max (0,(int)(lower_bound (nb, nb +n, 2LL*d - na[j]) - lower_bound (nb, nb +n, d - na[j])));
			sum += max (0,(int)(lower_bound (nb, nb +n, 4LL*d - na[j]) - lower_bound (nb, nb +n, 3LL*d - na[j])));
		}
		if (sum &1)ans |= 1<<i;
	}
	cout <<ans <<endl;

}


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

int main() {
	int n,m;
	cin >> n >> m;
	vector<int> a(n,0);
	int sm=0;
	for(int i=0;i<n;i++)
	{
		cin >> a.at(i);
		sm += a.at(i);
	}
	int sh = sm / (m * 4),am = sm % (m * 4);
	if(am > 0)
	{
		sh++;
	}
	string k = "No";
	int c =0;
	for(int i=0;i<n;i++)
	{
		if(a.at(i) >= sh)
		{
			c++;
		}
	}
	if(m <= c)
	{
		k = "Yes";
	}
	cout << k << endl;
	return 0;
}


Measured memory_bytes: 256
while True:
  a,b = map(int,input().split())

  if a == 0 & b == 0:
    break

  for i in range(a):
    if i == 0:
      print("#"*b)
    elif i == a-1:
      print("#"*b)
      print()
    else:
      print("#"+"."*(b-2)+"#")


Measured memory_bytes: 5612
# coding: utf-8
# Your code here!

x,y,z,k = map(int,input().split())

A = list(map(int,input().split()))
A.sort(reverse = True)
B = list(map(int,input().split()))
B.sort(reverse = True)
C = list(map(int,input().split()))
C.sort(reverse = True)



AB = [a+b for a in A for b in B]
AB.sort(reverse = True)

ans = [ab + c for ab in AB[:k] for c in C]
ans.sort(reverse = True)

for i in ans[:k]:
    print(i)


Measured memory_bytes: 207436
#include <stdio.h>

int main(void)
{
	int a, b;
	int sum;
	int i;

	while (scanf("%d %d", &a, &b) != EOF){
		sum = a + b;
		
		for (i = 1; sum / 10 != 0; sum /= 10){
			i++;
		}
		printf("%d\n", i);
	}
	
	
	return (0);
}

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

using namespace std;

typedef long long ll;

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    int n, x;
    cin >> n >> x;
    swap(x, n);
    set <int> s;
    for (int i = 1; i <= n; i++) {
        int y;
        cin >> y;
        s.insert(y);
    }
    int df = 1e9;
    int mn = 1e9;
    for (int i = x - 1001; i <= x + 1001; i++) {
        if (!s.count(i)) {
            if (df > abs(i - x)) {
                df = abs(i - x);
                mn = i;
            }
        }
    }
    cout << mn << '\n';
    return 0;
}

Measured memory_bytes: 3660
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author Jaynil
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        Task solver = new Task();
        solver.solve(1, in, out);
        out.close();
    }

    static class Task {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int n = in.nextInt();
            ArrayList<Integer> a = new ArrayList<>();
            for (int i = 0; i < n; i++) {
                a.add(in.nextInt());
            }
            int ans = 0;
            int c = 1;
            for (int i = 0; i < n; i++) {
                if (a.get(i) == c) {
                    c++;
                } else {
                    ans++;
                }
            }
            out.println(ans > 0 && c == 1 ? -1 : ans);
        }

    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

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

    }
}



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

char maps[101][101];
int w,h;
int py[4]={-1,0,1,0};
int px[4]={0,1,0,-1};

void fruit(int y,int x,char c){
  if(y<h&&x<w&&y>=0&&x>=0&&maps[y][x]==c){
    for(int l=0;l<4;l++){
      maps[y][x]='$';
      fruit(y+py[l],x+px[l],c);
    }
  }
  return;
}

int main(){
  while(1){
    int cnt=0;
    scanf(" %d %d",&h,&w);
    if(h==0&&w==0)break;
    for(int i=0;i<h;i++){
      scanf(" %s",maps[i]);
    }
    for(int i=0;i<h;i++){
      for(int j=0;j<w;j++){
	if(maps[i][j]!='$'){
	  fruit(i,j,maps[i][j]);
	  cnt++;
	}
      }
    }
    cout << cnt << endl;
  }
  return 0;
}

Measured memory_bytes: 1684
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

func main() {
	readInt()
	Count := readInt()
	ACs, ACCount, WACount := map[int]int{}, 0, 0

	Loop(0, Count, func(i int) {
		No, Result := readInt(), readString()
		v := ACs[No]
		if v == 1 {
			return
		}

		if Result == "AC" {
			ACs[No] = 1
			WACount += abs(v)
			ACCount++
		} else {
			ACs[No] = ACs[No] - 1
		}
	})

	fmt.Printf("%d %d", ACCount, WACount)
}

var scanner = bufio.NewScanner(os.Stdin)

func init() {
	scanner.Split(bufio.ScanWords)
	//scanner.Split(bufio.ScanLines)
}

func readInt() int {
	scanner.Scan()
	t, _ := strconv.Atoi(scanner.Text())
	return t
}

func Loop(start, end int, f func(i int)) {
	for i := start; i < end; i++ {
		f(i)
	}
}

func readString() string {
	scanner.Scan()
	return scanner.Text()
}

func abs(i int) int {
	if i >= 0 {
		return i
	} else {
		return i * -1
	}
}

Measured memory_bytes: 6912
#include<bits/stdc++.h>
#define enld '\n'
#define rep(i,n) for(int i=0; i<(n); i++)
using namespace std;
using ll = long long;
using P = pair<int,int>;
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("Ofast")
constexpr ll INF = 1e18;
constexpr int inf = 1e9;
constexpr ll mod = 1000000007;
constexpr ll mod2 = 998244353;
const double PI = 3.1415926535897932384626433832795028841971;
const int dx[6] = {1, 0, -1, 0,1,1};
const int dy[6] = {0, 1, 0, -1,1,-1};
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
// ---------------------------------------------------------------------------


int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int a,b;
    cin >> a >> b;
    int pre = 0;
    int now = 0;
    for(int i=1; i<1000; i++){
        pre = now;
        now += i;
        if(b < now){
            if(pre-a == now-b){
                cout << pre-a << enld;
                return 0;
            }
        }
    }
    return 0;
}

Measured memory_bytes: 256
import java.io.IOException;
import java.util.Arrays;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) throws IOException {

		Scanner scan = new Scanner(System.in);

		int X = scan.nextInt();
		int t = scan.nextInt();

		int ans = Math.max(X - t, 0);

		System.out.println(ans);
	}

	//***********************以下共通関数************************************************
	/**
	 * 文字列を反転して返す
	 * @param pStr 文字列
	 * @return 反転した文字列
	 */
	public static String myReverse(String pStr) {
		if (pStr.length() < 1) {
			return "";
		}

		StringBuffer sb = new StringBuffer(pStr);
		return sb.reverse().toString();
	}

	/**
	 * 余りを求める。
	 * @param a
	 * @param b
	 * @return 余り。余りがマイナスの時はプラスで返す。
	 */
	public static long myMod(long a, long b) {
		long ret = 0;

		ret = a % b;

		if (ret < 0) {
			ret += b;
		}

		return ret;
	}

	/**
	 * 乗数を求める ※mod対応
	 * @param kisu 基数
	 * @param josu 乗数
	 * @param primeNumMod_0 法 mod値 使わない場合は「0」
	 * @return
	 */
	public static long myPowWithMod(long kisu, long josu, long primeNumMod_0) {

		long ans = 1;

		//乗数が0の場合→1
		if (josu == 0)
			return 1;

		if (primeNumMod_0 == 0) {
			//modを使わないとき

			while (josu > 0) {

				if (josu % 2 == 0) {
					//累乗が偶数の時

					kisu *= kisu;
					josu = josu / 2;
				} else {
					//累乗が奇数の時
					ans *= kisu;
					josu--;
				}
			}

			return ans;

		} else {
			//modを使うとき

			//初めに桁を落とす
			kisu = myMod(kisu, primeNumMod_0);

			while (josu > 0) {

				if (josu % 2 == 0) {
					//累乗が偶数の時

					kisu *= myMod(kisu, primeNumMod_0);
					josu = josu / 2;

				} else {
					//累乗が奇数の時
					ans *= myMod(kisu, primeNumMod_0);
					josu--;

				}
			}

			return myMod(ans, primeNumMod_0);

		}

	}

}


Measured memory_bytes: 26888
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define ALL(v) v.begin(), v.end()
#define downque(que) priority_queue<ll> que;
#define upque(que) priority_queue<ll, vector<int>, greater<int>> que;
typedef long long ll;
typedef vector<vector<int>> Matrix;
const int MOD = 1e9 + 7;
const int MAX = 1e7;
const int INF = numeric_limits<int>::max();


int main(){
  string s,res="";
  cin >> s;
  REP(i,s.length()){
    res += 'x';
  }

  cout << res << endl;
}

Measured memory_bytes: 256
x,y=map(int,input().split())
if abs(x)==abs(y):
  print((x*y<0)+0)
elif x*y==0:
    print(abs(x-y)+(x>0 or y<0)*1)
elif x*y<0:
  print(1+abs(abs(x)-abs(y)))
else:
  print((x>=y)*2+abs(abs(x)-abs(y)))


Measured memory_bytes: 3060
package main

import (
	"fmt"
)

func main() {
	var n int
	fmt.Scan(&n)
	attackMonstor(n)
}

func gcd(a, b int) int {
	if b == 0 {
		return a
	}
	return gcd(b, a%b)
}

func min(a, b int) int {
	if a > b {
		return b
	}
	return a
}

func attackMonstor(n int) {
	monstors := make([]int, n)
	for i := 0; i < n; i++ {
		fmt.Scan(&monstors[i])
	}
	ans := gcd(monstors[1], monstors[0])
	for i := 0; i < n-1; i++ {
		m := gcd(monstors[i+1], monstors[i])
		ans = min(ans, m)
	}
	fmt.Println(ans)
}


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

int main(){
    ll k;
    cin >> k;
    ll x = 1;
    ll n=0;
    ll cnt = 1;
    ll ans = -1;
    while(cnt<100000000){
        n += 7*x;
        if(n%k==0){
            ans = cnt;
            break;
        }
        x = x * 10 % k;
        cnt++;
    }
    cout << ans << endl;
    return 0;
}

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

using namespace std;

int main() {
    int N;
    cin >> N;
    vector<int> b(N);
    for(int n=0; n<N; n++) {
        cin >> b[n];
    }
    
    vector<int> ans(N);
    bool flag=true;
    for(int n=0; n<N; n++) {
        int ind=-1;
        for(int n=0; n<b.size(); n++) {
            if(b[n]==n+1) {
                ind = n;
            }
        }
        if(ind==-1) {
            flag = false;
            break;
        }
        ans[N-1-n] = b[ind];
        b.erase(b.begin()+ind);
    }
    
    if(flag) {
        for(int n=0; n<N; n++) {
            cout << ans[n] << endl;
        }
    } else {
        cout << -1 << endl;
    }



    return 0;
    
}

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

void dfs(vector<ll> &v, ll n, int digit) {
	if(digit > 10) return;
	digit++;
	ll last = n % 10;
	for(int i = max(0LL, last-1); i <= min(9LL, last+1); i++) {
		ll now = n * 10 + i;
		v.push_back(now);
		dfs(v, now, digit);
	}
}

int main() {
	ll k;
	cin >> k;
	vector<ll> lunlun;
	rep(i, 9) {
		lunlun.push_back(i+1);
		dfs(lunlun, i+1, 1);
	}
	sort(all(lunlun));
	cout << lunlun[k-1] << endl;
	// rep(i, lunlun.size()) cout << lunlun[i] << endl;
	return 0;
}

Measured memory_bytes: 10348
import random

def is_prime3(q,k=50):
    q = abs(q)
    #計算するまでもなく判定できるものははじく
    if q == 2: return True
    if q < 2 or q&1 == 0: return False

    #n-1=2^s*dとし（但しaは整数、dは奇数)、dを求める
    d = (q-1)>>1
    while d&1 == 0:
        d >>= 1
    
    #判定をk回繰り返す
    for i in range(k):
        a = random.randint(1,q-1)
        t = d
        y = pow(a,t,q)
        #[0,s-1]の範囲すべてをチェック
        while t != q-1 and y != 1 and y != q-1: 
            y = pow(y,2,q)
            t <<= 1
        if y != q-1 and t&1 == 0:
            return False
    return True

x = int(input())
while True:
    if is_prime3(x):
        print(x)
        break
    else:
        x += 1

Measured memory_bytes: 4208
#include <iostream>
#include <string.h>
using namespace std;

int main() {
    char s[4];
    cin >> s;
    if (!strncmp(s, "ABC", 3)) {
        cout << "ARC";
    } else if (!strncmp(s, "ARC", 3)) {
        cout << "ABC";
    }
    return 0;
}

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

int main() {
	int N, M, C, B[25]; cin >> N >> M >> C;
	for(int i=0; i<M; ++i) cin >> B[i];
	int ans=0;
	for(int i=0; i<N; ++i){
	    int now=C;
	    for(int p=0; p<M; ++p){
	        int A;
	        cin >> A;
	        now += A*B[p];
	    }
	    if(now>0) ++ans;
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>

int MaxOf3Nums(int a, int b) {
  int plus = a + b;
  int minus = a - b;
  int multiple = a * b;
  
  int max1 = plus;
  if (max1 < minus) {
    max1 = minus;
  }
  if (max1 < multiple) {
    max1 = multiple;
  }
  return max1;
}
  
int main() {
  int a, b;
  std::cin >> a;
  std::cin >> b;
  int max1 = MaxOf3Nums(a, b);
  std::cout << max1 << std::endl;
}


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

#define F first
#define S second
#define MP make_pair
#define pb push_back
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define LCM(a, b) (a) / __gcd((a), (b)) * (b)
#define CEIL(a, b) (a)/(b)+(((a)%(b))?1:0)
#define ln '\n'

using namespace std;
using LL = long long;
using ldouble = long double;
using P = pair<int, int>;
using LP = pair<LL, LL>;

static const int INF = INT_MAX;
static const LL LINF = LLONG_MAX;
static const int MIN = INT_MIN;
static const LL LMIN = LLONG_MIN;
static const int MOD = 1e9 + 7;
static const int SIZE = 200005;

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

vector<LL> Div(LL n) {
    vector<LL> ret;
    for(LL i = 1; i * i <= n; ++i) {
        if(n % i == 0) {
            ret.pb(i);
            if(i * i != n) ret.pb(n / i);
        }
    }
    sort(all(ret));
    return ret;
}

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

    int N;
    int x;
    cin >> N >> x;
    vector<int> a(N), b(N);
    for(int i = 0; i < N; ++i) {
        cin >> a[i];
        b[i] = a[i];

    }

    LL res = 0;
    for(int i = 1; i < N; ++i) {
        LL t = a[i] + a[i - 1];
        if(t <= x) continue;
        res += (a[i] + a[i - 1]) - x;
        if(a[i - 1] > x) a[i - 1] = x;
        a[i] = x - a[i - 1];

    }

    LL rres = 0;
    reverse(all(b));
    for(int i = 1; i < N; ++i) {
        LL t = b[i] + b[i - 1];
        if(t <= x) continue;
        rres += (b[i] + b[i - 1]) - x;
        if(b[i - 1] > x) b[i - 1] = x;
        b[i] = x - b[i - 1];

    }
    cout << min(res, rres) << endl;
    return 0;
}



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

# プラン 1: T時間駐車した場合、A × T円 が駐車料金となる。
# プラン 2: 駐車した時間に関わらず B円 が駐車料金となる。
# N時間駐車するとき、駐車料金は最小でいくらになるか求めてください。

plan_A = A * N
plan_B = B

print(min(plan_A, plan_B))

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

const int M=3005;
vector<int> g[M];
int d[M];
int ans[M];

int main()
{
	int n,x,y;
	scanf("%d%d%d",&n,&x,&y);
	for(int i=1;i<n;i++)
	{
		g[i].push_back(i+1);
		g[i+1].push_back(i);
	}
	g[x].push_back(y);
	g[y].push_back(x);
	for(int i=1;i<=n;i++)
	{
		memset(d,-1,sizeof(d));
		queue<int> qu;
		qu.push(i);
		d[i]=0;
		while(!qu.empty())
		{
			int u=qu.front(); qu.pop();
			for(int v:g[u])
			{
				if(d[v]==-1)
				{
					d[v]=d[u]+1;
					ans[d[v]]++;
					qu.push(v);
				}
			}
		}
	}
	for(int i=1;i<n;i++)
		printf("%d\n",ans[i]/2);
	return 0;
}

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

int n,v,u,m,U[1000001],V[1000001],M[100000],sumu=0,sumv=0,x;
int HU[501]={},WU[501]={},unaname1=0,unaname2=0;
int HV[501]={},WV[501]={},vnaname1=0,vnaname2=0;

int main()
{

  for(int i=0;i<1000001;i++){
    U[i]=-1;
    V[i]=-1;
  }
  cin>>n>>u>>v>>m;
  for(int i=0;i<n;i++){
    for(int j=0;j<n;j++){
      cin>>x;
      U[x]=i*n+j;
    }
  }
  for(int i=0;i<n;i++){
    for(int j=0;j<n;j++){
      cin>>x;
      V[x]=i*n+j;
    }
  }

  for(int i=0;i<m;i++)cin>>M[i];

  for(int k=0;k<m;k++){
    if(U[M[k]]!=-1){
      int a=U[M[k]]/n,b=U[M[k]]%n;
      HU[a]++;
      WU[b]++;
      if(HU[a]==n)sumu++;
      if(WU[b]==n)sumu++;
      if(a==b){
	unaname1++;
	if(unaname1==n)sumu++;
      }
      if(a+b==n-1){
	unaname2++;
	if(unaname2==n)sumu++;
      }
    }
    
    if(V[M[k]]!=-1){
      int a=V[M[k]]/n,b=V[M[k]]%n;
      HV[a]++;
      WV[b]++;
      if(HV[a]==n)sumv++;
      if(WV[b]==n)sumv++;
      if(a==b){
	vnaname1++;
	if(vnaname1==n)sumv++;
      }
      if(a+b==n-1){
	vnaname2++;
	if(vnaname2==n)sumv++;
      }
    }

    if(n==1){
      sumu=min(sumu,1);
      sumv=min(sumv,1);
    }
    if(sumu>=u && sumv>=v){
      cout<<"DRAW"<<endl;
      break;
    }
    if(sumu>=u){
      cout<<"USAGI"<<endl;
      break;
    }
    if(sumv>=v){
      cout<<"NEKO"<<endl;
      break;
    }
    if(k==m-1)cout<<"DRAW"<<endl;
  }
  return 0;
}

Measured memory_bytes: 9136
from sys import stdin

n, m = [int(i) for i in stdin.readline().rstrip().split()]
max_l = -1
min_r = 100000

for _ in range(m):
  l, r = [int(i) for i in stdin.readline().rstrip().split()]
  if l > max_l:
    max_l = l
  if r < min_r:
    min_r = r
    
if(min_r >= max_l):
  print(min_r - max_l + 1)
else:
  print(0)

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

using namespace std;

bool isAC(const string &S)
{
	if (S[0] != 'A') {
		return false;
	}
	if (count(S.begin() + 2, S.end() - 1, 'C') != 1) {
		return false;
	}
	for (auto c : S) {
		if (c != 'A' && c != 'C' && !islower(c)) {
			return false;
		}
	}
	return true;
}

int main()
{
	string S;
	cin >> S;
	if (isAC(S)) {
		cout << "AC" << endl;
	}
	else {
		cout << "WA" << endl;
	}
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define IOS ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define endl '\n'
#define ll int64_t
#define ull uint64_t
using namespace std;

int main() {
	IOS;
	int n;
  cin >> n;
  int b = ceil((float)n / 1000);
  cout << (b * 1000 - n) << endl;
	return 0;
}


Measured memory_bytes: 3652
n, m = map(int, input().split())
demands = []
for _ in range(m):
    a, b = map(int, input().split())
    demands.append([b, a])
demands.sort()

p = demands[0][0]
ans = 1

for i in range(1, m):
    if p <= demands[i][1]:
        ans += 1
        p = demands[i][0]


print(ans)

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

using namespace std;
typedef long long ll;

#define FAST ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define mp make_pair
#define pb push_back
#define lp(i,s,f) for(ll i = s; i < ll(f); i++)
#define inF freopen("input.in", "r", stdin);
#define outF freopen("output.in", "w", stdout);
#define endl '\n'
#define MOD 1000000007
#define mm(arr) memset(arr, 0, sizeof(arr))

int main(){
    FAST
    string s; cin >> s;
    if(s[0] == '7' || s[1] == '7' || s[2] == '7'){
        cout << "Yes";
    }
    else{
        cout << "No";
    }
    return 0;
}


Measured memory_bytes: 3580
import java.io.IOException;

import java.io.BufferedReader;
import java.io.InputStreamReader;

import java.io.PrintWriter;

@SuppressWarnings("unchecked")
public class Main {
    static long f(int x, int y) {
        long ret = Long.MAX_VALUE;
        for (int i = 0; i < x; i++) {
            int x2 = (x - i) / 2;
            int x3 = x - i - x2;
            long xmin = (long)Math.min(i, x2) * y;
            long xmax = (long)Math.max(i, x3) * y;
            long xdiv = xmax - xmin;

            int y2 = y / 2;
            int y3 = y - y2;
            long ymin = (long)Math.min((long)i * y, (long)(x - i) * y2);
            long ymax = (long)Math.max((long)i * y, (long)(x - i) * y3);
            long ydiv = ymax - ymin;

            ret = Math.min(ret, Math.min(xdiv, ydiv));
        }
        return ret;
    }

    public static void main(String[] args) throws IOException {
        final String s;

        try (
            BufferedReader reader = new BufferedReader(
                new InputStreamReader(System.in))) {
            s = reader.readLine();
        }

        PrintWriter out = new PrintWriter(System.out);

        final String[] sl = s.split(" ");
        int H = Integer.parseInt(sl[0]);
        int W = Integer.parseInt(sl[1]);

        long tate = f(H, W);
        long yoko = f(W, H);

        out.println(Math.min(tate, yoko));

        out.flush();
    }
}


Measured memory_bytes: 23252
#include <bits/stdc++.h>
using namespace std;
int main() {
  int h, w;
  cin >> h >> w;
  for (int i = 0; i < h; i++) {
    for (int j = 0; j < w; j++) {
      string s;
      cin >> s;
      if (s == "snuke") {
        cout << char('A' + j) << (i + 1) << endl;
        return 0;
      }
    }
  }
  return 0;
}

Measured memory_bytes: 256
/*  -*- coding: utf-8 -*-
 *
 * b.cc: B: ISU
 */

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
 
using namespace std;

/* constant */

/* typedef */

/* global variables */

/* subroutines */

/* main */

int main() {
  int x, y, z;
  cin >> x >> y >> z;
  printf("%d\n", (x - z) / (y + z));
  return 0;
}


Measured memory_bytes: 256
using System;

class Rectangle {
    public static void Main() {
        string Input_Str = Console.ReadLine();
        string[] Input_Num = Input_Str.Split(' ');
        int a = int.Parse(Input_Num[0]);
        int b = int.Parse(Input_Num[1]);
        int area = a * b;
        int length = a * 2 + b * 2;
        Console.WriteLine(area + " " + length);
    }
}

Measured memory_bytes: 9012
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using ll = long long;
ll GetDigit(ll num){ return log10(num)+1; } //numの桁数を求める

int main()
{
    ll A,B;
    cin >> A >> B;
    cout << A * B << endl;
}

Measured memory_bytes: 3640
package main

import (
	"fmt"
)

func main() {
  var a, b, x float64
  fmt.Scanf("%f %f", &a, &b)
  
  x = (a + b) / 2
  ans := int(x)
  if x - float64(ans) > 0 {
    ans++
  }
  
  fmt.Printf("%d\n", ans)
}

Measured memory_bytes: 1832
inp = list(map(int, input().split()))

flag_5 = 0
flag_7 = 0

if len(inp) == 3:
    for i in range(3):
        if inp[i] == 5:
            flag_5 += 1
        elif inp[i] == 7:
            flag_7 += 1
        else :
            break

if flag_5 == 2 and flag_7 == 1:
    print('YES')
else :
    print('NO')

Measured memory_bytes: 3060
// Sky's the limit :)
#include <bits/stdc++.h>
using namespace std;
#define int long long

signed main() {
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    
    int T = 1; 
    // cin >> T; 
    while (T--) {
        int a;
        cin >> a;

        int ans = a + a * a + a * a * a;
        cout << ans << '\n';   
        
    }
    
    return 0;
}



Measured memory_bytes: 3636
def gcd(x, y):
  if y == 0:
    return x
  else:
    return gcd(y, x % y)

def resolve():
  n = int(input())
  a = list(map(int, input().split()))
  ans = a[0]
  for x in a:
    ans = gcd(ans, x)

  print(ans)
  return

if __name__ == "__main__":
  resolve()


Measured memory_bytes: 20084
#include <iostream>
#include <sstream>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <memory>
#include <complex>
#include <numeric>
#include <cstdio>
#include <iomanip>

#define REP(i,m,n) for(int i=int(m);i<int(n);i++)
#define RREP(i,m,n) for(int i=int(n)-1;i>=int(m);--i)
#define EACH(i,c) for (auto &(i): c)
#define all(c) begin(c),end(c)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort(begin(c),end(c))
#define pb emplace_back
#define MP make_pair
#define SZ(a) int((a).size())

#ifdef LOCAL
#define DEBUG(s) cout << (s) << endl
#define dump(x)  cerr << #x << " = " << (x) << endl
#define BR cout << endl;
#else
#define DEBUG(s) do{}while(0)
#define dump(x) do{}while(0)
#define BR 
#endif
using namespace std;

using UI = unsigned int;
using UL = unsigned long;
using LL = int_fast64_t;
using ULL = unsigned long long;
using VI = vector<int>;
using VVI = vector<VI>;
using VLL = vector<LL>;
using VS = vector<string>;
using PII = pair<int,int>;
using VP = vector<PII>;

//struct edge {int from, to, cost;};

constexpr double EPS = 1e-10;
//constexpr double PI  = acos(-1.0);
//constexpr int INF = INT_MAX;

template<class T> inline T sqr(T x) {return x*x;}

struct S{
    int c,t;
};

void solve() {
    int n,t;
    cin >> n >> t;
    vector<S> ss(n);
    REP(i,0,n) cin >> ss[i].c >> ss[i].t;
    sort(all(ss), [](auto &l, auto &r) {
        return l.c != r.c ? l.c < r.c : l.t < r.t;
    });
    REP(i,0,n) {
        if (ss[i].t <= t) {
            cout << ss[i].c << endl;
            return;
        }
    }
    cout << "TLE" << endl;
}

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

Measured memory_bytes: 256
while 1:
    a,b=map(int, input().split())
    if a==0:break
    for i in range(a):
        for j in range(b):
            if (i+j)%2==0:
                w='#'
            else:
                w='.'
            print(w,end='')
        print()
    print()
            


Measured memory_bytes: 7004
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cassert>
#include <string>
#include <cstring>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <algorithm>

using namespace std;

// ---------------------
// repetition
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)

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

// ---------------------
#define INF 922337203685477580
typedef long long ll;

int dp[50];

int fib(int n) {
  if (dp[n] != -1) return dp[n];
  if (n == 0 || n == 1) {
    dp[n] = 1;
    return dp[n];
  }
  dp[n] = fib(n - 1) + fib(n - 2);
  return dp[n];
}

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

  REP(i, 50) {
    dp[i] = -1;
  }

  cout << fib(X) << endl;
  return 0;
}

Measured memory_bytes: 3080
#include <bits/stdc++.h>
	#define mset(a,b) memset(a,b,sizeof a)
	#define mcpy(a,b) memcpy(a,b,sizeof b)
	#define lb(x) ((x)&(-(x)))
	#define dalao 1000000007
	#define inf 0x7fffffff
	#define N 200010
	using namespace std;
	typedef long long ll;
	int main(){
		int a,b,c,d;
		cin>>a>>b>>c>>d;
		if(a>c)swap(a,c),swap(b,d);
		if(b<c)puts("0");
		else if(b>=d)printf("%d",min(abs(a-b),abs(c-d)));
		else printf("%d",b-c);
		return 0;
	}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		char[] c = sc.next().toCharArray();
		int n = c.length;
		int[] a = new int[n];
		for (int i = 0; i < n; i++) {
			a[i] = 0;
		}
		int evn = 0;
		int odd = 0;
		int rtnPos = 0;
		for (int i = 0; i < n - 1; i++) {
			if (c[i] == 'R' && c[i + 1] == 'L') {
				a[i]++;
				if (i % 2 == 0) {
					a[i] += evn;
					a[i + 1] += odd;
				} else {
					a[i] += odd;
					a[i + 1] += evn;
				}
				evn = 0;
				odd = 0;
				rtnPos = i;
			} else if (c[i] == 'L' && c[i + 1] == 'R') {
				if (i % 2 == 0) {
					evn++;
				} else {
					odd++;
				}
				if (rtnPos % 2 == 0) {
					a[rtnPos] += evn;
					a[rtnPos + 1] += odd;
				} else {
					a[rtnPos] += odd;
					a[rtnPos + 1] += evn;
				}
				evn = 0;
				odd = 0;
			} else if (i % 2 == 0) {
				evn++;
			} else {
				odd++;
			}
		}

		if ((n - 1) % 2 == 0) {
			evn++;
		} else {
			odd++;
		}

		if (rtnPos % 2 == 0) {
			a[rtnPos] += evn;
			a[rtnPos + 1] += odd;
		} else {
			a[rtnPos] += odd;
			a[rtnPos + 1] += evn;
		}

		System.out.print(a[0]);
		for (int i = 1; i < n; i++) {
			System.out.print(" " + a[i]);
		}
	}
}


Measured memory_bytes: 44560
import java.util.Scanner;

public class Main {
	static boolean memo[];
	static int ans, min;

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		StringBuilder sb = new StringBuilder();
		int n = sc.nextInt();
		int q = sc.nextInt();
		char[] s = sc.next().toCharArray();
		int[] cnt = new int[n];
		cnt[0] = 0;
		for (int i = 1; i < n; i++) {
			if (s[i - 1] == 'A' && s[i] == 'C') {
				cnt[i] = cnt[i - 1] + 1;
			} else {
				cnt[i] = cnt[i - 1];
			}
		}
		int l, r;
		for (int i = 0; i < q; i++) {
			l = sc.nextInt() - 1;
			r = sc.nextInt() - 1;
			sb.append(cnt[r] - cnt[l] + "\n");
		}
		System.out.print(sb);
	}
}


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

int main(){
   int a,b,k,s=0;
  cin >> k >> a >> b;
  for(int i=a;i<=b;i++){
    if(i%k == 0){
      cout << "OK" << endl;
      s = -1;
      break;
    }
  }
  
  if(s == 0) cout << "NG" << endl;
  
  return 0;
}


Measured memory_bytes: 3632
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args) throws IOException {
		// TODO 自動生成されたメソッド・スタブ
		BufferedReader input = new BufferedReader(new InputStreamReader(System.in));
		String[] inputRowAndCol = (input.readLine()).split("\\s");
		int row = Integer.parseInt(inputRowAndCol[0]);
		int col = Integer.parseInt(inputRowAndCol[1]);

		// 行列A
		int[][] matrixA = new int[row][col];
		String[] matrixData = null;
		for (int i = 0; i < row; i++) {
			matrixData = (input.readLine()).split("\\s");
			for (int j = 0; j < col; j++) {
				matrixA[i][j] = Integer.parseInt(matrixData[j]);
			}
		}
		// ベクトルb
		int[] vectorB = new int[col];
		for (int k = 0; k < col; k++) {
			vectorB[k] = Integer.parseInt(input.readLine());
		}

		// 行列の積
		for (int l = 0; l < row; l++) {
			int result = 0;
			for (int m = 0; m < col; m++) {
				result += (matrixA[l][m] * vectorB[m]);
			}
			System.out.println(result);
		}

	}

}



Measured memory_bytes: 28560
import numpy as np
N,M,X = map(int,input().split())
CA = [np.array(list(map(int,input().split()))) for i in range(N)]
ans = -1
for i in range(1,2**N):
    und = np.zeros(M+1,dtype=int)
    flag = True
    for j in range(N):
        if (i >> j) & 1:
            und += CA[j]
    for k in range(M):
        if und[k+1] < X:
            flag = False
            break
    if flag:
        tmp = und[0]
        if ans == -1:
            ans = tmp
        else:
            ans = min(ans,tmp)
print(ans)

Measured memory_bytes: 27208
#include<stdio.h>
#include<string.h>
int main()
{
    long long int x,sum=0,i;
    scanf("%lld",&x);
    for(i=0;i<=x;i++)
    {
        if(i%3!=0&&i%5!=0)
            sum+=i;
    }
    printf("%lld",sum);
    return 0;
}

Measured memory_bytes: 1736
#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long ULL;
typedef long long LL;
#define FOR(i, a, b) for(LL i=(LL)(a);i<(LL)(b);i++)
#define REP(i,x) for(LL i=0;i<(LL)(x);i++)

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

    int N, M;
    cin >> N >> M;

    map<int, int> num;
    REP(i, M)
    {
        int s, c;
        cin >> s >> c;

        if(num.count(s))
        {
        // キーが有る
            // 桁が矛盾
            if(num.at(s) != c)
            {
                cout << -1 << endl;
                return 0;
            }
        }
        else
        {
        // キーがない
            num.emplace(s, c);
        }
        
    }

    // 縛りなし
    if(M == 0)
    {
        if(N==1)
          cout << 0 << endl;
        else
          cout << pow(10, N-1) << endl;
        return 0;
    }

    // 1桁じゃないのに最上位桁の値が0
    if(N > 1 && num.count(1) && num.at(1) == 0)
    {
        cout << -1 << endl;
        return 0;
    }

    string S(N, '0');
    // 最上位の桁
    char digit1 = '0';
    if(num.count(1))
    {
        digit1 += num.at(1);
    }
    else
    {
        digit1 = '1';
    }
    S.at(0) = digit1;

    // 2番目の桁
    char digit2 = '0';
    if(N > 1)
    {
        if(num.count(2))
        {
            digit2 += num.at(2);
        }
        S.at(1) = digit2;
    }

    // 3番目の桁
    char digit3 = '0';
    if(N > 2)
    {
        if(num.count(3))
        {
            digit3 += num.at(3);
        }
        S.at(2) = digit3;
    }

    cout << S << endl;
    return 0;
}


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

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

  int ans = 10000;
  for (int i = 0; i < N; i++) {
    int c, t;
    cin >> c >> t;
    if (t > T) continue;
    else ans = min(ans, c);
  }

  if (ans == 10000) cout << "TLE" << endl;
  else cout << ans << endl;
}

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

#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define sf scanf
#define pf printf
#define str string
#define vec vector
#define rep(i, n) for (i = 0; i < n; ++i)
#define rep0(i, n) for (i = 0; i <= n; ++i)
#define rep1(i, n) for (i = 1; i <= n; ++i)
#define repp(i, a, n) for (i = a; i <= n; ++i)
#define repb(i, a, n) for (i = a; i >= n; --i)
#define asort(a) sort(a.begin(), a.end())
#define vi vector<int>
#define pb push_back
#define mpp make_pair
#define fi first
#define se second
#define mem(a, n) memset(a, n, sizeof(a))
#define mem0(a) memset(a, 0, sizeof(a))

using namespace std;
typedef long long ll;

int main() {
    int w, h, x, y;
    sf("%d %d %d %d", &w, &h, &x, &y);
    pf("%lf %d\n", (double)w * h / 2.0, ((2*x == w) && (2*y == h)));
    return 0;
}


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

int main()
{
  int A, B;
  cin >> A >> B;
  int ans = 0;
  int sum = A + (A - 1);
  ans = max(ans, sum);
  sum = B + (B - 1);
  ans = max(ans, sum);
  sum = A + B;
  ans = max(ans, sum);
  cout << ans << endl;
}

Measured memory_bytes: 256