akhauriyash/Code-Regression huggingface dataset:
// Problem : B - Echo
// Contest : AtCoder - AtCoder Beginner Contest 145
// URL : https://atcoder.jp/contests/abc145/tasks/abc145_b
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include<bits/stdc++.h>
#include<set>
#define lli long long int
#define pb push_back
#define cio ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define rep(i,a,n) for(i=a;i<n;i++)
#define all(v) (v.begin(),v.end())
#define ppb pop_back
#define vsz v.size()
using namespace std;
int main()
{
	lli n;
	string s,a,b;
	cin>>n>>s;
	if(n&1)
	cout<<"No";
	else{
		b=s.substr(0,n/2);
		a=s.substr(n/2,n-1);
		if(a==b)
		cout<<"Yes\n";
		else
		cout<<"No";
	}
	
	
	return 0;
}

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

int main(){
  int N;
  cin >>N;
  int n=N;
  int tmp=0;
  while(N!=0){
    tmp+=N%10;
    N/=10;
  }
  if (n%tmp==0) cout <<"Yes"<<endl;
  else cout <<"No"<<endl;
}


Measured memory_bytes: 256
n, X = map(int, input().split())
x = list(map(int, input().split()))
x_sum = [0] # 1-indexed
for i in range(n):
	x_sum.append(x_sum[-1] + x[i])

ans = float("inf")
for i in range(1, n):
	res = X * (i + n)
	res += 5 * (x_sum[-1] - x_sum[-i - 1])
	cost = 5
	j = 1
	while (j * i) + i + 1 <= n:
		#print(-(j * i) - 1, -(j * i) - i - 1)
		res += cost * (x_sum[-(j * i) - 1] - x_sum[-(j * i) - i - 1])
		cost += 2
		j += 1
	res += cost * (x_sum[-(j * i) - 1])

	ans = min(res, ans)

print(ans)

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

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

using namespace std;
using lint=long long;

const long long INF=1LL<<61;

int n;
lint x[15],y[15],p[15];
lint res[16][15],ans[16];

void dfs(int i,int num){
	if(i==n){
		ans[num]=min(ans[num],accumulate(res[n],res[n]+n,0LL));
		return;
	}

	rep(j,n) res[i+1][j]=res[i][j];
	dfs(i+1,num);

	// 縦
	rep(j,n) res[i+1][j]=min(res[i][j],p[j]*abs(x[j]-x[i]));
	dfs(i+1,num+1);

	// 横
	rep(j,n) res[i+1][j]=min(res[i][j],p[j]*abs(y[j]-y[i]));
	dfs(i+1,num+1);
}

int main(){
	scanf("%d",&n);
	rep(i,n) scanf("%lld%lld%lld",&x[i],&y[i],&p[i]);

	rep(j,n){
		res[0][j]=p[j]*min(abs(x[j]),abs(y[j]));
		ans[j]=INF;
	}
	dfs(0,0);

	rep(i,n+1) printf("%lld\n",ans[i]);

	return 0;
}


Measured memory_bytes: 3804
N,M,X,Y = [int(a) for a in input().split(" ")]
xs=[int(a) for a in input().split(" ")]
ys=[int(a) for a in input().split(" ")]
x0, y0 = max(xs), min(ys)
print("No War" if X<y0 and x0<y0 and x0<Y else "War")

Measured memory_bytes: 38256
def insertionSort(A, n, g, cnt):
    for i in range(g, n):
        v = A[i]
        j = i - g
        while j >= 0 and A[j] > v:
            A[j+g] = A[j]
            j = j - g
            cnt += 1
        A[j+g] = v
    return [cnt, A]

def shellSort(A, n):
    cnt = 0
    a = 1
    G = []
    while a <= n:
        G.append(a)
        a = 3*a + 1
    m = len(G)
    G = G[::-1]
    for i in range(0, m):
        cnt, A = insertionSort(A, n, G[i], cnt)
    return [m, G, cnt, A]
        
if __name__ == "__main__":
    n = int(input())
    A = [int(input()) for _ in range(n)]
    m, G, cnt, A = shellSort(A, n)
    print(m)
    print(*G)
    print(cnt)
    for i in A:
        print(i)


Measured memory_bytes: 45516
#include <stdio.h>
#include <algorithm>
using namespace std;

int main(void){
    // Your code here!
    int N,C,K;
    int T[100000];
    int cnt = 0;
    
    scanf("%d%d%d",&N,&C,&K);
    
    for(int i = 0; i < 100000; i++){
        scanf("%d",&T[i]);
    }
    
    sort(T, T + N);
    for(int i = 0; i < N; i++){
        int c = C -1;
        int max_time = T[i] + K;
        cnt++;
        while(c > 0){
            if(T[i+1] <= max_time){
                i++;
                c--;
            }
            else{
                break;
            }
        }
    }
    
    printf("%d\n",cnt);
}


Measured memory_bytes: 2064
N, K = map(int, input().split())
d=[]
A=[]

for i in range(K):
    hoge = int(input())
    d.append(hoge)
    hoge = list(map(int, input().split()))
    for k in hoge:
        A.append(k)

A=set(A)
n=len(A)

print(N-n)

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

#include <boost/range/adaptors.hpp>
#include <boost/range/irange.hpp>

using namespace std;
using namespace boost;
using namespace boost::adaptors;

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

  map<string, int64_t, less<>> m;
  int64_t k = 0;
  for (auto _ : irange(0L, n)) {
    string s;
    cin >> s;

    ++m[s];

    k = max(m[s], k);
  }

  for (const auto& sv : m) {
    if (sv.second != k) {
      continue;
    }

    cout << sv.first << "\n";
  }
}

Measured memory_bytes: 25216
#include<bits/stdc++.h>
namespace imzzy{
	#define endl '\n'
	#define ccf std::cout<<"f**k"<<endl
	// #define rgi register int
	#define rgi int
	#define ll long long
	class fastin{private:int _ch,_f;
	public:inline fastin&operator>>(char&c){c=getchar();return*this;}
	template<typename _Tp>inline fastin&operator>>(_Tp&_x){
	_x=0;while(!isdigit(_ch))_f|=(_ch==45),_ch=getchar();
	while(isdigit(_ch))_x=(_x<<1)+(_x<<3)+(_ch^48),_ch=getchar();
	_f&&(_x=-_x,_f=0);return*this;}fastin(){_ch=_f=0;}
	}fin;class fastout{private:int _num[32],_head;
	public:inline fastout&operator<<(char c){putchar(c);return*this;}
	template<typename _Tp> inline fastout&operator<<(_Tp _x){
	_Tp _k;if(_x==0){putchar('0');return *this;}if(_x<0)putchar('-'),_x=-_x;
	while(_x>0)_k=_x/10,++_head,_num[_head]=(_x-(_k<<1)-(_k<<3))^48,_x=_k;
	while(_head>0)putchar(_num[_head]),--_head;return*this;}fastout(){_head=0;}
	}fout;inline void P_INIT(){
	#ifdef D_STDOUT_UNBUFFERED
	setbuf(stdout,NULL);
	#endif
}}using namespace imzzy;
// ----------------------------
// #define int ll
// using namespace std;
const int maxn=200004;
const int mod=1000000007,inf=1201201201;

