akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define FOR(i, a, n) for(ll i = (ll)a; i < (ll)n; i++)
#define rep(i, n) FOR(i, 0, n)
#define ALL(x) (x).begin(), (x).end()
using namespace std;
typedef long long ll;

constexpr ll mod = 1e9 + 7;

template <typename T> inline bool chmax(T &a, const T b) {
    if(a >= b) return false;
    a = b;
    return true;
}
template <typename T> inline bool chmin(T &a, const T b) {
    if(a <= b) return false;
    a = b;
    return true;
}

/*-------------------------------------------*/

const int Match[10] = {0, 2, 5, 5, 4, 5, 6, 3, 7, 6};
int n, m, a[9], dp[20000];
int main() {
    cin.tie(0);
    ios::sync_with_stdio(0);

    cin >> n >> m;
    for(int i = 1; i <= n; i++)
        dp[i] = -1e9;
    for(int i = 0; i < m; i++)
        cin >> a[i];
    for(int i = 0; i <= n; i++) {
        for(int j = 0; j < m; j++) {
            int x = Match[a[j]];
            chmax(dp[i + x], dp[i] + 1);
        }
    }
    sort(a, a + m, greater<int>());
    int x = dp[n];
    for(int i = 0; i < x; i++) {
        for(int j = 0; j < m; j++) {
            if(n - Match[a[j]] >= 0 && dp[n - Match[a[j]]] + 1 == dp[n]) {
                n -= Match[a[j]];
                cout << a[j];
                break;
            }
        }
    }
    cout << endl;
}

Measured memory_bytes: 256
import java.io.FileNotFoundException;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) throws FileNotFoundException {

//    	File file = new File("src/in.txt");

        //コード
//    	Scanner sc = new Scanner(file);
    	Scanner sc = new Scanner(System.in);

    	int N = sc.nextInt();


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

    	for(int i=0;i<N;i++) {
    		result.add(sc.nextInt());
    	}
		ArrayList<Integer> ans = new ArrayList<Integer>(new HashSet<>(result));

		if(result.size()==ans.size()) {
			System.out.println("YES");
		} else {
			System.out.println("NO");
		}

    }

}

Measured memory_bytes: 92396
n,m=map(int,input().split())
A=[]
B=[]
for i in range(m):
  a,b=map(int,input().split())
  if a==1:
    A.append(b)
  if b==n:
    B.append(a)
if len(set(A) & set(B))>0:
  print("POSSIBLE")
else:
  print("IMPOSSIBLE")

Measured memory_bytes: 27656
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int a,b,c;
    while(cin>>a>>b>>c)
    {
        int ans1=0,ans2=0,ans3=0;
        int maxx=max(max(a,b),c);
        int minn=min(min(a,b),c);
        int mid=(a+b+c)-minn-maxx;
        while(1)
        {

            if(minn==mid && mid==maxx)
            {
                break;
            }
            if(mid<maxx && minn<maxx)
            {
                //cout<<"yes1"<<endl;
                mid++;
                minn++;
                ans1++;
            }
            else if(mid>=maxx && minn<maxx)
            {
                //cout<<"yes2"<<endl;
                minn+=2;
                ans1++;
            }
            else if(mid<maxx && minn>=maxx)
            {
               // cout<<"yes3"<<endl;
                mid+=2;
                ans1++;
            }
            int ans;
            ans=minn+maxx+mid;
            minn=min(minn,min(maxx,mid));
            maxx=max(max(maxx,mid),minn);
            mid=ans-minn-maxx;
        }
        cout<<ans1<<endl;
    }
}


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

int main() {
  int N;
  cin >> N;
  vector<int> vec(N);
  for (int i = 0; i < N; i++) {
    cin >> vec.at(i);
  }
  sort(vec.begin(), vec.end());
  int count = 1;
  for (int j = 1; j < N; j++) {
    if (vec.at(j - 1) != vec.at(j)) {
      count += 1;
    }
  }
  cout << count << endl;
}

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

namespace ConsoleApp2
{
    class Program
    {
        static void Main(string[] args)
        {
            char[] input = Console.ReadLine().ToCharArray();
            int answer = 0;

            foreach (char num in input)
            {
                if (Convert.ToInt32(num.ToString()) == 1)
                {
                    answer += 1;
                }
            }
            Console.WriteLine(answer);
        }
    }
}


Measured memory_bytes: 11220
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		int[][] a=new int[3][3];
		int[] x=new int[3];
		int[] y=new int[3];
		Scanner sc=new Scanner(System.in);
		for(int i=0;i<3;i++) {
			for(int j=0;j<3;j++) {
				a[i][j]=sc.nextInt();
			}
			
		}
		boolean flag=true;
		
			x[0]=0;
			for(int i=0;i<3;i++) {
				y[i]=a[0][i]-x[0];
			}
			for(int i=0;i<3;i++) {
				x[i]=a[i][0]-y[0];
			}
			flag=true;
			for(int i=0;i<3;i++) {
				for(int j=0;j<3;j++) {
					if(x[i]+y[j]!=a[i][j]) {
						flag=false;
						break;
					}
				}
				
			}
			
			
		
		
		if(flag) {
			System.out.println("Yes");
		}
		else{
				System.out.println("No");
			}
		
	}

}


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

template<class T> void vin(vector<T>& v, int n) {
    v.resize(n);
    for (int i = 0; i < n; ++i) {
        cin >> v[i];
    }
}

struct UnionFind {
    static const int MAX = 100001;
    int par[MAX];
    void init(int N) {
        for (int i=0; i<N; ++i) {
            par[i] = -1;
        }
    }
    void init() {
        for (int i=0; i<MAX; ++i) {
            par[i] = -1;
        }
    }
    int find(int x) {
        if (par[x] < 0) return x;
        else return par[x] = find(par[x]);
    }
    bool unite(int x, int y) {
        x = find(x);
        y = find(y);
        if (x == y) return false;
        if (par[x] > par[y]) {
            int tmp = x;
            x = y;
            y = tmp;
        }
        par[x] += par[y];
        par[y] = x;
        return true;
    }
    bool same(int x, int y) {
        return find(x) == find(y);
    }
    // そのグループの木の大きさを返す
    int size(int x) {
        return -par[find(x)];
    }
};

int aa[100001];
priority_queue<int, vector<int>, greater<int>> que[100001];

int main() {
    int N, M;
    cin >> N >> M;
    for (int i = 0; i < N; ++i) {
        cin >> aa[i];
    }
    UnionFind uf;
    uf.init(N);
    for (int i = 0; i < M; ++i) {
        int x, y;
        cin >> x >> y;
        uf.unite(x, y);
    }
    if (M == N-1) {
        cout << 0 << endl;
        return 0;
    }
    if (N<2*(N-M-1)) {
        cout << "Impossible" << endl;
        return 0;
    }

    set<int> s;
    for (int v = 0; v < N; ++v) {
        int par = uf.find(v);
        que[par].push(aa[v]);
        s.insert(par);
    }

    ll res = 0;
    ll use = 0;
    for (int tmp : s) {
        res += que[tmp].top();
        que[tmp].pop();
        use++;
    }
    vector<int> t;
    for (int tmp : s) {
        while (que[tmp].size()) {
            t.emplace_back(que[tmp].top());
            que[tmp].pop();
        }
    }
    sort(t.begin(), t.end());
    rep(i, 2*(N-M-1)-use) {
        res += t[i];
    }
    cout << res << endl;
}


