akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long ul;
typedef signed long long ll;
ul over = 1000000007;

int main(void)
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed;
  int n, a, b;
  cin >> n >> a >> b;
  a--; b--;
  cout << ((b-a)%2==0 ? "Alice" : "Borys") << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <utility>
#include <string.h>
#include <map>
#include <stack>
#include <iomanip>
#include <chrono>
#include <random>
#include <math.h>
#include <time.h>
#include <assert.h>
#define rnd mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#define ll long long
#define pb push_back 
#define mp make_pair
#define ff first
#define ss second
#define FIO ios_base::sync_with_stdio(false); cin.tie(NULL);
#define all(x) x.begin(),x.end() 
#define PII pair <ll,ll>
#define N 100005
#define MOD 1000000007
#define INF 1000000000000000000
using namespace std;

int main()
{
	int A[3];
	cin >> A[0] >> A[1] >> A[2];
	sort(A, A + 3);
	cout << A[2] * 10 + A[1] + A[0];
}



Measured memory_bytes: 256
const MOD = 10**9+7
// factors[f].e+n-1、において max(n)=10**5, max(factors[f].e)=log(M)=log(10**9)=21
const N = 10**5+28

let fac = [...new Array(N)].fill(0)
let ifac = [...new Array(N)].fill(0)
const mul = (a,b) => ((a>>16)*b%MOD*65536+(a&65535)*b)%MOD;

const factorization = (n) => {
    let primes= []
    for(let i=2; i*i<=n; i++) {
        let exponent = 0
        while(n%i===0) {
            n /= i
            exponent++
        }
        if(exponent) {
            primes.push({p:i, e:exponent})
        }
    }
    
    if(n!==1) {
        primes.push({p:n, e:1})
    }
    return primes
}

const mpow = (x, n) => {
    ans = 1;
    let _x = x
    while(n != 0){
        if(n & 1) ans = mul(ans,_x);
        _x = mul(_x,_x);
        n = n >> 1;
    }
    return ans;
}

const comb = (n, r) => {
    if(n == 0 && r == 0) return 1;
    if(n < r || n < 0) return 0;
    const tmp = mul(ifac[n-r],ifac[r])
    return mul(tmp,fac[n])
}

const init = () => {
    fac[0] = 1;
    ifac[0] = 1;
    for(let i=0; i<N; i++){
        fac[i+1] = mul(fac[i],(i+1));
        ifac[i+1] = mpow(fac[i+1], MOD - 2)
    }
}

const main = (arg) => {
    let [n, m] = arg.split(" ").map(Number)
    let factors = factorization(m)
    let ans = 1
    init()
    Object.keys(factors).forEach(f=>{
        let a = factors[f].e+n-1
        let b = factors[f].e
        ans = mul(ans,comb(a, b))
    })
    console.log(ans)
}

main(require("fs").readFileSync("/dev/stdin", "utf8"));

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

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

    int n, x, t;
    cin >> n >> x >> t;

    const int complete_batches = n / x;
    const int remainder = n % x;
    const int ans =
        remainder == 0 ? complete_batches * t : (complete_batches + 1) * t;

    cout << ans << '\n';

    return 0;
}


Measured memory_bytes: 3608
#include <iostream>
using namespace std;
int main(){
    int a,b;
    cin>>a>>b;
    if(a<b){
        for (int i=0; i<b; i++)
            cout<<a;
    }
    else{
        for (int i=0; i<a; i++){
            cout<<b;
        }
    }
}

Measured memory_bytes: 256
using LinearAlgebra

function solve()
    H, W, K = parse.(Int, split(readline()))

    c = zeros(Int, H, W)

    for i = 1:H
        s = readline()
        for j = 1:W
            c[i,j] = Int(s[j] == '.' ? 0 : 1)
        end
    end

    sumrow = [sum(view(c, i, 1:W)) for i = 1:H]
    sumcol = [sum(view(c, 1:H, j)) for j = 1:W]

    stack = [[0],[1]]

    cnt = 0

    for i = 0:2^(H+W)
        x = i
        bits = []
        for j = 1:(H+W)
            push!(bits, x&1)
            x ÷= 2
        end

        P = Diagonal(bits[1:H])
        Q = Diagonal(bits[(H+1):(H+W)])
        if sum(P*c*Q) == K cnt += 1 end

    end

    println(cnt)
end

solve()


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

// ワーシャルフロイド法 全ポイント間の距離算出 , O(V^3)
class class_WarshallFloyd{
public:
	class_WarshallFloyd(){};
	virtual ~class_WarshallFloyd(){};
	void Init(int n , double distanceMaxVal);
	void Set_2Way(int a, int b, double distance);
	void Scan();
	double Lng(int x, int y){return Length2D[y*Num+x];}
	void DebugDump();

protected:
	int Num=0;
	double DistanceMaxVal = LLONG_MAX;
	vector<double> Length2D;
};

void class_WarshallFloyd::Init(int n , double distanceMaxVal){
	Num = n;
	DistanceMaxVal = distanceMaxVal;
	Length2D.resize( (n*n) , distanceMaxVal);
}

void class_WarshallFloyd::Set_2Way(int a, int b, double distance){
	Length2D[a*Num+b] = distance;
	Length2D[b*Num+a] = distance;
}

void class_WarshallFloyd::Scan(){
	for(int k=0;k<Num;k++){
		for(int b=0;b<Num;b++){
			for(int a=0;a<Num;a++){
				int c = b*Num+a , c1 = k*Num+a , c2 = b*Num+k;
				if ( (Length2D[c1] + Length2D[c2]) < Length2D[c]  ){
					Length2D[c] = Length2D[c1] + Length2D[c2];
				}
			}
		}
	}
}

void class_WarshallFloyd::DebugDump(){
	for(int b=0;b<Num;b++){
		for(int a=0;a<Num;a++){
			int c = b*Num+a;
			if( Length2D[c] < DistanceMaxVal) {
				printf ("%2.1lf ",Length2D[c]);
			}else{
				printf ("--- ");
			}
		}
		printf("\n");
	}
}


int main(int argc , char **argv)
{
	(void)argc;
	(void)argv;
	class_WarshallFloyd graph;
	int N,M,RNum;// N:町 , M:道
	cin >> N >> M >> RNum;

	vector<int> R(RNum);
	for(int i=0;i<RNum;i++){
		int r;
		cin >> r;
		R[i] = r-1;
	}

	graph.Init(N+1,INT_MAX);
	for(int i=0;i<M;i++)
	{
		int a,b;
		double d;
		cin >> a >> b >> d;
		a--;b--;
		graph.Set_2Way(a,b,d);
	}

	graph.Scan();
//	graph.DebugDump();

	// R[] の順列を 全探索で最小値を求める
	double minLength = INT_MAX;
	stable_sort(R.begin(),R.end());

	int iMax= RNum-1;
	do{
		double sum=0.0;
		for(int i=0;i<iMax;i++){
			sum += graph.Lng(R[i],R[i+1]);
		}
		minLength = min(minLength,sum);
	}while( next_permutation(R.begin(),R.end()) );

	printf("%d\n",(int)minLength );

	return 0;
}


