akhauriyash/Code-Regression huggingface dataset:
#include <assert.h>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <numeric>
#include <functional>
#include <iostream>
#include <string>
#include <array>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <complex>
#include <bitset>
typedef long long ll;
typedef unsigned long long ull;

using namespace std;


template <typename T>
struct Counter {
  map<T, ll> cnt;
  void add(T key) {
    if (cnt.count(key)) {
      cnt[key]++;
    } else {
      cnt[key] = 1;
    }
  }
  ll get(T key) {
    if (cnt.count(key)) {
      return cnt[key];
    } else {
      return 0;
    }
  }
  typename map<T, ll>::iterator begin() {
    return cnt.begin();
  }
  typename map<T, ll>::iterator end() {
    return cnt.end();
  }
  typename map<T, ll>::reverse_iterator rbegin() {
    return cnt.rbegin();
  }
  typename map<T, ll>::reverse_iterator rend() {
    return cnt.rend();
  }
};


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

  int N;
  cin >> N;
  Counter<int> counter;

  for (int i = 0; i < N; i++) {
    int a;
    cin >> a;
    counter.add(a);
  }

  ll first = 0;
  ll second = 0;

  for (auto it = counter.rbegin(); it!= counter.rend(); it++) {
    if (it->second >= 2) {
      if (first == 0) {
        first = it->first;
        if (it->second >= 4) {
          second = it->first;
          break;
        }
      } else if (second == 0) {
        second = it->first;
        break;
      }
    }
  }

  cout << first * second << endl;
  return 0;
}


Measured memory_bytes: 6528
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <cstring>
#include <string>
#include <cstdlib>
#include <cstdio>
using namespace std;
typedef long long int ll;


typedef string::const_iterator State;
class ParseError {};

// beginがexpectedを指していたらbeginを一つ進める。
void consume(State &begin, char expected) {
	if (*begin == expected) {
		begin++;
	} else {
		cerr << "Expected '" << expected << "' but got '" << *begin << "'" << endl;
		cerr << "Rest string is '";
		while (*begin) {
			cerr << *begin++;
		}
		cerr << "'" << endl;
		throw ParseError();
	}
}

struct Genom{
	int type;
	char c;
	int rec;
	vector<Genom> child;
};
vector<Genom> parse(State &begin);

Genom factor(State &begin) {
	Genom ret;
	if (isalpha(*begin)) {
		ret.type = 0;
		ret.c = *begin++;	
	}else if (isdigit(*begin)) {
		ret.type = 1;
		ret.rec = 0;
		while(isdigit(*begin)) ret.rec = ret.rec*10 + *begin++ - '0';
		if(*begin == '(') ret.child = parse(begin);
		else ret.child.push_back(factor(begin));
	}
	return ret;
}
vector<Genom> parse(State &begin) {
	vector<Genom> ret;
	consume(begin, '(');
	while(*begin!=')') ret.push_back(factor(begin));
	consume(begin, ')');
	return ret;
}
char dfs(vector<Genom> g, int &n){
	for(int i=0;i<g.size();i++){
		if(g[i].type == 0){
			if(!n--) return g[i].c;
		//	cout << g[i].c;
		}else{
			for(int j=g[i].rec;j;j--){
				char ret = dfs(g[i].child, n);
				if(n < 0) return ret;
			}
		}
	}
	return '0';
}
main(){
	int i,j;
	int n;
	string s;
	while(cin >> s >> n, s!="0"){
		s = '(' + s + ')';
		State begin = s.begin();
		cout << dfs(parse(begin), n) << endl;
	}
	return 0;
}

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

int main() {
    string s; cin >> s;
    int k; cin >> k;
    vector<vector<vector<ll>>> dp(s.size() + 1, vector<vector<ll>>(k + 1, vector<ll>(2, 0)));
    dp[0][0][0] = 1;
    for (int i = 0; i < s.size(); i++) {
        for (int j = 0; j <= k; j++) {
            dp[i + 1][j][1] += dp[i][j][1];
            if (j - 1 >= 0) {
                dp[i + 1][j][1] += dp[i][j - 1][1] * 9;
                if (s[i] >= '1') {
                    dp[i + 1][j][0] += dp[i][j - 1][0];
                }
                if (s[i] >= '2') {
                    dp[i + 1][j][1] += dp[i][j - 1][0] * (s[i] - '1');
                }
            }
            if (s[i] == '0') {
                dp[i + 1][j][0] += dp[i][j][0];
            }
            else {
                dp[i + 1][j][1] += dp[i][j][0];
            }
        }
    }
    cout << dp[s.size()][k][0] + dp[s.size()][k][1] << endl;
    return 0;
}

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

int main() {
    string A, B;
    cin >> A >> B;

    if (A.size() > B.size()) cout << "GREATER" << endl;
    else if (A.size() < B.size()) cout << "LESS" << endl;
    else if (A.size() == B.size())
        if (A > B) cout << "GREATER" << endl;
        else if (A < B) cout << "LESS" << endl;
        else if (A == B) cout << "EQUAL" << endl;
}

Measured memory_bytes: 256
import sys
input = lambda: sys.stdin.readline().rstrip("\r\n")

n, x, m = map(int, input().split())
s = set([x])
l = [x]
for i in range(m):
    x = x**2 % m
    if x in s:
        start_index = l.index(x)
        break
    else:
        s.add(x)
        l.append(x)
ans = sum(l[:start_index])

q = l[start_index:]
p = (n - start_index) // len(q)
ans += sum(q) * p
ans += sum(q[:(n - p*len(q) - start_index)])
print(ans) 

Measured memory_bytes: 77432
#include <stdio.h>
#include <string.h>

int main(){

    char a;
    long int v1,v2;

    scanf("%ld ", &v1);
    scanf("%c ", &a);
    if(strncmp(&a,"+",1)==0){
        scanf("%ld", &v2);
        printf("%ld",v1+v2);
    }
    else{
        scanf("%ld", &v2);
        printf("%ld",v1-v2);
    }
    return 0;
}

Measured memory_bytes: 128
from collections import deque

def main():
    H, W = map(int, input().split())
    S = list(input() for _ in range(H))
    dx = [1,0,-1,0]
    dy = [0,1,0,-1]

    def bfs(h,w):
        Q = deque([(h,w)])
        dist = [[-1] * W for _ in range(H)]
        dist[h][w] = 0
        while Q:
            y, x = Q.popleft()

            for i in range(4):
                nh = y + dy[i]
                nw = x + dx[i]

                if 0 <= nh < H and 0 <= nw < W and S[nh][nw] == '.' and dist[nh][nw] == float(-1):
                    dist[nh][nw] = dist[y][x] + 1
                    Q.append((nh,nw))

        tmp = 0
        for a in range(H):
            tmp = max(tmp, max(dist[a]))
        return tmp
    
    ans = []
    for h in range(H):
        for w in range(W):
            if S[h][w] == '.':
                ans.append(bfs(h,w))
    

    print(max(ans))


    

