akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>
/*
typedef long long int int64;
int64 max2(int64 a, int64 b) { return a > b ? a : b; }

int64 max3(int64 a, int64 b, int64 c) { return ((a > b ? a : b) > c ? (a > b ? a : b) : c); }
*/
int main()
{
    int a[110]={0};
    int b[110]={0};
    int i,n;
    int flag=0;
    scanf("%d",&n);
    for(i=0;i<n;i++)
    {
        scanf("%d %d",&a[i],&b[i]);
        if(i>=2)
        {
            if(a[i-2]==b[i-2]&&a[i-1]==b[i-1]&&a[i]==b[i])flag=1;
        }
    }

    if(flag)printf("Yes");
    else printf("No");
}


Measured memory_bytes: 1732
#include <iostream>

int main()
{
	int N;
	int* X;
	std::cin >> N;
	X = new int[N];
	for (int i = 0; i < N; i++)
	{
		std::cin >> X[i];
	}

	double mean=0;
	for (int i = 0; i < N; i++)
	{
		mean += X[i];
	}
	mean = mean / (double)N;

	int P;
	if (mean - (int)mean >= 0.5) {
		P = (int)mean + 1;
	}
	else {
		P = (int)mean;
	}

	int sum = 0;
	for (int i = 0; i < N; i++)
	{
		sum += (X[i] - P) * (X[i] - P);
	}

	std::cout << sum;

	delete[] X;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
using namespace std;
typedef int64_t ll;
typedef vector<ll> vll;
struct Solution {
public:
    void solve(std::istream& in, std::ostream& out) {
        ll n;
        in >> n;
        vll a(n);
        rep (i, n) {
            in >> a[i];
        }
        
        string ans = "";
        for (int i = n - 1; i >= 0; i--) {
            if (n % 2 == 0 && i % 2 == 1) ans += to_string(a[i]) + " ";
            if (n % 2 == 1 && i % 2 == 0) ans += to_string(a[i]) + " ";
        }
        for (int i = 0; i < n; i++) {
            if (n % 2 == 0 && i % 2 == 0) ans += to_string(a[i]) + " ";
            if (n % 2 == 1 && i % 2 == 1) ans += to_string(a[i]) + " ";
        }
        out << ans.substr(0, ans.size()-1) << endl;
    }
};
void solve(std::istream& in, std::ostream& out)
{
    out << std::setprecision(12);
    Solution solution;
    solution.solve(in, out);
}
#include <fstream>
#include <iostream>
int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    istream& in = cin;
    ostream& out = cout;
    solve(in, out);
    return 0;
}


Measured memory_bytes: 7808
#include <stdio.h>

#define MIN(a,b) ((a)<(b)?(a):(b))


int main()
{
  int cnt;
  int A,B,K;
  int result;
  int min;
  int k;
  int i;

  cnt = scanf("%d %d %d", &A,&B,&K);

  min = MIN(A,B);

  k=0;
  for(i=min; i>0; i--) {
    if(((A%i) == 0) && ((B%i) == 0)) k++;
    if (k==K) break;
  }

  printf("%d", i);
  
  return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define INF 1000000000
#define LINF 1000000000000000000
#define MOD 1000000007
#define mod 1000007
#define INF63 1061109567
#define INF127 9187201950435737471
#define UINF 18446744073709551615
#define F first
#define S second
#define ll long long
using namespace std;
set<string> st;
ll n;
string s;
int main(){
	ll i;
	cin>>n;
	for(i=0;i<n;i++)
	{
		cin>>s;
		st.insert(s);
	}
	cout<<st.size()<<endl;
	return 0;
}

Measured memory_bytes: 19224
using System;
using System.IO;
using System.Linq;

namespace AtCoder {
	class Program {
		public static void Main(string[] args) {
			Console.SetOut(new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false });
			long[] input = Console.ReadLine().Split(' ').Select(long.Parse).ToArray();
			long n = input[0];
			long a = input[1];
			long b = input[2];
			long sum = 0;
			//for (long i = 0; i <= n / (a + b); i++) sum += a;
			if (a == 0) {
				sum = 0;
			} else {
				sum = n / (a + b) * a;
				sum += n % (a + b) < a ? n % (a + b) : a;
			}
			Console.WriteLine(sum);
			Console.Out.Flush();
		}
	}
}


Measured memory_bytes: 13396
import java.util.*;
import java.math.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		// 整数の入力

		String s = sc.next();
		String t = sc.next();
		String[] sa = s.split("");
		String[] ta = t.split("");
		int count  =0;

		if(sa[0].equals(ta[0])){
			count++;
		}
		if(sa[1].equals(ta[1])){
			count++;
		}		
		if(sa[2].equals(ta[2])){
			count++;
		}

		System.out.println(count);

	}
}


Measured memory_bytes: 21844
#include <stdio.h>
int main(void){
  int N,T,X;
  int s=0;
  scanf("%d %d %d",&N,&X,&T);
  while(N>0){
    s=s+1;
    N=N-X;
  }
  printf("%d\n",s*T);
  return 0;
}

Measured memory_bytes: 1712
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <string>
#include <ctype.h>
#include <stdlib.h>
#include <vector>
#include <math.h>
using namespace std;
int main()
{
    ios_base :: sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    string s;
    cin>>s;
    for(int i=0;i<s.size();i++){
        if(s[i]=='B'){
      //  cout<<i<<" "<<s[i]<<" "<<s<<endl;
      if(i==0){
        s.erase(i,1);
        i=-1;
       // cout<<"iam here"<<" ";
      }
      else  if(i==1){
            s.erase(i-1,2);
            i=-1;
        }
        else{
            s.erase(i-1,2);
            i=-1;
           }
        }
     //  cout<<i<<" "<<s[i]<<" "<<s<<endl;
    }
    cout<<s;


}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const long long mod = 998244353;
const int max_size = 300000;
vector<long long> fac(max_size+1), ifac(max_size+1);

long long pow_mod(long long x, long long n){
    long long ans = 1;
    while(n != 0){
        if(n&1) ans = ans*x % mod;
        x = x*x % mod;
        n = n >> 1;
    }
    return ans;
}

long long comb(long long a, long long b){
    if(a == 0 && b == 0) return 1;
    if(a < b || a < 0) return 0;
    long long tmp = ifac[a-b] * ifac[b] % mod;
    return tmp * fac[a] % mod;
}
int main(){
    fac[0] = 1;
    ifac[0] = 1;
    for(long long i = 0; i < max_size; i++){
        fac[i+1] = fac[i]*(i+1) % mod;
        ifac[i+1] = ifac[i]*pow_mod(i+1,mod-2) % mod;
    }
    long long n,m,k;
    cin >> n >> m >> k;
    long long ans = 0;
    for(int i=0; i<=k; i++){
        ans += ((m*pow_mod(m-1,n-1-i))%mod)*comb(n-1,i);
        ans %= mod;
    }
    cout << ans << endl;
    return 0;
}


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

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

  map<string,int>m;
  
  rep(i,n){
    string s;
    cin>>s;
    m[s]++;
  }

  int mx=0;
  for(auto x:m){
    mx=max(x.second,mx);
  }
  
  for(auto x:m){
    if(x.second==mx){
    cout<<x.first<<endl;
    }
  }
  return 0;
}

