akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
//#include <set>
//#include <map>
//#include <iomanip>
//#include <algorithm>
//#include <numeric>
//#include <queue>
//#include <stack>
//#include <math.h>
//#include <vector>
//#include <string>
//#include <list>
//#include <deque>
//#include <unordered_map>
//typedef long long LL;
//typedef long double LD;
using namespace std;
 
//#define MOD 1000000007
//#define MAX 100100
//#define NIL -1

int main() {
    int k;
    int ans=0;
    int tmp;
    cin >> k;
    tmp = k/2;
    if(k%2==0){
        ans = tmp*tmp;
    }else{
        ans = tmp*(tmp+1);
    }
    cout << ans << endl;

    return 0;
}

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

int main(){
    string a,b;
    cin>>a>>b;
    for(int i=0,j=a.size()-1;i<j;i++,j--){
        char temp=a[i];
        a[i]=a[j];
        a[j]=temp;
    }
    if(a==b) cout<<"YES"<<endl;
    else cout<<"NO"<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <cstring>
#include <vector>
#include <iostream>
#include <queue>
#include <unordered_map>
#include <cmath>
#include <queue>
#include <string>
#include <random>
#include <stack>
#include <set>
#include <unordered_set>

#define bug(x) cout<<"zdongdebug: "<<x<<endl;
#define bug2(x, y) cout<<"zdongdebug: "<<x<<" "<<y<<endl;
#define bug3(x, y, z) cout<<"zdongdebug: "<<x<<" "<<y<<" "<<z<<endl;
using namespace std;
typedef long long ll;
const int maxn = 100005;
const int mod = 1000000007;


int main() {
#ifdef suiyuan2009
  freopen("/Users/suiyuan2009/CLionProjects/icpc/input.txt", "r", stdin);
  //freopen("/Users/suiyuan2009/CLionProjects/icpc/output.txt", "w", stdout);
#endif
  string s;
  cin>>s;
  int l = 0, r = s.size() - 1;
  int ret = 0;
  while(l<r){
    if(s[l]!=s[r])ret++;
    l++;
    r--;
  }
  cout<<ret<<endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cctype>
#include <functional>
#include <map>
using namespace std;
using ll = long long;

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

int main(){
    map<int,int> counter;
    int n;
    int tmp;
    cin >> n;
    
    rep(i,n){
        cin >> tmp;
        counter[tmp]++;
    }
    int cnt = 0;
    for(auto elem : counter){
        //cout << elem.first << "," << elem.second << endl;
        if(elem.first > elem.second){
            cnt += elem.second;
        }else{
            cnt += (-elem.first + elem.second);
        }
    }
    cout << cnt << endl;

    return 0;
}
/*
    
*/

Measured memory_bytes: 4736
#include<bits/stdc++.h>
using namespace std;
const int maxn=1e5+5;
int n;
long long sum=0;
int a[maxn],b[maxn];
int main(){
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
		scanf("%d",&a[i]);
	for(int i=1;i<=n;i++)
		scanf("%d",&b[i]);
	long long sum=0;
	for(int i=1;i<=n;i++){
		if(a[i]<b[i])
			sum+=(b[i]-a[i])/2;
	}
	for(int i=1;i<=n;i++){
		if(a[i]>b[i])
			sum-=(a[i]-b[i]);
	}
	puts(sum>=0? "Yes" :"No");
	return 0;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
int64_t gcd(int64_t x,int64_t y){
if(x==0 || y==0)
  return max(x,y);
  else{
  if(x<y)
    return gcd(x,y%x);
    else if(y<x)
      return gcd(y,x%y);
    else
      return x;
  }

}
int64_t lcm(int64_t x,int64_t y){
return (x*y)/gcd(x,y);
}
int main(){
int64_t N,M;
  cin>>N>>M;
  set<int>S;
  vector<int64_t>A(N);
  for(int64_t i=0;i<N;i++){
  int64_t a;
    cin>>a;
    a/=2;
     A.at(i)=a;
    int64_t s=0;
    for(int i=0; ;i++){
     if(a%2!=0){
        s=i; break;
     }else
         a/=2;
    }
    S.insert(s);
  }int m=S.size();
  if(m!=1)
    cout<<0<<endl;
  else{
    int64_t l=A.at(0);
    for(int i=1;i<N;i++){
      l=lcm(l,A.at(i));
      if(M<l){l=M+1; break;}
    }
    int64_t ans=((M/l)+1)/2;
    cout<<ans<<endl;
  
  }
    return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
        using namespace std;
   #define int long long
   #define PP pair<int,pair<int,int>>
const int MAX = 1000001;
const int MOD =1000000007;
const int INV2 = (MOD+1)/2;



     signed main(){
   int x;
  int n;
  cin>>n;
  map<int,pair<int,int>> mp;
  int a;
  for(int i=1;i<=n;i++){
    cin>>a;
    if(mp.find(-a-i)==mp.end()){
      mp[-a-i]=make_pair(0,0);
    }
    mp[-a-i].first++;
    if(mp.find(a-i)==mp.end()){
      mp[a-i]=make_pair(0,0);
    }
    mp[a-i].second++;
  }
  int ans=0;
  for(auto&& i :mp)ans+=(i.second).first*(i.second).second;
  cout<<ans<<endl;

        





}


        


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

int main() {
	// your code goes here
	long long int n = 0, m = 0, a = 0, b = 0, c = 0;
	string s;
	cin >> n >> a;
	int ans = n >= a ? 10 : 0;
	cout << ans << endl;
	

	return 0;
}

Measured memory_bytes: 256
from itertools import groupby
from math import ceil
*A, T = open(0).read().split()
n, k, r, s, p = map(int, A)
T = T.strip()

d = {'r':p, 's':r, 'p':s}
X = [T[i::k] for i in range(k)]
s = 0
for x in X:
    for key, rep in groupby(x):
        s += d[key] * ceil(len(list(rep)) / 2)
print(s)

Measured memory_bytes: 8820
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 1e5 + 7;
int arr[N];

int main(){
	int n, q, flag;
	scanf("%d", &n);
	for(int i = 0; i < n; i ++ ){
		scanf("%d",arr + i);
	}
	flag = arr[0];
	for(int i = 1; i < n; i ++ ){
		flag = __gcd(arr[i],flag);
	}
	cout << flag << endl;
	return 0;
}

Measured memory_bytes: 640
#include<stdio.h>
#include<string.h>
int main(void)
{
	char str[81];
	int i;

	while (fgets(str,81,stdin) != NULL) {
		while (1) {
			for (i = 0; i < strlen(str); i++) {
				if (str[i] >= 'a' && str[i] <= 'z')
					str[i] = (str[i] - 'a' + 1) % 26 + 'a';
			}
			if (strstr(str, "this") != NULL) break;
			else if (strstr(str, "the") != NULL)break;
			else if (strstr(str, "that") != NULL)break;
		}
		printf("%s", str);
	}
	return 0;
}

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

UL N,K;
const ULL M=1000000007;
ULL F[1001];
ULL I[1001];
ULL iF[1001];
ULL Pow[1001][1001];
ULL dp[1001];

ULL C(UL n,UL r){return F[n]*iF[r]%M*iF[n-r]%M;}

int main() {
 cin>>N>>K;
 F[0]=I[1]=iF[0]=1;
 for(UL i=1;i<=1000;i++) F[i]=F[i-1]*i%M;
 for(UL i=2;i<=1000;i++) I[i]=M-M/i*I[M%i]%M;
 for(UL i=1;i<=1000;i++) iF[i]=iF[i-1]*I[i]%M;
 for(UL k=0;k<=K;k++) {
  Pow[k][0]=1;
  for(UL n=1;n<=N;n++) Pow[k][n]=Pow[k][n-1]*k%M;
 }
 dp[0]=0;
 for(UL k=1;k<=K;k++){
  dp[k]=Pow[k][N];
  rep(j,k) dp[k]+=(M-C(k,j)*dp[j]%M);
  dp[k]%=M;
 }
 for(UL k=1;k<=K;k++) dp[k]=(dp[k-1]+dp[k]*iF[k])%M;
 cout<<dp[K]<<endl;
 return 0;
}



Measured memory_bytes: 10932
#include <vector>
#include <iostream>
using namespace std;
const int bits = 40;
int main() {
	int N, K;
	cin >> N >> K;
	vector<int> A(N);
	vector<long long> S(N + 1);
	for (int i = 0; i < N; ++i) {
		cin >> A[i];
		S[i + 1] = S[i] + A[i];
	}
	vector<long long> v;
	for (int i = 0; i < N; ++i) {
		for (int j = i + 1; j <= N; ++j) {
			v.push_back(S[j] - S[i]);
		}
	}
	long long ans = 0;
	for (int i = bits - 1; i >= 0; --i) {
		long long w = ans + ((long long)(1) << i);
		int cnt = 0;
		for (long long j : v) {
			if ((j & w) == w) {
				++cnt;
			}
		}
		if (cnt >= K) ans += (long long)(1) << i;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 6516
import java.util.Scanner;
public class Main {
	public static void main(String[] args){
		Scanner scan = new Scanner(System.in);
		String S = scan.nextLine();
      
      	int c = 0;
      	for(int i = 0; i < S.length(); i++){
        if(S.charAt(i) == 'o'){
        	c ++;
        }
      }
      
      System.out.println(700 + 100 * c);
    }
}

Measured memory_bytes: 35588
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <vector>
#include <utility>
#include <cstdio>
#include <iomanip>
#include <cmath>
#include <string>
#include <stack>
#include <queue>
#include <map>
#include <stdlib.h>
#include <set>
typedef long long ll;
using namespace std;

int main() {
	string s1,s2,s3;
	cin>>s1>>s2>>s3;
	cout<<s1.substr(0,1)+s2.substr(1,1)+s3.substr(2,1)<<endl;;
	return 0;
}


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

#define ll long long

template<typename T> void drop(const T &x){cout<<x<<endl;exit(0);}

void solve() {
  int n,x,t; cin >> n >> x >> t;
  int a=n/x;
  n%=x;
  if(n) a++;
  cout << a*t << endl;

  return;
}

signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int T=1;
  //cin >> T;
  while(T--) solve();

  return 0;
}


Measured memory_bytes: 3636
import java.util.Scanner;


	public class Main {

		public static void main(String[] args) {

			Scanner sc = new Scanner(System.in);

			int n = sc.nextInt();
			int[] a = new int[n];
			int o = 0;
			int f = 0;
			
			for(int i=0;i<n;i++) {
				a[i] = sc.nextInt();
			}
			
			for(int i=0;i<n;i++) {
				if(a[i]%2!=0) {
					o++;
				}
				if(a[i]%4==0) {
					f++;
				}
			}
			
			if(o==0) {
				System.out.println("Yes");
				return;
			}
			
			if(o==f+1&&o+f==n&&f!=0) {
				System.out.println("Yes");
			}else if(o==f){
				System.out.println("Yes");
			}else {
				System.out.println("No");
			}
			
		}

	}


Measured memory_bytes: 50088
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        FastScanner in = new FastScanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        ProblemA_SumOfTwoIntegers solver = new ProblemA_SumOfTwoIntegers();
        solver.solve(1, in, out);
        out.close();
    }

    static class ProblemA_SumOfTwoIntegers {
        public void solve(int testNumber, FastScanner in, PrintWriter out) {
            int n = in.nextInt();
            int ans = 0;
            for (int i = 1; i <= n && i < n - i; i++) {
                ++ans;
            }
            out.println(ans);
        }

    }

    static class FastScanner {
        private BufferedReader in;
        private StringTokenizer st;

        public FastScanner(InputStream stream) {
            in = new BufferedReader(new InputStreamReader(stream));
        }

        public String next() {
            while (st == null || !st.hasMoreTokens()) {
                try {
                    String rl = in.readLine();
                    if (rl == null) {
                        return null;
                    }
                    st = new StringTokenizer(rl);
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return st.nextToken();
        }

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

    }
}



Measured memory_bytes: 21460
#include <bits/stdc++.h>
#include<string.h>
using namespace std;
#define FAST ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define endl "\n"
#define Max(x,y,z) max(x,max(y,z))
#define Min(x,y,z) min(x,min(y,z))
#define fr(i,s,e) for(i=s;i<e;i++)
#define rf(i,s,e) for(i=s-1;i>=e;i--)
#define pb push_back
#define eb emblace_back
#define mp make_pair
#define ff first
#define ss second
//#define int   long long
#define ll   long long
#define trace1(x)                cerr<<#x<<": "<<x<<endl
#define trace2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define trace4(a, b, c, d)       cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
#define trace5(a, b, c, d, e)    cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
#define trace6(a, b, c, d, e, f) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl
#define vl vector<long long>
#define inf (1LL<<61)
#define vi vector<int>
#define vii vector< vector<int> >
#define vll vector< vector<long long> >
#define vpi vector< pair<int,int> >
#define vpl vector< pair<ll,ll> >
#define viii vector< vector<vector<int> > >
typedef pair<pair<int, int>,int> P;
#define cd complex<double>
#define PI 4*atan(1)
#define mod %1000000007
#define pi 3.14159265358979323846//20 decimals
#define ld long double

bool isPowerOfTwo(ll n) 
{ 
   if(n==0) 
   return false; 
   return (ceil(log2(n)) == floor(log2(n))); 
}

int main()
{
	FAST;
	ld n,k;
	ll i;
	ld ans = 0; 
	cin >> n >> k;
	fr(i,1,n+1)
	{
		if(i >= k)
			ans += (ld)1/n;
		else 
		{
			ll t1 = log2(k/i);
			t1++;
			if(((ll)k % i == 0)&&(isPowerOfTwo(k/i)))
				t1--;
			ld t2 = (ld)1/n;
			t2 = t2 / (pow(2,t1));
			ans += t2;
//			trace2(i,t2);	
		}
	}
	std::cout << std::fixed << std::setprecision(12) << ans;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
#define MAX_N 1000001
#define MAX_M 100010
const long long mod=1e9+7;
#define vec vector<int>
#define vecll vector<ll>
#define vecllvec vector<vector<ll>>
#define vecb vector<bool>
#define vecBvec vector<vector<bool>>
#define vecst vector<string>
#define veche vector<char>
#define vecd vector<double>
#define vecvec vector<vector<int>>
#define vecDvec vector<vector<double>>
#define vecHvec vector<vector<char>>
#define all(x) (x).begin(),(x).end()
#define ent cout<<endl
#define printvec(vec) for(int aqw=0;aqw<vec.size();aqw++){cout<<vec[aqw]<<" ";}ent;
#define rep(i,n) for(int i=0;i<(int)n;++i)
#define REP(i,m,n) for(int i=m;i<(int)n;++i)
#define INF 1e+9
#define P pair<int, int>;
#define YES "Yes"
#define NO "No"
#define MAX_V 1000
#define PI 3.141592653589793
// cout << setprecision(15) << std::fixed;

// テレンス「もしかしてACですかーッ!?」　ジョセフ「Yse! Yse! Yse! Oh~MyGod」

int main(){
  int h,w;
  cin>>h>>w;
  vecHvec G(h+2,veche(w+2));
  for(int i=1;i<=h;i++){
    for(int j=1;j<=w;j++){
      cin>>G[i][j];
    }
  }
  vecllvec dp(1010,vecll(1010,0));
  dp[1][1]=1;
  for(int i=1;i<=h;i++){
    for(int j=1;j<=w;j++){
      if(G[i+1][j]=='.') dp[i+1][j]+=dp[i][j];
      if(G[i][j+1]=='.') dp[i][j+1]+=dp[i][j];
      dp[i+1][j]%=mod;
      dp[i][j+1]%=mod;
    }
  }
  cout<<dp[h][w]%mod<<endl;
}


Measured memory_bytes: 9344
#include <bits/stdc++.h>
#define int long long
#define double long double
#define INF 1e18
using namespace std;
int a[1010];
int s[1010];
signed main() { 
  // ruisekiwa!!!
  for (int i = 0; i < 1010; i++) {
    a[i] = i+1;
  }

  int N;
  while (cin>>N, N!=0) {
    s[0] = 0;
    for (int i = 0; i < N; i++) {
      s[i+1] = s[i] + a[i];
    }
  
    int ans = 0;
    for (int l = 0; l < N; l++) {
      for (int r = l+2; r <= N; r++) {
        if (s[r]-s[l] == N) ans++;
      }
    }
  
    cout << ans << endl;
  }
}




Measured memory_bytes: 3072
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int h = sc.nextInt();
        int a = sc.nextInt();
        int b = 0;
        if(h%a !=0) b = 1;
        System.out.println(h/a+b);
    }
}

Measured memory_bytes: 35784
// HTTF.cpp : このファイルには 'main' 関数が含まれています。プログラム実行の開始と終了がそこで行われます。
//

#include "bits/stdc++.h"
#define YES "YES"
#define NO "NO"
#define YESNO OUT(three(solve(),YES,NO))
#define ECHO OUT(solve())
#define three(A,B,C) ((A)?(B):(C))
#define FOR(i,a,b)  for(LL i=(a);i< (LL)(b);i++)
#define EFOR(i,a,b) for(LL i=(a);i<=(LL)(b);i++)
#define RFOR(i,a,b) for(LL i=(a);i>=(LL)(b);i--)
#define REP(i,b) FOR(i,zero,b)
#define EREP(i,b) EFOR(i,zero,b)
#define RREP(i,b) RFOR(i,b,zero)
#define ALL(c) c.begin(),c.end()
#define UNIQUE(c) sort(ALL(c));c.erase(unique(ALL(c)),c.end())
#define MAX(c) (*max_element(ALL(c)))
#define MIN(c) (*min_element(ALL(c)))
#define MP make_pair
#define FI first
#define SE second
#define SI(x) (LL(x.size()))
#define PB push_back
#define DEBUG(a) OUT(a)
#define DEBUG2(a,b) OUT2(a,b)
#define cat cout << __LINE__ << endl
#define OUT(a) cout << (a) << endl
#define OUT2(a,b) cout << (a) <<" "<<(b) << endl
#define zero 0LL
#define int LL
#define pb emplace_back
#define eb pb

using namespace std;
template<typename T> inline void maximize(T &a, T b) { a = max(a, b); }
template<typename T> inline void minimize(T &a, T b) { a = min(a, b); }
template<typename T> inline bool middle(T a, T b, T c) { return b <= a && a <= c; }
template<class T> inline bool MX(T &l, const T &r) { return l < r ? l = r, 1 : 0; }
template<class T> inline bool MN(T &l, const T &r) { return l > r ? l = r, 1 : 0; }
typedef long long LL;
typedef double ld;
typedef int ut;
typedef vector<ut> VI;
typedef vector<VI> VII;
typedef pair<ut, ut> pr;
typedef pair<ut, pr> ppr;
typedef vector<pr> Vpr;
typedef vector<ppr> Vppr;
typedef priority_queue<pr, Vpr, greater<pr> > PQ;
inline void outputVI(VI x) { REP(i, SI(x)) { cout << three(i, " ", "") << x[i]; }OUT(""); }
const int SIZE1 = 5e5 + 1000;
const int SIZE2 = 3010;
const int SIZE3 = 330;
const int SIZE = SIZE1;
const int MAPSIZE = 40;
const LL p = 7 + 1e9;
const LL INF = 1LL << 60;
const long double EPS = 1e-7;
typedef pair<ld, ut> pld;

#define endl "\n" //インタラクティブでは消す
ut N, M, K, L, Q, D, H, W;
// ut A,B,C,D,E,F,G,H,I,J,O,P,Q,R,T,U;
VI edges[SIZE];
LL vals[SIZE], maps2[SIZE2][SIZE2], answer = zero;
LL maps[SIZE2][SIZE2];
LL DP[SIZE2][SIZE2];
bool finished[SIZE2][SIZE2];
LL A[SIZE];
string s, t;
LL solve2(LL a,LL b,bool ismax) {
	if (a==b) return 0;
	if (finished[a][b]) return DP[a][b];
	finished[a][b] = true;
	if (ismax) {
		DP[a][b] = max(solve2(a + 1, b, 0) + A[a], solve2(a, b - 1, 0) + A[b - 1]);
	}
	else {
		DP[a][b] = min(solve2(a + 1, b, 1) - A[a], solve2(a, b - 1, 1) - A[b - 1]);
	}
	//cout << a << " " << b << " " << DP[a][b] << endl;
	return DP[a][b];
}
LL solve() {
	cin >> N ;
	REP(i, N) cin >> A[i];
	cout << solve2(0, N,1) << endl;
	return 0;
}




//!!!!!!!!!!!!!!!!!!!実装を詰める!!!!!!!!!!!!!!!!!!!!!!!!!
signed main() {

	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(12);
	solve();
	cin >> N;
	return 0;

}

Measured memory_bytes: 95872
#include <stdio.h>
#define NMAX 100000
int main(void)
{
  int i, j, n, q, a[NMAX];
  long long x;
  scanf("%d %d", &n, &q);
  for (i = 0; i < n; i++) scanf("%d", &a[i]);
  for (i = 0; i < q; i++) {
    int s = 0;
    long long sum = 0, ans = 0;
    scanf("%lld", &x);
    for (j = 0; j < n; j++) {
      sum += a[j];
      while (sum > x) sum -= a[s++];
      if (s == n) break;
      ans += j - s + 1;
    }
    printf("%lld\n", ans);
  }
}


Measured memory_bytes: 2116
<?php

$f_money = fgets(STDIN);
$f_money = intval($f_money);

$five_hund = floor($f_money / 500);
$fivehund_happy = $five_hund * 1000;

$five = floor(($f_money - $five_hund*500) /5);
$five_happy = $five * 5;

echo $fivehund_happy + $five_happy;

 ?>


Measured memory_bytes: 4604
N = int(input())
a = list(map(int, input().split()))
el = []
for i in a:
    if i % 2 == 0:
        el.append(i)

for i in range(len(el)):
    if el[i] % 3 == 0 or el[i] % 5 == 0:
        el[i] = True
    else:
        el[i] = False

if el.count(False):
    print("DENIED") 
else:
    print("APPROVED")


Measured memory_bytes: 3060
#include<iostream>
#include<cstring>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<set>
#include<bitset>
#include<map>

#define fo(i,a,b) for(int i=a;i<=b;i++)
#define fd(i,a,b) for(int i=a;i>=b;i--)

using namespace std;

typedef long long LL;
typedef double db;

int get(){
	char ch;
	while(ch=getchar(),(ch<'0'||ch>'9')&&ch!='-');
	if (ch=='-'){
		int s=0;
		while(ch=getchar(),ch>='0'&&ch<='9')s=s*10+ch-'0';
		return -s;
	}
	int s=ch-'0';
	while(ch=getchar(),ch>='0'&&ch<='9')s=s*10+ch-'0';
	return s;
}

const int N = 200005;
const int mo =1e+9+7;

LL js[N],inv[N];
int n;
struct ball{
	int col,w;
}a[N];
int mv[N],cnt[N];
int X,Y;

int main(){
	n=get();X=get();Y=get();
	js[0]=js[1]=inv[0]=inv[1]=1;
	fo(i,2,n)js[i]=js[i-1]*i%mo;
	fo(i,2,n)inv[i]=1ll*(mo-mo/i)*inv[mo%i]%mo;
	fo(i,2,n)inv[i]=inv[i-1]*inv[i]%mo;
	fo(i,1,n)mv[i]=2e+9;
	fo(i,1,n){
		a[i].col=get();a[i].w=get();
		cnt[a[i].col]++;
		mv[a[i].col]=min(mv[a[i].col],a[i].w);
	}
	int v1=2e+9,w,v2;
	fo(i,1,n)
	if (mv[i]<2e+9){
		if (mv[i]<v1){v2=v1;v1=mv[i],w=i;}
		else v2=min(v2,mv[i]);
	}
	fo(i,1,n)
	if (a[i].col==w){if (a[i].w!=mv[w]&&a[i].w+v2>Y&&a[i].w+v1>X)cnt[a[i].col]--;}
	else
		if (a[i].w!=mv[a[i].col]&&a[i].w+mv[a[i].col]>X&&a[i].w+v1>Y)cnt[a[i].col]--;
	int tot=0;
	fo(i,1,n)
	if (i==w||mv[i]+v1<=Y)tot+=cnt[i];
	LL ans=js[tot];
	fo(i,1,n)
	if (i==w||mv[i]+v1<=Y)ans=ans*inv[cnt[i]]%mo;
	printf("%lld\n",ans);
	return 0;
}

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

#define int long long
struct Fast {Fast(){cin.tie(0);ios::sync_with_stdio(0);}} fast;
using intpair = pair<int, int>;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define reps(i, n, m) for (int i = (int)(n); i <= (int)(m); i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()
#define ceiv(a, b) ((int)((a) + (b) - 1)/(int)(b))

signed main(){
    string s; cin >> s;
    cout << s[0] << to_string(s.length()-2) << s[s.length()-1] << endl;
}

Measured memory_bytes: 256
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();
    String ans;
    
    if(a==b) ans = "Draw";
    else if((a<b&&a!=1)||b==1) ans = "Bob";
    else ans = "Alice";
    System.out.println(ans);
    
  }
}

Measured memory_bytes: 35696
#include<iostream>
using namespace std;
int main()
{
    unsigned int k,a,b,sign=0,i;
    cin>>k>>a>>b;
    for(i=a/k;k*i<=b;i++){
        if(k*i>=a && k*i<=b){
            sign=1;
            break;
        }
    }
    if(sign==1) cout<<"OK"<<endl;
    else cout<<"NG"<<endl;
    return 0;
}


Measured memory_bytes: 3604
#pragma comment(linker, "/stack:200000000")
        #pragma GCC optimize ("Ofast")
        #pragma GCC target ("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
         
         
        #include <iostream>
        #include <iomanip>
        #include <sstream>
        #include <cstring>
        #include <vector>
        #include <deque>
        #include <queue>
        #include <set>
        #include <map>
        #include <valarray>
        #include <iterator>
        #include <functional>
        #include <limits>
        #include <algorithm>
        #include <numeric>
        #include <cmath>
        #include <cassert>
        #include <unordered_map>
        #include <unordered_set>
        #include <stack>
        using namespace std;
        #define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
         #define trace(x) cerr << #x << ": " << x << " " << endl;
     
        typedef int64_t ll;
     
        #define endl '\n'
        #define int ll
        ll mod=1e9+7;
        ll mod1=1e9+5;
        ll power(ll a,ll b)
        {
            if(b==0) return 1;
            else if(b%2==0)
                return power((((a%mod)*(a%mod))%mod),b/2)%mod;
            else return ((a%mod)*(power((((a%mod)*(a%mod))%mod),b/2)%mod))%mod;
        }
        double tak[601];
        vector<int>  v[600];
     int32_t main()
        {
            IOS
      
        memset(tak,0,sizeof(tak));
        int n,m;
        cin>>n>>m;
        cout<<setprecision(10)<<fixed;
        for(int i=0;i<m;++i)
        {
            int c,d;
            cin>>c>>d;
            c--,d--;
            v[c].push_back(d);
        }
        //this is correct because si<ti else we had to do topological sorting of graph 
        //and apply the same
        for(int i=n-2;i>=0;--i)
        {
            for(int j=0;j<v[i].size();++j)
            {
                tak[i]+=(1+tak[v[i][j]])/(v[i].size());
            }
        }
        double ans=tak[0];
        for(int i=n-2;i>=0;--i)
        {
            double ans1=0;
            if(v[i].size()==1)
                continue;
            int index=-1;
            for(int j=0;j<v[i].size();++j)
            {
                if(tak[v[i][j]]>ans1)
                    ans1=tak[v[i][j]],index=v[i][j];
            }
            double p1[n];
            memset(p1,0,sizeof(p1));
            //cout<<i<<" "<<index<<endl;
            for(int j=n-2;j>=0;--j)
            {
                int s=v[j].size();
                if(j==i)
                    s--;

                for(int k=0;k<v[j].size();++k)
                {
                    if(i==j and index==v[i][k])
                        continue;
                    p1[j]+=(1+p1[v[j][k]])/s;
                }
            }
            ans=min(ans,p1[0]);

        }
        cout<<ans;





        }

Measured memory_bytes: 2560
import sys
input = sys.stdin.readline


def main():
    h, w = map(int, input().split())
    s = [input() for _ in range(h)]
    L = [[0] * w for _ in range(h)]
    R = [[0] * w for _ in range(h)]
    U = [[0] * w for _ in range(h)]
    D = [[0] * w for _ in range(h)]
    ans = 0
    for i in range(h):
        for j in range(w):
            if j != 0:
                L[i][j] = L[i][j - 1]
            if s[i][j] == ".":
                L[i][j] += 1
            else:
                L[i][j] = 0
    for i in range(h):
        for j in range(w - 1, -1, -1):
            if j != w - 1:
                R[i][j] = R[i][j + 1]
            if s[i][j] == ".":
                R[i][j] += 1
            else:
                R[i][j] = 0
    for j in range(w):
        for i in range(h):
            if i != 0:
                U[i][j] = U[i - 1][j]
            if s[i][j] == ".":
                U[i][j] += 1
            else:
                U[i][j] = 0
    for j in range(w):
        for i in range(h - 1, -1, -1):
            if i != h - 1:
                D[i][j] = D[i + 1][j]
            if s[i][j] == ".":
                D[i][j] += 1
            else:
                D[i][j] = 0
    for i in range(h):
        for j in range(w):
            if s[i][j] == ".":
                ans = max(ans, L[i][j] + R[i][j] + U[i][j] + D[i][j] - 3)
    print(ans)


if __name__ == "__main__":
    main()

Measured memory_bytes: 177672
/* Author: Rennan Rocha
 * Time: $%Y%$-$%M%$-$%D%$ $%h%$:$%m%$:$%s%$
**/

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

#define F first
#define S second
#define PB push_back
#define MP make_pair

#define ll long long
#define vi vector<int>
#define vll vector<ll>
#define pi pair<int,int>
#define pll pair<ll, ll>
#define vpi vector<pi>
#define vpll vector<pll>
#define all(x) x.begin(), x.end()

#define INF 1e18
#define MOD 998244353
#define LSB(i) ((i) & -(i))
//#define DEBUG

using namespace std;
using namespace __gnu_pbds;

typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
//*find_by_order(); order_of_key();

unsigned seed = std::chrono::system_clock::now().time_since_epoch().count();
std::default_random_engine e(seed);
std::mt19937 rng((int) seed);


// LSB = Less Significant Bit

using namespace std;

ll dp[200010]; // 1..N indexed

ll add(ll a, ll b) {
    return ((a % MOD) + (b % MOD)) % MOD;
}

ll getSum(int index) {
    ll ans = 0;
    for(int i = index; i > 0; i -= LSB(i))
        ans = add(ans, dp[i]);
    return ans;
}

void update(int i, ll val) {
    for(int j = i; j <= 200000; j += LSB(j)) {
        dp[j] = add(dp[j], val);
    }
}

ll query(int begin, int end) {
    return getSum(end) - getSum(begin - 1);
}

int n, k;
pi seg[10];

void solvetask() {
    cin >> n >> k;
    for(int i = 0; i < k; i++) {
        cin >> seg[i].F >> seg[i].S;
    }
    sort(seg, seg + k);

    update(1, 1);
    for(int i = 2; i <= n; i++) {
        for(int j = 0; j < k; j++) {
            if(i - seg[j].F < 1) continue;
            ll mini = max(1, i - seg[j].S);
            ll maxi = max(1, i - seg[j].F);
            update(i, query(mini, maxi));
        }
    }
    cout << (query(n, n) + MOD) % MOD << "\n";
}

int main() {
    ios_base::sync_with_stdio(false);

    int t = 1;

    while(t--) solvetask();
}


Measured memory_bytes: 5180
#define _CRT_SECURE_NO_WARNINGS
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cstring>

using namespace std;
#define TEST 0

#if TEST
FILE* in = freopen("./D", "r", stdin);
FILE* out = freopen("./ans", "w", stdout);
#endif
enum{ Nothing, Barrier, Start, Goal, Failure = 100 };

int dx[4] = { 1, 0, -1, 0 }, dy[4] = { 0, 1, 0, -1 };
int result = Failure;
int state[22][22];

int dfs(int x, int y, int c){
	int nx, ny;

	if (c > 10) return Failure;
	for (int i = 0; i < 4; i++){
		nx = x + dx[i], ny = y + dy[i];
		if (state[nx][ny] == Barrier) continue;
		while (!state[nx][ny]){ //state[nx][ny] == Nothing
			nx += dx[i], ny += dy[i];
		}
		if (state[nx][ny] == Goal){
			return c + 1;
		}
		else if (state[nx][ny] == Barrier){
			state[nx][ny] = 0;
			int temp = dfs(nx - dx[i], ny - dy[i], c + 1);
			result = min(result, temp);
			state[nx][ny] = 1;
		}
	}
	return result;
}

int main(){
	while (1){
		int w, h; cin >> w >> h; //width, heignt
		if (!w && !h) break;
		result = Failure;
		int sx, sy;

		memset(state, -1, sizeof(state));
		for (int i = 1; i <= h; i++){
			for (int j = 1; j <= w; j++){
				cin >> state[i][j];
				if (state[i][j] == Start){
					sx = i; sy = j;
					state[i][j] = Nothing;
				}
			}
		}
		int cnt = dfs(sx, sy, 0);
		if (cnt <= 10) cout << cnt << endl;
		else cout << -1 << endl;
	}
#if TEST
	fclose(in);
	fclose(out);
#endif
}

Measured memory_bytes: 1160
#include <iostream>
#include <numeric>
#include <stdio.h>
#include <iomanip>
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
using namespace std;
#define rep(i, n) for (long long i = 0; i < (long long)(n); i++)
int Max(int(a), int(b), int(c)) {
	return max(max(a,b), c);
}
int Min(int(a), int(b), int(c)) {
	return min(min(a, b), c);
}





int main() {
	
	int N,K,a=0;
	cin >>N>>K;
	while (N != 0) {
		N /= K;
		a++;
	}
	
	cout << a<<endl;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>

#include <algorithm>
#include <iostream>
#include <string>
#include <vector>
using namespace std;
using ull = unsigned long long int;
using ll = long long int;
constexpr ull mod = 1000000007;

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

    ull sum = 0;
    ull state = 0;
    for (int i = n - 2; i >= 0; i--) {
        state += A[i + 1];
        state = state % mod;
        sum += state * A[i];
        sum = sum % mod;
    }

    cout << sum << endl;

    return 0;
}

Measured memory_bytes: 4796
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin>>n;
  vector<int> v(n);
  for(int i=0;i<n;i++){
    cin>>v[i];
  }
  sort(v.begin(),v.end());
  cout<<v[n-1]-v[0]<<endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <string>
#include <vector>
#include <cmath>
using namespace std;

#define REPI(i,a,b) for (int i=(a);i<(b);i++)
#define REP(i,n) REPI(i,0,n)

typedef long long ll;

int SURP = 1000000007;

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

	int ret = 0;
	ret += (N-1)/(K-1);
	if((N-1)%(K-1) !=0) ret++;

	cout << ret << endl;
	return 0;
}


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

#define debug(x) (cerr << #x << " = " << x << endl;)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define FOR(it, b, e) for (typeof(b) it = (b); it != (e); ++it)
#define MSET(c, v) memset(c, v, sizeof(c))

const int INF = 0x3F3F3F3F;
const int NEGINF = 0xC0C0C0C0;
const int NULO = -1;
const double EPS = 1e-10;

inline int cmp(double x, double y = 0)
{
  if (fabs(x - y) < EPS)
    return 0;
  return x > y ? 1 : -1;
}

const int maxn = 2e5 + 100;
int a[maxn], pref[maxn];

int main()
{
  ios::sync_with_stdio(false);
  int n;
  cin >> n;
  for(int i = 1 ; i <= n; i++)
  {
    cin >> a[i];
    pref[i] = __gcd(pref[i - 1], a[i]);
  }
  int g = 0;
  int ans = 0;
  for(int i = n ; i >= 1 ; i--)
  {
    auto c = __gcd(pref[i - 1], g);
    ans = max(ans, c);
    g = __gcd(g, a[i]);
  }
  cout << ans << endl;
  return 0;

}

Measured memory_bytes: 4356
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		//		new Main().solveA();
		new Main().solveB();
		// new Main().solveC();
		// new Main().solveD();
	}

	private void solveA() {
		Scanner scanner = null;
		String[] stringS = new String[4];

		try {
			scanner = new Scanner(System.in);
			stringS = scanner.next().split("");

			int res = 0;
			for (int i = 0; i < stringS.length; i++) {
				if (stringS[i].equals("+")) {
					res++;
				} else if (stringS[i].equals("-")) {
					res--;
				}
			}

			System.out.println(res);

		} finally {
			if (scanner != null) {
				scanner.close();
			}
		}
	}

	private void solveB() {
		Scanner scanner = null;
		int numN = 0;

		try {
			scanner = new Scanner(System.in);
			numN = scanner.nextInt();

			int wkN = 0;
			int tmp = numN;
			while (tmp != 0) {
				wkN += tmp % 10;
				tmp /= 10;
			}

			System.out.println(numN % wkN == 0 ? "Yes" : "No");

		} finally {
			if (scanner != null) {
				scanner.close();
			}
		}
	}

	private void solveC() {
		Scanner scanner = null;
		int numN = 0;
		int numK = 0;
		int numS = 0;

		try {
			scanner = new Scanner(System.in);
			numN = scanner.nextInt();

			System.out.println("");

		} finally {
			if (scanner != null) {
				scanner.close();
			}
		}
	}

	private void solveD() {
		Scanner scanner = null;
		int numN = 0;
		int numK = 0;
		int numS = 0;

		try {
			scanner = new Scanner(System.in);
			numN = scanner.nextInt();

			System.out.println("");

		} finally {
			if (scanner != null) {
				scanner.close();
			}
		}
	}
}

