akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
#define all(x) (x).begin(),(x).end()
#define pll pair<ll,ll>
#define pii pair<int,int>
#define rep(i,n) for(int i=0;i<n;i++)
#define sz(x) ((ll)(x).size())
#define pb push_back
#define mp make_pair
#define bit(n) (1LL<<(n))
#define F first
#define S second
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
const ll INF = 1LL<<60;
const ll mod = (int)1e9 + 7;

int main() {
    int a,b,t;
    cin >> a >> b >> t;
    cout << t/a*b;
    


}

/*



 */



Measured memory_bytes: 256
/*
ID: learnin7
TASK: test
LANG: C++                 
*/
/* LANG can be C++11 or C++14 for those more recent releases */
#include<bits/stdc++.h>

using namespace std;
typedef long long ll;

int main(){
        
    ios_base::sync_with_stdio(0);
    //ofstream fout ("test.out");
    //ifstream fin ("test.in");
    //fin >> a >> b;
    //fout << a+b << endl;
    int a,b;
    cin>>a>>b;
    string s;
    cin>>s;
    if(s[a]!='-'){
        cout<<"No\n";
        return 0;
    }
    for(int i=0;i<a;i++){
        if(s[i]>=48 && s[i]<=57)    continue;
        else{
            cout<<"No\n";
            return 0;
        }
    }
    for(int i=a+1;i<a+b+1;i++){
        if(s[i]>=48 && s[i]<=57)    continue;
        else{
            cout<<"No\n";
            return 0;
        }
    }

    cout<<"Yes\n";
    return 0;
}



Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>
#include<ios>//左右揃え
#include<iomanip>//setwで幅指定

using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define MOD 1000000007LL

int main(void) {
    string s;
    cin >> s;
    bool b = 1;
    for (int i = 0; i < s.size(); i += 2) {
        if (s.size() == 1) {
            b = 0;
            break;
        }
        if (s[i] != 'h' || s[i + 1] != 'i') b = 0;
    }
    if (b) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 256
import java.util.*;

class Main{
        public static void main(String[] args){
                Scanner sc = new Scanner(System.in);
                int[] list = new int[101];
                int max = 0;
                while(sc.hasNext()){
                        max = Math.max(max, ++list[sc.nextInt()]);
                }   
                sc.close();
                for(int i = 0; i < 101; i++){
                        if(list[i] == max){
                                System.out.println(i);
                        }   
                }   
        }   
}

Measured memory_bytes: 12000
# -*- coding: utf-8 -*-
import sys
import copy
import collections
from bisect import bisect_left
from bisect import bisect_right
from collections import defaultdict
from heapq import heappop, heappush
import math

# NO, PAY-PAY
#import numpy as np
#import statistics
#from statistics import mean, median,variance,stdev
 
def main():
    N,A,B = map(int,input().split())
    ans = 0
    for i in range(1,N+1):
        to = 0
        tmp = str(i)
        for j in range(len(tmp)):
            to += int(tmp[j])
        if to >= A and to <= B:
            ans += i
            
    print(ans)
            	
if __name__ == "__main__":
	main()


Measured memory_bytes: 39536
import math

a, b, x = [int(_) for _ in input().split()]

if a * a * b <= 2 * x:
  print(math.degrees(math.atan(2 * (a * a * b - x) / (a * a * a))))
else:
  print(math.degrees(math.atan(a * b * b / (2 * x))))

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

using namespace std;

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

    int n;
    cin >> n;
    string s;
    cin >> s;

    vector<int> pref(n), suff(n);
    pref[0] = (s[0] == 'W' ? 1 : 0);
    suff[n - 1] = (s[n - 1] == 'E' ? 1 : 0);
    for(int i = 1; i < n; i++)
    {
        if(s[i] == 'W')
            pref[i] = pref[i - 1] + 1;
        else
            pref[i] = pref[i - 1];
    }
    for(int i = n - 2; i >= 0; i--)
    {
        if(s[i] == 'E')
            suff[i] = suff[i + 1] + 1;
        else
            suff[i] = suff[i + 1];
    }
    int ans = 1e9;
    for(int i = 0; i < n; i++)
    {
        int cur = 0;
        if(i == 0)
            cur = suff[i + 1];
        else if(i == n - 1)
            cur = pref[i - 1];
        else
            cur = pref[i - 1] + suff[i + 1];
        ans = min(ans, cur);
    }

    cout << ans;

    return 0;
}


Measured memory_bytes: 2964
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ABC129A
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] input = Console.ReadLine().Split();
            int P = int.Parse(input[0]);
            int Q = int.Parse(input[1]);
            int R = int.Parse(input[2]);
            int SUM = P + Q + R;

            //一番大きいのはどれか調べて、変数maxに入れておく
            int max = Math.Max(P, Q);
            max = Math.Max(max, R);

            //SUM-maxが答えになる
            int ans = SUM - max;

            Console.WriteLine(ans);
        }
    }
}


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

long N, ans;

