akhauriyash/Code-Regression huggingface dataset:
/*its_Rashid*/
#include <bits/stdc++.h>
using namespace std ;

typedef double du ;
typedef string st ;
typedef long long ll ;
typedef long double ld ;
typedef long long int lli ;

#define vi vector <lli>
#define loop(num) for (lli i = 0 ; i < num ; i ++ )
#define loopcin(num , ar ) for (lli i = 0 ; i < num ; i ++ ) {cin >> ar [i] ;}
#define loopcout(num , ar) for (lli i = 0 ; i < num ; i ++ ) {cout << ar [i] << ' '; }

#define forr(num1 , num2) for (lli i = num1 ; i < num2 ; i ++ )
#define forrcin(num1 , num2 , ar ) for (lli i = num1 ; i < num2 ; i ++ ) {cin >> ar [i] ;}
#define forrcout(num1 , num2 , ar) for (lli i = num1 ; i < num2 ; i ++ ) {cout << ar [i] << ' '; }

#define D2forrcin(num1_1 , num1_2 , num2_1 , num2_2 , A ) for (lli i = num1_1 ; i < num1_2 ; i ++){ for (lli j = num2_1 ; j < num2_2 ; j++){cin >> A[i][j] ;}}
#define D2forrcout(num1_1 , num1_2 , num2_1 , num2_2 , A ) for (lli i = num1_1 ; i < num1_2 ; i ++){ for (lli j = num2_1 ; j < num2_2 ; j++){cout << A[i][j] << ' ' ;}cout << endl ;}

#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl

#define F first
#define S second

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

int main ()
{
    fastio
    lli a , b ;
    cin >> a >> b ;
    cout << (a % b == 0 ? 0 : 1) ;

    return 0 ;
}

/*___________________________________________________________________functions___________________________________________________________________________*/



Measured memory_bytes: 256
#include <string>
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <stdlib.h>
#include <algorithm>
#include <list>
#include <math.h>
#include<string.h>
#define reps(i,j,k) for(int i=(j);i<(k);i++)
#define rep(i,j) reps(i,0,j)

//	rep(i,10)cout << i << endl;
using namespace std;

int main(void){
	int n,m;
	cin >> n;
	int d[n];
	rep(i,n) cin >> d[i];
	cin >> m;
	int t[m];
	rep(i,m) cin >> t[i];
	sort(d,d+n);
	sort(t,t+m);
	int i=0;
	int j=0;
	while(i<m && j < n){
		if(t[i] == d[j]){
			i++;
			j++;
		}
		else{
			j++;
		}
		if(t[i] < d[j]) break;
	}
	if(i >= m) cout << "YES" << endl;
	else cout << "NO" << endl;
	
	return 0;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
#define REP(i,a,b) for(int (i)=(a);(i)<(int)(b);++(i))
#define RREP(i,a,b) for(int (i)=(a);(i)>=(int)(b);--(i))
typedef long long ll;
typedef pair<ll, ll> P;
const int MOD = 1000000007;

int n;
ll ans = 0;

void dfs(ll cur, int mask){
    if (cur > n) return;
    if (mask == 7) ans++;

    dfs(cur * 10 + 3, mask | 1);
    dfs(cur * 10 + 5, mask | 2);
    dfs(cur * 10 + 7, mask | 4);
}


int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cin >> n;
    dfs(0, 0);
    cout << ans << endl;
    
    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <algorithm>
#include <cstring>
#include <string.h>
#include <queue>
#include <stack>
#include <utility>
#include <queue>
#include <cmath>
#define mp make_pair
#define pii pair<int,int> 
#define ff first
#define ss second

using namespace std;

int n;
int list[10000],dp[10000];
int hasil;

int main()
{
	while(1)
	{
		scanf("%d",&n);
		if(n==0)
		break;
		hasil=-1000000;
		dp[0]=0;
		for(int a=1;a<=n;a++)
		{
			scanf("%d",&list[a]);
		}
		for(int a=1;a<=n;a++)
		{
			if(dp[a-1]>=0)
			{
				dp[a]=dp[a-1]+list[a];
			}
			else
			{
				dp[a]=list[a];
			}
			hasil=max(hasil,dp[a]);
		}
		/*for(int a=0;a<=n;a++)
		{
			printf("%d ",dp[a]);
		}*/
		printf("%d\n",hasil);
	}
	return 0;
}

Measured memory_bytes: 1220
#include "bits/stdc++.h"
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
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; }

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s;
    int k;
    cin >> s >> k;
    int n = s.size();
    set<string> ans;
    rep(i,n){
        string t = "";
        for(int j = i; j < min(n, i+5); j++){
            t += s[j];
            ans.insert(t);
        }
    }
    int cnt = 0;
    for(auto p : ans){
        if(k == ++cnt){
            cout << p << endl;
            return 0;
        }
    }
    return 0;
}

Measured memory_bytes: 1664
#include <algorithm>
#include <cmath>
#include <iostream>
#include <string>
#include <vector>

using namespace std;
using ll = long long;

int main() {
  ll N, H;
  cin >> N >> H;
  vector<ll> a(N), b(N);
  for (ll i = 0; i < N; ++i) {
    cin >> a[i] >> b[i];
  }

  ll max_a = *max_element(a.begin(), a.end());
  sort(b.begin(), b.end(), greater<ll>());
  ll ans = 0;
  for (ll i = 0; i < N; ++i) {
    if (b[ans] > max_a) {
      H -= b[i];
      ++ans;
      if (H <= 0) {
        cout << ans << endl;
        return 0;
      }
    }
  }
  if (H % max_a == 0) {
    cout << ans + H / max_a << endl;
  } else {
    cout << ans + H / max_a + 1 << endl;
  }
  return 0;
}


Measured memory_bytes: 1792
N=input()
keta=len(N)
K=int(input())
seiyaku=[[0 for a in range(120)] for b in range(keta+2)]
museiyaku=[[0 for a in range(120)] for b in range(keta+2)]
seiyaku[0][0]=1
seiyaku[0][0]=1
for i in range(keta):
 a=int(N[i])
 for j in range(keta+1):
  if a==0:
   seiyaku[i+1][j]=seiyaku[i][j]
   museiyaku[i+1][j+1]+=museiyaku[i][j]*9
   museiyaku[i+1][j]+=museiyaku[i][j]
  else:
   seiyaku[i+1][j+1]=seiyaku[i][j]
   museiyaku[i+1][j]+=seiyaku[i][j]
   museiyaku[i+1][j+1]+=seiyaku[i][j]*(a-1)
   museiyaku[i+1][j+1]+=museiyaku[i][j]*9
   museiyaku[i+1][j]+=museiyaku[i][j]
