akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
#define ll long long
#define _GLIBCXX_DEBUG
const ll MOD = 1000000007;
const int MAX = 510000;

int main() {
  vector<int> a(3), b(3);
  for (int i=0; i<3; i++) cin >> a[i] >> b[i];
  vector<int> count(4, 0); // 各整数の登場回数
  for (int i=1; i<=4; i++) {
    for (int j=0; j<3; j++) {
      if (i==a[j]) count[i-1]++;
    }
  }
  for (int i=1; i<=4; i++) {
    for (int j=0; j<3; j++) {
      if (i==b[j]) count[i-1]++;
    }
  }
  sort(count.begin(), count.end());
  if (count[3]<3) cout << "YES" << endl;
  else cout << "NO" << endl;
}

Measured memory_bytes: 256
/*
ID: tohoast1
TASK: gymnastics
LANG: C++
*/
#include <bits/stdc++.h>
#define speedup ios_base::sync_with_stdio(NULL)
#define fin freopen("allcodefs.in", "r", stdin)
#define fout freopen("allcodefs.out", "w", stdout)
#define FILENAME
#define PUBG push_back
#define p_b pop_back
#define mp make_pair
#define fi first
#define se second
#define cls clear
#define INF const int ci = 1e6 + 100
#define K_INF 1e9 + 7
#define time cerr << "\nTime elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n"
#define MIN_INT -999999999
#define MOD 1000000007
#define d109 1000000000
#define basay break
#define bmbr exit(0)

using namespace std;
typedef long long LL;
typedef long L;
typedef unsigned long long ULL;
typedef unsigned long UL;
typedef string STR;
int N, san, h, a;

int main() {
    #ifdef FILENAMEs
        fin;
        fout;
    #endif // FILENAME
    cin >> h >> N;
    while (N --) {
        cin >> a;
        san += a;
    }
    (san >= h) ? cout << "Yes" : cout << "No";
    ///time;
    return 0;
}


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