Measured memory_bytes: 25216
#include <bits/stdc++.h>
#define err(args...) {}
#ifdef DEBUG
#include "_debug.cpp"
#endif
using namespace std;
using ll = long long;
using ld = long double;
template <typename T> using lim = numeric_limits<T>;
template <typename T> istream& operator>>(istream& is, vector<T>& a) { for(T& x : a) { is >> x; } return is; }
template <typename Iter, typename T> int gt(Iter L, Iter R, T v) { return upper_bound(L, R, v) - L; }
template <typename Iter, typename T> int ge(Iter L, Iter R, T v) { return lower_bound(L, R, v) - L; }
template <typename Iter, typename T> int lt(Iter L, Iter R, T v) { return lower_bound(L, R, v) - L - 1; }
template <typename Iter, typename T> int le(Iter L, Iter R, T v) { return upper_bound(L, R, v) - L - 1; }
template <typename Bst, typename T> typename Bst::const_iterator gt(const Bst& bst, T v) { return bst.upper_bound(v); }
template <typename Bst, typename T> typename Bst::const_iterator ge(const Bst& bst, T v) { return bst.lower_bound(v); }
template <typename Bst, typename T> typename Bst::const_iterator lt(const Bst& bst, T v) { return bst.lower_bound(v) == bst.begin() ? bst.end() : --bst.lower_bound(v); }
template <typename Bst, typename T> typename Bst::const_iterator le(const Bst& bst, T v) { return bst.upper_bound(v) == bst.begin() ? bst.end() : --bst.upper_bound(v); }
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    vector<int> p(n), I(n);
    cin >> p;
    iota(I.begin(), I.end(), 0);
    sort(I.begin(), I.end(), [&](int i, int j) { return p[i] > p[j]; });
    set<int> s = {-1, n};
    ll ans = 0;
    for(int i : I) {
        int pre = *lt(s, i);
        int suc = *gt(s, i);
        auto prepre = lt(s, pre);
        auto sucsuc = gt(s, suc);
        if(prepre != s.end()) {
            ans += p[i] * ll(suc - i) * (pre - *prepre);
        }
        if(sucsuc != s.end()) {
            ans += p[i] * ll(i - pre) * (*sucsuc - suc);
        }
        s.insert(i);
    }
    cout << ans << endl;
    return 0;
}


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

using namespace std;

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

int n,x,m;
int l[11],r[11],s[11];
bool flag=false;
int ans[11];

bool check(const int* values) {
    int s2[11]={};
    rep(i,m) {
        for(int j=l[i];j<=r[i];j++) {
            s2[i]+=values[j];
        }
        if(s[i]!=s2[i]) return false;
    }
    return true;
}

//何番目,部屋の状態
void dfs(int index, int* values) {
    //printf("[debug] %d,%d\n",index,0);
    if(index == n+1) {
        if(check(values)) {
            flag = true;
            for(int i=1;i<=n;i++) {
                ans[i] = values[i];
            }
        }
        return;
    }
    rep(i,x+1) {
        values[index+1] = i;
        dfs(index+1,values);
    }

}


int main() {
    cin>>n>>x>>m;
    rep(i,m) cin>>l[i]>>r[i]>>s[i];

    int values[7]={};
    dfs(0,values);

    if(!flag) cout<<"-1"<<endl;
    else {
        for(int i=1;i<=n;i++) {
            cout<<(i==1?"":" ")<<ans[i];
        }
        cout<<endl;
    }

    return 0;
}

Measured memory_bytes: 1160
'use strict';

function main(input) {
  const lines = input.split('\n');
  lines.pop();
  const numberOfElements = parseInt(lines[0], 10);
  const array = lines[1].split(' ').map(x => {
    return parseInt(x, 10);
  });
  console.log(fn(array));
}

function fn(raw) {
  const keep = raw.slice();
  let x = 0;
  keep.forEach((v, idx) => {
    if (v !== idx+1) {
      x++;
    }
  })
  if (x <= 2) {
    return 'YES';
  }
  return 'NO';
}

main(require('fs').readFileSync('/dev/stdin', 'utf8'));


Measured memory_bytes: 7372
//  ALDS1_1_D
using System;

namespace Aizu
{
    class Program
    {
        static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());
            int[] prices = new int[n];

            for (int i = 0; i < n; i++)
            {
                prices[i] = int.Parse(Console.ReadLine());
            }

            int maxv = GetMaxDifferential(n, prices);

            /*
            int maxv = prices[1] - prices[0];
            int minv = prices[0];

            for (int i = 1; i < n; i++)
            {
                maxv = Math.Max(maxv, prices[i] - minv);
                minv = Math.Min(minv, prices[i]);
            }
            */

            Console.WriteLine(maxv);

        }

        static int GetMaxDifferential(int n, int[] values)
        {
            int maxv = values[1] - values[0];
            int minv = values[0];

            for (int i = 1; i < n; i++)
            {
                maxv = Math.Max(maxv, values[i] - minv);
                minv = Math.Min(minv, values[i]);
            }

            return maxv;
        }
    }
}



Measured memory_bytes: 20308
from collections import defaultdict
d = defaultdict(int)
s = list(input())

for c in s:
    d[c] += 1

flag = False

if len(d.keys()) == 2:
    for v in d.values():
        if v != 2:
            flag = False
            break
        else:
            flag = True
if flag:
    print("Yes")
else:
    print("No")




Measured memory_bytes: 3316
fn main(){
    
    let scan = std::io::stdin();
    let mut line = String::new();
    let _ = scan.read_line(&mut line);
    line = line.trim_right().to_owned();

    if line == "1"{
        println!("Hello World");
    }else if line == "2"{
        let mut a_s = String::new();
        let _=scan.read_line(&mut a_s);
        let mut b_s = String::new();
        let _=scan.read_line(&mut b_s);
        let a = &a_s.trim_right().to_owned().parse::<i32>().unwrap();
        let b = &b_s.trim_right().to_owned().parse::<i32>().unwrap();
        println!("{}",a+b);
    }
}

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

int main() {
  int A, B, C, D;
  cin >> A >> B >> C >> D;
  
  if (A+B == C+D) {
    cout << "Balanced" << endl;
  }
  
  else if (A+B > C+D) {
    cout << "Left" << endl;
  } 
  
  else {
    cout << "Right" << endl;
  } 
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
template <class Q>
void clearQueue(Q & q) {
    q = Q();
}
void solve(){
	int n;cin>>n;
    vector<int>l(n);
    for(int& x:l){
        cin>>x;
    }
    sort(l.begin(),l.end());set<pair<int,pair<int,int>>>s;
    int cnt=0;
    for(int i=0;i<=n-3;i++){
        for(int j=i+1;j<=n-2;j++){
            for(int k=j+1;k<=n-1;k++){
                if(l[i]+l[j]>l[k]&&l[i]+l[k]>l[j]&&l[j]+l[k]>l[i]&&l[i]!=l[j]&&l[j]!=l[k]&&l[i]!=l[k]) 
                s.insert({i+1,{j+1,k+1}});
            }
        }
    }
    cout<<s.size();
}
int32_t main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);cout.tie(NULL); 
	int T=1;
	// cin>>T;
	while(T--){
		solve();
	}
	return 0;
}


