akhauriyash/Code-Regression huggingface dataset:
/* author : akshatjai258 */
#include<bits/stdc++.h>
using namespace std;   
typedef long long ll; 
typedef pair<int, int> pii; 
typedef pair<ll, ll> pll; 
typedef pair<string, string> pss; 
typedef vector<int> vi; 
typedef vector<vi> vvi; 
typedef vector<pii> vii; 
typedef vector<ll> vl; 
typedef vector<vl> vvl; 
#define int ll
#define mod int(1e9+7)
#define inf int(1e9)
#define endl "\n"  
#define FOR(a, b, c) for (int(a) = (b); (a) < (c); ++(a)) 
#define FORN(a, b, c) for (int(a) = (b); (a) <= (c); ++(a)) 
#define fi first
#define mem0(a) memset(a,0,sizeof(a))
#define mem1(a) memset(a,-1,sizeof(a))
#define memf(a) memset(a,false,sizeof(a))
#define all(v) v.begin(),v.end() 
#define se second 
#define mp make_pair 
#define pb push_back 
#define w(x)   int x; cin>>x; while(x--)
#define ps(x,y)     fixed<<setprecision(y)<<x
void prep()
{
	ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
/*#ifndef ONLINE_JUDGE
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
#endif*/
		
}
int32_t main()
{
	prep();
	int n,k;
	cin>>n>>k;
	vi dp(n+1,inf),arr(n);
	dp[0]=0;
	for(int i=0;i<n;i++)
	{
		cin>>arr[i];
	}
	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];
			
	
	return 0;
}


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