int main(void) {

    cin >> N;

    for (long i = 1; i <= N; i++) {
        long k = floor(N / i);
        ans += k * (k+1) * i / 2;
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3592
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define io ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
const int MAX = 1000001;

// array to store prime factors
int factor[MAX] = { 0 };


void generatePrimeFactors()
{
	factor[1] = 1;

	for (int i = 2; i < MAX; i++)
		factor[i] = i;

	for (int i = 4; i < MAX; i += 2)
		factor[i] = 2;

	
	for (int i = 3; i * i < MAX; i++) {
		
		if (factor[i] == i) {
			
			for (int j = i * i; j < MAX; j += i) {
				
				if (factor[j] == j)
					factor[j] = i;
			}
		}
	}
}


int calculateNoOFactors(int n)
{
	if (n == 1)
		return 1;

	int ans = 1;


	int dup = factor[n];

	
	int c = 1;

	
	int j = n / factor[n];


	while (j != 1) {
		
		if (factor[j] == dup)
			c += 1;

		
		else {
			dup = factor[j];
			ans = ans * (c + 1);
			c = 1;
		}

		
		j = j / factor[j];
	}

	
	ans = ans * (c + 1);

	return ans;
}

// Driver program to test above function
int32_t main()
{
    io;
	
	generatePrimeFactors();

  int fac[1000001],i;
  for(i=1;i<=1000000;i++)
  fac[i]=calculateNoOFactors(i);

  int n,ans=0;
  cin>>n;
  for(i=1;i<n;i++)
  {
    ans=ans+fac[n-i];
  }
  cout<<ans<<endl;




	return 0;
}


Measured memory_bytes: 19252
package main

import "fmt"

func main() {
	var n int
	fmt.Scan(&n)

	loop := true
	nums := make(map[int]int)
	nums[n]++
	for loop {
		if n%2 == 0 {
			n /= 2
		} else {
			n = n*3 + 1
		}
		nums[n]++

		if nums[n] > 1 {
			loop = false
		}
	}

	var count int
	for _, val := range nums {
		count += val
	}
	fmt.Print(count)
}


Measured memory_bytes: 640
#include <stdio.h>
//挿入ソート
//配列の要素を順番に出力
void trace(int A[],int N){
    int i;
    for(i = 0; i < N;i++){
        if(i > 0){
            printf(" ");//隣の要素の間に一つの空白を出力
        }
        printf("%d",A[i]);
    }
    printf("\n");
}

//挿入ソート
void insertionSort(int A[], int N){
    int j, i, v;
    //jは
    for(i = 1;i < N;i++){
        v = A[i];
        j = i - 1;
        while(j >= 0 && A[j] > v){
            A[j + 1] = A[j];//この行が意味わからん　わかった自分でかける自信がない
            j--;
        }
        A[j + 1] = v;
        trace(A, N);
    }
}

int main(){
    int N, i, j;
    int A[100];

    scanf("%d",&N);
    for(i = 0;i < N;i++){
        scanf("%d",&A[i]);
    }
    trace(A,N);
    insertionSort(A,N);
    return 0;
}


Measured memory_bytes: 2140
#include <bits/stdc++.h>
#define ref(i,n) for(int i=0;i<n;i++)
using namespace std;
#define INF 10000000

int main()
{
    double n;
    cin>>n;
    double k=n*n*n/27;
    cout<<setprecision(30) <<k;

    return 0;
}


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

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

  if (N.at(1) == N.at(2))
  {
    if (N.at(0) == N.at(1) || N.at(2) == N.at(3))
    {
      cout << "Yes" << endl;
      return 0;
    }
  }

  cout << "No" << endl;
}


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

using namespace std;

#define lp(i,n) for(int i = 0; i <n;i++)
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define MP make_pair
#define SZ(v) ((int)((v).size()))
typedef long long ll;

const ll MOD = 1e9 + 7;
const int OO = (int)1e6;
const int N = (int)1e7;

void init(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
}

int main() {
	#   ifdef LOCAL_PROJECT
        freopen("in.txt", "r", stdin);
    #   endif
    int n;
    vector<pair<int,int>>v;
    scanf("%d",&n);
    int x;
    for(int i=1;i<=n;i++){
        scanf("%d",&x);
        v.push_back({x,i});
    }
    sort(all(v));
    for(int i=0;i<n;i++){
        printf("%d ",v[i].second); 
    }
    return 0;
}

Measured memory_bytes: 1780
package main

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

var sc *bufio.Scanner

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func main() {
	sc = bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	k := nextInt()

	aArray := make([]int, k)
	for i := 0; i < k; i++ {
		aArray[i] = nextInt()
	}

	if aArray[k-1] != 2 {
		fmt.Println(-1)
		return
	}
	min := 2
	max := 3
	for i := k - 2; i >= 0; i-- {
		if aArray[i] > max {
			fmt.Println(-1)
			return
		}
		min = aArray[i] * (((min - 1) / aArray[i]) + 1)
		max = aArray[i]*((max/aArray[i])+1) - 1
		if min > max {
			fmt.Println(-1)
			return
		}
	}
	fmt.Println(min, max)
}


Measured memory_bytes: 3072
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		int n = Integer.parseInt(br.readLine());

		System.out.println((n / 2) * ((n + 1) / 2));
	}
}

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

using namespace std;

int main(void) {

  int n, k;
  cin >> n >> k;
  
  vector<int> sunuke(n);
  
  int tmp;
  
  for (int i = 0;i < k;i++) {
    int d;
    cin >> d;
    for (int j = 0;j < d;j++) {
      cin >> tmp;
      sunuke[tmp-1]++;
    }
  }
  
  int ans = 0;
  for (int i = 0;i < n;i++) {
    if (sunuke[i] == 0) ans++;
  }
  
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3592
#include<iostream>
#include<cstdlib>
#include<cstring>
#include<climits>
#include<vector>
#include<list>
#include<functional>
#include<algorithm>
#include<string>
#include<cmath>
#include<complex>
#include<set>
#include<map>
#include<stack>
#include<queue>
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) for(int i=0;i<(n);i++)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;

string s, t;

int memo[3001][3001];

string dp() {
	for (int i = 1;i <= s.size();i++) {
		for (int j = 1;j <= t.size();j++) {
			if (s[i - 1] == t[j - 1]) {
				memo[i][j] = memo[i - 1][j - 1] + 1;
			}
			else {
				memo[i][j] = max(memo[i - 1][j], memo[i][j - 1]);
			}
		}
	}
	string res;
	int i = s.size(), j = t.size();
	while (i >= 1 && j >= 1) {
		while (i >= 1 && j >= 1 && memo[i - 1][j] == memo[i][j]) i--;
		if (i >= 1) res.push_back(s[i - 1]);
		while (i >= 1 && j >= 1 && memo[i][j - 1] == memo[i][j]) j--;
		j--;
	}
	reverse(res.begin(), res.end());
	return res;
}

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

	cin >> s >> t;
	cout << dp() << "\n";

	return 0;
}

Measured memory_bytes: 35456
import sys
input = sys.stdin.readline
def main():
    N = int( input())
    A = list( map( int, input().split()))
    if sum(A)%(N*(N+1)//2) != 0:
        print("NO")
        return
    t = sum(A)//(N*(N+1)//2)
    d = [0]*N
    for i in range(N):
        d[i] = A[i] - A[i-1] - t
    for i in range(N):
        if d[i] > 0 or d[i]%N != 0:
            print("NO")
            return
    print("YES")
    
if __name__ == '__main__':
    main()


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

class UnionFindTree {
public:
  class Node {
  public:
    int parent, rank; 
  } node[16384];
  UnionFindTree(int n) {
    for(int i = 0; i < n; ++i) {
      node[i].parent = i;
      node[i].rank = 0;
    }
  }
};

template<typename T>
int find(T& uftree, int index) {
  int res = index;
  while( uftree.node[res].parent != res ) {
    res = uftree.node[res].parent;
  }
  int t = index;
  int t2;
  while( t != res ) {
    t2 = uftree.node[t].parent;
    uftree.node[t].parent = res;
    t = t2;
  }
  return res;
}

template<typename T>
void unite(T& uftree, int n1, int n2) {
  int p1 = find(uftree, n1);
  int p2 = find(uftree, n2);
  if( p1 == p2 ) return;
  if( uftree.node[p1].rank < uftree.node[p2].rank ) {
    uftree.node[p1].parent = p2;
  }
  else if( uftree.node[p1].rank == uftree.node[p2].rank ) {
    uftree.node[p1].parent = p2;
    uftree.node[p2].rank += 1;
  }
  else if( uftree.node[p1].rank > uftree.node[p2].rank ) {
    uftree.node[p2].parent = p1;
  }
  else {
    abort();
  }
}

template<typename T>
bool same(T& uftree, int n1, int n2) {
  int p1 = find(uftree, n1);
  int p2 = find(uftree, n2);
  return (p1 == p2);
}

int main() {
  int n, q;
  int com, x, y;
  scanf("%d %d", &n, &q);
  UnionFindTree uf(n);
  for(int i = 0; i < q; ++i) {
    scanf("%d %d %d", &com, &x, &y);
    if( com == 0 ) {
      unite(uf, x, y);
    }
    else if( com == 1 ) {
      printf("%d\n", same(uf, x, y));
    }
  }

  return 0;
}

Measured memory_bytes: 3284
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cstring>
#include <complex>
#include <stack>
#include <queue>
#include <unordered_map>
#include <map>
#define rep(i, a) for (int i = 0; i < (a); i++)
using namespace std;
using ll = long long;

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

    int count = 0;
    int i, j, k;
    for(i = a; i >= 0; i--){
        for(j = b; j >= 0; j--){
            k = (x - 500*i - 100*j) / 50;
            if(0 <= k && k <= c){
                count++;
            }
        }
    }

    cout << count << endl;
 }


