akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#include <iostream>
#include <string>

using namespace std;

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

int N;
int main()
{
    int d[100];
    int max, n;
    int cnt;
    cnt = max = 0;
    cin >> N;
    REP(i, N) scanf("%d", &d[i]);
    //cout << endl;
    REP(i, N) {
        max = 0;
        //cout << endl;
        REP(j, N) {
            //cout << j << "j:" << d[j] << endl;
            if (max < d[j] && d[j] < 101) {
                max = d[j];
                n = j;
            }
        }
        if (d[n] == 101) {
            continue;
        } else {
            REP(i, N) {
                if (i == n) continue;
                if (d[i] == d[n]) d[i] = 101;
            }
            //cout << d[n] << endl;
            d[n] = 101;
            ++cnt;
        }
    }
    cout << cnt << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
  //入力
  int N;
  cin >> N;
  vector<int> tower(N);
  for (int i=0;i<N;i++){
    cin >> tower.at(i);
  }
  
  int Total=0;
  for(int i=1;i<101;i++){
    int CutNum =0;
    bool Reach = false;
    for(int j=0;j<N;j++){
      if (Reach == false && i <= tower.at(j)){
        CutNum++;
        Reach = true;
      }
      if (Reach == true && i > tower.at(j)){
        Reach = false;
      }
    }
    Total += CutNum;
  }
  
  cout << Total <<endl;
  
}

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

#define rep(i, n) for(int i = 0; i < (n); i++)
#define all(a) (a).begin(),(a).end()
#define SORT(a) sort(all(a))
#define rSORT(a, i) sort(all(a),(i))

using ll = long long;
constexpr ll INF = 10000000000;
constexpr ll MOD = 1000000007;
const int MAX_N = 110000; 
constexpr double EPS = 1E-11;

using namespace std;

//fixed << setprecision(10)

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

	vector<ll>a(n);
	vector<ll>b(n);
	rep(i, n)cin >> a[i] >> b[i];

	vector<ll> C(n + 1, 0);

	for (int i = n - 1; i >= 0; i--) {

		a[i] += C[i + 1];
		ll am = a[i] % b[i];
		ll need = 0;

		if (am != 0) need = b[i] - am;
		C[i] = C[i + 1] + need;
	}
	cout << C[0] << endl;
}

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

int main() {
	long long int n,a[100002],i,j,k,ans,x,y,z,mi=1e10;
	cin>>n;
	for(i=0;i<n;i++)
	{
	    cin>>a[i];
	    mi=min(mi,a[i]);
	}
	if(mi==1)
	cout<<1;
	else
	{
	    vector<long long int>v;
	    for(i=0;i<n;i++)v.push_back(a[i]);
	    mi=1e10;
	    for(j=1;j<=1000;j++)
	    {
	        if(v.size()==1 || mi==1)
	        {
	            if(v.size()==1)
	            cout<<v[0];
	            else
	            cout<<1;
	            break;
	        }
	        mi=1e10;
	        long long int in;
	        for(i=0;i<v.size();i++)
	        {
	            if(mi>v[i])
	            {
	                mi=v[i];
	                in=i;
	            }
	        }
	        vector<long long int >v1;
	        for(i=0;i<v.size();i++)
	        {
	            if(v[i]%mi!=0 && i!=in)
	            v1.push_back(v[i]%mi);
	            if(i==in)
	            v1.push_back(v[i]);
	        }
	        v=v1;
	    }
	}
}


Measured memory_bytes: 3316
N = int(input())
stone = input()

R_count = 0
W_count = 0
for i in range(len(stone)):
  if stone[i] == "R":
    R_count = R_count + 1
  else:
    W_count = W_count + 1

W = 0
R = R_count
try_num_prev = -1
for i in range(N):
  if R_count == 0 or W_count == 0:
    try_num = 0
    break
  
  if W <= R:
    try_num = R
  else:
    try_num = W
  
  #print(try_num_prev, try_num)
  if try_num_prev >= 0 and try_num_prev < try_num:
    try_num = try_num_prev
    break
  else:
    try_num_prev = try_num
    if stone[i] == "R":
      R = R - 1
    else:
      W = W + 1
    
print(try_num)

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

using namespace std;

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


Measured memory_bytes: 256
pub fn main() {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    let nm: Vec<i32> = s.split_whitespace().map(|w| w.parse().unwrap()).collect();
    if nm[0] == nm[1] {
        println!("Yes");
    } else {
        println!("No");
    }
}

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

int main() {
    string s;
    cin >> s;
    int counter = 0;
    if (s[0] == '1') ++counter;
    if (s[1] == '1') ++counter;
    if (s[2] == '1') ++counter;
    cout << counter << endl;
    return 0;
}

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

const int maxn = 110;
int n;
int a[maxn];
int b[maxn];

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

  cin >> n;

  for (int i = 1; i <= n; i++) {
    int at; cin >> at;
    a[i] = a[i-1] + at;
  }

  for (int i = 1; i <= n; i++) {
    int bt; cin >> bt;
    b[i] = b[i-1] + bt;
  }

  int ans = 0;
  for (int i = 1; i <= n; i++) {
    int cur = a[i] + (b[n] - b[i-1]);
    ans = max(ans, cur);
  }

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


Measured memory_bytes: 256
#include "bits/stdc++.h"
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a),i##_len=(b);i<i##_len;++i)
#define MSVC_UNKO(x) x
#define rep(...) MSVC_UNKO(_overload3(__VA_ARGS__,repi,_rep,_rep)(__VA_ARGS__))
#define all(c) c.begin(),c.end()
#define mp make_pair
#define write(x) cout<<(x)<<'\n'
using namespace std; typedef long long ll; template<class T>using vv = vector<vector<T>>;
template<class T>auto vvec(int n, int m, T v) { return vv<T>(n, vector<T>(m, v)); }
template<class T1, class T2>bool chmax(T1& a, const T2& b) { return a < b ? a = b, 1 : 0; }
template<class T1, class T2>bool chmin(T1& a, const T2& b) { return b < a ? a = b, 1 : 0; }
constexpr int INF = 1 << 29, MOD = int(1e9) + 7; constexpr ll LINF = 1LL << 60;
struct aaa { aaa() { cin.tie(0); ios::sync_with_stdio(0); cout << fixed << setprecision(12); }; }aaaa;

struct Y {
    int l1, l2, r1, r2;
};

int N;
vector<int> P;