Measured memory_bytes: 640
struct Scanner {
	handle: std::io::Stdin,
	buffer: std::collections::VecDeque<String>
}

impl Scanner {
	fn new() -> Scanner {
		Scanner {
			handle: std::io::stdin(),
			buffer: std::collections::VecDeque::new()
		}
	}
	fn next<T: std::str::FromStr>(&mut self) -> Result<T, T::Err> {
		if self.buffer.len() == 0 {
			loop {
				let mut available = String::new();
				self.handle.read_line(&mut available).unwrap();
				self.buffer = available.split_whitespace().map(String::from).collect();
				if self.buffer.len() > 0 {
					break;
				}
			}
		}
		T::from_str(&self.buffer.pop_front().unwrap())
	}
}

fn main() {
	let mut scanner = Scanner::new();
	let a: i64 = scanner.next().unwrap();
	let b: f64 = scanner.next().unwrap();
	let c = (b*100.0).round() as i64;
	println!("{}", a*c/100);
}


Measured memory_bytes: 2612
import fractions
from functools import reduce

def gcd(*numbers):
    return reduce(fractions.gcd, numbers)

def gcd_list(numbers):
    return reduce(fractions.gcd, numbers)

N = int(input())
A = [int(x) for x in input().split()]
L = [0]*N
R = [0]*N
ans = 0
for i in range(N):
    if(i==0):
        L[i] = A[0]
        R[i] = A[-1]
    else:
        L[i] = gcd(A[i],L[i-1])
        R[i] = gcd(A[-i-1],R[i-1])

for i in range(N):
    if(i==0):
        ans = R[-2]
    elif(i==N-1):
        ans = max(ans,L[-2])
    else:    
        ans = max(ans,gcd(L[i-1],R[-i-2]))
print(ans)


Measured memory_bytes: 16152
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
using ll = long long;
using vec = vector<ll>;
using vec2 = vector<vector<ll>>;
ll inf = pow(2,62);

int main(){
    ll n,d;cin >> n >> d;
    d = d*d;
    vec2 a(n,vector<ll>(2,0));
    rep(i,n){
        cin >> a[i][0];
        cin >> a[i][1];
    }
    ll count = 0;
    rep(i,n){
        ll b = a.at(i).at(0) * a.at(i).at(0) + a.at(i).at(1) * a.at(i).at(1);
        if(b <= d){
            count++;
        }
    }
    cout << count;

}

Measured memory_bytes: 14348
import math

students = []
data = []
ans = []
while True:
  n = int(input())
  if n == 0:
    break
  students.append(n)
  data.append(list(map(int,input().split())))
for student, result in zip(students, data):
  total = 0
  for i in result:
    total += i
  average = total / student
  S = 0
  for j in result:
    S += (j - average) ** 2
  dispersion = S / student
  ans.append(math.sqrt(dispersion))
for out in ans:
  print(out)


Measured memory_bytes: 5704
#include <bits/stdc++.h>
using namespace std;
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;
}
typedef long long int ll;

#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define endl "\n"
const double EPS = 1e-7;
const int INF = 1 << 30;
const ll LLINF = 1LL << 60;
const double PI = acos(-1);
const int MOD = 1000000007;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

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

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int a, b, c;
    cin >> a >> b >> c;
    if(a + b + c >= 22) {
        cout << "bust" << endl;
    } else {
        cout << "win" << endl;
    }
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		String x = sc.next();
		int y = 0;
		for(int i =0; i < x.length(); i++){
			y += Character.getNumericValue(x.charAt(i));
		}
		if(y % 9 == 0){
			System.out.println("Yes");
		}else{
			System.out.println("No");
		}
	}
}

Measured memory_bytes: 40576
# coding: utf-8
# Your code here!


n = [input() for i in range(5)]

mn = [10 if i[-1] == "0" else int(i[-1]) for i in n]
mn = min(mn)

n=[int(i) for i in n]

ans=0

for i in n:
    if i%10==0:
        ans+=i
    else:
        ans+=i-i%10+10

ans -= 10-mn

print(ans)

Measured memory_bytes: 3064
import java.util.Scanner;
public class Main {
	public static void main(String[] args){
		Scanner scan = new Scanner(System.in);
		for(;;){
		String x = scan.next();
		if(x.equals("-"))
			break;
		String sx[] = x.split("");
		String[] a;
		a = new String[10000];
		int m = scan.nextInt();
		int i,t,c;
		for(i = 0; i < m; i++){
			c = 0;
			int h = scan.nextInt();
			for(t = h; t < x.length(); t++){
				a[c++] = sx[t];
			}
			for(t = 0; t < h; t++){
				a[c++] = sx[t];
			}
			for(t = 0; t < x.length(); t++){
				sx[t] = a[t];
			}
		}
		for(t = 0; t < x.length(); t++){
			System.out.print(sx[t]);
		}
		System.out.println();
		}
	}
}

		

	

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

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

typedef long long ll;

const int INF = 1 << 30;
const ll LLINF = 1LL << 60;

int mod = 1000000007;

int calc(int fr, int to){
    return (fr-to)*(fr-to);
}

int main(void){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int N; cin >> N;
    int A[N]; rep(i, N) cin >> A[i];
    int ans = mod;
    for(int i = -100; i <= 100; i++){
        int res = 0;
        rep(j, N){
            res += calc(A[j], i);
        }
        ans = min(ans, res);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author mikit
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        CMinimization solver = new CMinimization();
        solver.solve(1, in, out);
        out.close();
    }

    static class CMinimization {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int n = in.nextInt();
            int k = in.nextInt();
            for (int i = 0; i < n; i++) {
                in.nextInt(); //ぽい
            }
            if ((n - 1) % (k - 1) == 0) {
                out.println((n - 1) / (k - 1));
            } else {
                out.println((n - 1) / (k - 1) + 1);
            }
        }

    }
}



Measured memory_bytes: 50068
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;cin>>N;
  int N2=N;
  int sum=0;
  for(int i=0;i<10;i++){
    sum+=N%10;
    N/=10;
  }
  
  if(N2%sum==0){
    cout<<"Yes"<<endl;
  }
  if(N2%sum!=0){
    cout<<"No"<<endl;
  }
}