Measured memory_bytes: 256
def CountingSort(A,k):
    ans=[0 for _ in range(len(A))]
    C=[0 for _ in range(k+1)]
    for i in range(len(A)):
        C[A[i]]+=1
    for i in range(1,k+1):
        C[i]=C[i]+C[i-1]
    for i in reversed(range(len(A))):
        ans[C[A[i]]-1]=A[i]
        C[A[i]]-=1
    return ans
    
n=int(input())
A=list(map(int,input().split()))
k=max(A)
ans=CountingSort(A,k)

print(' '.join(map(str,ans)))


Measured memory_bytes: 241920
//Atcoder 3
#include <cstring>
#include <iostream>
#include <algorithm>
using namespace std;
 
int num[30];
 
int main(){
	memset(num,0,sizeof(num));
	char tmp;
	int n,m;
	cin>>n>>m;
	for(int i=1;i<=n;i++)
	for(int j=1;j<=m;j++)
	cin>>tmp,num[tmp-'a']++;
	
	if(n%2==0&&m%2==0){//Å¼Å¼ 
		int cnt4=0;
		for(int i=0;i<26;i++){
			cnt4+=num[i]/4;num[i]%=4;
		}
		if(4*cnt4!=n*m) {cout<<"No"<<endl;return 0;}
	}
	else if((n*m)%2==1){//ÆæÆæ 
		int cnt1=0,cnt2=0,cnt4=0;
		for(int i=0;i<26;i++){
			cnt4+=num[i]/4;num[i]%=4;
			cnt2+=num[i]/2;num[i]%=2;
			cnt1+=num[i];
		}
		if(cnt1!=1||(2*cnt2+4*cnt4)!=(n*m-1)||(4*cnt4)<(n*m-1-2*(n/2+m/2))) 
		{cout<<"No"<<endl;return 0;}
	}
	else if((n*m)%2==0){//ÆæÅ¼
		int cnt2=0,cnt4=0; 
		for(int i=0;i<26;i++){
			cnt4+=num[i]/4;num[i]%=4;
			cnt2+=num[i]/2;num[i]%=2;
		}
		if((2*cnt2+4*cnt4)!=(n*m)||(4*cnt4<(m/2*2)*(n/2*2)))
		{cout<<"No"<<endl;return 0;}
	}
	
	cout<<"Yes"<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(void){
int N;
int a,b=0,i,j;
scanf("%d",&N);
for(i=1;i<=N;i++){
    a=0;
    for(j=1;j<i;j++){
        if(i%(2*j-1)==0){
            a++;
            if(a==8)b++;
        }
    }
   
}
printf("%d",b);

}

Measured memory_bytes: 128
using System;
using System.Collections;
class main{
	public static void Main(){
		int ct = 0;
		int[] x = new int[100000];
		int[] y = new int[100000];
		while (true)
		{
			string[] str = Console.ReadLine().Split(' ');
			x[ct] = int.Parse(str[0]);
			y[ct] = int.Parse(str[1]);
			if(x[ct] == 0 && y[ct] == 0) break;
			if (x[ct] > y[ct])
			{
				int tmp = x[ct];
				x[ct] = y[ct];
				y[ct] = tmp;
			}
			ct++;
		}
		for (int i = 0; i < ct; i++)
		{
			Console.WriteLine("{0} {1}", x[i], y[i]);
		}
	}
}

Measured memory_bytes: 10596
#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<cstring>
#include<functional>
#include<vector>
#include<math.h>
using namespace std;

int main(){
  int pA,pB,pC,x,y;
  cin>>pA>>pB>>pC>>x>>y;
  long long int money=pA*x+pB*y;
  long long int tmp;
  //まず枚数を決めて値段を考えよう
  // Aをa枚、Bをb枚、Cをc枚とするとx<=a+c/2 y<=b+c/2
  int xy_min=min(x,y);
  int xy_max=max(x,y);
  //int aとint bを動かすとTLEでしょう。。。
  //cの枚数を動かしましょう!!
  for(int c=0;c<=2*xy_max;c++){
     int a=x-c/2; //マイナスにもなりうる
     int b=y-c/2; //マイナスにもなりうる
    if(a<0) a=0;
    if(b<0) b=0;
     tmp=pA*a+pB*b+pC*c;
     money=min(money,tmp);
  }
  cout<<money<<endl;
}

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

using ll = long long;

int main(){
  ll a,b,c,d,k;
  cin >> a >> b >> c >> d;
  k = max(a*c,a*d);
  k = max(k,b*c);
  k = max(k,b*d);
  cout << k << endl;
}

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

using namespace std;
using ll = long long;
const ll MOD = 1000000007;
const ll LNF = __LONG_LONG_MAX__;

int main(){
    string S,T; cin >> S >> T;
    int out=10101010;
    for(int i=0;i<S.size()-T.size()+1;i++){
        int sum=0;
        for(int j=0;j<T.size();j++){
            if(S[i+j]!=T[j]) sum++;
        }
        if(out>sum) out=sum;
    }
    cout << out << endl;
    return 0;
}


Measured memory_bytes: 3600
#include<bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(),(x).end()
const long long mod = 1e9+7;
const int dx[4] = {0,1,0,-1};
const int dy[4] = {1,0,-1,0};
const int ddx[4] = {1,1,-1, -1};
const int ddy[4] = {1,-1,-1,1};
//////////////////////////////////

int main() {
    int n, m; cin >> n >> m;
    priority_queue<long long> pq;
    long long a;
    for(int i=0; i<n; i++) {
        cin >> a;
        pq.push(a);
    }
    for(int i=0; i<m; i++) {
        int tp = pq.top();
        pq.pop();
        pq.push(tp/2);
    }

    long long sum = 0;
    while(!pq.empty()) {
        sum += pq.top();
        pq.pop();
    }
    cout << sum << endl;


    return 0;
}

// EOF


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

#define int long long
#define forn(i, n) for (int i = 0; i < n; ++i)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((int) (x).size())


int32_t main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	string s, t; 
	cin >> s >> t;
	int a, b;
	cin >> a >> b;
	string u;
	cin >> u;
	if (u == s) a--;
	if (u == t) b--;
	cout << a << ' ' << b << endl;
	return 0;
}



