akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;

using i64 = int_fast64_t;
using f64 = double;

constexpr i64 INF = INT_FAST64_MAX / 2;
constexpr f64 EPS = DBL_EPSILON;

void solve() {
    string s;
    cin >> s;
    i64 n = s.size();

    map<i64, i64> cnt;
    cnt[0] = 1;
    i64 d = 1, x = 0;
    for (i64 i = n - 1; i >= 0; i--) {
        x = (x + (s[i] - '0') * d) % 2019;
        cnt[x]++;
        d = d * 10 % 2019;
    }

    i64 ans = 0;
    for (auto& e : cnt) ans += e.second * (e.second - 1) / 2;
    cout << ans << endl;
}

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


Measured memory_bytes: 3716
//
//  main.cpp
//  ProCon
//
//  Created by hashimotoryoma on 2017/08/20.
//  Copyright © 2017年 hashimotoryoma. All rights reserved.
//

#include <iostream>
#include <fstream>
#include <algorithm>
#include <string>
#include <map>
#include <queue>
#include <vector>

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

using namespace std;

typedef long long ll;



int main() {
    // insert code here...    return 0;
    //////
    // input from txt
    /*
     std::ifstream in("input.txt");
     std::cin.rdbuf(in.rdbuf());
     std::ofstream out("output.txt");
     std::cout.rdbuf(out.rdbuf());
     ////
     */
    string A,s,C;
    cin >> A >> s >> C;
    cout << A[0] << s[0] << C[0] << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)
#define INF 999999999
using namespace std;
typedef pair<int, int> P;
typedef pair<llong, llong> LP;
typedef pair<int, P> PP;
typedef pair<llong, LP> LPP;

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

