akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <unordered_map>
#include <map>
#include <algorithm>
#include <set>
#include <unordered_set>
#include <deque>
#include <cmath>
#include <stack>
#include <queue>
#include <string>
#include <iomanip>
#include <cstring>
#include <climits>
#include <cstdio> 

#define nl '\n'

using namespace std;

string n;

int main(){

    cin >> n;

    for(long long i = 0; i < n.length(); i++) {
        if(n[i] == '7') {
            cout << "Yes";
            return 0;
        }
    }

    cout << "No";


}
 
//g++ -std=c++14 comp.cpp -o c && c.exe
//g++ -std=c++14 comp.cpp -o c; ./c.exe
//g++ -std=c++14 comp.cpp && ./a.out

//Surely this is going to AC

Measured memory_bytes: 3604
#include<iostream>
#include<vector>
#include <cmath>
#include <map>
#include <algorithm>
using namespace std;
int main(void){
    int K , X ;
    cin >> K >> X;
    if(K * 500 >= X){
        cout << "Yes" << endl;
    }else{
        cout <<"No" << endl;
    }
    return 0;
}

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

#define rep(i, n) for (int i = 0; i < n; i++)
#define repr(i, n) for (int i = n-1; i >= 0; i--)
#define ALL(x) x.begin(),x.end()

using ll = long long;
using pii = pair<int, int>;
using vi = vector<int>;

const int mod = 1e9+7;
const ll INF = 1e18;
const int MAX = 1e6;

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

struct edge {int to, cost;}; // 辺
// vector<edge> graph[MAX]; // 隣接リスト
bool visited[MAX]; // 訪問状況

int n, m; // 変数
ll k;
int a[MAX];

int main() {
// input
    cin >> n >> k;
    rep(i, n+1) {
        if (i > 0) cin >> a[i];
    }
// solve
    int cnt = 1; // ループに突入するテレポート回数
    int start = 1;
    visited[start] = true;
    int next = a[start];
    while (not visited[next]) {
        cnt++;
        visited[next] = true;
        next = a[next];
    }
    int loop_start = next; // ループの始点
    // printf("ループに突入するテレポート回数%d\n", cnt);
    // printf("ループの始点%d\n", next);
    int ans;
    if (cnt < k) {
        next = 1;
        int d = 0; // ループ始点までに訪問する都市の数
        while (next != loop_start) {
            d++;
            next = a[next];
        }
        int loop_size = cnt - d;
        // printf("ループの大きさ%d\n", loop_size);
        int pos = 1;
        rep(i, d) {
            pos = a[pos];
        }
        if (loop_size == 0) {
            ans = pos;
        } else {
            rep(i, (k-d)%loop_size) {
                pos = a[pos];
            }
            ans = pos;
        }
    } else {
        int pos = 1;
        rep(i, k) {
            pos = a[pos];
        }
        ans = pos;
    }
// output
    cout << ans << "\n";
}

Measured memory_bytes: 4616
using System;
 
namespace Sample
{
  class Sample
  {
    static void Main(string[] args)
    {
    string[] input =Console.ReadLine().Split(' ');
    int a =int.Parse(input[0]);
    int b =int.Parse(input[1]);
    int c =int.Parse(input[2]);
      
      if (a == b){
        Console.WriteLine(c);
      }else if (b == c){
        Console.WriteLine(a);
      }else{
        Console.WriteLine(b);
      }
    }
    
  }

}

Measured memory_bytes: 11092
import sys

stdin = sys.stdin

ns = lambda: stdin.readline().rstrip()
ni = lambda: int(stdin.readline().rstrip())
nm = lambda: map(int, stdin.readline().split())
nl = lambda: list(map(int, stdin.readline().split()))

k,n = nm()
a = nl()
a.append(a[0] + k)
print(k - max(a[i+1] - a[i] for i in range(n)))


Measured memory_bytes: 25880
#include<bits/stdc++.h>
#define ll long long
using namespace std;
ll gcd(ll a,ll b)
{
if(b==0)
{
return a;
}
return gcd(b,a%b);
}
int main()
{
long long n;
ll dp[201][201];
ll ans=0;
memset(dp,-1,sizeof(dp));
cin>>n;
for(ll i=1;i<=n;i++)
{
for(ll o=1;o<=n;o++)
{
for(ll j=1;j<=n;j++)
{
ll k;
if(dp[i][o]==-1)
{
dp[i][o]=gcd(i,o);
}
k=dp[i][o];
if(dp[k][j])
{
dp[k][j]=gcd(k,j);
}
ans+=dp[k][j];
}
}
}
cout<<ans;
return 0;
}

Measured memory_bytes: 3936
#require 'prime'
#require 'openssl'
MOD=10**9+7;  cnt=0; sum=0; prev=nil; can=true; h=Hash.new(0)
def gs() gets.chomp end
def gi() gets.chomp.to_i end
def gsmi() gets.chomp.split.map(&:to_i) end

def ar2(s1,s2,de=nil) Array.new(s1){Array.new(s2,de)} end
def ar3(s1,s2,s3,de=nil) Array.new(s1){Array.new(s2){Array.new(s3,de)}} end

def desc(ar) ar.sort!{|x,y| y<=>x} end
def min(a,b) a<=b ? a : b end
def max(a,b) a>=b ? a : b end
def sum(ar) ar.inject(:+).to_i end
def ceil(a,b) (a.to_f/b).ceil end

def C(a,b) b==0||a==b ? 1 : (b=a-b if a/2<b;(a-b+1..a).inject(:*)/(1..b).inject(:*)) end
def rui(ar) s=[0]; ar.size.times{|i| s<<s[-1]+ar[i]}; s end
def rev_rui(ar) s=[0]; ar.size.times.reverse_each{|i| s<<s[-1]+ar[i]}; s end

def puts_yesno(b) puts(b ? 'Yes' : 'No') end
def putsend(s) puts s; exit end
def pu(h) begin; require './../nemi_lib/debug.rb'; puts_val(h); rescue LoadError; end; end
########### ( ˘ω˘ )ｽﾔｧ… ###########
a,b,c,d=gsmi
t_turn=ceil(c,b)
a_turn=ceil(a,d)
puts_yesno t_turn<=a_turn

Measured memory_bytes: 14336
package main

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

var sc = bufio.NewScanner(os.Stdin)

func nextLine() string {
    sc.Scan()
    return sc.Text()
}

func nextInt() int {
    sc.Scan()
    i, _ := strconv.Atoi(sc.Text())
    return i
}

func storeIntArr(n int) []int {
    var a []int
    for i := 0; i < n; i++ {
        a = append(a, nextInt())
    }
    return a
}

// 数値を桁区切りのスライスにする
func digit(n int, list []int) []int {
   if n > 0 {
       return digit(n/10, append(list, n%10))
   }
   return list
}