Measured memory_bytes: 25172
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
//---------------------------------------------------------------------------------------------------
/*---------------------------------------------------------------------------------------------------
　　　　　　　　　　　 ∧＿∧  
　　　　　 ∧＿∧ 　（´<_｀ ）　 Welcome to My Coding Space!
　　　　 （ ´_ゝ`）　/　 ⌒i     
　　　　／　　　＼　 　  |　|     
　　　 /　　 /￣￣￣￣/　　|  
　 ＿_(__ﾆつ/　    ＿/ .| .|＿＿＿＿  
　 　　　＼/＿＿＿＿/　（u　⊃  
---------------------------------------------------------------------------------------------------*/



typedef long long ll;
#define INF 1LL<<50
int N, H[5010], P[5010];
ll dp[5010][5010];
//---------------------------------------------------------------------------------------------------
void _main() {
    cin >> N;
    rep(i, 0, N) cin >> H[i] >> P[i];

    vector<int> ord;
    rep(i, 0, N) ord.push_back(i);
    sort(ord.begin(), ord.end(), [&](int a, int b) { return H[a] + P[a] < H[b] + P[b]; });

    rep(i, 0, N + 1) rep(j, 0, N + 1) dp[i][j] = INF;
    dp[0][0] = 0;
    rep(i, 0, N) rep(j, 0, N + 1) {
        dp[i + 1][j] = min(dp[i + 1][j], dp[i][j]);
        if (dp[i][j] <= H[ord[i]]) dp[i + 1][j + 1] = min(dp[i + 1][j + 1], dp[i][j] + P[ord[i]]);
    }

    int ans = 0;
    rep(j, 0, N + 1) if (dp[N][j] != INF) ans = j;
    cout << ans << endl;
}