int main() {
    int x,a,b;
    cin>>x>>a>>b;
    if(abs(x-a)>abs(x-b)) {cout<<"B"<<endl;}
    else cout<<"A"<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ft first
#define sd second
#define mp make_pair
#define MAX 100010
#define pub push_back
#define pob pop_back
#define mt make_tuple
#define len length
#define dbgn(x) cerr<<#x<<": "<<x<<'\n'
#define dbg(x) cerr<<#x<<": "<<x<<' '
#define FOR(i,lbd,rbd) for((i)=(lbd);(i)<(rbd);++(i))
#define setZ(A) memset(A,0,sizeof A)
using namespace std;
typedef long long int lli;
typedef pair<lli,lli> pll;
typedef pair<int,int> pii;
typedef map<lli,lli> mll;
typedef map<int,int> mii;
typedef priority_queue<int,vector<int>,greater<int> > pqi_min;
template<class T, class Y> 
T pow(T a,Y p) {
	if (p==0) return 1;
	if (p&1) {
		return (a*pow(a,p-1));
	}
	T y = pow(a,p>>1);
	return (y*y);
}
//int+string
//cin.ignore();

const int M=1e9+7;

void solve() {
	int n;
	cin>>n;
	if  (n%10==9 || (n/10)%10==9) cout<<"Yes\n";
	else cout<<"No\n";
}

int main(int argc, char const *argv[])
{
	ios::sync_with_stdio(false);
	solve();
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<cmath>
#define pb push_back
#define ld long double
#define mp make_pair
#define vl vector<ll> 
#define vd vector<double>
#define vld vector<long double>
#define ll long long int
#define pl pair<ll, ll>
#define all(a) a.begin(), a.end()
#define forr(i, n) for(ll i=0; i<n; i++) 
#define forr1(i, n) for(ll i=1; i<=n; i++)
using namespace std;
const ld PI =3.1415926535897923846;
const ll MOD = 1000000007;
const ll N=998244353;
ll power(ll x,ll n){ll res=1;while(n>0){if(n&1) res=res*x%MOD;x=x*x%MOD;n>>=1;}return res;}
ll modinverse(ll a){return power(a, MOD-2);}
void solve()
{
    string str;
    cin>>str;
    ll n=str.length();
    if(str[n-1]=='s')
    {
    	str=str+"es";
    	cout<<str;
    }
    else
    {
    	cout<<str<<'s'<<endl;
    }
}
int main()
{
	#ifndef ONLINE_JUDGE
        // for getting input from input.txt
        freopen("input.txt", "r", stdin);
        // for writing output to output.txt
        freopen("output.txt", "w", stdout);
    #endif
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll test=1;
    //cin>>test;
    while(test--)
    {
        solve();
    }
    cerr << "Time : " << 1000 * ((double)clock()) / (double)CLOCKS_PER_SEC << "ms\n";
}

Measured memory_bytes: 3840
#include <cstdio>

using namespace std;

int main(){
	char find[11];
	char tar[11];
	int n;
	scanf("%s",find);
	scanf("%d",&n);
	
	bool f;
	int ans = 0;
	for(int i=0;i<n;i++){
		scanf("%s",tar);
		for(int j=0;j<20;j++){
			f = false;
			if(tar[j % 10] == find[0]){
				for(int k=0;k<11;k++){
					if(find[k] == '\0'){
						f = true;
						ans += 1;
						break;
					}
					if(tar[(j + k) % 10] != find[k]){
						break;
					}
				}
			}
			if(f){break;}
		}
	}
	printf("%d\n",ans);
}

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

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

    for (int i = 0; i < N; ++i) {
        cin >> A;
        if (A % 2 == 0) {
            if (A % 3 != 0 && A % 5 != 0) {
                goto error;
            }
        }
    }
    cout << "APPROVED" << endl;
    return 0;
error:
    cout << "DENIED" << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ii = pair<int, int>;
#ifdef XVENOM
	#define errp(...) fprintf(stderr, __VA_ARGS__)
	#define dbg(...) errp("[%s]: ", #__VA_ARGS__), dbg_str(__VA_ARGS__)
#else
	#define errp(...)
	#define dbg(...)
#endif
template <typename U, typename V> string to_string (pair<U, V>);
string to_string (const string& e_) { return "\"" + e_ + "\""; }
string to_string (char e_) { return "\'" + string(1, e_) + "\'"; }
string to_string (bool e_) { return e_ ? "true" : "false"; }
template <typename T> string to_string (T e_) {
	string s_ = "[ ";
	for (const auto& x_ : e_) s_ += to_string(x_) + " ";
	return s_ + "]";
}
template <typename U, typename V> string to_string (pair<U, V> e_) {
	return "(" + to_string(e_.first) + ", " + to_string(e_.second) + ")";
}
void dbg_str () { errp(" \n"); }
template <typename U, typename... V> void dbg_str (U u, V... v) {
	errp(" %s", to_string(u).c_str()); dbg_str(v...);
}
/* --- */
const int N = 100;
double a[N];
int main () {
	ios_base::sync_with_stdio(0); cin.tie(0);
	/* --- */
	int n;
	cin >> n;
	for(int i = 0; i < n; i++) cin >> a[i];

	sort(a,a+n);
	double ans = (a[0] + a[1])/2.0 ;

	for(int i = 2; i < n; i++) ans = ((ans + a[i])/2.0);

	cout << fixed << setprecision(5) << ans ;
}

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

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

typedef int _loop_int;
#define REP(i,n) for(_loop_int i=0;i<(_loop_int)(n);++i)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a);i<(_loop_int)(b);++i)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1;i>=(_loop_int)(a);--i)

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

#define CHMIN(a,b) a=min((a),(b))
#define CHMAX(a,b) a=max((a),(b))

// mod
const ll MOD = 1000000007ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

// floating
typedef double Real;
const Real EPS = 1e-11;
#define EQ0(x) (abs(x)<EPS)
#define EQ(a,b) (abs(a-b)<EPS)
typedef complex<Real> P;

ll n,x;

int main(){
  cin>>n>>x;
  // ll ans = 0;
  // while(n!=x){
  //   ll st = n/x;
  //   ans += (st+1)*n - st*(st-1)/2*x;
  //   n %= x;
  //   swap(n,x);
  // }
  // cout<<ans<<endl;
  ll k = x;
  ll h = n-x;
  ll ans = n;
  while(true){
    ll c = h/k;
    // DEBUG(ans);
    // DEBUG(h);
    // DEBUG(k);
    // DEBUG(c);
    if(h%k==0){
      // goal
      ans += k*(2*c-1);
      break;
    }else{
      // step
      ans += c*2*k;
      ll rest = h - c*k;
      h = k;
      k = rest;
    }
  }
  printf("%lld\n",ans);
  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>

int main(void)

{
    
    double r,m,n;

    scanf("%lf",&r);
    
    m = r * r * 3.141592653589;
    n = (r + r) * 3.141592653589;

    printf("%lf %lf",m,n);

    return 0;
}

Measured memory_bytes: 648
#include <bits/stdc++.h>
#include <queue>
using namespace std;
int main(){
	int N, M; cin >> N >> M; 
	priority_queue<long long, vector<long long>> que; 
	for(int i = 0; i < N; i++){
		long long int a; cin >> a; 
		que.push(a); 
	}
	long long int ans = 0; 
	for(int i = 0; i < M; i++){
		long long int p = que.top(); 
		que.pop(); 
		que.push(p / 2); 
	}
	while(que.size()){
		long long int p = que.top(); 
		que.pop(); ans += p; 
	}
	cout << ans << endl; 
}

Measured memory_bytes: 1400
def slove():
    import sys
    input = sys.stdin.readline
    n, l = list(map(int, input().rstrip('\n').split()))
    ls = []
    t = 0
    for i in range(n):
        ls.append([abs(l + i), l + i])
        t += (l + i)
    ls.sort()
    print(t - ls[0][1])


if __name__ == '__main__':
    slove()


Measured memory_bytes: 38384
//#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#define int long long
#define x first
#define y second
#define pb push_back
#define inf 10000000000000000
#define N 1000000007
#define speed ios_base::sync_with_stdio(0);cin.tie(0);
using namespace std;
template<class L,class R> ostream& operator<<(ostream& cout,pair<L, R> P)
{return cout<<'('<<P.x<<','<< P.y<<')';}
template<class T> ostream& operator<<(ostream& cout,vector<T> V)
{cout<<"[ ";for(auto v:V)cout<<v<<' ';return cout<<']';}


signed main()
{
	speed
	string str;cin>>str;
	int n=str.length();
	for (int i = 0; i < n; ++i)
	{
		cout<<'x';
	}
}

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

int main() {
// 	cout<<"GfG!";
int a,b,c;
cin >> a >> b >>c;
if((a==b &&c!=b)|| (a==c && b!=c) || (b==c && b!=a))
cout<< "Yes";

else
cout << "No";

	return 0;
}

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

#define rep(i, a) for (int i = 0; i < (a); ++i)
#define REP(i, a, b) for (int i = (a); i < (b); ++i)

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

void Main() {
  string s;
  cin >> s;
  int n = s.size();
  vector<int> an(n + 1, 0);
  {
    int count = 0;
    rep(i, n) {
      if (s[i] == '<')
        count++;
      else
        count = 0;
      an[i + 1] = max(an[i + 1], count);
    }
  }
  {
    int count = 0;
    for (int i = n - 1; i >= 0; --i) {
      if (s[i] == '>')
        count++;
      else
        count = 0;
      an[i] = max(an[i], count);
    }
  }
  ll ans = 0;
  rep(i, n + 1) ans += an[i];
  cout << ans << endl;
}

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


Measured memory_bytes: 2844
#include<bits/stdc++.h>
                    #include<chrono>
                     
                    using namespace std;
                    using namespace std::chrono;
                    typedef long long ll;
                    typedef vector<int> vi;
                    typedef pair<int,int> pi;
                    #define F first
                    #define S second
                    #define PB push_back
                    #define EB emplace_back
                    #define MP make_pair
                    #define REP(i,a,b) for(i=a;i<=b;i++)
                    #define RAP(i,a,b) for(i=a;i>=b;i--)
                    const ll mod=1000000007;
                	const int MX=0x3f3f3f;
             
                    int main(){
                    	ios::sync_with_stdio(0);
                    	cin.tie(0);
                        ll n,a,b;
                        cin>>n>>a>>b;
                        if((b-a-1)&1) cout<<(b-a)/2<<"\n";
                        else{
                            cout<<(b-a-1)/2+min(a,n-b+1);
                        }
                    	return 0;
                    }

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

typedef long long ll;


int main(){
	
	ll n,m,i;
	cin>>n>>m;
	
	char a[n][m];
	for(i=0;i<n;i++){
		for(int j=0;j<m;j++){
			cin>>a[i][j];
		}
	}
	vector <int > r,c;
	for(i=0;i<n;i++){
		ll w=1;
		for(int j=0;j<m;j++){
			if(a[i][j]=='#'){
				w=0;
				break;
			}
		}
		if(w){
			r.push_back(i);
		}
	}
	
	for(int j=0;j<m;j++){
		ll w=1;
		for(i=0;i<n;i++){
			if(a[i][j]=='#'){
				w=0;
				break;
			}
		}
		if(w){
			c.push_back(j);
		}
	}
	ll check[n][m]={};
	
	for(i=0;i<r.size();i++){
		for(int j=0;j<m;j++){
			check[r[i]][j]=1;
		}
	}
	for(i=0;i<n;i++){
		for(int j=0;j<c.size();j++){
			check[i][c[j]]=1;
		}
	}
	
	for(i=0;i<n;i++){
		int flag=1;
		for(int j=0;j<m;j++){
			if(!check[i][j]){
				cout<<a[i][j];
				flag=0;
			}
		}
	//	if(flag)
			cout<<endl;
	}
	
}



Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    string s;
    cin >> s;
    
    int size = s.size();
    for (int i = 0; i < size; i++) {
        s.pop_back();
        int ss = s.size();
        if (s.substr(0, ss/2) == s.substr(ss/2, ss/2)) {
            cout << ss - 1 << endl;
            return 0;
        }
    }
    
    return 0;
}

Measured memory_bytes: 256
class UnionFind:
    def __init__(self, size):
        self.parent = [-1 for i in range(size)]#非負なら親ノード，負ならグループの要素数

    def root(self, x):
        if self.parent[x] < 0:
            return x
        else:
            self.parent[x] = self.root(self.parent[x]) #xをxの根に直接つなぐ
            return self.parent[x]

    def union(self, x, y):
        x = self.root(x)
        y = self.root(y)
        if x == y:
            return False

        if self.parent[x] > self.parent[y]: #xの要素数がyの要素数より「小さい」とき
            x,y=y,x
        self.parent[x] += self.parent[y] #xの要素数を更新
        self.parent[y] = x #yをxにつなぐ
        return True

    def same(self, x, y):
        return self.root(x) == self.root(y)



n,m = list(map(int,input().split()))
p = list(map(lambda x: int(x)-1,input().split()))

uf = UnionFind(n)
for i in range(m):
    x,y=list(map(int,input().split()))
    uf.union(x-1,y-1)

ans = 0
for i in range(n):
    if uf.same(i,p[i]):
        ans += 1

print(ans)

Measured memory_bytes: 13812
import java.util.*;
    public class Main {
     
    	public static void main(String[] args) {
    			
    		Scanner scan=new Scanner(System.in);
    		
    		int a=Integer.parseInt(scan.next());
    		int b=Integer.parseInt(scan.next());
    		int c=Integer.parseInt(scan.next());
    		
    		if (a==b) {
    			System.out.print(c);
    		}else if (a==c) {
    			System.out.print(b);
    		}else if (c==b) {
    			System.out.print(a);
    		}
    		
    		
    	
  
    				
 
     
    }
    }

Measured memory_bytes: 21844
#include <iostream>
#include <string>
#include <vector>
#include <list>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <fstream>
#include <sstream>
#include <iomanip>
#define ll long long

using namespace std;

long long MOD = 1000000007;

int main(){
    int N;
    cin >> N;
    map<string, int> m;

    int max_=0;
    for(int i=0; i<N; i++){
        string S;
        cin >> S;
        if(m.count(S)){
            m[S]++;
        }else{
            m[S]=1;
        }
        max_=max(max_,m[S]);
    }

    for(auto it=m.begin(); it!=m.end(); it++){
        if(it->second == max_){
            cout << it->first << endl;
        }
    }
}

Measured memory_bytes: 25216
#include<iostream>
#include<algorithm>
#include<cstdio>

using namespace std;
int main()
{
  int n;
  for(;cin>>n,n;)
    {
      string map[n];
      int sum[n][n];
      for(int i=0;i<n;i++)
	{
	  cin>>map[i];
	  for(int j=0;j<n;j++)
	    {
	      int tmp=0;
	      if(j>0)
		tmp+=sum[i][j-1];
	      if(i>0)
		  tmp+=sum[i-1][j];
	      if(j>0&&i>0)
		tmp-=sum[i-1][j-1];
	      if(map[i][j]=='.')
		tmp++;
	      sum[i][j]=tmp;	      
	    }
	}
      /*      cout<<endl;
      for(int i=0;i<n;i++,cout<<endl)
	for(int j=0;j<n;j++)
	printf("%3d ",sum[i][j]);*/
      int ans=0;
      for(int i=0;i<n;i++)
	for(int j=0;j<n;j++)
	  for(int x=min(i,j);x>=ans;x--)
	    {
	      int tmp=sum[i][j];
	      if(i-x > 0)
		tmp-=sum[i-x-1][j];
	      if(j-x > 0)
		tmp-=sum[i][j-x-1];
	      if(i-x > 0 && j-x > 0)
		tmp+=sum[i-x-1][j-x-1];
	      if((x+1)*(x+1)==tmp)
		ans = max(x+1,ans);
	    }
      cout<<ans<<endl; 
    }
}

Measured memory_bytes: 6160
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <map>
#include <set>
using namespace std;
int l[100005];
struct node{
    long long l;
    long long r;
    bool operator<(const node & t)const{
        return r<t.r;
    }
};
node zzz[100005];
int dp[200005]={0};
map<long long,int>mm;
int getnum(long long num){
    return mm[num];
}
int seg[800005];
void _insert(int i,int l,int r,int indx,int num){
    if(l==r){
        seg[i]=num;
        return ;
    }
    int m = (l+r)/2;
    if(indx<=m)
        _insert(i<<1,l,m,indx,num);
    else
        _insert(i<<1|1,m+1,r,indx,num);
    seg[i]=max(seg[i<<1],seg[i<<1|1]);
}
int query(int i,int l,int r,int x,int y){
    if(l>=x&&r<=y)
        return seg[i];
    int m = (l+r)/2;
    int num =0 ;
    if(m>=x)
        num=max(num,query(i<<1,l,m,x,y));
    if(m<y)
        num=max(num,query(i<<1|1,m+1,r,x,y));
    return num;
}
int main()
{
    int n;
    cin >> n;
    int a,x;
    set<long long>vv;
    for(int i=0;i<n;i++){
        cin >>a >> x;
        vv.insert(a-x);
        vv.insert(a+x);
        zzz[i].l=a-x;
        zzz[i].r=a+x;
        //cout << a-x <<endl;
    }
    int cnt = 0 ;
    for(auto num:vv){
        mm[num]=++cnt;
        //cout << num <<  " "<< cnt <<  endl;
    }
    sort(zzz,zzz+n);
    for(int i=0;i<n;i++){
        int num;
        if(getnum(zzz[i].r)==1)
            num=0;
        else
            num = query(1,1,cnt,getnum(zzz[i].r),getnum(zzz[i].r));
        //cout << num <<endl;
        num = max(num,1+query(1,1,cnt,1,getnum(zzz[i].l)));
        _insert(1,1,cnt,getnum(zzz[i].r),num);
    }
    cout << query(1,1,cnt,1,cnt);
    return 0;
}


Measured memory_bytes: 29092
from sys import stdout
printn = lambda x: stdout.write(x)
inn = lambda : int(input())
inl   = lambda: list(map(int, input().split()))
inm   = lambda:      map(int, input().split())
DBG = True # and False
BIG = 999999999
R = 10**9 + 7

def ddprint(x):
  if DBG:
    print(x)

n,m = inm()
u0 = []
u1 = []
u2 = []
u3 = []
u4 = []
u5 = []
u6 = []
u7 = []
for i in range(n):
    x,y,z = inm()
    u0.append(x+y+z)
    u1.append(x-y+z)
    u2.append(x+y-z)
    u3.append(x-y-z)
    u4.append(-x+y+z)
    u5.append(-x-y+z)
    u6.append(-x+y-z)
    u7.append(-x-y-z)
u0.sort(reverse=True)
u1.sort(reverse=True)
u2.sort(reverse=True)
u3.sort(reverse=True)
u4.sort(reverse=True)
u5.sort(reverse=True)
u6.sort(reverse=True)
u7.sort(reverse=True)
s0 = sum(u0[0:m])
s1 = sum(u1[0:m])
s2 = sum(u2[0:m])
s3 = sum(u3[0:m])
s4 = sum(u4[0:m])
s5 = sum(u5[0:m])
s6 = sum(u6[0:m])
s7 = sum(u7[0:m])
print(max([s0,s1,s2,s3,s4,s5,s6,s7]))


Measured memory_bytes: 39024
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define REP(i, n) rep(i, 0, n)
#define repb(i, a, b) for(int i = a; i >= b; i--)
#define all(a) a.begin(), a.end()
#define int long long
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
using namespace std;
typedef pair<int, int> P;
const int mod = 1000000007;
const int INF = 1e12;

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int h;
    while(1){
        cin >> h;
        if(h == 0) break;
        int d[11][5];
        rep(i, 0, h){
            rep(j, 0, 5){
                cin >> d[i][j];
            }
        }
        int ans = 0;
        while(1){
            bool f = false;
            rep(i, 0, h){
                rep(j, 0, 3){
                    bool g = true;
                    rep(k, j, j + 3){
                        if(d[i][k] == -1 || d[i][k] != d[i][j]) g = false;
                    }
                    if(g){
                        int tmp = d[i][j];
                        rep(k, j, 5){
                            if(d[i][k] == tmp){
                                d[i][k] = -1; ans += tmp;
                            }else{
                                break;
                            }
                        }
                        f = true;
                        break;
                    }
                }
            }
            if(f == false) break;
            rep(j, 0, 5){
                repb(i, h - 1, 0){
                    if(d[i][j] != -1) continue;
                    repb(k, i - 1, 0){
                        if(d[k][j] != -1){
                            swap(d[k][j], d[i][j]);
                            break;
                        }
                    }
                }
            }
        }
        cout << ans << endl;
    }   
}


Measured memory_bytes: 3180
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <cctype>
#define len length()
#define sz size()
#define rng(i, a, b) for(int i = a; i < b; i++)
#define rep(i, n) rng(i, 0, n)
#define srt(v) sort(v.begin(), v.end())
#define rev(s) reverse(s.begin(), s.end())
#define vi(a, n) vector<int> a(n)
#define vs(a, n) vector<string> a(n)
#define vc(a, n) vector<char> a(n)
#define psb(a) push_back(a)
#define ppb pop_back()
#define erc(S, i) S.erase(S.begin() + i)
#define ers(S, i, j) S.erase(S.begin() + i, S.begin() + j)
#define sp(n) cout << setprecision(n) << fixed
#define fst(s) s.at(0)
#define lst(s) s.at(s.len - 1)
using namespace std;

int ndg(int x, int n){ //xのn番目の位の数
    return (x % int (pow(10, n))) / pow(10, n-1);
}

int sumi(int n){
    int ans=0;
    int i=0;
    while(pow(10,i) <= 10*n){
        ans += ndg(n,i);
        i++;
    }
    return ans;
}

int main(){
    int N;
    cin >> N;
    int ans = N;
    int A=1;
    int B=N-1;
    for(int i = 1; A <= B; i++){
        ans = min(ans, sumi(A) + sumi(B));
        A++;
        B--;
    }
    cout << ans << endl;
    return 0;
    
}

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

// ABC060C Sentou

int main() {
    ios::sync_with_stdio(false);
    int N, T, t;
    cin >> N >> T;
    int total = T;
    int prev_t = 0;
    for (int i = 0; i < N; ++i){
        cin >> t;
        if (prev_t + T < t){
            total += T;
        }else {
            total += t - prev_t;
        }
        prev_t = t;
    }
    cout << total << endl;
    return 0;
}

Measured memory_bytes: 256
l = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14,
     1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
print(l[int(input())-1])


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

#define REP(i, a, b) for (auto i = (a); i < (b); ++i)
using namespace std;
#define int long long

signed main() {
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);

	string s; cin >> s;
	int n = s.size(); ++n;
	int ans = 0, a[n];
	REP(i, 0, n) a[i] = 0;

	REP(i, 0, n - 1) if (s[i] == '<') a[i + 1] = a[i] + 1;
	for (int i = n - 2; i >= 0; --i) {
		if (s[i] == '>')
			a[i] = max(a[i], a[i + 1] + 1);
	}

	REP(i, 0, n) ans += a[i];
	cout << ans;
}

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

