akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
 
#define ll          long long
#define pb          push_back
#define ppb         pop_back
#define int         ll int
#define float       double
#define	endl		'\n'
#define maxpq       priority_queue<ll>
#define minpq       priority_queue<ll, vector<ll>, greater<ll> >
#define mii         map<int,int>
#define msi         map<string,int>
#define mis         map< int, string>
#define mpi         map<pair< int, int>, int>
#define pii         pair< int, int>
#define vi          vector< int>
#define vs          vector<string>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (ll int)x.size()
#define hell        1000000007
#define lbnd        lower_bound
#define ubnd        upper_bound
#define bs          binary_search
#define mp          make_pair
#define EPS         1e-9
#define INF         1e18
#define PI          3.14159265358979323846
#define MAXI        1000000
#define what_is(x)  cerr << #x << " is " << x << endl;
#define fast ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
using namespace std;
#define N 100005
int modexp(int x,int n,int mod){
	x%=mod;
	int res=1;
	while(n>0){
		if(n&1) res=res*x%mod;
		x=x*x%mod;
		n/=2;
	}
	return res;
}
int modInverse(int n, int p)
{ 
    return modexp(n, p - 2, p); 
} 
int nCr(int n,int r, int p) 
{ 
    if (r == 0) 
        return 1; 
    int fac[n + 1]; 
    fac[0] = 1; 
    for (int i = 1; i <= n; i++) 
        fac[i] = (fac[i - 1] * i) % p; 
  
    return (fac[n] * modInverse(fac[r], p) % p * modInverse(fac[n - r], p) % p) % p; 
} 
// writing good dfs function
//void dfs(int start,int parent)
//{
//	sz[start]=1;
//	df[start]=df[parent]+1;
//	for(auto x:v[start])
//	{
//		if(x==parent) continue;
//		dfs(x,start);
//		sz[start]+=sz[x];
//	}
//}
int dp[2005];
int rec(int s)
{
	if(s==0) return 1;
	if(s>0&&s<=2) return 0;
	if(dp[s]!=-1) return dp[s];
	int sum=0;
	for(int i=3;i<=s;i++)
	{
		sum+=rec(s-i)%hell;
	}
	return dp[s]=sum;
}
signed main()
{
	fast;
	int t=1;
//	cin>>t;
	while(t--)
	{
//		int n;
//		cin>>n;
//		if(n==1) cout<<0<<endl;
//		else if(n==2) cout<<2<<endl;
//		else {
//			int x=n*(n-1);
//			x%=hell;
//			int y=modexp(10,n-2,hell);
//			y%=hell;
//			cout<<((x*y))%hell;
//		}
      int s;
      cin>>s;
      memset(dp,-1,sizeof(dp));
      cout<<rec(s)%hell<<endl;
	}
   return 0;
}

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

typedef long long ll;

#define REP(i, n) for(int i= 0; i < (n); ++i)
#define FOR(i, a, b) for(int i = (a); i < (b); ++i)
const ll MOD = 1e9 + 7;


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

template<class T> inline bool chmax(T& a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}
 
 //入力
int N;          //段数
int M;          //移動不可ノード数
vector<bool> issafe;    //移動不可ノード
vector<ll> dp(110000);  //DPテーブル

const ll INF = 1LL << 60;   //2^60で初期化

int main() {
    cin >> N >> M; //N= 階段の総数 M=移動が不可能な段数
    
    issafe.assign(N+1, true); //issafeをN個作成し、trueで初期化

    for (int i = 0; i < M; ++i) {
        int a; cin >> a;
        issafe[a] = false;  //壊れている段数をfalseに
    }

    //初期条件
    dp[0] = 1;
    if (issafe[1]) dp[1] = 1;

    //ループ、比較
    for (int i = 2; i <= N; ++i) {
        if (issafe[i-1]) dp[i] += dp[i - 1];
        if (issafe[i-2]) dp[i] += dp[i - 2];
        dp[i] %= MOD;
    }

    cout << dp[N] << '\n';

    return 0;
}

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

using namespace std;

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

    vector<int> v(N);
    for (int i = 0; i < N; ++i)
        cin >> v[i];

    // ceil((N-1) / (K-1))
    int count = ((N - 1) + ((K - 1) - 1)) / (K - 1);
    cout << count << '\n';
}


Measured memory_bytes: 640
#include "bits/stdc++.h"
using namespace std;
#define REP(i, n) for(ll i = 0;i < n;i++)
#define ll long long
#define MOD 1000000007LL
using vi = vector<ll>; // intの1次元の型に vi という別名をつける
using vvi = vector<vi>; // intの2次元の型に vvi という別名をつける
using vvvi = vector<vvi>; // intの2次元の型に vvi という別名をつける
const ll llMAX=9223372036854775807LL; 
const ll llMIN=-9223372036854775808LL;

ll n,x,m;

