akhauriyash/Code-Regression huggingface dataset:
import sys
from collections import deque, defaultdict
import copy
import bisect
input=sys.stdin.readline
sys.setrecursionlimit(10 ** 9)
import math

N, M = list(map(int, input().split()))
XYZ = []
for i in range(M):
	XYZ.append(list(map(int, input().split())))

renketu = [dict() for i in range(N)]
for i in range(N):
	renketu[i]["iro"] = -1
	renketu[i]["eda"] = []
for i in range(M):
	renketu[XYZ[i][0] - 1]["eda"].append([XYZ[i][0], XYZ[i][1]])
	renketu[XYZ[i][1] - 1]["eda"].append([XYZ[i][1], XYZ[i][0]])

num = 0
for i in range(N):
	if renketu[i]['iro'] == -1:
		num += 1
		stack = [i]
		# print(rest, num)
		renketu[i]['iro'] = num
		while len(stack) > 0:
			node = stack.pop()
			for edge in renketu[node]["eda"]:
				if renketu[edge[1] - 1]["iro"] == -1:
					renketu[edge[1] - 1]["iro"] = num
					stack.append(edge[1] - 1)

print(num)

Measured memory_bytes: 118620
#include<bits/stdc++.h>
using namespace std;
 
int N;
int a[305];
int dp[305][305];
int sum[305][305];
 
int calc(int x,int y){
  int res=0,c=0;
 
  while(x>0||y>0){
    int px=x%10,py=y%10;
    res+=( px*py + c );
    if(px+py+c<10)c=0;
    else c=1;
    x/=10;
    y/=10;
  }
 
  return res+c;
}
 
int solve(int l,int r){
  if(dp[l][r]!=-1)return dp[l][r];
 
  if(l==r)return 0;
   
  int res=1e9;
  for(int i=l;i<r;i++){
    int L=solve(l,i);
    int R=solve(i+1,r);
    res=min(res,L+R+calc(sum[l][i],sum[i+1][r]));
  }
  return dp[l][r]=res;
}
 
int main(){
  memset(dp,-1,sizeof(dp));
  cin>>N;
  for(int i=0;i<N;i++)cin>>a[i];
  for(int l=0;l<N;l++){
    for(int r=l;r<N;r++){
      sum[l][r]=0;
      for(int i=l;i<=r;i++)sum[l][r]+=a[i];
    }
  }
 
 
  cout<<solve(0,N-1)<<endl;
  return 0;
}

Measured memory_bytes: 1920
#include<bits/stdc++.h>  // ain't my code, it's hust the  nearst idea to mine
using namespace std;
using Int = long long;
bool isprime(Int x){
  if(x<=1) return 0;
  for(Int i=2;i*i<=x;i++)
    if(x%i==0) return 0;
  return 1;
}
signed main(){
  const Int n=2e5;
  vector<Int> s(n);
  for(Int i=1;i<n;i++)
    s[i]=s[i-1]+((i&1)&&isprime(i)&&isprime((i+1)/2));
  Int q;
  cin>>q;
  
  for(Int i=0;i<q;i++){
    Int l,r;
    cin>>l>>r;
    cout<<s[r]-s[l-1]<<endl;
  }
  return 0;
}  

Measured memory_bytes: 2176
#include <bits/stdc++.h>
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
typedef long long int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define MOD (1000000007)
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1}; // 移動方向

string s;
bool flg = false;

void input(){
    cin >> s;
}

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    input();
    string words[4] = {"maerd", "remaerd", "esare", "resare"};
    string tmp = "";
    int sz = s.size();
    for(int i=sz-1;i>=0;--i) tmp += s[i];
    for(int i=0;i<sz;++i){
        if(tmp.substr(i, 5) == words[0]) i += 4;
        else if(tmp.substr(i, 7) == words[1]) i += 6;
        else if(tmp.substr(i, 5) == words[2]) i += 4;
        else if(tmp.substr(i, 6) == words[3]) i += 5;
        else{
            cout << "NO" << endl;
            return 0;
        }
    }
    cout << "YES" << endl;
    return 0;
}

Measured memory_bytes: 592
import java.util.*;
public class Main { 
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String a = sc.next();
        String b = sc.next();
        if(a.equals("H") && b.equals("H") || a.equals("D") && b.equals("D"))
            System.out.println("H");
        else
            System.out.println("D");
    }
}

Measured memory_bytes: 21844
using System;
using System.Collections.Generic;
using System.Linq;

namespace AOJ
{
    class Program
    {
        static bool[] prime = new bool[50022];
        static bool[] check = new bool[50022];
        static void Main(string[] args)
        {
            int end = (int)Math.Sqrt(50022) + 1;
            for(int i = 2; i < end; i++)
            {
                if (check[i]) continue;
                prime[i] = true;
                for(int j = 1; i * j < 50022; j++)
                {
                    check[i * j] = true;
                }
            }
            for(int i = end; i < 50022; i++)
            {
                if (check[i]) continue;
                prime[i] = true;
            }
            string line;
            while((line = Console.ReadLine()) != null)
            {
                var n = int.Parse(line);
                for(int i = n - 1; i >= 2; i--)
                {
                    if (!prime[i]) continue;
                    Console.Write(i + " ");
                    break;
                }
                for(int i = n + 1; i < 50022; i++)
                {
                    if (!prime[i]) continue;
                    Console.WriteLine(i);
                    break;
                }
            }
        }
    }
}

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

#define ms(a,b) memset(a, b, sizeof(a))
#define rep(a,b,c) for(int a = (int)(b); a < (int)(c); a++)
#define fi first
#define se second
#define pb push_back
#define pf push_front
#define m_p(a,b) make_pair(a, b)
#define lson l,mid,o << 1
#define rson mid + 1,r,o << 1 | 1
#define ls o << 1
#define rs o << 1 | 1
#define inf 0x3f3f3f3f

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef double db;
typedef pair<int,int> pii;

inline bool isdigit(char& ch) {
	return ch >= '0' && ch <= '9';
}
template<class T>
void read(T &x) {
	x = 0;
	ll f = 1;char ch = getchar();
	for (;!isdigit(ch);ch = getchar()) 
		if (ch == '-') f = -1;
	for (; isdigit(ch);ch = getchar())
		x = (x << 1) + (x << 3) + ch - '0';
	x *= f;
}
template<class T>
inline void write(T x) {
	if (x == 0) {putchar('0');return ;}
	if (x < 0) {putchar('-');x = -x;}
	int _stk[65],_top = 0;
	for (;x;x /= 10) _stk[++_top] = x % 10 + 48;
	for (;_top;_top--)putchar(_stk[_top]);
}

int h, w, k;
vector<vector<char> >g;
vector<vector<int> >dis;

