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

public class Main {

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

    void solve() {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int M = sc.nextInt();
        int[] g = new int[N + 1];
        for (int i = 0; i < M; i++) {
            int a = sc.nextInt();
            int b = sc.nextInt();
            if (a > b) {
                int t = 0;
                t = a;
                a = b;
                b = a;
            }
            g[b] = Math.max(g[b], a);
        }
        int ans = 0;
        int h = 1;
        for (int i = 1; i <= N; i++) {
            if (g[i] >= h) {
                ans++;
                h = i;
            }
        }
        System.out.println(ans);
    }
}

Measured memory_bytes: 65204
s=input()
l,r=0,len(s)-1
c=0

while l<r:
  if s[l]==s[r]:
    l+=1
    r-=1
  elif s[l]=="x":
    l+=1
    c+=1
  elif s[r]=="x":
    r-=1
    c+=1
  else:
    print(-1)
    break
else:
  print(c)

Measured memory_bytes: 3316
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double db;
typedef pair<ll,ll> P;
#define pb push_back
#define ft first
#define sd second
#define mp make_pair
#define fr(i,n) for(int i=0;i<(n);i++)
#define Fr(i,n) for(int i=0;i++<(n);)
#define ifr(i,n) for(int i=(n)-1;i>=0;i--)
#define iFr(i,n) for(int i=(n);i>0;i--)

int main(){
  int a,b;
  cin>>a>>b;
  if(a==b) cout<<a+b<<endl;
  else cout<<max(a,b)*2-1<<endl;
}

Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
#include<cstring>
#include<string>
#include<cmath>
#include<algorithm>
#include<queue>
#include<cstdlib>
#include<map>
#include<vector>
#include<ctime>
#include<stack>
#define mp make_pair
#define pa pair<int,int>
#define INF 0x3f3f3f3f
#define inf 0x3f
#define fi first
#define se second
#define pb push_back
#define ll long long
#define ull unsigned long long

using namespace std;

inline ll read()
{
	long long f=1,sum=0;
	char c=getchar();
	while (c<'0' || c>'9')
	{
		if (c=='-')	f=-1;
		c=getchar();
	}
	while (c>='0' && c<='9')
	{
		sum=sum*10+c-'0';
		c=getchar();
	}
	return sum*f;
}
const int MAXN=110;
char s[MAXN];
map <char,bool> mmp;
int main()
{
	int n;
	scanf("%d",&n);
	int cnt=0;
	for (int i=1;i<=n;i++)
	{
		scanf("%s",s+1);
		if (!mmp[s[1]]) cnt++;
		mmp[s[1]]=1;
	}
	if (cnt==3) cout<<"Three";
	else cout<<"Four";
	return 0;
}


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

using namespace std;
#define ll long long
#define ld long double
#define mk make_pair
#define pb push_back
#define sz(a) (int)(a).size()
#define rep(i, a, b) for (int i = (a), _b = (b); i < _b; ++i)
#define frep(i, a, b) for (int i = (a), _b = (b); i <= _b; ++i)
#define fwr(x) { cout << x << '\n'; }

typedef complex<ld> cplex;
typedef vector<int> vi;
typedef pair<int, int> ii;
typedef pair<ii, int> iii;
typedef vector<ii> vii;
typedef vector<iii> viii;

const int inf = 1e9 + 7;
const ll linf = 1ll * inf * inf;
const int N = 100000 + 7;
const int M = 1600;
const int multipleTest = 0;
const double pi = acos(-1);

int n;
int a[N];

bitset<4000007> has;


void solve() {
    cin >> n;
    int sum = 0;
    rep(i, 1, n + 1) {
        cin >> a[i];
        sum += a[i];
    }
    
    if (n == 1) {
        cout << a[1];
        return;
    }
    
    has[0] = 1;
    
    rep(i, 1, n + 1) has |= (has << a[i]);
    rep(i, 1, 4000007) {
        if (has[i] && i >= sum - i) {
            cout << i;
            break;
        }
    }
    
}

int main() {
#ifdef _LOCAL_
    freopen("inp.txt", "r", stdin);
    //    freopen("out.txt", "w", stdout);
#endif
    
    int Test = 1;
    if (multipleTest)
        cin >> Test;
    
    for(int i = 0; i < Test; ++i) {
        //        printf("Case #%d: ", i + 1);
        solve();
    }
#ifdef _LOCAL_
    cout<< "\n" << 1.0 * clock() / CLOCKS_PER_SEC << "\n";
#endif
}


Measured memory_bytes: 1664
N, K = gets.split.map(&:to_i)

def max(a,b); a > b ? a : b; end
def count_mod_ge_K(b)
  r,m = N.divmod(b)
  c = r * (b - K) + max(m + 1 - K, 0)
  K.zero? ? c - 1 : c
end
puts (K + 1 .. N).map{|b| count_mod_ge_K(b) }.sum


Measured memory_bytes: 15244
import sys
input = sys.stdin.readline
import math
def print_ans(S, T, A, B, U):
    """Test Case
    >>> print_ans("red", "blue", 3, 4, "red")
    2 4
    >>> print_ans("red", "blue", 5, 5, "blue")
    5 4
    """
    if S == U:
        A = A -1
    else:
        B = B -1
    print('{} {}'.format(A, B))


if __name__ == '__main__':
    S, T = input().rstrip().split()
    A, B = map(int, input().rstrip().split())
    U = input().rstrip()
    print_ans(S, T, A, B, U)




Measured memory_bytes: 3060
/**
 *    author:  otera    
**/
#include<iostream>
#include<string>
#include<cstdio>
#include<cstring>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<deque>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<cassert>
using namespace std;

//#define int long long
typedef long long ll;
typedef unsigned long long ul;
typedef unsigned int ui;
typedef long double ld;
const int inf=1e9+7;
const ll INF=1LL<<60 ;
const ll mod=1e9+7 ;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<int, int> P;
typedef pair<ld, ld> LDP;
typedef pair<ll, ll> LP;
#define fr first
#define sc second
#define all(c) c.begin(),c.end()
#define pb push_back
#define debug(x)  cerr << #x << " = " << (x) << endl;
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; }

void solve() {
	string s; cin >> s;
    s.pop_back();
    s.pop_back();
    while(true) {
        int n = (int)s.size();
        if(s.substr(0, n / 2) == s.substr(n / 2)) {
            cout << n << endl;
            break;
        }
        s.pop_back();
        s.pop_back();
    }
}

signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	//cout << fixed << setprecision(10);
	//int t; cin >> t; rep(i, t)solve();
	solve();
    return 0;
}

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