Measured memory_bytes: 196224
'use strict'

function main(s) {

  s = s.split('\n');

  const n = Number(s[0]);
  const names = s.slice(1, -1);

  const has = [0, 0, 0, 0, 0];

  for (const name of names) {
    if (name.charAt(0) === 'M') has[0]++;
    if (name.charAt(0) === 'A') has[1]++;
    if (name.charAt(0) === 'R') has[2]++;
    if (name.charAt(0) === 'C') has[3]++;
    if (name.charAt(0) === 'H') has[4]++;
  }

  let ans = 0;

  const comb = (i, pro) => {
    if (i === 5) {
      if (pro.length === 3) {
	    ans += pro.reduce((a, b) => a * b);
      }
      return;
    }
    comb(i + 1, [...pro, has[i]]);
    comb(i + 1, pro);
    return;
  }

  comb(0, [])

  console.log(ans);

}

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


Measured memory_bytes: 28552
import java.math.BigInteger;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		int k = sc.nextInt();
		sc.close();

		long ans = 0;
		for (int a = 1; a <= k; a++) {
			for (int b = 1; b <= k; b++) {
				int gcd1 = gcd(a, b);
				for (int c = 1; c <= k; c++) {
					int gcd2 = gcd(gcd1, c);
					ans += gcd2;
				}
			}
		}
		System.out.println(ans);
	}

	static int gcd(int a, long b) {
		return BigInteger.valueOf(a).gcd(BigInteger.valueOf(b)).intValue();
	}
}