int main () {
	ios::sync_with_stdio(false);
	cin >> h >> w >> k;
	int x, y, a, b;
	cin >> x >> y >> a >> b;

	x -= 1, y-= 1, a -= 1, b -= 1;
	int dx[4] = {-1, 1, 0, 0};
	int dy[4] = {0, 0, -1, 1};

	rep(i, 0, h) {
		vector<char>tmp;
		vector<int>d;
		char a;
		rep(j, 0, w) {
			cin >> a;
			tmp.pb(a);
			d.pb(-1);
		}
		g.pb(tmp);
		dis.pb(d);
	}

	queue<pii>que;
	que.push(m_p(x, y));
	dis[x][y] = 0;
	while(!que.empty()) {
		auto now = que.front();
		que.pop();
		x = now.fi;
		y = now.se;
		rep(i, 0, 4) {
			int xx = x;
			int yy = y;
			rep(j, 0, k) {
				xx += dx[i];
				yy += dy[i];
				if (xx < 0 || xx >= h || y < 0 || y >= w || g[xx][yy] == '@' || (dis[xx][yy] != -1 && dis[xx][yy] < dis[x][y] + 1))
					break;
				if (dis[xx][yy] == -1) {
					dis[xx][yy] = dis[x][y] + 1;
					que.push(m_p(xx, yy));
				}
			}
		}
	}
	cout << dis[a][b] ;
	return 0;
}

Measured memory_bytes: 13088
#include<bits/stdc++.h>
using namespace std;
/*#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
/*template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
*/typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<ll,ll> pl;
typedef pair<int,int> pii;

#define LOCAL 0
#define dbg(x) cout << #x << " is " << x << "\n"
#define gll(x) scanf("%d",&x)
#define gll2(x,y) scanf("%d%d",&x,&y)
#define gll3(x,y,z) scanf("%d%d%d",&x,&y,&z)
#define gllarr(arr,n) f(i,n) gll(arr[i]);
#define sz(x) ((int)x.size())
#define s(x) sort(x.begin(),x.end())
#define all(v) v.begin(),v.end()
#define rs(v) { s(v) ; r(v) ; }
#define r(v) {reverse(all(v));}
#define pb push_back
#define f(i,n) for(int i=0;i<n;i++)
#define fr(i,n) for(int i=n-1;i>=0;i--)
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define repr(i,a,b) for(int i=a;i>=b;i--)

const ll mod = (ll)1e9 + 7;
const ll inf = (ll)1e16;
const ld eps = 1e-12;
const ll N = (int)1e5 + 5;
const ll LOGN = 19;
const ld PI = 3.14159265358979323846;
inline ll mul(ll a, ll b, ll m = mod) { return (ll)(a * b) % m;}
inline ll add(ll a, ll b, ll m = mod) { a += b; if(a >= m) a -= m; if(a < 0) a += m; return a;}
inline ll power(ll a, ll b, ll m = mod) { if(b == 0) return 1; if(b == 1) return (a % m); ll x = power(a, b / 2, m); x = mul(x, x, m); if(b % 2) x = mul(x, a, m); return x;}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    if (LOCAL) {
        freopen("C:\\Users\\Dishant\\Desktop\\Collection-DEV c++\\input.txt", "r", stdin);
        freopen("C:\\Users\\Dishant\\Desktop\\Collection-DEV c++\\output.txt", "w", stdout);
    }
    ll a, b, k;
    cin>>a>>b>>k;
    ll A = a, B = b;
    while(k){
        a = A, b = B;
        if(a & 1) a--;
        b += a/2;
        a /= 2;
        A = a, B = b;
        k--;
        if(k == 0) break;
        if(b & 1) b--;
        a += b/2;
        b /= 2;
        A = a, B = b;
        k--;
    }
    cout<<A<<' '<<B;
    return 0;
}

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

using ll = long long;

const int mod = 1000000007;
const int INF = 1000000000;
const double EPS = 1e-9;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    vector<int> a(n);
    ll sum = 0;
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
        sum += a[i] * (i % 2 == 0 ? +1 : -1);
    }
    cout << sum << " ";
    ll prev_ans = sum;
    for (int i = 0; i < n - 1; ++i) {
        ll ans = 2 * a[i] - prev_ans;
        cout << ans << " ";
        prev_ans = ans;
    }
    cout << endl;
}


Measured memory_bytes: 1792
dic = {}
dic['a'] = input()
dic['b'] = input()
dic['c'] = input()

cur = 'a'
while True:
    if len(dic[cur]) == 0:
        break

    nex = dic[cur][0]
    dic[cur] = dic[cur][1:]
    cur = nex
print(cur.upper())

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll MOD=1e9+7;
const ll LINF=1e18;
const int INF=0x3f3f3f3f;
const int MAXN=5050;

void solve(int T){
	int n,m,t;
	scanf("%d %d %d",&n,&m,&t);
	if(m*t>=n)puts("Yes");
	else puts("No"); 
}
signed main(){
	int t=1;
	//scanf("%d",&t);
	for(int i=1;i<=t;i++){
		solve(i);
	}
}

Measured memory_bytes: 3656
#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>;

int main() {
  int n, m;
  cin >> n >> m;
  string s;
  cin >> s;

  stack<int> st;
  int now = n;
  while (1) {
    if (now <= m) {
      st.push(now);
      break;
    }
    for (int j = m; j >= 0; j--) {
      if (j == 0) {
        cout << -1 << endl;
        return 0;
      }
      if (s[now - j] == '0') {
        now -= j;
        st.push(j);
        break;
      }
    }
  }
  while (1) {
    cout << st.top();
    st.pop();
    if (st.empty()) break;
    cout << " ";
  }
  cout << endl;
  return 0;
}

Measured memory_bytes: 868
/* {{{ */
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};
    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };
    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };
    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };
    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };
    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}
/* }}} */

fn main() {
    input! {
        n: u32,
        r: u32
    }
    if n < 10 {
        println!("{}", r + (100 * (10 - n)));
    } else {
        println!("{}", r);
    }
}
/* vim:set foldmethod=marker: */


Measured memory_bytes: 4352
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < n; i++)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
int s[5],c[5];

int main()
{
	/*
	rep(i,5)
	{
		d[i] = -1;
	}
	*/
	int N,M;
	cin >> N >> M;
	rep(i,M)
	{
		cin >> s[i] >> c[i];
	}

	bool ans0 = true;
	if (N != 1) ans0 = false;
	rep(i,M)
	{
		if (s[i] != 1 || c[i] != 0) ans0 = false;
	}
	if (ans0)
	{
		cout << "0" << endl;
		return 0;
	}
	for (int i = 1; i <= 999; ++i)
	{
		int d = 0;
		int temp = i;
		bool check = true;
		while(temp > 0)
		{
			d++;
			temp /= 10;
		}
		if (d != N) continue;
		rep(j,M)
		{
			temp = i;
			rep(i,N-s[j])
			{
				temp /= 10;
			}
			temp = temp % 10;
			//cout << temp << " ";
			if (c[j] != temp) check = false;
		}
		//cout << endl;
		if (check)
		{
			cout << i << endl;
			return 0;
		}
	}
	cout << -1 << endl;
	return 0;
		/*
		if (s == 1 && c == 0 && N != 1)
		{
			cout << "-1" << endl;
			return 0;
		}
		if (d[s] != c && d[s] != -1)
		{
			cout << "-1" << endl;
			return 0;
		}
		d[s] = c;
	}
	if (d[1] == -1) cout << 1;
	else cout << d[1];
	for (int i = 2; i <= N; ++i)
	{
		if (d[i] == -1) cout << 0;
		else cout << d[i];
	}
	cout << endl;
	*/
	return 0;
}