ll dfs(ll a,ll b) {
	if(a<b) std::swap(a,b);
	if(a%b==0) return a*2ll-b;
	else return dfs(a%b,b)+(a/b)*b*2ll;
}
signed main()
{P_INIT();
	ll n,m;
	fin>>n>>m;
	fout<<dfs(n-m,m)+n;
	return 0;
}
// ----------------------------
// by imzzy


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

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

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

template<typename T> ostream& operator <<(ostream& r, const vector<T> t){vrep(v,t)r<<*v<<(v+1==t.end()?"":" ");return r;}
template<typename T> ostream& operator <<(ostream& r, const pair<vector<T>, int> p){int n=p.second;minup(n,p.first.size());rep(i,n-1)r<<p.first[i]<<' ';r<<p.first[n-1];return r;}
template<typename T> ostream& operator <<(ostream& r, const pair<T*, int> p){int n=p.second-1;rep(i,n)r<<p.first[i]<<' ';return r<<p.first[n];}
template<typename T, size_t S> ostream& operator <<(ostream& r, const T (&a)[S]){rep(i,S-1)r<<a[i]<<' ';return r<<a[S-1];}


const int MAX_N = 15;
int a[MAX_N][MAX_N];
int n;

inline int nextX(int& x){ return x = (x + n - 1) % n; }
inline int nextY(int& y){ return y = (y + 1) % n; }
inline int prevY(int& y){ return y = (y + n - 1) % n; }

int main()
{
  while((cin >> n) && n){
    rep(i, n) rep(j, n) a[i][j] = 0;
    int hx = n / 2;
    int hy = n / 2 - 1;
    erep(cnt, 1, n * n){
      if(!a[nextX(hx)][nextY(hy)]) a[hx][hy] = cnt;
      else a[nextX(hx)][prevY(hy)] = cnt;
    }
    rev(i, n) rep(j, n) printf("%4d%s", a[i][j], (j >= n - 1 ? "\n" : ""));
 }

  return 0;
}

Measured memory_bytes: 1160
X = int(input())

L = []

for i in range(500000):
  t = pow(i, 5)
  L.append(t)
  if t >= X:
    k = i
    break

for i in range(len(L)):
  for j in range(len(L)):
    if L[i] - L[j] == X:
      print(i, j)
      exit()
    if L[i] + L[j] == X:
      print(i, -j)
      exit()

while True:
  t = L[-1]
  if t == X:
    print(k, 0)
    exit()
  for i in range(len(L)):
    if t - L[i] == X:
      print(k, i)
      exit()
    if t + L[i] == X:
      print(k, -i)
      exit()
  k += 1
  L.append(pow(k, 5))




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

#define int long long

#define rep(i,n) for(int i=0;i<(n);i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;

template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}

signed main(){
    int N;cin>>N;
    vint D(N);rep(i,N)cin>>D[i];
    sort(all(D));D.erase(unique(all(D)),D.end());
    cout<<D.size()<<endl;
    return 0;
}


Measured memory_bytes: 256
def check(n):
  if n=='a':
    if len(a)>0: check(a.pop())
    else: print('A')
  elif n=='b':
    if len(b)>0: check(b.pop())
    else: print('B')
  elif n=='c':
    if len(c)>0: check(c.pop())
    else: print('C')
a,b,c=[[*input()][::-1] for _ in range(3)]
check(a.pop())

Measured memory_bytes: 9144
#include<stdio.h>
#include<string.h>
int main(void)
{
  int n, i, j, l, f=0;
  char s[100][11]={""};
  scanf("%d", &n);
  scanf("%s", s[0]);
  for(i= 1; i<n;  i++){
    scanf("%s", s[i]);
    if(s[i][0] != s[i-1][strlen(s[i-1])-1]){
      f = 1;
      break;
    }
    for(j = 0; j < i; j++){
      if(strcmp(s[i], s[j])==0){
        f = 2;
        break;
      }
    }
  }
  printf("%s\n", f ? "No" : "Yes");
  
  return 0;
}

Measured memory_bytes: 128
import java.util.Scanner;

public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		for(int i=0;i<50;i++){
			int m = sc.nextInt();
			int f = sc.nextInt();
			int r = sc.nextInt();
			if(m==-1 && f==-1 && r==-1){
				break;
			}else if(m==-1 || f==-1){
				System.out.println("F");
			}else if(m+f >= 80){
				System.out.println("A");
			}else if(m+f >= 65){
				System.out.println("B");
			}else if(m+f >= 50){
				System.out.println("C");
			}else if(m+f >= 30){
				if(r >= 50){
					System.out.println("C");
				}else{
					System.out.println("D");
				}
			}else{
				System.out.println("F");
			}
		}
	}
}


Measured memory_bytes: 26132
#include<bits/stdc++.h>
#define ll long long
#define int long long int
#define MOD 1000000007
#define mkp make_pair
#define maxN 100005
#define pb push_back
#define ff first
#define ss second
#define debug1(a) cout<<a<<endl;
#define debug2(a,b) cout<<a<<' '<<b<<endl;
#define debug3(a,b,c) cout<<a<' '<<b<<' '<<c<<endl;
#define rep(i,n) for(int i=0;i<n;i++)
#define repl(i,a,b) for(int i=a;i<b;i++)
#define pi pair<int,int>
#define pii pair<int,pi>
#define mp map<int,int>
#define ump unordered_map<int,int>
#define  vi vector<int>
#define st set<int>
#define mst multiset<int>
#define pq priority_queue
#define mpq priority_queue<int,vector<int>,greater<int> >
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define in cin>>
#define out cout<<
using namespace std;
const int infi=1e9+7;

void printArray(int arr[],int n)
{
   for(int i=0;i<n;i++)cout<<arr[i]<<' ';
cout<<endl;
}
 set<pair<int,int>> primeset;
void SieveOfEratosthenes(int n)
{
    bool prime[n+1];
    memset(prime, true, sizeof(prime));

    for (int p=2; p*p<=n; p++)
    {
        if (prime[p] == true)
        {
        for (int i=p*p; i<=n; i += p)
                prime[i] = false;
        }
    }
    for (int p=2; p<=n; p++)
       if (prime[p])
          primeset.insert(mkp(p,1));
}
ll modExp(ll base, ll power) {
    if (power == 0) {
        return 1;
    } else {
        ll cur = modExp(base, power / 2); cur = cur * cur; cur = cur % MOD;
        if (power % 2 == 1) cur = cur * base;
        cur = cur % MOD;
        return cur;
    }
}
int32_t main()
{
fastio;
int n;in n;
vi dp(3,0);
for(int day=0;day<n;day++){
    vi new_dp(3,0);
    int arr[3];
    rep(i,3) in arr[i];
    for(int i=0;i<3;i++){
        for(int j=0;j<3;j++)
            {
                if(i!=j)
                    new_dp[j]=max(new_dp[j],dp[i]+arr[j]);
            }
    }
    dp=new_dp;
}
int ans=-1ll;
for(int i=0;i<3;i++)
    ans=max(ans,dp[i]);
out ans;
    return 0;
}


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