using namespace std;

int main(void) {
        int N;
        int a;
        scanf("%d", &N);

        int x[N] = {0};

        for(int i=0; i<N-1; i++) {
                scanf("%d", &a);
                x[a-1] += 1;
        }

        for(int i=0; i<N; i++) {
                printf("%d\n", x[i]);
        }

        return 0;
}


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

int main(){
    string str,o;
    cin >> str;
    int q,s,e;
    cin >> q;
    for(int i=0;i<q;i++){
        cin >> o >> s >> e;
         string s2=str.substr(s,e-s+1);
        if(o=="print") cout << s2 <<endl;
        else if(o=="reverse"){
           reverse(s2.begin(),s2.end());
           str=str.substr(0,s)+s2+str.substr(e+1);
        }
        else if(o=="replace"){
            string o2;
            cin >> o2;
            str.replace(s,o2.size(),o2);
            }
    }
    return 0;
}


Measured memory_bytes: 3196
while s=gets
	n=s.to_i
	break if n==0
	a=n;b=1
	r=0
	(2..1/0.0).each{|i|
		x=n-i*(i-1)/2
		break if x<i
		if x%i==0
			a=x/i
			b=i
		end
	}
	puts '%d %d'%[a,b]
end


Measured memory_bytes: 6892
from collections import defaultdict
N=int(input())
alist=list(map(int,input().split()))

