akhauriyash/Code-Regression huggingface dataset:
// +build ignore
package main

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

// I/O
type Scanner struct {
	sc *bufio.Scanner
}

func NewScanner() *Scanner {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 1024), int(1e+9))
	return &Scanner{sc}
}

func (s *Scanner) nextStr() string {
	s.sc.Scan()
	return s.sc.Text()
}

func (s *Scanner) nextInt() int {
	i, e := strconv.Atoi(s.nextStr())
	if e != nil {
		panic(e)
	}
	return i
}

func (s *Scanner) nextFloat() float64 {
	f, e := strconv.ParseFloat(s.nextStr(), 64)
	if e != nil {
		panic(e)
	}
	return f
}

func (s *Scanner) nextRuneSlice() []byte {
	return []byte(s.nextStr())
}

func (s *Scanner) nextIntSlice(n int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ {
		res[i] = s.nextInt()
	}
	return res
}

func (s *Scanner) nextFloatSlice(n int) []float64 {
	res := make([]float64, n)
	for i := 0; i < n; i++ {
		res[i] = s.nextFloat()
	}
	return res
}

func run(input io.Reader, output io.Writer) int {
	sc := NewScanner()
	N := sc.nextInt()
	K := sc.nextInt()

	N = N % K

	for {
		if N >= K {
			N = N - K
		} else {
			n := K - N
			if n <= N {
				fmt.Println(n)
			} else {
				fmt.Println(N)
			}
			break
		}
	}

	return 0
}

func main() {
	os.Exit(run(os.Stdin, os.Stdout))
}


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

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

using namespace std;

int main()
{
  int s;
  int a[1000000];
  cin >> s;
  a[s] = 1;
  int result = 0;
  for (int i = 2; true; i++)
  {
    if (s % 2 == 0)
    {
      s = s / 2;
    }
    else
    {
      s = 3 * s + 1;
    }
    if (a[s] != 0)
    {
      result = i;
      break;
    }
    a[s]++;
  }
  cout << result << endl;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
	int a, b, c;
	int tyo, hisi;
	
	tyo = 0;
	hisi = 0;
	while (scanf("%d,%d,%d", &a, &b, &c) != EOF){
		if (a * a + b * b == c * c) {
			tyo++;
		}
		else if (a == b) {
			hisi++;
		}
	}
	printf("%d\n%d\n", tyo, hisi);
	
	return (0);
}

Measured memory_bytes: 596
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int N,M;
ll dp[100010];
#define MOD 1000000007
//int A[100010];
struct square
{
    bool available;
    int left;
    int right;
    int up;
    int down;
};
int main()
{
    
int H,W,M=0;
cin>>H>>W;
square S[H][W];
for(int i=0;i<H;i++)
{
    for(int j=0;j<W;j++)
    {
        char c;
        cin>>c;
        if(c=='#')
        {
            S[i][j].available=false;
        }
        else
        {
            S[i][j].available=true;
            if(j>0 && S[i][j-1].available!=false)
            
            S[i][j].left=(S[i][j-1].left)+1;
            else
            S[i][j].left=0;
            if(i>0 && S[i-1][j].available!=false)
            S[i][j].up=(S[i-1][j].up)+1;
            else
            S[i][j].up=0;
            //cout<<S[i][j].left<<" "<<S[i][j].up<<"  ";
        }
    }
    //cout<<endl;
}
for(int i=H-1;i>=0;i--)
{
    for(int j=W-1;j>=0;j--)
    {
        if(S[i][j].available==false)
        continue;
        if(i<H-1 && S[i+1][j].available==true)
        S[i][j].down=(S[i+1][j].down)+1;
        else
        S[i][j].down=0;
        if(j<W-1 && S[i][j+1].available==true)
        S[i][j].right=(S[i][j+1].right)+1;
        else
        S[i][j].right=0;
        M=max(M,S[i][j].right+S[i][j].left+S[i][j].up+S[i][j].down+1);
    }
}
cout<<M;
return 0;
    
}

Measured memory_bytes: 78464
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
 
int N, M, Q;
int A[11]{};
int a[50], b[50], c[50], d[50];
 
int ans = 0;
 
void dfs(int n) {
    if (n == N) {
        int sum = 0;
        for (int i = 0; i < Q; i++) {
            if (A[b[i]] - A[a[i]] == c[i]) sum += d[i];
        }
        ans = max(ans, sum);
        return;
    }
    for (int i = min(A[n], M); i <= M; i++) {
        A[n + 1] = i;
        dfs(n + 1);
    }
 
}
int main() {
    cin >> N >> M >> Q;
 
    for (int i = 0; i < Q; i++) {
        cin >> a[i] >> b[i] >> c[i] >> d[i];
    }
    A[0] = 1;
    dfs(0);
    cout << ans << endl;;
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
using vint = vector<int>;
using vvint = vector<vint>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vchar = vector<char>;
using vvchar = vector<vchar>;
using vp = vector<P>;
using vpp = vector<pair<P, P>>;
using vvp = vector<vp>;

#define rep(i, n) for (int i = 0; i < n; ++i)
#pragma region Debug
istream &operator>>(istream &is, P &a)
{
    return is >> a.first >> a.second;
}
ostream &operator<<(ostream &os, const P &a) { return os << "(" << a.first << "," << a.second << ")"; }

template <typename T>

void view(const std::vector<T> &v)
{
#ifndef ONLINE_JUDGE
    for (const auto &e : v)
    {
        std::cout << e << " ";
    }
    std::cout << std::endl;
#endif
}
template <typename T>
void view(const std::vector<std::vector<T>> &vv)
{
    for (const auto &v : vv)
    {
        view(v);
    }
}
#pragma endregion

int main()
{
    int n;
    cin >> n;
    vector<pair<string, int>> r(n), q(n);
    rep(i, n)
    {
        string s;
        int p;
        cin >> s >> p;
        r[i] = {s, p};
        q[i] = r[i];
    }
    auto cmp = [](pair<string, int> a, pair<string, int> b) {
        if (a.first == b.first)
        {
            return a.second > b.second;
        }
        return a.first < b.first;
    };

    sort(r.begin(), r.end(), cmp);
    for (auto p : r)
    {
        int id = 0;
        rep(i, n)
        {
            if (p == q[i])
            {
                id = i + 1;
            }
        }
        cout << id << endl;
    }

    return 0;
}

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

#define rep(i,n) for(long long i = 0; i < (long long)(n); i++)
#define repi(i,a,b) for(long long i = (long long)(a); i < (long long)(b); i++)
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define fi first
#define se second
#define mt make_tuple
#define mp make_pair
template<class T1, class T2> bool chmin(T1 &a, T2 b) { return b < a && (a = b, true); }
template<class T1, class T2> bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }

using ll = long long; using vll = vector<ll>; using vvll = vector<vll>; using P = pair<ll, ll>;
using ld = long double;  using vld = vector<ld>; 

int main(void) {
	/*
    string s(9, ' ');
	rep(i,9)  cin >>s[i];
	
	cout<<s[0]<<s[4]<<s[8]<<endl;
	*/
	/*
	string s;
	rep(i, 9) {
		char c; cin >> c;
		s += c;
	}
	cout<<s[0]<<s[4]<<s[8]<<endl;
	*/	
	vector<string> c(3);
	rep(i, 3) cin >> c[i];
	rep(i, 3) cout << c[i][i];
	
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <string>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <string.h>
#include <vector>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <time.h>
#define int long long
#define ll long long
#define us unsigned
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rrep(i, n) for (int i = (n)-1; i >= 0; ++i)
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define nin(ary, n) for (int i = 0; i < (n); i++) cin >> ary[i]
#define nnin(ary, h, w) for (int i = 0; i < (h); ++i) for (int j = 0; j < (w); ++j) cin >> ary[i][j]
#define opt(conditions, a, b) cout << ((conditions) ? #a : #b) << endl
using namespace std;
const double PI = acos(-1.0);
const int MOD = 1e9 + 9;

int max_n(int ary[], int length) {
	int max = ary[0];
	for (int i = 1; i < length; i++)
		if (max < ary[i]) max = ary[i];
	return max;
}

int max_o(int ary[], int length) {
	int max;
	max = max_n(ary, length);
	for (int i = 0; i < length; i++) {
		if (ary[i] == max) return i;
	}
	return -1;
}

int min_n(int ary[], int length) {
	int min = ary[0];
	for (int i = 1; i < length; i++)
		if (min > ary[i]) min = ary[i];
	return min;
}

int min_o(int ary[], int length) {
	int min;
	min = min_n(ary, length);
	for (int i = 0; i < length; i++) {
		if (ary[i] == min) return i;
	}
	return -1;
}

int gcm(int a, int b) {
	int result = a;
	int k = 0;
	int n = b;
	do {
		k = result % n;
		result = n;
		n = k;
	} while (k != 0);
	return result;
}

int gcm_n(int ary[], int length) {
	int g = ary[0];
	for (int i = 0; i < length; i++)
		g = gcm(g, ary[i]);
	return g;
}

int lcm(int a, int b) {
	int g, n;
	g = gcm(a, b);
	n = gcm(a, g);
	a = a / n;
	b = b / (g / n);
	return a*b;
}

int lcm_n(int ary[], int length) {
	int l = ary[0];
	for (int i = 0; i < length; i++)
		l = lcm(l, ary[i]);
	return l;
}






signed main() {
	
	int n, l[1000], r[1000], cnt = 0;
	cin >> n;
	rep(i, n) {
		cin >> l[i] >> r[i];
	}

	rep(i, n) {
		cnt += r[i] - l[i] + 1;
	}

	cout << cnt << endl;
	return 0;
}

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

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

#define fi first
#define se second
#define repl(i,a,b) for(ll i=(ll)(a);i<(ll)(b);i++)
#define rep(i,n) repl(i,0,n)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define mmax(x,y) (x>y?x:y)
#define mmin(x,y) (x<y?x:y)
#define maxch(x,y) x=mmax(x,y)
#define minch(x,y) x=mmin(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt __builtin_popcountll

#define INF 1e16
#define mod 1000000007

ll l,r;

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

  cin>>l>>r;
  if(r-l<=3000){
    ll res=100000;
    repl(i,l,r+1)repl(j,i+1,r+1){
      minch(res,i*j%2019);
    }
    cout<<res<<endl;
  }else{
    cout<<0<<endl;
  }

  return 0;
}


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

using namespace std;
using ll=long long;
using ull=unsigned long long;
using pii=pair<int,int>;

#define INF LONG_MAX
#define MOD 1000000007
#define rng(a) a.begin(),a.end()
#define rrng(a) a.end(),a.begin()
#define rep(i,N) for(int i=0;i<N;i++)

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

  int A,B;
  cin>>A>>B;
  for(double i=0;i<=10000;i++){
    int a=(i*0.08);
    int b=(i*0.1);
    if(A==a&&B==b){
      cout<<i<<endl;
      return 0;
    }
  }
  cout<<-1<<endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define INF 1e9
#define llINF 1e18
#define MOD 1000000007
#define pb push_back
#define mp make_pair 
#define F first
#define S second
#define ll long long
#define vi vector<ll>
#define vvi vector<vi>
#define BITLE(n) (1LL<<((ll)n))
#define SHIFT_LEFT(n) (1LL<<((ll)n))
#define SUBS(s,f,t) ((s).substr((f),(t)-(f)))
#define ALL(a) (a).begin(),(a).end()
using namespace std;

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll n;cin>>n;
  string a,b,c;cin>>a>>b>>c;
  ll ans = 0;
  for(int i=0;i<n;i++){
    set<char>se;
    se.insert(a[i]);
    se.insert(b[i]);
    se.insert(c[i]);
    ans += se.size()-1;
  }
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main()
{
    int i,c;
    string s;
    cin>>s;
    
    if((s[0]==s[1]&& s[1]==s[2])||(s[1]==s[2]&& s[2]==s[3]))
    cout<<"Yes";
    else
    cout<<"No";
    
    return 0;
}


Measured memory_bytes: 3616
import java.util.Scanner;