Measured memory_bytes: 57984
N = int(input())

A = list(map(int, input().split()))

A.sort()
count = 0
for i in range(N):
    a = A[i]
    for j in range(i+1, N):
        b = A[j]
        if b == a:
            continue
        for k in range(j+1, N):
            c = A[k]
            if b == c:
                continue
            if c < a + b:
                count += 1
            else:
                break

print(count)


Measured memory_bytes: 68004
#include<bits/stdc++.h>
#define crap ios_base::sync_with_stdio(0);cin.tie(0)
#define ll long long
#define pb push_back
#define ff first
#define ss second
#define endl "\n"
#define int ll

using namespace std;

const int mod = 1e9+7;
int A[25][25];
int n;
int dp[25][1<<21];

int solve(int num, int mask){
    if(num<0 && mask==(1<<n)-1)return 1;
    if(num<0) return 0;
    if(mask>=(1<<n)-1) return 0;

    if(dp[num][mask]!=-1) return dp[num][mask];
    dp[num][mask]=0;
    for(int i=0;i<n;i++){
        if(A[num][i] && !(mask & 1<<i) ){
            int ms = mask|(1<<i);
            dp[num][mask] = (dp[num][mask] %mod + solve(num-1,ms)%mod)%mod;
        }
    }
    return dp[num][mask];
}