using namespace std;
long long int LCM(long long int a,long long int b);
int main(){
    long long int N,M;
    long long int ans,memo;
    string S,T;
    cin >> N >> M;
    cin >> S;
    cin >> T;

    ans=LCM(N,M);
    memo=LCM(ans/N,ans/M);
    for(long long int i=0;i<ans;i+=memo){
        if(S[i*N/ans]!=T[i*M/ans]){
            cout << "-1";
            return 0;
        }
    }
    cout << ans;
    return 0;
}
long long int LCM(long long int a,long long int b){
    long long int n=a,m=b;
    while(1){
        if(n>m){
            n=n%m;
            if(n==0) {
                return a*b/m;
            }
        } else {
            m=m%n;
            if(m==0) {
                return a*b/n;
            }
        }
    
    }
    return -1;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
#ifdef ONLINE_JUDGE
#define LLD "%I64d"
#else
#define LLD "%lld"
#endif
#define fu(a,b,c) for(int a=b;a<=(int)c;++a)
#define fd(a,b,c) for(int a=b;a>=(int)c;--a)
#define cu(a,b,c) for(int a=b;a<(int)c;++a)
#define cd(a,b,c) for(int a=(b)-1;a>=(int)c;--a)
#define gcd(a,b) __gcd(a,b) 
#define pii pair<int,int>
#define pll pair<long long,long long>
#define all(a) a.begin(),a.end()
#define F first
#define S second
#define pb push_back
#define pf push_front
#define MOD 1000000007
#define MAXN 205
#define MAXH 20
#define MAXM 52
#define INF 1LL << 30
#define ll long long
#define ull unsigned long long
#define RNG rng mt19937(time(NULL))
#define udist(a,b) uniform_int_distribution<uint32_t> distribution(a,b)
#define max3(a,b,c) max(a, max(b, c))
#define min3(a,b,c) min(a, min(b, c))
#define gmax(a,b) a = max(a, b)
#define gmin(a,b) a = min(a, b)
#define whatis(x) cerr << #x << " is " << x << endl;
#define fast_io() ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define PI 3.1415926535897932384626433
using namespace std;

int main(){
	int n;
	string s;
	cin >> n >> s;
	int a[n] = {};
	cu(i,0,4){
		a[0] = i&1;
		a[1] = i >= 2;
		cu(j,2,n){
			a[j] = a[j - 1] ^ (s[j-1] == 'x') ^ a[j - 2];
		}
		if(a[0] == (a[n - 1] ^ (s[n-1] == 'x') ^ a[n - 2]) && a[1] == (a[0] ^ (s[0] == 'x') ^ a[n - 1])){
			cu(j,0,n){
				cout << (a[j]?'W':'S');
			}
			cout << '\n';
			return 0;
		}
	}
	cout << "-1" << '\n';
}


Measured memory_bytes: 896
import java.util.*;

public class Main {    
    public static void main(String[] args){
        
        Scanner sc = new Scanner(System.in);          
           
        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();
        
        System.out.println( (b-a == c - b) ? "YES" : "NO");
                 
    }            
}
        
        

Measured memory_bytes: 21844
#include<iostream>
#include<string>
#include<stdio.h>
using namespace std;

int selection(int a[],int n){
    int count=0,min;
    for(int i=0;i<n-1;i++){
        min=i;
        for(int j=i;j<n;j++){
            if(a[j]<a[min])min=j;
        }
        int t=a[i];a[i]=a[min];a[min]=t;
        if(i!=min)count++;
    }
    return count;
}

int main(){
    int a[100],n,i,count;
    
    cin>>n;
    for(i=0;i<n;i++)cin>>a[i];
    
    count=selection(a,n);
    
    for(i=0;i<n;i++){
        if(i>0)cout<<" ";
        cout<<a[i];
    }
    cout<<endl;
    cout<<count<<endl;
    
    return 0;
}


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

using namespace std;

long double p[301][301][301], D[301][301][301];

int main()
{
    int n, K[4]={0}, s;
    cin >> n;
    long double a, b, c;
    for (int i = 0; i < n; i++)
    {
        cin >> s;
        K[s]++;
    }
    for (int i = 0; i <= n; i++)
    {
        for (int y = 0; y <= n; y++)
        {
            for (int u = 0; u <= n; u++)
            {
                p[i][y][u] = 0;
                D[i][y][u] = 0;
            }
        }
    }
    p[K[1]][K[2]][K[3]] = 1;
    for (int u = n; u >= 0; u--)
    {
        for (int y = n; y >= 0; y--)
        {
            for (int i = n; i >= 0; i--)
            {
                if (i+y+u == 0 || i+y+u > n)
                {
                    continue;
                }
                a = i;
                b = y;
                c = u;
                long double w = (long double) 1 / (1 - (n-(a+b+c))/n);
                D[i][y][u] += p[i][y][u] * w;
                if (u > 0)
                {
                    p[i][y+1][u-1] += p[i][y][u] * c / (a+b+c);
                    D[i][y+1][u-1] += D[i][y][u] * c / (a+b+c);
                }
                if (y > 0)
                {
                    p[i+1][y-1][u] += p[i][y][u] * b / (a+b+c);
                    D[i+1][y-1][u] += D[i][y][u] * b / (a+b+c);
                }
                if (i > 0)
                {
                    p[i-1][y][u] += p[i][y][u] * a / (a+b+c);
                    D[i-1][y][u] += D[i][y][u] * a / (a+b+c);
                }
            }
        }
    }
    cout << fixed << setprecision(10) << D[0][0][0];
    return 0;
}


Measured memory_bytes: 852480
#include<bits/stdc++.h>
using namespace std;
const double PI=3.14159265358979323846;
//class ThreeNeighbors{
    //public:
        //vector<string> construct(int a);
//};
//vector<string> construct(int a){
    //vector<string> str(50);
int main(){
    double n;
    cin>>n;
    printf("%.10lf",n*2*PI);
    return 0;
}

Measured memory_bytes: 3792
import java.util.Scanner

object Main {
  def solve(sc: => Scanner): Unit = {
    val S = sc.next
    if (S != "0") {
      val A = S.drop(1).filter(c => 'A' == c).length
      val B = S.drop(1).filter(c => 'B' == c).length
      if (A < B)
        println(A + " " + (B + 1))
      else
        println((A + 1) + " " + B)
      solve(sc)
    }
  }

  def main(args: Array[String]): Unit = {
    val sc: Scanner = new Scanner(System.in)
    solve(sc)
  }
}

Measured memory_bytes: 44668
from collections import Counter
n = int(input())
s = [input() for i in range(n)]
a = Counter(s)
AC = 0
WA = 0
TLE = 0
RE = 0

if "AC" not in a.keys():
    AC = 0
else:
    AC = a['AC']
if "WA" not in a.keys():
    WA = 0
else:
    WA = a['WA']
if "TLE" not in a.keys():
    TLE = 0
else:
    TLE = a['TLE']
if "RE" not in a.keys():
    RE = 0
else:
    RE = a['RE']

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

Measured memory_bytes: 16612
#include <bits/stdc++.h>
using i64 = long long;

int main() {
    int k, q;
    std::cin >> k >> q;
    std::vector<int> a(k);
    for (auto &e : a) std::cin >> e;

    while (q--) {
        int n, mod;
        i64 x;
        std::cin >> n >> x >> mod;
        x %= mod;
        --n;

        int ret = 0;
        for (int i = 0; i < k; i++) {
            const int co = n / k + (n % k > i);
            if (a[i] % mod == 0) ret += co;
            else x = x + 1ll * co * (a[i] % mod);
        }

        std::cout << n - (ret + x / mod) << std::endl;
    }

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
#include <cmath>
#include <map>
#include <queue>
#include <string>

#define reps(i,s,n) for(int (i) = (s); (i) < (n); (i)++)
#define rep(i,n) reps(i,0,n)
using namespace std;
using ll = long long;

int main(){
    char c;
    cin >> c;
    int t = c -'a';
    if(t >= 0){
        cout << 'a' << endl;
    }else{
        cout << 'A' << endl;
    }


    return 0;
}

Measured memory_bytes: 3632
#include<iostream>
#include<vector>
#include<bits/stdc++.h>
#define lli long long int
#define mod 1000000007
#define pb push_back
#define mk make_pair
#define fastio ios_base::sync_with_stdio(false); cout.tie(NULL);
using namespace std;

int main()
{
	fastio;
	lli x,n,i;
	cin>>n;
	map<lli,lli> m;
	for(i=0;i<n-1;i++)
	{
		cin>>x;
		m[x]++;
	}
	for(i=1;i<=n;i++)
		cout<<m[i]<<"\n";
	return 0;
}


Measured memory_bytes: 16164
#include<bits/stdc++.h>
#define int long long int
#define pb push_back
#define ipair pair<int,int>
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
using namespace std;
int arr[1000001],dp[1000001];

int32_t main()
{
  int n,k,mini=1e18;
  cin>>n>>k;
  for(int i=0;i<n;i++)
  {
    cin>>arr[i];
  }
  dp[0]=0;
  dp[1]=abs(arr[1]-arr[0]);
  for(int i=2;i<n;i++)
  {
    mini=1e18;
    for(int j=1;(j<=k)&&(i-j>=0);j++)
    {
      int x=dp[i-j]+abs(arr[i-j]-arr[i]);
      mini=min(x,mini);
    }
    dp[i]=mini;
  }
  cout<<dp[n-1];
}


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

using namespace std;
#define all(a)a.begin(),a.end()
#define rep(i,n) for (int i = 0; i < (n); ++i)
using ll=long long;
const int INF = 1<<30;
const ll INFll =1LL<<62;
const int mod = int(1e9)+7;
using V = vector<int>;
using P = pair<int,int>;

 V a,b,c,d;
ll ans=0;int n,q,m;


void dfs(string s,int x){
    V p(n);
    if(s.size()==n){
        rep(i,n){
            p[i]=s[i]-'0';
        }
        ll sum=0;
        rep(i,q){
            if(p[b[i]]-p[a[i]]==c[i])sum+=d[i];
        }
        ans=max(ans,sum);
    }
    else {
        for(int i=x;i<=m;i++){
            dfs(s+(char)('0'+i),i);
        }
    }
}

int main()
{
    cin >>n>>m>>q;
    a.resize(q);
    b.resize(q);
    c.resize(q);
    d.resize(q);
    rep(i,q)cin>>a[i]>>b[i]>>c[i]>>d[i];
    V l;
    rep(i,q)a[i]--;
    rep(i,q)b[i]--;
    dfs("",1);
    cout <<ans << endl;
    return 0;
}


Measured memory_bytes: 3632
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>

using namespace std;

int main(){
  int N, sum = 0, p[50];
  cin >> N;
  for(int i = 0; i < N; i++){
    cin >> p[i];
  }

  for(int i = 0; i < N - 1; i++){
    if(p[i] != i + 1)sum++;
  }
  if(sum <= 2)cout << "YES" << endl;
  else cout << "NO" << endl;
}


Measured memory_bytes: 256
import copy
n = int(input())
t = list(map(int,input().split()))
m = int(input())
p = [list(map(int,input().split())) for l in range(m)]
for pp in p:
	tmp = copy.copy(t)
	tmp[pp[0]-1] = pp[1]
	print(sum(tmp))

	
    

Measured memory_bytes: 3444
#include<iostream>
using namespace std;
#define ll long long int
#include<cmath>
#include<bits/stdc++.h>
int main()
{
	ll n;
	cin>>n;
	ll k;
	cin>>k;
	ll arr[n];
	for(ll i=0;i<n;i++)
	{
		cin>>arr[i];
	}
	ll dp[n];
	dp[0]=0;
	dp[1]=abs(arr[1]-arr[0]);
	for(ll i=2;i<n;i++)
	{
		dp[i]=dp[i-1]+abs(arr[i]-arr[i-1]);
		ll x=k;
		ll j=i;
		while(x>0&&j>0)
		{
			j--;
			dp[i]=min(dp[i],dp[j]+abs(arr[j]-arr[i]));
			x--;
		}
	}
		
	cout<<dp[n-1]<<endl;
}

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

int main()
{
   int n;
   cin>>n;
   long long int a[n],b[n],i,j=0,k=0;
   for(i=0;i<n;i++)
   {
   cin>>a[i];
   b[i]=a[i];
   }
  
   for(i=1;i<n;i++)
   {
       b[i]=max(b[i],b[i-1]);
   }
   for(i=0;i<n;i++)
   {
       j+=(b[i]-a[i]);
   }
cout<<j<<endl;
}

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

#define range 100005
#define mod 1000000007
#define eps 1e-9
#define PI 3.14159265358979323846
#define pb push_back
#define pf push_front
#define mp make_pair
#define fi first
#define se second
#define ALL(V) V.begin(), V.end()
#define _ <<" "<<

using namespace std;

typedef long long ll;
typedef vector <int> vi;
typedef vector<vi> vvi;
typedef pair <int, int> ii;
typedef pair<int, pair<int,int> > iii;
typedef vector<ii> vii;
typedef vector<iii> viii;

int main(int argc, char const *argv[])
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	//freopen("test.txt","r",stdin);
	int n,k;
	cin>>n>>k;
	int h[n];
	int dp[n];
	for(int i=0;i<n;i++)
	{
		cin>>h[i];
		dp[i] = INT_MAX;
	}
	dp[0] =0;
	for(int i=1;i<n;i++)
	{
		int temp = i;
		if (temp-k>=0)
		{
			temp = i-k;
		}
		else
		{
			temp = 0;
		}
		int tempo = INT_MAX;
		for(int j=temp;j<i;j++)
		{
			int tt = dp[j] + fabs(h[i] - h[j]);
			dp[i] = min(dp[i],tt);
		}		
	}
	cout<<dp[n-1];
	return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <algorithm>
#include <utility>
using namespace std;
int main(){
	int n, ymax, jred, xblue, res;
	res = 0;
	cin >> n;
	vector<pair<int, int>> red(n);
	vector<pair<int, int>> blue(n);
	for(int i=0; i<n; i++){
		cin >> red[i].first >> red[i].second;
	}
	for(int i=0; i<n; i++){
		cin >> blue[i].first >> blue[i].second;
	}
	sort(blue.begin(), blue.end());
	for(int i=0; i<n; i++){
		xblue = blue[i].first;
		jred = -1;
		ymax = -1;
		for(int j=0; j<n; j++){
			if(red[j].first < xblue && red[j].second < blue[i].second && red[j].first != -1 && red[j].second > ymax){
				jred = j;
				ymax = red[j].second;
			}
		}
		if(jred != -1){
			red[jred].first = -1;
			res++;
		}
	}
	cout << res << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define PB push_back
#define MP make_pair
#define REP(i,a,b) for(inti=a;i<=b;i++)

typedef long long int ll;
typedef vector<int>vi;
typedef pair<int,int>pi;



int main()
{
double d,t,s;
cin>>d>>t>>s;

if(d/s<=t)
    cout<<"Yes"<<endl;
else
    cout<<"No"<<endl;

 return 0;
}


Measured memory_bytes: 3720
#!/usr/bin/env python3
import sys


def solve(a: int, b: int):
    if a * b % 2 == 0:
        ret = 'Even'
    else:
        ret = 'Odd'
    print(ret)
    return


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    a = int(next(tokens))  # type: int
    b = int(next(tokens))  # type: int
    solve(a, b)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;
int main() {
    int n; cin >> n;
    vector<int> a(n);
    rep(i, n) cin >> a[i];
    sort(a.begin(), a.end());
    int p[2] = {0};
    for(int i=0;!a.empty();i++) {
        p[i%2] += a.back();
        a.pop_back();
    }
    cout << p[0] - p[1];
}


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

using namespace std;

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

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

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

template<typename T> inline void CHMAX(T& a, const T b) {if(a<b) a=b;}
template<typename T> inline void CHMIN(T& a, const T b) {if(a>b) a=b;}

constexpr ll MOD=1000000007ll;
// constexpr ll MOD=998244353ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

const double EPS=1e-11;
#define EQ0(x) (abs((x))<EPS)
#define EQ(a, b) (abs((a)-(b))<EPS)

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	// cout<<setprecision(10)<<fixed;
	int n, m;
	ll a[125252], b[125252];
	cin>>n>>m;
	REP(i, n){
		cin>>a[i]>>b[i];
	}
	vi ord(n);
	iota(ALL(ord), 0);
	sort(ALL(ord), [&](int x, int y){return a[x]<a[y];});
	// DEBUG_VEC(ord);
	priority_queue<int> pq;
	ll ans=0;
	int j=0;
	FORR(i, 0, m){
		while(j<n && i+a[ord[j]]<=m){
			pq.push(b[ord[j]]);
			++j;
		}
		if(pq.size()>0){
			// DEBUG(i);
			// DEBUG(pq.top());
			// DEBUG(j);
			ans+=pq.top();
			pq.pop();
		}
	}
	cout<<ans<<'\n';
	return 0;
}


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

using namespace std;

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

#define ALL(obj)	(obj).begin(),(obj).end()

typedef unsigned int 			uint;
typedef unsigned long long int	ull;
typedef long long int 			ll;

typedef pair<int,int>			P;

#define LINF		((ll)1 << 63 -1)
#define INF 		(1<<29)
#define MINF		-2000000007
#define MAX 		205

const int MOD = 1e9+7;
// テンプレ終了
//====================================================================//

//
int main(){
	int H,W;cin>>H>>W;
	vector<vector<int>> B(H,vector<int>(W));

	int whtNum = 0;
	REP(i,H)REP(j,W){
		char s;
		cin>>s;
		if(s=='.'){
			B[i][j]=0;	// WHITE
			whtNum++;
		}else {
			B[i][j]=1;			// BLACK
		}
	}
	vector<vector<int>> used(H,vector<int>(W,0));
	queue<P> q;
	P diff[4] = {P(1,0),P(-1,0),P(0,1),P(0,-1)};
	q.push(P(0,0));
	used[0][0]=1;	
	while(!q.empty()){
		P a = q.front();q.pop();
		//cout << a.first << " " << a.second << " " << cnt << endl;
		for(P d : diff){
			int y=a.first+d.first;
			int x=a.second+d.second;
			if(x<0||x>=W ||y<0 || y>=H)continue;
			if(B[y][x]==1)continue;
			if(used[y][x]!=0)continue;
			q.push(P(y,x));
			used[y][x] = used[a.first][a.second]+1;
		}
	}

	cout << (used[H-1][W-1] != 0 ? whtNum-used[H-1][W-1] : -1) << endl;

	return 0;
}




Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; ++i)
#define REPR(i, n) for (int i = n - 1; i >= 0; --i)
#define FOR(i, a, b) for (int i = a; i < b; ++i)
#define FORR(i, a, b) for (int i = b - 1; i >= a; --i)
#define SORT(v) sort(v.begin(), v.end())
#define SORTR(v) sort(v.rbegin(), v.rend())
#define REV(v) reverse(v.begin(), v.end())
#define ITER(itr, v) for (auto itr = v.begin(); itr != v.end(); ++itr)
#define LB(v, x) (lower_bound(v.begin(), v.end(), x) - v.begin())
#define UB(v, x) (upper_bound(v.begin(), v.end(), x) - v.begin())
#define SZ(v) (int)v.size()
using namespace std;
using ll = long long;
using P = pair<int, int>;

class Main {
    int N;
    void input() { cin >> N; }
    void output() {
        ll res = 0;
        for (ll i = 1; i * (i + 1) < N; ++i) { res += (N - 1) / i - i; }
        res *= 2;
        for (ll i = 1; i * i < N; ++i) { ++res; }
        cout << res << endl;
    }

public:
    Main() {
        input();
        output();
    }
};

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

    Main();

    return 0;
}