public class Main {
	public static void main(String [] args) {
		Scanner scan = new Scanner(System.in);
		int n, b, f, r, v;
		int data1[][] = new int[3][10];
		int data2[][] = new int[3][10];
		int data3[][] = new int[3][10];
		int data4[][] = new int[3][10];
		
		for(int i = 0; i < 3; i++) {
			for(int j = 0; j < 10; j++) {
				data1[i][j] = 0;
				data2[i][j] = 0;
				data3[i][j] = 0;
				data4[i][j] = 0;
			}
		}
		
		n = scan.nextInt();
		
		for(int i = 1; i <= n; i++) {
			b = scan.nextInt();
			f = scan.nextInt();
			r = scan.nextInt();
			v = scan.nextInt();
			
			switch(b) {
			case 1:
				data1[f - 1][r - 1] += v; 
				break;
			case 2:
				data2[f - 1][r - 1] += v; 
				break;
			case 3:
				data3[f - 1][r - 1] += v; 
				break;
			case 4:
				data4[f - 1][r - 1] += v; 
				break;
			default:
				break;
			}
		}
		
		for( int i = 0; i < 4; i++) {
			for(int j = 0; j < 3; j++) {
				for(int k = 0; k < 10; k++) {
					switch(i) {
					case 0:
						if( k == 9) {
							System.out.println(" " + data1[j][k]);
						}else {
							System.out.print(" " + data1[j][k]);
						}
						break;
					case 1:
						if( k == 9) {
							System.out.println(" " + data2[j][k]);
						}else {
							System.out.print(" " + data2[j][k]);
						}
						break;
					case 2:
						if( k == 9) {
							System.out.println(" " + data3[j][k]);
						}else {
							System.out.print(" " + data3[j][k]);
						}
						break;
					case 3:
						if( k == 9) {
							System.out.println(" " + data4[j][k]);
						}else {
							System.out.print(" " + data4[j][k]);
						}
						break;
					default:
						break;
					}
				}
			}
			if( i != 3) {
				for( int m = 0; m < 20; m++) {
					if( m == 19) {
						System.out.println("#");
					}else {
						System.out.print("#");
					}
				}
			}
		}
		
		
	}
}


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

int main() {
  string s;
  cin>>s;
  int n=s.size();
  
  int a,b=0;
  for (int i = 0; i < n; i++) {
    if(s[i]=='A'){a=i; break;}
  }
  
  for (int i = n; i >a; i--) {
    if(s[i]=='Z'){b=i; break;}
  }
  cout<<b-a+1<<endl;
}

Measured memory_bytes: 640
#include <iostream>
using namespace std;
int main(){
  int s[6];
  int p[6][6] = {{0,3,5,2,4,0},{4,0,1,6,0,3},{2,6,0,0,1,5},{5,1,0,0,6,2},{3,0,6,1,0,4},{0,4,2,5,3,0}};
  int a,b,n;

  for(int i=0;i<6;i++) cin>>s[i];
  cin>>n;
  for(int i=0;i<n;i++){
    cin>>a>>b;
    for(int j=0;j<6;j++){
      if(a==s[j]) a=j;
      if(b==s[j]) b=j;
    }
    cout<<s[p[a][b]-1]<<endl;
  }
  return 0;
}



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

#define ll long long
#define p_q priority_queue
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define MAX 1000000001



int main(){
    int a,b;
    cin>>a>>b;
    
    cout<<a*b/2<<endl;
}

Measured memory_bytes: 256
import java.util.Scanner;
 
public class Main {
 
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
 
        int p = scanner.nextInt(); 
        int m = scanner.nextInt();
        int c = scanner.nextInt();
            System.out.println(p+m+c);
        
    }
}
 



Measured memory_bytes: 26072
using System;
using System.Collections.Generic;

class Program {
    static void Main (string[] args) {
        int N = int.Parse (Console.ReadLine ());
        char[] S = Console.ReadLine ().ToCharArray ();
        var R = new HashSet<int> ();
        var G = new HashSet<int> ();

        for (int i = 0; i < N; i++) {
            if (S[i] == 'R') {
                R.Add (i);
            } else if (S[i] == 'G') {
                G.Add (i);
            }
        }

        int Rnum = R.Count;
        int Gnum = G.Count;
        int Bnum = N - Rnum - Gnum;
        long ans = 0;

        foreach (int x in R) {
            foreach (int y in G) {
                ans += Bnum;
                if (x < y) {
                    int left = 2 * x - y;
                    if (0 <= left && left < N) {
                        if (S[left] == 'B') {
                            ans--;
                        }
                    }
                    int right = 2 * y - x;
                    if (0 <= right && right < N) {
                        if (S[right] == 'B') {
                            ans--;
                        }
                    }
                    if ((y - x) % 2 == 0) {
                        if (S[(y + x) / 2] == 'B') {
                            ans--;
                        }
                    }
                } else {
                    int left = 2 * y - x;
                    if (0 <= left && left < N) {
                        if (S[left] == 'B') {
                            ans--;
                        }
                    }
                    int right = 2 * x - y;
                    if (0 <= right && right < N) {
                        if (S[right] == 'B') {
                            ans--;
                        }
                    }
                    if ((x - y) % 2 == 0) {
                        if (S[(y + x) / 2] == 'B') {
                            ans--;
                        }
                    }
                }
            }
        }

        Console.WriteLine (ans);
    }
}

Measured memory_bytes: 27736
#define rep(i,n) REP(i,0,n)
#define REP(i, a, b) for(int i = a; i < (int)(b); i++)
#include <bits/stdc++.h>

typedef long long ll;
using namespace std;
template<class T> inline void chmax(T &a, const T &b) {if(a < b) a = b;}
template<class T> inline void chmin(T &a, const T &b) {if(a > b) a = b;}

const ll MAXN = (ll)1e5+10;
const long long INF = 1LL<<60;
ll dp[110][MAXN];

int main(void) {
   ll N,W;
   cin>>N>>W;
   ll w[N];
   ll v[N];
   rep(i,N) {
      cin>>w[i];
      cin>>v[i];
   }
   // memset(dp,0,sizeof(dp));
   rep(i,110) rep(val,MAXN) dp[i][val] = INF;
   dp[0][0] = 0;
   rep(i,N) rep(val,MAXN){
      chmin(dp[i+1][val],dp[i][val]);
      if (val+v[i]>=MAXN) continue; 
      chmin(dp[i+1][val+v[i]],dp[i][val]+w[i]);
   }
   // cout<<dp[N][W]<<endl;

   ll ans = 0;
   rep(val,MAXN) {
      if (dp[N][val] <= W) chmax(ans,(ll)val);
   }
   cout<<ans<<endl;




   return 0;
}

Measured memory_bytes: 86144
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Console;
using System.Text;
using System.IO;
using static System.Math;
namespace AtCoder
{
    class Program
    {
        static public long[] Sarray() { return ReadLine().Split().Select(long.Parse).ToArray(); }
        static public List<long> Slist() { return ReadLine().Split().Select(long.Parse).ToList(); }


        static void Main(string[] args)
        {
            //SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
            var s = ReadLine().ToCharArray();
            var t = ReadLine().ToCharArray();
            Array.Sort(s);
            Array.Sort(t);Array.Reverse(t);
            for (var i = 0; i < Min(s.Length, t.Length); ++i)
            {
                if (s[i] == t[i])
                {
                    continue;
                }
                else if (s[i] < t[i])
                {
                    WriteLine("Yes");
                    return;
                }
                else
                {
                    WriteLine("No");
                    return;
                }
            }
            if (t.Length <= s.Length)
            {
                WriteLine("No");
                return;
            }
            WriteLine("Yes");

            //Out.Flush();
        }
    }
}

