akhauriyash/Code-Regression huggingface dataset:
n, m = [int(_) for _ in input().split()]

devs = []
for i in range(1,int((m+1) ** (1/2))+1):
    if m % i == 0:
        devs.append(i)
        devs.append(m // i)

devs = sorted(list(set(devs)), reverse=True)

for dev in devs:
    if m // dev >= n:
        print(dev)
        break

Measured memory_bytes: 3188
import sys

def main():
  input = sys.stdin.readline
  N = int(input())
  X = list(map(int, input().split()))
  Y = sorted(X)
  Ml, Mr = Y[N//2-1], Y[N//2]
  for i in range(N):
    if X[i] <= Ml:
      print(Mr)
    else:
      print(Ml)


if __name__ == '__main__':
  main()

Measured memory_bytes: 26028
package main

import "fmt"

func main(){
	var N, M int
	var L []int
	var ans int

	fmt.Scan(&N,&M)


	for i:=0; i<N; i++{
		//var k []int
		var x int
		fmt.Scan(&x)

		for j:=0; j<x; j++{
			var tmp int
			fmt.Scan(&tmp)
			L = append(L, tmp)
		}
		//L = append(L, k)
	}

	for i:=1; i<=M; i++{
		count := 0
		for _,num := range L {
			if num == i {
				count ++
			}
		}
		if count == N {
			ans ++
		}
	}

	fmt.Println(ans)
}


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

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int T = sc.nextInt();
        int K = sc.nextInt();
        int[] list = new int[T];
        for(int i = 0 ; i < T ; i++)
            list[i] = sc.nextInt();
        int[] dp = new int[T];
        Arrays.fill(dp,Integer.MAX_VALUE);
        dp[0] = 0 ;
        for(int i = 1 ; i < T ; i ++)
        {
            for(int j = 1 ; j <= K ;j++)
            {
                if(i-j<0)
                    break;
                dp[i] = Math.min(dp[i-j] + Math.abs(list[i] - list[i-j]) , dp[i]);
            }
        }
        System.out.println(dp[T-1]);

    }
}


Measured memory_bytes: 50564
import sys
import heapq

X, Y, Z , K = map(int, sys.stdin.readline().split())
A = sorted(list(map(int, sys.stdin.readline().split())), reverse=True)
B = sorted(list(map(int, sys.stdin.readline().split())), reverse=True)
C = sorted(list(map(int, sys.stdin.readline().split())), reverse=True)

ans_heapq = []
i = 0
j = 0
k = 0
heapq.heappush(ans_heapq, [-1 * (A[0] + B[0] + C[0]), i, j, k])
ijk_list = [[0, 0, 0]]
            
for _ in range(K):
    ans, i, j, k = heapq.heappop(ans_heapq)
    print(-1 * ans)
    if i < X - 1 and [i + 1, j, k] not in ijk_list:
        abc = -1 * (A[i + 1] + B[j] + C[k])
        heapq.heappush(ans_heapq, [abc, i + 1, j, k])
        ijk_list.append([i + 1, j, k])
    if j < Y - 1 and [i, j + 1, k] not in ijk_list:
        abc = -1 * (A[i] + B[j + 1] + C[k])
        heapq.heappush(ans_heapq, [abc, i, j + 1, k])
        ijk_list.append([i, j + 1, k])
    if k < Z - 1 and [i, j, k + 1] not in ijk_list:
        abc = -1 * (A[i] + B[j] + C[k + 1])
        heapq.heappush(ans_heapq, [abc, i, j, k + 1])
        ijk_list.append([i, j, k + 1])

Measured memory_bytes: 4724
import sys

input = sys.stdin.readline
N = int(input())
S = input().rstrip()
Q = int(input())
K = list(map(int, input().split()))

ds = [0] * N
ms = [0] * N
dms = [0] * N
cpos = []
for i, c in enumerate(S):
    if i > 0:
        ds[i] += ds[i - 1]
        ms[i] += ms[i - 1]
        dms[i] += dms[i - 1]
    if c == "D":
        ds[i] += 1
    elif c == "M":
        ms[i] += 1
    elif c == "C" and i > 0 and dms[i - 1] > 0:
        cpos.append(i)

    if i > 0 and c == "M":
        dms[i] += ds[i - 1]

for k in K:
    ans = 0
    for i in cpos:
        ans += dms[i - 1]
        if i - k >= 0:
            ans -= dms[i - k] + (ms[i - 1] - ms[i - k]) * ds[i - k]
    print(ans)


Measured memory_bytes: 116136
#include "bits/stdc++.h"
using namespace std;
#define rep(i, n) for(int i=0;i<(n);i++)
typedef complex<double> xy_t;
double cross_product(xy_t a, xy_t b) { return (conj(a) * b).imag(); }
double eps=1e-10;
double x[4], y[4];

int main() {
	while (true) {
		rep(i, 4) cin >> x[i] >> y[i];
		if (!cin) break;
		xy_t a(x[0], y[0]), b(x[1], y[1]), c(x[2], y[2]), p(x[3], y[3]);
		double pab = cross_product(a - p, b - p);
		double pbc = cross_product(b - p, c - p);
		double pca = cross_product(c - p, a - p);
		bool ok = ((pab + eps) > 0 && (pbc + eps) > 0 && (pca + eps) > 0) || ((pab - eps) < 0 && (pbc - eps) < 0 && (pca - eps) < 0);
		cout << (ok ? "YES" : "NO")<<endl;
	}
	return 0;	
}


Measured memory_bytes: 3144
def main():
    N = int(input())
    A = [int(a) for a in input().rstrip().split()]
    sum_A = sum(A)
    sum_N = (N + 1) * N // 2
    if sum_A % sum_N:
        print('NO')
        return

    ope_num = sum_A // sum_N
    diffs = [r - l - ope_num for l, r in zip(A[:-1], A[1:])] + [A[0] - A[-1] - ope_num]
    if all([d % N == 0 and d <= 0 for d in diffs]):
        print('YES')
    else:
        print('NO')


if __name__ == '__main__':
    main()


Measured memory_bytes: 14716
#include <bits/stdc++.h>
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define rep(i,n) for (int i=0;i<(int)(n);i++)
#define codefor int test;scanf("%d",&test);while(test--)
#define yn(ans) if(ans)printf("Yes\n");else printf("No\n")
#define YN(ans) if(ans)printf("YES\n");else printf("NO\n")
#define vector2d(type,name,h,...) vector<vector<type>>name(h,vector<type>(__VA_ARGS__))
#define umap unordered_map
#define uset unordered_set
using namespace std;
using ll = long long;
const int MOD=1000000007;
//入力系
void scan(int& a){scanf("%d",&a);}
void scan(long long& a){scanf("%lld",&a);}
template<class T> void scan(T& a){cin>>a;}
template<class T> void scan(vector<T>& vec){for(auto&& it:vec)scan(it);}
void in(){}
template <class Head, class... Tail> void in(Head& head, Tail&... tail){scan(head);in(tail...);}
//出力系
void print(const int& a){printf("%d",a);}
void print(const long long& a){printf("%lld",a);}
void print(const double& a){printf("%.15lf",a);}
template<class T> void print(const T& a){cout<<a;}
template<class T> void print(const vector<T>& vec){if(vec.empty())return;print(vec[0]);for(auto it=vec.begin();++it!= vec.end();){putchar(' ');print(*it);}}
void out(){putchar('\n');}
template<class T> void out(const T& t){print(t);putchar('\n');}
template <class Head, class... Tail> void out(const Head& head,const Tail&... tail){print(head);putchar(' ');out(tail...);}
//デバッグ系
template<class T> void dprint(const T& a){cerr<<a;}
template<class T> void dprint(const vector<T>& vec){if(vec.empty())return;cerr<<vec[0];for(auto it=vec.begin();++it!= vec.end();){cerr<<" "<<*it;}}
void debug(){cerr<<endl;}
template<class T> void debug(const T& t){dprint(t);cerr<<endl;}
template <class Head, class... Tail> void debug(const Head& head, const Tail&... tail){dprint(head);cerr<<" ";debug(tail...);}

