akhauriyash/Code-Regression huggingface dataset:
import sys
from collections import deque
sys.setrecursionlimit(1000000)
input = sys.stdin.readline
mod = 10**9+7
def dfs():
    stack = deque([[-1,0]])
    visited = set()
    case_num=1
    while stack:
        fr,n = stack.pop()
        if(n in visited):continue
        visited.add(n)
        color = 0
        if(fr==-1):
            color = K-1
        else:
            color = K-2
        if(K<len(edges[n])):
            return 0
        else:
            for e in edges[n]:
                if(e==fr):continue
                case_num*=color
                color-=1
                stack.append([n,e])
                case_num%=mod
    return case_num%mod

if(__name__=='__main__'):
    N,K = [int(x) for x in input().split()]
    edges = [[] for _ in range(N)]
    for _ in range(N-1):
        s,d = [int(x) for x in input().split()]
        edges[s-1].append(d-1)
        edges[d-1].append(s-1)
    ans = K*dfs()
    print(ans%mod)


Measured memory_bytes: 74160
#include <bits/stdc++.h>
#define FOR(i, m, n) for (int i = m; i < (n); i++)
#define RFOR(i, m, n) for (int i = (m - 1); i >= 0; i--)
#define REP(i, n) FOR(i, 0, n)
#define RREP(i, n) RFOR(i, n, 0)
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
using namespace std;
typedef long long ll;
const int mod = 1e9 + 7;

int main() {
  string s;
  cin >> s;
  string anser = "";
  REP(i, s.size()) {
    if (s[i] == 'B' && anser.size() != 0) {
      anser.erase(anser.size() - 1);
    } else if (s[i] == '1') {
      anser += '1';
    } else if (s[i] == '0') {
      anser += '0';
    }
  }
  cout << anser << endl;
  return 0;
}

Measured memory_bytes: 256
class Dice
  def initialize
    @top = 1
    @near = 2
    @right = 3
  end

  def north
    @top, @near = @near, 7-@top
  end

  def east
    @top, @right = 7-@right, @top
  end

  def west
    @top, @right = @right, 7-@top
  end

  def south
    @top, @near = 7-@near, @top
  end

  def right
    @near, @right = @right, 7-@near
  end

  def left
    @near, @right = 7-@right, @near
  end

  attr_reader :top
end

loop do
  count = STDIN.readline.to_i
  break if count == 0

  dice = Dice.new
  ans = dice.top

  count.times do
    command = STDIN.readline
    dice.send(command.chomp.downcase)
    ans += dice.top
  end

  puts ans
end

Measured memory_bytes: 6100
#include<bits/stdc++.h>
using namespace std;
typedef     long long    ll;
typedef     vector<int> vi;
typedef     vector<long long> vl;
typedef     pair<int, int>pi;
typedef     pair<long long, long long>pl;
#define F   first
#define S   second
#define pb  push_back
#define     all(x)      x.begin() , x.end()
#define mp  make_pair
#define       FOR(i,a,b) for(i=a;i<=b;i++)
#define     mem(a)      memset(a , 0 ,sizeof a)
#define     memn(a)     memset(a , -1 ,sizeof a)
ll m=1e9+7; 
int main()
 {
  int t=1;
  //cin>>t;
  while(t--)
  {
    ll n,i,j,x,y,ans=1,ans1=1,ans2=1;
    cin>>n;
    for(i=1;i<=n;i++)
    {
      ans=(ans*10)%m;
    }
    for(i=1;i<=n;i++)
    {
     ans1=(ans1*9)%m; 
    }
  
    ans2=1;
      for(i=1;i<=n;i++)
    {
     ans2=(ans2*8)%m; 
    }
    ans=ans-(2*ans1)%m+ans2;
    if(ans<0)  ans=(ans+m);
    cout<<ans<<endl;
     

  }

  return 0;
}


Measured memory_bytes: 3512
#include <iostream>
#include <algorithm>
#include <string>
#include <cmath> //abs();
using namespace std;

int main(void)
{
    long long int a,b,c,d,i,j,k,n,x[10];
    char C;
    string s;

    cin >> C;

    if(C=='a' || C=='e' || C=='i' || C=='o' || C=='u') cout << "vowel";
    else cout << "consonant";
    return 0;
}


