akhauriyash/Code-Regression huggingface dataset:
import java.util.*;
public class Main {
    public static void main(String args []){
        Scanner sc = new Scanner (System.in);
        String S = sc.next();
        int num = 0;
        for(int i=0;i<S.length()/2;i++) if(S.charAt(i)!=S.charAt(S.length()-i-1))num ++;
        System.out.println(num);
    }
}

Measured memory_bytes: 22740
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int a,b,c,d;
    int x,y;
    cin>>a>>b>>c>>d;
    x=a*b;
    y=c*d;
    if(x>=y)
    {
        cout<<x;
    }
    else if(x<y)
    {
        cout<<y;
    }
    return 0;
}


Measured memory_bytes: 256
n,m = map(int, input().split())
ab = [list(map(int, input().split())) for i in range(n)]
cd = [list(map(int, input().split())) for i in range(m)]
for i in ab:
  x1, y1 = i[0], i[1]
  ans = 0
  MIN = 10 ** 9 + 7
  for key,j in enumerate(cd): 
    x2, y2 = j[0], j[1]
    manhattan = abs(x2-x1) + abs(y2-y1)
    if MIN > manhattan:
      ans = key + 1
      MIN = manhattan
  print(ans)
    


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

using namespace std;

#define int long long
#define pii pair<int, int>
#define pb push_back

signed main() {
    ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
    int N;
    cin >> N;
    vector<int> v;
    for(int i = 0; i < N; i++) v.pb(i + 1);
    vector<int> a(N, 0);
    vector<int> b(N, 0);
    for(auto &i: a) cin >> i;
    for(auto &i: b) cin >> i;
    int A = -1, B = -1, i = 0;
    do {
        if(a == v) {
            A = i;
        }
        if(b == v) {
            B = i;
        }
        i++;
    }
    while (next_permutation(v.begin(), v.end()));
    cout << abs(A - B) << endl;
    return 0;
}



Measured memory_bytes: 256
using System;
//using System.Collections.Generic;
public class ProCon
{
    public static void Main(){     
        string[] number =　Console.ReadLine().Split(' ');
        string X = number[0];
        string Y = number[1];
        string Z = number[2];

        Console.WriteLine(Z + " " + X + " " + Y);
    }
}

Measured memory_bytes: 11092
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <queue>
#include <stack>
#include <map>
#include <algorithm>
#include <math.h>
#include <cassert>
#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,m;
  cin >> n >> m;
  int ans = n*(n-1)/2+m*(m-1)/2;
  cout << ans << endl;
}