Measured memory_bytes: 8576
import java.lang.Math.hypot

fun main(args: Array<String>) = p15()

fun p15() {
    data class Xy(val x: Double, val y: Double)

    val n = readLine()!!.toInt()
    val xyList = Array(n) {
        val (x, y) = readLine()!!.split(' ').map { it.toDouble() }
        Xy(x, y)
    }

    val permutations = permutations((0 until n).toList())
    var answer = 0.0

    for (permutation in permutations.map { perm -> perm.map { xyList[it] } }) {
        var (currX, currY) = permutation.first()
        for ((x, y) in permutation.drop(1)) {
            answer += hypot(currX - x, currY - y)
            currX = x
            currY = y
        }
    }

    answer /= permutations.size

    println(answer)
}

private fun permutations(src: List<Int>): List<List<Int>> {
    if (src.size == 1) return listOf(src)
    val perms = mutableListOf<List<Int>>()
    val insertElement = src[0]
    permutations(src.drop(1)).forEach { perm ->
        for (i in 0..perm.size) {
            val newPerm = perm.toMutableList()
            newPerm.add(i, insertElement)
            perms.add(newPerm.toList())
        }
    }
    return perms
}


Measured memory_bytes: 45992
x, y, a, b, c = map(int, input().split())
p = sorted(map(int, input().split()))
q = sorted(map(int, input().split()))
r = sorted(map(int, input().split()))
ans = p[-x:] + q[-y:] + r
ans.sort()
n = len(ans)
cnt = 0
for i in range(x+y):
    cnt += ans[n-1-i]
print(cnt)

Measured memory_bytes: 29236
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ll long long
int main(){
  int n;
  cin >> n;
  string s;
  cin >> s;
  ll ans=0;
  for(int i=1;i<n;i++){
    string t=s.substr(0,i),u=s.substr(i);
    vector<bool> ts(26,false),us(26,false);
    ll maxi=0;
    for(char c='a';c<='z';c++){
      rep(j,t.size()){
        if(t.at(j)==c){
          ts.at(c-'a')=true;
        }
      }
      rep(j,u.size()){
        if(u.at(j)==c){
          us.at(c-'a')=true;
        }
      }
    }
    rep(k,26){
      if(ts.at(k)==true &&us.at(k)==true){
        maxi++;
      }
    }
    ans=max(ans,maxi);
  }
  cout << ans;
}

Measured memory_bytes: 3588
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
ll MOD = 1e9+7;

#define vec vector<int>
#define vecll vector<ll>
#define vpair vector<pair<int, int>>
#define vpairll vector<pair<ll, ll>>

#define rep(i,n)         for(int i=(int)0; i<(int)n; i++)
#define REP(i,m,n)       for(int i=(int)m; i<(int)n; i++)
#define arr(var, n)      vec var(n); rep(i,n){cin >> var[i];}
#define arrll(var, n)    vecll var(n); rep(i,n){cin >> var[i];}
#define all(var)         (var).begin(), (var).end()
#define sortall(var)     sort(all(var))
#define prt(var)         cout << var << "\n"
#define prtd(n, var)     cout << fixed << setprecision(n) << var << "\n"
#define prt2(v1, v2)     cout << v1 << " " << v2 << "\n"
#define prt3(v1, v2, v3) cout << v1 << " " << v2 << " " << v3 << "\n"
#define prtall(var)      rep(i,var.size()){cout << var[i] << " ";} cout << "\n"

//----------------------------------------------------------------

int main(void) {
  string s;
  cin >> s;

  int n=s.size();
  int ans1=0, ans2=0;
  rep(i,n){
    if(i%2==0){
      if(s[i]=='0'){
        ans2++;
      } else {
        ans1++;
      }
    }
    if(i%2==1){
      if(s[i]=='1'){
        ans2++;
      } else {
        ans1++;
      }
    }
  }
  prt(min(ans1,ans2));

}


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

int main(){
int N; cin >> N;
int A,B,C,D; cin >> A >> B >> C >> D;
char T[200020];
for(int i=1;i<=N;i++){
  cin >> T[i];
}
  bool can = true;
  int rns = 0;
  for(int j=A;j<C;j++){
    if(T[j] == '#' && T[j+1] == '#'){
      can = false;}
    }
    for(int k=B;k<D;k++){
      if(T[k] == '#' && T[k+1] == '#')
        can = false;
  }
  if(D < C)rns++; 
    int ans = 0;
    for(int i=B;i<=D;i++){
      if(T[i-1] != '#' && T[i+1] != '#' && T[i] != '#'){
        ans++;}
    }
     if(ans == 0 && rns == 1) can = false;
  if(can){cout << "Yes" << endl;}
  else{cout << "No" << endl;}
  
}
       
       
       


Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
#define fo(i, n) for(int i=0; i<n; i++)
#define Fo(i, k, n) for(int i=k; i<n; i++)
#define MOD 1000000007
#define vi vector<int>
#define deb(n) cout<<"[ "#n<<" = "<<n<<" ]"<<endl;
#define FIO ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
const long long  MAX = 1e18;
int case_no=1;
#define w(x) int x; cin>>x; while(x--)

int main()
{
	FIO
	vector<int> nums(5);
	for(int i=0; i<5; i++) {
		cin >> nums[i];
		if(nums[i] == 0) {
			cout << i+1 << endl;
			break;
		}
	}
	
	return 0;
}

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

#define int long long int 
#define endl "\n"
typedef long double ld ;


