akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp93 {
    class Program {
        static void Main(string[] args) {
            int N = int.Parse(Console.ReadLine());
            var C = new int[N - 1];
            var S = new int[N - 1];
            var F = new int[N - 1];

            for (int i = 0; i < N - 1; i++) {
                var st = Console.ReadLine().Split().Select(int.Parse).ToArray();
                C[i] = st[0];
                S[i] = st[1];
                F[i] = st[2];
            }

            int cur = 0;  //現在のポジション
            int next = 0;  //次のポジション

            for (int i = 0; i < N - 1; i++) {
                cur = S[i];

                for (int j = 0; i + j < N - 1; j++) {
                    //次の着地点
                    next = cur + C[i + j];

                    if (i + j == N - 2) {
                        cur = next;
                        break;
                    }

                    //次の開始点
                    if (next <= S[i + j + 1]) {
                        cur = S[i + j + 1];
                    } else if ((next - S[i + j + 1]) % F[i + j + 1] == 0) {
                        cur = next;
                    } else {
                        cur = (
                                  (int)Math.Ceiling(  (double)(next - S[i + j + 1]) / F[i + j + 1]  )
                                                                                               ) 
                                                                                                  * F[i + j + 1] 
                                                                                                               + S[i + j + 1];
                    }
                }

                Console.WriteLine(cur);
            }


            Console.WriteLine(0);



        }
    }
}


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

int main() {
    int N, M;
    cin >> N >> M;
    if (N > M) swap(N, M);

    long long res = 1;
    int mod = 1000000007;

    if (abs((N - M)) > 1)
        res = 0;
    else if (N == M) {
        for (int i = 1; i <= N; i++)
            res = res * i % mod;
        res = res * res % mod;
        res = res * 2 % mod;
    } else {
        for (int i = 1; i <= N; i++)
            res = res * i % mod;
        res = res * res % mod;
        res = res * M % mod;
    }

    cout << res << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int a=-1,b,i; main(){
string s;
cin>>s;
for(i=0;i<s.length()-1;i++)if(s[i]==s[i+1])a=i+1,b=i+2;
for(i=0;i<s.length()-2;i++)if(s[i]==s[i+2])a=i+1,b=i+3;
if(a!=-1)cout<<a<<" "<<b;
else cout<<-1<<" "<<-1;
}


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

int main()
{
  string s,t;
  
  cin>>s;
  
  cin>>t;
  
  int flag=1;
  
  if(s.length()+1 == t.length())
  {
    for(int i=0;i<s.length();i++)
    {
      if(s[i] != t[i])
      {
        flag=0;
        break;
      }
    }
    
    if(flag)
      cout<<"Yes";
    
    else
      cout<<"No";
  }
  else
    cout<<"No";
  return 0;
}


Measured memory_bytes: 3624
#include<bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define pii pair<int,int>
#define vpii vector< pair<int,int> >
#define mii map<int,int>
#define MOD 1000000007
#define fr(i,k,n) for(int i=k;i<n;i++)
#define fl(i,k,n) for(int i=k;i>=n;i--)
using namespace std;
typedef long long ll;
int val(int n)
{
	ll x=0;
	if(n==1 || n==2)
	return 1;
	for(int i=2;i<=n;i++)
	{
		if(i*(i+1)/2<=n)
		x=i;
	}
	return x;
}
ll factorize(long long n) 
{ 
     int count = 0; 
      ll ans=0; 
     // count the number of times 2 divides  
    while (!(n % 2)) { 
        n >>= 1; // equivalent to n=n/2; 
        count++; 
    } 
  
    // if 2 divides it 
    if (count) 
       ans+=val(count);
  
    // check for all the possible numbers that can  
    // divide it 
    for (long long i = 3; i <= sqrt(n); i += 2) { 
        count = 0; 
        while (n % i == 0) { 
            count++; 
            n = n / i; 
        } 
        if (count) 
             ans+=val(count);
    } 
  
    // if n at the end is a prime number. 
    if (n > 2) 
         ans+=val(1);
         return ans;
} 
void solve()
{
	ll n;
	cin>>n;
	cout<<factorize(n)<<endl;
}
int main()
{
ios::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
int t=1;
//cin>>t;
while(t--)
{
solve();
}

return 0;
}




Measured memory_bytes: 3696
#n = int(input())
#a = int(input())
#ls = list(input().split(" "))
#ls = list(map(int,input().split(" ")))
a,b = list(map(int,input().split(" ")))
#string = input()

if a + b >= 10:
  print("error")
else:
  print(a + b)

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

int main(){
    char s;
    cin >> s;
    for(int i=0;i<2;i++){
        char t;
        cin >> t;
        if(t!=s){
            cout << "Yes" << endl;
            break;
        }
        else{
            s = t;
        }

        if(i==1)
            cout << "No" << endl;
    }

    return 0;
}


Measured memory_bytes: 256
A,B = map(int,(input().split()))

l = 0
if A > B: 
    l = A
    s = B
else:
    l = B
    s = A

for i in range(1,10**10):
    if (l*i)%s == 0:
        print(l*i)
        exit()
    else:
        continue

Measured memory_bytes: 3060
import java.util.Scanner;

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

    final Integer[] input =
        {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};

    int a = sc.nextInt();

    System.out.println(input[a - 1]);
  }
}


Measured memory_bytes: 23764
import java.util.Scanner;

import javax.sql.rowset.serial.SerialArray;

public class Main {

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

			int N = sc.nextInt();

			double k;
			for (int i = N ; i >  0. ; i--){
				k=Math.sqrt(i);
				if (Math.round(k) == k){
				    System.out.println(i);
					return;
				}
			}
		}
}


Measured memory_bytes: 23092
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<math.h>
#include<queue>
#include<deque>
#include<stack>
#include<cstdio>
#include<utility>
#include<set>
#include<list>
#include<cmath>
#include<stdio.h>
#include<string.h>
#include<iomanip>
using namespace std;
#define FOR(i, a, b) for (ll i = (a); i <= (b); i++)
#define REP(i, n) FOR(i, 0, n - 1)
#define NREP(i, n) FOR(i, 1, n)
using ll = long long;
using pii = pair<int, int>;
using piii = pair<pii, pii>;
const int dx[4] = { 0, -1, 1, 0 };
const int dy[4] = { -1, 0, 0, 1 };
const int INF = 1e9 + 7;
int gcd(int x, int y) {
	if (x < y)swap(x, y);
	if (y == 0)return x;
	return gcd(y, x%y);
}

template<class T1, class T2> void chmin(T1 &a, T2 b) { if (a>b)a = b; }

template<class T1, class T2> void chmax(T1 &a, T2 b) { if (a<b)a = b; }
template<class T>
void Add(T &a, const T &b, const T &mod = 1000000007) {
	int val = ((a % mod) + (b % mod)) % mod;
	if (val < 0) { val += mod; }
	a = val;
}
////////////////////////////////////////