using namespace std;
using ll = long long;

const int maxn = 1e5 + 5;
const int mod = 1e9 + 7;

int n;
vector<int> adj[maxn];
int dp[maxn][2];

int solve(int u, int color, int p){
    if (dp[u][color] != -1) return dp[u][color];
    ll res = 1;
    for (auto v : adj[u]){
        if (v != p){
            if (color == 1){
               res *= solve(v, 0, u);
               res %= mod;
            } else {
                ll tmp = solve(v, 1, u) + solve(v, 0, u);
                tmp %= mod;
                res *= tmp;
                res %= mod;
            }
        }
    }
    return dp[u][color] = res;
}

int main()
{
    memset(dp, -1, sizeof dp);
    cin >> n;
    for (int i = 0; i < n - 1; i++){
        int x, y;
        cin >> x >> y;
        adj[x].push_back(y);
        adj[y].push_back(x);
    }
    ll ans = solve(1, 0, -1) + ll(solve(1, 1, -1));
    ans %= mod;
    cout << ans;
    return 0;
}


Measured memory_bytes: 14848
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "set"
#include "functional"
#include "algorithm"
#include "math.h"
#include "utility"

using namespace std;

long long int N;
long long int W, T;
long long int place[100000];
long long int ans;

int main() {
	cin >> N >> W >> T;
	for (int i = 0; i < N; i++) {
		cin >> place[i];
	}
	for (int i = 1; i < N; i++) {
		ans += min(T, (place[i] - place[i - 1])*W);
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 1024
#define _USE_MATH_DEFINES

#include <cstdio>
#include <cstdlib>
#include <string.h>
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <map>

using namespace std;

typedef pair<long long int, long long int> P;
long long int INF = 1e18;
long long int MOD = 1000000007;

int main(){
	while(true){
		int h, w;
		cin >> w >> h;
		if(h == 0){
			break;
		}
		string str[25];
		int px[20], py[20];
		int cnt = 1;
		for(int i = 0; i < h; i++){
			cin >> str[i];
			for(int j = 0; j < w; j++){
				if(str[i][j] == 'o'){
					py[0] = i;
					px[0] = j;
				}
				if(str[i][j] == '*'){
					py[cnt] = i;
					px[cnt] = j;
					cnt++;
				}
			}
		}
		int cost[15][15];
		for(int i = 0; i < cnt; i++){
			for(int j = 0; j < cnt; j++){
				cost[i][j] = 100000;
			}
		}
		for(int i = 0; i < cnt; i++){
			for(int j = i + 1; j < cnt; j++){
				bool used[25][25] = {};
				P pp = make_pair(py[i], px[i]);
				queue<P> que;
				que.push(pp);
				for(int loop = 0; !que.empty(); loop++){
					int sz = que.size();
					for(int k = 0; k < sz; k++){
						P p = que.front();
						que.pop();
						if(p.first < 0 || p.second < 0 || p.first >= h || p.second >= w){
							continue;
						}
						if(used[p.first][p.second]){
							continue;
						}
						used[p.first][p.second] = true;
						if(p.first == py[j] && p.second == px[j]){
							cost[i][j] = loop;
							cost[j][i] = loop;
						}
						if(str[p.first][p.second] == 'x'){
							continue;
						}
						P p2 = make_pair(p.first - 1, p.second);
						que.push(p2);
						p2 = make_pair(p.first + 1, p.second);
						que.push(p2);
						p2 = make_pair(p.first, p.second - 1);
						que.push(p2);
						p2 = make_pair(p.first, p.second + 1);
						que.push(p2);
					}
				}
				//cout << cost[i][j] << " ";
			}
		}
		
		int a[20];
		for(int i = 0; i < cnt; i++){
			a[i] = i;
		}
		
		int ans = 100000;
		do{
			int ret = 0;
			for(int i = 0; i < cnt - 1; i++){
				ret += cost[a[i]][a[i + 1]];
			}
			ans = min(ans, ret);
		}while(next_permutation(a + 1, a + cnt));
		if(ans < 100000){
			cout << ans << endl;
		}else{
			cout << "-1" << endl;
		}
	}
	return 0;
}



Measured memory_bytes: 3168
#include <iostream>
#include <cstring>

using namespace std;

int main()
{
    int N; cin >> N;
    int ctr = 0;
    int c0=0, c1=0, c2=0, c3=0;
    char input[6];
    do
    {
        cin >> input;
        ctr++;
        if (strcmp(input,"AC") == 0)
        {
            c0++;
        }
        else if (strcmp(input,"WA") == 0)
        {
            c1++;
        }
        else if (strcmp(input,"TLE") == 0)
        {
            c2++;
        }
        else if (strcmp(input,"RE") == 0)
        {
            c3++;
        }
    } while ( ctr < N);
    cout << "AC x "<< c0 << endl;
    cout << "WA x "<< c1 << endl;
    cout << "TLE x "<< c2 << endl;
    cout << "RE x "<< c3 << endl;
    return 0;
}

Measured memory_bytes: 3560
N = int(input())
A = list(map(int, input().split()))
A.sort()
l = 0
m = 0
while len(A) >= 2:
    a = A.pop()
    b = A.pop()
    if a == b:
        if l == 0:
            l = a
        elif m == 0:
            m = a
    else:
        A.append(b)
print(l * m)


Measured memory_bytes: 14252
#include <iostream>
using namespace std;
#include <vector>
#define ll long long
#define min(x,y) (x>y?y:x)
#define loop(i,s,e) for(int i=s;i<e;i++)
int * ops;
int minOp(int * heights, int n){
	if(ops[n]!=-1)return ops[n];
  	if(n==0)ops[n]=0;
  	else if(n==1)ops[n]=abs(heights[n]-heights[n-1]);
      
  	else{
          int alpha=minOp(heights,n-1)+abs(heights[n]-heights[n-1]);
          int beta=minOp(heights,n-2)+abs(heights[n]-heights[n-2]);
          ops[n]=min(alpha,beta);
      } 
  	return ops[n];
}

int main(){
    ll n;cin>>n;
  	ops=new int[n];
    int * heights=new int[n];
  	loop(i,0,n){
  	cin>>heights[i];
      ops[i]=-1;
    }
  	cout<<minOp(heights,n-1)<<endl;
}

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

int main(){
  long long n;
  cin >> n;
  
  long long ans = 0;
  for(int i = 1; i < n; i++){
    long long now = (n-i) / i;
    if(now <= i) break;
    if((n-i) % i) continue;
    ans += now;
  }
  
  cout << ans << endl;
}

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

public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here!
        
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String str = br.readLine();
        
        boolean isEasyStep = true;
        
        for(int i = 0; i  < str.length(); i++){
            char c = str.charAt(i);
            
            if( (i + 1) % 2 == 0){
                if( c == 'R'){
                    isEasyStep = false;
                    break;
                }
            }else{
                if( c == 'L'){
                    isEasyStep = false;
                    break;
                }
            }
        }
        
        System.out.println( isEasyStep ? "Yes" : "No");

    }
}