func sortIntsRev(list []int) {
    sort.Sort(sort.Reverse(sort.IntSlice(list)))
}


func main() {
    sc.Split(bufio.ScanWords)
    //sc.Split(bufio.ScanLines)

    n, y := nextInt(), nextInt()

    for i := y/10000; i >= 0; i-- {
        for j := (y-i*10000)/5000; j >= 0 ; j-- {
            z := n - i - j
            if z >= 0 && y == (i*10000+5000*j+z*1000) {
                fmt.Println(i, j, z)
                os.Exit(0)
            }
        }
    }

    fmt.Println(-1, -1, -1)
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
#define int long long
#define P pair<int,int>
#define PP pair<P,int>
#define F first
#define S second
#define f(i,n) for(int i=0;i<(n);i++)
#define INF LLONG_MAX/3
#define eps LDBL_EPSILON
#define mod (int)(1000000007)
#define pie 3.141592653589793238462643383279
#define Bpri priority_queue
#define Spri priority_queue<P,vector<P>,greater<P>>
using namespace std;
int n,x[100000];
signed main(){
	cin>>n;
	int sum=0,s=0,mi=INF;
	f(i,n){
		cin>>x[i];
		sum+=x[i];
	}
	f(i,n){
		s+=x[i];
		mi=min({mi,abs(s-(sum-s))});
	}
	cout<<mi<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1LL<<62
#define inf 1000000007

int main() {
	string s;
	cin>>s;
	ll ans=0,cnt=0;
	for(int i=s.size()-1;i>=0;i--){
		//cout << s[i];
		if(i!=0&&s[i]=='C'&&s[i-1]=='B'){
			cnt++;
			i--;
		}
		else if(s[i]=='A'){
			ans+=cnt;
		}
		else{
			cnt=0;
		}
	}
	cout <<ans;
	// your code goes here
	return 0;
}

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

int		main(void)
{
	vector<int> Group1 = {1,3,5,7,8,10,12};
	vector<int> Group2 = {4,6,9,11};
	int Group3 = 2;
	int		a, b;
	int		cnt = 0;
	cin >> a >> b;
	for (auto &i : Group1)
	{
		if (i == a)
			cnt++;
		if (i == b)
			cnt++;
		if (cnt == 2)
			goto OUT;
	}
	cnt = 0;
	for (auto &i : Group2)
	{
		if (i == a)
			cnt++;
		if (i == b)
			cnt++;
		if (cnt == 2)
			goto OUT;
	}
	cnt = 0;
	if (Group3 == a)
		cnt++;
	if (Group3 == b)
		cnt++;
	OUT:
	cout << (cnt == 2 ? "Yes" : "No") << endl;
}

Measured memory_bytes: 256
#include <cstring>
#include <sstream>
#include <cstdio>
#include <algorithm>
#include <iostream>
#include <vector>
#include <map>
#include <unordered_map>
#include <cmath>
#include <queue>
#include <set>
#include <numeric>
#include <stack>

using namespace std;
typedef long long ll;
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define repr(i, n) for(ll i = n - 1; i >= 0; i--)
#define repone(i, n) for(ll i = 1; i <= (ll)(n); i++)
#define each(i, mp) for(auto i:mp)
const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
const ll mod = 1000000007;
const ll inf = ll(1e9);
const ll half_inf = ll(1e5);
const ll ll_inf = ll(1e9) * ll(1e9);
typedef unordered_map<ll, ll> ump;
typedef pair<ll, ll> P;

ump mp;

ll getnum(ll x) {
    switch (x) {
        case 1:
            return 2;
        case 2:
            return 5;
        case 3:
            return 5;
        case 4:
            return 4;
        case 5:
            return 5;
        case 6:
            return 6;
        case 7:
            return 3;
        case 8:
            return 7;
        case 9:
            return 6;
        default:
            throw "invalid number";
    }

}

string max_s(string s1, string s2) {
    if (s1.size() == s2.size()) return s1 > s2 ? s1 : s2;
    else return s1.size() > s2.size() ? s1 : s2;
}

int main() {
#ifdef MY_DEBUG
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wmissing-noreturn"
    while (true) {
        mp = ump();
#pragma clang diagnostic pop
#endif
        ll n, m;
        cin >> n >> m;
        vector<ll> a(m);
        rep(i, m) cin >> a[i];

        string dp[n + 1];
        rep(i, n + 1) dp[i] = "-";
        dp[0] = "";
        rep(i, n + 1) {
            rep(j, a.size()) {
                if (i < getnum(a[j])) continue;
                if (dp[i - getnum(a[j])] == "-") continue;
                else {
                    dp[i] = max_s(dp[i - getnum(a[j])] + to_string(a[j]), dp[i]);
                }
            }
        }
        cout << dp[n] << endl;


#ifdef MY_DEBUG
    }
#endif
    return 0;
}

Measured memory_bytes: 31872
x,k,d=map(int, input().split())
x=abs(x)
if x-k*d>=0:
  print(x-k*d)
elif x==0:
  if k%2==0:
    print(0)
  else:
    print(k)
else:
  m=x//d
  if (k-m)%2==0:
    print(x-m*d)
  else:
    print(abs(x-(m+1)*d))

Measured memory_bytes: 9184
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<double,double> pdd;
typedef vector<pii> vii;
#define IOS ios_base::sync_with_stdio(0); cin.tie(0)
#define ALL(a) a.begin(),a.end()
#define SZ(a) ((int)a.size())
#define F first
#define S second
#define rep(i,n) for(int i=0;i<((int)n);i++)
#define rep1(i,n) for(int i=1;i<=((int)n);i++)
#define pb push_back
#define mp(a,b) make_pair(a,b)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
template<typename T1,typename T2>
ostream& operator<<(ostream& out,pair<T1,T2> P){
	out<<'('<<P.F<<','<<P.S<<')';
	return out;
}

//}}}
const ll maxn= 55;
const ll maxlg=__lg(maxn)+2;
const ll INF64=8000000000000000000LL;
const int INF=0x3f3f3f3f;
const ll MOD=ll(1e9+7);
const double PI=acos(-1);
//const ll p=880301;
//const ll P=31;

ll mypow(ll a,ll b){
	ll res=1LL;
	while(b){
		if(b&1) res=res*a%MOD;
		a=a*a%MOD;

		b>>=1;
	}
	return res;
}

ll dp[maxn][maxn][maxn],n,t;
int main()
{
	//IOS;
    string s;
    int k;
    while(cin>>n>>s>>k)
    {
        rep(i,n)
        {
            if(s[i]!=s[k-1]) cout<<'*';
            else cout<<s[i];
        }
        cout<<"\n";
    }
	return 0;
}

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

int main() {

  int d[26] = { 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 1, 0, 0, 0, 1, 0 };

  while( true ) {

    string in;
    cin >> in;
    if ( in == "#" ) break;

    long long int h = d[ in[0] - 'a' ];
    long long int ans = 0;

    for ( long long int i = 0; i < in.size(); i++ ) {

      long long int k = d[ in[i] - 'a' ];
      if ( h != k ) ans++;
      h = k;

    }
    cout << ans << endl;

  }

  return 0;

}

Measured memory_bytes: 1188
import java.util.Arrays;
import java.util.Collections;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();
		int k = scan.nextInt();
		Integer[] l = new Integer[n];
		for(int i=0;i<n;i++) {
			l[i]=scan.nextInt();
		}
		Arrays.sort(l, Collections.reverseOrder());
		int sum=0;
		for(int i=0;i<k;i++) {
			sum=sum + l[i];
		}
		System.out.println(sum);
	}

}