dic_a=defaultdict(int)
for a in alist:
  dic_a[a]+=1
#print(dic_a)

max_answer=0
for v in list(dic_a):
  answer=dic_a[v-2]+dic_a[v-1]+dic_a[v]
  max_answer=max(answer,max_answer)

  answer=dic_a[v-1]+dic_a[v]+dic_a[v+1]
  max_answer=max(answer,max_answer)

  answer=dic_a[v]+dic_a[v+1]+dic_a[v+2]
  max_answer=max(answer,max_answer)
  
print(max_answer)

Measured memory_bytes: 19424
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define fr(i,j,k) for(int i=j;i<k;i++)
#define f(n) fr(i,0,n)
#define f1(n) fr(i,1,n+1)
#define ms(i) memset(i,-1,sizeof(i));
#define pb push_back
int main(){
	ios_base::sync_with_stdio(0);
	int a,b,t;
	cin >> a >> b >>t;
	cout<<b*(t/a)<<endl;
	
	
}

Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>
 
int isPrime(x){
  int i=3;
  if(x == 2) return 1;
 
  if(x < 2 || x % 2 == 0) return 0;
 
  while(i <= sqrt(x)){
    if(x % i == 0) return 0;
    i += 2;
  }
 
  return 1;
}
 
int main(){
  int x, n, i, count=0;
 
  scanf("%d", &n);
 
  for(i = 0; i < n; i++){
    scanf("%d", &x);
    if(isPrime(x)) count++;
  }
 
  printf("%d\n", count);
 
  return 0;
}