Measured memory_bytes: 256
// 標準入力
var fs = require('fs'),
length = fs.fstatSync(process.stdin.fd).size,
buffer = new Buffer(length),
bytesRead = fs.readSync(process.stdin.fd, buffer, 0, length, 0),
input = buffer.toString('utf8', 0, bytesRead).split('\n');
main();
 
// ここから
function main(){

  var primeNumbers = new Int32Array(65535);
  var maxNum = 0;

  // 素数計算
  primeNumbers[0] = 2;
  var pcount = 1;
  for(var i = 3; i <= 999999; i+=2){
    var isPrime = true;
    for(var j = 3, maxJ = ~~Math.sqrt(i); j <= maxJ; j+=2){
      if(!(i % j)){
        isPrime = false;
        break;
      }
    }

    if(isPrime){
      primeNumbers[pcount] = i;
      pcount++;
    }
  }

  // 出力
MLOOP: for(var line = 0, inputLength = input.length; line < inputLength - 1; line++){
    for(var k = 0; k < pcount; k++){
      var prime = primeNumbers[k];
      if(prime > (input[line] - 0)){
        console.log(k);
        continue MLOOP;
      }
    }
  console.log(pcount);
  
  }

  
  
}

Measured memory_bytes: 8668
import java.util.*;

class Main{
  public static void main(String[] args){
    Scanner sc=new Scanner(System.in);
    int n=sc.nextInt();
    int l=0;int r=n-1;
    System.out.println(0);
    String ot=sc.next();
    boolean lm=ot.equals("Male");
    while(!ot.equals("Vacant")){
      int g=l+(r-l+1)/2;
      System.out.println(g);
      ot=sc.next();
      boolean gm=ot.equals("Male");
      boolean sag=((g-l)&1)==0;
      if(((lm==gm)&&sag)||((lm!=gm)&&!sag)){
        l=g;
        lm=gm;
      }else{
        r=g-1;
      }
    }
  }
}

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

Measured memory_bytes: 5088
/*
  AOJ 0582
  Title:
  @kankichi573
*/
#include <stdio.h>
// #include <stdlib.h>
// #include <string.h>
// #include <math.h>
// #include <float.h>
// #include <stdlib.h>


istriangle(int a,int b,int c)
{
        return(a+b>c && b+c>a && c+a>b);
}
isright(int a,int b,int c)
{
        return ((a*a+b*b==c*c)|| \
                (b*b+c*c==a*a)|| \
                (c*c+a*a==b*b));
}
iseikaku(int a,int b,int c)
{
        return ((a*a+b*b>c*c)&& \
                (b*b+c*c>a*a)&& \
                (c*c+a*a>b*b));
}
main()
{
        int tri,right,eikaku,donkaku,flag;
        int a,b,c;

        tri=right=eikaku=donkaku=flag=0;

        while(EOF!=scanf("%d %d %d",&a,&b,&c))
        {
                //printf("%d %d %d \n",a,b,c);
                if(flag==0 && istriangle(a,b,c))
                {
                        tri++;
                        if(isright(a,b,c))
                                right++;
                        else if (iseikaku(a,b,c))
                                eikaku++;
                        else
                                donkaku++;
                }
                else
                        flag=1;
        }
        printf("%d %d %d %d\n",tri,right,eikaku,donkaku);
        return(0);
}

Measured memory_bytes: 596
import java.util.*;
class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        long l = sc.nextLong();
        long r = sc.nextLong();
        long min = Long.MAX_VALUE;
        int cnt = 0;
        if(r-l>=2018) {

            System.out.println(0);
            return;
        }
        for(long i = l; i<r; i++) {
            for(long j = i+1; j<=r; j++) {
                cnt++;
                //if(cnt>=2019) break;
                min = Math.min((i*j)%2019, min);
            }
            if(min==0) break;
        }
        System.out.println(min);
    }
}

Measured memory_bytes: 21844
#include <bits/stdc++.h>
#define int long long
#define endl '\n'
#define pii pair<int, int>
#define ff first
#define ss second
using namespace std;

const int INF = 1LL << 40;
const int N = 101;
const int M = 100001;
int dp[N][M];
int w[N], v[N];

int f(int n, int c) {
    if(n == 0 || c == 0)
        return 0;
    int &ans = dp[n][c];
    if(ans != -1)
        return ans;
    
    ans = -INF;
    ans = max(ans, f(n - 1, c));
    if(c - w[n] >= 0)
        ans = max(ans, f(n - 1, c - w[n]) + v[n]);
    
    return ans;
}
 
signed main() {
 
    int n, c; cin >> n >> c;
    for(int i = 1; i <= n; i++)
        cin >> w[i] >> v[i];
        
    for(int i = 0; i < N; i++)
        for(int j = 0; j < M; j++)
            dp[i][j] = -1;
    
    cout << f(n, c) << endl;
 
    return 0;
}

Measured memory_bytes: 79104
#include <iostream>
#include <string>

int main ()
{
	std::string s, p;
	getline(std::cin, s);
	getline(std::cin, p);
	
	s += s;
	if (s.find(p, 0) != std::string::npos) std::cout << "Yes" << std::endl;
	else std::cout << "No" << std::endl;
	
	return 0;
}




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

using namespace std;

#define all(v)				((v).begin()), ((v).end())
#define allr(v)				((v).rbegin()), ((v).rend())
#define sz(v)				((int)((v).size()))
#define ll long long
#define pb					push_back
#define fIO ios_base::sync_with_stdio(0);cin.tie(0);

const ll oo = 1e8;
const double pi = 3.1415926535897;


const double EPS = (1e-7);
int dcmp(double x, double y) {	return fabs(x-y) <= EPS ? 0 : x < y ? -1 : 1;	}


typedef vector<int>                vi;
typedef vector<pair<int,int>>      vii;
typedef vector<ll>                 vll;
typedef vector<double>             vd;
typedef vector< vi >               vvi;
typedef vector< vd >               vvd;
typedef vector<string>             vs;
typedef pair<int, int>             pii;

/**
    * PLEASEEE READDD PROBLEEEM CARFULLY ****
    * Always check for OVERFLOW ll vs int
    * Always check for array bounds
    * Check for function return
    * READ OUTPUT SECTION AGAIN!!!
**/