Measured memory_bytes: 764
import java.io.BufferedReader
import java.io.InputStreamReader

fun main(args: Array<String>) {
    val br = BufferedReader(InputStreamReader(System.`in`))
    val n = br.readLine()!!.filterNot { it == ' ' }.toInt()
    var a = 1
    while (a * a <= n) {
        if (a * a == n ) {
            println("Yes")
            return
        } else {
            a++
        }
    }
    println("No")
}

fun err(print: Any) {
    System.err.println(print)
}

Measured memory_bytes: 29600
#include <iostream>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <iomanip>
#include <cmath>
using namespace std;

void solve(){
  long long n, ans = 0; cin >> n;
  vector<int> l(n), sum(2001, 0);
  for(int i = 0; i < n; i++){
    cin >> l[i];
  }
  sum[0] = 0;
  int j = 0;
  for(int i = 0; i < n; i++){
    sum[l[i]]++;
  }
  for(int i = 1; i <= 2000; i++){
    sum[i] += sum[i - 1];
  }
  for(int i = 0; i < n - 1; i++){
    for(int j = i + 1; j < n; j++){
      int a = l[i], b = l[j];
      //cout << a << " " << b << " -> ";
      long long left = abs(a - b), right = a + b, t;
      t = sum[right - 1] - sum[left];
      //cout << left << " < c < " << right << endl;
      //cout << t << endl;
      if(a > left && a < right) t--;
      if(b > left && b < right) t--;
      //cout << t << endl;
      ans += t;
    }
  }
  cout << ans / 3<< endl;

  return;
}

int main(){
  solve();
  return 0;
}


Measured memory_bytes: 256
//package april2020;

import java.util.*;
import java.lang.*;
import java.math.*;
import java.io.*;

public class Main {
	public static void main(String[] args) throws IOException {
		FastReader scn = new FastReader();
		OutputStream out = new BufferedOutputStream ( System.out );
		int n =scn.nextInt();
		double[] p = new double[n];
		for(int i=0;i<n;i++) {
			p[i] = scn.nextDouble();
		}
		double[] dp = new double[n+1];
		
		dp[0]=1;
		
		for(int coin = 0;coin<n;coin++) {
			for(int i=coin+1;i>=0;i--) {
				dp[i] = (i==0?0:(dp[i-1]*p[coin]))+dp[i]*(1-p[coin]);
			}
		}
		double ans = 0;
		for(int heads = 0;heads<=n;heads++) {
			int tails = n-heads;
			if(heads>tails) {
				ans+=dp[heads];
			}
		}
		out.write((ans+"\n").getBytes());
		out.close();
	}
	static class FastReader 
    { 
        BufferedReader br; 
        StringTokenizer st; 
  
        public FastReader() 
        { 
            br = new BufferedReader(new
                     InputStreamReader(System.in)); 
        } 
  
        String next() 
        { 
            while (st == null || !st.hasMoreElements()) 
            { 
                try
                { 
                    st = new StringTokenizer(br.readLine()); 
                } 
                catch (IOException  e) 
                { 
                    e.printStackTrace(); 
                } 
            } 
            return st.nextToken(); 
        } 
  
        int nextInt() 
        { 
            return Integer.parseInt(next()); 
        } 
  
        long nextLong() 
        { 
            return Long.parseLong(next()); 
        } 
  
        double nextDouble() 
        { 
            return Double.parseDouble(next()); 
        } 
  
        String nextLine() 
        { 
            String str = ""; 
            try
            { 
                str = br.readLine(); 
            } 
            catch (IOException e) 
            { 
                e.printStackTrace(); 
            } 
            return str; 
        } 
    }
}


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

main(){
	int n,p,pm,pe,pj ;
	while( cin >> n , n ){
		for( int i=0 ; i<n ; i++ ){
			cin >> pm >> pe >> pj ;
			double a = (pm+pe) / 2.0 ;
			double b = (pm+pe+pj) / 3.0 ;
			bool t = false ;
			if( pm >= 80 || pe >= 80 ) t = true ;
			
			if( pm==100 || pe==100 || pj==100 ) cout << "A" ;
			else if( a >= 90 ) cout << "A" ;
			else if( b >= 80 ) cout << "A" ;
			else if( b >= 70 ) cout << "B" ;
			else if( b >= 50 && t ) cout << "B" ;
			else cout << "C" ;
			
			cout << endl ;
		}
	}
}

Measured memory_bytes: 1156
#include <iostream>
#include <vector>
#include <algorithm>
#include <utility>
#include <queue>
#include <string>
#include <set>
#include <bitset>
#include <unordered_map>

using namespace std;
using ll = long long;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;
template <class T>
using Vvec = vector<vector<T> >;

int main()
{
    int N;
    cin >> N;
    vector<ll> A(N);
    for(ll& x: A) cin >> x;

    sort(A.begin(), A.end());
    ll ans = 0;
    vector<Pll> ope;
    bool flag = false;
    if(A[0] >= 0){
        ans = A[0];
        for(int i=1; i<N-1; i++){
            ope.emplace_back(ans, A[i]);
            ans -= A[i];
        }
        ope.emplace_back(A[N-1], ans);
        ans = A[N-1] - ans;
    }
    else if(A[N-1] <= 0){
        ans = A[N-1];
        for(int i=N-2; i>=0; i--){
            ope.emplace_back(ans, A[i]);
            ans -= A[i];
        }
    }
    else{
        int j = distance(A.begin(), upper_bound(A.begin(), A.end(), 0));
        ans = A[0];
        bool flag = false;
        for(int i=N-1; i>0; i--){
            if(i == j){
                flag = true;
                ope.emplace_back(A[i], ans);
                ans = A[i] - ans;
            }
            else{
                ope.emplace_back(ans, A[i]);
                ans -= A[i];
            }
        }
    }

    cout << ans << endl;
    for(Pll& p: ope) cout << p.first << " " << p.second << endl;
}

Measured memory_bytes: 4336
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
const ll MOD = 1e9 + 7;
const ll INF = 1LL << 60;
const double PI = 3.141592653589793238;
const double EPS = 1e-10;

int main() {
	int H, W;
	int h, w;
	cin >> H >> W;
	cin >> h >> w;
	cout << (H - h)*(W - w) << endl;
 }

Measured memory_bytes: 764
import math

K = int(input())

ans = 0
memo = {}
for a in range(1, K+1):
    for b in range(1, K+1):
        gcd_ab = math.gcd(a, b)
        try:
            memo[gcd_ab] += 1
        except:
            memo[gcd_ab] = 1


for c in range(1, K+1):
    for key in memo.keys():
        ans += math.gcd(c, key) * memo[key]