int main() {
    cin >> N;
    P.resize(N);
    rep(i, N) cin >> P[i];

    vector<int> Q(N);
    rep(i, N) Q[P[i] - 1] = i;

    vector<Y> R(N);
    map<int, int> m;
    for (int i = N - 1; i >= 0; --i) {
        m.emplace(Q[i], i);

        auto it = m.find(Q[i]);
        it++;
        if (it != m.end()) {
            R[i].r1 = (*it).first;
            it++;
            if (it != m.end()) {
                R[i].r2 = (*it).first;
            }
            else {
                R[i].r2 = N;
            }
        }
        else {
            R[i].r1 = R[i].r2 = N;
        }

        it = m.find(Q[i]);
        if (it != m.begin()) {
            it--;
            R[i].l1 = (*it).first;
            if (it != m.begin()) {
                it--;
                R[i].l2 = (*it).first;
            }
            else {
                R[i].l2 = -1;
            }
        }
        else {
            R[i].l1 = R[i].l2 = -1;
        }
    }

    ll ans = 0;
    rep(i, N) {
        ll b = 0;
        b += (ll)(R[i].r2 - R[i].r1) * (Q[i] - R[i].l1);
        b += (ll)(R[i].l1 - R[i].l2) * (R[i].r1 - Q[i]);
        ans += b * (i + 1);
    }

    write(ans);
}

Measured memory_bytes: 7296
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i,n) for(int i=0; i<(n); i++)
#define REP2(i,x,n) for(int i=x; i<(n); i++)
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const long long INF = 1LL << 60;

int cnt(int n){
    set<int> ans;
    for(int i=1; i*i<=n; i++){
        if(n%i==0) {
            ans.insert(i);
            ans.insert(n/i);
        }
    }
    //cout << ans.size() << endl;
    return ans.size();
}
int main()
{
    int N;
    cin >> N;
    int ans=0;
    REP(i, N+1){
        if(i%2==1&&cnt(i)==8){
            ans++;
        }
    }

    cout << ans << endl;

    return 0;
}

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

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

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

    int min_dist = INT_MAX;
    int a;
    for (int i = 0; i < N; i++)
    {
        if (i == 0)
            a = A[A.size()-1] - A[0];
        else if (i > 0)
            a = (K - A[i]) + A[i-1];
        
        if (a < min_dist)
            min_dist = a;
    }
    std::cout << min_dist << std::endl;
    
    return 0;
}


Measured memory_bytes: 1024
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
#define double long double
using datas=pair<ll,ll>;
using ddatas=pair<double,double>;
using tdata=pair<ll,datas>;
using vec=vector<ll>;
using mat=vector<vec>;
using pvec=vector<datas>;
using pmat=vector<pvec>;
#define For(i,a,b) for(i=a;i<(ll)b;i++)
#define bFor(i,a,b) for(i=a;i>=(ll)b;i--)
#define rep(i,N) For(i,0,N)
#define rep1(i,N) For(i,1,N)
#define brep(i,N) bFor(i,N-1,0)
#define all(v) (v).begin(),(v).end()
#define allr(v) (v).rbegin(),(v).rend()
#define vsort(v) sort(all(v))
#define vrsort(v) sort(allr(v))
#define endl "\n"
#define pb push_back
#define print(v) cout<<v<<endl
#define printyes cout<<"Yes"<<endl
#define printno cout<<"No"<<endl
#define printYES cout<<"YES"<<endl
#define printNO cout<<"NO"<<endl
#define output(v) do{bool f=0;for(auto outi:v){cout<<(f?" ":"")<<outi;f=1;}cout<<endl;}while(0)
const ll mod=1000000007;
const ll inf=1LL<<60;
const double PI = acos(-1);
const double eps = 1e-9;
template<class T> inline bool chmax(T& a,T b){bool x=a<b;if(x)a=b;return x;} 
template<class T> inline bool chmin(T& a,T b){bool x=a>b;if(x)a=b;return x;} 

void startupcpp(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout<<fixed<<setprecision(15);
}

double distance(ddatas x,ddatas y){
  double a=x.first-y.first,b=x.second-y.second;
  return sqrt(a*a+b*b);
}

ll modinv(ll a) {
  ll b=mod,u=1,v=0,t;
  while(b){
    t=a/b;
    a-=t*b; swap(a,b);
    u-=t*v; swap(u,v);
  }
  return (u+mod)%mod;
}

ll moddevide(ll a,ll b){return (a*modinv(b))%mod;}

vec modncrlistp,modncrlistm;

ll modncr(ll n,ll r){
  ll i,size=modncrlistp.size();
  if(size<=n){
    modncrlistp.resize(n+1);
    modncrlistm.resize(n+1);
    if(!size){
      modncrlistp[0]=modncrlistm[0]=1;
      size++;
    }
    For(i,size,n+1){
      modncrlistp[i]=modncrlistp[i-1]*i%mod;
      modncrlistm[i]=modinv(modncrlistp[i]);
    }
  }
  return modncrlistp[n]*modncrlistm[r]%mod*modncrlistm[n-r]%mod;
}

ll modpow(ll a,ll n){
  ll res=1;
  while(n){
    if(n&1)res=res*a%mod;
    a=a*a%mod;
    n>>=1;
  }
  return res;
}

ll gcd(ll a,ll b){if(!b)return a;return (a%b==0)?b:gcd(b,a%b);}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}

ll countdigits(ll n){
  ll ans=0;
  while(n){n/=10;ans++;}
  return ans;
}

ll sumdigits(ll n){
  ll ans=0;
  while(n){ans+=n%10;n/=10;}
  return ans;
}

int main(){
  // startupcpp();
  // ll test;cin>>test;while(test--){
  ll i,j,H,W;
  cin>>H>>W;
  mat dp(H,vec(W,0));
  dp[0][0]=1;
  string s;
  rep(i,H){
    cin>>s;
    rep(j,W){
      if(s[j]=='#')continue;
      if(i)dp[i][j]+=dp[i-1][j];
      if(j)dp[i][j]+=dp[i][j-1];
      dp[i][j]%=mod;
    }
  }
  cout<<dp[H-1][W-1]<<endl;
  return 0;
}


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

int main()
{
    ll X;
    cin >> X;
    ll res = 0;
    res += X/500*1000;
    X %= 500;
    res += X/5*5;
    cout << res << endl;
    return 0;
}

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

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

    for (int i = A; i <= B; i++) {
        if (i % K == 0) {
            cout << "OK" << endl;
            return 0;
        }
    }
    
    cout << "NG" << endl;
        
    return 0;
}

Measured memory_bytes: 3648
#include <iostream>
#include <cmath>

int main()
{
	int e;
	while (std::cin >> e, e > 0) {
		int m = e;	// ツ可シツづ個値
		const int z_max = static_cast<int>(pow(static_cast<double>(e), 1. / 3.)) + 1;
		for (int z = 0; z <= z_max; ++z) {
			const int y_max = static_cast<int>(sqrt(static_cast<double>(e))) + 1;
			for (int y = 0; y < y_max; ++y) {
				const int x = e - y * y - z * z * z;
				if (x < 0) { break; }
				const int m_ = x + y + z;
				if (m_ < m) { m = m_; }
			}
		}
		std::cout << m << std::endl;
	}
	return 0;
}

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

#define ll long long