Measured memory_bytes: 21204
#include <stdio.h>

int main(){
   long x,k,d,i;

   scanf("%ld %ld %ld",&x,&k,&d);
   if (x<0) x=-x;
   if (d<0) d=-d;
   i=x/d;
   if (i<=k) {
      x-=d*i;
      k-=i;
      if (k%2==0) printf("%ld\n",x);
      else        printf("%ld\n",d-x);
   } else
      printf("%ld\n",x-k*d);
   return 0;
}


Measured memory_bytes: 1736
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;

int main(){
   string s, t;
   cin>>s>>t;
   LL dp[s.size()+1][t.size()+1];
   for(LL i=0; i<=s.size(); i++){
    for(LL j=0; j<=t.size(); j++){
      dp[i][j]=0;
    }
   }
   if(s[0]==t[0]) dp[1][1]=1;
   for(LL n=1; n<=s.size(); n++){
    for(LL m=1; m<=t.size(); m++){
      if(n==1 && m==1 ) continue;
      else if(s[n-1]==t[m-1]){
        dp[n][m]=dp[n-1][m-1]+1;
      }else{
        dp[n][m]=max(dp[n-1][m], dp[n][m-1]);
      }
    }
   }
   string ans="";
   LL i=s.size(), j=t.size();
   while(i>0 && j>0){
      if(s[i-1]==t[j-1]) {ans+=s[i-1]; i--; j--;}
      else if(dp[i-1][j]>dp[i][j-1]){
        i--;
      }else 
        j--;
    
   }
   reverse(ans.begin(), ans.end());
   cout<<ans;
   return 0;
}


Measured memory_bytes: 70656
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
const int INT_INF = 2147483647;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
typedef pair<int,int> P;

int main(){
  vector<char> v;
  int n;
  cin >> n;
  string s;
  cin >> s;
  rep(i,n){
    if(v.size()==0)v.push_back(s[i]);
    else if(*(v.end()-1)==s[i])continue;
    else v.push_back(s[i]);
  }
  cout << v.size() << endl;
}


Measured memory_bytes: 640
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
 
namespace ABC061A
{
    class Program
    {
        static void Main(string[] args)
        {
            int a,b,c;
 
            var word = Console.ReadLine().Split(' ');
            a = int.Parse(word[0]);
            b = int.Parse(word[1]);
            c = int.Parse(word[2]);
 
            if (c >= a && c <= b)
                Console.WriteLine("Yes");
            else
                Console.WriteLine("No");
 
            Console.ReadKey();
        }
    }
}

Measured memory_bytes: 13140
#include <stdio.h>

int main(void) {
	int n, i;
	int a[1000];
	for(i = 0; i < 1000; i++) a[i] = 0;
	scanf("%d", &n);
	for(i = 0; i < n ; i++) scanf("%d", &a[i]);
	for(i = n - 1; i > 0; i--){
		printf("%d ", a[i]);
	}
	printf("%d\n", a[0]);
	return 0;
}



Measured memory_bytes: 2068
n,k = map(int,input().split())
if k == 0:
    print(n**2)
elif k <= 100:
    ans = 0
    for j in range(k):
        for i in range(k+1,n+1):
            ans += (n-j)//i
    print((n-k+1)*(n-k)-ans)