int main() {
	int N;
	cin >> N;
	ll dp[110][5][5][5];
	memset(dp, 0, sizeof(dp));
	//dp[N][i][j][k]でN-2文字目、N-1文字目,N文字目
	//0=A,1=C,2=G,3=T;
	for (int i = 0; i < 4; ++i) {
		for (int j = 0; j < 4; ++j) {
			for (int k = 0; k < 4; ++k) {
				if (i == 0 && j == 2 && k == 1)continue;
				if (i == 2 && j == 0 && k == 1)continue;
				if (i == 0 && j == 1 && k == 2)continue;
				dp[3][i][j][k]++;
			}
		}
	}
	for (int i = 3; i < N; ++i) {
		for (int j = 0; j < 4; ++j) {
			for (int k = 0; k < 4; ++k) {
				for (int l = 0; l < 4; ++l) {
					for (int m = 0; m < 4; ++m) {
						if (m == 0 && j == 2 && l == 1)continue;
						if (j == 0 && k == 2 && l == 1)continue;
						if (j == 0 && k == 1 && l == 2)continue;
						if (j == 2 && k == 0 && l == 1)continue;
						if (i == 0 && j == 2 && k == 1)continue;
						if (m == 0 && k == 2 && l == 1)continue;
						dp[i + 1][j][k][l] += dp[i][m][j][k];
						dp[i + 1][j][k][l] %= INF;
					}
				}
			}
		}
	}
	ll ans = 0;
	for (int i = 0; i < 4; ++i) {
		for (int j = 0; j < 4; ++j) {
			for (int k = 0; k < 4; ++k) {
				ans += dp[N][i][j][k];
				ans %= INF;
			}
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 384
#!/usr/bin/perl

my ($n) = map { $_ - 0 } split(/\s+/,<STDIN>);

my %k = ();
for(my $i=0;$i<$n;$i++){
  my $ss = scalar(<STDIN>);
  $ss =~ s/[\x00-\x20]+$//ios;
  $k{$ss} = 1;
}
my @a = keys %k;
my $r = 1 + $#a;
print "$r\n";




Measured memory_bytes: 44768
#include <iostream>
#include<map>
#include <unordered_map>
#include <map>
#include <algorithm>
#include <vector>
#include<math.h>
#define int long long
const int maxvalue = 2 * 1e5;


using namespace std;


void solver() {

    int n;
    cin >> n;
//    int *arr=new int[2*n];
//    for(int i=0;i<2*n;i++)
//    {
//        cin>>arr[i];
//    }
    int c ;
    int d ;
    cin>>c>>d;
    while (n-1 > 0) {


        int a, b;
        cin >> a >> b;
        int my1 = c / a;
        if(c%a!=0)
        {
            my1++;
        }
        int my2 = d / b;
        if(d%b!=0)
        {
            my2++;
        }
        c = a * max(my1, my2);
        d = b * max(my1, my2);
        n--;

    }
    cout << c + d;


}

int32_t main() {
    int n=1;
    //cin >> n;
    while (n--) {
        solver();
    }
}

Measured memory_bytes: 3176
#include<iostream>
#include<algorithm>
using namespace std;
int main() {
	string s;
	long long n, l;
	cin >> n >> l;
	string arr[n];
	for(int i = 0; i < n; i++) {
		cin >> arr[i];
	}
	sort(arr, arr+n);
	for(int i = 0; i < n; i++) {
		s += arr[i];
	}
	cout << s;
	return 0;
}

Measured memory_bytes: 3636
"use strict";
function main(input) {
    const line = input.split("\n");
    let arr = line[0].split(" ");
    const A = parseInt(arr[0]);
    const B = parseInt(arr[1]);
    console.log(2 * B < A ? A - 2 * B : 0);
    return;
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 29480
#include<iostream>
#include <string>
#include <algorithm>

using namespace std;

void Reverse()
{
    string str;
    
    cin>>str;
    
    reverse(str.begin(), str.end()); //function is used for reversing sequence
    
    cout<<str<<endl;
   
    return;
}
    
  
int main()
{  
    Reverse();
    return 0;
}

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

int main() {
  int n, k, a, ans = 0;
  cin >> n >> k;

  map<int, int> p;
  for (int i = 0; i < n; i++) {
    cin >> a;
    p[a]++;
  }

  priority_queue<pair<int, int> > pq;
  for (auto x : p) {
    auto key = x.first;
    auto value = x.second;
    pq.push({-value, -key});
  }

  while (pq.size() > k) {
    ans -= pq.top().first;
    pq.pop();
  }

  cout << ans << endl;
}

Measured memory_bytes: 11768
N = int(input())
X = [list(input().split()) for i in range(N)]

for i in range(N):
    X[i].append(i + 1)
# print(X)

for i in X:
    i[1] = int(i[1])
X.sort()
# print(X)

for i in range(N):
    for j in range(i + 1, N):
        if X[i][0] == X[j][0]:
            if X[i][1] < X[j][1]:
                X[i], X[j] = X[j], X[i]

for value in X:
    print(value[2])


Measured memory_bytes: 38896
using System;
using System.Text;
using System.Collections.Generic;
using System.Linq;
using E = System.Linq.Enumerable;
 
class Program
 {
        static int R;

        static void Main(string[] args)
        {
          var grid = new long[3][];
          for(int i = 0; i < 3 ; i++){
            grid[i] = Console.ReadLine().Split(' ').Select(x => long.Parse(x)).ToArray();
          }
          
          var flag = true;
          for(int i = 0; i < 2 ; i++){
            for(int j = i+1; j < 3 ; j++){
              
              if(grid[j][0]-grid[i][0] != grid[j][1]-grid[i][1]){
                flag = false;
              }
              
              if(grid[j][0]-grid[i][0] != grid[j][2]-grid[i][2]){
                flag = false;
              }
              
            }
          }
          
          for(int i = 0; i < 2 ; i++){
            for(int j = i+1; j < 3 ; j++){
              
              if(grid[0][j]-grid[0][i] != grid[1][j]-grid[1][i]){
                flag = false;
              }
              
              if(grid[0][j]-grid[0][i] != grid[2][j]-grid[2][i]){
                flag = false;
              }

            }
          }
          
          if(flag){
            Console.WriteLine("Yes");
          }else{
            Console.WriteLine("No");
          }
            
          
          

          
        }
}







Measured memory_bytes: 13396
import java.util.*;

class Main {
  public static void main(String args[]) {
      Scanner sc = new Scanner(System.in);
      int[] x = new int[5];
      for(int i = 0; i < 5; i++){
        x[i] = sc.nextInt();
      }
      for(int i = 0; i < 5; i++){
        if(x[i] == 0){
          System.out.println(i + 1);
          break;
        }
      }
  }
}

Measured memory_bytes: 35768
using System;
using System.Collections.Generic;
using System.Linq;
using System.Numerics;
using static System.Console;
using static System.Math;

namespace abc167A
{
  public class MainClass
  {
    public static void Main(string[] args)
    {
      long[] input = Console.ReadLine().Split(' ').Select(x => long.Parse(x)).ToArray();
      long X = input[0];
      long Y = input[1];
      bool ok = true;
      
      if(Y%2 == 1){ok = false;}
      if(2*X > Y || Y > 4*X){ok = false;}
      
      if(ok == true){Console.WriteLine("Yes");}
      else{Console.WriteLine("No");};
    }
  }
}

Measured memory_bytes: 28028
//高知能系Vtuberの高井茅乃です。
//Twitter: https://twitter.com/takaichino
//YouTube: https://www.youtube.com/channel/UCTOxnI3eOI_o1HRgzq-LEZw

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

#define INTINF 1999999999
#define REP(i,n) for(int i=0;i<n;i++)
#define REP1(i,n) for(int i=1;i<=n;i++)
#define MODA 1000000007 

int main() {
	ll ans = 0;
	int tmp;
	string s;
	cin >> s;
	ll co[26] ={};
	ll n = s.size();
	ans = n * (n-1) /2 + 1;
	REP(i, n) co[s[i]-'a']++;
	REP(i, 26) ans -= co[i] * (co[i] -1)/2;
	cout << ans << endl;
}

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

#define all(x) begin(x), end(x)

using i64 = int_fast64_t;
using f64 = double;
using p64 = pair<i64, i64>;

constexpr i64 INF = INT_FAST64_MAX / 2;
constexpr f64 EPS = DBL_EPSILON;

void solve() {
    i64 n;
    cin >> n;
    vector<i64> a(n + 1, 0);
    for (i64 i = 1; i <= n; i++) cin >> a[i];
    partial_sum(all(a), begin(a));
    map<i64, i64> cnt;
    i64 ans = 0;
    for (auto& e : a) ans += cnt[e], cnt[e]++;
    cout << ans << endl;
}

int main() {
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    solve();
}


Measured memory_bytes: 14336
//For higher stack size use g++ -O2 -std=c++11 -Wall -Wl,--stack=268435456 a.cpp -o a.exe in cmd
    #include <bits/stdc++.h>
    #include <cstdio>
    #include <cstring>
    #include <cmath>
    #include <cstring>
    #include <chrono>
    #include <complex>
    #define ll long long
    #define ld long double
    #define vi vector<int>
    #define vll vector<ll>
    #define vvi vector < vi >
    #define pii pair<int,int>
    #define pll pair<long long, long long>
    #define mod 1000000007
    #define inf 1000000000000000001;
    #define all(c) c.begin(),c.end()
    #define mp(x,y) make_pair(x,y)
    #define mem(a,val) memset(a,val,sizeof(a))
    #define eb emplace_back
    #define pb push_back
    #define f first
    #define s second
    
    using namespace std;
    int main()
    {
        std::ios::sync_with_stdio(false);
        int T;
        T=1;
        // cin.ignore(); must be there when using getline(cin, s)
        while(T--)
        {
            ll a,b;
            cin>>a>>b;
            cout<<max({a+b,a-b,a*b})<<endl;
        }
        return 0;
    }


Measured memory_bytes: 256
import collections
import math
n = int(input())
s = [0]*n
T = [0]*n
L = [0]*n
ans = 0
for i in range(n):
	s[i] = input()
	T[i] = sorted(list(s[i]))
	L[i] = ''.join(T[i])
D = collections.Counter(L)
for i in D.values():
	ans += i*(i-1)/2
print(int(ans))

Measured memory_bytes: 48100
#include<bits/stdc++.h>
using namespace std;
char arr[1006][1006];
int path[1006][1006];
int visited[1006][1006];
int h,w;
int mod=1000000007;
int funcc(int i,int j)
{
    if(arr[i][j]=='#'||i>h||j>w)
    return 0;
    if(i==h&&j==w)
    return 1;
    if(path[i][j]!=0)
    return path[i][j];
    if(visited[i][j]==1)
        return 0;
    visited[i][j]=1;
    int k=funcc(i+1,j)+funcc(i,j+1);
    k=k%mod;
    path[i][j]=k;
    return k;
}
int main()
{
    for(int i=0;i<=1005;i++)
    {
        for(int j=0;j<=1005;j++)
        {
        path[i][j]=0;
        visited[i][j]=0;
        }
    }
    cin>>h;
    cin>>w;
    for(int i=1;i<=h;i++)
    {
        for(int j=1;j<=w;j++)
        cin>>arr[i][j];
    }
    int a=funcc(1,1);
    a=a%mod;
    cout<<a<<endl;
}


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

int main(){
  int a,b,c;
  cin >> a >> b >> c;
  cout << c << " " << a << " " << b << endl;
 
}

Measured memory_bytes: 3592
import java.util.Scanner;
import java.math.*;

public class Main {
	
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		// 整数の入力
		//int a = sc.nextInt();
		// スペース区切りの整数の入力
		//int b = sc.nextInt();
		//int c = sc.nextInt();
		// 文字列の入力
		//String s = sc.next();
		//1文字ずつ
		//s.atChar(i);
		//s.charAt(i); for String
		// 出力
		//System.out.println("");
		//int count=0;
		int count=0;
		int A1=sc.nextInt();
		int A2=sc.nextInt();
		int A3=sc.nextInt();
	
	
		int sum1=Math.abs(A1-A2)+Math.abs(A2-A3);//1
		int sum2=Math.abs(A1-A3)+Math.abs(A3-A2);//2
		int sum3=Math.abs(A2-A1)+Math.abs(A1-A3);//3
		
		if(sum1<sum2){
			if(sum3<sum1){
				System.out.println(sum3);
			}else{
				System.out.println(sum1);
			}
		}else{
			if(sum3<sum2){
				System.out.println(sum3);
			}else{
				System.out.println(sum2);
			}
		}
		
		//int sum4=Math.abs(A2-A3)+Math.abs(A3-A1);
		//int sum5=Math.abs(A3-A1)+Math.abs(A1-A2);
		//int sum6=Math.abs(A3-A2)+Math.abs(A2-A1);
	}
	
}
	

Measured memory_bytes: 21844
#include<bits/stdc++.h>
using namespace std;
#define next Next
#define gc getchar
#define int long long
const int N=1e6+5;
int n,m,k,ans,a[N],b[N];
char s[N];
//char buf[1<<21],*p1=buf,*p2=buf;
//inline int gc(){return p1==p2&&(p2=(p1=buf)+fread(buf,1,1<<21,stdin),p1==p2)?EOF:*p1++;}
inline int read()
{
    int ret=0,f=0;char c=gc();
    while(!isdigit(c)){if(c=='-')f=1;c=gc();}
    while(isdigit(c)){ret=ret*10+c-48;c=gc();}
    if(f)return -ret;return ret;
}
signed main()
{
	n=read();int X=read(),Y=read();
	for(int i=1;i<=n;i++)
		for(int j=i+1;j<=n;j++)
		{
			int x=j-i;
			int y=abs(i-X)+1+abs(j-Y);
			a[min(x,y)]++;
		}
	for(int i=1;i<n;i++)printf("%lld\n",a[i]);
	return 0;
}


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

#define rep(i,n) for(int i=0; i<n; i++)
#define rept(i,a,b) for(int i=a; i<b; i++)
#define all(x) (x).begin(),(x).end()

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

const int mod = 1e9 + 7;


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

	int a, b;
	cin >> a >> b;

	int ans = a - (b * 2);
	if(ans > 0){
		cout << ans << endl;
	}else{
		cout << 0 << endl;
	}


    return 0;
}



Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
using namespace std;
static const double EPS = 1e-5;
typedef long long ll;
typedef pair<int,int> pint;
#define rep(i,n) for(int i=0;i<n;i++)
#define F first
#define S second
int dx[]={1,-1,0,0},dy[]={0,0,1,-1};

int m;

int f(string s1,string s2,int x){
	if(m>80){cout<<"overflow";return 0;}
	if(s1.size()<=m&&s2.size()<=m&&x==0)return 0;
	if(s1.size()>m)x+=s1[s1.size()-m-1]-'0';
	if(s2.size()>m)x+=s2[s2.size()-m-1]-'0';
	++m;
	f(s1,s2,x/10);
	if(m<=80)cout<<x%10;
	return 0;
}

int main(){
	int n;
	cin>>n;
	rep(i,n){
		m=0;
		string s1,s2;
		cin>>s1>>s2;
		f(s1,s2,0);
		cout<<endl;
	}
	return 0;
}

Measured memory_bytes: 0
n = int(input())
s = []
for i in range(n):
  tmp = input()
  s.append(tmp)
  
for i in range(n):
  l = [c for c in s[i]]
  l.sort()
  s[i] = ''.join(l)
  
import collections
d = dict(collections.Counter(s))
#print(d)

def henkan(n):
  return n * (n-1) // 2

ans = 0
for key in d.keys():
  value = d[key]
  if value != 1:
    ans += henkan(value)
    
print(ans)

Measured memory_bytes: 80984
# -*- coding: utf-8 -*-

def get_input() -> tuple:
    """
    標準入力を取得する.

    Returns:\n
        tuple: 標準入力
    """
    S = input()
    T = input()

    return S, T


def main(S: str, T: str) -> None:
    """
    メイン処理.

    Args:\n
        S (str): 文字列
        T (str): 文字列
    """
    # 求解処理
    ans = 0
    for s, t in zip(S, T):
        ans += (s != t)

    # 結果出力
    print(ans)


if __name__ == "__main__":
    # 標準入力を取得
    S, T = get_input()

    # メイン処理
    main(S, T)


Measured memory_bytes: 9548
public class Main {
    public static void main(String args[]) {
        for(int i = 1; i <= 9; i++) {
            for(int j = 1; j <= 9; j++) {
                // ?¨??????????
                System.out.println(""+i+'x'+j+'='+(i*j));
            }
        }
    }
}

Measured memory_bytes: 24148
#[allow(unused_imports)]
use std::cmp::max;
#[allow(unused_imports)]
use std::fmt;
#[allow(unused_imports)]
use std::fmt::Debug;
#[allow(unused_imports)]
use std::io;
#[allow(unused_imports)]
use std::str::FromStr;

fn main() {
    loop {
        let n: i64 = get_vec_input()[0];
        if n == 0 {
            break;
        }
        let s_input: Vec<f64> = get_vec_input();
        let m = s_input.iter().sum::<f64>() / n as f64;
        let a2 = s_input.iter().fold(0.0, |a, b| a + (b - m).powi(2)) / n as f64;
        println!("{}", a2.sqrt());
    }
}

#[allow(dead_code)]
fn sum_digit2(value: String) -> u32 {
    return value.chars().fold(0u32, |a, b| a + b.to_digit(10).unwrap());
}

#[allow(dead_code)]
fn sum_digit(value: i64) -> i64 {
    if value < 10 {
        return value;
    }
    return sum_digit(value / 10) + value % 10;
}

#[allow(dead_code)]
fn update_max<T>(left: &mut T, right: T)
where
    T: std::cmp::Ord + std::clone::Clone,
{
    if *left < right {
        *left = right.clone();
    }
}

#[allow(dead_code)]
fn update_min<T>(left: &mut T, right: T)
where
    T: std::cmp::Ord + std::clone::Clone,
{
    if *left > right {
        *left = right.clone();
    }
}

#[allow(dead_code)]
fn get_vec_input<T>() -> Vec<T>
where
    T: FromStr,
    T::Err: Debug,
{
    let mut input = String::new();
    io::stdin()
        .read_line(&mut input)
        .expect("Failed to read line");
    let vec: Vec<T> = input
        .split_whitespace()
        .map(|x| x.parse().unwrap())
        .collect();
    vec
}

#[allow(dead_code)]
fn get_tuple_input() -> (u64, f32) {
    let mut s = String::new();
    io::stdin().read_line(&mut s).expect("");
    let mut iter = s.trim().split_whitespace();
    let c: u64 = iter.next().unwrap().parse().unwrap();
    let n: f32 = iter.next().unwrap().parse().unwrap();
    (c, n)
}

#[allow(dead_code)]
fn get_string_input() -> String {
    let mut s = String::new();
    io::stdin().read_line(&mut s).expect("");
    s.trim().to_string()
}



Measured memory_bytes: 5084
#include<iostream>
#include<string>
#include<vector>
#include<utility>
#include<queue>
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<cstring>
#define INF 2147483647
#define llINF 9223372036854775807
#define pb push_back
#define mp make_pair 
#define F first
#define S second
#define ll long long

using namespace std;
int a,b,c,d,e,f;
int was=0;int sug=0;double noudo=0;
bool Wa[10000];
bool su[10000];
int main(){
  cin>>a>>b>>c>>d>>e>>f;
  Wa[a*100]=true;Wa[b*100]=true;
  su[c]=true;su[d]=true;
  for(int i=1;i<f;i++){
    if(Wa[i]){
      Wa[i+a*100]=true;
      Wa[i+b*100]=true;
    }
    if(su[i]){
      su[i+c]=true;
      su[i+d]=true;
    }
  }
  vector<int>water;
  vector<int>suger;
  for(int i=f-1;i>0;i--){
    if(Wa[i])
      water.pb(i);
    if(su[i])
      suger.pb(i);
  }
  suger.pb(0);
  for(int i=0;i<water.size();i++){
    for(int j=0;j<suger.size();j++){
      double no=(100.0*suger[j])/(water[i]+suger[j]);
      if(no>=noudo&&(e*(water[i]/100)>=suger[j])&&(water[i]+suger[j])<=f){
	noudo=no;
	was=water[i]+suger[j];sug=suger[j];
	//cout<<water[i]<<" "<<suger[j]<<" "<<e*(water[i]/100)<<endl;
	//break;
      }
    }
  }
  cout<<was<<" "<<sug<<endl;
  return 0;
}


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

using namespace std;

#define pb push_back
#define mp make_pair
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
typedef long long LL;
typedef pair<int, int> PII;

int n, k;
int a[100000];
int ans = 0;
vector<int> g[100000];

int dfs(int v, int par = -1) {
    int dep = 0;
    for (int to : g[v]) {
        dep = max(dep, dfs(to, v));
    }
    if (dep == k - 1 && v != 0 && par != 0) {
        dep = -1;
        ++ans;
    }
    return dep + 1;
}

int main() {
    scanf("%d%d", &n, &k);
    forn(i, n) scanf("%d", a + i), --a[i];
    if (a[0] != 0) {
        ans = 1;
        a[0] = 0;
    }
    for (int i = 1; i < n; ++i) {
        g[a[i]].pb(i);
    }
    dfs(0);
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 10752
#include <string>
#include <queue>
#include <stack>
#include <vector>
#include <sstream>
#include <algorithm>
#include <deque>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <list>
#include <cstdio>
#include <iostream>
#include <cmath>
#include <climits>
#include <bitset>
#include <functional>
#include <numeric>
#include <ctime>
#include <cassert>
#include <cstring>
#include <fstream>

using namespace std;

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

    int total = 1900 * m + 100 * (n - m);
    int two = 1;
    for (int i = 0; i < m; i++) {
        two *= 2;
    }

    cout << total * two << endl;


    return 0;
}

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

using namespace std;
using namespace __gnu_pbds;

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

long long n,k;
long long ans;
long long pre[maxn];
long long val[maxn];

int main()
{
	scanf("%lld%lld",&n,&k);
	for(int i=0;i<=n;i++)
		pre[i] = (pre[i-1]+i)%mod;
	for(int i=1;i<=n+1;i++)
	{
		long long x=pre[i-1];
		long long y=(i==n+1)?pre[n]:pre[n]-pre[n-i];
		val[i]=(y-x+1+mod)%mod;
	}
	
	for(long long i=k;i<=n+1;i++)
	{
		ans=(ans+val[i])%mod;
	}
	
	printf("%lld\n",ans);
	return 0;
}




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

int main()
{
	int n, x;
	cin >> n >> x;
	int ans = 0;
	for (int i = 0; i <= x && ++ans < n + 1;) {
		int in;
		cin >> in;
		i += in;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<cmath>
#include<map>
#include<iomanip>
#include<queue>
#include<stack>
#include<time.h>
#define rep(i,n)for(int i=0;i<n;i++)
#define int long long
#define ggr getchar();getchar();return 0;
#define prique priority_queue
constexpr auto mod = 1000000007;
#define inf 1e15
#define key 1e9
using namespace std;
typedef pair<int, int>P;
void yes() { cout << "Yay!" << endl; }
void no() { cout << ":(" << endl; }
template<class T> inline void chmax(T& a, T b) {
	a = std::max(a, b);
}
template<class T> inline void chmin(T& a, T b) {
	a = std::min(a, b);
}

//combination(Nが小さい時はこれを使う)
const int MAX = 330000;
int fac[MAX], finv[MAX], inv[MAX];
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAX; i++) {
		fac[i] = fac[i - 1] * i % mod;
		inv[i] = mod - inv[mod % i] * (mod / i) % mod;
		finv[i] = finv[i - 1] * inv[i] % mod;
	}
}
int COMB(int n, int k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % mod) % mod;
}

bool prime(int n) {
	int cnt = 0;
	for (int i = 1; i <= sqrt(n); i++) {
		if (n % i == 0)cnt++;
	}
	if (cnt != 1)return false;
	else return n != 1;
}
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x % y);
}
int lcm(int x, int y) {
	return x / gcd(x, y) * y;
}