Measured memory_bytes: 384
{-# LANGUAGE BangPatterns #-}
{-# LANGUAGE ScopedTypeVariables #-}
import qualified Data.ByteString.Char8 as BS
import qualified Data.Vector.Unboxed as U

main = do
  n :: Int <- readLn
  s <- BS.getLine
  let count s | BS.null s = []
              | otherwise = let (s1,s2) = BS.span (== '.') s
                                (s3,s4) = BS.span (== '#') s2
                                !n1 = BS.length s1
                                !n2 = BS.length s3
                            in (n1,n2) : count s4
      vec = U.fromList $ count s
      blackAcc = U.init $ U.scanl' (\n (_,m) -> n + m) 0 vec
      whiteAcc = U.tail $ U.scanr' (\(m,_) n -> n + m) 0 vec
      acc = U.zipWith (+) blackAcc whiteAcc
  print $ if U.null acc then 0 else U.minimum acc


Measured memory_bytes: 8316
using System;
using static System.Console;
using static System.Math;


class Program
{
    static void Main(string[] args)
    {
        string[] input = ReadLine().Split(' ');
        int n = int.Parse(input[0]);
        int X = int.Parse(input[1]);
        string[] xs = ReadLine().Split(' ');
        int[] x = new int[n];
        for (int i = 0; i < n; i++)
        {
            x[i] = int.Parse(xs[i]);
        }
        int ans = Abs(X - x[0]);
        for (int i = 0; i < n; i++)
        {
            if (ans > Gcd(ans, Abs(X - x[i]))) { ans = Gcd(ans, Abs(X - x[i])); };
        }

        WriteLine(ans);
 
      }
    public static int Gcd(int a, int b)
    {
        return a > b ? GcdRecursive(a, b) : GcdRecursive(b, a);
    }

    private static int GcdRecursive(int a, int b)
    {
        return b == 0 ? a : GcdRecursive(b, a % b);
    }
}

Measured memory_bytes: 18400
#include<stdio.h>
int main(){
  int a,b,i,j,k;
  long long d[15][1010];
  while(scanf("%d %d",&a,&b),a||b){
    for(i=0;i<15;i++){
      for(j=0;j<1010;j++)d[i][j]=0;
    }
    d[0][0]=d[1][0]=1;
    for(i=1;i<101;i++){
      for(j=a-1;j>-1;j--){
	for(k=b-1;k>-1;k--){
	  if(d[j][k]==0||k+i>b)continue;
	  d[j+1][k+i]+=d[j][k];
	}
      }
    }
    printf("%lld\n",d[a][b]);
  }
  return 0;
}

Measured memory_bytes: 720
#include<bits/stdc++.h>
using namespace std;
const int mod=1e9+7;
int s;
long long a[2010];//表示用3~i组合成和为i的方案数。 
long long ans;
int main()
{
	cin>>s;
	a[0]=1;
	for(int i=3;i<=s;i++)
	{
		for(int j=3;j<=i;j++)
		{
			a[i]=(a[i]+a[i-j])%mod;
		}
	}
	cout<<a[s];
	return 0;
}

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

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
ll gcd(ll a, ll b){return (b==0)?a:gcd(b,a%b);}


int printknapSack(int W, vector<int>& wt, vector<int>& val, int n) 
{ 
    int i, w; 
    int K[n + 1][W + 1]; 
  
    // Build table K[][] in bottom up manner 
    for (i = 0; i <= n; i++) { 
        for (w = 0; w <= W; w++) { 
            if (i == 0 || w == 0) 
                K[i][w] = 0; 
            else if (wt[i - 1] <= w) 
                K[i][w] = max(val[i - 1] +  
                    K[i - 1][w - wt[i - 1]], K[i - 1][w]); 
            else
                K[i][w] = K[i - 1][w]; 
        } 
    } 
  
    // stores the result of Knapsack 
    int res = K[n][W];     
    int tres = res;
	vector<bool> tmparr(n,false);
      
    w = W; 
    for (i = n; i > 0 && res > 0; i--) { 
          
        // either the result comes from the top 
        // (K[i-1][w]) or from (val[i-1] + K[i-1] 
        // [w-wt[i-1]]) as in Knapsack table. If 
        // it comes from the latter one/ it means  
        // the item is included. 
        if (res == K[i - 1][w])  
            continue;         
        else { 
  
            // This item is included. 
            //printf("%d ", wt[i - 1]); 
			tmparr[i-1] = true;
              
            // Since this weight is included its  
            // value is deducted 
            res = res - val[i - 1]; 
            w = w - wt[i - 1]; 
        } 
    } 

	int maxval = -1;
	for(int i = 0; i < n; ++i){
		if(tmparr[i] == false){
			maxval = max(maxval,val[i]);
            
		}
	}
    //cout << maxval << endl;
    if(maxval == -1) return tres;
    else return (maxval + tres);
} 


int main(){

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

	int n, t; cin >> n >> t;
	vector<int> weight(n);
    vector<int> value(n);

	for(int i = 0; i < n; ++i) {
		cin >> weight[i] >> value[i];
	}

	cout << printknapSack(t-1,weight,value,n) << endl;

    return 0;
}

Measured memory_bytes: 35456
import java.io.BufferedReader;
import java.io.File;
import java.io.FileInputStream;
import java.io.InputStreamReader;
import java.util.Comparator;
import java.util.PriorityQueue;
import java.util.StringTokenizer;


public class Main {
    FastIO io = new FastIO("in.txt");
    int N; char[] S;
    public void main() throws Exception {
        N = io.nextInt();
        S = io.nextLine().toCharArray();

        int i = 0, j = N - 1;
        long ans = 0;
        while(i < j){
            while(i < j && S[i] != 'W') i++;
            while(i < j && S[j] != 'R') j--;
            if(i < j){
                ans++;
                S[i] = 'R';
                S[j] = 'W';
            }
        }

        io.out(ans + "\n");
        
    }

    public static void main(String[] args) throws Exception {
        Main task = new Main();
        task.main();
    }

    class FastIO {
        BufferedReader br;
        StringTokenizer sk;

        public FastIO(String fname){
            try{
                File f = new File(fname);
                if(f.exists()) {
                    System.setIn(new FileInputStream(fname));
                }

            }catch (Exception e){
                throw new IllegalArgumentException(e);
            }

            br = new BufferedReader(new InputStreamReader(System.in));
        }

        public FastIO(){
            br = new BufferedReader(new InputStreamReader(System.in));
        }

        String next(){
            while(sk==null || !sk.hasMoreElements()){
                try {
                    sk = new StringTokenizer(br.readLine());
                }catch (Exception e){
                    throw new IllegalArgumentException(e);
                }
            }
            return sk.nextToken();
        }

        public int nextInt(){
            return Integer.parseInt(next());
        }

        public char nextChar(){
            return next().charAt(0);
        }

        public long nextLong(){
            return Long.parseLong(next());
        }

        public double nextDouble(){
            return Double.parseDouble(next());
        }

        public String nextLine(){
            String str = "";
            try {
                str = br.readLine();
            }catch (Exception e){
                e.printStackTrace();
            }
            return str;
        }

        public void out(String v){
            System.out.print(v);
        }

        public void out(int v) {
            System.out.print(v);
        }

        public void out(long v){
            System.out.print(v);
        }

        public void out(double v) {
            System.out.print(v);
        }
    }
}



Measured memory_bytes: 38404
#include<bits/stdc++.h>
#define ll long long
#define p5 100005
using namespace std;
int n,e,dp[p5+2];
vector<int>graph[p5+2];
bool visit[p5+2];
void bfs(int x)
{
    //cout<<" x : "<<x<<endl;
    visit[x]=true;
    for(int i=0;i<graph[x].size();i++){
        int r=graph[x][i];
        if(visit[r]==false)
            bfs(r);
            dp[x]=max(dp[x],dp[r]+1);
    }

}
int main()
{
    cin>>n>>e;
    for(int i=0;i<e;i++){
        int x,y;
        cin>>x>>y;
        graph[x].push_back(y);
    }
    for(int i=1;i<=n;i++){
        if(visit[i]==false)
            bfs(i);
    }
    int mx=0;
    for(int i=0;i<=n;i++){
        mx=max(mx,dp[i]);
    }
    cout<<mx<<endl;
    return 0;
}


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

using namespace std;

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

 if (n%2==1){ cout << "No"; return 0;}
 for (int i=0; i<n/2; ++i)
   if (s[i]!=s[i+n/2]){ cout << "No"; return 0;}

  cout << "Yes";


 }


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


int		main(void)
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	int a, b, c, d;
	cin >> a >> b >> c >> d;
	if (a + b > c + d)
		cout << "Left" << "\n";
	else if (a + b < c + d)
		cout << "Right" << "\n";
	else
		cout << "Balanced" << "\n";
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define forn(i,n) for(int i=0;i<n;i++)
#define fre(i,a,b) for(int i = a; i < b; i++)
#define sf(n) scanf("%lld", &n)
#define sff(a,b) scanf("%lld %lld", &a, &b)
#define sfff(a,b,c) scanf("%d %d %d", &a, &b, &c)
#define pfn(n) printf("%d\n", n)
#define pfs(n) printf("%d ", n)
#define ff first
#define ss second
#define mem(a,b) memset(a,b,sizeof(a))
#define ll long long int
#define f find
#define ub upper_bound
#define lb lower_bound
#define ld long double
#define in insert
#define bs binary_search  
#define le length()
const ll max_i=1e15;
#define np(s) next_permutation(s.begin(),s.end())
//it gives the lexicographically next string
 ll GCD(ll a,ll b)
    {
        if(b==0)
            return a;
        else return GCD(b,a%b);
    }
int main()
{
  int t=1;
  //cin>>t;
  while(t--)
  {
   int a,b;
   cin>>a>>b;
   if((b-1)%(a-1)==0) cout<<(b-1)/(a-1);
   else cout<<(b-1)/(a-1)+1;
  }
  return 0;
}


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

using namespace std;


#define MAXN 51
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int k = -1;
  string s, t;
  cin >> s >> t;
  for (int i = 0; i < s.size()-t.size()+1; ++i) {
    int da = 1;
    for (int j = 0; j < t.size(); ++j) {
      da &= s[i+j]=='?' || s[i+j]==t[j];
    }
    if (da) k = i;
  }
  if (k==-1) {
    cout << "UNRESTORABLE" << endl;
    return 0;
  }
  for (int i = 0; i < s.size(); ++i) {
    if (s[i]=='?') {
      if (i>=k && i<t.size()+k) {
        cout << t[i-k];
      } else {
        cout << 'a';
      }
    } else {
      cout << s[i];
    }
  }
  cout << endl;
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>
#include<set>
#include<map>
#include<iomanip>

using namespace std;

int main(void) {
	int x, y, z;
	cin >> x >> y >> z;
	int n = 0;
	for (n; n*(y + z) + z <= x; n++) {
	}
	cout << n - 1;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n)for(long long i=0;i<(n);i++)
using namespace std;
using P=pair<int,int>;
typedef unsigned long long ull;
typedef long long ll;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
const ll INF=1e18;
const ll MOD=998244353;
const double pi=acos(-1);
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

int n;
int d[100010];
ll c[100010];
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);  
  
  cin >> n;  
  rep(i,n){
    cin >> d[i];
    c[d[i]]++;
  }
  if(d[0]!=0){
    cout << 0 << endl;
    return 0;
  }
  
  ll ans=1ll;
  for(int i=1;i<n;i++){
    ans=ans*c[d[i]-1]%MOD;
  }
  cout << ans << endl;
}


