akhauriyash/Code-Regression huggingface dataset:
#include<iostream>

// 配列要素を順に出力
void trace(int A[], int N){
    int i;
    for (i=0;i<N;i++){
        if(i>0){
            printf(" "); /*隣接する要素の間に１つの空白を出力*/
        }
        printf("%d", A[i]);
    }
    printf("\n");
}

// 挿入ソート0オリジン
void insertionSort(int A[], int N){
    int j, i, v;
    for(i=1; i<N; i++){
        v = A[i];
        j=i-1;
        while(j>=0 && A[j]>v){
            A[j+1]=A[j];
            j--;
        }
        A[j+1]=v;
        trace(A, N);
    }
}

int main(){
    int N, i, j;
    int A[100];

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

    trace(A, N);
    insertionSort(A, N);

    return 0;
}


Measured memory_bytes: 3216
#include<iostream>
#define ll long long
#define mod 1000000007
using namespace std;

int main()
{
    ll n;
    cin >> n;
    ll a[n];
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }
    ll one, zero;
    ll ans = 0, r;

    for (int i = 0; i < 60; i++) {
        one = zero = 0;
        for (int j = 0; j < n; j++) {
            if (a[j] & (1LL<<i)) one++;
            else zero++;
        }
        //cout << (1LL<<i) << "\n";
        //cout << "One = " << one << "\n";
        //cout << "Zero = " << zero << "\n";
        r = (1LL << i)%mod;
        r *= (one * zero)%mod;
        ans = (ans + r)%mod;
        //cout << "r = " << r << "\n";
    }

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


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

int main() {
    int n,m;
    cin >> n >> m;
    cout << n*(n-1)/2 + m*(m-1)/2;
}

Measured memory_bytes: 3604
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <ctime>
#include <cstring>
#include <functional>
#include <iostream>
#include <iomanip>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <regex>
#include <vector>

#define fix(n)          cout<<fixed<<setprecision(n)
#define rep(i,n)        for (int i = 0; i < (n); ++i)
#define sort(a)         sort((a).begin(), (a).end())
#define uniq(a)         sort(a);(a).erase(unique((a).begin(), (a).end()), (a).end())
#define reverse(a)      reverse((a).begin(), (a).end())
#define ctos(c)         string(1, (c))
#define out(d)          cout << (d)
#define outl(d)         std::cout<<(d)<<"\n"
#define YES()           cout << "YES" << endl
#define NO()            cout << "NO" << endl
#define Yes()           cout << "Yes" << endl
#define No()            cout << "No" << endl
#define ceil(x, y)      ((x + y - 1) / (y))
#define debug(x)        cerr << #x << ": " << (x) << '\n'
#define debug2(x, y)    cerr << #x << ": " << (x) << ", " << #y << ": " << (y) << '\n'
#define debug3(x, y, z) cerr << #x << ": " << (x) << ", " << #y << ": " << (y) << ", " << #z << ": " << (z) << '\n'
#define dbg(v)          for (size_t _ = 0; _ < v.size(); ++_){ cerr << #v << "[" << _ << "] : " << v[_] << '\n'; }

using namespace std;
using ll = long long;
using ld = long double;
using P = pair<ll,ll>;

const ll MOD = 1000000007; // 10^9 + 7
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};

void solve() {
  int n; cin >> n;
  int color[9] = {};
  int lims[9] = {400, 800, 1200, 1600, 2000, 2400, 2800, 3200, __INT_MAX__};
  rep(i, n) {
    int a; cin >> a;
    for (int j = 0; j < 9; j++) {
      if (a < lims[j]) {
        color[j]++;
        break;
      }
    }
  }

  int minCnt = 0;
  for (int i = 0; i < 8; i++) {
    // debug2(i, color[i]);
    if (color[i] > 0) minCnt++;
  }
  cout << max(minCnt, 1) << " " << minCnt + color[8] << endl;
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  srand((unsigned)time(NULL));
  fix(12);

  solve();
}


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

signed main() {
    //printf("Hello, World!");
    int n,m;
    vector<int> M;
    cin>>n>>m;
    int t;
    int sum=0;
    for(int i=0;i<m;i++)
    {
        cin>>t;
        sum = sum +t;
    }
    if(n-sum<0)
    cout<<-1;
    else
    cout<<(n-sum);
    return 0;
}

Measured memory_bytes: 3632
#include <cstdio>
#include <cmath>
#include <cstring>
#include <algorithm>
using namespace std;

long long x, y;
int main()
{
	int ans = 1;
	scanf("%lld %lld", &x, &y);
	while(true)
	{
		x *= 2;
		if(x <= y) ans++;
		else break;
	}
	printf("%d\n", ans);
}

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

#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, n, m) for(int (i) = (n); (i) < (m); ++(i))

constexpr int INF = 1e9;
//constexpr ll INF = 1LL<<61;
constexpr ll mod = 1e9+7;