Measured memory_bytes: 13676
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <set>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define reps(i, s, n) for (int i = s; i < (int)(n); i++)
#define out(x) cout << x << endl
#define INF 1000000;
#include <map>
#include <math.h>
 
using ll = long long;
using namespace std;

ll n, k;
const ll mod = 1000000007;


int main(){
   int a1, a2, a3;
   cin >> a1 >> a2 >> a3;
   if(a1+a2+a3>=22) out("bust");
   else out("win");
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int dx[]={1,0,-1,0,1,-1,-1,1};
const int dy[]={0,1,0,-1,1,1,-1,-1};
const int INF = 1e9;
const long long LINF = 1e18;
const double EPS = 1e-8;
#define pb push_back
#define mk make_pair
#define fr first
#define sc second
#define reps(i,j,k) for(int i = (j); i < (k); ++i)
#define rep(i,j) reps(i,0,j)
#define all(a) (a).begin(),(a).end()
#define MOD 1000000007
typedef long long ll;
typedef pair<ll,ll> Pii;
typedef pair<Pii,int> P;
typedef vector<int> vi;
typedef vector<ll> vll;
#define int ll

template<class T>
ostream& operator<<(ostream &out, const vector<T> &v){
	out << "{";
	rep(i,v.size()){
		out << v[i] <<", ";
	}
	return out << "}" << endl;
}

signed main() {
	
	int N;
	cin >> N;
	int a[10001];
	int b[10001];
	int diff[10001];
	int sumA = 0;
	int sumB = 0;
	rep(i,N){
		cin >> a[i];
		sumA += a[i];
	}

	rep(i,N){
		cin >> b[i];
		sumB += b[i];
	}

	/*if(sumA-sumB>0){
		cout << "No" << endl;
		exit(0);
	}*/

	int tm = sumB-sumA;
	int atm = 0;
	int btm = 0;
	int s = 0;
	rep(i,N){
		if(a[i] > b[i]){
			btm+=(a[i]-b[i]);
		}
		else if(a[i] < b[i]){
			if((b[i]-a[i])%2 == 0) {
				atm+=(b[i]-a[i])/2;
			}
			else{
				atm+=((b[i]-a[i])/2+1);
				btm++;
			}
		}
		
	}
	//atm = tm-atm;
	//btm = tm-btm;
	//cout << atm <<" " << btm << endl;
	//cout << tm << " " << s << endl;
	if(atm <= tm && btm <= tm){
		cout << "Yes" << endl;
	}
	else cout << "No" << endl;

	return 0;
}


Measured memory_bytes: 384
import java.util.Arrays;
import java.util.Scanner;
public class Main {
	public static void main(String[] args)throws Exception{
		Scanner stdIn=new Scanner(System.in);
		int N=stdIn.nextInt();
		int A[]=new int[N+1];
		int B[][]=new int[N+1][2];
		int C[]=new int[N];
		int z=0,y=0;
		long ans=0,sum=0;
		A[N]=1000000005;B[N][0]=1000000005;
		while(z<N){
			A[z]=stdIn.nextInt();
			z++;
		}z=0;
		while(z<N){
			B[z][0]=stdIn.nextInt();
			z++;
		}z=0;
		while(z<N){
			C[z]=stdIn.nextInt();
			z++;
		}z=0;
		Arrays.sort(A);
		Arrays.sort(C);
		Arrays.sort(B, (a, b) -> Long.compare(a[0], b[0]));
		while(z<N){
			while(y<N+1){
				if(B[z][0]<=A[y]){
					B[z][1]=y;
					break;
				}
				y++;
			}
			z++;
		}z=0;y=0;
		while(z<N){
			while(y<N+1){
				if(C[z]<=B[y][0]){
					ans+=sum;
					break;
				}
				sum+=B[y][1];
				y++;
			}
			z++;
		}
		System.out.println(ans);
	}
}

Measured memory_bytes: 98872
#include <iostream>
#include <algorithm>
#include <climits>
#include <numeric>
#include <iomanip>
#include <cmath>
#include <vector>
#include <set>
#include <unordered_set>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <unordered_map>
 
#define barsik ios::sync_with_stdio(false)
#define all(x) begin(x), end(x)
#define rall(x) rbegin(x), rend(x)
typedef long long ll;
typedef std::vector<int> vi;
typedef std::pair <int, int> pii;
typedef std::unordered_set <int> u_si;
const double PI = acos(-1);
const long double EPS = 1e-9;
using namespace std;


void solve(){
    int x, y, z;
    cin >> x >> y >> z;
    x -= z;
    cout << x / (y + z);
}
int main(){
    int q = 1;
    //cin >> q;}
    while(q--) solve();
}


Measured memory_bytes: 256
#<B>
N = int(input())
test = []
for i in range(N):
    s = input()
    test.append(s)

print("AC x {}".format(test.count("AC")))
print("WA x {}".format(test.count("WA")))
print("TLE x {}".format(test.count("TLE")))
print("RE x {}".format(test.count("RE")))


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

using Cons = System.Console;

class PriorityQueue<T>
{
    private readonly List<T> m_list;
    private readonly Func<T, T, int> m_compare;
    private int m_count;
    public PriorityQueue(int capacity, Func<T, T, int> compare)
    {
        m_list = new List<T>(capacity);
        m_compare = compare;
        m_count = 0;
    }
    private int Add(T value)
    {
        if (m_count == m_list.Count)
        {
            m_list.Add(value);
        }
        else
        {
            m_list[m_count] = value;
        }
        return m_count++;
    }
    private void Swap(int a, int b)
    {
        T tmp = m_list[a];
        m_list[a] = m_list[b];
        m_list[b] = tmp;
    }
    public void Enqueue(T value)
    {
        int c = Add(value);
        while (c > 0)
        {
            int p = (c - 1) / 2;
            if (m_compare(m_list[c], m_list[p]) < 0) { Swap(p, c); } else { break; }
            c = p;
        }
    }
    public T Dequeue()
    {
        T value = m_list[0];
        m_list[0] = m_list[--m_count];
        int p = 0;
        while (true)
        {
            int c1 = p * 2 + 1;
            int c2 = p * 2 + 2;
            if (c1 >= m_count) { break; }
            int c = (c2 >= m_count || m_compare(m_list[c1], m_list[c2]) < 0) ? c1 : c2;
            if (m_compare(m_list[c], m_list[p]) < 0) { Swap(p, c); } else { break; }
            p = c;
        }
        return value;
    }
}

class Program
{
    static int Main(string[] args)
    {
        var sw = new StreamWriter(Cons.OpenStandardOutput()){AutoFlush = false};
        Cons.SetOut(sw);

        int ret = Solve();
        Cons.Out.Flush();

        return ret;
    }

    static int Solve()
    {
        int[] L = new int[4];
        for(int i = 0; i < 3; i++)
        {
            List<int> list = Console.ReadLine().Split(' ').Select(str => int.Parse(str)).ToList();
            L[list[0] - 1]++;
            L[list[1] - 1]++;
        }

        if(L.Max() == 3) Cons.WriteLine("NO");
        else Cons.WriteLine("YES");

        return 0;
    }
}

Measured memory_bytes: 13396
//#include<bits/stdc++.h>
#include<cstdio>
#include<map>
#include<vector>
#include<algorithm>
#define maxn 100050
using namespace std;
typedef long long LL;


int cnt[2][maxn];
vector<int> A[2];

bool cmp0(int i,int j)
{
	return cnt[0][i]>cnt[0][j];
}

bool cmp1(int i,int j)
{
	return cnt[1][i]>cnt[1][j];
}

void insert(int c,int x)
{
	if (!cnt[c][x])
		A[c].push_back(x);
	++cnt[c][x];
}

int n,a[maxn];

int N;

void init()
{
	scanf("%d",&n);
	for (int i=1;i<=n;++i)
	{
		scanf("%d",&a[i]);
		insert(i&1,a[i]);
	}
}

void solve()
{
	sort(A[0].begin(),A[0].end(),cmp0);
	sort(A[1].begin(),A[1].end(),cmp1);
	
	if (A[0][0]!=A[1][0])
		printf("%d\n",n-cnt[0][A[0][0]]-cnt[1][A[1][0]]);
	else
	{
		if (A[1].size()<=1||(A[0].size()>1&&cnt[0][A[0][1]]>cnt[1][A[1][1]]))
			printf("%d\n",n-cnt[0][A[0][1]]-cnt[1][A[1][0]]);
		else
			printf("%d\n",n-cnt[0][A[0][0]]-cnt[1][A[1][1]]);
	}
}

int main()
{
//    freopen("c.in","r",stdin);
    init();
    solve();
    return 0;
}

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

int main() {
  int m; cin>>m;
  vector<ll> d(m),c(m);
  for (int i=0;i<m;i++) cin>>d[i]>>c[i];
  ll res=0, digit=0;
  for (int i=0;i<m;i++) {
    res+=c[i];
    digit+=d[i]*c[i];
  }
  res=res-1+(digit-1)/9;
  cout<<res<<endl;
}


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

using namespace std;

int main()
{
	string s, t;

	cin >> s;
	cin >> t;

	long pos = 0;
	long count = 0;
	for ( long i = 0; i < t.size(); i ++ ) {
		pos = s.find( t[i], pos );
		if ( pos == -1 ) {
			pos = 0;
			pos = s.find( t[i], pos );
			if ( pos == -1 ) {
				cout << -1 << endl;
				return 0;
			}
			count ++;
		}
		pos ++;
	}

	cout << ( (long long)count * (long long)(s.size()) + (long long)(pos) ) << endl;
	

	return 0;
}

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

#define f(i,a,b) for (int i = a; i < b; i++)
#define fr(i,a,b) for (int i = b-1; i >= 0; i--)

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
#ifdef LOCAL
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
	clock_t start = clock();
#endif

	string s; cin >> s;
	int n = s.length();
	if (s == "zyxwvutsrqponmlkjihgfedcba")
		cout << -1 << endl;
	else {
		string r;
		bool found[26];
		fill(found,found+26,0);
		f(i,0,n+1) {
			int a = i==n?0:s[i]-'a'+1;
			f(c,a,26) if (!found[c]) {
				r = s.substr(0,i);
				r += char(c+'a');
				break;
			}
			if (i!=n) found[s[i]-'a']=1;
		}
		cout << r << endl;
	}


#ifdef LOCAL
	cout << setprecision(12) << (long double)(clock()-start) / CLOCKS_PER_SEC << endl;
#endif
	
	return 0;
}



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