int main(){
  ll ans=0;
  cin >> n>>x>>m;
  vi a(m*2+1);
  vi sued(m*2+1);

  a[0]=x;
  sued[a[0]]++;
  ll repnum_start=0;
  ll repnum_end=0;
  

  for(ll i=1;i<m*2;i++){
    
    a[i]=a[i-1]*a[i-1]%m;
    
    if (sued[a[i]]==1)
    {
      repnum_end=i;
      for(ll j=0;j<repnum_end;j++){
        if (a[j]==a[i]){
          repnum_start=j;
          break;
        }
      }
      break;
    }
    
    sued[a[i]]++;
    /*
    if (a[i]==a[0]){
      repnum=i;
      break;
    }
    */
  }
  
/*
  cout<<repnum_start<<endl;
  cout<<repnum_end<<endl;
*/
  if (n<=repnum_end){

    for(ll i=0;i<n;i++){
      ans+=a[i];
    }
    cout<<ans<<endl;
    return 0;
  }


  ll onesum=0;
  for(ll i=repnum_start;i<repnum_end;i++){
    onesum+=a[i];
  }
  for(ll i=0;i<repnum_start;i++){
    ans+=a[i];
  }

  n-=repnum_start;
  ll repnum=repnum_end-repnum_start;
  ll nn=n/repnum;

  ans+=nn*onesum;

  n-=nn*repnum;

  for(ll i=repnum_start;i<(repnum_start+n);i++){
    ans+=a[i];
  }

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

Measured memory_bytes: 6348
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int n;
int enda, startb, ba, occ;
char inp[20];
int main()
{
	scanf("%d", &n);
	for (int i = 0; i < n; i++)
	{
		scanf(" %s", inp);
		for (int j = 0; j < (int)strlen(inp)-1; j++)
		{
			if (inp[j] == 'A' && inp[j+1] == 'B') occ++;
		}
		if (inp[0] == 'B' && inp[(int)strlen(inp)-1] == 'A') ba++;
		else if (inp[0] == 'B') startb++;
		else if (inp[strlen(inp)-1] == 'A') enda++;
	}
	bool havea = 0;
	if (enda)
	{
		enda--;
		havea = 1;
	}
	while (ba)
	{
		if (havea) occ++;
		ba--;
		havea = 1;
	}
	while (enda || startb)
	{
		if (havea && startb)
		{
			havea = 0;
			startb--;
			occ++;
		}
		else if (enda)
		{
			enda--;
			havea = 1;
		}
		else break;
	}
	printf("%d\n", occ);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
  long long N; cin >> N;
  vector<long long> A(N);
  for(int i=0; i<N; i++) cin >> A[i];
  
  vector<long long> B(N+1,0);
  map<long long,long long> nums;
  for(int i=1; i<=N; i++) B[i] = B[i-1] + A[i-1];
  for(int i=0; i<=N; i++) nums[B[i]]++;
  
  long long ans =0;
  for(auto it : nums) {
    long long num = it.second;
    ans += num*(num-1)/2;
  }
  cout << ans << endl;
}

Measured memory_bytes: 18820
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.math.BigInteger;
import java.util.*;
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskD solver = new TaskD();
        solver.solve(1, in, out);
        out.close();
    }
    static class TaskD {
        static int log(long a  , long b){
            int ans = 0;
            while (a/b!=0){a/=b;ans++;}
            return ans;
        }
        static long pow(long a , long b){
            if (b==0)return 1;
            long v = pow(a , b/2);
            long ans = v*v;
            if (b%2!=0)ans*=a;
            return ans;
        }
        static  int[] count;
        static  boolean[] visited;
        static ArrayList<Integer>[] frinds;
        static int[] color ;
        public static void dfs(int v , int val){
            visited[v]=true;
            count[val]++;
            color[v]=val;
            if (frinds[v]!=null)for (int u: frinds[v]) {
                if (!visited[u]) dfs(u , val);
            }
        }
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            long n = in.nextInt();
            long m = in.nextInt();
            long ans = n*m;
            if (n>=2 && m>=2)ans-=(2*n+2*m-4);
            else {
                if (n==1 && m==1)ans=1;
                else ans-=2;
            }
            System.out.println(ans);

        }
    }
    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }
        public int nextInt(){return  Integer.parseInt(next());}
        public long nextLong() {
            return Long.parseLong(next());
        }

    }
}

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


int main(){
    string s1,s2;
    cin >> s1 >> s2;

    s1 += s2;
    ll num = stoi(s1);

    for(int i = 0; i < 1000; i++){
        if(num == i * i){
            cout << "Yes" << endl;
            return 0;
        }
    }

    cout << "No" << endl;
}

Measured memory_bytes: 256
/*
    Problem 87
    https://atcoder.jp/contests/abc120/tasks/abc120_d
*/
#include <bits/stdc++.h>
using namespace std;
/* typedef */
typedef long long ll;
typedef pair<ll, ll> pii;
/* class */
class DisjointSet {
    public:
    vector<int> d;
    DisjointSet(int size) : d(size, -1) {}
    int find(int x) {
        if (d[x] < 0) return x;
        return d[x] = find(d[x]);
    }
    bool unite(int x, int y) {
        x = find(x), y = find(y);
        if (x == y) return 0;
        if (d[x] > d[y]) swap(x, y);
        d[x] += d[y];
        d[y] = x;
        return true;
    }
    bool same(int x, int y) { return find(x) == find(y); }
    ll size(int x) { return -d[find(x)]; }
};
/* constant */
/* global variables */
/* function */
/* main */
int main(){
    ll N, M;
    ll x, y;
    cin >> N >> M;
    DisjointSet ds = DisjointSet(N);
    vector<pii> edge(M);
    for (int i = 0; i < M; i++) {
        cin >> x >> y;
        x--; y--;
        edge[i] = pii(x, y);
    }
    reverse(edge.begin(), edge.end());
    vector<ll> res;
    ll ans = N * (N-1) / 2;
    res.push_back(ans);
    for (int k = 0; k < M - 1; k++) {
        int x = edge[k].first, y = edge[k].second;
        if (!ds.same(x, y)) {
            ans -= ds.size(x) * ds.size(y);
            ds.unite(x, y);
        }
        res.push_back(ans);
    }
    for (auto it = res.rbegin(); it != res.rend(); it++) cout << *it << '\n';
}

Measured memory_bytes: 4212
def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))

def main():
    mod=10**9+7
    N=I()
    from collections import defaultdict
    dd = defaultdict(int)
    for i in range(N):
        S=input()
        dd[S]+=1
        
    print("AC x",dd["AC"])
    print("WA x",dd["WA"])
    print("TLE x",dd["TLE"])
    print("RE x",dd["RE"])

main()


Measured memory_bytes: 69956
#include <bits/stdc++.h>
#define rep(i,n) for(long long int i = 0; i < n; i++)
#define _rep(i,m,n) for(long long int i = m; i < n; i++)
#define print(n) std::cout << n << std::endl
#define _print(n) std::cout << n
using namespace std;
typedef long long ll;
const int N = 1000000;
const ll mod = 1000000007;
using Graph = vector<vector<int>>;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