int32_t main()
{
   
   
    crap;
    memset(dp,-1,sizeof(dp));
    cin>>n;
    for(int i=0;i<n;i++){
        for(int j=0;j<n;j++) cin>>A[i][j];
    }
    int ans = solve(n-1,0);
    cout<<ans<<endl;
  	
}

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

int main() {
//	cout<<"GfG!";
    int a,b,c,d;
    cin>>a>>b>>c>>d;
    while(a>0&&c>0)
    {
        c-=b;
        if(c<=0)
        {
            cout<<"Yes"<<endl;
            break;
        }
        a-=d;
        if(a<=0)
        {
            cout<<"No"<<endl;
            break;
        }
    }
	return 0;
}

Measured memory_bytes: 3596
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const long long MOD = 1000000007;
vector<ll> cnt[200001];
ll dp[200001];
ll dp2[200001];
int main(){
    long long N;
    scanf("%lld",&N);
    std::vector<long long> C(N);
    ll index=0;
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&C[index]);
        C[index]--;
        if(index==0||C[index]!=C[index-1])index++;
    }

    dp[0]=1;
    for(long long i = 0; i < index; i++){
        if(i==0)dp[i]=1;
        else dp[i]=dp[i-1];
        dp[i]+=dp2[C[i]];
        dp[i]%=MOD;
        if(i!=0)dp2[C[i]]+=dp[i-1];
        else dp2[C[i]]=1;
        dp2[C[i]]%=MOD;
    }/*
    for(long long i = 0; i < index; i++){
        cerr<<dp2[i]<<endl;
    }
    cerr<<endl;
    for(long long i = 0; i < index; i++){
        cerr<<dp[i]<<endl;
    }*/
    ll ans=0;
    for(size_t i = 0; i < index; i++)
    {
        ans+=dp[i]-1;
        ans%=MOD;
    }
    ans+=1;
    ans%=MOD;
    cout<<dp[index-1]<<endl;
    return 0;
}