if __name__ == "__main__":
    main()

Measured memory_bytes: 45276
//https://atcoder.jp/contests/agc002/tasks/agc002_a
//A - Range Product
#include <bits/stdc++.h>
using namespace std;
using ll=int64_t;
#define FOR(i,a,b) for(int64_t i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
int main() {
    ll a,b; cin>>a>>b;
    ll ans=0;
    do{
        if(a==0||b==0) {
            ans=0;
            break;
        }
        if(a<0&&b>0){
            ans=0;
            break;
        }
        if(a>0){
            ans=1;
            break;
        }
        if(b<0){
            if ((b-a)%2==1) ans=1;
            else ans=-1;
            break;
        }
        assert(0);
    }while(false);
    if(ans==0){
        cout<<"Zero"<<endl;
    } else {
        cout<<(ans>0?"Positive":"Negative")<<endl;
    }
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static int count=0;
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int n, i;
		n = scan.nextInt();
		int[] s = new int[n];
		for (i = 0; i < n; i++) {
			s[i] = scan.nextInt();
		}
		margesort(s);
		scan.close();
		show(s);
		System.out.println(count);
	}
	public static void margesort(int[] a) {
		if(a.length>1) {
			int m,n;
			m=a.length/2;
			n=a.length-m;
			int[] a1=new int[m];
			int[] a2=new int[n];
			System.arraycopy(a, 0, a1, 0, m);
			System.arraycopy(a, m, a2, 0, n);
			margesort(a1);
			margesort(a2);
			marge(a1,a2,a);
		}
	}
	public static void marge(int[] a1,int[] a2,int[] a) {
		int i=0,j=0;
		while(i<a1.length || j<a2.length) {
			if(j>=a2.length || (i<a1.length && a1[i]<a2[j])) {
				a[i+j]=a1[i];
				i++;
			}
			else {
				a[i+j]=a2[j];
				j++;
			}
			count++;
		}
	}
	public static void show(int[] a) {
		int i;
		for(i=0;i<a.length-1;i++) {
			System.out.print(a[i]+" ");
		}
		System.out.println(a[a.length-1]+"");
	}
}


Measured memory_bytes: 170076
#include <bits/stdc++.h>
#define int long long
#define double long double
#define INF 1e18
using namespace std;

signed main() {
  int N, K;
  cin>>N>>K;
  int ans = 0;
  vector<int> ex;
  for (int i = 1; i <= N; i++) {
    if (i >= K) {
      ans += N-i+1;
      break;
    }
    for (int j = 1; j < K; j++) {
      if (i*pow(2, j) >= K) {
        ex.push_back(j);
        break;
      }
    }
  }
  double res;
  if (ex.size() > 0) {
  int max = *max_element(ex.begin(), ex.end());
  ans *= pow(2, max);
  for (int i = 0; i < ex.size(); i++) {
    ans += pow(2, max-ex[i]);
  }
  res=ans/(N*pow(2,max));
  } else {
    res=ans/N;
  }
  cout << setprecision(15) << res << endl;
}

Measured memory_bytes: 512
import java.util.*;
class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        char[] s= sc.next().toCharArray();
        int ans = 0;
        outloop:for(int i = 0;i<s.length;i++){
            if(s[i]=='A'){
                for(int j = i+1;j<s.length;j++){
                    if(s[j]=='Z'){
                        ans = j-i+1;
                    }
                }
                break outloop;
            }
        }
        System.out.println(ans);
    }
}

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

using ll = long long;

int main(){
  int N, K;
  string S;
  cin >> N >> S >> K;

  for (int i = 0; i < N; i++) {
    if(S[i]==S[K-1]) cout << S[i];
    else cout << '*';
  }
  cout << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<string>
#include<algorithm>
#include<utility>
#include<numeric>
#include<vector>
#include<map>
#include<unordered_map>
#include<set>
#include<tuple>
#include<stack>
#include<queue>
#include<functional>
#include<iterator>
#include<cmath>
#include<cctype>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;

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

#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define rep(i,n) FOR(i,0,n)

struct edge{int to,cost;};

void dump(ll *b,int n){
	for(int i=0;i<n;i++){
		cout << b[i] << " ";
	}
	cout << "\n";
}

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

	int n;
	cin >> n;
	string s1,s2;
	cin >> s1 >> s2;
	bool previstate;
	ll ans=1;
	for(int i=0;i<s1.size();i++){
		if(s1[i]==s2[i]){//縦
			if(i==0){
				ans*=3;
				ans%=MOD;
			}else if(previstate){
				ans*=2;
				ans%=MOD;
			}
			previstate=true;		
		}else{//横
			if(i==0){
				ans*=6;
				ans%=MOD;
			}else if(previstate){
				ans*=2;
				ans%=MOD;
			}else{
				ans*=3;
				ans%=MOD;
			}
			previstate=false;
			i++;
		}
	}
	cout << ans << "\n";

	return 0;
}

Measured memory_bytes: 256
void main() {
    int[] tmp = readln.split.to!(int[]);
    int a = tmp[0], b = tmp[1], k = tmp[2];
    int[] divisor;
    foreach (i; 1 .. min(a, b)+1) {
        if (a % i == 0 && b % i == 0) {
            divisor ~= i;
        }
    }
    divisor.sort!"a > b";
    divisor[k-1].writeln;
}

import std.stdio;
import std.string;
import std.array;
import std.conv;
import std.algorithm;
import std.range;
import std.math;
import std.container;
import std.typecons;

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

const int DIM = 1e5 + 5;

long long cnt[2];
int mat[4][DIM], prm[2][DIM], inv[2];

void solve(int k, int l, int r) {
    if (l == r)
        return;
    
    int m = (l + r) >> 1;
    solve(k, l, m); solve(k, m + 1, r);
    
    for (int i = l, j = m + 1; j <= r; ++j) {
        while (i <= m and prm[k][i] <= prm[k][j])
            ++i;
        cnt[k] += m - i + 1;
    }
    
    sort(prm[k] + l, prm[k] + r + 1);
    return;
}