Measured memory_bytes: 256
def divisors(N):
    U = int(N ** 0.5)
    res = [i for i in range(1, U) if N % i == 0]
    if N % U == 0:
        res.append(U)
    res += [N // r for r in reversed(res)]
    return res

N, M = map(int, input().split())
print(max(d for d in divisors(M) if d * N <= M))


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


int main() {
    int n,k,a;
    cin>>n>>k;
    long long sum=0;
    for(int i=0; i<k; i++) {
        cin>>a;
        sum=sum+a;
    }
    sum=n-sum;
    if(sum<0)
        cout<<-1<<endl;
    else
        cout<<sum<<endl;

    return 0;
}







Measured memory_bytes: 3604
#include <iostream>
#include <algorithm>
 
using namespace std;
 
int main(){
    int a[10];
    for (int i = 0; i < 10; i++){
        cin >> a[i];
    }
    sort(a, a+10, less<int>());
    for (int i = 9; i > 6; i--){
        cout << a[i] << endl;
    }
}

Measured memory_bytes: 1176
#include<bits/stdc++.h>
using namespace std;
char s[100010],s1[100010];
int main()
{
    cin>>s;
    int l=strlen(s);
    if(l&1)
    {
    	cout<<"No";
    	return 0;
	}
    for(int i=0;i<l;i++)s1[i]=s[l-i-1];
	for(int i=0;i<l;i++)
    {
        if(s1[i]=='b')s1[i]='d';
        else if(s1[i]=='d')s1[i]='b';
        else if(s1[i]=='p')s1[i]='q';
        else s1[i]='p';
    }
    if(!strcmp(s1,s))cout<<"Yes";
    else cout<<"No";
    return 0;
}

Measured memory_bytes: 384
import scala.io.StdIn


object Main extends App {
  val Array(r, d, x)  = StdIn.readLine.split(" ").map(_.toInt)

  def solve(r: Int, d: Int, x: Int) : Unit  = {
    (0 to 9).foldLeft(x) {(acc, v) =>
      println(r * acc - d)
      r * acc - d
    }
  }
  (solve(r, d, x))

}
  



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

using namespace std;
typedef long long ll;
typedef long double ld;
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REPR(i,n) for(int i=n; i>-1; --i)
#define ALL(a) (a).begin(),(a).end()
#define FILL(a,n,x); REP(i,(n)){ (a)[i]=(x); }
#define CINA(a,n); REP(i,(n)){ cin >> (a)[i]; }
#define FILL2(a,n,m,x); REP(i,(n)){ REP(j,(m)){(a)[i][j]=(x);} }
#define CINA2(a,n,m); REP(i,(n)){ REP(j,(m)){cin >> (a)[i][j];} }
#define Liny "Yes\n"
#define Linn "No\n"
#define LINY "YES\n"
#define LINN "NO\n"

#define umap unordered_map
//cout << setfill('0') << right << setw(4) << 12; // "0012"
int keta(ll x){ if(x<10){return 1;} else{return keta(x/10) + 1;}}
int keta_wa(ll x){ if(x<10){return x;} else{return keta_wa(x/10) + x%10;} }
int ctoi(char c){ return ( (c>='0' && c<='9')? c - '0': 0 );}
int __stoi(string s){ return atoi(s.c_str()); }
ll sum(ll a[],ll N){ return accumulate(a,a+N,0LL);}
ll gcd(ll a,ll b){if(a<b)swap(a,b); return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){if(a<b){swap(a,b);} return a/gcd(a,b)*b;}
template<class T> void chmax(T& a, T b){ if(a<b){a=b;} }
template<class T> void chmin(T& a, T b){ if(a>b){a=b;} }
const ll MOD = 1e9+7;

#define pll pair<ll,ll>

bool func(pll x,pll y){
    if(x.second!=y.second){ return x.second<y.second; }
    else{ return x.first<y.first; }
}

int main(){
    int N; cin>>N;
    pll p[N];
    REP(i,N){
        ll a,b; cin>>a>>b;
        p[i] = make_pair(a,b);
    }
    sort(p,p+N,func);
    
    ll time = 0;
    bool ok = true;
    REP(i,N){
        time += p[i].first;
        if(time>p[i].second){ ok = false; break;}
    }
    cout << (ok?Liny:Linn);
    
}


Measured memory_bytes: 3328
import sys

inf = 1<<30

def solve():
    n = int(sys.stdin.readline().rstrip())

    for i in range(n):
        x, y = sys.stdin.readline().split()

        x = mcxi_to_digit(x)
        y = mcxi_to_digit(y)

        ans = digit_to_mcxi(x + y)

        print(ans)

def mcxi_to_digit(x):
    res = 0
    ps = -1

    for i, num in enumerate(x):
        if ps == i:
            continue
        if num.isdigit():
            if x[i + 1] == 'm':
                res += 1000 * int(num)
            elif x[i + 1] == 'c':
                res += 100 * int(num)
            elif x[i + 1] == 'x':
                res += 10 * int(num)
            else:
                res += int(num)

            ps = i + 1
        else:
            if num == 'm':
                res += 1000
            elif num == 'c':
                res += 100
            elif num == 'x':
                res += 10
            else:
                res += 1

    return res

def digit_to_mcxi(x):
    res = []

    if x % 10 == 1:
        res.append('i')
    elif x % 10 > 1:
        res.append('i')
        res.append(str(x % 10))

    x //= 10

    if x % 10 == 1:
        res.append('x')
    elif x % 10 > 1:
        res.append('x')
        res.append(str(x % 10))

    x //= 10

    if x % 10 == 1:
        res.append('c')
    elif x % 10 > 1:
        res.append('c')
        res.append(str(x % 10))

    x //= 10

    if x % 10 == 1:
        res.append('m')
    elif x % 10 > 1:
        res.append('m')
        res.append(str(x % 10))

    res.reverse()

    return ''.join(res)

if __name__ == '__main__':
    solve()

Measured memory_bytes: 7960
// dfmt off
T lread(T=long)(){return readln.chomp.to!T;}T[] lreads(T=long)(long n){return iota(n).map!((_)=>lread!T).array;}
T[] aryread(T=long)(){return readln.split.to!(T[]);}void arywrite(T)(T a){a.map!text.join(' ').writeln;}
void scan(L...)(ref L A){auto l=readln.split;foreach(i,T;L){A[i]=l[i].to!T;}}alias sread=()=>readln.chomp();
void dprint(L...)(lazy L A){debug{auto l=new string[](L.length);static foreach(i,a;A)l[i]=a.text;arywrite(l);}}
static immutable MOD=10^^9+7;alias PQueue(T,alias l="b<a")=BinaryHeap!(Array!T,l);import std;
// dfmt on

void main()
{
    long a = lread();
    writeln(a + a * a + a * a * a);
}


Measured memory_bytes: 3652
#include <algorithm>
#include<iostream>
#include<vector>
#include<list>
#include<map>
#include<set>
#include<string>

#include<stdlib.h>
#include<string.h>
#include<math.h>
#include<limits.h>
using lll = long long;
using ull = unsigned long long;
using namespace std;


int main(){
  lll ii,jj,kk;
  vector<int> ret;
  int a,b;
  cin >> a >> b;
  int ans;
  ans = a - 2*b;
  if(ans < 0){
    cout << 0 << endl;
  }
  else{
    cout << ans << endl;
  }

  return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstdint>
#include <algorithm>
#include <cmath>

int main() {
  int n;
  scanf("%d", &n);

  intmax_t times[2]={};
  intmax_t sum[2]={};
  for (int i=0; i<n; ++i) {
    int a;
    scanf("%d", &a);

    for (int j=0; j<2; ++j) {
      int sgn=1;
      if ((i ^ j) & 1)
        sgn = -1;

      if (sgn*(sum[j] + a) > 0) {
        sum[j] += a;
      } else {
        // a -> sgn
        times[j] += std::abs(sgn-(sum[j]+a));
        sum[j] = sgn;
      }
    }
  }

  printf("%jd\n", std::min(times[0], times[1]));
  return 0;
}


Measured memory_bytes: 128
use proconio::input;
fn main() {
    input! {
        a: usize,
        b: usize,
        n: usize
    }
    let res = calc(a, b, std::cmp::min(b - 1, n));
    println!("{}", res);
}

fn calc(a: usize, b: usize, x: usize) -> usize {
    (a * x) / b - a * (x / b)
}


Measured memory_bytes: 2088
#include <bits/stdc++.h>
#define ll long long int
#define ld long double
#define pb push_back
#define mp make_pair
#define all(a) a.begin(), a.end()
#define X first
#define Y second
#define sz(x) (int)x.size()
#define el '\n'
#define M 10e9 + 7 
using namespace std;
class Graph { 
    // No. of vertices 
    int V; 
  
    // Pointer to an array containing adjacency lists 
    list<int>* adj; 
  
    // A function used by DFS 
    void DFSUtil(int v, bool visited[]); 
  
public: 
    // Constructor 
    Graph(int V); 
  
    void addEdge(int v, int w); 
    int NumberOfconnectedComponents(); 
}; 
  
// Function to return the number of 
// connected components in an undirected graph 
int Graph::NumberOfconnectedComponents() 
{ 
  
    // Mark all the vertices as not visited 
    bool* visited = new bool[V]; 
  
    // To store the number of connected components 
    int count = 0; 
    for (int v = 0; v < V; v++) 
        visited[v] = false; 
  
    for (int v = 0; v < V; v++) { 
        if (visited[v] == false) { 
            DFSUtil(v, visited); 
            count += 1; 
        } 
    } 
  
    return count; 
} 
  
void Graph::DFSUtil(int v, bool visited[]) 
{ 
  
    // Mark the current node as visited 
    visited[v] = true; 
  
    // Recur for all the vertices 
    // adjacent to this vertex 
    list<int>::iterator i; 
  
    for (i = adj[v].begin(); i != adj[v].end(); ++i) 
        if (!visited[*i]) 
            DFSUtil(*i, visited); 
} 
  
Graph::Graph(int V) 
{ 
    this->V = V; 
    adj = new list<int>[V]; 
} 
  
// Add an undirected edge 
void Graph::addEdge(int v, int w) 
{ 
    adj[v].push_back(w); 
    adj[w].push_back(v); 
} 
signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int n,m;
  cin>>n>>m;
  int a,b,z;
     Graph g(n);
     for(int i=0;i<m;i++){
        cin>>a>>b>>z;
        a--;
        b--;
        g.addEdge(a, b); 
     }
      cout << g.NumberOfconnectedComponents(); 
  return 0;
}


Measured memory_bytes: 12800
n, q = map(int, input().split())
queue = []
for i in range(n):
  queue.append(input().split())

wholetime = 0
while len(queue) != 0:
  target = queue.pop(0)
  time = int(target[1])
  if time <= q:
    wholetime += time
    print(target[0], wholetime)
  else:
#    print(target[0], 100)
    wholetime += q
    queue.append([target[0], time - q])


Measured memory_bytes: 16848
#include<iostream>
#include<vector>
using namespace std;
vector<int>array;

int main() {
	int N;
	cin >> N;
	cout << endl;
	array = vector<int>(N);
	int large = 0,small;
	for(int n = 0;n < N;n++) {
		cin >> array[n];
		if(large < array[n]) {
			large = array[n];
		}
		if(n == 0) {
			small = array[n];
			continue;
		}else if(small > array[n]) {
			small = array[n];
		}
	}
	cout << large-small << endl;

	
	
	

		

	

}


Measured memory_bytes: 256
N = int ( input().strip() ) ;
arr = list ( map ( int , input().strip().split(" ") ) ) ;
arr.sort() ;

c = 1 ;
m = pow ( 10 , 18 ) ;
for v in arr :
	c *= v ;
	if c ==0 : break ;
	if c > m : 
		c = -1 ;
		break ;
print  ( c ) ;



Measured memory_bytes: 21640
#include <iostream>
#define ll long long
using namespace std;

int main()
{
	ll x;
	cin>>x;
	ll num = 1;
	ll ans = 0;
	while(x)
	{
		x /= 2 ;
		ans += num;
		num = num*2;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ull unsigned long long
#define ld long double
#define lll __int128
#define lp(i, a, b) for (int i = a; i < b; i++)
#define vec(v, type, sz) vector<type> v(sz)
#define in(v) \
    for (auto &i : v) cin >> i
#define all(v) v.begin(), v.end()
#define prv(v)                         \
    for (auto i : v) cout << i << " "; \
    cout << "\n"
#define MOD 1000000007
#define INF 1000000000
#define INFL 1000000000000000000ll
#define fast_io                       \
    ios_base::sync_with_stdio(false); \
    cin.tie(NULL);                    \
    cout.tie(NULL);
#define vi vector<int>
#define vl vector<ll>
#define vii(v, n, m, val) vector<vector<int>> v(n, vector<int>(m, val))
#define viii(v, i, j, k, val)        \
    vector<vector<vector<int>>> v(i, \
                                  vector<vector<int>>(j, vector<int>(k, val)))
#define pii pair<int, int>
#define pb push_back
#define file_io                       \
    freopen("input.txt", "r", stdin); \
    freopen("output.txt", "w", stdout);

int main() {
	fast_io;
	double pi=atan(1)*4.0;
	double r; cin>>r;
	cout<<2*pi*r;
}

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

using namespace std;

int main()
{
  string s;
  cin >> s;
  int Q;
  cin >> Q;
  int f;
  string c;
  string ans;
  bool reversed = false;

  for (int i = 0; i < Q; i++)
  {
    int t;
    cin >> t;
    if (t == 1)
    {
      if (reversed)
      {
        reversed = false;
      }
      else
      {
        reversed = true;
      }
    }
    else if (t == 2)
    {
      cin >> f >> c;
      {
        if (f == 2 && !reversed || f == 1 && reversed)
        {
          s += c;
        }
        else
        {
          ans += c;
        }
      }
    }
  }
  reverse(ans.begin(), ans.end());
  ans += s;
  if (reversed)
  {
    reverse(ans.begin(), ans.end());
  }
  cout << ans << endl;
  return 0;
}

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

int main(){
  int n; cin >> n;
  vector<int> 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};
  cout << l[n-1] << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>

using namespace std;

long long gcd(long long a, long long b){ return a%b ? gcd(b, a%b) : b; }
long long lcm(long long a, long long b){ return a/gcd(a, b)*b; }

int main(){
    long long N, M; cin >> N >> M;
    string S, T; cin >> S >> T;
    long long res = lcm(N, M);
    bool ok = true;
    int s = res/M;
    int t = res/N;
    for(int i=0;i*s<N;i++){
        if(S[i*s] != T[i*t]) ok = false;
    }
    cout << (ok ? res : -1) << endl;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
 
#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)
 
#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=(int)(a)-1;i>=(int)(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)
 
#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define getidx(ary,key) lower_bound(_all(ary),key)-begin(ary)
#define clr(a,b) memset((a),(b),sizeof(a))
#define bit(n) (1LL<<(n))
 
// #define DEBUG
 
#ifdef DEBUG
    #define dump(...) fprintf(stderr, __VA_ARGS__)
#else
    #define dump(...)
#endif
 
template<class T>bool chmax(T &a, const T &b) { return (a<b)?(a=b,1):0;}
template<class T>bool chmin(T &a, const T &b) { return (b<a)?(a=b,1):0;}
 
using namespace std;
using ll=long long;
using vi=vector<int>;
using vll=vector<ll>;
 
const double EPS = 1e-10;
const double PI = acos(-1.0);
const ll inf =1LL << 62;
const ll mod=1000000007LL;
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
 
 
ll extgcd(ll a,ll b,ll& x,ll& y){x=1,y=0;ll g=a;if(b!=0) g=extgcd(b,a%b,y,x),y-=a/b*x;return g;}
ll ADD(const ll &a, const ll &b,const ll &mod) { return (a+b)%mod;}
ll SUB(const ll &a, const ll &b,const ll &mod) { return (a-b+mod)%mod;}
ll MUL(const ll &a, const ll &b,const ll &mod) { return (1LL*a*b)%mod;}
ll DIV(const ll &a, const ll &b,const ll &mod) {ll x,y; extgcd(b,mod,x,y);return MUL(a,(x+mod)%mod,mod);}
 
random_device rd;
mt19937 mt(rd());
uniform_int_distribution<int> dice(1,6);
uniform_real_distribution<double> score(0.0,10.0);

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

    int n; cin >> n;
    vi a(n); for(auto& e : a) cin >> e;
    ll s0, s1, s2, s3; s0 = s1 = s2 = s3 = 0;
    s0 = a[0], s1 = a[1];
    s2 = a[2];
    rep(i, 3, n) s3 += a[i];

    int i1, i3; i1 = 1, i3 = 3;
    ll res = inf;
    rep(i2, 2, n - 1){
    	bool ok;
    	do {
    		ok = false;
    		if(abs(s0 + a[i1] - (s1 - a[i1])) < abs(s0 - s1)){
    			s0 += a[i1], s1 -= a[i1];
    			i1++;
    			ok = true;
    		}
    	} while(ok);

    	do {
    		ok = false;
    		if(abs(s2 + a[i3] - (s3 - a[i3])) < abs(s2 - s3)){
    			s2 += a[i3], s3 -= a[i3];
    			i3++;
    			ok = true;
    		}
    	} while(ok);

    	ll cur = max({s0, s1, s2, s3}) - min({s0, s1, s2, s3});
    	// cerr << s0 << " " << s1 << " " << s2 << " " << s3 << " -> " << cur << endl;
    	chmin(res, cur);

    	s1 += a[i2];
    	s2 -= a[i2];
    }

    cout << res << endl;

    return 0;
}


Measured memory_bytes: 1024
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <set>
#include <queue>
#include <map>
#include <stdio.h>
#include <numeric>
using namespace std;

int main()
{
	ios_base::sync_with_stdio(false);
	//freopen("input.txt", "rt", stdin);
	//freopen("out.txt", "wt", stdout);
	int a, b;
	cin >> a >> b;
	if (!((a % 2) ^ (b % 2))) cout << (a + b) / 2 << endl;
	else cout << "IMPOSSIBLE\n";
	/*int n, m, k;
	cin >> n >> m >> k;
	vector <tuple<int, int, int>> edges(m);
	for (int i = 0; i < m; ++i) {
		int x, y, w;
		cin >> x >> y >> w;
		if (x > y) swap(x, y);
		edges[i] = make_tuple(w, x, y);
	}
	sort(edges.begin(), edges.end());
	vector <tuple<int, int, int>> paths;
	int curmin = get<0>(edges[0]);
	int ind = 0;
	int cnt = 0;
	while (get<0>(edges[ind]) == curmin && cnt < k) {
		paths.push_back(edges[ind]);
		++ind;
		++cnt;
	}
	while (cnt < k) {
		curmin = get<0>(edges[ind]);
		bool added = false;
		for (int i = 0; i < paths.size(); ++i)
			for (int j = i + 1; j < paths.size(); ++j) {
				int xi = get<1>(paths[i]);
			}

	}*/
	/*int n, m;
	cin >> n >> m;
	vector<vector<int>> graph(n);
	vector<int> powers(n);
	for (int i = 0; i < m; ++i) {
		int a, b;
		cin >> a >> b;
		--a; --b;
		graph[a].push_back(b);
		graph[b].push_back(a);
		++powers[a];
		++powers[b];
	}
	vector<pair<int, int>> sorted(n);
	for (int i = 0; i < n; ++i) {
		sorted[i].first = powers[i];
		sorted[i].second = i;
	}
	sort(sorted.begin(), sorted.end());
	if (m % 2) {
		cout << -1 << endl;
		return 0;
	}*/
	//cout << get<0>(paths[k - 1]);
	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;
using P = pair<int, int>;
using Graph = vector<vector<int>>;

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

  Graph G(n);
  for (int i = 0; i < m; ++i) {
    int a, b;
    cin >> a >> b;
    a--;
    b--;
    G[a].push_back(b);
    G[b].push_back(a);
  }

  vector<int> dist(n, -1);
  vector<int> pre(n, -1);
  queue<int> que;

  dist[0] = 0;
  que.push(0);

  while (!que.empty()) {
    int v = que.front();
    que.pop();

    for (int nv : G[v]) {
      if (dist[nv] != -1) continue;  // すでに発見済みの頂点は探索しない

      dist[nv] = dist[v] + 1;
      pre[nv] = v + 1;
      que.push(nv);
    }
  }

  rep(i, n - 1) {
    if (pre[i + 1] == -1) {
      cout << "No" << endl;
      return 0;
    }
  }

  cout << "Yes" << endl;
  rep(i, n - 1) { cout << pre[i + 1] << endl; }

  return 0;
}

Measured memory_bytes: 10724
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int X = sc.nextInt();
		int Y = sc.nextInt();
		int A = sc.nextInt();
		int B = sc.nextInt();
		int C = sc.nextInt();

		long sum = 0;
		int[] p = new int[A + 1];
		for (int i = 0; i < A; i++) {
			p[i] = sc.nextInt();
			sum = sum + p[i];
		}
		p[A] = Integer.MAX_VALUE;
		Arrays.sort(p);
		int[] q = new int[B + 1];
		for (int i = 0; i < B; i++) {
			q[i] = sc.nextInt();
			sum = sum + q[i];
		}
		q[B] = Integer.MAX_VALUE;
		Arrays.sort(q);
		int[] r = new int[C + 1];
		for (int i = 0; i < C; i++) {
			r[i] = sc.nextInt();
			sum = sum + r[i];
		}
		r[C] = Integer.MAX_VALUE;
		Arrays.sort(r);
		sc.close();

		int cura = 0;
		int curb = 0;
		int curc = 0;
		long sumd = 0;
		int dis = A + B + C - X - Y;
		while ( cura + curb + curc < dis ) {
			int rema = A - cura;
			int remb = B - curb;
			int remc = C - curc;
			if ( X >= rema + remc ) {
				sumd = sumd + q[curb];
				curb++;
			} else if ( Y >= remb + remc ) {
				sumd = sumd + p[cura];
				cura++;
			} else if ( p[cura] <= q[curb] && p[cura] <= r[curc] ) {
				sumd = sumd + p[cura];
				cura++;
			} else if ( q[curb] <= r[curc] ) {
				sumd = sumd + q[curb];
				curb++;
			} else {
				sumd = sumd + r[curc];
				curc++;
			}
		}
		long ans = sum - sumd;
		System.out.println(ans);
	}
}


Measured memory_bytes: 90476
function Main(s) {
  var s = s.split("\n");
  var n = s[0].split(" ")[0]*1, w = s[0].split(" ")[1]*1;
  var w_v = [[0, 0]].concat(s.slice(1, n + 1).map(e => e.split(" ").map(e => e*1)));
  var dp = new Array(n + 1);
  for (var i = 0; i < n + 1; i++) {
    dp[i] = new Array(w + 1).fill(0);
  }
  for (var i = 1; i <= n; i++) {
    for (var j = 1; j <= w; j++) {
      if (j - w_v[i][0] >= 0) {
        dp[i][j] = Math.max(dp[i][j], dp[i-1][j - w_v[i][0]] + w_v[i][1]);
      }
      dp[i][j] = Math.max(dp[i][j], dp[i-1][j]);
    }
  }
  console.log(dp[n][w]);
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 186896
using System;

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            string a = Console.ReadLine();
            int b,c,d,e,f;

            b = int.Parse(a);
            c = b / 3600;
            d = b % 3600;
            e = d / 60;
            f = d % 60;

            System.Console.WriteLine(c+":"+e+":"+f);

        }
    }
}