int main() {
	int n, k;
	cin >> n >> k;
	vector<int> v;
	for (int i = 0; i < n; i++){
		int a;
		cin >> a;
		v.push_back(a);
	}
	sort(v.begin(), v.end());
	int counter = 0;
	for (int i = 0; i < k; i++){
		counter += v[i];
	}
	cout << counter;
}


Measured memory_bytes: 3604
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#define pb push_back
#define INF 0x3f3f3f3
#define LINF 0x3f3f3f3f3f3f3f
#define MAXN 2*int(1e5)+5
#define fim '\n'
#define ll long long
#define f first
#define s second
#define FAST cin.tie(0), cout.tie(0), ios::sync_with_stdio(0)
#define debug(x) cout << "DEBUG " << x << fim
#define debug2(x, y) cout << "DEBUG " << x << " " << y << fim
#define debug3(x, y, z) cout << "DEBUG " << x << " " << y << " " << z<< fim
#define debug4(x, y, z, o) cout << "DEBUG " << x << " " << y << " " << z<< " " << o << fim
#define max3(x, y, z) max(x, max(y, z))
#define ull unsigned long long
using namespace std;
using namespace __gnu_pbds;
typedef pair<int, int> pii;
typedef pair<string, int> psi;
typedef pair<unsigned ll, pair<int, int> > piii;
typedef pair<pair<int, int>, int> piii2;
typedef tree<int,null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> indexed_set;
const ll MOD = 1e9+7;

int main() {
	ll r;
	cin >> r;
	cout << r*r << endl;
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Collections;
import java.util.StringTokenizer;

public class Main {

	public static void main(String[] args) {
		FastScanner fs=new FastScanner();
		int a = fs.nextInt();

		System.out.println(a + a*a + a*a*a);
	}

	static void sort(int[] a) {
		ArrayList<Integer> l=new ArrayList<>();
		for (int i:a) l.add(i);
		Collections.sort(l);
		for (int i=0; i<a.length; i++) a[i]=l.get(i);
	}

	static class FastScanner {
		BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
		StringTokenizer st=new StringTokenizer("");
		String next() {
			while (!st.hasMoreTokens())
				try {
					st=new StringTokenizer(br.readLine());
				} catch (IOException e) {
					e.printStackTrace();
				}
			return st.nextToken();
		}

		int nextInt() {
			return Integer.parseInt(next());
		}
		int[] readArray(int n) {
			int[] a=new int[n];
			for (int i=0; i<n; i++) a[i]=nextInt();
			return a;
		}
		long nextLong() {
			return Long.parseLong(next());
		}
	}


}


Measured memory_bytes: 32676
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define printVec(v) printf("{"); for (const auto& i : v) { std::cout << i << ", "; } printf("}\n");
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
using namespace std;
using P = pair<int,int>;
using ll = long long;
const ll INF = 1LL<<60;
const double PI = 3.1415926535897932;
const int MOD = 1e9 + 7;

//cin.tie(0);ios::sync_with_stdio(false);
int main() {
  int n;
  cin >> n;
  vector<int> s(n);
  int cnt = 0;
  rep (i, n) cin >> s[i];
  for (int i = 0; i < n - 2; i++) {
    for (int j = i + 1; j < n - 1; j++) {
      for (int k = j + 1; k < n; k++) {
	if (s[i] != s[j] && s[i] != s[k] && s[j] != s[k]) {
	  if (s[i] < s[j] + s[k] && s[j] < s[i] + s[k] && s[k] < s[i] + s[j])cnt++;
	}
      }
    }
  }
  cout << cnt << endl;
  return 0;
}


Measured memory_bytes: 3616
#include <iostream>
#include<algorithm>
#include<vector>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i = 0; i < n;i++)
int main() {
	ll n;cin >> n;vector<ll> a(n), s(n + 1,0);
	rep(i, n) {
		cin >> a[i];s[i + 1] = s[i] + a[i];
	}
	sort(s.begin(), s.end());ll sum = 0,e =0;
	rep(i, n) {
		if (s[i] == s[i + 1]) {
			e++;
		}
		else {
			sum += e * (e + 1) / 2;
			e = 0;
		}
	}
	sum += e * (e + 1) / 2;
	cout << sum << endl;
}

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

#define watch(x) cerr << (#x) << ": " << (x) << endl
#define int long long

const int N = 2500, inf = 1000000000000;
int n, m, p;
vector<pair<int, int>> graph[N+1];
vector<int> rev_graph[N+1];
int d[N+1];
bool reach[N+1], sreach[N+1];

void dfs(int cur) {
    reach[cur] = true;
    for(int child : rev_graph[cur]) {
        if(!reach[child])
            dfs(child);
    }
}

void dfs2(int cur) {
    sreach[cur] = true;
    for(auto child : graph[cur]) {
        if(!sreach[child.first])
            dfs2(child.first);
    }
}

bool solve() {
    d[1] = 0;
    for(int i = 0; i < n-1; ++i) {
        for(int from = 1; from <= n; ++from) {
            for(pair<int, int> edge : graph[from]) {
                d[edge.first] = min(d[edge.first], d[from] + edge.second);
            }
        }
    }

    for(int i = 0; i < n; ++i) {
        for(int from = 1; from <= n; ++from) {
            for(pair<int, int> edge : graph[from]) {
                if(d[edge.first] > d[from] + edge.second && sreach[from] && reach[edge.first])
                    return false;
                d[edge.first] = min(d[edge.first], d[from] + edge.second);
            }
        }
    }

    return true;
}

int32_t main() {

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

    cin >> n >> m >> p;
    for(int i = 0; i < m; ++i) {
        int a, b, c; cin >> a >> b >> c;
        graph[a].emplace_back(b, p-c);
        rev_graph[b].push_back(a);
    }

    for(int i = 1; i <= n; ++i) {
        reach[i] = false;
        sreach[i] = false;
    }
    
    dfs(n);
    dfs2(1);
    for(int i = 1; i <= n; ++i) d[i] = inf;

    bool good = solve();

    if(good) {
        cout << max(-d[n], 0LL) << endl;
    } else {
        cout << -1 << endl;
    }
    
    return 0;
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
#define range(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,b) for(int i = 0; i < (b); i++)
#define all(a) (a).begin(), (a).end()
#define debug(x) cout << "debug " << x << endl;
#define INF (1 << 29)
using namespace std;

int main(){
    int n, k;
    cin >> n >> k;
    int ans = k;
    rep(i,n - 1){
        ans*= (k - 1);
    }
    cout << ans << endl;
}


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

using ll=long long;
using namespace std;

#define rep_i(i, n) for (int i = 0; i < (n); ++i)
#define rep_ll(i, n) for (long long i = 0; i < (n); ++i)
#define r_rep_i(i, start, end) for (int i = (start); i < (end); ++i)
#define r_rep_ll(i, start, end) for (long long i = (start); i < (end); ++i)
#define debug_vi(v) copy((v).begin(), (v).end(), ostream_iterator<int>(cout, " "));
#define debug_vll(v) copy((v).begin(), (v).end(), ostream_iterator<long long>(cout, " "));
#define debug_vd(v) copy((v).begin(), (v).end(), ostream_iterator<double>(cout, " "));
#define sort_v(v) sort((v).begin(), (v).end()); //昇順
#define d_sort_vi(v) sort((v).begin(), (v).end(), greater<int>()); //降
#define d_sort_vll(v) sort((v).begin(), (v).end(), greater<long long>()); //降
#define d_sort_vd(v) sort((v).begin(), (v).end(), greater<double>()); //昇順
#define say(t) cout << (t) << endl;
#define sum_vi(v) accumulate((v).begin(), (v).end(), 0);
#define sum_vll(v)accumulate((v).begin(), (v).end(), 0LL);

ll gcd(ll a, ll b) { return b?gcd(b, a%b):a;}
ll lcm(ll a, ll b) { return a/gcd(a, b)*b;}

const int IINF=(1<<30);
const ll LLINF = 1LL<<60;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(0);
    string s, p;cin >> s >> p;
    bool f;
    for (int i = 0; i < s.length(); i++){
        f = true;
        for (int a = 0; a < p.length(); a++){
            if(s[(i + a)%s.length()] != p[a])f = false;
        }
        if(f){
            say("Yes")
            return 0;
        }
    }
    say("No")
}


Measured memory_bytes: 3228
import java.util.Map.Entry;
import java.util.*;
 
//import org.w3c.dom.css.Counter;
 
public class Main {
//public class App {
 
    public static void main(final String[] args){
     //スキャン
     final Scanner s = new Scanner(System.in);
      //String N = Integer.parseInt(s.next());
      long N = Integer.parseInt(s.next());
      //int T = Integer.parseInt(s.next());
      //int ans = N /X;
      //String hoge = s.next();
      //int huge = hoge.length();
      //int hage = 0;
      int tmp = 0;
      long ans=0;
    for(long i =0;i<N;i++){
        int T = Integer.parseInt(s.next());
        if(tmp >T){
            ans += tmp -T;
        }else{
            tmp = T;
        }
    }
    System.out.println(ans);
    }
}

Measured memory_bytes: 58452
// Problem : E - Logs
// Contest : AtCoder - AtCoder Beginner Contest 174
// URL : https://atcoder.jp/contests/abc174/tasks/abc174_e
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;

//Macros

#define ll long long
#define db long double
#define pb push_back
#define eb emplace_back
#define pii pair<int,int>
#define vi vector<int>
#define vii vector<pii>
#define mi map<int,int>
#define mii map<pii,int>
#define fi first
#define se second
#define all(a) (a).begin(),(a).end()
#define sz(x) (int)x.size()
#define mod 1000000007
#define EPS 1e-9
#define io ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define inf 1e10
#define PI acos(-1.0)
#define int long long
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
#define N 200005

//Solution

int n,k,a[N];

bool check(db x){
    int cnt = 0;
    for(int i=0;i<n;i++){
        int k0 = ceil(a[i]/x) - 1;
		if (round(a[i]/(k0+1)) > x) k0++;
		cnt += k0;
    }
    return cnt <= k;
}

void solve(){
    cin>>n>>k;
    for(int i=0;i<n;i++) cin>>a[i];
    int lo = 1, hi = 1e9, ans;
    while(lo <= hi){
        int mid = (lo+hi)/2;
        if(check(mid)) ans = mid, hi = mid-1;
        else lo = mid+1;
    }
    cout<<ans;
}

signed main(){
    io;
    //freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout);
    int tests;
    //cin>>tests;
    tests = 1;
    while(tests--){
        solve();
    }
    return 0;
}

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

int main(){
  int n;
  bool zero = false;
  cin >> n;
  vector<ll> nums(n);
  rep(i,n){
  cin >> nums[i];
  if(nums[i] == 0){zero = true;break;}
  }
  ll ans = 0;
  if(!zero){
  ans = 1;
  rep(i,n){
    if(ans > powl(10,18)/nums[i] || ans < 0){
      ans = -1;
      break;
    }
    ans *= nums[i];
  }
  }
  cout << ans << endl;
}

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

ll solve() {
    ll N, a;
    cin >> N;
    map<ll,int> c;
    for ( int i = 0; i < N; i++ ) {
        cin >> a;
        c[a]++;
    }
    ll ans = 0;
    for ( auto it = c.rbegin(); it != c.rend(); it++ ) {
        if ( it->second == 0 ) continue;
        ll s = 1;
        while ( s <= it->first ) s *= 2;
        if ( it->first * 2 == s ) {
            ans += it->second / 2;
            it->second -= (it->second / 2) * 2;
        } else {
            auto it2 = c.find(s - it->first);
            if ( it2 == c.end() || it2->second == 0) continue;
            int n1 = min(it->second, it2->second);
            ans += n1;
            it->second -= n1;
            it2->second -= n1;
        }
    }
    return ans;
}

int main() {
    auto ans = solve();
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 12800
import java.util.Arrays;
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		while(true){
			int n = sc.nextInt();
			if(n == 0 ) break;
			int[] score = new int[n];
			for(int i = 0 ; i < n ; i++){
				score[i] = sc.nextInt();
			}
			Arrays.sort(score);
			score[0] = 0; score[n-1] = 0;
			int sum = 0 ; int count = 0;
			for(int i = 0 ; i < n ;i++){
				if(score[i] != 0) count++;
				sum += score[i];
			}
			System.out.println(sum/count);
		}
		sc.close();
	}

}

