akhauriyash/Code-Regression huggingface dataset:
import java.util.Scanner;

class Main{
	static class Pair{
		public long x, y;
		Pair( long xx, long yy ){ x=xx; y=yy; }
	}
	public static void main(String[]av){
		Scanner sc = new Scanner( System.in );
		java.util.ArrayList<Pair> list = new java.util.ArrayList<Pair>();
		while( sc.hasNextInt() )	{
			long x = sc.nextInt();
			long y = sc.nextInt();
			list.add( new Pair( Math.max(x,y), Math.min(x,y)));
		}
		for ( Pair p : list ){
			long x = p.x;
			long y = p.y;
			do{
				long	z = x % y;
				x = y;
				y = z;
			}while( 0 < y );
			System.out.println( x + " " + p.x*p.y/x );
		}
	}
}
				

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

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  long long n, d;
  cin >> n >> d;
  long long x, y;
  int ans = 0;
  for (int i = 0; i < n; i++) {
    cin >> x >> y;
    if (x * x + y * y <= d * d) ans++;
  }
  cout << ans << '\n';
  return 0;
}

Measured memory_bytes: 3692
#include <iostream>
#include <vector>
#include <queue>
#include <random>
#define ll long long
#define pii pair<int, int>
#define fst first
#define snd second
using namespace std;
 
struct FlowGraph
{
	const ll FMX = 1e15;
	int N, M, s, t;
	vector<vector<pii>> adj;
	vector<pii> edge;
	vector<ll> cap, flow;
	vector<int> ptr, level;
	queue<int> q;
	
	void init(int n, int ss, int tt)
	{
		adj.clear(); edge.clear();
		cap.clear(); flow.clear();
		ptr.clear(); level.clear();
		M = 0;
		adj.assign(n, vector<pii>());
		N = n; s = ss; t = tt;
	}
	
	void newEdge(int u, int v, ll c)
	{
		if (c < 0) {swap(u, v); c = -c;}
		if (c == 0) {return;}
		adj[u].push_back({v, M});
		adj[v].push_back({u, M + 1});
		edge.push_back({u, v});
		edge.push_back({v, u});
		cap.push_back(c);
		cap.push_back(c);
		flow.push_back(0);
		flow.push_back(c);
		M += 2;
	}
	
	bool bfs()
	{
		level.assign(N, -1);
		level[s] = 0;
		q.push(s);
		while (q.size())
		{
			int u = q.front(); q.pop();
			for (auto v : adj[u])
			{
				if (cap[v.snd] == flow[v.snd]) continue;
				if (level[v.fst] == -1)
				{
					level[v.fst] = level[u] + 1;
					q.push(v.fst);
				}
			}
		}
		return (level[t] != -1);
	}

	ll dfs(int u, ll f)
	{
		if (f == 0) {return 0;}
		if (u == t) {return f;}
		for (; ptr[u] < adj[u].size(); ptr[u]++)
		{
			int v = adj[u][ptr[u]].fst;
			int id = adj[u][ptr[u]].snd;
			if (level[v] == level[u] + 1)
			{
				ll ret = dfs(v, min(f, cap[id] - flow[id]));
				if (ret == 0) continue;
				flow[id] += ret;
				flow[id ^ 1] -= ret;
				return ret;
			}
		}
		return 0;
	}

	ll findFlow()
	{
		ll ret = 0;
		
		while (bfs()) 
		{
			ll tp;
			ptr.assign(N, 0);

			while (tp = dfs(s, FMX)) 
			{
				ret += tp;
			}
		}
		return ret;
	}
};

int n, ar[101] = {};
FlowGraph g;
long long res = 0;

int main()
{
	cin >> n;
	g.init(n + 2, 0, n + 1);
	for (int i = 1; i <= n; i++) 
	{
		cin >> ar[i];
		if (ar[i] >= 0) res += ar[i];
		if (ar[i] < 0) g.newEdge(0, i, -ar[i]);
		else g.newEdge(i, n + 1, ar[i]);
	}
	for (int i = 1; i <= n; i++)
	{
		if (ar[i] < 0)
		{
			for (int j = 2 * i; j <= n; j += i) if (ar[j] >= 0) g.newEdge(i, j, g.FMX);
		}
	}
	cout << res - g.findFlow() << "\n";
	return 0;
}

Measured memory_bytes: 3624
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#define ll long long
#define forn(i,l,r) for(int i=l;i<n;i++)
using namespace std;

int main() {
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    string s;
    cin>>s;
    int r=0,ans=0;
    for(int i=0;i<s.length();i++)
    {
        if(s[i]=='R')
        {
            r++;
            ans = max(ans,r);
        }
        else
        {
            r=0;
        }
    }
    cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 3608
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define all(a)  (a).begin(),(a).end()
#define vi vector<int>
#define pb push_back
#define INF 999999999

//??????
ll factmemo[30]={1};
ll fact(int n){
    if(factmemo[n]!=0)return factmemo[n];
    return factmemo[n] = n*fact(n-1);
}

int main(){
    int al[30]={};
    
    string s;
    cin>>s;
    rep(i,s.size()){
        al[s[i]-'a']++;
    }
    
    int even=0,odd=0;
    ll div=1;
    rep(i,28){
        if(al[i]==0)continue;
        if(al[i]%2==0){
            even+=al[i]/2;
            div*=fact(al[i]/2);
        }
        else{
            odd++;
            even+=(al[i]-1)/2;
            if(al[i]>1)div*=(al[i]-1)/2;
        }
    }
    
    if(odd>1){
        cout<<0<<endl;
    }
    else{
        cout<<fact(even)/div<<endl;
    }
    
}

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

using namespace std;

#define INF 100000000
#define YJ 1145141919
#define INF_INT_MAX 2147483647
#define INF_LL 9223372036854775
#define INF_LL_MAX 9223372036854775807
#define EPS 1e-10
#define MOD 1000000007
#define MOD9 998244353
#define Pi acos(-1)
#define LL long long
#define ULL unsigned long long
#define LD long double

#define int long long

using II = pair<int, int>;

int gcd(int a, int b) { return b != 0 ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a * b / gcd(a, b); }
int extgcd(int a, int b, int &x, int &y) { int g = a; x = 1; y = 0; if (b != 0) g = extgcd(b, a % b, y, x), y -= (a / b) * x; return g; }

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(a)  begin((a)), end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())

const int MAX_N = 200005;
int N;
string S[MAX_N];
map<string, int> M;
vector<string> ans;

signed main()
{
  cin >> N;
  int ret = 0;
  REP(n,N) {
    cin >> S[n];
    M[S[n]]++;
    ret = max(ret, ++M[S[n]]);
  }

  REP(n,N) {
    if(M[S[n]] == ret) {
      ans.push_back(S[n]);
      M[S[n]] = -1000;
    }
  }

  sort(begin(ans), end(ans));

  for(string s : ans) {
    cout << s << endl;
  }

  return 0;
}