Measured memory_bytes: 9600
import sys, math
input = sys.stdin.readline
rs = lambda: input().strip()
ri = lambda: int(input())
rl = lambda: list(map(int, input().split()))
mod = 10**9 + 7

s = rs()
t = rs()


import collections
pos = collections.defaultdict(list)
for i, c in enumerate(s):
	pos[c].append(i)

import bisect

num = 0
cur = -1

for c in t:
	if c not in pos:
		print(-1)
		exit()
	i = bisect.bisect_right(pos[c], cur)
	if i == len(pos[c]):
		i = 0
		num += 1
	cur = pos[c][i]
print(num*len(s)+cur+1)



Measured memory_bytes: 80184
#include<bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define pb push_back
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()
#define uni(x) x.erase(unique(rng(x)),x.end())
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define dup(x,y) (((x)+(y)-1)/(y))
#define v(T) vector<T>
#define vv(T) v(v(T))
using ll = int64_t;
using ull = uint64_t;
using uint = uint32_t;
using pii = pair<int,int>;
using pll = pair<ll,ll>;
using pil = pair<int,ll>;
using pil = pair<int,ll>;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
template<typename T>inline istream& operator>>(istream&i,v(T)&v)
{rep(j,v.size())i>>v[j];return i;}
template<typename T>string join(const v(T)&v)
{stringstream s;rep(i,v.size())s<<' '<<v[i];return s.str().substr(1);}
template<typename T>inline ostream& operator<<(ostream&o,const v(T)&v)
{if(v.size())o<<join(v);return o;}
template<typename T1,typename T2>inline istream& operator>>(istream&i,pair<T1,T2>&v)
{return i>>v.fi>>v.se;}
template<typename T1,typename T2>inline ostream& operator<<(ostream&o,const pair<T1,T2>&v)
{return o<<v.fi<<","<<v.se;}
constexpr double eps = 1e-6;
constexpr ll LINF = 100200300400500600ll;
constexpr int INF = 2*((1<<30)-1)+1;
//--------------------------------------------------------
#define fastio cin.tie(nullptr); std::ios::sync_with_stdio(false);
#define myio ifstream iofi; if(argc>1){iofi.open(argv[1]); std::cin.rdbuf(iofi.rdbuf());}
#define myloopset int loop = 1; if(argc>2) loop =stoi(argv[2]); rep(i,loop)
//--------------------------------------------------------------
template <class T> T chmin(T &a,T b){if(a>b){a=b; return 1;}else return 0;}
template <class T> T chmax(T &a,T b){if(a<b){a=b; return 1;}else return 0;}
constexpr int dx[4] = {0,1,0,-1};
constexpr int dy[4] = {-1,0,1,0};
constexpr int mod = 1000000007;
#define Yes(ifeq) cout<<(( ifeq )? "Yes":"No")<<endl;