Measured memory_bytes: 596
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <map>
#include <memory>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#include <random>
#include <tuple>
#include <iomanip>
#include <cstring>

using namespace std;

typedef long long ll;
//typedef pair<int,int> Pint;
//typedef pair<ll, ll> P;
//typedef pair<ll, pair<ll, ll>> P;
//typedef tuple<int,int,int> T;
typedef vector<ll> vec;
typedef vector<vec> mat;
#define rep(i, n) for(ll i = 0; i < (n); i++)
#define revrep(i, n) for(ll i = (n-1); i >= 0; i--)
#define pb push_back
#define f first
#define s second
const ll INFL = 1LL << 60;//10^18 = 2^60
const int INF = 1 << 30;//10^9
//const ll MOD = 1e9 + 7;
//const ll MOD  = 998244353;
ll MOD;
vector<ll> dy = {0, 0, 1, -1, 1, 1, -1, -1, 0};
vector<ll> dx = {1, -1, 0, 0, 1, -1, 1, -1, 0};

ll max(ll a, ll b){return (a > b) ? a : b;}
ll min(ll a, ll b){return (a < b) ? a : b;}
ll pow_long(ll x, ll k){
  ll res = 1;
  while(k > 0){
    if(k % 2) res *= x;
    x *= x;
    k /= 2;
  }
  return res;
}
ll pow_mod(ll x, ll k){
  x %= MOD; x += MOD; x %= MOD;
  ll res = 1;
  while(k > 0){
    if(k % 2){
      res *= x; res %= MOD;
    }
    x *= x; x %= MOD;
    k /= 2;
  }
  return res;
}
ll inverse(ll x){return pow_mod(x, MOD - 2);};

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

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

//コンビネーション
const int MAXcomb = 5000;
ll fac[MAXcomb], finv[MAXcomb], inv[MAXcomb];
//facはn!,finvは1/n!
//invは逆元
void COMinit(){
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for(int i = 2; i < MAXcomb; i++){
        fac[i] = fac[i-1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD/i) % MOD;
        finv[i] = finv[i-1] * inv[i] % MOD;
    }
}
ll comb(int n, int k){
    if(n < k) return 0;
    if(n < 0 || k < 0) return 0;
    return fac[n] * finv[k] % MOD * finv[n-k] % MOD;
}

//約数の列挙O(√n)
vector<ll> divisor(ll n){
    vector<ll> res(0);
    for(ll i = 1; i * i <= n; i++){
        if(n % i == 0){
            res.push_back(i);
            if(i != n/i) res.push_back(n/i);
        }
    }
    sort(res.begin(), res.end());
    return res;
}



int main(void){
  ll p;
  cin >> p;
  MOD = p;
  COMinit();
  vector<ll> A(p);
  rep(i, p) cin >> A[i];
  vector<ll> B(p, 0);
  rep(i, p){
    if(A[i] == 0) continue;
    B[0]++;
    ll pow_i = 1;
    revrep(j, p){
      if((p + j) % 2) B[j] -= pow_i * comb(p-1, j);
      else B[j] += pow_i * comb(p-1, j);
      B[j] %= MOD;
      B[j] += MOD;
      B[j] %= MOD;
      pow_i *= i;
      pow_i %= MOD;
    }
  }
  rep(i, p){
    cout << B[i];
    if(i == p-1) cout << endl;
    else cout << " ";
  }
}


Measured memory_bytes: 512
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <set>
#include <map>
#include <string.h>
#include <cmath>

using namespace std;
typedef long long i64;
typedef long double ld;
typedef pair<i64,i64> P;
#define rep(i,s,e) for(int (i) = (s);(i) <= (e);++(i))

int n;
i64 MAX;

i64 v[41];
i64 w[41];

int main()
{
	cin >> n >> MAX;
	int sz = n / 2;
	for(int i = 0;i < sz;i++)
		cin >> v[i] >> w[i];
	map<i64,i64> mp;
	mp[0] = 0;
	for(int i = 1;i < (1 << (sz));i++)
	{
		i64 we = 0;
		i64 val = 0;
		for(int j = 0;j < sz;j++)
		{
			if(i & (1 << j))
			{
				we += w[j];
				val += v[j];
			}
		}
		mp[we] = max(mp[we] , val);
	}

	auto ite = mp.begin();
	++ite;
	auto before = mp.begin();

	while(ite != mp.end())
	{
		(*ite).second = max((*ite).second , (*before).second);
		before = ite;
		++ite;
	}


	for(int i = sz;i < n;i++)
	{
		cin >> v[i - sz] >> w[i - sz];
	}
	
	sz = n - sz;


	i64 result = 0;
	for(int i = 0;i < (1 << sz);i++)
	{
		i64 we = 0;
		i64 val = 0;
		for(int j = 0;j < sz;j++)
		{
			if(i & (1 << j))
			{
				we += w[j];
				val += v[j];
			}
		}
		auto ite = mp.lower_bound(MAX - we + 1);
		if(ite == mp.begin()) continue;
		--ite;
		if((*ite).first + we <= MAX)
		{
			result = max(result , val + (*ite).second);
		}
	}

	cout << result << endl;
}



