akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Text;

class Program
{
    static void Main(string[] args)
    {
        string s = Console.ReadLine();
        string t =Console.ReadLine();
        char[] cs = s.ToCharArray();
        char[] ct = t.ToCharArray();
        List<string> sarray = new List<string>();
     

        for (int i = 0; i < cs.Length - ct.Length + 1; i++)
        {
            if(match(ct,cs,i))
            {
                char[] ans = new char[cs.Length];
                cs.CopyTo(ans,0);

                for (int j = i; j < i+ct.Length;j++)
                {
                    ans[j] = ct[j - i];
                }

                for (int j = 0; j < ans.Length;j++)
                {
                    if (ans[j] == '?') ans[j] = 'a';
                }

                sarray.Add(new String(ans));
            }
        }

        sarray.Sort();

        if (sarray.Count == 0)
        {
            Console.WriteLine("UNRESTORABLE");
        }
        else
        {
            Console.WriteLine("{0}", sarray[0]);
        }
    }

    static bool match(char[] ct,char[] cs,int k)
    {

        for (int i = 0; i < ct.Length; i++)
        {
            if (cs[i + k] != '?' && cs[i + k] != ct[i]) return false;
			
		}

        return true;
    }
}


Measured memory_bytes: 13408
#!/usr/bin/env python3

N = int(input().split()[0])
s = input()
c = 0

for i, ch in enumerate(s):
    if i + 3 > len(s):
        break

    sub = s[i : i + 3]
    if sub == "ABC":
        c += 1
ans = c
print(ans)


Measured memory_bytes: 2940
#include <stdio.h>
#include <math.h>
#include <iostream>
#include <algorithm>
#include <vector>
#include <numeric>
#include <string>
#include <map>
#include <bitset>
#include <stack>
//#include <bits/stdc++.h>
using namespace std;
typedef long long int lli;
#define urept(soeji, start, n) for (int soeji = start; soeji < n; soeji++)
#define drept(soeji, start, n) for (int soeji = start; soeji > n; soeji--)

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