int main(){
    ll n,m; cin >> n >> m;
    cout << (ll)pow(2, m) * (n - m) * 100 + 1900 * m * (ll)pow(2, m);
    



    /*int n; cin >> n;
    string s; cin >> s;
    vector<int> white(n, 0);
    vector<int> white_sum(n + 1);
    vector<int> black(n, 0);
    vector<int> black_sum(n + 1);

    
    rep(i,n){
        if(s[i] == '.')white[i] = 1;
        if(s[i] == '#')black[i] = i;
    }
    _rep(i, 1, n + 1){
        white_sum[i] = white[i - 1] + white_sum[i - 1];
        black_sum[i] = black[i - 1] + black_sum[i - 1];
        cout << white_sum[i] << endl;
    }
    int ans_min = N;
    rep(i,n + 1){
        int ans = white_sum[n] - white_sum[i];
        ans_min = min(ans, ans_min);
    }
    cout << ans_min << endl;*/
}

Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#include<bits/stdc++.h>
using namespace std;
#define ull unsigned long long
#define ll long long
#define fast  ios_base::sync_with_stdio(0); cin.tie(0);
#define f(i,k) for(i=0;i<k;i++)
#define rep(i,n) for(i=1;i<=n;i++)
#define input(i,n,arr) for(i=0;i<n;i++) cin>>j, arr.push_back(j)
#define vect_ll vector<long long>
#define vect_ll_it vector<long long>::iterator
#define pb(p) push_back(p)
#define endl "\n"
#define mod 1000000007
const ll inf = 1e18;
ll l[1000001], h[1000001], p[1000001];
unordered_map<ll, ll> m;
int main()
{
#ifndef ONLINE_JUDGE
	freopen("input1.txt" , "r" , stdin);
	freopen("output1.txt" , "w", stdout);
#endif
	fast
	int t = 1, test;
	//cin >> t;
	for (test = 1; test <= t; test++)
	{
		ll i, j, n;
		vect_ll a;
		a.clear();
		cin >> n;
		input(i, n, a);
		ll dp[n + 1];
		dp[0] = 0, dp[1] = abs(a[1] - a[0]) + dp[0];
		for (i = 2; i < n; i++)
		{
			dp[i] = min(dp[i - 1] + abs(a[i] - a[i - 1]), dp[i - 2] + abs(a[i] - a[i - 2]));
		}
		cout << dp[n - 1] << endl;

	}
	cerr << "Time : " << 1000 * ((double)clock()) / (double)CLOCKS_PER_SEC << "ms\n";
	return 0;
}

Measured memory_bytes: 4864
package main

import (
        "bufio"
        "fmt"
        "os"
        "strconv"
        "strings"
)

var sc = bufio.NewScanner(os.Stdin)

func readInt() int              { return readIntArray()[0] }
func readInt2() (int, int)      { a := readIntArray(); return a[0], a[1] }
func readInt3() (int, int, int) { a := readIntArray(); return a[0], a[1], a[2] }
func readIntArray() []int {
        a := make([]int, 0, 1000)
        sc.Scan()
        for _, v := range strings.Split(sc.Text(), " ") {
                vv, _ := strconv.Atoi(v)
                a = append(a, vv)
        }
        return a
}
func readString() string        { return readStringArray()[0] }
func readStringArray() []string { sc.Scan(); return strings.Split(sc.Text(), " ") }

func main() {
        a, b := readInt2()

        fmt.Println(a * b / gcd(a, b))
}

func gcd(a, b int) int {
        if b == 0 {
                return a
        }

        if a < b {
                a, b = b, a
        }

        return gcd(b, a%b)
}

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

int main() {

  int a, b;
  cin >> a >> b;
  int count = 0;
  for(int i = a; i <= b; i++){
    if ( (i / 10000 == i % 10) && (i / 1000 % 10 == i % 100 / 10 )) {
      count++;
    }
  }
  cout << count << endl;
}

Measured memory_bytes: 256
N = int(input())
A = [int(x) for x in input().split()]
B = [int(x) for x in input().split()]
L = 0
for i in range(N):
  l = min(A[i], B[i])
  B[i] -= l
  r = min(A[i + 1], B[i])
  A[i + 1] -= r
  L += l + r
print(L)

Measured memory_bytes: 18468
#include<bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp>
// using namespace __gnu_pbds;
using namespace std;
#define ff              first
#define ss              second
#define int             long long
#define pb              push_back
#define eb              emplace_back
#define pii             pair<int,int>
#define vi              vector<int>
#define mpii            map<int,int>
#define mpsi            map<string,int>
#define mpss            map<string,string>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int>>
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define all(v)          v.begin(),v.end()
#define mod             1000000007
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x

#define deb(x)          cout<<"("<<#x<<")"<<"----->"<<x<<"\n"
#define clr(ar)         memset(ar,0,sizeof(ar))
// typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;
#define sz 100009
#define si(x) scanf("%lld",&x)
#define sii(x,y) scanf("%lld %lld",&x,&y)
#define out(x) printf("%lld\n",x)
#define spc  printf(" ")
#define line printf("\n")
#define mod 1000000007
#define pf printf
int a[sz];
int32_t main()
{
	int i,j,n,m,cs,test,k,l;
	sii(n,k);
	for(i=1;i<=n;i++)
		si(a[i]);
	int dp[n+1];
	clr(dp);


	dp[1] = 0;
	for(i=2;i<=k+1 && i<=n;i++)
	{
		dp[i] = abs(a[i] - a[1]);
	}


	for(i=k+2;i<=n;i++)
	{
		int mn = INT_MAX;
		for(j=1;j<=k && j<=n;j++)
		{
			mn = min(mn,dp[i-j] +abs(a[i] - a[i-j]));
		}

		dp[i] = mn;
	}
	out(dp[n]);

return 0;
}







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

using namespace std;

typedef unsigned long long ll;

int main()
{
    int   n ;
    cin >> n ;
    int a[n] ;

    for(int i=0;i<n;i++)
        cin >> a[i];


    int* m=max_element(a,a+n);
    int a1=*m;
    *m=0;
    int* m1=max_element(a,a+n);
    int a2=*m1;
    *m=a1;
    for(int i=0;i<n;i++)
    {
        if (a[i]<a1) cout<<a1<<endl;
        else
        {

            cout<<a2<<endl ;
        }
    }

    return 0;
}




Measured memory_bytes: 2432
#include <iostream>
using namespace std;
#include <vector>
#include <stdio.h>
#include <algorithm>
#define _USE_MATH_DEFINES
#include <math.h>
#include <string>
#include <cstdlib>

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

int main() {

	string s; cin >> s;
	string ans = "";
	for(int i = 0; i < s.length(); i++) {
		if(s[i] == 'B') { 
			if(!ans.empty() ) ans.erase( ans.length()-1);
		}
		else ans += s[i];
	}
	cout << ans <<endl;
}

Measured memory_bytes: 256
#!/usr/bin/env python3
from collections import defaultdict, Counter
from itertools import product, groupby, count, permutations, combinations
from math import pi, sqrt
from collections import deque
from bisect import bisect, bisect_left, bisect_right
from string import ascii_lowercase
from functools import lru_cache
import sys
sys.setrecursionlimit(10000)
INF = float("inf")
YES, Yes, yes, NO, No, no = "YES", "Yes", "yes", "NO", "No", "no"
dy4, dx4 = [0, 1, 0, -1], [1, 0, -1, 0]
dy8, dx8 = [0, -1, 0, 1, 1, -1, -1, 1], [1, 0, -1, 0, 1, 1, -1, -1]