Measured memory_bytes: 256
A, B = (int(i) for i in input().split())  
A_list = []
for i in range(8001):
    tmp = int(i*0.08)
    if tmp==A:
        A_list.append(i)
B_list = []
for i in range(10001):
    tmp = int(i*0.1)
    if tmp==B:
        B_list.append(i)
and_list =  set(A_list)&set(B_list)
try:
    print(min(and_list))
except:
    print(-1)

Measured memory_bytes: 3064
#include <iostream>
#include <cmath>
#include <cassert>
#include <vector>
#include <map>
#include <string>
#include <algorithm>
#include <numeric>
#include <queue>
#include <type_traits>
#include <fstream>

typedef long long ll;
const ll INF = (ll)1e18 + 1;
const ll MOD = 1e9 + 7;

template<typename Head> void print(Head head) { std::cout << head << std::endl; }
template<typename Head, typename... Tail> void print(Head head, Tail... tail)
{
  std::cout << head << " ";
  print(tail...);
}

struct UnionFind {
public:
  std::vector<ll> par;
  std::vector<ll> rank;
  std::vector<ll> size;
  std::vector<ll> diff_weight;

  UnionFind(ll N){
    par         = std::vector<ll>(N+1, 0LL);
    rank        = std::vector<ll>(N+1, 0LL);
    size        = std::vector<ll>(N+1, 1LL);
    diff_weight = std::vector<ll>(N+1, 0LL);
    for (ll i = 0; i <= N; i++) par[i] = i;
  }

  ll find(ll x){
    if (par[x] == x) return x;
    ll root = find(par[x]);
    diff_weight[x] += diff_weight[par[x]];
    par[x] = root;
    return root;
  }

  void unite(ll x, ll y, ll w) {
    w += get_weight(x);
    w -= get_weight(y);

    x = find(x);
    y = find(y);
    if (x == y) return;

    size[x] += size[y];
    size[y] = size[x];

    if (rank[x] < rank[y]) std::swap(x, y), w = -w;
    if (rank[x] == rank[y]) rank[x]++;

    par[y] = x;
    diff_weight[y] = w;
    //print(x, y, diff_weight[x], diff_weight[y]);

    return;
  }

  bool is_same(ll x, ll y){
    return find(x) == find(y);
  }

  ll get_size(ll x){
    return size[find(x)];
  }

  ll get_weight(ll x){
    find(x);
    return diff_weight[x];
  }

  ll get_diff(ll x, ll y){
    //print("diff", y, x, get_weight(y), get_weight(x));
    return get_weight(y) - get_weight(x);
  }
};

int main(int argc, char* argv[])
{
  //std::ifstream ifs("input.txt");
  //std::cin.rdbuf(ifs.rdbuf());

  ll N, M;
  std::cin >> N >> M;

  UnionFind info(N);

  std::string judge = "Yes";
  for (int i = 0; i < M; i++) {
    ll l, r, d;
    std::cin >> l >> r >> d;
    info.unite(l, r, d);
    //print("diff", l, r, info.get_diff(l, r));
    if (info.get_diff(l, r) != d) {
      judge = "No";
    }
  }

  std::cout << judge << std::endl;
  return 0;
}


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

int main(){

    string s;
    cin >>s;

    map<string,int> a;
    a.emplace("SUN",7);
    a.emplace("MON",6);
    a.emplace("TUE",5);
    a.emplace("WED",4);
    a.emplace("THU",3);
    a.emplace("FRI",2);
    a.emplace("SAT",1);
    
    auto ans =  a.find(s);
    cout << ans->second << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define double long double
#define rep(i,n) for(int i=0;i<(n);i++)
#define REP(i,n) for(int i=1;i<=(n);i++)
#define mod (ll)(1e9+7)
#define inf (ll)(3e18+7)
#define pi (double) acos(-1)
#define P pair<int,int>
#define PiP pair<int,pair<int,int>>
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
using namespace std;

int main() {
    ll n, k;
    cin >> n >> k;
    n = n - (n/k*k);
    cout << min(n, abs(n-k)) << endl;
}   

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

const int Max = 30;
const int NIL = -1;
struct Node
{
    int parent, left, right;
};
int n, id, l, r, root;
Node T[Max];
void preParse(int u)
{
    if(u==NIL) return;
    printf(" %d", u);
    preParse(T[u].left);
    preParse(T[u].right);
}
void inParse(int u)
{
    if(u==NIL) return;
    inParse(T[u].left);
    printf(" %d", u);
    inParse(T[u].right);
}
void postParse(int u)
{
    if(u==NIL) return;
    postParse(T[u].left);
    postParse(T[u].right);
    printf(" %d", u);
}
int main()
{
    scanf("%d", &n);
    for(int i=0; i<n; i++)
    {
        T[i].parent = T[i].left = T[i].right = NIL;
    }
    for(int i=0; i<n; i++)
    {
        scanf("%d %d %d", &id, &l, &r);
        T[id].left = l;
        T[id].right = r;
        if(l!=NIL)
            T[l].parent = id;
        if(r!=NIL)
            T[r].parent = id;
    }
    for(int i=0; i<n; i++)
    {
        if(T[i].parent==NIL)
        {
            root = i;
            break;
        }
    }
    printf("Preorder\n");
    preParse(root);
    printf("\n");
    printf("Inorder\n");
    inParse(root);
    printf("\n");
    printf("Postorder\n");
    postParse(root);
    printf("\n");
    return 0;
}



Measured memory_bytes: 3212
N,A,B,C=map(int,input().split())
mod=10**9+7

#factorial,facotiralの逆数を事前計算.
#N=10**5あたりまで有効

FACT=[1,1]
FACT_INV=[1,1]
for i in range(2,2*10**5+1):
    FACT.append(FACT[-1]*i%mod)
    FACT_INV.append(FACT_INV[-1]*pow(i,mod-2,mod)%mod)
    
def Combi(N,K):
    return FACT[N]*FACT_INV[N-K]*FACT_INV[K]%mod


#Aが勝つ場合

ANS=0
SUM=A+B
A_n=pow(A,N,mod)*pow(pow(SUM,mod-2,mod),N,mod)%mod
B_n=pow(B,N,mod)*pow(pow(SUM,mod-2,mod),N,mod)%mod
SUMINV=pow(SUM,mod-2,mod)

for i in range(N):
    ANS=(ANS+(A_n*pow(B,i,mod)+B_n*pow(A,i,mod))*Combi(N-1+i,i)*pow(SUMINV,i,mod)*(N+i))%mod

print(ANS*100*pow(100-C,mod-2,mod)%mod)


Measured memory_bytes: 18984
import java.util.*;

class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = Integer.parseInt(sc.next());
		int[] A = new int[N+1];
		int[] B = new int[N];
		for (int i=0;i<N+1;i++) {
			A[i] = Integer.parseInt(sc.next());
		}
		for (int i=0;i<N;i++) {
			B[i] = Integer.parseInt(sc.next());
		}
		long cnt = 0L;

		for (int i=0;i<N;i++) {
			if (A[i]>=B[i]) {
				cnt+=B[i];
			} else {
				cnt+=A[i];
				int tmp = B[i]-A[i];
				if (A[i+1]>=tmp) {
					A[i+1]-=tmp;
					cnt+=tmp;
				} else {
					cnt+=A[i+1];
					A[i+1]=0;
				}
			}
		}
		System.out.println(cnt);
	}
}