int main(void)
{
    string s, t;
    cin >> s >> t;
    int N = s.length();
    int K = t.length();
    int cnt = 0;
    int ans = t.length();
    for (int i = 0; i < N - K + 1; i++)
    {
        for (int j = 0; j < K; j++)
        {
            if (s[i + j] != t[j])
            {
                cnt++;
            }
        }
        ans = min(ans, cnt);
        cnt = 0;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3640
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.HashSet;
import java.util.Set;

public class Main {
	public static void main(String[] args) throws Exception {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String[] sa = br.readLine().split(" ");
		int h = Integer.parseInt(sa[0]);
		int w = Integer.parseInt(sa[1]);
		int m = Integer.parseInt(sa[2]);

		int[] a = new int[m];
		int[] b = new int[m];
		int[] x = new int[h];
		int[] y = new int[w];
		for (int i = 0; i < m; i++) {
			sa = br.readLine().split(" ");
			a[i] = Integer.parseInt(sa[0]) - 1;
			b[i] = Integer.parseInt(sa[1]) - 1;
			x[a[i]]++;
			y[b[i]]++;
		}
		br.close();

		int xx = 0;
		for (int i = 0; i < x.length; i++) {
			xx = Math.max(xx, x[i]);
		}
		Set<Integer> sx = new HashSet<>();
		for (int i = 0; i < x.length; i++) {
			if (x[i] == xx) {
				sx.add(i);
			}
		}

		int yy = 0;
		for (int i = 0; i < y.length; i++) {
			yy = Math.max(yy, y[i]);
		}
		Set<Integer> sy = new HashSet<>();
		for (int i = 0; i < y.length; i++) {
			if (y[i] == yy) {
				sy.add(i);
			}
		}

		int cnt = 0;
		for (int i = 0; i < m; i++) {
			if (sx.contains(a[i]) && sy.contains(b[i])) {
				cnt++;
			}
		}
		if ((long) sx.size() * sy.size() == cnt) {
			System.out.println(xx + yy - 1);
		} else {
			System.out.println(xx + yy);
		}
	}
}


Measured memory_bytes: 88936
#include <bits/stdc++.h>
using namespace std;
bool cmp(pair<int, int>a, pair<int, int>b){
	return a.first+a.second>b.first+b.second;
}
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	int n;
	cin>>n;
	vector<pair<int, int>>v1, v2;
	int tot=0;
	for(int i=0;i<n;i++){
		string s;
		cin>>s;
		int cnt=0, mini=0;
		for(int j=0;j<s.size();j++){
			if(s[j]=='(') cnt++;
			else cnt--;
			mini=min(mini, cnt);
		}
		tot+=cnt;
		if(cnt>=0) v1.push_back({-mini, cnt});
		else v2.push_back({-mini, cnt});
	}
	if(tot!=0){
		cout<<"No";
		return 0;
	}
	sort(v1.begin(), v1.end());
	sort(v2.begin(), v2.end(), cmp);
	int cur=0;
	for(int i=0;i<v1.size();i++){
		if(v1[i].first>cur){
			cout<<"No";
			return 0;
		}
		cur+=v1[i].second;
	}
	//cout<<v1.size()<<endl;
	for(int i=0;i<v2.size();i++){
		if(v2[i].first>cur){
			cout<<"No";
			return 0;
		}
		cur+=v2[i].second;
	}
	cout<<"Yes";
}

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

using namespace std;

#define lli long long int
#define REP(i,s,n) for(int i=s;i<n;i++)
#define MOD 1000000007
#define NUM 2520
#define INF (1LL<<50)
#define DEBUG 0
#define mp(a,b) make_pair(a,b)
#define SORT(V) sort(V.begin(),V.end())
#define PI (3.141592653589794)

signed main(){

    lli a[4];
    REP(i,0,4){
        cin>>a[i];
    }

    a[1]=min(a[0]*2,a[1]);
    a[2]=min({a[0]*4,a[1]*2,a[2]});
    a[3]=min({a[0]*8,a[1]*4,a[2]*2,a[3]*1});

    lli n;
    cin>>n;

    n*=4;
    lli cost=0;

    cost+=(n/8)*a[3];
    n%=8;
    cost+=(n/4)*a[2];
    n%=4;
    cost+=(n/2)*a[1];
    n%=2;
    cost+=(n/1)*a[0];
    n%=1;
    cout<<cost<<endl;

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <iomanip>
#include <stdio.h>
#include <queue>
#include <string.h>
#define endl '\n'
#define pb push_back
#define mp make_pair
#define LL long long
#define INF 0x3f3f3f3f
#define Inf 1000000000000000000LL
#define F first
#define S second
using namespace std;
typedef pair<int,int>pii;
int main(){
	int a,b,c;
	cin>>a>>b>>c;
	if(a==b&&b==c)return puts("No"),0;
	if(a==b||b==c||c==a)return puts("Yes"),0;
	return puts("No"),0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
 
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
#define int ll
#define fi first
#define se second
#define SORT(a) sort(a.begin(),a.end())
#define rep(i,n) for(int i = 0;i < (n) ; i++) 
#define REP(i,n) for(int i = 0;i < (n) ; i++) 
#define MP(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define INF LLONG_MAX/2
#define all(x) (x).begin(),(x).end()
#define debug(x) cerr<<#x<<": "<<x<<endl
#define debug_vec(v) cerr<<#v<<":";rep(i,v.size())cerr<<" "<<v[i];cerr<<endl
/*----------------------------------------------------------------*/

// int MOD = 998244353;
int MOD = 1000000007;


/*----------------------------------------------------------------*/
signed main(){

    int n;
    cin >> n;
    vector<double> x(n),y(n);
    rep(i,n)cin >> x[i] >> y[i];

    vll s(n);
    rep(i,n)s[i] = i;

    double ans = 0;
    do{
        rep(i,n-1){
            ans += sqrt((x[s[i]]-x[s[i+1]])*(x[s[i]]-x[s[i+1]]) + (y[s[i]]-y[s[i+1]])*(y[s[i]]-y[s[i+1]]));
        }
    }while(next_permutation(all(s)));
    rep(i,n)ans /= i+1;
    printf("%0.10lf\n",ans);

    
	return 0;
}
/*----------------------------------------------------------------*/

// g++ -std=c++14 code1.cpp
// sudo pip3 install --upgrade online-judge-tools
// rm -r -f test;oj dl https://code-festival-2018-quala.contest.atcoder.jp/tasks/code_festival_2018_quala_c
// rm -r -f test;oj dl https://pakencamp-2019-day3.contest.atcoder.jp/tasks/pakencamp_2019_day3_c
// rm -r -f test;oj dl https://abc145.contest.atcoder.jp/tasks/abc145_c

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
int main(void)
{
    int x[100], i, n, p, sum[100], min;
    scanf("%d", &n);
    for (i = 0; i < 100; i++)
    {
        sum[i] = 0;
    }
    for (i = 0; i < n; i++)
    {
        scanf("%d", &x[i]);
    }
    for (p = 0; p < 100; p++)
    {
        for (i = 0; i < n; i++)
        {
            sum[p] += (int)pow(x[i] - p, 2.0);
        }
    }
    min = sum[0];
    for (p = 0; p < 100; p++)
    {
        if (abs(sum[p]) < min)
        {
            min = sum[p];
        }
    }
    printf("%d\n", min);
    return 0;
}


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

int main(){
    int a[3];
    int x;
    cin >> a[0] >> a[1] >> a[2];
    if(a[0] > a[1]){
        x = a[1];
        a[1] = a[0];
        a[0] = x;
    }if(a[1] > a[2]){
        x = a[2];
        a[2] = a[1];
        a[1] = x;
    }if(a[0] > a[1]){
        x = a[1];
        a[1] = a[0];
        a[0] = x;
    }
    cout << a[0] << " " << a[1] << " " << a[2] << endl;
}


Measured memory_bytes: 3104
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <bits/stdc++.h>
using namespace std;
char s[201010]={0};
int main()
{
    int a[3];
    cin >> a[0] >> a[1] >> a[2];
    sort(a,a+3);
    cout << a[0] +a[1] << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define erep(i, n) for (ll i = 0; i <= (ll)(n); ++i)
#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)
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } }


struct Edge {
    ll to;
    ll weight;
    Edge(ll t, ll w) : to(t), weight(w) { }
};
using Graph = vector<vector<Edge>>;


int main() {
    int n; cin >> n;
    Graph G(n);
    rep(i, n-1) {
        ll a,b,c; cin >> a >> b >> c;
        a--;
        b--;
        G[a].emplace_back(b, c);
        // 無向グラフなので逆も
        G[b].emplace_back(a, c);
    }
    queue<int> que;
    que.push(0);
    vector<bool> seen(n, false);
    seen[0] = true;
    vector<int> color(n, -1);
    color[0] = 0;
    while(!que.empty()) {
        int u = que.front();
        que.pop();
        for(Edge e : G[u]) {
            int v = e.to;
            // 繋ぐ先がまだ見てなければ、queueに追加する
            if(!seen[v]) {
                if(e.weight%2 == 1) {
                    // 距離が奇数なら別の色
                    if(color[u] == 0) color[v] = 1;
                    else color[v] = 0;
                } else {
                    // 距離が偶数だったら同じ色
                    color[v] = color[u];
                }
                que.push(v);
                seen[v] = true;
            }
        }
    }
    rep(i, n) {
        cout << color[i] << endl;
    }

    return 0;
}



Measured memory_bytes: 8320
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <set>
#include <queue>
#include <stack>
#include <tuple>
#include <cmath>
#include <iomanip>
#include <map>
#include <stdio.h>
#include <cstring> //memset(dp,0,sizeof(dp))
#include <functional>
#define ll long long
#define rep(i,n) for(int i=0;i<(n);i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define fi first
#define se second
#define pb push_back
#define ALL(a) (a).begin(),(a).end()
using namespace std;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}
typedef pair<int,int> P;
typedef pair<ll,ll> Pll;
//小数点以下　cout << fixed << setprecision(10) << num << endl;
//桁数はlog10(mid)でやれ　log(mid)/log(10)はWA
//long*long<0で判定するな
//開区間と閉区間
//アルファベットが何番目かは x=s[i]-'a'
//bfsはmain()内で　rep(i,h)rep(j,w)rep(i,4)でバグ
//切り上げ：(a+(b-1))/b
//32bit以上は 1ull<<j
// map 初期値0 for(auto itr=mp.begin();itr!=mp.end();++itr) itr->fi itr->se で全探索
// for(auto u:mp) u.fi u.se も可能
//n個のgcd,lcmは一つずつみて更新していく
//大きな数を扱うときは素因数分解した形で持っておく
// (l/a[i]) = l*powmod(a[i],MOD-2)%MOD;
//auto itr=lower_bound(ALL(a),key) a[itr-a.begin()]
const ll MOD = 1000000007;

signed main(){
    int n; cin >> n;
    int a[n];
    ll sum[n];
    rep(i,n){
        cin >> a[i];
        if(i==0){
            sum[0]=a[0];
            continue;
        }
        sum[i]=sum[i-1]+a[i];
    }
    int r[n],l[n];
    //iで切るときの最適
    int j=0;
    int k=2;
    for(int i=1;i<n-2;i++){
        while(1){
            if(sum[j]>sum[i]-sum[j]){
                if(j==0){
                    l[i]=j;
                    break;
                }
                if(llabs(2*sum[j]-sum[i])<llabs(2*sum[j-1]-sum[i])){
                    l[i]=j;
                    break;
                }else{
                    j--;
                    l[i]=j;
                    break;
                }
            }
            j++;
        }
        while(1){
            if(2*(sum[k]-sum[i])>sum[n-1]-sum[i]){
                if(k==2){
                    r[i]=k;
                    break;
                }
                if(llabs(2*(sum[k]-sum[i])-(sum[n-1]-sum[i]))<llabs(2*(sum[k-1]-sum[i])-(sum[n-1]-sum[i]))){
                    r[i]=k;
                    break;
                }else{
                    k--;
                    r[i]=k;
                    break;
                }
            }
            k++;
        }
    }
    ll ans=1001001001;
    for(int i=1;i<n-2;i++){
        //cout << l[i] << " "<<r[i]<<endl;
        ll b=sum[l[i]];
        ll c=sum[i]-b;
        ll d=sum[r[i]]-sum[i];
        ll e=sum[n-1]-sum[r[i]];
        ll maa=max(b,max(c,max(d,e)));
        ll mii=min(b,min(c,min(d,e)));
        chmin(ans,maa-mii);
    }
    cout << ans << endl;
    
}


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

int main() {
  int H, N;
  cin >> H >> N;
  
  vector<int> A(N);
  for(int i =0;i < N;i++){
    cin >> A.at(i);
  }
    
  for(int i = 0;i < N;i++){
    H -= A.at(i);
    if(H <= 0){
      break;
    }
  }
  
  if(H > 0){
    cout << "No" << endl;
  } else {
    cout << "Yes" << endl;
  }
  
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int,int>;




int main() {
    int n;
    scanf("%d", &n);
    int ans = 0;
    for (int i = 1; i <= n; ++i) {
        for (int j = 1; j <= n; ++j) {
            for (int k = 1; k <= n; ++k) {
                ans++;
            }
        }
    }
    printf("%d\n", ans);
    return 0;
}



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

#define ll long long
#define all(it) it.begin(), it.end()
#define FOR(i, n) for(int i = 0; i < n; i++)
#define FORU(i, a, b, s) for(int i = a; i < b; i += s)
#define FORD(i, a, b, s) for(int i = a; i > b; i -= s)
#define endl "\n"

ll INF = 2e18;
ll MOD = 1e9 + 7;
int i, j, k, t;

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

    if(X == 7 || X == 5 || X == 3) {
        cout << "YES" << endl;
    } else {
        cout << "NO" << endl;
    }
}


Measured memory_bytes: 3596
MOD = 10**9 + 7

def f(n):
    res = 1
    for i in range(1, n+1):
        res *= i
        res %= MOD
    return res


def H(n, r):
    n = n + r - 1
    return f(n) * pow(f(n - r), MOD - 2, MOD) * pow(f(r), MOD - 2, MOD) % MOD


S = int(input())
n = S // 3
r = S - 3*n
ans = 0
while n:
    ans += H(n, r)
    ans %= MOD
    n -= 1
    r += 3

print(ans)

Measured memory_bytes: 67648
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int n = in.nextInt();
		ArrayList<String> list = new ArrayList<>();
		
		for ( int i = 0; i < n; i++ ) {
			char[] s = in.next().toCharArray();
			Arrays.sort(s);
			String str = new String(s);
			list.add(str);
		}
		
		Map<String, Integer> map = new HashMap<>();
		for (String s : list) {
		    Integer i = map.get(s);
		    map.put(s, i == null ? 1 : i + 1);
		}
		long cnt = 0;
		
		for ( Entry<String, Integer> en : map.entrySet() ) {
			Integer n1 = en.getValue();
			cnt += nCr(n1, 2);			
		}
		
		System.out.println(cnt);
		in.close();
	}
	
	private static long nCr(int n, int r) {
		if ( r == 0 ) return 1;
		return n * nCr(n - 1, r - 1) / r;
	}
}

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