print(seiyaku[keta][K]+museiyaku[keta][K])

Measured memory_bytes: 3440
#ifndef _GLIBCXX_NO_ASSERT
#include <cassert>
#endif
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#if __cplusplus >= 201103L
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
#endif

// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

#if __cplusplus >= 201103L
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#endif


using namespace std;

// #define int long long
struct Fast {Fast(){std::cin.tie(0);ios::sync_with_stdio(false);}} fast;

inline bool inside(int y, int x, int H, int W) {return y >= 0 && x >= 0 && y < H && x < W;}
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

const int MOD = 1e9 + 7;
const int INF = INT_MAX;

signed main() {
    Fast();

    int a, b, c, d;
    cin >> a >> b >> c >> d;
    cout << min(a, b) + min(c, d) << endl;

    return 0;
}



Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

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

    char[] s = sc.next().toCharArray();
    char[] t = sc.next().toCharArray();
    
    int ans = 0;
    for (int i = 0; i < 3; i++) {
        if (s[i] == t[i]) ans++;
    }

    System.out.println(ans);
  }
}

Measured memory_bytes: 22740
#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >>n;
  vector<pair<int,int>> v(n);
  
  for(int i=0;i<n;i++){
    int x;
    cin >> x;
    pair<int,int> p;
    p = make_pair(x,i+1);
    v.at(i)=p;
  }

  sort(v.begin(),v.end());
  

    for(int i=0;i<n;i++){
      cout << v.at(i).second <<endl;
    }
  
  return 0;
}

Measured memory_bytes: 1664
#include <iostream>
#include <vector>
#include <queue>
using namespace std;
using Graph = vector<vector<int>>;

int main() {
    int N, M; cin >> N >> M;
    vector<int> a(M), b(M);
    for(int i = 0; i < M; ++i) {
        cin >> a[i] >> b[i];
        --a[i], --b[i];
    }
    
    int ans = 0;
    for(int i = 0; i < M; ++i) {
        Graph G(N);
        for(int j = 0; j < M; ++j) {
            if(i == j) continue;
            G[a[j]].push_back(b[j]);
            G[b[j]].push_back(a[j]);
        }
        vector<int> dist(N, -1);
        queue<int> que;
        int count = 0;
        for(int v = 0; v < N; ++v) {
            if(dist[v] != -1) continue;
            dist[v] = 0;
            que.push(v);
            while(!que.empty()) {
                int v = que.front(); que.pop();
                for(auto nv : G[v]) {
                    if(dist[nv] != -1) continue;
                    dist[nv] = dist[v] + 1;
                    que.push(nv);
                }
            }
            ++count;
        }
        if(count > 1) ++ans;
    }
    
    cout << ans << endl;
}


Measured memory_bytes: 256
def is_integer_num(n):
    if isinstance(n, int):
        return True
    if isinstance(n, float):
        return n.is_integer()
    return False
 
A,B,K = [int(i) for i in input().split()]

i = 100
count = 0
while(i>0):
    
    if is_integer_num(A/i) and is_integer_num(B/i):
        count = count+1
 
    if count == K:
        print(i)
        break    
    
    i = i-1

Measured memory_bytes: 3060
N = int(input())
S = input()
ans = 0
for i in range(1000):
	a = '{:0=3}'.format(i)
	b = [False] * 3
	for j in S:
		if j == a[0] and not b[0]:
			b[0] = True
		elif j == a[1] and b[0] and not b[1]:
			b[1] = True
		elif j == a[2] and b[0] and b[1] and not b[2]:
			b[2] = True
	if all(b):
		ans += 1
print(ans)

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

void solve()
{
    vector<string> s(3);
    rep(i, 3) cin >> s[i];
    rep(i, 3) rep(j, 3)
    {
        if (i == j)
            cout << s[i][j];
    }
    cout << endl;
}

int main()
{
    solve();
    return 0;
}

Measured memory_bytes: 3544
a,b,c = map(int, input().split())
k = int(input())
#print(a,b,c,k)

if b < a:
    for i in range(1, 10):
        b = b*2
        if b > a:
            y = i
            break
elif b == a:
    y = 1
    b = b * 2
else:
    y = 0

if c < b:
    for i in range(1, 10):
        c = c*2
        if c > b:
            x = i
            break
elif c == b:
    x = 1
else:
    x = 0


if (x+y) <= k:
    print('Yes')
else:
    print('No')




Measured memory_bytes: 9172
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<vector<int>> vvi;
const int MOD = 1e9 + 7;
const int INF = 2e9;
#define pb push_back
#define mp make_pair
#define mt make_tuple
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }

int main(){
    int n, m;
    cin >> n >> m;
    vector<tuple<int, int, int>> a;
    vector<int> cnt(n,0);
    for (int i = 0; i < m; i++){
        int p, y;
        cin >> p >> y;
        a.pb(mt(p, y, i));
        cnt[p - 1]++;
    }
    sort(a.begin(), a.end());
    vector<pair<string, string>> ans(m);
    int k = 0;
    for (int i = 0; i < n; i++){
        for (int j = 0; j < cnt[i]; j++){
            string str = "000000";
            ans[get<2>(a[k])].first = str.substr(0, 6 - to_string(i + 1).length()) + to_string(i + 1);
            ans[get<2>(a[k])].second = str.substr(0, 6 - to_string(j + 1).length()) + to_string(j + 1);
            k++;
        }
    }
    for (int i = 0; i < m; i++){
        cout << ans[i].first << ans[i].second << endl;
    }
}

Measured memory_bytes: 14068
import java.util.Scanner;

class Main {
    public static void main(String[] args){
        Scanner stdIn = new Scanner(System.in);
        int a = stdIn.nextInt();
        int b = stdIn.nextInt();
        int k = stdIn.nextInt();

        if(a+k-1 < b-k+1) {
            for(int i = 0; i < k; i++)
                System.out.println(a+i);
            for(int i = 0; i < k; i++)
                System.out.println(b-k+1+i);
        }
        else
            for(int i = a; i < b + 1; i++)
                System.out.println(i);
    }
}