else:
    r = n//k
    ans = 0
    for i in range(1,r+3): #a=(i-1)×b+あまり
        genkai = n - (i)*k
        for j in range(1,n-k+1): #b=k+j
            x = (i-1)*j
            ans += min(max(genkai-x+1,0),j)
    print(ans)
    

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define MM = 1000000000;
#define mod = MM + 7;
#define INF (ll)1e18
#define pi acos(-1.0)
#define MAX 10000000005
#define NIL -1
int main(){
    ll n, a, b; cin >> n >> a >> b;
    ll ans;
    if(a > b) ans = 0;
    else if(n == 1 && a < b) ans = 0;
    else if(n == 1 && a == b) ans = 1;
    else {
        ans = (n-2)*(b-a) + 1;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include<queue>
#include<stack>
#include<vector>
#include<set>
#include<map>
#include<algorithm>
#include<cstring>
#include<string>
#include<cassert>
#include<cmath>
#include<climits>
#include<iomanip>
#include<bitset>
#include<unordered_map>

using namespace std;

#define REP(i,n) for(ll (i)=0;(i)<(n);(i)++)
#define rep(i,j,n) for(ll (i)=(j);(i)<(n);(i)++)
#define FOR(i,c) for(decltype((c).begin())i=(c).begin();i!=(c).end();++i)
#define ll long long
#define ull unsigned long long
#define all(hoge) (hoge).begin(),(hoge).end()
#define en '\n'
typedef pair<ll, ll> P;
constexpr long long INF = 1LL << 60;
constexpr int INF_INT = 1 << 25;
constexpr long long MOD = 1e9 + 7;
typedef vector<ll> Array;
typedef vector<Array> Matrix;
template <class T> using vec = vector<T>;
template <class T> using vvec = vector<vec<T>>;


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

struct Edge {
	ll to, cap, rev;
	Edge(ll _to, ll _cap, ll _rev) {
		to = _to; cap = _cap; rev = _rev;
	}
};
typedef vector<Edge> Edges;
typedef vector<Edges> Graph;

void add_edge(Graph& G, ll from, ll to, ll cap, bool revFlag, ll revCap) {
	G[from].push_back(Edge(to, cap, (ll)G[to].size()));
	if (revFlag)G[to].push_back(Edge(from, revCap, (ll)G[from].size() - 1));
}

void solve() {
	string s;
	cin >> s;
	bool flag = true;
	REP(i, 2) {
		if (s[0] != s[i + 1]) flag = false;
	}

	if (!flag) cout << "Yes" << en;
	else cout << "No" << en;
}

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

	solve();
	//int t; cin >> t; REP(i, t) solve();

	return 0;
}

Measured memory_bytes: 256
// ALDS1_5_C.cpp : このファイルには 'main' 関数が含まれています。プログラム実行の開始と終了がそこで行われます。
//

//#include "pch.h"
#define _USE_MATH_DEFINES
#include <iostream>
#include<math.h>
#define MY_PI 3.141592
struct Point {
	double x, y;
};
using namespace std;
void koch(int n, Point a, Point b) {
	if (n==0)
	{
		return;
	}
	Point s, t, u;
	double th = M_PI * 60.0 / 180.0;
	s.x = (2.0*a.x + 1.0*b.x) / 3.0;
	s.y = (2.0*a.y + 1.0*b.y) / 3.0;
	t.x = (1.0*a.x + 2.0*b.x) / 3.0;
	t.y = (1.0*a.y + 2.0*b.y) / 3.0;
	u.x = (t.x - s.x)*cos(th) - (t.y - s.y)*sin(th) + s.x;
	u.y = (t.x - s.x)*sin(th) + (t.y - s.y)*cos(th) + s.y;

	koch(n - 1, a, s);
	printf("%.8f %.8f\n", s.x, s.y);
	koch(n - 1, s, u);
	printf("%.8f %.8f\n", u.x, u.y);
	koch(n - 1, u, t);
	printf("%.8f %.8f\n", t.x, t.y);
	koch(n - 1, t, b);
}
int main()
{
	int n;
	cin >> n;
	Point a, b;
	a.x = 0.0;
	a.y = 0.0;
	b.x = 100.0;
	b.y = 0.0;
	printf("%.8f %.8f\n", a.x, a.y);
	koch(n, a, b);
	printf("%.8f %.8f\n", b.x, b.y);
}




Measured memory_bytes: 3200
#include <iostream>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <string>
#include <vector>
#include <cstdlib>
#include <queue>
#include <cstring>
#include <set>
#include <map>
#include <unordered_map>

const int maxN = 310;

using namespace std;

#define FORU(i, l, r) for (int i = l; i <= r; ++i)
#define FORD(i, r, l) for (int i = r; i >= l; --i)
#define REPU(i, r) for (int i = 0; i < r; ++i)
#define LL long long
#define F first
#define S second
#define MP make_pair
#define PB push_back
#define PINT pair < int, int >
#define BIT(x, i) ((x >> i) & 1)
#define NUM_SET_BIT __builtin_popcountll

LL check[maxN][maxN], n, d[maxN][maxN], c[maxN][maxN], res;

int main() {
    cin >> n;
    FORU(i, 1, n)
        FORU(j, 1, n) cin >> c[i][j], d[i][j] = c[i][j];
    FORU(t, 1, n)
        FORU(u, 1, n)
            FORU(v, 1, n)
                if (u != t && v != t && u != v)
                    if (d[u][t] + d[t][v] <= d[u][v]) {
                        d[u][v] = d[u][t] + d[t][v];
                        check[u][v] = 1;
                    }
    FORU(i, 1, n)
        FORU(j, 1, n) {
            if (d[i][j] != c[i][j]) { cout << -1; return 0; }
            if (!check[i][j]) res += d[i][j];
        }
    cout << res / 2;
}


Measured memory_bytes: 2432
#include<stdio.h>

int main(void){

  int A, B;
  int count = 0;
  int coin = 0;
  
  scanf("%d %d", &A, &B);
  
  count++;
  
  if(count == 1){
   
    if(A > B){
      coin += A;
      A--;
    }
    
    else if(B > A){
      coin += B;
      B--;
    }
    
    else if(A == B){
      coin += A;
      A--;
    }
    
  }
  
    
  count++;
  
  if(count == 2){
    
    if(A > B){
      coin += A;
      A--;
    }
    
    else if(B > A){
      coin += B;
      B--;
    }
    
    else if(A == B){
      coin += A;
      A--;
    }
    
  }

     
  printf("%d\n", coin);
  
  return 0;
  
}
  
  

Measured memory_bytes: 128
import java.io.*;
import java.util.*;
import java.util.function.*;

final class Solver {
	static final Solver INSTANCE = new Solver();

	void solve(Supplier<String> sc) {
		String N = sc.get();
		var chars = N.toCharArray();
		for (char aChar : chars) {
			if (aChar == '7') {
				System.out.println("Yes");
				return;
			}
		}
		System.out.println("No");
	}
}

class Main {
	public static void main(String... args) {
		var reader = new BufferedReader(new InputStreamReader(System.in));
		Solver.INSTANCE.solve(new Supplier<>() {
			private StringTokenizer line;

			public String get() {
				try {
					return (line = line != null && line.hasMoreTokens() ? line : new StringTokenizer(reader.readLine())).nextToken();
				} catch (IOException e) {
					throw new UncheckedIOException(e);
				}
			}
		});
	}
}

Measured memory_bytes: 32860
#include <bits/stdc++.h>
using namespace std;
 
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define int long long

bool compare(pair<int, int> &a, pair<int, int> &b){
	return a.second < b.second;
}

int32_t main(){
	IOS;
	int n;
	cin >> n;
	vector< pair<int, int> > jobs(n);

	for(int i = 0; i < n; i++)
		cin >> jobs[i].first >> jobs[i].second;

	sort(jobs.begin(), jobs.end(), compare);

	int time = 0;

	for(int i = 0; i < n; i++){
		time = time + jobs[i].first;
		if(time > jobs[i].second){
			cout << "No" << endl;
			return 0;
		}
	}	

	cout << "Yes" << endl;



	return 0;
}

Measured memory_bytes: 3328
#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(){
    string s;
    cin >> s;

    if(s[s.size()-1]=='s'){
        cout<<s<<"es"<<endl;
    }else{
        cout<<s<<"s"<<endl;
    }
    return 0;
}