int main(){
    ll ans=0;
    string s;
    while(1){
        cin>>s;
        if(s=="0")break;
        ans=0;
        for(int i=0;i<s.length();i++){
            ans+=stoi(s.substr(i,1));
        }
        out(ans);
    }
}



Measured memory_bytes: 3352
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n, a[100010];
  cin >> n;
  for(int i = 0; i < n; i++) cin >> a[i];
  int dp[100010];
  dp[0] = dp[1] = 0; dp[2] = abs(a[0]-a[1]);
  for(int i = 3; i <= n; i++){
    dp[i] = min( dp[i-2]+abs(a[i-3]-a[i-1]), dp[i-1]+abs(a[i-2]-a[i-1]) );
  }
  cout << dp[n] << endl;
}

Measured memory_bytes: 1024
#include<stdio.h>
#include<stdlib.h>

int main(void)
{
    int N, K;
    scanf("%d %d", &N, &K);
    char *str = (char*)malloc((N+3)*sizeof(char));
    scanf("%s", str);
    str[K-1] = 'a' + (str[K-1] - 'A');
    printf("%s\n", str);
    free(str);
    return 0;
}

Measured memory_bytes: 128
def solve():
    N, K = list(map(int, input().split()))
    if(N >= K):
        tmp = N - ((N // K) * K)
        ans = min(tmp, abs(abs(tmp) - K))
    elif(N < K):
        if(K <= 2*N):
            ans = abs(N - K)
        else:
            ans = abs(N)
    print(ans)

if __name__ == "__main__":
    solve()

Measured memory_bytes: 61884
#include <iostream>
#include <vector>
#include<algorithm>
#include<string>
#include<stdio.h>
#include<map>
#include<math.h>
#include<queue>
using namespace std;
using ll = long long;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
const int MOD = 1000000007;
const int mod = 1000000007;
const int INF = 1000000000;
const long long LINF = 1e18;
const int MAX = 510000;
int gcd(int a, int b)
{
	if (a % b == 0)
	{
		return(b);
	}
	else
	{
		return(gcd(b, a % b));
	}
}
int main(){
	int g, n;
	cin >> n;
	vector<int> a(n);
	for (int i = 0; i < n; i++) {
		cin >> a.at(i);
	}
	g = a.at(0);
	for (int i = 0; i < n; i++) {
		g = gcd(g, a.at(i));
	}
	cout << g << endl;
		return 0;

	
}

Measured memory_bytes: 3780
#include<bits/stdc++.h> 
using namespace std;
int main()
{
	int a,b,c;
	scanf("%d%d%d",&a,&b,&c);
	if(b<a)swap(a,b);
	if(c<a)swap(a,c);
	if(c<b)swap(b,c);
	printf("%d\n",abs(b-a)+abs(c-b));
}

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

typedef long long ll;
const int N = 1010;
const ll INF = 0x3f3f3f3f3f3f3f3f;
struct edge
{
    int to, cost, next;
}g[N*10];
int cnt, head[N];
int num[N];
ll dis[N];
bool vis[N];
void add_edge(int v, int u, int cost)
{
    g[cnt].to = u, g[cnt].cost = cost, g[cnt].next = head[v], head[v] = cnt++;
}
void spfa(int s, int t, int n)
{
    queue<int> que;
    memset(dis, 0x3f, sizeof dis);
    memset(vis, 0, sizeof vis);
    memset(num, 0, sizeof num);
    que.push(s), dis[s] = 0, vis[s] = true, num[s]++;
    bool flag = false;
    while(! que.empty())
    {
        int v = que.front(); que.pop();
        vis[v] = false;
        for(int i = head[v]; i != -1; i = g[i].next)
        {
            int u = g[i].to;
            if(dis[u] > dis[v] + g[i].cost)
            {
                dis[u] = dis[v] + g[i].cost;
                if(! vis[u])
                {
                    vis[u] = true, que.push(u);
                    num[u]++;
                    if(num[u] >= n && num[t] >= n)
                    {
                        printf("inf\n"); return;
                    }
                    if(num[u] >= 2*n)
                    {
                        flag = true; break;
                    }
                }
            }
        }
        if(flag) break;
    }
    printf("%lld\n", -dis[t]);
}
int main()
{
    int n, m, a, b, c;
    scanf("%d%d", &n, &m);
    cnt = 0;
    memset(head, -1, sizeof head);
    for(int i = 1; i <= m; i++)
    {
        scanf("%d%d%d", &a, &b, &c);
        add_edge(a, b, -c);
    }
    spfa(1, n, n);
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(){
  int n,h[100],r,l,min,count=0,
      i,j,k;
  
  scanf("%d", &n);
  for(i=0;i<n;i++){
    scanf("%d",&h[i]);
  }
  
  for(i=0;i<n;){
    while(h[i] == 0){
      i++;
      if(i == n){
        break;
      }
    }
    if(i == n){
      break;
    }
    j = i;
    min = 100;
    while(h[j] != 0){
      if(min > h[j]){min = h[j];}
      j++;
      if(j == n){
        break;
      }
    }
    
    for(k=i;k<j;k++){
      h[k] -= min;
    }
    count += min;
  }
  printf("%d", count);
  return 0;
}

Measured memory_bytes: 128
#include <iostream>
using namespace std;
int main(){
  int n;
  cin >> n;
  int count=0;
  for (int j=1;j<=n;j++){
  int yakusu=0;
   for(int i=1;i<=j;i++){
     if(j%i==0){
      yakusu++;
    }
   }
  if(yakusu==8&&j%2==1){
    count++;
  }
  }
  cout << count << endl;
}
    

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

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

  if(s[2]==s[3]){
    if(s[4]==s[5]){
      cout << "Yes" << endl;
    }
    else{
      cout << "No" << endl;
    }
  }
  else{
    cout << "No" <<endl;
  }
  return 0;
}

Measured memory_bytes: 3616
#include<iostream>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>
#include<iomanip>
#include<map>
using namespace std;
#define ll long long
#define pb push_back
#define mp make_pair
#define t ll t;cin>>t;while(t--)
#define nn cout<<endl;
int main()
{
	char a;
	cin>>a;
	if(a=='A')cout<<"T\n";
	else if(a=='T')cout<<"A\n";
	else if(a=='C')cout<<"G\n";
	else if(a=='G')cout<<"C\n";
}

Measured memory_bytes: 3576
#include<bits/stdc++.h>
using namespace std;
long long n;
long long k;
long long a[2000006];
int main()
{
	cin >> n;
    int count = 0;
    for(int i=0;i < n; i++)
    {
        cin >> a[i];
    }
    for(int i=1;i <= n; i++)
    {
        if(a[i-1] != i) {
            count++;
        }
    }
    if(count == 0 || count == 2) {
        cout << "YES";
    } else {
        cout << "NO";
    }
}


Measured memory_bytes: 256
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using static System.Console;
using static System.Linq.Enumerable;

class Program
{
    static void Main()
    {
        var (A, B) = ReadLine().Split(' ').Select(int.Parse).ToArray();

        var ans = Math.Max(Math.Max(A + B, A - B), A * B);

        WriteLine(ans);
    }
}

static class ArrayDeconstructExtensions
{
    public static void Deconstruct<T>(this T[] a, out T i1, out T i2) => (i1, i2) = (a[0], a[1]);
    public static void Deconstruct<T>(this T[] a, out T i1, out T i2, out T i3) => (i1, i2, i3) = (a[0], a[1], a[2]);
    public static void Deconstruct<T>(this T[] a, out T i1, out T i2, out T i3, out T i4) => (i1, i2, i3, i4) = (a[0], a[1], a[2], a[3]);
    public static void Deconstruct<T>(this T[] a, out T i1, out T i2, out T i3, out T i4, out T i5) => (i1, i2, i3, i4, i5) = (a[0], a[1], a[2], a[3], a[4]);
}


Measured memory_bytes: 28248
#include<bits/stdc++.h>
typedef long long int ll;
using namespace std;
ll n,k,x,i;
map<ll,ll>a;
ll falcon(ll p){
 while(p){
    if(a[p%10]){
        return 0;
        break;
    }
    else
        p/=10;
 }
 return 1;
}
int main()
{
    cin>>n>>k;
    for(i=0;i<k;i++){
        cin>>x;
        a[x]++;
    }
    while(1){
        if(falcon(n)){
            cout<<n<<endl;
            return 0;
        }
        n++;

    }
}


Measured memory_bytes: 3604
#include <iostream>
#include <cstdio>
#include <cstring>
#include <string>
#include <vector>
#include <iostream>
#include <cstdio>
#include <cstring>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <numeric>
#include <cassert>
#include <memory>
#include <stack>
#include <set>
#include <map>
#include <cctype>
#include <climits>

#define MAX_SIZE 100000000
typedef long long ll;
typedef unsigned long long ull;
using namespace std;

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

  int H,W; cin>>H>>W;
  vector<string> grid(H);
  for(auto& g: grid) {
    cin>>g;
  }

  vector<int> dx = {0, -1, 1, 0}; // up, left, right, down
  vector<int> dy = {-1, 0, 0, 1};

  bool ans = true;
  for(int i = 0; i < H; i++) {
    for(int j = 0; j < W; j++) {
      if(grid[i][j] != '#') {
        continue;
      }
      bool success = false;
      for(int k = 0; k < 4; k++) {
        int nx = j + dx[k], ny = i + dy[k];
        if(!(nx >= 0 && nx < W) || !(ny >= 0 && ny < H)) {
          continue;
        }
        if(grid[ny][nx] == '#') {
          success = true;
        }
      }
      if(!success) {
        ans = false;
        break;
      }
    }
  }

  string ret = "Yes";
  if(!ans) ret = "No";
  cout << ret << endl;
}


Measured memory_bytes: 256
import Data.Maybe
main :: IO ()
main = do
  s <- getLine
  let r = solve s ['a'..'z']
  putStrLn $ if isNothing r then "None" else [fromJust r]

solve :: String -> String -> Maybe Char
solve _ "" = Nothing
solve s (c:cs) = 
  let 
    f = filter (/=c) s
     in if length f == length s then Just c else solve f cs

Measured memory_bytes: 12540
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        String s = sc.next();
        int x = 0;
        int max = 0;
        for(int i = 0; i < n; i++) {
           if(s.charAt(i) == 'I') {
               x++;
           } else {
               x--;
           }
           max = Math.max(max, x);
        }
        System.out.println(max);
    }
}