Measured memory_bytes: 21844
#include <iostream>
#include <map>
#include <string>

using namespace std;

int main(){
	map<char,int> mp;
	int count = 0;
	string S;
	for(int i = 0;i < 26;i++){
		mp['a' + i] = 0;
	} 

	cin >> S;
	for(int i = 0;i < S.size();i++){
		mp[S[i]]++;	
	}

	for(int i = 0;i < 26;i++){
		if(mp['a'+ i] % 2 != 0){
			count++;
		}
	}

	if((S.size() % 2 == 0 && count % 2 == 0) || (S.size() % 2 != 0 && count % 2 != 0)){
		cout << count / 2 << endl;
	} else {
		cout << count / 2 + 1 << endl; 
	}

	return 0;	
}

Measured memory_bytes: 3176
// https://atcoder.jp/contests/abc158/tasks/abc158_c
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define REP(i, n) FOR(i, 0, n)
#define REPR(i, n) for (int i = n - 1; i >= 0; i--)
#define FOR(i, s, n) for (int i = (s), i##_len = (n); i < i##_len; ++i)
#define ALL(obj) (obj).begin(), (obj).end()
#define ALLR(obj) (obj).rbegin(), (obj).rend()
#define DIV(a, b) ((a - 1) / b + 1)

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int A, B;
    cin >> A >> B;
    double calcA1 = (double)A / 0.08;
    double calcA2 = (double)(A + 1) / 0.08;
    double calcB1 = (double)B / 0.1;
    double calcB2 = (double)(B + 1) / 0.1;
    if (calcA1 < calcB2 && calcB1 < calcA2) {
        int minv = ceil(min(calcA1, calcB1));
        int maxv = max(calcA2, calcB2);
        FOR(i, minv, maxv + 1) {
            if (floor(i * 0.08) == A && floor(i * 0.1) == B) {
                cout << i << endl;
                break;
            }
        }
    } else {
        cout << -1 << endl;
    }

    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String args[]){
        Scanner stdIn = new Scanner(System.in);
        //int a = stdIn.nextInt();
        //int b = stdIn.nextInt();
        int n = stdIn.nextInt();
        //int p = stdIn.nextInt();
        int k = stdIn.nextInt();
        String s = stdIn.next();
        String ss = s.toLowerCase();
        char sc[] = ss.toCharArray();
        char c[] = s.toCharArray();
        
        for(int i = 0; i < n; i++){
            if(i != k - 1){
                System.out.print(c[i]);
            }else{
                System.out.print(sc[i]);
            }
        }
        
        
        
        
        
        System.out.println();
    }
}


Measured memory_bytes: 23764
#include <stdio.h>          // printf(), scanf()
#include <stdbool.h>

#define N 12
char field[N][N];

void
dfs(int x, int y)
{
	int dx[4] = {1, 0,-1, 0};
	int dy[4] = {0, 1, 0,-1};
	int i;

	field[y][x] = '.';
	for (i = 0; i < 4; ++i)
	{
		int nx = x + dx[i], ny = y + dy[i];
		if (0 <= nx && nx < N && 0 <= ny && ny < N && field[ny][nx] == '1')
			dfs(nx, ny);
	}
}

int
main(int argc, char **argv)
{
	char c;
	int x, y;

	while (true)
	{
		for (y = 0; y < N; ++y)
		{
			for (x = 0; x < N; ++x)
				 if (scanf("%c", &field[y][x]) == EOF)
				 	goto l_end;

			scanf("%c", &c);
			if (c != '\n')
				goto l_end;
		}

		int count = 0;
		for (y = 0; y < N; ++y)
		{
			for (x = 0; x < N; ++x)
			{
				if (field[y][x] == '1')
				{
					dfs(x, y);
					count++;
				}
			}
		}

		printf("%d\n", count);
		scanf("%c", &c);
		if (c != '\n')
			break;
	}

l_end:
	return 0;
}

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

using lint = long long;

int main() {
    ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    lint a, b, c, d;
    cin >> a >> b >> c >> d;
    lint lcm = c*d/__gcd(c,d);
    --a;
    lint x = b/c - a/c;
    lint y = b/d - a/d;
    lint z = b/lcm - a/lcm;
    cout << (b - a) - (x + y) + z << '\n';
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n;
	cin >> n;
	int g[n][n];
	for(int i = 0; i < n; i++)
		for(int j = 0; j < n; j++)
			g[i][j] = 100000000;
	int r,k,t;
	for(int i = 0; i < n; i++){
		cin >> r >> k;
		r--;
		for(int j = 0; j < k; j++){
			cin >> t;
			t--;
			g[r][t] = 1;
		}
	}
	int p;
	cin >> p;
	for(int i = 0; i < p; i++){
		int s,d,v;
		cin >> s >> d >> v;
		s--; d--;
		vector <int> used(n,false);
		vector <int> dist(n,100000000);
		dist[s] = false;
		while(1){
			int va = -1;
			for(int j = 0; j < n; j++){
				if(used[j] == false && (va == -1 || dist[va] > dist[j]))
					va = j;
			}
			if(va == -1)
				break;
			used[va] = true;
			for(int j = 0; j < n; j++)
				dist[j] = min(dist[j] , dist[va] + g[va][j]);	
		}

		if(v > dist[d])
			cout << dist[d] + 1 << endl;
		else
			cout << "NA" << endl;
	}
	return 0;
}

Measured memory_bytes: 3096
import math
 

def is_prime(n):
    if n == 1: return False

    for k in range(2, int(math.sqrt(n)) + 1):
        if n % k == 0:
            return False

    return True


X=int(input())
judge=not is_prime(X)
while judge:
    X+=1
    judge=not is_prime(X)
    
print(X)

Measured memory_bytes: 3060
#include <iostream>
          