int main() {
  string s;
  cin >> s;
  int n = s.size();
  string ans = "Yes";
  for(int i = 1; i <= n; i++){
    if(i%2 == 1 && s.at(i-1) == 'L'){
      ans = "No";
      break;
    }
    if(i%2 == 0 && s.at(i-1) == 'R'){
      ans = "No";
      break;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#define rep(i, start, end) for (int i = (int)start; i < (int)end; ++i)
#define rrep(i, start, end) for (int i = (int)start - 1; i >= (int)end; --i)
#define all(x) (x).begin(), (x).end()
using namespace std;
using ll = long long;
template<typename T> inline bool chmax(T& a, T b) {if (a < b) {a = b; return true;} return 0;}
template<typename T> inline bool chmin(T& a, T b) {if (a > b) {a = b; return true;} return 0;}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int H, W, K;
    cin >> H >> W >> K;
    vector<string> C(H);
    rep(i, 0, H) {
        cin >> C[i];
    }
    int ans = 0;
    rep(mask1, 0, 1 << H) rep(mask2, 0, 1 << W) {
        vector<string> CC(C);
        rep(i, 0, H) {
            if ((mask1 >> i) & 1) {
                rep(j, 0, W) {
                    CC[i][j] = '?';
                }
            }
        }
        rep(i, 0, W) {
            if ((mask2 >> i) & 1) {
                rep(j, 0, H) {
                    CC[j][i] = '?';
                }
            }
        }
        int cnt = 0;
        rep(i, 0, H) rep(j, 0, W) {
            if (CC[i][j] == '#') {
                ++cnt;
            }
        }
        if (cnt == K) {
            ++ans;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3616
N,K = map(int,input().split())
A = list(map(int,input().split()))
tmp = 0
tmp2 = 0
ans = 0
MOD = 10**9+7

for i in range(N):
  for j in range(i,N):
    if i == j:
      pass
    else:
      if A[i] > A[j]:
        tmp += 1
  for k in range(N):
    if A[i] > A[k]:
      tmp2 += 1  
  ans += tmp2*K*(K-1)//2+tmp*K
  ans %= MOD
  tmp = 0
  tmp2 = 0
print(ans)

Measured memory_bytes: 3188
var chunk = require('fs').readFileSync('/dev/stdin', 'utf8');
var lines = chunk.split('\n');

while (true) {
    var hw = lines.shift().split(' ').map(Number);
    var h = hw[0], w = hw[1];
    if (0 === h && 0 === w) {
        break;
    }
    var side = '';
    for (var i = 0; i < w; i++) {
        side += '#';
    }
    side += '\n';
    var rectangle = '';
    for (var i = 0; i < h; i++) {
        rectangle += side;
    }
    console.log(rectangle);
}

Measured memory_bytes: 15508
X, Y = list(map(int, input().split()))
x = y = 0
if X >= Y:
    x = X
    y = Y
else:
    x = Y
    y = X

def calcGCD(a, b):
    d = a % b
    if d != 0:
        a = b
        b = d
        return calcGCD(a, b)
    else:
        return b


print(calcGCD(x, y))


Measured memory_bytes: 5600
#include <iostream>
#include <complex>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <numeric>
#include <cstring>
#include <ctime>
#include <cstdlib>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <list>
#include <cmath>
#include <bitset>
#include <cassert>
#include <queue>
#include <stack>
#include <deque>
#include <random>
#include <iomanip>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
typedef long long int ll;
typedef long double ld;
typedef pair<int,ll> P;
typedef pair<P,P> PP;
const ll MOD=1000000007;
const ll MAX_N=500010;
const ll INF=999999999999999;



int main(){
    int n;
    cin>>n;
    vector<ll> a(n),b(n),c(n);
    for(int i=0;i<n;i++){
        cin>>a[i];
    }
    for(int i=0;i<n;i++){
        cin>>b[i];
    }
    for(int i=0;i<n;i++){
        cin>>c[i];
    }
    sort(a.begin(),a.end());
    sort(b.begin(),b.end());
    sort(c.begin(),c.end());
    vector<ll> B(n,0);
    for(int i=0;i<n;i++){
        ll bn=b[i];
        ll num=c.end()-upper_bound(c.begin(),c.end(),bn);
        B[i]=num;
    }
    for(int i=n-2;i>=0;i--){
        B[i]+=B[i+1];
    }
    ll ans=0;
    for(int i=0;i<n;i++){
        ll an=a[i];
        int itr=upper_bound(b.begin(),b.end(),an)-b.begin();
        ans+=B[itr];
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 6388
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; ++i)
#define REPP(i, n) for(int i = 1; i <= n; ++i)
#define REPR(i, n) for(int i = n-1; i >= 0; --i)
#define FOR(i, m, n) for(int i = m; i < n; ++i)
#define ALL(v) v.begin(), v.end()
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end());
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const ll MOD = 1000000007;
const ll INF = 1000000000;

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

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n,k,q; cin >> n >> k >> q;
    vector<int> ans(n);
    REP(i,q) {
        int a;cin >> a; --a;
        ++ ans[a];
    }
    REP(i,n) {
        cout << (k-(q-ans[i])>0 ? "Yes" : "No") << '\n';
    }
    return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <functional>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <bitset>
#include <cassert>
#include <exception>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<int,int> P;
#define rep(i,a,n) for(ll i = (a);i < (n);i++)
#define per(i,a,n) for(ll i = (a);i > (n);i--)
#define lep(i,a,n) for(ll i = (a);i <= (n);i++)
#define pel(i,a,n) for(ll i = (a);i >= (n);i--)
#define clr(a,b) memset((a),(b),sizeof(a))
#define pb push_back
#define mp make_pair
#define all(c) (c).begin(),(c).end()
#define sz size()
#define print(X) cout << (X) << endl
const ll INF = 1e+9+7;
ll n,m,l;
string s,t;
ll d[100000],dp[100][100];

int main(){
  cin >> n >> m >> l;
  if(m == l)puts("0");
  else if(m < l){
    if(n + m < l)print(l-(n+m));
    else puts("0");
  }else{
    if(l + n < m)print(m-(l+n));
    else puts("0");
  }
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#ifdef LOCAL
#include "debug.h"
#else
#define dump(...)
#endif
#define endl "\n"
#define ll long long
#define FOR(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define REP(i, x) for (int i = 0; i < (int)(x); i++)
#define REPS(i, x) for (int i = 1; i <= (int)(x); i++)
#define RREP(i, x) for (int i = ((int)(x)-1); i >= 0; i--)
#define RREPS(i, x) for (int i = ((int)(x)); i > 0; i--)
#define INF 2147483647
#define LLINF 9223372036854775807LL
#define vi vector<int>
#define vvi vector<vector<int>>
#define pi pair<int, int>
#define ALL(a) (a).begin(), (a).end()
#define BIT(n) (1LL << (n))
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end()) //sortしてからつかうこと
constexpr ll MOD = 1e9 + 7;
int dx[8] = {1, 0, -1, 0, 1, 1, -1, -1};
int dy[8] = {0, 1, 0, -1, 1, -1, 1, -1};
ll A, B, C, D, E, F, G, H, N, M, L, K, P, Q, R, W, X, Y, Z;
string S, T;
ll ans = 0;

template <typename T>
istream &operator>>(istream &is, vector<T> &vec) {
    for (T &x : vec)
        is >> x;
    return is;
}

int gcd(int m, int n) {
    return n == 0 ? m : gcd(n, m % n);
}
int lcm(int m, int n) {
    return (m / gcd(m, n)) * n;
}

signed main() {
    cin >> S;
    cout << S[0] + to_string(S.size() - 2) + S.back() << endl;
}

Measured memory_bytes: 3624
s=list(input())
S=list(set(s))
ans=100
for c in S:
  kari=0
  tmp=0
  for w in s:
    if w==c:
      kari=max(tmp, kari)
      tmp=0
    else:
      tmp+=1
  kari=max(tmp,kari)
  ans=min(ans, kari)
print(ans)

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

typedef long long ll;
using namespace std;

int main() {
    string s;
    cin >> s;
    int ans = 10000;
    for (int i = 0; i < (int)s.size() - 2; i++) {
        int diff = s[i + 2] + s[i + 1] * 10 + s[i] * 100;
        ans = min(ans, abs(diff - '7' * 100 - '5' * 10 - '3'));
    }
    cout << ans;
    return 0;
}


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

struct Solver {
	Solver() {
		ios::sync_with_stdio( false );
		cout << fixed << setprecision( 10 );
	}

	void solve() {
		int S, W;
		cin >> S >> W;
		cout << (S <= W ? "unsafe" : "safe") << endl;
	}
};

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


Measured memory_bytes: 3636
import scala.io.StdIn.readLine
import scala.math.{max,min}

object Main extends App {

  var m = readLine.split(" ").map(_.toInt)
  while( (m(0),m(1)) != (0,0) ){
    val Array(n,x) = m
    println( ( 1 until min(n-1,x/3) ).foldLeft(0) { (sum,i) => sum + max(min(n,(x-i+1)/2)- max(i+1,x-i-n),0)})

    m = readLine.split(" ").map(_.toInt)
  }
}

Measured memory_bytes: 43940
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#define int long long
#define ld long double

#define all(X) (X).begin(), (X).end()
#define reset(X) memset(X, 0, sizeof(X))
#define mp(a, b) make_pair(a, b)
#define pb push_back
#define endl '\n'
#define ff first
#define ss second


using namespace __gnu_pbds;
using namespace std;
const int mod=1e9+7;
 // const int mod=998244353;
 // const int mod=1e9+9;
const int INF=4e18+10;
// const int INF=4e18+10;
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
template <typename T>
using ordered_multiset = tree<T, null_type, less_equal<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define read(n) int n; cin>>n;
#define readv(x, n) vector<int> x(n); for(auto &i:x) cin>>i;


typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef pair<int, int> pii;

template<typename T1,typename T2>
void set_min(T1& a, T2 b)
{
    a=min(a, (T1)b);
}


int multiply(int a, int b, int in_mod){return (a*b)%in_mod;}
int mult_identity(int a){return 1;}


auto power(auto a, int b, int in_mod)
{
    auto prod=mult_identity(a);
    auto mult=a%in_mod;
    while(b!=0)
    {
        if(b%2)
        {
            prod=multiply(prod,mult, in_mod);

        }
        mult=multiply(mult, mult,in_mod);
        b/=2;
    }
    return prod;
}
int mod_inv(int q, int in_mod)
{

    return power(q, in_mod-2,in_mod);
}

int gcd(int a,int b){
    if(b==0) return a;
    return gcd(b,a%b);
}

int fact(int n,int in_mod){
    int f=1;
    for(int i=1;i<=n;i++) f=(f*i)%in_mod;
    return f;
}
int ncr(int n,int r,int in_mod){
    return (((fact(n,in_mod)*mod_inv(fact(r,in_mod),in_mod))%in_mod)*mod_inv(fact(n-r,in_mod),in_mod))%in_mod;
}

void solve()
{
    int a[5];
    int f;
    for(int i=0;i<5;i++){
         cin>>a[i];
         if(a[i]==0) f=i;
    }
    cout<<f+1<<endl;
}

signed main()

{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    cout<<fixed<<setprecision(10);
    #ifndef ONLINE_JUDGE
    if(fopen("INPUT.txt","r"))
    {
        freopen ("INPUT.txt" , "r" , stdin);
        freopen ("OUTPUT.txt" , "w" , stdout);
    }
    #endif
    auto clk=clock();
    mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
    // -------------------------------------Code starts here---------------------------------------------------------------------

    int t=1;
    //cin>>t;
    for(int test=1;test<=t;test++)
    {
        // cout<<"Case #"<<test<<": ";
        // cout<<endl;
        solve();
        // cout<<endl;

    }

    // -------------------------------------Code ends here------------------------------------------------------------------


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

Measured memory_bytes: 3808
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep_(i, n, m) for (int i = n; i < (int)(m); i++)
#define all(v) v.begin(), v.end()
#define int long long
#define stoi stoll
//#define _GLIBCXX_DEBUG



signed main() {
  int N; cin >> N;
  
  int ans = 0;
  rep(i, N+1) {
    if(i>0) {
      ans += (N+i-1)/i;
    }
  }
  cout << ans-N << endl;

}


Measured memory_bytes: 3620
#include<bits/stdc++.h>
using namespace std;
int main(void){
    int x=1;
    int y;
    
    for(int i=0; i<5; i++){
       cin>>y;
       if(y==0){
           break;
       }else {
           x++;
       }
    }
cout<<x<<endl;
}

Measured memory_bytes: 3596
#include <bits/stdc++.h>
#define EB emplace_back

typedef std::vector <int> vector;
const int N = 200054;

int n, m;
int b[N];
vector ri[N];

inline void down(int &x, const int y) {x > y ? x = y : 0;}
inline int min(const int x, const int y) {return x < y ? x : y;}

namespace ST {
	#define segc int M = (L + R - 1) >> 1, lc = id << 1, rc = lc | 1
	int x[N * 4], *val[N];

	void build(int id, int L, int R) {
		x[id] = INT_MAX;
		if (L == R) {val[L] = x + id; return;}
		segc; build(lc, L, M), build(rc, M + 1, R);
	}

	void adj(int id, int L, int R, int h, int v) {
		if (L == R) {x[id] = v; return;}
		segc; h <= M ? adj(lc, L, M, h, v) : adj(rc, M + 1, R, h, v);
		x[id] = min(x[lc], x[rc]);
	}

	int range(int id, int L, int R, int ql, int qr) {
		if (ql <= L && R <= qr) return x[id];
		segc, s = INT_MAX;
		if (ql <= M) down(s, range(lc, L, M, ql, qr));
		if (qr > M) down(s, range(rc, M + 1, R, ql, qr));
		return s;
	}
}

int main() {
	int i, l, r, ans = 0;
	scanf("%d", &n);
	for (i = 1; i <= n; ++i) scanf("%d", b + i), ans += !b[i];
	scanf("%d", &m);
	for (i = 0; i < m; ++i) scanf("%d%d", &l, &r), ri[l].EB(r);
	ST::build(1, 0, n), ST::adj(1, 0, n, 0, 0);
	for (i = 1; i <= n; ++i) {
		for (int r : ri[i]) ST::adj(1, 0, n, r, ST::range(1, 0, n, i - 1, r));
		if ((l = *ST::val[i - 1] + (b[i] ? 1 : -1)) < *ST::val[i])
			ST::adj(1, 0, n, i, l);
	}
	printf("%d\n", ans + *ST::val[n]);
	return 0;
}

Measured memory_bytes: 14336
# coding: utf-8

import math
import fractions
import heapq
import collections
import re
import array
import bisect

from collections import Counter, defaultdict


def array2d(dim1, dim2, init=None):
    return [[init for _ in range(dim2)] for _ in range(dim1)]


N = int(input())
d4 = 0
d2 = 0
for n in map(int, input().split(" ")):
    if n % 4 == 0:
        d4 += 1
    elif n % 2 == 0:
        d2 += 1
d1 = N - d4 - d2

if d2:
    print(["No", "Yes"][d4 >= d1])
else:
    print(["No", "Yes"][d4 >= d1 - 1])


Measured memory_bytes: 13172
MOD = 998244353
max2 = lambda x,y: x if x > y else y
min2 = lambda x,y: x if x < y else y

N,K = map(int,input().split())
f = lambda x: (int(x[0]),int(x[1])+1)
lr = [f(input().split()) for _ in range(K)]

dp = [0]*(N+1)

dp[1] = 1

for i in range(2,N+1):
    t = 0
    for l,r in lr:
        if l > i:
            continue
        a = i - l
        b = max2(0, i - r)
        t += dp[a] - dp[b]
    dp[i] = (dp[i-1]+t)%MOD
print((dp[-1]-dp[-2])%MOD)

Measured memory_bytes: 69652
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main
{
	public static void main(String[] Arguments) throws IOException
	{
		BufferedReader BR = new BufferedReader(new InputStreamReader(System.in)); StringTokenizer ST = new StringTokenizer(BR.readLine());
		int A = Integer.parseInt(ST.nextToken()), B = Integer.parseInt(ST.nextToken()), C = Integer.parseInt(ST.nextToken()), K = Integer.parseInt(ST.nextToken()), Sum = 0;
		Sum += Math.min(A, K);
		K -= Math.min(A, K);
		K -= Math.min(B, K);
		Sum -= Math.min(C, K);
		System.out.println(Sum);
	}
}


Measured memory_bytes: 25388
#pragma GCC target ("avx2")
#pragma GCC optimize ("unroll-loops")
#pragma GCC optimize ("O3")
#include "bits/stdc++.h"
#include <unordered_set>
#include <unordered_map>
#include <random>
using namespace std;
typedef long long ll;
const ll MOD = 1'000'000'007LL; /*998'244'353LL;*/
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for(int (i)=0; (i)<(n); (i)++)
const int dx[4]={ 1,0,-1,0 };
const int dy[4]={ 0,1,0,-1 };

int N, M;
bool con[700][700] ={};

int gro[700];
vector<pair<int, int>> v;

int dp[701][701];
int solve(int n, int a, int b){
    if(n == v.size()) return abs(a-b);
    if(dp[a][b] != -1) return dp[a][b];
    return dp[a][b] = min(solve(n+1, a+v[n].first, b+v[n].second),
        solve(n+1, a+v[n].second, b+v[n].first));
}

signed main(){
    cin >> N >> M;
    rep(i, M){
        int A, B;
        cin >> A >> B;
        con[A-1][B-1] = true;
        con[B-1][A-1] = true;
    }

    memset(gro, -1, sizeof(gro));
    rep(i, N){
        if(gro[i] == -1){
            gro[i] = i<<1;
            queue<int> que;
            que.push(i);
            while(!que.empty()){
                int j = que.front();
                que.pop();
                rep(k, N){
                    if(j == k) continue;
                    if(!con[j][k]){
                        if(gro[k] == -1){
                            gro[k] = gro[j]^1;
                            que.push(k);
                        }
                        if(gro[k] != (gro[j]^1)){
                            cout << -1 << endl;
                            exit(0);
                        }
                    }
                }
            }
            int a = 0, b = 0;
            rep(j, N){
                if(gro[j] == (i<<1)) a++;
                if(gro[j] == (i<<1)+1) b++;
            }
            v.pb({ a,b });
        }
    }

    memset(dp, -1, sizeof(dp));
    int ans = solve(0, 0, 0);
    int a = (N+ans)/2;
    int b = (N-ans)/2;
    cout << a*(a-1)/2 + b*(b-1)/2 << endl;
}

Measured memory_bytes: 6024
#include<iostream>
#include<string>
#include<math.h>
#include<stdio.h>

using namespace std;

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

    while (n != 0)
    {
        double a=0;
        double m = 0;
        int s[1000] = {0};

        for(int i=0;i<n;i++)
        {
            cin>>s[i];
            m = m + s[i];
        }
        m= m/n;

        for(int i=0;i<n;i++)
        {
            a = a + pow((s[i]-m),2);
        }
        a = a/n;

        printf("%.5f\n",pow(a,0.5));

        cin>>n;
    }

    return 0;
}

Measured memory_bytes: 1252
def main():
    # 入力
    n, m = map(int, input().split())
    ls = []
    for i in range(m):
        ls.append(list(map(int, input().split())))
    pls = list(map(int, input().split()))



    boolls = [[]]
    for i in range(n):
        tmpls = []
        for x in boolls:
            y = x.copy()
            x.append(True)
            y.append(False)
            tmpls.append(x)
            tmpls.append(y)
        boolls = tmpls

    cnt = 0
    for z in boolls:
        on = True
        for i in range(len(ls)):
            li = ls[i]
            pi = pls[i]

            lix = li[1:]

            oncnt = 0
            for ix in lix:
                if z[ix-1]:
                    oncnt += 1

            if oncnt % 2 != pi:
                on = False
                break
        if on:
            cnt += 1

    print(cnt)



main()


Measured memory_bytes: 3188
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <algorithm>


using namespace std;

int main()
{
    char a[5][5];
    for(int i=1;i<=3;i++)
    {
        scanf("%s",a[i]);
    }
    printf("%c%c%c\n",a[1][0],a[2][1],a[3][2]);
    return 0;
}


Measured memory_bytes: 256
n,m = map(int,input().split())
L = []
for i in range(m):
    li = list(map(int,input().split()))
    L.append(li)

li = []
for i,j in enumerate(L):
    li.append(j+[i])
li.sort(key = lambda x:(x[0],x[1]))

li.append([0,0,0])

k,r = li[0][0],1
for i in range(m):
    if li[i][0] == k:
        if li[i+1][1] == li[i][1]:
            li[i][1] = r
            li[i+1][1] = r
        else:
            li[i][1] = r
            r +=1
    else:
        k = li[i][0]
        r = 1
        li[i][1] = r
        r +=1

li.pop()

li.sort(key = lambda x:x[2])

for i in range(m):
    print("{:06d}".format(li[i][0])+"{:06d}".format(li[i][1]))

Measured memory_bytes: 49660
local n, a = io.read("*n", "*n")
local t = {}
for i = 1, n * 50 * n do
  t[i] = 0
end
for i = 1, n do
  local x = io.read("*n")
  for j = i - 1, 1, -1 do
    for k = n * 50 - x, 1, -1 do
      if 0 < t[n * 50 * (j - 1) + k] then
        t[n * 50 * j + k + x] = t[n * 50 * j + k + x] + t[n * 50 * (j - 1) + k]
      end
    end
  end
  t[x] = t[x] + 1
end
local cnt = 0
for i = 1, n do
  cnt = cnt + t[n * 50 * (i - 1) + a * i]
end
print(cnt)


Measured memory_bytes: 2424
#include<bits/stdc++.h>
#define fast ios::base_sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define int long long int
#define M 1000000007
#define pie 3.141592653589793238
using namespace std;


signed main(){  
    int n;cin >> n;
    string s;cin >> s;
    int ans = 0;
    for(int i=0; i<s.size()-2; i++){
        if(s[i] == 'A'){
            if(s[i+1] == 'B' && s[i+2] == 'C')
                ans++;
        }
    }
    cout << ans;
    return 0;
}

Measured memory_bytes: 256
n = int(input())
A = list(map(int,input().split()))
B = list(map(int,input().split()))
cnt = 0
for i in range(n):
    v=min(A[i],B[i])
    cnt +=v
    B[i]-=v
    plus = A[i+1] if B[i]>=A[i+1] else B[i]
    A[i+1]= 0 if B[i]>=A[i+1] else A[i+1]-B[i]
    cnt += plus
print(cnt)

Measured memory_bytes: 90704
#include<cstdio>
const int MAXN=43,MAXS=(1<<18)+3,MOD=1000000007;

int N,X,Y,Z;
int dp[MAXN][MAXS];
int pow10[MAXN];

int main()
{
	scanf("%d%d%d%d",&N,&X,&Y,&Z);
	pow10[0]=1;
	for(int i=1;i<=N;i++)
		pow10[i]=(pow10[i-1]*10ll)%MOD;
	int ans=0;
	dp[0][1]=1;
	for(int i=0;i<=N;i++)
		for(int s=1;s<(1<<18);s++)
			if(dp[i][s])
			{
				/*printf("dp[%d][",i);
				for(int k=0;k<=17;k++)
					if(s&(1<<k))
						printf("%d ",k);
				printf("]=%d\n",dp[i][s]);*/
				
				
				if((s&(1<<Z))&&(s&(1<<(Y+Z)))&&(s&(1<<(X+Y+Z))))
				{
					(ans+=1LL*dp[i][s]*pow10[N-i]%MOD)%=MOD;
					continue;
				}
				for(int k=1;k<=10;k++)
					(dp[i+1][((s<<k)|1)&((1<<18)-1)]+=dp[i][s])%=MOD;
			}
		
	printf("%d\n",ans);
	
	return 0;
}


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

int main() {
	string a,b;
	cin >> a >> b;
	if(a==b.substr(0,b.size()-1)){
		cout << "Yes" << endl;
	}else{
		cout << "No" << endl;
	}
}


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

#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n - 1; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i <= n; i++)
#define FORR(i, m, n) for(int i = m; i >= n; i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define VSORTR(v) sort(v.rbegin(), v.rend());
#define ALL(v) (v).begin(),(v).end()
using namespace std;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<ll, ll>;
const ll mod = 1e9+7;


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

    ll x,a;cin>>x>>a;
    if(x<a)cout<<0;
    else cout<<10;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>

int main() {
  int n, x;
  std::cin >> n;
  std::vector<int> a;
  for (int i = 0; i < n; i++) {
    std::cin >> x;
    a.push_back(x);
  }
  for (int i = n - 1; i >= 0; i--) {
    std::cout << a.at(i);
    if (i > 0) {
      std::cout << " ";
    }
  }
  std::cout << std::endl;
}



Measured memory_bytes: 3148
//khodaya khodet komak kon
#include <bits/stdc++.h>

#define F first
#define S second
#define pb push_back
#define all(x) x.begin(), x.end()
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math")
#define int long long

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;

const int N = 200000 + 10;
const ll MOD = 998244353;
const ll INF = 1000000010;
const ll LOG = 20;

int fen[2][N], n, k, a[N], ans, Fac;

int POW(int a, int b){
	int res = 1;
	while (b){
		if (b & 1) res = res * 1ll * a % MOD;
		b >>= 1;
		a = a * 1ll * a % MOD;
	}
	return res;
}

inline int add(int a, int b){
	a += b;
	if (a >= MOD) a -= MOD;
	return a;
}

inline int mul(int a, int b){
	return a * 1ll * b % MOD;
}

inline int minu(int a, int b){
	a -= b;
	if (a < 0) a += MOD;
	return a;
}

inline void Add(int ind, int id, int x){
	for (; id < N; id += id & (-id)) fen[ind][id] = (fen[ind][id] + x) % MOD;
	return;
}

inline int get(int ind, int id){
	int res = 0;
	for (; id > 0; id -= id & (-id)) res = (res + fen[ind][id]) % MOD;
	return res;
}

int32_t main(){
	ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	cin >> n >> k;
	Fac = 1;
//	cout << POW(2, 4) << '\n';
	for (int i = 3; i <= k; i++) Fac = Fac * 1ll * i % MOD;
	for (int i = 1; i <= n; i++) cin >> a[i];
	int tot = mul(POW(k, n - k), Fac * 2 % MOD);
//	cout << tot << '\n';
	for (int i = 1; i <= n; i++){
		int x = max(k, i);
		int res = get(0, a[i]);
//		cout << res << '\n';
		ans = add(ans, mul(res,mul(mul(POW(k - 1, x), POW(k, n - x)), Fac)));
		res = minu(get(0, n), get(0, a[i]));
//		cout << ans << '\n';
		int ted = minu(get(1, n), get(1, a[i]));
		ted = ted * 1ll * tot % MOD;
		ted = minu(ted, mul(res,mul(mul(POW(k - 1, x), POW(k, n - x)), Fac)));
		ans = add(ans, ted);
//		cout << ans << '\n';
		Add(1, a[i], 1);
		Add(0, a[i], mul(POW(k, x - k), POW(k - 1, MOD - 1 - x)));
	}
//	cout << ans << '\n';
	cout << mul(ans, POW(tot, MOD - 2));
	return 0;
}

/*
4 2
4 2 1 3
*/


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

int main()
{
    int x, y, z;
    cin >> y >> z >> x;
    cout << x << " " << y << " " << z << endl;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <climits>
#include <queue>
using namespace std;

#define INF INT_MAX/3
#define MP make_pair

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

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

void solve(int H,int W){
    int maze[100][100];
    for(int i=0;i<2*H-1;i++){
        if(i%2==0){
            for(int j=0;j<W-1;j++) cin>>maze[i][j];
        }else{
            for(int j=0;j<W;j++) cin>>maze[i][j];
        }
    }

    //(0,0) -> (H-1,W-1)
    vector<vector<int>> d(H,vector<int>(W,INF));
    d[0][0] = 1;
    queue<pii> que;
    que.push(MP(0,0));
    while(!que.empty()){
        pii q = que.front();
        que.pop();
        int x = q.first;
        int y = q.second;
        
        for(int i=0;i<4;i++){
            int nx = x + dx[i];
            int ny = y + dy[i];
            if(nx<0 or ny<0 or nx>=H or ny>=W) continue;
            if(i==0 and maze[2*x+1][y]==0 and d[nx][ny]==INF){
                d[nx][ny]=d[x][y]+1;
                que.push(MP(nx,ny));
            }
            if(i==1 and maze[2*x][y]==0 and d[nx][ny]==INF){
                d[nx][ny]=d[x][y]+1;
                que.push(MP(nx,ny));
            }
            if(i==2 and maze[2*x-1][y]==0 and d[nx][ny]==INF){
                d[nx][ny]=d[x][y]+1;
                que.push(MP(nx,ny));
            }
            if(i==3 and maze[2*x][y-1]==0 and d[nx][ny]==INF){
                d[nx][ny]=d[x][y]+1;
                que.push(MP(nx,ny));
            }
        }
    }

    if(d[H-1][W-1]==INF){
        cout << 0 << endl;
        return;
    }
    cout << d[H-1][W-1] << endl;
    return;
}

int main(){
    int w,h;
    while(cin>>w>>h){
        if(w==0 and h==0) break;
        solve(h,w);
    }
}

Measured memory_bytes: 3168
def main():
    N = int(input())
    S = str(input())
    
    ans = []
    now = "_"
    for i in range(N):
        if now != S[i]:
            now = S[i]
            ans.append(S[i])
            
    print(len(ans))

if __name__ == "__main__":
    main()

Measured memory_bytes: 3956
#include<iostream>
#include<cmath>
#include<complex>
using namespace std;
typedef long double D;
typedef complex<D> P;
const D PI = acos(-1);

D cross(P x,P y){return imag(conj(x)*y);}

P rot(P v, D s){
  s = 2*PI-s;
  return P(real(v)*cos(s) - imag(v)*sin(s), real(v)*sin(s) + imag(v)*cos(s));
}

D area(P a, P b, P c){
  return cross(c-a,b-a)/2;
}

D r,x,y;
int n;
D p[10];
P p1[10],p2[10];

int main(){
  cin >> r >> x >> y >> n;
  for(int i=0;i<n;i++)cin >> p[i];

  p1[0] = p2[n-1] = P(0,r);
  for(int i=0;i<n-1;i++){
    D seta = 2*PI*p[i]/100;
    p2[i] = rot(p1[i],seta);
    p1[i+1] = p2[i];
  }

  for(int i=0;i<n;i++){
    D tri = area(P(0,0),p1[i],p2[i]);
    D curve = r*r*PI * p[i]/100;
    D comp = curve-tri + area(P(x,y),p1[i],p2[i]);
    cout << floor(comp*100/curve) << (i==n-1?"\n":" ");
  }
}

  

Measured memory_bytes: 1312
#include<iostream>
#include<vector>
#include<stdlib.h>
#include<time.h>
#include<math.h>
#include<string.h>
#include<algorithm>
#include<queue>
using namespace std;

int main(void){
 int A,P;
 cin>>A>>P;

 cout<<(A*3+P)/2<<endl;
 return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FAST ios_base::sync_with_stdio(0); cin.tie(); cout.tie();

#define MAXX 500005
#define PI 3.14159265358979323846264338327950
#define F first
#define S second
#define ll   long long int
#define mod  1000000007



int main()
{
	FAST;
	ll n;
	cin >> n;
	string s;
	cin >> s;
	string a = "";
	a += s[0];
	for(ll i = 1; i < s.size(); i ++){
		if(s[i] != s[i-1]){
			a += s[i];
		}
	}
	cout << a.size();
}

Measured memory_bytes: 3768
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
using namespace std;
struct State { int x[4][4]; };
char F[4][4]; vector<pair<int, int>>v; string U[100]; int V[100], dp[10009];
int solve(string S, int depth, int cx, int cy, State Y) {
	if (depth == S.size())return 1;
	int dx[8] = { 1,1,1,0,-1,-1,-1,0 }, dy[8] = { -1,0,1,1,1,0,-1,-1 };
	int cnt = 0;
	for (int i = 0; i < 8; i++) {
		int ex = cx + dx[i], ey = cy + dy[i];
		if (ex < 0 || ey < 0 || ex >= 4 || ey >= 4)continue;
		if (Y.x[ex][ey] == 0 && F[ex][ey] == S[depth]) {
			State Z = Y; Z.x[ex][ey] = 1;
			cnt += solve(S, depth + 1, ex, ey, Z);
		}
	}
	return cnt;
}
int main() {
	int n; cin >> n;
	for (int i = 0; i < n; i++) { cin >> U[i] >> V[i]; }
	for (int i = 0; i < 16; i++)cin >> F[i / 4][i % 4];
	for (int i = 0; i < n; i++) { 
		int c = 0;
		for (int j = 0; j < 16; j++) {
			if (F[j / 4][j % 4] != U[i][0])continue;
			State R; for (int k = 0; k < 16; k++)R.x[k / 4][k % 4] = 0; R.x[j / 4][j % 4] = 1;
			c += solve(U[i], 1, j / 4, j % 4, R);
		}
		for (int j = 0; j < 20; j++) {
			if (c >= (1 << j)) { v.push_back(make_pair(V[i] * (1 << j), U[i].size()*(1 << j))); c -= (1 << j); }
			else { v.push_back(make_pair(V[i] * c, U[i].size()*c)); break; }
		}
	}
	int T; cin >> T; int maxn = 0;
	for (int i = 0; i < v.size(); i++) {
		for (int j = T; j >= v[i].second; j--) {
			dp[j] = max(dp[j], dp[j - v[i].second] + v[i].first); maxn = max(maxn, dp[j]);
		}
	}
	cout << maxn << endl;
	return 0;
}

Measured memory_bytes: 3220
#include<bits/stdc++.h>
#include<vector>
#include<list>
#include<stack>
#include<queue>
#include<algorithm>
using namespace std;

/**
 * vector<int>ar(3);
 * for(auto&e:ar){
 *     scanf("%d",&e);
 * }
 * sort(ar.begin(),ar.end())
 * int sum=accumulate(ar.begin(),ar.end(),0);
 ***/

int main(){
    double pai=3.141592653589;
    int n,m;
    scanf("%d %d",&n,&m);
    vector<int> ar(m);
    for(auto&e:ar){
        scanf("%d",&e);
    }
    int INF=1<<28, MAX_N=50010;
    int dp[MAX_N];
    fill(dp, dp+MAX_N, INF);
    dp[n]=0;
    for(int i=n;i>0;i--){
        for(int j=0;j<m;j++){
            dp[i-ar[j]]=min(dp[i]+1,dp[i-ar[j]]);
        }
    }
    printf("%d\n",dp[0]);
    return 0;
}

Measured memory_bytes: 1404
N=int(input())
S=0
canuse=[False]*40
for i in range(N):
  A=int(input())
  S^=A
  for k in range(40):
    if A&(1<<k):
      canuse[k]=True
      break
ans=0
for k in range(40)[::-1]:
  if S&(1<<k):
    if canuse[k]:
      S^=(1<<(k+1))-1
      ans+=1
    else:
      print(-1)
      exit()
print(ans)

Measured memory_bytes: 51048
#include<iostream>
#include<cstdio>
#include<stdio.h>
#include<algorithm>
#include<cmath>
#include<utility>
#include<cstring>
#include<string>
#include<queue>
#include<vector>
#include<stack>
#include<set>
#include<map>
#include<bitset>
#define inf 0x3f3f3f3f
using namespace std;
typedef long long LL;
typedef pair<int,int> pll;
const int maxn= 1e6+10;
const int mod =1e9+7;
const double EPS = 1e-6;

int a[maxn];

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int n,x,y;
    cin >> n >> x >> y;
    for(int i=1;i<=n;i++)
    {
        int ans;
        for(int j=i+1;j<=n;j++)
        {
            ans=min(j-i,abs(x-i)+abs(j-y)+1);
            a[ans]++;
        }
    }
    for(int i=1;i<=n-1;i++)
        cout << a[i] << endl;
    return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
// Begin Header {{{
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
using Graph = vector<vector<ll>>;
#define rep(i,n) for(ll i=0; i<n; i++)
#define loop(i, j, n) for(ll i=j; i<n; i++)
#define all(x) (x).begin(), (x).end()
constexpr int INF  = 0x3f3f3f3f;
const long long mod=1e9+7;
const long double PI = acos(-1);
// }}} End Header

int main() {
	string s;
	cin >> s;
	map<char, int> t;
	rep(i,s.length()){
		t[s[i]]++;
	}
	for(const auto& x : t){
		if(x.second%2!=0){
			puts("No");
			return 0;
		}
	}
	puts("Yes");
	return 0;
}

Measured memory_bytes: 3632
N, K = map(int, input().split())
S = [tuple(map(int, input().split())) for _ in range(N)]

S.sort(key=lambda x: -x[1])
st = set()
first_acc, other_acc = [0], [0]
for t, d in S:
  if t in st:
    other_acc.append(other_acc[-1] + d)
  else:
    st.add(t)
    first_acc.append(first_acc[-1] + d)

ans = 0
for i in range(K + 1):
  if len(first_acc) <= i or len(other_acc) <= K - i:
    continue
  ans = max(ans, first_acc[i] + other_acc[K - i] + i * i)

print(ans)

Measured memory_bytes: 32840
parseInt(x) = parse(Int, x)
parseBigInt(x) = parse(BigInt, x)
parseFloat(x) = parse(Float64, x)
parseBigFloat(x) = parse(BigFloat, x)
parseMap(x::Array{SubString{String},1}) = map(parseInt, x)

function main()
    n,m=parseMap(split(readline()))
    a=sort(parseMap(split(readline())))
    l,r=1,10^10
    x=0                 # 答え
    while r-l>1
        i=l+(r-l)÷2     # 割引券を使う基準となる価格
        d=m             # 割引券の数
        k=0             # 何円必要か
        for j in 1:n
            num=a[j]
            while i<=num
                num÷=2
                d-=1
            end
            k+=num
        end
        if d>=0
            x=k-i÷2*d
            r=i         # d>=0のとき(割引券があまった/ピッタリのとき)は基準を下げる
        else
            l=i         # d<0のとき(割引券が足りなかったとき)は基準を上げる
        end
    end
    println(max(x,0))
end
main()

Measured memory_bytes: 171272
/* Manish Pant - insider_pants */

#include <bits/stdc++.h>
using namespace std;
#ifndef ONLINE_JUDGE
#include "debug.h"
#endif

#define F first
#define S second
#define endl "\n"
#define pb push_back
typedef long long ll;
typedef long double ldob;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

void fast()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
}


int main()
{
    fast();
    int a; cin >> a;

    cout << a + a * a + a * a * a << endl;
}

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

int main() {
    string n; cin >> n;
    int count = 0;
    for(int i = 0; i < n.size(); i ++) {
        if(n[i]=='9') count ++;
    }
    cout << (count > 0 ? "Yes" : "No") << endl;
}

Measured memory_bytes: 256
#[allow(unused_macros)]
macro_rules! scan {
    () => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.trim().to_string()
        }
    };
    (;;) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.trim().split_whitespace().map(|s| s.to_string()).collect::<Vec<String>>()
        }
    };
    (;;$n:expr) => {
        {
            (0..$n).map(|_| scan!()).collect::<Vec<_>>()
        }
    };
    ($t:ty) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.trim().parse::<$t>().unwrap()
        }
    };
    ($($t:ty),*) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            (
                $(iter.next().unwrap().parse::<$t>().unwrap(),)*
            )
        }
    };
    ($t:ty;;) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.split_whitespace()
                .map(|t| t.parse::<$t>().unwrap())
                .collect::<Vec<_>>()
        }
    };
    ($t:ty;;$n:expr) => {
        (0..$n).map(|_| scan!($t;;)).collect::<Vec<_>>()
    };
    ($t:ty; $n:expr) => {
        (0..$n).map(|_|
                    scan!($t)        ).collect::<Vec<_>>()
    };
    ($($t:ty),*; $n:expr) => {
        (0..$n).map(|_|
                    scan!($($t),*)
        ).collect::<Vec<_>>()
    };
}
fn f(b: i64, n: i64) -> i64 {
    let mut rem = n;
    let mut ret = 0;
    while rem > 0 {
        ret += rem % b;
        rem /= b;
    }
    ret
}