Measured memory_bytes: 13396
// #define _GLIBCXX_DEBUG
// #pragma GCC optimize("Ofast")
#pragma GCC diagnostic ignored "-Wsign-compare"
#include <bits/stdc++.h>
using namespace std;
using i64 = int_fast64_t;
#define rep(i, n) for (int i = 0; i < (i64)(n); ++i)
#define reps(i, s, n) for (int i = s; i < (i64)(n); ++i)

void solve() {
    int n;
    cin >> n;
    vector<int> P(n);
    vector<int> Q(n);
    for (auto &&e : P) cin >> e;
    for (auto &&e : Q) cin >> e;
    int a = -1, b = -1;
    int cnt = 1;
    vector<int> A(n);
    rep(i, n) A[i] = i + 1;
    do {
        if (a == -1)
            if (A == P) a = cnt;
        if (b == -1)
            if (A == Q) b = cnt;
        cnt++;
    } while (next_permutation(A.begin(), A.end()));
    cout << abs(b - a) << "\n";
}
int main() {
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    // cout << fixed << setprecision(15);
    solve();
}

Measured memory_bytes: 3656
package main

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

func main() {
	A := nextInt()
	B := nextInt()
	C := nextInt()

	K := nextInt()

	c := 0

	for c <= K {
		if A >= B {
			B *= 2
			c++
		} else if B >= C {
			C *= 2
			c++
		} else {
			break
		}
	}

	if c <= K {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
}

var stdin = initStdin()

func initStdin() *bufio.Scanner {
	bufsize := 1 * 1024 * 1024 // 1 MB
	var stdin = bufio.NewScanner(os.Stdin)
	stdin.Buffer(make([]byte, bufsize), bufsize)
	stdin.Split(bufio.ScanWords)
	return stdin
}

func nextString() string {
	stdin.Scan()
	return stdin.Text()
}

func nextBytes() []byte {
	stdin.Scan()
	return stdin.Bytes()
}

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

func nextInt64() int64 {
	i, _ := strconv.ParseInt(nextString(), 10, 64)
	return i
}

func debug(args ...interface{}) {
	fmt.Fprintln(os.Stderr, args)
}


Measured memory_bytes: 1804
#include<bits/stdc++.h>
#include<iostream>
#include<cstdio>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
using namespace std;
#define rep(i,x) for(int i = 0; i < x; i++)
#define pb push_back
#define mp make_pair
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<ll,ll> Pll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<vector<vector<int>>> vvvi;
const ll N = 1e9+7;
const int n_max = 1e5+10;


void print() {
    cout << endl;
}
 
template <class Head, class... Tail>
void print(Head&& head, Tail&&... tail) {
    cout << head;
    if (sizeof...(tail) != 0) cout << ' ';
    print(forward<Tail>(tail)...);
}
 
template <class T>
void print(vector<T> &vec) {
    for (auto& a : vec) {
        cout << a;
        if (&a != &vec.back()) cout << ' ';
    }
    cout << endl;
}
 
template <class T>
void print(vector<vector<T>> &df) {
    for (auto& vec : df) {
        print(vec);
    }
}
 
int main(){
  int n;cin >> n;
  bool ok=false;
  if(n == 3 || n == 5||n==7)ok=true;
  cout <<(ok ? "YES" : "NO") << endl;
}
    

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

#define ll long long

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

    c = min({c, 2*b, 4*a});

    if(2*c < d) cout << n*c << endl;
    else cout << (n/2)*d + (n%2)*c << endl;

    return 0;
}


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

int main()
{
	int N, tmp, num, sum = 0;
	cin >> N;
	tmp = N;

	while (tmp) {
		num = tmp % 10;
		sum += num;
		tmp /= 10;
	}

	if (N % sum == 0) {
		cout << "Yes" << endl;
	}

	else {
		cout << "No" << endl;
	}
}

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