struct edge{
    int from, to, w;

    edge(){}
    edge(int x, int y, int we): from(x), to(y), w(we){}

    bool operator < (const edge &rhs) const{
        return w > rhs.w;
    }

};

int main(){
    fIO
//    freopen("", "r", stdin);
//    freopen("", "w", stdout);

    int n;
    cin >> n;

    ll A[n];
    for(int i = 0; i < n; i++) {
        cin >> A[i];
        if(A[i] == 0) return cout << 0, 0;
    }

    ll tot = 1LL;

    ll mx = 1e18;
    for(int i = 0; i < n; i++) {
        //cout << tot << " " << (mx / A[i]) << "\n";
        if(A[i] != 0 && tot > (mx / A[i])) return cout << -1, 0;
        tot *= A[i];
    }

    cout << tot;
}








Measured memory_bytes: 4396
#include <vector>
#include <iostream>
#include <cmath>
#include <map>
#include <unordered_map>
#include <algorithm>
#include <fstream>
#include <unistd.h>
#include <string.h>
#include <string>
#include <numeric>
#include <queue>
#include <deque>
#include <sstream>
#include <iomanip>
#include <set>
#include <stack>
#include <cassert>
#include <functional>
#include <random>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<vvl> vvvl;
typedef vector<vvvl> vvvvl;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<bool> vb;
typedef vector<vector<bool>> vvb;
typedef vector<vvb> vvvb;
typedef vector<vvvb> vvvvb;
typedef vector<string> vs;
typedef vector<vs> vvs;
typedef vector<vvs> vvvs;
typedef vector<char> vc;
typedef vector<vector<char>> vvc;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<vvd> vvvd;
typedef long double LD;
typedef vector<LD> vld;
typedef vector<pair<LD, LD>> vpld;
typedef pair<ll, ll> PL;
typedef vector<PL> vpl;
typedef vector<vector<PL>> vvpl;
typedef vector<vvpl> vvvpl;
typedef pair<ll, PL> TL;
typedef vector<TL> vtl;
typedef vector<vtl> vvtl;
typedef long double ld;
typedef vector<ld> vld;
const ll LINF = 1e17;
const double pi = 3.1415926535897932;
const string endstr = "\n";
#define FOR(i, a, b) for(ll i = (a); i < b; i++)
#define RFOR(i, a, b) for(ll i = (a); i > b; i--)
#define rep(i, n) for(ll i = 0; i < n; i++)
#define rrep(i, n) for(ll i = n-1; i > -1; i--)
#define FORMAP(it, m) for(auto it = m.begin(); it != m.end(); it++)
#define ff first
#define ss second
#define pb push_back
#define epb emplace_back
#define ALL(X) (X).begin(),(X).end()

template <typename T> T gcd(T a, T b) {return (a == 0) ? b : gcd(b%a, a);}
template <typename T> T lcm(T a, T b) { return a / gcd(a, b) * b;}

bool p_comp_fs(const PL p1, const PL p2){ return p1.first < p2.first;};
bool p_comp_fg(const PL p1, const PL p2){ return p1.first > p2.first;};
bool p_comp_ss(const PL p1, const PL p2){ return p1.second < p2.second;};
bool p_comp_sg(const PL p1, const PL p2){ return p1.second > p2.second;};
template <typename T>
vector<T> uniquen(vector<T> vec /* copy */){
    sort(ALL(vec)); vec.erase(unique(vec.begin(), vec.end()), vec.end()); return vec;
}

inline ll popcnt(ll x){return __builtin_popcountll((unsigned long long)x);};
template<class T> bool chmax(T &a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; }
//friend bool operator<(const tpl& lhs, const tpl& rhs){
//    return std::tie(lhs.l, lhs.r) < std::tie(rhs.l, rhs.r);
//}

bool bit(ll st, ll b){return ((st>>b)&1) == 1;}


int main(){
#ifdef __DEBUG_LOCAL__
    ifstream file("../../../../../in.txt"); if(file.is_open()) cin.rdbuf(file.rdbuf());
#endif
    ios_base::sync_with_stdio(false); cin.tie(nullptr);
    
    ll N; cin >> N;
    set<ll> s;
    rep(_, N){
        ll a; cin >> a; s.insert(a);
    }
    cout << (s.size() == N ? "YES" : "NO") << endstr;
    return 0;
}


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

int main(){
    int n;
    cin >> n;
    if(n == 3 || n == 5 || n == 7){
        cout << "YES" << endl;
    }else{
        cout << "NO" << endl;
    }
    return 0;
}


Measured memory_bytes: 256
# solution
import io
import math

nim, mike = map(int, input().split())
if mike // 3 > (nim - 1) // 3 and mike // 673 > (nim - 1) // 673:
    print(0)
else:
    print(min(i * j % 2019 for i in range(nim, mike + 1) for j in range(nim, i)))

Measured memory_bytes: 3060
#include <vector>
#include <iostream>
#include <fstream>
#include <unordered_map>
#include <unordered_set>
#include <set>
#include <map>
#include <stdint.h>
#include <math.h>
#include <algorithm>

using namespace std;

class Task {
	public:
		void solve(istream &in, ostream &out) {
            vector<int> houses;
            int N, ai;
            in >> N;
            for (int i = 0; i < N; ++i) {
                in >> ai;
                houses.push_back(ai);
            }            

            sort(houses.begin(), houses.end());
            
            int res = 0; 
            for (int i = 0; i < houses.size() - 1; ++i) {
                res += houses[i+1] - houses[i];
            }

            cout << res;
		}
};