fn main() {
    let n = scan!(i64);
    let s = scan!(i64);
    if n == s {
        println!("{}", n + 1);
        return;
    }

    for b in 2..(n as f64).sqrt() as i64 + 1 {
        if f(b, n) == s {
            println!("{}", b);
            return;
        }
    }

    let rem = n - s;
    let mut divisors = vec![];
    for b_minus_1 in 1..(rem as f64).sqrt() as i64 + 1 {
        if rem % b_minus_1 == 0 {
            let b = b_minus_1 + 1;
            if f(b, n) == s {
                divisors.push(b);
            }
            let b = rem / b_minus_1 + 1;
            if f(b, n) == s {
                divisors.push(b)
            }
        }
    }

    divisors.sort();
    println!("{}", divisors.first().unwrap_or(&-1))
}


Measured memory_bytes: 4352
public class Main{
  public void run(java.io.InputStream in, java.io.PrintStream out){
    java.util.Scanner sc = new java.util.Scanner(in);
/*answer*/
    int n;
    int[] a;
    int i;

    a = new int[31];
    a[1] = 1; a[2] = 2; a[3] = 4;
    for(i = 4;i < 31;i++)a[i] = a[i - 1] + a[i - 2] + a[i - 3];

    for(;;){
      n = sc.nextInt();
      if(n == 0)break;
      else if(a[n] % 3650 == 0)out.println(a[n] / 3650);
      else out.println(a[n] / 3650 + 1);
    }

    sc.close();
  }
  public static void main(String[] args){
    (new Main()).run(System.in, System.out);
  }
}

