akhauriyash/Code-Regression huggingface dataset:
import java.util.Scanner;
	public class Main {
	public static void main(String[] args) {
	// 標準入力からデータを読み込む準備
		try (Scanner sc = new Scanner(System.in)) { 
			int w = sc.nextInt();
			int n = sc.nextInt();
			int[] values = new int[w];
			for (int i = 0; i < values.length; i++) { 
				values[i] = i + 1;
			}
			for (int i = 0; i < n; i++) {
				String str = sc.next();
				String[] ab = str.split(",");
				int a = Integer.parseInt(ab[0]) - 1; 
				int b = Integer.parseInt(ab[1]) - 1; // aとbを使ってvaluesを操作しよう
				int copy;
				copy = values[a];
				values[a] = values[b];
				values[b] = copy;
			}
			for(int i=0; i<values.length; i++){
				System.out.println(values[i]);
			}
			sc.close();
		}
	}
}


Measured memory_bytes: 26116
S=str(input())
if S=='RRR':
    print(3)
if S=='RRS':
    print(2)
if S=='RSR':
    print(1)
if S=='SRR':
    print(2)
if S=='RSS':
    print(1)
if S=='SRS':
    print(1)
if S=='SSR':
    print(1)
if S=='SSS':
    print(0)

Measured memory_bytes: 9056
program ABC_093_B_SmallandLargeIntegers
   implicit none
   integer(8) A, B
   integer K, i
   read(*, *) A, B, K
   if(B-A+1 <= 2 * K) then
       do i = A, B
	       write(*, *) i
	   end do
   else 
       do i = A, A + K - 1
          write(*, *) i
       end do
       do i = B - K + 1, B
           write(*, *) i
       end do
   end if
end program ABC_093_B_SmallandLargeIntegers

Measured memory_bytes: 768
package main

import (
	"bufio"
	"fmt"
	"log"
	"os"
	"strconv"
)

func main() {
	scanner := bufio.NewScanner(os.Stdin)
	scanner.Split(bufio.ScanWords)

	scanner.Scan()
	N, err := strconv.Atoi(scanner.Text())
	if err != nil {
		log.Fatal(err)
	}

	scanner.Scan()
	K, err := strconv.Atoi(scanner.Text())
	if err != nil {
		log.Fatal(err)
	}

	counter := 0

	for i := 0; i < N; i++ {
		scanner.Scan()
		target, err := strconv.Atoi(scanner.Text())
		if err != nil {
			log.Fatal(err)
		}

		if target >= K {
			counter++
		}
	}

	fmt.Println(counter)
}


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

using namespace std;

typedef long long ll;

constexpr ll MOD = 998244353;

ll power(ll x, ll n){
    x %= MOD;
    ll res = 1;
    while(n > 0){
        if(n&1){
            res *= x;
            res %= MOD;
        }
        x *= x;
        x %= MOD;
        n >>= 1;
    }
    return res;
}

ll mod_inv(ll x){
    return power(x, MOD-2);
}

vector<ll> factrial, inverse;

void init(ll n) {
    factrial.resize(n+1);
    inverse.resize(n+1);
    factrial[0] = 1;
    inverse[0] = 1;
    for (ll i = 1; i <= n; i++) {
        factrial[i] = (factrial[i - 1] * i) % MOD;
        inverse[i] = mod_inv(factrial[i]);
    }
}

ll nCk(ll n, ll k) {
    if(n < 0 || k < 0 || n < k) return 0;
    return factrial[n] * inverse[k] % MOD * inverse[n - k] % MOD;
}

ll nCk_big(ll n, ll k){
    if(k == 0) return 1;
    else return nCk_big(n, k-1) * ((n-k+1)%MOD) % MOD * mod_inv(k) % MOD;
}

// x種類の文字ですべての文字が少なくとも1回現れる長さnの文字列の数
ll calc(ll x, ll n){
    ll res = 0;
    for(int i=0;i<x;i++){
        res += power(x-i,n)*nCk(x,x-i)%MOD*(i%2?-1:1);
        res = (res%MOD+MOD)%MOD;
    }
    return res;
}