int main() {

	int n; cin >> n;
	string s; cin >> s;
	int w_cnt = 0;
	int r_cnt = 0;
	for (int i = 0; i < n; i++) {
		if (s[i] == 'W') w_cnt++;
		else r_cnt++;
	}
	string t = "";
	for (int i = 0; i < r_cnt; i++) t += "R";
	for (int i = 0; i < w_cnt; i++) t += "W";
	int diff_w_cnt = 0;
	int diff_r_cnt = 0;
	for (int i = 0; i < n; i++) {
		if (s[i] == 'R' && t[i] =='W') {
			diff_r_cnt++;
		}
		else if (s[i] == 'W' && t[i] == 'R') {
			diff_w_cnt++;
		}
	}
	int ans = 0;
	ans += min(diff_r_cnt, diff_w_cnt);
	ans += abs(diff_r_cnt - diff_w_cnt);
	cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3920
#include<stdio.h>

int main(void){
    int i,j,k,count=0;
    long int x;

    scanf("%ld",&x);

    for(i=x;i<100004;i++){
        for(j=2;j<x/2;j++){
            if(x%j==0){
                count++;
            }
        }
        if(count>0){
            x++;
            count=0;
        }
        else{
            break;
        }
    }

    printf("%ld",x);

    return 0;
}


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

int main() {
  
  int H, W;
  cin >> H >> W;
  
  
  for ( int i=0; i<W+2 ;i++) {
    cout << "#";
  }
  
  cout << endl;
  
  
  for ( int l=0; l<H; l++) {
    
    string P;
    cin >> P;
    
    
    cout << "#";
  
    vector<string> vec(W);
    
    for ( int i=0; i<W ;i++) {
      
     vec.at(i) = P.at(i);
      
    }
    
    for ( int i=0; i<W ;i++) {
      
      cout << vec.at(i);
      
    }
    
    
    
    cout << "#" << endl;
  
  
  }
  
  
  for ( int i=0; i<W+2 ;i++) {
    cout << "#";
  }
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <string>
#include <algorithm>
#include <map>
#include <vector>

#define mem(x) memset(x,0,sizeof(x))

using namespace std;

typedef long long ll;

const int INF = 0x3f3f3f3f;
const int NINF = 0xc0c0c0c0;

int main()
{
    int n, l, r, sum = 0;
    cin >> n;
    for(int i = 0; i < n; i++){
        cin >> l >> r;
        sum += r - l + 1;
    }
    cout << sum << endl;
    return 0;
}


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

#define MP make_pair
#define FF first
#define SS second
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pie;
const int MOD = 1e9 + 7;
const int INF = 2e9;
const ll LINF = 4e18;
const ll delta = 96181;

struct node {
	int v;
	int d;
	int c;
};

const int N = 1e5 + 20;
vector<int> G[N];
vector<node> Q;
int n, m, ans[N], q;
bool mark[N][11];

void go(int v, int d, int c) {
	if (mark[v][d] || d < 0) return ;
	mark[v][d] = 1;
	if (d == 0)
		ans[v] = c;
	go(v, d - 1, c);
	for (int u : G[v])
		go(u, d - 1, c);
}

int main() {
	ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	cin >> n >> m;
	for (int i = 0, v, u; i < m; i++) {
		cin >> v >> u;
		G[v].push_back(u);
		G[u].push_back(v);
	}
	cin >> q;
	for (int i = 0, v, d, c; i < q; i++) {
		cin >> v >> d >> c;
		Q.push_back({v, d, c});
	}	
	for (int i = Q.size() - 1; i >= 0; i--)
		go(Q[i].v, Q[i].d, Q[i].c);
	for (int i = 1; i <= n; i++)
		cout << ans[i] << endl;
}



Measured memory_bytes: 9584
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <utility>
#include <numeric>
using namespace std;
//変数デバッグ
#define DEB(variable) cout << #variable << '=' << variable << endl

//for簡易表記(引数ミス防止)
#define FOR(LoopVariable,numberOFbegin,numberOFend) for (int LoopVariable = (numberOFbegin); (LoopVariable) < (numberOFend); (LoopVariable)++)
#define REP(LoopVariable,numberOFend) for(int LoopVariable = 0;(LoopVariable)<(numberOFend);LoopVariable++)


int main(){

    int a,b;
    cin>>a>>b;
    int dif=b-a;
    cout<<((dif/2.0)*(dif+1))-b<<endl;

    return 0;
}

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

int main()
{
	int X;
	cin >> X;
	/*
	while(X >= 0)
	{
		int shita2 = X - X/100*100;
		if (shita2 >= 5)
		{
			X -= 105;
		}
		else if (shita2 > 0)
		{
			X -= (100 + shita2);
		}
		else
		{
			cout << "1" << endl;
			return 0;
		}
	}
	cout << "0" << endl;
	*/
	int shita2 = X - X/100*100;
	int a = (shita2 + 4) / 5;
	if (a <= X/100)
	{
		cout << "1" << endl;
	}
	else
	{
		cout << "0" << endl;
	}
	return 0;
}

Measured memory_bytes: 256
s = input()
for l in s:
	if l == "N":
		if "S" not in s:
			print("No")
			break
	if l == "S":
		if "N" not in s:
			print("No")
			break
	if l == "E":
		if "W" not in s:
			print("No")
			break
	if l == "W":
		if "E" not in s:
			print("No")
			break
else:
	print("Yes")

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

int main() {
 string S;
 cin >> S;
  
 //9行目の解説　S[0] - '0'の意味は(1文字目)-(0という文字の文字コード)=(数)
 int A = (S[0] - '0') * 10 + (S[1] - '0');
 int B = (S[2] - '0') * 10 + (S[3] - '0');
 
 bool YYMM = (1 <= B && B <= 12);
 bool MMYY = (1 <= A && A <= 12);
   
 if(YYMM){
  if(MMYY) puts("AMBIGUOUS");
  else puts("YYMM");
  }
  else {
  if(MMYY) puts("MMYY");
  else puts("NA");
  }
}


Measured memory_bytes: 384
#include<iostream>
#include <bits/stdc++.h>
//1000000000000223
#define ll long long
#define ld long double
#define IO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
using namespace std;
int dp[100002], k;
queue<int> q;
int main()
{
    IO
    cin>>k;
    for(int i=0; i<=k; i++)
        dp[i]=k;
    for(int i=1; i<=9; i++)
        q.push(i), dp[i]=i;
    while(!q.empty())
    {
        int x=q.front();
        q.pop();
        for(int i=0; i<=9; i++)
        {
            int cur=(x*10+i)%k;
            if(dp[cur]>dp[x]+i)
                dp[cur]=dp[x]+i, q.push(cur);
        }
    }
    cout<<dp[0];
    return 0;
}


Measured memory_bytes: 2176
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>

using namespace std;

int main(){
    int N, R;
    cin >> N >> R;
    if(N >= 10){
        cout << R << endl;
    }else{
        int res = R + (100 * (10 - N));
        cout << res << endl;
    }
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
#define ll int64_t

int main() {
	ios_base::sync_with_stdio(0);cin.tie(0);
	int n,sum=0;
	cin>>n;
	vector<int> a(n);
	for(int& x:a){
		cin>>x;
		sum+=x;
	}
	if(sum%10==0){
		sort(a.begin(),a.end());
		for(int i=0;i<n;++i)
			if(a[i]%10){
				sum-=a[i];
				break;
			}
	}
	cout<<(sum%10==0?0:sum)<<'\n';
}



Measured memory_bytes: 3668
using System;

namespace _200113
{
    class Class1
    {
        static void Main(string[] args)
        {
            var _N = int.Parse(Console.ReadLine());
            var _S = Console.ReadLine();
            char[] ch = _S.ToCharArray();

            int ans = 1;
            for(int i = 0; i < _N-1; i++)
            {
                if (ch[i] != ch[i + 1])
                {
                    ans++;
                }
            }
            Console.WriteLine(ans);
        }
    }
}

Measured memory_bytes: 11488
#include<iostream>
using namespace std;
#define MAX 100000

int parent(int i) { return i / 2; }
int left(int i) { return 2 * i; }
int right(int i) { return 2 * i + 1; }

int main() {
	int H, i, A[MAX + 1];

	cin >> H;
	for (i = 1; i <= H; i++) cin >> A[i];

	for ( i = 1; i <= H; i++)
	{
		cout << "node " << i << ": key = " << A[i] << ", ";
		if (parent(i) >= 1) cout << "parent key = " << A[parent(i)] << ", ";
		if (left(i) <= H) cout << "left key = " << A[left(i)] << ", ";
		if (right(i) <= H) cout << "right key = " << A[right(i)] << ", ";
		cout << endl;
	}
	return 0;
}

Measured memory_bytes: 3116
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;
char upperCase(char str)
{
 
    if('a'<=str&&str<='z')
    {str=str+('A'-'a');}
  
  return str;
}
int main() {

char a;
cin>>a;
if(a==upperCase(a))cout<<"A"<<endl;
else cout<<"a"<<endl;



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

Measured memory_bytes: 3600
#include <iostream>
#include <vector>
#include <bitset>
using namespace std;

int main() {
    int a, b, c, d;
    int s;
    cin >> s;
    a = s / 1000;
    b = s / 100 % 10;
    c = s / 10 % 10;
    d = s % 10;
    for (int i = 0; i < (1 << 3); i++) {
        int sum = a;
        bitset<3> bit(i);
        sum += bit[0] ? b : -b;
        sum += bit[1] ? c : -c;
        sum += bit[2] ? d : -d;
        if (sum == 7) {
            cout << a << (bit[0] ? "+" : "-");
            cout << b << (bit[1] ? "+" : "-");
            cout << c << (bit[2] ? "+" : "-");
            cout << d << "=7" << endl;
            return 0;
        }
    }
}

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

int main() {
 long long A, B, C ;
  cin >> A >> B >> C;

  if (A <= C && B<=C) {
    cout << C *10 +B+A  << endl;
  }
  
 else if (A<=B&&C<=B){
     cout << B*10 +A+C << endl;}
else{
   cout << A*10+B+C << endl;
}
}

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

using namespace std;

int main(){
	int n;	cin>>n;
	while(n--){
		string s,m;	cin>>s>>m;
		int len=m.length();
		for(int i=s.length()-1;i>=0;i--){
			if     (s[i]=='J')	rotate(m.begin(),m.begin()+len-1,m.end());
			else if(s[i]=='C')	rotate(m.begin(),m.begin()+1,m.end());
			else if(s[i]=='E'){
				if(len%2==0)	m=m.substr(len/2)+m.substr(0,len/2);
				else			m=m.substr(len/2+1)+m[len/2]+m.substr(0,len/2);
			}
			else if(s[i]=='A')	reverse(m.begin(),m.end());
			else if(s[i]=='P'){
				for(int j=0;j<len;j++){
					if(isdigit(m[j]))	m[j]=(m[j]-'0'+9)%10+'0';
				}
			}
			else if(s[i]=='M'){
				for(int j=0;j<len;j++){
					if(isdigit(m[j]))	m[j]=(m[j]-'0'+1)%10+'0';
				}
			}
		}
		cout<<m<<endl;
	}

	return 0;
}

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

int main() {
  
  for (int i = 0; ; i++) {
    int x, y;
    cin >> x >> y;
    if (x == 0 && y == 0) {
      break;
    } else if (x < y) {
      cout << x << ' ' << y << endl;
    } else {
      cout << y << ' ' << x << endl;
      
    }
  }
 
}


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

int main() {
  
  string S;
  string s;
  string sr;
  string a;
  string ar;
  string b;
  string br;
  
  cin >> S;
  
  for(int i = 0; i <= S.size()-1; i++){
    s.push_back(S[i]);
  }
  
  for(int i = S.size()-1; i >= 0; i--){
    sr.push_back(S[i]);
  }
  
  for(int i = 0; i <= (S.size()-1)/2-1; i++){
    a.push_back(S[i]);
  }
  
  for(int i = (S.size()-1)/2-1; i >= 0; i--){
    ar.push_back(S[i]);
  }
  
  for(int i = (S.size()+3)/2-1; i <= S.size()-1; i++){
    b.push_back(S[i]);
  }

  for(int i = S.size()-1; i >= (S.size()+3)/2-1; i--){
    br.push_back(S[i]);
  }
  
  if(!s.compare(sr) && !a.compare(ar) && !b.compare(br)){
    cout << "Yes";
  }else{
    cout << "No";
  }

  return 0;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<int(n);++i)
#define all(a) (a).begin(),(a).end()
typedef long long ll;
#define rep1(i,n) for(int i=1;i<=int(n);++i)
#define lb(s,x) (lower_bound(all(s),x)-s.begin())
#define ub(s,x) (upper_bound(all(s),x)-s.begin())
#define uniq(a) a.erase(unique(all(a)),a.end())
#define bit(k) (1LL<<(k))
const int INF = 1e9;

#define debug(x) cerr<<(#x)<<": "<<(x)<<endl
template<class T,class U>
ostream& operator<<(ostream& o, const pair<T,U> &p){
    o<<"("<<p.first<<", "<<p.second<<")";
    return o;
}
#define print(v) { cerr<<#v<<": [ "; for(auto _ : v) cerr<<_<<", "; cerr<<"]"<<endl; }


int main(void){
    int a,p;
    cin >> a >> p;
    cout << (a*3+p)/2 << endl;
    return 0;
}


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

int main(){
    //input notation
    long long N;
    vector<long long> A;
    long long i, j;
    for(i = 0; i <= 15; i++){
        A.push_back(0);
    }
    vector<long long> zero;
    for(j = 0; j <= 15; j++){
        zero.push_back(0);
    }
    vector<vector <long long>> x, y;
    for(i = 0; i <= 15; i++){
        x.push_back(zero);
        y.push_back(zero);
    }

    //input
    cin >> N;
    for(i = 1; i <= N; i++){
        cin >> A[i];
        for(j = 1; j <= A[i]; j++){
            cin >> x[i][j] >> y[i][j];
        }
    }

    //bit
    long long k, nibeki = 1, true_sum, true_num = 0;
    bool zeus;
    vector<long long> true_man;
    for(i = 1; i <= N; i++){
        nibeki *= 2;
    }
    for(i = 0; i <= N; i++){
        true_man.push_back(0);
    }
    for(k = 1; k < nibeki; k++){
        zeus = 1;
        for(i = 1; i <= N; i++){
            true_man[i] = (k >> (i-1)) % 2;
        }
        for(i = 1; i <= N; i++){
            if(true_man[i]){
                for(j = 1; j <= A[i]; j++){
                    if(true_man[x[i][j]] != y[i][j]){
                        zeus = 0;
                    }
                }
            }
        }
        if(zeus){
            true_sum = 0;
            for(i = 1; i <= N; i++){
                true_sum += true_man[i];
            }
            if(true_num < true_sum){
                true_num = true_sum;
            }
        }
    }
    cout << true_num << endl;
    system("pause");
    return 0;
}

Measured memory_bytes: 504
#define _CRT_SECURE_NO_WARNINGS
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <vector>
#include <algorithm>
#include <functional>
#include <ccomplex>
#include <unordered_map>
#include <cstring>
#include <iostream>
#include <numeric>

using namespace std;
#define MAX 100000

int main(){
    char n[3];

    cin >> n[0] >> n[1] >> n[2];

    for (int i = 0; i < 3; i++){
        if ('1' == n[i]){
            n[i] = '9';
        }
        else if ('9' == n[i]){
            n[i] = '1';
        }
    }
    cout << n[0] << n[1] << n[2] << "\n";

    return 0;
}

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

int dsum(int n) {
    int sum = 0;
    while (n) {
        sum += n % 10;
        n /= 10;
    }
    return sum;
}
int main() {
    int A, B, N;
    int smin = 2000000;
    cin >> N;
    for (A = 1; A <= N/2; A++) {
        B = N - A;
        smin = min(dsum(A) + dsum(B), smin);
    }
    cout << smin;
}

Measured memory_bytes: 256
class dice:
    def __init__(self, f0, f1, f2, f3, f4, f5):
        self.dice_num = [f0, f1, f2, f3, f4, f5]

    def roll_dice(self, command):
        for i in command:
            if i == 'N':
                tmp = self.dice_num[0]
                self.dice_num[0] = self.dice_num[1]
                self.dice_num[1] = self.dice_num[5]
                self.dice_num[5] = self.dice_num[4]
                self.dice_num[4] = tmp

            if i == 'S':
                tmp = self.dice_num[0]
                self.dice_num[0] = self.dice_num[4]
                self.dice_num[4] = self.dice_num[5]
                self.dice_num[5] = self.dice_num[1]
                self.dice_num[1] = tmp

            if i == 'E':
                tmp = self.dice_num[0]
                self.dice_num[0] = self.dice_num[3]
                self.dice_num[3] = self.dice_num[5]
                self.dice_num[5] = self.dice_num[2]
                self.dice_num[2] = tmp

            if i == 'W':
                tmp = self.dice_num[0]
                self.dice_num[0] = self.dice_num[2]
                self.dice_num[2] = self.dice_num[5]
                self.dice_num[5] = self.dice_num[3]
                self.dice_num[3] = tmp

    def print_topface(self):
        print(self.dice_num[0])

    def turn_clockwise(self):
        tmp = self.dice_num[1]
        self.dice_num[1] = self.dice_num[2]
        self.dice_num[2] = self.dice_num[4]
        self.dice_num[4] = self.dice_num[3]
        self.dice_num[3] = tmp

    def check_same_dice(self, dice2):
        for i in range(4):
            self.roll_dice('W')
            for j in range(4):
                self.turn_clockwise()
                if self.dice_num == dice2.dice_num:
                    return True
        for i in range(4):
            self.roll_dice('N')
            for j in range(4):
                self.turn_clockwise()
                if self.dice_num == dice2.dice_num:
                    return True
        return False


if __name__ == "__main__":
    num_list1 = list(map(int, input().split()))
    num_list2 = list(map(int, input().split()))
    mydice1 = dice(*num_list1)
    mydice2 = dice(*num_list2)
    same_dice = mydice1.check_same_dice(mydice2)
    if same_dice:
        print('Yes')
    else:
        print('No')



Measured memory_bytes: 5620
#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::*;
use std::io::*;
#[allow(dead_code)]
fn getline() -> String {
    let mut ret = String::new();
    std::io::stdin().read_line(&mut ret).ok();
    return ret;
}
fn get_word() -> String {
    let mut stdin = std::io::stdin();
    let mut u8b: [u8; 1] = [0];
    loop {
        let mut buf: Vec<u8> = Vec::with_capacity(16);
        loop {
            let res = stdin.read(&mut u8b);
            if res.is_err() || res.ok().unwrap() == 0 || u8b[0] <= ' ' as u8 {
                break;
            } else {
                buf.push(u8b[0]);
            }
        }
        if buf.len() >= 1 {
            let ret = std::string::String::from_utf8(buf).unwrap();
            return ret;
        }
    }
}
fn parse<T: std::str::FromStr>(s: &str) -> T { s.parse::<T>().ok().unwrap() }

#[allow(dead_code)]
fn get<T: std::str::FromStr>() -> T { parse(&get_word()) }

const INF: i64 = 1i64 << 50;

fn dfs(v: usize, p: Option<usize>, a: &[i64], dp: &mut [i64], edges: &[Vec<usize>]) {
    let mut inf = false;
    for &w in edges[v].iter() {
        if Some(w) == p {
            continue;
        }
        dfs(w, Some(v), a, dp, edges);
        if dp[w] < a[v] {
            inf = true;
        }
    }
    dp[v] = if inf { INF } else { a[v] };
}

fn solve(v: usize, a: &[i64], edges: &[Vec<usize>]) -> bool {
    let n = edges.len();
    let mut dp = vec![0; n];
    dfs(v, None, a, &mut dp, edges);
    dp[v] == INF
}

fn main() {
    let n = get();
    let mut edges = vec![Vec::new(); n];
    let a: Vec<_> = (0 .. n).map(|_| get()).collect();
    for _ in 0 .. n - 1 {
        let a = get::<usize>() - 1;
        let b = get::<usize>() - 1;
        edges[a].push(b);
        edges[b].push(a);
    }
    let mut ans = Vec::new();
    for i in 0 .. n {
        if solve(i, &a, &edges) {
            ans.push(i)
        }
    }
    for i in 0 .. ans.len() {
        print!("{}{}", ans[i] + 1, if i == ans.len() - 1 { "" } else { " " });
    }
    println!("");
}


Measured memory_bytes: 1148
#include <stdio.h>
int main(){
  int m1,m2,m3,m4,rem,res;

  scanf("%d",&m1);
  scanf("%d",&m2);
  scanf("%d",&m3);
  scanf("%d",&m4);

  rem=(m1+m2+m3+m4)/60;
  res=(m1+m2+m3+m4)%60;

  printf("%d\n%d\n",rem,res);

  return 0;
}

Measured memory_bytes: 596
// abc171_d
#include <bits/stdc++.h>
#ifdef LOCAL
#include "../cxx-prettyprint/prettyprint.hpp"
#endif
using namespace std;

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

#define REP(i, n) for (int (i) = 0 ; (i) < (int)(n) ; ++(i))
#define REPN(i, m, n) for (int (i) = m ; (i) < (int)(n) ; ++(i))
#define REP_REV(i, n) for (int (i) = (int)(n) - 1 ; (i) >= 0 ; --(i))
#define REPN_REV(i, m, n) for (int (i) = (int)(n) - 1 ; (i) >= m ; --(i))
#define ALL(x) x.begin(), x.end()

#define INF (ll)(1e9)
#define MOD (1000000007)

#define print2D(h, w, arr) REP(i, h) { REP(j, w) cout << arr[i][j] << " "; cout << endl; }
#define print_line(vec, n) {for(int i=0;i<(n-1);i++) cout << (vec)[i] << " "; cout << (vec)[(n)-1] << endl;}
template<class T> void print(const T& x){cout << x << endl;}
template<class T, class... A> void print(const T& first, const A&... rest) { cout << first << " "; print(rest...); }
struct PreMain {PreMain(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(20);}} premain;

int main() {
#ifdef LOCAL
    ifstream in("../arg.txt"); cin.rdbuf(in.rdbuf());
#endif

    int N;
    cin >> N;

    map<ll, ll> mp;
    ll sm = 0;
    REP(i, N){
        int a;
        cin >> a;
        mp[a]++;
        sm += a;
    }

    int Q;
    cin >> Q;

    REP(_, Q){

        int b, c;
        cin >> b >> c;

        ll n = mp[b];
        mp[b] -= n;
        mp[c] += n;

        sm += (c - b) * n;
        print(sm);

    }


    return 0;
}


Measured memory_bytes: 9592
/// 28-01-2018
/// MD:NUR ALAM
/// Eastern University of Bangladesh

#include "bits/stdc++.h"

#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repp(i, a, b) for (int i = (a); i < (b); ++i)
#define fo(i, a, b) for (int i = (a); i <(b); ++i)
#define fors(i, s) for (int i = 0; s[i]; ++i)
#define rs(x) scanf("%s", (x))
#define mp make_pair
#define pb push_back
#define mso(X) memset((X), 0, sizeof((X)))
#define MS1(X) memset((X), -1, sizeof((X)))
#define len(X) strlen(x)

using namespace std;

typedef long long ll;
typedef uint64_t ull;
typedef long double lu;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<pii> vpll;
typedef pair<int,int> Pll;
typedef map<string,int>msi;
typedef set<int>se;

template<class t> void _r(t &x) { cin >> x; }
void _r(int &x) { scanf("%d", &x); }
void _r(int64_t &x) { scanf("%lld", &x); }
void _r(double &x) { scanf("%lf", &x); }
void _r(char &x) { scanf(" %c", &x); }
void _r(char *x) { scanf("%s", x); }
void r() {}
template<class t, class... u> void r(t &head, u &... tail) { _r(head); r(tail...); }
template<class t> void _w(const t &x) { cout << x; }
void _w(const int &x) { printf("%d", x); }
void _w(const int64_t &x) { printf("%lld", x); }
void _w(const double &x) { printf("%.16f", x); }
void _w(const char &x) { putchar(x); }
void _w(const char *x) { printf("%s", x); }
template<class t,class u> void _w(const pair<t,u> &x) {_w(x.f); putchar(' '); _w(x.s);}
void w() {}
template<class t, class... u> void w(const t &head, const u &... tail) { _w(head); putchar(sizeof...(tail) ? ' ' : '\n'); w(tail...); }
template<class t, class... u> void debug(const t &head, const u &... tail) {
#ifdef HOME
#endif
}

///------------------------------------------------------------------------------------------------------------------------------------


int main()
{
   ll n,a,b,s=0;
   r(n,a,b);
   s=(n-a)%b;
   w(s);


}


Measured memory_bytes: 256
n=input()
dic = {'A': True, 'C': True, 'G': True, 'T': True}
lens = []

for i in range(0, len(n)):
    length = 0
    s = n[i]

    if s not in dic:
        lens.append(length)
        continue

    length += 1
    for j in range(i+1, len(n)):
        t = n[j]
        if t not in dic:
            break

        length += 1

    lens.append(length)
print(max(lens))

Measured memory_bytes: 3064
from statistics import mean, median,variance,stdev
import numpy as np
import sys
import math
import fractions
import itertools
import copy
import collections
from operator import itemgetter
#以下てんぷら
def j(q):
    if q==1: print("Yay!")
    else:print(":(")
    exit(0)


def ct(x,y):
    if (x>y):print("+")
    elif (x<y): print("-")
    else: print("?")

def ip():
    return int(input())
def printrow(a):
    for i in range(len(a)):
        print(a[i])
#n = ip()                                     #入力整数1つ
#n,q= (int(i) for i in input().split())       #入力整数横2つ以上
#a = [int(i) for i in input().split()]        #入力整数配列
#b = input()                                  #入力文字列
#a = input().split()                          #入力文字配列
#n = ip()                      #入力セット(整数改行あり)(1/2)
a=[ip() for i in range(5)]    #入力セット(整数改行あり)(2/2)
#jの変数はしようできないので注意
#全足しにsum変数使用はsum関数使用できないので注意
#こっから本文
ms = [a[i]%10 for i in range(5)]
for i in range(5):
    if ms[i]==0:ms[i]+=10
p = ms.index(min(ms))
b = []
for i in range(5):
    if i==p:
        b.append(a[i])
    elif a[i]%10:
        b.append(a[i]//10*10+10)
    else: b.append(a[i])
print(sum(b))

Measured memory_bytes: 18612
#include <stdio.h>

int main(void){
	int N,C;
	int i,j,ans;
	scanf("%d %d",&N,&C);
	int D[C][C],color[3][30];
	for(i=0;i<C;i++){
		for(j=0;j<C;j++){
			scanf("%d",&D[i][j]);
		}
	}
	int x;
	for(i=0;i<3;i++){
		for(j=0;j<30;j++){
			color[i][j]=0;
		}
	}
	for(i=0;i<N;i++){
		for(j=0;j<N;j++){
			scanf("%d",&x);
			color[(i+j)%3][x-1]++;// %3で割ったチームにx色が何個あるか
		}
	}
		
	ans = 1e9;int k,l;
	for(i=0;i<C;i++){
		for(j=0;j<C;j++){
			if(i != j){
				for(k=0;k<C;k++){
					if(i != k && j != k){
						int a = 0;
						for(l=0;l<C;l++){
							a += D[l][i]*color[0][l]; //%3=0チームでl色からi色に塗り替え
							a += D[l][j]*color[1][l]; //%3=1チームでl色からj色に塗り替え
							a += D[l][k]*color[2][l]; //%3=2チームでl色からk色に塗り替え
						}
						if(a < ans) ans = a;
					}
				}
			}
		}
	}
	
	
	printf("%d",ans);
	return 0;}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define stoi stoll
using ll=long long;
using vi=vector<int>;
using pii=pair<int,int>;
#define ALL(c) begin(c),end(c)
#define RALL(c) rbegin(c),rend(c)
#define ITR(i,b,e) for(auto i=(b);i!=(e);++i)
#define FORE(x,c) for(auto &&x:c)
#define REPF(i,a,n) for(int i=a,i##len=(int)(n);i<i##len;++i)
#define REP(i,n) REPF(i,0,n)
#define REPR(i,n) for(int i=(int)(n);i>=0;--i)
#define SZ(c) ((int)c.size())
#define CONTAIN(c,x) (c.find(x)!=end(c))
#define INSEG(l,x,r) ((l)<=(x)&&(x)<(r))
#define dump(...)
#define pb push_back
#define _ 0
const signed INF_=1001001001; const long long INF=1001001001001001001LL;
const int DX[9]={0,1,0,-1,1,1,-1,-1,0},DY[9]={-1,0,1,0,-1,1,1,-1,0};
template<class T> ostream& operator<<(ostream &os,const vector<T> &v) {
    ITR(i,begin(v),end(v))os<<*i<<(i==end(v)-1?"":" ");return os;}
template<class T> istream& operator>>(istream &is,vector<T> &v) {
    ITR(i,begin(v),end(v)) is>>*i;return is;}
template<class T,class U> istream& operator>>(istream &is, pair<T,U> &p) {
    is>>p.first>>p.second;return is;}
template<class T, class U> bool chmax(T &a,const U &b){return a<b?a=b,1:0;}
template<class T, class U> bool chmin(T &a,const U &b){return a>b?a=b,1:0;}
template <class T> void PSUM(T& c) {partial_sum(begin(c), end(c), begin(c));}
template<class T> using heap=priority_queue<T,vector<T>,greater<T>>;
struct before_main_function {
    before_main_function() {
        cin.tie(0); ios::sync_with_stdio(false);
        cout << setprecision(15) << fixed;
        #define endl "\n"
    }
} before_main_function;
//------------------8<------------------------------------8<--------------------

long double dp[3000][3000];
signed main() {
    int N;
    cin >> N;
    vector<long double> p(N);
    cin >> p;
    dp[0][0] = 1;
    REP(i, N) {
        REP(j, i + 1) {
            dp[i + 1][j + 1] += dp[i][j] * p[i];
            dp[i + 1][j] += dp[i][j] * (1.0 - p[i]);
        }
    }
    long double ans = 0;
    REPF(i, N / 2 + 1, N + 1) {
        ans += dp[N][i];
    }
    cout << ans << endl;
    return (0^_^0);
}



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

using namespace std;

#define YES cout << "YES" << endl;
#define NO  cout << "NO"  << endl;
#define Yes cout << "Yes" << endl;
#define No  cout << "No"  << endl;
 
#define INF INT_MAX
#define MOD 1000000007
#define PI  acos(-1)

using ll  = long long;
using ull = unsigned long long;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;

#define rep(i, n) for (ll i = 0; i < (n); i++)
#define rrep(i, n) for (ll i = (n)-1; i >= 0; i--)

int main(int argc, char *argv[])
{
    cin.tie(0);
    ios::sync_with_stdio(false);

    ll N;
    cin >> N;

    vector<ll> C(N-1), S(N-1), F(N-1);
    rep (i, N-1) {
        cin >> C[i] >> S[i] >> F[i];
    }

    vector<ll> ans(N);
    rep (i, N) {
        ll t = 0;
        for (int j = i; j < N-1; j++) {
            if (t < S[j]) {
                t = S[j];
            } else if (t%F[j] == 0) {
                ;
            } else {
                t = t+F[j]-t%F[j];
            }
            t += C[j];
        }
        ans[i] = t;
    }

    rep (i, N) {
        cout << ans[i] << endl;
    }
    return 0;
}


Measured memory_bytes: 256
n, k = map(int, input().split())
a = list(map(int, input().split())) 
b = 0
if k<=n:
  for i in range(k):
    b = a[b]-1
  print(b+1)
  exit(0)
c = [0]
for i in range(n):
  b = a[b]-1
  c.append(b)
d = c[:-1].index(c[-1])
c = c[d:-1]
k = k-d
print(c[k%len(c)]+1)



Measured memory_bytes: 32344
N = int(input())
A_int_list = list(map(int, input().split()))
B_int_list = list(map(int, input().split()))
C_int_list = list(map(int, input().split()))

ans = 0

for i in range(N):
    ans += B_int_list[A_int_list[i] - 1]
    if i != N - 1 and A_int_list[i] + 1 == A_int_list[i + 1]:
        ans += C_int_list[A_int_list[i] - 1]

print(ans)


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

using namespace std;

const int mod = 1e9 + 7;

string s, t;

long long n, ans = 1;

int main() {
    cin >> n;
    cin >> s >> t;
    if (s[0] == t[0]) {
        ans = 3;
    }
    else {
        ans = 6;
    }
    for (int i = 0; i < n; ++i) {
        if (s[i] == t[i] && i >= 1 && s[i - 1] == t[i - 1]) {
            ans = (ans * 2) % mod;
        }
        else if (i >= 1 && s[i] == s[i - 1]) {
            if (i >= 2 && s[i - 2] == t[i - 2]) {
                ans = (ans * 2) % mod;
            }
            else if (i >= 3 && s[i - 2] == s[i - 3]) {
                ans = (ans * 3) % mod;
            }
        }
    }
    cout << ans;
}


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

int main() {
	
	vector<int> coordinate;
	int n;
	
	cin >> n;
	for(int i;i<n;++i){
		int tmp;
		cin >> tmp;
		coordinate.push_back(tmp);
	}
	
	sort(coordinate.begin(),coordinate.end());
	
	int min = coordinate.front();
	int max = coordinate.back();
	
	cout << max-min << endl;
	
	return 0;
}

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


#define li          long long int
#define rep(i,to)   for(li i=0;i<((li)(to));i++)
#define repp(i,start,to)    for(li i=(li)(start);i<((li)(to));i++)
#define pb          push_back
#define sz(v)       ((li)(v).size())
#define bgn(v)      ((v).begin())
#define eend(v)     ((v).end())
#define allof(v)    (v).begin(), (v).end()
#define dodp(v,n)       memset(v,(li)n,sizeof(v))
#define bit(n)      (1ll<<(li)(n))
#define mp(a,b)     make_pair(a,b)
#define rin rep(i,n)
#define EPS 1e-12
#define ETOL 1e-8
#define MOD 1000000007
typedef pair<li, li> PI;

#define INF bit(60)

#define DBGP 1


#define idp if(DBGP)
#define F first
#define S second
#define p2(a,b)     idp cout<<a<<"\t"<<b<<endl
#define p3(a,b,c)       idp cout<<a<<"\t"<<b<<"\t"<<c<<endl
#define p4(a,b,c,d)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<endl
#define p5(a,b,c,d,e)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<endl
#define p6(a,b,c,d,e,f)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<endl
#define p7(a,b,c,d,e,f,g)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<endl
#define p8(a,b,c,d,e,f,g,h)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<endl
#define p9(a,b,c,d,e,f,g,h,i)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<"\t"<<i<<endl
#define p10(a,b,c,d,e,f,g,h,i,j)        idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<"\t"<<i<<"\t"<<j<<endl
#define foreach(it,v)   for(__typeof((v).begin()) it=(v).begin(); it!=(v).end(); ++it)
#define p2p(x)      idp p2((x).F, (x).S)
#define dump(x,n)   idp{rep(i,n){cout<<x[i]<<" ";}puts("");}
#define dump2(x,n)  idp{rep(i,n){cout<<"["<<x[i].F<<" , "<<x[i].S<<"] ";}puts("");}
#define dumpi(x)    idp{foreach(it, x){cout<<(*it)<<" ";}puts("");}
#define dumpi2(x)   idp{foreach(it, x){cout<<"["<<(it)->F<<" , "<<(it)->S<<"] ";}puts("");}

#define read2d(a,w,h)   rep(i,h)rep(j,w)cin>>a[i][j]
#define dump2d(a,w,h)   rep(i,h){rep(j,w)cout<<a[i][j]<<" ";puts("");}

typedef pair<li, li> PI;


li sum_e[300300];
li sum_w[300300];

int main() {
    li n;
    string s;
    cin >> n >> s;
    sum_e[0] = 0;
    rin{
        sum_e[i + 1] = sum_e[i] + (s[i] == 'W' ? 1 : 0);
    }
    sum_w[n] = 0;
    for (li i = n - 1; i >= 0; i--) {
        sum_w[i] = sum_w[i + 1] + (s[i] == 'E' ? 1 : 0);
    }

    li res = INF;
    rin{
        res = min(res, sum_e[i] + sum_w[i + 1]);
    }
    cout << res << endl;



    return 0;
}

Measured memory_bytes: 5380
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
using namespace std;
 
int main(){
    int n,x;
    cin >> n >> x;
    vector<int> l(n),d(n+1);
    for(int i=0;i<n;i++) cin >> l[i];
    int count=0;
    d[0]=0;
    int i,j=0;
    for(i=1;i<=n;i++){
        d[i]=d[i-1]+l[i-1];
        if(d[i]<=x) j++;
    }
    cout << j+1 << endl;
    }

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
#define ALL(A) A.begin(), A.end()

using namespace std;

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

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

	string S; cin >> S;

	bool ok = (S.substr(0, min(4, (int)S.length())) == "YAKI");

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

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

int main(){
    int n; cin >> n;
    vector<int> a(n);
    vector<vector<int>> x(n), y(n);
    for (int i = 0; i < (n); ++i)
    {
        cin >> a[i];
        x[i].resize(a[i]);
        y[i].resize(a[i]);
        for(int j = 0; j < (a[i]); ++j){
            cin >> x[i][j] >> y[i][j];
        }
    }

    int ans = 0;
    for (int bit = 1; bit < (1 << n); ++bit){
        bitset<15> b(bit);
        int c = b.count();
        bool f = true;
        for (int i = 0; i < (n); ++i)
        {
            if(b.test(i)){
                for (int j = 0; j < (a[i]); ++j)
                {
                    if (b.test(x[i][j] - 1) != y[i][j])
                    {
                        f = false;
                    }
                }
            }
        }
        if(f) {
            ans = max(ans, c);
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
import std.stdio;
import std.string;
import std.conv;
import std.algorithm: canFind;

void main() {
	string[] inputs = split(readln());
	string s1 = inputs[0];
	string s2 = inputs[1];
	string s3 = inputs[2];
	
	format("%s%s%s", s1[0].toUpper, s2[0].toUpper, s3[0].toUpper).writeln;
}


Measured memory_bytes: 256
n,m=map(int, input().split()) 
s=list(input())

# dp[i]=iに行くのに最短の手数
dp=[0]*(n+1)
ans=0
now=n
count=0
flag=True
ans=[]
for i in range(10**11):
    if flag==False:
        break
    for j in range(m,0,-1):
        if now-j<=0:
            ans.append(now)
            flag=False
            break
        elif s[now-j]!='1':
            ans.append(j)
            count+=1
            now-=j
            break
        else:
            if j==1:
                print(-1)
                exit()
            continue
        

ans.reverse()

print(*ans)
        

                
            
        
        
        

Measured memory_bytes: 55688
#arc061_C - たくさんの数式 / Many Formulas
s = list(str(input()))
l = len(s)
def dfs(i,f):
    if i == l-1:
        return sum(list(map(int,f.split("+"))))
    #この記号の正体を教えて下さい
    return dfs(i + 1, f + s[i+1]) + \
           dfs(i + 1, f + "+" +s[i + 1])
print(dfs(0,s[0]))

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

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
//const ll mod = 1000000007;

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


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

using namespace std;

int N;
int P[202020];
int ma[202020];

signed main()
{
    cin >> N;
    int tmi;
    int ans = 0;
    for (size_t i = 0; i < N; i++)
    {
        cin >> P[i];
        if (i == 0)
            tmi = P[i];
        if (tmi >= P[i])
        {
            ans++;
        }
        tmi = min(tmi, P[i]);
    }
    cout << ans << endl;
}

Measured memory_bytes: 1792
#include <stdio.h>
#define MAX 100
#define INF 1000000
#define NIL -1
 
int Thank[MAX][MAX];
int you;
int AlgorithmsAndDataStructures[MAX];
int I[MAX];
void had(int, int);
void a(int);
void GreatTime(int);

main()
{
  int i, j ,u ,k,v,c;
  scanf("%d",&you);
 
  for(i=0; i<you; i++)
    {
      for(j=0; j<you; j++)
	{
	  Thank[i][j]=-1;
	}
    }
 
  for(i=0; i<you; i++)
    {
      scanf("%d %d",&u,&k);
      for(j=0; j<k; j++)
	{
	  scanf("%d %d",&v,&c);
	  Thank[i][v]=c;
	}
    }
 
  GreatTime(0);
  for(i=0; i<you; i++)
    {
      printf("%d %d\n", i, AlgorithmsAndDataStructures[i]);
    }
  
  return 0;
}

void had(int u, int v)
{
  if(AlgorithmsAndDataStructures[v]> AlgorithmsAndDataStructures[u]+Thank[u][v])
    {
      AlgorithmsAndDataStructures[v]=AlgorithmsAndDataStructures[u]+Thank[u][v];
      I[v]=u;
    }
}
 
void a(int s)
{
  int v;
  for(v=0; v<you; v++)
    {
      AlgorithmsAndDataStructures[v]=INF;
      I[v]=NIL;
    }
  AlgorithmsAndDataStructures[s]=0;
}

void GreatTime(int s)
{
  int i, v1, v, minv, u;
  int flag[MAX];
  a(s);
  
  for(i=0; i<you; i++)
    {
      flag[i]=0;
    }
  for(v1=0; v1<you; v1++)
    {
      minv = INF;
      for ( i = 0; i < you; i++ )
	{
	  if(flag[i]==1)
	    {
	      continue;
	    }
	  if(AlgorithmsAndDataStructures[i]<=minv)
	    {
	      u=i;
	      minv=AlgorithmsAndDataStructures[i];
	    }
	}
      
      for(v=0; v<you; v++)
	{
	  if(Thank[u][v]==-1)
	    {
	      continue;
	    }
	  if(flag[v]==1)
	    {
	      continue;
	    }
	  had(u, v);
	}
      flag[u]=1;
    }
}

Measured memory_bytes: 640
import java.util.*;
import java.util.Map.Entry;
 
 
 
public class Main{
	
	
	
	public static long A;
	public static long answer = 0;
	

 
	
	//最大公約数・最小公倍数（セットで使う）
	public static long gcm(long a, long b) {
		long result = a;
		long k = 0;
		long n = b;
		do {
			k = result % n;
			result = n;
			n = k;
		} while(k != 0);
		return result;
	}
	
	public static long lcm(long a, long b) {
		long g;
		g = gcm(a, b);
		return a/g*b;
	}
	
	static long gcd(long a, long b) {
		if (b == 0) {
			return a;			
		}
		return gcd(b, a % b);
	}
	
	//等差数列
	static long tousasum(int n) {
		return (long)n*((long)n+1)/2;
	}
 
 
 
	//素数判定
	static boolean isPrime (int n) {
		if (n==2) return true;
		if (n<2 || n%2==0) return false;
		double d = Math.sqrt(n);
		for (int i=3; i<=d; i+=2) if(n%i==0){return false;}
		return true;
	}
 
 
	//倍数判定（10進数以外のときに有用）
	static boolean isMultiple (String s, int base, int m) {
		int temp = 0;
		for (int i=0; i<s.length(); i++) {
			temp = (temp*base+Character.getNumericValue(s.charAt(i)))%m;
		}
		if (temp==0) {return true;}
		return false;
	}
 
 
	//階乗
	static long factorial (int i) {
		if (i==1) {return 1;}
		else {return i*factorial(i-1);}
	}
 
 
	//進数変換
	static String toNbase (String sm, int m, int n) {
		return Long.toString(Long.parseLong(sm,m),n);
	}
	
	public static final long gcd_n(long[] param) {
	    final int len = param.length;
	    long g = gcd(param[0], param[1]);    //gcd(a, b) は以前作ったもの
	    for (int i = 1; i < len - 1; i++) {
	        g = gcd(g, param[i + 1]);       //gcd(a, b) は以前作ったもの
	    }
	    return g;
	}
	
	public static long lcm_n(long[] numbers) {
		long l;
		l = numbers[0];
		for (int i = 1; i < numbers.length; i++) {
			l = lcm(l, numbers[i]);
		}
		return l;
	}
	public static int H,W;
	public static char[][] c;
	public static boolean[][] b;
	
	

    
	
	
 public static void main(String[] args) {
	 Scanner sc=new Scanner(System.in);
	 int M=sc.nextInt();
	 String S=sc.next();
	 int D=Integer.valueOf(S);
	 int result = 0;
	 for(int i=1;i<=M;i++) {
		 for(int j=1;j<=D;j++) {
			 if((j%10)>=2&&(j/10)>=2&&i==(j%10)*(j/10)) {
				 result++;
			 }
		 }
		 
	 }
	 
	 System.out.println(result);
	 
	
}
}



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

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

int main(){
    int N;
    string s;
    cin >> N >> s;
    s.push_back('#');
    int ans = 0;
    rep(i, N){
        if(s[i] != s[i+1]) ans++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3708
#include <bits/stdc++.h>
using namespace std;
#define sz(x) ((int) (x).size())
#define forn(i,n) for (int i = 0; i < int(n); ++i)
typedef long long ll;
typedef long long i64;
typedef long double ld;
const int inf = int(1e9) + int(1e5);
const ll infl = ll(2e18) + ll(1e10);

int main() {
    #ifdef LOCAL
    assert(freopen("c.in", "r", stdin));
    #else
    #endif
    string s;
    int k;
    cin >> s >> k;
    int n = sz(s);
    forn (i, n) {
        if (s[i] == 'a')
            continue;
        int x = 'z' + 1 - s[i];
        if (x > k)
            continue;
        k -= x;
        s[i] = 'a';
    }
    k %= 26;
    int ch = s[n - 1] + k;
    if (ch > 'z')
        ch -= 26;
    s[n - 1] = ch;
    cout << s << '\n';
}

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

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

    int a[n];
    for(int i = 0; i < n; i++)  cin >> a[i];
 
    int ans = accumulate(a, a+n, 0);
    cout << ans-n << endl;

    return 0;
}

Measured memory_bytes: 384
import java.math.BigDecimal;
import java.math.MathContext;
import java.util.Scanner;

class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		double a = sc.nextDouble();
		double b = sc.nextDouble();
		double c = sc.nextDouble();
		int scale = 50;

		BigDecimal aa = sqrt(BigDecimal.valueOf(a), scale);
		BigDecimal bb = sqrt(BigDecimal.valueOf(b), scale);
		BigDecimal cc = sqrt(BigDecimal.valueOf(c), scale);

		boolean isok = (aa.add(bb)).compareTo(cc) < 0;
		if (isok) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}
		sc.close();
	}

	public static BigDecimal sqrt(BigDecimal a, int scale) {

		BigDecimal x = new BigDecimal(Math.sqrt(a.doubleValue()), MathContext.DECIMAL64);
		if (scale < 17) {
			x = x.setScale(scale, BigDecimal.ROUND_HALF_EVEN);
			return x;
		}

		BigDecimal b2 = new BigDecimal(2);
		for (int tempScale = 16; tempScale < scale; tempScale *= 2) {
			x = x.subtract(
					x.multiply(x).subtract(a).divide(
							x.multiply(b2), scale, BigDecimal.ROUND_HALF_EVEN));
		}
		return x;
	}

}


Measured memory_bytes: 23508
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define ll long long
int n,m;
ll mod=1e9+7,dp[1010][1010];
string s[1010];
ll solve(int i,int j)
{
    if(s[i][j]=='#')
        return 0;
    if(i==n-1&&j==m-1)
        return 1;
    if(i==n-1)
        return solve(i,j+1)%mod;
    if(j==m-1)
        return solve(i+1,j)%mod;
    ll &ret=dp[i][j];
    if(ret+1)
        return ret;
    ret=0;
    ret+=solve(i+1,j)%mod+solve(i,j+1)%mod;
    ret%=mod;
    return ret;
}
int main()
{
    ios::sync_with_stdio(0);
    cin>>n>>m;
    for(int i=0;i<n;i++)
        cin>>s[i];
    memset(dp,-1,sizeof dp);
    cout<<solve(0,0);
    return 0;
}


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

#define rep(i,n) for(int i = 0; i < n; i++)
#define REP(i,n) for(int i = 1; i < n; i++)
#define per(i,n) for(int i = n; i >= 0; i--)
#define sz(x) int(x.size())
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define YesorNo(a) printf(a ? "Yes\n" : "No\n")
#define endl '\n'
#define fi first
#define se second
using ll = long long;
using P = pair<int,int>;
using Pl = pair<ll,ll>;
using vi = vector<int>;
using vii = vector<vi>;
using vl = vector<ll>;
using vll = vector<vl>;
using vs = vector<string>;
using vb = vector<bool>;
using vc = vector<char>;
using vcc = vector<vc>;
const int dx[] = {0,1,0,-1,1,1,-1,-1};
const int dy[] = {1,0,-1,0,1,-1,-1,1};
const int inf = (1<<30)-1;
const ll infll = (1LL<<62)-1;
ll ceil(const ll &a, const ll &b){return ((a)+(b)-1)/b;}
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }



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

  string s, t;
  cin >> s >> t;
  rep(cnt,2){
  map<char, char> mp;
  int n = sz(s);
  rep(i,n) {
    char c = t[i];
    if(mp.find(c) != mp.end()) {
      if(mp[c] != s[i]) {
        cout << "No" << endl;
        return 0;
      }
    }
    else {
      mp[c] = s[i];
    }
  }
  swap(s,t);
  }

  cout << "Yes" << endl;
}

Measured memory_bytes: 916
def uf_init(n):
    return list(range(n))

def uf_root(uf, x):
    if uf[x] != x:
        uf[x] = uf_root(uf, uf[x])
    return uf[x]

def uf_same(uf, x, y):
    return uf_root(uf, x) == uf_root(uf, y)

def uf_unite(uf, x, y):
    x = uf_root(uf, x)
    y = uf_root(uf, y)
    if x == y:
        return
    uf[x] = y


N = int(input())

x_dict = {}
y_dict = {}
uf = uf_init(N)

xy_arr = []
for i in range(N):
    x,y = (int(x) for x in input().split())
    if x in x_dict:
        uf_unite(uf, i, x_dict[x])
    else:
        x_dict[x] = i
    if y in y_dict:
        uf_unite(uf, i, y_dict[y])
    else:
        y_dict[y] = i
    xy_arr.append((x,y))

unite_dict = {}
for i in range(N):
    ur = uf_root(uf, i)
    unite_dict.setdefault(ur, [set(), set()])
    unite_dict[ur][0].add(xy_arr[i][0])
    unite_dict[ur][1].add(xy_arr[i][1])

total_points = 0
for k,v in unite_dict.items():
    total_points += len(v[0])*len(v[1])

print(total_points-N)


Measured memory_bytes: 32104
#include<iostream>
#include<cmath>
#include<string>
using namespace std;

int main()
{
  long int A;
  long int ans;
  string B;
  int B_i;
  cin>>A>>B;
  B_i=(B[0]-48)*100+(B[2]-48)*10+(B[3]-48);
  ans=A*B_i;
  ans=ans/100;
  cout<<ans;
}

Measured memory_bytes: 3108
import java.io.IOException;
import java.util.Scanner;

public class Main {

    public static void main(String[] args) throws IOException {
        // write your code here
        Scanner sc = new Scanner(System.in);

        int x = sc.nextInt();
        int a = sc.nextInt();
        int b = sc.nextInt();

        if (a - b >= 0) {
            System.out.println("delicious");
        } else if (x + a - b >= 0) {
            System.out.println("safe");
        } else {
            System.out.println("dangerous");
        }

    }
}

Measured memory_bytes: 24020
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt(), X = sc.nextInt();
    int[] L = new int[N];
    for (int i = 0; i < N; i++) L[i] = sc.nextInt();

    int ans = 1;
    for (int i = 0, sum = 0; i < N; i++) {
      sum += L[i];
      if (sum <= X) ans++;
      else break;
    }
    System.out.println(ans);
  }
}

Measured memory_bytes: 23892