Measured memory_bytes: 9136
#include <stdio.h>

int sum(int t){
  int res=0;
  
  while(t!=0){
    res += t%10;
    t /= 10;
  }
  return res;
}

int main(){
  int n,a,b,
      i,
      res=0;
  
  scanf("%d%d%d", &n, &a, &b);
  
  for(i=1;i<=n;i++){
    if((a <= sum(i)) && (sum(i) <= b)){
      res += i;
    }
  }
  
  printf("%d", res);
  
  return 0;
}

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

namespace Practice
{
    class Program
    {
        static void Main(string[] args)
        {
            SolveA();
            //SolveB();
            //SolveC();
            //SolveD();
        }
        private const long MOD = 1000000007;
       
        static void SolveA()
        {
            int n = ReadAndParseInt();
            int f = 0;
            int m = n;
            while(m >= 1)
            {
                f += m % 10;
                m /= 10;
            }
            string ans = n % f == 0 ? "Yes" : "No";
            Console.WriteLine(ans);
        }

        #region よく使う便利関数
        private static bool isPrime(long x)
        {
            if( x == 2) { return true; }
            if( x < 2 || x % 2 == 0) { return false; }
            long i = 3;
            while( i * i <= x)
            {
                if( x % i == 0) { return false; }
                i = i + 2;
            }
            return true;
        }
        private static long lcm(long x, long y)
        {
            return x / gcd(x, y) * y;
        }
        private static long gcd(long x, long y)
        {
            return y > 0 ? gcd(y, x % y) : x;
        }