Measured memory_bytes: 28404
/** author: __nishad__ **/

#include<bits/stdc++.h>
using namespace std;


typedef long long ll ;
typedef vector<ll> vll ;

#define IOS ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define all(v) (v).begin(),(v).end()
#define precision(k) cout<<setprecision(k)<<fixed;
#define loop(i,a) for(int i=0; i<a;i++)
#define loop2(i,a,b) for(int i=(a);i<=(b);++i)
#define minv(v) *min_element(all(v))
#define maxv(v) *max_element(all(v))
#define getpos(v,x) (lower_bound(v.begin(),v.end(),x)-v.begin())
#define unq(v) sort(all(v)),(v).erase(unique((v).begin(),(v).end()),(v).end())
#define pb push_back
#define pi 3.14159265358979323
#define endl "\n"

int main()
{
    IOS;

    ll n, m;
    cin>>n;

    string s;
    vector<string>::iterator it;
    vector<string> str;
    vector<int> v;

    for(int i=1; i<=n; i++){
        cin>>s;
        it = find(str.begin(), str.end(), s);
        if(it != str.end()){
            v[it-str.begin()]++;
        }

        else{
            str.pb(s);
            v.pb(1);
        }

    }

    cin>>m;

    for(int i=0; i<m; i++){
        cin>>s;
        it = find(str.begin(), str.end(), s);
        if(it != str.end()){
            v[it-str.begin()]--;
        }

    }
    sort(all(v));

    int ans = v[v.size()-1];

    if(ans > 0)
        cout<<ans;
    else
        cout<<"0";


}



Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<queue>
#include<vector>
#include<map>
using namespace std;
const int N=2e6+5;
typedef long long ll;
int n,m;
bool vis[N];
vector<int>edge[N];
queue<int>q;
map<int,int>f[N];
int dist[N];
int fa[N];
int find_father(int x){
    if(x==fa[x]) return x;
    return fa[x]=find_father(fa[x]);
}
void merge(int x,int y){
    int f1=find_father(x),f2=find_father(y);
    fa[f1]=f2;
}
void bfs(){
    memset(dist,-1,sizeof dist);
    q.push(1);
    vis[1]=1;
    dist[1]=0;
    while(!q.empty()){
        int u=q.front();
        q.pop();
        for(int i=0,sz=edge[u].size();i<sz;i++){
            int v=edge[u][i];
            v=find_father(v);
            if(!vis[v]){
                dist[v]=dist[u]+1;
                q.push(v);
                vis[v]=1;
            }
        }
    }
}
void Read(int &x){
	char ch = getchar();x = 0;
	for (; ch < '0' || ch > '9'; ch = getchar());
	for (; ch >='0' && ch <= '9'; ch = getchar()) x = x * 10 + ch - '0';
}
int main()
{
    while(~scanf("%d%d",&n,&m)){
        int cnt=0;
        for(int i=1;i<=n;i++){
            f[i].clear();
            f[i][0]=++cnt;
        }
        for(int i=1;i<N;i++)
            fa[i]=i;
        for(int i=1;i<=m;i++){
            int u,v,w;
            //scanf("%d%d%d",&u,&v,&w);
            Read(u),Read(v),Read(w);
            if(f[u][w]==0){
                f[u][w]=++cnt;
            }
            u=f[u][w];
            u=find_father(u);
            if(f[v][w]==0){
                f[v][w]=++cnt;
            }
            v=f[v][w];
            v=find_father(v);
            merge(u,v);
        }
        for(int i=1;i<=cnt;i++)
            vis[i]=0,edge[i].clear();
        for(int i=1;i<=n;i++)
            for(map<int,int>::iterator it=f[i].begin();it!=f[i].end();it++){
                int j=it->second;
                j=find_father(j);
                edge[i].push_back(j);
                edge[j].push_back(i);
            }
        bfs();
        if(dist[n]==-1)
            puts("-1");
        else
            printf("%d\n",dist[n]/2);
    }
}


Measured memory_bytes: 192640
#include <stdio.h>
#include <string.h>
#include <math.h>

long Combination(long n, long r) {
  long answer = 1;
  if (n-r < r) {
    r = n-r;
  }
  for (long i = 1; i <= r; i++) {
    answer *= n+1-i;
    answer /= i;
  }
  return answer;
}

int main(void) {

  char n[200];
  scanf("%s", n);
  int length = strlen(n);
  int k;
  scanf("%d", &k);
  long count;
  long sum = 0;
  int flag;
  for (int digits = k; digits < length; digits++) {
    count = pow(9,k);
    count *= Combination(digits-1,k-1);
    sum += count;
  }
  if (k == 1) {
    sum += n[0]-'0';
  } else if (k == 2) {
    sum += (n[0]-'0'-1)*9*(length-1);
    flag = 0;
    for (int i = 1; i < length; i++) {
      if (flag == 0) {
        sum += n[i]-'0';
      } else {
        sum += 9;
      }
      if (n[i] != '0') {
        flag = 1;
      }
    }
  } else {
    sum += (n[0]-'0'-1)*pow(9,2)*Combination(length-1,2);
    for (int second = 1; second < length-1; second++) {
      if (n[second] != '0') {
        sum += (n[second]-'0'-1)*9*(length-second-1);
      }
    }
    for (int second = 1; second < length-1; second++) {
      if (n[second] == '0') {
        continue;
      }
      for (int third = second+1; third < length; third++) {
        flag = 0;
        for (int i = 1; i < third; i++) {
          if (i == second) {
            continue;
          }
          if (n[i] != '0') {
            flag = 1;
            break;
          }
        }
        if (flag == 0) {
          sum += n[third]-'0';
        } else {
          sum += 9;
        }
      }
    }
    flag = 0;
    for (int second = 1; second < length-1; second++) {
      if (flag == 1) {
        sum += (9-n[second]+'0')*9*(length-second-1);
      }
      if (n[second] != '0') {
        flag = 1;
      }
    }
  }
  printf("%ld\n", sum);

  return 0;
}

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

 
int main(){
    
    string s,t,u;
    int a,b;
    cin>>s>>t;
    cin>>a>>b;
    cin>>u;
    if(u==s)cout<<a-1<<" "<<b<<endl;
    else cout<<a<<" "<<b-1<<endl;
}

Measured memory_bytes: 256
N,K=map(int,input().split())
A=list(map(int,input().split()))

#DP[keta][limit]で考える