int main() {
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	istream &in(cin);
	ostream &out(cout);
	Task t;
	t.solve(in, out);
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
using ld=long double;
using P=pair<ll,ll>;
#define MOD 1000000007LL
#define INF 1000000000LL
#define EPS 1e-10
#define FOR(i,n,m) for(ll i=n;i<(ll)m;i++)
#define REP(i,n) FOR(i,0,n)
#define DUMP(a) REP(d,a.size()){cout<<a[d];if(d!=a.size()-1)cout<<" ";else cout<<endl;}
#define ALL(v) v.begin(),v.end()
#define UNIQUE(v)  sort(ALL(v));v.erase(unique(ALL(v)),v.end());
#define pb push_back

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	ll n;
	cin>>n;
	vector<ll> a(n);
	vector<ll> b(n);
	REP(i,n) cin>>a[i]>>b[i];
	ll ans=INF*INF;
	ll sum=0;
	REP(i,n) sum+=a[i];
	ans=min(ans,sum);
	sum=0;
	REP(i,n) sum+=b[i];
	ans=min(ans,sum);
	sum=0;
	vector<pair<P,ll>> c;
	REP(i,n) {
		ll aa=a[i],bb=b[i];
		c.pb(make_pair(P(aa,i),0));
		c.pb(make_pair(P(bb,i),1));
	}
	sort(ALL(c));
	vector<ll> det1(n,false);
	vector<ll> det2(n,false);
	REP(i,n) {
		if(c[i].second==0) {
			det1[c[i].first.second]=true;
		} else {
			det2[c[i].first.second]=true;
		}
		sum+=c[i].first.first;
	}
	vector<ll> t1; // 00
	vector<ll> t2; // 11
	vector<ll> t3; // 10
	vector<ll> t4; // 01
	REP(i,n) {
		if(det1[i]&&det2[i]) t2.pb(i);
		if(!det1[i]&&!det2[i]) t1.pb(i);
		if(!det1[i]&&det2[i]) t4.pb(i);
		if(det1[i]&&!det2[i]) t3.pb(i);
	}
	if(t1.size()!=0||t3.size()==n||t4.size()==n) {
		ans=min(ans,sum);
		cout<<ans<<endl;
	} else {
		vector<ll> tmp(n);
		REP(i,t3.size()) tmp[t3[i]]=3;
		REP(i,t4.size()) tmp[t4[i]]=4;
		ll mincost=INF*INF;
		REP(i,n) {
			if(tmp[i]==3) ans=min(ans,sum+mincost-a[i]);
			if(tmp[i]==4) ans=min(ans,sum+mincost-b[i]);

			if(tmp[i]==3) mincost=min(mincost,b[i]);
			if(tmp[i]==4) mincost=min(mincost,a[i]);
		}
		mincost=INF*INF;
		for(ll i=n-1; i>=0; i--) {
			if(tmp[i]==3) ans=min(ans,sum+mincost-a[i]);
			if(tmp[i]==4) ans=min(ans,sum+mincost-b[i]);

			if(tmp[i]==3) mincost=min(mincost,b[i]);
			if(tmp[i]==4) mincost=min(mincost,a[i]);
		}
		cout<<ans<<endl;
	}
	return 0;
}


Measured memory_bytes: 11756
#include<stdio.h>
int main( ) {
  int a,b,c,d,e;
  scanf("%d %d %d",&a,&b,&c);
  d=b-a;
  e=c-b;
  if(e==d){
    printf("YES\n");
  }else{
    printf("NO\n");
  }
  return 0;
}

Measured memory_bytes: 128
n = int(input())
v = [0] * n
for i in range(n):
    v[i] = list(input().split())
    v[i][0] = float(v[i][0])
# print(v)
ans = 0
for i in range(n):
    if v[i][1] == "JPY":
        ans += v[i][0]
    else:
        ans += v[i][0] * 380000.0
print(ans)


Measured memory_bytes: 38256
from collections import deque
n, q = list(map(int, input().split()))
A = deque()
for i in range(n):
    A.append(deque())
for i in range(q):
    query = list(map(int, input().split()))
    if query[0] == 0:
        A[query[1]].append(query[2])
    elif query[0] == 1:
        print(*list(map(str,A[query[1]])))
    else:
        A[query[1]].clear()


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

int main() {
  int x, a, b, c, d, t;
  cin >> x;
  a = x / 1000;
  t = x % 1000;
  b = t / 100;
  t = t % 100;
  c = t / 10;
  d = t % 10;
  
  if ((a == b && b == c) || (b == c && c == d)) {
      cout << "Yes" << endl;
  } else {
    	cout << "No" << endl;
  	}
}

Measured memory_bytes: 256
#include <iostream>
#include <queue>
#include <algorithm>

using namespace std;

int main(){
    int N, a, b;
    cin >> N;
    vector<int> deg(N), visited(N, 0), number(N, 0);
    vector<vector<int>> edges;
    vector<int> C;
    queue<int> Q;
    for (int i=0; i<N; i++){
        vector<int> tmp(N, 0);
        edges.emplace_back(tmp);
    }
    for (int i=0; i<N-1; i++){
        cin >> a >> b;
        edges[a - 1][b - 1] = 1;
        edges[b - 1][a - 1] = 1;
        deg[a - 1]++;
        deg[b - 1]++;
    }
    for (int i=0; i<N; i++){
        cin >> a;
        C.emplace_back(a);
    }
    sort(C.begin(), C.end());
    int max_deg = 0, root = 0;
    for (int i=0; i<N; i++){
        if (max_deg < deg[i]){
            max_deg = deg[i];
            root = i;
        }
    }
    Q.push(root);
    int counter = N - 1;
    while (!Q.empty()){
        int node = Q.front();
        visited[node] = 1;
        number[node] = C[counter];
        counter--;
        Q.pop();
        for (int i=0; i<N; i++){
            if (visited[i] == 0 && edges[node][i] == 1){
                Q.push(i);
            }
        }
    }
    int sum = 0;
    for (int i=0; i<C.size() - 1; i++){
        sum += C[i];
    }
    cout << sum << endl;
    for (int i=0; i<N; i++) cout << number[i] << " ";
    cout << endl;
    return 0;
}

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

#define DEBUG(x) cout<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cout<<#v<<":";for(int i=0;i<v.size();i++) cout<<" "<<v[i]; cout<<endl

typedef long long ll;
#define vi vector<int>
#define vl vector<ll>
#define vii vector< vector<int> >
#define vll vector< vector<ll> >
#define vs vector<string>
#define pii pair<int,int>
#define pis pair<int,string>
#define psi pair<string,int>
const int inf = 1000000001;
const ll INF = 1e16;
#define MOD 1000000007
#define mod 1000000009
#define pi 3.14159265358979323846
#define Sp(p) cout<<setprecision(15)<<fixed<<p<<endl;
int dx[4] = { 1,0,-1,0 }, dy[4] = { 0,1,0,-1 };




int main() {
	string s;
	cin >> s;
	sort(s.begin(), s.end());
	string a = "abcdefghijklmnopqrstuvwxyz";
	bool flag = false;
	int i;
	for (i = 0; i < 26; i++) {
		flag = false;
		for (int j = 0; j < s.size(); j++) {
			if (s[j] == a[i]) {
				flag = true;
				break;
			}
		}
		if (!flag) {
			break;
		}
	}
	if (i == 26) {
		cout << "None" << endl;
	}
	else {
		cout << a[i] << endl;
	}
}

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

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

  if (s == "ABC")
  {
    cout << "ARC" << endl;
  }
  else
  {
    cout << "ABC" << endl;
  }
}


Measured memory_bytes: 3560
import sys
input = lambda : sys.stdin.readline().rstrip()

import heapq
h = []
heapq.heapify(h)

n, m, s = list(map(int, input().split()))
a, b = [[None] * m for _ in range(2)]
c, d = [[None] * n for _ in range(2)]

ns = {u: set() for u in range(n)}
uv2e = {}
for i in range(m):
    u,v,a[i],b[i] = list(map(int, input().split()))
    ns[u-1].add(v-1)
    ns[v-1].add(u-1)
    uv2e[u-1,v-1] = i
    uv2e[v-1,u-1] = i