print(ans)


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


vector<long long> calc_divisors(long long N) {
    vector<long long> res;
    for (long long i = 1; i * i <= N; ++i) {
        if (N % i == 0) {
            res.push_back(i);
            if (N/i != i) res.push_back(N/i);
        }
    }
    // 小さい順に並び替える
    sort(res.begin(), res.end());
    return res;
}


int main() {
    long long X;
    cin >> X;

    long long d, q;
    const auto &divisors = calc_divisors(X);
    int a = 1;
    while (true) {
        for (int i = 0; i < divisors.size(); ++i) {
            d = divisors[i];
            q = 5 * pow(a, 4) - 10 * pow(a, 3) * d + 10 * pow(a, 2) * pow(d, 2) - 5 * a * pow(d, 3) + pow(d, 4);
            if (d * q == X) {
                cout << a << " " << a - d << endl;
                return 0;
            }
        }
        a++;
    }
    return 0;
}


Measured memory_bytes: 4108
//by yjz
#include<bits/stdc++.h>
using namespace std;
#define FF first
#define SS second
#define PB push_back
#define MP make_pair
#define foreach(it,s) for(__typeof((s).begin()) it=(s).begin();it!=(s).end();it++)
#ifndef LOCAL
#define cerr if(0)cout
#endif
typedef long long ll;
const int mod=1e9+7;
//My i/o stream
struct fastio
{
	char s[100000];
	int it, len;
	fastio() {it=len=0;}
	inline char get()
	{
		if (it<len) return s[it++]; it=0;
		len=fread(s, 1, 100000, stdin);
		if (len==0) return EOF; else return s[it++];
	}
	bool notend()
	{
		char c=get();
		while (c==' '||c=='\n') c=get();
		if (it>0) it--;
		return c!=EOF;
	}
}_buff;
#define geti(x) x=getnum()
#define getii(x,y) geti(x),geti(y)
#define getiii(x,y,z) getii(x,y),geti(z)
#define puti(x) putnum(x),putchar(' ')
#define putii(x,y) puti(x),puti(y)
#define putiii(x,y,z) putii(x,y),puti(z)
#define putsi(x) putnum(x),putchar('\n')
#define putsii(x,y) puti(x),putsi(y)
#define putsiii(x,y,z) putii(x,y),putsi(z)
inline ll getnum()
{
	ll r=0; bool ng=0; char c; c=_buff.get();
	while (c!='-'&&(c<'0'||c>'9')) c=_buff.get();
	if (c=='-') ng=1, c=_buff.get();
	while (c>='0'&&c<='9') r=r*10+c-'0', c=_buff.get();
	return ng?-r:r;
}
template <class T> inline void putnum(T x)
{
	if (x<0) putchar('-'), x=-x;
	register short a[20]={}, sz=0;
	while (x) a[sz++]=x%10, x/=10;
	if(sz==0) putchar('0');
	for (int i=sz-1; i>=0; i--) putchar('0'+a[i]);
}
inline char getreal() {char c=_buff.get(); while (c<=32) c=_buff.get(); return c;}
ll qpow(ll x, ll k) {return k==0? 1: 1ll*qpow(1ll*x*x%mod,k>>1)*(k&1?x:1)%mod;}
const int maxn = 200111;
int n;
ll a[maxn];
int main()
{
	geti(n);
	for (int i=1; i<=n; i++) geti(a[i]), a[i] += a[i-1];
	map<ll,int> mp;
	ll ans = 0;
	for (int i=0; i<=n; i++)
	{
		ans += mp[a[i]];
		mp[a[i]]++;
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 14464
import java.util.Scanner;
 
public class Main {
 
    public static void main(String[] args) {
    	Scanner scan = new Scanner(System.in); 
    	int n = scan.nextInt();
         
        for (int i = 1; i <= n; i++) {//入力回数分繰り返しの指定
        	int x = i;//x を増大
        	if (x % 3 == 0) {//xを３で割って余りがなければ
        		System.out.print(" " + i);//スペースとiの値を出力
        		continue;//スキップ
        	}
        	if (x % 10 == 3) {//xを１０で割って余りが３ならば
        		System.out.print(" " + i);//スペースとiの値を出力
        		continue;//スキップ
        	}
        	/*
        	* xを10で割ったものを初期値として、
        	* ｘ割る１０を xが0になるまで続ける。
        	* 計算終了後プログラム終了。
        	*/
        	for (x /= 10; x != 0; x /= 10) {
        		if (x % 10 == 3) {
        			System.out.print(" " + i);
        			break;
        		}
        	}
        }
    	System.out.println();
    	scan.close();
    }
}

Measured memory_bytes: 24288
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repr(i, n) for (int i = (n); i >= 0; --i)
#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define FORR(i, m, n) for (int i = (m); i >= (n); --i)
#define equals(a, b) (fabs((a) - (b)) < EPS)
using namespace std;
typedef long long ll;
const ll mod = 1000000007;
const ll mod2 = 998244353;
const ll INF = 1e18;
const long double EPS = 1e-10;

ll gcd(ll a,ll b) {
  if (a < b) swap(a, b);
  if (a % b == 0) return b;
  return gcd(b, a%b);
}

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

  cout << a * b / gcd(a, b) << endl;

  


  
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define int long long int
// #define ll long long int
#define ld long double
#define ff first
#define ss second
#define mp make_pair
#define IOS std::ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define pb push_back
#define eb emplace_back
#define pii pair<int, int>
#define endl '\n'
#define all(x) x.begin(),x.end()
#define f(i,j,l) for(i=j;i<l;i++)
#define smax(a,b) a=max(a,b)
// #if !defined(ONLINE_JUDGE)
// #include "debugging.h"
// #endif
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
// find_by_order(k)  returns iterator to kth element starting from 0;
// order_of_key(k) returns count of elements strictly smaller than k;
// erase,insert same as normal set

// int const mod = 7340033;
// int const mod = 998244353;
int const mod = 1e9+7;
int power(int a,int b,int m){
    int res = 1;
    while(b){
        if(b&1){
            res = res*a;
            res %= m;
        }
        a=a*a;
        a%=m;
        b=b/2;
    }
    return res;
}

int inverse(int x , int m){
    return power(x,m-2,m);
}

int const N = 2e5+5;
int const inf = 2e9;

vector<int> adj[N];


void solve(){  
    int i,j,l;
	int n;
	cin>>n;
	for(i=0;i<n-1;i++){
		int u,v;
		cin>>u>>v;
		if(u > v) swap(u,v);
		adj[v].pb(u);
	}	
	int ans = 0;
	int k = 0;
	for(i=1;i<=n;i++){
		int x = i*(i+1)/2;
		ans = ans + x;
		int z = 0;
		for(auto y:adj[i]){
			z = z + y;
		}
		ans = ans - z - k;
		k += z;
	}
	cout<<ans<<endl;
}           


int32_t main(){
    IOS;
    int t;
    t = 1;
    // precompute();
    // cin>>t;
    for(int tt=1;tt<=t;tt++){
        solve();
    }
    return 0;
}


/*

10
3 5
5 7
8 9
1 9
9 10
4 8
4 7
6 10
2 7

1  2  3  4   5   6    7     8  9  10
4  4  3  2   1   0    0     0  0   0 

1  3  6  10  12  18   28-




*/

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

int main(){
  int N;
  std::cin >> N;
  int sum = 0;
  int max = 0;
  for(int i = 0;i<N;++i){
    int p;
    std::cin >> p;
    sum += p;
    max = std::max(max, p);
  }
  std::cout << sum-max/2 << std::endl;
}

Measured memory_bytes: 256
def problem():
    N = int(input())
    V = list(map(int, input().split()))
    C = list(map(int, input().split()))

    print(algorithm(N, V, C))


def algorithm(N, V, C):
    indices = list(filter(lambda i: V[i] - C[i] > 0, list(range(0, N))))

    sum = 0
    for i in indices:
        sum += V[i] - C[i]
    return sum

problem()

Measured memory_bytes: 3064
#include <iostream>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cassert>
#include <ctime>
#include <sstream>
#include <algorithm>
#include <functional>
#include <numeric>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>

using namespace std;

#define f first
#define s second
#define pb push_back
#define mp make_pair
#define ll long long
#define pii pair < int, int >
#define pll pair < long long, long long>
#define ull unsigned long long
#define y1 stupid_cmath
#define left stupid_left
#define right stupid_right
#define vi vector <int>
#define sz(a) (int)a.size()
#define forit(it, s) for(__typeof(s.begin()) it = s.begin(); it != s.end(); it++)
#define all(a) a.begin(), a.end()
#define sqr(x) ((x) * (x))

const int inf = (int)1e9;
const int mod = 998244353;
const double eps = 1e-9;
const double pi = acos(-1.0);

string s;
map<string, int> dp;

int calc(string s) {
    if (s.size() <= 0) return 1;
    if (dp.count(s)) return dp[s];
    int &res = dp[s];
    res = calc(s.substr(1));
    if (s[0] == '1') {
        res += calc(s.substr(1));
        if (res >= mod) res -= mod;
    }
    for (int len = 1; len <= sz(s); len++) {
        for (int k = 2; k * len <= sz(s); k++) {
            string rest = s.substr(len * k);
            int cur = calc(rest);
            string t = s.substr(0, len);
            for (int i = 0; i < len; i++) {
                for (int j = i; j < k * len; j += len) {
                    if (s[j] == '0') {
                        t[i] = '0';
                        break;
                    }
                }
            }
            res += calc(t) * 1ll * cur % mod;
            if (res >= mod) res -= mod;
        }
    }
    return res;
}

int main(){

    string s;

    cin >> s;

    cout << calc(s) << endl;

    return 0;
}


Measured memory_bytes: 5632
#include <bits/stdc++.h>
#include <iomanip>
#include <math.h>
#include <unistd.h>
#include <stdio.h>
#define all(a) (a).begin(),(a).end()
#define vecin(a) rep(i,a.size())cin >> a[i]
#define vecout(a) rep(i,a.size()){cout << a[i];cout << (i == a.size() - 1 ? "\n":" ");}
#define rep(i,x) for(int i = 0;i<x;i++)
#define REP(i,x) for(ll i = 1;i<=x;i++)
#define mp make_pair
using ll = long long;
using ld = long double;
using namespace std;
using dou = double;
const ll inf = 2147483647;
const ll INF = 1LL << 60;
const dou pi = 3.14159265358;
const ll mod = 1000000007LL;
//const ll mod = 998244353LL;
typedef pair<ll,ll> P;
using graph = vector<vector<ll>>;
template<class T> inline bool chmax(T& a, T b){if(a < b){a = b; return true;}return false;}
template<class T> inline bool chmin(T& a, T b){if(a > b){a = b; return true;}return false;}
template<class T> inline bool change(T a,T b){if(a > b){swap(a,b);return true;}return false;}
ll gcd(ll a,ll b){
    if(a < b)swap(a,b);
    if(a % b == 0)return b;
    else return gcd(b,a%b);
}
ll lcm(ll a,ll b){
    return a / gcd(a,b) * b;
}

//素数判定O(sqrt(N))
bool isp(ll n){
    bool res = true;
    if(n == 1)return false;
    else{
        for(ll i = 2;i * i <= n;i++){
            if(n % i == 0){
                res = false;
                break;
            }
        }
        return res;
    }
}
const ll cmax = 1000000;
ll fac[cmax], finv[cmax], inv[cmax];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (ll i = 2; i < cmax; 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;
    }
}

// 二項係数計算
ll nCk(ll n, ll k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % mod) % mod;
}
//nのm乗をMODで割ったあまりO(logm)
ll modpow(ll n,ll m,ll MOD){
    if(m == 0)return 1;
    if(m < 0)return -1;
    ll res = 1;
    while(m){
        if(m & 1)res = (res * n) % MOD;
        m >>= 1;
        n *= n;
        n %= MOD;
    }
    return res;
}
ll mypow(ll n,ll m){
    if(m == 0)return 1;
    if(m < 0)return -1;
    ll res = 1;
    while(m){
        if(m & 1)res = (res * n);
        m >>= 1;
        n *= n;
    }
    return res;
}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll N,M;
    cin >> N >> M;
    struct edge{ll from,to,cost;};
    vector<edge> es(M);
    rep(i,M){
        cin >> es[i].from >> es[i].to >> es[i].cost;
        es[i].from--;es[i].to--;es[i].cost = -es[i].cost;
    }
    vector<ll> dist(N,INF);
    dist[0] = 0;
    ll ans1 = 0,ans2 = 0;
    rep(i,N + 2){
    //vecout(dist);
        rep(j,M){
            if(dist[es[j].from] == INF)continue;
            dist[es[j].to] = min(dist[es[j].from] + es[j].cost,dist[es[j].to]);
        }
        if(i == N - 1)ans1 = dist[N - 1];
        if(i == N + 1)ans2 = dist[N - 1];
    }
    //vecout(dist);
    if(ans1 == ans2){
        cout << -ans1 << "\n";
    }
    else{
        cout << "inf\n";
    }
}