Measured memory_bytes: 3668
//#include <bits/stdc++.h>
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstdlib>
#include <string>
#include <vector>
#include <map>
#include <queue>

using namespace std;

typedef long long ll;
typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<n;++i)
#define mod (ll)(1e9+7)
#define FIX(a) ((a)%mod+mod)%mod
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define fi first
#define se second
#define pb push_back
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s,t;
    cin >> s >> t;
    int a,b;
    cin >> a >> b;
    string u;
    cin >> u;
    if(u==s){
        cout << a-1 << " " << b << endl;
    }else{
        cout << a << " " << b-1 << endl;

    }

    return 0;
}

Measured memory_bytes: 256
N = int(input())
A = list(map(int, input().split()))
MOD = 10**9 + 7

bit = [0] * 61
for i in range(N):
    for x in range(61):
        if 2**x > A[i]:
            break
        elif (1<<x) & A[i] > 0:
            bit[x] += 1

ans = 0
for i in range(61):
    ans += 2**i * (bit[i] * (N-bit[i]))
    ans %= MOD

print(ans)

Measured memory_bytes: 122808
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <fstream>
#include <iostream>
#include <map>
#include <queue>
#include <string>
#include <stack>
#include <vector>
#include <set>
#include <tuple>
#include <utility>
#include <functional>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef tuple<int,int,int> T;
const int INF = 1000000000;
const int MOD = 1000000009;