Measured memory_bytes: 23892
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); ++i)
using namespace std;
const double PI=3.14159265358979323846;
 
const string YES = "Yes";
const string NO = "No";
 
void solve(long long N){
    double result = (double)N*2*PI;
    printf("%8.20f\n", result);
}
 
int main(){
    long long N;
    scanf("%lld",&N);
    solve(N);
    return 0;
}

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

#define rep(i,n) for(int i = 0; i < (n); ++i)
#define ll long long
#define P pair<ll,ll>
#define all(v) v.begin(),v.end()
const ll mod = 1e9+7;
const ll INF = 1e18;
const double pi = acos(-1.0);

int main(void)
{
   
    ll n; cin>>n;
    bool a[n+1]={};
    for(int i=1;i<=n;i++){
        if(i%3==0) a[i]=true;
        string s=to_string(i);
        rep(j,s.size()){
            if(s[j]=='3') a[i]=true;
        }
    }
    for(int i=1;i<=n;i++){
        if(a[i]) cout<<" "<<i;
    }
    cout<<endl;
    return 0;
}


Measured memory_bytes: 3244
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
typedef long long ll;
int main(){
    int n,m,a,num[200001]={0};
    cin>>n>>m;
    rep(i,2*m) cin>>a,num[a]++;
    int x=1;
    rep(i,n) if(num[i+1]%2==1) x=0;
    if(x) cout<<"YES";
    else cout<<"NO";
}

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

int main(){
  int n;
  cin >> n;
  int sum=0;
  for (int i = 1; i <= n; i+=2) {
    int num=0;
    for (int j = 1; j <= i; j+=2) {

      if(i%j==0){
        num++;
      }
      if(num>8){
        break;
      }
    }
    if(num==8){
      sum++;
    }
  }

  cout << sum <<endl;

  return 0;
}

Measured memory_bytes: 888
#include<iostream>
#include<bits/stdc++.h>
using namespace std;
#define ll long long  //1 taro   2 jiro

int main()
{
ll N,K;
cin>>N>>K;
ll moves[N];
ll dp[K+1];
for(ll i=0;i<=K;i++)
{
	dp[i]=0;
}
for(ll i=0;i<N;i++)
{
	cin>>moves[i];
	dp[moves[i]]=1;
}
for(ll i=0;i<moves[0];i++)
{
	dp[i]=2;
}

for(ll i=moves[0]+1;i<=K;i++)
{
	if(dp[i]==0)
	{
		ll tarowin=0;
		for(ll j=0;j<N;j++)
		{
			if(i-moves[j]>=0)
			{
			if(dp[i-moves[j]]==2)
			{
				tarowin=1;
				break;
			}
			
			}
			else
			{
				break;
			}
			
			}
		if(tarowin==1)
			{
				dp[i]=1;
			}
			else
			{
				dp[i]=2;
			}
	}
}

if(dp[K]==1)
{
	cout<<"First"<<endl;
}
else
{
	cout<<"Second"<<endl;
}


}


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

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

	int n;
	cin >> n;
	int ans = 0;
	int ans1 = 0;
	int ans2 = 0;
	int med = 0;
    vector<int> x(n);
    for(int i = 0; i < n; i++) {
    	cin >> x[i];
    	med += x[i];
    }
    if(med % n == 0) {
    	med = med / n;
    	for(int i = 0; i < n; i++) {
    	ans += pow(x[i] - med, 2);
        }
    }else {
    	int med1 = med / n;
    	for(int i = 0; i < n; i++) {
    	ans1 += pow(x[i] - med1, 2);
        }
    	int med2 = (med + n - 1) / n;
    	for(int i = 0; i < n; i++) {
    	ans2 += pow(x[i] - med2, 2);
        }
        ans = min(ans1, ans2);
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define endl "\n"
using namespace std;
#define ll long long
#define ld long double
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define repo(i,n) for(int i = 1; i < (int)(n); i++)
#define pb push_back
#define mp make_pair
#define np next_permutation
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()
#define uniq(v) v.erase(unique(v.begin(),v.end()),v.end())
#define lb(v,x) (lower_bound(v.begin(),v.end(),x)-v.begin())
#define ub(v,x) (upper_bound(v.begin(),v.end(),x)-v.begin())
using Pair = pair<ll,pair<int,int>>;
#define pq priority_queue<Pair, vector<Pair>, greater<Pair>> 
const ll mod=1000000007;
//const ll mod=998244353;
const ld pi=acos(-1.0);
const ll INF = 1LL<<61;
template<class T>bool chmax(T &a, const T &b) { 
  if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) {
  if (b<a) { a=b; return 1; } return 0; }
ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; }
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }
//intの最大値2147483647 ≒ 2×10^9
//long longの最大値9223372036854775807 ≒ 9×10^18
//'大文字'+=32;    で小文字に
//  cout << fixed << setprecision (20);   小数点以下2０桁まで
//実行時間制約2秒では２×10^8回くらいまで計算できる




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

  int n;
  cin>>n;

  vector<ll>p(n);
  rep(i,n){
    cin>>p[i];
  }

  vector<ll> ans0(n,-INF);
  vector<ll> ans1(n,-INF);
  vector<ll> ans2(n,-INF);

  if(n%2==0){
    ans0[0]=p[0];
    ans1[1]=p[1];
    for(int i=2;i<n;i++){
      chmax(ans0[i],ans0[i-2]+p[i]);
      if(i>=3) chmax(ans1[i],ans0[i-3]+p[i]);
      chmax(ans1[i],ans1[i-2]+p[i]);
    }
    cout << max(ans0[n-2],ans1[n-1]) << endl;
  }

  if(n%2==1){
    ans0[0]=p[0];
    ans1[1]=p[1];
    ans2[2]=p[2];
    for(int i=2;i<n;i++){
      if(i!=n-1) chmax(ans0[i],ans0[i-2]+p[i]);
      if(i>=3) chmax(ans1[i],ans0[i-3]+p[i]);
      if(i>=4) chmax(ans2[i],ans0[i-4]+p[i]);
      chmax(ans1[i],ans1[i-2]+p[i]);
      if(i>=3) chmax(ans2[i],ans1[i-3]+p[i]);
      chmax(ans2[i],ans2[i-2]+p[i]);
    }
    cout << max({ans0[n-3],ans1[n-2],ans2[n-1]}) << endl;
  }

}


Measured memory_bytes: 9496
#include <random>
#include "bits/stdc++.h"