Measured memory_bytes: 3604
def main():
    s = input()
    f1 = False
    f2 = False
    l = [1]
    if s[0] == "<":
        f1 = True
        l.insert(0,0)
    if s[-1] == ">":
        f2 = True
    sm = [i for i in range(0,len(s)+1)]
    for i in range(1,len(sm)):
        sm[i] = sm[i-1]+sm[i]
    lap = l.append
    for i in range(1,len(s)):
        if s[i] == s[i-1]:
            l[-1] += 1
        else:
            lap(1)
    dlist = []
    plist = []
    dap = dlist.append
    pap = plist.append
    if f2:
        l.append(0)
    for i in range(len(l)//2):
        dap(l[2*i])
        pap(l[2*i+1])   
    for i in range(1,len(dlist)):
        x = dlist[i]
        y = plist[i-1]
        if y <= x:
            dlist[i] = sm[x]
            plist[i-1] = sm[max([0,y-1])]
        else:
          dlist[i] = sm[max([0,x-1])]
          plist[i-1] = sm[y]
    dlist[0] = sm[dlist[0]]
    plist[-1] = sm[plist[-1]]
    print(sum(dlist)+sum(plist))
    
if __name__ == '__main__':
    main()

Measured memory_bytes: 77132
#include <bits/stdc++.h>
#define int long long
using namespace std;
signed main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    string s;
    cin >> s;
    int pref[n+1];
    pref[0] = 0;
    for (int i=0; i < n; i++) pref[i+1] = pref[i] + (s[i] == 'E');
    int ans = n;
    for (int i=0; i < n; i++){
        int pr = i - pref[i];
        int ost = pref[n] - pref[i+1];
        pr += ost;
        ans = min(ans, pr);
    }
    cout << ans;
}