int main(){
	string s;
	cin >> s;
	int n = s.size();

	for(int i = 0;i < n;i++){
		if(i + 1 < n && s[i] == s[i+1]){
			cout << i+1 << " " << i+2 << endl;
			return 0;
		}
		if(i + 2 < n && s[i] == s[i+2]){
			cout << i+1 << " " << i+3 << endl;
			return 0;
		}
	}

	cout << -1 << " " << -1 << endl;
}


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

using namespace std;
#define REPP(i,a,b,c) for(int i=a; i<=b; i+=c)
#define REP(i,a,b) REPP(i,a,b,1)
#define REVV(i,a,b,c) for(int i=a; i>=b; i-=c)
#define REV(i,a,b) REVV(i,a,b,1)
#define FOR(i,a) REP(i,0,(int)a-1)
#define FORD(i,a) REV(i,(int)a-1,0)
#define MP make_pair
#define PB push_back
#define POB pop_back
#define FI first
#define SE second
typedef long long ll;
typedef unsigned long long ull;
typedef pair < int , int > pii;
typedef vector < int > vi;
typedef vector < pii > vii;
typedef vector < ll > vl;

const double PI = acos(-1);
const double EPS = 1e-9;
const int INF = 1e9;
const ll MOD = 1e9 + 7;