//繰り返し二乗法（Nが大きい時の場合のcombination)
int mod_pow(int x, int y, int m) {
	int res = 1;
	while (y) {
		if (y & 1) {
			res = res * x % m;
		}
		x = x * x % m;
		y >>= 1;
	}
	return res;
}
int kai(int x, int y) {
	int res = 1;
	for (int i = x - y + 1; i <= x; i++) {
		res *= (i % mod); res %= mod;
	}
	return res;
}
int comb(int x, int y) {
	if (y > x)return 0;
	return kai(x, y) * mod_pow(kai(y, y), mod - 2, mod) % mod;
}
//UnionFind
class UnionFind {
protected:
	int* par, * rank, * size;
public:
	UnionFind(unsigned int size) {
		par = new int[size];
		rank = new int[size];
		this->size = new int[size];
		rep(i, size) {
			par[i] = i;
			rank[i] = 0;
			this->size[i] = 1;
		}
	}
	int find(int n) {
		if (par[n] == n)return n;
		return par[n] = find(par[n]);
	}
	void unite(int n, int m) {
		n = find(n);
		m = find(m);
		if (n == m)return;
		if (rank[n] < rank[m]) {
			par[n] = m;
			size[m] += size[n];
		}
		else {
			par[m] = n;
			size[n] += size[m];
			if (rank[n] == rank[m])rank[n]++;
		}
	}
	bool same(int n, int m) {
		return find(n) == find(m);
	}
	int getsize(int n) {
		return size[find(n)];
	}
};
signed main() {
	string s;
	cin >> s;
	if (s[0] == '7' || s[1] == '7' || s[2] == '7')puts("Yes");
	else puts("No");
	ggr
}