        private static int ReadAndParseInt()
        {
            return int.Parse(Console.ReadLine());
        }
        private static int[] ReadAndParseIntArr()
        {
            return Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);
        }
        private static long ReadAndParseLong()
        {
            return long.Parse(Console.ReadLine());
        }
        private static long[] ReadAndParseLongArr()
        {
            return Array.ConvertAll(Console.ReadLine().Split(' '), long.Parse);
        }
        #endregion
    }
}

Measured memory_bytes: 11092
import sys
import math
from fractions import gcd
# import queue
# from collections import Counter
# from itertools import accumulate
# from functools import reduce

def lcm(a, b):
    return a * b // gcd(a, b)

def combination_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

def permutations_count(n, r):
    return math.factorial(n) // math.factorial(n - r)

big_prime = 1000000007

"""
# 標準入力取得
## 文字列
 =  sys.stdin.readline().rstrip()
 =  list(sys.stdin.readline().rstrip())

## 数値
 =  int(sys.stdin.readline())
 =  map(int, sys.stdin.readline().split())
 =  list(map(int, sys.stdin.readline().split()))
 =  [list(map(int,list(sys.stdin.readline().split()))) for i in range(N)]
"""


N =  int(sys.stdin.readline())
L =  list(map(int, sys.stdin.readline().split()))