int main(void) {
    ios::sync_with_stdio(false);
    
    int n;
    cin >> n;
    
    for (int l = 1; l <= 3; ++l)
    for (int i = 1; i <= n; ++i)
        cin >> mat[l][i];
    
    bool ok = true;
    for (int i = 1; i <= n; ++i) {
        if (mat[1][i] + 1 == mat[2][i] and mat[2][i] + 1 == mat[3][i] and mat[3][i] % 3 == 0 and (mat[1][i] & 1) == (i & 1))
            prm[i & 1][(i + 1) >> 1] = mat[3][i] / 3, inv[i & 1] += 0;
        else
        if (mat[3][i] + 1 == mat[2][i] and mat[2][i] + 1 == mat[1][i] and mat[1][i] % 3 == 0 and (mat[3][i] & 1) == (i & 1))
            prm[i & 1][(i + 1) >> 1] = mat[1][i] / 3, inv[i & 1] += 1;
        else
            ok = false;
    }
    
    solve(0, 1, n / 2); solve(1, 1, (n + 1) / 2);
    ok &= ((cnt[0] & 1) == (inv[1] & 1) and
           (cnt[1] & 1) == (inv[0] & 1));
    
    cout << (ok ? "Yes" : "No") << endl;
    return 0;
}

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

void fn(ll x) { printf("%lld\n", x); exit(0); }

int main(){
	int n, m;
	scanf("%d%d", &n, &m);
	if (m == 1)swap(n, m);
	if (n == 1){
		if (m == 1)fn(1);
		fn(m - 2);
	}
	fn((ll)(n - 2) * (m - 2));
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll mod = 1e9+7;
ll inf = 1e18;
int main() {
    int a, b;
    cin >> a >> b;
    for (int i = 1; i <= 10000; i++) {
        if (i * 8 / 100 == a && i * 10 / 100 == b) {
            cout << i << endl;
            return 0;
        }
    }
    cout << -1 << endl;
    return 0;
}

Measured memory_bytes: 384
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<bitset>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<deque>
#include<list>
#include<iomanip>
#include<cmath>
#include<cstring>
#include<functional>
#include<cstdio>
#include<cstdlib>
#include<unordered_map>
#include<unordered_set>
using namespace std;

#define repr(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) repr(i, 0, n)
#define INF 2e9
#define MOD 1000000007
//#define MOD 998244353
#define LINF (long long)4e18
#define jck 3.141592
#define PI acos(-1.0);

const double EPS = 1e-10;

using ll = long long;
using Pi = pair<int,int>;
using Pl = pair<ll,ll>;



int main(){
    int N,M; cin >> N >> M;
    int ans = N*(N-1)/2+M*(M-1)/2;
    cout << ans << endl;
}



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

public class Main {
	
	public void sort(int[] x, double[] y){
		for(int i = 0; i < x.length; i++){
			int min = i;
			for(int j = i; j < x.length; j++){
				if( y[j] < y[min] ){
					min = j;
				}
			}
			int temp1 = x[min];
			double temp2 = y[min];
			x[min] = x[i];
			y[min] = y[i];
			x[i] = temp1;
			y[i] = temp2;
		}
	}
	public void solve() throws IOException{
		int[] spare = new int[6];
		double[] spare_time = new double[6];
		for(int i = 0; i < 3; i++){
			int[] n = new int[8];
			double[] time = new double[8];
			for(int j = 0; j < 8; j++){
				n[j] = nextInt();
				time[j] = nextDouble();
			}
			sort(n, time);
			writer.printf("%d %.2f\n", n[0], time[0]);
			writer.printf("%d %.2f\n", n[1], time[1]);
			spare[i*2] = n[2]; spare_time[i*2] = time[2];
			spare[i*2+1] = n[3]; spare_time[i*2+1] = time[3];			
		}
		sort(spare, spare_time);
		writer.printf("%d %.2f\n", spare[0], spare_time[0]);
		writer.printf("%d %.2f\n", spare[1], spare_time[1]);
		writer.flush();
	}			
	public static void main (String args[]) throws IOException{
		new Main().run();
	}
	
	BufferedReader reader;
	StringTokenizer tokenizer;
	PrintWriter writer;
	
	public void run() throws IOException{
		try{
			reader = new BufferedReader(new InputStreamReader(System.in));
			tokenizer = null;
			writer = new PrintWriter(System.out);
			solve();
			reader.close();
			writer.close();
		} catch (Exception e){
			e.printStackTrace();
			System.exit(1);
		}
	}
	public int nextInt() throws IOException{
		return Integer.parseInt(nextToken());
	}	
	public double nextDouble() throws IOException{
		return Double.parseDouble(nextToken());
	}
	public String nextToken() throws IOException{
		while( tokenizer == null || !tokenizer.hasMoreTokens() ){
			tokenizer = new StringTokenizer(reader.readLine());
		}
		return tokenizer.nextToken();
	}
}

Measured memory_bytes: 11000
-- 1_2_D
main = do ns <- getLine
          let [w, h, x, y, r] = map (\x -> read x::Int) $ words ns
          putStrLn $ check w h x y r

check :: Int -> Int -> Int -> Int -> Int -> String
check w h x y r = if x + r <= w && y + r <= h && x - r >= 0 && y - r >= 0
                    then "Yes"
                    else "No"

Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const static ll INF = 1e9;
//const static ll MOD = 1e9+7;

long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = (a * a) % mod;
        n >>= 1;
    }
    return res;
}

const static ll mod = 998244353;
int main(){
    ll N; cin >> N;
    ll Max = 0;
    vector<ll> V(N+10);
    for(int i = 0; i < N; i++){
        ll x; cin >> x; V[x]++;
        if((i == 0 && x != 0) || (i != 0 && x == 0)) {
            cout << 0 << endl; return 0;
        }
        Max = max(Max, x);
    }
    ll ans = 1;
    for(int i = 1; i < N; i++){
        ans *= modpow(V[i-1], V[i], mod);
        ans%=mod;
    }
    cout << ans << endl;

}

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

using ll = long long;