Measured memory_bytes: 3724
#include <algorithm>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>

#define SREP(s,i,m) for(unsigned int i = s; i < m; ++i)
#define REP(i,m) SREP(0,i,m)

using namespace std;
#ifdef _MSC_VER
using LONG = __int64;
#else
using LONG = long long int;
#endif

int main(void) {
  int N;
  int a[100001];
  cin >> N;
  REP(i, N) cin >> a[i];
  REP(i, N) a[i]--;
  int cnt = 0;
  REP(i, N) {
    if (a[a[i]] == i) cnt++;
  }
  cout << (cnt / 2) << endl;
  return 0;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
#define ll long long
#define oo 0x7fffffff
using namespace std;
inline int read()
{
	int out=0,fh=1;
	char cc=getchar();
	while ((cc>'9'||cc<'0')&&cc!='-')
		cc=getchar();
	if (cc=='-')
		{
			fh=-1;
			cc=getchar();
		}
	while (cc>='0'&&cc<='9')
		{
			out=out*10+cc-'0';
			cc=getchar();
		}
	return out*fh;
}
const int mod=998244353;
const int MAXN=2010;
inline int add(int a,int b)
{
	return (a+b) % mod;
}
inline int sub(int a,int b)
{
	return (a-b)%mod>0? (a-b)%mod : (a-b)%mod+mod;
}
inline int mul(int a,int b)
{
	return 1ll * a * b % mod;
}
int fpow(int a,int b)
{
	int ans=1;
	while(b)
		{
			if(b&1)
				ans=mul(ans,a);
			b>>=1;
			a=mul(a,a);
		}
	return ans;
}
int k,n,p;
ll C[MAXN<<1][MAXN<<1],bits[MAXN<<1];
void init()
{
	bits[0]=1;
	for(register int i=1; i<=4000; ++i)
		bits[i]=mul(bits[i-1],2);
	C[0][0]=1;
	for(register int i=1; i<=4000; ++i)
		{
			C[i][0]=1;
			for(int j=1; j<=i; ++j)
				C[i][j]=add(C[i-1][j],C[i-1][j-1]);
		}
}
/*ll solve(int i,int tot)
{
	int k2=min(k-i/2,(i-1)/2);
	int k1=k-k2*2-(i%2==0);
	ll ans=0;
	for(int j=0;j<k2;++j)
		{
			ll s;
			s=mul(C[n+k1+k2-j-1][k1+k2-j-1],bits[k2-j]);
			s=mul(s,C[k2][j]);
			if(j&1)
				ans=sub(ans,s);
			else
				ans=add(ans,s);
		}
	return ans;
}*/
ll count(int s,int tot)
{
	return C[s+tot-1][s-1];
}
ll solve(int i,int tot)
{
	int k2=min(k-i/2,(i-1)/2);
	int k1=k-k2*2-((i%2)==0);
	ll flag=1;
	ll res=0;
	for(int l=k2; l+k1>0&&l>=0; l--,flag=-flag)
		{
			res+=flag*count(l+k1,tot)*bits[l]%mod*C[k2][l]%mod;
			res%=mod;
		}
	return (res+mod)%mod;
}
int main()
{
	//freopen(".in","r",stdin);
	//freopen(".out","w",stdout);
	k=read(),n=read();
	init();
	ll ans=0;
	for(register int i=2; i<=2*k; ++i)
		{
			if(i%2==0)
				ans=add(solve(i,n),solve(i,n-1));
			else
				ans=solve(i,n);
			printf("%lld\n",ans);
		}
	//fclose(stdin);
	//fclose(stdout);
	return 0;
}


Measured memory_bytes: 124288
#pragma GCC optimize("Ofast")
#pragma GCC optimize("no-stack-protector")
#pragma GCC optimize("unroll-loops")
#pragma GCC optimize("fast-math")
#pragma GCC target("sse,sse2,sse3,ssse3,popcnt,abm,mmx,tune=native")
#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <stdio.h>
#include <cstdio>
#include <math.h>
#include <cmath>
#include <string>
#include <cstring>
#include <queue>
#include <deque>
#include <random>
#include <iomanip>
#include <bitset>
 
using namespace std;
 
template<typename T> void uin(T &a, T b) {
    if (b < a) {
        a = b;
    }
}
 
template<typename T> void uax(T &a, T b) {
    if (b > a) {
        a = b;
    }
}


#define left left228
#define right right228
#define prev prev228
#define mp make_pair
#define all(v) v.begin(), v.end()
#define forn(i, n) for (int i = 0; i < (int)n; ++i)
#define firn(i, n) for (int i = 1; i < (int)n; ++i)
#define x first
#define y second

const int N = 100 * 1000 + 228;

int n, m;
vector<int> g[N];
bool used[N];

signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cin >> n >> m;
    for (int i = 0; i < m; ++i) {
        int u, v;
        cin >> u >> v;
        g[u].emplace_back(v);
        g[v].emplace_back(u);
    }
    int x = 1, y = 1;
    used[1] = 1;
    vector<int> right;
    vector<int> left;
    while (1) {
        int A = -1;
        for (int to : g[y]) {
            if (!used[to]) {
                A = to;
                break;
            }
        }
        if (A == -1) break;
        used[A] = 1;
        y = A;
        right.emplace_back(y);
    }
    while (1) {
        int A = -1;
        for (int to : g[x]) {
            if (!used[to]) {
                A = to;
                break;
            }
        }
        if (A == -1) break;
        used[A] = 1;
        x = A;
        left.emplace_back(x);
    }
    reverse(all(left));
    cout << left.size() + 1 + right.size() << endl;
    for (int I : left) {
        cout << I << " ";
    }
    cout << 1 <<  " ";
    for (int i : right) {
        cout << i << ' ';
    }
    cout << endl;
    return 0;
}
 