int main() {
  int X,Y;
  cin >> X >> Y;
  int ans = 0;
  if(X == 1) ans += 300000;
  else if(X == 2) ans += 200000;
  else if(X == 3) ans += 100000;
  
  if(Y == 1) ans += 300000;
  else if(Y == 2) ans += 200000;
  else if(Y == 3) ans += 100000;
  
  if(X == 1 && Y == 1) ans += 400000;
  
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <vector>
#include <list>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>
#include <numeric>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
using namespace std;

const int size = 1000001;
bool T[size];

int solve( int n, int a, int b ) {
    for ( int i = 0; i <= n; ++ i ) T[i] = false;
    for ( int i = 0; i < a; ++ i ) {
        long long x = b * i;
        if ( x > n ) break;
        while ( x <= n ) {
            T[x] = true;
            x += a;
        }
    }
    int res = 0;
    for ( int i = 1; i <= n; ++ i ) {
        if ( ! T[i] ) res ++;
    }
    return res;
}

int main() {
    int n, a, b;
    while ( cin >> n >> a >> b && a > 0 ) {
        cout << solve( n, a, b ) << endl;
    }
    return 0;
}

Measured memory_bytes: 0
i1 = input()
i2 = input()



minNeeded = 99999999999
tt =0 
for i in i1[0:1+(len(i1)-len(i2))]:
  neededChanges = 0
  t = 0
  for ii in i2:
    if ii != i1[tt+t]:
      neededChanges +=1
    t +=1
  if neededChanges < minNeeded:
    minNeeded = neededChanges
  tt += 1
print(minNeeded)

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

int gcd(int i,int j,int k){
for(int ii=i;ii>=1;ii--){
    if(i%ii==0&&j%ii==0&&k%ii==0)
        return ii;
}
}

int main(){
    int n;
    cin>>n;
    long long sum=0;
    for(int i=1;i<=n;i++)
        for(int j=1;j<=n;j++)
        for(int k=1;k<=n;k++){
        sum+=gcd(i,j,k);
    }
    cout<<sum<<endl;
    return 0;


}


Measured memory_bytes: 3596
#include<iostream>

using namespace std;

int main()
{
    int N;
    cin>>N;
    double sum = 0;
    double x; char u[3];
    for(int i=0; i<N; i++){
        cin >> x >> u;
        if(u[0]=='J'){ sum += x;}
        else if(u[0]=='B'){ sum += 380000*x;}
    }
    cout << sum << endl;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <string>
#include <vector>

using namespace std;
using LLONG = long long;

int N, D;

const int ComputeDist(const vector<int> &x1, const vector<int> &x2)
{
    int dist = 0;
    for (int i = 0; i < D; ++i)
    {
        dist += pow(x1[i] - x2[i], 2.0);
    }
    return dist;
}

const bool IsSquaredInteger(const int x)
{
    const int root = static_cast<int>(sqrt(x));
    return root * root == x;
}

int main()
{
    cin >> N >> D;
    vector<vector<int>> Xs(N, vector<int>(D));
    for (int i = 0; i < N; ++i)
    {
        for (int j = 0; j < D; ++j)
        {
            cin >> Xs[i][j];
        }
    }
    int count = 0;
    for (int i = 0; i < N; ++i)
    {
        for (int j = i + 1; j < N; ++j)
        {
            if (IsSquaredInteger(ComputeDist(Xs[i], Xs[j])))
            {
                ++count;
            }
        }
    }
    cout << count << endl;
}


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

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
char a,b;
int x,y;
int main(){
ios_base::sync_with_stdio(0);
cin.tie(0);cout.tie(0);
cin>>a>>b;

if(a=='A')x=10;
else if(a=='B')x=11;
else if(a=='C')x=12;
else if(a=='D')x=13;
else if(a=='E')x=14;
else x=15;
if(b=='A')y=10;
else if(b=='B')y=11;
else if(b=='C')y=12;
else if(b=='D')y=13;
else if(b=='E')y=14;
else y=15;
if(x>y)cout<<'>';
else if(x<y) cout<<'<';
else cout<<'=';



return 0;}



Measured memory_bytes: 3664
def main():
    A, B, C, X, Y = map(int, input().split())
    ans = min(X, Y) * min(A+B, 2*C) + max(X-Y, 0) * \
        min(A, 2*C) + max(Y-X, 0) * min(B, 2*C)
    print(ans)


if __name__ == "__main__":
    main()


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

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

int main(){
    int h,w;
    cin >> h >> w;
    char maze[h][w];
    for (int i = 0; i < h; i++){
        for (int j = 0; j < w; j++){
            cin >> maze[i][j];
        }
    }
    
    queue<P> que;
    int dis[h][w];
    int ans = 0;
    P next;
    int nexth[4] = {0,0,1,-1}; int nextw[4] = {1,-1,0,0};

    for (int a = 0; a < h; a++){
        for (int b = 0; b < w; b++){
            if (maze[a][b] == '#') continue;

            P start = P(a,b);
            for (int i = 0; i < h; i++){
                for (int j = 0; j < w; j++){
                    dis[i][j] = INF;
                }
            }
            dis[start.first][start.second] = 0;

            que.push(start);
            while(que.size()){
                P now = que.front(); que.pop();

                for (int i = 0; i < 4; i++){
                    next = P(now.first + nexth[i], now.second + nextw[i]);
                    if (next.first >= 0 && next.second >= 0 && next.first < h && next.second < w && maze[next.first][next.second] != '#' && dis[next.first][next.second] == INF){
                        que.push(next);
                        dis[next.first][next.second] = dis[now.first][now.second] +1;
                        ans = max(ans, dis[next.first][next.second]);
                    }
                }
            }

        }
    }
    cout << ans << "\n";
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LINF = 1e18;
template<class S,class T> ostream &operator << (ostream& out,const pair<S,T>& o){
    out << "(" << o.first << "," << o.second << ")"; return out;
}

/*
<url:https://arc079.contest.atcoder.jp/tasks/arc079_b>
問題文============================================================
 長さ N の非負整数列 ai に対し、数列の最大値が N−1 以下になるまで以下の操作を繰り返し行うことを考えます。
 
 数列のうち最も大きい要素を求める、複数ある場合はどれか 1 つ選ぶ。
 この要素の値を N 減らす。これ以外の要素の値を 1 増やす。
 なお、この操作を行い続けると、いつかは数列の最大値が N−1 以下になることが証明できます。
 
 ここで、整数 K が与えられるので、
 この操作を行う回数がちょうど K 回になるような数列 ai を 1 つ求めてください。
 なお、この問題の入出力の制約下では、かならず 1 つは条件を満たすような数列が存在することが示せます。
=================================================================

解説=============================================================

================================================================
*/
void solve(){
    ll K; cin >> K;
    const ll N = 50;
    vector<ll> a(N,0);
    iota(a.begin(),a.end(),0);
    for(int i = 0; i < N;i++) a[i] += K/N;
    K %= N;
    for(int i = 0; i < K;i++){
        a[i] += (N+1);
        for(int j = 0; j < N;j++) a[j]--;
    }
    cout << N << endl;
    for(int i = 0; i< N;i++){
        cout << a[i] << " ";
    }
    cout << endl;
}
int main(void) {
	cin.tie(0); ios::sync_with_stdio(false);
    solve();
	return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <map>
#include <math.h>
#include <numeric>
#include <set>
#include <string>
#include <utility>
#include <vector>
using namespace std;
typedef long long ll;


int main(){
    ll N;
    set<string> st;
    string S;

    cin >> N;

    for(ll i = 0; i < N; i++){
        cin >> S;
        if(st.count(S) == 0){
            st.insert(S);
        }
    }

    cout << st.size() << endl;

    return 0;
}


Measured memory_bytes: 19228
#include <iostream>
#include <vector>
#include <map>
using namespace std;
int N;

void solve(vector<int> cur, vector<int> prev, int turn) {
    if(cur == prev) {
        cout << turn-1 << endl;
        for(int i=0; i<N; i++) cout << (i!=0 ? " " : "") << cur[i];
        cout << endl;
        return;
    }

    map<int, int> m;
    for(int i=0; i<N; i++) m[ cur[i] ]++;
    vector<int> nx(N);
    for(int i=0; i<N; i++) nx[i] = m[ cur[i] ];
    solve(nx, cur, turn+1);
}

int main() {
    while(cin >> N, N) {
        vector<int> v(N);
        for(int i=0; i<N; i++) cin >> v[i];
        solve(v, vector<int>(N, 0), 0);
    }
    return 0;
}

Measured memory_bytes: 3092
#include <iostream>
#include <algorithm>
using namespace std;
int main(void){
    // Your code here!
    int N;
    cin>>N;
    long long A[3];
    long long i,j,v,k,minA;
    long long per0,per1,per2;
    
    
    for(i=0;i<N;i++)
    {
        cin>>A[i];
    }
    
    if(N==3)
    {
        minA=min(min(A[0],A[1]),A[2]);
        
        for(i=1;i<=minA;i++)
        {
            if(A[0]/i*i==A[0] && A[1]/i*i==A[1] && A[2]/i*i==A[2])
            {
                cout<<i<<endl;
            }
        }
        
    }
    else
    {
         minA=min(A[0],A[1]);
        
        for(i=1;i<=minA;i++)
        {
            if(A[0]/i*i==A[0] && A[1]/i*i==A[1])
            {
                cout<<i<<endl;
            }
        }
    }
    
}



Measured memory_bytes: 3112
use proconio::input;
use std::collections::BTreeMap;

const M: u64 = 1_000_000_007;

fn main() {
    input! {
        n: usize,
        d: [(i64, i64); n],
    }

    let mut z = 0;
    let mut t = BTreeMap::new();
    for e in d {
        if e.0 == 0 && e.1 == 0 {
            z += 1;
        } else {
            fn grouping(e: (i64, i64)) -> (i64, i64) {
                let e = if e.0 < 0 { (-e.0, -e.1) } else { e };
                let g = num::integer::gcd(e.0, e.1);
                (e.0 / g, e.1 / g)
            }
            let e = match e {
                _ if e.0 == 0 => (0, 1),
                _ if e.1 == 0 => (1, 0),
                _ => grouping(e),
            };
            *t.entry(e).or_insert(0) += 1;
        }
    }
    z %= M;

    let mut ans = 1;
    while let Some((&k, &c)) = t.iter().next() {
        t.remove(&k);
        let inv = if k.1 < 0 {
            (-k.1, k.0)
        } else {
            (k.1, -k.0)
        };

        let c2 = modpow(2, c);
        if let Some(invc) = t.remove(&inv) {
            let i2 = modpow(2, invc);
            ans *= c2 + i2 - 1;
        } else {
            ans *= c2;
        }
        ans %= M;
    }
    ans += z + M - 1;
    ans %= M;
    println!("{}", ans);
}

fn modpow(x: u64, y: u64) -> u64 {
    let mut result = 1;
    let mut a = x;
    let mut b = y;
    while b > 0 {
        if b % 2 == 1 {
            result = result * a % M;
        }
        a = a * a % M;
        b /= 2;
    }
    result
}


Measured memory_bytes: 20556
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String line=sc.nextLine();
		char [] s=new char[line.length()];
		for(int i=0; i<line.length(); i++){
			if(Character.isUpperCase(line.charAt(i))){
				s[i]=Character.toLowerCase(line.charAt(i));
			}else if(Character.isLowerCase(line.charAt(i))){
				s[i]=Character.toUpperCase(line.charAt(i));
			}else{
				s[i]=line.charAt(i);
			}
		}
		for(int j=0; j<s.length; j++){
			System.out.print(s[j]);
		}
		System.out.println();
		}


}


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

void b_training_camp(void) {
	long long int n;
	long long int power = 1;
	const int a = 1000000007;

	cin >> n;
	for (long long int i = 1; i <= n; i++) {
		power = power*i;
		power = power % a;
		
	}
	cout << power << endl;
	//cout << power % (a) << endl;
}

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

Measured memory_bytes: 3600
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    int N; cin >> N;
    string stones; cin >> stones;
    int flag = 0;
    char tmp1 = stones[0];
    int stone_R = 0;
    int stone_W = 0;
    if(tmp1 == 'R') stone_R ++;
    else stone_W ++;

    for(int i = 1; i < N; i++){
        char tmp2 = stones[i];
        if(tmp2 == 'R') stone_R ++;
        else stone_W ++;
        if(tmp1 == 'W' && tmp2 == 'R') flag = 1;
        tmp1 = tmp2;
    }

    int ans = 777;
    if(flag == 0) ans = 0;
    else{
        int a_R = stone_R;
        int a_W = stone_W;
        int a_swap = 0;
        int i = 0;
        int j = N-1;
        while(true){
            while(true){
                char tmp = stones[i];
                if(tmp == 'W') break;
                else i++;
            }
            while(true){
                char tmp = stones[j];
                if(tmp == 'R') break;
                else j--;
            }
            if(j < i) break;
            else{
                stones[i] = 'R';
                stones[j] = 'W';
                a_swap ++;
            }
        }
        ans = min(a_R, a_W);
        ans = min(ans, a_swap);
    }

    cout << ans << endl;
}

Measured memory_bytes: 3708
import java.util.*;class Main{public static void main(String[]z){Scanner s=new Scanner(System.in);String e="",r;for(int a,b;(a=s.nextInt())+(b=s.nextInt())>0;e+="\n"){r="";for(;a<=b;a++)r+=(a%100<1?a%400<1?1:0:a%4<1?1:0)<1?"":a+"\n";e+=r.isEmpty()?"NA\n":r;}System.out.println(e.replaceAll("\n$",""));}}

Measured memory_bytes: 12000
#include <iostream>
#include <iomanip>

int main()
{
	int M, N;
    std::cin >> M >> N;
  	for(int i=0; i<N; i++)
    {
      	int A; 
		std::cin >> A;
        M -= A;
        if( M<0 ) { break; }
    }

	std::cout << (0 <= M ? M : -1) << std::endl;
	return 0; 
}

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

int main(void){
    int H=0;
    int W=0;
    int h=0;
    int w=0;
    int num=0;

    cin >> H >> W;
    cin >> h >> w;

    num=H*W-(h*W+w*H-h*w);
    
    cout << num << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
typedef pair<int, int> P;

int main()
{
    int n, m, c;
    cin >> n >> m >> c;
    int b[20];
    for(int i = 0; i < m; i++){
        cin >> b[i];
    }
    int a[20][20];
    for(int i = 0; i < n; i++){
        for(int j = 0; j < m; j++){
            cin >> a[i][j];
        }
    }
    int ans = 0;
    for(int i = 0; i < n; i++){
        int sum = 0;
        for(int j = 0; j < m; j++){
            sum += a[i][j] * b[j];
        }
        sum += c;
        if(sum > 0){
            ans++;
        }
    }
    cout << ans << endl;
}

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

int main(){

  int a, b, c, d;

  cin>>a>>b>>c>>d;

  if(a+b>c+d) cout<<"Left"<<endl;
  else if(a+b<c+d) cout<<"Right"<<endl;
  else cout<<"Balanced"<<endl;

  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn=1e5;
map<ll, int> mymap;
ll sum[2*maxn+5];
int main(){
	int n,a;
	scanf("%d",&n);
	long long ans=0;
	mymap[0]++;
	for(int i=1;i<=n;i++){
		scanf("%d",&a);
		sum[i]=sum[i-1]+a;
		ans+=mymap[sum[i]];
		//cout<<i<<" "<<sum[i]<<" "<<ans<<endl;
		mymap[sum[i]]++;
		
	}
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 14336
import sys

stdin = sys.stdin

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

def main():
  n = ni()
  a = na()

  for i in range(n - 1, 1, -1):
    if a[i] > a[i - 1]:
      continue
    if a[i] < a[i - 1]:
      if a[i] == a[i - 1] - 1:
        a[i - 1] -= 1
        continue
    if a[i] == a[i - 1]:
      continue
    print("No")
    return
  print("Yes")
main()

Measured memory_bytes: 14340
#include <bits/stdc++.h>
using namespace std;
const long long mod = 1e9 + 7;
const long double pi = acos(-1.0); 
typedef long long ll;

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

	char c;
	cin >> c;
	if(65 <= c && c <= 90) {
		cout << "A" << endl;
	}else {
		cout << "a" << endl;
	}
}

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

int main() {
  int N;
  cin >> N;
  
  string S,T;
  
//  cout << "aa" << endl;
 
  cin >> S;
  cin >> T;

//  cout << "bb" << endl;
  string M;
  
//  string X;
  
  for(int i = 0;i < N;i++){
    M = M +S.at(i) + T.at(i);

//  X =S.at(i);
//  X =T.at(i);
    
  }


  
    cout << M << endl;

}





Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <cmath>
#include <ctype.h>
#include <string>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <cstdlib>
#include <map>
#include <queue>
#include <utility>
#include <vector>
#include <set>
#include <list>
#include <cstring>
#include <stack>

using namespace std;

#define mod 1000000007

class RMQ
{
	private:
		vector<long long int> data1;
		vector<long long int> data2;
		int elemnum;

	public:
		RMQ(int n)
		{
			elemnum = 1;
			while(elemnum < n) elemnum *= 2;
			data1 = vector<long long int>(2 * elemnum, 0);
			data2 = vector<long long int>(2 * elemnum, 0);
		}

		int getelemnum()
		{
			return elemnum;
		}

		// [a, b)???x???????????????
		//  k : ??????????????????[l, r)?????????
		void add(int a, int b, int l, int r, int k, long long int x)
		{
			if(a <= l && r <= b){
				data1[k] += x;
			} else if(l < b && a < r){
				data2[k] += x * (min(b, r) - max(a, l));
				add(a, b, l, (l + r) / 2, 2 * k, x);
				add(a, b, (l + r) / 2, r, 2 * k + 1, x);
			}
		}

		long long int getsum(int a, int b, int l, int r, int k)
		{
			if(a <= l && r <= b){
				return data1[k] * (r - l) + data2[k];
			} else if(b <= l || r <= a){
				return 0;
			} else {
				long long int ans = data1[k] * (min(b, r) - max(a, l));
				ans += getsum(a, b, l, (l + r) / 2, 2 * k);
				ans += getsum(a, b, (l + r) / 2, r, 2 * k + 1);
				return ans;
			}
		}

		void print()
		{
			for(int i = 0; i < 2 * elemnum; i++){
				cout << data1[i] << " ";
			}
			cout << endl;
			for(int i = 0; i < 2 * elemnum; i++){
				cout << data2[i] << " ";
			}
			cout << endl;
		}
};

int main()
{
	int n;
	cin >> n;
	RMQ rmq = RMQ(n);
	int q;
	cin >> q;
	n = rmq.getelemnum();
	for(int i = 0; i < q; i++){
		int com, s, t, x;
		cin >> com;
		if(com == 0){
			cin >> s >> t >> x;
			s--;
			t--;
			rmq.add(s, t + 1, 0, n, 1, x);
			// rmq.print();
		} else {
			cin >> s >> t;
			s--;
			t--;
			cout << rmq.getsum(s, t + 1, 0, n, 1) << endl;
		}
	}
}

Measured memory_bytes: 9052
n= int(input())
A = [int(x) for x in input().split()]

ans = 1
ans_over = 0

for x in A:
        ans *= x
        if ans > 10 ** 18:
                ans = 1
                ans_over = 1

if ans_over == 1:
        if ans != 0:
                ans = -1


print(ans)


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

 using namespace std;
 typedef long long ll;

 int main() {
   int N, M;
   cin >> N;
   vector<int> D(N);
   map<int, int> mapD, mapT;
   for (int i = 0; i < N; i++) {
     cin >> D.at(i);
     mapD[D.at(i)]++;
   }

   cin >> M;
   vector<int> T(M);
   for (int i = 0; i < M; i++) {
     cin >> T.at(i);
     mapT[T.at(i)]++;
   }

   string ans = "YES";
   for (auto p : mapT) {
     if (p.second > mapD[p.first]) {
       ans = "NO";
       break;
     }
   }
   cout << ans << endl;
 }


Measured memory_bytes: 20608
// 解説AC
#include <bits/stdc++.h>

using namespace std;
typedef long long ll;

#define MOD (long long)(1e9+7)
#define INF (1LL<<60)
#define rep(i,n) for(ll i = 0; i < (n); i++)
#define rep1(i,n) for(ll i = 1; i <= (n); i++)

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;
}


// 最大公約数
ll gcd(ll a, ll b)
{
  if(b == 0) return a;
  return gcd(b, a % b);
}

// mod m におけるa の逆元
ll modinv(ll a, ll m) {
  ll b = m, u = 1, v = 0;
  while (b) {
    ll t = a / b;
    a -= t * b; swap(a, b);
    u -= t * v; swap(u, v);
  }
  u %= m;
  if (u < 0) u += m;
  return u;
}

// 素因数分解
vector<pair<ll, ll>> prim;
void pf(ll n)
{
  ll s = sqrt(n);
  ll r = 0;
  for(ll i = 2; i <= s; i++) {
    if((n % i) == 0) {
      r = 0;
      do {
	r++;
	n = n / i;
      } while((n % i) == 0);
      prim.push_back({i, r});
    }
  }
  if(n > s) {
    prim.push_back({n, 1});
  }
}

void solve()
{
  ll N; cin >> N;
  ll y, ans = 0;
  rep1(i, N) {
    y = N / i;
    ans += y * (y + 1) * i / 2;
  }
  

  cout << ans << endl;
}


int main(void)
{
  // ll t; cin >> t; rep(i, t)
  solve();
}


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

main(){

  ll n,k;
  string s;
  cin>>n>>k>>s;

  ll cnt=1;
  vector<ll> x;
  rep(i,n-1){
    if(s[i]!=s[i+1]){
      x.push_back(cnt);
      cnt=1;
    }
    else{
      cnt++;
    }
  }
  x.push_back(cnt);
  ll tmp=0;
  for(auto v:x)tmp+=v-1;


  cout<<min(n-1,tmp+2*k)<<endl;


}

Measured memory_bytes: 1528
a,b,c=map(int,input().split())
a,b,c=sorted([a,b,c])

#parity=set(list(map(lambda x: x % 2,[a,b,c])))
parity=list(map(lambda x: x % 2,[a,b,c]))

if len(set(parity))==1:
    print(int((3*max(a,b,c)-a-b-c)/2))
else:
    if (b-a)%2==0:
        ex=1
    else:
        ex=2
    print(int((max(a,b,c)-a)/2)+int((max(a,b,c)-b)/2)+int((max(a,b,c)-c)/2) + ex)
    

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

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

    int wide = abs(a-b) + W;

    if(abs(a-b)<=W){
        cout<<"0"<<endl;
    }else if(a<b){
        cout<<b-a-W<<endl;
    }else if(b<a){
        cout<<a-b-W<<endl;
    }

    return 0;
    }

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

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0),cout.tie();
	ll n;
	cin>>n;
	ll now=100;
	for(ll i=1;;i++){
		now+=now*0.01;
		if(now>=n){
			cout<<i<<endl;
			break;
		}
	}
	return 0;
}

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