void Main(){
  ll n=100;
  ll x;
  cin>>x;
  int a=0;
  while( n < x ){
    a++;
    n+=n*0.01;
  }
  cout<<a<<endl;
} signed main(int argc,char** argv)
{fastio; myio; myloopset Main();}


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

using VI = vector<int>;
using VVI = vector<VI>;
using PII = pair<int, int>;
using LL = long long;
using VL = vector<LL>;
using VVL = vector<VL>;
using PLL = pair<LL, LL>;
using VS = vector<string>;

#define ALL(a)  begin((a)),end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define MT make_tuple
#define SZ(a) int((a).size())
#define SORT(c) sort(ALL((c)))
#define RSORT(c) sort(RALL((c)))
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))

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

#define FF first
#define SS second

template<class S, class T>
istream& operator>>(istream& is, pair<S,T>& p){
  return is >> p.FF >> p.SS;
}
template<class T>
istream& operator>>(istream& is, vector<T>& xs){
  for(auto& x: xs)
	is >> x;
  return is;
}
template<class S, class T>
ostream& operator<<(ostream& os, const pair<S,T>& p){
  return os << p.FF << " " << p.SS;
}
template<class T>
ostream& operator<<(ostream& os, const vector<T>& xs){
  for(unsigned int i=0;i<xs.size();++i)
	os << (i?" ":"") << xs[i];
  return os;
}
template<class T>
void maxi(T& x, T y){
  if(x < y) x = y;
}
template<class T>
void mini(T& x, T y){
  if(x > y) x = y;
}
void debug(istringstream&){}
template <char sep=',', class Head, class... Tail>
void debug(istringstream& iss, Head&& head, Tail&&... tail)
{
  string name;
  getline(iss, name, ',');
  cerr << sep << name << "=" << head;
  debug(iss, forward<Tail>(tail)...);
}
#define DEBUG(...) \
  do{ \
    istringstream ss(#__VA_ARGS__); \
    debug<' '>(ss, __VA_ARGS__); \
    cerr<<endl; \
  }while(0)

const double EPS = 1e-10;
const double PI  = acos(-1.0);
const LL MOD = 1e9+7;

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

  int X, Y;
  cin >> X >> Y;
  cout << X+Y/2<<endl;

  return 0;
}