bool is_correct_circle_center_point(int x, int y) {
    if(x > 0 && y > 0) return true;
          
    return false;
}         
          
bool is_axis_contains(int a, int b, int r) {
    if(a - r < 0) return false;
    if(a + r > b) return false;
          
    return true;
}         
          
bool is_contains(int x, int y, int w, int h, int r) {
    if(!is_correct_circle_center_point(x, y)) return false;
          
    if(!is_axis_contains(x, w, r)) return false;
    if(!is_axis_contains(y, h, r)) return false;
          
    return true;
}         
          
int main() {
    int x, y, w, h, r = 0;     
    std::cin >> w >> h >> x >> y >> r;
    if(is_contains(x, y, w, h, r)) {
        std::cout << "Yes" << std::endl;
    }     
    else {  
        std::cout << "No" << std::endl;
    }       
    return 0;
}

Measured memory_bytes: 1156
s = int(input())

dict = {}
dict[s] = 1

last_a = s
f = 0
n = 2
ans = 0
while True:
    if last_a % 2 == 0:
        last_a = last_a // 2
    else:
        last_a = 3 * last_a + 1

    if last_a not in dict.keys():
        dict[last_a] = n
    else:
        ans = n
        break
    n += 1

print(ans)


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

int main() {
    int x, ans;
    cin >> x;
    ans = 1000 * (x / 500) + 5 * (x % 500 / 5);
    cout << ans << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;
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();
        if (a < c && b < c) {
            if (a < b) {
                System.out.printf("%d %d %d\n", a, b, c);
            } else {
                System.out.printf("%d %d %d\n", b, a, c);
            }
        } else if (a < b && c < b){
            if (a < c) {
                System.out.printf("%d %d %d\n", a, c, b);
            } else {
                System.out.printf("%d %d %d\n", c, a, b);
            }
    }else {
            if (b < c) {
                System.out.printf("%d %d %d\n", b, c, a);
            }else {
                System.out.printf("%d %d %d\n", c, b, a);
            }
        }

            }
    }


Measured memory_bytes: 26500
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
#define pf push_front
#define fr first
#define sc second
#define r_0 return 0
#define ld long double

using namespace std;

    const ll N = 1e5 + 7;
    const ll mod = 1e9 + 7;
ll n  , ans , m , a ,b , c , d, cnt;
string s , s1;
int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    cin >> s >> s1;
    for( int i = 0;i < s.size();i ++ ){
        if( s[i] != s1[i] )
            cnt ++;
    }
    cout << cnt;
}


Measured memory_bytes: 3744
using System;

namespace A___Apple_Pie
{
    class Program
    {
        static void Main (string[] args)
        {
            var input = Console.ReadLine ().Split (' ');
            var a = int.Parse (input[0]);
            var p = int.Parse (input[1]);
            Console.WriteLine ((a * 3 + p) / 2);
        }
    }
}

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

