akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <cmath>
#include<algorithm>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<iomanip>
#define _USE_MATH_DEFINES
#include <math.h>
#include <functional>
using namespace std;

#define rep(i,x) for(ll i=0;i<x;i++)
#define repn(i,x) for(ll i=1;i<=x;i++)

typedef long long ll;
const ll INF = 1e17;
const ll MOD = 998244353;
const ll MAX = 1000001;

ll max(ll a, ll b) {
	if (a > b) { return a; }
	return b;
}

ll min(ll a, ll b) {
	if (a > b) { return b; }
	return a;
}

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

ll lcm(ll a, ll b) {
	return a / gcd(a, b) *b;
}

struct edge {
	ll ind;
	ll fr;
	ll to;
	ll d;
};


///////////////////////////

ll p(ll n) {
	if (n == 0) { return 1; }
	return p(n - 1) * 2 % MOD;
}



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

	vector<vector<ll>> a(N + 1, vector<ll>(M + 1));

	repn(i, N)repn(j, M) cin >> a[i][j];

	vector<ll> see(N + 1, 0);

	repn(i, M) {
		ll t = 0;
		repn(j, N) {
			if (a[j][i] == 1&&see[j]==0) { t = j; break; }
		}

		see[t] = 1;

		if (t == 0) { continue; }

		for (ll j = t+1; j <= N; j++) {
			if (a[j][i] == 0) { continue; }

			for (ll k = i; k <= M; k++) {
				a[j][k] = (a[j][k] + a[t][k]) % 2;
			}
		}
	}


	ll zero = 0;
	
	repn(i, N) {
		ll b = 1;
		repn(j, M) {
			if (a[i][j] != 0) { b = 0; }
			//cout << a[i][j];
		}
		//cout << endl;
		zero += b;
	}

	
	ll X = p(N) - p(zero);
	X = (X%MOD + MOD) % MOD;

	ll ans = X * p(M - 1) % MOD;
	cout << ans;
	system("PAUSE");
}


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

using namespace std;

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


Measured memory_bytes: 3116
s=input()
if s=='SUN':
    ans=7
elif s=='MON':
    ans=6
elif s=='TUE':
    ans=5
elif s=='WED':
    ans=4
elif s=='THU':
    ans=3
elif s=='FRI':
    ans=2
elif s=='SAT':
    ans=1
print(ans)

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