def inside(y, x, H, W):
    return 0 <= y < H and 0 <= x < W


def ceil(a, b):
    return (a + b - 1) // b


def sum_of_arithmetic_progression(s, d, n):
    return n * (2 * s + (n - 1) * d) // 2


def gcd(a, b):
    if b == 0:
        return a
    return gcd(b, a % b)


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


def solve():
    S, T = input().split()
    A, B = map(int, input().split())
    U = input()
    if U == S:
        print(A - 1, B)
    else:
        print(A, B - 1)


def main():
    solve()


if __name__ == '__main__':
    main()


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

int main(){

  int n,m;
 
  while(true){
    cin >> n >> m;
    if(n == m && n == 0) break;

    int a,z[10000] = {0},x[10000] = {0},tmp;

    for(int i=0;i<n;i++){
      for(int j=0;j<m;j++){
	cin >> a;
	z[j] += a;
	x[j] = j+1;
      }
    }

    for(int i=0;i<m-1;i++){
      for(int j=m-1;j>i;j--){
	if(z[j] > z[j-1]){
	  tmp = z[j];
	  z[j] = z[j-1];
	  z[j-1] = tmp;

	  tmp = x[j];
	  x[j] = x[j-1];
	  x[j-1] = tmp;
	}
      }
    }

    for(int i=0;i<m-1;i++) cout << x[i] << " ";
   
    cout << x[m-1] << endl;

  }
}

Measured memory_bytes: 1244
#include <iostream>
#include <cstring>
#include <cmath>
#include <vector>
#include <algorithm>
#include <numeric>
#include <array>
using namespace std;

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define pow(x) x*x

void insertionSort(int* A, int N){ // N個の要素を含む0-オリジンの配列A

  int v, i, j;

  for( i = 1; i < N; i++ ){
    v = A[i];
    j = i - 1;
    while (j >= 0 && A[j] > v){
      A[j+1] = A[j];
      j--;
    }
    A[j+1] = v;
    REP( i, N ){
      cout << A[i];
      if( i == N - 1 ) break;
      cout <<" ";
    }
    cout << endl;
  }
  
}

int main() {

  int N, i;
  int A[1010];

  cin >> N;

  REP( i, N ){
    cin >> A[i];
  }
    REP( i, N ){
      cout << A[i];
      if( i == N - 1 ) break;
      cout <<" ";
    }
    cout << endl;

  insertionSort( A, N );

}

/*
                   _ooOoo_
                  o8888888o
                  88" . "88
                  (| -_- |)
                  O\  =  /O
               ____/`---'\____
             .'  \\|     |//  `.
            /  \\|||  :  |||//  \
           /  _||||| -:- |||||-  \
           |   | \\\  -  /// |   |
           | \_|  ''\---/''  |   |
           \  .-\__  `-`  ___/-. /
         ___`. .'  /--.--\  `. . __
      ."" '<  `.___\_<|>_/___.'  >'"".
     | | :  `- \`.;`\ _ /`;.`/ - ` : | |
     \  \ `-.   \_ __\ /__ _/   .-` /  /
======`-.____`-.___\_____/___.-`____.-'======
                   `=---='
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
         pass System Test!
*/


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

int main()
{
    int K, A, B;
    cin >> K;
    cin >> A >> B;
    for (int i = 0; i <= (B - A); i++)
    {
        if ((A + i) % K == 0)
        {
            cout << "OK" << endl;
            break;
        }
        else if ((A + i) % K != 0)
        {
            if (i < (B - A))
            {
                continue;
            }
            if(i == (B - A))
            {
                cout << "NG" << endl;
            }
        }
    }
}

Measured memory_bytes: 3604
n = gets.to_i
t,a = gets.split.map(&:to_i)
comp = Float::INFINITY
ans = 1
h = gets.split.map{|u| t-u.to_i*0.006}
h.each_with_index do |k,idx|
  if comp > (k-a).abs
    comp = (k-a).abs
    ans = idx+1
  end
end
puts ans


Measured memory_bytes: 14212
N=int(input())
A=list(map(int,input().split()))
x=(N+1)*N//2
a=0 if sum(A)%x else 1
d=sum(A)//x
y=0
for i in range(N):
    if (A[i]-A[i-1])%N!=d%N or A[i]-A[i-1]>d:
        a=0
    else:
        y-=(A[i]-A[i-1]-d)//N
print(['NO','YES'][a and y==d])

Measured memory_bytes: 20388
#include <bits/stdc++.h>
using namespace std;
#define ll long long int 
#define inf 1e18
int main()
{
    ll n, i, k;
    cin >> n >> k;
    vector<pair<ll, ll>> v;
    ll a[n + 2], b[n + 2];
    for (i = 0; i < n; i++)
    {
        cin >> a[i];
        cin >> b[i];
        v.push_back({b[i], a[i]});
    }
    sort(v.begin(), v.end(), greater<pair<ll, ll>>());
    ll num = 0;
    ll sum = 0;
    vector<ll> x, y;
    map<ll, ll> mp;
    for (i = 0; i < k; i++)
    {
        if (mp[v[i].second] == 0)
            num++;
        else
            x.push_back(v[i].first);
        sum = sum + v[i].first;
        mp[v[i].second]++;
    }
    reverse(x.begin(), x.end());
    sum = sum + num * num;

    for (i = k; i < n; i++)
    {
        if (mp[v[i].second] == 0)
            y.push_back(v[i].first);
        mp[v[i].second]++;
    }
    ll ans = sum;
    for (i = 0; i < min(x.size(), y.size()); i++)
    {
        sum = sum - (x[i] - y[i]);
        num++;
        sum = sum + (num * num) - (num-1)*(num-1);
        ans = max(ans, sum);
    }
    cout << ans << "\n";

    return (0);
}

Measured memory_bytes: 9968
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int prev = sc.nextInt();
        int direction = 0;
        int cut = 0;
        for(int i=1;i<N;i++){
        	int cur = sc.nextInt();
        	switch(direction){
        		case 0:// -
        			if(cur>prev) direction = 1;
        			else if(cur<prev)direction = -1;
        			else direction = 0;
        			break;
        		case 1:// /
        			if(cur<prev){
        				cut++;
        				direction = 0;
        			}break;
        		case -1:
        			if(cur>prev){
        				cut++;
        				direction = 0;
        			}break;
        	}
        	prev=cur;
        }
        System.out.println(1+cut);
    }
}

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