def ANS(keta,limit):
    
    if keta==-1:
        return 0

    A1=0
    A0=0
    for a in A:
        if a & (1<<keta)==0:
            A1+=1<<keta
        else:
            A0+=1<<keta
    
    if limit==1:               
        return max(A0,A1)+ANS(keta-1,1)

    if limit==0:
        if K & (1<<keta)==0:
            return A0+ANS(keta-1,0)
        else:
            return max(A0+ANS(keta-1,1),A1+ANS(keta-1,0))

print(ANS(50,0))

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

int main(){
	string a;
	string b;
	int x, y, z, w;
	int n;
	cin >> n;
	while(n){
		cin >> a;
		for(int i=0;i<n;i++){
			x = a[0];
			y = 1;
			for(int j=1;j<a.size();j++){
				if(x == a[j]){
					y += 1;
				}else{
					z = (int)log10(y) + 1;
					for(int k=z-1;k>=0;k--){
						w = y / pow(10,k);
						b += w + 48;
						y -= w * pow(10,k);
					}
					b += x;
					x = a[j];
					y = 1;
				}
			}
			z = (int)log10(y) + 1;
			for(int k=z-1;k>=0;k--){
				w = y / pow(10,k);
				b += w + 48;
				y -= w * pow(10,k);
			}
			b += x;
			a = b;
			b.clear();
		}
		cout << a << endl;
		cin >> n;
	}
	return 0;
}

Measured memory_bytes: 0
import java.util.Scanner;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Map;
import java.util.TreeMap;

import javax.print.attribute.standard.SheetCollate;

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

        try{
            //入力
            int N = scan.nextInt();
            int M = scan.nextInt();
            int[] P_ = new int[M];
            int[] Y_ = new int[M];
            Map<Integer, ArrayList> sheet = new TreeMap<Integer, ArrayList>();
            for(int i = 0; i < M; i++){
                P_[i] = scan.nextInt();
                Y_[i] = scan.nextInt();
                sheet.put(Y_[i], new ArrayList<Integer>(Arrays.asList(P_[i], i)));
            }

            String[] ans = new String[M];
            int[] pre = new int[N+1];
            for(ArrayList<Integer> list : sheet.values()){
                ans[list.get(1)] = String.format("%06d%06d", list.get(0), ++pre[list.get(0)]);
            }

            for(int i = 0; i < M; i++){
                System.out.println(ans[i]);
            }

        }finally{
            scan.close();
        }
    }
}


Measured memory_bytes: 181904
#include<bits/stdc++.h>
using namespace std;
const int inf=1e9,mod=1e9+7;
typedef long long ll;
int read() {
	int x=0,f=1;
	char c=getchar();
	while(c<'0'||c>'9') f=(c=='-')?-1:1,c=getchar();
	while(c>='0'&&c<='9') x=x*10+c-'0',c=getchar();
	return x*f;
}
int main() {
	int n=read(),k=read(),ans=(n-1)*(n-2)>>1,i,j;
	if (k>ans)
		puts("-1"),exit(0);
	ans-=k;
	printf("%d\n",n+ans-1);
	for(int i=2; i<=n; i++)
		printf("1 %d\n",i);
	for(int i=2; i<n&&ans; i++)
		for(int j=i+1; j<=n&&ans; j++)
			printf("%d %d\n",i,j), ans--;
	return 0;
}

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

public class Main {
	InputStream in = System.in;
	PrintStream out = System.out;

	int f(int[][] c, int from, boolean[] visited) {
		if (visited[from]) {
			return 1000000;
		}
		visited[from] = true;

		int[] a = new int[10];
		for (int i = 0; i <= 9; i++) {
			if (i == 1) {
				a[1] = c[from][1];
			} else if (i == from) {
				a[i] = Integer.MAX_VALUE;
			} else {
				boolean[] v2 = visited.clone();
				a[i] = c[from][i] + f(c, i, v2);
			}
		}

		return min(a);

	}

	public void _main(String[] args) {
		Scanner sc = new Scanner(in);

		int H = sc.nextInt();
		int W = sc.nextInt();
		int[][] c = new int[10][10];

		for (int i = 0; i <= 9; i++) {
			for (int j = 0; j <= 9; j++) {
				c[i][j] = sc.nextInt();
			}
		}

		int[] A = nextIntArray(sc, W * H);

		sc.close();

		int[] a = new int[10];
		for (int i = 0; i <= 9; i++) {
			a[i] = f(c, i, new boolean[10]);
		}

		int ans = 0;
		for (int x : A) {
			if (x != -1) {
				ans += a[x];
			}
		}

		out.println(ans);
	}

	public static void main(String[] args) {
		new Main()._main(args);
	}

	@SuppressWarnings("unused")
	private int min(int[] arr) {
		if (arr == null || arr.length == 0) {
			throw new IllegalArgumentException(Arrays.toString(arr));
		}

		int candidate = arr[0];
		for (int i = 1; i < arr.length; i++) {
			candidate = candidate < arr[i] ? candidate : arr[i];
		}
		return candidate;
	}

	@SuppressWarnings("unused")
	private int[] nextIntArray(Scanner sc, int n) {
		int[] result = new int[n];
		for (int i = 0; i < n; i++) {
			result[i] = sc.nextInt();
		}
		return result;
	}
}


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

#define ASC(vec) vec.begin(), vec.end()		// 昇順ソート 例：sort(ASC(vec));
#define DESC(vec) vec.rbegin(), vec.rend()	// 降順ソート 例:sort(DESC(vec));
#define rep(i, n) for(i = 0; i < n; i++)

const int inf = (int)1e9 + 7;
const long long INF = 1LL << 60;

typedef long long ll;

// 4,8方向に探索する際に用いる配列
//int dx[4] = { 0,  0, 1, -1 };
//int dy[4] = { 1, -1, 0,  0 };
//int dx[8] = { 1, 0, -1,  0, 1, -1, -1,  1 };
//int dy[8] = { 0, 1,  0, -1, 1,  1, -1, -1 };

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

	int ans = 0;

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

		ans += val - 1;
	}
	cout << ans << endl;
}


Measured memory_bytes: 256
n = int(input())
f = [0] * n
m = - 10 ** 10
for i in range(n):
  f[i] = list(map(int,input().split()))
p = [0] * n
for i in range(n):
  p[i] = list(map(int,input().split()))
for i in range(1,2**10):
  cur = bin(i)[2:]
  cur = '0'*(10-len(cur)) + cur
  ri = 0
  for j in range(n):
    c = 0
    for k in range(10):
      if f[j][k] == int(cur[k]) == 1:
        c += 1
    ri += p[j][c]
  m = max(m,ri)
print(m)

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