Measured memory_bytes: 9684
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<stack>
#include<queue>
#include<map>
#include<functional>
#include<math.h>

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

int main() {
	int n;
	cin >> n;
	vector<ll> a(n);
	rep(i, n) cin >> a[i];

	ll cnt4 = 0;
	ll cnt2 = 0;
	ll cnto = 0;
	rep(i, n) {
		if (a[i] % 4 == 0) {
			cnt4++;
		}
		else if (a[i] % 2 == 0) {
			cnt2++;
		}
		else {
			cnto++;
		}
	}
	if (cnt2 > 0) {
		cnto++;
	}
	cnto -= cnt4 + 1;
	//printf("%d %d\n", cnt4, cnt2);
	puts(cnto <= 0 ? "Yes" : "No");


	return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define inf 0x7fffffff
#define eps 1e-6
using namespace std;
typedef long long ll;
const ll mod = 1e9 + 7;
//const double pi = acos(-1);
inline ll read(){
    ll x=0,f=1;char ch=getchar();
    while(ch>'9'||ch<'0'){if(ch=='-')f=-1;ch=getchar();}
    while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
    return x*f;
}
int n,k,x;
int a[200005],b[200005],cnt1,cnt2;
ll ans=1;
int main(){
    int i,j;
    n=read(),k=read();
    for(i=1;i<=n;i++) {
		x=read();
    	if(x>=0) a[++cnt1]=x;
		else b[++cnt2]=-x;
	}
	if(n==k){
		for(i=1;i<=cnt1;i++) ans=ans*a[i]%mod;
		for(i=1;i<=cnt2;i++) ans=ans*b[i]%mod;
		if(cnt2%2==1) ans=(mod-ans)%mod;
		cout<<ans;
		return 0;
	}
	sort(a+1,a+cnt1+1),sort(b+1,b+cnt2+1);
	if(!cnt1){
		if(k%2==0){
			for(i=cnt2;i>=cnt2-k+1;i--) ans=ans*b[i]%mod;
		}
		else {
			for(i=1;i<=k;i++) ans=ans*b[i]%mod;
			ans=(mod-ans)%mod;
		}
		cout<<ans;
		return 0;
	}
	while(k){
		if(k==1) ans=ans*a[cnt1]%mod,k--;
		else{
			if(cnt2<=1){
				for(i=cnt1;i>=cnt1-k+1;i--) ans=ans*a[i]%mod;
				k=0;
				break;
			}
			if(cnt1<=1){
				if(k%2==0){
					for(i=cnt2;i>=cnt2-k+1;i--) ans=ans*b[i]%mod;
					k=0;
					break;
				}
				else{
					for(i=cnt2;i>=cnt2-k+2;i--) ans=ans*b[i]%mod;
					k=0;
					ans=ans*a[1]%mod;
					break;
				}
			}
			if(1ll*a[cnt1]*a[cnt1-1]<=1ll*b[cnt2]*b[cnt2-1]) ans=ans*b[cnt2]%mod*b[cnt2-1]%mod,cnt2-=2;
			else ans=ans*a[cnt1]%mod*a[cnt1-1]%mod,cnt1-=2;
			k-=2; 
		}
	}
	cout<<ans;
    return 0;
}

Measured memory_bytes: 4388
n = int(input())
a = sorted(list(map(int, input().split())))

def gcd(a, b):
    return a if b == 0 else gcd(b, a % b)

left = [0 for _ in range(n + 1)]
right = [0 for _ in range(n + 1)]

for i in range(n):
    left[i + 1] = gcd(left[i], a[i])

for i in range(n - 1, -1, -1):
    right[i] = gcd(right[i + 1], a[i])

k = 0

for i in range(n):
    g = gcd(left[i], right[i + 1])

    if g > k:
        k = g

print(k)


Measured memory_bytes: 14488
#include<iostream>
#include<algorithm>
using namespace std;
int main()
{   int n;
    double sum=0,s[51],a[51];
    cin>>n;
    s[1]=2;
    for(int i=1;i<=n;i++)
      cin>>a[i];
    sort(a+1,a+1+n);
    for(int i=2;i<=n-1;i++)
      s[i]=s[i-1]*2;
    sum+=(a[1]+a[2])/s[n-1];
    for(int i=n-2;i>=1;i--)
      sum+=a[n-i+1]/s[i];
    cout<<sum;
    return 0;
}

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

void ioinit() { ios::sync_with_stdio(0); cin.tie(0); }

int main() {
  ioinit();
  int N, p = 0;
  string ret[] = {"NA","MMYY","YYMM","AMBIGUOUS"};
  cin >> N;
  if(1300 > N && N > 99) p++;
  N %= 100;
  if(13 > N && N > 00) p += 2;
  cout << ret[p] << endl;
}


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

using ll = long long;

int F[10000001] = {};
int main() {
	int N;
	ll ans = 0;
	scanf("%d", &N);
	for(int i=1;i<=N;i++) {
		for(int j=i;j<=N;j+=i) {
			F[j]++;
		}
		ans += (ll)i*F[i];
	}
	cout << ans << endl;
}

Measured memory_bytes: 42708
import java.util.*;

public class Main{
    public static void main(String[] args) {
        
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int sum = 0;
        for(int i = 1; i <= n; i++){
            sum += i;
        }
        System.out.println(sum);
    }
}

Measured memory_bytes: 35560
n = int(input()) # 宮殿の候補数
t,a = map(int,input().split())
x_li = list(map(int,input().split())) #標高のリスト

x_temp_li = []
x_a_li = []
for i in x_li:
    temp = t - i * 0.006
    x_temp_li.append(temp)
for i in x_temp_li:
    temp_a = i - a
    x_a_li.append(abs(temp_a))
print(x_a_li.index(min(x_a_li)) + 1)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;
#define chmax(x,y) x = max(x,y);
#define chmin(x,y) x = min(x,y);
const int di[] = {-1, 0, 1, 0};
const int dj[] = {0, -1, 0, 1};
const int INF = 1001001001;



int main() {
    string s, t;
    cin >> s >> t;
    string a = s;
    a += s;
    int n = s.size();
    string ans = "No";
    rep(i,n) {
        string now;
        rep(j,n) now += a[i+j];
        if (now == t) ans = "Yes";
    }
    cout << ans << endl;
    return 0;
}

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

// dp[i][500yen][num_1000yen] := remain ([i] is deleted)
int dp[128][512];
int n;
int P[128];

void init() {
  for(int j = 0; j < 128; ++j) {
    for(int k = 0; k < 512; ++k) {
      dp[j][k] = -1;
    }
  }
}

int main() {
  for(;;) {
    init();
    scanf("%d", &n);
    if( n == 0 ) break;
    for(int i = 0; i < n; ++i) {
      scanf("%d", &P[i]);
    }
    dp[0][0] = 0;
    for(int i = 0; i < n; ++i) {
      for(int j = n-1; j >= 0; --j) {
        for(int k = 512 - 1; k >= 0; --k) {
          if( dp[j][k] == -1 ) continue;
          int n1kyen = (P[i] + 999) / 1000;
          int rem = dp[j][k] + n1kyen * 1000 - P[i];
          int next_num500yen = j + (rem >= 500 ? 1 : 0);
          int next_num1kyen  = k + n1kyen;
          int next_rem       = rem >= 500 ? rem - 500 : rem;
          int& next = dp[next_num500yen][next_num1kyen];
          next = std::max(next, next_rem);
        }
      }
    }    
    int res = (1 << 28);
    int max = -1;
    for(int j = n; j >= 0; --j) {
      for(int k = 0; k < 512; ++k) {
        if( dp[j][k] == -1 ) continue;
        int cost = k * 1000 - 500 * j - dp[j][k];
        res = std::min(res, cost);
      }
      if( res != (1 << 28) ) {
        max = j;
        break;
      }
    }
    printf("%d %d\n", max, res);
  }

  return 0;
}

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

int main(){
    int n;
    int a=4,b=7;
    cin >> n;
    if((n+a)%a==0||(n+b)%b==0){
        cout << "Yes" <<endl;
        return 0;
    }
    int ch = n/b;
    for(int i=ch;i>0;i--){
        int temp = n-(b*i);
        if(temp%a==0){
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
    return 0;
}

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

#define rep(i,l,r) for(int i=(l);i<(r);i++)
#define pb push_back
#define fi first
#define se second

using ll = long long;
using G = vector<vector<int>>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
const ll MOD = 1000000007;

ll GCD(ll x, ll y){
	return y ? GCD(y, x%y) : x;	
}
ll LCM(ll x, ll y){
	return x/GCD(x, y)*y;
}

int main() {
	int a, b, k; cin >> a >> b >> k;
	int cnt = 0;
	for(int i=100;i>=0;i--){
		if(a%i==0 && b%i==0){
			cnt++;
		}
		if(cnt==k){
			cout << i << endl;
			return 0;
		}
	}
	return 0;
}

Measured memory_bytes: 3636
n = int(input())
a = list(map(int, input().split()))

flag = True
for i in range(n-1):
    if a[n-i-2] > a[n-i-1]:
        a[n-i-2]-= 1

    if a[n-i-2] > a[n-i-1]:
        flag = False
        break

print("Yes") if flag else print("No")


Measured memory_bytes: 14396
#include <bits/stdc++.h>
using namespace std;
 
 
typedef long long ll;
typedef pair<int,int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef long double ld;
 
typedef set<int>::iterator sit;
typedef map<int,int>::iterator mit;
typedef vector<int>::iterator vit;
 
const int INF = 1e9 + 7;
const int MOD = 1e9 + 7;
const int MAXN = 1e6 + 3;
 
#define _  %  MOD
#define __ %= MOD
 
#define      each(it,s)        for(auto it = s.begin(); it != s.end(); ++it)
#define      sortA(v)          sort(v.begin(), v.end())
#define      sortD(v)          sort(v.begin(), v.end(), greater<auto>())
#define      fill(a)           memset(a, 0, sizeof (a))
 
#define      swap(a,b)        {a=a+b;b=a-b;a=a-b;}
#define      rep(i, n)         for(ll i = 0; i < (n); ++i)
#define      repA(i, a, n)     for(ll i = a; i <= (n); ++i)
#define      repD(i, a, n)     for(ll i = a; i >= (n); --i)
#define watch(x) cout << (#x) << " is " << (x) <<endl
 
#define fi first
#define se second
#define mp make_pair
#define pb push_back
 
#define fbo find_by_order
#define ook order_of_key
 
ll gcd(ll a,ll b){if(b==0) return a; else return gcd(b,a%b);}
ll power(ll x,ll y){ll res=1; while(y>0){if(y&1) res=res*x;y=y>>1;x=x*x;}return res;} // modular exponent
 
int main()
{
    ios_base::sync_with_stdio(false); // don't use printf and scanf
    cin.tie(NULL); // cout<<fixed<<setprecision
 	string s;
 	cin>>s;
	int ans=0;
	for(int i=0;i<3;)
	{
		if(s[i]=='S')
		{
			i++;
			continue;
		}
		int len=0;
		while(i<3 && s[i]=='R')
		{
			i++;
			len++;
		}
		ans=max(ans,len);
	}	
	cout<<ans<<'\n';
	return 0;
}
// JUST ASK YOURSELF DID YOU GIVE YOUR BEST ? ISSE ZYADA
// KUCH KAR BHI NAHI SAKTE !! ENJOY AND GIVE YOUR BEST!!



Measured memory_bytes: 3604
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define EPS (1e-7)
#define INF (1e9)
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
const double PI = acos(-1);
const ll MOD = 1000000007;
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;
}
///////////////////////////////////////////////////////////////

int main() {
    ios::sync_with_stdio(false); cin.tie(nullptr);
    int N; cin >> N;
    vector<int> L(2*N);
    rep(i,2*N) cin >> L[i];

    sort(all(L));

    int ans = 0;
    rep(i,2*N) if (i % 2 == 0) ans += L[i];
    cout << ans << endl;
}


Measured memory_bytes: 256
import java.util.*;

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

        int a = sc.nextInt();
        int b = sc.nextInt();

        if (a % 2 != b %2) {
            System.out.println("IMPOSSIBLE");
        } else {
            System.out.println((a + b) / 2);
        }
    }
}

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