Measured memory_bytes: 2964
#include<bits/stdc++.h>
#define rep(i, n) for(int i=0; i<int(n); i++)
using namespace std;
typedef long long ll;
const int mod = 1e9 + 7;

int N;
char ans[10];

void dfs(int now, int n){
	if(now == N){
		for(int i=0; i<N; i++) cout << ans[i];
		cout << endl;
		return;
	}
	for(int i=0; i<=n+1; i++){
		ans[now] = 'a' + i;
		if(i == n+1){ dfs(now+1, n+1); }
		else { dfs(now+1, n); }
	}
}

int main(){
	cin >> N;
	dfs(0, -1);
	return 0;
}


Measured memory_bytes: 1536
//templates
#include <iostream>
#include <algorithm>
#include <string>
#include <numeric>
#include <vector>
#include <unordered_map>
#include <map>
#include <cmath>
#include <iomanip>
#include <bitset>
#include <sstream>
#define rep(i,n) for(int i = 0; i < (n); i++)
#define ALL(x) (x).begin(),(x).end()
#define sort_key(struct_name,key_name) [](const struct_name &x, const struct_name &y){return x.key_name < y.key_name;}
#define pb(x) push_back(x)
typedef long long ll;
const long long MOD = 1e9 + 7;
using namespace std;

//main
int main(){
    int N; cin >> N;
    cout << N*N*N << endl;
}


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

#define int long long
#define rep(n, i) for (int i = 0; i < n; i++)
#define rep2(m, n, i) for (int i = m; i < n; i++)
#define rep_r(n, i) for (int i = n - 1; i >= 0; i--)

typedef pair<int, int> P;
typedef pair<P, P> PP;

const int MAX_H = 501;
const int MAX_W = 501;

const int x[4] = {-1, 0, 1, 0};
const int y[4] = {0 ,-1, 0, 1};

int h, w;
int a[MAX_H][MAX_W];
bool selected[MAX_H][MAX_W];
vector<PP> v;

void solve() {
    rep2(1, h + 1, i) {
        int j = (i % 2 == 0) ? w : 1;
        int cnt = w - 1;
        while (cnt > 0) {
            cnt--;
            int ny = (i % 2 == 0) ? j - 1 : j + 1;
            if (a[i][j] % 2) {
                a[i][j]--;
                a[i][ny]++;
                v.push_back(PP(P(i, j), P(i, ny)));
            }
            j = ny;
        }
        if (i < h) {
            if (a[i][j] % 2) {
                a[i][j]--;
                a[i + 1][j]++;
                v.push_back(PP(P(i, j), P(i + 1, j)));
            }
        }
    }
    
}

signed main() {
    cin >> h >> w;
    rep2(1, h + 1, i) {
        rep2(1, w + 1, j) {
            cin >> a[i][j];
        }
    }
    solve();
    cout << v.size() << endl;
    rep(v.size(), i) {
        cout << v[i].first.first << ' ' << v[i].first.second << ' ' << v[i].second.first << ' ' << v[i].second.second << endl;
    }
    return 0;
}

Measured memory_bytes: 8432
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

N,M = map(int,readline().split())
m = map(int,read().split())
ST = zip(m,m)

out_edge = [[] for _ in range(N+1)]
in_edge = [[] for _ in range(N+1)]

for s,t in ST:
    out_edge[s].append(t)
    in_edge[t].append(s)

out_deg = [len(x) for x in out_edge]

arrive_prob = [0]*(N+1)
arrive_prob[1] = 1.0
for n in range(2,N+1):
    arrive_prob[n] = sum(arrive_prob[p]/out_deg[p] for p in in_edge[n])

# その頂点に辿り着くまでの回数期待値
# いらなかったっぽい
# expected_to = [0]*(N+1)
# for n in range(2,N+1):
#     expected_to[n] = 1 + sum(expected_to[p]*arrive_prob[p]/out_deg[p] for p in in_edge[n])/arrive_prob[n]

# その頂点に辿り着いてからの回数期待値
expected_from = [0]*(N+1)
for n in range(N-1,0,-1):
    expected_from[n] = 1+sum(expected_from[c] for c in out_edge[n])/out_deg[n]

current_time = expected_from[1]

improve = 0
for n in range(1,N):
    if out_deg[n] == 1:
        continue
    x = expected_from[n]
    d = out_deg[n]
    y = (d*(x-1)-max(expected_from[c] for c in out_edge[n]))/(d-1) + 1
    value = (x-y)*arrive_prob[n]
    if improve < value:
        improve = value

answer = current_time - improve
print(answer)

Measured memory_bytes: 29724
/* include c++ libraries */
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <unordered_map>
#include <map>
#include <queue>
#include <set>

/* include c-lang libraries */
#include <climits>
#include <cmath>

/* include my libraries */
//#include <show_vec.hh>

using namespace std;

#define LINE DEBUG{ printf("LINE : %d\n", __LINE__); }
#define DEBUG if(false)

using ll = long long;
template<class T> using vec = vector<T>;

const int MOD = 1000000007;