int main() {
  int a,b,c;
  cin >> a >> b >> c;
  if(a+b==c){
    cout << "Yes" << endl;
  }
  else if(a+c==b){
    cout << "Yes" << endl;
  }
  else if(b+c==a){
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define fo(i,a,b) for(register int (i)=(a);(i)<=(b);++(i))
#define of(i,a,b) for(register int (i)=(a);(i)>=(b);--(i))
#define rd read()
#define maxn 500001
#define ll long long
#define fre(a) freopen("a.in","r",stdin);freopen("a.out","w",stdout);
const int p=998244353;
int read() {int x=0,f=1;char ch=getchar();while(!isdigit(ch)){if(ch=='-')f=-1;ch=getchar();}while(isdigit(ch))x=x*10+ch-'0',ch=getchar();return x*f;}
void print(int x) { if(x<0){putchar('-');x=-x;}if(x>9)print(x/10);putchar(x%10+'0');}
int qp(int a, int  b) {int ans = 1;for(; b; b >>= 1, a *= a, a %= p) if(b & 1) ans *= a, ans %= p;return ans % p;}
int a[maxn];
int main() {
    int n=rd,m=rd;
    fo(i,1,m)
    {
    	int x=rd,y=rd;a[x]++;a[y]++;
	}
	fo(i,1,n)
	{
		print(a[i]),puts(" ");
	}
    return 0;
}

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

int main(){
    int n;
    cin>>n;
    int x[n];
    for(int i=0;i<n;i++){
        cin>>x[i];
    }
    int cnt=0;
    int breakflag=false;
    while(1){
        for(int i=0;i<n;i++){
            if(x[i]%2==0){
                x[i]/=2;
            }else{
                breakflag=true;
            }
        }
        if(breakflag){
            break;
        }else{
            cnt++;
        }
    }
    cout<<cnt<<endl;
}

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

//for loop関係
#define rep(i,a,n) for(int i=(a);i<(n);++i)
#define repe(i,a,n) for(int i=(a);i<=(n);++i)
#define rrep(i,n,a) for(int i=(n);n>(a);--i)
#define rrepe(i,n,a) for(int i=(n);n>=(a);--i)

//略記
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define all(v) v.begin(),v.end()
#define ENDL << "\n"

using ll = long long;
using P = pair<int,int>;
using itn = int;

//定数
const int INF = 1<<30;
const ll MOD = 1000000007;
const long double PI =(acos(-1));

/***スニペット***
ifelse, isprime, torad, todeg, lcm, bfs
****************/

//隣接リスト
vector<int> to[100005];

int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    string s;
    cin >> s;
    vector<string> a={"Sunny","Cloudy","Rainy"};
    rep(i,0,3){
        if(a[i]==s){
            cout << a[(i+1)%3] ENDL;
        }
    }
    
    return 0;
}

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

struct Q{
    int a, b, c, d;
};
Q q[60];
int arr[11];
int n, m, qq;
int ans;
void dfs(int idx, int val){
    if(idx>n){
        int t = 0;
        for(int i=0; i<qq; ++i){
            int a=q[i].a, b=q[i].b, c=q[i].c, d=q[i].d;
            if(arr[b]-arr[a]==c) t += d;
        }
        ans = max(ans, t);
        return;
    }
    for(int i=val; i<=m; ++i){ arr[idx]=i; dfs(idx+1, i); }
}

int main()
{
    scanf("%d%d%d", &n, &m, &qq);
    for(int i=0; i<qq; ++i){
        scanf("%d%d%d%d", &q[i].a, &q[i].b, &q[i].c, &q[i].d);
    }
    dfs(1,1);
    printf("%d\n", ans);
}

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

using namespace std;

const int mxn = 2e5 + 10;
const int Mod = 1e9 + 7;

long long Ans = 0, s = 0;
int arr[mxn];

int main()
{
    ios::sync_with_stdio(false);

    int n;
    cin>>n;
    for(int i=0 ; i<n ; i++){
        cin>>arr[i];
        s+=arr[i];
    }

    for(int i=0 ; i<n ; i++){
        s-=arr[i];
        Ans += (((s%Mod)*1LL*(arr[i]%Mod))%Mod);
        Ans%=Mod;
    }
    cout<<Ans<<endl;

    return 0;
}


Measured memory_bytes: 4380
import java.util.Scanner;

public class Main{
	public static void main(String[] args) {
		// 標準入力からデータを読み込む準備
		Scanner sc = new Scanner(System.in);
		// 2つの文字の固まりをそれぞれ整数値と想定して読み込む
		int a = sc.nextInt();
		int b = sc.nextInt();
		int area = a * b;
		/* ここを変えて面積を求めよう */;
		int length = 2 * a + 2 * b;
		/* ここを変えて周囲の長さを求めよう */;
		System.out.println(area + " " + length);
	}
}


Measured memory_bytes: 26176
//#include "bits/stdc++.h"
#include <iostream>
#include <vector>
#include <map>
#include <utility>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <stack>
#include <queue>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <numeric>
#include <complex>
#include <bitset>
#include <functional>
#include <stack>
#include <regex>
#include <tuple>
#include <iomanip>


#define int long long
#define REP(i,l,r) REPEAT(i,l,r,true) // [l, r)
#define rep(i,n) REP(i,0,n)           // [0, n)
#define REPEAT(i,l,r,condition) for(int i=(condition)?l:r-1;(condition)?i<r:i>=l;(condition)?++i:--i) // false<-[l, r)->true
#define all(e) e.begin(),e.end()
#define rall(e) e.rbegin(),e.rend()
#define pb push_back
#define fs first
#define sc second
#ifdef LOCAL
#define show(...) cerr<<#__VA_ARGS__<<" = ";_DEBUG(__VA_ARGS__)
#define showlr(n,l,r) cerr<<#n<<" = ";for(int i=l;i<r;i++){cerr<<n[i]<<", ";}cerr<<endl // [l, r)
#else
#define show(...)
#define showlr(n,l,r)
#endif

#define YN(condition) puts((condition)?"YES":"NO")
#define Yn(condition) puts((condition)?"Yes":"No")
#define yn(condition) puts((condition)?"yes":"no")
#define YES puts("YES")
#define Yes puts("Yes")
#define yes puts("yes")
#define NO  puts("NO")
#define No  puts("No")
#define no  puts("no")

#define case(i) printf("Case #%lld: ",i)

using namespace std;

using vi=vector<int>;
using pint=pair<int,int>;

struct io{io(){cin.tie(0);ios::sync_with_stdio(false);cout.tie(0);cout<<fixed<<setprecision(20);}}io;

template<class T> istream& operator >>(istream &is, vector<T> &v){for(T &e:v)is>>e;return is;}
template<class T> ostream& operator <<(ostream &os, vector<T> v){os<<"{";for(T &e:v)os<<e<<(v.size()-(int)(&e-&v[0])>1?", ":"");os<<"}";return os;}

void _DEBUG(){}
template<typename H,typename... T> void _DEBUG(H a,T...b){cerr<<a<<(sizeof...(b)?",":"\n");_DEBUG(b...);}

inline void in(){}
template<typename H,typename... T>void in(H &a, T&... b){cin>>a;in(b...);}
inline void out(){}
template<typename H,typename... T> void out(H a, T... b){cout<<a<<(sizeof...(b)?" ":"\n");out(b...);}

template<class T> void resz(int n,T& v){v.resize(n);}
template<class H,class... T> void resz(int n,H& a,T&... b){a.resize(n);resz(n,b...);}

template<typename V,typename H> void resize(vector<V>& v,const H a){v.resize(a);}
template<typename V,typename H,typename... T> void resize(vector<V>& v,const H& a,const T... b){v.resize(a);for(auto &v:v) resize(v,b...);}

const int INF=1LL<<55;
const int MOD=1000000007;
const double EPS=1e-8;
/*------------end of definitions------------*/

int N,A,B;

signed main(){

    in(N,A,B);
    out(min(A,B),A+B-N<0?0:A+B-N);

    return 0;
}


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

#define ll long long
#define ull unsigned long long
#define ld long double
#define Yes cout<<"Yes\n"
#define No cout<<"No\n"
#define fo(i,start,end) for(int i=start;start<end?i<end:i>end;start<end?i+=1:i-=1)
#define pb push_back
#define mp make_pair
#define lb lower_bound
#define ub upper_bound
#define F first
#define S second
#define vll vector<ll>
#define pll pair<ll,ll>
#define vop vector<pll>
#define vov vector<vector<ll>>
#define endl "\n"
using namespace std;
const ld pi=3.14159265358979323;

const long long mod1=1e9+7;
const long long mod2=1e18;
const ll mod3=9e18;
const ll N=1e9+7;

long long power(ll  x, ll n){if(n==0)return 1;ll temp=power(x,n/2);if(n%2==0)return temp*temp;else return x*temp*temp;}

ll gcd(ll a,ll b){if(a<b) return gcd(b,a);if(b==0) return a;return gcd(b,a%b);}
ll lcm(ll a,ll b){return (a*b)/(gcd(a,b));}
void swap(int* a, int* b){int t = *a;*a = *b;*b = t;}
bool f(ll x,ll y){return x>y;}

ll MAX(ll a,ll b){return a>b?a:b;}
ll MIN(ll x,ll  y){return x>y?y:x;}

ll pmod(ll a, ll b,ll mod)//a^b%mod
{
    ll ans=1;
    while(b)
    {
        if(b&1)
            ans=(ans*a)%mod;
        b/=2;
        a=(a*a)%mod;
    }
    return ans;
}

bool cmp2( pair<ll,ll> &a,
           pair<ll,ll> &b)
{
    return a.second>b.second;
}


void solve() {
    ll n,k;
    cin>>n>>k;
    ll arr[n+1];
    fo(i,1,n+1)cin>>arr[i];
    ll ans[k+1];
    memset(ans,0,sizeof(ans));

    for(ll i=1;i<=k;i++){
        for(ll j=1;j<=n;j++){
            if(i-arr[j]>=0){
                if(ans[i-arr[j]]==0){
                    ans[i]=1;
                    break;
                }

            }
        }

    }


if(ans[k]==1){
    cout<<"First";
}
    else {
        cout<<"Second";
    }






}

























int main() {

    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
#ifndef ONLINE_JUDGE
    freopen("input.txt" , "r" , stdin) ;
    freopen("output.txt" , "w" , stdout) ;
    //freopen("error.txt" , "w" , stderr) ;
#endif








    ll t;
    t=1;
    //cin>>t;
    //  cin.ignore();
    while(t--){

        solve();
    }




    return 0;


}

////vll adj[100001];
////ll vis[100001];
////ll sssp[100001];

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

using namespace std;

using ll = long long;

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

    ll x, t = 0;
    cin >> x;

    while (t <= x) {
        ll sum = t * (t + 1) / 2;
        if (x <= sum) break;
        ++t;
    }

    cout << t << endl;

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
long long a [100010];
int main (){
int n;
scanf("%d",&n);
for(int i=0;i<n;i++) scanf("%lld",&a[i]);
int zero =0;

for(int i=0;i<n;i++)if(a[i]==0) zero ++;
if(zero >0){
// a[i] contains 0
printf("0\n");
return 0;
}
long long prod =1;
for(int i=0;i<n;i++){
if(a[i ] <=1000000000000000000/ prod ){
// This condition is equivalent to prod*a[i] <=10ˆ18
prod *=a[i];
}else{
printf("-1\n");
return 0;
}
}
printf("%lld\n",prod );
}


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

#define rep(i, n) for (int i = 0; i < int(n); i++)
#define rrep(i, n) for (int i = int(n) - 1; i >= 0; i--)
#define reps(i, n) for (int i = 1; i <= int(n); i++)
#define rreps(i, n) for (int i = int(n); i >= 1; i--)
#define repc(i, n) for (int i = 0; i <= int(n); i++)
#define rrepc(i, n) for (int i = int(n); i >= 0; i--)
#define repi(i, a, b) for (int i = int(a); i < int(b); i++)
#define repic(i, a, b) for (int i = int(a); i <= int(b); i++)
#define each(x, y) for (auto &x : y)
#define all(a) (a).begin(), (a).end()
#define bit(b) (1ll << (b))

using namespace std;

using i32 = int;
using i64 = long long;
using u64 = unsigned long long;
using f80 = long double;
using vi32 = vector<i32>;
using vi64 = vector<i64>;
using vu64 = vector<u64>;
using vf80 = vector<f80>;
using vstr = vector<string>;

inline void yes() { cout << "Yes" << '\n'; exit(0); }
inline void no() { cout << "No" << '\n'; exit(0); }
inline i64 gcd(i64 a, i64 b) { if (min(a, b) == 0) return max(a, b); if (a % b == 0) return b; return gcd(b, a % b); }
inline i64 lcm(i64 a, i64 b) { return a / gcd(a, b) * b; }
inline u64 xorshift() { static u64 x = 88172645463325252ull; x = x ^ (x << 7); return x = x ^ (x >> 9); }
void solve(); int main() { ios::sync_with_stdio(0); cin.tie(0); cout << fixed << setprecision(16); solve(); return 0; }
template <typename T> class pqasc : public priority_queue<T, vector<T>, greater<T>> {};
template <typename T> class pqdesc : public priority_queue<T, vector<T>, less<T>> {};
template <typename T> inline void amax(T &x, T y) { if (x < y) x = y; }
template <typename T> inline void amin(T &x, T y) { if (x > y) x = y; }
template <typename T> inline T power(T x, i64 n, T e = 1) { T r = e; while (n > 0) { if (n & 1) r *= x; x *= x; n >>= 1; } return r; }
template <typename T> istream& operator>>(istream &is, vector<T> &v) { each(x, v) is >> x; return is; }
template <typename T> ostream& operator<<(ostream &os, vector<T> &v) { rep(i, v.size()) { if (i) os << ' '; os << v[i]; } return os; }
template <typename T, typename S> istream& operator>>(istream &is, pair<T, S> &p) { is >> p.first >> p.second; return is; }
template <typename T, typename S> ostream& operator<<(ostream &os, pair<T, S> &p) { os << p.first << ' ' << p.second; return os; }

void solve() {
  int n; cin >> n;
  string s; cin >> s;
  char prev = s[0];
  int cnt = 1;
  reps(i, n - 1) {
    if (prev != s[i]) {
      cnt++;
      prev = s[i];
    }
  }
  cout << cnt << endl;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
using P = pair<int, int>;

int main() {
  int h, w;
  cin >> h >> w;
  vector<string> g(h);
  vector<vector<bool>> seen(h, vector<bool>(w));
  for(int i=0;i<h;i++) cin >> g[i];
  long long ans = 0;
  long long black = 0, white = 0;
  for(int i=0;i<h;i++) {
    for(int j=0;j<w;j++) {
      if(seen[i][j]) continue;
      queue<P> que;
      que.emplace(make_pair(i, j));
      while(!que.empty()) {
        P p = que.front();que.pop();
        if(seen[p.first][p.second]) continue;
        seen[p.first][p.second] = true;
        char c = g[p.first][p.second];
        if(c == '.') white++;
        else black++;
        if(p.first != 0 && !seen[p.first-1][p.second] && g[p.first-1][p.second] != c) que.emplace(make_pair(p.first-1, p.second));
        if(p.first != h-1 && !seen[p.first+1][p.second] && g[p.first+1][p.second] != c) que.emplace(make_pair(p.first+1, p.second));
        if(p.second != 0 && !seen[p.first][p.second-1] && g[p.first][p.second-1] != c) que.emplace(make_pair(p.first, p.second-1));
        if(p.second != w-1 && !seen[p.first][p.second+1] && g[p.first][p.second+1] != c) que.emplace(make_pair(p.first, p.second+1));
      }
      ans += black * white;
      black = white = 0;
    }
  }
  cout << ans << endl;
}



Measured memory_bytes: 512
H, W=map(int, input().split())

if H==1 or W==1:
  print(1)
else:
  if H%2==0:
    print(int((H/2)*W))
  else:
    first=int((H/2))+1
    sec=first-1
    if W%2==0:
      print(int((first+sec)*(W/2)))
    else:
      print((first+sec)*int((W/2))+first)

Measured memory_bytes: 3060
N = int(input())
A = list(map(int, input().split()))
INF = 10**9

dp0 = [0]
dp1 = [-INF-1]

for i, x in enumerate(A):
  dp0.append( max(dp0[i] + x, dp1[i] - x) )
  dp1.append( max(dp0[i] - x, dp1[i] + x) )

print(dp0[-1])


Measured memory_bytes: 24240
//abc170_b.cpp
//Sun Jun 14 20:56:21 2020

#include <iostream>
#include <string>
#include <queue>
#include <map>
#include <unordered_map>
#include <vector>
#include <algorithm>
#include <math.h>
#include <set>
#define INTINF 2147483647
#define LLINF 9223372036854775807
#define MOD 1000000007

using namespace std;
using ll=long long;
typedef pair<int,int> P;

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

	int flag = 0;
	for (int i=0;i<=100;i++){
		for (int j=0;j<=100;j++){
			if (x==i+j && y==i*2+j*4){
				flag = 1;
			}
		}
	}

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

}

Measured memory_bytes: 3636
#include<iostream>
#include<stdio.h>
//#include <bits/stdc++.h>
#include<vector>
#include<float.h>
#include<iomanip>
#include<algorithm>
#include<string>
#include<cstring>
#include<math.h>
#include<cmath>
#include<sstream>
#include<set>
#include<map>
#include<queue>
#include <cassert>
#include <cmath>
#include<cstdint>

#define INF 1e9
#define rep(i,n)for(int i=0;(i)<(int)(n);i++)
#define REP(i,a,b)for(int i=(int)(a);(i)<=(int)(b);i++)
#define VEC(type, c, n) std::vector<type> c(n);for(auto& i:c)std::cin>>i;
#define vec(type,n) vector<type>(n)
#define vvec(m,n) vector<vector<int>> (int(m),vector<int>(n))
#define ALL(a)  (a).begin(),(a).end()

using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
using P = pair<int,int>;

vector<int>bitSearch(int bit,int n){
    vector<int>S;
    rep(i,n)if(bit&(1<<i))S.push_back(i);
    return S;
}

int d[100][100];             //スタートからの距離を保存
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};