int main() {
	int N, K; cin >> N >> K;
	ll ans = 0;
	for (int b = K + 1; b <= N; b++) {
		ans += (b - K) * (N / b) + max(0, 1 + N % b - K) - (K == 0);
	}
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
using namespace std;

int main()
{
	int a;
	bool b = false;
	vector<string>str;
	cin >> a;
	for (int i = 0; i < a; i++)
	{
		string s;
		cin >> s;
		if (find(str.begin(), str.end(), s) != str.end())
		{
			b = true;
		}
		str.push_back(s);
	}
	if (b)
	{
		cout << "No" << endl;
		return 0;
	}
	for (int i = 0; i < a; i++)
	{
		if (i > 0)
		{
			if (str[i - 1][str[i - 1].size() - 1] != str[i][0])
			{
				cout << "No" << endl;
				return 0;
			}
		}
	}
	cout << "Yes" << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
 
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define int long long int
#define mod 1000000007
#define inf 1e18+42
#define endl "\n"

#define out1(a) cout<<#a<<" "<<a<<endl
#define out2(a,b) cout<<#a<<" "<<a<<" "<<#b<<" "<<b<<endl
#define out3(a,b,c) cout<<#a<<" "<<a<<" "<<#b<<" "<<b<<" "<<#c<<" "<<c<<endl

#define rep(i,a,b) for(int i=a;i<b;i++)
#define repr(i,a,b) for(int i=a;i>=b;i--)
#define fori(it,A) for(auto it=A.begin();it!=A.end();it++)

#define ft first
#define sd second
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define zero(x) memset(x,0,sizeof(x));
 
using namespace std;

int binpow(int,int);
void dfs( vector< vector<int> >&, int , vector<int>& );
void bfs( vector< vector<int> >&, int , vector<int>& );

void solve()
{
    int n;
    cin>>n;

    vector<int> a(n);

    rep(i,0,a.size())
    {
        cin>>a[i];
    }

    int dp[n+1][n+1];
    zero(dp);
    vector< pair<int,int> > s;

    rep(i,0,a.size())
    {
        s.pb(mp(a[i],i));
    }

    sort(all(s));

    int ans = 0;

    repr(len,n,1)
    {
        rep(st,0,n-len+1)
        {
            if ( len == 1 )
            {
                ans = max(dp[st][st]+s[len-1].ft*abs(s[len-1].sd-st),ans);
                continue;
            }
            dp[st][st+len-2] = max(dp[st][st+len-2],dp[st][st+len-1]+(s[len-1].ft*abs(s[len-1].sd-(st+len-1))));
            dp[st+1][st+len-1] = max(dp[st+1][st+len-1],dp[st][st+len-1]+(s[len-1].ft*abs(s[len-1].sd-(st))));
        }
    }

    cout<<ans<<endl;
}

signed main()
{
    fast;
    int t = 1;
    // cin>>t;

    while(t--)
    {
        solve();
    }
    return 0;
}

int binpow(int a, int b) {
    int res = 1;
    while (b > 0) {
        if (b & 1)
            res = res * a;
        a = a * a;
        b >>= 1;
    }
    return res;
}

void dfs ( vector< vector<int> > &v , int x , vector<int> &vis )
{
    vis[x] = 1;

    rep(i,0,v[x].size())
    {
        if( vis[v[x][i]] == 0 )
        {
            dfs(v,v[x][i],vis);
        }
    }
}

void bfs( vector< vector<int> > &v , int x , vector<int> &vis )
{
    queue<int> q;
    q.push(x);

    while( !q.empty() )
    {
        int p = q.front();
        q.pop();

        rep(i,0,v[p].size())
        {
            if ( vis[v[p][i]] == 0 )
            {
                vis[v[p][i]] = 1;
                q.push(v[p][i]);
            }
        }
    }
}

Measured memory_bytes: 35008
#include<iostream>
#include<algorithm>
#include<vector>
#include<climits>
using namespace std;

static const int MAX = 100;
static const long long INFTY = (1LL << 32);

int n;
long long d[MAX][MAX];

void floyd() {
	for (int k = 0; k < n; k++) {
		for (int i = 0; i < n; i++) {
			if (d[i][k] == INFTY)continue;
			for (int j = 0; j < n; j++) {
				if (d[k][j] == INFTY)continue;
				d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
			}
		}
	}
}

int main() {
	int e, u, v, c;
	cin >> n >> e;

	for (int i = 0; i < n; i++) {
		for (int j = 0; j < n; j++) {
			d[i][j] = ((i == j) ? 0 : INFTY);
		}
	}

	for (int i = 0; i < e; i++) {
		cin >> u >> v >> c;
		d[u][v] = c;
	}

	floyd();

	bool negative = false;
	for (int i = 0; i < n; i++)if (d[i][i] < 0)negative = true;

	if (negative) {
		cout << "NEGATIVE CYCLE" << endl;
	}
	else {
		for (int i = 0; i < n; i++) {
			for (int j = 0; j < n; j++) {
				if (j)cout << " ";
				if (d[i][j] == INFTY)cout << "INF";
				else  cout << d[i][j];
			}
			cout << endl;
		}
	}

	return 0;
}


Measured memory_bytes: 3176
def isPrime(n):
  if n < 2:
    return False
  if n == 2:
    return True
  for p in range(2, n):
      if n % p == 0:
        return False
  return True
def main():
    X = int(input())
    while True:
        if isPrime(X) == True:
            print(X)
            break
        X += 1
main()

Measured memory_bytes: 2940
//#include <bits/stdc++.h>
#include <iostream>
#include <fstream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <map>
#include <iomanip>
#include <stdlib.h>
#include <queue>
#include <deque>
#include <set>
#include <stack>
#include <time.h>
 
using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef pair<int, int> Pii;
typedef pair<int, ll> Pil;
typedef pair<ll, ll> Pll;
typedef pair<ll, int> Pli;

const ll nmax = 1e9 + 7;
const ll Mod = 998244353;
const double PI = 2 * asin(1);

int main(){
  int H, W; cin >> H >> W;
  int A[H][W];
  for (int i = 0; i < H; i++){
    for (int j = 0; j < W; j++){
      cin >> A[i][j];
    }
  }

  vector <Pii> ans1, ans2;
  for (int i = 0; i < H; i++){
    for (int j = 0; j < W; j++){
      if (A[i][j] % 2 == 0) continue;
      else{
        if (j < W - 1){
          ans1.push_back(make_pair(i, j));
          ans2.push_back(make_pair(i, j + 1));
          A[i][j]--; A[i][j + 1]++;
        }else{
          if (i == H - 1) continue;
          A[i][j]--; A[i + 1][j]++;
          ans1.push_back(make_pair(i, j));
          ans2.push_back(make_pair(i + 1, j));
        }
      }
    }
  }
  
  cout << ans1.size() << endl;
  for (int i = 0; i < ans1.size(); i++){
    cout << ans1[i].first + 1 << " " << ans1[i].second + 1 << " ";
    cout << ans2[i].first + 1 << " " << ans2[i].second + 1 << endl;
  }
  
  
  return 0;
}


Measured memory_bytes: 5228
#include <iostream>
#include <stdio.h>
#include <string>
#include <vector>

using namespace std;

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

	vector<int> a(n);
	for (int i = 0; i < n; i++) {
		cin >> a.at(i);
	}

	int c = 0;

	for (;;) {
		bool b = true;
		for (int i = 0; i < n; i++) {
			if (a.at(i) % 2 == 1) {
				b = false;
			}
		}
		if (b) {
			for (int i = 0; i < n; i++) {
				a.at(i) /= 2;
			}
		}
		else {
			break;
		}
		c++;
}
	cout << c << endl;

	return 0;
}

Measured memory_bytes: 256
import sys
input = sys.stdin.readline
from collections import deque

N = int(input())
edge = [list(map(int,input().split())) for i in range(N-1)]

graph = [[] for i in range(N)]
for e in edge:
    graph[e[0]-1].append(e[1]-1)

queue = deque()
queue.append(0)

color = [-1 for _ in range(N)]

k = 0

while queue:
    c = 0
    node = queue.popleft()
    for adj in graph[node]:
        if color[node] == c:
            c += 1
        color[adj] = c
        k = max(k,c+1)
        c += 1
        queue.append(adj)
print(k)

for e in edge:
    print(color[e[1]-1]+1)


Measured memory_bytes: 76892
#include <bits/stdc++.h>
const int INF = 1e9;
const int MOD = 1e9+7;
const long long LINF = 1e18;
#define dump(x)  cout << 'x' << ' = ' << (x) << ` `;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<(n);++i)
#define REPR(i,n) for(int i=n;i>=0;i--)
#define FOREACH(x,a) for(auto& (x) : (a) )
typedef long long ll;
using namespace std;
typedef pair<ll, ll> P;

int main(int argc, char const *argv[]) {
    ll n; cin >> n;
    if (n == 0) cout << 1 << endl;
    else if (n == 1) cout << 2 << endl;
    else if (n == 2) cout << 1 << endl;
    else cout << 0 << endl;
    return 0;
}


Measured memory_bytes: 3116
#include<iostream>
#include<string>
using namespace std;
string S, T[4] = { "A","B","AB","O" }; int x[4], a; char c;
int main() {
	while (cin>> a >> c >> S) {
		for (int i = 0; i < 4; i++) {
			if (T[i] == S) { x[i]++; }
		}
	}
	cout << x[0] << endl << x[1] << endl << x[2] << endl << x[3] << endl;
}

Measured memory_bytes: 1204
import java.util.Scanner;

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


			int N = scan.nextInt();
			int[]h = new int[N];
			for(int i = 0;i<N;i++)h[i] =scan.nextInt();

			long[]dp = new long[N+2];

			for(int i = 1;i<N;i++) {
				if(i==1) {
					int a =  Math.abs(h[i]-h[i-1]);
					dp[i] = dp[i-1]+a;

				}else {
				int a =  Math.abs(h[i]-h[i-1]);
				int b =  Math.abs(h[i]-h[i-2]);

				if(dp[i-1]+a>dp[i-2]+b) {
					dp[i] = dp[i-2]+b;
				}else {
					dp[i] = dp[i-1]+a;
				}
				}
			}

			System.out.println(dp[N-1]);

		}


	}


}