L.sort()

prev = L[0]
ans = 0
cnt = 0
L.append(-1)
for l in L:
    if l != prev:
        if cnt > prev:
            ans += cnt - prev
        elif cnt < prev:
            ans += cnt
        else:
            pass
        prev = l
        cnt = 1
    else:
        cnt += 1
print(ans)

Measured memory_bytes: 85228
#include<bits/stdc++.h>
using namespace std;
int p[60000],cnt,n;
bool b[1000005];
void work(int n)
{
    memset(b,1,sizeof b);
    b[1]=0;
    for(int i=2;i<=n;i++)
    {
        if(b[i])p[++cnt]=i;
         for(int j=1;j<=cnt&&i*p[j]<=n;j++)
         {
            b[i*p[j]]=0;
            if(i%p[j]==0)break;
        }
    }
}
int main()
{
    scanf("%d",&n);
    work(60000);int kk=0;
    for(int i=1;i<=cnt;i++) 
		if(kk==n) break;
    	else if(p[i]%5==1)
    		cout<<p[i]<<' ',kk++;
    	
    return 0;
}

Measured memory_bytes: 1280
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
using ll = long long;
using ld = long double;
const int INF = (1<<30)-1;
const long long LINF = (1LL<<62)-1;
const long double PI = acos(-1.0L);
const int dx[] = {-1, 0, 1, 0};
const int dy[] = {0, 1, 0, -1};
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int a, b;
  cin >> a >> b;
  if (a%2 && b%2)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
  return 0;
}

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

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

using namespace std;
template<typename T>
using table = vector<vector<T>>;
using wall = bitset<4>;

int main() {
  while(1){
    int h,w,r,c;
    cin>>h>>w>>r>>c;
    if(!h)break;
    int H=h+2, W=w+2;
    table<wall> g(H,vector<wall>(W));
    REP(i,h+1) {
      REP(j,w) {
        bool b;
        cin>>b;
        g[i][j+1][1] = g[i+1][j+1][3] = b;
      }
      if (i < h) {
        REP(j, w+1) {
          bool b;
          cin>>b;
          g[i+1][j][0] = g[i+1][j+1][2] = b;
        }
      }
    }
    table<bool> win(H, vector<bool>(W, false));
    REP(i,W) win[0][i] = win[h+1][i] = true;
    REP(i,H) win[i][0] = win[i][w+1] = true;
    using P = pair<int, int>;
    queue<P> que;
    REP(i,w) {
      que.emplace(1,i+1);
      que.emplace(h,i+1);
    }
    REP(i,h) {
      que.emplace(i+1,1);
      que.emplace(i+1,w);
    }
    int di[] = {0, 1, 0, -1};
    int dj[] = {1, 0, -1, 0};
    while(!que.empty()) {
      int i,j;
      tie(i,j) = que.front(); que.pop();
      bool ok_t = false, ok_f = false;
      REP(k,4) {
        if(win[i+di[k]][j+dj[k]]) {
          if (g[i][j][k]) ok_t = true;
          else ok_f = true;
        }
      }
      if (ok_t && ok_f) {
        win[i][j] = true;
        REP(k,4) {
          int ni=i+di[k];
          int nj=j+dj[k];
          if (win[ni][nj]) continue;
          que.emplace(ni,nj);
        }
      }
    }
    bool isw = false;
    REP(k,4) {
      if (!g[r][c][k] && win[r+di[k]][c+dj[k]]) isw = true;
    }
    if (isw) cout << "Yes" << endl;
    else cout << "No" << endl;
  }
  return 0;
}

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