Measured memory_bytes: 68572
#include "bits/stdc++.h"
using namespace std;
// #define endl '\n'
// #define double long double
#define int long long
// int MOD = 1000 * 1000 * 1000 + 7;
// int MOD = 998244353;

signed main() {
	
	int a, b;
	cin >> a >> b;
	int x = a % b;
	cout << min(x, b-x) << endl;
	
}


Measured memory_bytes: 256
def gcd(a,b):
    if b == 0:
        return a
    return gcd(b,a%b)
n,X = map(int,input().split())
x = [abs(X-int(i)) for i in input().split()]
g = x[0]
for i in range(1,n):
    g = gcd(g,x[i])
print(g)

Measured memory_bytes: 14212
#include<cstdio>
#include<algorithm>
using namespace std;
const int N=3030,P=1000000007;
int i,j,k,n,m,x,y;
int r[N],sum[N],f[N][N];
char s[N];
void Up(int &x,int y) {
	x=(x+y)%P;
}
int main() {
	scanf("%d%d",&n,&m);
	scanf("%s",s+1);
	for (i=1;i<=n;i++) sum[i]=sum[i-1]+s[i]-'0';
	for (i=1;i<=n;i++) r[i]=i;
	for (i=1;i<=m;i++) {
		scanf("%d%d",&x,&y);
		r[x]=max(r[x],y);
	}
	f[1][sum[r[1]]]=1;
	int ma=r[1];
	for (i=1;i<n;i++) {
		int tmp=ma;
		ma=max(ma,r[i+1]);
		for (j=0;j<=tmp-i+1;j++) if (f[i][j]) {
			if (j) Up(f[i+1][j-1+sum[ma]-sum[tmp]],f[i][j]);
			if (j!=tmp-i+1) Up(f[i+1][j+sum[ma]-sum[tmp]],f[i][j]);
		}
	}
	printf("%d\n",(f[n][0]+f[n][1])%P);
}

Measured memory_bytes: 33920
import sys
input = sys.stdin.readline

S = list(input().rstrip())
L = len(S)

T = []
Inds = [-1]
for i, s in enumerate(S):
    if s != "x":
        T.append(s)
        Inds.append(i)
Inds.append(L)

if T != T[::-1]:
    print(-1)
else:
    R = len(T)
    ans = 0
    for i in range((R+1)//2):
        l = Inds[i+1] - Inds[i]
        r = Inds[-i-1] - Inds[-i-2]
        ans += abs(r-l)
    print(ans)

Measured memory_bytes: 9424
#include <iostream>
#include <cstdio>
#include <vector>
#include <string>
#include <numeric>
#include <algorithm>
#include <cmath>
#include <functional>
#include <map>
#include <set>
#include <stack>
#include <deque>

#define INF 1000000000;
#define MOD 1000000007;
#define LIMIT 1000000000000000000;
typedef long long ll;
typedef unsigned long long ull;
using namespace std;
typedef pair<int, int> P;

template<typename T>
T gcd(T a, T b) {
    return b ? gcd(b, a % b) : a;
}

template<typename T>
T lcm(T a, T b) {
    return (a * b) / gcd(a, b);
}

int main()
{
    ll a, b, c; cin >> a >> b >> c;
    ll arr[3];
    ll ans;
    if (a % 2 == 0 || b % 2 == 0 || c % 2 == 0) {
        ans = 0;
    }
    else {
        arr[0] = a, arr[1] = b, arr[2] = c;
        sort(arr, arr + 3);
        ans = arr[0] * arr[1];
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
from collections import defaultdict
def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr


N = int(input())
Mod = 10 ** 9 + 7
if N == 1:
    print(1)
    exit()
d = defaultdict(int)
for i in range(2, N + 1):
    l = factorization(i)
    for j in range(len(l)):
        d[l[j][0]] += l[j][1]
# print(d, list(d.values()))
l = list(d.values())
ans = 1
for i in range(len(l)):
    ans = ans * (l[i] + 1) % Mod
print(ans)


Measured memory_bytes: 3316
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<bitset>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<deque>
#include<iomanip>
#include<math.h>
using namespace std;
int main(){
  int A,B;
  cin >> A >> B;
  cout << max(max(A+B,A-B),A*B) << endl;
}

Measured memory_bytes: 256
d, g = [int(i) for i in input().split()]
p = [[0 for j in range(3)] for i in range(d)]
for i in range(d):
    p[i][1], p[i][2] = [int(i) for i in input().split()]
    p[i][0] = 100*(i+1)
p = sorted(p)
min_num = 10000000
bit = [0 for i in range(d)]
flag = 0
for i in range(2 ** d):
    flag = 0
    sum = 0
    num = 0
    tmp = i
    for j in range(d):
        bit[j] = tmp % 2
        tmp = int(tmp/2)
    for j in range(d):
        if bit[j] == 1:
            num += p[j][1]
            sum += p[j][1]*p[j][0] + p[j][2]
    #print("sum:{} num:{} bit:{}".format(sum,num,bit))
    if sum >= g:
        if num < min_num:
            min_num = num
            #print(num)
            continue
    else:
        res = g - sum
        for j in range(d):
            if bit[j] == 0:
                if res < p[j][0]*p[j][1]:
                    for k in range(p[j][1]-1):
                        #print("sum:{} num:{} bit:{}".format(sum, num, bit))
                        num += 1
                        sum += p[j][0]
                        res -= p[j][0]
                        if res <= 0:
                            if num < min_num:
                                min_num = num
                            break
print(min_num)

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

int main()
{
  vector<int> train;
  int in;
  while(cin>>in){
    if(in){
      train.push_back(in);
    }
    else{
      cout << train.back() << endl;
      train.pop_back();
    }
  }
  return 0;
}

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

int main(){
  int n,k=1;
  cin >> n;
  vector<int> a(n);
  for(int i=0;i<n;i++){
    cin >> a.at(i);
  }
  for(int i=0;i<n;i++){
    if(a.at(i)%2 == 0){
      if(a.at(i)%3 != 0 && a.at(i)%5 != 0){
        k = -1;
        break;
      }
    }
  }
  if(k >0) cout << "APPROVED" << endl;
  else cout << "DENIED" << endl;
  
  return 0;
}


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

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  char a, b;
  cin >> a >> b;
  if(a == b)
    cout << 'H' << endl;
  else
    cout << 'D' << endl;
  return 0;
}

Measured memory_bytes: 256
ia = input().split(" ")
n = int(ia[0])
price = int(ia[1])

for x in range(n + 1):
  for y in range(n + 1 - x):
    z = n - x - y
    sum = 10000 * x + 5000 * y + 1000 * z
    if sum == price:
      print(str(x) + " " + str(y) + " " + str(z))
      break
  else:
    continue
  break
else:
  print("-1 -1 -1")

Measured memory_bytes: 3064
#include<bits/stdc++.h>
#define rep(i,n) for(ll i=0;i<n;++i)
#define rrep(i,n) for(int i=n-1;i>=0;--i)
#define yesno(flg) if(flg){cout<<"YES"<<endl;}else{cout<<"NO"<<endl;}
#define MAX_N 1002
#define i197 1000000007
#define Vi vector<int>
#define Vl vector<long long>
#define pb(a) push_back(a)

using namespace std;

typedef long long ll;
typedef pair<ll,ll> P1;
typedef pair<int,int> Pi;
typedef pair<double,Pi> Pdi;
typedef pair<ll,int>Pli;
typedef pair<P1,ll> P2;
const ll INF=10000000000000000001;
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};
struct Road{double cost;int a,b;};
struct edge{int to,cost;};
struct pos{
	int x,y,cost;
};

int main() {

	int x,y;
	cin>>x>>y;

	if(y-x*2>=0&&(y-x*2)%2==0){
		int a=(y-x*2)/2;
		if(x-a>=0){
			int b=x-a;
			if(2*b+4*a==y){
				cout<<"Yes"<<endl;
				return 0;
			}
		}
	}
	cout<<"No"<<endl;

	return 0;
}


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

using namespace std;
typedef long long ll;
typedef pair<ll, ll> p_ll;

template<class T>
void debug(T itr1, T itr2) { auto now = itr1; while(now<itr2) { cout << *now << " "; now++; } cout << endl; }
#define repr(i,from,to) for (ll i=(ll)from; i<(ll)to; i++)
#define all(vec) vec.begin(), vec.end()
#define rep(i,N) repr(i,0,N)
#define per(i,N) for (int i=(int)N-1; i>=0; i--)

const ll MOD = 998244353;
const ll LLINF = pow(2,61)-1;
const int INF = pow(2,30)-1;

vector<ll> fac;
void c_fac(int x=pow(10,6)+10) { fac.resize(x,true); rep(i,x) fac[i] = i ? (fac[i-1]*i)%MOD : 1; }
ll inv(ll a, ll m=MOD) { ll b = m, x = 1, y = 0; while (b!=0) { int d = a/b; a -= b*d; swap(a,b); x -= y*d; swap(x,y); } return (x+m)%m; }
ll nck(ll n, ll k) { return fac[n]*inv(fac[k]*fac[n-k]%MOD)%MOD; }
ll gcd(ll a, ll b) { if (a<b) swap(a,b); return b==0 ? a : gcd(b, a%b); }
ll lcm(ll a, ll b) { return a/gcd(a,b)*b; }


int main() {
  ll N, A, B, K; cin >> N >> A >> B >> K;

  c_fac();
  ll result = 0;
  rep(i,N+1) {
    if (K-A*i<0||(K-A*i)%B||(K-A*i)/B>N) continue;
    ll j = (K-A*i)/B;
    result = (result+nck(N,i)*nck(N,j)) % MOD;
    // cout << i << " " << j << endl;
  }
  cout << result << endl;
  return 0;
}

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

namespace q3
{
    class Program
    {
        static void Main(string[] args)
        {
            var l = Convert.ToDouble(Console.ReadLine());
            var x = l / 3;
            var ret = x * x * x;
            Console.WriteLine(ret);
        }
    }
}


Measured memory_bytes: 11220
import java.util.*;

public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);

        int A = sc.nextInt();
        int B = sc.nextInt();
        int C = sc.nextInt();

        for(int i=0; i<B; i++){
            if((A*(i+1))%B==C){
                System.out.println("YES");
                break;
            }
            if(i==B-1){
                System.out.println("NO");
            }
        }

    }
}