using namespace std;

using ll = long long;
using ld = long double;
using P = pair<int, int>;
constexpr ld eps = 1e-12;
constexpr int inf = numeric_limits<int>::max() / 2;
constexpr ll mod = 1e9 + 7;
mt19937_64 rnd{random_device()()};

template <typename T>
void printv(const vector<T> &v) {
  int sz = v.size();
  for (int i = 0; i < sz; i++) {
    cout << v[i] << " \n"[i == sz - 1];
  }
}

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

  string s;
  cin >> s;
  int n = s.size();
  for (int i = 0; i < n; i++)
    if (s[i] == '?') s[i] = 'D';
  cout << s << endl;
}


Measured memory_bytes: 3748
#include <iostream>
#include <algorithm>

using namespace std;
int main(void){
    int N;
    int m;
    int s=0;
    int A[100001]={0};
    cin >> N;
    m = N;
    for(int i=0;i<N;i++){
        int tmp;
        cin >> tmp;
        A[tmp]++;
    }
    for(int i=1;i<=100000;i++){
        if(A[i]>1){
            s +=A[i]-1;
        }
    }
    if(s%2==0){
        cout << N - s;
        return 0;
    }
    cout << N-s-1;
    
    return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>
#include <queue>
#include <stack>
#include <string>
#include<map>

#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
typedef long long ll;

using namespace std;


int inputValue() {
  int a;
  cin >> a;
  return a;
};
void inputVector(vector<int>* v) {
  //cin.tie(0);
  //ios::sync_with_stdio(false);
  int a;
  while (cin >> a) {
    if (a == -1)break;
    v->push_back(a);
  }
};

void inputVector(vector<int> * p, int a) {
  rep(i, a) {
    int input;
    cin >> input;
    p->push_back(input);
  }
}

void inputVector2(vector<vector<int>>& v, int r, int c) {
  int temp;
  for (size_t i = 0; i < r; i++)
  {
    for (size_t j = 0; j < c; j++)
    {
      scanf("%d", &temp);
      v[i][j] = temp;
    }
  }
}
void inputVector3(vector<int>* v0, vector<int>* v1) {
  int a;
  unsigned short count = 0b0;
  while (cin >> a) {
    if (a == -1)break;
    if (count)v0->push_back(a); else v1->push_back(a);
    count = count ^ 1;
  }
};

template <typename T>
void output(T a, int precision) {
  if (precision > 0) {
    cout << setprecision(precision) << a << "\n";
  }
  else {
    cout << a << "\n";
  }
}

void comboSearch(vector<int>& v, vector<int>& combo) {
  int sa = v[1] - v[0];
  int sa_sqrt = (int) sqrt(sa);
  for (size_t i = sa_sqrt; i >= 1; i--) {
    if (sa % i == 0) {
      combo.insert(combo.begin(), i);
      if (i != (int)(sa / i)) {
        combo.push_back((int)(sa / i));
      }
    }
  }
}

void comboMatch(vector<int>& v, vector<int>& combo) {
  int sa;
  for (size_t i = 1; i < v.size() - 1; i++) {
    sa = v[i + 1] - v[i];
    for (int j = combo.size()-1; j >= 0; j--) {
      if (sa % combo[j] != 0) {
        combo.erase(combo.begin() + j);
      }
    }
  }
}

int main(int argc, const char * argv[]) {
  int n;
  vector<int> v;
  vector<int> combo;
  scanf("%d", &n);
  inputVector(&v);
  sort(v.begin(), v.end());
  if (v.size() == 2) {
    cout << v[1] - v[0] << endl;
    return 0;
  }
  comboSearch(v, combo);
  comboMatch(v, combo);
  cout << *(combo.end() - 1) << endl;
  return 0;
}

Measured memory_bytes: 892
#include <iostream>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
int main()
{
    int N, count = 1;
    string S;
    cin >> N >> S;
    char B = S[0];
    rep(i, N - 1)
    {
        if (S[i + 1] != B)
        {
            count++;
            B = S[i + 1];
        }
    }
    cout << count << "\n";
}

Measured memory_bytes: 512
// /*
// power code taken from geeks for geeks
// */
// cout << setprecision (2) << fixed << 1.2;

#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
typedef long double ld;

const ll INF = 1e18 + 5;
const ll MAX_N = 1e5 + 5;
const ll MODD = 1e9 + 7;

ll max(ll a,ll b){return a>b?a:b;}
ll min(ll a,ll b){return a<b?a:b;}
double max(double a,double b){return a>b?a:b;}
double min(double a,double b){return a<b?a:b;}

ll modd(ll a){if(a<0LL) return a*-1LL;return a;}
double modd(double a){if(a<0.0) return a*-1.0;return a;}

ll modulo(ll a){return a % MODD; }

ll power(ll k, ll p){
    if (p == 0)
        return 1LL;
 
    ll P = power(k, p/2LL);
    P = (P * P) % MODD;
 
    if (p % 2 == 1)
        P = (P * k) % MODD;
 
    return P;
}



struct p_str {
    ll a, b;
};




void solve() {
    ll l, r;
    ll d;
    cin >> l >> r >> d;
    ll ans = 0;
    for(ll i = l; i <= r; i++) {
        if(i % d == 0) {
            ans++;
        }
    }
    cout << ans << endl;
}



int main(){



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



    ll t=1;


    // cin>>t;
    


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

Measured memory_bytes: 3556
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define scn(n) scanf("%d",&n)
#define lscn(n) scanf("%lld",&n)
#define pri(n) printf("%d",n)
#define lpri(n) printf("%lld",n)
#define priln(n) printf("%d\n",n)
#define lpriln(n) printf("%lld\n",n)
#define F first
#define S second
const int mod=1e9+7;

int main()
{
    int n,k;
    cin>>n>>k;
    
    int arr[n+1];
    for(int i=0;i<n;i++)
        cin>>arr[i];
    
    int dp[n];
    for(int i=0;i<n;i++)
    dp[i]=INT_MAX;

    dp[0]=0;
    for(int i=1;i<n;i++)
    {
        for(int j=1;j<=k;j++)
        {
            if(i-j>=0)
            dp[i]=min(dp[i],dp[i-j]+abs(arr[i]-arr[i-j]));
        }
    }
    
    cout<<dp[n-1];
}

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

#define ll long long

using namespace std;



int p,q,r;
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cin>>p>>q>>r;
    int aux = max (p,max(q,r));
    if (aux==p){
        cout<<q+r;
    }
    else if (aux==q){
        cout<<p+r;
    }
    else cout<<q+p;
    
    
    
    
    
    
    return 0;
}

Measured memory_bytes: 256
(r, c) = [int(i) for i in input().split()]
last_row = [0 for _ in range(c+1)]

for _ in range(r):
    row = [int(i) for i in input().split()]
    for cc in range(c):
        last_row[cc] += int(row[cc])
        print(row[cc], end=' ')

    print(sum(row))

last_row[-1] = sum(last_row)
print(' '.join([str(a) for a in last_row]))

Measured memory_bytes: 7788
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define ALL(x) (x).begin(),(x).end()
#define LL long long

using namespace std;

LL dp[5001][5002];

int main(){

    int N;cin>>N;
    string s;cin>>s;
    LL inf = 1e9 + 7;
    fill(dp[0],dp[N+1],0);
    dp[0][0]=1;
    for (int i=1;i<=N;i++)for (int j=0;j<=N;j++)dp[i][j] =(dp[i-1][j+1] + (j==0 ? dp[i-1][0] : 2*dp[i-1][j-1]))%inf;
    LL inv=500000004;

    LL ans =dp[N][s.size()];
    REP(i,s.size())ans=(ans*inv)%inf;
    cout<<ans<<endl;



    return 0;
}

Measured memory_bytes: 195712
#include<iostream>
#include<iomanip>
#include<math.h>
#include<vector>
#include<algorithm>
#include<set>
#include<map>
#include<queue>
#include<stack>
#include<string>
#include<bitset>
#include<random>
#include<time.h>
#define INF 1000000000ll
#define MOD 1000000007ll
#define EPS 1e-10
#define REP(i,m) for(long long i=0; i<m; i++)
#define FOR(i,n,m) for(long long i=n; i<m; i++)
#define DUMP(a) for(long long dump=0; dump<(ll)a.size(); dump++) { cout<<a[dump]; if(dump!=(ll)a.size()-1) cout<<" "; else cout<<endl; }
#define ALL(v) v.begin(),v.end()
#define pb push_back
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef long double ld;

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll n,m;
	cin>>n>>m;
	if(n==1&&m==1) {
		cout<<1<<endl;
		return 0;
	}
	if(n==1) {
		cout<<m-2<<endl;
		return 0;
	}
	if(m==1) {
		cout<<n-2<<endl;
		return 0;
	}
	cout<<(n-2)*(m-2)<<endl;
}


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