int main(){
	int h[9],m[9],s[9];
	int a;
	for(a=0;a<=2;a++){
		scanf("%d %d %d %d %d %d",&h[a*3],&m[a*3],&s[a*3],&h[a*3+1],&m[a*3+1],&s[a*3+1]);
		h[a*3+2]=0,m[a*3+2]=0,s[a*3+2]=0;
	}
	for(a=0;a<=2;a++){
		if(s[a*3+1]>=s[a*3])s[a*3+2]+=s[a*3+1]-s[a*3];else s[a*3+2]+=60+s[a*3+1]-s[a*3],m[a*3+2]-=1; 
		if(m[a*3+1]>=m[a*3])m[a*3+2]+=m[a*3+1]-m[a*3];else m[a*3+2]+=60+m[a*3+1]-m[a*3],h[a*3+2]-=1;
		if(h[a*3+1]>=h[a*3])h[a*3+2]+=h[a*3+1]-h[a*3];else h[a*3+2]+=24+h[a*3+1]-h[a*3];
	}
	for(a=0;a<=2;a++)printf("%d %d %d\n",h[a*3+2],m[a*3+2],s[a*3+2]);
	return 0;
}

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

using namespace std;

#define int long long
//#define endl '\n'
#define maxn 100010
const int MOD = 1000000007;

void solve() {
    string s;
    cin >> s;

    for (auto &x: s)if (x == '?')x = 'D';
    int ans = 0;
    cout << s << endl;
//    for (int i = 0; i < s.size(); i++) {
//        if (i + 1 < s.size() and s.substr(i, 2) == "PD") {
//            ans++;
//        }
//        if (s[i] == 'D')ans++;
//    }
//    cout << ans << endl;
}

int32_t main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);

    int t = 1;
//    cin >> t;

    while (t--)
        solve();
    return 0;
}

Measured memory_bytes: 3692
#include<iostream>
#include <iomanip>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <cstdlib>

using namespace std;
int main(){

  double a,b,c;

  cin >> a >> b >> c;
  cout << setprecision(15) << a*b*sin(c * M_PI / 180.0)/2 << endl;
  cout << setprecision(15) << (a+b+ sqrt(pow(a,2)+pow(b,2)-2*a*b*cos(c * M_PI / 180.0))) << endl;
  cout << setprecision(15) << b*sin(c * M_PI / 180.0) <<  endl;

}





Measured memory_bytes: 3488
#include <iostream>
#include <sstream>
#include <fstream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <utility>
#include <bitset>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cstdio>
#include <stdio.h>
#include <string.h>
#include <cassert>

using namespace std;

static const double EPS = 1e-9;
template<class T> bool INRANGE(T x, T a, T b) { return a <= x && x <= b; }
template<class T> void amin(T &a, T v) { if (a > v) a = v; }
template<class T> void amax(T &a, T v) { if (a < v) a = v; }
int ROUND(double x) { return (int)(x + 0.5); }
bool ISINT(double x) { return fabs(ROUND(x) - x) <= EPS; }
bool ISEQUAL(double x, double y) { return fabs(x - y) <= EPS * max(1.0, max(fabs(x), fabs(y))); }
double SQSUM(double x, double y) { return x * x + y * y; }
#define PI  (acos(-1))
#define ARRAY_NUM(a) (sizeof(a)/sizeof(a[0])) 
#define NG (-1)
#define BIG ((int)1e9+10)
#define BIGLL ((ll)4e18)
#define SZ(a) ((int)(a).size())
#define SQ(a) ((a)*(a))
typedef unsigned long long ull;
typedef long long ll;