Measured memory_bytes: 256
def solve(h, w, s):
    p = [chr(ord("A") + i) for i in range(26)]
    for r in range(h):
        for c in range(w):
            if s[r][c] == "snuke":
                return "%s%s" % (p[c], r+1)

h, w = map(int, input().split())
s = [input().split() for r in range(h)]
print(solve(h, w, s))

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
const string ln = "\n";
constexpr int INF = 1001001001;
constexpr int MOD = 1000000007;

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

  string s;
  cin >> s;

  bool a = false;
  bool b = false;
  for (int i = 0; i < s.size(); i++) {
    if (s[i] == 'A') {
      a = 1;
    } else {
      b = 1;
    }
  }

  if (a && b) {
    cout << "Yes" << ln;
  } else {
    cout << "No" << ln;
  }

  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#define MOD1 1000000007
#define MOD2 998244353
#define LIMIT1 200002
#define LIMIT2 500002
typedef long long ll;
typedef long double ld;
#define rep(i,n) for(i=0;i<n;i++)
#define max(a,b) ((a)>(b) ? (a) : (b))
#define min(a,b) ((a)<(b) ? (a) : (b))
#define zt(a,b) (max((a),(b))-min((a),(b)))
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll nPr(int n,int r){ll i,result=1;rep(i,r){result*=(ll)(n-i);}return result;}
ll nCr(int n,int r){ll i,result=1; rep(i,min(r,n-r)){result*=(ll)(n-i);result/=(ll)(i+1);}return result;}
#define fact(n) nPr((int)(n),(int)(n))
#define nHr(n,r) nCr((int)((n)+(r)+1),(int)(r))
#define sankaku(x) (((x)*((x)+1))/2)
int dx[8]={1,0,-1,0,1,-1,-1,1};
int dy[8]={0,1,0,-1,1,1,-1,-1};
int upint(const void *a, const void *b) { return *(int *)a < *(int *)b ? -1 : *(int *)a > *(int *)b ? 1 : 0; }
int downint(const void *a, const void *b) { return *(int *)a < *(int *)b ? 1 : *(int *)a > *(int *)b ? -1 : 0; }
int upchar(const void* left, const void* right) {return strcmp((char *)left,(char *)right);}
int downchar(const void* left, const void* right) {return strcmp((char *)right,(char *)left);}
ll modpow(ll a, ll n, ll mod) {
  ll res = 1;
  while (n > 0) {
    if (n & 1) res = res * a % mod;
    a = a * a % mod;
    n >>= 1;
  }
  return res;
}
void initialize(){
    
}
int main(void){
  initialize();
  ll n,m,i,j,k,result=0,tmp=0,start=0;
  char s[LIMIT1];
  int u[LIMIT2]={0};
  int cc[2020]={0};
  
  scanf("%s",s);
  n=strlen(s);
  for(i=n-1;i>=0;i--){
    //tmp=1;
    tmp=modpow(10,n-1-i,2019);
    tmp*=(int)(s[i]-'0');
    if(i<n-1) tmp+=u[i+1];
    tmp%=2019;
    u[i]=tmp;
    cc[u[i]]++;
  }
  //qsort(u,n,sizeof(int),upint);
  result=cc[0];
  for(i=0;i<2019;i++){
    if(cc[i]>=2) result+=nCr(cc[i],2);
  }
  //rep(i,n) printf("%d ",u[i]);
  //printf("\n");
  printf("%lld",result);
  return 0;
}
 

Measured memory_bytes: 3892
import java.util.*;

public class Main {

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

        int max = 0;
        for (int i = 0; i < n; i++) {
            pArr[i] = sc.nextInt();
            max = Math.max(max, pArr[i]);
        }

        int sum = 0;
        boolean flg = false;// 1つだけ半額にする管理フラグ
        for (int i = 0; i < n; i++) {
            if (max == pArr[i] && !flg) {
                sum += pArr[i]/2;
                flg = true;
            } else {
                sum += pArr[i];
            }
        }

        System.out.println(sum);
    }
}


Measured memory_bytes: 21844