Measured memory_bytes: 58908
import java.io.*;

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

      BufferedReader br =
       new BufferedReader(new InputStreamReader(System.in));

      String str = br.readLine();
      int x = Integer.parseInt(str);

      //System.out.println( x^3 );   //^???java??§???????????§?????????XOR???????????????
      System.out.println( x*x*x );           // <= ??£?§£
      //System.out.println( Math.pow(x,3) ); // Math.pow ???double???????????????
      //System.out.println( (int)Math.pow(x,3)); // <= ??£?§£

    }
}

Measured memory_bytes: 24356
import java.util.*;
import static java.lang.Math.*;

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

		// 入力
		int h = sc.nextInt();// 縦のマス数
		int w = sc.nextInt();// 横のマス数

		String[][] grid = new String[h][w];

		for(int i = 0; i < h; i++){
			String temp = sc.next();
			grid[i] = temp.split("");
		}

		// 判定
		String result = "Yes";
		for(int i = 0; i < h; i++){
			for(int j = 0; j < w; j++){
				if(!hasNeighbor(grid, i, j)){
					result = "No";
					break;
				}
			}
		}

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

	// 自分が","、または、自分が"#"かつ隣に"#"がいるか
	static boolean hasNeighbor(String[][] grid, int x, int y){
		
		// 宣言
		int h = grid.length;    // 縦のサイズ
		int w = grid[0].length; // 横のサイズ
		//System.out.println("h:" + h + " w:" + w);

		String up = null;   // 上
		String down = null; // 下
		String left = null; // 左
		String right = null;// 右
		String lu = null;   // 左上
		String ru = null;   // 右上
		String ld = null;   // 左下
		String rd = null;   // 右下

		if(x > 0)     up = grid[x - 1][y]; // 上
		if(x < h - 1) down = grid[x + 1][y]; // 下
		if(y > 0)     left = grid[x][y - 1]; // 左
		if(y < w - 1) right = grid[x][y + 1]; // 右
		//if(x > 0 && y > 0)         lu = grid[x - 1][y - 1]; // 左上
		//if(x > 0 && y < w - 1)     ru = grid[x - 1][y + 1]; // 右上
		//if(x < h - 1 && y > 0)     ld = grid[x + 1][y - 1]; // 左下
		//if(x < h - 1 && y < w - 1) rd = grid[x + 1][y + 1]; // 右下
		
		// 判定
		if(grid[x][y].equals(".")) return true;
		if(up != null && up.equals("#")) return true;
		if(down != null && down.equals("#")) return true;
		if(left != null && left.equals("#")) return true;
		if(right != null && right.equals("#")) return true;

		return false;
	}

}




Measured memory_bytes: 21844
#include <bits/stdc++.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

using namespace std;

typedef long long int lli;
typedef pair<int, int> ii;

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

#ifdef LOCAL
    #define eprintf(...) printf(__VA_ARGS__)
#else
    #define eprintf(...) 1
#endif

#define ROUNDUP(a, b)         ( ((a) + ((b) - 1) ) / (b))
#define SET_ZERO(a)             ( memset((a), 0, sizeof(a)))
#define SET_NUM_ARRAY(a,b)    ( memset((a), b, sizeof(a)))
//#define int long long int //dont forget to change int to signed

const int INT_INF = 1000000007;

int main() {
    int N, K;
    cin >> N >> K;
    int a[100009];
    for (int i = 1; i <= N; i++) {
        cin >> a[i];
    }

    int min = INT_INF;
    for (int i = 1; i <= N-K+1; i++) {
        int cost = abs(a[i+K-1] - a[i]) + (abs(a[i+K-1]) < abs(a[i]) ? abs(a[i+K-1]) : abs(a[i]));
        chmin<int>(min, cost);
    }
    cout << min << endl;
}