int main(){
    ll m, n, k, ans;
    cin >> m >> n >> k;
    init(k);
    ans = power(m,n);
    for(int i=1;i<k;i++){
        ans -= calc(i,n)*nCk_big(m,i)%MOD;
        ans = (ans%MOD+MOD)%MOD;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3152
#include <bits/stdc++.h>
#define REP(i, s, n) for (int i = s; i < n; i++)
#define ALL(a) a.begin(), a.end()
#define MOD 1000000007
using namespace std;
typedef long long ll;

int main() {
    int W, H, x, y; cin >> W >> H >> x >> y;
    cout << fixed << setprecision(15);
    cout << (double)W * H / 2 << endl;

    if ((double)W / 2 == x && (double)H / 2 == y) cout << 1 << endl;
    else cout << 0 << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
int n,m,x,y;
int main()
{
	scanf("%d%d",&n,&m);
	m = m / 1000;
	if(m > n*10|| m < n)
	{
		printf("-1 -1 -1\n");
		return 0;
	}
	for(int i=0;i*10<=m;i++)
	{
		int a = m-10*i;
		y = n-i;
		if((a-y)%4==0&&(a-y)/4>=0&&y-(a-y)/4>=0)
		{
			printf("%d %d %d\n",i,(a-y)/4,y-(a-y)/4);
			return 0;
		}
	}
	printf("-1 -1 -1\n");
	return 0;
}

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

using namespace std;

int main() {
	int a, b, c;
	cin >> a >> b >> c;

	bool ans = false;

	if (a == b + c) ans = true;
	if (b == c + a) ans = true;
	if (c == a + b) ans = true;

	if (ans) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <string>
#include <queue>
#include <stack>
#include <math.h>
#include <set>
#include <cstdio>
#define ALL(obj) (obj).begin(),(obj).end()
#define RALL(obj) (obj).rbegin(),(obj).rend()
#define P pair<int, int>

#define MOD 1000000007
#define INF 1012345678
#define NINF (-2147483647-1)
#define LLINF 9223372036854775807
using ll = long long;
using namespace std;

struct edge {
    int a, b, c;
};

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N, M;
    cin >> N >> M;
    vector<vector<int>> dist(N, vector<int>(N, INF));
    /*for (int i = 0; i < N; i++)
    {
        dist[i][i] = 0;
    }*/
    vector<edge> A;
    for (int i = 0; i < M; i++)
    {
        int a, b, c;
        cin >> a >> b >> c;
        a--; b--;
        dist[a][b] = c;
        dist[b][a] = c;
        A.push_back(edge{a,b,c});
    }
    for (int k = 0; k < N; k++) {
        for (int i = 0; i < N; i++) {
            for (int j = 0; j < N; j++) {
                dist[i][j] = min(dist[i][j], dist[i][k] + dist[k][j]);
            }
        }
    }
    int cnt = 0;
    for (int i = 0; i < M; i++)
    {
        if (dist[A[i].a][A[i].b] < A[i].c) {
            cnt++;
        }
    }
    cout << cnt << endl;
    getchar(); getchar();
}

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

using namespace std;

#define X first
#define Y second
#define mp make_pair
#define pb push_back
#define Debug(...) fprintf(stderr, __VA_ARGS__)

typedef long long LL;
typedef long double LD;
typedef unsigned int uint;
typedef pair <int, int> pii;
typedef unsigned long long uLL;

template <typename T> inline void Read(T &x) {
  char c = getchar();
  bool f = false;
  for (x = 0; !isdigit(c); c = getchar()) {
    if (c == '-') {
      f = true;
    }
  }
  for (; isdigit(c); c = getchar()) {
    x = x * 10 + c - '0';
  }
  if (f) {
    x = -x;
  }
}

template <typename T> inline bool CheckMax(T &a, const T &b) {
  return a < b ? a = b, true : false;
}

template <typename T> inline bool CheckMin(T &a, const T &b) {
  return a > b ? a = b, true : false;
}

const int N = 2005;

int n, m, a[N];
bitset <N * N> f;

int main() {
#ifdef wxh010910
  freopen("d.in", "r", stdin);
#endif
  Read(n), f[0] = 1;
  for (int i = 1; i <= n; ++i) {
    Read(a[i]), m += a[i];
    f |= f << a[i];
  }
  m = m + 1 >> 1;
  for (int i = m; ; ++i) {
    if (f[i]) {
      printf("%d\n", i);
      break;
    }
  }
#ifdef wxh010910
  Debug("My Time: %.3lfms\n", (double)clock() / CLOCKS_PER_SEC);
#endif
  return 0;
}


Measured memory_bytes: 1664
import math

def is_prime(n):
    if n == 1:
        return False
    for i in range(2,int(n**0.5)+1):
        if n % i == 0:
            return False
    return True
    
n = int(input())

while True:
    if is_prime(n):
        break
    n += 1

print(n)

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

using namespace std;

#define MOD 1000000007

char s[2][60];
bool form[60];

int main() {
	int n; cin >> n;
	for(int i=0;i<2;++i)
		for(int j=0;j<n;++j)
			cin >> s[i][j];
	for(int i=0;i<n;++i)
		if(s[0][i]==s[0][i+1]) form[i]=form[i+1]=true,++i;
	long long ans=form[0]==1?6:3;
	for(int j=ans>>1;j<n;++j) {
	    if(form[j]) {
			if(form[j-1]) ans*=3;
			else ans*=2;
			++j;
		} else if(!form[j-1]) ans*=2;
		ans%=MOD;
	}
	cout << ans << endl;
	
	return 0;
}


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

int main(){
  int k,s,count,time,z;
  cin>>k>>s;
  count=0;
  for(int x=0;x<=k;x++){
    for(int y=x;y<=k;y++){
      z=s-x-y;
 
     
      if(y<=z and z<=k ){
        if(x==y and x==z and y==z )count+=1;
        else if(x==y or x==z or y==z )count+=3;
        else count+=6;
      } 
  	} 
  }  
  cout<<count<<endl;
}




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

int main() {
        int n, k;
        int tmp, tmpSum=0;
        double maxNum;
        cin >> n >> k;
        vector<int> p;
        vector<int> sum;
        for(int i=0; i<n; i++) {
                cin >> tmp;
                p.push_back(tmp);
                if (i<k-1) {
                        tmpSum+=tmp;
                } else
                {
                        tmpSum+=tmp;
                        sum.push_back(tmpSum+k);
                        tmpSum-=p[i-(k-1)];
                }
        }
        maxNum = *(max_element(sum.begin(), sum.end()));
        maxNum/=2;
        cout << fixed << setprecision(1) << maxNum << endl;
}


Measured memory_bytes: 2036
#a=int(input())
#a,b,c=map(int, input().split())
#c=list(map(int, input().split()))
L=['SUN','MON','TUE','WED','THU','FRI','SAT']
S=str(input())
N=L.index(S)
if N==0:
  print(7)
else:
  print(7-N)

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

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define ci cin >>
#define co cout <<

int main() {
	int N;
	ci N;
	if (N % 2 == 1)co N * 2;
	if (N % 2 == 0)co N;
}

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

const int Maxn = 200005;

int n;
int pos[Maxn];
int dp[Maxn];
int res = Maxn;

int main()
{
	scanf("%d", &n);
	for (int i = 1; i <= n; i++) {
		int a; scanf("%d", &a);
		pos[a] = i;
		dp[i] = i - 1;
	}
	for (int i = 1; i <= n; i++) {
		res = min(res, dp[pos[i]] + n - pos[i]);
		if (i < n && pos[i] < pos[i + 1])
			dp[pos[i + 1]] = min(dp[pos[i + 1]], dp[pos[i]] + pos[i + 1] - pos[i] - 1);
	}
	printf("%d\n", res);
	return 0;
}

Measured memory_bytes: 1792
#include <iostream>
#include<vector>
#include<string>
using namespace std;
int main() {
	int h, w, n; int sx, sy;//x<h,y<w
	cin >> h >> w >> n;
	vector<int> zer(w, 0);
	vector<vector<int> > syo(h, zer);
	vector<int> chx(n);
	vector<int> chy(n);
	for (int i = 0; i < h; i++) {
		string s;
		cin >> s;
		for (int j = 0; j < w; j++) {
			char t = s[j];
			if (t == 'S') {
				sx = i;
				sy = j;
			}
			else if (t == 'X') {
				syo[i][j] = 1;
			}
			else if (t != '.') {
				int x = '1';
				int y = t - x;
				chx[y] = i;
				chy[y] = j;
			}
		}
	}
	int ans = 0;
	int bax = sx; int bay = sy;
	for (int i = 0; i < n; i++) {
		int x = chx[i];
		int y = chy[i];
		vector<vector<int> > c(h, zer);
		c[bax][bay] = 1;
		vector<int> nex(h*w);
		vector<int> ney(h*w);
		nex[0] = bax;
		ney[0] = bay;
		int st = 0;
		int end = 1;
		while (c[x][y] == 0) {
			int th = end;
			for (int i = st; i < end; i++) {
				int ax = nex[i];
				int ay = ney[i];
				if (ax > 0) {
					if (c[ax - 1][ay] == 0 and syo[ax - 1][ay] == 0) {
						c[ax - 1][ay] = 1;
						nex[th] = ax - 1;
						ney[th] = ay;
						th++;
					}
				}
				if (ay > 0) {
					if (c[ax][ay - 1] == 0 and syo[ax][ay - 1] == 0) {
						c[ax][ay - 1] = 1;
						nex[th] = ax;
						ney[th] = ay-1;
						th++;
					}
				}
				if (ax < h - 1) {
					if (c[ax + 1][ay] == 0 and syo[ax + 1][ay] == 0) {
						c[ax + 1][ay] = 1;
						nex[th] = ax + 1;
						ney[th] = ay;
						th++;
					}
				}
				if (ay < w - 1) {
					if (c[ax][ay + 1] == 0 and syo[ax][ay + 1] == 0) {
						c[ax][ay + 1] = 1;
						nex[th] = ax;
						ney[th] = ay + 1;
						th++;
					}
				}
			}
			st = end;
			end = th;
			ans++;
		}
		bax = x;
		bay = y;
	}
	cout << ans << endl;
}



Measured memory_bytes: 18592
#include <algorithm>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#include <queue>
#define MOD (1000000007l)
#define rep(i, n) for(long i = 0; i < n; i++)

using namespace std;

void solve() {
  long N, K;
  cin >> N >> K;

  long ans = 1;

  while (N--) {
    if (ans < K) ans *= 2;
    else ans += K;
  }

  cout << ans << endl;
}

int main(void) {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout.precision(12);
  solve();
  return 0;
}


Measured memory_bytes: 256
import math
a,b,x=map(int,input().split())
#x=math.degrees(math.atan( 2*((a**2)*b-x)/(a**3) ))
tmp=math.atan( 2*((a**2)*b-x)/(a**3) )
if a*math.tan(tmp)<=b:
  print(math.degrees(tmp))
else:
  print(90.0-math.degrees(math.atan( 2*x/(a*b*b) )))

Measured memory_bytes: 3060
import java.util.*;
public class Main {
    public static void main(String[] args){
      // 入力
      Scanner sc = new Scanner(System.in);
      String N = sc.next();
      
      // 判定
      String result = "No";
      int total = 0;
      for(int i = 0; i < N.length(); i++){
        int num = Integer.parseInt(strAt(N,i));
        total += num;
      }
      if(total % 9 == 0){
        result = "Yes";
      }
      
      // 出力
      System.out.println(result);
    }
    
    // 文字列のx文字目を取得する関数
    public static String strAt(String str, int x){
      return String.valueOf(str.charAt(x));
    }

}

Measured memory_bytes: 49828
#include <bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
/*
    s.find_by_order(k) ---> returns iterator to the element at index(from 0) k
    s.order_of_key(val) ---> number of elements that are strictly smaller than the given value
*/
typedef long long int ll;
typedef unsigned long long ull;
typedef long double ld;
typedef vector<int> vi;
typedef vector<long long int> vl;
typedef vector<vector<int>> vvi;
typedef vector<vector<long long int>> vvl;
typedef pair<int, int> pii;
typedef pair<long long int, long long int> pll;
typedef vector<pair<int, int>> vii;
typedef vector<pair<long long int, long long int>> vll;
#define fastIO() ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define test() long long int tc; cin >> tc; cin.ignore(); while(tc--) 
#define ff first
#define ss second
#define pb push_back
#define pf push_front
#define mp make_pair
#define MOD 1000000007
#define SMOD 998244353
#define pq priority_queue
#define all(x) x.begin(),x.end()
#define SP(x) setprecision(x)
#define sp " "
#define inp(a) ll a;cin>>a;cin.ignore()
#define inps(a,b) ll a,b;cin>>a>>b;cin.ignore()
#define out(a) cout<<SP(20)<<a<<'\n'
#define outs(a,b) cout<<SP(20)<<a<<" "<<b<<'\n'
#define ins insert
#define er erase
#define lb lower_bound
#define ub upper_bound
#define printclock cerr<<"Time : "<<1000*(ld)clock()/(ld)CLOCKS_PER_SEC<<"ms\n";
#define inpa(a,n) ll a[n]; for(int i=0; i<n; i++){cin>>a[i];}
#define inpv(a,n) vl a; for(int i=0; i<n; i++){inp(x);a.pb(x);}
#define outa(a,n) for(int i=0;i<n;i++){cout<<a[i]<<" ";}cout<<'\n';
#define outv(v) for(auto i:v){cout<<i<<" ";}cout<<'\n';
set<char> vow = {'a','e','i','o','u','A','E','I','O','U'};
ll xpow(ll n, ll m){if(m==0){return 1;}else{ll x = xpow(n, m/2);if(m&1){return x*x*n;}else{return x*x;}}}
ll xmod(ll a, ll m){return (((a%m)+m)%m);}
ll xmodpow(ll n, ll m, ll y){if(m==0){return 1;}else{ll x = xmodpow(n, m/2, y);if(m&1){return xmod((xmod((xmod(x,y)*xmod(x,y)),y)*xmod(n,y)),y);}else{return xmod((xmod(x,y)*xmod(x,y)),y);}}}



void SOLVE(){
    ll a, b, c, d;
    cin >> a >> b >> c >> d;
    ll x = 60*a + b;
    ll y = 60*c + d;
    ll k;
    cin >> k;
    ll diff = y - x;
    if(diff<k){
        cout << 0 << '\n';
    }
    else{
        cout << diff-k << '\n';
    }
}

int main() {
	fastIO();
	// #ifndef ONLINE_JUDGE
    //     freopen("i.txt", "r", stdin);
    //     freopen("o.txt", "w", stdout);
	// #endif

    ll TC;
    // cin >> TC;
    TC = 1;
    for(ll tc1=1; tc1<=TC; tc1++){
        // cout << "Case #" << tc1 << ": ";
        SOLVE();
    }
    printclock;
}

Measured memory_bytes: 3848
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cctype>
#include <functional>
#include <iostream>
#include <iterator>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
#define ll long long
#define imfor(i, n) for(int i = 0; i < n; i++)
using namespace std;
ll MOD = 1000000007;

int main() {
    int a, b, c;
    cin >> a >> b >> c;
    for (int i = 1; i <= b; i++) {
        if (a * i % b == c) {
            cout << "YES" << endl;
            return 0;
        }
    }
    cout << "NO" << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <time.h>

#define _CRT_SECURE_NO_WARNINGS
#define TLong long long

// fact(n)
int fact(int n){
	if(n == 1)	return 1;
	else return (n * fact(n - 1));
}

// combination(n,r)
int combination(int n, int r){
	if(r == 0 || r == n)	return 1;
	else if(r == 1)	return n;
	return (combination(n - 1, r - 1) + combination(n - 1, r));
}

int gcd(int a,int b){
	if(!(a % b)) return b;
	return gcd(b,a % b);
}

// lcm(a.b)
int lcm(int a,int b){
	return (a * b) / gcd(a,b);
}

// qsort(array, size, sizeof(int),comp);
int comp(const int *a,const int *b){
	return (*a - *b);
}

// append(array,*size,addNum)
void append(int *array,int *size,int num){
	realloc(array, sizeof(int) * (*size + 1));
	array[(*size)] = num;
	++(*size);
}

// pop(array,*size) & nongetpop(array,*size)
int pop(int *array,int *size){
	int temp = array[(*size - 1)];
	nongetpop(array,&(*size));
	return temp;
}

void nongetpop(int *array,int *size){
	realloc(array,sizeof(int) * (*size - 1));
	--(*size);
}

int main(int argc, char const *argv[]){
	int up = 0,down = 0;
	char pass[2][57];
	for (int i = 0; i < 2; ++i)	scanf("%s ",pass[i]);
	for (int i = 0; i < strlen(pass[0]) + strlen(pass[1]); ++i){
		if(!(i % 2))	printf("%c", pass[0][up++]);
		else printf("%c", pass[1][down++]);
	}
	printf("\n");
	return 0;
}

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

int main() {

string N;
	cin>>N;
	
	for(int i=0;i<2;i++){
      if(N.at(i)==N.at(i+1)&&N.at(i+1)==N.at(i+2)){cout<<"Yes"<<endl;break;}
    else if(i==1){cout<<"No"<<endl;}
  
}
}


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

arr = map(int,raw_input().split())

dic = [0,0,0]

for i in arr:
	if i%4==0:
		dic[2] += 1
	elif i%2 == 0:
		dic[1] += 1
	else :
		dic[0] += 1


if dic[2]+1 <= dic[0] and 0 < dic[1]:
	print 'No'
elif dic[2]+1 == dic[0] and dic[1] == 0:
	print 'Yes'

elif dic[2] >= dic[0] :
	print 'Yes'

else :
	print 'No'

Measured memory_bytes: 11320
#include <bits/stdc++.h>
#define FASTIO ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define LL long long int
using namespace std;
 
const int N = 2e5 + 5;
const int oo = 1e9;
 
int movex[4] = {-1, 1, 0, 0};
int movey[4] = {0, 0, -1, 1};
 
void solve() {
    int h, w, k;
    cin >> h >> w >> k;
    vector<string> v(h);
    int x1, y1, x2, y2;
    cin >> x1 >> y1 >> x2 >> y2;
    x1--; y1--; x2--; y2--;
    for (auto &it : v) cin >> it;
    vector<vector<int>> reach(h, vector<int>(w, oo));
    queue<pair<int, int>> bfs;
    bfs.push({x1, y1});
    reach[x1][y1] = 0;
    while(!bfs.empty()) {
        auto now = bfs.front(); bfs.pop();
        int xx = now.first, yy = now.second;
        for (int move=0;move<4;++move) {
            for (int d=1;d<=k;++d) {
                int x = xx + movex[move] * d;
                int y = yy + movey[move] * d;
                if (x < 0 || x >= h || y < 0 || y >= w) break;
                if (v[x][y] != '.') break;
                if (reach[x][y] < reach[xx][yy] + 1) break;
 
                if (reach[x][y] > reach[xx][yy] + 1) {
                    bfs.push({x, y});
                    reach[x][y] = min(reach[xx][yy] + 1, reach[x][y]);
                }
            }
        }
    }
    int ans = reach[x2][y2];
    if (ans >= oo) ans = -1;
    cout << ans << '\n';
} 
int main() {
    FASTIO;
    int t = 1;
    // cin >> t;
    while(t--) solve();
    return 0;
}

Measured memory_bytes: 12152
#include <bits/stdc++.h>
#define ri register
#define int long long
#define E (n+1)
using namespace std; const int N=200010;
inline int read()
{
    int s=0, w=1; ri char ch=getchar();
    while(ch<'0'||ch>'9') { if(ch=='-') w=-1; ch=getchar(); }
    while(ch>='0'&&ch<='9') s=(s<<3)+(s<<1)+(ch^48), ch=getchar();
    return s*w;
}
signed main()
{
    int a,b,c,x;
    a=read(), b=read(), c=read();
    x=read();
    int res=0;
    for(ri int i=0;i<=a;i++)
    for(ri int j=0;j<=b;j++)
    for(ri int k=0;k<=c;k++)
    if(i*500+j*100+k*50==x) res++;
    printf("%lld\n",res);
    return 0;
}

Measured memory_bytes: 3756
n = int(input())
s = input()

pin = []
for i in range(1000):
    i = str(i)
    if len(i) == 1:
        i = '00' + i
    elif len(i) == 2:
        i = '0' + i
    pin.append(i)

ans = 0
for i in pin:
    c = 0
    for j in s:
        if j == i[c]:
            c += 1
        if c == 3:
            ans += 1
            break
print(ans)

Measured memory_bytes: 42300
A, B, C, X, Y = map(int, input().split())

ans = 0
# A,B単体で買ったほうがよい場合
if 2 * C >= A + B:
    ans += A * X + B * Y

# Cを買ったほうが良い場合
else:
    if X > Y:
        ans = min((X - Y) * A + 2 * C * Y, 2 * C * X)
    else:
        ans = min((Y - X) * B + 2 * C * X, 2 * C * Y)

print(ans)

Measured memory_bytes: 3060
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <fstream>
#include <sstream>
#include <set>
#include <map>
#include <vector>
#include <list>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <string>
#include <stack>
#include <queue>
#include <bitset>     //UWAGA - w czasie kompilacji musi byc znany rozmiar wektora - nie mozna go zmienic
#include <cassert>
#include <iomanip>        //do setprecision
#include <ctime>
#include <complex>
using namespace std;

#define FOR(i,b,e) for(int i=(b);i<(e);++i)
#define FORQ(i,b,e) for(int i=(b);i<=(e);++i)
#define FORD(i,b,e) for(int i=(b)-1;i>=(e);--i)
#define REP(x, n) for(int x = 0; x < (n); ++x)

#define ST first
#define ND second
#define PB push_back
#define PF push_front
#define MP make_pair
#define LL long long
#define ULL unsigned LL
#define LD long double
#define pii pair<int,int>
#define pll pair<LL,LL>
#define vi vector<int>
#define vii vector<vi>

const double pi = 3.14159265358979323846264;
const int mod=1000000007;

int main(){
	 //cin.tie(0);
	//ios::sync_with_stdio(false);
	//std::cout << std::fixed;
	//std::cout << std::setprecision(12);
	//std::cout << std::defaultfloat;
	int n;
	cin>>n;
	n--;
	cout<<1LL*n*(n+1)/2;

	return 0;
}


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

#define REP(i, a, b) for (int i = int(a); i < int(b); i++)
#ifdef _DEBUG_
#define dump(val) cerr << __LINE__ << ":\t" << #val << " = " << (val) << endl
#else
#define dump(val)
#endif

using namespace std;

typedef long long int ll;

template<typename T>
vector<T> make_v(size_t a, T b) {
    return vector<T>(a, b);
}
template<typename... Ts>
auto make_v(size_t a, Ts... ts) {
    return vector<decltype(make_v(ts...))>(a, make_v(ts...));
}


class UnionFind {
public:
    vector<int> par;
    UnionFind(int n) {
        par.resize(n, -1);
    }
    int Find(int n) {
        return par[n] < 0 ? n : par[n] = Find(par[n]);
    }
    bool Union(int x, int y) {
        x = Find(x);
        y = Find(y);
        if (x == y) return false;
        if (-par[x] < -par[y]) swap(x, y);
        par[y] += par[x];
        par[x] = y;
        return true;
    }
    bool Same(int x, int y) {
        return Find(x) == Find(y);
    }
    int size(int x) {
        return -par[Find(x)];
    }
};


int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int n, q;
    cin >> n >> q;
    UnionFind uf(n);
    REP(i, 0, q) {
        int com, x, y;
        cin >> com >> x >> y;
        if (com) {
            cout << uf.Same(x, y) << endl;
        } else {
            uf.Union(x, y);
        }
    }
    return 0;
}



Measured memory_bytes: 3268
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#define rep(i, n) for(int i=0; i<n; i++)
int main(void){
    int n, m, k;
    int a[200000+5], b[200000+5];
    
    scanf("%d %d %d", &n, &m, &k);
    
    rep(i,n)scanf("%d", &a[i]);
    rep(i,m)scanf("%d", &b[i]);
    
    long long int t=0;
    
    rep(i, m)t+=b[i];
    
    int ans=0;
    int j=m;
    rep(i, n+1){
        while(k<t && 0<j){
            t-=b[j-1];
            j--;
        }
        if(k<t)break;
        if(ans<i+j)ans=i+j;
        if(i==n)break;
        t+=a[i];
    }
    
    
    printf("%d\n", ans);
    
    return 0;
}


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

int main(int argc , char** argv){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);cout.tie(NULL);
	int n;
	cin >> n;
	vector<long long> x(n,0),y(n,0),h(n,0);
	for(int i = 0 ; i < n ; ++i){
		cin >> x[i] >> y[i] >> h[i];
	}
	for(int x_cen = 0 ; x_cen <= 100 ; ++x_cen){
		for(int y_cen = 0 ; y_cen <= 100 ; ++y_cen){
			long long H = 0;
			int flag = 1;
			for(int i = 0 ; i < n ; ++i){
				if(h[i] > 0){
					H = h[i] + abs(x_cen - x[i]) + abs(y_cen - y[i]);
					break;
				}
			}
			for(int i = 0 ; i < n ; ++i){
				if(max(0LL , H - abs(x_cen - x[i]) - abs(y_cen - y[i])) != h[i]){
					flag = 0;
					break;
				}
			}
			if(flag == 1){
				cout << x_cen << " " << y_cen << " " << H << endl;
				return 0;
 			}
		}
	}
	return 0;
}

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

tmp = nil
side = nil

sticks.sort{|a,b| b<=>a}.each do |length|
  if tmp == length
    unless side.nil?
      puts side * length
      exit
    end
    side = length
    tmp = nil
  else
    tmp = length
  end
end

puts 0

Measured memory_bytes: 13080
package main

import "fmt"

func FactoredPrimeNumber(num int) map[int]int {
	return factor(num, 2)
}

func merge(m1, m2 map[int]int) map[int]int {
	ans := map[int]int{}
	for k, v := range m1 {
		ans[k] += v
	}
	for k, v := range m2 {
		ans[k] += v
	}
	return ans
}

func factor(num, pnum int) map[int]int {
	result := make(map[int]int)
	if pnum*pnum > num {
		if num != 1 {
			result[num] += 1
		}
		return result
	}

	if num%pnum == 0 {
		num /= pnum
		result[pnum]++
	} else {
		pnum++
	}
	return merge(result, factor(num, pnum))
}

func count(n int) int {
	cnt := 0
	for n%2 == 0 {
		cnt++
		n /= 2
	}
	return cnt
}

func gcd(x, y int) int {
	if y == 0 {
		return x
	}
	return gcd(y, x%y)
}
func main() {
	var N, M int
	fmt.Scanf("%d %d\n", &N, &M)

	a := make([]int, N)
	for i := 0; i < N; i++ {
		var ai int
		fmt.Scan(&ai)
		a[i] = ai / 2
	}
	cnt := count(a[0])
	M = M >> uint(cnt)
	for i := 0; i < N; i++ {
		if cnt != count(a[i]) {
			fmt.Println(0)
			return
		}
		a[i] = a[i] >> uint(cnt)
	}
	lcm := 1
	for i := 0; i < N; i++ {
		r := gcd(lcm, a[i])
		lcm = lcm / r * a[i]
	}
	if lcm > M {
		fmt.Println(0)
		return
	}
	fmt.Println((M/lcm + 1) / 2)
}


Measured memory_bytes: 5504
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update>   
using namespace std;
using namespace __gnu_pbds;
typedef long long ll; 
#define int long long
typedef unsigned long long lu;
typedef vector<ll> v;
typedef vector<vector<ll> > vv;
typedef vector<string>  vs;
typedef vector<pair<ll,ll>> vpr;
typedef long double ld;
#define f(i,n) for(ll i = 0; i < n; i++)
#define ff(i,n) for(ll i=1;i<=n;i++)
#define pb push_back
#define mp make_pair
#define endl "\n"
#define fi first
#define se second
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define amax(x,y) if(y>x) x=y;
#define amin(x,y) if(y<x)x=y;
#define bg(x) x.begin()
#define sz(x) (ll)x.size()
#define in(x,n) for(ll i=0;i<n;i++)cin>>x[i]
#define out(x,n) for(ll i=0;i<n;i++)cout<<x[i]<<" " 
#define mxt(a) *(max_element(a.begin(),a.end()))
#define mnt(a) *(min_element(a.begin(),a.end())
#define tc ll t;cin>>t;while(t--)
typedef pair<ll,ll> pi;
#define yes cout<<"YES\n";
#define no cout<<"NO\n";
#define yesno(f) if(f) yes else no
const v dx = {1, -1, 0, 0};
const v dy = {0, 0, 1, -1};
const ll mod=1e9+7;
const ld PI = 2 * acos(0.0);
ll m(ll a){ return (a+mod)%mod;}
ll cel(ll x1,ll y1){if((x1%y1)==0)return x1/y1;else return x1/y1+1;}
ll power(ll a,ll b,ll m)
{
	if(b==0)
		return 1;
	ll d=power(a,b/2,m);
	d=(d*d)%m;
	if(b&1)
		d=(d*a)%m;
	return d;
}
// set_name.find_by_order(k) It returns to an iterator to the kth element (counting from zero) in the set in O(logn) time
// set_name.order_of_key(k) It returns to the number of items that are strictly smaller than our item k in O(logn) time.
/*string operations :
str.substr (x,y) : returns a substring str[x],str[x+1],...str[x+y-1]
str.substr (x) : returns a substring str[x],... end of string
str.find(qtr) : returns the first occurenece of qtr in str */
int32_t main()
{
	ios::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);
	int n;cin>>n;
	v a(n),b(n-1);in(b,n-1);
	a[0]=b[0];
	b.pb(1e16);
	int sum=a[0];
	for(int i=1;i<n;i++)
	{
		a[i]=min(b[i-1],b[i]);
		sum+=a[i];
	}
	cout<<sum<<endl;
	return 0;
}

Measured memory_bytes: 256
n,p = map(int, input().split())
if n==1:
    print(p)
    exit()
elif p==1:
    print(1)
    exit()
elif n>60:
    print(1)
    exit()
a = int(p**(1/n)+1)
for i in range(a,0,-1):
  if p%(i**n)==0:
    print(i)
    exit()


Measured memory_bytes: 63884
#include <iostream>
#include <string>
#include <map>
#include <queue>
#include <algorithm>
#include <vector>
#include <math.h>
#include <bitset>
#include <cmath>
#include <set>
#include <queue>

typedef long long ll;
#define rep(i,s,n)for(ll i = s;i<n;i++)
#define repe(i,s,n)for(ll i = s;i<=n;i++)
#define rep_r(i,s,n)for(ll i = n;i>s;i--)
#define rep_re(i,s,n)for(ll i = n;i>=s;i--)
using namespace std;
static const ll MOD = 1e9 + 7;
static const ll INF = 1e25;
static const ll MAX_N = 100001;

ll b[101];
ll a[101];
int main() {
	ll n; cin >> n;
	rep(i, 1, n)cin >> b[i];
	repe(i, 1, n)a[i] = INF;

	rep(i, 1, n) {
		a[i] = min(a[i], b[i]);
		a[i + 1] = min(a[i + 1], b[i]);
	}

	ll ans = 0;
	repe(i, 1, n) ans += a[i];
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_set>
#include <vector>

using namespace std;

#define ll long long
#define P pair<int, int>
#define FOR(i, N) for (int i = 0; i < (int)N; i++)
#define FORIN(i, a, b) for (int i = a; i < (int)b; i++)
#define ALL(x) (x).begin(), (x).end()
#define GI(name) \
  int(name);     \
  scanf("%d", &(name))
#define GI2(name1, name2) \
  int(name1), (name2);    \
  scanf("%d %d", &(name1), &(name2))
#define GI3(name1, name2, name3) \
  int(name1), (name2), (name3);  \
  scanf("%d %d %d", &(name1), &(name2), &(name3))
#define GVI(name, size)    \
  vector<int>(name)(size); \
  FOR(i, (size)) scanf("%d", &(name)[i])
#define GS(name) \
  string(name);  \
  cin >> (name);
#define MOD 1000000007
#define DEBUG(...) debug(__LINE__, ":" __VA_ARGS__)

string to_string(string s) {
  return s;
}

template <class T>
string to_string(vector<T> v) {
  string ret = "{";
  FOR(i, v.size() - 1) { ret += to_string(v[i]) + ","; }
  if (v.size() > 0) {
    ret += to_string(v.back());
  }
  ret += "}";
  return ret;
}

void debug() {
  cerr << endl;
}

template <class Head, class... Tail>
void debug(Head head, Tail... tail) {
  cerr << to_string(head) << " ";
  debug(tail...);
}

void print() {
  cout << endl;
}

template <class Head, class... Tail>
void print(Head head, Tail... tail) {
  cout << to_string(head);
  print(tail...);
}

#define MAX 500000
long long fac[MAX], finv[MAX], inv[MAX];

void COMinit() {
  fac[0] = fac[1] = 1;
  finv[0] = finv[1] = 1;
  inv[1] = 1;
  for (int i = 2; i < MAX; i++) {
    fac[i] = fac[i - 1] * i % MOD;
    inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
    finv[i] = finv[i - 1] * inv[i] % MOD;
  }
}

long long COM(int n, int k) {
  if (n < k)
    return 0;
  if (n < 0 || k < 0)
    return 0;
  return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

int main() {
  GI2(N, K);
  COMinit();
  FORIN(i, 1, K + 1) {
    ll a1 = COM(N - K + 1, i);
    ll a2 = COM(K - 1, i - 1);
    print((a1 * a2) % MOD);
  }
  return 0;
}

Measured memory_bytes: 11904
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n,i,l,r,ans=0;
	scanf("%d",&n);
	for(i=1;i<=n;i++)
	{
		scanf("%d %d",&l,&r);
		ans+=r-l+1;
    }
    printf("%d",ans);
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
	long long m,n;
	cin>>m>>n;
	if(n==1 || m==1)
	if(n*m>=2)
	cout<<n*m-2;
	else
	cout<<'1';
	else
	cout<<(n-2)*(m-2);
}

Measured memory_bytes: 3596
def bubbleSort(c):
    for i in range(len(c)):
        for j in range(len(c) - 1, i, -1):
            if c[j][1] < c[j - 1][1]:
                c[j], c[j - 1] = c[j - 1], c[j]
    return c


def selectionSort(c):
    for i in range(len(c)):
        minj = i
        for j in range(i, len(c)):
            if c[j][1] < c[minj][1]:
                minj = j
        c[i], c[minj] = c[minj], c[i]
    return c


n = int(input())
b = input().split()
s = b[:]

b = bubbleSort(b)
s = selectionSort(s)

print(*b)
print('Stable')
print(*s)
print('Stable' if b == s else 'Not stable')



Measured memory_bytes: 5616
//AUTHOR: RAVAN_2070
//PUNE INSTITUTE OF COMPUTER TECHNOLOGY
/*
    I LOVE CLARICE STARLING

     ♥LOVE♥        ♥LOVE♥
  ♥LOVE♥♥LOVE♥  ♥LOVE♥♥LOVE♥
♥LOVE♥♥LOVE♥♥LOVE♥♥LOVE♥♥LOVE♥
   ♥LOVE♥♥LOVE♥♥LOVE♥♥LOVE♥
      ♥LOVE♥♥LOVE♥♥LOVE♥
         ♥LOVE♥♥LOVE♥
            ♥LOVE♥
               ♥


        EXPLAINATION BELOW->
        Read Editorial first
        1)Since 10^100 is a very large number, the sum of M numbers is almost M × 10^100. Since the
         contribution of the “fraction” is small enough, two sets with different numbers of items have not
         the same sum in common.
         ex=> even the smallest difference between the two different sets==(M)*10^100-(M-1)*(10^100)+sumofchoosenM-sumofchoosen(M-1)
          * ==>1*(10^100)+sumofchoosenM-sumofchoosen(M-1)..
          and definelty sumofchoosenM <<<< then 10^100
        2)When choosing M numbers, the sum is minimum when the smallest M numbers are chosen,
        and the sum is maximum when the largest M numbers are chosen. Actually every value between
        the minimum and the maximum can be constructed. (You can see that by imagining increasing
        the chosen numbers little by little, starting from the minimum)
            All that left is finding maximum - minimum.
        3)Ignore 10^100 since it cancels out;
*/
//D-Sum of Large numbers
#include<bits/stdc++.h>
using namespace std;
typedef unsigned long long int ull;
typedef long long int ll;
typedef long double ld;
typedef vector<ll> vi;
typedef vector<pair<ll,ll>> vii;
typedef pair<ll,ll> pii;
typedef map<ll,ll> mii;
#define MOD7 1000000007
#define MOD9 1000000009
#define pi 3.1415926535
#define Test_cases ll TC;cin>>TC;while(TC--)
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(), x.rend()
#define sp(x) fixed<<setprecision(x)
#define sz(x) (ll)(x.size())
#define fo(i,a,b) for(i=a;i<b;i++)
#define foe(i,a,b) for(i=a;i<=b;i++)
void solve()
{
  ll n,k,i;cin>>n>>k;
  ll ans=0;
  foe(i,k,n+1)
  {
      ll mx=((n+1)*(n+2)/2)-((n+1-i)*(n+1-i+1)/2);
      ll mn=i*(i+1)/2;
      ans+=mx-mn+1;
      ans%=MOD7;
  }
  cout<<ans<<"\n";
}
int main()
{
   fastio
   solve();
  return 0;
}
//map<ll,ll,greater<int>> to sort in descending order ,in iterator declaration no greater<int>
//if you want to apply lowerbound on set use s.lower_bound(key),not the one used for vector
/* TIPS FOR DEBUGGING
 * Check if values are not overflowing (use long long where required)
 * Check if ranges are inclusive or not.
 * Check properly if greedy will work or not before using it.
 * Check EDGE CASES!! Seriously, even in 2B, saving 8 points by being
 * 2 minutes faster will bite you in the ass if you don't make sure
 * it works on edge cases.
 * Keep adding to this list.
*/

Measured memory_bytes: 3644
#include<bits/stdc++.h>
using namespace std;
int main(){
  long N,x,ans = 0;
  cin>>N>>x;
  vector <long> a(N);
  long b = 0;
  for(long i = 0;i<N;i++){
    cin >> a.at(i);
    b += a.at(i);
  }
  if(b == x){
    ans = N;
  }
  if(b < x){
    ans = N-1;
  }
  
  if(b > x){
    sort(a.begin(),a.end());
    long sum = 0;
    long count = 0;
    for(long k = 0;k<N;k++){
      sum = sum + a.at(k);
      if(sum > x){
        ans = count;
        break;
      }
      count++;
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
p = 226732710 #10***100 %(10**9+7)
num = 10**9+7
[N,K] = [int(s) for s in input().rstrip().split(' ')]
L = []
ans = 0
for i in range(K,N+2):
    ans += i*(N-i+1)+1
    ans %= num
print(ans)

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

int main() {
    int h1,m1,h2,m2,k,temp1;
    cin>>h1>>m1>>h2>>m2>>k;
    temp1 = (h1*60)+m1;
    int temp2 = (h2*60)+m2;
    int ans = temp2-temp1 - k;
    if(ans<=0)
        cout<<"0"<<endl;
    else{
        cout<<ans<<endl;
    }
	// your code goes here

	return 0;
}


Measured memory_bytes: 3636
func readInts() -> [Int] {
    return readLine()!.split(separator: " ").map { Int($0)! }
}

func main() {
    let abc = readInts()
    
    if abc[2] + abc[1] - abc[0] >= 0 {
        print(abc[2] + abc[1] - abc[0])
    } else {
        print("0")
    }
}

main()


Measured memory_bytes: 8192
N=int(input())
s=input()
c=0
if N%2==1:
 print("No")
else:
 r=int(N/2)
 for i in range(r):
  if s[i]==s[i+r]:
   c+=1
 if c==r:
  print("Yes")
 else:
  print("No")


Measured memory_bytes: 2940
using System;
using System.Linq;

public class AtCoderD
{
    static void Main()
    {
        int n = int.Parse(Console.ReadLine());

        int[] nums = new int[n];
        {
            var line = Console.ReadLine();
            var words = line.Split(' ');
            for (int i = 0; i < n; i++)
            {
                nums[i] = int.Parse(words[i]);
            }
        }

        if (!nums.Contains(1))
        {
            Console.WriteLine(-1);
            return;
        }

        int answer = 0;
        int current = 1;

        for (int i = 0; i < n; i++)
        {
            if (nums[i] != current)
            {
                answer++;
            }
            else
            {
                current++;
            }
        }

        Console.WriteLine(answer);
    }
}

Measured memory_bytes: 34140
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <string>
#include <map>
#include <set>
#include <stack>
#include <tuple>
#include <deque>
#include <numeric>
#include <bitset>
#include <iomanip>
#include <cassert>
#include <chrono>
#include <random>
#include <limits>
#include <iterator>
#include <functional>
#include <sstream>
#include <complex>
using namespace std;

typedef long long ll;
typedef uint64_t ull;
typedef pair<int, int> P;
constexpr double EPS = 1e-9;
constexpr int INF = 1001001001;
constexpr int mod = 1000000007;
// constexpr int mod = 998244353;

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

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

    ll a, v, b, w, t;
    cin >> a >> v >> b >> w >> t;
    if(a > b)   swap(a, b);
    ll foo = a + v * t, bar = b + w * t;
    if(foo >= bar)  cout << "YES\n";
    else    cout << "NO\n";
}

Measured memory_bytes: 3648
#include <bits/stdc++.h>
#include <assert.h>
using namespace std;
using i64 = long long;

int main()
{
  i64 a, b;
  cin >> a >> b;
  i64 g = __gcd(a, b);
  i64 ans = 1;
  for (i64 i = 2; i * i <= g; i++)
    if (g % i == 0)
    {
      ans++;
      while (g % i == 0)
        g /= i;
    }
  if (2 < g)
    ans++;
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
/*zxj*/
#include<iostream> 
#include<string>
#include<cstring>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<set>
#include<map>
#include<vector>
#include<queue>
#include<sstream>
#define sf scanf
#define pf printf
#define pfn printf("\n");
#define pfk printf(" ");
#define pf0 printf("0");
#define pf1 printf("1");
#define ll long long
#define sfd(n) scanf("%d",&n);
#define sfdd(n,m) scanf("%d%d",&n,&m);
#define sfld(n) scanf("%lld",&n);
#define sfldd(n,m) scanf("%lld%lld",&n,&m);
#define sflf(n) scanf("%lf",&n);
#define sflff(n,m) scanf("%lf%lf",&n,&m);
#define sfc(n) scanf("%c",n);
#define sfcc(n,m) scanf("%c%c",n,m);
#define sfs(n) scanf("%s",n);
#define sfss(n,m) scanf("%s%s",n,m);
#define pfd(n) printf("%d",n);
#define pfld(n) printf("%lld",n);
#define pflf(n) printf("%lf",n);
#define pfc(n) printf("%c",n);
#define pfs(n) printf("%s",n);
using namespace std;
#define csh(a,n) memset(a,n,sizeof(a));
int arr[1000000];
int main(){
	int n,a,b;
	cin>>n;
	for(int i=0;i<n;i++){
		cin>>arr[i];
	}
	int q=0;
	for(int i=n-1;i>0;i--){
		if(arr[i]<arr[i-1]){
			arr[i-1]--;
			if(arr[i]<arr[i-1]){
				q=1;
				break;
			}
		}
	} 
	if(q){
		cout<<"No"<<endl;
	}
	else{
		cout<<"Yes"<<endl;
	}
} 

Measured memory_bytes: 640
#include <algorithm>
#include <iostream>
#include <string>
#include <typeinfo>
#include <vector>

using namespace std;
using ll = long long int;

// to format a document: ctrl + K -> ctrl + D

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

    int a = stoi(S);
    int b = a % 100;
    a     = a / 100;
    if (1 <= a && a <= 12) {
        if (1 <= b && b <= 12) {
            cout << "AMBIGUOUS" << endl;
        }
        else {
            cout << "MMYY" << endl;
        }
    }
    else {
        if (1 <= b && b <= 12) {
            cout << "YYMM" << endl;
        }
        else {
            cout << "NA" << endl;
        }
    }

    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int gcd(int, int);

int main() {
	int K;
	int x = scanf("%d", &K);
	long long int sum = 0;
	for (int i = 1;i <= K;++i) {
		for (int j = 1;j <= K;++j) {
			for (int k = 1;k <= K;++k) {
				sum += gcd(gcd(i, j), k);
			}
		}	
	}
	
	printf("%lld\n", sum);
	return 0;
}

int gcd(int x, int y) {
	int a = x, b = y;
	while (1) {
		if (a == b) {
			return a;
		}
		else if (a < b) {
			int t = a;
			a = b;
			b = t;
		}

		a -= b;
	}
}


Measured memory_bytes: 1728
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define all(c) (c).begin(),(c).end()
#define pb push_back
#define dbg(...) do{cerr<<__LINE__<<": ";dbgprint(#__VA_ARGS__, __VA_ARGS__);}while(0);

using namespace std;

namespace std{template<class S,class T>struct hash<pair<S,T>>{size_t operator()(const pair<S,T>&p)const{return ((size_t)1e9+7)*hash<S>()(p.first)+hash<T>()(p.second);}};template<class T>struct hash<vector<T>>{size_t operator()(const vector<T> &v)const{size_t h=0;for(auto i : v)h=h*((size_t)1e9+7)+hash<T>()(i)+1;return h;}};}
template<class T>ostream& operator<<(ostream &os, const vector<T> &v){os<<"[ ";rep(i,v.size())os<<v[i]<<(i==v.size()-1?" ]":", ");return os;}template<class T>ostream& operator<<(ostream &os,const set<T> &v){os<<"{ "; for(const auto &i:v)os<<i<<", ";return os<<"}";}
template<class T,class U>ostream& operator<<(ostream &os,const map<T,U> &v){os<<"{";for(const auto &i:v)os<<" "<<i.first<<": "<<i.second<<",";return os<<"}";}template<class T,class U>ostream& operator<<(ostream &os,const pair<T,U> &p){return os<<"("<<p.first<<", "<<p.second<<")";}
void dbgprint(const string &fmt){cerr<<endl;}template<class H,class... T>void dbgprint(const string &fmt,const H &h,const T&... r){cerr<<fmt.substr(0,fmt.find(","))<<"= "<<h<<" ";dbgprint(fmt.substr(fmt.find(",")+1),r...);}
typedef long long ll;typedef vector<int> vi;typedef pair<int,int> pi;const int inf = (int)1e9;const double INF = 1e12, EPS = 1e-9;

int v[400010];
vector<vi> e;
string s;
void rec(int c, int d){
	v[2 * c + d] = 1;
	for(int i : e[c]){
		if((d > 0) == (s[c] == s[i])) continue;
		if(v[2 * i + 1 - d] == 1){
			cout << "Yes" << endl;
			exit(0);
		}
		if(!v[2 * i + 1 - d]) rec(i, 1 - d);
	}
	v[2 * c + d] = 2;
}
int main(){
	cin.tie(0); cin.sync_with_stdio(0);
	
	int n, m; cin >> n >> m >> s;
	e.resize(n);
	rep(i, m){
		int a, b; cin >> a >> b; a--; b--;
		e[a].pb(b);
		if(a != b) e[b].pb(a);
	}
	
	rep(i, n) if(s[i] == 'A' && !v[2 * i]) rec(i, 0);
	cout << "No" << endl;
	
	return 0;
}

Measured memory_bytes: 22480
#x!=y
#赤があったことがあってボールが残っていれば行先も赤があるかも
#空なら赤いボールもない

n,m = map(int, input().split( ))
red = [0]*(n+1)
cnt = [1]*(n+1)
red[1] = 1
flag = False
for _ in range(m):
    x,y = map(int, input().split( ))
    if red[x] and cnt[x]:
        red[y] = 1
    cnt[x] -= 1
    cnt[y] += 1
    if not cnt[x]:
        red[x] = 0
ans = 0
for i in range(n+1):
    if red[i] and cnt[i]:
        ans += 1

print(ans)

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

#define ll long long
#define pb push_back
#define iter std::vector<int>::iterator

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

	int n;
	cin >> n;

	vector<ll> vi (n);
	int odd = 0;
	for (int i=0; i<n; i++) {
		ll x;
		cin >> x;
		if (x < 0) {
			odd++;
		}
		vi[i] = abs(x);

	}

	sort(vi.begin(), vi.end());

	vi[0] = odd % 2 != 0 ? -vi[0] : vi[0];
	ll res = 0;
	for (ll x : vi) {
		res += x;
	}

	cout << res;

	return 0;	
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0 ; i < n ; i++)
#define repr(i, a, b) for(int i = a ; i < b ; i++)
typedef long long ll;

int main(){
    double N,a=0;
    cin >> N;
    vector<double> abc(N);
    rep(i,N) cin >> abc[i];
    rep(i,N) a+=1.0/abc[i];
    cout << fixed << setprecision(5) << 1.0/a << endl;
    return 0;
}

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

using mint = modint998244353;
const mint inv9 = mint(1)/9;

struct S {
    mint x, w;
    S(mint x=0, mint w=1):x(x),w(w) {}
};

S op(S a, S b) {
    return S(a.x*b.w + b.x, a.w*b.w);
}

S e() { return S();}

S mapping(int f, S a) {
    if (f == 0) return a;
    return S((a.w-1)*inv9*f, a.w);
}

int composition(int f, int g) {
    if (f == 0) return g;
    return f;
}

int id() { return 0;}

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

    lazy_segtree<S,op,e,int,mapping,composition,id> t(n);
    rep(i,n) t.set(i, S(1,10));
    rep(qi,q) {
        int l, r, d;
        cin >> l >> r >> d;
        l--;
        t.apply(l,r,d);
        S ans = t.prod(0,n);
        cout << ans.x.val() << "\n";
    }
    return 0;
}

Measured memory_bytes: 9816