int32_t main() 
{
   
   /*#ifndef ONLINE_JUDGE 
   freopen("input.txt","r",stdin) ;
   freopen("output.txt","w",stdout);
   #endif */
   string s ;
   cin >> s ;
   int N = s.size() ;
   char a[N+5] ;
   a[0] = '#' ;
   int ind = 0 , ans = 0  ;
   for(int i = 0 ; i < N ; i++ )
   {
      if(a[ind] == '#' || a[ind] == s[i])
      {
         ind++;
         a[ind] = s[i] ;
      }
      else if(a[ind] != s[i])
      {
         ind-- ;
         ans += 2 ;
      }
   }
   cout<<ans<<endl;
  
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
#define REP(i, a, b) for (long long i = a; i <= b; ++i)
#define ll long long
using namespace std;

ll n, m, x, y, ans;

inline ll read(){
	ll s = 0, w = 1;
	char ch = getchar();
	for (; ch < '0' || ch > '9'; ch = getchar()) w *= ch == '-' ? -1 : 1;
	for (; ch >= '0' && ch <= '9'; ch = getchar()) s = s * 10 + ch - '0';
	return s * w;
}

inline void work(){
	n = read(), m = read();
	REP(i, 1, n){
		x = read(), y = read();
		if (sqrt(x * x + y * y) <= m) ans++;
	}
	printf("%lld\n", ans);
}

int main(){
	work();
	return 0;
}

Measured memory_bytes: 3736
export default solve;

// =================================================
// ABC086A
// =================================================

// main
function main(lines) {
  console.log(solve(lines));
}

// solver
function solve(lines: string[]): string {
  const { a, b } = parseLines(lines);

  return (a * b) % 2 === 0 ? 'Even' : 'Odd';
}

// helpers
function parseLines(lines: string[]) {
  const [a, b] = lines[0].split(' ').map(s => +s);
  const obj = { a, b };
  debug(obj);
  return obj;
}

// general helpers
function debug(message?: any, ...optionalParams: any[]) {
  if (!!process.env.LOCAL_DEBUG) console.log(message, ...optionalParams);
}

// reader
if (!process.env.LOCAL_DEBUG) {
  const { stdin: input, stdout: output } = process;
  input.resume();
  input.setEncoding('utf8');
  const lines = [];
  require('readline')
    .createInterface({ input, output })
    .on('line', line => lines.push(line))
    .on('close', () => main(lines));
}


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

int main() {
  int N;
  cin >> N;
  vector<int> a(N + 1);
  int sum;
  for(int i = 1; i < N + 1; i++)
    cin >> a.at(i);
  for(int i = 1; i < N + 1; i = a.at(i)){
    sum ++;
    if(a.at(i) == 2){
      cout << sum << endl;
      break;
    }
    if(sum > N){
      cout << -1 << endl;
      break;
    }
  }
}

Measured memory_bytes: 640
#include <cstdio>
#include <algorithm>
using namespace std;

int N;
int a[100010];

void solve()
{
	int i;
	sort(a, a+N);
	int *l, *r;
	int res = 0;
	for(i=0; i<N; i++){
		l = lower_bound(a, a+N, a[i]-1);
		r = upper_bound(a, a+N, a[i]+1);
		if(r-l > res)
			res = r-l;
		l = lower_bound(a, a+N, a[i]);
		r = upper_bound(a, a+N, a[i]+2);
		if(r-l > res)
			res = r-l;
		l = lower_bound(a, a+N, a[i]-2);
		r = upper_bound(a, a+N, a[i]);
		if(r-l > res)
			res = r-l;
	}
	printf("%d\n", res);
}

int main()
{
	int i;
	scanf("%d", &N);
	for(i=0; i<N; i++)
		scanf("%d", &a[i]);
	solve();
	return 0;
}

Measured memory_bytes: 640
#include <stdio.h>
int main(void){
    char served[200];
    char pick[100];
    int i=0;
    int j=0;
    int k,l,cnt=0;

    scanf("%s",served);
    scanf("%s",pick);
    
    while(1){
        if(served[i++]=='\0') break;
    }
    while(1){
        if(pick[j++]=='\0') break;
    }


    for(k=i-1; k<=2*i-3; k++){
        served[k]=served[k-i+1];
    }
   
   for(l=0; l<=2*i-j; l++){
      if(served[l] == pick[cnt]){
          while(1){
              if(served[l+cnt]==pick[cnt]) cnt++;
              else break;
          }
        if(cnt == j-1)break;
        else cnt=0;
      }
   }
   
   if(cnt) printf("Yes\n");
   else printf("No\n");
   
   return 0;
}

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

int main(){
  int n;
  cin >> n;
  vector<int> p(n);
  for(int i=0; i<n; i++){
    cin >> p[i];
  }

  int ans = 0;
  int mn = 1001001001;
  for(int i=0; i<n; i++){
    mn = min(mn, p[i]);
    if(mn == p[i]) ans++;
  }

  cout << ans << endl;
  
  return 0;
}

Measured memory_bytes: 1024
S=input()
N = len(S)+1
from_left = [0]*N
from_right = [0]*N

for i,s in enumerate(S,1):
    if s == '>':
        from_left[i] = 0
    else:
        from_left[i] = from_left[i-1]+1

for i,s in enumerate(S[::-1]):
    i = N-2-i
    if s == '<':
        from_right[i] = 0
    else:
        from_right[i] = from_right[i+1]+1

seq = [x if x>y else y for x,y in zip(from_left,from_right)]

answer = sum(seq)
print(answer)

Measured memory_bytes: 31644
a, b = map(int,input().split())
if b < 10:
  for x in range(10*b,10*(b+1)):
    if int(0.08*x) == a:
      print(x)
      exit()
else:
  for x in range(10*b,10*b+10):
    if int(0.08*x) == a:
      print(x)
      exit()
print(-1) 

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
int n;
string s,t;
char c[2]={'W','S'};
void end_(string t)
{
	cout<<t;
	exit(0);
}
char change(char c)
{
	if(c=='S')
		return 'W';
	else
		return 'S';
}
bool ok(char a,char x,char y,char b)
{
	if(x=='o'&&y=='S'&&a=='S'&&b=='S')return true;
	if(x=='o'&&y=='S'&&a=='W'&&b=='W')return true;
	if(x=='x'&&y=='S'&&a=='S'&&b=='W')return true;
	if(x=='x'&&y=='S'&&a=='W'&&b=='S')return true;
	if(x=='o'&&y=='W'&&a=='S'&&b=='W')return true;
	if(x=='o'&&y=='W'&&a=='W'&&b=='S')return true;
	if(x=='x'&&y=='W'&&a=='S'&&b=='S')return true;
	if(x=='x'&&y=='W'&&a=='W'&&b=='W')return true;
	return false;
}
void dfs(int now)
{
	if(now==n-1)
	{
		if(ok(t[n-2],s[n-1],t[n-1],t[0])&&ok(t[n-1],s[0],t[0],t[1]))end_(t);
		return;
	}
	int bef=now-1;
	int nxt=now+1;
	if(t[now]=='S')
	{
		if(s[now]=='x')t[nxt]=change(t[bef]);
		else t[nxt]=t[bef];
	}
	else
	{
		if(s[now]=='o')t[nxt]=change(t[bef]);
		else t[nxt]=t[bef];
	}
	dfs(now+1);
}
int main()
{
	cin>>n;
	cin>>s;
	t=s;
	for(int i=0;i<2;i++)
	{
		for(int j=0;j<2;j++)
		{
			t[0]=c[i];
			t[1]=c[j];
			dfs(1);
		}
	}
	cout<<"-1\n";
	return 0;
}

Measured memory_bytes: 8448
#define  _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <math.h>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <math.h>
#include <iostream> 
#include <random>
#include<map>
#include <iomanip>
#include <time.h>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
#include <cassert>
#include<fstream>
#include <unordered_map>  
using namespace std;
#define Ma_PI 3.141592653589793
#define eps 0.00000000000000000000000001
#define LONG_INF 10000000000000000LL
#define GOLD 1.61803398874989484820458
#define MAX_MOD 1000000007
#define MOD  998244353
#define REP(i,n) for(long long i = 0;i < n;++i)
long long inv(long long now) {
	long long ans = 1;
	long long te = MAX_MOD - 2LL;
	while (te != 0) {
		if (te % 2 == 1) {
			ans *= now;
			ans %= MAX_MOD;
		}
		te /= 2;
		now *= now;
		now %= MAX_MOD;
	}
	return ans;
}
long long summing[1000000] = {};
int main() {
#define int long long
	long long n, x;
	cin >> n >> x;
	vector<long long> geko;
	REP(i, n) {
		long long a;
		cin >> a;
		geko.push_back(a);
	}
	reverse(geko.begin(), geko.end());
	REP(i, geko.size()) {
		summing[i + 1] = summing[i] + geko[i];
	}
	for (int i = geko.size(); i < 1000000; ++i) {
		summing[i + 1] = summing[i];
	}
	long long final_ans = LONG_INF;
	for (long long k = 1; k <= n; ++k) {
		long long now_ans = x * (n + k);
		for (int q = 0; q < n; q += k) {
			long long going = q / k + 1;
			long long nya = summing[q + k] - summing[q];
			going = max(2 * going + 1, 5LL);
			if (LLONG_MAX - nya * going <= now_ans) {
				now_ans = -1;
				break;
			}
			now_ans += nya * going;
		}
		if (now_ans == -1) continue;
		final_ans = min(final_ans, now_ans);
	}
	cout << final_ans << endl;
	return 0;
}

Measured memory_bytes: 9712
#include<vector>
#include<set>
#include<map>
#include<queue>
#include<string>
#include<algorithm>
#include<iostream>
#include<bitset>
#include<functional>
#include<numeric>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<cassert>
#include<cmath>
#include<random>
#include<ctime>
#include<complex>
using namespace std;
typedef long long LL;
mt19937 gene(233);
typedef complex<double> Complex;
#define fi first
#define se second
#define ins insert
#define pb push_back
inline char GET_CHAR(){
	const int maxn = 131072;
	static char buf[maxn],*p1=buf,*p2=buf;
	return p1==p2&&(p2=(p1=buf)+fread(buf,1,maxn,stdin),p1==p2)?EOF:*p1++;
}
inline int getInt() {
	int res(0);
	char c = getchar();
	while(c < '0') c = getchar();
	while(c >= '0') {
		res = res * 10 + (c - '0');
		c = getchar();
	}
	return res;
}

inline LL fastpo(LL x, LL n, LL mod) {
	LL res(1);
	while(n) {
		if(n & 1) {
			res = res * (LL)x % mod;
		}
		x = x * (LL) x % mod;
		n /= 2;
	}
	return res;
}

inline string itoa(int x, int width = 0) {
  string res;
  if(x == 0) res.push_back('0');
  while(x) {
    res.push_back('0' + x % 10);
    x /= 10;
  }
  while((int)res.size() < width) res.push_back('0');
  reverse(res.begin(), res.end());
  return res;
}
template<const LL mod> struct MI{
	LL a;
	MI operator + (const MI & b) {
		MI res{a + b.a};
		if(res.a >= mod) res.a -= mod;
		return res;
	}
	MI operator - (const MI & b) {
		MI res{a - b.a};
		if(res.a <= 0) res.a += mod;
		return res;
	}
	MI operator * (const MI & b) {
		return MI{a * b.a % mod};
	}
	MI operator / (const MI & b) {
		return MI{a * fastpo(b.a, mod - 2, mod) % mod};
	}
};
const int N = 300033;
const int LOG = 20;
const int mod = 1e9 + 7;
const int inf = 1e9 + 7;
int n, m;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
int main() {
	string t;
	cin >> t;
	for(char & c : t) {
		if(c == '?') c = 'D';
	}
	cout << t << endl;
}






Measured memory_bytes: 3756
cnt = 0
min = 10
li =[]

for i in range(5):
	a = int(input())
	li.append(a)
	if a % 10 == 0:
		cnt += a
	else:
		cnt += a + 10 - a % 10
		if a % 10 < min:
			min = a % 10

cnt = cnt + min - 10

print(cnt)


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

int main() {
  using tsii = tuple<string, int, int>;
  
  int N;
  
  cin >> N;
  
  vector<tsii> data(N);
  
  for (int i = 0; i < N; i++) {
    string town;
    int point;
    cin >> town >> point;
    data.at(i) = make_tuple(town, -1 * point, i + 1);
  }
  
  sort(data.begin(), data.end());
  
  for (int i = 0; i < N; i++) {
    cout << get<2>(data.at(i))  << endl;
  }
}

Measured memory_bytes: 256
#include<iostream>
#include<stack>
#include<string>
#include<vector>
#include<algorithm>
using namespace std;

int main(){
  stack<int> S1;
  stack<pair<int, int> > S2;
  char ch;
  int sum = 0;
  for (int i = 0; cin >> ch; i++){
    if(ch == '\\') S1.push(i);
    else if (ch == '/' && S1.size() > 0){
      int j = S1.top(); S1.pop();
      sum += i-j;
      int a = i - j;
      while(S2.size()>0 && S2.top().first >j){
        a += S2.top().second; S2.pop();
      }
      S2.push(make_pair(j, a));
    }
  }

  vector<int> ans;
  int t = 0;
  while(S2.size() > 0){ans.push_back(S2.top().second); S2.pop();}
  reverse(ans.begin(), ans.end());
  cout << sum << endl;
  cout << ans.size();
  for (int i = 0; i < ans.size(); i++){
    cout << " ";
    t += ans[i];
    cout << ans[i];
  }
  cout << endl;
  return 0;
}

Measured memory_bytes: 1280
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
int n,sum=0,m=101;
vector<int> s(100);

int main(){
 
  cin>>n;
  for(int i=0;i<n;i++){
    cin>>s[i];sum+=s[i];
    if(s[i]%10!=0)m=min(s[i],m);
  }
  if(sum%10!=0){cout<<sum<<endl;return 0;}
  else if(m!=101){cout<<sum-m<<endl;return 0;}
  else{cout<<0<<endl;}
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <algorithm>
using namespace std;

int N, Q, K;

vector<long long> dijkstra(int s, vector<vector<pair<int, long long>>>& adj) {
    vector<bool> visit(N);
    vector<long long> dist(N, 1e18), par(N);
    priority_queue<pair<long long, int>> q;
    dist[s] = 0; q.push(make_pair(0, s)); visit[s] = true;
    while (!q.empty()) {
        pair<int, int> tmp = q.top(); q.pop();
        int t = tmp.second; visit[t] = true;
        if (dist[t] < tmp.first * (-1) ) continue;  //別のルートでdist[t]が更新されていれば無視
        for (int i = 0; i < adj[t].size(); i++) {
            int next = adj[t][i].first;
            if (visit[next]) continue;
            if (dist[next] > dist[t] + adj[t][i].second) {
                dist[next] = dist[t] + adj[t][i].second;
                par[next] = t;
                q.push(make_pair(dist[next] * (-1), next));
            }
        }
    }
    return dist;
}

int main() {
    cin >> N;
    vector<vector<pair<int, long long>>> adj(N);
    for (int i = 1; i < N; i++) {
        int a, b; long long c;
        cin >> a >> b >> c;
        adj[a - 1].push_back(make_pair(b - 1, c));
        adj[b - 1].push_back(make_pair(a - 1, c));
    }
    cin >> Q >> K;
    vector<int> x(Q), y(Q);
    for (int i = 0; i < Q; i++) {
        cin >> x[i] >> y[i];
    }
    vector<long long> dist = dijkstra(K - 1, adj);
    for (int i = 0; i < Q; i++) {
//        cout << x[i] - 1 << " " <<  dist[x[i] - 1] << " " << y[i] - 1 << " " <<  dist[y[i] - 1] << endl;
        cout << dist[x[i] - 1] + dist[y[i] - 1] << endl;
    }
}



Measured memory_bytes: 12656
#include <bits/stdc++.h>
#define rep(i,n) for(int i=(0);i<(n);i++)

using namespace std;

typedef long long ll;

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

	int x;
	cin >> x;

	if(x == 7 || x == 5 || x == 3){
		cout << "YES" << endl;
	}else{
		cout << "NO" << endl;
	}
}


Measured memory_bytes: 256
#pragma region
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <vector>
#include <map>
#include <queue>
#include <stack>
#include <set>
#include <list>
#include <iomanip>
#include <cstdint>
#include <bitset>
#include <sstream>
#include <regex>

using namespace std;
typedef long long ll;
//#define rep(i, s, e) for (int(i) = (s); (i) < (e); ++(i))
#define rep(i, e) for (int(i) = 0; (i) < (e); ++(i))
#define rrep(i, s) for (int(i) = (s) - 1; (i) >= 0; --(i))
#define all(x) x.begin(),x.end()

#pragma region UnionFind
struct UnionFind
{
	vector<int> par;

	UnionFind(int n) : par(n, -1) {}
	void init(int n) { par.assign(n, -1); }

	int root(int x)
	{
		if (par[x] < 0) return x;
		else return par[x] = root(par[x]);
	}

	bool issame(int x, int y)
	{
		return root(x) == root(y);
	}

	bool merge(int x, int y)
	{
		x = root(x); y = root(y);
		if (x == y) return false;
		if (par[x] > par[y]) swap(x, y);
		par[x] += par[y];
		par[y] = x;
		return true;
	}

	int size(int x)
	{
		return -par[root(x)];
	}
};
#pragma endregion
#pragma region GCD
ll gcd(ll a, ll b)
{
	if (b == 0)return a;
	return gcd(b, a%b);
}
#pragma endregion
#pragma region LCM
ll lcm(ll a, ll b)
{
	return a / gcd(a, b) * b;
}
#pragma endregion
#pragma region chmin
template<class T> inline bool chmin(T& a, T b)
{
	if (a > b)
	{
		a = b;
		return true;
	}
	return false;
}
#pragma endregion
#pragma region chmax
template<class T> inline bool chmax(T& a, T b)
{
	if (a < b)
	{
		a = b;
		return true;
	}
	return false;
}
#pragma endregion
#pragma endregion


int main()
{
	vector<int> v(4);
	rep(i, 3)
	{
		int a, b; cin >> a >> b;
		--a, --b;
		++v[a], ++v[b];
	}
	rep(i, 4)
	{
		if (v[i] == 3)
		{
			cout << "NO" << endl;
			return 0;
		}
	}
	cout << "YES" << endl;
}

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

using namespace std;

deque<int> deq;

void rec(int x) {
  deq.push_front(x);
  if (x == 1) {
    return;
  } else if (x % 2 == 1) {
    rec(x - 1);
  } else {
    rec(x / 2);
  }
}

struct edge {
  int from, to, cost;
};

int main() {
  int l;
  cin >> l;
  rec(l);
  vector<edge> e;
  int now = 1;
  for (auto d: deq) {
    if (d == 1) continue;
    if (d % 2 == 1) {
      e.push_back({1, now, d - 1});
    } else {
      for (auto &v: e) {
        v.cost *= 2;
      }
      e.push_back({now, now + 1, 1});
      e.push_back({now, now + 1, 0});
      now++;
    }
  }
  cout << now << " " << e.size() << endl;
  for (auto &v: e) {
    cout << v.from << " " << v.to << " " << v.cost << 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++)
using ll = long long;
using P = pair<int,int>;
int main(void) {
    string s[3];
    rep(i, 3) cin >> s[i];
    bool ok = false;
    if(s[0][s[0].size()-1] == s[1][0]&&s[1][s[1].size()-1]==s[2][0])
    ok = true;
    if(ok) cout << "YES";
    else cout << "NO";
}


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

#define fi first
#define se second

using namespace std;

typedef pair<int, int> ii;

int n, w, v[105], we[105];
long long dp[100005][105];

long long recur(int cap, int i)
{
	if(i > n)
		return 0;
	if(cap < we[i])
		return recur(cap, i + 1);
	else
		return max(v[i] + recur(cap - we[i], i + 1), recur(cap, i + 1));
}
int main()
{
	cin >> n >> w;
	for(int i = 1; i <= n; ++i)
		cin >> we[i] >> v[i];
	memset(dp, 0, sizeof dp);
//	for(int i = 0; i <= w; ++i)
//		dp[i][0] = 0;
//	for(int i = 0; i <= n; ++i)
//		dp[0][i] = 0;
	for(int i = 1; i <= w; ++i)
	{
		for(int j = 1; j <= n; ++j)
		{
			if(we[j] > i)
				dp[i][j] = dp[i][j - 1];
			else
				dp[i][j] = max(v[j] + dp[i - we[j]][j - 1], dp[i][j - 1]);
		}
	}
	cout << dp[w][n];
	return 0;
}

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

#define fi first
#define se second
#define pb push_back
 
#define limit (int) (1e6 + 5)

#define maxn (long long int) (2147483647);

using namespace std;
using lli = long long int;
using ulli = unsigned long long int;
using ld = long double;


int main()
{
    lli n,d;
    cin >> n >> d;

    int ans = 0;

    lli x,y;
    d *= d;

    // cout << d << "\n";

     for (int i = 0; i < n; ++i)
     {
        cin >> x >> y;

        if (d >= (x*x) + (y*y))
        {
            ans++;
        }
     }

     cout << ans;
    return 0;
}


















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

int main() {
    char c[4];
    int flg = 0;
    cin >> c;

    if(c[0]==c[1] && c[0]== c[2])
        flg = 1;
    if(c[3]==c[1] && c[3]== c[2])
        flg = 1;

    if(flg)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 3624
from collections import Counter
N,K,L=map(int,input().split())
drive = [-1] * N;train = [-1] * N
def find(List,x):
  if List[x] < 0:
    return x
  List[x] = find(List,List[x])
  return List[x]
def unite(List,x,y):
  if find(List,x) != find(List,y):
    List[find(List,y)] = find(List,x)
for i in range(K+L):
  a, b = map(int,input().split())
  unite(drive if i < K else train,a-1, b-1)
pair = [(find(drive,i), find(train,i)) for i in range(N)]
c =Counter(pair)
print(*[c[pair[i]] for i in range(N)])

Measured memory_bytes: 44392
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define ld long double
#define ff first
#define ss second
#define pb push_back
#define all(x) x.begin(),x.end()
#define pll pair<ll,ll>
#define mp make_pair
#define bp __builtin_popcountll
#define MOD  998244353
const int N = 10000;
#define FAST ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);srand(time(NULL));

void solve()
{
     ll n;
     cin >> n;
     ll temp = 100;
     ll ans = 0;
     while(temp<n)
     {
          ans++;
          temp = temp + temp/100;
     }
     cout<<ans;
}

int main()
{
     FAST;
     ll t = 1;
   //  cin >> t; 
     for(ll i=1;i<=t;i++)
     {
         // cout<<"Case #"<<i<<": ";
          solve();
     }
}

Measured memory_bytes: 3660
#include "bits/stdc++.h"
#define in std::cin
#define out std::cout
#define rep(i,N) for(int i=0;i<N;++i)
typedef long long int LL;
 
std::string S, T;
 
int main()
{
	in >> S >> T;
 
	if (S.length() < T.length())
	{
		out << "UNRESTORABLE" << std::endl;
		return 0;
	}
	for (int i = S.length() - T.length(); i >= 0; --i)
	{
		bool ok = true;
		for (int j = i; (j - i) < T.length(); ++j)
		{
			if (S[j] != '?'&&S[j] != T[j - i])
			{
				ok = false;
				break;
			}
		}
		if (ok)
		{
			rep(j, i)
			{
				if (S[j] == '?') { S[j] = 'a'; }
				out << S[j];
			}
			out << T;
			for (int j = i + T.length(); j < S.length(); ++j)
			{
				if (S[j] == '?') { S[j] = 'a'; }
				out << S[j];
			}
			out << std::endl;
			return 0;
		}
	}
	out << "UNRESTORABLE" << std::endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <queue>
#include <cstring>
#include <algorithm>
#include <cstdlib>
#include <string>
#include <set>
#include <stack>
#include <map>
#include <tuple>
#include <cmath>

using namespace std;
typedef long long ll;


int main() {
	ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
	string s; cin >> s;
	if (s[0] == 'R' && s[1] == 'R' && s[2] == 'R') {
		cout << 3 << '\n';
	}
	else if (s[0] == 'R' && s[1] == 'R') {
		cout << 2 << '\n';
	}
	else if (s[1] == 'R' && s[2] == 'R') {
		cout << 2 << '\n';
	}
	else if(s[0] == 'R' || s[1] == 'R' || s[2] == 'R'){
		cout << 1 << '\n';
	}
	else cout << 0 << '\n';





}

Measured memory_bytes: 3200
#include <bits/stdc++.h>
#define REP(i, s, n) for (int i = s; i < (int)(n); i++)
#define ALL(a) a.begin(), a.end()
#define MOD 1000000007
using namespace std;
using ll = long long;

int N, K;
vector<int> D;

int main() {
    cin >> N >> K;
    D.resize(N);
    REP(i, 0, N) cin >> D[i];
    
    vector<int> A(N + 1, 0), B(N + 1, 0);
    using pq = priority_queue<int, vector<int>, greater<int>>;
    vector<pq> AQ(N + 1), BQ(N + 1);
    REP(i, 0, N) {
        A[i + 1] += A[i] + D[i];
        B[i + 1] += B[i] + D[N - 1 - i];
        AQ[i + 1] = AQ[i];
        BQ[i + 1] = BQ[i];
        if (D[i] < 0) AQ[i + 1].push(D[i]);
        if (D[N - 1 - i] < 0) BQ[i + 1].push(D[N - 1 - i]);
    }

    int ans = 0;
    REP(a, 0, min(N, K) + 1) {
        REP(b, 0, min(N, K) + 1) {
            if (a + b > min(N, K)) continue;
            int rem = K - a - b, cur = A[a] + B[b];
            // cout << "# a : " << a << ", b : " << b << ", cur : " << cur << ", rem : " << rem << endl;
            if (rem > 0) {
                pq tmpa = AQ[a], tmpb = BQ[b];
                while (rem--) {
                    if (tmpa.empty() && tmpb.empty()) {
                        break;
                    } else if (tmpa.empty()) {
                        cur -= tmpb.top(); tmpb.pop();
                    } else if (tmpb.empty()) {
                        cur -= tmpa.top(); tmpa.pop();
                    } else {
                        if (tmpa.top() < tmpb.top()) {
                            cur -= tmpa.top(); tmpa.pop();
                        } else {
                            cur -= tmpb.top(); tmpb.pop();
                        }
                    }
                }
            }
            // cout << "--> cur : " << cur << endl;
            ans = max(ans, cur);
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
/*
 * Creat       : Sat Jul 13 16:04:22 CST 2019
 * Accept      : Sat Jul 13 16:27:03 CST 2019
 * Author      : landcold7
 */
#include <bits/stdc++.h>
using namespace std;

#define x first
#define y second
#define sz(x) ((int)(x).size())
#ifndef _has_trace
#define trace(...)
#endif
typedef long long ll;

void solve() {
  int n, m;
  cin >> n >> m;
  typedef pair<int, int> pii;
  priority_queue<pii, vector<pii>> dq;
  for (int i = 0; i < n; ++i) {
    int x;
    cin >> x;
    dq.push({x, 1});
  }
  for (int i = 0; i < m; ++i) {
    int x, y;
    cin >> x >> y;
    dq.push({y, x});
  }
  ll ans = 0;
  while (n > 0) {
    auto p = dq.top();
    dq.pop();
    int x = min(n, p.y);
    ans += x * 1ll * p.x;
    n -= x;
  }
  cout << ans << "\n";
}

int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  solve();
  return 0;
}


Measured memory_bytes: 2420
N = int(input())
a = list(map(int, input().split()))
if 0 in a:
    print(0)
else:
    ans = 1
    for i in range(N):
        ans *= a[i]
        if ans > 10 ** 18:
            break
    if ans > 10 ** 18:
        print(-1)
    else:
        print(ans)

Measured memory_bytes: 21640
import math
n, m = map(int, input().split())
if abs(n - m) == 1:
  print(math.factorial(n) * math.factorial(m) % (10**9 + 7))
elif abs(n - m) == 0:
  print(math.factorial(n) * math.factorial(m) * 2 % (10**9 + 7))
else:
  print(0)

Measured memory_bytes: 55152
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef unsigned int uint;
typedef unsigned char uchar;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;

#define REP(i,x) for(int i=0;i<(int)(x);i++)
#define REPS(i,x) for(int i=1;i<=(int)(x);i++)
#define RREP(i,x) for(int i=((int)(x)-1);i>=0;i--)
#define RREPS(i,x) for(int i=((int)(x));i>0;i--)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();i++)
#define RFOR(i,c) for(__typeof((c).rbegin())i=(c).rbegin();i!=(c).rend();i++)
#define ALL(container) (container).begin(), (container).end()
#define RALL(container) (container).rbegin(), (container).rend()
#define SZ(container) ((int)container.size())
#define mp(a,b) make_pair(a, b)
#define pb push_back
#define eb emplace_back
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
#define __builtin_popcount __builtin_popcountll

template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
template<class T> ostream& operator<<(ostream &os, const vector<T> &t) {
    os<<"["; FOR(it,t) {if(it!=t.begin()) os<<","; os<<*it;} os<<"]"; return os;
}
template<class T> ostream& operator<<(ostream &os, const set<T> &t) {
    os<<"{"; FOR(it,t) {if(it!=t.begin()) os<<","; os<<*it;} os<<"}"; return os;
}
template<class S, class T> ostream& operator<<(ostream &os, const map<S, T> &t) {
    os<<"{"; FOR(it,t) {if(it!=t.begin()) os<<","; os<<*it;} os<<"}"; return os;
}
template<class S, class T> ostream& operator<<(ostream &os, const pair<S,T> &t) { return os<<"("<<t.first<<","<<t.second<<")";}
template<class S, class T> pair<S,T> operator+(const pair<S,T> &s, const pair<S,T> &t){ return pair<S,T>(s.first+t.first, s.second+t.second);}
template<class S, class T> pair<S,T> operator-(const pair<S,T> &s, const pair<S,T> &t){ return pair<S,T>(s.first-t.first, s.second-t.second);}

const int INF = 1<<28;
const double EPS = 1e-8;
const int MOD = 1000000007;


int T, n, m;

int calc(int l, int r) {
    if (0 <= l) return r;
    if (r <= 0) return -l;
    return min(-l * 2 + r, -l + r * 2);
}

int main(int argc, char *argv[]){
    ios::sync_with_stdio(false);
    while(cin >> n >> m) {
        vi d(n);
        REP(i, n) cin >> d[i];
        int ans = MOD;
        for(int l=0,r=l+m-1;r<n;l++, r++) {
            ans = min(ans, calc(d[l], d[r]));
        }
        cout << ans << endl;
    }
    return 0;
}


Measured memory_bytes: 640
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string.h>
#include<queue>
#include<utility>
#include<algorithm>
#include<math.h>
using namespace std;
int main(){
	int N,D;
	cin>>N>>D;
	D=D*2+1;
	int ans=0;
	if(N%D==0) ans=N/D;
	else ans=N/D+1;
	cout<<ans;
	return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define all(s) s.begin(), s.end()
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<P> vp;
const int MX = 100005, INF = 1001001001;
const ll LINF = 1e18;
const double eps = 1e-10;
const int DIV = 1e9+7;


int main() {
    int d;
    cin >>d;
    if (d == 25) cout << "Christmas" << endl;
    else if (d == 24) cout << "Christmas Eve" << endl;
    else if (d == 23) cout << "Christmas Eve Eve" << endl;
    else if (d == 22) cout << "Christmas Eve Eve Eve" << endl;
}


Measured memory_bytes: 256
from collections import deque
n =int(input())
a = [0]+list(map(int, input().split()))
d = deque()
cnt=0
for i in range(n,0,-1):    
  for j in range(i,n+1,i):
    if a[j]==0:
      continue
    cnt+=1
  b = cnt%2
  a[i] = b
  if b == 1:
    d.appendleft(i)
  cnt = 0
print(len(d))
print(' '.join(map(str,d)))


Measured memory_bytes: 100752
n=int(input())
a=list(map(int,input().split()))

x=1000
y=0
for i in range(n):
    if i==0:
        if a[i]<a[i+1]:
            y=x//a[i]
            x%=a[i]
    elif i==n-1:
        x+=y*a[i]
    else:
        if y>0 and a[i]>a[i+1]:
            x+=y*a[i]
            y=0
        elif y==0 and a[i]<a[i+1]:
            y=x//a[i]
            x%=a[i]
print(x)


Measured memory_bytes: 61908
package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
)

const pi = math.Pi

var mod int = pow(10, 9) + 7
var Umod uint64 = 1000000007
var ans, cnt, sum int = 0, 0, 0

func main() {
	var N int
	var S string
	fmt.Scan(&N, &S)

	// i文字目から，j文字目から始まる文字列のうち最長のもの
	var dp = [5005][5005]int{}
	//dp[0][0] = 1

	for i := N - 1; 0 <= i; i-- {
		for j := N - 1; 0 <= j; j-- {
			if string(S[i]) == string(S[j]) {
				dp[i][j] = dp[i+1][j+1] + 1
			} else {
				dp[i][j] = 0
			}
		}
	}

	for i := 0; i < N; i++ {
		for j := i + 1; j < N; j++ {
			now := min(dp[i][j], j-i)
			ans = max(ans, now)
		}
	}
	fmt.Println(ans)
}

/*  ----------------------------------------  */

var reader = bufio.NewScanner(os.Stdin)

func read() string {
	reader.Scan()
	return reader.Text()
}

func lcm(x, y int) int {
	return (x / gcd(x, y)) * y
}

func gcd(x, y int) int {
	if x%y == 0 {
		return y
	} else {
		r := x % y
		return gcd(y, r)
	}
}

var fac [1000000]int
var finv [1000000]int
var inv [1000000]int

func combination_init() {
	fac[0], fac[1] = 1, 1
	finv[0], finv[1] = 1, 1
	inv[1] = 1

	// invは a^(-1) mod p
	// pをaで割ることを考える

	// p/a*(a) + p%a = p
	// p/a*(a) + p%a = 0          (mod p)
	// -p%a = p/a*(a)             (mod p)
	// -p%a *a^(-1)= p/a          (mod p)
	// a^(-1)= p/a * (-p%a)^(-1)  (mod p)
	// a^(-1) =

	for i := 2; i < 1000000; i++ {
		fac[i] = fac[i-1] * i % mod
		inv[i] = mod - inv[mod%i]*(mod/i)%mod
		finv[i] = finv[i-1] * inv[i] % mod
	}
}

func combination(x, y int) int {
	if x < y {
		return 0
	}
	if fac[0] != 1 {
		combination_init()
	}
	return fac[x] * (finv[y] * finv[x-y] % mod) % mod
	//return fac[x] / (fac[y] * fac[x-y])
}

func permutation(x, y int) int {
	if x < y {
		return 0
	}
	if fac[0] != 1 {
		combination_init()
	}
	return fac[x] * (finv[x-y] % mod) % mod
	//return fac[x] / fac[x-y]
}

func max(x ...int) int {
	var res int = x[0]
	for i := 1; i < len(x); i++ {
		res = int(math.Max(float64(x[i]), float64(res)))
	}
	return res
}

func min(x ...int) int {
	var res int = x[0]
	for i := 1; i < len(x); i++ {
		res = int(math.Min(float64(x[i]), float64(res)))
	}
	return res
}
func pow(x, y int) int { return int(math.Pow(float64(x), float64(y))) }
func abs(x int) int    { return int(math.Abs(float64(x))) }
func floor(x int) int  { return int(math.Floor(float64(x))) }
func ceil(x int) int   { return int(math.Ceil(float64(x))) }

type SortBy []int

func (a SortBy) Len() int           { return len(a) }
func (a SortBy) Swap(i, j int)      { a[i], a[j] = a[j], a[i] }
func (a SortBy) Less(i, j int) bool { return a[i] < a[j] }

type PriorityQueue []int

func (h PriorityQueue) Len() int            { return len(h) }
func (h PriorityQueue) Less(i, j int) bool  { return h[i] > h[j] }
func (h PriorityQueue) Swap(i, j int)       { h[i], h[j] = h[j], h[i] }
func (h *PriorityQueue) Push(x interface{}) { *h = append(*h, x.(int)) }
func (h *PriorityQueue) Pop() interface{} {
	old := *h
	n := len(old)
	x := old[n-1]
	*h = old[0 : n-1]
	return x
}


Measured memory_bytes: 205184
// AtCoder template
// sabaより胡蝶しのぶさんの方が可愛いのではないか？
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i = 0; i < n; ++i)

struct edge{
    int to;
    ll cost;
};
vector<vector<edge>> graph(100001);
vector<ll> dp(100001,-1);

void dfs(int now, ll depth){
    if(dp[now] != -1) return;
    dp[now] = depth;
    rep(i,graph[now].size()){
        int next = graph[now][i].to;
        dfs(next,depth+graph[now][i].cost);
    }
}

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

    string s; cin >> s;
    int gcnt = 0;
    int pcnt = 0;
    int ans = 0;
    rep(i,s.size()){
        if(s[i] == 'g'){
            if(pcnt+1 <= gcnt){
                pcnt++;
                ans++;
            }else{
                gcnt++;
            }
        }else{
            if(pcnt+1 <= gcnt) pcnt++;
            else{
                gcnt++;
                ans--;
            }
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 3712
#include <algorithm>
#include <array>
#include <bitset>
#include <cstdint>
#include <deque>
#include <functional>
#include <iostream>
#include <limits>
#include <memory>
#include <vector>

constexpr std::int64_t INF = 1ull << 50;

auto main() -> int {
  int A, B;
  std::cin >> A >> B;
  int ans = (B % A == 0) ? A + B : B - A;
  std::cout << ans << '\n';
}


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

#define NREP() for(ll i = 0; i < n; i++)
#define REP(i, n) for(ll i = 0; i < n; i++)
#define ALL(x) (x).begin(), (x).end()
#define MSG(x) cout << x << endl;
#define YN(x) x ? cout << "YES" << endl : cout << "NO" << endl;
#define Yn(x) x ? cout << "Yes" << endl : cout << "No" << endl;
#define yn(x) x ? cout << "yes" << endl : cout << "no" << endl;

using namespace std;
using ll = long long;
const static ll MOD = 1e9 + 7;

int main(int argc, char *argv[]) {
    ll a, b, c;
    cin >> a >> b >> c;
    Yn(a == b && a != c || a != b && b == c || a == c && b != c)
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define f first
#define s second
#define MOD 1000000007
#define PMOD 998244353
#define pb(x) push_back(x)
using namespace std;

typedef long long int ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> plii;
typedef pair<int, pii> piii;
const int INF = 1e9+10;
const ll LINF = 1LL*INF*INF;
const int MAXN = 2e5+10;
const int MAXM = 5e3+10;

priority_queue<int> pq;
vector<vector<int> > graph;
queue<int> que;

char S[MAXM];
int dp[MAXM][MAXM];

int main()
{
    int n,m,k,a,b,x,y,q;
    int sum = 0;
    int cnt = 0;
    int mx = 0;
    int mn = INF;
    int cur = 0, idx = -1;
    int tc;

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    cin>>n>>S;

    int res = 0;

    for(int i=n-1;i>=0;i--)
        for(int j=n-1;j>i;j--){
            if(S[i]==S[j])dp[i][j] = max(dp[i][j],dp[i+1][j+1]+1);
            res = max(res,min(dp[i][j],j-i));
        }

    cout<<res<<"\n";

    return 0;
}


Measured memory_bytes: 96896
buildings=[[[0 for i in range(10)]for m in range(3)]for k in range(4)]
x=int(input())
for i in range(x):
    a,b,c,d=map(int,input().split())
    buildings[a-1][b-1][c-1]+=d
for i in range(4):
    for j in range(3):
        for k in range(10):
            print("",buildings[i][j][k],end="")
        print()
    if i!=3:
        print("#"*20)

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

uint64_t sum(uint64_t *ar, int n) {
    uint64_t r = 0;
    for (int i = 0; i < n; ++i) {
        r += ar[i];
    }
    return r;
}

int arcount(uint64_t *ar, int n, uint64_t t) {
    int r = 0;
    for (int i = 0; i < n; ++i) {
        if (ar[i] == t) { ++r; }
    }
    return r;
}

uint64_t ncm(int n, int m) {
    uint64_t r = 1;
    for (int i = 1; i < m+1; ++i, --n) {
        r *= n;
        r /= i;
    }
    return r;
}

int f(uint64_t s, int n) {
    int r = 10;
    int b = 0;
    string t = to_string(s % n) + "000000";
    for (int i = 0; i < 6; ++i) {
        b += (int)(t[i] - '0');
        r += b / n;
        b %= n;
        r *= 10;
        b *= 10;
    }
    return (r - 10000000) / 10;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N, A, B;
    cin >> N >> A >> B;
    uint64_t v[N];
    for (auto& i : v) { cin >> i; }
    sort(v, v+N, greater<uint64_t>());
    uint64_t d = sum(v, A) / A;
    int m = f(sum(v, A), A);
    vector<int> l;
    for (int i = A; i < B+1; ++i) {
        if (sum(v, i) / i == d && f(sum(v, i), i) == m) { l.push_back(i); }
    }
    uint64_t cnt = 0;
    for (auto& i : l) {
        uint64_t tcnt = 1;
        uint64_t t = 0;
        for (int j = 0; j < i; ++j) {
            if (v[j] != t) {
                t = v[j];
                int x = arcount(v, N, t);
                int y = arcount(v, i, t);
                tcnt *= ncm(x, y);
            }
        }
        cnt += tcnt;
    }
    
    cout << d << '.' << m << endl;
    cout << cnt << endl;
    
    
    
    return 0;
}

Measured memory_bytes: 256