Measured memory_bytes: 21120
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn=100000000;

int main()
{
    int a;
    string s;
    cin>>a>>s;
    if(a>=3200)
        cout<<s<<endl;
    else
        cout<<"red"<<endl;
    return 0;
}


Measured memory_bytes: 256
#include<map>
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<string>
#include<stack>
#define REP(i,x,y) for(ll i=x;i<=y;i++)
typedef long long ll;
using namespace std;

int main(){
	ll n, m;
	cin >> n >> m;
	cout << (n%m != 0) << endl;
}

Measured memory_bytes: 256
import java.util.*;

class Main{
    public static void main(String[] args){
        Scanner scan = new Scanner(System.in);
        int n = scan.nextInt();
        int m = scan.nextInt();
        int sumHyo = 0;
        int norma = 0;
        int count = 0;
        ArrayList<Integer> list = new ArrayList<Integer>();

        for(int i = 0; i < n; i++){
            int hyo = scan.nextInt();
            sumHyo += hyo;
            list.add(hyo);
        }
        scan.close();

        if(sumHyo % (m * 4) == 0) norma = sumHyo / (m * 4);
        else norma = (sumHyo / (m * 4)) + 1;

        for(int i = 0;i < list.size(); i++){
            if(!(list.get(i) < norma)) count++;
        }

        if(count >= m) System.out.println("Yes");
        else System.out.println("No");

    }
}