#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define BIT(X,i) ((X>>i)&1)
#define REP(i,a,b) for(int i = (a); i < (b); ++i)
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define SORT(a) sort(all(a))
#define RSORT(a) sort(rall(a))
#define ina(x,n) rep(x_i,n) cin>>x[x_i]
#define outa(x,n) rep(x_i,n) cerr<<x[x_i]<<" \n"[x_i==n-1]

using ll  = long long int;
using vl  = vector<ll>;
using vvl = vector<vl>;
using pll = pair<ll, ll>;
using vll = vector<pll>;

const int inf = (1<<28);
const ll infl = (1LL<<60);
const int mod = 1e9+7;
const int MAX_LEN = 100000;

int main() {
    string s; cin >> s;
    deque<char> S(all(s));

    int q; cin >> q;
    int dir = 0;
    for (int i = 0; i < q; ++i) {
        int t; cin >> t;
        if (t == 1) {
            dir = 1 - dir;
            continue;
        }

        int f; cin >> f; f--;
        char c; cin >> c;
        if (f ^ dir == 0) {
            S.push_front(c);
        }
        if (f ^ dir == 1) {
            S.push_back(c);
        }
    }
    if (dir == 1) {
        reverse(all(S));
    }
    for (const auto& c : S) {
        cout << c;
    } cout << endl;
    return 0;
}