typedef long long ll;
 
int main(){
  int n, k;
  cin >> n >> k;
  int num = 1<<n;
  int ans=1000000007;
  for(int i=0; i<num; i++){
    int tmp = 1;
    for(int bit=0; bit<n; bit++){
      if(i & (1<<bit)) tmp *= 2;
      else tmp += k;
    }
    ans = min(ans, tmp);
  }
  cout << ans << endl;
  return 0;
}


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


using namespace std;

void Solution()
{
    int l, w, h;
    
    while (cin>>l>>w>>h, l) //when l or w or h = 0 it shoud be break
    {
        int n;
        
        cin>>n;
        
        while (n--)
        {
            int r;
            
            cin>>r;
            
            r *= 2;
            
            if((r * r > w * w + h * h) || (r * r > l * l + w * w) || (r * r > l * l + h * h))
            {
                cout<<"OK"<<endl;
            }
            else
            {
                cout<<"NA"<<endl;
            }
        }
    }

}

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

Measured memory_bytes: 1152
fun main(arr: Array<String>) {
    val (a,b,m) = readLine()!!.split(" ").map { it.toInt() }
    val fridge = readLine()!!.split(" ").map { it.toInt() }
    val microwave = readLine()!!.split(" ").map { it.toInt() }
    val coupon = (1..m).map { readLine()!!.split(" ").map { it.toInt() } }
    var ans = fridge.min()!! + microwave.min()!!
    for(c in coupon) {
        ans = Math.min(ans, fridge[c[0]-1] + microwave[c[1]-1] - c[2])
    }
    println(ans)
}