Measured memory_bytes: 21716
import sys
sys.setrecursionlimit(10000000)
"""
違反文字列
AGC -> AGときたらCはNG
GAC -> GAときたらCはNG
ACG -> ACときたらGはNG
AQGC-> A*GときたらCはNG
AGQC-> AG*ときたらCはNG
"""
n=int(input())
p=10**9+7
ok = ['A','G','C','T']
ng = ['AGC','GAC','ACG']
memo =[{} for i in range(n+1)]

def check(text):
  if text[1:] in ng:
    return 0
  if (text[:2] == 'AG' and text[3]=='C') or (text[0]=='A' and text[2:]=='GC'):
    return 0
  return 1

def dfs(cnt, last):
  if last in memo[cnt]:
    return memo[cnt][last]
  if cnt == n:
    return 1
  ans=0
  for o in ok:
    if check(last+o):
      ans += dfs(cnt+1, last[1:]+o) % p
  memo[cnt][last] = ans
  return ans % p
  

print(dfs(0,'TTT')%p)

Measured memory_bytes: 9800
import qualified Data.Vector.Unboxed as U
import qualified Data.Vector.Unboxed.Mutable as UM
import qualified Data.Vector as V
import qualified Data.ByteString.Char8 as C
import Debug.Trace
import Data.List
import Control.Monad
import Data.Ord
import Data.Maybe
import qualified Data.Set as S

r :: Int -> IO (U.Vector Int)
r n = U.unfoldrN n (C.readInt . C.dropWhile (==' ')) <$> C.getLine

r' :: IO [Int]
r'  =   unfoldr    (C.readInt . C.dropWhile (==' ')) <$> C.getLine

data Q = Q {a::Int,b::Int,c::Int,points::Int} deriving Show

main :: IO ()
main = do
    [n,m,q] <- r'
    qs <- replicateM q (r'>>=(\[a,b,c,d]->return (Q a b c d) ))
    print $ maximum $ map (pointsOf qs) $ generate n m

generate :: Int -> Int -> [[Int]]
generate 1 m = map (:[]) [1..m]
generate n m =
    concatMap (\(r@(h:t)) ->
            map (:r) [1..h]) (generate (n-1) m :: [[Int]])

pointsOf :: [Q] -> [Int] -> Int
pointsOf qs as =
    sum $ map (pts as) qs


pts as q = if as!!((b q) -1) - as!!((a q) -1) == c q then points q else 0


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

const int N = 110;
int a[2][N];

int Sum(int row, int l, int r) {
  int res = 0;
  for (int i = l; i < r; i++) res += a[row][i];
  return res;
}

int main() {
  int n;
  scanf("%d", &n);
  for (int i = 0; i < 2; i++) {
    for (int j = 0; j < n; j++) {
      scanf("%d", &a[i][j]);      
    }
  }
  int res = 0;
  for (int i = 0; i < n; i++) {
    int sum = 0;
    sum += Sum(0,0,i+1);
    sum += Sum(1,i,n);
    res = max( res, sum );
  }
  printf("%d\n", res);
  return 0;
}


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

using namespace std;

//int N,M,K,L,R,H,W;
long long int N,M,K,L,R,H,W;

constexpr long long int MOD=1000000007;
//constexpr  int MOD=1000000007;
//constexpr int MOD=998244353;
//constexpr long long int MOD=998244353;

constexpr long double EPS=1e-8;

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	
	int ans=0;
	string s;
	cin>>s;
	s='P'+s+'P';
	for(int i=1;i<=s.size();i++){
		if(s[i]=='O'){
			int add=0;
			while(s[i+add]=='O')add++;
			bool flag=true;
			for(int k=i-1;k>=i-add;k--){
				//cout<<"J "<<k<<endl;
				flag&=s[k]=='J';
				if(!flag)break;
			}
			for(int k=i+add;k<i+2*add;k++){
				//cout<<"I "<<k<<endl;
				flag&=s[k]=='I';
				if(!flag)break;
			}
			if(flag)ans=max(ans,add);
			i+=add-1;
		}
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 4976
import Control.Monad
import qualified Data.Map as M

main :: IO ()
main = replicateM 2 getLine >>= putStrLn . solve 

solve :: [String] -> String
solve [s, t]
    | all (\(x, y) -> x == y) xs = "Yes"
    | otherwise = "No"
    where
        xs = zip ys zs
        ys = cvt s
        zs = cvt t
        cvt = fst' . foldr ff ([], 0, M.empty)
        fst' (a, _, _) = a 
        ff x (acc, n, m)
            | M.member x m = (m M.! x : acc, n, m)
            | otherwise = (n : acc, n + 1, M.insert x n m)

Measured memory_bytes: 45564
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
int m[4];
char s[5];
int sum,a,b,c,d;
void dfs(int k){
	if(k==4){
		sum=a;
		sum+=m[1]*b;
		sum+=m[2]*c;
		sum+=m[3]*d;
		if(sum==7){
			printf("%d",a);
			printf("%c",m[1]==1?'+':'-');
			printf("%d",b);
			printf("%c",m[2]==1?'+':'-');
			printf("%d",c);
			printf("%c",m[3]==1?'+':'-');
			printf("%d=7",d);
			exit(0);
		} 
		return;
	}
	m[k]=1;
	dfs(k+1);
	m[k]=-1;
	dfs(k+1);
}
int main(){
	scanf("%s",s);
	a=s[0]-'0';b=s[1]-'0';c=s[2]-'0';d=s[3]-'0';
	dfs(1);
}

Measured memory_bytes: 256
ans = 0
def C4():
    N = int(input())
    def check(S):
        global ans
        s = 0
        f = 0
        t = 0
        #print(S)
        for j in list(S):
            if j == "7":
                s += 1
            if j == "5":
                f += 1
            if j == "3":
                t += 1
        if s != 0 and t != 0 and f != 0 and int(S) <= N:
            ans += 1

    def sarch(s):
        if int(s) <= N:
            check(s)
            sarch(s + '3')
            sarch(s + '5')
            sarch(s + '7')
    sarch("0")
    print(ans)
C4()

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ull unsigned long long
#define ld long double
#define mod 1000000007LL
#define eps 1e-13
#define PI 3.141592653589793238L
#define INF 1000000011
#define INFLL 10000000011LL
#define vi vector<int>
#define vll vector<long long>
#define pii pair<int, int>
#define pll pair<long long, long long>
#define pil pair<int, long long>
#define pli pair<long long, int>
#define mp make_pair
#define F first
#define S second
#define pb push_back
#define fo(i,a,n) for(i = (a); i < (n); i++)
#define gtl(x) getline(cin, (x))
#define flsh fflush(stdout)
#define sws ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define gcd __gcd
#define all(a) (a).begin(), (a).end()
#define sz(a) (int)((a).size())
#define io_file freopen("D:/Coding Problems/Contest/input_file.in", "r", stdin); freopen("D:/Coding Problems/Contest/output_file.out", "w", stdout)

ll modx(ll Base, ll exponent)
{
	ll ans = 1;
	if(Base == 1)
		return Base;
	while(exponent)
	{
		if(exponent & 1)
			ans = (ans * Base)%mod;
		Base = (Base * Base)%mod;
		exponent = exponent >> 1;
	}
	return ans;
}

ll inmodx(ll num)
{
	return (modx(num, mod-2LL));
}

bool cmp(pair < vi, int > a, pair < vi, int > b)//true for a before b
{
	if(a.F.empty())
		return 1;
	if(b.F.empty())
		return 0;
	int i;
	fo(i,0,min(sz(a.F),sz(b.F)))
	{
		if(a.F[i] < b.F[i])
			return 1;
		else if(a.F[i] > b.F[i])
			return 0;
	}
	return (sz(a.F) <= sz(b.F));
}

const int N = (2e3) + 9;
const int M = (N<<2) + 9;
const int LOGN = ((int)log2(N)) + 3;
const int LOGM = ((int)log2(M)) + 3;
const int BUCK = 900;
const int SQRT = BUCK+9;

string s[N];
int a[4][N][N];//up, left, down, right

inline int func(int i, int j)
{
	int ans = 1;
	ans += (i-a[0][i][j]-1);
	ans += (j-a[1][i][j]-1);
	ans += (a[2][i][j]-i-1);
	ans += (a[3][i][j]-j-1);
	return ans;
}

void solve()
{
	int n, m, i, j, ans = 0;
	cin >> n >> m;
	fo(i,0,n)
		cin >> s[i];
	
	i = 0;
	fo(j,0,m)
		a[0][i][j] = (s[i][j] == '#') ? 0 : -1;
	fo(i,1,n)
		fo(j,0,m)
			a[0][i][j] = (s[i][j] == '#') ? i : a[0][i-1][j];

	j = 0;
	fo(i,0,n)
		a[1][i][j] = (s[i][j] == '#') ? 0 : -1;
	fo(i,0,n)
		fo(j,1,m)
			a[1][i][j] = (s[i][j] == '#') ? j : a[1][i][j-1];

	i = n-1;
	fo(j,0,m)
		a[2][i][j] = (s[i][j] == '#') ? n-1 : n;
	for(i = n-2; i >= 0; i--)
		fo(j,0,m)
			a[2][i][j] = (s[i][j] == '#') ? i : a[2][i+1][j];

	j = m-1;
	fo(i,0,n)
		a[3][i][j] = (s[i][j] == '#') ? m-1 : m;
	fo(i,0,n)
		for(j = m-2; j >= 0; j--)
			a[3][i][j] = (s[i][j] == '#') ? j : a[3][i][j+1];

	fo(i,0,n)
		fo(j,0,m)
			if(s[i][j] == '.')
				ans = max(ans, func(i,j));
	cout << ans << '\n';
	return;
}

int main()
{
	sws;
	clock_t clk;
	clk = clock();
	// io_file;
	// srand (time(NULL));

	//Code here
	int t = 1, cs;
	cout << fixed << setprecision(15);
	// cin >> t;
	fo(cs,1,t+1)
	{
		// cout << "Case #" << cs << ": ";
		solve();
	}
	// Code ends here

	clk = clock() - clk;
	cerr << fixed << setprecision(6) << "Time: " << ((double)clk)/CLOCKS_PER_SEC << "\n";
	return 0;
}

Measured memory_bytes: 67584
#include <iostream>
#include <stdio.h>
#include <vector> 
#include <math.h> 
using namespace std;
int main(void){
    int n; cin >> n;
    vector<int> v(n);
    int i = 0;
    while (i < n) {
        cin >> v[i];
        i++;
    }
    i = 1;
    int ans = 10e8;
    while(i < n) {
        int S1 = 0;
        int S2 = 0;
        int j = 0;
        while(j < n) {
            if (j <= i) S1 += v[j];
            else S2 += v[j];
            j++;
        }
        i++;
        ans = min(ans, abs(S1-S2));
    }
    cout << ans << endl;
}

Measured memory_bytes: 3604
#include <bits/stdc++.h>
#define make_pair mp
#define pii pair<int,int>
using namespace std;
typedef long long ll;
const int maxn=100007;
const int inf=(1LL<<29);
char s[maxn];
stack<char> ss;
int main(){
    scanf("%s",s+1);
    int len=strlen(s+1);int ans=0;
    for(int i=1;i<=len;i++){
        if(!ss.empty()&&ss.top()!=s[i]) ans+=2,ss.pop();
        else ss.push(s[i]);
    }
    cout<<ans;
    return 0;
}


Measured memory_bytes: 384
import java.util.Scanner;
import java.util.Arrays;
public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		String s = sc.next();
		int[] al=new int[26];
		Arrays.fill(al,100000);
		for(int i = 0; i<s.length(); i++){
			if(i==al[s.charAt(i)-'a']+1 || i==al[s.charAt(i)-'a']+2){
				System.out.println((al[s.charAt(i)-'a']+1)+" "+(i+1));
				return;
			}
			al[s.charAt(i)-'a']=i;
		}
		System.out.println(-1+" "+-1);
	}
}