int main() 
{
	int N;
	string s[3];
	cin >> N >> s[0] >> s[1] >> s[2];

	int ans = 0;
	for (int i = 0; i < N; ++i)
	{
		if (s[0][i] != s[1][i] && s[1][i] != s[2][i] && s[2][i] != s[0][i])
		{
			ans += 2;
		}
		else if (s[0][i] == s[1][i] && s[1][i] == s[2][i])
		{
			ans += 0;
		}
		else
		{
			ans += 1;
		}

	}

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < n; i++)
#define per(i,n) for(int i = n-1; i >= 0; i--)
typedef long long ll;
typedef pair<int, int> P;
typedef pair<long long, long long> Pll;
typedef vector<int> vi;
typedef vector<ll> vll;

ll dp[3300][3300];

int main() {
  ll n;
  cin >> n;
  vll a(n);
  rep(i,n) cin >> a.at(i);
  rep(i,n) dp[i][i] = 0;
  for(ll width = 1; width <= n; width++) {
    for(ll l = 0; l + width <= n; l++) {
      ll r = l + width;
      if(width%2 == n%2) {
        dp[l][r] = max(dp[l+1][r]+a[l],dp[l][r-1]+a[r-1]);
      }
      else dp[l][r] = min(dp[l+1][r]-a[l],dp[l][r-1]-a[r-1]);
    }
  }
  cout << dp[0][n] << endl;
  return 0;
}

Measured memory_bytes: 78080
#include<iostream>
#include<algorithm>
#include<string>
using namespace std;
int N_MAX = 200000;
int main()
{
  int n,t,i,res=1;
  string s[N_MAX];
  cin >> n;
  for(i=0;i<n;i++)
    cin >> s[i];
  sort(s,s+n);
  for(i=1;i<n;i++)
    if(s[i]!=s[i-1])
      res++;
  cout << res << endl;
  return 0;
}

Measured memory_bytes: 7924
#coding:utf-8
import math

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

if(int(math.log(n,k)) != math.log(n,k)):
  t1 = math.ceil(math.log(n,k))
else:
  t1 = math.ceil(math.log(n,k)) + 1

print("{}".format(t1))

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

int main() {
  int n;
  cin >> n;
  vector<int> l(n);
  for(int i=0; i<n; i++) cin >> l[i];
  
  sort(l.begin(),l.end());
  int sum=0;
  for(int i=0; i<n-1; i++) sum+=l[i];
  
  if(sum>l[n-1]) cout << "Yes" << endl;
  else cout << "No" <<endl;
}

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

class UnionFind {
private:
    vector<int> par;
    vector<int> rank;

public:
    UnionFind(int n) {
        par.resize(n);
        rank.resize(n);
        for (int i = 0; i < n; i++) {
            par[i] = i;
            rank[i] = 0;
        }
    }

    int find(int x) {
        if (par[x] == x) {
            return x;
        }
        return par[x] = find(par[x]);
    }