#define rep(i,n) FOR(i,0,n)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define ROF(i,a,b) for(int i=(a);i>(b);i--)
#define all(a) (a).begin(),(a).end()
#define UNIQUE(v) v.erase(unique(all(v)),v.end())
typedef vector<int> vi;
typedef vector<vi> vii;
typedef vector<string> vs;
typedef pair<int,int> pii;
typedef long long ll;

vector<ll> lucas(87);

main(){
  int n; cin >> n;
  lucas[0]=2; lucas[1]=1;
  if(n==1) cout << 1;
  else{
    FOR(i,2,n+1) lucas[i]=lucas[i-1]+lucas[i-2];
    cout << lucas[n];
  }
  cout << endl;
}


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

#define INF 1000000000

int dp[3001][3001];

int main() {
  string s1,s2;
  cin >> s1;
  cin >> s2;
  
  memset(dp, 0, sizeof dp);
  for (int i = 1; i <= s1.length(); i++){
    for (int j = 1; j <= s2.length(); j++) {
      dp[i][j] = dp[i - 1][j - 1] + (s1[i - 1] == s2[j - 1] ? 1 : -INF); // match/mismatch
      dp[i][j] = max(dp[i][j], dp[i - 1][j]); // delete
      dp[i][j] = max(dp[i][j], dp[i][j - 1]); // insert
    }
  }

  string ans = "";
  int count = dp[s1.length()][s2.length()];
  int i = s1.length(), j = s2.length();
  while(i > 0 && j > 0){
    if(dp[i-1][j-1] != count && dp[i][j-1] != count && dp[i-1][j] != count){
      ans += s1.substr(i-1,1);
      i--; j--;
      count = dp[i][j];
    }else{
      if(dp[i-1][j] == count) i--;
      else if(dp[i][j-1] == count) j--;
    }
  }

  reverse(ans.begin(),ans.end());
  cout << ans << endl;
}


Measured memory_bytes: 35456
#include<iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <tuple>
#include <cmath>
#include <queue>
#include <vector>
#include <map>
using namespace std;

#define ll int64_t
const long MOD = 1e9 + 7;


int main()
{
  long h, w;
  cin >> h >> w;//nは10の5乗数

  vector<vector<long>> a(h, vector<long>(w, 0));

  vector<vector<bool>> a_odd(h, vector<bool>(w, false));
  for (int i = 0; i < h; ++i) {
    for (int j = 0; j < w; ++j) {
      cin >> a[i][j];
      if (a[i][j] % 2 == 1)a_odd[i][j] = true;
    }
  }

  vector<tuple<long, long, long, long>> coutlist;


  bool isSearch = false;
  long tempx, tempy;
  for (int i = 0; i < h; ++i) {
    for (int j = 0; j < w; ++j) {

      long j_f = j;
      if (i % 2 == 1)j_f = w - 1 - j;
      if (!isSearch) { //サーチしてないとき

        if (a_odd[i][j_f] == true) { //奇数見つかる
          tempx = j_f;
          tempy = i;
          isSearch = true;
        }

      } else if (isSearch) {

        if (a_odd[i][j_f] == true) { //奇数見つかる
          for (int r = tempy; r < i + 1; r++) {
            long start = 0;
            bool isfind = false;

            if (r % 2 == 0) { //順方向
              start = 0;
              if (r == tempy)start = tempx;

              for (int c = start; c <= w - 1; ++c) {
                if (r == i && j_f == c) {
                  if (tempy != r || tempx != c) {
                    isfind = true;
                    break;
                  }

                }
                if (c == w - 1)break;
                coutlist.push_back(make_tuple(r, c, r, c + 1));
              }
            }
            if (r % 2 == 1) {
              start = w - 1;
              if (r == tempy)start = tempx;

              for (int c = start; c >= 0; --c) {
                if (r == i && j_f == c) {
                  if (tempy != r || tempx != c) {
                    isfind = true;
                    break;
                  }

                }
                if (c == 0)break;
                coutlist.push_back(make_tuple(r, c, r, c - 1));
              }
            }

            if ( isfind == true) {
              break;
            } else {
              if (r % 2 == 0)coutlist.push_back(make_tuple(r, w - 1, r + 1, w - 1));
              if (r % 2 == 1)coutlist.push_back(make_tuple(r, 0, r + 1, 0));
            }

          }
          isSearch = false;
        }


      }
      cerr << "isSearch:" << isSearch << endl;
    }
  }

  long n = 0;
  // long fy, fx, ty, tx;
  cout << coutlist.size() << endl;
  for (int i = 0; i < coutlist.size(); ++i) {
    cout << get<0>(coutlist[i]) + 1 << " " << get<1>(coutlist[i]) + 1 << " " << get<2>(coutlist[i]) + 1 << " " << get<3>(coutlist[i]) + 1 << endl;
  }

  // cout << n << endl;
  // cout << fx << " " << fx << " " << ty << " " << tx << endl;


  return 0;
}