int main(){
    int n,k;
    string s;
    cin>>n>>k>>s;
    if(s[k-1]=='A'){s[k-1]='a';}
    else if(s[k-1]=='B'){s[k-1]='b';}
    else{s[k-1]='c';}
    cout<<s<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
/*
 *  JUST KEEP GOING
 */
#define endl			'\n'
#define ll				long long
#define all(v)			((v).begin()), ((v).end())
#define allr(v)			((v).rbegin()), ((v).rend())
#define sz(v)			((int)((v).size()))
#define clr(v, d)		memset(v, d, sizeof(v))
#define rep(i, v)		for(int i=0;i<sz(v);++i)
#define For(i,s)        for(auto i:s)
#define Forr(i,s)        for(auto &i:s)
#define lp(i, n)		for(int i=0;i<(int)(n);++i)
#define lpi(i, j, n)	for(int i=(j);i<(int)(n);++i)
#define lpd(i, j, n)	for(int i=(j);i>=(int)(n);--i)
#define vi				vector <int>
#define vl				vector <ll>
#define ii				pair <int,int>
#define vii				vector <ii>
#define vll				vector <pair<ll,ll>>
#define PI				double PPPPPP = 3.14159265358979323846;
#define bit(mask,i) ((mask>>i)&1)

void run() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr), cout.tie(nullptr);
}
const int N = 2e5+5,mod=1e9+7;

int main() {
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    run();
    ll x, d, k;
    cin >> x >> k >> d;
    ll need = abs(x) / d;
    need = min(k, need);
    if (x < 0) {
        x += need * d;
        k -= need;
        ll ans1 = abs(x - (k) / 2 * d + (k + 1) / 2 * d);
        ll ans2 = abs(x + (k) / 2 * d - (k + 1) / 2 * d);
        cout << min(ans1, ans2);

    } else {
        x -= need * d;
        k -= need;
        ll ans1 = abs(x - (k) / 2 * d + (k + 1) / 2 * d);
        ll ans2 = abs(x + (k) / 2 * d - (k + 1) / 2 * d);
        cout << min(ans1, ans2);
    }
}

Measured memory_bytes: 3564
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll MOD = (ll)(1e9 + 7);
vector<string> grid;
ll dp[1100][1100];
int main() {
    int h, w;
    cin >> h >> w;
    for (int i = 0; i < h; i++) {
        string s;cin >> s;
        grid.push_back(s);
    }
    dp[0][0] = 1ll;
    for (int i = 0; i < h; i++) for (int j = 0; j < w; j++) {
        dp[i][j] %= MOD;
        if (i + 1 < h && grid[i+1][j] == '.') dp[i+1][j] += dp[i][j];
        if (j + 1 < w && grid[i][j+1] == '.') dp[i][j+1] += dp[i][j];
    }
    cout << dp[h-1][w-1] << endl;
    return 0;
}

Measured memory_bytes: 13212
import re

n,k= map(int,(input().split()))
b= input()
LRn=len(re.findall('LR',b))
RLn=len(re.findall('RL',b))

if min(LRn,RLn)>=k:
    ans=k*2
elif min(LRn,RLn)<=k and max(LRn,RLn)>=k:
    ans=k+min(LRn,RLn)
else:
    ans=LRn+RLn

a= list(b)
for i in range(len(a)-1):
    if a[i]==a[i+1]:
        ans +=1

print(ans)

Measured memory_bytes: 6516
#include<cstdio>
#include<algorithm>
using namespace std;

int n;
int a[222];