Measured memory_bytes: 896
A,B,K=map(int, raw_input().split())
c=set()
for i in range(A,min(B+1,A+K)):
	c.add(i)

for i in range(B,max(A-1,B-K),-1):
	c.add(i)


a=list(c)
a.sort()
for i in a:
	print i


Measured memory_bytes: 2568
#include <iostream>
#include <climits>
using namespace std;
int x,y,X,Y,mn,i,j;
int main()
{
    cin>>x>>y;mn=INT_MAX;
    for(i=-1;i<=1;i+=2)
        for(j=-1;j<=1;j+=2)
    {
        X=x*i;Y=y*j;
        if(X<=Y)
            mn=min(mn,Y-X+(i<0)+(j<0));
    }
    cout<<mn;
    return 0;
}


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

ll n,k;
char s[210];

inline int rd()
{
	int x=0;char ch=getchar();
	for (;ch<'0'||ch>'9';ch=getchar());
	for (;ch>='0'&&ch<='9';ch=getchar()) x=x*10+ch-'0';
	return x;
}

int main()
{
	scanf("%s",s+1);
	n=strlen(s+1);k=rd();
	for (int i=1;i<=n;i++) s[n+i]=s[i];
	bool flag=true;
	for (int i=1;i<=n;i++) if (s[i]!=s[1]) flag=false;
	if (flag) { printf("%lld\n",n*k/2);return 0; }
	int id=0;
	for (int i=2;i<=n;i++) if (s[i]!=s[i-1]) id=i;
	ll sum=0;
	for (int i=id,j;i<id+n;i=j)
	{
		for (j=i;j<id+n&&s[j]==s[i];j++);
		sum+=(j-i)/2;
	}
	ll ans=sum*(k-1);
	for (int i=1,j;i<=n;i=j)
	{
		for (j=i;j<=n&&s[j]==s[i];j++);
		ans+=(j-i)/2;
	}
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<cctype>
#include<cmath>
#define reg register
typedef long long ll;
template<typename T>inline T read(){
	reg T x=0,f=1;reg char ch=getchar();
	for(;!isdigit(ch);f=ch=='-'?-1:1,ch=getchar());
	for(;isdigit(ch);x=(x*10)+(ch^48),ch=getchar());
	return x*f;
}
#define min(a,b) (a<b?a:b)
#define max(a,b) (a>b?a:b)
#define S 0
#define T (n+1)
#define y1 Y1
typedef long double ld;
ld g[1010][1010];
int n,x1,x2,y1,y3;
int x[1010],y[1010],r[1010];
inline ld sqr(int x){return ((ld)(x))*x;}
inline ld dis(int x1,int y1,int x2,int y3){
	return sqrt(ld(sqr(x1-x2)+sqr(y1-y3)));
}
ld d[1010];
bool vis[1010];
void Dij(){
	d[S]=0;vis[S]=1;
	for(reg int i=1;i<=T;i++)d[i]=g[S][i];
	for(reg int i=2;i<=T;i++){
		reg int id=S;
		ld minv=1e25;
		for(reg int j=1;j<=T;j++)
			if(!vis[j]&&d[j]>=0&&d[j]<minv)id=j,minv=d[j];
		vis[id]=1;
		for(reg int j=1;j<=T;j++)
			if(!vis[j]&&g[id][j]>=0)
				if(d[id]+g[id][j]<d[j])d[j]=d[id]+g[id][j];
	}
}
int main(){
	x1=read<int>();y1=read<int>();x2=read<int>();y3=read<int>();
	n=read<int>();g[S][T]=dis(x1,y1,x2,y3);
	for(reg int i=1;i<=n;i++)
		x[i]=read<int>(),y[i]=read<int>(),r[i]=read<int>();
	for(reg int i=1;i<=n;i++)
		for(reg int j=1;j<=n;j++)
			if(i!=j)
		g[i][j]=g[j][i]=max(dis(x[i],y[i],x[j],y[j])-r[i]-r[j],0.0);
	for(reg int i=1;i<=n;i++){
		g[S][i]=max(dis(x1,y1,x[i],y[i])-r[i],0.0);
		g[i][T]=max(dis(x[i],y[i],x2,y3)-r[i],0.0);
	}
	Dij();double ans=d[T];
	printf("%.15lf\n",ans);
    return 0;
}

Measured memory_bytes: 16000
#include <iostream>
#include <assert.h>
#include <vector>
#include <unordered_map>
#include <queue>
#include <climits>
#include <cmath>
#include <algorithm>
using namespace std;
constexpr int64_t MOD = 1e9 + 7;

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

  string S;
  cin >> S;
  if (S.size() < 6) {
    cout << "No" << endl;
  } else if (S[2] == S[3] && S[4] == S[5]) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }

  return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