int main() {
    vector<char> s(4);
    for(int i=0;i<4;i++){
        cin>>s[i];
    }
    sort(s.begin(),s.end());
    if(s[0]==s[1] &&s[2]==s[3] &&s[1]!=s[2]){
        cout<<"Yes"<<endl;
    }else{
        cout<<"No"<<endl;
    }
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main() {
    int n, k;
    cin >> n >> k;
    long long result = 1;
    for (int i = 0; i < n - 1; ++i) {
        result *= k - 1;
    }
    if (n == 1) {
        cout << k;
        return 0;
    }
    cout << result * k;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;

const ll LINF = 1e18;
const int INF = 1e9;
const ll MOD = 1000000007;

template<class T> inline bool chmin(T& a, T b){
    if(a > b){
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b){
    if(a < b){
        a = b;
        return true;
    }
    return false;
}
bool is_ok(ll x, ll y){
    if(x == y) return true;
    else return false;
}
int main(){
    int a, b;
    cin >> a >> b;
    bool flg = false;
    for(int i = 0; i < 10000; i++){
        if(floor(i * 0.1) == b){
            if(floor(i * 0.08) == a){
                cout << i << endl;
                return 0;
            }
        }
    }
    if(flg == false) cout << -1 << endl;

}


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

static const int N = 100;

int main() {
  int n, p[N + 1], m[N + 1][N + 1];
  cin >> n;
  for (int i = 1; i <= n; i++) {
    cin >> p[i - 1] >> p[i];
  }

  for (int i = 1; i <= n; i++) m[i][i] = 0;
  for (int l = 2; l <= n; l++) {
    for (int i = 1; i <= n - l + 1; i++ ) {
      int j = i + l - 1;
      m[i][j] = (1 << 21);
      for (int k = i; k <= j - 1; k++) {
        m[i][j] = min(m[i][j], m[i][k] + m[k + 1][j] + p[i - 1] * p[k] * p[j]);
      }
    }
  }

  cout << m[1][n] << endl;

  return 0;
}



Measured memory_bytes: 3116
#define rep(i, n) for (int i = 0; i < (n); i++)
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
const int MOD = 1000000007;
// MAX int 2,147,483,647
// MAX O(n) 10^18

int main() {
    int N;
    cin >> N;
    vector<int> p(N);
    rep(i, N) cin >> p.at(i);

    int counter = 0;
    rep(i, N) {
        if (i + 1 != p.at(i)) counter++;
    }

    string ans = (counter == 0 || counter == 2) ? "YES" : "NO";

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3612
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;

int main()
{
	int h, w, k, xs, ys;
	scanf("%d %d %d", &h, &w, &k);
	char a[800][800];
	for(int i=0; i<h; i++){
		scanf("%s", a[i]);
	}
	for(int i=0; i<h; i++){
		for(int j=0; j<w; j++){
			if(a[i][j]=='S') xs=i, ys=j;
		}
	}
	int dmin=min(xs, min(h-1-xs, min(ys, w-1-ys)));
	int d[800][800];
	for(int i=0; i<h; i++){
		fill(d[i], d[i]+w, -1);
	}
	queue<P> que;
	que.push(P(xs, ys));
	d[xs][ys]=0;
	while(!que.empty()){
		P p=que.front();
		que.pop();
		int x=p.first, y=p.second;
		if(d[x][y]<=k && dmin>min(x, min(h-1-x, min(y, w-1-y)))) dmin=min(x, min(h-1-x, min(y, w-1-y)));
		if(x-1>=0 && a[x-1][y]=='.' && d[x-1][y]<0){
			que.push(P(x-1, y));
			d[x-1][y]=d[x][y]+1;
		}
		if(x+1<h && a[x+1][y]=='.' && d[x+1][y]<0){
			que.push(P(x+1, y));
			d[x+1][y]=d[x][y]+1;
		}
		if(y-1>=0 && a[x][y-1]=='.' && d[x][y-1]<0){
			que.push(P(x, y-1));
			d[x][y-1]=d[x][y]+1;
		}
		if(y+1<w && a[x][y+1]=='.' && d[x][y+1]<0){
			que.push(P(x, y+1));
			d[x][y+1]=d[x][y]+1;
		}
	}
	printf("%d\n", (dmin+k-1)/k+1);
	return 0;
}

Measured memory_bytes: 3328
#include<queue>
#include<stack>
#include<math.h>
#include<cmath>
#include<bitset>
#include<stdio.h>
#include<string>
#include<map>
#include<algorithm>
#include<vector>
#include<iostream>
#include<utility>
#include<functional>
#include<deque>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
int main(){
  int a,b,c,d,e,f,g;
  cin >> a >> b >>c >> d >>e;
  f=60*a+b,g=60*c+d;
  g=g-e;
  if(g-f<0){
    cout << '0' << endl;
  }
  else{
    cout << g-f << endl;
  }
  return 0;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i < (n); i++)
template<class T> istream& operator >> (istream& s, vector<T>& v)
{ for (T& x: v) { s >> x; } return s;}

#define D1(a) cerr<<#a<<":"<<a<<endl
#define D2(a,b) cerr<<#a<<":"<<a<<","<<#b<<":"<<b<<endl
#define D3(a,b,c) cerr<<#a<<":"<<a<<","<<#b<<":"<<b<<","<<#c<<":"<<c <<endl
#define D4(a,b,c,d) cerr<<#a<<":"<<a<<","<<#b<<":"<<b<<","<<#c<<":"<<c<<","<<#d<<":"<<d<<endl
#define DH(c) do{rep(__i, c.size())cerr<<c[__i]<<(__i==c.size()-1?'\n':' ');}while(0)

#define MOD 1000000007

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

    ll ans = 0;
    for (ll r = K; r <= N + 1; r++) {
        ll s_min = (r-1) * r / 2;
        ll s_max = (N-r+1 + N) * r / 2;
        // D2(s_min, s_max);
        ans = (ans + (s_max - s_min + 1)) % MOD;
    }

    cout << ans << endl;
}


Measured memory_bytes: 3612
#include <iostream>
#include <math.h>
#include <algorithm>
#include <string>
#include <string.h>
#include <numeric>

using namespace std;

int main() {
	long long int n, m;
	cin >> n >> m;
  
    if(n*500 >= m) cout << "Yes" << endl;
    else cout << "No" << endl;
    
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define rep1(i,n) for(int i=1;i<=(int)n;i++)
#define sp(n) cout << fixed << setprecision(n)
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
typedef long long ll;
using namespace std;
int main(void){
    ll k;cin>>k;
    priority_queue<ll, vector<ll>, greater<ll> > que;
    rep1(i,9) que.push(i);
    rep(i,k-1){
        ll x=que.top();que.pop();
        //cout<<x<<endl;
        if(x%10==0){
            ll y=x*10;
            que.push(y);
            y=x*10+1;
            que.push(y);
        }else if(x%10==9){
            ll y=x*10+9;
            que.push(y);
            y=x*10+8;
            que.push(y);
        }else{
            ll y=x*10+x%10;
            que.push(y);
            y=x*10+x%10+1;
            que.push(y);
            y=x*10+x%10-1;
            que.push(y);
        }
    }
    ll res=que.top();que.pop();
    cout<<res<<endl;
}

Measured memory_bytes: 5248
N = int(input())
X = list(map(int, input().split()))
M = int(input())
A = list(map(int, input().split()))

loc = [False] * 2020
for x in X:
    loc[x] = True

for m in range(M):
    now = X[A[m] - 1]
    new = X[A[m] - 1] + 1

    if now == 2019:
        continue

    if not loc[new]:
        X[A[m] - 1] = new
        loc[now] = False
        loc[new] = True

for x in X:
    print(x)


Measured memory_bytes: 5628
#include <iostream>

int main(void)
{
	int16_t a = 0;
	int16_t b = 0;
	int16_t c = 0;
	int16_t d = 0;
	int16_t n = 0;
	int16_t count = 0;

	while (std::cin >> n)
	{
		count = 0;
		for (int i = 0; i < 10; i++)
		{
			for (int j = 0; j < 10; j++)
			{
				for (int k = 0; k < 10; k++)
				{
					for (int l = 0; l < 10; l++)
					{
						if ((i + j + k + l) == n)
						{
							count++;
						}
					}
				}
			}
		}
		std::cout << count << std::endl;
	}

	return 0;
}

Measured memory_bytes: 2984
#include <bits/stdc++.h>
#define rep(i, s, n) for (int i = (s); i < (int)(n); i++)
#define per(i, n, s) for (int i = (n-1); i >= (int)(s); i--)
#define all(x) (x).begin(),(x).end()
#define debug(x) cout<<#x<<": "<<x<<endl
using namespace std;
using ll = long long;
const ll MOD = 1e9+7;
const ll LINF = LLONG_MAX;
const int INF = INT_MAX;
const double PI=acos(-1);
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int main(){
	ll n; cin>>n;
	ll ans=1;
	vector<ll> a(n);
	rep(i,0,n){
		cin>>a[i];
		if(a[i]==0){
			cout<<0<<endl;
			return 0;
		}
	}
	rep(i,0,n){
		if(a[i]>1000000000000000000/ans){
			cout<<-1<<endl;
			return 0;
		}
        ans*=a[i];
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 3920
#include <iostream>
#include <cstdio>
#include <vector>
#include <queue>

using namespace std;
struct Point
{
	int x;
	int y;
	Point(){};
	Point(int a, int b)
	{
		x = a;
		y = b;
	}
};
int dx[4] = { 1, 0, -1, 0 };
int dy[4] = { 0, -1, 0, 1 };
double dp[17][3][3];
char stage[3][3];

void solve()
{
	int n;
	while (cin >> n, n)
	{
		char s, t, b;
		cin >> s >> t >> b;
		Point start, goal, warehouse;
		start.x = (s - 'A') % 3;
		start.y = (s - 'A') / 3;
		goal.x = (t - 'A') % 3;
		goal.y = (t - 'A') / 3;
		warehouse.x = (b - 'A') % 3;
		warehouse.y = (b - 'A') / 3;
		fill(dp[0][0], dp[0][0] + 3 * 3 * 17, 0.0);
		dp[0][start.y][start.x] = 1.0;
		for (int i = 0; i < n; ++i)
		{
			for (int y = 0; y < 3; ++y)
			{
				for (int x = 0; x < 3; ++x)
				{
					for (int j = 0; j < 4; ++j)
					{
						int nx = x + dx[j];
						int ny = y + dy[j];
						if ((nx < 0 || nx >= 3 || ny < 0 || ny >= 3) || (nx == warehouse.x && ny == warehouse.y))
						{
							dp[i + 1][y][x] += dp[i][y][x] / 4.0;
						}
						else
						{
							dp[i + 1][ny][nx] += dp[i][y][x] / 4.0;
						}
					}
				}
			}
		}
		printf("%.7f\n", dp[n][goal.y][goal.x]);
	}
}

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

Measured memory_bytes: 1188
#include <iostream>
typedef long long int ll;
using namespace std;
int main(int argc, char const *argv[]) {
  ll A, B, C;
  std::cin >> A >> B >> C;
  if(A%2==0||B%2==0||C%2==0) std::cout << 0 << '\n';
  else std::cout << min(A*B, min(A*C, B*C)) << '\n';
}


Measured memory_bytes: 256
import java.util.*;

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

        int N = sc.nextInt();
        int min = 100000;

        for (int i=1; i<N; i++) {
            int A = i;
            int B = N - i;
            int AB = Main.calc(A) + Main.calc(B);
            min = min < AB ? min : AB;
        }

        System.out.println(min);
    }

    static int calc(int a) {
        int[] nums = {100000, 10000, 1000, 100, 10, 1};
        int sum = 0;

        for (int num : nums) {
            sum += a / num;
            a = a % num;
        }
        return sum;
    }
}



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

typedef long long ll;
const long long LINF = 1LL << 60;
const long long LMINF = 1LL << 63;
const int INF = 1 << 30;

#define REP(i,n) for(int i = 0;i < n;++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 PB push_back
#define F first
#define S second
#define MP make_pair
#define ALL(obj) (obj).begin(),(obj).end()
#define debug(x) cerr << #x << ": " << x << "\n"

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



int main(){
    ios::sync_with_stdio(false);cin.tie(0);
    ll w,h;
    cin >> h >> w;
    if(h == 1 || w == 1){
        cout << 1 << endl;
        return 0;
    }
    ll mas = w * h;
    if(mas % 2 == 0){
        cout << mas/2 << endl;
    }else{
        cout << mas/2 + 1 << endl;
    }
    
    return 0;
}

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

int main() {
  int N, K, x=0, a=0;
  cin >> N >> K;
  
  for(int i=0; i<N; i++){
    cin >> x;
    if(x < K-x){
      a += x*2;
    }
    else{
      a += (K-x)*2;
    }
  }
  
  cout << a << endl;
}

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

class UF{
public:
  int V;
  vector<int> par,rnk,sz;
  UF(){}
  UF(int V):V(V),par(V),rnk(V,0),sz(V,1){for(int i=0;i<V;i++)par[i]=i;}
  
  int find(int x){
    assert(x < V);
    if(par[x]==x)return x;
    return par[x]=find(par[x]);
  }
  
  void unite(int x,int y){
    x=find(x), y=find(y);
    if(x==y)return;
    if(rnk[x]<rnk[y])par[x]=y, sz[y] += sz[x];
    else{
      par[y]=x;
      sz[x] += sz[y];
      if(rnk[x]==rnk[y])rnk[x]++;
    }
  }

  bool same(int x,int y){return find(x)==find(y);}

  int size(int x){return sz[find(x)];}
};


signed main(){
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  cout << fixed << setprecision(12);
  int n,m;
  cin>>n>>m;
  vector<int> p(n);
  cin>>p;
  for(int i=0;i<n;i++) p[i]--;

  vector<P> A(m);
  cin>>A;

  UF uf(n);  
  for(int i=0;i<m;i++){
    int x = A[i].first - 1;
    int y = A[i].second - 1;
    uf.unite(x, y);
  }

  int ans = 0;
  for(int i=0;i<n;i++){
    ans += uf.same(i,p[i]);
  }
  cout<<ans<<endl;
  
  return 0;
}


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

int main() {
    string S;
    cin >> S;
    if (S == "hi" || S == "hihi" || S == "hihihi" || S == "hihihihi" || S == "hihihihihi") {
        cout << "Yes\n";
    }else {
        cout << "No\n";
    }
    return 0;
}

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

namespace AtCoder.Abc
{
    class A_Therefore_168
    {
        public static void Main(string[] args)
        {
            var sw = new System.IO.StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);

            // 整数の入力
            long n = long.Parse(Console.ReadLine());
            n = n % 10;

            if (n == 3)
            {
                Console.WriteLine("bon");
            }
            else if(n == 0 || n == 1 || n == 6 || n == 8)
            {
                Console.WriteLine("pon");
            }
            else
            {
                Console.WriteLine("hon");
            }



            string result = "";

            Console.WriteLine(result);

            Console.Out.Flush();
        }
    }
}


Measured memory_bytes: 27460
#include<iostream>
#include<algorithm>
#include<string>
#include<cmath>
using namespace std;
int main() {
  string o, e;
  cin >> o >> e;
  int os = o.size();
  int es = e.size();
  if(os == es){
    for(int i = 0; i < es; i++){
      cout << o[i] << e[i];
    }
    cout << endl;
    return 0;
  }

  else if(os = es + 1){
    for(int i = 0; i < es; i++){
      cout << o[i] << e[i]; 
    }
    cout << o[es] << endl;
    return 0;
  }
  return 0;
}


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

typedef long long ll;
typedef pair<int, int> pii;
#define FOR(i, n) for(int (i)=0; (i)<(n); (i)++)
#define FOR1(i, n) for(int (i)=1; (i)<=(n); (i)++)
#define FORI(i, n) for(int (i)=n-1; (i)>=0; (i)--)

int main(int argc, char** argv) {
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); cout << setprecision(15);
    if (argc == 2 && atoi(argv[1]) == 123456789) freopen("d:\\code\\cpp\\contests\\stdin", "r", stdin);

    string t;
    cin >> t;

    FOR(i, t.length()){
        if (t[i] == '?') t[i] = 'D';
    }
    cout << t << endl;

    if (argc == 2 && atoi(argv[1]) == 123456789) cout << clock()*1.0/CLOCKS_PER_SEC << " sec\n";
    return 0;
}

Measured memory_bytes: 3748
#include<bits/stdc++.h>
using namespace std;
int main(){
  int a,b;
  cin >> a >> b;
  int count = 0;
  for(int q=0;q<=a;q++){
    for(int w=0;w<=a;w++){
      if(b-q-w <= a && 0 <= b-q-w)
        count++;
    }
  }
  cout << count << endl;
}

Measured memory_bytes: 256
from collections import Counter

n, m = map(int,input().split())
li = list(map(int,input().split()))

sli = []
tmp = 0

for i in range(n):
    tmp = (tmp + li[i])%m
    sli.append(tmp)


cnt = Counter(sli)
ans = cnt[0]

for a,ii in cnt.items():
    ans = ans + ii*(ii-1)//2

print(ans)


Measured memory_bytes: 16556
#include <stdio.h>
#include <algorithm>

#define lli long long int

using namespace std;

int main() {
	lli banyak, angka[100010], ans = 0, temp = 0;
	scanf("%lld", &banyak);
	for (lli i = 0; i < banyak; i++)
		scanf("%lld", &angka[i]);
	sort(angka, angka + banyak);
	if (banyak % 2 < 1) {
		for (lli i = 0; i < ((banyak / 2) - 1); i++)
			ans -= (2 * angka[i]);
		ans += (angka[banyak / 2] - angka[(banyak / 2) - 1]);
		for (lli i = ((banyak / 2) + 1); i < banyak; i++)
			ans += (2 * angka[i]);
	}
	else {
		for (lli i = 0; i < (banyak / 2) - 1; i++)
			ans -= (2 * angka[i]);
		ans -= (angka[banyak / 2] + angka[(banyak / 2) - 1]);
		for (lli i = ((banyak / 2) + 1); i < banyak; i++)
			ans += (2 * angka[i]);
		for (lli i = 0; i < (banyak / 2); i++)
			temp -= (2 * angka[i]);
		temp += (angka[banyak / 2] + angka[(banyak / 2) + 1]);
		for (lli i = (banyak / 2) + 2; i < banyak; i++)
			temp += (2 * angka[i]);
		ans = max(ans, temp);
	}
	printf("%lld\n", ans);
	return 0;
}

Measured memory_bytes: 896
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i, n) for(int i=0;i<(int)n;i++)
#define PI acos(-1)
#define fast_io ios_base::sync_with_stdio(false) ; cin.tie(0); cout.tie(0);
ll mod=1e9+7;

ll rep_pow(ll a, ll b){//繰り返し2乗法
    if(b==0) return 1;
    else if(b%2==0){
        ll memo = rep_pow(a, b/2);
        return memo*memo%mod;
    }else{
        return rep_pow(a, b-1)*a%mod;
    }
}

ll nCr(ll n, ll r){//mod逆元使ったnCr
    ll ret=1;
    rep(i,r){
        ret *= n-i;//分子
        ret %= mod;
        ret *=rep_pow(r-i, mod-2);//mod逆元によりr!で割ると同値
        ret %= mod;
    }
    return ret;
}

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

    int n;
    ll X;
    cin>>n>>X;
    vector<ll> x(n);
    rep(i,n) cin>>x[i];
    ll ans=abs(X-x[0]);
    for(int i=1;i<n;i++){
        ans=gcd(ans, abs(X-x[i]));
    }
    cout<<ans<<endl;
    
    return 0;
}