Measured memory_bytes: 17188
#include<bits/stdc++.h>
using namespace std;
#define sz(x) (int)x.size()
#define pb push_back
#define mp make_pair
#define ll long long 
#define mod 1000000007
void fast(){
  ios_base::sync_with_stdio(false);cin.tie(NULL);
}
int n,m;
int cnt=1;
int ans=1;
vector<int> adj[200001];
bool visited[200001]={0};
void dfs(int node){
  visited[node]=1;
  ans=max(cnt,ans);
  for(int next:adj[node]){
    if(!visited[next]){
      dfs(next);
      cnt++;
      //cout<<cnt<<"\n";
    }
  }
  ans=max(cnt,ans);
}
int main() {
   fast();
   cin>>n>>m;
   map<pair<int,int>,int> mt;
   for(int i=0;i<m;i++){
     int u,v;
     cin>>u>>v;
     --u;--v;
     if(mt[{u,v}]==1 ||  mt[{v,u}]==1){
         ;
     }else{
     adj[u].pb(v);
     adj[v].pb(u);
     mt[{u,v}]=1;
     }
   }
   for(int i=0;i<n;i++){
       if(!visited[i]){
        dfs(i);
        cnt=1;
       }
   }
   cout<<ans<<"\n";

   
   
}
 

Measured memory_bytes: 45924
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
const ll MOD = 1e9 + 7;
const ll INF = 1LL << 60;
const double PI = 3.141592653589793238;
const double EPS = 1e-10;
int cntS[100001];
int cntT[100001];
int main() {
	string S, T;
	cin >> S >> T;
	for (int i = 0; i < S.size(); i++) {
		if (i > 0) cntS[i] += cntS[i - 1];
		if (S[i] == 'A') cntS[i]++;
		else cntS[i] += 2;
	}
	for (int i = 0; i < T.size(); i++) {
		if (i > 0) cntT[i] += cntT[i - 1];
		if (T[i] == 'A') cntT[i]++;
		else cntT[i] += 2;
	}
	int q;
	cin >> q;
	for (int i = 0; i < q; i++) {
		int a, b, c, d;
		cin >> a >> b >> c >> d;
		a--; b--; c--; d--;
		int s = cntS[b];
		if (a > 0) s -= cntS[a - 1];
		int t = cntT[d];
		if (c > 0) t -= cntT[c - 1];
		if (s % 3 == t % 3) {
			cout << "YES" << endl;
		}
		else {
			cout << "NO" << endl;
		}
	}
}

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