typedef long long int ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pair<int, int> > vii;
#define rrep(i, m, n) for(int (i)=(m); (i)<(n);  (i)++)
#define erep(i, m, n) for(int (i)=(m); (i)<=(n); (i)++)
#define  rep(i, n)    for(int (i)=0; (i)<(n);  (i)++)
#define rrev(i, m, n) for(int (i)=(n)-1; (i)>=(m); (i)--)
#define erev(i, m, n) for(int (i)=(n); (i)>=(m); (i)--)
#define  rev(i, n)    for(int (i)=(n)-1; (i)>=0; (i)--)
#define vrep(i, c)    for(__typeof((c).begin())i=(c).begin(); i!=(c).end(); i++)
#define  ALL(v)       (v).begin(), (v).end()
#define pb            push_back
template<class T, class S> inline pair<T, S> mp(T x, S y){ return make_pair(x, y); }
template<class T, class S> inline bool minup(T& m, S x){ return m>(T)x ? (m=(T)x, true) : false; }
template<class T, class S> inline bool maxup(T& m, S x){ return m<(T)x ? (m=(T)x, true) : false; }

static const int    INF = 1000000000;
static const ll     MOD = 1000000007LL;
static const double EPS = 1E-12;

const int MAX_N = 1000011;
int dp1[MAX_N+2];
int dp2[MAX_N+2];
vi w1;
vi w2;
int N;

inline int get(int i){ return i * (i + 1) / 2 * (i + 2) / 3; }

int main()
{
  rrep(i, 1, MAX_N){
    if(get(i) >= MAX_N) break;
    w1.pb(get(i));
    if(get(i) & 1) w2.pb(get(i));
  }
  int n1 = w1.size();
  int n2 = w2.size();

  rep(i, MAX_N) dp1[i] = dp2[i] = INF;
  rep(i, n1) dp1[w1[i]] = 1;
  rep(i, n2) dp2[w2[i]] = 1;
  rrep(i, 1, MAX_N) rep(j, n1) if(i + w1[j] < MAX_N) minup(dp1[i + w1[j]], dp1[i] + 1);
  rrep(i, 1, MAX_N) rep(j, n2) if(i + w2[j] < MAX_N) minup(dp2[i + w2[j]], dp2[i] + 1);

  while(cin >> N, N) cout << dp1[N] << ' ' << dp2[N] << endl;

  return 0;
}

Measured memory_bytes: 9032
S=input()
N=len(S)
A=[int(i) for i in S]
D=["+" for i in range(N-1)]
output=S[0]
for i in range(2**N):
  C=A
  B=D
  for j in range(N-1):
    if ((i>>j)&1):
      C[j+1]= -1*int(str(S[j+1]))
      B[j]=  "-"
    else:
      C[j+1]= int(str(S[j+1]))
      B[j]=  "+"
  #print(C,B,sum(C))
  if sum(C) ==7:
    for i in range(1,N):
      output += B[i-1] + str(S[i])
    print(output+"=7")
    break


Measured memory_bytes: 3064
#include <iostream>
#include <string>
#include <vector>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>

using namespace std;

int main()
{
  int v[3];
  int A, B, C;
  cin >> v[0] >> v[1] >> v[2];
  
  sort(&v[0], &v[3]);

  int increment=0;
  int a = v[2] - v[0];
  int count = a / 2;
  if(a%2 == 1) ++increment;
  a = v[2] - v[1];
  count += a / 2;
  if(a%2 == 1) ++increment;
  
  if(increment == 1) {
    count += 2;
  } else if(increment == 2) {
    count += 1;
  }
  cout << count << endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i=0; i<n; i++)
typedef long long ll;
typedef pair<int, int> P;
 
int main(){
  int r;
  cin >> r;

  double pi = 3.1415;
  
  cout << 2*pi*r << endl;
  return 0;
}

Measured memory_bytes: 3788
def main():
    n = input()
    if n % 2 == 0:
        s = n + 1
        print n * (n / 2 - 1)
    else:
        s = n
        print (n - 1) * (n / 2)
    for i in range(1, n + 1):
        for j in range(i + 1, n + 1):
            if i + j != s or j == s:
                print i, j


if __name__ == "__main__":
    main()


Measured memory_bytes: 33260
#include<bits/stdc++.h>
using namespace std;
#define inf INT_MAX
#define INF LLONG_MAX
#define ll long long
#define ull unsigned long long
#define M (int)(1e9+7)
#define P pair<int,int>
#define PLL pair<ll,ll>
#define FOR(i,m,n) for(int i=(int)m;i<(int)n;i++)
#define RFOR(i,m,n) for(int i=(int)m;i>=(int)n;i--)
#define rep(i,n) FOR(i,0,n)
#define rrep(i,n) RFOR(i,n,0)
#define all(a) a.begin(),a.end()
#define IN(a,n) rep(i,n){ cin>>a[i]; }
const int vx[4] = {0,1,0,-1};
const int vy[4] = {1,0,-1,0};
#define PI 3.14159265
#define F first
#define S second
#define PB push_back
#define EB emplace_back
#define int ll
#define vi vector<int>
#define IP pair<int,P>
#define PP pair<P,P>
#define Yes(f){cout<<(f?"Yes":"No")<<endl;}
#define YES(f){cout<<(f?"YES":"NO")<<endl;}


string n;
int dp[21][10010][3][3];

bool judge(int n){
  if((n/100)!=51) return false;
  if(n%10!=3) return false;
  return true;
}


signed main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout<<fixed<<setprecision(20);
  cin>>n;

  dp[0][0][0][0]=1;
  rep(i,n.size()+1){
    rep(j,10000){
      rep(k,10){
        int nj=(j%1000*10+k);

        dp[i+1][nj][1][1]+=dp[i][j][1][1];

        if(judge(nj)) dp[i+1][nj][1][1]+=dp[i][j][0][1];
        else dp[i+1][nj][0][1]+=dp[i][j][0][1];

        if(k<n[i]-'0'){
          dp[i+1][nj][1][1]+=dp[i][j][1][0];

          if(judge(nj)) dp[i+1][nj][1][1]+=dp[i][j][0][0];
          else dp[i+1][nj][0][1]+=dp[i][j][0][0];
        }

        if(k==n[i]-'0'){
          dp[i+1][nj][1][0]+=dp[i][j][1][0];

          if(judge(nj)) dp[i+1][nj][1][0]+=dp[i][j][0][0];
          else dp[i+1][nj][0][0]+=dp[i][j][0][0];
        }
      }
    }
  }

  int ans=0;
  rep(j,10000){
    rep(s,2){
      ans+=dp[n.size()][j][1][s];
    }
  }

  cout<<ans<<endl;


}