Measured memory_bytes: 23716
#include<bits/stdc++.h> 
#define fo(i,a,b) for(i=a;i<=b;i++)
#define fd(i,a,b) for(i=a;i>=b;i--)
#define min(a,b) (a<b?a:b)
#define max(a,b) (a>b?a:b)
typedef long long ll;
using namespace std;
const int maxn=1e3+5,mo=1e9+7;
int H,W,i,j,c1,c2,c3,c4;ll k;
char c[maxn][maxn];
int qs(int x,ll y){
	int s=1;
	for(;y;y>>=1,x=(ll)x*x%mo) if (y&1) s=(ll)s*x%mo;
	return s; 
}
struct ar{
	int a[2][2];
}a,b;
void mod(int &x){
	x-=(x>=mo)?mo:0;
}
ar operator *(ar a,ar b){
	ar c;
	memset(c.a,0,sizeof(c.a));
	int i,j,k;
	fo(i,0,1)
	fo(k,0,1){
		int x=a.a[i][k];
		fo(j,0,1) mod(c.a[i][j]+=(ll)x*b.a[k][j]%mo);
	}return c;
}
int main(){
	scanf("%d%d%lld",&H,&W,&k);
	if (k<=1) {
		puts("1");return 0;
	}
	fo(i,1,H) {
		scanf("%s",c[i]+1);
		fo(j,1,W) c1+=c[i][j]=='#';
	}
	fo(i,1,H) if (c[i][1]=='#'&&c[i][W]=='#') c3++;
	fo(i,1,W) if (c[1][i]=='#'&&c[H][i]=='#') c4++;
	if (c3&&c4){
		puts("1");return 0;
	}
	if (!c3&&!c4){
		printf("%d\n",qs(c1,k-1));return 0;
	}
	if (c3){
		fo(i,1,H)
		fo(j,1,W-1) if (c[i][j]=='#'&&c[i][j+1]=='#') c2++; 
	}else{
		c3=c4;
		fo(i,1,H-1)
		fo(j,1,W) if (c[i][j]=='#'&&c[i+1][j]=='#') c2++; 
	}
	a.a[0][0]=1,a.a[0][1]=1,k--;
	b.a[0][0]=c1,b.a[1][0]=c2?mo-c2:0,b.a[1][1]=c3;
	for(;k;k>>=1,b=b*b) if (k&1) a=a*b;
	printf("%d\n",a.a[0][0]);
}