Measured memory_bytes: 1408
#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++)
 
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; }
 
const long long INF = 1LL << 60;
#define PI 3.14159265359 
bool dp[100100];
 
 
int main () {
    string S;
    cin >> S;

    cout << S[0] << S[1] << S[2] << endl;

    

}

Measured memory_bytes: 3628
class Process():
  def __init__(self, name, time):
    self.name = name
    self.time = time

  def getName(self):
    return self.name

  def getTime(self):
    return self.time

  def runTask(self, q):
    if(self.time > q):
      self.time -= q
      return q
    else:
      tempTime = self.time
      self.time = 0
      return tempTime

n, q = map(int, input().split())

retAry = []
qTime = 0
que = []

for i in range(n):
  name, time = input().split()
  process = Process(name, int(time))
  que.append(process)

while(len(que)):
  process = que.pop(0)

  qTime += process.runTask(q)
  if(process.getTime() != 0):
    que.append(process)
  else:
    retAry.append(process.getName() + ' ' + str(qTime))

for i in range(len(retAry)):
  print(retAry[i])


Measured memory_bytes: 19872
<?php
  
  fscanf(STDIN,"%d",$N);
$a_list = explode(" ",trim(fgets(STDIN)));
$b_list = explode(" ",trim(fgets(STDIN)));
$c_list = explode(" ",trim(fgets(STDIN)));

$sum=0;

for($i=0;$i<$N;$i++){
  if($a_list[$i]+1 == $a_list[$i+1]){
    
    $sum+=($b_list[$a_list[$i]-1]+$c_list[$a_list[$i]-1]);
  }else{
    $sum+=$b_list[$a_list[$i]-1];
  }
}

echo $sum."\n";



 





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

int main(){
    int N; cin >> N;
    string S; cin >> S;
    int EAST=0;
    int WEST=0;
    int ans =N;

    rep(i,N){

        if(S[i] == 'E'){
            EAST++;
        }

    }

    rep(i,N){

        if(S[i] == 'E'){
            EAST--;
        }

        ans = min(ans, EAST+WEST );

        if(S[i] == 'W'){
            WEST++;
        }

    }

    cout << ans << endl;

}

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


int main(){
double  d,t,s;cin>>d>>t>>s;
if((d/s)>t){cout<<"No";return 0;}
else {cout<<"Yes";return 0;}

}



Measured memory_bytes: 3704
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double db;
typedef pair<int,int> pii;
#define fir first
#define sec second
#define rep(i,a,b) for (int i = (a) ; i <= (b) ; ++ i)
#define rrp(i,a,b) for (int i = (a) ; i >= (b) ; -- i)
#define gc() getchar()
template <typename tp>
inline void read(tp& x) {
  x = 0; char tmp; bool key = 0;
  for (tmp = gc() ; !isdigit(tmp) ; tmp = gc())
    key = (tmp == '-');
  for ( ; isdigit(tmp) ; tmp = gc())
    x = (x << 3) + (x << 1) + (tmp ^ '0');
  if (key) x = -x;
}
template <typename tp>
inline void ckmn(tp& x,tp y) {
  x = x < y ? x : y;
}
template <typename tp>
inline void ckmx(tp& x,tp y) {
  x = x < y ? y : x;
}

const int MOD = 998244353;
inline void Add(int& x,int y) {
  x = x + y >= MOD ? x + y - MOD : x + y;
}
inline void Sub(int& x,int y) {
  x = x - y < 0 ? x - y + MOD : x - y;
}
int power(int a,int b) {
  int ret = 1;
  while (b) {
    if (b&1) ret = 1ll * ret * a % MOD;
    a = 1ll * a * a % MOD;
    b >>= 1;
  }
  return ret;
}
const int N = 3000000;
int jc[N], ijc[N], n, m, ans;
void init(int t) {
  jc[0] = 1;
  rep (i, 1, t) jc[i] = 1ll * jc[i-1] * i % MOD;
  ijc[t] = power(jc[t], MOD - 2);
  rrp (i, t-1, 0) ijc[i] = 1ll * ijc[i+1] * (i+1) % MOD;
}
int comb(int a,int b) {
  if (a < b || b < 0) return 0;
  return 1ll * jc[a] * ijc[b] % MOD * ijc[a-b] % MOD;
}
int main() {
  read(n), read(m);
  init(n + 3 * m);
  rep (i, 0, min(n, m)) if ((m-i) % 2 == 0) {
    Add(ans, 1ll * comb(n, i) * comb((3 * m - i) / 2 + n - 1, n - 1) % MOD);
    if (i <= m-2)
      Sub(ans, 1ll * n * comb(n-1,i) % MOD * comb((3*m-i-2*(m+1)) / 2 + n - 1, n - 1) % MOD);
    if (i <= m)
      Sub(ans, 1ll * n * comb(n-1,i-1) % MOD * comb((3*m-i-2*m)/2 + n-1, n-1) % MOD);
  }
  printf("%d\n", ans);
  return 0;
}


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

//定数
const long long MOD1=1000000007;
const long long MOD2=998244353;
const long double PI=3.1415926535897932;
const long long MAXLL=9223372036854775807;
const long long INF=2305843009213693951;
const long long dx[]={0,1,0,-1,1,-1,1,-1};
const long long dy[]={1,0,-1,0,1,1,-1,-1};