////////////////////////////////////////////////////////////
#define all(x) (x).begin(), (x).end()
const int inf = 1e9;
const long long INF=1e15;
#define endl '\n'
#define rep(i, n) for(int i=0;i<(n);++i)
#define repp(i, a, b) for(int i=(a);i<=(b);++i)
#define pb push_back
#define eb emplace_back
#define fastio ios::sync_with_stdio(false);cin.tie(0); //cout.tie(0);

using namespace std;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

typedef long long ll;
typedef pair<int,int> ii;
typedef pair<ll,ll> llll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<ii> vii;

void solve() {
	ll x, y, a, b, c;
	cin >> x >> y >> a >> b >> c;
	vll p(a), q(b), r(c);
	rep(i, a) cin >> p[i];
	rep(i, b) cin >> q[i];
	rep(i, c) cin >> r[i];
	sort(all(p)); sort(all(q)); sort(all(r));
	reverse(all(p)); reverse(all(q)); reverse(all(r));
	priority_queue<ll, vll, greater<ll> > pq1, pq2;
	ll sum = 0;
	rep(i, x) pq1.push(p[i]), sum += p[i];
	rep(i, y) pq2.push(q[i]), sum += q[i];
	rep(i, c) {
		ll one = INF, two = INF;
		if(!pq1.empty()) one = pq1.top();
		if(!pq2.empty()) two = pq2.top();
		if(one == INF && two == INF) break;
		ll opt = min(one, two);
		if(opt < r[i]) {
			sum += r[i] - opt;
			if(opt == one) pq1.pop();
			else pq2.pop();
		}
	}
	cout << sum;
}
int main() {
	fastio;
	solve();
}

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

#define MAX 200005
#define INFTY INT_MAX;

ll invCount = 0;

void merge(int *a, int left, int mid, int right)
{
    int n1 = mid - left;
    int n2 = right - mid;

    int *l, *r;
    l = new int[n1+1];
    r = new int[n2+1];

    for (int i = 0; i < n1; i++)
        l[i] = a[left+i];
    for (int i = 0; i < n2; i++)
        r[i] = a[mid+i];
    l[n1] = r[n2] = INFTY;

    int i = 0;
    int j = 0;
    for (int k = 0; k < n1+n2; k++) {
        if (l[i] <= r[j]) {
            a[left+k] = l[i];
            i++;
        } else {
            a[left+k] = r[j];
            j++;
            invCount += n1-i;
        }
    }

    delete[] l;
    delete[] r;

}

void mergeSort(int* a, int left, int right)
{
    if (left + 1 >= right) return;
    int mid = (left + right) / 2;
    mergeSort(a, left, mid);
    mergeSort(a, mid, right);
    merge(a, left, mid, right);
}

int main(int, char**)
{
    int n;
    cin >> n;

    int *a;
    a = new int[MAX];
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }
    mergeSort(a, 0, n);

    cout << invCount << endl;
    delete[] a;

    return 0;
}


Measured memory_bytes: 4368
#include<iostream>
#include<stdio.h>
#include<string>
#include<vector>
#include<map>
#include<tuple>
#include<algorithm>
#include<cmath>
#include<limits>
#include<set>
#include<queue>
using namespace std;
#define int long  long int
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a / gcd(a, b) * b; }
typedef pair<int, int>P;
const int INF = 1e15;

signed main() {
	int N;
	cin >> N;
	map<int, int>m;
	int num;
	int free = 0;
	rep(i, N) {
		cin >> num;
		num /= 400;
		if (num >= 8)free++;
		else m[num]++;
	}
	if (m.size() == 0)cout << 1 << " " << free;
	else {
		int mn = m.size();
		int mx = mn + free;
		cout << mn << " " << mx;
	}
}

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

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

    vector<int> A(N);
    int sum = 0;
    for(int i=0; i<N; i++){
        cin>> A[i];
        sum += A[i];
    }
    
    sort(A.begin(), A.end() ,greater<int>());
  /*  
    for(int i=0; i<M; i++){
        if(sum/(4*M) > A[i]){
            cout<<"No"<<endl;
            return 0;
        }
    }
*/
if(A[M-1] >= (sum+(4*M-1))/(4*M)){
    cout<<"Yes"<<endl;
}else{
    cout<<"No"<<endl;
}
    return 0;
}

Measured memory_bytes: 3572
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); i++)
#define sz(x) int(x.size())
typedef long long ll;
const int inf = 100100100;


int main(){
  int n,m;
  cin >> n >> m;
  vector<vector<int>> g(n);

  rep(i,m){
    int a,b;
    cin >> a >> b;
    a--; b--;
    g[a].push_back(b);
    g[b].push_back(a);
  }

  bool flag = 0;
  for(auto v : g[0]){
    for(auto to : g[v]){
      if(to == n-1) flag = 1;
    }
  }
  if(flag) cout << "POSSIBLE" << endl;
  else cout << "IMPOSSIBLE" << endl;
}


Measured memory_bytes: 14960
#include <stdio.h>

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

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

    sum   = a + b;
    i     = 10;
    digit = 1;

    while (sum % i != sum || sum % i == 0) {
      i     *= 10;
      digit += 1;
    }
    
    printf("%d\n", digit);
  }

  return 0;
}

Measured memory_bytes: 600
d,g=map(int,input().split())
pc=[list(map(int,input().split())) for _ in range(d)]
ans=float('inf')
for i in range(2**d):
  al=[]
  notal=[]
  anstmp=0
  score=0
  for j in range(d):
    if (i>>j)&1:al.append(j)
    else:notal.append(j)
  for j in al:
    score+=(j+1)*100*pc[j][0]
    score+=pc[j][1]
    anstmp+=pc[j][0]
  while notal and score<g:
    j=notal.pop()
    k=(g-score+(j+1)*100-1)//((j+1)*100)
    k=min(k,pc[j][0]-1)
    score+=(j+1)*100*k
    anstmp+=k
  if score>=g:ans=min(ans,anstmp)