/*



3
0 1
-2 3
2 2

3
0 1
-2 2
2 2

*/

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

using namespace std;
int main(void){
  string s;
  int K,c=0;
  
  cin>>s>>K;
  
  while(K>0){
    if(s[c]=='a');
    else if((int('z')-int(s[c])+1)<=K){
      K-=(int('z')-int(s[c])+1);
      s[c]='a'; 
    }
    c++;
    if(c>=(s.size()-1)) break;
  }

  if(K>0){
    K=K%26;
    if((int(s[s.size()-1])+K)>int('z')) s[s.size()-1]=char(int(s[s.size()-1])+K-26);
    else s[s.size()-1]=char(int(s[s.size()-1])+K);
  }
  
  cout<<s<<endl;

  return 0;
}

Measured memory_bytes: 640
#include<stdio.h>
int main() {
	int C1, C2, C3, i, safe;
	while(~scanf("%d%d%d", &C1, &C2, &C3)) {
		safe = 0;
		for (i = 1; i <= 10; i ++) {
			if (i != C1 && i != C2 && i != C3) {
				if (C1 + C2 + i <= 20)
					safe ++;
			}
		}
		puts (safe > 3 ? "YES" : "NO");
	}
	return 0;
}

Measured memory_bytes: 0
#include <cstdio>
#include <iostream>
#include <iomanip>
#include <string>
#include <queue>
#include <stack>
#include <vector>
#include <set>
#include <map>
#include <algorithm>
#include <utility>
#include <cmath>