int main() {
	scanf("%d", &n);
	for(int i=0;i<2*n;i++)
		scanf("%d", &a[i]);
	sort(a,a+2*n);
	int ans=0;
	for(int i=0;i<2*n;i+=2)
		ans+=a[i];
	printf("%d\n", ans);
	
	return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <algorithm>
#include <cmath>
using namespace std;
int main() {
  int n, x, count=0, min_m=pow(10, 5);
  cin >> n >> x;
  int m[n];
  for (int i = 0; i < n; i++) {
    cin >> m[i];
    x -= m[i];
    count += 1;
    if (m[i] < min_m) min_m = m[i];
  }
  while (x >= min_m) {
    x -= min_m;
    count += 1;
  }
  cout << count << endl;
  return 0;
}


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

#define int long long

using namespace std;
#define rep(i,s,n) for(int i = s;i<n;i++)
#define repe(i,s,n) for(int i = s;i<=n;i++)
#define pb push_back
#define fi first
#define se second
typedef long long ll;
typedef pair<int,int>pint;
typedef vector<int>vint;
typedef vector<pint>vpint;
static const ll maxLL = (ll)1 << 62;
const ll MOD=1000000007,INF=1e18;
int dy[]={-1,0,1,0};
int dx[]={0,1,0,-1};

int n,k,x;
bool d[11];

signed main(){
    cin>>n>>k;
    rep(i,0,11)d[i]=true;
    rep(i,0,k){
        cin>>x;
        d[x]=false;
    }
    rep(i,0,100000){
        if(n>i)continue;
        int x=i;
        bool can=true;
        while(x){
            if(d[x%10])x/=10;
            else {
                can=false;
                break;
            }
        }
        if(can){
            cout<<i<<endl;
            return 0;
        }
    }
    
    
    
    
    
    
    
    
    
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void){
	int n;
	scanf("%d",&n);
	int i;
	int ans = 0,a,b;
	for(i=0;i<n;i++){
		scanf("%d %d",&a,&b);
		ans += (b-a)+1;
	}
	printf("%d",ans);
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define pb push_back
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define ll long long
using namespace std;

int gcd(int a, int b) { return b != 0 ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a * b / gcd(a, b); }

int main()
{
  int n;
  cin >> n;
  int m;
  cin >> m;
  REP(i, n - 1) {
    int h;
    cin >> h;
    if(m > h + 1) {
      cout << "No" << endl;
      return 0;
    }
    m = max(m, h);
  }
  cout << "Yes" << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <queue>
#include <deque>
#include <algorithm>
#include <string>
#include <numeric>
#include <cmath>
#include <map>
#include <iomanip>

using namespace std;

void solve(){
    int n, _max=0;
    cin >> n;
    string tmp;
    map<string, int> memo;
    for(int i=0; i<n; i++) cin >> tmp, memo[tmp]++;
    for(auto e: memo){
        if(e.second > _max) _max = e.second;
    }
    for(auto e:memo){
        if(e.second == _max)
            cout << e.first << endl;
    }
}

int main(){

    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << setprecision(16);
    
    solve();

    return 0;
}


Measured memory_bytes: 23808
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;
#define rep(i,n) for (ll i=0;i<(n);++i)
#define rep2(i,a,b) for (ll i=(a);i<(b);++i)
#define debug(x) cout << #x << '=' << x << endl
#define all(v) (v).begin(),(v).end()
const ll MOD=1e9+7;
//const ll MOD=998244353;
const ll INF=1e9;
const ll IINF=1e18;
const double EPS=1e-8;
const double pi=acos(-1);

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

const int MAX_N=1e5+10;
int N,K,s;
vector<vector<int>> G(MAX_N);
vector<int> lower(MAX_N),upper(MAX_N),ans(MAX_N,INF);
bool ok=true;

void dfs1(int v,int p){
    for (auto nv:G[v]){
        if (nv==p) continue;
        lower[nv]=lower[v]-1;
        upper[nv]=upper[v]+1;
        if (ans[nv]!=INF){
            if (abs(lower[nv])%2!=ans[nv]%2) ok=false;
            if (ans[nv]<lower[nv]||upper[nv]<ans[nv]) ok=false;
            lower[nv]=upper[nv]=ans[nv];
        }
        dfs1(nv,v);
        chmax(lower[v],lower[nv]-1);
        chmin(upper[v],upper[nv]+1);
        if (upper[v]<lower[v]) ok=false;
    }
}

void dfs2(int v,int p){
    int n=ans[v];
    for (auto nv:G[v]){
        if (nv==p) continue;
        if (upper[nv]<n+1) ans[nv]=n-1;
        else ans[nv]=n+1;
        dfs2(nv,v);
    }
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> N;
    rep(i,N-1){
        int a,b; cin >> a >> b; --a,--b;
        G[a].push_back(b);
        G[b].push_back(a);
    }
    cin >> K;
    rep(i,K){
        int V,P; cin >> V >> P;
        ans[--V]=P;
        if (i==0){
            s=V;
            lower[s]=upper[s]=P;
        }
    }
    dfs1(s,-1);
    if (!ok){
        cout << "No" << endl;
        return 0;
    }
    cout << "Yes" << endl;
    dfs2(s,-1);
    rep(i,N) cout << ans[i] << endl;
}

Measured memory_bytes: 15360
def getN():
    return int(input())

def getMN():
    return list(map(int, input().split()))

def getlist():
    return list(map(int, input().split()))

n, m = getlist()
anums = getlist()
anums = sorted(anums)

opes = []
for i in range(m):
    opes.append(getlist())

opes.sort(key=lambda x: -x[1])

ans = 0
idx = 0
for ope in opes:
    width, v = ope
    for i in range(width):
        if idx == n:
            break
        if anums[idx] < v:
           ans += v
           idx += 1
        else:
            break
if idx != n:
    ans += sum(anums[idx:])

print(ans)

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

// macro
#define rep(i,n) for(i=0;i<n;i++)
#define ll long long
#define all(v) v.begin(), v.end()

// code starts
typedef pair<ll,ll> P;
#define MOD 1000000007

ll pows(ll a, ll b)
{
  ll left = b;
  ll ans = 1;
  ll ks = a;
  while(left > 0)
  {
    if(left%2 == 1)
    {
      ans = ans*ks%MOD;
    }
    ks = ks*ks%MOD;
    left /= 2;
  }
  return ans;
}

int main()
{
  int n;
  cin >> n;
  vector<ll> a(n);
  vector<ll> b(n);
  int i;
  map<P,int> m;
  rep(i,n) cin >> a[i] >> b[i];
  int i00 = 0;
  rep(i,n)
  {
    if(a[i] == 0 && b[i] == 0)
    {
      i00++;
    }
    else if(b[i] == 0)
    {
      if(m.find(make_pair(1,0)) == m.end())
      {
        m.insert(make_pair(make_pair(1,0),1));
      }
      else
      {
        auto it = m.find(make_pair(1,0));
        pair<P,int> ch = *it;
        int count = ch.second;
        m.erase(make_pair(1,0));
        m.insert(make_pair(make_pair(1,0),count+1));
      }
    }
    else
    {
      if(a[i] == 0)
      {
        if(m.find(make_pair(0,1)) == m.end())
        {
          m.insert(make_pair(make_pair(0,1),1));
        }
        else
        {
          auto it = m.find(make_pair(0,1));
          pair<P,int> ch = *it;
          int count = ch.second;
          m.erase(make_pair(0,1));
          m.insert(make_pair(make_pair(0,1),count+1));
        }
      }
      else
      {
        ll gcabs = gcd(abs(a[i]),abs(b[i]));
        a[i] /= gcabs;
        b[i] /= gcabs;
        if(b[i] < 0)
        {
          a[i] *= -1;
          b[i] *= -1;
        }
        if(m.find(make_pair(a[i],b[i])) == m.end())
        {
          m.insert(make_pair(make_pair(a[i],b[i]),1));
        }
        else
        {
          auto it = m.find(make_pair(a[i],b[i]));
          pair<P,int> ch = *it;
          int count = ch.second;
          m.erase(make_pair(a[i],b[i]));
          m.insert(make_pair(make_pair(a[i],b[i]),count+1));
        }
      }
    } 
  }
  ll ans = 1;
  int ex = n-i00;
  auto it = m.begin();
  while(it != m.end())
  {
    pair<P,int> ch = *it;
    int count = ch.second;
    if(count == 0)
    {
      it++;
      continue;
    }
    P now = ch.first;
    ll na = now.first;
    ll nb = now.second;
    ll pa,pb;
    if(na == 0 || nb == 0)
    {
      pa = nb;
      pb = na;
    }
    else
    {
      pa = -nb;
      pb = na;
      if(pb < 0)
      {
        pa *= -1;
        pb *= -1;
      }
    }
    auto it2 = m.find(make_pair(pa,pb));
    if(it2 != m.end())
    {
      pair<P,int> p2 = *it2;
      int count2 = p2.second;
      ans *= pows(2,count)+pows(2,count2)-1;
      ans %= MOD;
      ex -= (count+count2);
      m[make_pair(na,nb)] = 0;
      m[make_pair(pa,pb)] = 0;
    }
    it++;
  }
  ans *= pows(2,ex);
  ans = (ans+i00+MOD-1)%MOD;
  cout << ans << endl;
}


Measured memory_bytes: 18752
#include <iostream>
#include <cstdlib>
#include <time.h>
#include <algorithm>
#include <map>
#include <queue>
#include <stack>
#include <vector>
#include <array>
#include <string>
#include <iomanip>
#include <cstring>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define mp make_pair
#define eb emplace_back
#define f first
#define s second
#define sz(x) (ll)x.size()
using namespace std;
using namespace __gnu_pbds;

typedef long long int ll;
typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> osSet;

using pll = pair<ll, ll>;

const ll maxN = 1e5;
const ll INF = 1e17;
const ll MOD = 1e9 + 7;

ll xs[] = {-1, 1, 0, 0, -1, 1, 1, -1};
ll ys[] = {0, 0, -1, 1, -1, 1, -1, 1};

ll segtree[maxN << 2];
ll lazy[maxN << 2];
ll A[maxN];

inline ll left(ll x){
	return x << 1;
}

inline ll right(ll x){
	return (x<<1) + 1;
}

ll func(ll x){
	return (x*(x+1))/2;
}

ll _pow(ll b, ll p){
	if(p == 0) return 1;
	if(p == 1) return b;
	ll exB = b*b;
	if(p&1) return b*_pow(exB, p/2);
	return _pow(exB, p/2);
}

int main(){
	cin.sync_with_stdio(false);
	cin.tie(0);
	string s;
	cin >> s;
	ll m=0, d=0;
	for(ll i=5; i<7; i++)
		m = m*10 + s[i]-'0';
	for(ll i=8; i<10; i++)
		d = d*10 + s[i]-'0';
	if(m < 4 or (m == 4 and d <= 30))
		cout << "Heisei";
	else
		cout << "TBD";
	return 0;
}

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

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

int main() {
	int N;
	while (cin >> N) {
		if (N == 0) return 0;
		vector<pair<int, int> > P(N, { 0, 0 });
		for (int i = 1; i < N; i++) {
			int N, D;
			cin >> N >> D;
			P[i] = { P[N].first + dx[D], P[N].second + dy[D] };
		}
		int MINX = 0, MAXX = 0, MINY = 0, MAXY = 0;
		for (int i = 0; i < N; i++) {
			MINX = min(MINX, P[i].first);
			MAXX = max(MAXX, P[i].first);
			MINY = min(MINY, P[i].second);
			MAXY = max(MAXY, P[i].second);
		}
		cout << MAXX - MINX + 1 << ' ' << MAXY - MINY + 1 << endl;
	}
}


Measured memory_bytes: 3020
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int a,b,c,ab,ac;
    cin>>a>>b>>c;
    ab=abs(a-b);
    ac=abs(a-c);
    if(ab<ac) puts("A");
    else puts("B");
    return 0;
}

Measured memory_bytes: 256
list=[]
for i in range(4):
    a,b=map(int,input().split())
    if a==1:
        a=6000
    elif a==2:
        a=4000
    elif a==3:
        a=3000
    else:
        a=2000
    list.append((a,b))
    print(a*b)
    


Measured memory_bytes: 5600
import java.util.*
fun main(args:Array<String>){
    val array = arrayOf(1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51)
    val k = readLine()!!.toInt()
    println(array[k-1])
}

Measured memory_bytes: 29792
tmp = []
cnt = "1"
while cnt != [0, 0]
  i = gets.chomp.split.map(&:to_i)
  tmp.push(i)
  tmp.flatten!
  cnt = i
end
tmp.delete(tmp[-1])
length = tmp.length/2
i = 0
length.times do
  h = tmp[i].to_i
  w = tmp[i+1].to_i
  hh = h-2
  ww = w-2

  w.times do
    print"#"
  end
  print"\n"
  hh.times do
    print"#"
    ww.times do
      print "."
    end
    print"#\n"
  end
  w.times do
    print"#"
  end
  i = i + 2
  print"\n\n"
end

Measured memory_bytes: 8772
#include"bits/stdc++.h"
using namespace std;
typedef long long ll;
const ll MOD = (ll)(1e9 + 7);
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for(int (i)=0; (i)<(int)(n); (i)++)
#ifdef LOCAL
#define debug(x) cerr << #x << ": " << x << endl
#else
#define debug(x)
#endif
int dx[4] = { 1,0,-1,0 };
int dy[4] = { 0,1,0,-1 };

int N;
string S;

vector<int> Z_algorithm(string S) {
	vector<int> A(S.size());
	A[0] = S.size();
	int i = 1, j = 0;
	while (i < S.size()) {
		while (i + j < S.size() && S[j] == S[i + j]) j++;
		A[i] = j;
		if (j == 0) i++;
		else {
			int k = 1;
			while (i + k < S.size() && k + A[k] < j) {
				A[i + k] = A[k];
				k++;
			}
			i += k;
			j -= k;
		}
	}
	return A;
}

signed main() {
	cin >> N >> S;
	ll ans = 0;
	rep(i, N) {
		string T = S.substr(i, N - i);
		vector<int> v = Z_algorithm(T);
		for (int j = 1; j < v.size(); j++) {
			if(v[j] <= j) ans = max(ans, (ll)v[j]);
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 384
#include <stdio.h>
#define N 100001

int Partition(int *,int,int);

int main()
{
  int A[N];
  int i;
  int n;
  int k;
  scanf("%d",&n);
  
  for(i=1;i<=n;i++)
    {
      scanf("%d",&A[i]);
      
    }
  k = Partition(A,1,n);
  
  for(i=1;i<=n;i++)
    {
      if(i == k)printf("[%d] ",A[i]);
      else if(i==n)printf("%d\n",A[i]);
      else printf("%d ",A[i]);
    }

return 0;
  
}
 
int Partition (int *A,int p,int r)
{
  int x;
  int i;
  int j;
  int temp;
  x=A[r];
  i=p-1;
  
 for(j=p;j<r;j++)
    {
      if(A[j]<=x)
    {
      i++;
      temp=A[i];
      A[i]=A[j];
      A[j]=temp;
    }
    }
  temp=A[i+1];
  A[i+1]=A[r];
  A[r]=temp;
  return i+1;
}

Measured memory_bytes: 992
#include<bits/stdc++.h>
using namespace std;
using ll = int64_t;
int main(){
    ll N;
    cin >> N;
    ll a[N];
    ll po = N * (N + 1) / 2;
    ll sum = 0;
    bool ok = 1;
    for(ll i = 0; i < N; i++){
        cin >> a[i];
        sum += a[i];
    }
    ll sa;
    if(sum % po) ok = 0;
    ll kaisu = sum / po;
    ll yo = kaisu;
    for(ll i = 0; i < N; i++){
        sa = a[(i + 1) % N] - a[i] - kaisu;
        if(sa < 0){
            if(-sa % N) ok = 0;
            yo -= -sa / N;
        }
    }
    if(yo) ok = 0;
    cout << (ok ? "YES\n" : "NO\n");
    return 0;
}

Measured memory_bytes: 1024
import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int k = sc.nextInt();
        String s = sc.next();
        if(k < s.length()){
            s = s.substring(0, k);
            s = s + "...";
        }
        System.out.println(s);
        sc.close();

    }

}


Measured memory_bytes: 38648
S = input()

u = S[0] + S[1]
l = S[2] + S[3]

u = int(u)
l = int(l)

if (0 < u <= 12) :
	if (0 < l <= 12) : 
		print ("AMBIGUOUS")
	else:
		print ("MMYY")
else:
	if (0 < l <= 12) :
		print ("YYMM")
	else:
		print ("NA")


Measured memory_bytes: 3060
#[macro_use]
mod input {

use std;
use std::io;

const SPLIT_DELIMITER: char = ' ';

#[macro_export]
#[allow(unused_macros)]
macro_rules! input {
    ( $($x:expr ),*) => {
        {
            let temp_str = input_line_str();
            let mut split_result_iter = temp_str.split_whitespace();
                $(
                let buf_split_result = split_result_iter.next();
                let buf_split_result = buf_split_result.unwrap();
                    ($x) = buf_split_result.parse().unwrap();
                )*
        }
    };
}

#[allow(dead_code)]
pub fn input_line_str() -> String {
    let mut s = String::new();
    io::stdin().read_line(&mut s).unwrap();
    s.trim().to_string()
}

#[allow(dead_code)]
pub fn p<T>(t: T)
where
    T: std::fmt::Display,
{
    println!("{}", t);
}

#[allow(dead_code)]
pub fn input_vector2d<T>(line: usize) -> Vec<Vec<T>>
where
    T: std::str::FromStr,
{
    let mut v: Vec<Vec<T>> = Vec::new();

    for _ in 0..line {
        let vec_line = input_vector();
        v.push(vec_line);
    }
    v
}

#[allow(dead_code)]
pub fn input_vector<T>() -> Vec<T>
where
    T: std::str::FromStr,
{
    let mut v: Vec<T> = Vec::new();

    let s = input_line_str();
    let split_result = s.split(SPLIT_DELIMITER);
    for z in split_result {
        let buf = match z.parse() {
            Ok(r) => r,
            Err(_) => panic!("Parse Error"),
        };
        v.push(buf);
    }
    v
}

#[allow(dead_code)]
pub fn str2vec(s: &str) -> Vec<char> {
    let mut v: Vec<char> = Vec::new();
    for c in s.chars() {
        v.push(c);
    }
    v
}

}

use input::*;
use std::collections::HashMap;

fn main() {
    let s = str2vec(&input_line_str());
    let t = str2vec(&input_line_str());
    let mut map = HashMap::new();
    let mut map2 = HashMap::new();
    let mut flag = true;

    for i in 0..s.len() {
        if map.contains_key(&s[i]) {
            if map[&s[i]] != t[i] {
                flag = false;
                break;
            }
        }
        if map2.contains_key(&t[i]) {
            if map2[&t[i]] != s[i] {
                flag = false;
                break;
            }
        }
        map.insert(s[i], t[i]);
        map2.insert(t[i], s[i]);
    }
    if flag {
        p("Yes");
    } else {
        p("No");
    }
}

Measured memory_bytes: 6396
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define double long double
#define SZ(x) ((int)(x).size())
#define rep(i,n) for(int i=0;i<(n);++i)
#define fore(i,a) for(auto &i:a)
#define min(...) min({__VA_ARGS__})
#define max(...) max({__VA_ARGS__})
#define Yes cout << "Yes" << endl;
#define No cout << "No" << endl;
#define answer cout << ans << endl;
signed _main(); signed main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
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; }
template<class T> using v = vector<T>;
template<class T> using vv = vector<v<T>>;
const int MOD=1e9+7;
const long long INF = 1LL << 60;
/*素数判定*/int isPrime(int n){if(n<2){return 0;}for(int i=2; i*i<=n; i++){if(n%i==0){return 0;}}return 1;}

signed _main(){
  string S; cin >> S;
  rep(i,2){
    if(S[i]!=S[i+1]){
      Yes
      return 0;
    }
  }
  No
  return 0;
}


Measured memory_bytes: 256
L,A,B,M=map(int,input().split())

def partsum(a,b,l,n):
    doublingconst=[0 for i in range(0,60)]
    doublingconst[0]=1
    doublingline=[0 for i in range(0,60)]
    doublingline[0]=0
    for i in range(1,60):
        doublingconst[i]=((pow(10,l*2**(i-1),M)+1)*doublingconst[i-1]%M)
        doublingline[i]=((pow(10,l*2**(i-1),M)+1)*doublingline[i-1]+pow(2,i-1,M)*pow(10,l*2**(i-1),M)*doublingconst[i-1])%M

    ansconst=0
    chousei=0
    for i in range(0,60):
        if n>>i &1==1:
            ansconst+=doublingconst[i]*pow(10,chousei*l,M)
            ansconst%=M
            chousei+=2**i

    ansline=0
    chousei=0
    for i in range(0,60):
        if n>>i &1==1:
            ansline+=(doublingline[i]+chousei*doublingconst[i])*pow(10,chousei*l,M)
            ansline%=M
            chousei+=2**i

    return ansline*a+ansconst*b

start=len(str(A))
end=len(str(B*L+A-B))
part=[]
for i in range(start-1,end):
    l=1+(10**i-A-1)//B
    r=(10**(i+1)-A-1)//B
    l=max(0,l)
    r=min(L-1,r)
    part.append([i+1,l,r])

part.sort(reverse=True)
ans=0
chousei=0
for i in range(0,len(part)):
    length,l,r=part[i]
    const=B*r+A
    line=B
    ans+=(partsum(-line,const,length,r-l+1)*pow(10,chousei,M))%M
    ans%=M
    chousei+=length*(r-l+1)
print(ans)

Measured memory_bytes: 38512
import java.util.*;

public class Main {

    public static void main(String args[]) {

        // 入力
        Scanner sc = new Scanner(System.in);
        int a = Integer.parseInt(sc.next());
        int b = Integer.parseInt(sc.next());
        sc.close();

        // 主処理
        boolean isZero = a < 0 && 0 < b;

        String result = "Zero";
        if (!isZero) {
            boolean isNegative = (a < 0 && b < 0) && ((b - a) % 2 == 0);
            result = isNegative ? "Negative" : "Positive";
        }

        // 出力
        System.out.println(result);
    }
}


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

using namespace std;

typedef long long ll;
typedef long double ld;

const int MOD = 998244353;

int add(int a, int b)
{
    a += b;
    if (a >= MOD)
    {
        return a - MOD;
    }
    if (a < 0)
    {
        return a + MOD;
    }
    return a;
}

int mul(int a, int b)
{
    return a * (ll) b % MOD;
}

int pw(int a, int b)
{
    int r = 1;
    while (b)
    {
        if (b & 1)
        {
            r = mul(r, a);
        }
        a = mul(a, a);
        b /= 2;
    }
    return r;
}

const int N = (int) 3e5 + 7;
int n;
int q;
int a[N];
int all[4 * N];
int t[4 * N];
int p10[N];
int num[N];

void push(int v, int tl, int tr)
{
    if (all[v])
    {
        t[v] = mul(all[v], num[tr - tl]);
        if (tl < tr)
        {
            all[2 * v] = all[2 * v + 1] = all[v];
        }
        all[v] = 0;
    }
}

void upd(int v, int tl, int tr, int l, int r, int x)
{
    push(v, tl, tr);
    if (tr < l || r < tl)
    {
        return;
    }
    if (l <= tl && tr <= r)
    {
        all[v] = x;
        push(v, tl, tr);
        return;
    }
    int tm = (tl + tr) / 2;
    upd(2 * v, tl, tm, l, r, x);
    upd(2 * v + 1, tm + 1, tr, l, r, x);
    t[v] = add(mul(t[2 * v], p10[tr - tm]), t[2 * v + 1]);
}

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

    p10[0] = num[0] = 1;
    for (int i = 1; i < N; i++)
    {
        p10[i] = mul(p10[i - 1], 10);
        num[i] = add(num[i - 1], p10[i]);
    }

    cin >> n >> q;
    upd(1, 1, n, 1, n, 1);
    int sol = 0;
    for (int i = 1; i <= q; i++)
    {
        int l, r, x;
        cin >> l >> r >> x;
        upd(1, 1, n, l, r, x);
        push(1, 1, n);
        cout << t[1] << "\n";
    }
}


Measured memory_bytes: 10072
// template {{{

#include <bits/stdc++.h>
using namespace std;

#define loop(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) loop(i, 0, n)
#define rloop(i, a, b) for (int i = (int)(b) - 1; i >= (int)(a); i--)
#define rrep(i, n) rloop(i, 0, n)
#define eb emplace_back
#define ef emplace_front
#define pb pop_back
#define pf pop_front
#define all(c) std::begin(c), std::end(c)
#define mp std::make_pair
#define mt std::make_tuple
#define fi first
#define se second
#define popcnt __builtin_popcountll

using uint = unsigned;
using ll = long long;
using ull = unsigned long long;
using ld = long double;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vvl = vector<vl>;
using vd = vector<double>;
using vvd = vector<vd>;
using pi = pair<int, int>;
using pl = pair<ll, ll>;
using pd = pair<double, double>;
using tp = tuple<int, int, int>;
using tp4 = tuple<int, int, int, int>;
using tp5 = tuple<int, int, int, int, int>;

template<typename T>
using max_pq = priority_queue<T, vector<T>, less<T>>;

template<typename T>
using min_pq = priority_queue<T, vector<T>, greater<T>>;

const int MOD = 1e9 + 7;
const int INF = 1e9 + 10;
const ll LLINF = 1e18 + 10;

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

template<typename T>
inline T sq(T x){ return x * x; }

template<typename T, typename U>
inline bool chmax(T &x, U y){ if (x >= y) return false; x = y; return true; }

template<typename T, typename U>
inline bool chmin(T &x, U y){ if (x <= y) return false; x = y; return true; }

template<typename T>
inline void sort(T &c){ std::sort(std::begin(c), std::end(c)); }

template<typename T>
inline void reverse(T &c){ std::reverse(std::begin(c), std::end(c)); }

template<typename T>
inline void unique(T &c){ std::sort(std::begin(c), std::end(c)); c.erase(std::unique(all(c)), std::end(c)); }

// }}}

int main()
{
	int m;
	cin >> m;
	while (m--){
		int s, y, n;
		cin >> s >> y >> n;
		int res = 0;
		rep(i, n){
			int t, c;
			double r;
			cin >> t >> r >> c;
			if (t == 0){
				int a = s, b = 0;
				rep(j, y){
					b += a * r;
					a -= c;
				}
				chmax(res, a + b);
			}
			else {
				int a = s;
				rep(j, y){
					a = a + a * r - c;
				}
				chmax(res, a);
			}
		}
		cout << res << endl;
	}
}

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

using namespace std;

#define bug(x) cerr << #x << " = " << x << '\n'
#define ll     long long
#define x      first
#define y      second
#define eb     emplace_back
#define maxn   300005
#define mod    1000000007
#define ar2    array<int, 2>

ar2 a[maxn], b[maxn];
map <ar2, bool> d;

int dx[maxn], dy[maxn];

int main() {
        #ifndef ONLINE_JUDGE
            //freopen(".inp","r",stdin);
        #endif // ONLINE_JUDGE

        ios_base::sync_with_stdio(0);
        cin.tie(0); cout.tie(0);

        int n, m, k;
        cin >> n >> m >> k;

        for(int i = 1; i <= k; ++ i) {
            cin >> a[i][0] >> a[i][1];
            b[i] = {a[i][1], a[i][0]};
            d[a[i]] = 1;
        }

        sort(a + 1, a + k + 1);
        sort(b + 1, b + k + 1);

        int cx = 1, cy = 1;
        ar2 x = {0, 0}, y = {0, 0};

        for(int i = 1; i <= k; ++ i) {
            if(i == k || a[i][0] != a[i+1][0]) {
                x = max(x, {cx, a[i][0]});
                dx[a[i][0]] = cx;
                cx = 1;
            } else
                cx ++;
            if(i == k || b[i][0] != b[i+1][0]) {
                y = max(y, {cy, b[i][0]});
                dy[b[i][0]] = cy;
                cy = 1;
            } else
                cy ++;
        }

        int ret = 0;
        for(int i = 1; i <= k; ++ i) {
            int cnt = x[0] + dy[b[i][0]];
            if(d.count({x[1], b[i][0]})) cnt --;
            ret = max(ret, cnt);

            cnt = y[0] + dx[a[i][0]];
            if(d.count({a[i][0], y[1]})) cnt --;
            ret = max(ret, cnt);
        }
        cout << ret;
}





Measured memory_bytes: 29456
n, t = gets.split(' ').map(&:to_i)

ary = []
n.times do
    ary << gets.split(' ').map(&:to_i)
end

min = 1001
n.times do |i|
    if ary[i][1] <= t then
        if ary[i][0] < min then
            min = ary[i][0]
        end
    end
end

if min == 1001 then
    print 'TLE'
else
    print min
end

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

using namespace std;

#define INF (1 << 30)
#define EPS 1e-10
#define MOD 1000000007

#define rep(i, n) FOR(i, 0, n)
#define FOR(i, x, n) for (int i = (x); i < (n); ++i)
#define all(v) (v).begin(), (v).end()

using ll = long long;

template<class T> void chmax(T& a, T b){ a>b?:a=b; }
template<class T> void chmin(T& a, T b){ a<b?:a=b; }

int main() {
    int x;
    cin >> x;
    cout << (x >= 30 ? "Yes" : "No") << endl;

    return 0;
}

Measured memory_bytes: 3648