print(ans)



Measured memory_bytes: 74184
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
using namespace std;
typedef  long long ll;
typedef  vector<int> vi;
typedef  pair<int,int> pii;
typedef  pair<int,string> pis;
double   pi=3.1415926535898;
#define speed      ios::sync_with_stdio(false);cin.tie(NULL); cout.tie(NULL);
#define lop(i,n)   for(int i=0;i<int(n);i++)
#define rep(i,a,b) for(int i=a;i<=int(b);i++)
#define rng(i,a,b) for(int i=a;i>=int(b);i--)
#define ms(x,a)    memset(x,a,sizeof(x))
#define all(x)     (x).begin(),(x).end()
#define sz(x)      int(x.size())
#define pb         push_back
#define r0         return 0;
#define CC         continue;
#define bb(x)      cerr<< x <<endl;
#define F          first
#define S          second       //  __builtin_popcount;
//freopen("output.txt","w",stdout),freopen("input.txt","r",stdin);
const ll M  = 1e9+7 ;
const int N = 100100;
const int inf = INT_MAX;
const double eps = 1e-7;
const ll iinf = -1e18 ;
//////////////////////    Hi    ^_^  hack me if you can :P

int a[200];
int n;
int f[10];

int main()
{
    speed;
    cin >> n ;
    lop(i,n)
    {
        cin >> a[i];
        if (a[i]>=3200)
        {
            f[8]++;
            continue;
        }
        f[(a[i])/400]++;
    }
    int ans = 0;
    rep(i,0,7)
    {
        ans += !!f[i];
    }
    int ff = f[8]>=1;
    cout << max(ff,ans) << ' ' << f[8]+ans <<endl;
}


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