#define ll long long int
#define pb push_back
#define mk make_pair
#define pq priority_queue

using namespace std;
typedef pair<int, int> P;
typedef pair<ll, int> Pl;
typedef pair<ll, ll> Pll;
const int inf = 1e9;
const ll linf = 1LL << 50;

int main(int argc, char const* argv[])
{
  string a[3];
  cin >> a[0] >> a[1] >> a[2];
  int cur[3] = {0, -1, -1};
  int at = 0;
  while(true){
    if(cur[at] >= a[at].size()){
      cout << char('A' + at) << endl;
      return 0;
    }
    at = int(a[at][cur[at]] - 'a');
    cur[at]++;
  }
	return 0;
}


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

typedef pair<int, int> P;
const int INF = 100000000;

struct Edge {
    int to;
    int cost;

    Edge(int t, int c) : to(t), cost(c) {};
};

int N;
vector<vector<Edge>> G;
vector<int> cnt;

void dijkstra(int s) {
    priority_queue<P, vector<P>, greater<P>> que;
    vector<int> dist(N, INF);
    dist[s] = 0;
    que.push(P(0, s));

    while (!que.empty()) {
        P p = que.top(); que.pop();
        int v = p.second;
        if (dist[v] < p.first) continue;
        for (int i = 0; i < G[v].size(); i++) {
            Edge e = G[v][i];
            if (dist[e.to] > dist[v] + e.cost) {
                dist[e.to] = dist[v] + e.cost;
                que.push(P(dist[e.to], e.to));
            }
        }
    }

    for (int i = 0; i < N; i++) {
        cnt[dist[i]]++;
    }
}