for i in range(n):
    c[i], d[i] = list(map(int, input().split()))

maxs = max(a)*(n-1)
s = min(s, maxs)
state = (0, 0, s) # (距離, ノード, 銀貨枚数)
ans = [[None] * (maxs+1) for _ in range(n)]
ans[0][s] = 0
done = [[None] * (maxs+1) for _ in range(n)]
heapq.heappush(h, state)
count = 0
while h:
    count += 1
    dd, u, ss = heapq.heappop(h)
#     if ans[u][ss] is not None and ans[u][ss] <= dd:
#         continue
#     ans[u][ss] = dd
    
    if done[u][ss]:
        continue
    done[u][ss] = True
    
    # グラフの隣接点
    for v in ns[u]:
        e= uv2e[u,v]
        if ss<a[e] or done[v][ss-a[e]] :
            continue
        ans[v][ss-a[e]] = min(ans[v][ss-a[e]], dd + b[e]) if ans[v][ss-a[e]] is not None else dd+b[e]
#         if ss<a[e] or ans[v][ss-a[e]] is not None:
#             continue
        heapq.heappush(h, (dd + b[e], v, ss-a[e]))
    # 両替
    if ss+c[u] <= maxs:
        sss = ss+c[u]
    elif ss < maxs:
        sss = maxs
    else:
        continue
    heapq.heappush(h, (dd + d[u], u, sss))
#     print(sss, maxs, ss, c[u])
    ans[u][sss] = min(ans[u][sss], dd + d[u]) if ans[u][sss] is not None else dd+d[u]

for item in ans[1:]:
    print(min(item))

Measured memory_bytes: 125756
#include<cstdio>
#include<string.h>
#include<stack>
#include<iostream>
using namespace std;

int main() {

  string seq;

  while ( getline(cin, seq) ) {

    if ( seq.size() == 1 && seq[0] == '.' ) return 0;

    stack<int> V;
    int sw = 0;
    for ( int i = 0; i < seq.length(); i++ ) {
      if ( seq[i] == '(' ) V.push(0);
      if ( seq[i] == '[' ) V.push(1);
      if ( seq[i] == ')' ) {
        if ( !V.empty() && V.top() == 0 ) V.pop();
        else sw = 1;
      }
      if ( seq[i] == ']' ) {
        if ( !V.empty() && V.top() == 1 ) V.pop();
        else sw = 1;
      }
      continue;
    }
    if ( sw == 0 && V.empty() ) printf("yes\n");
    else printf("no\n");
  }

  return 0;
}


Measured memory_bytes: 3152
#include<stdio.h>

int isprime(int n) {
  for(int i = 2; i * i <= n; i++) {
    if(n % i == 0) return 0;
  }
  return 1;
}

int main(){
  int MAX_V = 1000000;
  int prime[MAX_V+1];
  int i, v;
  for(i = 2;i <= MAX_V;i++){
    prime[i] = isprime(i);
  }

  while(scanf("%d", &v) != 0){
    for(int i = v;i > 0;i--){
      if(prime[i] == 1&&prime[i-2] == 1){
          printf("%d %d\n",i-2,i);
          break;
        }
      }
    if(v == 0) break;
  }
  return 0;
}

Measured memory_bytes: 5652
#include <iostream>
#include <algorithm>
#include <vector>
#include <cstring>
#include <map>
#include <set>
#include <queue>
#include <cstdio>
#include <cmath>
using namespace std;
typedef long long LL;

LL a,b;

int main() {
	scanf("%lld %lld",&a,&b);
	if(a>b) swap(a,b);
	LL ans=0;
	if(a==1 && b==1) ans=1;
	else if(a==1) {
		ans=b-2;
	}
	else {
		ans=(a-2)*(b-2);
	}
	printf("%lld\n",ans);
}

Measured memory_bytes: 256
/*dismint|jjc*/
#include <bits/stdc++.h>
using namespace std;
#define forl(V, S, E) for(int V = S; V < E; V++)
#define ford(V, S, E) for(int V = S; V >= E; V--)
#define fore(E, X) for(auto &E:X)
#define println(X) cout << X << endl
#define printe(X) for(auto &E:X) cout << E << " "; cout << endl
typedef unordered_map<int, unordered_set<int>> graph;
typedef long long ll;

int main() {
	ios_base::sync_with_stdio(false); cin.tie(NULL);
	int n, k; string s; cin >> n >> k >> s;
	int p1 = 0, p2 = 0, ans = 0;
	while(p2 < n) {
		while(p2 < n and s[p2] == '1') p2++;
		ans = max(ans, p2-p1);
		while(p2 < n and s[p2] == '0') p2++;
		k--;
		if(k < 0) {
			while(p1 < n and s[p1] == '1') p1++;
			while(p1 < n and s[p1] == '0') p1++;
		}
		ans = max(ans, p2-p1);
	}
	println(ans);
}


Measured memory_bytes: 512
let NMK: [Int] = readLine()!.split(separator: " ").map { Int($0)! }
let As: [Int64] = readLine()!.split(separator: " ").map { Int64($0)! }
let Bs: [Int64] = readLine()!.split(separator: " ").map { Int64($0)! }

var remainTime = Int64(NMK[2])
var res: Int = 0
for A in As {
    if remainTime - A < 0 {
        break
    } else {
        remainTime -= A
        res += 1
    }
}

var aIdx: Int = res-1
for bIdx in 0..<NMK[1] {
    remainTime -= Bs[bIdx]
        
    while remainTime < 0 && aIdx >= 0 {
        remainTime += As[aIdx]
        aIdx -= 1
    }
    
    if remainTime >= 0 {
        res = max(res, aIdx + bIdx + 2)
    }
}
print(res)  // (๑•ૅㅁ•๑)

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

#define _USE_MATH_DEFINES
#include<cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <deque>
#include <algorithm>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <iterator>
#include<iomanip>
#include<unordered_set>
#include<bitset>
#include<complex>

using namespace std;

#define rep(i,a,b) for(int i=(a), i##_len=(b);i<i##_len;i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)

#define int ll
#define SZ(x) ((int)(x).size())
#define pb push_back
#define mp make_pair

//typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<double, double> pdd;
typedef vector< vector<int> > mat;

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

const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD =  (int)1e9 + 7;
const double EPS = 1e-9;