Measured memory_bytes: 8180
#include <stdio.h>
#include <math.h>
#include <iostream>
#include <vector>
using namespace std;

int main(void){
  int N;
  cin >> N;
  int l;
  vector<int> A(N);
  vector<int> sum(N);
  sum[0]=0;
  A[0] = 0;
  for(int i=1;i<N;i++){
    cin >> l;
    A[i] = l;
    sum[i] = 0;
  }

  for(int i=1;i<N;i++){
    sum[A[i]-1] = sum[A[i]-1]+1;
  }

  for(int i=0;i<N;i++){
    printf("%d\n",sum[i]);
  }

  return 0;
}

Measured memory_bytes: 4768
#include<cstdio>
#include<cstdlib>
#include<string>
#include<iostream>
 
using namespace std;
 
struct Node
{
  int key;
  Node *right, *left, *parent;
};
 
Node *root, *NIL;
 
void insert(int k){
  Node *y=NIL;
  Node *x=root;
  Node *z;
 
  z=(Node *)malloc(sizeof(Node));
  z->key = k;
  z->left = NIL;
  z->right = NIL;
 
  while(x!=NIL)
    {
      y=x;
      if(z->key < x->key)
    {
      x = x->left;
    }
      else
    {
      x = x->right;
    }
    }
 
  z->parent = y;
 
  if(y == NIL)
    {
      root=z;
    }
  else
    {
      if(z->key < y->key)
    {
      y->left = z;
    }
      else
    {
      y->right = z;
    }
    }
}
 
 
void inoder(Node *u){
  if(u == NIL)
    return;
  inoder(u->left);
  printf(" %d", u->key);
  inoder(u->right);
}
 
void preoder(Node *u){
  if(u == NIL)
    return;
  printf(" %d", u->key);
  preoder(u->left);
  preoder(u->right);
}
 
int main(){
  int n, i, x;
  string com;
 
  scanf("%d", &n);
 
  for(i=0; i<n; i++)
    {
      cin >> com;
      if(com == "insert")
    {
      scanf("%d", &x);
      insert(x);
    }
      else if(com == "print")
    {
      inoder(root);
      printf("\n");
      preoder(root);
      printf("\n");
    }
    }
 
  return 0;
}


Measured memory_bytes: 26752
#include <bits/stdc++.h>
#define rep(i, n) for (int i=0; i<(n); ++i)
#define repr(i, a, b) for (int i=a; i<(b); ++i)
#define reprev(i, n) for (int i=n-1; i>=0; --i)
#define reprrev(i, a, b) for (int i=b-1; i>=(a); --i)
using namespace std;
using ll = long long;
using P = pair<int, int>;

int main() {
    cout << fixed << setprecision(10);
    
    int N, P; cin >> N >> P;
    string S; cin >> S;

    if (10 % P == 0) {
        // Pが2か5のとき
        ll ans = 0;
        reprev (i, N) {
            if ((S[i] - '0') % P == 0) {
                // そのSiを一の位に持つ数は全てPで割れる
                ans += i + 1;
            }
        }
        cout << ans << endl;
    } else {
        ll ans = 0;
        // modの累積和をSの右側から計算する
        vector<int> d(N+1);
        int ten = 1;
        reprev (i, N) {
            int si = (S[i] - '0') * ten % P;
            d[i] = (d[i+1] + si) % P;
            ten *= 10; ten %= P;
        }

        vector<int> cnt(P);
        reprev (i, N+1) {
            ans += cnt[d[i]];
            cnt[d[i]] += 1;
        }
        cout << ans << endl;
    }
    return 0;
}

Measured memory_bytes: 1412
import java.math.BigDecimal;
import java.util.*;
import java.util.stream.Collectors;

class Main {
    public static void main(String args[]) {
        Scanner sc = new Scanner(System.in);
        int D = sc.nextInt();
        int G = sc.nextInt();
        int[] p = new int[D];
        int[] c = new int[D];
        for(int i = 0; i < D; i++) {
            p[i] = sc.nextInt();
            c[i] = sc.nextInt();
        }

        int sumCnt = Integer.MAX_VALUE;
        for (int i = 0; i < Math.pow(2, D); i++) {
            int result = 0;
            int cnt = 0;
            int rest = 0;
            for (int j = 0; j < D; j++) {
                if ((1 << j & i) != 0) {
                    result += (j + 1) * 100 * p[j] + c[j];
                    cnt += p[j];
                } else {
                    rest = j;

                }
            }
            if (result < G) {
                int need = (int) Math.ceil((G - result) / ((rest + 1) * 100F));
                if (need > p[rest]) {
                    continue;
                }
                cnt += Math.ceil((G - result) / ((rest + 1) * 100F));
            }
            sumCnt = Math.min(sumCnt, cnt);
        }
        System.out.println(sumCnt);
    }
}

Measured memory_bytes: 21828
//#include <boost/multiprecision/cpp_dec_float.hpp>
//#include <boost/multiprecision/cpp_int.hpp>
#include <stdio.h>
#include <iostream>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <math.h>
#include <algorithm>
#include <bitset>
using namespace std;
//namespace mp = boost::multiprecision;
//using llll = mp::cpp_int;
// 仮数部が1024ビットの浮動小数点数型(TLEしたら小さくする)
//using Real = mp::number<mp::cpp_dec_float<1024>>;
using ll = long long;
const double EPS = 1e-10;
const ll MOD = 7+(1e+9);