///////////////////////////////////////////////////////

int main(){
	ios_base :: sync_with_stdio(0); cin.tie(0); cout.tie(0);
	int n;
	cin >> n;
	int ans = 1;
	FOR(i,3){
		ans *= n;
	}
	cout << ans << endl;
	return 0;
} 

Measured memory_bytes: 256
import numpy as np
from sys import stdin

def main():
  n = map(int,input().split())
  a = list(map(int, input().split()))
  b = np.argsort(a)+1
  str_ = ""
  for i in b:
    str_ = str_ + "{:d} ".format(i)  
  print(str_)
  
if __name__ == "__main__":
    main()



Measured memory_bytes: 23360
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vb=vector<bool>;
using vvb=vector<vb>;
using vd=vector<double>;
using vvd=vector<vd>;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using pll=pair<ll,ll>;
using tll=tuple<ll,ll>;
using tlll=tuple<ll,ll,ll>;
using vs=vector<string>;
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rep(i,n) range(i,0,n)
#define rrep(i,n) for(ll i=(n)-1;i>=0;i--)
#define range(i,a,n) for(ll i=(a);i<(n);i++)
#define LINF ((ll)1ll<<60)
#define INF ((int)1<<30)
#define EPS (1e-9)
#define MOD (1000000007ll)
#define fcout(a) cout<<setprecision(a)<<fixed
#define fs first
#define sc second
#define PI (3.1415926535897932384)

int dx[]={1,0,-1,0,1,-1,-1,1},dy[]={0,1,0,-1,1,1,-1,-1};
template<class T>bool chmax(T&a,T b){if(a<b){a=b; return true;}return false;}
template<class T>bool chmin(T&a,T b){if(a>b){a=b; return true;}return false;}
template<class S>S sum(vector<S>&a){return accumulate(all(a),S());}
template<class S>S max(vector<S>&a){return *max_element(all(a));}
template<class S>S min(vector<S>&a){return *min_element(all(a));}
ll max(int a,ll b){return max((ll)a,b);} ll max(ll a,int b){return max(a,(ll)b);}
int sgn(const double&r){return (r>EPS)-(r<-EPS);} // a>0  : sgn(a)>0
int sgn(const double&a,const double&b){return sgn(a-b);} // b<=c : sgn(b,c)<=0

template<class T>void puta(T&&t){cout<<t<<"\n";}
template<class H,class...T>void puta(H&&h,T&&...t){cout<<h<<' ';puta(t...);}
template<class S,class T>void tf(bool b,S t,T f){if(b)puta(t);else puta(f);}
void YN(bool b){tf(b,"YES","NO");}
void Yn(bool b){tf(b,"Yes","No");}
void yn(bool b){tf(b,"yes","no");}
template<class S,class T>ostream&operator<<(ostream&os,pair<S,T>p){os<<"["<<p.first<<", "<<p.second<<"]";return os;};
template<class S>auto&operator<<(ostream&os,vector<S>t){bool a=1;for(auto s:t){os<<(a?"":" ")<<s;a=0;}return os;}
template<class S>auto&operator>>(istream&is,vector<S>&t){for(S&a:t)cin>>a;return is;}

/*他のライブラリを入れる場所*/


int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll n,a,b;
	cin>>n>>a>>b;
	puta(min(n*a,b));
	return 0;
}

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

using namespace std;

using ll = long long;
using ld = long double;

const double PI = 3.1415926535897932384626433832795;

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

int gcd(int x, int y) { return y ? gcd(y, x % y) : abs(x); }
ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : abs(x); }
int lcm(int x, int y) { return x / gcd(x, y) * y; }
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }

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

	string s;
	cin >> s;

	for (auto v : s) {
		if (v == 'A') {
			cout << "T";
		} else if (v == 'T') {
			cout << "A";
		} else if (v == 'C') {
			cout << "G";
		} else if (v == 'G') {
			cout << "C";
		}
	}
	cout << endl;

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0, i##_len = (n); i < i##_len; i++)
#define reps(i, s, n) for(int i = (s), i##_len = (n); i < i##_len; i++)
#define rrep(i, n) for(int i = (n) - 1; i >= 0; i--)
#define rreps(i, e, n) for(int i = (n) - 1; i >= (e); i--)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((int)(x).size())
#define uniq(x) (x).erase(unique((x).begin(), (x).end()), (x).end())

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    // std::ifstream in("input.txt");
    // std::cin.rdbuf(in.rdbuf());
    string s;
    cin >> s;
    if (s == "SUN") {
        cout << 7 << endl;
    }
    else if (s == "MON") {
        cout << 6 << endl;
    }
    else if (s == "TUE") {
        cout << 5 << endl;
    }
    else if (s == "WED") {
        cout << 4 << endl;
    }
    else if (s == "THU") {
        cout << 3 << endl;
    }
    else if (s == "FRI") {
        cout << 2 << endl;
    }
    else if (s == "SAT") {
        cout << 1 << endl;
    }
    return 0;
}