#define fi first
#define se second
#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repl(i,0,n)
#define each(itr,v) for(auto itr:v)
#define pb(s) push_back(s)
#define mp(a,b) make_pair(a,b)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define maxch(x,y) x=max(x,y)
#define minch(x,y) x=min(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt(x) bitset<32>(x).count()

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

#define INF INT_MAX/3

#define MAX_N 1000

int n;
int a[111111];
int b[111111];

int main(){
	cin.sync_with_stdio(false);
	cin>>n;
	rep(i,n)cin>>a[i];
	rep(i,n)b[i]=a[i];
	sort(b,b+n);
	int res=0;
	rep(i,n){
		int idx=lower_bound(b,b+n,a[i])-b;
		if(i%2!=idx%2)res++;
	}
	res/=2;
	cout<<res<<endl;
	return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <stdio.h>
#include <vector>

using namespace std;
int main() {
  int N;
  cin >> N;
  vector<int> A(N);
  
  int max1=0;
  int max2=0;
  int i1;
  
  for (int i=0;i<N;i++){
    cin >> A.at(i);
    if (A.at(i)>max1){
      max1=A.at(i);
      i1=i;
    }else if (A.at(i)>max2){
      max2=A.at(i);
    }
  }
  for (int i=0;i<N;i++){
    if (i!=i1){
      cout << max1 << endl;
    }else{
      cout << max2 << endl;
    }
  }
  
  return 0;
}

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

typedef long long ll;

int arr[100007][3];
int ans[10000][3];
ll func(int n){
    ans[0][1] = arr[0][1];
    ans[0][2] = arr[0][2];
    ans[0][0] = arr[0][0];
    for(int i=1; i<n; i++){
        ans[i][0] = max(ans[i-1][1], ans[i-1][2]) + arr[i][0];
        ans[i][1] = max(ans[i-1][0], ans[i-1][2]) + arr[i][1];
        ans[i][2] = max(ans[i-1][0], ans[i-1][1]) + arr[i][2];
    }
    return max(ans[n-1][0], max(ans[n-1][1], ans[n-1][2]));

}
int main(){
    int n; cin >> n;
    //int arr[n][3];
    for(int i=0; i<n; i++){
        for(int j=0; j<3; j++) cin >> arr[i][j];
    }
    cout << func(n) << endl;

}

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

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

  int x;
  cin >> x;

  string s;
  switch(x % 7) {
    case 0: s = "thu"; break;
    case 1: s = "fri"; break;
    case 2: s = "sat"; break;
    case 3: s = "sun"; break;
    case 4: s = "mon"; break;
    case 5: s = "tue"; break;
    case 6: s = "wed"; break;
  }
  cout << s << endl;
}