int main(){
  ll n,ans=0;
  cin>>n;
  vector<ll>v(n,0);
  for(ll i=0;i<n;i++){
    cin>>v[i];
  }
  ll t=0;
  for(ll i=1;i<n;i++){
    if(v[i]>v[i-1]){
      ans=max(ans,t);
      t=0;
    }
    else{
      t++;
    }
  }
  ans=max(ans,t);
  cout<<ans<<endl;
}


Measured memory_bytes: 1024
# 何回ループするか
times = int(input())
# トランプ生成
cards = [[False for i in range(13)] for j in range(4)]
pattern = ["S", "H", "C", "D"]

for time in range(times):
    ch,rank = input().split()
    rank = int(rank)
    cards[pattern.index(ch)][rank-1] = True

for i in range(4):
    for j in range(13):
        if cards[i][j] == False:
            print(pattern[i],j+1)



Measured memory_bytes: 5600
#include "iostream"
#include "algorithm"
#include "string"
#include "vector"
#include "cmath"
using namespace std;
int main(){
	string c1, c2, c3;
	cin >> c1 >> c2 >> c3;
	cout << c1[0] << c2[1] << c3[2] << endl;
	return 0;
}

Measured memory_bytes: 256
use std::io;
use std::cmp;


// read a line(without line feed)
fn read_line() -> String {
    let mut in_str = String::new();
    io::stdin().read_line(&mut in_str).unwrap();
    return in_str.trim().to_string();
}

// read wods on a line
pub fn read_words_in_line() -> Vec<String> {
    let s = read_line();
    return s.split_whitespace().map(|x| x.to_string()).collect::<Vec<String>>()
}

// read type t on a line
pub fn read_t_in_line<T : std::str::FromStr>() -> Vec<T> {
    let mut v : Vec<T> = Vec::new();
    for e in read_words_in_line().iter().map(|x| x.parse::<T>()) {
        if let Ok(r) = e {
            v.push(r);
        }
        else{
            return Vec::new();
        }
    }
    return v;
}

// sort slice
pub fn sort<T : std::cmp::Ord>(slice : &mut [T]) {
    slice.sort();
}
// sort slice by reverse order
pub fn sort_rev<T : std::cmp::Ord>(slice : &mut [T]) {
    slice.sort_by(|x, y| y.cmp(x));
}

pub fn min<T : std::cmp::Ord>(a : T, b : T) -> T{
    return cmp::min(a, b);
}

pub fn max<T : std::cmp::Ord>(a : T, b : T) -> T{
    return cmp::max(a, b);
}


fn main() {
    let v1 = read_t_in_line::<i64>();
    let (n, m) = (v1[0], v1[1]);
    let mut abs = vec![];
    for _ in 0..n {
        let tmp = read_t_in_line::<i64>();
        abs.push((tmp[0], tmp[1]));
    }
    abs.sort();
    let mut left = m;
    let mut ans = 0;
    for (a, b) in abs {
        let cnt = min(left, b);
        ans += cnt * a;
        left -= cnt;
        if left == 0 {
            break;
        }
    }
    println!("{}", ans);
}


Measured memory_bytes: 6396
#include <bits/stdc++.h>
#define rep(i,n) for(ll i=0;i<(n);i++)
#define rrep(i,n) for(ll i = 1; i <= (n); ++i)
#define drep(i,n) for(ll i = (n)-1; i >= 0; --i)
#define all(v) v.begin(),v.end()
#define len(x) (ll)(x).length()
#define maxs(x,y) x = max(x,y)
#define mins(x,y) x = min(x,y)
#define pb push_back
#define sz(x) (ll)(x).size()
#define v(T) vector<T>
#define vv(T) vector<vector<T>>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
ll gcd(ll a,ll b){if(a%b==0){return b;}else{return(gcd(b,a%b));}}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
const int INF=1e9;
const ll MX = 1e18;
const ll MOD=INF+7;
const int di[] = {-1,0,1,0};
const int dj[] = {0,-1,0,1};
const double PI=acos(-1);
const string tr="abcdefghijklmnopqrstuvwxyz";
#define dame { puts("-1"); return 0;}
#define yn {puts("Yes");}else{puts("No");}
#define YN {puts("YES");}else{puts("NO");}
const ll MAX = 1000001;
long long fac[MAX], finv[MAX], inv[MAX];
void COMinit() {fac[0] = fac[1] = 1;finv[0] = finv[1] = 1;inv[1] = 1;for (ll i = 2; i < MAX; i++){fac[i] = fac[i - 1] * i % MOD;inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;finv[i] = finv[i - 1] * inv[i] % MOD;}}
long long COM(ll n, ll k){if (n < k) return 0;if (n < 0 || k < 0) return 0;return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;}
ll llpow(ll n,ll i){ll cnt=n;  for(ll j=0;j<i-1;j++){n*=cnt;}return n;}

int main(){
  string s;
  cin>>s;
  int n=len(s);
  int ans=0;
  char state=s[0];
  rrep(i,n-1){
    if(state!=s[i]){
      ans++;
      state=s[i];
    }
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 3588
#include<stdio.h>

int main(void){
  int n, i, j, q, a, count = 0, S[10000];
  scanf("%d", &n);
  for(i=0;i<n;i++) scanf("%d ", &S[i]);
  scanf("%d", &q);
  for(i=0;i<q;i++){
    scanf("%d", &a);
    for(j=0;j<n;j++){
      if(S[j] == a){
        count++;
        break;
      }
    }
  }
  printf("%d\n", count);
  return 0;
}

Measured memory_bytes: 1844
#include<bits/stdc++.h>
#define rep(i,N) for(int i=0;i<(N);i++)
#define rrep(i, n) for (int i = (int)n-1; i >= 0; --i)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
using namespace std;
const long long MOD = 1e9 + 7;
const long long INF = 1e12;
const int inf = 1e9;
const int mod = 1e9+7;
typedef long long ll;
typedef pair<ll,int> P;
typedef set<int> S;

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; }

__attribute__ ((constructor))
void fastio() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(10);
}

int main(){
    int n;
    cin >> n;
    vector<int> a(n), b(n);
    rep(i, n) { 
        cin >> a[i] >> b[i];
    }
    bool ok = 0;
    int now = 0;
    rep(i,n){
        if(a[i]==b[i]){
            now++;
            if(now==3)
                ok = 1;
        }
        else
        {
            now = 0;
        }
        
    }
    if(ok){
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }
    
    return 0;
}