Measured memory_bytes: 3620
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<n;i++)
using namespace std;
int main() {
   cin.tie(0);
   ios::sync_with_stdio(false);
   int n;
   cin >> n;
   int a[n];
   string ans = "APPROVED";
   REP(i, n) cin >> a[i];
   REP(i, n) {
       if(a[i]%2==0) {
           if(a[i]%3==0||a[i]%5==0) {

           } else {
               ans = "DENIED";
           }
       }
   }
   cout << ans << endl;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;

int main(){

    ll N;
    cin >> N;
    vector<ll>v(N);
    for(ll i = 0; i < N; i++)cin >> v[i];
    sort(v.begin(), v.end());
    cout << v[N - 1] - v[0] << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define rep(i, n) FOR(i, 0, n)
#define rep1(i, n) FOR(i, 1, n+1)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; --i)
#define whole(x) (x).begin(),(x).end()
#define rwhole(x) (x).rbegin(), (x).rend()
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())
#define P pair<int, int>
#define debug(var) cerr << "[" << #var << "] " << var << endl
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define vi vector<int>
#define vl vector<ll>
#define pb push_back
#define eb emplace_back
const ll mod = 1000000007;
const int dx[] = {-1,0,1,0};
const int dy[] = {0,-1,0,1};
 
struct Query {
    int l, r, i;
    Query(int l, int r, int i): l(l), r(r), i(i){}
};
 
template<typename T>
struct BIT {
  int n;
  vector<T> d;
  BIT(int n=0):n(n),d(n+1) {}
  void add(int i, T x=1) {
    for (i++; i <= n; i += i&-i) {
      d[i] += x;
    }
  }
  T sum(int i) {
    T x = 0;
    for (i++; i; i -= i&-i) {
      x += d[i];
    }
    return x;
  }
  T sum(int l, int r) {
    return sum(r-1) - sum(l-1);
  }
};
 
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
    int n, q;
    cin >> n >> q;
    vector<int> c(n);
    rep(i, n) cin >> c[i];
    vector<Query> query;
    rep(qi, q) {
        int l, r;
        cin >> l >> r;
        l--; r--;
        query.eb(l, r, qi);
    }
    auto comp = [](Query a, Query b) {
        return a.l<b.l;
    };
    sort(whole(query), comp);
    reverse(whole(query));
    vector<int> ans(q);
    vector<int> pi(n+1, -1);
    vector<P> p;
    rep(i, n) {
        int prev = pi[c[i]];
        if (prev!=-1) {
            p.emplace_back(prev, i);
        }
        pi[c[i]] = i;
    }
    BIT<int> bit(n+5);
    sort(whole(p));
    reverse(whole(p));
    int index = 0;
 
    rep(i, q) {
        int l = query[i].l;
        int r = query[i].r;
        int qi = query[i].i;
        while (index<p.size()) {
            if (p[index].first<l) break;
            bit.add(p[index].second, 1);
            index++;
        }
        int a = bit.sum(r);
        ans[qi] = r - l + 1- a;
    }
 
    rep(i, q) cout << ans[i] << "\n";
    return 0;
}

Measured memory_bytes: 23052
#include <bits/stdc++.h>
#define IO ios::sync_with_stdio(0);cin.tie(0)
#define endl '\n'
#define MAXN 105

using namespace std;

int N;
int a[MAXN];
bool ok;

signed main()
{
	IO;
	cin >> N;
	for (int i = 0; i < N; i++) {
		int d1, d2;
		cin >> d1 >> d2;
		a[i] = d1 == d2;
	}

	for (int i = 2; i < N; i++) {
		if (a[i - 2] & a[i - 1] & a[i]) {
			ok = true;
			break;
		}
	}

	cout << (ok ? "Yes" : "No") << endl;
	return 0;
}


Measured memory_bytes: 3644
a_list = []
for i in range(1, 151):
    for j in range(1, 151):
        tmp_list = []
        tmp_list.append(i**2+j**2)
        tmp_list.append(i)
        tmp_list.append(j)
        a_list.append(tmp_list)

a_list.sort()
while(True):
    n = input()
    n = n.split()
    h = int(n[0])
    w = int(n[1])
    flag = 0

    if h==0 and w==0:
        break
    a = h**2 + w**2
    for i in range(len(a_list)):
        if a == a_list[i][0] and flag==0:
            if h < a_list[i][1] and a_list[i][1] < a_list[i][2]:
                print(str(a_list[i][1])+" "+str(a_list[i][2]))
                flag = 1
        elif a < a_list[i][0] and flag==0:
            if a_list[i][1] < a_list[i][2]:
                print(str(a_list[i][1]) + " " + str(a_list[i][2]))
                flag = 1


Measured memory_bytes: 10868
import java.util.*;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		final long MOD = 1000000007;
		int N = sc.nextInt();
		int[] cnt = new int[N+1];
		for(int i=2; i<=N; i++) {
			int temp = i;
			for(int j=2; j*j<=temp; j++) {
				while(temp%j==0) {
					cnt[j]++;
					temp/=j;
				}
			}
			if(temp>1)
				cnt[temp]++;
		}
		
		long ans = 1;
		for(int i=2; i<=N; i++)
			ans = (ans * (cnt[i]+1))%MOD;
		
		System.out.println(ans);
		sc.close();
	}
}


Measured memory_bytes: 10064
import java.util.Scanner

object Main extends App  {
  val sc = new Scanner(System.in)

  val iS = sc.next

  val s = iS.toVector

  val stack =
    s.foldLeft( Vector.empty[Char] ){(stack, ch) =>
      ch match{
        case '0' if stack.headOption.contains('1') => stack.tail
        case '0'                                   => ch +: stack
        case '1' if stack.headOption.contains('0') => stack.tail
        case '1'                                   => stack :+ ch
        case _                                     => ch +: stack
      }
    }

  val res = s.length - stack.length

  println(res)
}

Measured memory_bytes: 51156
#include<iostream>
#include<cstring>
#include<algorithm>
#include<cmath>
#define mm(a,x) memset(a,x,sizeof(a))
#define sync std::ios::sync_with_stdio(false);std::cin.tie(0)
#define ll long long
using namespace std;
const int N=2e5+10;
int a[N];
int main(void)
{
    sync;
    int n;
    cin>>n;
    for(int i=0;i<n;++i)
        cin>>a[i];
    ll res=0;
    for(int i=1;i<n;++i)
    {
        if(a[i]<a[i-1])
        {
            res+=a[i-1]-a[i];
            a[i]=a[i-1];
        }
    }
    cout<<res<<endl;
    return 0;
}

Measured memory_bytes: 3968
#include<bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
#define cases long long test;cin>>test;while(test--)
#define f_io ios::sync_with_stdio(false); cin.tie(0)
#define foi(a,n) for(long long i=a;i<n;i++)
#define foj(a,n) for(long long j=a;j<n;j++)
#define fok(a,n) for(long long k=a;k<n;k++)
#define ll long long
#define MOD 1000000007
#define INF 1000000000
using namespace std;
const int N=1000000;
long long dp[N],height[N];
//using namespace __gnu_pbds;
//typedef tree<ll,null_type,less<ll>,rb_tree_tag, tree_order_statistics_node_update> indexed_set;
int main()
{
    f_io;
    int n,k;
    cin>>n>>k;
    foi(1,n+1)
    {
        cin>>height[i];
        dp[i]=INF;
    }
    dp[1]=0;
    foi(1,n+1)
    {
        for(long long j=1;j<=k && i-j>0;j++)
        {
            dp[i]=min(dp[i],dp[i-j]+abs(height[i]-height[i-j]));
        }
    }
    cout<<dp[n];
}