Measured memory_bytes: 256
def B_Balance():
    N = int(input())
    Wn = list(map(int, input().split()))
    abs_min = 100 * N
    for i in range(N-1):
        s1 = sum(Wn[:i+1])
        s2 = sum(Wn[i+1:])
        S_abs = abs(s1 - s2)
        if (S_abs < abs_min):
            abs_min = S_abs
        if (s1 > s2):
            break
    print(abs_min)

if __name__ == "__main__":
    B_Balance()

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

int main(){
    int a,b,c,n,ans=0;
    cin >> a >> b >> c >> n;
   
    for(int i=0;i<=3000;i++){
        for(int j=0;j<=3000;j++){
            if((n-(i*a+j*b))%c==0&&(n-(i*a+j*b))>=0) ans++;
        }
    }
    
    cout << ans << endl;
    
    return 0;
}










Measured memory_bytes: 256
use proconio::{fastout, input};

#[fastout]
fn main() {
    input! {
        n: usize,
        a: [u128; n]
    };

    let mut sum: u128 = 0;

    let mut cur_sum: u128 = 0;
    for j in 0..n {
        cur_sum += a[j];
        // cur_sum = cur_sum % (10u128.pow(9) + 7);
    }

    for i in 0..n - 1 {
        cur_sum -= a[i];
        let x = cur_sum % (10u128.pow(9) + 7);
        sum += a[i] * x % (10u128.pow(9) + 7);
    }
    sum = sum % (10u128.pow(9) + 7);

    println!("{}", sum);
}


Measured memory_bytes: 7256
#include<stdio.h>
#include<algorithm>
#include<functional>
#include<cmath>
using namespace std;
long long  mod = 1000000007;
int main()
{
	int N, K, A[100000];
	scanf("%d%d", &N, &K);
	for (int i = 0; i < N; i++) {
		scanf("%d", &A[i]);
	}
	int count = 1;
	N -= K;
	while (N > 0) {
		count++;
		N -= K - 1;
	}
	printf("%d", count);
	return 0;
}

Measured memory_bytes: 512
object Main extends App {
    for (Array(a, b, n) <- io.Source.stdin.getLines.map(_.split(" ").map(_.toInt))) {
        var rem = a
        var res = 0
        (0 until n).foreach(_ => {
            rem = rem % b * 10
            res += rem / b
        })
        println(res)
    }
}

Measured memory_bytes: 43948
/* 条件式クッサ kyuridenamidaみたい*/

#include <cstdio>
#include <vector>
#include <utility>
#include <queue>
#include <algorithm>
#include <functional>

using namespace std;

int main() {
    int i;
    int n, l, d, done;
    char flg[100000];
    int a[100000];
    int done_pos[100000];
    priority_queue<pair<int, int>, vector<pair<int, int> >, less<pair<int, int> > > next_broken;

    scanf("%d %d", &n, &l);

    scanf("%d", &a[0]);
    flg[0] = 1;

    for (i=0;i<n;i++) {
        done_pos[i] = 0;
    }

    for (i=1;i<n;i++) {
        scanf("%d", &a[i]);
        flg[i] = a[i-1] < a[i];
        if (flg[i-1] && !flg[i]) {
            next_broken.push(make_pair(a[i-1], i-1));
            done_pos[i-1] = 1;
        }
    }

    if (flg[n-1]) {
        next_broken.push(make_pair(a[n-1], n-1));
        done_pos[n-1] = 1;
    }

    d = 0;
    done = 0;
    while (!next_broken.empty() && done < n) {
        pair<int, int> tmp = next_broken.top();
        int len = tmp.first;
        int pos = tmp.second;

        a[pos] = 0;
        len += d;
        d += (l - len);

        done++;

        if ((pos == 1 && a[0] > a[1]) || (pos > 1 && a[pos-1] > a[pos] && !(done_pos[pos-2] && a[pos-2] != 0) && a[pos-2] < a[pos-1])) {
            a[pos-1] -= d;
            next_broken.push(make_pair(a[pos-1], pos-1));
            done_pos[pos-1] = 1;
        }

        if ((pos == n-2 && a[n-2] < a[n-1]) || (pos < n-2 && a[pos] < a[pos+1] && !(done_pos[pos+2] && a[pos+2] != 0) && a[pos+1] > a[pos+2])) {
            a[pos+1] -= d;
            next_broken.push(make_pair(a[pos+1], pos+1));
            done_pos[pos+1] = 1;
        }

        next_broken.pop();
    }

    printf("%d\n", d);
}

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

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    vector<vector<string>> B={{},{},{},
    {"aa.","..b","..b"},
    {"aacd","bbcd","efgg","efhh"},
    {"aabbc","hii.c","h..jd","g..jd","gffee"},
    {"aa.ccd","..bf.d","..bfee","ccdaa.","f.d..b","fee..b"},
    {".aabbcc","a.ddee.","adff...","bd....g","be....g","ce....h","c...iih"}};
    int N; cin >> N;
    if (N==2){cout << -1 << endl; return 0;}
    if (N==3){
        rep(i,3) cout << B[3][i] << endl;
        return 0;
    }
    vector<vector<char>> ans(N,vector<char>(N,'.'));
    int x=(N-N%4)/4-1,y=N-x*4;
    rep(k,x) rep(i,4) rep(j,4) ans[4*k+i][4*k+j]=B[4][i][j];
    rep(i,y) rep(j,y) ans[4*x+i][4*x+j]=B[y][i][j];
    rep(i,N) rep(j,N){
        cout << ans[i][j];
        if (j==N-1) cout << endl;
    }
}

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

using namespace std;

string s;
int n;