Measured memory_bytes: 3664
import qualified Data.ByteString.Char8 as C
import Data.List

main = C.interact $ put . sol . get

get = unfoldr (C.readInt . C.dropWhile (==' ')) . last . C.lines

put = C.pack . show

sol = (\(a,b) -> length a+length b `div` 2*2) . break (==True) . 
  sort . fmap (even . length) . group . sort


Measured memory_bytes: 18812
// Author : Sarthak Kapoor
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace std;
using namespace __gnu_pbds;
#define rep(i,n) for(int i=0;i<n;++i)
#define repa(i,a,n) for(int i=a;i<n;++i)
#define repr(i,n) for(int i=n-1;i>=0;--i)
#define repba(i,b,a) for(int i=b;i>=a;--i)
#define repab(i,a,b) for(int i=a;i<b;++i)
#define ll long long
#define pi pair<int,int> 
#define pii pair<pi,int>
#define ull unsigned long long
#define vi vector<int>
#define viip vector<pair<int,pair<int,int> > > 
#define mp make_pair
#define vip vector<pair<int,int> >
#define pb push_back 
#define fi first
#define sec second
#define all(v) v.begin(),v.end()
#define s(v) v.size()
ll mod = 1000000007;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());//use rng()%n for numbers in range [0,n-1]
ll gcd(ll a,ll b){
	if(b==0)return a;
	return gcd(b,a%b);
}
ll fastexp(ll x,ll a){
    ll res = 1;
    while(a>0){
        if(a&1){
            res = (res*x)%mod;
        }
        a=a>>1;
        x=(x*x)%mod;
    }
    return res;
}
ll inverse(ll n){
    return fastexp(n,mod-2);
}
template <typename T>
void add(T &a, T b){
	a += b;
	if(a >= mod)a -= mod;
}
template <typename T>
void sub(T &a, T b){
	a -= b;
	if(a < 0)a += mod;
}
template <typename T>
void mul(T &a, T b){
	a *= b;
	if(a >= mod)a %= mod;
}
int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	
	int r;
	cin>>r;
	double ans = M_PI*2*r;
	cout<<fixed<<setprecision(12)<<ans;	
	return 0;
}

Measured memory_bytes: 3804
#include<bits/stdc++.h>
#include <iomanip>
#include <iostream>
using namespace std;
using ll = unsigned long long;
const long long INF = 1LL << 60;
 
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
 
ll min(ll a, ll b){
    if(a < b) return a;
    else return b;
}
 
int main(void){
    int N; cin >> N;
    vector<int> p(N,0); for(int i = 0; i < N; i++) cin >> p[i];
    int a = -1, b;
    int ai = 0, bi = 0;
    for(int i = 0; i < N; i++){
        if(p[i] != i+1){
            if(a == -1){
                a = p[i];
                ai = i;
            }
            else{
                b = p[i];
                bi = i;
            }
        } 
    }
    p[ai] = b;
    p[bi] = a;
    bool OK = true;
    if(a != -1){
        for(int i = 0; i < N; i++){
            if(p[i] != i + 1) OK = false;
        }
    }
    if(OK) cout << "YES" << endl;
    else cout << "NO" << endl;
}

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

int main(){
    int n; cin>>n;
    set<int> s;
    for(int i=0;i<n;i++){
        int a; cin>>a;
        if(s.find(a)==s.end()) s.insert(a);
        else s.erase(a);
    }
    cout<<s.size()<<endl;
}

Measured memory_bytes: 4864
import core.bitop, std.algorithm, std.ascii, std.bigint, std.conv, std.math,
    std.functional, std.numeric, std.range, std.stdio, std.string, std.random,
    std.typecons, std.container, std.format;

// dfmt off
T lread(T = long)(){return readln.chomp.to!T();}
T[] lreads(T = long)(long n){return generate(()=>readln.chomp.to!T()).take(n).array();}
T[] aryread(T = long)(){return readln.split.to!(T[])();}
void scan(TList...)(ref TList Args){auto line = readln.split();
foreach (i, T; TList){T val = line[i].to!(T);Args[i] = val;}}
alias sread = () => readln.chomp();enum MOD = 10 ^^ 9 + 7;
alias PQueue(T, alias less = "a<b") = BinaryHeap!(Array!T, less);
// dfmt on

void main()
{
    float A, B;
    scan(A, B);
    foreach (x; 1 .. 10_000)
    {
        // writeln(x, " ", (x * 108) / 100);
        if (A == floor(x * 0.08) && B == floor(x * 0.1))
        {
            writeln(x);
            return;
        }
    }
    writeln(-1);
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
using namespace std;
const int N=100010;
bool st[N];

int main(){
    int n,k,r,s,p;
    cin>>n>>k>>r>>s>>p;
    char t[N];
    cin>>t;
    int sum=0;
    for(int i=0;i<n;i++){
        if(st[i]==false){
            if(i+k<n && t[i]==t[i+k]){
                st[i+k]=true;
            } 
            if(t[i]=='r') sum+=p;
            else if(t[i]=='s') sum+=r;
            else if(t[i]=='p') sum+=s;
        }
    }
    cout<<sum<<endl;
    return 0;
}

Measured memory_bytes: 384
#d=["a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z"]
#import numpy as np
#n=int(input())
#li=input().split()
#import fractions
#n=int(input())
#S=input()
#import math

lis=list(map(int,input().split()))
ans=0
if lis[0]>=13:
    ans=lis[1]
elif lis[0]>=6 and lis[0]<=12:
    ans=int(lis[1]/2)
else:
    ans=0
print(ans)


Measured memory_bytes: 2940
# coding:utf-8

import sys
from collections import deque

INF = float('inf')
MOD = 10 ** 9 + 7
dy, dx = (0, -1, 0, 1), (1, 0, -1, 0)

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x) - 1 for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def II(): return int(sys.stdin.readline())
def SI(): return input()


def main():
    r, g, b, n = LI()

    res = 0
    for ri in range(n // r + 1):
        for gi in range(n // g + 1):
            t = n - r * ri - g * gi
            if t >= 0 and t % b == 0:
                res += 1

    print(res)


if __name__ == '__main__':
    main()


Measured memory_bytes: 40684