int main(){
  int N;
  cin >> N;
  vector<ll> A(N);
  vector<ll> sum(N+1, 0);
  REP(i, N){
    cin >> A[i];
    sum[i+1] = sum[i] + A[i];
  }
  ll ans = 0;
  REP(i, N){
    ll add = (A[i] * ((sum[N] - sum[i+1])%mod)) % mod;
    ans += add;
    ans %= mod;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 6424
import std.stdio;
import std.string;
import std.conv;
import std.typecons;
import std.algorithm;
import std.functional;
import std.bigint;
import std.numeric;
import std.array;
import std.math;
import std.range;
import std.container;
import std.ascii;

void main(){
	auto n = readln.chomp.to!int;
	auto a = readln.chomp.to!int;
	((n % 500) <= a ? "Yes" : "No").writeln;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define For(i,x,y) for (register int i=(x);i<=(y);i++)
#define FOR(i,x,y) for (register int i=(x);i<(y);i++)
#define Dow(i,x,y) for (register int i=(x);i>=(y);i--)
#define Debug(v) for (auto i:v) printf("%lld ",i);puts("")
#define mp make_pair
#define fi first
#define se second
#define pb push_back
#define ep emplace_back
#define siz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
#define fil(a,b) memset((a),(b),sizeof(a))
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pa;
typedef pair<ll,ll> PA;
typedef vector<int> poly;
inline ll read(){
    ll x=0,f=1;char c=getchar();
    while ((c<'0'||c>'9')&&(c!='-')) c=getchar();
    if (c=='-') f=-1,c=getchar();
    while (c>='0'&&c<='9') x=x*10+c-'0',c=getchar();
    return x*f;
}

const int N = 1e5+10;
int n,w,h;
struct node{
	int x,y,z;
}a[N];

int fa[N<<1],flag[N<<1];
inline int Find(int x){
	return fa[x]==x?x:fa[x]=Find(fa[x]);
}
inline bool check(int x,int y){
	int a=Find(x),b=Find(y+w);
	if (a!=b){
		int ret=1;
		if (flag[a]&&flag[b]) ret=0;
		fa[a]=b,flag[b]|=flag[a];
		return ret;
	} else if (flag[a]) return 0;
	else return flag[a]=1;
}

int main(){
	n=read(),w=read(),h=read();
	For(i,1,w+h) fa[i]=i;
	For(i,1,n) a[i]=(node){read(),read(),read()};
	sort(a+1,a+1+n,[](node a,node b){
		return a.z>b.z;
	});
	ll ans=0;
	For(i,1,n) if (check(a[i].x,a[i].y)){
		ans+=a[i].z;
	}
	printf("%lld\n",ans);
}

Measured memory_bytes: 6492
#include"bits/stdc++.h"
using namespace std;

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep3(i,m,n) for(int (i)=m;(i)<=(n);(i)++)
#define rep3rev(i,m,n) for(int (i)=m;(i)>=(n);(i)--)
#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define pb push_back
#define eb emplace_back

using ll = long long;
using vll = vector<ll>;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using P = pair<int, int>;

void Main(){
    int n, m; cin >> n >> m;
    bool rev = false;
    if(n <= m) {
        swap(n, m);
        rev = true;
    }
    
    int N = 1 << n;
    int M = 1 << m;
    vvi sum(N, vi(N, 0)), sum_i(N, vi(N, 0)), ans(N, vi(N, 0));
    
    rep(i, N){
        rep(j, N){
            sum[i][j] = __builtin_popcount(i & j) % 2; 
        }
    }

    rep3(i, 1, N-1){
        rep(j, N){
            sum_i[i][j] = (sum[i][j] + sum[i-1][j]) % 2;
        }
    }

    rep(i, N){
        rep3(j, 1, N-1){
            ans[i][j] = (sum_i[i][j] + sum_i[i][j-1]) % 2;
        }
    }
    
    /*
    rep(i, N){
        rep(j, M){
            cout << sum[i][j] << " ";
        }
        cout << endl;
    }
    cout << endl;
    
    rep(i, N){
        rep(j, M){
            cout << sum_i[i][j] << " ";
        }
        cout << endl;
    }
    cout << endl;
    */
    
    if(rev) swap(N, M);
    
    rep3(i, 1, N-1){
        rep3(j, 1, M-1){
            cout << ans[i][j];
        }
        cout << endl;
    }
    return;
}

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

Measured memory_bytes: 15472
#include <stdio.h>

int abs(int n)
{
    if(n>=0) return n;
    else return -n;
}

int main()
{
    int a,b;
    scanf("%d %d",&a,&b);
    if(abs(a-b)%2) 
    {
        printf("IMPOSSIBLE\n");
        return 0;
    }
    int x=abs(a-b)/2;
    if(a>b) printf("%d\n",a-x);
    else printf("%d\n",b-x);
}

Measured memory_bytes: 128
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;

namespace AtCoder.D
{
    public class Program
    {
        public static void Main() { var r = GetResult(); Debug.WriteLine(r); Console.Write(r); }

        private static object GetResult()
        {
            var S = ReadText().ToCharArray();
            var length = S.Length;
            if(length == 2)
            {
                if(S[0] == S[1])
                {
                    return "1 2";
                }
            }
            for (var i = 0; i <= length - 3; i++)
            {
                if (S[i] == S[i + 1] || S[i] == S[i + 2] || S[i + 1] == S[i + 2])
                {
                    return $"{i + 1} {i + 3}";
                }

            }
            return "-1 -1";
        }
        #region Console.Read

        public static string ReadText() { return Console.ReadLine(); }
        public static List<string> ReadTexts() { return Console.ReadLine().Split(' ').ToList(); }
        public static long ReadLong() { return long.Parse(Console.ReadLine()); }
        public static (long, long) Read2Longs() { var ls = ReadLongs(); return (ls[0], ls[1]); }
        public static (long, long, long) Read3Longs() { var ls = ReadLongs(); return (ls[0], ls[1], ls[2]); }
        public static (long, long, long, long) Read4Longs() { var ls = ReadLongs(); return (ls[0], ls[1], ls[2], ls[3]); }
        public static (long, long, long, long, long) Read5Longs() { var ls = ReadLongs(); return (ls[0], ls[1], ls[2], ls[3], ls[4]); }
        public static List<long> ReadLongs() { return Console.ReadLine().Split(' ').Select(x => long.Parse(x)).ToList(); }

        #endregion
    }
}


Measured memory_bytes: 26444
// Link: https://atcoder.jp/contests/abc147/tasks/abc147_a

#include <iostream>

using namespace std;

int main() {
    // DECLARATION
    int a1, a2, a3;

    // INPUT
    cin>>a1>>a2>>a3;

    if (a1 + a2 + a3 >= 22) {
        cout<<"bust"<<endl;
    } else {
        cout<<"win"<<endl;
    }

    return 0;
}

Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Scanner;
import java.util.function.Consumer;
import java.util.stream.Collectors;

public class Main {
    private static final Scanner scanner = new Scanner(System.in);
    private static final Consumer<List<String>> consumer = solve();

    public static void main(String[] args) {
        consumer.accept(readInput());
    }

    private static List<String> readInput() {
        final List<String> lineList = new ArrayList<>();
        while (scanner.hasNextLine()) {
            lineList.add(scanner.nextLine());
        }
        return lineList;
    }

    private static Consumer<List<String>> solve() {
        return args -> {
            List<Integer> numList = Arrays.stream(args.get(0).split(" ")).map(Integer::valueOf).sorted().collect(Collectors.toList());
            System.out.println(numList.get(0) + numList.get(1));
        };
    }

}


Measured memory_bytes: 27860
#include<bits/stdc++.h>
#include<unordered_map>
#include<algorithm>

/*
*▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀
*    ▀▀       ▀▀▀▀▀▀    ▀     ▀▀▀▀▀▀      ▀    ▀
*   ▀  ▀      ▀         ▀     ▀            ▀  ▀
*  ▀    ▀     ▀ ▀ ▀     ▀     ▀ ▀ ▀         ▀
* ▀ ▀▀▀▀ ▀    ▀         ▀     ▀             ▀
*▀        ▀   ▀         ▀     ▀             ▀
*▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀
*/
using namespace std;
void afify()
{
	ios::sync_with_stdio(0);
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
}
//===============================================
#define ll long long
#define ld long double
#define mk make_pair
#define loop(i,intial,n)  for(int i=(intial);i<n;i++)
#define loopn(j,n,ends) for(int j=int(n-1);j>=ends;j--)
#define loopm(name)  for(auto it : name)
#define loopm2(name)  for(auto it2 : name)
#define min3(a,b,c) min(a,min(b,c))
#define max3(a,b,c) max(a,max(b,c))
#define all(v) v.begin(),v.end()
#define PI (ld)(3.14159265358979323846)
//===============================================
#define SF(a) scanf("%d",&a)
#define SF2(a,b) scanf("%d %d",&a,&b)
#define SFLL(a) scanf("%lld",&a)
#define SFLL2(a,b) scanf("%lld %lld",&a,&b)
#define PF(a) printf("%d\n",a)
#define PFLL(a) printf("%lld\n",a)
//===============================================
typedef vector <int> vi;
typedef vector <ll> vll;
typedef vector <ld> vld;
typedef vector <vi> vvi;
typedef vector <vll> vvll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<pii> vpii;
typedef vector<pll> vpll;
typedef vector<vpll> vvpll;
typedef vector<vpii> vvpii;
typedef stringstream ss;
const double EPS = 1e-4;
const ll oo = (ll) 10e7 + 7;
const ll N = 1000018; 
const ll mod = 1073741824;
int dx[] = { -1, 0, 0, 1 };
int dy[] = { 0, -1, 1, 0 }; // 4 Direction*/
//int dx[]={1,1,0,-1,-1,-1,0,1};
//int dy[]={0,1,1,1,0,-1,-1,-1};//8 direction*/
//freopen("largest.in", "r", stdin);
//freopen("output.txt", "w", stdout);
//ifstream ifs("input.txt");
//ofstream ofs("output.txt");

int main()
{
	afify();
	string s;
	cin >> s;
	cout << s[0] << s.length() - 2 << s.back() << endl;


	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void) {
	int A,B;
	scanf("%d%d",&A,&B);
	if(A==1){
		if(B==1){
			printf("Draw");
		}
		else{
			printf("Alice");
		}
	}
	else if(B==1){
		if(A==1){
			printf("Draw");
		}
		else{
			printf("Bob");
		}
	}
	else if(A>B){
		printf("Alice");
	}
	else if(B>A){
		printf("Bob");
	}
	else{
		printf("Draw");
	}
	return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <utility>
#include <cstdlib>
#include <queue>
#include <map>
#include <stack>
#include <set>
#include <sstream>
#include <bitset>
#define ll long long
using namespace std;


int main(){
  //cout<<1<<endl;
  ll ans=0;
  ll N,K;
  cin>>N>>K;
  vector <ll> opt(0);
  ll base=N/K;
  ll remain = N%K;
  for(ll i=0;i<K;i++){
 
    if(i<=remain and i!=0) opt.push_back(base+1);
    else opt.push_back(base);
    
  }
 
  for(ll a=0;a<=K-1 and a<=N;a++){
    ll b,c;
    b=K-a;
    c=-b+3*K;
    b=b%K;c=c%K;
    if(b>N or (a+c)%K!=0 or c>N or a>N) continue;
    ans+=opt[a]*opt[b]*opt[c];
    //cout<<a<<" "<<b<<" "<<c<<endl;
  }
  cout<<ans<<endl;
  return 0;
}



Measured memory_bytes: 2420
#include <stdio.h>
int main(void)
{
    int N;
    float ans;
    
    scanf("%d",&N);
    
    if(N%2 == 0)
    {
        ans = 0.5;
    }
    else
    {
        ans = ((float)N+1)/(2*N);
    }
    
    printf("%f",ans);
}


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

#define fi                      first
#define se                      second
#define pb                      push_back
#define endl                    '\n'
#define all(x)                  x.begin(),x.end()
#define pii                     pair<int,int>
#define pll                     pair< long long int, long long int> 
#define fast                    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define SZ(x)                   ((int)x.size())

#define FOR(i,a,b)              for(int i = a; i < b; ++i)
#define REV(i,a,b)              for(int i = a; i >= b; --i)
#define FORE(i,a,b)             for(int i = a; i <= b; ++i)

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;

void solve();

int32_t main()
{
        fast;
        int t = 1;
        // cin >> t;
        for(int i = 1; i <= t; ++i)
                solve();
        cerr << "Time taken: " << ((clock() * 1000) / CLOCKS_PER_SEC) << "ms\n";
}

const int N = 500+2;
ll d[N][N];

int n;
void FloydWarshall() {
        FOR(k,1,n) { // minimum distance between node using first k nodes only
                FOR(i,1,n) {
                        FOR(j,1,n) {
                                d[i][j] = min(d[i][j],d[i][k]+d[k][j]);
                        }
                }
        }
}

void solve() {
        FOR(i,0,N) {
                FOR(j,0,N) {
                        d[i][j] = 1e6;
                }
        }
        int h,w;
        cin >> h >> w;
        char arr[h+1][w+1];
        FOR(i,1,h+1) {
                FOR(j,1,w+1) {
                        cin >> arr[i][j];
                }
        }
        FOR(i,1,h+1) {
                FOR(j,1,w+1) {
                        if(i-1 > 0 and arr[i][j] == arr[i-1][j] and arr[i][j] == '.') {
                                int a = (i-2)*w + j;
                                int b = (i-1)*w + j;
                                // cout << a << " " << b << endl;
                                d[a][b] = 1;
                                d[b][a] = 1;
                        }      
                        if(j-1 > 0 and arr[i][j] == arr[i][j-1] and arr[i][j] == '.') {
                                int a = (i-1)*w + j-1;
                                int b = (i-1)*w + j;
                                // cout << a << " " << b << endl;
                                d[a][b] = 1;
                                d[b][a] = 1;
                        }           
                }
        }
        n = h*w+1;
        FloydWarshall();
        ll out = -1;
        FOR(i,1,n) {
                FOR(j,1,n) {
                        // cout << i << " " << j <<  " " << d[i][j] << endl;
                        if(d[i][j] == (ll)(1e6) or i == j)
                                continue;
                        out = max(out,d[i][j]);
                }
        }
        cout << out << endl;
}

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

int main() {
  int N;
  cin >> N;
  vector<int> vec(N);
  vector<double> divVec(N);
  double sum = 0.0;
  double answer = 0.0;


  for(int i=0;i<N;i++){
    cin >> vec[i];
    divVec[i] = 1.0/vec[i];
    sum += divVec[i];
  }

  answer = 1.0/sum;

  cout << fixed << answer << endl;
}


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

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

  // ここにプログラムを追記
  for (int i = 0; i < N; i++) {
    int l, r;
    cin >> l >> r;
    
    x += r - l + 1;
  }
  cout << x << endl;
}



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 int ll

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

  int N;
  cin>>N;
  vector<vector<int>>x(N,vector<int>(N,2));
  for(int i=0;i<N;i++){
    int A;
    cin>>A;
    vector<int>xx(A),yy(A);
    for(int j=0;j<A;j++)cin>>xx[j]>>yy[j];
    for(int j=0;j<A;j++)x[i][xx[j]-1]=yy[j];
  }
  int n=pow(2,N);
  int ans=0;
  /*
  for(int i=0;i<N;i++){
    for(int j=0;j<N;j++){
      cout<<x[i][j];
    }
    cout<<endl;
  }
  */
  for(int bit=0;bit<n;bit++){
    bool ok=true;
    for(int i=0;i<N;i++){
      if((bit>>i)&1){
        for(int j=0;j<N;j++){
          if(j==i)continue;
          if(x[i][j]==1){
            if((bit>>j)&1){}
            else ok=false;
          }
          else if(x[i][j]==0){
            if((bit>>j)&1)ok=false;
          }
        }
      }
    }
    if(ok)ans=max(ans,(ll)__builtin_popcount(bit));
  }
  cout<<ans<<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 ll long long
#define ld long double
typedef vector <ll> vi;                 // Vector of long long
typedef vector <vi> vvi;                // Vector of vi
typedef vector <pair<ll,ll>> ii;        // Vector of pairs
#define ff first                        // For pairs
#define ss second                       // For pairs
#define sz(a) int((a).size())           // Function to determine size of any container
#define pb push_back                    // Pushback to vector
#define mp make_pair                    // Makes pairs to be stored as pair
#define all(c) (c).begin(), (c).end()   // Mainly used by me in sorting
// ordered_set adds two new functions to set - (set).find_by_order([kth element based on zero indexing]) and order_of_key()
// order_of_key returns number of elements less that parameter. If element exists, that order is its index
#define ordered_set tree < ll ,  null_type ,  less<ll> ,  rb_tree_tag ,  tree_order_statistics_node_update >
#define MOD (ll)(1e9 + 7)

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

    ll r, c;
    cin >> r >> c;

    ll dp[r][c];
    memset(dp, -1, sizeof(dp));
    dp[0][0] = 1;

    char x;
    for (int i = 0; i < r; i++)
    {
        for (int j = 0; j < c; j++)
        {
            cin >> x;
            if (x == '#')
                dp[i][j] = 0;
        }
    }

    for (int i = 0; i < r; i++)
    {
        for (int j = 0; j < c; j++)
        {
            if (dp[i][j] == -1)
            {
                ll ans = 0;
                if (i > 0)
                    ans = (ans + dp[i - 1][j]) % MOD;
                if (j > 0)
                    ans = (ans + dp[i][j - 1]) % MOD;
                dp[i][j] = ans;
            }
        }
    }

    cout << dp[r - 1][c - 1] << "\n";
}


Measured memory_bytes: 8064
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Numerics;
using System.Text;
using System.Threading;
using System.Threading.Tasks;

namespace ConsoleApp2
{
    class Program
    {
        static void Main(string[] args)
        {
            var NK = Console.ReadLine().Split(' ').Select(s=>long.Parse(s)).ToArray();
            var N = NK[0];
            var K = NK[1];
            Console.WriteLine(Math.Min(N,Math.Min(Math.Abs((N%K)-K), (N % K))));
        }
    }
}

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

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

  int maxi = 1,ans=1;
  for (int i = 1; i < x; i++)
  {
    for (int j = 2; j < x; j++)
    {
      if(pow(i,j)<=x){
          maxi = pow(i,j);
      }
      else break;
    }
    ans = max(maxi,ans);
  }
  cout << ans << endl;
  
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main()
{
    int n;
    int num;
    int i;
    int mult4,mult2;
    while (cin>>n)
    {
        mult4=mult2=0;
        for (i=0;i<n;i++)
        {
            cin>>num;
            if (num%4==0)
                mult4++;
            else if (num%2==0)
                mult2++;
        }
        if (mult2)
            n-=mult2-1;
        if(mult4>=n/2)
            cout<<"Yes\n";
        else
            cout<<"No\n";
    }
    return 0;
}

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

using namespace std;

int main()
{
    string S,T;
    cin >>S>>T;
    int i=0;
    if (S.at(0)==T.at(0))
        i=i+1;
    if (S.at(1)==T.at(1))
        i=i+1;

    if (S.at(2)==T.at(2))
        i=i+1;



        cout << i;


    return 0;
}



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

int main()
{
    int t;
    vector<int> v;
    cin >> t;

    while(t--){
        int n;
        cin >> n;
        v.push_back(n);
    }
    sort(v.begin(), v.end());

    for(unsigned int i=1; i<v.size(); i++){
        if(v[i] == v[i-1]){
            v[i] = 0;
            v[i-1] = 0;
        }
    }

    int ans = 0;
    for(unsigned int i=0; i<v.size(); i++){
        if(v[i]) ans++;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3928
s=list(input())
ls=len(s)
t=list(input())
lt=len(t)
can=[]
for i in range(ls-lt,-1,-1):
    ok=0
    for j in range(lt):
        if s[i+j]==t[j] or s[i+j]=='?':
            ok+=1
    if ok==lt:
        c=[0]*ls
        for k in range(ls):
            if s[k]=='?':
                if k<i or k>=i+lt:
                    c[k]='a'
                else:
                    c[k]=t[k-i]
            else:
                c[k]=s[k]
        can.append(''.join(c))
if len(can)==0:
    print('UNRESTORABLE')
else:
    print(sorted(list(can))[0])

Measured memory_bytes: 8980
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll a[505][505];
bool chk[23333333];
ll gcd(ll x,ll y){return y?gcd(y,x%y):x;}
ll lcm(ll x,ll y){return x/gcd(x,y)*y;}
int nxtPrime(int&x){
    auto chk=[&](int x){
        if(x<2)return false;
        for(int i=2;i*i<=x;i++)
            if(x%i==0)
                return false;
        return true;
    };
    do x++;while(!chk(x));
    ::chk[x]=true;
    return x;
}
void CCC(int n){
    map<int,pair<int,int>>s;
    for(int i=1;i<=n;i++)
        for(int j=1;j<=n;j++){
            if(s.count(a[i][j])){
                cout<<s[a[i][j]].first<<" "<<s[a[i][j]].second<<" "<<i<<" "<<j<<"\n";
                break;
            }
            s[a[i][j]]=make_pair(i,j);
        }
}
void solve(int n){
    int p=0;
    for(int i=1,j=n-(~n&1);i<=n;i++,j--)
        if(!a[i][j]&&1<=j&&j<=n)
            a[i][j]=nxtPrime(p);
    for(int i=n,j=n;i>=1;i--,j--)
        if(!a[i][j])
            a[i][j]=nxtPrime(p);
    for(int i=1;i<=n;i++)
        for(int j=1;j<=n;j++)
            if((i+j)%2==0){
                if(a[i][j])continue;
                auto get=[&](int dx,int dy)->ll{
                    int x=i,y=j;
                    while(1<=x&&x<=n&&1<=y&&y<=n){
                        if(chk[a[x][y]])return a[x][y];
                        x+=dx,y+=dy;
                    }
                    return 1;
                };
                a[i][j]=get(+1,+1)*get(+1,-1)*get(-1,+1)*get(-1,-1);
            }
    for(int i=1;i<=n;i++)
        for(int j=1;j<=n;j++)
            if((i+j)%2==1){
                auto upd=[&](int dx,int dy){
                    if(a[i+dx][j+dy])
                        a[i][j]=lcm(a[i][j],a[i+dx][j+dy]);
                };
                a[i][j]=1;
                upd(+1,0);
                upd(-1,0);
                upd(0,+1);
                upd(0,-1);
                a[i][j]++;
            }
}
int main(){
    solve(500);
    int n;cin>>n;
    for(int i=1;i<=n;i++)
        for(int j=1;j<=n;j++)
            cout<<a[i][j]<<" \n"[j==n];
    return 0;
}

Measured memory_bytes: 5376
import math

N = int(input())
n = 0
m = 0
res =0 
List1 = ["INF"]*(N+1)
for i in range(1,N+1):
  for j in range(1,N+1):
    n = math.gcd(i,j)
    if List1[n] == "INF":
      for k in range(1,N+1):
        m += math.gcd(n,k)
      res += m
      List1[n] = m
      m = 0
    else:
      res += List1[n]
print(res)

Measured memory_bytes: 9208
N, *A = map(int, open(0).read().split())

dp = [[0] * (N + 1) for _ in range(N + 1)]
for d in range(1, N + 1):
    for l in range(N - d + 1):
        r = l + d
        if (N - d) % 2 == 0:
            dp[l][r] = max(
                A[l] + dp[l + 1][r],
                A[r - 1] + dp[l][r - 1]
            )
        else:
            dp[l][r] = min(
                - A[l] + dp[l + 1][r],
                - A[r - 1] + dp[l][r - 1]
            )

print(dp[0][N])

Measured memory_bytes: 113244
#include "bits/stdc++.h"
using namespace std;
using ll = long long; using pii = pair<int, int>;
const int MOD = (int)1e9 + 7, INF = (1 << 27); const ll INFLL = (1LL << 55);
#define FOR(i,a,b) for(int (i)=(a);(i)<(int)(b);(i)++)
#define rep(i,n) FOR(i,0,n)
template<typename T, typename U> inline void chmax(T &x, U y) { if (x < y) x = y; }
template<typename T, typename U> inline void chmin(T &x, U y) { if (x > y) x = y; }

using P = pair<ll, ll>;

int main() {
	int n;
	cin >> n;
	vector<P> ps;
	
	vector<ll> as, bs;
	rep(i, n) {
		ll a, b;
		scanf("%lld%lld", &a, &b);
		ps.emplace_back(a + b, i);
		as.emplace_back(a);
		bs.emplace_back(b);
	}

	sort(ps.rbegin(), ps.rend());
	ll ans = 0;
	rep(i, n) {
		if (~i & 1)
			ans += as[ps[i].second];
		else
			ans -= bs[ps[i].second];
	}
	cout << ans << endl;
}

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

using namespace std;

const int mod = (1e9) + 7;


int h, w, a[81][81], b[100][100], x;


bitset<4 * 80 * 80>dp[81][81];

int main()
{
  cin >>h >> w;
  for (int i = 1; i <= h; i++)
    for (int j = 1; j <= w; j++)
      cin >> a[i][j];
  for (int i = 1; i <= h; i++)
    for (int j = 1; j <= w; j++) {
      cin >> x;
      a[i][j] -= x;
      a[i][j] = abs(a[i][j]);
    }
  dp[1][1][80 * 80 * 2] = 1;
  for (int i = 1; i <= h; i++)
    for (int j = 1; j <= w; j++) {
      dp[i][j] = (dp[i][j] << a[i][j]) | (dp[i][j] >> a[i][j]);
      if (i < h)
        dp[i + 1][j] |= dp[i][j];
      if (j < w)
        dp[i][j + 1] |= dp[i][j];
    }
  for (int i = 0; ; i++)
    if (dp[h][w][2 * 80 * 80 - i] || dp[h][w][2 * 80 * 80 + i]) {
      cout << i;
      return 0;
    }
  return 0;
}


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

int a, b; string S;

int main() {
	cin >> a >> b;
	S += to_string(a);
	S += to_string(b);
	int G = stoi(S);
	for (int i = 0; i*i <= G; i++) {
		if (i*i == G) {
			cout << "Yes" << endl;
			return 0;
		}
	}
	cout << "No" << endl;
	return 0;
}

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

int main() {
  int N = 0, K = 0;
  int count = 1;
  
  cin >> N >> K;
  
  int x = K;

  while (N >= x) {
    x = x * K;
    count++;
  }
  cout << count << endl;
}


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

#define fRead(x)        freopen(x,"r",stdin)
#define fWrite(x)       freopen (x,"w",stdout)

#define LL              long long
#define ULL             unsigned long long
#define ff              first
#define ss              second
#define pb              push_back
#define INF             2e16
#define PI              acos(-1.0)
#define mk              make_pair
#define pii             pair<int,int>
#define pll             pair<LL,LL>


#define min3(a,b,c)     min(a,min(b,c))
#define max3(a,b,c)     max(a,max(b,c))
#define min4(a,b,c,d)   min(a,min(b,min(c,d)))
#define max4(a,b,c,d)   max(a,max(b,max(c,d)))
#define SQR(a)          ((a)*(a))
#define FOR(i,a,b)      for(int i=a;i<=b;i++)
#define ROF(i,a,b)      for(int i=a;i>=b;i--)
#define REP(i,b)        for(int i=0;i<b;i++)
#define MEM(a,x)        memset(a,x,sizeof(a))
#define ABS(x)          ((x)<0?-(x):(x))

#define SORT(v)         sort(v.begin(),v.end())
#define REV(v)          reverse(v.begin(),v.end())


#define FastRead        ios_base::sync_with_stdio(0);cin.tie(nullptr);

const int N=2;
const LL MOD = 1e9 + 7;





int main()
{
  FastRead;
 LL a,b,c;
 cin>>a>>b>>c;
 LL d=(c-a-b);


 if(d>0 && d*d> (4*a*b))
 cout<<"Yes"<<"\n";

 else
 cout<<"No"<<"\n";













   return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
int main(){
    int n,i; 
    cin >> n;
    int a[n+2]; 
    a[0] = 0; a[n+1] = 0;
    for(i=0;i<n;i++) cin >> a[i+1];
    int cost0 = 0;
    for(i=0;i<n+1;i++){
        cost0 += abs(a[i+1]-a[i]);
    }
    for(i=0;i<n;i++){
        cout << cost0 - abs(a[i+1]-a[i]) - abs(a[i+2]-a[i+1]) + abs(a[i+2]-a[i]) << endl;
    }
    return 0;
}

Measured memory_bytes: 1664
import math
import queue
import bisect
import heapq
import time
import itertools

mod = 1e9+7
global a,n,xy,ans

def swap(a,b):
    return (b,a)

def gcd(a,b): #最大公約数
    if (a<b):
        a,b = swap(a,b)
    if (b==0):
        return a
    else:
        return gcd(b,a%b)

def divisors(a): # 約数列挙
    divisors = []
    for i in range(1,int(a**0.5)+1):
        if a%i==0:
            divisors.append(i)
            if i!=a//i:
                divisors.append(a//i)
    return divisors

def is_prime(a): #素数判定
    if a<2:
        return False
    elif a==2:
        return True
    elif a%2==0:
        return False
    sqrt_num = int(a**0.5)
    for i in range(3,sqrt_num+1,2):
        if a%i==0:
            return False
    return True

def prime_num(a): #素数列挙
    pn = [2]
    for i in range(3,int(a**0.5),2):
        prime = True
        for j in pn:
            if i%j==0:
                prime = False
                break
        if prime:
            pn.append(i)
    return pn


def func():
    global a,n,xy,ans
    count = 0
    for i in range(n):
        for j in xy[i]:
            if a[i]:
                if a[j[0]]!=j[1]:
                    return
        if a[i]:
            count += 1
    ans = max(ans,count)

def dfs(pos):
    global n
    if pos==n:
        func()
        return
    a[pos] = 0
    dfs(pos+1)
    a[pos] = 1
    dfs(pos+1)

def main():
    global a,n,xy,ans
    n = int(input())
    xy = []
    for i in range(n):
        a = int(input())
        xy.append([])
        for j in range(a):
            x,y = map(int,input().split())
            xy[i].append([x-1,y])
    a = [0 for i in range(n)]
    ans = 0
    dfs(0)
    print(ans)
    return

if __name__=='__main__':
    main()


Measured memory_bytes: 46804
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<math.h>
#include<queue>
#include<deque>
#include<stack>
#include<cstdio>
#include<utility>
#include<set>
#include<list>
#include<cmath>
#include<stdio.h>
#include<string.h>
#include<cstdio>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using piii = pair<pii, pii>;
const int INF = 1e9 + 7;
int main() {
	int N;
	int a[100010][3];
	cin >> N;
	int dp[100010][3] = {};
	for (int i = 0; i < N; ++i) {
		for (int j = 0; j < 3; ++j) {
			cin >> a[i][j];
		}
	}
	for (int i = 0; i < N; ++i) {
		for (int j = 0; j < 3; ++j) {
			for (int k = 0; k < 3; ++k) {
				if (j != k) {
					dp[i+1][j] = max(dp[i][k] + a[i][j], dp[i+1][j]);
				}
			}
		}
	}
	int ans = 0;
	for (int i = 0; i < 3; ++i) {
		ans = max(ans, dp[N][i]);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 2560
#include<bits/stdc++.h>
using namespace std;
long long int n,f[10000005],cnt,ans,s;
int main(){
	int i,j,k;
	cin>>n;
	for(i=1;i<=n;i++){
		for(j=i;j<=n;j+=i){
			f[j]++;
		}
	}
	for(i=1;i<=n;i++)ans+=i*f[i];
	cout<<ans;
}

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

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

  int64_t x;
  x = min(a, min(b, min(c, min(d, e))));

  int64_t tmp;
  if (n > x) {
    if (n % x == 0) {
      tmp = n / x - 1;
    }
    else {
      tmp = n / x;
    }
  }

  int64_t ans = 5 + tmp;

  cout << ans << endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cassert>
#include <climits>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
using namespace std;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int N;
  cin >> N;
  vector<int> as;
  for (int i = 0; i < N; ++i) {
    int tmp;
    cin >> tmp;
    as.push_back(tmp);
  }

  int f = 0;
  for (auto &e : as) {
    f += e - 1;
  }
  cout << f << endl;
  return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>

#define N 117
#define NIL -1
#define INF 100000000
#define BLACK 4
#define WHITE 0



void minimumST (void);

int Tree[N][N];


int d[N],pi[N],color[N];
int num;
int H[N];
int heapsize;
int result=0;

int main(){
  int i,j;
  int sum=0;

  scanf("%d",&num);

  for(i=1;i<=num;i++){
    for(j=1;j<=num;j++){
      scanf("%d",&Tree[i][j]);
    }
  }

  minimumST();

  for(i=2;i<=num;i++)
    {
      //printf("%d \n",Tree[i][pi[i]]);
      //printf("d[%d] = %d : pi[%d] = %d\n",i,d[i],i,pi[i]);
      //sum+=d[i];
      result+=Tree[i][pi[i]];
    }
  printf("%d\n",result);


  

  return 0;
}

//
void minimumST (void){
  int i;
  int v;
  int u;
  int mincost;

  for(i=1;i<=num;i++) {
    d[i] = INF;
    pi[i] = NIL;
    color[i] = WHITE;
  }

  d[1] = 0;

  while(1){
    mincost = INF;

    for(i=1;i<=num;i++){
      if(color[i] != BLACK && d[i] < mincost){
	mincost = d[i];
	u = i;
      }
    }

    if(mincost == INF) break;
    
    color[u] = BLACK;

    //printf("u = %d\n",u);

    for(v=1;v<=num;v++){
      //printf("%d ",Tree[u][v]);
      if(Tree[u][v] == -1) continue;
      
      if(color[v] != BLACK && Tree[u][v] < d[v]){
	pi[v] = u;
	d[v] = Tree[u][v];
      }   
    }
  }
}






Measured memory_bytes: 2112
#include<iostream>
#include<cstdio>
using namespace std;
const int N=100005,mod=1e9+7;
int n;
char s[N];
long long ans=1,a[30];
int main()
{
	scanf("%d%s",&n,s+1);
	for(int i=1;i<=n;i++)
		a[s[i]-'a']++;
	for(int i=0;i<26;i++)
		ans=ans*(a[i]+1)%mod;
	printf("%lld\n",(ans-1+mod)%mod);
	return 0;
}

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

int main() {
  int N, kind =3;
  string c;
  cin >> N;
  for(int i =0; i < N; i++){
    cin >> c;
    if(c == "Y"){
      kind = 4;
    }
  }
  if(kind == 4){
    cout << "Four" << endl;
  }
  else{
    cout << "Three" << endl;
  }
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <sstream>
#include <algorithm>
using namespace std;
#define pb push_back
#define mp make_pair
#define ms(a, b)  memset((a), (b), sizeof(a))
//#define LOCAL
typedef long long LL;
const int inf = 0x3f3f3f3f;
const int maxn = 100000+10;
const int mod = 1e9+7;
LL x[maxn];
LL y[maxn];
LL mult(LL a, LL b)
{
    LL ans =0;
    LL base = a;
    while(b){
        if(b&1)     ans=(ans+base)%mod;
        b >>= 1;
        base = (base * 2)%mod;
    }
    return ans;
}
int main()
{
    #ifdef LOCAL
        freopen("input.txt" , "r", stdin);
    #endif // LOCAL
    int n, m;
    scanf("%d%d", &n, &m);
    for(int i=1;i<=n;i++)   scanf("%lld", &x[i]);
    for(int i=1;i<=m;i++)   scanf("%lld", &y[i]);
    LL ans =0;
    LL sumx = 0, sumy=0;
    for(int i=1;i<=n;i++)
        sumx =(sumx+ ( (i-1)*x[i] - (n-i)*x[i] )%mod)%mod;
    for(int i=1;i<=m;i++)
        sumy =(sumy+ ( (i-1)*y[i] - (m-i)*y[i] )%mod)%mod;
//    printf("%lld %lld\n", sumx, sumy);
    printf("%lld\n", mult(sumx, sumy));
    return 0;
}


Measured memory_bytes: 1792
#include <algorithm>
#include <iostream>
#include <vector>

using namespace std;

typedef long long ll;
// typedef pair<ll, ll> P;
typedef pair<int, int> P;
typedef pair<P, int> pi;
typedef pair<int, P> ip;

#define MOD 1000000007
#define REP(i, N) for (int i = 0; i < N; ++i)
#define REP1(i, N) for (int i = 1; i <= N; ++i)
#define RREP(i, N) for (int i = N - 1; i >= 0; --i)
#define ALL(a) a.begin(), a.end()

struct UnionFind {
  vector<int> par;
  vector<int> sz;

  UnionFind(int n) { init(n); }

  void init(int n) {
    par.resize(n);
    sz.resize(n);
    REP(i, n) {
      par[i] = i;
      sz[i] = 1;
    }
  }

  int find(int x) {
    if (par[x] == x)
      return x;
    else
      return par[x] = find(par[x]);
  }

  void unite(int x, int y) {
    x = find(x);
    y = find(y);
    if (x == y) return;
    if (sz[x] < sz[y]) {
      par[x] = y;
      sz[y] += sz[x];
    } else {
      par[y] = x;
      sz[x] += sz[y];
    }
  }

  bool same(int x, int y) { return find(x) == find(y); }

  int size(int x) { return sz[find(x)]; }
};

int main() {
  int N;
  cin >> N;
  vector<pi> p1(N);  // 点iの座標(x_i, y_i), 点iの番号i
  vector<pi> p2(N);  // 点iの座標(y_i, x_i), 点iの番号i
  REP(i, N) {
    int x, y;
    cin >> x >> y;
    p1[i] = make_pair(P(x, y), i);
    p2[i] = make_pair(P(y, x), i);
  }
  sort(ALL(p1));  // x座標でソート
  sort(ALL(p2));  // y座標でソート
  vector<ip> edge;
  REP(i, N - 1) {
    int u = p1[i].second;
    int v = p1[i + 1].second;
    int cost = abs(p1[i].first.first - p1[i + 1].first.first);
    edge.push_back(make_pair(cost, P(u, v)));
  }
  REP(i, N - 1) {
    int u = p2[i].second;
    int v = p2[i + 1].second;
    int cost = abs(p2[i].first.first - p2[i + 1].first.first);
    edge.push_back(make_pair(cost, P(u, v)));
  }
  // クラスカル法
  sort(ALL(edge));
  UnionFind uf(N);
  ll ans = 0;
  REP(i, edge.size()) {
    int u = edge[i].second.first;
    int v = edge[i].second.second;
    int cost = edge[i].first;
    if (!uf.same(u, v)) {
      uf.unite(u, v);
      ans += cost;
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 7284
#pragma GCC optimize("O3")
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("unroll-loops")

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds; 

#define int long long
#define pb push_back
#define pf push_front
#define eb emplace_back
#define mp make_pair
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define f first
#define s second
#define sz(x) (int)x.size()
#define endl "\n"
#define forn(i,n) for(int i=0;i<n;++i)
#define fore(i,l,r) for(int i=int(l);i<=int(r);++i)
#define rep(i,begin,end) for(__typeof(end) i=(begin);i!=(end);i++)
#define fill(a,value) memset(a,value,sizeof(a));
#define gcd(a,b) __gcd((a),(b))
#define watch1(x) cout<<(x)<<endl
#define watch2(x,y) cout<<(x)<<" "<<(y)<<endl
#define watch3(x,y,z) cout<<(x)<<" "<<(y)<<" "<<(z)<<endl
#define fastio ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);

typedef long long ll;
typedef long double ld; 
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vpii;
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> oset;

const int INF = 9e18;
const int M = 1e7 + 5;
const int N = 2e5 + 5;

int i,j,n,spf[M],curr,cnt;

void sieve()
{
    for(i=1;i<M;++i)
        spf[i]=i;
    for(i=2;i*i<M;++i)
    {
        if(spf[i]==i)
        {
            for(j=i*i;j<M;j+=i)
            {
                if(spf[j]==j)
                    spf[j]=i;
            }
        }
    }
}

map<int,int> factorize(int N)
{
    map<int,int> fact;
    curr=spf[N];  
    cnt=1;  
    while(N>1){ 
        N/=spf[N];
        if(curr==spf[N]){
            cnt++; 
            continue; 
        }
        fact[curr]=cnt;
        curr=spf[N]; 
        cnt=1;
    }
    return fact;
}

void solve()
{
    sieve();
    cin>>n;
    int ans=0;
    for(i=1;i<=n;++i)
    {
        int k=1;
        map<int,int> mp=factorize(i);
        for(auto it:mp)
        {
            k*=(it.s+1);
        }
        ans+=k*i;
    }
    cout<<ans;
}

signed main()
{
    fastio;
    int t;
    //cin>>t;
    t=1;
    while(t--)
    {
        solve();
    }
    return 0;
}

Measured memory_bytes: 81728
import sys
import math
import itertools
import collections
from collections import deque
from collections import defaultdict

sys.setrecursionlimit(1000000)
MOD = 10 ** 9 + 7
MOD2 = 998244353
INF = float('inf')
input = lambda: sys.stdin.readline().strip()

NI = lambda: int(input())
NMI = lambda: map(int, input().split())
NLI = lambda: list(NMI())
SI = lambda: input()

def main():
    N = NI()
    CSF = [NLI() for _ in range(N-1)]
    CSF.append([0,0,1])

    
    for n in range(N-1):
        time = CSF[n][1]
        
        for m in range(n,N-1):
            time += CSF[m][0]
            if time < CSF[m+1][1]:
                time = CSF[m+1][1]
            else:
                if time % CSF[m+1][2] != 0:
                    time = ((time//CSF[m+1][2])+1)*CSF[m+1][2]
        print(time)
    print(0)



if __name__ == '__main__':
    main()

Measured memory_bytes: 9500
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <map>
#include <set>
#include <vector>
#include <iostream>
#include <algorithm>
#include <string>
#include <iomanip>
#include <assert.h>
#include <math.h>
#include <stack>
#include <queue>
#include <list>
using namespace std;

// #define __DEBUG__

#ifdef __DEBUG__
bool debug_disabled = false;
#else
bool debug_disabled = true;
#endif

#define dbg if (debug_disabled) {} else cerr

void solve() {
    int A, B, K;
    cin >> K >> A >> B;

    if (A % K == 0 || A / K != B / K)
        cout << "OK" << endl;
    else
        cout << "NG" << endl;
}

int main() {
    cout.setf(ios::fixed, ios::floatfield);
    cout.setf(ios::showpoint);
    cout.precision(12);
    cin.tie(0);
    cout.tie(0);
    ios::sync_with_stdio(false);

    int T = 1;
    // cin >> T;
    for (int i = 1; i <= T; ++i) {
        solve();
    }

    return 0;
}

Measured memory_bytes: 3648
import Control.Monad
import Data.List

-- firstBinary :: (Int -> Bool) -> Int -> Int -> Int
firstBinary _ l r | l == r = l
firstBinary f l r = let m = div (l + r) 2 in if f m then firstBinary f l m else firstBinary f (m + 1) r

count :: (a -> Bool) -> [a] -> Int
count f l = length [i | i <- l, f i]

divCount :: Int -> Int
divCount n = count ((== 0) . mod n) [1..n]

main = do
    [n]  <- map read . words <$> getLine
    print $ count cond [1..n]
    where cond i = divCount i == 8 && mod i 2 == 1


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

using namespace std;

#define MAX_N 1010

struct Edge{
    int to,cost;
    Edge(){}
    Edge(int to,int cost) :
        to(to),cost(cost) {}
};

vector<Edge> G[MAX_N];
vector<int> C;

int solve(int v){
    int res = 0;
    for(int i = 0 ; i < (int)G[v].size() ; i++){
        Edge e = G[v][i];
        if(C[e.to-1] > 0){
            res += e.cost;
        }else{
            res += min(e.cost,solve(e.to));
        }
    }
    return res;
}

int main(){
    int N,u,v,p;
    cin >> N; C.resize(N-1);
    for(int i = 0 ; i < N-1 ; i++){
        cin >> C[i];
    }
    for(int i = 0 ; i < N-1 ; i++){
        cin >> u >> v >> p;
        G[u].push_back(Edge(v,p));
    }
    cout << solve(0) << endl;
    return 0;
}

Measured memory_bytes: 1244
s = gets.chomp
k = gets.to_i
(s.size-1).times{|i|
	toa = (?z.ord + 1 - s[i].ord) % 26
	if toa <= k
		print 'a'
		k -= toa
	else
		print s[i]
	end
}
puts ((s[-1].ord-?a.ord+k)%26 + ?a.ord).chr


Measured memory_bytes: 2172
#include <bits/stdc++.h>
using namespace std;
vector<vector<int>> adj;
vector<int> dp, vis;
int ans = 0;
void dfs(int node){
    vis[node] = 1;
    int maxi = 0;
    for (auto &i: adj[node])
        if(!vis[i])
            dfs(i), maxi = max(maxi, 1+dp[i]);
        else maxi = max(maxi, 1+dp[i]);
    dp[node] = maxi;
}
int main(){
    ios::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr);
    int n, m, src, dest;
    cin >> n >> m;
    adj.resize(n+1), dp.resize(n+1), vis.resize(n+1);
    for (int i=0; i<m ;i++){
        cin >> src >> dest;
        adj[src].emplace_back(dest);
    }
    for(int i=1; i<=n; i++)
        if (!vis[i])
            dfs(i), ans = max(ans, dp[i]);
    cout << ans << "\n";
}

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

using namespace std;

#define int long long
#define all(v) begin(v), end(v)
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define reps(i, s, n) for(int i = (int)(s); i < (int)(n); i++)

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

using pint = pair<int, int>;
using tint = tuple<int, int, int>;
using vint = vector<int>;

const int inf = 1LL << 55;
const int mod = 1e9 + 7;

double P[100010]; // i?????£?¶???§???????¢????
double dp[100010]; // i??\????????§??????????????????????????????

signed main()
{
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  cout << fixed << setprecision(12);

  P[1] = 1.0;
  double p = 0.5;
  reps(i, 2, 100010) {
    P[i] = P[i-1] * p;
    p /= 2.0;
  }
  dp[1] = 1.0;
  reps(i, 2, 100010) {
    double p = 0.5;
    reps(j, 1, min(i, 100LL)) {
      // j+1??\?????§???????????????????????????P[j]*(1-p)????¢??????§?????????
      // ???????????§???j??????????????????????????????????????????i-j-1??\??????????????????????????????
      // ??????i-j-1??\?????????????????????????????????1??\?????????i-j-1????????§????????????????????????
      dp[i] += P[j]*(1-p)*(j+dp[i-j-1]);
      p /= 2.0;
    }
    // P[i]????¢??????§???????¶?????????¨i????????????
    dp[i] += i*P[i];
  }

  int n;
  while(cin >> n, n) {
    cout << dp[n] << endl;
  }

  return 0;
}

Measured memory_bytes: 4840