Measured memory_bytes: 51084
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(int i = a; i < (b); ++i)
#define rrep(i,a,b) for(int i = b; i --> (a);)
#define all(v) v.begin(),v.end()
#define trav(x,v) for(auto &x : v)
#define sz(v) (int)(v).size()
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pii;

int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	
	int h,w, d;
	cin >> h >> w >> d;
	rep(i,0,h) rep(j,0,w){
		int val =(i+j)/(d) % 2;
		int val2 =(w+i-j)/(d) % 2;
		if(val && val2) cout << "B";
		if(!val && val2) cout << "G";
		if(val && !val2) cout << "Y";
		if(!val && !val2) cout << "R";
		if(j+1==w) cout << endl;
	}
}

Measured memory_bytes: 512
#include <iostream>
#include <string>
using namespace std;
int main(){
  int N,k;
  string S;
  cin >> N >> S >> k;
  char C = S[k-1];
  for(int i = 0; i < N; i++){
    if (S[i] != C){
      S[i] = '*';
    }
  }
  cout << S << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <math.h>
#include <algorithm>
#include <numeric>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)

int main() {
    int N;
    cin >> N;
    vector<int> P(N);
    rep(i, N) cin >> P[i];

    int cnt = 1;
    int leftMin = P[0];
    rep(i, N) {
        if (P[i] < leftMin) {
            cnt++;
            leftMin = P[i];
        }
    }

    cout << cnt << endl;
}

Measured memory_bytes: 1024
#!/usr/bin/env python3
import sys
import queue

K = int(input())
q = queue.Queue()
for i in range(1,10):
    q.put(i)

i = 1
while True:
    r = q.get()
    if ( r % 10 != 0 ):
        q.put(10 * r + int(str(r)[-1]) -1)
    q.put(10*r + int(str(r)[-1]))
    if ( r % 10 != 9 ):
        q.put(10 * r + int(str(r)[-1]) + 1)

    if (i == K):
        print(r)
        break
    i += 1

Measured memory_bytes: 51284
#include <iostream>
#include <functional>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>

using namespace std;
typedef long long int ll;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)

ll gcd(ll a, ll b) { return b ? gcd(b,a%b) : a;}
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
typedef pair <ll,ll> P;
ll MOD = 1000000007;

int main()
{
    ll H, W;
    cin >> H >> W;
    rep(i, H) {
        string s;
        cin >> s;
        cout << s << endl;
        cout << s << endl;
    }
    return 0;
}


Measured memory_bytes: 256
import math
import bisect
import sys
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))
mod = 10**9 + 7
inf = float('inf')
a, b, x = LI()
ans = float(0)
c = float(0)
V = (a**2)*b

if x>(V/2):
    c = (V-x)/(V/2)
    ans = math.degrees(math.atan(b*c/a))

elif x==V/2:
    c = x/(V/2)
    ans = math.degrees(math.atan(a*c/b))
else:
    c = x/(V/2)
    ans = 90 - math.degrees(math.atan(a*c/b))


print(ans)

Measured memory_bytes: 3188
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
 
int main() {
	cin.tie(0);
    ios::sync_with_stdio(false);

    int a, b, c, d;
    cin >> a >> b >> c >> d;

    if(abs(a - c) <= d || (abs(a - b) <= d && abs(b - c) <= d)) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}

Measured memory_bytes: 256
#import math
#import bisect
#import numpy as np
#import itertools
#import copy
import sys

ipti = sys.stdin.readline
MOD = 10 ** 9 + 7
INF = float('INF')
sys.setrecursionlimit(10 ** 5)

def main():
    n = int(input())
    s = input()
    l = len(s)
    a = [0] * l

    for i in range(l):
        a[i] = (ord(s[i]) + n - 65) % 26 + 65
        a[i] = chr(a[i])

    print(''.join(a))


if __name__ == '__main__':
    main()

Measured memory_bytes: 3064
#include<iostream>
#include<algorithm>
#include<string>
using namespace std;
int main(){
	long long a,b;
	cin>>a>>b;
	if(a-b<-1||a-b>1){
		cout<<"0"<<endl;
		return 0;
	}
	long long ans=1;
	if(a==b)ans*=2;
	while(a>1)ans*=a,ans%=1000000007,a--;
	while(b>1)ans*=b,ans%=1000000007,b--;
	cout<<ans<<endl;
	return 0;
}


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

int main()
{
    int N;
    cin >> N;
    vector<int> L(N);
    for (int i = 0; i < N; i++) {
        cin >> L[i];
    }
    sort(L.begin(), L.end(), greater<int>());
    
    int sum = 0;
    for (int i = 1; i < L.size(); i++) {
        sum += L[i];
    }
    
    if (L[0] < sum) {
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
}

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

using namespace std;

typedef long long ll;
typedef pair<ll,ll> ii;
typedef vector<ll> vi;
typedef vector<ii> vii;
#define _ ios::sync_with_stdio(false),cin.tie(0),cout.tie(0);

#define sll(x) scanf("%I64d",&x)
#define sd(x)  scanf("%d",&x)
#define pll(x) printf("%I64d",x)
#define pd(x)  printf("%d",x)

#define clr(x) memset(x,0,sizeof x)
#define sf .second.first
#define ss .second.second
#define mid    ((l+r)>>1)
#define Pi acos(-1)
#define EPS 1e-12
#define MOD  1000000007
#define MOD1 1000000009
#define INF  1000000000

#define N 100005

ll n,w,a[200],v[200],dp[200][N];


int main()
{
    memset(dp,0,sizeof dp);
    cin >>n>>w;
    for(int i=0; i<n; i++)
            cin>>a[i]>>v[i];

        //cout<<dp[0][0]<<" "<<dp[0][1]<<" "<<dp[0][2]<<endl;
    for(int i=0;i<=n;i++){
        for(int j=0;j<=w;j++){
            if(j==0||i==0)
                dp[i][j]=0;
            else if(a[i-1]<=j)
                dp[i][j]=max(v[i-1]+dp[i-1][j-a[i-1]],dp[i-1][j]);
            else
                dp[i][j]=dp[i-1][j];
        }
    }


    cout<<dp[n][w]<<endl;
    return 0;
}


Measured memory_bytes: 156544
#include<bits/stdc++.h>
using namespace std;
int main(){
  string s; 
  int a=0;
  cin>>s;
  for(int i=0;i<s.size()/2;i++){
    if(s[i]!=s[s.size()-1-i])a++;
  }
  cout<<a<<endl;
}

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

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

  //a && b > 0
  if (a > 0 && b > 0){
    cout << "Positive" << endl;
    return 0;
  }
  //a && b or a or b == 0
  if (a == 0 || b == 0 || (a < 0 && b > 0)){
    cout << "Zero" << endl;
    return 0;
  }
  //a & b < 0
  if (a < 0 && b < 0){
    a = a*(-1);
    b = b*(-1);
    ll ab = a-b;
    if (ab%2 == 0){
      cout << "Negative" << endl;
      return 0;
    }
    cout << "Positive" << endl;
  }

  return 0;
}

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