Measured memory_bytes: 16604
import sys
input = sys.stdin.buffer.readline


#sys.setrecursionlimit(10**9)
#from functools import lru_cache

def RD(): return sys.stdin.read()
def II(): return int(input())
def MI(): return map(int,input().split())
def MF(): return map(float,input().split())
def LI(): return list(map(int,input().split()))
def LF(): return list(map(float,input().split()))
def TI(): return tuple(map(int,input().split()))
# rstrip().decode()

#import numpy as np

def main():
	n,m=MI()
	li=[LI() for _ in range(m)]

	li.sort(key=lambda x:x[1])
	#print(li)

	now=0
	ans=0

	for a,b in li:
		if now<=a:
			now=b
			ans+=1
	print(ans)

























if __name__ == "__main__":
	main()


Measured memory_bytes: 91144
# coding: utf-8
import sys
from collections import deque

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

def slide_min(A, K):
    res = []
    Q = deque()
    for i, a in enumerate(A):
        while Q and A[Q[-1]] > a:
            Q.pop()
        Q.append(i)
        if Q[0] == i - K:
            Q.popleft()
        res.append(A[Q[0]])
    return res[K - 1:]

# 0〜N-1回、魔法を唱える方法で場合分け、スライド最小値
N, X = lr()
A = lr()
INF = 10 ** 15
A += A
answer = INF
for t in range(N):
    temp = t * X
    mi = slide_min(A, t + 1)
    mi = mi[N-t:]
    temp += sum(mi)
    if temp < answer:
        answer = temp

print(answer)
 

Measured memory_bytes: 60380
using System;
using System.Collections.Generic;
using System.Linq;

class PrimeNumber 
{
    static void Main()
    {
        var cp = new bool[1000000];
        var count = 1;

        var odds = Enumerable.Range( 0, 500000 )
            .Select( n => n * 2 + 1 );
        var pre =
            from n in odds.Skip( 1 )
            let cmp = !cp[n]
                ? odds.Skip( 1 )
                    .Select( m => n * m )
                    .TakeWhile( nm => nm < 1000000 )
                    .Select( nm => cp[nm] = true )
                    .ToArray()
                : Enumerable.Empty<bool>()
                    .ToArray()
            select Enumerable.Repeat( !cp[n] ? ++count : count, 2 );
        var primeCount = new[] { 0, 0, 1 }
            .Concat( pre.SelectMany( _ => _ ) )
            .ToArray();
        var q = Enumerable.Repeat( 0, 30 )
            .Select( _ => Console.ReadLine() )
            .TakeWhile( _ => !string.IsNullOrEmpty( _ ) )
            .Select( _ => primeCount[int.Parse( _ )] + "\n" );
        Console.Write( new string( q.SelectMany( _ => _ ).ToArray() ) );
    }
}

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

#define rep(i,s,n) for (int i = (int)s; i < (int)n; i++)
#define ll long long
#define pb push_back
#define All(x) x.begin(), x.end()
#define Range(x, i, j) x.begin() + i, x.begin() + j

int main() {
  int N, K;
  cin >> N >> K;
  vector<int> V(N);
  rep(i, 0, N) {
    cin >> V[i];
  }

  vector<int> ans;

  // l左からとる個数, r右からとる個数
  rep(l, 0, N + 1) {
    rep(r, 0, N - l + 1) {
      if (l + r > K) continue;
      // 残った使える操作の回数
      int remK = K - l - r;
      // 取り出した数
      vector<int> pick;
      rep(i, 0, l) {
        pick.pb(V[i]);
      }
      rep(i, 0, r) {
        pick.pb(V[N - 1 - i]);
      }
      sort(All(pick));
      int tmp = 0;
      rep(i, 0, pick.size()) {
        if (pick[i] < 0 && remK > 0) {
          remK--;
        } else {
          tmp += pick[i];
        }
      }
      ans.pb(tmp);
    }
  }
  sort(All(ans));
  reverse(All(ans));
  cout << ans[0] << endl;
};


Measured memory_bytes: 256
#include<stdio.h>
#include<vector>
#include<algorithm>
#include<math.h>
#include<stdlib.h>
#include<string>
#include<iostream>
#include<set>
#include<map>
#include<deque>
using namespace std;
typedef long long ll;
typedef pair<ll, ll>pii;
typedef pair<pii, ll>pi3;
ll mod = 1000000007;
int d[1000];
int main()
{
	string s;
	cin >> s;
	for (int i = 0; i < s.size(); i++)d[s[i]]++;
	for (char i = 'a'; i <= 'z'; i++)
	{
		if (d[i] == 0)
		{
			printf("%c\n", i);
			return 0;
		}
	}
	printf("None\n");
}

Measured memory_bytes: 512
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<numeric>
#include<utility>
#include<unordered_map> //hash map
#include<cmath>

#define rep(i,a,n) for(int (i)=(a);(i)<(n);(i)++)
#define rrep(i,a,n) for(int (i)=(a);(i)>=(n);(i)--)

#define INF 10000007

typedef  long long ll;

using namespace std;

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

ll deg(int i){
  ll ret = 1;
  while(i != 0){
    if(i/10 == 0){
      break;
    }
    i/=10;
  }
  return i;
}

void solve(){
  int n;
  cin >> n;
  ll s = 0;
  for(ll i = 1;i <= n;i++){
    if(i%5!=0&&i%3!=0){
      s+=i;
    }
  }
  cout << s << endl;
}


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


Measured memory_bytes: 3640
let inp = readLine()!.split(separator: " ").map { Int($0)! }

var x = abs(inp[0])
var k = inp[1]
let d = inp[2]

if x / d > k {
  print(x - k * d)
} else {
  k = k - x / d
  x = x % d
  if k == 0 {
    print(x)
  } else if k & 1 == 0 {
    print(x)
  } else {
    print(abs(x - d))
  }
}