Measured memory_bytes: 640
N, M = gets.chomp.split.map(&:to_i)
cards = gets.chomp.split.map(&:to_i)

class PriorityQueue

  def initialize
    @queue = []
  end

  def top
    @queue.last
  end

  def push(pair)
    @queue.push pair
  end

  def pop
    @queue.pop
  end

  def empty?
    @queue.empty?
  end

  def sort!
    @queue = @queue.sort_by {|change| change.first }
  end
end

changes = PriorityQueue.new

M.times do
  b, c = gets.chomp.split.map(&:to_i)
  changes.push [c, b]
end

cards = cards.sort
changes.sort!

cards.each_with_index do |card, i|
  break if changes.empty?
  break if changes.top.first <= card

  cards[i] = changes.top.first
  change = changes.pop
  if (change[1] > 1)
      change[1] -= 1
      changes.push change
  end
end

puts cards.inject(&:+)


Measured memory_bytes: 21488
A = "1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51"

K = int(input())
print(A.split(", ")[K-1])

Measured memory_bytes: 3064
import java.util.*;
import java.math.BigInteger;
import static java.lang.System.*;
import java.util.*;
import java.math.BigInteger;
import static java.lang.System.*;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String s = sc.next();
		char[] C = new char[s.length()];
		for(int i=0; i<s.length(); i++)
			C[i] = s.charAt(i);
		boolean flag = true;
		
		for(int i=0; ; i++) {
			//out.print("i =" + i);
			int right = (s.length()-1) / 2 - 1 - i;
			//out.println("right=" + right);
			if (i >= right) break;
			if ( C[i] != C[right]) {
				//out.println("FALSE");
				flag = false; break;
			}
		}
			int left = (s.length()+3)/2 - 1;
		
			if (flag) {
		for(int i = left; ; i++) {		
			int minus = i - left;
			int right = s.length() - 1 - minus;
			//out.print("i =" + i);
			//out.println("right=" + right);
			if (i >= right) break;
			if (C[i] != C[right]) {
				flag = false; break;
			}
		}
			}
		for(int i=0; i<(s.length()-1) /2; i++) {
			int right = left + i;
			if ( C[i] != C[right]) {
				flag = false; break;
			}
		}
			
		if (flag) out.print("Yes");
		else out.print("No");
		
	}
}

Measured memory_bytes: 22608
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
#define mod 1000000007
#define pb(x) push_back(x);
#define mp(x,y) make_pair(x,y)
#define mem(dp,a) memset(dp,a,sizeof dp);
#define all(a) a.begin(),a.end()
#define sall(a) sort(all(a))
#define X first
#define Y second
typedef long long int ll;
typedef pair<ll,ll> pp;

#define debug(x) cout << #x << " :: "<< x <<"\n";
#define debug2(x,y) cout << #x << " :: "<< x << "\t" << #y << " :: " << y << "\n";
#define debug3(x,y,z) cout << #x << " :: "<< x << "\t" << #y << " :: " << y << "\t" << #z << " :: " << z << "\n";
#define boost ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define ordered_set tree< pp , null_type,less< pp >, rb_tree_tag,tree_order_statistics_node_update>

ll power(ll b, ll exp){
    ll res = 1;
    while(exp > 0){
        if(exp % 2){
            res = 1LL * res * b % mod;
        }
        b = 1LL * b * b % mod;
        exp /= 2;
    }
    return res;
}

int main()
{
    boost
    ll t,n;
    cin >> n;
    vector<ll> a(n);
    for(ll i=0;i<n;i++) {
        cin >> a[i];
    }
    sort(all(a),greater<ll>());
    ll ans=a.front(),cnt=2,temp=0,i=1;
    while( cnt<n )  {
        if( temp==2 )   {
            temp=0;
            i++;
        }
        ans+=a[i];
        temp++;
        cnt++;
    }
    cout << ans ;
    return 0;
}


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

#define ALL(obj) (obj).begin(),(obj).end()
#define SPEED cin.tie(0);ios::sync_with_stdio(false);

template<class T> using PQ = priority_queue<T>;
template<class T> using PQR = priority_queue<T,vector<T>,greater<T>>;

constexpr long long MOD = (long long)1e9 + 7;
constexpr long long MOD2 = 998244353;
constexpr long long HIGHINF = (long long)1e18;
constexpr long long LOWINF = (long long)1e15;
constexpr long double PI = 3.1415926535897932384626433L;

template <class T> vector<T> multivector(size_t N,T init){return vector<T>(N,init);}
template <class... T> auto multivector(size_t N,T... t){return vector<decltype(multivector(t...))>(N,multivector(t...));}
template <class T> void corner(bool flg, T hoge) {if (flg) {cout << hoge << endl; exit(0);}}
template <class T, class U>ostream &operator<<(ostream &o, const map<T, U>&obj) {o << "{"; for (auto &x : obj) o << " {" << x.first << " : " << x.second << "}" << ","; o << " }"; return o;}
template <class T>ostream &operator<<(ostream &o, const set<T>&obj) {o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr) o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;}
template <class T>ostream &operator<<(ostream &o, const multiset<T>&obj) {o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr) o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;}
template <class T>ostream &operator<<(ostream &o, const vector<T>&obj) {o << "{"; for (int i = 0; i < (int)obj.size(); ++i)o << (i > 0 ? ", " : "") << obj[i]; o << "}"; return o;}
template <class T, class U>ostream &operator<<(ostream &o, const pair<T, U>&obj) {o << "{" << obj.first << ", " << obj.second << "}"; return o;}
template <template <class tmp>  class T, class U> ostream &operator<<(ostream &o, const T<U> &obj) {o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr)o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;}
void print(void) {cout << endl;}
template <class Head> void print(Head&& head) {cout << head;print();}
template <class Head, class... Tail> void print(Head&& head, Tail&&... tail) {cout << head << " ";print(forward<Tail>(tail)...);}
template <class T> void chmax(T& a, const T b){a=max(a,b);}
template <class T> void chmin(T& a, const T b){a=min(a,b);}
void YN(bool flg) {cout << (flg ? "YES" : "NO") << endl;}
void Yn(bool flg) {cout << (flg ? "Yes" : "No") << endl;}
void yn(bool flg) {cout << (flg ? "yes" : "no") << endl;}

int main() {
    int N; cin >> N;
    ll ans = 0;
    for(int i = 0; i <= N; ++i) {
        if(i%3 && i%5) ans += i;
    }
    cout << ans << endl;
    return 0;
}


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