Measured memory_bytes: 23764
#include <bits/stdc++.h>
#define rep0(i,n) for (int i = 0; i < (n); ++i)  //0index
#define rep1(i,n) for (int i = 1; i < (n); ++i)  //1index
#define REP(i,a,b) for (int i = a; i < (b); ++i)  //aからb - 1まで
#define mREP(i,a,b) for (int i = a; i > (b); --i)  //逆
#define all(x) (x).begin(),(x).end()
const int INF = 1000000007;  //最大値兼MOD
typedef long long ll;
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }  //GCD
int dp[100010][3];
int a[100010][3];
int main(){
    int n;
    cin >> n;
    vector<int>v(n);
    int not0 = 0;
    rep0(i,n)cin >> v[i];
    rep0(i,n)if(v[i] % 10 == 0)not0++;
    if(not0 == n){
        cout << 0 << endl;
        return 0;
    }
    sort(v.begin(),v.end());
    int ans = 0;
    rep0(i,n)ans += v[i];
    if(ans % 10 != 0){
        cout << ans << endl;
        return 0;
    }
    rep0(i,n)if(v[i] % 10 != 0){
        cout << ans - v[i] << endl;
        return 0;
    }
    

    return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        int w = sc.nextInt();
        StringBuilder sb = new StringBuilder();
        int count = 0;
        for (int i = 0; i < s.length(); i++) {
            if (count % w == 0) {
                sb.append(s.charAt(i));
            }
            count ++;
        }
        System.out.println(sb.toString());
    }
}

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

using namespace std;

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

	int d,t,s;

	cin >> d >> t >> s;

	if(t*s>=d)
	{
		cout << "Yes" << '\n';
	}
	else
	{
		cout << "No" << '\n';
	}
	return 0;	
}

Measured memory_bytes: 3632
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.PrintWriter;

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

    static class DSumOfLargeNumbers {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            long n = in.readLong();
            long k = in.readLong();
            int m = (int) 1e9 + 7;

            long sum = 0;

            // n given .. n+ 1 asked
            // fix
            // AP
            for (long i = k; i < n + 2; i++) {
                long max = (2 * n - i + 1) * i / 2;
                long min = (i - 1) * i / 2;

                sum += max - min + 1;
                sum = (sum + m) % m;
            }

            System.out.println(sum);

        }

    }

    static class InputReader {
        private InputStream stream;
        private byte[] buf = new byte[1024];
        private int curChar;
        private int numChars;

        public InputReader(InputStream stream) {
            this.stream = stream;
        }

        public int read() {
            if (numChars == -1)
                throw new RuntimeException();
            if (curChar >= numChars) {
                curChar = 0;
                try {
                    numChars = stream.read(buf);
                } catch (IOException e) {
                    throw new RuntimeException();
                }
                if (numChars <= 0)
                    return -1;
            }
            return buf[curChar++];
        }

        public long readLong() {
            int c = read();
            while (isSpaceChar(c))
                c = read();
            int sgn = 1;
            if (c == '-') {
                sgn = -1;
                c = read();
            }
            long res = 0;
            do {
                res *= 10;
                res += c - '0';
                c = read();
            } while (!isSpaceChar(c));
            return res * sgn;
        }

        public boolean isSpaceChar(int c) {
            return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
        }

    }
}