    void unite(int x, int y) {
        x = find(x);
        y = find(y);
        if (x == y) return;

        if (rank[x] < rank[y]) {
            par[x] = par[y];
        } else {
            par[y] = par[x];
            if (rank[x] == rank[y]) rank[x]++;
        }
    }

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

int main() {
    int N, M;
    cin >> N >> M;
    vector<int> P(N);
    for (int i = 0; i < N; i++) {
        cin >> P[i];
        P[i]--;
    }
    UnionFind uf = UnionFind(N);
    for (int i = 0; i < M; i++) {
        int x, y;
        cin >> x >> y;
        x--; y--;
        uf.unite(x, y);
    }

    int res = 0;
    for (int i = 0; i < N; i++) {
        if (uf.same(i, P[i])) res++;
    }

    cout << res << endl;
    return 0;
}

Measured memory_bytes: 1408
#include<bits/stdc++.h> 
using namespace std; 
#define ll long long
#define pii pair<int,int>
#define ff first
#define ss second
#define vi vector<int>
#define fo(n) for(int i = 0;i < int(n);i++)
#define foo(a,b) for(int i = int(a);i <= int(b);i++)
#define mk make_pair
#define pb push_back
#define MAXN 1000
#define mod 1000000007
#define all(x) x.begin(),x.end()
#define fastio ios_base:: sync_with_stdio(false)
#define inf (int)1e9
int dp[MAXN][MAXN];
vector<string> arr(MAXN);

ll sol(int r,int c){
	if(dp[r][c] != -1) return dp[r][c];

	ll tw = 0;

	if(r-1 >= 0 && arr[r-1][c] == '.')
		tw = (tw + sol(r-1,c))%mod;

	if(c-1 >= 0 && arr[r][c-1] == '.')
		tw = (tw + sol(r,c-1))%mod;

	dp[r][c] = tw;
	return tw;
}

int main(){
	
	fastio;
	int n,m;
	cin >> n >> m;

	fo(n) cin >> arr[i];

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

	dp[0][0] = 1;
	ll ans = sol(n-1,m-1);

	cout << ans%mod << endl;

	return 0;
 }	

Measured memory_bytes: 5376
#include <cstdio>
#include <algorithm>

const int MN = 200005;

int N, M, A[MN], Ans;

inline bool check(int pos) {
	int Now = 0;
	for (int i = 1; i <= pos; ++i)
		Now = std::max(Now, A[i] + A[2 * pos - i + 1]);
	for (int i = 1; i <= N - pos; ++i) {
		int v = A[2 * pos + i] + A[2 * N - i + 1];
		if (v < M) return 0;
		Now = std::max(Now, v - M);
	}
	Ans = std::min(Ans, Now);
	return 1;
}

int main() {
	scanf("%d%d", &N, &M), Ans = M;
	for (int i = 1; i <= 2 * N; ++i) scanf("%d", &A[i]);
	std::sort(A + 1, A + 2 * N + 1);
	int l = 0, r = N, mid;
	while (l <= r) {
		mid = (l + r) >> 1;
		if (check(mid)) r = mid - 1;
		else l = mid + 1;
	}
	printf("%d\n", Ans);
	return 0;
}

// Luogu : PinkRabbit

Measured memory_bytes: 896
#include "bits/stdc++.h"
using namespace std ;

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

typedef long long ll ;
typedef long double ldb ;

#define mp make_pair
#define pb push_back
#define F first
#define S second
#define nl '\n'

#define all( x ) x.begin(),x.end() 
#define sz( x ) ( int )( x ).size( )
#define mem( a, val ) memset(a, val, sizeof( a ) )
#define deci( x ) cout<<fixed<<setprecision( x );
#define bitcount( x ) __builtin_popcountll( x )

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

const int MAX = 2*1000*1000 + 10 ;
const ll INF = 1e18 ;
const int MOD = 1e9 + 7 ;

void sol( ){
    string s ;
    cin >> s; 
    if(s.back()=='s')
        s += "es" ;
    else
        s += 's' ;
    cout << s << nl ;
}

signed main( ){
  timesaver ;
//  int t = 1 ; cin >> t ; while(t--)
  {
      sol( );
  }
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
#define err(args...) {}
#ifdef DEBUG
#include "_debug.cpp"
#endif
using namespace std;
using ll = long long;
using ld = long double;
template <typename T> using lim = numeric_limits<T>;
template <typename T> istream& operator>>(istream& is, vector<T>& a) { for(T& x : a) { is >> x; } return is; }
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int n, m, c;
    cin >> n >> m >> c;
    vector<int> b(m);
    cin >> b;
    vector<vector<int>> a(n, vector<int>(m));
    cin >> a;
    int ans = 0;
    for(int i = 0; i < n; i++) {
        int s = c;
        for(int j = 0; j < m; j++) {
            s += a[i][j] * b[j];
        }
        ans += s > 0;
    }
    cout << ans << endl;
    return 0;
}


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

string s[5];
int main(){
  for(int i=0;i<3;i++){ 
    cin >> s[i];
    transform(s[i].begin(), s[i].end(), s[i].begin(), ::toupper);
    cout << s[i].substr(0,1);
  }
  cout << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
int N;
  cin>>N;
  vector<int>A(N);
  for(int i=0;i<N;i++)
    cin>>A.at(i);
  int ans=1;
  int a=1;
  for(int i=1;i<N;i++){
   if(A.at(i-1)<A.at(i)){
    if(a==1)
    a=0;
    else if(a==2){
      ans++; a=1;
    }else
      a=0;
   }
   if(A.at(i)<A.at(i-1)){
    if(a==1)
    a=2;
    else if(a==0){
      ans++; a=1;
    }else
      a=2;
   }
  }cout<<ans<<endl;
   return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define x first
#define y second
using namespace std;
typedef long long ll;
const int MAXN = 100500;


bool arr[MAXN];
int n;


int check(string s, char c)
{
	n = s.size();
	bool ok = false;
	for (int i = 0; i < n; i++)
		ok |= arr[i] = s[i] == c;

	if (!ok)
		return MAXN;

	int last_pos = -1;

	int res = -1;

	for (int i = 0; i < n; i++)
	{
		if (arr[i])
		{
			res = max(res, i - last_pos - 1);
			last_pos = i;
		}
	}
	res = max(res, n - last_pos - 1);
	return res;
}

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

	string s;
	cin >> s;
	int res = MAXN;

	for (char c = 'a'; c <= 'z'; c++)
	{
		res = min(res, check(s, c));
	}

	cout << res << '\n';
	
	return 0;
}


Measured memory_bytes: 256
N = int(input())
A = list(map(int,input().split()))
total = abs(A[0])+abs(A[N-1])
for i in range(N-1):
  total += abs(A[i+1]-A[i])

#print(total)
for i in range(N):
  if i == 0:
    temp = -abs(A[0]-0)-abs(A[0]-A[1])+abs(A[1]-0)
    #print(temp)
  elif i == N-1:
    temp = -abs(A[i]-0)-abs(A[i]-A[i-1])+abs(A[i-1]-0)
  else:
    temp = -abs(A[i]-A[i-1])-abs(A[i]-A[i+1])+abs(A[i+1]-A[i-1])
  ans = total+temp
  print(ans)

Measured memory_bytes: 20560
#include<iostream>
#include<cctype>
#include<queue>
#include<cstdio>
#include<cmath>
#include<sstream>
#include<string>
#include<algorithm>
#include<cstring>
#include<vector>
#include<ctime>
#include<cstdlib>
#include<map>
#include<utility>
#include<iomanip>
#include<set>
#include<stack>
//#include<Windows.h>
using namespace std;
typedef long long ll;typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vii;typedef vector<pii> vpi;
typedef vector<ll> vll;typedef vector<pll> vpl;
typedef queue<int> qii;typedef queue<pii> qpi;
qii q;
int n,k,a,b,ans=50000,dis[2005];
vii v[2005];
bool vis[2005];
void bfs(){
	while(!q.empty()){
		int u=q.front();q.pop();
//		cout<<u<<' ';
		for(int i=0;i<v[u].size();i++){
				if(vis[v[u][i]]) continue;
				if(dis[v[u][i]]<=dis[u]+2) continue;
				vis[v[u][i]]=true;
				dis[v[u][i]]=dis[u]+2;
				q.push(v[u][i]);
		}
	}
//	cout<<endl;
}
int solve1(int u){
	int res=0;
	fill(dis,dis+n+1,5000);
	memset(vis,false,sizeof(vis));
	while(!q.empty()) q.pop();
	q.push(u);vis[u]=true;
	dis[u]=0;
	bfs();
	for(int i=1;i<=n;i++)
		if(dis[i]>k)
			res++;
	return res;
}
int solve2(int u,int v){
	int res=0;
	fill(dis,dis+n+1,5000);
	memset(vis,false,sizeof(vis));
	while(!q.empty()) q.pop();
	q.push(u);q.push(v);vis[u]=true;vis[v]=true;
	dis[u]=0,dis[v]=0;
	bfs();
	for(int i=1;i<=n;i++)
		if(dis[i]>k)
			res++;
	return res;
}
int main()
{
// 	freopen("shorten diameter.txt","r",stdin);
	cin>>n>>k;
	for(int i=0;i<n-1;i++){
		cin>>a>>b;
		v[a].push_back(b);
		v[b].push_back(a);
	}
	if(k%2==0)	
		for(int i=1;i<=n;i++)
			ans=min(ans,solve1(i));
	else
		for(int i=1;i<=n;i++)
			for(int j=0;j<v[i].size();j++)
				if(v[i][j]>i)
					ans=min(ans,solve2(i,v[i][j]));
	cout<<ans<<endl;
	return 0;
}

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

int main()
{
	int H, W;
	scanf("%d%d", &H, &W);
	using vi = std::vector<int>;
	using vvi = std::vector<vi>;
	using vvvi = std::vector<vvi>;
	vvi number(H + 1, vi(W + 1));
	for (int i{1}; i <= H; i++)
		for (int j{1}; j <= W; j++)
		{
			int A;
			scanf("%d", &A);
			number[i][j] = A;
		}
	for (int i{1}; i <= H; i++)
		for (int j{1}; j <= W; j++)
		{
			int A;
			scanf("%d", &A);
			number[i][j] -= A;
			number[i][j] = std::abs(number[i][j]);
		}
	constexpr int center{80 * 80 * 80};
	using vbs = std::vector<std::bitset<center * 2 + 1>>;
	using vvbs = std::vector<vbs>;
	vvbs dp(2, vbs(W + 1));
	dp[0][1][center] = true;
	for (int i{1}; i <= H; i++)
	{
		for (int j{1}; j <= W; j++)
		{
			dp[1][j] |= dp[0][j] << number[i][j];
			dp[1][j] |= dp[0][j] >> number[i][j];
			dp[1][j] |= dp[1][j - 1] << number[i][j];
			dp[1][j] |= dp[1][j - 1] >> number[i][j];
			dp[0][j].reset();
			// for (int k{}; k < 2 * center + 1; k++)
			// 	if (dp[1][j][k])
			// 		printf("%d ", k - center);
			// putchar(':');
		}
		// putchar('\n');
		std::swap(dp[0], dp[1]);
	}
	int ans{1 << 30};
	for (int i{}; i < 2 * center + 1; i++)
		if (dp[0][W][i])
			ans = std::min(ans, std::abs(i - center));
	printf("%d\n", ans);

	return 0;
}

Measured memory_bytes: 30720
#include<iostream>
#include<vector>
#include<map>
#include<queue>
#include<functional>
using namespace std;
typedef pair<int,int> P;
int main(){
	int n,p,x,y;
	while(cin>>n,n){
		priority_queue<P> vec;
		for(int i=0;i<n;i++){
			cin>>p>>x>>y;
			vec.push(P(x+y,p));
		}
		P now=vec.top();
		cout<<now.second<<' '<<now.first<<endl;
	}
	return 0;
}

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

int main(){
  int n; cin>>n;
  vector<ll> ra(n+1);
  ra[0]=0;
  rep(i,n){
    ll a; cin>>a;
    ra[i+1]=ra[i]+a;
  }
  ll ans=1001001001001001001;
  for(int i=1; i<=n-1; i++){
    ll now_ans=abs((ra[i]-ra[0])-(ra[n]-ra[i]));
    ans=min(ans,now_ans);
  }
  cout<<ans<<endl;
}

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

ll A;
string B;

int main(){
  cin >> A >> B;
  B.erase(B.begin()+1);
  ll ans = A * stoi(B);
  cout << ans / 100 << endl;
}


Measured memory_bytes: 3640
#include <iostream>
#include <string>
#include <sstream>
#include <iomanip> 
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <queue>
#include <stack>
#include <vector>
#include <map>
#include <set>
#include <functional>
#include <algorithm>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <complex>

using namespace std;

//#pragma GCC optimize("Ofast")
//#pragma GCC optimization("unroll-loops, no-stack-protector")
//#pragma GCC target("avx,avx2,fma")



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