Measured memory_bytes: 73028
m=1000000007
n,k=gets.split.map &:to_i

def pmod(b, i, m)
  if i==0 then
    1
  elsif (i%2)==1 then
    b * pmod(b, i-1, m) % m
  else
    h = pmod(b, i/2, m)
    h*h%m
  end
end
    
def inv(a, p)
  pmod(a, p-2, p)
end

$f=Array.new(n+1)
$fi=Array.new(n+1)
$f[0]=1
n.times do|i|
  $f[i+1] = $f[i] * (i+1) % m
end
$fi[n] =inv($f[n],m)
n.times do|i|
  j=n-i
  $fi[j-1] = $fi[j] * j % m
end
def comb(n,k,m)
  $f[n]*$fi[k]%m*$fi[n-k]%m
end
t = 0
mn=[n,k+1].min

mn.times do|i|
  sel=comb(n,i,m)
  rem=n-i
  t+=sel*comb(n-1,i,m)%m
  t %= m
end
puts t


Measured memory_bytes: 4988
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
#define rep(i,n) for(int i=0, i##_len=(int)(n); i<i##_len; i++)
#define reps(i,n) for(int i=1 , i##_len=(int)(n);i<=i##_len;i++)
#define rrep(i,n) for(int i=((int)(n)-1);i>=0;i--)
#define rreps(i,n) for(int i=((int)(n));i>0;i--)
#define repi(i,x) for(auto i=(x).begin(),i##_fin=(x).end();i!=i##_fin;i++)
#define all(x) (x).begin(), (x).end()
#define F first
#define S second
#define mp make_pair
#define pb push_back
#define solve(a) ((a)?"Yes":"No")
typedef vector<int> Vi;
typedef vector<Vi> VVi;
typedef pair<int , int> Pi;
typedef vector<Pi> VPi;
typedef vector<long long> V;
typedef vector<V> VV;
typedef pair<long long , long long> P;
typedef vector<P> VP;
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 long long INFLL = 1LL<<60;
const int INF = 1<<30;
const double PI=acos(-1);
int main(){
	string s;
	int ans=0;
	cin >>s;
	if(s[0]!=s[1] or s[1]!=s[2]){
		ans=1;
	}
	cout<<solve(ans)<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <cmath>
using namespace std;
int main()
{
    int v, totala, n, sum=0;
    cin >> v >> totala;
    int a[totala];
    for(int i=0; i<totala; i++)
    {
        cin >> n;
        sum+=n;
    }
    if(v>=sum)
    {
        cout << (v-sum) << endl;
    }
    else cout << "-1" << endl;

}

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

int main()
{
ll n , m ;
cin >> n >> m ;
string ans="";
rep(i,n)ans+='a';
rep(i,m){
  ll s , c ;
  cin >> s >> c ;
  if(ans[s-1]=='a'||ans[s-1]=='0'+c)ans[s-1]='0'+c;
  else{
    cout << -1 << endl;
    return 0;
  }
}
if(n==1){
  if(ans[0]=='a'){
  ans[0]='0';
  }
  cout << ans << endl;
  return 0;
}
rep(i,n){
  if(i==0&&ans[i]=='0'){
    cout << -1 << endl;
    return 0;
  }
  if(i==0&&ans[i]=='a'){
    ans[i]='1';
  }
  if(i!=0&&ans[i]=='a'){
    ans[i]='0';
  }
}
cout << ans << endl;
return 0;
}

Measured memory_bytes: 256