int facl[100010],facr[100010];
int cnt[100010];
int X[100010];

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

	int N;
	cin >> N;
	rep(i, 0, N)
	{
		cin >> X[i];
	}

	facl[0] = facl[1] = 1;
	rep(i, 2, N)
	{
		facl[i] = i * facl[i - 1];
		facl[i] %= MOD;
	}
	facr[N] = 1;
	rrep(i, 1, N)
	{
		facr[i] = i * facr[i + 1];
		facr[i] %= MOD;
	}

	cnt[0] = facl[N - 1];
	rep(i, 2, N)
	{
		cnt[i - 1] = facl[i - 1];
		cnt[i - 1] *= facr[i + 1];
		cnt[i - 1] %= MOD;
		cnt[i - 1] += cnt[i - 2];
		cnt[i - 1] %= MOD;
	}

	int ans = 0;
	rep(i, 0, N - 1)
	{
		ans += cnt[i] * (X[i + 1] - X[i]);
		ans %= MOD;
	}

	cout << ans << endl;

	return 0;
}

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

int main(){
  int A,B;
  cin >> A >> B;
  int plus = A + B;
  int minus = A - B;
  int multiple = A * B;
  int X = max(plus,minus);
  int Y = max(minus,multiple);
  cout << max(X,Y);
}

Measured memory_bytes: 256
#include<stdio.h>
#include<algorithm>
#include<string.h>
#include<vector>
#define fst first
#define snd second

using namespace std;

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

const int MN = 5e5 + 1;

char eq[MN];

int N;
int A[MN];
bool memo[MN];
int f(int i) {
    if(memo[i]) return A[i];
    memo[i] = true;
    if(i > 0 && eq[i-1] == '<') {
        A[i] = max(A[i], f(i-1) + 1);
    }
    if(i < N-1 && eq[i] == '>') {
        A[i] = max(A[i], f(i+1) + 1);
    }
    return A[i];
}

int main() {
    scanf("%s", eq);
    N = strlen(eq) + 1;
    ll ans = 0;
    for (int i = 0; i < N; i++) {
        ans += f(i);
    }
    printf("%lld\n", ans);
    return 0;
}

Measured memory_bytes: 18688
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef unordered_set<int> us;
#define ft first
#define se second
#define pb(x) push_back(x)
#define mk(a,b) make_pair(a,b)
#define all(x) x.begin(),x.end()
#define endll "\n"
int main(){
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    int k,a,b;cin>>k>>a>>b;
    if(ceil((float)a/k)*k<=b)cout<<"OK"<<endl;
    else cout<<"NG"<<endl;
}


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

namespace _0338
{
    class Program
    {
        static void Main(string[] args)
        {
            int[] whc = RArInt();
            int g = (int)Gcd(whc[0], whc[1]);
            Console.WriteLine(whc[0]/g * whc[1]/g * whc[2]);
        }

        /// <summary>
        ///最大公約数
        /// </summary>
        public static long Gcd(long a, long b)
        {
            if (a < b) return Gcd(b, a);  // 引数を入替えて自分を呼び出す
            if (b == 0) return a; //一方が0の場合は、もう片方の数自身がGCD

            long d = 0;
            do
            {
                d = a % b;
                a = b;
                b = d;
            } while (d != 0);
            return a;
        }

        static string RSt() { return Console.ReadLine(); }
        static int RInt() { return int.Parse(Console.ReadLine().Trim()); }
        static long RLong() { return long.Parse(Console.ReadLine().Trim()); }
        static double RDouble() { return double.Parse(Console.ReadLine()); }
        static string[] RArSt(char sep = ' ') { return Console.ReadLine().Trim().Split(sep); }
        static int[] RArInt(char sep = ' ') { return Array.ConvertAll(Console.ReadLine().Trim().Split(sep), e => int.Parse(e)); }
        static long[] RArLong(char sep = ' ') { return Array.ConvertAll(Console.ReadLine().Trim().Split(sep), e => long.Parse(e)); }
        static double[] RArDouble(char sep = ' ') { return Array.ConvertAll(Console.ReadLine().Trim().Split(sep), e => double.Parse(e)); }
        static string WAr<T>(IEnumerable<T> array, string sep = " ") { return string.Join(sep, array.Select(x => x.ToString()).ToArray()); }
    }
}



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

int main() {

  int a, b, c;
  cin>>a>>b>>c;
  if (a < b) {
    if (a < c && c < b) {
      cout<<"Yes"<<endl;
    } else {
      cout<<"No"<<endl;
    }
  } else {
    if (b < c && c < a) {
      cout<<"Yes"<<endl;
    } else {
      cout<<"No"<<endl;
    }
  }
}

Measured memory_bytes: 256
import Control.Monad
import Control.Applicative
import Control.Monad.State

type Count = (Int, Int)
type Nums = [Int]
type CountState = (Count, Nums)

toSpace :: String -> String
toSpace [] = []
toSpace (x:xs) = if x == ','
                      then ' ' : toSpace xs
                      else x : toSpace xs

solve :: State CountState Count
solve = do
  ((rec, loz), numList) <- get
  if numList == []
    then return (rec, loz)
    else do
      let (x:y:z:zs) = numList
      if x^2 + y^2 == z^2
        then do
          put ((rec + 1, loz), zs)
          solve
        else if x == y
          then do
            put ((rec, loz + 1), zs)
            solve
          else do
            put ((rec, loz), zs)
            solve

main = do
  contents <- join <$> map (map (read :: String -> Int) . words . toSpace) . lines <$> getContents
  let ans = evalState solve ((0, 0), contents)
  print $ fst ans
  print $ snd ans

Measured memory_bytes: 3828
import java.util.*;

class Main{
	public static void main(String[] args){
		Solve s = new Solve();
		s.solve();
	}	
}

class Solve{
	Solve(){}
	
	Scanner in = new Scanner(System.in);

	int ans, a, b;
	int[] dx = {0,1};
	int[] dy = {1,0};
	boolean[][] d;

	void solve(){
		while(in.hasNext()){
			a = in.nextInt(); b = in.nextInt();
			if(a == 0 && b == 0) return;
			d = new boolean[a][b];
			int n = in.nextInt();
			for(int i = 0; i < n; i++){
				int x = in.nextInt() - 1, y = in.nextInt() - 1;
				d[x][y] = true;
			}
			ans = 0;
			calc(0,0);
			System.out.println(ans);
		}
	}

	void calc(int x,int y){
		if(x == a - 1 && y == b -1){
			ans++;
			return;
		}
		for(int i = 0; i < 2; i++){
			int nx = x + dx[i], ny = y + dy[i];
			if(nx >= 0 && nx < a && ny >= 0 && ny < b && !d[nx][ny]){
				calc(nx,ny);
			}
		}
	}
	
}

Measured memory_bytes: 26968
//Use valgrind once if the submission doesn't go through. It can detect uninitialized variables and see where they could be an issue.
#include <bits/stdc++.h>
#include <numeric>
#include <ext/pb_ds/assoc_container.hpp>
#define MOD 1000000007;
using namespace __gnu_pbds;
using namespace std;
template <typename T> using ordered_set =  tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