Measured memory_bytes: 1280
S = input()
le = len(S)
ACGT = ['A','C','G','T']
cntlist = []
for i in range(le):
    cnt = 0
    for d in ACGT:
        if S[i] == d:
            cnt += 1
            for j in range(i+1,le):
                t = 0
                for d_ in ACGT:
                    if S[j] == d_:
                        cnt += 1
                        t += 1
                if t == 0: break
                    
    cntlist.append(cnt)

#print(cntlist)
print(max(cntlist))

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

using namespace std;

int main(int argc, char *argv[]) {
	int n;
	cin >> n;
	string s[n];
	for (int i = 0; i < n; i++) {
		cin >> s[i];
	}
	
	for (int i = 0; i < n; i++) {
		sort(s[i].begin(), s[i].end());
	}
	sort(s, s + n);
	long ans = 0;
	long count = 1;
	for (int i = 1; i < n; i++) {
		if (s[i] == s[i-1]) {
			count += 1;
		} else {
			ans += count * (count-1) / 2;
			count = 1;
		}
	}
	ans += count * (count-1) / 2;

	cout << ans << endl;
}

Measured memory_bytes: 7296
#include <bits/stdc++.h>
using namespace std;
#define mod 1000000007
int main() {
    ios_base::sync_with_stdio(false); 
    cin.tie(NULL);
    
	long long n,i,j,k,count=0,ans=0,l,r,x,y,sum=0,mx=0,m;
	cin>>n>>k;
	long long a[n+1],b[n+1]={0};
	for(i=0;i<(n+1);i++)
	{
	    a[i]=i;
	    sum+=a[i];
	    b[i]=sum;
	}
	
	for(i=(k);i<=(n+1);i++)
	{
	    sum=b[i-1];
	    if(i==(n+1))
	    count=b[n];
	    else
	    count=b[n]-b[n-i];
	    ans=(ans%mod+(count-sum+1)%mod)%mod;
	}
	cout<<ans;
	return 0;
}

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

int main() {
  int N;
  cin >> N;
  string result = "No";
  for (int i = 1; i < 10; i++) {
  	for (int j = 1; j < 10; j++) {
    	if (i * j == N) {
        	result = "Yes";
            goto BREAK_LABEL;
        }
    }
  }
  BREAK_LABEL:
  cout << result << endl;
}


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

int main (void) {
    char str[1001];
    int q;
    char command[8];
    int op1, op2;
    char op3[1001];
    char sub_str[1001];

    scanf ("%s", str);
    scanf ("%d", &q);

    for (int i=0; i<q; i++) {
        scanf ("%s", command);
        if (strcmp(command, "print")==0) {
            scanf ("%d %d", &op1, &op2);
            for (int j=op1; j<=op2; j++) printf ("%c", str[j]);
            printf ("\n");
        } else if (strcmp(command, "reverse")==0) {
            scanf ("%d %d", &op1, &op2);
            strncpy (sub_str, str+op1, op2-op1+1);
            for (int j=op1; j<=op2; j++) str[j] = sub_str[op2-j];
        } else if (strcmp(command, "replace")==0) {
            scanf ("%d %d %s", &op1, &op2, op3);
            strncpy (str+op1, op3, op2-op1+1);
        }
    }

    return 0;
}


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

using namespace std;

#ifndef errOut
#define errOut(s)
#endif

using Value = int64_t;

struct Row {
    Value a;
    Value b;

    Row(Value a_ = INT64_C(0), Value b_ = INT64_C(0)) : a(a_), b(b_) {
    }

    Value diff() const {
        return a - b;
    }
};

ostream& operator<<(ostream& os, const Row& row)
{
    os << "a: " << row.a << ", " << "b: " << row.b;
    return os;
}

Value calc(std::vector<Row>& rows) {
    auto n = static_cast<const int>(rows.size());
    Value ret = 0;
    for (auto&& row: rows) {
        if (row.diff() >= 0) {
            continue;
        }
        ret += row.a;
        row.b -= row.a;
        row.a = 0;
    }

    std::sort(rows.begin(), rows.end(),  [](Row x, Row y) -> bool {
        if (x.diff() == 0 && y.diff() == 0) {
            return x.b > y.b;
        }
        if (x.diff() == 0) {
            return true;
        }
        if (y.diff() == 0) {
            return false;
        }
        if (x.diff() > 0 && y.diff() > 0) {
           return x.b > y.b;
        }
        if (x.diff() >= 0) {
            return true;
        }
        if (y.diff() >= 0) {
            return false;
        }
        return x.diff() > y.diff();
    });

    bool foundAnyPositiveOrZeroDiff = false;
    for (auto itr = rows.rbegin(); itr != rows.rend(); ++itr) {
        auto& row = *itr;
        if (foundAnyPositiveOrZeroDiff) {
            ret += row.a;
        } else {
            if (row.diff() >= 0) {
                foundAnyPositiveOrZeroDiff = true;
                ret += row.diff();
            }
        }
    }
    return ret;
}

int main() {
    int n;
    std::cin >> n;
    std::vector<Row> rows(n, Row());
    bool anyDiff = false;
    for (int i = 0; i < n; ++i) {
        std::cin >> rows[i].a >> rows[i].b;
        if (rows[i].diff()) {
            anyDiff = true;
        }
    }
    if (!anyDiff) {
        std::cout << 0 << std::endl;
        return 0;
    }
    std::cout << calc(rows) << std::endl;
    return 0;
}


Measured memory_bytes: 512
#include <cstdio>
#include <cstring>
#include <cmath>
#include <vector>
#include <iostream>
#include <iomanip> 
#include <algorithm>
#include <queue>
#include <list>
#include <numeric>
#include <stack>
#include <unordered_map>
#include <map>
#include <set>

using namespace std;

#define sz(a) int((a).size())
#define all(x) x.begin(), x.end()
#define pb push_back
#define endl '\n'
#define watch(x) cout << #x << " : " << x << endl;

#define FastIO ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

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

const int N = int(2e5)+10;
const int K = int(2e6)+10;
const int MOD = int(1e9)+7;
const int INF = int(1e9)+5;
const ll INF64 = 2e18;

map<string,int> mp;