int main(){
	int n = 0,tmp = 0;
	string a,b;
	cin >> a >> b;
	a += b;
	for(int i = 0;i < a.length();i++) n = n * 10 + a[i] - '0';
	while(tmp * tmp < n) tmp++;
	if(tmp * tmp == n) cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 256
n = gets.chomp.split(" ").map(&:to_i)[0]

t = 0
x = 0
y = 0
flag = true
n.times do
    line = gets.chomp.split(" ").map(&:to_i)
    t = line[0] - t
    d = (x - line[1]).abs + (y - line[2]).abs
    if d > t or d % 2 != t % 2
        flag = false
    end
    t = line[0]
    x = line[1]
    y = line[2]
end

if flag
    puts "Yes"
else
    puts "No"
end


Measured memory_bytes: 1788
N = int(input())
W = [int(i) for i in input().split()]

lr = [0] * N
rl = [0] * N
lr[0] = W[0]
rl[-1] = W[-1]

for i in range(1, N):
    lr[i] = W[i] + lr[i-1]

for i in range(0, N-1)[::-1]:
    rl[i] = W[i] + rl[i+1]

sub = [10000] * N
for i in range(N-1):
    sub[i] = abs(lr[i]- rl[i+1])

T = sub.index(min(sub))
print(abs(lr[T] - rl[T+1]))

Measured memory_bytes: 3064
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
using namespace std;

int flag;
char a[105], b[105];
int main()
{
	scanf("%s %s", a, b);
	int lena = strlen(a);
	int lenb = strlen(b);
	if(lena > lenb) printf("GREATER\n");
	else if(lena < lenb) printf("LESS\n");
	else {
		for(int i = 0; i <= lena - 1; i++)
		{
			if(a[i] > b[i]) {printf("GREATER\n");flag = 1; break;}
			if(a[i] < b[i]) {printf("LESS\n"); flag = 1; break;}
		}
		if(flag != 1) printf("EQUAL\n");
	}
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
#define all(x) (x).begin(),(x).end()
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
typedef long long ll;
const long long INF = 1LL << 60;
typedef pair<int, int> P;
int dx[4] = {0, 0, 1, -1};
int dy[4] = {1, -1, 0, 0};
int main()
{
    int H, W;
    cin >> H >> W;
    int b = 0;
    vector<string> s(H);
    rep(i, H) cin >> s[i];
    rep(i, H) {
        rep(j, W) {
            if (s[i][j] == '#') b++;
        }
    }

    vector<vector<int>> d(H, vector<int>(W, -1));
    queue<P> que;
    que.push(P(0, 0));
    d[0][0] = 1;
    int gx = W - 1, gy = H - 1;
    while (!que.empty()) {
        P p = que.front(); que.pop();
        if (gx == p.first && gy == p.second) break;
        rep(i, 4) {
            int tx = dx[i] + p.first, ty = dy[i] + p.second;
            if (tx < 0 || tx >= W || ty < 0 || ty >= H || d[ty][tx] != -1 || s[ty][tx] == '#') continue;
            d[ty][tx] = d[p.second][p.first] + 1;
            que.push(P(tx, ty));
        }
    }

    if (d[gy][gx] == -1) cout << -1 << endl;
    else cout << (H * W) - b - d[gy][gx] << endl;
    return 0;
}

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

#define rep(i, n) for(int i = 0; i < (n); i++)
using ll = long long;
constexpr ll INF = 1000000000;

using namespace std;

ll gcd(ll a, ll b) {
	if (b == 0)return a;
	return gcd(b, a % b);
}
ll lcm(ll a, ll b) {
	return a * b / gcd(a, b);
}

int main() {
	ll n, k; cin >> n >> k;
	vector<int>a(n);
	vector<int>b(n);
	rep(i, n)cin >> a[i] >> b[i];

	vector<pair <ll, ll>>pr(n);
	rep(i, n) {
		pr[i].first = a[i];
		pr[i].second = b[i];
	}
	sort(pr.begin(), pr.end());

	ll sum = 0;
	ll ans = 0;
	for (int i = 0; i < n; i++) {
		sum = sum + pr[i].second;
		if (sum >= k) {
			ans = pr[i].first;
			break;
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 2560
#include <bits/stdc++.h>
using namespace std;
typedef tuple<int, int, int, int> t;

int main(){
  int H, W;
  cin >> H >> W;
  int a[H+1][W+1];
  int ans = 0;
  for(int i = 1; i <= H; i++){
    for(int j = 1; j <= W; j++){
      cin >> a[i][j];
    }
  }
  int count = 0;
  vector<t> v;
  for(int i = 1; i <= H; i++){
    for(int j = 1; j < W; j++){
      if(a[i][j] % 2){
        a[i][j]--;
        a[i][j+1]++;
        count++;
        v.push_back(t(i,j,i,j+1));
      }
    }
  }
  for(int i = 1; i < H; i++){
    if(a[i][W] % 2){
      a[i][W]--;
      a[i+1][W]++;
      count++;
      v.push_back(t(i,W,i+1,W));
    }
  }
  cout << count << endl;
  for(int i = 0; i < v.size(); i++){
    cout << get<0>(v[i]) << " " <<  get<1>(v[i]) << " " <<  get<2>(v[i]) << " " <<  get<3>(v[i]) << endl;
  }
  return 0;
}


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

int main()
{
	while (true) {
		double n;
		cin >> n;
		if (n == 0) break;
		vector<double> s(n);
		for (int i = 0; i < n; i++) cin >> s[i];
		double m = accumulate(s.begin(), s.end(), 0) / n;

		double ans = 0;
		for (int i = 0; i < n; i++) {
			ans += (s[i] - m) * (s[i] - m) / n;
		}
		cout << fixed << setprecision(12) << sqrt(ans) << endl;
	}
}


Measured memory_bytes: 3260
#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>
using namespace std;

struct Edge {
	int to, flow, rev;
	Edge(int to, int flow, int rev) {
		this->to = to;
		this->flow = flow;
		this->rev = rev;
	}
};

typedef vector<int> Array;
typedef vector<Edge> Edges;
typedef vector<Edges> Graph;

void add_edge(Graph &g, int from, int to, int flow) {
	g[from].push_back(Edge(to, flow, g[to].size()));
	g[to].push_back(Edge(from, 0, g[from].size() - 1));
}

int dfs(Graph &g, int s, int t, int f, Array &dist, Array &iter) {
	if (s == t) return f;
	
	for (int &i = iter[s]; i < g[s].size(); i++) {
		int ns = g[s][i].to;
		if (g[s][i].flow == 0 || dist[ns] != dist[s] + 1) continue;
		
		int res = dfs(g, ns, t, min(f, g[s][i].flow), dist, iter);
		if (res > 0) {
			g[s][i].flow -= res;
			g[ns][g[s][i].rev].flow += res;
			return res;
		}
	}
	return 0;
}

int maxflow(Graph g, int s, int t) {
	int n = g.size();
	int i, sumFlow = 0;
	
	while (true) {
		Array dist(n, -1);
		queue<int> que;
		que.push(s); dist[s] = 0;
		while (!que.empty()) {
			int pos = que.front(); que.pop();
			for (i = 0; i < g[pos].size(); i++) {
				int npos = g[pos][i].to;
				if (dist[npos] == -1 && g[pos][i].flow > 0) {
					dist[npos] = dist[pos] + 1;
					que.push(npos);
				}
			}
		}
		if (dist[t] == -1) break;

		Array iter(n, 0);
		while (true) {
			int f = dfs(g, s, t, 1e+9, dist, iter);
			if (f == 0) break;
			sumFlow += f;
		}
	}
	return sumFlow;
}

int x, y, m;
int u, v;
Graph g;

int main() {
	int i;
	
	cin >> x >> y >> m;
	int n = x + y + 2;
	g.resize(n);
	
	for (i = 0; i < m; i++) {
		cin >> u >> v;
		add_edge(g, 1 + u, 1 + x + v, 1);
	}
	
	for (i = 0; i < x; i++) add_edge(g, 0, 1 + i, 1);
	for (i = 0; i < y; i++) add_edge(g, 1 + x + i, n - 1, 1);
	cout << maxflow(g, 0, n - 1) << endl;
	return 0;
}


Measured memory_bytes: 3464
A,B,C,D,E,F = map(int,input().split())
noudo_max = (100*E)/(100+E)

# noudo,water,sugar
res = [-float('inf')]*3

i,j = 0,0
while 100*A*i<=F:
    j = 0
    while 100*A*i+100*B*j<=F:
        water = 100*A*i + 100*B*j
        sugar_max = F - water
        # sugarを全探索
        p = 0
        while C*p<=sugar_max:
            q = 0
            while C*p+D*q<=sugar_max:
                sugar = C*p+D*q
                if water+sugar!=0:
                    noudo = (100*sugar)/(water+sugar)
                    if noudo<=noudo_max and res[0]<noudo:
                        res = noudo,water,sugar
                q += 1
            p += 1
        j += 1
    i += 1

print(res[1]+res[2],res[2])


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

#define fastio 			ios::sync_with_stdio(0);	cin.tie(0); cout.tie(0);  cout<<fixed;  cout<<setprecision(12);
#define randomINT 		mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());
#define	newl 			cout<<"\n"
#define DISP(as)		for(auto it : as) cout<<it<<" ";newl;
#define all(x)         	(x).begin(),(x).end()
#define mset(x,val)    	memset(x,val,sizeof(x))
#define newl           	cout<<"\n"
#define pb             	push_back
#define mp             	make_pair
#define f 				first
#define s 				second
#define dline          cerr<<"///REACHED///\n";
#define deb1(x)        cerr<<#x<<" = "<<x<<'\n';
#define deb2(x,y)      cerr<<'['<<#x<<','<<#y<<"] = "<<'['<<x<<','<<y<<']'<<'\n';
#define deb3(x,y,z)    cerr<<'['<<#x<<','<<#y<<','<<#z<<"] = "<<'['<<x<<','<<y<<','<<z<<']'<<'\n';
#define N 300000 // prime modulo value 

typedef long long 				ll;
typedef long double 			ld;
typedef vector<ll> 				vll;
typedef pair<ll , ll> 			pll;
typedef pair<ld, ld> 			pld;
typedef unordered_map<ll, ll> 	um;
typedef vector<pll> 			vpll;

const ll 	MAX5 	= 	3e+5 + 7;
const ll 	MAX7 	= 	1e+7 + 7;
const ll 	MAXN 	= 	MAX7;
const ll   	INF   	=  	0x7f7f7f7f7f7f7f7f;
const int  	INFi 	=  	0x7f7f7f7f;
const ll 	MOD		=  	1e9 + 7;


// <------------- Declare Variables Here ------------> //

ll T = 1;
ll n, x, k, p, m, y, z;
string s, t;
ld w;
ll a, b;


// <------------- Implement Functions Here ----------> //


// <------------- Implement Functions Here ----------> //


// <------------- Start of main() -------------------> //

void MAIN() {	
	ll K;
	cin >> x >> y >> z >> K;
	vll a(x),b(y),c(z);
	for(ll i=0;i<x;i++) cin>>a[i];
	for(ll i=0;i<y;i++) cin>>b[i];
	for(ll i=0;i<z;i++) cin>>c[i];

	sort(all(a)); reverse(all(a));
	sort(all(b)); reverse(all(b));
	sort(all(c)); reverse(all(c));
	
	vll ans;

	for(ll i=0;i<x;i++) {
		for(ll j=0;j<y;j++) {
			for(ll k=0;k<z;k++) {
				if((i+1)*(j+1)*(k+1) <= K) ans.pb(a[i]+b[j]+c[k]); 
			}
		}
	}

	sort(all(ans)); reverse(all(ans));

	for(ll i=0;i<K;i++) cout<<ans[i]<<endl;
}

int main() {
	fastio; randomINT;
	//cin >> T;
	while (T--) {
		MAIN();
	}
	return 0;
}

Measured memory_bytes: 4348
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) rep2(i,0,n)
#define rep2(i,m,n) for(int i=m;i<(n);i++)
#define ALL(c) (c).begin(),(c).end()
using ll = long long;
const ll mod = 1000000007;
const ll INF = 100000000000000000LL;
signed main(){
    int a,b;
    cin>>a>>b;
    int res = 0;
    rep2(i,a,b+1){
        string s = to_string(i);
        if(s[0]==s[4]&&s[1]==s[3])res++;
    }
    cout<<res<<endl;
}

Measured memory_bytes: 256