	long long n, x, m, i, j, k, ans, c, ct, a, ss;
	cin >> n >> x >> m;
	vector<long long> last(m, -1), s(m);

	ans = 0;
	ss = 0;
	for (i = 1; i <= n; i++) {
		if (i == 1) a = x;
		else a = (a * a) % m;
		ss += a;

		if (last[a] == -1) {
			last[a] = i;
			ans += a;
			s[a] = ss;
		}
		else {
			c = i - last[a];
			ct = (n - last[a]) / c;
			
			ans = s[a] + ct * (ss - s[a]);
			i = last[a] + ct * c;

			for (j = i + 1; j <= n; j++) {
				a = (a * a) % m;
				ans += a;
			}
			break;
		}
	}

	cout << ans << "\n";


	return 0;
}




Measured memory_bytes: 4756
#include<bits/stdc++.h>
using namespace std;
//
//unsigned int MAX=100000+9;
//int N, dp[100000][3], ns[100000][3];
//int solve(int cur=0, int pre=0){
//    if(cur == N) return 0;
//
//    int &ret=dp[cur][pre];
//    if(ret!=-1) return ret;
//
//    ret=0;
//    for(int i=0;i<3;i++){
//        if(i == pre && cur != 0) continue;
//        ret=max(ret, solve(cur+1, i)+ns[cur][i]);
//    }
//
//    return ret;
//}
//
//int main(){
//    scanf("%d",&N);
//    memset(dp, -1, sizeof(dp));
//    for(int i=0;i<N;i++) for(int j=0;j<3;j++) scanf("%d",&ns[i][j]);
//    printf("%d", solve());
//    return 0;
//}

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

    typedef vector <int> v_int;
    v_int swim_happiness(no_of_days + 1);
    v_int bug_happiness(no_of_days + 1);
    v_int homework_happiness(no_of_days + 1);

    for(int i = 1; i <= no_of_days; i++)
        cin >> swim_happiness[i] >> bug_happiness[i] >> homework_happiness[i];

    const int NO_OF_TYPES = 3;
    vector <v_int> maximum_happiness(no_of_days + 1, v_int(NO_OF_TYPES, 0));

    const int SWIM_TODAY = 0, BUG_TODAY = 1, HOMEWORK_TODAY = 2;
    for(int i = 1; i <= no_of_days; i++)
    {
        maximum_happiness[i][SWIM_TODAY] = swim_happiness[i] + max(maximum_happiness[i - 1][BUG_TODAY], maximum_happiness[i - 1][HOMEWORK_TODAY]);

        maximum_happiness[i][BUG_TODAY] = bug_happiness[i] + max(maximum_happiness[i - 1][HOMEWORK_TODAY], maximum_happiness[i - 1][SWIM_TODAY]);

        maximum_happiness[i][HOMEWORK_TODAY] = homework_happiness[i] + max(maximum_happiness[i - 1][SWIM_TODAY], maximum_happiness[i - 1][BUG_TODAY]);
    }

    int overall_happiness = max(maximum_happiness[no_of_days][SWIM_TODAY], max(maximum_happiness[no_of_days][BUG_TODAY], maximum_happiness[no_of_days][HOMEWORK_TODAY]));

    cout << overall_happiness;
    return 0;
}


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

using namespace std;

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

typedef pair<ll, ll> P;

#define bit(n) (1LL << (n))

//#define int long long

#define all(v) v.begin(), v.end()
#define sortAl(v) sort(all(v))
#define sortAlr(v)          \
  sort(v.begin(), v.end()); \
  reverse(v.begin(), v.end())

#define cout(n) cout << fixed << setprecision(n)

#define rep(i, n) for (ll i = 0; i < n; i++)
#define REP(i, n) for (ll i = 1; i < n; i++)

#define FOR(i, a, b) for (ll i = (a); i < (b); i++)
#define FORm(i, m) for (auto i = m.begin(); i != m.end(); i++)

template <class T>
inline void chmax(T &a, T b) {
  a = std::max(a, b);
}
template <class T>
inline void chmin(T &a, T b) {
  a = std::min(a, b);
}

#define mod (ll)(1e9 + 7)
#define INF LLONG_MAX

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

  ll n, a, b;
  cin >> n >> a >> b;

  cout << min(a * n, b) << endl;

  return 0;
}


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

using namespace std;

#define REP(i,a,b) for(int i = a; i <= b; ++i)
#define PER(i,a,b) for(int i = a; i >= b; --i)
#define MP make_pair
#define PB push_back
#define fi first
#define se second
typedef long long LL;
typedef long double LD;

const int maxn = 1e6;

int n, f[maxn+5], mx[maxn+5], mi[maxn+5];
char ss[maxn+5];