//型名省略
#define ll long long
#define ull unsigned long long
#define ld long double
#define uld unsigned long double
#define pll pair<long long,long long>
#define tll(n) array<long long,(int)(n)>
#define pcc pair<char,char>
#define vl vector<long long>
#define vvl vector<vector<long long>>
#define vc vector<char>
#define vvc vector<vector<char>>
#define vb vector<bool>
#define vvb vector<vector<bool>>
#define vp vector<pair<long long,long long>>
#define vt(n) vector<array<long long,(int)(n)>>
#define umap unordered_map
#define uset unordered_set
#define Lqueue priority_queue<long long>
#define Squeue priority_queue<long long,vector<long long>,greater<long long>>
#define Fi first
#define Se second
#define mp make_pair
#define eb emplace_back

//マクロ
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define rbf(a,x) for(auto& a:x)
#define rep(i,n) for(long long i=0;i<(long long)(n);i++)
#define rep2(i,s,n) for(long long i=(s);i<(long long)(n);i++)
#define bitrep(i,s,n) for(long long i=(s);i<(1LL<<(n));i++)
#define Maxe(x) *max_element((x).begin(),(x).end())
#define Mine(x) *min_element((x).begin(),(x).end())
#define Size(x) ((long long)(x).size())
#define lin(s) getline(cin,(s))
#define Ssort(v) sort((v).begin(),(v).end(),[](auto &left,auto &right){return left.second<right.second;})

//Yes,No
void Yes(bool a){cout<<(a?"Yes":"No")<<endl;}
//YES.NO
void YES(bool a){cout<<(a?"YES":"NO")<<endl;}

//MAX,MIN
template<class T,class U> auto max(T a,U b){return a>b?a:b;}
template<class T,class U> auto min(T a,U b){return a<b?a:b;}

//最大公約数,最小公倍数
long long gcd(long long a,long long b){return b?gcd(b,a%b):a;}
long long lcm(long long a,long long b){return a/gcd(a,b)*b;}

//累乗
template<typename t>
constexpr t mypow(t a,long long b){
    if(b==0)return 1;
    if(a==0)return 0;
    t x=1;
    while(b>0){
        if(b&1LL)x*=a;
        a*=a;
        b>>=1LL;
        }
    return x;
}
#define pow mypow

//chmin,chmax
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;}

//組み合わせ O(r)
template<typename t>
constexpr t nCr(t n,long long r){
    if(r==0)return 1;
    if(n==0)return 0;
    if(n<r)return 0;
    t x=1;
    for(long long i=1;i<=r;i++){
        x*=n-i+1;
        x/=i;
    }
    return x;
}

//main関数
signed main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    ll n;
    string s;
    cin>>n>>s;
    ll r=0;
    ll w=0;
    rep(i,n){
        if(s[i]=='R')r++;
        else w++;
    }
    ll res=0;
    rep(i,r){
        if(s[i]=='W')res++;
    }
    cout<<res<<endl;
}

Measured memory_bytes: 3732
//inlclude前用define 
#define _USE_MATH_DEFINES

//include
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<cmath>
#include<type_traits>
#include<numeric>
//#include<deque>
#include<iomanip>
#include<set>
#include<tuple>
#include<map>

using namespace std;

//typedef
typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<char> VC;
typedef long long int ll;

//define
#define INF 1e9 
#define NUM 1000000007
#define all(x) begin(x), end(x)
#define rep(i,n) for(int i=0;i<(int)(n);i++)

int main() {
    int n;
    cin>>n;
    int ans=pow(n,3);
    cout<<ans<<endl;

}



Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<cctype>
#include<cstdlib>
#include<algorithm>
#include<bitset>
#include<vector>
#include<list>
#include<deque>
#include<queue>
#include<map>
#include<set>
#include<stack>
#include<cmath>
#include<sstream>
#include<fstream>
#include<iomanip>
#include<ctime>
#include<complex>
#include<functional>
#include<climits>
#include<cassert>
#include<iterator>
#include<random>
#include<unordered_set>
#include<unordered_map>
using namespace std;

#define MAX 100002

int n;
int k;
vector<long long int> v;

long long int solve(vector<long long int> &v) {
	long long int ret = LLONG_MAX;
	for (int i = 0; i < v.size(); i++) {
		if (v[i] >= 0) {
			long long int cost = v[i];
			int need = i - k + 1;
			if (need < 0)continue;
			if (v[need] < 0) {
				cost *= 2;
				cost += abs(v[need]);
			}
				ret = min(ret, cost);
			//}
		}
	}
	return ret;
}

int main() {
	cin >> n>>k;
	for (int i = 0; i < n; i++) {
		int x;
		scanf("%d", &x);
		if (x == 0) {
			k--;
			continue;
		}
		v.push_back(x);
	}
	if (k == 0) {
		puts("0");
		return 0;
	}
	long long int ans = solve(v);
	for (int i = 0; i < v.size(); i++)v[i] = -v[i];
	reverse(v.begin(), v.end());
	ans = min(ans, solve(v));
	printf("%lld\n", ans);
	return 0;
}

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

typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<ld,ld> pdd;
typedef vector<ll> vll;
typedef vector<ld> vld;
typedef vector<pll> vpl;
typedef vector<vll> vvll;

#define ALL(a) a.begin(),a.end()
#define SZ(a) ((int)a.size())
#define FI first
#define SE second
#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 FOR(i,a,b) for(int i=(a);i<(b);i++)
#define PB push_back
#define EB emplace_back
#define MP(a,b) make_pair(a,b)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define yes cout<<"Yes"<<endl
#define YES cout<<"YES"<<endl
#define no cout<<"No"<<endl
#define NO cout<<"NO"<<endl
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL

const int inf = 1e9;
const ll linf = 1LL << 50;
const double eps = 1e-10;
const int MOD = 1e9 + 7;
const int dx[4] = {-1, 0, 1, 0};
const int dy[4] = {0, -1, 0, 1};

int main(){
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);

  ll n;
  cin>>n;
  ll base=0;
  REP(i,32){
    if(i%2==1)
      base-=pow(2,i);
  }

  ll target=n-base;


  vll ans(32);
  REP(i,32){
    if(i%2==1)
      ans[i]=1;
  }

  for(ll i=31; i>=0; i--){
    if((target>>i)&1)
      ans[i]=(ans[i]+1)%2;
  }

  bool flag=false;
  for(ll i=31; i>=0; i--){
    if(ans[i]==1)
      flag=true;
    if(flag || i==0)
      cout<<ans[i];
  }
  cout<<endl;

}



Measured memory_bytes: 4052
#include <bits/stdc++.h>
#define pb push_back
#define cmin(a,b) (a>b?a=b:a)
#define cmax(a,b) (a<b?a=b:a)
#define mem(a,k) memset(a,k,sizeof(a))
#define lop(i,s,t) for(int i=s;i<(t);++i)
#define rep(i,s,t) for(int i=s;i<=(t);++i)
#define dec(i,s,t) for(int i=s;i>=(t);--i)
#define fore(i,v) for(int i=g[v],d=es[i].d;i;i=es[i].nxt,d=es[i].d)
using namespace std;