Measured memory_bytes: 1024
import math
import numpy as np
from decimal import *
L,A,B,M=map(int, input().split())

def matpow(X,n,mod):
  E = np.eye(N=X.shape[0],dtype=int)
  Y = X%mod
  if n == 1:
    return Y
  else:
    return np.dot(matpow(np.dot(Y,Y)%mod,n//2,mod), (Y if n % 2 else E))%mod
  
a = 0
for d in range(1,19):
  left = math.ceil(Decimal(10**(d-1)-A)/Decimal(B))
  right = math.ceil(Decimal(10**d-A)/Decimal(B))-1
  if right < 0:
    continue
  if left > L-1:
    break
  if left > right:
    continue
  if left < 0:
    left = 0
  if right > L-1:
    right = L-1
  mat = np.matrix([[10**d,0,0],[1,1,0],[0,1,1]])
  result = np.dot(np.array([a,A+B*left,B])%M, matpow(mat,right-left+1,M))
  a = result[0,0]%M
  
print(a)

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

using namespace std;
#define int long long
#define N 150000
struct str{
	int x,y;
}st[N];
bool cmp(str a,str b){
	return a.y>b.y;
}
map<int,int> mp;
stack<int> s;
signed  main(){
	int n,k;
	cin>>n>>k;
	for(int i=1;i<=n;i++){
		cin>>st[i].x>>st[i].y;
	}
	sort(st+1,st+1+n,cmp);
	int maxn=0;
	int type=0;
	int sum=0;
	for(int i=1;i<=k;i++){
		if(!mp[st[i].x]){
			mp[st[i].x]=1;
			type++;
		}else{
			s.push(st[i].y);
		}
		sum+=st[i].y;
		maxn=max(maxn,type*type+sum);	
	}
	for(int i=k+1;i<=n;i++){
		if(s.empty())
			break;
		if(mp[st[i].x])
			continue;
		mp[st[i].x]=1;
		type++;
		sum-=s.top();
		s.pop();
		sum+=st[i].y;
		maxn=max(maxn,type*type+sum);	
	}
	cout<<maxn;
	return 0;
}

Measured memory_bytes: 6016
from itertools import combinations

N, M, X = map(int, input().split())
C, A = [], []
for i in range(N):
    c, *a = map(int, input().split())
    C.append(c)
    A.append(a)

ans = float('INF')
for i in range(1,N+1):
    for li in combinations(list(range(N)), i):
        cost = 0
        skill = [0] * M
        for j in li:
            cost += C[j]
            for k in range(M):
                skill[k] += A[j][k]
        if all([s >= X for s in skill]):
            ans = min(ans, cost)
if ans == float('INF'):
    print(-1)
else:
    print(ans)

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

int main() {
	int N;
	cin >> N;
	
	int h = N/100;
	int t = (N-h*100)/10;
	int o = (N-h*100-t*10);
	
	if(h == o) cout << "Yes";
	else cout << "No";
	
	
	cout << endl;
	
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ss second
#define ff first
#define all(x) x.begin(), x.end()
 
using namespace std;
using ll = long long;
using pii = pair<int, int>;
 
const int oo = 1e9 + 7;
const int mod = 1e9 + 7, maxn = 100100;
const long double PI = acos(-1);
 
int main (){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int n, k;
    cin >> n >> k;

    vector<int> v(n);

    for (auto& x: v) cin >> x;

    sort(all(v));

    ll ans = 0;

    for (int i=0; i<n-k; i++){
        ans += v[i];
    }

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

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

ll A[1001];

int main() {
    int x;
    cin >> x;
    for (int i=0;i<=1000;i++) {
        ll z=i;
        for (int j=0;j<4;j++) z*=i;
        A[i]=z;
    }

    for (int i=0;i<=1000;i++) {
        for (int j=i;j<=1000;j++) {
            if (A[j]-A[i]==x) {
                cout << j << " " << i;
                return 0;
            }
            else if (A[j]+A[i]==x) {
                cout << j << " " << -i;
                return 0;
            }
        }
    }

}



Measured memory_bytes: 3636
k,n = map(int, input().split())
a = list(map(int,input().split()))
a.sort()
b = []

for i in range(n):
    if i == n-1:
        b.append(k-(a[i]-a[0]))
    else:
        b.append(a[i+1]-a[i])

b.sort()
print(k-b[n-1])

Measured memory_bytes: 26444
import java.util.*;
import java.lang.*;

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

		Scanner scn = new Scanner(System.in);
		
		int a = scn.nextInt();
		int b = scn.nextInt();
		int c = scn.nextInt();
		
		if (a < b && b < c){
			System.out.println("Yes");
		}
		else {
			System.out.println("No");
		}
	}
}

Measured memory_bytes: 26068
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N,A; cin >>N;
  int sum=1;
  int kazu=0;
  for(int i=0;i<N;i++){
    cin>>A;
    if(A%2==0){
      kazu=2;
    }else{
      kazu=1;
    }
    sum*=kazu;
  }
  long long kotae;
  kotae=pow(3,N)-sum;
  cout<<kotae<<endl;
}

Measured memory_bytes: 256
def solve(A, B, C):
    A, B, C = sorted([A, B, C])
    # print(A, B, C)
    r = 0
    while A <= C - 2:
        A += 2
        r += 1
    while B <= C - 2:
        B += 2
        r += 1
    A, B, C = sorted([A, B, C])
    A, B, C = A - A, B - A, C - A
    # print(A, B, C, r)
    if (A, B, C) == (0, 0, 0):
        r += 0
    elif (A, B, C) == (0, 0, 1):
        r += 1
    elif (A, B, C) == (0, 0, 2):
        r += 2
    elif (A, B, C) == (0, 1, 1):
        r += 2
    elif (A, B, C) == (0, 1, 2):
        r += 3
    elif (A, B, C) == (0, 2, 2):
        r += 1
    return r

A, B, C = [int(_) for _ in input().split()]
print(solve(A, B, C))


Measured memory_bytes: 3064