int main(){
  int K;
  cin >> K;
  string S;
  for(int i = 0; i < K; i++){
    S = S + "ACL";
  }
  cout << S << endl;
  return 0;
}


Measured memory_bytes: 3600
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();

		int max = Math.max(a, b);
		max = Math.max(max, c);
		int sum = a + b + c;

		int ans1 = max * 3;
		int ans2 = (1 + max) * 3;

		if (sum % 2 == ans1 % 2) {
			System.out.println((ans1 - sum) / 2);
		} else {
			System.out.println((ans2 - sum) / 2);
		}

	}
}


Measured memory_bytes: 23892
#include <iostream>
#include <iomanip>
#include <utility>
#include <cmath>
#include <random>
#include <vector>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <string>
#include <algorithm>
using namespace std;

#define rep(i,n) for(int i = 0; i<n; ++i)
#define REP(i,n) for(int i = 1; i<=n; ++i)
#define all(x) begin(x),end(x)
#define show(obj) {for(auto x:obj)cout<<x<<' ';cout<<endl;}
#define line "----------"
typedef long long ll;
typedef pair<int,int> ip;
typedef pair<ll,ll> lp;
const int inf = 1001001000;
const ll INF = 1LL<<60;
const int MOD = (int)1e9 + 7;

int main(){
	string s;cin>>s;
	vector<int> ans(s.size(), 0);
	int r_pos, l_pos;
	int cnt1 = 0, cnt0 = 0;
	rep(i,s.size()){
		if(i%2==0)++cnt0;
		else ++cnt1;
		if(i == s.size()-1)break;
		if(s[i] == 'R' && s[i+1] == 'L'){
			r_pos = i; l_pos = i+1;
		}
		if(s[i] == 'L' && s[i+1] == 'R'){
			if(r_pos%2 == 0){
				ans[r_pos] = cnt0;
				ans[l_pos] = cnt1;
			}else{
				ans[r_pos] = cnt1;
				ans[l_pos] = cnt0;
			}
			cnt0 = 0; cnt1 = 0;
		}
	} 
	if(r_pos%2 == 0){
		ans[r_pos] = cnt0;
		ans[l_pos] = cnt1;
	}else{
		ans[r_pos] = cnt1;
		ans[l_pos] = cnt0;
	}
	show(ans);
	return 0;
}

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

int main(){
    int N;
    int t = 0;
    cin >> N;
    vector<int> p(N);
    for(int i = 0; i < N; i++){
        cin >> p.at(i);
    }

    for(int i = 0; i < N-2; i++){
        if(p.at(i)< p.at(i+1) && p.at(i+1)< p.at(i+2)) t++;
        else if(p.at(i)> p.at(i+1) && p.at(i+1)> p.at(i+2)) t++;
    }
    cout << t << endl;
}

Measured memory_bytes: 256
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

def divisor(n):
    yakusuu = set()
    for i in range(1, int(math.sqrt(n)) + 1):
        if n % i == 0:
            yakusuu.add(i)
            yakusuu.add(n//i)
    return yakusuu

A, B = map(int, input().split())

Adiv = divisor(A)
Bdiv = divisor(B)

commondivisor = Adiv & Bdiv

count = 1
for a in commondivisor:
    if is_prime(a):
        count += 1

print(count)

Measured memory_bytes: 5136
#include <bits/stdc++.h>
// g++ test.cpp && ./a.out < in
#pragma GCC optimize("O3")
using namespace std;
#define fi first
#define se second
#define pb push_back
#define loop(i, a, b) for (int i=a; i<(b); i++)
typedef long long ll;
typedef pair<int,int> pi;
const int INF = 1e9;
const int MOD = 1000000007;



void test_case() {
	int n; cin>>n;
	vector<int> ans(n+1, 0);
	for(int i=1;i<105;i++)
		for(int j=1;j<105;j++)
			for(int k=1;k<105;k++){
				int v = i*i+j*j+k*k+i*j+j*k+k*i;
				if(v <=n ) ans[v]++;
			}
	for(int i=1;i<=n;i++) cout<<ans[i]++<<endl;
}

int main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int t = 1;
	// cin >> t;
	for (int i = 1; i <= t; i++) {
		test_case();
	}
	return 0;
}

Measured memory_bytes: 3592
#include<stdio.h>

int main() {
   char N[3];
   scanf("%s", N);
   
   if(N[0] == '7' || N[1] == '7' || N[2] == '7') {
      printf("Yes");
   }else{
      printf("No");
   }
   printf("\n");
   return 0;
}


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

typedef long long int ll;
ll MOD = 1000000007;
ll INFL = 1ll << 60;
ll INF = 1 << 28;

// =================グラフテンプレート==================

// costの部分の型は指定できます
template <typename T>
struct edge {
  int from, to;
  T cost;

  edge(int to, T cost) : from(-1), to(to), cost(cost) {}
  edge(int from, int to, T cost) : from(from), to(to), cost(cost) {}

  // 行き先を代入できる
  edge &operator=(const int &x) {
    to = x;
    return *this;
  }

  // その他便利機能、って感じ
  operator int() const { return to; }
  bool operator<(edge x) { return this->cost < x.cost; }
};

template <typename T>
using Edges = vector<edge<T>>;

template <typename T>
using WeightedGraph = vector<Edges<T>>;

template <typename T>
using Matrix = vector<vector<T>>;

using UnWeightedGraph = vector<vector<int>>;

//=====================Dijkstra法=======================
// 重み付きグラフと始点を与えると、距離が入ったvectorが帰ってきます
// 距離の型はintでもllでもいいです

template <typename T>
vector<T> dijkstra(WeightedGraph<T> &g, int s) {
  const auto INF = numeric_limits<T>::max();
  vector<T> dist(g.size(), INF);  // 距離をINFで埋める

  using P = pair<T, int>;
  priority_queue<P, vector<P>, greater<P>> que;
  dist[s] = 0;
  que.emplace(0, s);

  while (!que.empty()) {
    T cost;
    int now;
    tie(cost, now) = que.top();
    que.pop();
    if (dist[now] < cost) continue;
    for (auto &e : g[now]) {
      auto next_cost = cost + e.cost;
      if (dist[e.to] <= next_cost) continue;
      dist[e.to] = next_cost;
      que.emplace(dist[e.to], e.to);
    }
  }
  return dist;
}

template <typename T>
ostream &operator<<(ostream &os, vector<T> &vec) {
  cout << "{";
  for (int i = 0; i < vec.size(); i++)
    os << vec[i] << (i + 1 == vec.size() ? "" : " ");
  cout << "}";
  return os;
}