int main(){
   int n;
   cin >> n;
   vector<int> p;
   REP(i, 1, n){
       int a;
       cin >> a;
       if(a == i)p.push_back(i);
   }

   int res = 0;
   const int len = p.size();

   rep(i, len){
       if(p[i] + 1 == p[i + 1]){
           res++;
           i++;
       }
       else res++;
   }
   cout << res << endl;
}



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

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, m;
    cin >> n >> m;
    vector<i64> hs(n);
    vector<p64> his(n);
    for (i64 i = 0; i < n; i++) {
        cin >> hs[i];
        his[i] = { hs[i], i };
    }

    sort(begin(his), end(his), greater());

    vector<vector<i64>> p(n);
    for (i64 i = 0; i < m; i++) {
        i64 a, b;
        cin >> a >> b, a--, b--;
        p[a].emplace_back(b);
        p[b].emplace_back(a);
    }

    vector<i64> g(n, -1);
    for (auto& e : his) {
        i64 h, i;
        tie(h, i) = e;
        if (g[i] != -1) continue;
        i64 res = 1;
        for (auto& j : p[i]) {
            g[j] = 0;
            res &= h > hs[j];
        }
        g[i] = res;
    }

    cout << accumulate(begin(g), end(g), 0l) << endl;
}

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


Measured memory_bytes: 12176
#include <iostream>
#include <cstring>
#include <map>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <set>
#include <vector>
#include <queue>
#include <list>
#include <numeric>
#include <stdio.h>
#include <string>
#include <cstdlib>
#include <math.h>
#include <stack>
#include <climits>
#include <bitset>
#include <utility>