const int N=1e6+50; 

int n,ans;
char S[N],T[N]; 
queue<int> q;

int main(int argc,char *argv[]){
#ifdef CURIOUSCAT
	freopen("dat.in","r",stdin);
//	freopen("bru.out","w",stdout);
#endif
	scanf("%d%s%s",&n,S+1,T+1); 
	if(strcmp(S+1,T+1)==0)return puts("0"),0; 
	int p=n;
	dec(i,n,1){
		if(T[i]==T[i-1])continue;
		cmin(p,i); 
		while(p&&S[p]!=T[i])--p;
		if(!p)return puts("-1"),0;
		while(!q.empty()&&q.front()-(int)q.size()>=i){
			q.pop();
		}
		q.push(p);
		if(i!=p)cmax(ans,(int)q.size()); 
	}
	printf("%d\n",ans+1);
	return 0; 
}


Measured memory_bytes: 6272
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(k,i,n) for(ll i=k;i<n;++i)
int main(void){
    // Your code here!
    ll n,d;
    cin>>n>>d;
    ll x[n][d];
    rep(0,i,n)rep(0,j,d)cin>>x[i][j];
    ll ans=0;
    rep(0,i,n){
        ll sum=0;
        rep(i+1,j,n){
            sum=0;
            rep(0,k,d)sum+=(x[i][k]-x[j][k])*(x[i][k]-x[j][k]);
                if((ll)sqrt(sum)==sqrt(sum)){
                    ++ans;
                }
        }
    }
    cout<<ans;
}


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

/* #pragma */
//#pragma GCC optimize("Ofast")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")


/*alias*/
#define F first
#define S second

#define y0 y3487465
#define y1 y8687969
#define j0 j1347829
#define j1 j234892
#define next asdnext
#define prev asdprev
#define itn int

/*template*/
template<class T>inline bool amax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>inline bool amin(T &a, const T &b) { if (b < a) { a = b; return 1; } return 0; }

/* func */
int32_t GCD(int32_t a, int32_t b){return b ? GCD(b, a%b) : a;}
int64_t GCD(int64_t a, int64_t b){return b ? GCD(b, a%b) : a;}
int32_t LCM(int32_t a, int32_t b){return a * b / GCD(a, b);}
int64_t LCM(int64_t a, int64_t b){return a * b / GCD(a, b);}

/*struct*/
struct aaa {
	aaa() {
		cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(20);
	};
}aaaaaaa;

/* const */
constexpr int32_t INF = 1001001001;
constexpr int64_t LINF = 1001001001001001001ll;
constexpr int32_t MOD = 1e9 + 7; //10^9
constexpr int64_t EPS = 1e-9;
constexpr int32_t dx[] = { 1, 1, 0, -1, -1, -1, 0, 1 }, dy[] = { 0, 1, 1, 1, 0, -1, -1, -1 };
//constexpr int32_t dx[] = {1, 0, -1, 0}, dy[] = {0, 1, 0, -1};
//Counterclockwise from the 6o'clock direction
//Take the x-axis downward and the y-axis right


//g++ -std=c++14 -Wall --pedantic-errors -o template template.cpp
//g++ -std=c++14 -Wall --pedantic-errors template.cpp
//chcp 65001

/*global*/



//#define int int64_t
signed main()
{
	int n; cin >> n;
	vector<int> a(n+1);
	for(int i = 0, i_len = (int)n+1; i < i_len; ++i) cin >> a[i+1];
	vector<int> b(n+1);

	for(int i = n; i >= 1; --i)
	{
		int sum{};
		for(int j = i+i; j <= n; j += i)
		{
			sum ^= b[j];
		}
		b[i] = sum^a[i];
	}	
	vector<int> ans;
	for(int i = 1; i <= n; ++i)
	{
		if(b[i]) ans.emplace_back(i);
	}
	cout << ans.size() << '\n';
	for(int i = 0; i < ans.size(); ++i)
	{
		cout << ans[i] << '\n';
	}
}

Measured memory_bytes: 3192
#include<stdio.h>

int main(){
  int i,input,fibonacciA=1,fibonacciB=1,fibonacciC=1;
  scanf("%d",&input);
  if(input == 0 || input == 1){
    printf("%d\n",fibonacciA);
  }else{
    for(i=1;i<input;i++){
      fibonacciC = fibonacciB + fibonacciA;
      fibonacciA = fibonacciB;
      fibonacciB = fibonacciC;
    }
    printf("%d\n",fibonacciC);
  }
  return 0;
}

Measured memory_bytes: 596
S = input()

N = len(S)

def func(S,ans,N):
    for i in range(N):
        if S[i] != S[N - i-1]:
            ans ='No'
    return (ans)