void solve () {
    int n;cin>>n;
    string s;
    for (int i=1;i<=n;i++) {
        cin>>s;
        mp[s] += 1;
    }
    cout<<"AC x "<<mp["AC"]<<endl;
    cout<<"WA x "<<mp["WA"]<<endl;
    cout<<"TLE x "<<mp["TLE"]<<endl;
    cout<<"RE x "<<mp["RE"]<<endl;
}

int main () {
    FastIO
// #ifndef ONLINE_JUDGE
//     freopen("input.txt", "r", stdin);
//     freopen("output.txt", "w", stdout);
// #endif
    int t;
    // cin>>t;
    t = 1;
    while (t--) {
        solve();
    }
    return 0;
}

Measured memory_bytes: 3660
import sys
sys.setrecursionlimit(100000000)
MOD = 10 ** 9 + 7
INF = 10 ** 15

def main():
    N = int(input())
    A = list(map(int,input().split()))
    ans = sum(a -1 for a in A)
    print(ans)
if __name__ == '__main__':
    main()


Measured memory_bytes: 3316
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define mp make_pair
#define gc getchar
#define pb push_back
#define eb emplace_back
#define all(x) (x).begin(),(x).end()
#define x1 uvuvwevwevwe
#define y1 onyetenyevwe
#define x2 ugwemubwem
#define y2 ossas
typedef long long LL;
typedef long double LD;
typedef pair<int,int> pii;
template <typename T> void scan(T &angka){
	angka=0;char input=gc();T kali=1;
	while(!(48<=input&&input<=57)){	if(input=='-')	kali=-1;input=gc();}
	while(48<=input&&input<=57)	angka=(angka<<3)+(angka<<1)+input-48,input=gc();angka*=kali;
}
template <typename T1,typename T2> void scan(T1 &angka1,T2 &angka2){
	scan(angka1);scan(angka2);
}
int n,total4=0,total2=0;
int main()
{
	scan(n);
	for(int i=1;i<=n;i++)
	{
		int input;
		scan(input);
		if(input%4==0)
			total4++;
		else if(input%2==0)
			total2++;
	}
	bool hasil=(((total4-1)>=(n-total2-1)/2)||(total4>=n/2)||(total2==n));
	if(hasil)
		cout<<"Yes"<<endl;
	else
		cout<<"No"<<endl;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <cstring>
#include <sstream>
#include <cassert>
#include <list>
using namespace std;
static const double EPS = 1e-10;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> PI;
#define rep(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
#define mp(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define SZ(a) (int(a.size()))
#define F first
#define S second
const double pi=acos(-1);
int dx[]={0,1,0,-1},dy[]={1,0,-1,0};


typedef pair<int,int> P; // ê,ÁÄé
typedef pair<float,P> PP;  // Ô,P

#define MAX 30
#define INFTY 1<<21
struct edge{int t;float c;};
float T[8];
vector<edge> v[MAX];
float dijkstra(int n,int m,int s,int g)
{
  priority_queue<PP,vector<PP>,greater<PP> > q;
  bool cost[1<<n][m];
  float c;
  int d,t,l,i,j;
  edge e;
  memset(cost,0,sizeof(cost));
  q.push(PP(0,P(s,0)));
  while(!q.empty()){
    PP p = q.top(); q.pop();
    c=p.first;
    d=p.second.first;
    t=p.second.second;
    if(d==g)return c;
    if(cost[t][d])continue;
    cost[t][d]=true;
    rep(i,v[d].size()){
      e=v[d][i];
      rep(j,n){
        if((t&(1<<j))==0){
          l=t|(1<<j);
          if(cost[l][e.t])continue;
          q.push(PP(c+e.c/T[j],P(e.t,l)));
        }
      }
    }
  }
  return INFTY;
}
int main(void)
{
  int n,m,p,a,b,i,f,t,c;
  float res;
  edge e;
  for(;;){
    scanf("%d%d%d%d%d",&n,&m,&p,&a,&b); if(!n)break;
    a--; b--;
    rep(i,n)scanf("%f",T+i);
    rep(i,p){
      scanf("%d%d%f",&f,&t,&e.c); f--;t--;
      e.t=t; v[f].push_back(e);
      e.t=f; v[t].push_back(e);
    }
    res=dijkstra(n,m,a,b);
    if(res>=INFTY-1)puts("Impossible");
    else printf("%.3f\n",res);
    rep(i,m)v[i].clear();
  }
  return 0;
}

Measured memory_bytes: 4476
#include <bits/stdc++.h>
using namespace std;
int main()
{
    string s,t; cin >> s>> t;
    int m=s.size();
    int n=t.size();
    int a[n+1][m+1];
    for(int i=0;i<=n;i++)
    {
        a[i][0]=0;
    }
    for(int i=0;i<=m;i++)
    {
        a[0][i]=0;
    }
    for(int i=1;i<=n;i++)
    {
        for(int j=1;j<=m;j++)
        {
            if(t[i-1]==s[j-1])
            {
                a[i][j]=a[i-1][j-1]+1;
            }
            else
            {
                a[i][j]=max(a[i-1][j-1],max(a[i][j-1],a[i-1][j]));
            }
        }
    }
    string p;
    int i=n,j=m;
    while(i>0 && j>0)
    {
        if(t[i-1]==s[j-1])
        {
            p=p+s[j-1];
            i--;
            j--;
        }
        else if(a[i][j-1]>a[i-1][j])
        {
            j--;
        }
        else
        {
            i--;
        }
    }
    reverse(p.begin(),p.end());
    cout << p;
}

Measured memory_bytes: 35456
using System;
using System.Linq;
using System.Collections.Generic;

namespace a
{
    class Program
    {
        static void Main(string[] args)
        {
            var s = Console.ReadLine().Split().Select(i => int.Parse(i)).ToArray();

            var d = new Dictionary<int,int>();
            foreach(var i in s){
                if(d.ContainsKey(i)){
                    d[i] += 1;
                }else{
                    d.Add(i,1);
                }
            }

            var ans = d.Where(t => t.Value == 1).First().Key;
            Console.WriteLine(ans);
        }
    }
}


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

using namespace std;

#define MOD 10000

int a[101];

int dp[101][4][4];

int n, k;

int rec(int day, int pp, int p)
{
    if (day > n) return 1;

    if (dp[day][pp][p] >= 0) return dp[day][pp][p];

    int res = 0;

    if (a[day]) {
        if (a[day] != pp || a[day] != p) {
            res = rec(day + 1, p, a[day]);
            res %= MOD;
        }
    } else {
        for (int i = 1; i <= 3; ++i) {
            if (pp == p && p == i) continue;
            res += rec(day + 1, p, i);
            res %= MOD;
        }
    }

    return dp[day][pp][p] = res;
}

int main()
{
    cin >> n >> k;

    for (int i = 0; i < k; ++i) {
        int day; cin >> day;
        cin >> a[day];
    }

    memset(dp, -1, sizeof(dp));

    printf("%d\n", rec(1, 0, 0));
}

Measured memory_bytes: 1156