int run(int lim) {
    int mmi = 0, mmx = 0, del = 0;
    for(int i = 1; i <= n; ++i) {
        if(ss[i]=='?' && mx[i]+del+2<=lim)
            del += 2;
        mmi = min(mmi, f[i]+del);
        mmx = max(mmx, f[i]+del);
    }
    return mmx-mmi;
}

int main() {
    scanf("%s", ss+1), n = strlen(ss+1);
    f[0] = 0;
    REP(i,1,n) {
        if(ss[i] == '1') f[i] = 1;
        else f[i] = -1;
        f[i] += f[i-1];
    }
    mx[n] = mi[n] = f[n];
    for(int i = n-1; i >= 0; --i) {
        mx[i] = max(f[i], mx[i+1]);
        mi[i] = min(f[i], mi[i+1]);
    }
    int ans = min(run(mx[0]), run(mx[0]+1));
    printf("%d\n", ans);
    return 0;
}


Measured memory_bytes: 16476
import java.util.*;

public class Main{
  public static void main(String[] args) {
    try {
      Scanner scn = new Scanner(System.in);
      int a, b;

      a = Integer.parseInt(scn.next());
      b = Integer.parseInt(scn.next());

      if(a*b%2 == 1){
       System.out.println("Odd");
      }else if(a*b%2 == 0){
       System.out.println("Even");
      }

    }
    catch (Exception e) {

    }
  }
}


Measured memory_bytes: 21460
#include <bits/stdc++.h>
#define REP(a,b,c) for((a)=(b);(a)<(c);(a)++)

using namespace std;

int main(){
    string d;
    int n;
    string ret="";
    cin >> n;
    cin >> d;
    for(char c : d){
        ret += ((((c - 'A') + n) % 26) + 'A');
    }
    cout << ret << endl;
    return 0;
}

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

using namespace std;

int main()
{
    char conv[128];
    
    conv['2'] = 'k'; conv['3'] = 's'; conv['4'] = 't'; conv['5'] = 'n';
    conv['6'] = 'h'; conv['7'] = 'm'; conv['8'] = 'y'; conv['9'] = 'r';
    conv['0'] = 'w'; conv['T'] = 'a'; conv['L'] = 'i'; conv['U'] = 'u';
    conv['R'] = 'e'; conv['D'] = 'o';
    
    char s[1024];
    
    scanf("%s", s);
    
    for (int i = 0; s[i]; i++){
        if (s[i] == '0' && s[i + 1] == 'U'){
            printf("nn");
            i += 1;
        }
        else if (s[i] != '1') printf("%c", conv[s[i]]);
    }
    printf("\n");
    
    return (0);
}

Measured memory_bytes: 1124
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
int main(void){
  int i,j;
  int n;

  scanf("%d",&n);
  if(n%2==0){
    printf("%d\n",n);
  }else{
    printf("%d\n",2*n);
  }
  return 0;
}


Measured memory_bytes: 128
#include<stdio.h>
#include<math.h>
#include<iostream>
#include<string>
#include<vector>
using namespace std;
int main()
{
	int n, count = 0;
	cin >> n;
	vector<vector<int>> d(n, vector<int>(2));
	for (int i = 0; i < n; i++)
	{
		for (int j = 0; j < 2; j++)
		{
			cin >> d.at(i).at(j);
		}
	}
	for (int k = 0; k < n; k++)
	{
		if (d.at(k).at(0) == d.at(k).at(1))
		{
			count++;
		}
		else if(count<3)
		{
			count = 0;
		}
	}
	if (count >= 3)
	{
		cout << "Yes" << endl;
	}
	else
	{
		cout << "No" << endl;
	}
}

Measured memory_bytes: 3636
import java.util.*;

public class Main {
	public static void main (String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int m = sc.nextInt();
		HashMap<Integer, Integer> map = new HashMap<>();
		map.put(0, 1);
		int prev = 0;
		for (int i = 0; i < n; i++) {
		    prev += sc.nextInt();
		    prev %= m;
		    if (map.containsKey(prev)) {
		        map.put(prev, map.get(prev) + 1);
		    } else {
		        map.put(prev, 1);
		    }
		}
		long total = 0;
		for (int x : map.values()) {
		    total += (long)x * (long)(x - 1) / 2L;
		}
        System.out.println(total);
	}
}


Measured memory_bytes: 63064
n = int(input())
data = [int(s) for s in input().split()]
ini = 1
indData = []
for i in range(len(data)):
  if data[i] == ini:
    ini += 1
    indData.append(i)
ans = 0
if len(indData) == 1:
  if len(data) == 1:
    print(0)
    exit()
  else:
    print(len(data) -1)
    exit()
if len(indData) == 0:
  print(-1)
  exit()
for i in range(len(indData)-1):
  ans += indData[i+1] - indData[i] -1

ans += indData[0]
print(ans)
#print(indData)

Measured memory_bytes: 26140
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<functional>
#include<vector>
#include<queue>
#include<stack>
#include<set>
#include<map>
using namespace std;
#define MOD 1000000007
#define f(i,n) for(long long i=0;i<(long long)(n);i++)
#define N 600000


int main() {
	long long b[N];
	long long c[N];
	long long nex[N];
	set<long long>s;
	map<long long, long long>m;
	long long dp[N];
	long long dp2[N];
	long long a[N];
	long long n, k;
	long long x, y, z;
	long long ans;
	bool v = true;
	ans = 0;
	scanf("%lld", &n);
	f(i, N) {
		a[i] = 0;
		b[i] = 0;
		c[i] = 0;
		nex[i] = 0;
		dp[i] = 0;
		dp2[i] = 0;
	}
	k = 0;
	f(i, n) {
		scanf("%lld", &x);
		a[i + 1] = a[i] ^ x;
		if (a[i + 1] == 0)b[i + 1] = b[i] + 1;
		else b[i + 1] = b[i];
	}
	for (int i = n; i >= 1; i--) {
		if (a[i] != 0) {
			if (s.count(a[i]) == 0) {
				s.insert(a[i]);
				m[a[i]] = k;
				c[k] = i;
				nex[i] = -1;
				k++;
			}
			else {
				x = m[a[i]];
				nex[i] = c[x];
				c[x] = i;
			}
		}
	}
	ans = 0;
	if (a[n] != 0) {
		f(i, k) {
			x = c[i];
			if (a[x] == a[n]) {
				dp[x] = 1;
				dp2[x] = 1;
				while (nex[x] != -1) {
					y = dp2[x] * (b[nex[x]] - b[x]);
					y += dp[x];
					dp[nex[x]] = y % MOD;
					dp2[nex[x]] = (dp2[x] + dp[nex[x]]) % MOD;
					x = nex[x];
				}
				ans = dp[x];
			}
		}
	}
	else {
		ans = 1;
		for (int i = 1; i < n; i++) {
			if (a[i] == 0)ans = (ans * 2) % MOD;
		}
		f(i, k) {
			x = c[i];
			dp[x] = 1;
			dp2[x] = 1;
			while (nex[x] != -1) {
				y = dp2[x] * (b[nex[x]] - b[x]);
				y += dp[x];
				dp[nex[x]] = y % MOD;
				dp2[nex[x]] = (dp2[x] + dp[nex[x]]) % MOD;
				x = nex[x];
			}
			ans += dp2[x];
			ans %= MOD;
		}
	}
	printf("%lld\n", ans);
	return 0;
}