int main() {
    int X, Y;
    cin >> N >> X >> Y;
    G.resize(N);
    for (int i = 0; i < N - 1; i++) {
        G[i].push_back(Edge(i + 1, 1));
        G[i + 1].push_back(Edge(i, 1));
    }
    G[X - 1].push_back(Edge(Y - 1, 1));
    G[Y - 1].push_back(Edge(X - 1, 1));

    cnt.resize(N);
    for (int i = 0; i < N; i++) {
        dijkstra(i);
    }
    for (int i = 1; i < N; i++) {
        cout << cnt[i] / 2 << endl;
    }
    return 0;
}

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

int fa[maxn], du[maxn];
int fst[maxn], co[maxn];
int n, m, e;
long long a, b, c;
struct str { int v, nex; } edge[maxn << 1];

bool dfs(int u) {
	for (int i = fst[u]; i; i = edge[i].nex) {
		int v = edge[i].v;
		if (co[v] == co[u]) return false;
		if (co[v]) continue;
		if (!co[v]) { co[v] = 3 - co[u]; if (!dfs(v)) return false; }
	}
	return true;
}

int find(int a) { return (fa[a] == a) ? a : (fa[a] = find(fa[a])); }

void make_edge(int a, int b) {
	edge[++e].nex = fst[a]; fst[a] = e; edge[e].v = b;
	edge[++e].nex = fst[b]; fst[b] = e; edge[e].v = a;
}

int main() {
	scanf("%d %d",&n,&m);
	
	for (int i = 1; i <= n; i++) fa[i] = i;
	for (int i = 1; i <= m; i++) {
		int a, b;
		scanf("%d %d",&a,&b);
		make_edge(a, b);
		du[a]++; du[b]++;
		find(a); find(b);
		if (fa[a] == fa[b]) continue;
		fa[fa[a]] = fa[b];
	}	

	for (int i = 1; i <= n; i++) {
		find(i);
		if (co[fa[i]]) continue;
		if (!du[i]) { c++; continue; }
		co[fa[i]] = 1;
		if (dfs(fa[i])) a++;
		else b++;
	}

	cout << c * (n - c) * 2LL + c * c + a * a * 2LL + a * b * 2LL + b * b << endl;
	
	return 0;
}

Measured memory_bytes: 8832
// Problem : F - Intervals on Tree
// Contest : AtCoder - AtCoder Beginner Contest 173
// URL : https://atcoder.jp/contests/abc173/tasks/abc173_f
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

/*
 *   ﷽
 * In the name of Allah, the Most Gracious, the Most Merciful
 */

#include <algorithm>
#include <iostream>
#include <map>
#include <set>
#include <string>
#include <vector>
#include <climits>

using namespace std;

int main()
{
	int n;
	cin>>n;
	if(n%1000) cout<<1000 - (n%1000) << "\n";
	else cout<<"0\n";
	return 0;
}

Measured memory_bytes: 3192
#include<iostream>
#include<algorithm>

#define REP(i,n) for(int i=0;i<n;i++)

using namespace std;

int main(){

  int a,b;

  cin>>a>>b;

  if(a%3==0 || b%3==0 || (a+b)%3==0)
    cout<<"Possible"<<endl;
  else
    cout<<"Impossible"<<endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define LL long long
using namespace std;
const int N=1e5+10;
const int B=316;
int read(){
    int x=0,f=1;char ch=getchar();
    while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
    while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
    return x*f;
}
void print(LL x){
    if(x>9) print(x/10);
    putchar(x%10+'0');
}
int n,x,t;
int main(){
	cin>>n>>x>>t;
	if(n%x==0) n=n/x;
	else n=n/x+1;
	cout<<n*t<<endl;
	return 0;
}

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

#define LL long long
#define VI vector<int>
#define VB vector<bool>
#define VL vector<long long>
#define FOR(i,a,b) for(int i= (a); i<((int)b); ++i)
#define RFOR(i,a) for(int i=(a); i >= 0; --i)
#define FOE(i,a) for(auto i : a)
#define ALL(c) (c).begin(), (c).end()
#define RALL(c) (c).rbegin(), (c).rend()
#define DUMP(x)  cerr << #x << " = " << (x) << endl;
#define SUM(x) std::accumulate(ALL(x), 0LL)
#define MIN(v) *std::min_element(v.begin(), v.end())
#define MAX(v) *std::max_element(v.begin(), v.end())
#define EXIST(v,x) (std::find(v.begin(), v.end(), x) != v.end())
#define BIT(n) (1LL<<(n))
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end());
#define EPS 1e-14
#define MINUS(a) memset(a,0xff,sizeof(a))

const std::string YES = "YES";
const std::string Yes = "Yes";
const std::string NO = "NO";
const std::string No = "No";

using namespace std;


void dfs(int station, int company, vector<int> &sta, vector<vector<int>> &station_graph, vector<int> &used) {
    if (used[station] == company) {
        return;
    }
    used[station] = company;
    sta.emplace_back(station);

    FOE(to_station,station_graph[station]) {
        dfs(to_station, company, sta, station_graph, used);
    }
}

int main() {
    int N, M;
    cin >> N >> M;

    int num_of_company = 1010101;

    vector<vector<pair<int,int>>> company_station(num_of_company);
    FOR(i, 0, M) {
        int p, q, c;
        cin >> p >> q >> c;
        company_station[c].emplace_back(make_pair(p, q));
    }

    vector<int> graph[303030 + 1];
    int id = N + 1;
    vector<int> used(num_of_company, -1);
    vector<vector<int>> station_graph(N + 1);
    FOR(company, 0, num_of_company) {
        if(company_station[company].empty()) { continue; }

        vector<int> station_list;   // 現在処理しているcompanyに所属している駅のリスト
        FOE(e, company_station[company]) {
            station_graph[e.first].push_back(e.second);
            station_graph[e.second].push_back(e.first);

            station_list.push_back(e.first);
            station_list.push_back(e.second);
        }

        FOE(station, station_list) {
            if(used[station] == company) { continue; }

            vector<int> sta;
            dfs(station, company, sta, station_graph, used);
            FOE(s, sta) {
                graph[id].push_back(s);
                graph[s].push_back(id);
            }

            id++;
        }

        FOE(e, company_station[company]) {
            station_graph[e.first].clear();
            station_graph[e.second].clear();
        }
    }

    vector<int> dist(303030, INT_MAX);
    dist[1] = 0;
    queue<int> que;
    que.push(1);
    while (not que.empty()) {
        int x = que.front();que.pop();
        FOE(e, graph[x]) {
            if(dist[e] > dist[x] + 1) {
                dist[e] = dist[x] + 1;
                que.push(e);
            }
        }
    }

    int ans = dist[N];
    cout << (ans == INT_MAX ? -1 : ans / 2) << endl;

    return 0;
}