Measured memory_bytes: 5120
#include<cstdio>
#include<algorithm>
#include<iostream>
#include<string>
#include<math.h>
#include<cstring>
using namespace std;
string s[200000];
bool cmp(string a,string b)
{
    return a<b;
}
int main()
{
    int n;
    int i;
    cin>>n;
    for(i=0;i<n;i++)
        cin>>s[i];
    sort(s,s+n,cmp);
    int con=1;
    int y=1;
    for(i=1;i<n;i++)
    {
        if(s[i]==s[i-1])
            con++;
        else
            con=1;
        y=max(con,y);
    }
    con=1;
    if(y==1)cout<<s[0]<<endl;
    for(i=1;i<n;i++)
    {
        if(s[i]==s[i-1])
            con++;
        else
            con=1;
        if(con==y)
        cout<<s[i]<<endl;
    }
    return 0;
}



Measured memory_bytes: 6656
#include <iostream>
#include <vector>
#include <queue>
#include <cmath>
#include <bitset>
#include <algorithm>
#include <set>
#include <string>
#include <queue>

using namespace std;

#define rep(i, N) for(int (i) = 0; (i) < (N); (i) ++)
typedef long long ll;
typedef pair<int, int> pii;

int ans = 0;
vector<int> ps = {3, 5, 7};
ll N;

void dfs(ll n, ll b){
    if(n <= N && b == 7){
        ans ++;
    }
    if(n > N){
        return ;
    }
    rep(i, ps.size()){
        ll nb = b | (1 << i);
        ll nn = 10 * n + 1L * ps[i];
        dfs(nn,  nb);
    }
    return ;
}

int main(){
    int N, K;
    cin >> N >> K;
    vector<int> hs(N);
    rep(i, N){
        cin >> hs[i];
    }
    sort(hs.begin(), hs.end());
    int ans = 1e9;
    for(int i = 0; i  + K - 1< N; i ++){
            int tmp = hs[i + K - 1] - hs[i];
            ans = min(tmp, ans);
    }
    cout << ans << endl;
    return 0;
}


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