int main() {
    int n;
    cin >> n;
    double sum = 0.0;
    for (int i=0; i<n; i++) {
        double num;
        cin >> num;
        sum += 1 / num;
    }
    double ans = 1 / sum;
    cout << fixed << setprecision(10) << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(ll i=0;i<(n);++i)
#define all(a) (a).begin(),(a).end()
#define dunk(a) cout << (a) << endl
#define rall(a) (a).rbegin(),(a).rend()
const int INF = 2e9;
using namespace std;
using Graph = vector<vector<int>>;
typedef pair<int,int> P;
typedef long long ll;

int main(){
    string a, b, c; cin >> a >> b >> c;
    if(a[a.size()-1] == b[0] && b[b.size()-1] == c[0]) cout << "YES" << endl;
    else cout << "NO" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n)for(long long i=0;i<(n);i++)
using namespace std;
typedef long long ll;
const int MOD=1e9+7;
const int MAX = 1000000;
const ll INF = (1LL << 31) - 1;
const double pi=acos(-1);

int main(){
  int a,b;
  cin >> a >> b;
  
  cout << max({a+b,a-b,a*b}) << endl;
}


Measured memory_bytes: 256
#include <functional>
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <random>
#include <bitset>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
typedef long long ll;
using namespace std;
const ll MOD = 1000000007LL;

// 約数のvectorを返す
vector<int> divisor(int n) {
    vector<int> ret;
    for (int i = 1; i * i <= n; i++) {
        if (n % i == 0) {
            ret.push_back(i);
            if (i != n / i) ret.push_back(n / i);
        }
    }
    return ret;
}

int main() {
    int n;
    cin >> n;
    vector<int> a(n);
    for (int i = 0; i < n; i++) cin >> a[i];
    sort(a.begin(), a.end());

    int ans = 0;
    vector<bool> divisible(1000005, false);
    for (int i = 0; i < n; i++) {
        if (i > 0 && a[i - 1] == a[i]) {
            divisible[a[i]] = true;
            continue;
        }
        if (i < n - 1 && a[i + 1] == a[i]) {
            divisible[a[i]] = true;
            continue;
        }

        auto div = divisor(a[i]);
        bool ok = true;
        for (auto x : div) {
            if (divisible[x]) {
                ok = false;
                break;
            }
        }

        if (ok) ans++;
        divisible[a[i]] = true;
    }

    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3984
S = str(input())
T = str(input())
m = len(S)
n = len(T)
mn = m
for i in range(m-n+1):
    sub = S[i:i+n]
    counter = 0
    for j in range(n):
        if sub[j] != T[j]:
            counter += 1
    if mn > counter:
       mn = counter 
print(mn)

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

#define el '\n'
#define fi first
#define se second
#define mp make_pair
#define pb push_back

typedef long long ll;

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

  int n,k;
  cin >> n >> k;
  vector<int> a(n);
  for(int i = 0; i < n; i++){
    cin >> a[i];
  }
  sort(a.begin(), a.end());
  
  int mini = INT_MAX;
  for(int i = 0; i < n-k+1  ; i++){
    mini = min(mini, abs(a[i]-a[i+k-1]));
  }
  cout << mini << el;
  return 0;
}

Measured memory_bytes: 640
from fractions import gcd
n, m, *a = map(int, open(0).read().split())
lcm = a[0] // 2
for x in a:
	x //= 2
	g = gcd(lcm, x)
	if (lcm // g) % 2 != (x // g) % 2:
		print(0)
		exit()
	lcm = lcm * x // g
print((m // lcm + 1) // 2)


Measured memory_bytes: 16120
//---------------------------------------------------------------
#include <bits/stdc++.h>
using namespace std;
#include <iostream>
#include <vector>
#include <cstdlib>
#include <cmath>
#include <math.h>
#include <sstream>
#include <numeric>
#include <cctype>
#include <bitset>
#include <cassert>
#include<algorithm>
//---------------------------------------------------------------
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i <= (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define SIZE 100005
#define INF 1000000000000000LL
#define all(x) x.begin(),x.end()
using pint = pair<int,int>;
using vec = vector<int>;
using ll=long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
//---------------------------------------------------------------
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
//---------------------------------------------------------------

//↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓

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

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

    ll n;cin>>n;
    map<string,ll> cnt;
    rep(i,n){
        string s;
        cin>>s;
        cnt[s]++;
    }

    ll m=0;
    for(auto x: cnt){
        m=max(x.second,m);
    }

    for(auto y:cnt){
        if(y.second==m){
            cout<<y.first<<endl;
        }
    }


}

Measured memory_bytes: 19280
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include <iostream>
#include <iomanip>
#include <string>
#include <cmath>
#include <vector>
#include <algorithm>
#include <queue>
#include <functional>

using namespace std;

#define MOD 1000000007
#define INF INT_MAX
#define ll long long

int main()
{
	int x, t;
	cin >> x >> t;	

	int res = 0;
	if (x - t > 0) {
		res = x - t;
	}
	cout << res << endl;

	return (0);
}

Measured memory_bytes: 256
n = int(input())

h = list(map(int,input().split()))

INF = 100100100100100
dp = [INF]*n

dp[0] = 0

for i in range(1,n):
    dp[i] = min(dp[i],dp[i-1]+abs(h[i]-h[i-1]))
    if i > 1:
        dp[i] = min(dp[i],dp[i-2]+abs(h[i]-h[i-2]))
        
print(dp[n-1])

Measured memory_bytes: 20528
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
  ll n;cin>>n;
  string s;cin>>s;
  ll ans=0;
  for(ll i=0;i<1<<n;i++){
    vector<char> r={'a'},b={'a'};
    ll u=i;
    for(ll j=0;j<n;j++){
      if(u%2==0)r.push_back(s[j]);
      else b.push_back(s[j]);
      u/=2;
    }
    ll rs=r.size()-1,bs=b.size()-1;
    //if(i==6){
      //for(ll ii=0;ii<bs;ii++)cout<<b[ii]<<" ";
      //return 0;
    //}
    ll dp[n+1][bs+1][rs+1];
    for(ll j=0;j<=n;j++)for(ll k=0;k<=bs;k++)for(ll l=0;l<=rs;l++)dp[j][k][l]=0;
    dp[0][0][0]=1;
    for(ll j=2*n;j>n;j--){
      ll num=2*n-j;
      for(ll k=0;k<=num;k++){
        if(k>bs||num-k>rs)continue;
        if(k<bs){
          if(s[j-1]==b[k+1]){
            dp[num+1][k+1][num-k]+=dp[num][k][num-k];
          }
        }
        if(num-k<rs){
          if(s[j-1]==r[num-k+1]){
            dp[num+1][k][num-k+1]+=dp[num][k][num-k];
          }
        }
      }
    }
    ans+=dp[n][bs][rs];
    //if(i==6)for(ll j=0;j<=n;j++)for(ll k=0;k<=bs;k++)for(ll l=0;l<=rs;l++)cout<<dp[j][k][l]<<endl;
    
  }
  cout<<ans<<endl;
}

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

int main()
{
  string s;
  int q, t, f, nverse = 0;
  char c;

  cin >> s;
  cin >> q;

  for (int i = 0; i < q; i++)
  {
    cin >> t;
    if (t == 1)
      nverse++;
    else
    {
      cin >> f >> c;
      if ((f == 1 && nverse % 2 == 0) || (f == 2 && nverse % 2 == 1))
        s.insert(0, &c);
      else
        s.push_back(c);
    }
  }
  if (nverse % 2 == 1)
    reverse(s.begin(), s.end());
  cout << s << endl;
}


Measured memory_bytes: 900
#include <iostream>
#include <algorithm>
#include <string>
#include <cmath>
#include <map>
#include <vector>

#define REP(i,n) for(int i=0;i<(int)n;i++)
#define REP1(j,n) for(int j=0;j<(int)n;j++)
#define REPD(i,n) for(int i=n;i>=0;i--)
#define REPD1(j,n) for(int j=n;j=>0;j--)
#define REPS(i,n) for(int i=1;i<=(int)n;i++)
#define REPS1(j,n) for(int j=1;j<=(int)n;j++)
#define rep(i,a,n) for(int i=a;i<(int)n;i++)
#define SZ(x) ((int)(x).size())	//size() unsigned -> int
#define DescSort(a) sort(a.begin(),a.end(),std::greater<int>())

using namespace std;
typedef long long ll;

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



Measured memory_bytes: 256
#include <iostream>
#include <stack>
using namespace std;
int N,A[100010];
char C[200010];

int main(){
    cin >> N;
    for(int i=1;i<=N;i++){
        cin >> A[i];
    }
    int cnt = 0,id = 1,j = 1;
    while(id<=2*N){
        while(cnt<A[j]){
            C[id] = '(';
            id++;
            cnt++;
        }
        C[id] = ')';
        j++;
        id++;
    }
    int d = 0;
    stack<int> s;
    int lid = 1,rid = 1;
    for(int i=1;i<=2*N;i++){
        if(C[i]=='('){
            s.push(lid);
            lid++;
        }
        else{
            int a = s.top(); s.pop();
            if(a!=A[rid]){
                cout << ":(" << endl;
                return 0;
            }
            rid++;
        }
    }
    for(int i=1;i<=2*N;i++) cout << C[i];
    cout << endl;
    return 0;
}


Measured memory_bytes: 3704
#include "bits/stdc++.h"
using namespace std;
#define REP(i, n) for(ll i = 0;i < n;i++)
#define ll long long
#define MOD 1000000007
#define llMAX 9223372036854775807
#define llMIN -9223372036854775808
using vi = vector<ll>; // intの1次元の型に vi という別名をつける
using vvi = vector<vi>; // intの2次元の型に vvi という別名をつける

ll k,a,b;

int main(){
  ll ans=0;
  cin >> k>>a>>b;
  for(ll i=a;i<=b;i++){
    if (i%k==0)ans=1;
    
  }

  if (ans==1){

    cout<<"OK"<<endl;
    return 0;
  }else{
    cout<<"NG"<<endl;
    return 0;
  }

}

Measured memory_bytes: 3636
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)

int main(){
	int a,b,c,N;
	while(cin >> a >> b >> c && a){
		cin >> N;
		vector< vector<int> > v(N,vector<int>(4));
		vector<int> chk(a+b+c,2);
		
		rep(i,N){
			rep(j,4){
				cin >> v[i][j];
				if(j!=3)v[i][j]--;
			}
		}
		rep(i,N){
			if(v[i][3] == 1){
				rep(j,3) chk[v[i][j]] = 1;
			}
		}
		rep(i,N){
			if(v[i][3] == 0){
				rep(j,3){
					if(chk[v[i][j]] == 2){
						int c = 0;
						rep(k,3)c += chk[v[i][k]] == 1;
						if(c==2)chk[v[i][j]] = 0;
					}
				}
			}
		}
		rep(i,a+b+c) cout << chk[i] << endl;
		
	}
}

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

int main(){
	int n,A,B,a,b;
	while(cin>>n){
		if(n == 0)break;
		A = 0;
		B = 0;
		for(int i = 0 ; i < n ; i++){
			cin>>a>>b;
			if(a > b){
				A += a + b;
			}else if(a < b){
				B += a + b;
			}else{
				A += a;
				B += b;
			}
		}
		cout<<A<<" "<<B<<endl;
	}
	return 0;
}


Measured memory_bytes: 3004
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
const int mod=1e9+7;
const int nax=22;
vector<vector<ll>> dp(1<<nax,vector<ll>(nax,-1));

ll calc(int index,int mask,int& size,vector<vector<int>>& pairs,int& n){
  if(mask==size){
    return 1;
  }
   if(index>=n) return 0;
   if(dp[mask][index]!=-1) return dp[mask][index];
   ll res=0;
   for(int i=0;i<n;i++){
     int val=(mask>>i)&1;
     if(!val && pairs[index][i]){
        res+=calc(index+1,mask|(1<<i),size,pairs,n);
        res%=mod;
     }
   }
   dp[mask][index]=res;
   return res;
}

int main()
{
     ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n;cin>>n;
    vector<vector<int>> pairs(n,vector<int>(n));
    for(int i=0;i<n;i++){
        for(int j=0;j<n;j++)
            cin>>pairs[i][j];
    }
    int size=(1<<n)-1;
    cout<<calc(0,0,size,pairs,n);

}


Measured memory_bytes: 887700
#include <iostream>
#include <vector>
#include <math.h>
#include <algorithm>

using namespace std;
int main() {
    long long int W,H,x,y; cin >> W >> H >> x >> y;
    double ans= (W*H)/2.0;
    printf("%.10f",ans);
    cout << " ";
    if (x*2==W&&y*2==H) cout << 1 << endl;
    else cout << 0 << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
string S,T;
  cin>>S>>T;
  int count = 0;
  for(int i = 0;i<3;i++){
    
    if(S.at(i)==T.at(i)){
      count++;
    }
    
  }
  
  cout<<count<<endl;
  
  return 0;
  
}

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

int main()
{
    int h , a ;
    cin >> h >> a ;

    int atk = 1 , aa = a ;

    while (aa < h)
    {
        atk++ ;
        aa += a ;
    }

    cout << atk << endl ;
    return 0 ;
}

Measured memory_bytes: 256