int main() {
  string S;
  cin >> S;
  int ans = 0;
  for (int i = 0; i < S.size() - 1; i++) {
    if (S[i] == S[i + 1]) {
      if (S[i + 1] == '0') S[i + 1] = '1'; else S[i + 1] = '0';
      ans++;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 512
# -*- coding: utf-8 -*-
#https://atcoder.jp/contests/abc129/tasks/abc129_b
import sys

n= int(input())
#s= input()
tmp = input().split()
w = list(map(lambda a: int(a), tmp))

sum=0
for i in range(n):
	sum+=w[i]
#w.sort()
ave=sum//2

#print(w)

sum2=0
for i in range(n):
	sum2+=w[i]
	if(sum2>ave):
		if((2*sum2-sum)>(sum-2*sum2+2*w[i])):
			print(sum-2*sum2+2*w[i])
			sys.exit()
		else:
			print(2*sum2-sum)
			sys.exit()

print(w)
#sum = p+q+r-max(p,max(q,r))
#print(sum)



Measured memory_bytes: 3064
#include <iostream>
#include <string>
#include <cstdlib>
#include <vector>
#include <array>
#include <map>
#include <set>
#include <algorithm>
#include <queue>
#include <stack>
#define _USE_MATH_DEFINES
#include <cmath>
#include <climits>
#include <cstdio>
#include <iomanip>
#include <utility>
#include <unordered_map>

using namespace std;
typedef long long int ll;

#define SP(x) setprecision((int)x)
#define SW(x) setw(x) // 桁数指定
#define SF(c) setfill(c) // 埋め文字指定('0')
#define ALL(v) v.begin(), v.end()

ll facctorialMethod(ll k)
{
    ll sum = 1;
    for (ll i = 1; i <= k; ++i)
    {
        sum *= i;
        sum %= 1000000007;
    }
    return sum;
}

int main(int argc, char const *argv[])
{
    ll n, m;
    cin >> n >> m;
    if (abs(n - m) > 1)
    {
        cout << 0 << endl;
    }
    else
    {
        ll ans = facctorialMethod(n) * facctorialMethod(m) % 1000000007;
        if (n == m)
        {
            ans *= 2;
            ans %= 1000000007;
        }
        cout << ans << endl;
    }
}


Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#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;
using ll = long long;
using u64 = uint_fast64_t;
using pii = pair<int, int>;
using pll = pair<long long, long long>;
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()
constexpr char ln =  '\n';
constexpr long long MOD = 1000000007;
//constexpr long long MOD = 998244353;
template<class T1, class T2> inline bool chmax(T1 &a, T2 b) { if (a < b) { a = b; return true;} return false; }
template<class T1, class T2> inline bool chmin(T1 &a, T2 b) { if (a > b) { a = b; return true;} return false; }
inline int popcount(int x) {return __builtin_popcount(x);}
inline int popcount(long long x) {return __builtin_popcountll(x);}
void print() { cout << "\n"; }
template<class T, class... Args>
void print(const T &x, const Args &... args) {
    cout << x << " ";
    print(args...);
}
///////////////////////////////////////////////////////////////////////////////////////////////////////////////

int main() {
    ios::sync_with_stdio(false); cin.tie(nullptr);
    int X; cin >> X;
    ll a = 0;
    int cnt = 0;
    while (true) {
        cnt++;
        a += X;
        if (a%360==0) {
            cout << cnt << ln;
            return 0;
        }
    }
}

Measured memory_bytes: 3604
#include <bits/stdc++.h>
using namespace std;
#define lli long long int
#define rep(i, n) ;for (int i = 0;i < (int)(n);i++)
#define rep2(i, s, n) ;for (int i = s; i < (int)(n);i++)
#define ALL(vec)  (vec).begin(),(vec).end()
#define pi 3.1415926535897932384626433832795
#define MAX_INF 9223372036854775807
#define MIN_INF (922337203685477587+1)
#define sosuu 1000000007

int main() {
  string S;
  cin>> S;
  if(S[2]==S[3]&&S[4]==S[5])
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
  
  
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ALL(v) (v).begin(),(v).end()
#define REP(i,p,n) for(int i=p;i<(int)(n);++i)
#define rep(i,n) REP(i,0,n)
#define SZ(x) ((int)(x).size())
#define debug(x) cerr << #x << ": " << x << '\n'
#define INF 999999999
typedef long long int Int;
typedef pair<int,int> P;
using ll = long long;
using VI = vector<int>;

int n;
VI l;
VI A;//A,B,C

int main(){
    cin >> n;
    A.resize(n);
    rep(i,3) cin >> A[i];
    l.resize(n);
    rep(i,n) cin >> l[i];
    int res = 1<<29;
    VI bit(3);
    for(bit[0] = 1;bit[0] <(1<<n);bit[0]++){
        for(bit[1]=1;bit[1]<(1<<n);bit[1]++){
            if(bit[1]&bit[0]) continue;
            for(bit[2]=1;bit[2]<(1<<n);bit[2]++){
                if(bit[2]&bit[0]) continue;
                if(bit[2]&bit[1]) continue;

                vector<int> sums(3,0),nums(3,0);
                for(int i=0;i<n;i++){
                    for(int j=0;j<3;j++){
                        if(bit[j]&(1<<i)){
                            sums[j]+=l[i];
                            nums[j]++;
                        }
                    }
                }
                int score = 0;
                for(int i=0;i<3;i++){
                    score+=abs(sums[i]-A[i]);
                    score+=(nums[i]-1) * 10;
                }
                res = min(res,score);
            }
        }
    }
    cout << res << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#define MAX 45

int array[MAX];

void makefibo();

int main(){
  int n;

  scanf("%d", &n);

  makefibo();

  printf("%d\n", array[n]);

  return 0;
}

void makefibo(){
  int i;

  array[0] = array[1] = 1;

  for( i=2; i<MAX; i++){
    array[i] = array[i-2] + array[i-1];
  }

}

Measured memory_bytes: 596
#include <stdio.h>
#include <math.h>
#define rep(i,l,r)for(int i=(l);i<(r);i++)
#define min(p,q)((p)<(q)?(p):(q))

double dp[1010][1010];
//dp[i][j]=現在地がiで最後に飛ばしたのがjで確定した距離
int x[1010],y[1010];

int main(){
	int n;
	scanf("%d",&n);
	rep(i,0,n)scanf("%d%d",x+i,y+i);
	dp[1][0]=hypot(x[1]-x[0],y[1]-y[0]);
	rep(i,2,n+1){
		rep(j,0,i-1)dp[i][j]=dp[i-1][j]+hypot(x[i]-x[i-1],y[i]-y[i-1]);
		dp[i][i-1]=1e10;
		rep(j,0,i-1)dp[i][i-1]=min(dp[i][i-1],dp[i-1][j]+hypot(x[i]-x[j],y[i]-y[j]));
	}
	double ans=1e10;
	rep(j,0,n-1)ans=min(ans,dp[n-1][j]+hypot(x[n-1]-x[j],y[n-1]-y[j]));
	printf("%.9f\n",ans);
}


Measured memory_bytes: 8780
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
using P = pair<int, int>;
using vec = vector<int>;
using mat = vector<vector<int>>;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()
#define endl "\n"

constexpr int MOD = 1000000007;
const int INF = 1 << 30;

int main() {
    int n;
    cin >> n;
    vec a(n-1);
    rep(i, n-1) cin >> a[i];
    vec b(n, 0);
    rep(i, n-1) b[a[i]-1]++;

    rep(i, n) cout << b[i] << endl;
    return 0;
}

Measured memory_bytes: 4844
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<set>
#include<iomanip>
#define rep(i, a, n) for(int i = a; i < n; i++)
using namespace std;
int main(){
int a, b, c;
cin >> a >> b >> c;
if(a == b) {
  cout << c;
}
  else if(a == c){
    cout << b;
  }
  else if(b == c){
    cout << a;
  }
}

Measured memory_bytes: 3620
#include <stdio.h>
int main(void){
  int n = 0;
  long int sum = 0;
  scanf("%d",&n);
  for(int i=1;i<n+1;i++){
    if( i % 3 != 0){
      if( i % 5 != 0){
        sum += i;
      }
    }
  }
  printf("%ld",sum);
  return 0;
}

Measured memory_bytes: 1728
import java.io.*;
import java.util.*;






public class Main
{

	static OutputStream outputStream = System.out;
	static PrintWriter out = new PrintWriter(outputStream);	


	static class node
	{
		int x;int y;int s;

		node(int dx,int dy,int ds)
		{
			x=dx;y=dy;s=ds;
		}
	}


	public static void main(String[] Atul)throws IOException
	{
		BufferedReader br=new BufferedReader(new InputStreamReader(System.in));

		
		String[] s_=br.readLine().split(" ");

		int n=Integer.parseInt(s_[0]),m=Integer.parseInt(s_[1]);


		int[][] vis=new int[n][m];

		int[][] a=new int[n][m];


		for(int i=0;i<n;i++)
		{
			String s1=br.readLine();
			for(int j=0;j<m;j++)
			{
				if(s1.charAt(j)=='#') a[i][j]=1;
				else a[i][j]=0;
			}
		}

		Queue<node> q=new LinkedList<node>();


		for(int i=0;i<n;i++)
		{
			for(int j=0;j<m;j++)
			{
				if(a[i][j]==1)
				{
					q.add(new node(i,j,0));
					vis[i][j]=1;
				}
			}
		}

		int max=0;

		while(q.size()>0)
		{
			node top=q.poll();

			int i=top.x,j=top.y,s=top.s;

			max=Math.max(max,s);

			if((j-1)>=0 && vis[i][j-1]==0 && a[i][j-1]==0)
			{
				vis[i][j-1]=1;
				q.add(new node(i,j-1,s+1));
			}
			if((j+1)<m && vis[i][j+1]==0 && a[i][j+1]==0)
			{
				vis[i][j+1]=1;
				q.add(new node(i,j+1,s+1));
			}
			if((i-1)>=0 && vis[i-1][j]==0 && a[i-1][j]==0)
			{
				vis[i-1][j]=1;
				q.add(new node(i-1,j,s+1));
			}
			if((i+1)<n && vis[i+1][j]==0 && a[i+1][j]==0)
			{
				vis[i+1][j]=1;
				q.add(new node(i+1,j,s+1));
			}
		}
		out.println(max);
		
		out.close();

	}
}

Measured memory_bytes: 92312
/*The woods are lovely, dark and deep,
But I have promises to keep,
And miles to go before I sleep,
And miles to go before I sleep.*/

//PRABHJOT SINGH A.K.A. PRABHI
//~~~~~conquizztador~~~~~


#include<bits/stdc++.h>
using namespace std;
using lli = long long int;
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
const int MOD = 1000000007;
const int MOD1 = 998244353;
const int maxn = 100010;
const int lim = (int)1e9;
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int ct=0;string s,t;
	cin>>s;
	cin>>t;
	for(int i=0;i<s.length();++i)
		if(s[i]!=t[i])
			++ct;
	cout<<ct<<endl;
}

Measured memory_bytes: 3800
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author
 */

#include<bits/stdc++.h>
using namespace std;
using ll=long long;
#define fr(i,n) for(int i=0;i<(n);++i)
#define Fr(i,n) for(int i=1;i<=(n);++i)
#define ifr(i,n) for(int i=(n)-1;i>=0;--i)
#define iFr(i,n) for(int i=(n);i>0;--i)

class ATenki {
public:
    void solve(istream& in, ostream& out) {
        cin.tie(nullptr);
        ios::sync_with_stdio(false);
        string s,t;
        in>>s>>t;
        int ans=0;
        fr(i,3) ans+=(s[i]==t[i]);
        out<<ans<<endl;
    }
};

int main() {
    ATenki solver;
    std::istream& in(std::cin);
    std::ostream& out(std::cout);
    solver.solve(in, out);
    return 0;
}


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

using namespace std;

void task()
{
    int n, m, sum=0, calc;

    cin>>n>>m;

    //calc=1;
    if(n==2) sum++;
    if(n>2){
        calc=1;
        for(int K=n; K>=n-1; K--){
            calc *= K;
        }
        calc /= 2;
        sum += calc;
    }

    //calc = 1;
    if(m==2) sum++;
    if(m>2){
        calc=1;
        for(int K=m; K>=m-1; K--){
            calc *= K;
        }
        calc /= 2;
        sum += calc;
    }

    cout<<sum<<endl;
}

int main()
{
    task();

    return 0;
}


Measured memory_bytes: 256
// The in-contest submission was overengineered.
// This one is better.

#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cfloat>
#include <chrono>
#include <climits>
#include <cmath>
#include <cstdio>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <unordered_map>
#include <unordered_set>
#include <vector>
using namespace std;

template <class T1, class T2>
ostream& operator << (ostream& out, const pair <T1, T2> p)
{
    out << '(' << p.first << ',' << p.second << ')';
    return out;
}

template <class T1, class T2>
istream& operator >> (istream& in, pair<T1, T2> &p)
{
    in >> p.first >> p.second;
    return in;
}

template <class T>
istream& operator >> (istream& in, vector<T> &v)
{
    for (T &x : v)
        in >> x;
    return in;
}

template <class T>
ostream& operator << (ostream& out, const vector<vector<T>> &v)
{
    for (const vector<T> &x : v)
        out << x << '\n';
    return out;
}

template <class T>
ostream& operator << (ostream& out, const vector<T> &v)
{
    for (const T &x : v)
        out << x << ' ';
    return out;
}

long long gcd (long long a, long long b)
{
    if (b > a)
        swap(a, b);
    return (b ? gcd(b, a % b) : a);
}

using ll   = long long;
using pii  = pair<int, int>;
using pll  = pair<long long, long long>;
using tiii = pair<pair<int, int>, int>;
using vi   = vector<int>;
using vl   = vector<long long>;
using vvi  = vector<vector<int>>;
using vvl  = vector<vector<long long>>;

#define F          first
#define S          second
#define First      first.first
#define Second     first.second
#define Third      second
#define mp         make_pair
#define rep(i,a,b) for (int i = (a); i < (b); i++)
#define per(i,b,a) for (int i = (b); i > (a); i--)
#define all(x)     x.begin(), x.end()
#define ret(x)     return cout << x, 0;
#define throwex    throw runtime_error ("Found the error.");

const int h = 1000000007;

signed main()
{
    ios::sync_with_stdio(false);
    #ifdef ONLINE_JUDGE
    cin.tie(nullptr);
    cout.tie(nullptr);
    cerr.setstate(ios::failbit);
    #endif

    int n;
    cin >> n;
    vl a(n+1);
    cin >> a;
    vl s = a;
    for(int i = n - 1; i > -1; i--)
        s[i] += s[i+1];
    ll nodes = 1, ans = 0;
    rep(i,0,n+1)
    {
        if(nodes < a[i])
            ret(-1);
        nodes = min(nodes, s[i]);
        ans += nodes;
        nodes -= a[i];
        nodes *= 2;
    }
    ret(ans);
}


Measured memory_bytes: 4792
using System;
using System.Net.Mail;
using System.Security.Cryptography;

namespace ARC090D
{
    internal class Program
    {
        public static void Main(string[] args)
        {
            int[] ints = Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);
            int n = ints[0];
            int m = ints[1];
            UnionFind union = new UnionFind(n);

            for (int i = 0; i < m; i++)
            {
                int[] line = Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);
                int l = line[0];
                int r = line[1];
                int d = line[2];
                --l;
                --r;
                if (union.Same(l, r))
                {
                    int diff = union.Diff(l, r);
                    if (diff != d)
                    {
                        Console.WriteLine("No");
                        return;
                    }
                }

                union.Unite(l, r, d);
            }

            Console.WriteLine("Yes");
        }
    }

    public class UnionFind
    {
        private int[] par;
        private int[] rank;
        private int[] weight;

        public UnionFind(int maxN)
        {
            par = new int[maxN + 1];
            rank = new int[maxN + 1];
            weight = new int[maxN + 1];
            Init(maxN);
        }

        void Init(int n)
        {
            for (int i = 1; i <= n; i++)
            {
                par[i] = i;
                rank[i] = 0;
                weight[i] = 0;
            }
        }

        public int Root(int x)
        {
            if (par[x] == x)
            {
                return x;
            }

            int r = Root(par[x]);
            weight[x] += weight[par[x]];
            return par[x] = r;
        }

        public int Weight(int x)
        {
            Root(x);
            return weight[x];
        }

        public int Diff(int x, int y)
        {
            return weight[y] - weight[x];
        }

        public bool Same(int x, int y)
        {
            return Root(x) == Root(y);
        }

        public bool Unite(int x, int y, int d)
        {
            d += weight[x];
            d -= weight[y];

            x = Root(x);
            y = Root(y);

            if (x == y) return false;

            if (rank[x] < rank[y])
            {
                int temp = x;
                x = y;
                y = temp;
                d = -d;
            }

            if (rank[x] == rank[y]) ++rank[x];

            par[y] = x;
            weight[y] = d;
            return true;
        }
    }
}

Measured memory_bytes: 17296
#include <bits/stdc++.h>
#define GET_MACRO(_1,_2,_3,_4,_5,_6,NAME,...) NAME
#define pr(...) cerr<< GET_MACRO(__VA_ARGS__,pr6,pr5,pr4,pr3,pr2,pr1)(__VA_ARGS__) <<endl
#define pr1(a) (#a)<<"="<<(a)<<" "
#define pr2(a,b) pr1(a)<<pr1(b)
#define pr3(a,b,c) pr1(a)<<pr2(b,c)
#define pr4(a,b,c,d) pr1(a)<<pr3(b,c,d)
#define pr5(a,b,c,d,e) pr1(a)<<pr4(b,c,d,e)
#define pr6(a,b,c,d,e,f) pr1(a)<<pr5(b,c,d,e,f)
#define pr7(a,b,c,d,e,f,g) pr1(a)<<pr6(b,c,d,e,f,g)
#define pr8(a,b,c,d,e,f,g,h) pr1(a)<<pr7(b,c,d,e,f,g,h)
using namespace std;
using Int = long long;
using ll = long long;
using Double = long double;
const Int INF = (1LL<<55)+1e9; // ~ 3.6 * 1e16
const Int mod = (1e9)+7;
const Double EPS = 1e-8;
const Double PI = 6.0 * asin((Double)0.5);
using P = pair<Int,Int>;
using T = tuple<Int,Int,Int>;
template<class T> T Max(T &a,T b){return a=max(a,b);}
template<class T> T Min(T &a,T b){return a=min(a,b);}
ostream& operator<<(ostream& o,P p){return o<<"("<<p.first<<","<<p.second<<")";}
ostream& operator<<(ostream& o,T t){return o<<"("<<get<0>(t)<<","<<get<1>(t)<<","<<get<2>(t)<<")";}
istream& operator>>(istream& i,P &p){return i>>p.first>>p.second;}
ostream& operator<<(ostream& o,vector<auto> &a){Int i=0;for(auto t:a)o<<(i++?" ":"")<<t;return o;}
istream& operator>>(istream& i,vector<auto> &a){for(auto &t:a)i>>t;return i;}
void prArr(auto a,string s=" "){Int i=0;for(auto t:a)cout<<(i++?s:"")<<t;cout<<endl;}


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

  Int n, C;
  cin>>n>>C;
  vector<vector<Int> > D(C,vector<Int>(C));
  cin>>D;
  vector<vector<Int> > mp(n,vector<Int>(n));
  cin>>mp;

  for(Int i=0;i<n;i++)
    for(Int j=0;j<n;j++) mp[i][j]--;

  Int used[30][3] = {},mem[30][3];
  auto calc2 =[&](Int a,Int mod){
    if(used[a][mod]++) return mem[a][mod];
    Int res = 0;
    for(Int i=0;i<n;i++)
      for(Int j=0;j<n;j++)
	if((i+j)%3 == mod && mp[i][j] != a) res += D[mp[i][j]][a];
    
    return mem[a][mod] = res;
  };

  auto calc =[&](Int a,Int b,Int c){
    if(a == b || a == c || b == c ) return INF;
    Int res = calc2(a, 0) + calc2(b, 1) + calc2(c, 2);
    return res;
  };


  Int ans = INF;
  for(Int i=0;i<C;i++)
    for(Int j=0;j<C;j++)
      for(Int k=0;k<C;k++) Min(ans, calc(i, j , k));
  
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 2304
row = input().split()
N = int(row[0])
K = int(row[1])
a = list(map(int, input().split()))
a.sort()
num = []
i = 0
count = 0
while i < N:
    j = 0
    while True:
        if a[i] == a[i+j]:
            count += 1
            j += 1
        else:
            num.append(count)
            i = i+j
            count = 0
            break
        if i+j >= N:
            num.append(count)
            i = i+j
            break
num.sort()
ans = 0
for i in range(len(num) - K):
    ans += num[i]
print(ans)
        




Measured memory_bytes: 25736
def main():
    D, G, *pc = map(int, open(0).read().split())
    p = pc[::2]
    c = pc[1::2]
    ans = 1e9 + 7
    # 2 ** D - 1 まで
    for b in range(2 ** D):
        num = 0
        pnt = 0
        # コンプリートしない MAX
        x = None
        # 得点が高い方から
        for i in range(D - 1, -1, -1):
            # i 番目 の フラグ が 立っている
            if b >> i & 1:
                num += p[i]
                # コンプリートする
                pnt += c[i] + 100 * (i + 1) * p[i]
            elif x is None:
                x = i
        # コンプリート オール
        # または 既に 目標の 総合スコア に到達
        if x is None or G <= pnt:
            ans = min(ans, num)
        # コンプリートしない MAX で 目標の 総合スコア に到達
        elif -(-(G - pnt) // (100 * (x + 1))) < p[x]:
            ans = min(ans, num - (-(G - pnt) // (100 * (x + 1))))
    print(ans)
    return


main()


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

using namespace std;
 
map<string, int> m;
 
void change()
{
    m["11"] = 'a'; m["12"] = 'b'; m["13"] = 'c'; m["14"] = 'd'; m["15"] = 'e';
    m["21"] = 'f'; m["22"] = 'g'; m["23"] = 'h'; m["24"] = 'i'; m["25"] = 'j';
    m["31"] = 'k'; m["32"] = 'l'; m["33"] = 'm'; m["34"] = 'n'; m["35"] = 'o';
    m["41"] = 'p'; m["42"] = 'q'; m["43"] = 'r'; m["44"] = 's'; m["45"] = 't';
    m["51"] = 'u'; m["52"] = 'v'; m["53"] = 'w'; m["54"] = 'x'; m["55"] = 'y';
    m["61"] = 'z'; m["62"] = '.'; m["63"] = '?'; m["64"] = '!'; m["65"] = ' ';
}
 
bool judge(string s)
{
    if (s.size()%2==1) return 0;
     
    for (int i = 0; i < (int)s.size(); i++) {
        if (i % 2 == 1 && !('1' <= s[i] && s[i] <='5')) return 0;
        if (i % 2 == 0 && !('1' <= s[i] && s[i] <= '6')) return 0;
    }
    return 1;
}
 
int main()
{
    string str;
     
    change();     
    while (cin >> str) {
        if (!judge(str)) {
            cout << "NA" << endl;
        } else {
            string ans = "";
            for (int i = 0; i < (int)str.size(); i++) {
                string k = str.substr(i, 2);
                if(i % 2 == 0) {
                    ans += m[k];
                }
            }
            cout << ans << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 3156
using System;
using System.IO;
using System.Linq;
using System.Collections.Generic;

public class Program
{

	public void Proc()
	{
        Dictionary<char, bool[]> flags = new Dictionary<char, bool[]>();
        char[] suit = new char[] { 'S', 'H', 'C', 'D' };
        suit.ToList().ForEach(a => flags.Add(a, new bool[13]));
        int inputCount = int.Parse(Reader.ReadLine());
        for (int i = 0; i < inputCount;i++) {
            string[] inpt = Reader.ReadLine().Split(' ');
            char c = inpt[0][0];
            int num = int.Parse(inpt[1]);
            flags[c][num - 1] = true;
        }

        System.Text.StringBuilder ans = new System.Text.StringBuilder();
        suit.ToList().ForEach(a =>
        {
            for (int i = 0; i < 13; i++)
            {
                if (!flags[a][i])
                {
                    ans.AppendLine(a + " " + (i + 1));
                }
            }
        });
        Console.Write(ans.ToString());
    }


    public class Reader
	{
		private static StringReader sr;
		public static bool IsDebug = false;
		public static string ReadLine()
		{
			if (IsDebug)
			{
				if (sr == null)
				{
					sr = new StringReader(InputText.Trim());
				}
				return sr.ReadLine();
			}
			else
			{
				return Console.ReadLine();
			}
		}
		private static string InputText = @"




47
S 10
S 11
S 12
S 13
H 1
H 2
S 6
S 7
S 8
S 9
H 6
H 8
H 9
H 10
H 11
H 4
H 5
S 2
S 3
S 4
S 5
H 12
H 13
C 1
C 2
D 1
D 2
D 3
D 4
D 5
D 6
D 7
C 3
C 4
C 5
C 6
C 7
C 8
C 9
C 10
C 11
C 13
D 9
D 10
D 11
D 12
D 13


";
	}

	public static void Main(string[] args)
	{
#if DEBUG
		Reader.IsDebug = true;
#endif
		Program prg = new Program();
		prg.Proc();
	}
}

Measured memory_bytes: 9968
#include "bits/stdc++.h"
using namespace std;
#define rep(i,n)for(int i=0;i<(int)(n);i++)
#define PI 3.141592653589793
//vector < vector<int>>a(0, vector<int>(0));二次元配列宣言


int main()
{
	string s, t;
	cin >> s >> t;
	int a, b;
	cin >> a >> b;
	string u;
	cin >> u;
	if (u == s)
		a--;
	else
		b--;
	cout << a << " " << b << endl;

}

Measured memory_bytes: 3600
#include<iostream>
using namespace std;
int main(){
	int N,K;
	int x[100];
	
	int i;
	int ans=0;
	
	cin>>N>>K;
	for(i=0;i<N;i++){
		cin>>x[i];
		if(x[i]<=K/2){
			ans=ans+x[i]*2;
		}else{
			ans=ans+(K-x[i])*2;
		}
	}
	
	cout<<ans;
	return 0;
} 

Measured memory_bytes: 256
/**
 * Sergey Kopeliovich (burunduk30@gmail.com)
 */

#include <bits/stdc++.h>

using namespace std;

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

int main() {
	int a, b;
	scanf("%d%d", &a, &b);
	vector<int> cnt(26);
	forn(i, a * b) {
		char c;
		scanf(" %c", &c);
		cnt[c - 'a']++;
	}
	int cnt4 = (a / 2) * (b / 2);
	int cnt2 = 0, cnt1 = 0;
	if (a & 1) cnt2 += b / 2;
	if (b & 1) cnt2 += a / 2;
	if ((a & 1) && (b & 1)) cnt1++;
	forn(i, 26)
		while (cnt[i] >= 4 && cnt4)
			cnt[i] -= 4, cnt4--;
	forn(i, 26)
		while (cnt[i] >= 2 && cnt2)
			cnt[i] -= 2, cnt2--;
	forn(i, 26)
		while (cnt[i] >= 1 && cnt1)
			cnt[i] -= 1, cnt1--;
	puts(cnt1 || cnt2 || cnt4 ? "No" : "Yes");
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
using namespace std;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define rep2(i, s, n) for (ll i = s; i < (ll)(n); i++)
typedef long long ll;
typedef vector<vector<ll>> vvl;
typedef vector<ll> vl;
typedef vector<vector<char>> vvc;
typedef vector<char> vc;
typedef pair<ll,ll> pll;
ll max(ll x,ll y){
if(x>y)return x;
else return y;
}
ll min(ll x,ll y){
  return x+y-max(x,y);
}


int main() {
  int a,b,c;
  cin >> a >> b >> c;
  if(a*c<=b){cout << c << endl;return 0;}
  cout << b/a << endl;
}


Measured memory_bytes: 256
'use strict'

const main = (input) => {
    const Ns = input.split('\n')[0].split('')
    if((Ns[0] === Ns[1] && Ns[1] === Ns[2]) || (Ns[1] === Ns[2] && Ns[2] === Ns[3])){
        console.log('Yes')
    }else{
        console.log('No')
    }
}

main(require('fs').readFileSync('/dev/stdin', 'utf-8'))

Measured memory_bytes: 9420
#include<bits/stdc++.h>
using namespace std;
#define MOD 1000000007
typedef long long int ll;

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int h,w,i,j;
    cin>>h>>w;
    char a[h][w];
    ll ways[h][w];
    for(i=0;i<h;++i)
    {
        for(j=0;j<w;++j) 
        ways[i][j] = 1;
    }
    ways[0][0] = 1;
    for(i=0;i<h;++i)
    {
        for(j=0;j<w;++j)
        {
            cin>>a[i][j];   
            if(a[i][j]=='#')
                ways[i][j] = 0;
        }
    }
    for(i=1;i<h;++i)
        if(ways[i][0]!=0)
        ways[i][0] = ways[i-1][0];
     for(i=1;i<w;++i)
        if(ways[0][i]!=0)
        ways[0][i] = ways[0][i-1];
    for(i=1;i<h;++i)
    {
        for(j=1;j<w;++j)
        {
            if(ways[i][j]!=0)
                ways[i][j] = (ways[i-1][j] + ways[i][j-1])%MOD;
        }
    }
    cout<<ways[h-1][w-1];
}

Measured memory_bytes: 9088
#include <bits/stdc++.h>
using namespace std;
int main(){
    long long int n;
    cin>>n;
    vector<long long int> sieve(n+1);
    for(long long int i=1;i<=n;i++){
        for(long long int j=i;j<=n;j+=i){
            sieve[j]++;
        }
    }
    long long tot=0;
    for(long long int i=1;i<=n;i++){
        tot+=(sieve[i]*i);
    }
    cout<<tot;
    return 0;
}


Measured memory_bytes: 81404
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(int (i) = 0; (i) < (n); (i)++)
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }

const int mod = 998244353;

int main() {
    int n, maxi = 0;
    cin >> n;
    vector<ll> d(101010, 0LL);
    rep(i,n){
        int di;
        cin >> di;
        if((i == 0) != (di == 0)){
            cout << 0 << endl;
            return 0;
        }
        d[di]++;
        if(di > maxi) maxi = di;
    }

    ll ans = 1LL;
    for(int i = 0; i < maxi; i++){
        ll prod = 1;
        rep(j, d[i+1]){
            prod *= d[i];
            prod %= mod;
        }
        ans *= prod;
        ans %= mod;
    }
    cout << ans << endl;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
string ALPHABET = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";

int main() {
    int n;
    cin >> n;
    string s;
    cin >> s;
    for(int i = 0;i < s.size();i++){
        auto tmp = s[i];
        for(int j = 0;j < n;j++){
            if(tmp == 'Z'){
                tmp = 'A';
            }else{
                tmp = (char)(tmp + 1);
            }
        }
        s[i] = tmp;
    }
    cout << s << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define vi vector<int>
#define vvi vector<vi>
#define pb push_back
#define P pair<int,int>
#define PP pair<P,int>
#define fi first
#define se second
#define INF 1e9
#define MOD 1000000007
#define REP(i,n) for(int i=0;i<n;i++)
#define REPR(i,n) for(int i=n;i>=0;i--)
#define FOR(i,m,n) for(int i=m;i<n;i++)
#define all(x) (x).begin(),(x).end()
int main(){
    int n;
    cin>>n;
    vector<vector<int> > g(n);
    REP(i,n){
        int a,b;
        cin>>a>>b;
        a--;
        REP(i,b){
            int t;
            cin>>t;
            t--;
            g[a].pb(t);
        }
    }
    vector<int> d(n,INF);
    queue<P> que;
    que.push(P(0,0));
    while(que.size()){
        P p=que.front();que.pop();
        if(p.se>=d[p.fi])continue;
        d[p.fi]=p.se;
        REP(i,g[p.fi].size()){
            que.push(P(g[p.fi][i],p.se+1));
        }
    }
    REP(i,n){
        cout<<i+1<<" ";
        if(d[i]==INF){
            cout<<-1<<endl;
        }else{
            cout<<d[i]<<endl;
        }
    }
    return 0;
}

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

int main() {
	int n;
	cin >> n;
	vector<vector<bool>> f(n, vector<bool>(10));
	vector<vector<int>> p(n, vector<int>(11));
	rep(i, n) rep(j, 10){
		int tmp;
		cin >> tmp;
		f[i][j] = !!tmp;
	}
	rep(i, n) rep(j, 11) cin >> p[i][j];
	int max = -1001001001;
	for(int joisino = 1; joisino < (1 << 10); joisino++){
		int profit = 0;
		for(int shop_i = 0; shop_i < n; shop_i++){
			int cnt_same = 0;
			for(int t = 0; t < 10; t++){
				bool joisino_t = joisino & (1 << t);
				if(joisino_t == 1 && f[shop_i][t] == 1) cnt_same++;
			}
			profit += p[shop_i][cnt_same];
		}
		if(max < profit) max = profit;
	}
	cout << max << endl;
	
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define F first
#define S second
#define pb push_back
#define mp make_pair
#define mod 1000000007
#define vlli vector<ll>
#define vi vector<int>
#define vs vector<string>
#define vplli vector< pair< ll,ll> >
#define plli pair< ll,ll >
#define vps vector< pair< string, string> >
#define vpi vector< pair< int, int> >
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define fast ios::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define forn(i,a,n) for(ll i=a;i<n;i++)
#define forr(i,n,a) for(ll i=n-1;i>=a;i--)
#define scan(arr,a,n) for(ll i=(a);i<(n);i++)cin>>(arr)[i];
#define print(arr,a,n) for(ll i=(a);i<(n);i++)cout<<(arr)[i]<<" ";

const ll inf = 1e18;

ll add(ll x, ll y) {ll res = x + y; return (res >= mod ? res - mod : res);}
ll mul(ll x, ll y) {ll res = x * y; return (res >= mod ? res % mod : res);}
ll sub(ll x, ll y) {ll res = x - y; return (res < 0 ? res + mod : res);}
ll power(ll x, ll y) {ll res = 1; x %= mod; while (y) {if (y & 1)res = mul(res, x); y >>= 1; x = mul(x, x);} return res;}
ll mod_inv(ll x) {return power(x, mod - 2);}


int main(){
	fast;
    #ifndef ONLINE_JUDGE
    freopen("input1.txt","r",stdin);
    freopen("output1.txt","w",stdout);
    #endif
	string s, ss = "";
	cin>>s;
	forn(i, 0, s.size()){
		ss+=s[0];
	}
	if(ss>=s){
		cout<<ss<<endl;
	} else {
		char c = s[0]+1;
		cout<<c<<c<<c<<endl;
	}
}

Measured memory_bytes: 3652
#include <iostream>

using namespace std;

int main()
{
  int n,a[3],i;
  cin >> n;
  for(i=0;i<3;i++)
  {
   a[i]=n%10;
   n=n/10;
  }
  if(a[0]==7 || a[1]==7 || a[2]==7) cout << "Yes" << endl;
  else  cout << "No" << endl;
  return 0;
}
  



Measured memory_bytes: 3628
#include<algorithm>
#include<bitset>
#include<iostream>
#include<iomanip>
#include<set>
#include<string>
#include<math.h>
#include<string>
using namespace std;

class zahyo{
	public:
	int x;
	int y;
	zahyo(){
		x=0;
		y=0;
	}
	zahyo(int x_,int y_){
		x=x_;
		y=y_;
	}
	void print(){
		cout<<x<<" "<<y;
	}
	zahyo operator+(zahyo add){
		add.x=this->x+add.x;
		add.y=this->y+add.y;
		return add;
	}
	zahyo operator-(zahyo add){
		add.x=this->x-add.x;
		add.y=this->y-add.y;
		return add;
	}
	bool operator==(const zahyo add) const{
		if(add.x==this->x and add.y==this->y){return true;}
		else{return false;}
	}
	bool operator!=(const zahyo add) const{
		if(add.x==this->x or add.y==this->y){return false;}
		else{return true;}
	}
	bool operator<(const zahyo add) const{
		if(this->x<add.x){return true;}
		else if(this->x==add.x and this->y<add.y){return true;}
		else{return false;}
	}
	bool operator>(const zahyo add) const{
		if(this->x>add.x){return true;}
		else if(this->x==add.x and this->y>add.y){return true;}
		else{return false;}
	}
	void input(){
		cin>>x>>y;
	}
};


int main(){
	int board[6][6];
	int h,w,k;
	cin>>h>>w>>k;
	for(int i=0;i<h;i++){
		for(int j=0;j<w;j++){
			char temp;
			cin>>temp;
			if(temp=='#'){board[i][j]=1;}
			else{board[i][j]=0;}
		}
	}
	int ans=0;
	for(int i=0;i<(1<<h);i++){
		for(int j=0;j<(1<<w);j++){
			int temp=0;
			for(int k=0;k<h;k++){
				for(int l=0;l<w;l++){
					if((i&(1<<k))!=0 and (j&(1<<l))!=0){
						temp+=board[k][l];
					}
				}
			}
			if(temp==k){ans++;}
		}
	}
	cout<<ans<<endl;
}


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

int main()
{
  string str;
  string::iterator p;

  getline(cin, str);

  for (p = str.begin(); p != str.end() ; p++) {
    if (isalpha(*p))
      if (islower(*p)) cout << (char)toupper(*p);
      else cout << (char)tolower(*p);
    else
      cout << *p;
  }
  cout << endl;

  return 0;
}



Measured memory_bytes: 3204
#include <iostream>
#include <math.h>
#include <string>
#include <string.h>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <stdlib.h>
#include <deque>  
#include <iomanip>

using namespace std;

#define INF 1e9
#define MOD 1e9 + 7
#define rep(i, n) for(int i = 0; i < n; i++)
#define loop(i, a, n) for(int i = a; i < n; i++)
#define all(in) in.begin(), in.end()
int main(){
    int n, w;
    while(true){
        cin >> n >> w;
        if(n == 0 && w == 0) break;
        vector<int> v(n);
        rep(i, n) cin >> v[i];
        int max_v = 0, K;
        rep(i, n) max_v = max(max_v, v[i]);
        map<int, int> interval;
        for(int i = 0; i < n; i++){
            for(int k = 0; k <= 120; k++){
                if(k * w <= v[i] && v[i] < (k + 1) * w){
                    if(max_v == v[i]) K = k;
                    interval[k]++;
                }
            }
        }
        double ans = 0;
        int h = 0;
        for(auto v: interval){
            int p = v.first, q = v.second;
            h = max(h, q);
        }
        for(int i = K; i >= 0; i--){
            ans += ((double)i/K) *( (double)interval[K - i]/h);
            //cout << ans << " " << interval[K - i] << endl;
        }
        ans += 0.01;
       printf("%.17lf\n", ans); 
    }
    return 0;
}


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

bool check(string S){
  if(S[0]!='A') return false;
  int C=0;
  for (int i = 2 ; i < S.length()-1; i++) {
    if(S[i]=='C'){
      C++;
    }
  }
  if(C!=1) return false;
  int upper=0;
  for (int i = 0; i < S.length(); i++) {
    if(S[i]>='A'&&S[i]<='Z'){
      upper++;
    }
  }
  if(upper!=2) return false;
  return true;
}

int main(){
  string S;
  cin >> S;
  if(check(S)){
    cout << "AC" << endl;
  } else {
    cout << "WA" << endl;
  }
}


Measured memory_bytes: 3632
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, tan, asin, acos, atan, radians, degrees, log2, gcd
from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left, insort, insort_left
from heapq import heappush, heappop
from functools import reduce, lru_cache
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def TUPLE(): return tuple(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7 
#mod = 998244353
from decimal import *
#import numpy as np
#decimal.getcontext().prec = 10

N = INT()
P = [INT() for _ in range(N)]

dp = [0]*(N+1)

for p in P:
	dp[p] = dp[p-1] + 1

print(N-max(dp))

Measured memory_bytes: 26344
#include <stdio.h>
int array[100][100];
int prim(int num);
int main(){
  int i,j,num;
  scanf("%d",&num);
  for(i=0;i<num;i++){
    for(j=0;j<num;j++){
      scanf("%d",&array[i][j]);
      if(array[i][j]==-1) array[i][j]=2001;
    }
  }
  printf("%d\n",prim(num));  /*output*/
  return 0;
}

int prim(int num){
  int val,min,i,j,sum=0;
  int weight[100],parent[100],col[100];
  for(i=0;i<num;i++){
    weight[i]=2001;
    parent[i]=-1;
    col[i]=0;
  }
  weight[0]=0;
  while(1){
    min=2001;
    for(i=0;i<num;i++){
      if(col[i]!=2 && weight[i]<min){
	min=weight[i];
	val=i;
      }
    }
    if(min==2001) break;
    col[val]=2;
    for(j=0;j<num;j++){
      if(col[j]!=2 && array[val][j]!=2001){
	if(array[val][j]<weight[j]){
	  weight[j]=array[val][j];
	  parent[j]=val;
	  col[j]=1;
	}
      }
    }
  }
  for(i=0;i<num;i++){
    if(parent[i]!=-1)sum+=array[i][parent[i]];
  }
  return sum;
}

		     



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

int main(void){
	int n,a[100],j;
	cin >> n;
	for (int i=0;i<n;i++) cin >> a[i];
	for (int i=1;i<=n;i++){
		for (int k=0;k<n-1;k++) cout << a[k] << " ";
		cout << a[n-1]<< endl;
		int v = a[i];
		j = i -1;
		while (j >= 0 && a[j] > v){
			a[j+1] = a[j];
			j--;
		}
		a[j+1] = v;
	}
}

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

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

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

template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b;return true;}return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b;return true;}return false;}
template<class T> void debug(T v){rep(i,v.size()) cout<<v[i]<<" ";cout<<endl;}
const ll dx[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll dy[8] = {0, 1, 1, 1, 0, -1, -1, -1};
//以降 cin の入力元が 'input.txt' になる
//std::ifstream in("input.txt");
//std::cin.rdbuf(in.rdbuf());

signed main()
{   
    gearup;
    ll n; cin >> n;
    vl a(n+1);
    rep1(i,n+1)for(int j=i;j<=n;j+=i)a[j]++;
    ll res = 0;
    rep1(i,n+1)res += ll(i)*a[i];
    out(res);
}

Measured memory_bytes: 81340
#include <algorithm>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <iostream>
#include <sstream>
#include <functional>
#include <map>
#include <string>
#include <cstring>
#include <vector>
#include <queue>
#include <stack>
#include <deque>
#include <set>
#include <list>
#include <numeric>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll,ll> P;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const ll INF = 1LL<<29;
const ll mod = 1e9+7;
#define rep(i,n) for(int (i)=0;(i)<(ll)(n);++(i))
#define repd(i,n,d) for(ll (i)=0;(i)<(ll)(n);(i)+=(d))
#define all(v) (v).begin(), (v).end()
#define pb(x) push_back(x)
#define mp(x,y) make_pair((x),(y))
#define mset(m,v) memset((m),(v),sizeof(m))
#define chmin(X,Y) ((X)>(Y)?X=(Y),true:false)
#define chmax(X,Y) ((X)<(Y)?X=(Y),true:false)
#define fst first
#define snd second
#define UNIQUE(x) (x).erase(unique(all(x)),(x).end())
template<class T> ostream &operator<<(ostream &os, const vector<T> &v){int n=v.size();rep(i,n)os<<v[i]<<(i==n-1?"":" ");return os;}
#define N 200010
ll d[N];
int main(){
	ll n, m;
	cin>>n>>m;
	vector<int> a(n);
	rep(i, n) cin>>a[i];
	ll res = 0;
	rep(i, n-1){
		int x = a[i], y = a[i+1];
		if(y<x) y += m;
		res += y-x;
		if(y-x<=1) continue;
		d[x+2] += 1;
		d[y+1] += -(y-x);
		d[y+2] += y-x-1;
	}
	rep(i, 2*m) d[i+1] += d[i];
	rep(i, 2*m) d[i+1] += d[i];
	ll mx = 0;
	rep(i, m) mx = max(mx, d[i+1]+d[i+1+m]);
	cout<<res-mx<<endl;
	return 0;
}

Measured memory_bytes: 2176
n = int(input())
s = input()

cnt = 0
for i in range(10):
    p1 = s.find(str(i))
    if p1 == -1:
        continue
    
    for j in range(10):
        p2 = s.find(str(j),p1+1)
        if p2 == -1:
            continue

        for k in range(10):
            p3 = s.find(str(k),p2+1)
            if p3 != -1:
                cnt += 1

print(cnt)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
int main(void){
    long N,A,B;
    cin>>N;
    vector<pair<long,long>> task(N); 
    for(long i=0;i<N;i++){
        cin>>A>>B;
        task.at(i).first=B;
        task.at(i).second=A;
    }
    sort(task.begin(),task.end());
    long tasktime=0;
    for(long i=0;i<N;i++){
        tasktime +=task.at(i).second;
        if(tasktime>task.at(i).first){
            cout<<"No"<<endl;
            return 0;
        }
    }
    cout<<"Yes"<<endl;
    return 0;
}


Measured memory_bytes: 3328
//#include <bits/stdc++.h>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <map>
#include <stack>
#include <bitset>
#include <array>
#include <set>
#include <string>

#include <iterator>
#include <algorithm>
#include <numeric>

#include <ios>
#include <sstream>
#include <iostream>
#include <fstream>

#include <climits>
#include <cmath>

using namespace std;

#define EPS (1e-7)
#define MOD ((int)1e9+7)
#define PI (atan(1.0)*4)

using ll=long long;
using vi=vector<int>;
using vll=vector<ll>;
using vvi=vector<vi>;
using vs=vector<string>;
using pii=pair<int,int>;
using pll=pair<ll,ll>;

void OUT(bool isTrue, string t="YES", string f="NO"){
    cout<<(isTrue?t:f)<<endl;
}
void out(bool isTrue, string t="Yes", string f="No"){
    cout<<(isTrue?t:f)<<endl;
}

template <typename T>
string printItr(T b, T e, string delim=" ")
{
    stringstream ss;
    ostream_iterator<decltype(*b)> out_it(ss, delim.c_str());
    copy(b,e - 1, out_it);
    ss<<*(e-1);
    return ss.str();
}

void bulk(){}
template <class Head, class... Tail>
void bulk(Head& head, Tail&... tail){
    cin>>head;
    bulk(tail...);
}

ll inv_pow(ll x, ll n, ll mod) {
  ll res = 1;
  for(;n>0;n>>=1){
    if(n&1) res=res*x%mod;
    x=x*x%mod;
  }
  return res;
}

void factMod(ll x, ll n, ll mod, vll& v) {
    v.resize(n+1);
    v[0]=1;
    for(int i=1;i<=n;i++){
        v[i]=v[i-1]*(i%mod)%mod;
    }
}

void factInv(ll x, ll n, ll mod, vll& v){
    v.resize(n+1);
    v[x]=inv_pow(x,mod-2,mod);
    for(int i=n;i>=0;i--){
        v[i-1]=v[i]*(x%mod)%mod;
    }
}

#define rep(i,n) for(int i=0;i<n;i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define range(i,m,n) for(int i=m; i<n;i++)
#define each(i,n) for(auto i:n)
#define all(i) i.begin(),i.end()
#define cint(...) int __VA_ARGS__;bulk(__VA_ARGS__);


int main(void){
    string s;
    cin>>s;
    out(s.find("AC")!=-1);
}

Measured memory_bytes: 256
#include<stdio.h>
int main(){
	int i,a,u;
	
	for(i=1;i<10;i++){
		for(a=1;a<10;a++){
			printf("%dx%d=%d\n",i,a,a*i);
		}
		
		
	}
	
	
	
	
	return 0;
	
	
}

Measured memory_bytes: 524
N = int(input())
check = [False]*8
over = 0
a_s = list(map(int, input().split()))
for a in a_s:
  if 1 <=a<=399:
    check[0] = True
  elif 400<=a<=799:
    check[1]=True
  elif 800<=a<=1119:
    check[2]=True
  elif 1200<=a<=1599:
    check[3]=True
  elif 1600<=a<=1999:
    check[4]=True
  elif 2000<=a<=2399:
    check[5]=True
  elif 2400<=a<=2799:
    check[6]=True
  elif 2800<=a<=3199:
    check[7]=True
  if a >= 3200:
    over += 1
mn = check.count(True)

if mn == 0:
  print(1, mn+over)
else:
  print(mn, mn+over)

Measured memory_bytes: 3064
#include <iostream>
#include <vector>

int main()
{
	int n;
	long long k;
	std::cin >> n >> k;
	std::vector<int> a(n);
	for (auto &e : a) {
		std::cin >> e;
		e -= 1;
	}
	
	std::vector<int> seen(n, -1);
	int hare = 0;
	for (int i = 0; i < k; i++) {
		if (seen[hare] >= 0) {
			k -= i;
			k %= i - seen[hare];
			for (int j = 0; j < k; j++) {
				hare = a[hare];
			}
			break;
		}
		seen[hare] = i;
		hare = a[hare];
	}
	
	std::cout << hare + 1 << std::endl;
	
	return 0;
}


Measured memory_bytes: 4396