int main(){
  int a,b,c;
  bool ans = false;
  cin >> a >> b >> c;
  
  if(a == b && a != c){
    ans = true;
  }else if(a == c && a != b) ans = true;
  else if(b == c && b != a) ans = true;
  
  if(ans == true) cout << "Yes" << endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <map>
#include <stack>

int main() {
  std::string str;
  std::cin >> str;


  std::stack<char> sk;
  for (auto it = str.begin(); it != str.end(); it++) {
    if (*it != 'B') sk.push(*it);
    else if (sk.size() != 0) sk.pop();   
  }

  std::string result = "";
  while(sk.size() != 0) {
    result = sk.top() + result;
    sk.pop();
  }

  std::cout << result << std::endl;

  return 0;
}


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

using namespace std;

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

	vector<int> a(n + 1, 1);
	int t;
	for (int i = 2; i <= n; i++) {
		t = i;
		for (int j = 2; t != 1; j++) {
			while (t % j == 0) {
				t /= j;
				a[j]++;
			}
		}
	}

	long long ans = 1;
	int mod = 1000000007;
	for (int i = 1; i <= n; i++) {
		ans *= a[i];
		ans %= mod;
	}
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#include<string>
#define ll long long int
#define ull unsigned long long int
#define ld long double
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define intarr(arr, n)  ll arr[n];  for (ll i = 0; i < n; i++)  cin >> arr[i]
#define ff first
#define ss second
#define pb push_back
#define mkp make_pair
const ll mod=1e9+7;

bool subsequence_checker(string str1, string str2, ll m, ll n) 
{ 
    if (m == 0) return true; 
    if (n == 0) return false; 
    if (str1[m-1] == str2[n-1]) 
        return subsequence_checker(str1, str2, m-1, n-1); 
    return subsequence_checker(str1, str2, m, n-1); 
}


void solve(){

    ll n,a,b;
    cin>>n>>a>>b;

    ll ans=0;

    if(a+b >=n){
        cout<< min(a,n);
        return; 
    }

    ll div = n/(a+b);
    ans+= div*a ;
    ll rem = n - div*a - div*b;
    ans += min(rem,a);
    cout<<ans;
    return;
}

int main()
{
    IOS;
    ll t;
    //cin>>t;
    t=1;
    while(t--){
        solve();
        cout<<endl;
    }
 
    return 0;
}       

Measured memory_bytes: 256
from collections import deque
N = int(input())
dp = [-1]*(N+1)
parent = [-1]*(N+1)
edges = [[] for _ in range(N+1)]
for i in range(2,N+1):
    a = int(input())
    parent[i] = a
    edges[i].append(a)
    edges[a].append(i)
d = deque([-2,1])
while d:
    x = d.pop()
    if x >= 0:
        for y in edges[x]:
            if y != parent[x]:
                d.append(~y)
                d.append(y)
    else:
        x = ~x
        li = []
        for y in edges[x]:
            if y != parent[x]:
                li.append(dp[y])
        li.sort(reverse = True)
        m = 0
        for i in range(len(li)):
            m = max(m,li[i]+i+1)
        dp[x] = m
print(dp[1])

Measured memory_bytes: 98976
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <cmath>
#include <tuple>
#include <cstdio>
#include <bitset>
#include <sstream>
#include <iterator>
#include <numeric>
#include <map>
#include <cstring>

using namespace std;

//#define DEBUG_ //!!提出時にコメントアウト!!
#ifdef DEBUG_
	#define dump(x)  cerr << #x << " = " << (x) << endl;
#else
	#define dump(x)  ; //何もしない文
#endif

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define SZ(x) ((int)(x).size()) //unsignedのサイズをint型に変換
#define pb push_back

typedef long long LL; 
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<LL, LL> PLL;

template <typename T>
std::string printVector(const std::vector<T> &data)
{
    std::stringstream ss;
    std::ostream_iterator<T> out_it(ss, ", ");
    ss << "[";
    std::copy(data.begin(), data.end() - 1, out_it);
    ss << data.back() << "]";
    return ss.str();
}

const int MOD = 1e9+7;
const LL LINF = 1001002003004005006ll;
const int INF = 1001001001;
const int MAX_N = 1e4+10;

int dp[MAX_N];
VI ans;
VI able;
VI priority;

void solve(int x, int *cost)
{
    if(x == 0) return;

    for(auto p : able)
    {
        if(dp[x - cost[p]] != -1 && dp[x-cost[p]] + 1 == dp[x] && x -cost[p] >= 0)
        {
            ans.pb(p);
            solve(x-cost[p], cost);
            break;
        }
    }
    return;
}

int main(int argc, char const *argv[])
{
    cin.tie(0);
    ios::sync_with_stdio(false);	
    int N,M;
    cin >> N >> M;
    int cost[10] = {0,2,5,5,4,5,6,3,7,6};


    REP(i,M)
    {
        int tmp; cin >> tmp;
        able.pb(tmp);
    }

    sort(able.begin(), able.end());
    reverse(able.begin(), able.end());


    FOR(i,2,8)
    {
        for(auto p : able)
        {
            if(cost[p] == i) priority.pb(p);
        }
    }


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

    dp[0] = 0;

    REP(i,N-1)
    {
        if(dp[i] != -1)
        {
            for(auto p: priority)
            {
                if(i+cost[p] <= N)
                {
                    if(dp[i+cost[p]] == -1) dp[i+cost[p]] = dp[i] + 1;
                    else
                    {
                        dp[i+cost[p]] = max(dp[i] + 1, dp[i+cost[p]]);
                    }
                }
            }
        }
    }


    solve(N, cost);

    for(auto p : ans)
    {
        cout << p;
    }
    cout << endl;





}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#define L long long
using namespace std;
int main()
{
	string x;
	cin >> x;
	for (int i = 0; i < x.length(); i++)
	{
		if (i % 2==0 && x[i] == 'L'){ cout << "No"; return 0; }
		else if (i % 2 == 1 && x[i] == 'R'){ cout << "No"; return 0; }
	}
	cout << "Yes";
	return 0;
}


Measured memory_bytes: 256
// #include <bits/stdc++.h>
#include <iostream>
#include <string>
#include <algorithm>
#include <math.h>
#include <vector>
#include <map>
#include <queue>
#include <set>
using namespace std;
typedef long long int lo;
#define pb push_back
#define mp make_pair
#define st first
#define nd second
#define inf (lo)1e9
#define mod (lo)1e9+7
lo k, a , b, c ,n;
string s1,s2,s3;
queue <pair<lo,lo> > q;
priority_queue <lo> pq;
map <lo,lo> mp1;
vector <lo> v[100005];
lo oyuncu;
set <lo> stt;
lo a1[500005];
int main(){
	// freopen("gir.gir","r",stdin);
	// freopen("cik.cik","w",stdout);
	cin >> n;
	for(lo i = 0 ; i < n ; i++){
		cin >> a1[i];
		mp1[a1[i]]++;
	}
	for(lo i = 0 ; i < n ; i++){
		if(mp1[a1[i]] > 1){
			cout << "NO\n";
			return 0;
		}
	}
	cout << "YES\n";
    return 0;
}

Measured memory_bytes: 18560
x, y, z = map(int,input().split())
a =[x]
b =[y]
c =[z]
if a[0] == b[0] == c[0]:
    if a[0] % 2 == 1:
        print(0)
        exit()
        
    else:
        print('-1')
        exit()
        
for i in range(1000):
    if a[i] % 2 == 0 and b[i] % 2 == 0 and c[i] % 2 == 0:
        a.append((b[i] + c[i]) // 2)
        b.append((a[i] + c[i]) // 2)
        c.append((b[i] + a[i]) // 2)
    
    else:
        print(i)
        exit()

Measured memory_bytes: 9176
from math import sqrt

N = 10**6

is_prime = [True] * (N + 1)
is_prime[0] = False
is_prime[1] = False

n = int(sqrt(N) + 1)
for i in range(4, N+1, 2):
   is_prime[i] = False

for i in range(3, n+1, 2):
   if is_prime[i]:
      for j in range(i+i, N+1, i):
         is_prime[j] = False

x = int(input())
for i in range(x, N+1):
   if is_prime[i]:
      print(i)
      break


Measured memory_bytes: 10868
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
#define INT(...) int __VA_ARGS__;in(__VA_ARGS__)
#define LL(...) ll __VA_ARGS__;in(__VA_ARGS__)
#define ULL(...) ull __VA_ARGS__;in(__VA_ARGS__)
#define STR(...) string __VA_ARGS__;in(__VA_ARGS__)
#define CHR(...) char __VA_ARGS__;in(__VA_ARGS__)
#define DBL(...) double __VA_ARGS__;in(__VA_ARGS__)
#define vec(type,name,...) vector<type> name(__VA_ARGS__)
#define VEC(type,name,size) vector<type> name(size);in(name)
#define vv(type,name,h,...) vector<vector<type>>name(h,vector<type>(__VA_ARGS__))
#define VV(type,name,h,...) vector<vector<type>>name(h,vector<type>(__VA_ARGS__));in(name)
#define vvv(type,name,h,w,...) vector<vector<vector<type>>>name(h,vector<vector<type>>(w,vector<type>(__VA_ARGS__)))
inline int scan(){ return getchar(); }
inline void scan(int &a){ scanf("%d", &a); }
inline void scan(unsigned &a){ scanf("%u", &a); }
inline void scan(long &a){ scanf("%ld", &a); }
inline void scan(long long &a){ scanf("%lld", &a); }
inline void scan(unsigned long long &a){ scanf("%llu", &a); }
inline void scan(char &a){ cin >> a; }
inline void scan(float &a){ scanf("%f", &a); }
inline void scan(double &a){ scanf("%lf", &a); }
inline void scan(long double &a){ scanf("%Lf", &a); }
inline void scan(vector<bool> &vec){ for(unsigned i = 0; i < vec.size(); i++) { int a; scan(a); vec[i] = a; } }
inline void scan(string &a){ cin >> a; }
template<class T> inline void scan(vector<T> &vec);
template<class T, size_t size> inline void scan(array<T, size> &vec);
template<class T, class L> inline void scan(pair<T, L> &p);
template<class T, size_t size> inline void scan(T (&vec)[size]);
template<class T> inline void scan(vector<T> &vec){ for(auto &i : vec) scan(i); }
template<class T, size_t size> inline void scan(array<T, size> &vec){ for(auto &i : vec) scan(i); }
template<class T, class L> inline void scan(pair<T, L> &p){ scan(p.first); scan(p.second); }
template<class T, size_t size> inline void scan(T (&vec)[size]){ for(auto &i : vec) scan(i); }
template<class T> inline void scan(T &a){ cin>>a; }
inline void in(){}
template <class Head, class... Tail> inline void in(Head &head, Tail&... tail){ scan(head); in(tail...); }
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; }
using Graph = vector<vector<int>>;
/* 4方向への隣接頂点への移動を表すベクトル */
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

const long long INF = 1LL << 60;
int main(){
    LL(n);
    VEC(ll,a,n);
    vector<ll> b(a);

    sort(a.begin(),a.end());
    for(int i = 0; i < n; ++i){
        if(b[i] == a.at(n-1)){
            cout << a.at(n-2) << endl;
        } else {
            cout << a.at(n-1) << endl;
        }
    }
}

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

int main() {
  int  N;
  cin >> N;
  double x =0.0;
  double y =0.0;

  
 for (int i = 0; i < N; i++) {
  double A;
  cin >> A;
  x = 1.0 / A;
  y =y + x;
  }
  y = 1.0 / y;
  cout << y << endl;
  

}


Measured memory_bytes: 256
n = gets.to_i
taro, hana = 0, 0
n.times do
    w1, w2 = gets.chomp.split(/ /)
    if w1 > w2
        taro += 3
    elsif w1 < w2
        hana += 3
    else
        taro += 1
        hana += 1
    end
end

print taro, " ", hana, "\n"
__END__
Sample Input
3
cat dog
fish fish
lion tiger
Sample Output
1 7

Measured memory_bytes: 8784
from collections import deque
s = deque(input())
q = int(input())
rev = False
for _ in range(q):
    que = input()
    if que == "1":
        rev = not rev
    else:
        f,c = que[2:].split()
        if (f == "1") ^ rev:
            s.appendleft(c)
        else:
            s.append(c)

if rev: s.reverse()

print("".join(s))


Measured memory_bytes: 8436
#include <iostream>
#include <vector>
#include <string>
#include <cstring>
#include <math.h>
#include <cmath>
#include <limits.h>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <functional>
#include <stdio.h>
using namespace std;

long long MOD = 1000000007;

int main() {
    
    int N,C;
    cin >> N >> C;
    int A[2*(100000+1)] = {0};
    
    vector< vector< pair< long long, long long> > > T(C);
    for ( int i = 0; i < N; i++ ) {
        long long s,t;
        int c;
        cin >> s >> t >> c;
        c--;
        T[c].push_back( make_pair(s,t) );
        
    }
    vector< vector< pair< long long, long long> > > T2(C);
    for ( int i = 0; i < C; i++ ) {
        sort( T[i].begin(), T[i].end() );
        
        if ( T[i].size() == 0 ) { continue; }
        
        T2[i].push_back( make_pair(T[i][0].first,T[i][0].second) );
        
        for ( int j = 1; j < T[i].size(); j++ ) {
            if ( T[i][j].first == T[i][j-1].second ) {
                long long f = T2[i].back().first;
                T2[i].pop_back();
                T2[i].push_back( make_pair(f, T[i][j].second) );
            }
            else { T2[i].push_back( T[i][j] ); }
        }
    }
    
    for ( int i = 0; i < C; i++ ) {
        
        for ( int j = 0; j < T2[i].size(); j++ ) {
          
            A[T2[i][j].first*2-1]++;
            A[T2[i][j].second*2]--;
        }
        
    }
    for ( int i = 1; i < 2*(100000+1); i++ ) {
        A[i] += A[i-1];
    }
    
    int ans = 0;
    for ( int i = 1; i < 2*(100000+1); i++ ) {
        ans = max( ans, A[i] );
    }
    
    cout << ans << endl;
    
    return 0;
}

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

int main(){
  int N;
  cin>>N;
  string S;
  cin>>S;
  int n=S.length();
  string str1 = S.substr(0,n/2);
  string str2=S.substr(n/2,n);
  if(str1==str2&&N==n&&N<=100&&N>=1){
      cout<<"Yes";
  }
  else{
      cout<<"No";
  }
   return 0;
   
}

Measured memory_bytes: 3596
#include<iostream>
#include<cstdio>
#include<string>
#include<algorithm>
#include<cstring>
#include<vector>
#include<cmath>
#include<queue>
#include<stack>
using namespace std;
#define INT(x) int x; scanf("%d",&x)
#define INPUT(x) scanf("%d",&x)
#define REP1(x,n) for(int x = 0; x < n; x++)
#define REP2(x,s,e) for(int x = s; x <= e; x++)
#define RREP1(x,n) for(int x = n-1; x >= 0; x--)
#define RREP2(x,s,e) for(int x = s; x >= e; x--)
#define BR printf("\n")
#define INF 2000000000

typedef long long ll;

int main(){
    int A[101] = {};
    INT(K);INT(T);
    
    int maxa = 0;
    REP2(i,1,T){
        INPUT(A[i]);
        maxa = max(A[i],maxa);
    }
    int max_can = K/2 + K%2;
    
    int odd = K%2;
    
    if (maxa <= max_can) {
        cout << '0' << endl;
    }else{
        if (odd) {
            cout << (maxa - max_can)*2 << endl;
        }else{
            cout << (maxa-max_can)*2-1 << endl;
        }
    }
    
    
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<vector>
#include<math.h>
#include<string.h>
using namespace std;
#define MOD 1000000007
#define MAX 200005
#define PMAX 55
#define PRECISION 0.00000000001
#define INF 2000000000
#define FASTIO ios_base::sync_with_stdio(false);cin.tie(NULL)
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>
int a[MAX];
int main()
{
    int n,i,j,k;
    scanf("%d %d",&n,&k);
    for(i=0;i<n;i++)
    {
        scanf("%d",&a[i]);
    }
    for(i=k;i<n;i++)
    {
        if(a[i-k]>=a[i])
        {
            printf("No");
        }
        else
        {
            printf("Yes");
        }
        printf("\n");
    }
    return 0;
}


Measured memory_bytes: 4500
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        String A = scanner.next();
        String B = scanner.next();
        String C = scanner.next();
        scanner.close();

        char aLast = A.charAt(A.length() -1);
        char bFirst = B.charAt(0);
        char bLast = B.charAt(B.length() -1);
        char cFirst = C.charAt(0);

        boolean isShiritori = aLast == bFirst && bLast == cFirst;
        System.out.println(isShiritori ? "YES" : "NO");
    }
}


Measured memory_bytes: 23764
def resolve():
	n, k = map(int, input().split())
	x = list(map(int, input().split()))
	ans = float('inf')
	for i in range(n-(k-1)):
		if abs(x[i] - x[i+(k-1)]) == (abs(x[i]) + abs(x[i+(k-1)])):
			v = abs(x[i] - x[i + (k - 1)]) + min(abs(x[i]), abs(x[i + (k - 1)]))
			ans = min(ans, v)
		else:
			v = max(abs(x[i]), abs(x[i + (k - 1)]))
			ans = min(ans, v)
	print(ans)
resolve()

Measured memory_bytes: 62576