using namespace std;
typedef long long ll;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
// const ll INF = 1LL <<60;
const int INF = 10000;

//最小公倍数
ll gcd(ll x, ll y) {
  ll tmp = 0;
  if (x < y){
    tmp=x;
    x=y;
    y=tmp;
  }
  while (y > 0) {
    ll r = x % y;
    x = y;
    y = r;
  }
  return x;
}

//最大公倍数
ll lcm(ll x,ll y){
  return x/gcd(x,y)*y;
}

const int MAX = 510000;
const int MOD = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}


//階乗
ll kaijo(ll k){
    ll sum = 1;
    for (ll i = 1; i <= k; ++i)
    {
        sum *= i;
        sum%=1000000000+7;
    }
    return sum;
}

//for(int i = ; i < ; i++){}

ll lmax(ll s,ll t){
  if(s>t){
    return s;
  }
  else{
    return t;
  }
}

ll lmin(ll s,ll t){
  if(s<t){
    return s;
  }
  else{
    return t;
  }
}
// ここから開始
int main(){
  int n;
  cin>>n;
  vector<int> l(n);
  int a[3];
  set <pair<int,pair<int,int> > > v;
  for(int i = 0; i < n; i++) cin>>l[i];
  sort(l.begin(),l.end());
  ll sum = 0;
  for(int i = 0; i < n; i++){
    for(int j = i+1; j < n; j++){
      sum+=lower_bound(l.begin(),l.end(),l[i]+l[j])-(l.begin()+j+1);
      }
    }
  cout<<sum<<endl;
  return 0;
}


Measured memory_bytes: 256
n = gets.to_i
data = Array.new(10){Array.new(10, 0)}

1.upto(9) do |i|
  if i <= n
    data[i][i] += 1
  end
  1.upto(9) do |j|
    next if i * 10 + j > n || j * 10 + i > n
    data[i][j] += 1
    cnt = 0
    keta = 1
    loop do
      num_str = sprintf("%0#{keta}d", cnt)
      num = (j.to_s + num_str + i.to_s).to_i
      break if num > n
      data[i][j] += 1
      if cnt < 10 ** keta -1 
        cnt += 1
      else
        keta += 1
        cnt = 0
      end
    end
  end
end

sum = 0
10.times do |i|
  i.upto(9) do |j|
    if i == j
      sum += data[i][j] ** 2
    else
      sum += 2 * data[i][j] * data[j][i]
    end
  end
end

p sum

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

//#define int long long
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<n;++i)
#define exrep(i, a, b) for(ll i = a; i < b; i++)
#define out(x) cout << x << endl
#define EPS (1e-7)
#define gearup ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