main()
{
    ios_base::sync_with_stdio(false);
    cin >> s;
    n = s.length();
    if(s == "zyxwvutsrqponmlkjihgfedcba") cout << -1 << endl;
    else{
        if(s.length() != 26){
            set<int> q;
            for(auto u: s) q.insert(u);
            for(int i = 0; i < 26; i++){
                if(!q.count(i + 'a')){
                    s.push_back(i + 'a');
                    break;
                }
            }
            cout << s << endl;
        }
        else{
            set<int> q;
            for(auto u: s) q.insert(u);
            for(int i = 25; i >= 0; i--){
                q.erase(s[i]);
                if(s[i] == 'z') continue;
                char c = -1;
                for(int j = s[i] + 1; j <= 'z'; j++){
                    if(!q.count(j)){
                        c = j;
                        break;
                    }
                }
                if(c == -1) continue;
                s = s.substr(0, i + 1);
                s.back() = c;
                break;
            }
            cout << s << endl;
        }
    }
}


Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <cstring>
#include <cstdio>
#include <bitset>
#include <cmath>
#include <queue>
#include <map>
#include <set>
using namespace std;
#define rg register
#define LL long long
#define __space putchar(' ')
#define __endl putchar('\n')
template <typename qwq> inline void read(qwq & x)
{
    x = 0;
    rg int f = 1;
    rg char c = getchar();
    while (c < '0' || c > '9')
    {
        if (c == '-') f = -1;
        c = getchar();
    }
    while (c >= '0' && c <= '9')
    {
        x = (x << 1) + (x << 3) + (c ^ 48);
        c = getchar();
    }
    x *= f;
}
template <typename qaq> inline void print(qaq x)
{
    if (x < 0)
    {
        putchar('-');
        x = -x;
    }
    if (x > 9) print(x / 10);
    putchar(x % 10 + '0');
}
/*
可以发现:除了最后一次染色的那个长度为k的区间以外的所有格子,都可以任意确定颜色

方法:先贴着整个序列两侧用区间涂色,然后慢慢地把涂色区间向中间挪,这样就可以一格一格地确定颜色

实现:那么只要用前缀和处理一下,枚举这个最后涂色的区间即可.

*/
#define max(a,b) (a > b ? a : b)
LL n,k,ans;
LL a[2333333],s[2333333],pre[2333333],Next[2333333];
int main()
{
	read(n),read(k);
	for (rg int i = 1;i <= n;++i)
	{
		read(a[i]);
		s[i] = s[i - 1] + a[i];
		pre[i] = pre[i - 1] + max(a[i],0);//预处理前i个的最大选择情况 
	}
	for (rg int i = n;i >= 1;--i) Next[i] = Next[i + 1] + max(a[i],0);//预处理i~n的最大选择 
	for (rg int i = 0;i <= n - k;++i)//枚举最后的区间 
	{
		rg LL lr = pre[i] + Next[i + k + 1],mid = s[i + k] - s[i];
		//lr:已经确定的两侧 mid:中间k个数 
		ans = max(ans,lr + max(mid,0));
	}
    print(ans);
}

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

int main(){
    int x,y;
    cin >> x >> y;
    string ans = "No";

    rep(i,x+1) {
        if(i*2 + (x-i)*4 == y)ans = "Yes";
    }
    
    cout << ans << endl;
    return 0;
}

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

int main() {
	string	S;
	cin >> S;
	int a;
	int b;
	a = 0;
	b = 0;
	for (int i = 0; i < 3; i++)
	{
		if (S.at(i) == 'A')	
			a++;
		if (S.at(i) == 'B')
			b++;
	}
	if (a > 0 && b > 0)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=300005,K=4,p=998244353;
int read(){
	int f=1,g=0;
	char ch=getchar();
	for (;!isdigit(ch);ch=getchar()) if (ch=='-') f=-1;
	for (;isdigit(ch);ch=getchar()) g=g*10+ch-'0';
	return f*g;
}
int qpow(int x,int k){
	int t=1;
	for (;k;k>>=1){
		if (k&1) t=(ll)t*x%p;
		x=(ll)x*x%p;
	}
	return t;
}
struct state{
	int a[K];
	int &operator[](int i){return a[i];}
	state(){memset(a,0,sizeof(a));}
}x,rx,s[N][2],c,e;
bool operator==(state a,state b){
	for (int i=0;i<K;i++)
	if (a[i]==b[i]) return false;
	return true;
}
bool operator<(state a,state b){
	for (int i=0;i<K;i++)
	if (a[i]!=b[i]) return a[i]<b[i];
	return false;
}
state operator*(state x,state y){for (int i=0;i<K;i++) x[i]=(ll)x[i]*y[i]%p;return x;}
state operator+(state x,state y){for (int i=0;i<K;i++) if((x[i]+=y[i])>=p) x[i]-=p;return x;}
state operator-(state x,state y){for (int i=0;i<K;i++) if((x[i]-=y[i])<0) x[i]+=p;return x;}
state operator+(state x,int k){for (int i=0;i<K;i++) if ((x[i]+=k)>=p) x[i]-=p;return x;}
state operator-(state x,int k){for (int i=0;i<K;i++) if ((x[i]-=k)<0) x[i]+=p;return x;}
state getval(state *a,state x){
	state cur=a[0]+a[1]*x;
	return cur;
}
int n,m;
ll ans;
char ch[N];
map<state,int> f;
int main(){
	for (int i=0;i<K;i++) x[i]=i+1,rx[i]=qpow(x[i],p-2);
	n=read();
	scanf(" %s",ch+1);
	for (int i=0;i<K;i++) s[n+1][1][i]=1;
	for (int i=n;i;i--)
	if (ch[i]=='+'){s[i][0]=s[i+1][0]+s[i+1][1];s[i][1]=s[i+1][1];c=c-1;}
	else if (ch[i]=='-'){s[i][0]=s[i+1][0]-s[i+1][1];s[i][1]=s[i+1][1];c=c+1;}
	else if (ch[i]=='>'){s[i][0]=s[i+1][0];s[i][1]=s[i+1][1]*x;c=c*rx;}
	else if (ch[i]=='<'){s[i][0]=s[i+1][0];s[i][1]=s[i+1][1]*rx;c=c*x;}
	for (int i=n;i;i--){
		f[getval(s[i+1],e)]++;
		ans+=f[getval(s[i],c)];
	}
	printf("%lld\n",ans);
	return 0;
}

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

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

  bool hasYellow = false;

  for (int i = 0; i < N; i++) {
    string S;
    cin >> S;
    if (S == "Y") {
      hasYellow = true;
      break;
    }
  }
  
  if (hasYellow) {
    cout << "Four" << endl;
  } else {
    cout << "Three" << endl;
  }
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//typedef __int128_t LL;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define F first
#define S second
#define pb push_back
mt19937 rnd;

const int N = 2e5 + 10;
int a[N];

int main() {
    ios_base::sync_with_stdio(0); cin.tie(0);
#ifdef LOCAL
    freopen("input.txt", "r", stdin);
#endif

    int n, k;
    cin >> n >> k;
    for (int i = 1; i <= n; i++) {
        cin >> a[i];
    }
    for (int i = k + 1; i <= n; i++) {
        if (a[i - k] < a[i]) {
            cout << "Yes\n";
        }
        else {
            cout << "No\n";
        }
    }

#ifdef LOCAL
    cerr << "\nTime elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif
    return 0;
}


Measured memory_bytes: 4440