ans = func(S, 'Yes',(len(S)-1//2))
S1 = S[(N+3)//2-1:N]
ans = func(S1, ans,len(S1))

print(ans)

Measured memory_bytes: 3064
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <vector>
#include <cstdio>
#include <cmath>

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

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

int main(){
    int n;
    cin >> n;
    ll ans = 1;
    ll mod = 1000000007;
    ll kyu = 1;
    ll hachi = 1;
    rep(i,n){
        ans *= 10;
        kyu *= 9;
        hachi *= 8;
        ans %= mod;
        kyu %= mod;
        hachi %= mod;
    }
    ans -= 2 * kyu;
    ans += hachi;
    ans %= mod;
    if(ans < 0) ans += mod;
    cout << ans << endl;
}

Measured memory_bytes: 3620
use std::cmp::max;
use std::collections::HashMap;
use std::error::Error;
use std::io;

pub fn main() {
    if let Err(_e) = run() {
        panic!("failed.");
    }
}

fn run() -> Result<(), Box<Error>> {
    let mut input = String::new();
    io::stdin().read_line(&mut input);
    let n = input.trim().parse::<i32>().unwrap();
    input.clear();
    let mut matrix = vec![];
    for _i in 0..n {
        io::stdin().read_line(&mut input);
        let row: Vec<i64> = input
            .trim()
            .split_whitespace()
            .map(|s| s.parse::<i64>().unwrap())
            .collect();
        matrix.push(row);
        input.clear();
    }

    let mut cache_sum: HashMap<i64, i64> = HashMap::new();
    cache_sum.insert(0, 0);

    let variations = 2.0f64.powi(n) as i32;
    for vairation in 1..variations {
        let mut new_one = vairation & -vairation;
        let previous_state = vairation - new_one;
        let mut new_one_index = 0;
        while new_one & 1 != 1 {
            new_one >>= 1;
            new_one_index += 1;
        }

        let mut sum = cache_sum.get(&(previous_state as i64)).unwrap().clone();
        for i in 0..n {
            if (previous_state >> i) & 1 == 1 {
                sum += matrix[i as usize][new_one_index as usize];
            }
        }
        cache_sum.insert(vairation as i64, sum);
    }

    //dp
    let mut dp = vec![0i64; variations as usize];
    let mut used = 0;
    while used < (1 << n) {
        let unused = used ^ ((1 << n) - 1);
        let mut use_ = unused;
        while use_ > 0 {
            dp[use_ | used] = max(
                dp[use_ | used],
                dp[used] + cache_sum.get(&(use_ as i64)).unwrap().clone(),
            );
            use_ = (use_ - 1) & unused;
        }
        used += 1;
    }
    println!("{}", dp[((1 << n) as usize - 1)]);
    Ok(())
}


Measured memory_bytes: 12540
#include <bits/stdc++.h>
using namespace std;
int main(){
	int a,b,c;
	cin>>a>>b>>c;
	if(a+b==c){
		cout<<"Yes"<<endl;
	}
	else if(a+c==b){
		cout<<"Yes"<<endl;	
	}
	else if(b+c==a){
		cout<<"Yes"<<endl;
	}
	else{
		cout<<"No"<<endl;
	}
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int A,B,M,mina=INT_MAX,minb=INT_MAX,a[233333],b[233333],x,y,c,ans;
int main(){
	scanf("%d%d%d",&A,&B,&M);
	for(int i=1;i<=A;i++)scanf("%d",&a[i]),mina=min(mina,a[i]);
	for(int i=1;i<=B;i++)scanf("%d",&b[i]),minb=min(minb,b[i]);
	ans=mina+minb;
	while(M--){
		scanf("%d%d%d",&x,&y,&c);
		ans=min(ans,a[x]+b[y]-c);
	}
	printf("%d\n",ans);
}

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

int main()
{
	int h, w;
	char flag[50][50];

	cin >> h >> w;
	for (int y = 0; y < h; y++)
	{
		for (int x = 0; x < w; x++)
		{
			cin >> flag[x][y];
		}
	}

	int ans = 999999;
	for (int a = 0; a < h - 2; a++)
	{
		for (int b = a + 1; b < h - 1; b++)
		{
			int cnt = 0;
			for (int y = 0; y < h; y++)
			{
				for (int x = 0; x < w; x++)
				{
					if (y <= a && flag[x][y] != 'W') cnt++;
					if (a < y && y <= b && flag[x][y] != 'B') cnt++;
					if (b < y && flag[x][y] != 'R') cnt++;
				}
			}
			ans = min(ans, cnt);
		}
	}
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 3088
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n=sc.nextInt();
		int t = sc.nextInt();

		int mini=-1;
		int a, b;

		for(int i=0;i<n;i++) {
			a=sc.nextInt();
			b=sc.nextInt();

			if(b<=t&&(a<=mini||mini==-1)){
				mini=a;
			}
		}

		if(mini!=-1) {
			System.out.print(mini);
		}
		else {
			System.out.print("TLE");
		}



	}

}


Measured memory_bytes: 21844
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cassert>
#include <complex>
#include <cmath>
#include <algorithm>
#include <vector>
#include <string>
#include <cstdlib>
#include <cstring>
#include <iomanip>
#include <numeric>
#include <sstream>
#include <ctime>
#include <cctype>
#include <set>
#include <map>
#include <queue>
#include <bitset>
#include <deque>
#include <stack>
#include <memory.h>
using namespace std;
typedef long long ll;
#define mp make_pair
int a;
int b;
int main()
{
	cin>>a>>b;
	if(a>8||b>8){
		cout<<":(";
		return 0;
	}
	cout<<"Yay!";
    return 0;
}


Measured memory_bytes: 256
/* ---------- STL Libraries ---------- */

// IO library
#include <cstdio>
#include <fstream>
#include <iomanip>
#include <ios>
#include <iostream>

// algorithm library
#include <algorithm>
#include <cmath>
#include <numeric>
#include <random>

// container library
#include <array>
#include <bitset>
#include <deque>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <tuple>
#include <vector>

/* ---------- Namespace ---------- */

using namespace std;

/* ---------- Type Abbreviation ---------- */

using ll = long long;

template <typename T>
using PQ = priority_queue<T>;
template <typename T>
using GPQ = priority_queue<T, vector<T>, greater<T>>;

#define mp make_pair
#define mt make_tuple

/* ---------- conversion ---------- */

#define INT(c) static_cast<int>(c)
#define CHAR(n) static_cast<char>(n)
#define LL(n) static_cast<ll>(n)
#define DOUBLE(n) static_cast<double>(n)

/* ---------- container ---------- */

#define gsort(b, e) sort(b, e, greater<decltype(*b)>())

/* ----------- debug ---------- */

template <class T>
ostream& operator<<(ostream& os, vector<T> v) {
    os << "[";
    for (auto vv : v)
        os << vv << ",";
    return os << "]";
}

template <class T>
ostream& operator<<(ostream& os, set<T> v) {
    os << "[";
    for (auto vv : v)
        os << vv << ",";
    return os << "]";
}

template <class L, class R>
ostream& operator<<(ostream& os, pair<L, R> p) {
    return os << "(" << p.first << "," << p.second << ")";
}

/* ---------- Constants ---------- */

// const ll MOD = 1e9 + 7;
// const int INF = 1 << 25;
// const ll INF = 1LL << 50;
// const double PI = acos(-1);
// const double EPS = 1e-10;
// mt19937 mert(LL(time(0)));

/* ---------- Short Functions ---------- */

template <typename T>
inline T sq(T a) { return a * a; }

template <typename T>
T gcd(T a, T b) {
    if (a > b) return gcd(b, a);
    return a == 0 ? b : gcd(b % a, a);
}

template <typename T, typename U>
T mypow(T b, U n) {
    if (n == 0) return 1;
    if (n == 1) return b /* % MOD */;
    if (n % 2 == 0) {
        return mypow(b * b /* % MOD */, n / 2);
    } else {
        return mypow(b, n - 1) * b /* % MOD */;
    }
}

ll pcnt(ll b) {
    return __builtin_popcountll(b);
}

/* v-v-v-v-v-v-v-v-v Main Part v-v-v-v-v-v-v-v-v */

int main() {
    string S;
    cin >> S;

    vector<ll> white;
    for (ll i = 0; i < S.size(); ++i) {
        if (S[i] == 'W') white.push_back(i);
    }

    ll ans = 0;
    for (ll i = 0; i < white.size(); ++i) {
        ans += white[i] - i;
    }

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


Measured memory_bytes: 2552
#include <bits/stdc++.h>
#define rep(i,s,t) for(int i=s;i<=(t);++i)
using namespace std; 
 
const int N=20; 
 
#define Pr(f,...) printf(f,##__VA_ARGS__),fflush(stdout)
 
char s[N][N],t[N][N];
int n,m,ans,mat[N],tot,vis[N];
string g[N]; 
 /*
bool cmp(string a,string b){
	reverse(a.begin(),a.end()); 
	return a==b;
}
 
bool chk(){
	//rep(i,1,n)Pr("Mat[%d]=%d\n",i,mat[i]); 
	++tot;
	int p=1,q=n;
	rep(i,1,n){
		if(mat[i]&&mat[i]<i){
			rep(j,1,m)t[p][j]=s[i][j];++p;
			rep(j,1,m)t[q][j]=s[mat[i]][j];--q;
		}
	}
	rep(i,1,n)if(mat[i]==i){
		rep(j,1,m)t[p][j]=s[i][j];
	}
	//rep(i,1,n)rep(j,1,m){putchar(t[i][j]);if(j==m)puts(""); }
	rep(j,1,m){
		g[j]="";
		rep(i,1,n)g[j]+=t[i][j];
		//Pr("g[%d]= ",j);cout<<g[j]<<endl;
	}
	rep(i,1,m)rep(j,i+1,m)if(!vis[i]&&!vis[j]&&cmp(g[i],g[j])){
		vis[i]=vis[j]=1;
	}
	int qwq=0;
	rep(i,1,m){
		if(!vis[i]){
			if(cmp(g[i],g[i]))++qwq;
			else return false;
		}
	}
	return qwq<=m%2;
}
 */
 bool chk()  
{  

	memset(vis,0,sizeof(vis));
	rep(i,1,m)rep(j,1,m){
            if(vis[i]||vis[j]||i==j) continue;  
            int suc=1;  
            rep(k,1,n){
                if(s[mat[k]][i]!=s[k][j]){  
                    suc=0;  
                    break;  
                }  
            }  
            if(suc){  
                vis[i]=vis[j]=1;  
            }  
        }  
    int cnt=0,to=0;  
    rep(i,1,m){
        if(!vis[i]){  
            cnt++;to=i;  
        }  
    }  
    if(cnt>=2||(m%2==0&&cnt)){  
        return false;  
    }  
    if(!cnt) return true;  
    rep(i,1,n){
        if(s[mat[i]][to]!=s[i][to]){  
            return false;  
        }  
    }  
    return true;  
}  
void dfs(int x,int c){
	if(c==n/2){
		ans|=chk(); 
		return ;
	}
	++x; 
	if(mat[x]){
		dfs(x,c);
		return;
	}
	rep(i,1,n)if(!mat[i]&&i!=x){
		mat[i]=x;
		mat[x]=i;
		dfs(x,c+1);
		mat[i]=0;
		mat[x]=0;
	}
}
 
int main(){
	
	//freopen("dat.in","r",stdin);freopen("my.out","w",stdout); 
	scanf("%d%d",&n,&m); 
	rep(i,1,n)scanf("%s",s[i]+1); 
	if(n%2==1){
		rep(i,1,n){
			mat[i]=i;
			dfs(0,0);
			mat[i]=0;
		}
	}else{
		dfs(0,0);
	}
	//cout<<tot<<endl;
	printf("%s\n",ans?"YES":"NO");
	return 0; 
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;
 
int main() {
  int n, k, c;
  cin >> n >> k >> c;
  string s;
  cin >> s;
  auto getPositions = [&]() {
    vector<int> res;
    for (int i = 0; i < n && res.size() < k;) {
      if (s[i] == 'o') {
        res.push_back(i);
        i += c+1;
      } else {
        ++i;
      }
    }
    return res;
  };
  vector<int> l, r;
  l = getPositions();
  reverse(s.begin(),s.end());
  r = getPositions();
  rep(i,k) r[i] = n-1-r[i];
  reverse(s.begin(),s.end());
 
  vector<int> lastL(n+1, -1);
  rep(i,k) lastL[l[i]+1] = i;
  rep(i,n) {
    if (lastL[i+1] == -1) lastL[i+1] = lastL[i];
  }
  vector<int> lastR(n+1, -1);
  rep(i,k) lastR[r[i]] = i;
  for (int i = n-1; i >= 0; --i) {
    if (lastR[i] == -1) lastR[i] = lastR[i+1];
  }
 
  rep(i,n) {
    if (s[i] == 'x') continue;
    int li = lastL[i];
    int ri = lastR[i+1];
    int cnt = 0;
    if (li != -1) cnt += li+1;
    if (ri != -1) cnt += ri+1;
    if (li != -1 && ri != -1 && r[ri]-l[li] <= c) {
      --cnt;
    }
    if (cnt >= k) continue;
    printf("%d\n", i+1);
  }
  return 0;
}

Measured memory_bytes: 4984
#include <cstdio>
#include <algorithm>
#define ll long long
#define rep(i,j,k) for (i=j;i<=k;i++)
using namespace std;
const int N=2e3+5,mod=1e9+7;
int n,m,l,k,i,j,p,q,ans,g[2][N],s[N];
int main()
{
	scanf("%d%d%d",&n,&m,&k);
	l=(n+m-1)/(k-1);
	g[0][0]=1; p=0; q=1;
	rep(i,1,l)
	{
		swap(p,q);
		s[0]=g[q][0];
		rep(j,1,n) s[j]=(g[q][j]+s[j-1])%mod;
		rep(j,0,min(n,k-1)) g[p][j]=s[j];
		rep(j,k,n) g[p][j]=(s[j]-s[j-k]+mod)%mod;
		rep(j,1,n)
			if ( j%(k-1)==n%(k-1) && (k-1-j%(k-1))%(k-1)==(m-1)%(k-1) && (k-1)*i-j<=m-1)
			  ans=((ll)ans+mod+g[p][j]+s[j-1]-s[j])%mod;
	}
	printf("%d\n",ans);
	return 0;

}

Measured memory_bytes: 1756
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <algorithm>
using namespace std;
int l, r;
int a[10];

int main() {
	while(~scanf("%d %d", &l, &r)) {
		int cnt = 0;
		for(int i = l; i <= r; i++) {
			int tmp = i;
			int t = 0;
			bool flag = 1;
			while(tmp) {
				t++;
				a[t] = tmp % 10;
				tmp /= 10;
			}
			for(int j = 1, k = 5; j <= 2, k >= 4; j++, k--) {
				if(a[j] != a[k]) flag = 0;
			}
			if(flag) cnt++;
		}
		printf("%d\n", cnt);
	}
	return 0;
}

Measured memory_bytes: 128
import java.util.*;

public class Main {

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

        final long N = sc.nextLong();
        final long P = sc.nextLong();

        List<Map<Long, Integer>> pfs = primeFactorize(P);

        long ans = 1;

        for (Map<Long, Integer> pf : pfs) {
            for (Map.Entry<Long, Integer> e : pf.entrySet()) {
                for (int i = 0; i < e.getValue() / N; i++) {
                    ans *= e.getKey();
                }
            }
        }

        System.out.println(ans);
    }

    private static List<Map<Long, Integer>> primeFactorize(long n) {
        List<Map<Long, Integer>> res = new ArrayList<>();
        for (long a = 2; a*a <= n; a++) {
            if (n % a != 0) {
                continue;
            }
            int ex = 0;
            while (n % a == 0) {
                ex++;
                n /= a;
            }
            res.add(Collections.singletonMap(a, ex));
        }
        if (n != 1) {
            res.add(Collections.singletonMap(n, 1));
        }
        return res;
    }
}


Measured memory_bytes: 23764
// nomura2020_a
#include <bits/stdc++.h>
#ifdef LOCAL
#include "../cxx-prettyprint/prettyprint.hpp"
#endif
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;

#define REP(i, n) for (int (i) = 0 ; (i) < (int)(n) ; ++(i))
#define REPN(i, m, n) for (int (i) = m ; (i) < (int)(n) ; ++(i))
#define REP_REV(i, n) for (int (i) = (int)(n) - 1 ; (i) >= 0 ; --(i))
#define REPN_REV(i, m, n) for (int (i) = (int)(n) - 1 ; (i) >= m ; --(i))
#define ALL(x) x.begin(), x.end()

#define INF (ll)(1e9)
#define MOD (1000000007)

#define print2D(h, w, arr) REP(i, h) { REP(j, w) cout << arr[i][j] << " "; cout << endl; }
#define print_line(vec, n) {for(int i=0;i<(n-1);i++) cout << (vec)[i] << " "; cout << (vec)[(n)-1] << endl;}
template<class T> void print(const T& x){cout << x << endl;}
template<class T, class... A> void print(const T& first, const A&... rest) { cout << first << " "; print(rest...); }
struct PreMain {PreMain(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(20);}} premain;

int main() {
#ifdef LOCAL
    ifstream in("../arg.txt"); cin.rdbuf(in.rdbuf());
#endif

    int H1, M1, H2, M2, K;
    cin >> H1 >> M1 >> H2 >> M2 >> K;

    int t1 = 60*H1 + M1;
    int t2 = 60*H2 + M2;

    int ans = max(0, t2 - t1 - K);
    print(ans);



    return 0;
}


Measured memory_bytes: 3644
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>
#include <queue>

using namespace std;

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);

int N, bd[1<<16];
int H[16], W[16];
VS orig(4);


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

  cin >> N;
  REP(i,N) cin >> H[i] >> W[i];
  REP(i,4) cin >> orig[i];

  vector<PII> trans[16];
  REP(i,N){
	for(int y=-H[i]+1;y<4;++y){
	  for(int x=-W[i]+1;x<4;++x){
		for(int k=0;k<3;++k){
		  int tmp1 = 0, tmp2 = (1<<16)-1;
		  char c = "RGB"[k];
		  for(int dy=0;dy<H[i];++dy){
			int ty = y + dy;
			if(ty < 0 || 4 <= ty) continue;
			for(int dx=0;dx<W[i];++dx){
			  int tx = x + dx;
			  if(tx < 0 || 4 <= tx) continue;
			  if(c == orig[ty][tx])
				tmp1 |= (1 << (ty*4+tx));
			  else
				tmp2 &= ~(1 << (ty*4+tx));
			}
		  }
		  trans[i].PB(MP(tmp1,tmp2));
		}
	  }
	}
  }

  
  priority_queue<PII, vector<PII>, greater<PII>> pq;
  fill(bd, bd+(1<<16), 1000);
  bd[0] = 0;
  pq.push(MP(0,0));
  while(!pq.empty()){
	PII pii = pq.top(); pq.pop();
	int ct = pii.first;
	int state = pii.second;
	if(ct > bd[state]) continue;

	REP(i,16){
	  for(PII& pii: trans[i]){
		int tmp = state;
		tmp |= pii.first;
		tmp &= pii.second;
		if(bd[tmp] > ct+1){
		  bd[tmp] = ct + 1;
		  pq.push(MP(bd[tmp], tmp));
		}
	  }
	}
  }
  

  cout << bd[(1<<16)-1] << endl;
  
  return 0;
}

Measured memory_bytes: 1956
#include <stdio.h>
 
int main(void)
{
    int i, j;
    int N;
    long a[100000];
    int sum, tmp;
 
    scanf("%d", &N);
    for (i = 0; i < N; i++) {
        scanf("%ld", &a[i]);
    }
 
    sum = 0;
    tmp = 0;
    for (i = 0; i < N; i++) {
        if (a[i] % 4 == 0) sum++;
        else if (a[i] % 2 == 0) {
            tmp++;
        }
    }
 
    sum += tmp / 2;
 
    if (sum < N / 2) {
        printf("No\n");
    }
    else {
        printf("Yes\n");
    }
}

Measured memory_bytes: 896
#include <bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
using namespace std;
using ll = long long;
using vi = vector<int>;
using vii = vector<vi>;

int main() {
    int A, B;
    cin >> A >> B;

    int ans = 0;
    int now = 1;
    while (now < B) {
        now = now - 1 + A;
        ans++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int N = in.nextInt();
		String S = in.next();
		int index = 0;
		int count = 0;
		while (index < N && index != -1) {
			index = S.indexOf("ABC", index);
			if (index != -1) {
				count++;
				index++;
			}
		}
		System.out.println(count);
		in.close();
	}
}

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

using namespace std;

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

    int n;
    cin >> n;
    char s[n];
    cin >> s;
   
    int right_e = 0;
    for (int i = 1; i < n; i++) right_e += (s[i] == 'E');
    int min_count = right_e;
    
    for (int i = 1; i < n; i++) {
        if (!min_count) break;
        right_e -= s[i] == 'E';
        right_e += s[i - 1] == 'W';
        min_count = min(min_count, right_e);
    }
 
    cout << min_count << '\n';

    return 0;
}


Measured memory_bytes: 512