typedef long long int ll;
typedef long double ld;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<bool> > vvb;
typedef vector<vector<double> > vvd;
typedef vector<vector<string> > vvs;
typedef vector<ll> vl;
typedef vector<vector<ll> > vvl;
typedef vector<vector<vector<ll> > > vvvl;
ll MOD = 1000000007;
const long long L_INF = 1LL << 60;
const int INF = 2147483647; // 2^31-1
const double PI = acos(-1);
//cout<<fixed<<setprecision(10);

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;}
template<class T> void debug(T v){rep(i,v.size()) cout<<v[i]<<" ";cout<<endl;}
const ll dx[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll dy[8] = {0, 1, 1, 1, 0, -1, -1, -1};

signed main()
{   
    gearup;
    ll n,k; cin >> n >> k;
    vl a(n);
    rep(i,n)cin>>a[i];
    ll res = (n-1 + k-2)/(k-1);
    out(res);
}


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

bool judge(vector<string> V){
    ll N = V.size();
    for(int i = 0; i < N-1; i++){
        for(int j = i+1; j < N; j++){
            if(V[i][j] != V[j][i]) return false;
        }
    }
    return true;

}

int main(){
    ll N; cin >> N;
    vector<string> V(N); for(int i = 0; i < N; i++) cin >> V[i];
    ll ans = 0;
    for(int A = 0; A < N; A++){
        vector<string> U(N);
        for(int i = 0; i < N; i++){
            U[(i+A)%N] = V[i];
        }
        if(judge(U)) ans+= N;
    }
    cout << ans << endl;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define light ios_base::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr)
#define endl "\n"
#define pb push_back
#define F first
#define S second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define REP(i,a,b) for(ll i = a; i < b; i++)
#define REPE(i,a,b) for(ll i = a; i <= b; i++)
#define REPR(i,a,b) for(ll i = a; i >= b; i--)
#define gcd(a, b) __gcd(a, b)
#define lcm(a, b) (a * b) / gcd(a, b)
#define bins(v, x) binary_search(v.begin(), v.end(), x)
const double pi = 2*acos(0.0);
const int INF = 1e9+1;
const int MOD = 1e9+7;
const int MOD1 = 998244353;

using ll = long long;
using ld = long double;
using vi = vector<int>;

#define oset tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>
#define osetll tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update>
//member functions :
//1. order_of_key(k) : number of elements strictly lesser than k
//2. find_by_order(k) : k-th element in the set
 
ll modExp(ll base, ll exp, ll mod) {
   ll res = 1;
   while (exp > 0) {
    	if (exp % 2 == 1) {
        	res= (res * base) % mod;
		}
      exp = exp >> 1;
      base = (base * base) % mod;
   }
   return res;
}

ll inverse(ll base, ll exp, ll mod) {
   return modExp(base, exp - 2, mod);
}

bool compare(const pair<int,int> &i, const pair<int,int> &j) {
   return (i.S > j.S || (i.S == j.S && i.F > j.F));
}

void test() {
	ll n, x, t;
   cin >> n >> x >> t;
   ll rem = n/x;
   if(n % x) rem++;
   cout << rem * t;
}

int main() {
   //freopen("input.txt","r",stdin);
   //freopen("output.txt","w",stdout);
   light;
   cout.precision(15);
   cout << fixed;

   int t = 1;
   //cin >> t;
   for(int i = 1; i <= t; i++) {
      //cout << "Case #" << i << ": ";
      test();
   }
   return 0;
}


Measured memory_bytes: 3644
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <numeric>
#include <cmath>
#include <cassert>

using namespace std;

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

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

const ll mod = 1e9+7;
const ll INF = 1e9;

ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

vector<vector<int>> g;
vector<ll> node,flag;

void dfs(int x,int cnt){
	flag[x] = true;
	for (int i = 0; i < g[x].size(); i++){
		int next = g[x][i];
		if(!flag[next]){
			node[next] += cnt;
			dfs(next,node[next]);
		}
	}

	return;
}

int main()
{
	int n,q;
	cin>>n>>q;
	g.resize(n,vector<int>());
	rep(i,n-1){
		int a,b;
		cin>>a>>b;
		a--,b--;
		g[a].push_back(b);
		g[b].push_back(a);
	}
	vector<P> query(q);
	rep(i,q){
		cin>>query[i].first>>query[i].second;
		query[i].first--;
	}
	node.resize(n,0);
	flag.resize(n);
	rep(i,q) node[query[i].first] += query[i].second;

	dfs(0,node[0]);

	rep(i,n)cout<<node[i]<<" ";
	cout<<endl;

	return 0;
}

Measured memory_bytes: 25856
#include <bits/stdc++.h>
#include <stdlib.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<ll,ll> llP;

ll mod(ll a, ll b){
  ll ret=a%b;
  if(ret<0) ret+=b;
  return ret;
}

ll modpow(ll a,ll b,ll c){
  ll res=1;
  while(b>0){
    if(b&1) res=mod(res*a,c);
    a=mod(a*a,c);
    b>>=1;
  }
  return res;
}

int main() {
  ll a,v,b,w,t;
  cin>>a>>v>>b>>w>>t;
  if(w>=v){
    cout<<"NO"<<endl;
    return 0;
  }
  if(a>b){
    if((a-b)<=(v-w)*t){
        cout<<"YES"<<endl;
    }
    else{
        cout<<"NO"<<endl;
    }
  }
  else{
    if((b-a)<=(v-w)*t){
        cout<<"YES"<<endl;
    }
    else{
        cout<<"NO"<<endl;
    }
  }
  return 0;
}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
#define P pair<int,int>
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define re(i,k,n) for(int i=k;i<n;i++)
#define mod 1000000007;
//最大公約数
int gcd(int s,int b){
    if(b==0)return s;
    return gcd(b,s%b);
}
signed main(){
    int n;
    cin>>n;
    if(n==1){
        cout<<0<<endl;
    }
    else{
        cout<<(1+n-1)*(n-1)/2<<endl;
    }
}

Measured memory_bytes: 256
#include<cstdio>
#include<queue>
#include<utility>
#include<vector>
using namespace std;
typedef pair<pair<int, int>, int> P;

struct vertex {
    vector<int> to;
};

const int INF = 1e9 + 7;
int n, m, l;
int c[300][300];
int que;
int s[89700], t[89700];
pair<int, int> cntd[300][300]; 
vertex ver[300];
priority_queue<P, vector<P>, greater<P>> q;

int main() {
    scanf("%d %d %d", &n, &m, &l);
    for (int i = 0; i < m; i++) {
        int a, b, cost;
        scanf("%d %d %d", &a, &b, &cost);
        ver[a - 1].to.emplace_back(b - 1);
        ver[b - 1].to.emplace_back(a - 1);
        c[a - 1][b - 1] = cost;
        c[b - 1][a - 1] = cost;
    }
    scanf("%d", &que);
    for (int i = 0; i < que; i++) scanf("%d %d", &s[i], &t[i]);
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < n; j++) {
            if (i == j) continue;
            cntd[i][j] = pair<int, int>(INF, INF);
        }
    }
  
    for (int i = 0; i < n; i++) {
        q.emplace(cntd[i][i], i);
        while (!q.empty()) {
            P p = q.top(); q.pop();
            if (p.first != cntd[i][p.second]) continue;
            for (auto &j : ver[p.second].to) {
                if (c[p.second][j] > l) continue;
                pair<int, int> r;
                if (p.first.second + c[p.second][j] > l) {
                    r.first = p.first.first + 1;
                    r.second = c[p.second][j];
                }
                else {
                    r.first = p.first.first;
                    r.second = p.first.second + c[p.second][j];
                }
                if (r < cntd[i][j]) {
                    cntd[i][j] = r;
                    q.emplace(cntd[i][j], j);
                }
            }
        }
    }

    for (int i = 0; i < que; i++) {
        printf("%d\n", (cntd[s[i] - 1][t[i] - 1].first == INF) ? -1
                      : cntd[s[i] - 1][t[i] - 1].first); 
    }
    return 0;
}


Measured memory_bytes: 3328