Measured memory_bytes: 50432
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll mod = 998244353;
const int N = 100000 + 5;
const int INF = 0x3f3f3f3f;
vector<int> a[N];
int vis[N],v[N];

int main()
{	
	ios::sync_with_stdio(false);
	cin.tie(0); 
	int h1,m1,h2,m2,k;
	cin >> h1 >> m1 >> h2 >> m2 >> k;
	ll t1 = h1*60+m1,t2 = h2*60+m2;
	ll z = t2-t1;
	if(z < k){
		cout << z << endl;
	}
	else{
		cout << (z-k) << endl;
	}
	return 0;
} 

Measured memory_bytes: 5988
#include <bits/stdc++.h>
using namespace std;
int main() {
  string s; cin>>s;
  for(int i=s.length()-2; i>0; i-=2){
    s.pop_back(); s.pop_back();
    int half=s.length()/2;
    if(s.substr(0,half)==s.substr(half,half)){
      cout<<s.length();
      return 0;
    }
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> pii;

#define mem(dp,a)       memset(dp,a,sizeof dp)
#define ninja           ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define pb(x)           push_back(x)
#define all(c)          c.begin(), c.end()
#define int             long long
#define ff              first
#define ss              second
#define nl              '\n'


int32_t main()
{
	ninja
	string s; cin>>s;
	if(s=="ABC")
		cout<<"ARC";
	else
		cout<<"ABC";
}



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

#define TRACE(x) x
#define WATCH(x) TRACE(cout << #x" = " << x << endl)
#define WATCHR(a, b) TRACE(for (auto it=a; it!=b;) cout << *(it++) << " "; cout << endl)
#define WATCHC(V) TRACE({cout << #V" = "; WATCHR(V.begin(), V.end());})

#define all(x) (x).begin(), (x).end()

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vb = vector<bool>;
using vs = vector<string>;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

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

    int N;
    cin >> N;

    vi targ(N);
    for (int i = 0; i < N; i++) {
        cin >> targ[i];
    }

    vector<array<ll, 5>> dp(N + 1);
    for (int i = N - 1; i >= 0; i--) {
        for (int s = 4; s >= 0; s--) {
            dp[i][s] = s + 1 < 5 ? dp[i][s+1] : LLONG_MAX;

            ll cost;
            if (s == 0 || s == 4)
                cost = targ[i];
            else if (s == 1 || s == 3)
                cost = (targ[i] < 2) ? 2 - targ[i] : (targ[i]&1);
            else
                cost = (targ[i] < 1) ? 1 - targ[i] : !(targ[i]&1);

            dp[i][s] = min(dp[i][s], cost + dp[i+1][s]);
        }
    }

    cout << dp[0][0] << endl;
    return 0;
}



Measured memory_bytes: 8832
from copy import deepcopy as dc

N, M = map(int, input().split())
edges = [list(map(lambda x:int(x) - 1, input().split())) for _ in range(M)]

edges_map = [[False for _ in range(N)] for _ in range(N)]
for edge in edges:
    edges_map[edge[0]][edge[1]] = True
    edges_map[edge[1]][edge[0]] = True
visited = [False for _ in range(N)]

def dfs(edge_now, edges_map, visited):
    visited[edge_now] = True
    for edge_to in range(N):
        if visited[edge_to]:
            continue
        if not edges_map[edge_now][edge_to]:
            continue
        dfs(edge_to, edges_map, visited)

def is_true(visited):
    if False in visited:
        return 1
    return 0

ans = 0
for edge in edges:
    visited_lc = dc(visited)
    edges_map_lc = dc(edges_map)
    edges_map_lc[edge[0]][edge[1]] = False
    edges_map_lc[edge[1]][edge[0]] = False
    dfs(0, edges_map_lc, visited_lc)
    ans += is_true(visited_lc)

print(ans)


Measured memory_bytes: 42604
import java.io.BufferedReader;
import java.io.Closeable;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.math.BigInteger;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.Map.Entry;

import java.util.PriorityQueue;
import java.util.Random;
import java.util.StringTokenizer;
import java.util.TreeSet;


public class Main {
	
	public static class Range implements Comparable<Range> {
		long x, l;
		
		public Range (long x, long l) {
			this.x = x;
			this.l = l;
		}

		@Override
		public int compareTo(Range o) {
			return Long.compare(this.x + this.l, o.x + o.l);
		}
	}
	
	public static void main(String[] args) throws IOException {	
		try(final Scanner sc = new Scanner(System.in)){
			final int a = sc.nextInt();
			final int b = sc.nextInt();
			
			if(a <= b) {
				for(int i = 0; i < b; i++) {
					System.out.print(a);
				}
				System.out.println();
			}else {
				for(int i = 0; i < a; i++) {
					System.out.print(b);
				}
				System.out.println();
			}
			
		}
	}

	public static class Scanner implements Closeable {
		private BufferedReader br;
		private StringTokenizer tok;

		public Scanner(InputStream is) throws IOException {
			br = new BufferedReader(new InputStreamReader(is));
		}

		private void getLine() throws IOException {
			while(!hasNext()){
				tok = new StringTokenizer(br.readLine());
			}
		}

		private boolean hasNext() {
			return tok != null && tok.hasMoreTokens();
		}

		public String next() throws IOException {
			getLine();
			return tok.nextToken();
		}

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

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

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

		public int[] nextIntArray(int n) throws IOException {
			final int[] ret = new int[n];
			for(int i = 0; i < n; i++){
				ret[i] = this.nextInt();
			}
			return ret;
		}

		public long[] nextLongArray(int n) throws IOException {
			final long[] ret = new long[n];
			for(int i = 0; i < n; i++){
				ret[i] = this.nextLong();
			}
			return ret;
		}

		public void close() throws IOException {
			br.close();
		}
	}
}

Measured memory_bytes: 21588
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define reps(i,n) for(int i=1;i<(int)(n);i++)

typedef long long ll;
using namespace std;
int main()
{
  int n,m;
  int a[200010],b[200010];
  cin>>n>>m;
  rep(i,m)cin>>a[i]>>b[i];

  int next[200010],last[200010];
  int size=0,size1=0;

  bool f1[200010],f2[200010];
  rep(i,n+1){
    f1[i]=false;
    f2[i]=false;
  }
  rep(i,n+1){
    if(a[i]==1)f1[b[i]]=true;
    if(b[i]==n)f2[a[i]]=true;
  }

  rep(i,n){
    if(f1[i]&&f2[i]){
      cout<<"POSSIBLE"<<endl;
      return 0;
    }
  }

  cout<<"IMPOSSIBLE"<<endl;
  return 0;
}


Measured memory_bytes: 5540