Measured memory_bytes: 32452
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
#include <cstring>
#include <utility>
#include <numeric>
#include <complex>
#include <iomanip>

using namespace std;

// common
#define X real()
#define Y imag()

using Vector2 = complex<double>;
using Line = pair<Vector2, Vector2>;
using Segment = pair<Vector2, Vector2>;
const double EPS = 1e-10;
const double PI = 3.14159265359;

bool equals(double a, double b){
    if(abs(a - b) < EPS){
        return true;
    }
    else{
        return false;
    }
}

// struct

struct Circle{
    Vector2 c;
    double r;
    Circle(Vector2 c, double r){
        this->c = c;
        this->r = r;
    }
};

// Vector2
double dot(Vector2 a, Vector2 b){
    return (a.X * b.X + a.Y * b.Y);
}

double cross(Vector2 a, Vector2 b){
    return (a.X * b.Y - a.Y * b.X);
}

Vector2 crossPoint(Line l1, Line l2){
    Vector2 v = l2.first;
    Vector2 base = l2.second - v;
    double d1 = abs(cross(base, l1.first - v));
    double d2 = abs(cross(base, l1.second - v));
    double t = d1 / (d1 + d2);
    return l1.first + (l1.second - l1.first) * t;
}

int main(){

    int q;
    cin >> q;
    for(int i = 0; i < q; i++){
        int x0, y0, x1, y1, x2, y2, x3, y3;
        cin >> x0 >> y0 >> x1 >> y1 >> x2 >> y2 >> x3 >> y3;
        Segment s1(Vector2(x0, y0), Vector2(x1, y1));
        Segment s2(Vector2(x2, y2), Vector2(x3, y3));
        Vector2 ans = crossPoint(s1, s2);
        cout << fixed << setprecision(9) << ans.X  << " " << ans.Y << endl;
    }

    return 0;
}


Measured memory_bytes: 3260
N = int(input())
S = input()

res = 0
for i in range(10):
    for j in range(10):
        for k in range(10):
            i_ok = False
            j_ok = False
            k_ok = False
            check = str(i)
            for l in range(N):
                if S[l] == check:
                    if not i_ok:
                        i_ok = True
                        check = str(j)
                    elif not j_ok:
                        j_ok = True
                        check = str(k)
                    elif not k_ok:
                        k_ok = True
                        break
    
            if i_ok and j_ok and k_ok:
                res += 1

print(res)

Measured memory_bytes: 74096
#include <bits/stdc++.h>
#define rf(x) (x)=0;while(*p<48)p++;while(47<*p)(x)=((x)<<3)+((x)<<1)+(*p++&15);
//#define rf(x) (x)=0;while(*p<48)im=*p=='-';while(47<*p)(x)=((x)<<3)+((x)<<1)+(*p++&15);if(im)(x)=-(x);
#define pb push_back
#define sz(V) ((int)(V).size())
#define allv(V) ((V).begin()),((V).end())
#define befv(V) ((V)[(sz(V)-2)])
#define sorv(V) sort(allv(V))
#define revv(V) reverse(allv(V))
#define univ(V) (V).erase(unique(allv(V)),(V).end())
#define clv(V) (V).clear()
#define upmin(a,b) (a)=min((a),(b))
#define upmax(a,b) (a)=max((a),(b))
#define rb(x) ((x)&(-(x)))
#define cb(x) (x)=(!(x))
#define INF (0x3f3f3f3f)
#define INFLL (0x3f3f3f3f3f3f3f3fll)
#define INFST (0x7f7f7f7f)
#define INFLLST (0x7f7f7f7f7f7f7f7fll)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<int, ll> pil;
typedef pair<ll, int> pli;
typedef pair<ld, ld> pdd;
typedef complex<ld> base;
const ld EPS = (ld)1e-7;
const ld PI = acos(0) * 2;
bool isZero(const ld& x) { return abs(x) <= EPS; }
int sign(const ld& x) { return isZero(x) ? 0 : (0 < x ? 1 : -1); }
ll gcd(ll a, ll b) { for(;b;a%=b,swap(a,b)){} return abs(a); }
pll operator + (const pll& a, const pll& b) { return pll(a.first+b.first, a.second+b.second); }
pll operator - (const pll& a, const pll& b) { return pll(a.first-b.first, a.second-b.second); }
pll operator * (const pll& a, const ll& b) { return pll(a.first*b, a.second*b); }
ll operator * (const pll& a, const pll& b) { return a.first*b.second - b.first*a.second; }
ll ccw(const pll& a, const pll& b, const pll& c) { return a*b + b*c + c*a; }
void fg(vector<int> G[], int a, int b) { G[a].pb(b); G[b].pb(a); }
void fg(vector<pii> G[], int a, int b, int c) { G[a].pb({b, c}); G[b].pb({a, c}); }

const int MAXM = 105;

int A[MAXM];

int N, M;

int main() {
	cin >> N >> M;
	for(int i = 0; i < M; i++) cin >> A[i];
	if(1 == M) {
		cout << N << endl;
		if(1 == N) {
			cout << "1\n1" << endl;
		} else {
			cout << "2\n" << N-1 << " 1" << endl;
		}
	} else if(2 == M) {
		for(int i = 0; i < M; i++) cout << A[i] << " ";
		cout << endl;
		if(1 == A[0] || 1 == A[1]) {
			cout << "1\n" << N << endl;
		} else {
			cout << "2\n" << A[0]-1 << " " << A[1]+1 << endl;
		}
	} else {
		int c = 0;
		for(int i = 0; i < M; i++) c += (A[i]&1);
		if(2 < c) {
			puts("Impossible");
		} else {
			for(int i = 1; i < M; i++) if(A[i]&1) swap(A[0], A[i]);
			for(int i = 1; i < M; i++) if(A[i]&1) swap(A[i], A[M-1]);
			for(int i = 0; i < M; i++) cout << A[i] << " ";
			cout << endl;

			vector<int> V;
			V.pb(A[0]+1);
			for(int i = 1; i+1 < M; i++) V.pb(A[i]);
			V.pb(A[M-1]-1);

			{
				vector<int> Q;
				for(int v : V) if(v) Q.pb(v);
				swap(V, Q);
			}

			cout << sz(V) << endl;
			for(int v : V) cout << v << " ";
			cout << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 256