// ====================================================================

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

  WeightedGraph<ll> g(n);  // rgは逆辺を張る
  for (int i = 0; i < m; i++) {
    int a, b;
    ll c;
    cin >> a >> b >> c;
    g[a].push_back(edge<ll>{b, c});
  }

  vector<ll> iki = dijkstra(g, s);

  for (int i = 0; i < n; i++) {
    if (INFL <= iki[i])
      cout << "INF" << endl;
    else
      cout << iki[i] << endl;
  }
}



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

int w,h;
int m[50][50];

void solve(int x,int y){
	if(m[y][x] == 1){
		m[y][x] = 0;
		for(int i=-1;i<2;i++){
			for(int j=-1;j<2;j++){
				if(i==0&&j==0){
					continue;
				}
				if(y+i >= 0 && y+i < h && x+j >= 0 && x+j < w){
					solve(x+j,y+i);
				}
			}
		}
	}
}

int main(){
	while(true){
		int count=0;

		cin >> w >> h;
		if(w==0&&h==0){
			break;
		}

		for(int i=0;i<h;i++){
			for(int j=0;j<w;j++){
				cin >> m[i][j];
			}
		}

		for(int i=0;i<h;i++){
			for(int j=0;j<w;j++){
				if(m[i][j] == 1){
					solve(j,i);
					count++;
				}
			}
		}

		cout << count << endl;
	}
}

Measured memory_bytes: 1276
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
const lint mod = 998244353;
#define all(x) (x).begin(), (x).end()
#define bitcount(n) __builtin_popcountl((lint)(n))
#define fcout cout << fixed << setprecision(15)
#define highest(x) (63 - __builtin_clzl(x))
template<class T> inline void YES(T condition){ if(condition) cout << "YES" << endl; else cout << "NO" << endl; }
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
template<class T = string, class U = char>int character_count(T text, U character){ int ans = 0; for(U i: text){ ans += (i == character); } return ans; }
lint power(lint base, lint exponent, lint module){ if(exponent % 2){ return power(base, exponent - 1, module) * base % module; }else if(exponent){ lint root_ans = power(base, exponent / 2, module); return root_ans * root_ans % module; }else{ return 1; }}
struct position{ int y, x; }; position mv[4] = {{0, -1}, {1, 0}, {0, 1}, {-1, 0}}; // double euclidean(position first, position second){ return sqrt((second.x - first.x) * (second.x - first.x) + (second.y - first.y) * (second.y - first.y)); }
template<class T, class U> string to_string(pair<T, U> x){ return to_string(x.first) + "," + to_string(x.second); } string to_string(string x){ return x; }
template<class itr> void array_output(itr start, itr goal){ string ans; for(auto i = start; i != goal; i++) ans += to_string(*i) + " "; if(!ans.empty()) ans.pop_back(); cout << ans << endl; }
template<class itr> void cins(itr first, itr last){ for(auto i = first; i != last; i++){ cin >> (*i); } }
template<class T> T gcd_calc(T a, T b){ if(b){ return gcd_calc(b, a % b); }else{ return a; }}
template<class T> T gcd(T a, T b){ if(a < b) swap(a, b); return gcd_calc(a, b); }
template<class T> T lcm(T a, T b){ return a / gcd(a, b) * b; }
struct combination{ vector<lint> fact, inv; combination(int sz) : fact(sz + 1), inv(sz + 1){ fact[0] = 1; for(int i = 1; i <= sz; i++){ fact[i] = fact[i - 1] * i % mod; } inv[sz] = power(fact[sz], mod - 2, mod); for(int i = sz - 1; i >= 0; i--){ inv[i] = inv[i + 1] * (i + 1) % mod; } } lint C(int p, int q) const{ if(q < 0 || p < q) return 0; return (fact[p] * inv[q] % mod * inv[p - q] % mod); } };
template<class itr> bool next_sequence(itr first, itr last, int max_bound){ itr now = last; while(now != first){ now--; (*now)++; if((*now) == max_bound){ (*now) = 0; }else{ return true; } } return false; }
inline int at(int x, int k){ return (x >> k) & 1; }
random_device rnd;

string day[7] =  {"SUN", "MON","TUE","WED","THU","FRI","SAT"};

int main(){
    int r;
    cin >> r;
    cout << r * r << endl;
}


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

int main(){
  int N,K,x,sum;
  sum=0;
  cin>>N>>K;
  for(int i=0;i<N;i++){
    cin>>x;
    if(x<=(K-x)){
      sum=sum+2*x;
    }else{
      sum=sum+2*(K-x);
    }
  }
  cout<<sum<<endl;
}


Measured memory_bytes: 256
#include "iostream"
#include <stdio.h>
#include <algorithm>
#include <stdlib.h>
#include <cstring>
#include <math.h>
#include <cctype>
#include <stack>
#include <vector>
#include <list>
#include <queue>
#include <set>
#include <map>
#include <bitset>
using namespace std;
using ll=long long;
#define MOD  1000000007

//互に素判定
ll gcd(ll a, ll b){
        if(b == 0) return a;
        return gcd(b, a % b);
}

// 最小公倍数を求める
ll lcm(ll a, ll b){
        return a / gcd(a, b) * b;
}

ll n,m;

int main(int argc, char const *argv[]) {
  std::cin >> n >> m;
  string s,t;
  std::cin >> s >> t;

  if(s[0]!=t[0]){
    std::cout << "-1" << '\n';
    return 0;
  }

  ll L=lcm(n,m);
  ll a=m/gcd(n,m),b=n/gcd(n,m);
  ll le=min(n,m)/(min(n,m)/gcd(n,m));

  for(int i=0; i<le; i++){
    if(s[b*i]!=t[a*i]){
      std::cout << "-1" << '\n';
      return 0;
    }
  }

  std::cout << L << '\n';
  

  return 0;
}


Measured memory_bytes: 512
if __name__ == "__main__":
    # 入力パターン．
    # 先に要素数Nが与えられて，その数読み込むパターン
    ### N
    ### a_1 a_2 a_3 ... a_N
    N = int(input())
    ans = 0
    for i in range(1, N+1):
        if i % 3 != 0 and i % 5 != 0:
            ans += i
    print(ans)

Measured memory_bytes: 9168
import sys


inint = lambda: int(sys.stdin.readline())
inintm = lambda: map(int, sys.stdin.readline().split())
inintl = lambda: list(inintm())
instr = lambda: sys.stdin.readline()
instrm = lambda: map(str, sys.stdin.readline().split())
instrl = lambda: list(instrm())

k = inint()

x = 7%k

for i in range(1,k+1):
    if x == 0:
        print(i)
        exit()
    x = (x*10+7)%k
print(-1)


Measured memory_bytes: 63312