Measured memory_bytes: 8280
using System;
using System.Collections.Generic;
public class ProCon
{
    public static void Main(){     
        string[] line1 =　Console.ReadLine().Split(' ');
        string[] fromStart = Console.ReadLine().Split(' ');
        int K = int.Parse(line1[0]);
        int N = int.Parse(line1[1]);

        int nextRight = 0;
        int nextLeft = K -1;

        int longest = 0;

        int shortest = 0;
        List<int> between = new List<int>();
        for(int i = 0; i < N; i++)
        {
            if(i == N - 1)
            {
                between.Add(int.Parse(fromStart[0]) + (K-int.Parse(fromStart[i])));
            }
            else
            {
                between.Add(int.Parse(fromStart[i + 1])-int.Parse(fromStart[i]));
            }
        }

        foreach(int meter in between)
        {
            if(longest < meter) longest = meter;
        }


        /*
        while(nextRight == nextLeft)
        {
            if(between[nextRight] > between[nextLeft])
            {
                shortest += between[nextLeft];
                nextLeft--;
            }
            else
            {
                shortest += between[nextRight];
                nextRight++;
            }
        }
        shortest += between[nextRight];
        */
        shortest = K - longest;
        Console.WriteLine(shortest);
    }
}

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

using namespace std;

int sum[100002];

int main(){
	int n;
	cin >> n;
	for(int i = 0;i < n;i++){
		int a;
		cin >> a;
		a++;
		
		sum[a]++;
		sum[a-1]++;
		sum[a+1]++;
	}
	
	int res = 0;
	for(int i = 0;i < 100002;i++){
		res = max(res, sum[i]);
	}
	
	cout << res << endl;
	
	return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#define rep(i, n) for(int i = 0; i < n; i++)
#define REP(i, m, n) for(int i = m; i < n; i++)
#define ALL(v) v.begin(),v.end()
#define INF 1e9
typedef long long ll;
using namespace std;

int main() {
    int r,b; cin >> r;
    vector<string> vr;
    vector<string> vb;
    rep(i,r) {
        string str; cin >> str;
        vr.push_back(str);
    }
    cin >> b;
    rep(i,b){
        string str; cin >> str;
        vb.push_back(str);
    }

    int count1,count2,maxnum=0;
    for(auto str1 : vr){
        count1 = 0;
        count2 = 0;
        for(auto str2 : vr){
            if(str1==str2){
                count1 += 1;
            }
        }
        for(auto str3 : vb){
            if(str3==str1){
                count2 += 1;
            }
        }
        maxnum = max(maxnum,count1-count2);
    }
    cout << maxnum << endl;
    return 0;
}

Measured memory_bytes: 256
N = int(input())
A_list = list(map(int, input().split()))

if 0 in A_list:
    total = 0
else:
    total = 1
    for i in range(N):
        total = total*A_list[i]
        if total > 10**18:
            total = -1
            break
print(total)


Measured memory_bytes: 21772
/*                        ______
 _______   /\     |``\   |        |  /
    |     /  \    |__/   |____    |/
    |    / _ _\   |  \   |        |\
    |   /      \  |   \  |______  |  \

            Dept. of CSE
        Comilla  University

*/
#include<bits/stdc++.h>
#define pi 2*acos(0.0)
#define ll long long
#define FIO ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define Node struct node
#define spc " "
#define  E  2.71828182845904523536
#define pb push_back
#define pp pop_back
#define valid(nx,ny) nx>=0 && nx<n && ny>=0 && ny<m
#define ee endl
#define pii pair<int,int>
#define infinity 10000000000000000
#define mod 1000000007
int fx[]={0,0,+1,-1};
int fy[]={+1,-1,0,0};

using namespace std;
///check n=1;
///check corner case;
const int maX=1e5+1;
vector<ll>Graph[maX],cost[maX];
ll visit[maX];
ll x[10];
ll y[10];
double dist(ll i, ll j)
{
    double dx=x[i]-x[j];
    double dy=y[i]-y[j];
    return pow(dx*dx+dy*dy,0.5);
}

int main()
{
    ll n,i,j;
    cin>>n;
    double sum=0;
    for(i=0;i<n;i++){
        cin>>j;
        sum+=(1.0/j*1.0);
    }
    cout<<1.0/sum<<endl;
}


Measured memory_bytes: 4992
import itertools

N = int(input())
P = ''.join([x for x in input().split()])
Q = ''.join([x for x in input().split()])
D = {}
for i, s in enumerate(sorted(itertools.permutations((str(n) for n in range(1, N + 1))))):
  D[''.join(s)] = i
print(abs(D[P] - D[Q]))


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

const ll MAX = 200000;
const ll INF = 1001001001;
const ll MOD = 1000000007;
const double PI=3.1415926535897932;

ll N, ans=0, tmp=0;
vector<ll> A, B;

signed main(){
    cin >> N;
    B.resize(N);
    for(int i=0;i<N;i++) {
        ll a;
        cin >> a;
        a--;
        A.push_back(1+(N+1)*i);
        B[a] = i+1+(N+1)*(N-1-a);
    }
    for(int i=0;i<N;i++) {
        cout << " " << A[i];
    }
    cout << endl;
    for(int i=0;i<N;i++) {
        cout << " " << B[i];
    }
    cout << endl;
    return 0;
}

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

int main(){
    int n,p;
    string s;
    cin >> n >> p >> s;
    if(p==2 || p == 5){
        ll ans=0;
        reverse(s.begin(), s.end());
        rep(i,n){
            if((s[i]-'0')%p == 0) ans += (n-i);
        }
        cout << ans << endl;
        return 0;
    }else{
        ve<int> mod(p);
        reverse(s.begin(), s.end());
        int k = 1;
        int sum = 0;
        rep(i,n){
            sum += ((s[i]-'0')*k) % p;
            sum %= p;
            mod[sum]++;
            k *= 10;
            k %= p;
        }
        ll ans=0;
        mod[0]++;
        rep(i,p){
            ans += (ll)(mod[i]-1)*mod[i]/2;
        }
        cout << ans << endl;
        return 0;
    }
}

Measured memory_bytes: 3720
N, M, C = map(int, input().split())
B = list(map(int, input().split()))
cnt = 0

for i in range(N):
    ans_sum = 0
    A = list(map(int, input().split()))

    for j in range(M):
        ans_sum += A[j]*B[j]

    if ans_sum + C > 0:
        cnt += 1

print(cnt)

Measured memory_bytes: 3060
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <iostream>
#include <algorithm>
#include <utility>
#include <functional>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <stack>
#include <list>
#include <set>
#include <map>
#include <unordered_map>

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
using namespace std;
typedef long long ll;
const int INF = (1<<30);
const int MOD = 1000000007;
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; }

int main() {
    int n, q;
    cin >> n >> q;
    queue<int> Q[n];
    rep(i, q){
        int a,b,c;
        cin >> a;
        switch (a)
        {
        case 0:
            cin >> b >> c;
            Q[b].push(c);
            break;
        case 1:
            cin >> b;
            if(!Q[b].empty()) cout << Q[b].front() << endl;
            break;        
        default:
            cin >> b;
            if(!Q[b].empty()) Q[b].pop();
            break;
        }
    }

    return 0;
}


Measured memory_bytes: 4392