Measured memory_bytes: 57600
#include <bits/stdc++.h>
using namespace std;
 
 
int main() {
    string S;
    cin >> S;
    int count=0;
    for(int i=0;i<S.size();i++){
        if(S.at(i)=='o') count++;
    }
    if(count+15-S.size()>=8)cout << "YES" << endl;
    else cout << "NO" << endl;
}

Measured memory_bytes: 256
n,m = map(int,input().split())
g = [[] for i in range(n)]
for i in range(m):
    a,b = map(int,input().split())
    a -= 1
    b -= 1
    g[a].append(b)
    g[b].append(a)
from collections import deque
d = deque([[0,0]]) # 左は今考えてる部屋、右は前の部屋
ans = [-1 for i in range(n)]
kak = [-100 for i in range(n)]
while d:
    u,v = d.popleft()
    ans[u] = v
    for j in g[u]:
        if  kak[j] == -100:
            kak[j] = 0
            d.append([j,u])
        else:
            continue
print('Yes')
for i in range(1,n):
    print(ans[i]+1)

Measured memory_bytes: 104460
#include <stdio.h>
#define  N 100
int main()
{
  int  A[N];
  int total;
  int  iS;
  int  iM;
  int  i,tmp,count=0;

  scanf("%d",&total);
  for(i=0;i<total;++i)
    scanf("%d",&A[i]);

  for(iS=0;iS<total-1;iS++){


        for( iM=iS,i=iS+1; i<total; i++ )
          {
            if ( A[i]<A[iM] ) iM=i;
          }

        if ( iS!=iM )
          {
            tmp=A[iM]; A[iM]=A[iS]; A[iS]=tmp;
            count++;
          }
  }
  for( i=0; i<total; i++ ){
    if(i){
      printf(" ");
    }
    printf("%d",A[i]);
  }
  printf("\n");
  printf("%d",count);
  printf("\n");
  return 0;
}



Measured memory_bytes: 2144
import math, string, itertools, fractions, heapq, collections, re, array, bisect, copy, functools, random
import sys
from collections import deque, defaultdict, Counter; from heapq import heappush, heappop
from itertools import permutations, combinations, product, accumulate, groupby
from bisect import bisect_left, bisect_right, insort_left, insort_right
from operator import itemgetter as ig
sys.setrecursionlimit(10 ** 7)
inf = 10 ** 20; INF = float("INF"); ans = 0; tmp = 0; ansli = []; tmpli = []; candili = []
eps = 1.0 / 10 ** 10; mod = 10 ** 9 + 7
dd = [(-1, 0), (0, 1), (1, 0), (0, -1)]; ddn = dd + [(-1, 1), (1, 1), (1, -1), (-1, -1)]; ddn9 = ddn + [(0, 0)]
"""for dx, dy in dd:
        nx = j + dx; ny = i + dy
            if 0 <= nx < w and 0 <= ny < h:"""
def wi(): return list(map(int, sys.stdin.readline().split()))
def wip(): return [int(x) - 1 for x in sys.stdin.readline().split()]#WideIntPoint
def ws(): return sys.stdin.readline().split()
def i(): return int(sys.stdin.readline())
def s(): return input()
def hi(n): return [i() for _ in range(n)]
def hs(n): return [s() for _ in range(n)]#HeightString
def mi(n): return [wi() for _ in range(n)]#MatrixInt
def mip(n): return [wip() for _ in range(n)]
def ms(n): return [ws() for _ in range(n)]

a, b = wi()
if (a + b) / 2 == int((a + b) / 2):
    print(int((a + b) / 2))
else:
    print("IMPOSSIBLE")

Measured memory_bytes: 6484
//! Framework <https://github.com/vain0x/procon>

#![allow(non_snake_case)]
#![allow(unused_imports)]

use std::collections::*;

pub struct Scan(Box<dyn Iterator<Item = &'static str>>); // '

impl Scan {
    fn new() -> Self {
        let mut buf = String::new();
        let read_line = move || {
            std::io::stdin().read_line(&mut buf).unwrap();
            Box::leak(buf.split_off(0).into_boxed_str()).split_whitespace()
        };
        Scan(Box::new(std::iter::repeat_with(read_line).flatten()))
    }

    pub fn word<T: std::str::FromStr>(&mut self) -> T {
        self.0.next().unwrap().parse().ok().unwrap()
    }

    pub fn list<T: std::str::FromStr>(&mut self, len: usize) -> Vec<T> {
        std::iter::repeat_with(|| self.word()).take(len).collect()
    }
}

fn main() {
    let mut scan = Scan::new();

    let S = scan.word::<usize>();
    let W = scan.word::<usize>();

    let is_unsafe = W >= S;

    println!("{}", if is_unsafe { "unsafe" } else { "safe" });
}


Measured memory_bytes: 2096
n = int(input())
l = list(map(int,input().split()))
dp = [0] * n
 
dp[1] = abs(l[0] - l[1])
 
for i in range(2,n):
    a = abs(l[i] - l[i-2]) + dp[i-2]
    b = abs(l[i] - l[i-1]) + dp[i-1]
    if a <= b:
        dp[i] = a
    else:
        dp[i] = b
 
print(dp[-1])

Measured memory_bytes: 20560
import math

A, B, H, M = map(float,input().split())

rad_M = math.radians(6*M)
rad_H = math.radians(30*H+0.5*M)
rad = abs(rad_M-rad_H)
if rad >= math.pi:
  rad = 2*math.pi - rad

S = (A**2) + (B**2) - 2*A*B*math.cos(rad)
S = S**0.5
print(S)

Measured memory_bytes: 9512
// Problem : C - Step
// Contest : AtCoder - AtCoder Beginner Contest 176
// URL : https://atcoder.jp/contests/abc176/tasks/abc176_c
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include <bits/stdc++.h>
#define ll long long
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL)
#define fr(i,a,b) for(int i=a;i<b;i++)
#define frr(i,a,b) for(int i=a;i>=b;i--)
//vector
#define pb push_back
#define vi vector<int>
#define vl vector<ll>
#define pp pop_back
//pair
#define pi pair<int ,int >
#define mk make_pair
#define ff first
#define ss second
//set
#define si set<int>
#define sit set<int>::iterator 
using namespace std;
int main()
{
	/*
	#ifndef ONLINE_JUDGE
        freopen("input.txt","r",stdin);
        freopen("output.txt","w",stdout);
	#endif
	*/
fast;
ll n;cin>>n;
ll ans=0,cmp;
fr(i,0,n)
{
	ll x;cin>>x;
	if(i==0) cmp=x;
	else if(x<cmp)
	{
		ans+=(cmp-x);
	}
	else
	{
		cmp=x;
	}
}
cout<<ans;
return 0;
}

Measured memory_bytes: 3664