int main(){

	ios_base::sync_with_stdio(false);
    	cin.tie(NULL);

	long long n,s{0};
	cin>>n;
	vector<long long> a(n),prefix(n+1,0);
	for(int i=0;i<a.size();++i){
		cin>>a[i];
		prefix[i+1]=prefix[i]+a[i];
		prefix[i+1]%=MOD;
		s+=prefix[i]*a[i];
		s%=MOD;
	}
	cout<<s<<endl;
}


Measured memory_bytes: 6364
//https://cs.stackexchange.com/questions/84426/find-a-node-with-maximum-distance-from-given-node-in-a-tree
#include<bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp> // Common file
//#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
//using namespace __gnu_pbds;
//#include <ext/rope> //header with rope
//using namespace __gnu_cxx;
//#define ordered_set tree<pii, null_type,less<pii>, rb_tree_tag,tree_order_statistics_node_update>
// find_by_order tells index pr kon hai..
// order_by_key  tells ki us element se kitne strictly smaller element hai...
#define mod 1000000007
#define fr first
#define se second
#define ll long long
#define PI 3.1415926535 
#define pb push_back
#define mpr make_pair
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define Senky_Bansal ios_base::sync_with_stdio(false);
#define IIIT_ALLAHABAD    cin.tie(NULL);cout.tie(NULL);
using namespace std;
ll fact[1000007];
ll mdpower(ll a,ll b)
{
    ll res =1;
    while(b)
    {
        if(b&1) res = (res%mod*a%mod)%mod;
        b/=2;
        a = (a%mod*a%mod)%mod;
    }
    return res;
}
void factorial()
{
    fact[0]=1;
    for(int i=1;i<1000007;i++)
        fact[i] = (fact[i-1]%mod*i%mod)%mod;
}
ll inverse(ll a,ll b)
{
    return mdpower(a,b-2);
}
ll power(ll a,ll b)
{
    ll res=1;
    while(b)
    {
        if(b&1)
            res=(res*a);
        a=(a*a);
        b/=2;
    }
    return res;
}
int main()
{   
    Senky_Bansal
    IIIT_ALLAHABAD


      ll a,b,c;
      cin>>a>>b>>c;
      cout<<min(b/a,c)<<endl;  




}

Measured memory_bytes: 256
import java.util.*;
import java.io.*;
import java.nio.charset.StandardCharsets;

public class Main {

	public static void main(String[] args) throws IOException {
		InputStreamReader reader = new InputStreamReader(System.in, StandardCharsets.UTF_8);
		BufferedReader in = new BufferedReader(reader);
		Main ins = new Main(in);
		ins.calc();
		ins.showResult();
	}

	int R, C, K;
	long[][] map;
	long[][][] memo;

	Main(BufferedReader in) throws IOException {
		String[] tokens = in.readLine().split(" ");
		R = Integer.parseInt(tokens[0]);
		C = Integer.parseInt(tokens[1]);
		K = Integer.parseInt(tokens[2]);
		map = new long[R][C];
		memo = new long[R][C][4];
		for (int i = 0; i < R; ++i) {
			Arrays.fill(map[i], 0);
		}
		for (int i = 0; i < R; ++i) {
			for (int j = 0; j < C; ++j) {
				Arrays.fill(memo[i][j], 0L);
			}
		}
		for (int i = 0; i < K; ++i) {
			tokens = in.readLine().split(" ");
			int r = Integer.parseInt(tokens[0]) - 1;
			int c = Integer.parseInt(tokens[1]) - 1;
			long v = Long.parseLong(tokens[2]);
			map[r][c] = v;
		}

	}

	void calc() {
		if (map[0][0] > 0L) {
			for (int i = 1; i < 4; ++i) {
				memo[0][0][i] = map[0][0];
			}
		}
		// 初期
		for (int r = 1; r < R; ++r) {
			if (map[r][0] > 0L) {
				long v = map[r][0];
				memo[r][0][0] = memo[r - 1][0][3];
				for (int i = 1; i < 4; ++i) {
					memo[r][0][i] = memo[r - 1][0][3] + v;
				}
			} else {
				for (int i = 0; i < 4; ++i) {
					memo[r][0][i] = memo[r - 1][0][3];
				}
			}
		}
		for (int c = 1; c < C; ++c) {
			if (map[0][c] > 0L) {
				long v = map[0][c];
				memo[0][c][0] = memo[0][c - 1][0];
				for (int i = 1; i < 4; ++i) {
					memo[0][c][i] = Math.max(memo[0][c - 1][i], memo[0][c - 1][i - 1] + v);
				}
			} else {
				for (int i = 0; i < 4; ++i) {
					memo[0][c][i] = memo[0][c - 1][i];
				}
			}
		}

		// 計算
		for (int r = 1; r < R; ++r) {
			for (int c = 1; c < C; ++c) {
				if (map[r][c] > 0L) {
					long v = map[r][c];
					// 拾わない場合
					memo[r][c][0] = Math.max(memo[r - 1][c][3], memo[r][c - 1][0]);
					for (int i = 1; i < 4; ++i) {
						// 横から来た場合
						memo[r][c][i] = Math.max(memo[r][c - 1][i], memo[r][c - 1][i - 1] + v);
						// 上から来た場合
						memo[r][c][i] = Math.max(memo[r][c][i], memo[r - 1][c][3] + v);
					}
				} else {
					// 単純に上下の比較をする
					for (int i = 0; i < 4; ++i) {
						memo[r][c][i] = Math.max(memo[r - 1][c][3], memo[r][c - 1][i]);
					}
				}
			}
		}
	}

	void show(int i) {
		for (int r = 0; r < R; ++r) {
			for (int c = 0; c < C; ++c) {
				System.out.print(memo[r][c][i] + " ");
			}
			System.out.println("");
		}
		System.out.println("");
	}

	void showResult() {
//		for (int i = 0; i < 4; ++i) {
//			show(i);
//		}
		long max = Long.MIN_VALUE / 2;
		for (int i = 0; i < 4; ++i) {
			max = Math.max(memo[R - 1][C - 1][i], max);
		}
		System.out.println(max);
	}
}

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

typedef uint64_t u64;
typedef int64_t i64;
typedef uint32_t u32;
typedef int32_t i32;
typedef uint16_t u16;
typedef int16_t i16;
typedef uint8_t u8;
typedef int8_t i8;

using namespace std;

#define REP(idx, N) for (u64 idx = 0; idx < N; idx++)

int main() {
  u32 s, w;
  cin >> s >> w;

  if (w >= s)
    cout << "unsafe";
  else
    cout << "safe";
  return 0;
}


Measured memory_bytes: 3640
import java.io.*;
    import java.util.Scanner;
     
    public class Main {
    	public static void main (String[] args) throws IOException
    {
 		BufferedReader br 
   		= new BufferedReader(new InputStreamReader(System.in));
			String str = br.readLine();
    	
    		for(int i=str.length()-1; i >= 0; i-- ){
    			System.out.print(str.charAt(i));
    		}
    		System.out.println();
    	}
    }
     

Measured memory_bytes: 24024