int get(int a)
{
    switch (a) {
        case 3: return 100000;
        case 2: return 200000;
        case 1: return 300000;
        default: break;
    }
    return 0;
}

int main()
{
    int x,y;
    std::cin >> x >> y;
    int total = get(x) + get(y);
    if (total == 600000) total += 400000;
    std::cout << total << std::endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int INF = 1<<30;
const ll LINF = 1LL<<60;

#define int long long

const int mxN = 1e7+10;
int spf[mxN];

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

int solve(int x) {
    map<int, int> cnt;
    while (x != 1) {
        cnt[spf[x]] += 1;
        x = x / spf[x];
    }
    int ret = 1;
    for (auto& p : cnt) if (p.second != 0) ret *= p.second+1;
    return ret;
}

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

    int n;
    cin >> n;
    sieve();

    int ans = 0;
    for (int i = 1; i <= n; i++) {
        ans += i*solve(i);
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 81788
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
struct point
{
  double x, y, val;
  point() {}
  point(double x, double y, double val) : x(x), y(y), val(val){};
  point(double x, double y) : x(x), y(y), val(0){};
};
struct vec
{
  double x, y;
  vec() {}
  vec(double x, double y) : x(x), y(y){};
  vec(point a, point b) : x(b.x - a.x), y(b.y - a.y){};
  double size() { return sqrt(x * x + y * y); };
};
vector<point> circle_intersection(point c1,double r1,point c2,double r2){
  vector<point> res;
  if(r1+r2==vec(c1,c2).size()||fabs(r1-r2)==vec(c1,c2).size()){
    point p(vec(c1,c2).x*r1/vec(c1,c2).size()+c1.x,vec(c1,c2).y*r1/vec(c1,c2).size()+c1.y);
    res.push_back(p);
  }
  else if(r1+r2>vec(c1,c2).size()&&fabs(r1-r2)<vec(c1,c2).size()){
    double di=vec(c1,c2).size()*vec(c1,c2).size();
    double li=(di+r1*r1-r2*r2)/2;
    point p1(c1.x+(li*(-c1.x+c2.x)+(-c1.y+c2.y)*sqrt(di*r1*r1-li*li))/di,c1.y+(li*(-c1.y+c2.y)-(-c1.x+c2.x)*sqrt(di*r1*r1-li*li))/di);
    res.push_back(p1);
    point p2(c1.x+(li*(-c1.x+c2.x)-(-c1.y+c2.y)*sqrt(di*r1*r1-li*li))/di,c1.y+(li*(-c1.y+c2.y)+(-c1.x+c2.x)*sqrt(di*r1*r1-li*li))/di);
    res.push_back(p2);
  }
  return res;
}


int main()
{
ll n , k ;
cin >> n >> k ;
vector<point> p;
rep(i,n){
  ll x , y , c ;
  cin >> x >> y >> c ;
  p.emplace_back(x,y,c);
}
auto judge_d = [&](double val) { 
  vector<point> v;
  rep(i,n)v.push_back(p[i]);
  rep(i,n-1)for (ll j = i+1; j < n; j++)
  {
    if(p[i].x==p[j].x&&p[i].y==p[j].y)continue;
    auto r=circle_intersection(p[i],val/p[i].val,p[j],val/p[j].val);
    for(auto rr:r)v.push_back(rr);
  }
  for(auto r:v){
    ll cnt=0;
    rep(i,n){
      if(vec(r,p[i]).size()<=val/p[i].val+0.0000001)cnt++;
    }
    if(cnt>=k)return false;
  }
  return true;
};
auto binarysearch_d = [&](double lowerbound, double upperbound) {
  if (!judge_d(lowerbound)) return 0.0;
  double lower = lowerbound, upper = upperbound;
  while (1){
    if (judge_d((lower + upper) / 2)) lower = (lower + upper) / 2;
    else upper = (lower + upper) / 2;
    if (fabs(upper - lower) <= 0.0000001){
      return upper;
    }
  }
};
double ans=binarysearch_d(0, 1000000);
cout<<fixed<<setprecision(12)<<ans<<endl;

return 0;
}

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

using namespace std;
using ll = long long;
int ar[110];

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  int n; cin >> n;
  int res = 1.01e9;
  for(int i = 0; i < n; ++i) {
    cin >> ar[i];
  }
  for(int x = 0; x <= 101; ++x) {
    int here = 0;
    for(int i = 0; i < n; ++i) {
      here += (ar[i] - x) * (ar[i] - x);
    }
    res = min(res, here);
  }
  cout << res << '\n';
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
using pint = pair<int,int>;
ll mod = 1000000007,mod2 = 998244353;

void chmin(long long &a, long long b) { if (a > b) a = b; }
void chmax(long long &a, long long b) { if (a < b) a = b; }
const long long INF = 1LL<<60;
ll gcd(ll a,ll b){
    if(b == 0) return a;
    else return gcd(b,a%b);
}

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

//重みある時
using Edge = pair<int,int>;
using Graph = vector<vector<Edge> >;

ll cnt5 = 0;

int main() {
    ll n;
    cin >> n;
    if(n %2 == 1){
        cout << 0 << endl;
        return 0;
    }
    n /= 2;
    while(n > 0){
        n /= 5;
        cnt5 += n;
    }
    cout << cnt5 << endl;
    return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
class Program
{
	static void Main(string[] args)
	{
		string[] str = Console.ReadLine().Split();
		long N = long.Parse(str[0]);
		long C = long.Parse(str[1]);
		long[,] X = new long[N+2,2];
		X[0,0] = 0;
		X[0,1] = 0;
		X[N+1,0] = C;
		X[N+1,1] = 0;
		for(var i=1;i<=N;i++){
			string[] str2 = Console.ReadLine().Split();
			X[i,0] = long.Parse(str2[0]);
			X[i,1] = long.Parse(str2[1]);
		}
		long[] ncsum1 = new long[N+2];
		long[] ncmax1 = new long[N+2];
		ncsum1[0] = 0;
		ncmax1[0] = 0;
		long[] ncsum2 = new long[N+2];
		long[] ncmax2 = new long[N+2];
		ncsum2[0] = 0;
		ncmax2[0] = 0;
		for(var i=1;i<=N;i++){
			ncsum1[i] = ncsum1[i-1] + X[i,1] - (X[i,0] - X[i-1,0]);
			ncmax1[i] = Math.Max(ncmax1[i-1],ncsum1[i]);
		}
		for(var i=N;i>=1;i--){
			ncsum2[i] = ncsum2[i+1] + X[i,1] - ((C-X[i,0]) - (C-X[i+1,0]));
			ncmax2[i] = Math.Max(ncmax2[i+1],ncsum2[i]);
		}
		long max = 0;
		for(var i=0;i<=N;i++){
			long tmp = ncmax1[i] + ncmax2[i+1] - Math.Min(X[i,0], C-X[i+1,0]);
			max = Math.Max(max,tmp);
		}
		Console.WriteLine(max);
	}
}

Measured memory_bytes: 19776
#include<cstdio>
#include<algorithm>
#include<cstring>
#define MN 200005
using namespace std;
int n,m,ans,a[MN],c[MN],now[MN];
int main(){
	scanf("%d%d",&n,&m);ans=n;int x,y;
	for(int i=1;i<=n;i++){
		scanf("%d",&a[i]);c[a[i]]++;
		if(a[i]-c[a[i]]>=0&&!(now[a[i]-c[a[i]]]++))ans--;
	}
	for(int i=1;i<=m;i++){
		scanf("%d%d",&x,&y);
		if(a[x]-c[a[x]]>=0&&!(--now[a[x]-c[a[x]]]))ans++;
		c[a[x]]--;a[x]=y;c[a[x]]++;
		if(a[x]-c[a[x]]>=0&&!(now[a[x]-c[a[x]]]++))ans--;
		printf("%d\n",ans);
	}
}



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

int main()
{
    int n;
    cin >> n;
    vector<int> x(n),y(n);
    rep(i,n) cin >> x[i] >> y[i];
    auto dist = [&](int i,int j){
        double dx = x[i] - x[j];
        double dy = y[i] - y[j];
        return sqrt(dx*dx+dy*dy);
    };
    vector<int> p(n);
    rep(i,n) p[i] = i;
    double len = 0;
    int cou = 0;
    do{
        rep(i,n-1){
            len += dist(p[i],p[i+1]);
        }
        cou++;
    }while(next_permutation(p.begin(),p.end()));
    double ans = len/cou;
    printf("%.10f\n",ans);
    
    return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
const long long N = 1e5 + 5;
long long n;
bool marked[N];
pair < long long , long long > b[N];
pair < long long , long long > c[N];
map < long long , set < pair < long long , long long > > > a;
long long prim(long long x){
            priority_queue < pair < long long , long long > , vector < pair < long long , long long > > , greater < pair < long long , long long > > > Q;
            long long y;
            long long mini = 0;
            pair < long long , long long > p;
            Q.push(make_pair(0 , x));
            while(!Q.empty()){
                    p = Q.top();
                    Q.pop();
                    x = p.second;
                    if(marked[x] == true){
                            continue;
                    }
                    mini += p.first;
                    marked[x] = true;
                    for(auto j : a[x]){
                            y = j.second;
                            if(marked[y] == false){
                                    Q.push(j);
                            }
                    }
            }
            return mini;
}
int main()
{
            ios_base::sync_with_stdio(false);
            cin.tie(0);
            cout.tie(0);
            cin >> n;
            for(long long i = 0 ; i < n ; i++){
                    cin >> b[i].first >> b[i].second;
                    c[i].first = b[i].second;
                    c[i].second = i;
                    b[i].second = i;
            }
            sort(b , b + n);
            sort(c , c + n);
            for(long long i = 0 ; i < n - 1 ; i++){
                    long long x = b[i].second;
                    long long y = b[i + 1].second;
                    a[x].insert(make_pair(b[i + 1].first - b[i].first , y));
                    a[y].insert(make_pair(b[i + 1].first - b[i].first , x));
            }
            for(long long i = 0 ; i < n - 1 ; i++){
                    long long x = c[i].second;
                    long long y = c[i + 1].second;
                    a[x].insert(make_pair(c[i + 1].first - c[i].first , y));
                    a[y].insert(make_pair(c[i + 1].first - c[i].first , x));
            }
            long long mini = prim(1);
            cout << mini << endl;
            return 0;
}


Measured memory_bytes: 40056
/*
これを入れて実行
g++ code.cpp
./a.out
 */
 
#include <iostream>
#include <stdio.h>
#include <vector>
#include <string>
#include <cstring>
#include <queue>
#include <deque>
#include <algorithm>
#include <utility>
#include <set>
#include <map>
#include <unordered_map>
#include <cmath>
#include <math.h>
#include <tuple>
#include <iomanip>
#include <bitset>
#include <functional>

#define all(x) (x).begin(),(x).end()
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
 
using namespace std;
typedef long long ll;
typedef long double ld;
 
int dy4[4] = {-1, 0, +1, 0};
int dx4[4] = {0, +1, 0, -1};
int dy8[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
int dx8[8] = {0, 1, 1, 1, 0, -1, -1, -1};
 
const long long INF = 1LL << 62;
const ll MOD = 1e9 + 7;
 
bool greaterSecond(const pair<int, int>& f, const pair<int, int>& s){
    return f.second > s.second;
}
 
ll gcd(ll a, ll b){
	if (b == 0)return a;
	return gcd(b, a % b);
}
 
ll lcm(ll a, ll b){
    return a / gcd(a, b) * b;
}

ll conbinationMemo[100][100];

ll cmemoInit(){
    rep(i, 100){
        rep(j, 100){
            conbinationMemo[i][j] = -1;
        }
    }
}
 
ll nCr(ll n, ll r){
    if(conbinationMemo[n][r] != -1) return conbinationMemo[n][r];
    if(r == 0 || r == n){
        return 1;
    } else if(r == 1){
        return n;
    }
    return conbinationMemo[n][r] = (nCr(n - 1, r) + nCr(n - 1, r - 1));
}
 
ll nPr(ll n, ll r){
    r = n - r;
    ll ret = 1;
    for (ll i = n; i >= r + 1; i--) ret *= i;
    return ret;
}
 
//-----------------------ここから-----------
int main(void){
    int s, w;
    cin >> s >> w;

    if(s <= w){
        cout << "unsafe" << endl;
    } else {
        cout << "safe" << endl;
    }
}


Measured memory_bytes: 3632
#include <iostream>
#include "bits/stdc++.h"
using namespace std;
#define print(x) cout<<x<<endl;
#define rep(i,a,b) for(int i=a;i<b;i++)
#define REP(i,a) for(int i=0;i<a;i++)
#define jkl int debug = 0;
#define RREP(i,a) for(int i=a-1;i>=0;i--)
#define rrep(i,a,b) for(int i=a-1;i>=b;i--)
#define printall(n,array) {for(int i=0;i<n;i++){cout<<array[i]<<" ";}cout<<endl;}
#define U() cout<<endl;
typedef long long ll;
typedef pair<int, int> Pi;
typedef pair<int, Pi> V;
typedef vector<ll> VE;
const ll mod = 1e9 + 7; //10^9+7

int main(){
    int n;
    int a[102];
    int color[9] = {};
    cin >> n;
    REP(i, n){
        cin >> a[i];
        if(a[i] < 400) color[0]++;
        else if(a[i] < 800) color[1]++;
        else if(a[i] < 1200) color[2]++;
        else if(a[i] < 1600) color[3]++;
        else if(a[i] < 2000) color[4]++;
        else if(a[i] < 2400) color[5]++;
        else if(a[i] < 2800) color[6]++;
        else if(a[i] < 3200) color[7]++;
        else color[8]++;
    }
    int colcnt = 0;
    REP(i, 8)if(color[i])colcnt++;
    int ans = colcnt + color[8];
    cout << max(colcnt, 1) << " " << ans;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
int main(void){
char s[15];
int count;
int kotae;
int a,b,c;
int min=9999;
int shutu=753;
scanf("%s",s);
for(count=0;s[count+2]!='\0';count++){
    a=s[count]-'0';
    b=s[count+1]-'0';
    c=s[count+2]-'0';
kotae=100*a+10*b+1*c;
if(abs(shutu-kotae)<=min){min=abs(shutu-kotae);}
}
printf("%d",min);
}

Measured memory_bytes: 128
#include <iostream>

using namespace std;

int main() {

    ios::sync_with_stdio(false);

    string s;
    cin >> s;

    if(s.size() < 4) {
        cout << "No";
        return 0;
    }

    bool f = (s[0] == 'Y' && s[1] == 'A' && s[2] == 'K' && s[3] == 'I');
    if(f)
        cout << "Yes";
    else
        cout << "No";

    return 0;
}


Measured memory_bytes: 256
import math
n, m = map(int, input().split())
MOD = 1000000007
count_n = 0
count_m = 0
count = 0
if abs(n-m) == 1:
  count_n = math.factorial(n) % MOD
  count_m = math.factorial(m) % MOD
  count = count_m * count_n % MOD
elif abs(n-m) == 0:
  count_n = math.factorial(n) % MOD
  count_m = math.factorial(m) % MOD
  count = 2 * count_m * count_n % MOD
else:
  count = 0

print(count % MOD)

Measured memory_bytes: 4096
# 正の数を受け取るように定義
def gcd(a,b):
    if b == 0:
        return a 
    return gcd(b,a % b)

N, X = map(int,input().split())
k = [abs(int(x) - X) for x in input().split()] # リスト内包表記で入力の受け取り
a = k[0]
for i in range(1,N):
    a = gcd(a,k[i])
print(str(a))

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

int main(){
    int N;
    cin >> N;
    int total;
    bool ans = false;
    for (int i=0; i<N; ++i){
        for (int j=0; j<N; ++j){
            total = 4*i + 7*j;
            if (total == N) ans = true;
        }
    }
    if (ans) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define aaa cout<<233<<endl;
#define endl '\n'
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
// mt19937 rnd(TM(0));
const int inf = 0x3f3f3f3f;//1061109567 > 1e9
const ll linf = 0x3f3f3f3f3f3f3f3f;
const double eps = 1e-6;
const double pi = 3.14159265358979;
const int maxn = 1e5 + 5;
const int maxm = 5e5 + 233;
const int mod = 1e9 + 7;

int n, a[maxn];
int main()
{
    // double pp = clock();
    // freopen("233.in", "r", stdin);
    // freopen("233.out", "w", stdout);
    ios_base::sync_with_stdio(0);
    cin.tie(0);cout.tie(0);
    
    int a, b; cin >> a >> b;
    cout << ((a <= 9 && b <= 9) ? (a * b) : -1) << endl;
    
    // cout << endl << (clock() - pp) / CLOCKS_PER_SEC << endl;
    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
    #include <cstring>
    #include <iostream>
    #include <vector>

    #define SIZE 2001 
    #define MOD 1000000007

    using namespace std;

    long long dp[SIZE][SIZE];
    void makePasTri(int n){
        dp[0][0]=1;
        for(int i=1; i<=n ; i++){
            dp[i][0]=1;
            for(int j=1;j<=i;j++){
                dp[i][j]= (dp[i-1][j]+dp[i-1][j-1])%MOD;    
            }
        }
    }

    int main(){
      int N,K;
      cin>>N>>K;
      makePasTri(N);
      for(int i=1;i<=K;i++){
        cout<<dp[N-K+1][i]*dp[K-1][i-1]%MOD<<endl;
      }
    }


Measured memory_bytes: 30080
use text_io::*;
use std::collections::*;
use std::process::exit;
use std::cmp::max;

fn main() {
    let mut n:usize = read!();
    let mut x:usize = 0;
    for i in 1..n+1 {
        let mut a:usize = read!();
        if a!=i{
            x+=1;
        }
    }
    if x<=2 {
        println!("YES");
    }
    else {
        println!("NO");
    }
}

Measured memory_bytes: 2052
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		long a = sc.nextLong();
		long b = sc.nextLong();
		long k = sc.nextLong();

		a -= k;

		if (a < 0) {
			b += a;
			a = 0;
		}
		if (b < 0) {
			b = 0;
		}

		--k;

		System.out.println(a + " " + b);

		sc.close();
	}
}

Measured memory_bytes: 38944
flag=true
t=x=y=0
gets.to_i.times{
  _t,_x,_y=gets.split.map(&:to_i)
  d0=(x-_x).abs+(y-_y).abs
  dt=_t-t
  unless dt>=d0 && (dt-d0)%2==0
    flag=false
    break 
  end
  t,x,y=_t,_x,_y
}

puts flag ? "Yes" : "No"

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

const int N = 1e5;

int n;
int li[N+5];

int main(){
	scanf("%d",&n);
	for(int i=1;i<=n;i++){
		scanf("%d",&li[i]);
	}
	int id = 1;
	int ans = 0;
	while(id <= n){
		if(id != li[id]) {
			id++;
			continue;
		}
		ans++;
		if(id+1 <= n && id+1 == li[id+1]) id+=2;
		else id++;
//		cout << ">> " << id << endl;
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 640
n, m = [int(i) for i in input().split()]
 
matrix = []
for ni in range(n):
    matrix.append([int(a) for a in input().split()])
 
vector = []
for mi in range(m):
    vector.append(int(input()))
 
for ni in range(n):
    sum = 0
    for mi in range(m):
        sum += matrix[ni][mi] * vector[mi]
 
    print(sum)

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

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  int n;
  cin>>n;
  vector<ll> a(n+1), b(n);
  rep (i, n+1) cin>>a.at(i);
  rep (i, n) cin>>b.at(i);
  ll ans = 0;
  
  rep (i, n) {
    //持ち場だけ
    if(b.at(i)<=a.at(i)) {
      ans+=b.at(i);
    }
    //救援可能
    else {
      ans+=a.at(i);
      b.at(i)-=a.at(i);
      if(b.at(i)>=a.at(i+1)) {
        ans+=a.at(i+1);
        a.at(i+1)=0;
      }
      else {
        ans+=b.at(i);
        a.at(i+1)-=b.at(i);
      }
    }
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 4792
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;

public class Main {
	public static void main (String[] args) throws IOException
	{
		BufferedReader input = new BufferedReader (new InputStreamReader (System.in));

		boolean set = true;

		int count = 0;

		ArrayList<String> result = new ArrayList<String>();

		//シャッフルを始める
		while(set)
		{
			//データを入力する
			String str = input.readLine();

			//終了条件
			if(str.equals("-"))
			{
				for(int num = 0; num < count; num++)
					System.out.println(result.get(num));

				break;
			}

			//カードごとに分ける
				char[] cards = str.toCharArray();

			int kaisuu = Integer.parseInt(input.readLine());

			int[] maisuu = new int[kaisuu];

			//カードをとる枚数を入力する
			for(int num = 0; num < kaisuu; num++)
				maisuu[num] = Integer.parseInt(input.readLine());

			char[] over = new char[cards.length];

			//シャッフルする
			for(int kai = 0; kai < kaisuu; kai++)
			{
				for(int mai = 0; mai < cards.length; mai++)
				{
					if(mai + maisuu[kai] < cards.length)
						over[mai] = cards[mai + maisuu[kai]];
					else
					{
						over[mai] = cards[mai + maisuu[kai] - cards.length];
					}
				}

				for(int num = 0; num < cards.length; num++)
					cards[num] = over[num];

			}

			result.add(String.valueOf(cards));

			count++;

		}
	}
}



Measured memory_bytes: 24208
#include<bits/stdc++.h>
using namespace std;
#define rep(i,x,y) for(int i=x;i<y;i++)
#define print(A,x,n) rep(I,0,n){cout<<(I ? " ":"")<<A[I]x;}cout<<endl;
#define pprint(A,y,m,n) rep(J,0,m){print(A[J],y,n);}
const long mod=1e9+7;
const int size=1e5;
const int inf=1e9;
int main(){
	int N; cin>>N;
	char c[N][N];
	rep(i,0,N)rep(j,0,N) cin>>c[i][j];
	int cnt = 0;
	rep(k,0,N){
		bool flag = true;
		rep(i,0,N)rep(j,0,N){
			if(c[i][j] != c[(j-k+N)%N][(i+k)%N]) flag = false;
		}if(flag) cnt++;
	}cout<<cnt * N<<endl;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
#define watch(x) cout << (#x) << " is " << (x) << endl
typedef long long ll;
using namespace std;
int static fast = [](){
  ios::sync_with_stdio(false);
  cin.tie(0); cout.tie(0); return 0;
}();

int main() {
    int L, R, val;
    cin >> L >> R;
    if (R - L > 2020) {
        cout << 0 << endl;
    } else {
        int ans = INT_MAX;
        vector<int> arr;
        for(int i = L; i <= R; i++) {
            arr.push_back(i%2019);
        }

        for(int i = 0; i < arr.size(); i++)
            for(int j = i+1; j < arr.size(); j++)
                ans = min(ans, (arr[i]*arr[j])% 2019);
        cout << ans << endl;

    }
    return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    string s;
    cin >> s;
    if(s == "SUN")
        cout << 7 << endl;
    else if(s == "MON")
        cout << 6 << endl;
    else if(s == "TUE")
        cout << 5 << endl;
    else if(s == "WED")
        cout << 4 << endl;
    else if(s == "THU")
        cout << 3 << endl;
    else if(s == "FRI")
        cout << 2 << endl;
    else if(s == "SAT")
        cout << 1 << endl;
    return 0;
}

Measured memory_bytes: 256
import std.stdio;
import std.string;
import std.conv;
import std.algorithm;
import std.typecons;

alias T = Tuple!(long, long, long);
long[] vs;
long[T] memo;
long n, k;

long f(long l, long r, long m) {
	auto key = tuple(l, r, m);
	if (key in memo) return memo[key];
	if (m < 0 || n-r-1 < l) return 0;
	long[] cands = [0];
	cands ~= vs[l]     + f(l+1, r  , m-1);
	cands ~= vs[$-r-1] + f(l  , r+1, m-1);
	if (m > 1) {
		cands ~= f(l+1, r  , m-2);
		cands ~= f(l  , r+1, m-2);
	}
	memo[key] = cands.reduce!max;
	return memo[key];
}

void main() {
	scanf("%ld %ld\n", &n, &k);
	vs = readln.chomp.split.to!(long[]);
	f(0, 0, k-1).write;
}


Measured memory_bytes: 8444
#include <bits/stdc++.h>
using namespace std;
#define ALL(a) (a).begin(),(a).end()
#define rALL(a) (a).rbegin(),(a).rend()
typedef pair<int, int> Pint;
typedef pair<int64_t, int64_t> Pll;

int main() {
    int64_t ans = 0;
    string S;
    cin >> S;
    for (int i = 0; i < pow(2, S.size() - 1); i++){
        int64_t a = i, now = 0;
        for (int j = 0; j < S.size(); j++){
            now *= 10;
            now += S.at(j) - '0';
            if (!(a & 1)){
                ans += now;
                now = 0;
            }
            a >>= 1;
        }
        
    }
    cout << ans << endl;
}


Measured memory_bytes: 384
#include <iostream>
#include <string>
#include <cstdio>
#include <cstdlib>
#define llint long long

using namespace std;

llint k;

string tostr(llint x)
{
	char buf[55];
	sprintf(buf, "%lld", x);
	return buf;
}

llint S(llint x)
{
	llint ret = 0;
	for(;x;x/=10) ret += x%10;
	return ret;
}

llint calc(llint x)
{
	string s = tostr(x);
	
	llint mn = x;
	for(int i = 0; i < s.size(); i++){
		for(char j = s[i]; j <= '9'; j++){
			string t;
			for(int k = 0; k < i; k++) t += s[k];
			t += j;
			while(t.size() < s.size()) t += '9';
			llint v = atoll(t.c_str());
			if(v*S(mn) < mn*S(v) || v*S(mn) == mn*S(v) && v < mn) mn = v;
		}
	}
	return mn;
}

int main(void)
{
	cin >> k;
	
	llint ans = 1;
	cout << 1 << endl;
	for(int i = 1; i <= k-1; i++){
		ans = calc(ans+1);
		cout << ans << endl;
	}
	return 0;
}

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

int64_t lucas(int n) {
  
  vector<int64_t> douteki(n + 1);
  
  douteki.at(0) = 2;
  douteki.at(1) = 1;
  
  for (int i = 2; i < n + 1; i++) {
    douteki.at(i) = douteki.at(i - 1) + douteki.at(i - 2);
  }
  
  return douteki.at(n);
}
  

int main() {
  int N;
  
  cin >> N;
  
  cout << lucas(N) << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<bits/stdc++.h>
#define fast  ios_base::sync_with_stdio(false);cin.tie(NULL)
#define ll long long 
#define li long int 
#define pp pair<int,int> 
#define lb lower_bound
#define ub upper_bound
#define mk make_pair
#define pb push_back
#define llp(i,x,n) for(int i=x;i<n;i++)
#define fr first
#define ss second
#define mod 1000000007
using namespace std;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n,w;
    cin>>n>>w;
    vector<ll>dp(w+1);
    for(int i=0;i<n;++i)
    {
       ll weight,value;
        cin>>weight>>value;
        for(int j=w-weight;j>=0;j--)
        {
            dp[j+weight]=max(dp[j+weight],dp[j]+value);
        }
    }
    ll ans=0;
    for(int i=0;i<=w;i++)
    {
        ans=max(dp[i],ans);
    }
    cout<<ans;
    
       
}


Measured memory_bytes: 3972
using System.Collections.Generic;
using System.IO;
using System.Linq;
using static System.Console;
class Z { static void Main() => new K(); }
class K
{
	int[] G => ReadLine().Split().Select(int.Parse).ToArray();
	public K()
	{
		SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
		Solve();
		Out.Flush();
	}
	int V, Mod;
	List<int>[] es;
	void Solve()
	{
		var I = G;
		V = I[0];
		Mod = I[1];
		es = new List<int>[V];
		for (var u = 0; u < V; u++) es[u] = new List<int>();
		for (var e = 0; e < V - 1; e++)
		{
			I = G;
			es[I[0] - 1].Add(I[1] - 1);
			es[I[1] - 1].Add(I[0] - 1);
		}
		var dp0 = DFS0(0, V);
		var dp1 = DFS1(0, dp0);
		for (var u = 0; u < V; u++) WriteLine(dp0[u] * (dp1[u] + 1) % Mod);
	}
	long[] DFS0(int u, int p)
	{
		var dp0 = new long[V];
		var st = new Stack<A0>();
		st.Push(new A0(u, p));
		while (st.Count > 0)
		{
			var f = st.Pop();
			if (f.p >= 0)
			{
				dp0[f.u] = 1L;
				es[f.u].Remove(f.p);
				if (es[f.u].Count == 0) continue;
				st.Push(new A0(f.u, -1));
				foreach (var v in es[f.u]) st.Push(new A0(v, f.u));
			}
			else foreach (var v in es[f.u]) dp0[f.u] = dp0[f.u] * (dp0[v] + 1) % Mod;
		}
		return dp0;
	}
	long[] DFS1(int u, long[] dp0)
	{
		var dp1 = new long[V];
		var st = new Stack<int>();
		st.Push(u);
		var x = new long[V + 1]; x[0] = 1;
		var y = new long[V + 1];
		while (st.Count > 0)
		{
			u = st.Pop();
			var W = es[u].Count;
			if (W == 0) continue;
			y[W] = 1;
			for (var i = 0; i < W; i++) x[i + 1] = x[i] * (dp0[es[u][i]] + 1) % Mod;
			for (var i = W - 1; i >= 1; i--) y[i] = y[i + 1] * (dp0[es[u][i]] + 1) % Mod;
			for (var i = 0; i < W; i++) dp1[es[u][i]] = (dp1[u] + 1) * x[i] % Mod * y[i + 1] % Mod;
			foreach (var v in es[u]) st.Push(v);
		}
		return dp1;
	}
}
struct A0 { public int u, p; public A0(int u, int p) { this.u = u; this.p = p; } }


Measured memory_bytes: 34444
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main() {
    ll N,K; cin >> N >> K;
    vector<pair<ll,ll>> A(N);
    for (int i=0;i<N;i++) cin >> A[i].first >> A[i].second;
    sort(A.begin(),A.end());
    ll cnt = 0;
    for (int i=0;i<N;i++) {
        cnt += A[i].second;
        if (cnt >= K) {
            cout << A[i].first << endl;
            break;
        }
    }
    return 0;
}

Measured memory_bytes: 1792