int main()
{
  int64_t n;
  cin >> n;
  vector<pair<int64_t, int64_t>> v(n);

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

  sort(begin(v), end(v));

  string ans = "Yes";
  int64_t s = 0;
  for (auto&& e : v) {
    s += e.second;
    if (s > e.first) {
      ans = "No";
      break;
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 3328
#include <bits/stdc++.h>
#define int long long
#define P(x) {if (debug) cout << x << endl;}
#define H(x) P(#x << ": " << (x))
#define FR(i,a,b) for (int i=(a); i<(b); i++)
#define F(i,n) FR(i,0,n)
#define DR(i,a,b) for (int i=(b); i-->(a);)
#define D(i,n) DR(i,0,n)
#define S(s) (int)(s).size()
#define ALL(v) v.begin(), v.end()
#define MI(a,v) a = min(a,v)
#define MA(a,v) a = max(a,v)
#define V vector
#define pb push_back
#define mt make_tuple
using namespace std;
template<class T> ostream &operator<<(ostream &os, V<T> v) {
    F(i,S(v)) os<<(i?" ":"")<<v[i];
    return os;
}
const bool debug = 1;

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    int n = 4;
    V<int> a(n);
    F(i,n) cin>>a[i];
    sort(ALL(a));
    if (a == V<int>{1,4,7,9})
        cout<<"YES\n";
    else
        cout<<"NO\n";
}

Measured memory_bytes: 256
//// 快速幂 
//
//#include<iostream>
//#include<algorithm>
//#include<cstring>
//#include<string>
//#include<cstdio>
//#include<vector>
//#include<cmath>
//#include<deque>
//#include<queue>
//#include<stack>
//#include<map>
//#include<set>
//
//using namespace std;
//typedef long long int LL; 
//// 正常快速幂 
//int quick_pow(int a,int n) {
//	int ans = 1;
//	while(n) {
//		if(n & 1) ans *= a;   // 判断二进制的最后一位是不是 1  
//		a *= a; 
//		n >>= 1;              // 右移判断下一个数 
//	}	
//	return ans;
//}
//// 模下快速幂 
//LL quick_pow_mod(LL a,LL n,LL k) {
//	LL ans = 1;
//	while(n) {
//		if(n & 1) ans = (ans * a) % k; //(乘法会爆 int,所以需要先转换成 LL,之后通过模运算取到 int) 
//		a = (a * a) % k;
//		n >>= 1;
//	}
//	return ans;
//} 
//int main(void) {
//	LL a;LL n,k;
//	scanf("%lld%lld%lld",&a,&n,&k);
//	printf("%d\nl",quick_pow(a,n));
//	printf("%lld^%lld mod %lld=%lld\n",a,n,k,quick_pow_mod(a,n,k));
//	return 0;
//}  
#include<iostream>
#include<algorithm>
#include<cstdio>
using namespace std;
int main(void) {
	int n;
	while(cin>>n) {
		if(n <= 2) {
			printf("%d\n",0);
			continue;
		}
		if(n % 2 == 0) printf("%d\n",n / 2 - 1);
		else printf("%d\n",n / 2);
	}
	return 0;
}

Measured memory_bytes: 888
//#include <boost/multiprecision/cpp_dec_float.hpp>
//#include <boost/multiprecision/cpp_int.hpp>
#include <stdio.h>
#include <iostream>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <math.h>
#include <algorithm>
#include <bitset>
using namespace std;
//namespace mp = boost::multiprecision;
//using llll = mp::cpp_int;
// 仮数部が1024ビットの浮動小数点数型(TLEしたら小さくする)
//using Real = mp::number<mp::cpp_dec_float<1024>>;
using ll = long long;
const double EPS = 1e-10;
const ll MOD = 7+(1e+9);

int main(){
  ll n,ans=0;
  cin>>n;
  vector<ll>v(n,0);
  vector<ll>vv(1001,0);
  for(ll i=0;i<n;i++){
    cin>>v[i];
    vv[v[i]]++;
  }
  vector<ll>x(1001,0);
  for(ll i=0;i<1000;i++){
    x[i+1]=x[i]+vv[i+1];
  }
  for(ll i=0;i<n-1;i++){
    for(ll j=i+1;j<n;j++){
      ll l=1,r=1000;
      r=min(r,v[i]+v[j]-1);
      l=max(l,abs(v[i]-v[j])+1);
      ll k=0;
      if(l<=v[i]&&v[i]<=r) k--;
      if(l<=v[j]&&v[j]<=r) k--;
      ans+=(x[r]-x[l-1]+k);
    }
  }
  cout<<ans/3<<endl;
}


Measured memory_bytes: 256
#include  <iostream>
#include  <stdio.h>
#include <algorithm>
#include <map>
#include <math.h>

using namespace std;
#include <vector>
#define rep(i,n) for (ll i = 0; i < (n) ; i++)
#define INF 1e9
#define llINF 1e18
#define base10_4 10000      //1e4
#define base10_5 100000     //1e5
#define base10_6 1000000    //1e6
#define base10_7 10000000   //1e7
#define base10_8 100000000  //1e8
#define base10_9 1000000000 //1e9

#define MOD 1000000007
#define pb push_back
#define ll long long
#define ull unsigned long long
#define vint vector<int>
#define vll vector<ll>

//#include <stack>
//#include <queue>

string ans_Yes = "Yes"; 
string ans_No = "No"; 
string ans_yes = "yes"; 
string ans_no = "no"; 

vll A;
vll B;
vll Ai;
vll Bi;
ll C;
ll N;
ll M;
ll K;

ll ltmp;
string stmp;
double dtmp;

int main(){

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

    cin >> N;
    cin >> M;
    cin >> K;
 
    ll sumA=0;
    A.push_back(0);
    rep(ni,N){
        cin >> ltmp;
        sumA+=ltmp;
        A.push_back(sumA);
    }
    
    ll sumB=0;
    B.push_back(0);
    rep(ni,M){
        cin >> ltmp;
        sumB+=ltmp;
        B.push_back(sumB);
    }

    ll bi = B.size()-1;
    ll cnt = 0;
    rep(ai,A.size()){
        if(A[ai]>K) break;
        while(A[ai]+B[bi]>K){
            bi--;
        }
        if(cnt<ai+bi) cnt = ai + bi;

    }

    cout << cnt << endl;




}

Measured memory_bytes: 7936
#include<stdio.h>
int main(void){
  long int a,b,c;
  scanf("%ld %ld %ld",&a,&b,&c);
  
  if(c>a+b&&4*a*b<(c-a-b)*(c-a-b)){
    printf("Yes");
  }else{
    printf("No");
  }
  
  return 0;
  
}


Measured memory_bytes: 128
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<algorithm>
#include<vector>
#include<queue>
using namespace std;
int main(void){

	int a[100000];
	int b[100000];
	int c, d;
	int k;
	int n, m;
	int s, t;
	int x, y, z;


	scanf("%d", &n);

	for (int i = 0; i < n; i++){
		scanf("%d", &a[i]);
	}
	z = 0;
	c = 1;
	for (int i = 0; i < n-1; i++){
		if (z == 0){
			if (a[i + 1] - a[i]>0)z = 1;
			else if (a[i + 1] - a[i] < 0)z = 2;
			else z = 0;
		}
		else{
			if (a[i + 1] - a[i] > 0 && z != 1){
				c++;
				z = 0;
			}
			else if (a[i + 1] - a[i] < 0 && z != 2){
				c++;
				z = 0;
			}
		}
	}
	printf("%d\n", c);

	return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define F first
#define S second
#define endl "\n"
#define nl cout<<endl
#define pb push_back
#define f(i,a,b) for(ll i=a;i<b;i++)
#define Knucklehead ios_base::sync_with_stdio(false);cin.tie(NULL);
#define txti freopen("input.txt", "r", stdin);
#define txto freopen("output.txt", "w", stdout);
//#define mod 100000007

#define mat vector<vector<ll>>
mat cn(ll n, ll m){return vector< vector<ll> >(n, vector<ll>(m));}
bool compare(char &s1,char &s2){return s1 > s2;} 
bool sortmahstyle(const pair<ll,ll> &a,  const pair<ll,ll> &b) 
{ 
    if(a.second > b.second )
        return true;
    if( a.second==b.second && a.first > b.second )
       return true;
 
    return false;
 }
//me
ll const mod = 1e9+7;
ll const inf = 1e5+1;

vector<ll> nodes[inf];
ll vis[inf];



void solve()
{   
    ll n,k; cin >> n >> k;

    ll a[n]; f(i,0,n) cin >> a[i];

    f(i,k,n)
    {
    
        if(a[i]>a[i-k])
            cout << "Yes\n";
        else
            cout << "No\n";
        
    }
}
int main() {
Knucklehead 
/*
#ifndef ONLINE_JUDGE
freopen("input.txt", "r", stdin);
freopen("output.txt", "w", stdout);
#endif
/**/


        
        ll t;
        /**/t=1;
        /*/cin>>t;/**/
        while(t-->0){
            solve();
 
        }
 
 
 
 
    return 0;
}

Measured memory_bytes: 7468
import math
a = input()
b = int(a)
c = 1000
if len(a) < 4:
  print(c-b)
else:
  if a[-4] != '0':
    b = int(a[-3:])
    if b == 0:
      print(int(0))
    else:
      print(c-b)
  elif a[-3] != '0':
    b = int(a[-2:])
    print(c-b)
  elif a[-2] != '0':
    b = int(a[-1:])
    print(c-b)
  else:
    print(int(0))

Measured memory_bytes: 9208
class Die
  attr_accessor :front, :back, :top, :bottom, :left, :right
  def initialize
  @front, @back, @top, @bottom, @left, @right = 6.times.map{0}
  end
  def check?
    return false if [@front, @back, @top, @bottom, @left, @right].any?(&:zero?)
    return false unless [@front + @back, @left + @right, @top + @bottom].all?{|v| v == 7}
    true
  end
  def rotate(direction)
    case direction
      when :top
        @top, @front, @bottom, @back = @front, @bottom, @back, @top
      when :bottom
        @top, @front, @bottom, @back = @back, @top, @front, @bottom
      when :clockwise
        @left, @front, @right, @back = @front, @right, @back, @left
      when :counterclockwise
        @left, @front, @right, @back = @back, @left, @front, @right
    end
  end
end

@net = Array.new
@die = Die.new
def dfs(i, j)
  if (0 < j) && (@net[i][j - 1] != 0)
    @die.rotate(:counterclockwise)
    @die.front = @net[i][j - 1]
    @net[i][j - 1] = 0
    dfs(i, j - 1)
    @die.rotate(:clockwise)
  end
  if (j + 1 < 5) && (@net[i][j + 1] != 0)
    @die.rotate(:clockwise)
    @die.front = @net[i][j + 1]
    @net[i][j + 1] = 0
    dfs(i, j + 1)
    @die.rotate(:counterclockwise)
  end
  if (i + 1 < 5) && (@net[i + 1][j] != 0)
    @die.rotate(:top)
    @die.front = @net[i + 1][j]
    @net[i + 1][j] = 0
    dfs(i + 1, j)
    @die.rotate(:bottom)
  end
end

gets.to_i.times do
  @die = Die.new
  @net = Array.new
  count = Hash.new{0}
  5.times do @net << gets.split.map(&:to_i) end
  5.times do |i|
    5.times do |j|
      v = @net[i][j]
      next if v.zero?
      count[v] += 1
    end
  end
  unless (1..6).all?{|n| count[n] == 1} # 1-6が不揃い
    puts "false"
    next
  end
  5.times do |i|
    5.times do |j|
      next if @net[i][j].zero?
      @die.front = @net[i][j]
      @net[i][j] = 0
      dfs(i, j)
    end
  end
  puts @die.check? ? "true" : "false"
end

Measured memory_bytes: 6148
a,b=map(int,input().split())

def gcd(a, b):
    while b:
        a, b = b, a % b
    return a

s=gcd(a,b)
x=[]
while s%2==0:
    s//=2
    x.append(2)
f=3
while f*f<=s:
    if s%f==0:
        s//=f
        x.append(f)
    else:
        f+=2
if s!=1:
    x.append(s)
      
print(len(set(x))+1)

Measured memory_bytes: 3064
n=int(input())
a=list(map(int,input().split()))
ans=-10**18
a_minus=[-x for x in a]
af=a[:n]
ae=a_minus[2*n:]
f_sum=[sum(af)]
e_sum=[sum(ae)]
from heapq import heapify,heappop,heappush
heapify(af)
for aa in a[n:2*n]:
  heappush(af,aa)
  t=heappop(af)
  f_sum.append(f_sum[-1]+aa-t)
heapify(ae)
for aa in reversed(a[n:2*n]):
  heappush(ae,-aa)
  t=heappop(ae)
  e_sum.append(e_sum[-1]-aa-t)
for f,e in zip(f_sum,reversed(e_sum)):
  ans=max(ans,f+e)
print(ans)


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

#define bit(x) (1 << (x))
#define For(i, j, k) for (int i = j; i <= k; i++)
#define Forr(i, j, k) for (int i = j; i >= k; i--)

const int N = 21;

int buffer[1 << N][N];
int n, k;

int& dp(int l, int ls, int r, int rs) {
	return buffer[bit(l + r) | (ls << r) | rs][r];
}

char S[1 << N];

int main() {

	scanf("%d%d", &n, &k);
	For(i, 0, n) {
		scanf("%s", S);
		For(j, 0, bit(i) - 1) if (S[j] == '1') 
			dp(0, 0, i, j) = 1;
	}

	Forr(r, n, 1) For(rs, 0, bit(r) - 1) {	
		int p1 = -1, p0 = -1;
		Forr(i, r - 1, 0) if (rs & bit(i)) { p1 = i; break; }
		Forr(i, r - 1, 0) if (!(rs & bit(i))) { p0 = i; break; }

		For(l, 0, n - r) For(ls, 0, bit(l) - 1) {
			int w = dp(l, ls, r, rs);
			if (!w) continue;
			if (p1 != -1) dp(l + 1, ls << 1 | 1, p1, rs & (bit(p1) - 1)) += w;
			if (p0 != -1) dp(l + 1, ls << 1, p0, rs & (bit(p0) - 1)) += w;
			dp(l, ls, 0, 0) += w;
		}
	}

	Forr(l, n, 0) For(st, 0, bit(l) - 1)
		if (dp(l, st, 0, 0) >= k) {
			Forr(j, l - 1, 0) putchar(st & bit(j) ? '1' : '0'); 
			puts("");
			return 0;
		}

	return 0;
}

Measured memory_bytes: 173440
#include <iostream>
#include <algorithm>
#include <string>
#include <math.h>
#include <cstdint>
#include <map>
 
using namespace std;
typedef long long ll;

ll ans,mx,sum;
int main(){
	ll n,k,q;
	cin>>n>>k>>q;
	ll a[q];
	ll b[n];
	for(int i=0; i<q; i++){
		cin>>a[i];
	}
	for(int i=0; i<n; i++){
		b[i]=k;
		b[i] -= q;
	}
	for(int i =0; i<q; i++){
		b[a[i] -1]++;
	}
	for(int i = 0; i<n; i++){
		if(b[i] > 0) cout<<"Yes"<<endl;
		else cout<<"No"<<endl;
	}
}

Measured memory_bytes: 2176
X = input()

T = 0
S = 0
TS = True
for x in X:
    if x=="T":
        if TS:
            T += 1
        else:
            S -= 1
            if S==0:
                TS = True
    else:
        if TS: TS = False
        S += 1
    
print(T+S)

Measured memory_bytes: 3500
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define ll long long
#define pb(a) push_back(a)
#define INF 999999999
using namespace std;

int main(){
  int n,m,ans = 0;
  cin >> n >> m;
  int x[m],sa[m-1];
  REP(i,m) {
    cin >> x[i];
  }
  SORT(x,m)
  REP(i,m-1) {
    sa[i] = x[i+1] - x[i];
  }
  SORT(sa,m-1)
  REP(i,m-n) {
    ans+=sa[i];
  }
  cout << ans;
} 

Measured memory_bytes: 1024
#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdint>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <regex>
#include <set>
#include <sstream>
#include <string>
#include <tuple>
#include <utility>
#include <vector>

using namespace std;
using ll = long long;

#define EPS (1e-7)

int main() {
  ll X, A;
  cin >> X >> A;
  const ll ans = (X < A) ? 0 : 10;

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


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  string s;
  cin >> s;
  int i;
  if(s == "zyxwvutsrqponmlkjihgfedcba")cout << -1 << endl;
  else{
    if(s.length() <26){
      vector<bool>alp(26,false);
      for(i=0;i<s.length();i++){
        alp[(int)(s[i]-'a')]=true;
      }
      for(i=0;i<26;i++){
        if(alp[i]==false){
          s += (char)(i+'a');
          break;
        }
      }

      cout << s << endl;
    }else{
      string ssub = s;
      next_permutation(s.begin(),s.end());
      for(i=0;i<26;i++){
        if(s[i] == ssub[i])cout<<s[i];
        else{
           cout << s[i] << endl;
           break;
        }

      }
    }
  }
}


Measured memory_bytes: 256
#include<stdio.h>
int main(void) {
  int A, B, C;
  scanf("%d %d %d", &A, &B, &C);
  int n;
  n = A;
  A = B;
  B = n;
  n = A;
  A = C;
  C = n;
  printf("%d %d %d\n", A, B, C);
  return 0;
}

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

#ifdef DEBUG
#include "../.inc/debug.hpp"
#else
#define debug(...) 42
#define rdfile(...) 42
#endif

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    // rdfile("_input.txt");

    int N;
    cin >> N;
    vector<int> p(N);
    for (int i=0; i<N; ++i) cin >> p[i];

    vector<int> p2 = p;
    sort(p.begin(), p.end());

    int diff = 0;
    for (int i=0; i<N; ++i) {
        if (p[i] != p2[i]) diff++;
    }

    if (diff <= 2) {
        cout << "YES" << endl;
    } else {
        cout << "NO" << endl;
    }

    return 0;
}

Measured memory_bytes: 256
n = int(input())
from itertools import product
l = list(range(1, 100+1))
f = [0 for _ in range(11000)]
def func(x,y,z):
    return x**2 + y**2 + z**2 + x*y + y*z + z*x
for x, y, z in product(l, l, l):
    v = func(x,y,z)
    if v <= n:
        f[v] += 1
for ans in f[1:n+1]:
    print(ans)


Measured memory_bytes: 69272
#include <bits/stdc++.h>
using namespace std;
#define rep(i,cc,n) for(int i=cc;i<n;++i)
#define lrep(i,cc,n) for(long long i=cc;i<n;++i)
#define rrep(i,cc,n) for(long i=cc;i>n;--i)
using ll = long long;

int main() {
    int n, count = 1;
    cin >> n;
    rep(i, 0, n){
        int c;
        cin >> c;
        if(c % 2 == 1) count *= 1;
        else count *= 2;
    }
    cout << pow(3, n) - count << endl; 
}

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

int main(){
  int K,S;
  cin>>K>>S;
  int64_t l=0;
  for(int i=0;i<=K && i<=S;i++)
    for(int j=i;S-(i+j)>=j;j++){
      int k=S-(i+j);
      if(k>K)
        continue;
      if(i==j && j==k)
        l++;
      else if(i==j||j==k||k==i)
        l+=3;
      else
        l+=6;
    }
  cout<<l<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long 
using namespace std;
int a[200005];
int main()
{
	int n;cin>>n;
	for(int i=1;i<=n;++i)
	cin>>a[i];
	sort(a+1,a+n+1);
	ll sum=a[n];int num=n-2,t=0,x=n-1;
	while(num--)
	{
		sum+=a[x];
		t++;
		if(t==2)
		{
			t=0;
			x--;
		}
	}
	cout<<sum;
 } 

Measured memory_bytes: 4388