Measured memory_bytes: 3228
from sys import stdin

def main():
    n = int(stdin.readline().rstrip())
    sps = [(i, x.split()) for i,x in enumerate(stdin.readlines())]
    sps = [(x[0], x[1][0], 100-int(x[1][1])) for x in sps]
    sps.sort(key=lambda x: (x[1], x[2]))

    for i,s,p in sps:
        print(i+1)
    
if __name__=='__main__':
    main()

Measured memory_bytes: 3060
/* Author - thiolhub */

#include <bits/stdc++.h>

using namespace std;

#define ll              long long int
#define ld              long double
#define db              double
#define pi              3.1415926535897932384626
#define PI              acos(-1.0)
#define endl            "\n"
#define mod             1000000007
#define mk              make_pair
#define pb              push_back
#define pii             pair<int,int>
#define vi              vector<int>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define ps(x,y)         fixed<<setprecision(y)<<x
#define w(t)            ll t; cin>>t; while(t--)
#define sc(a)	        scanf("%lld",&a);
#define pr(a)	        printf("%lld\n",a)
#define f(i,a,n)		for(ll i=a;i<n;i++)
#define m(a)		    memset(a,0,sizeof(a))
#define FastIO          ios_base::sync_with_stdio(0);cin.tie(0),cout.tie(0)



int main(){ FastIO;

string s,l="",r="";cin>>s;
int q,i,f=0;
cin>>q;
while(q--)
{
	int t;cin>>t;
	if(t==1)
	{
		f=(f+1)%2;
	}
	else
	{
		int p;char c;cin>>p>>c;
		if(p==1)
		{
			if(f==0) l+=c;
			else r+=c;
		}
		else
		{
			if(f==0) r+=c;
			else l+=c;
		}
	}
}
if(!f) {reverse(l.begin(),l.end()),cout<<l<<s<<r;}
else{reverse(r.begin(),r.end());reverse(s.begin(),s.end()); cout<<r<<s<<l;}

return 0;
}

Measured memory_bytes: 1040
#include <iostream>
#include <cstdio>
#include <cmath>
#include <string>
#include <cstring>
#include <algorithm>
#include <iomanip>
#include <cstdlib>
#include <cctype>
#define ll long long
#define PI 3.14159265358979323846
using namespace std;
const int maxn = 1e6+7;

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


Measured memory_bytes: 256
import math
n=int(input())
if n<=3:
    print(1)
    exit()
rn=int(math.sqrt(n))
s=set()
for i in range(2,rn+1):
    tmp=i
    while tmp<n:
        tmp*=i
        if tmp<=n:
            s.add(tmp)
print(max(s))

Measured memory_bytes: 3060