akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 

using namespace __gnu_pbds; 
using namespace std;

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

#define fast        	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define ordered_set 	tree<pll, null_type,less<pll>, rb_tree_tag,tree_order_statistics_node_update>
#define endl        	"\n"
#define int         	long long int  
#define pb          	push_back
#define mp          	make_pair
#define F           	first
#define S           	second
#define pll         	pair<ll,ll>
#define vec     		vector<ll>
#define ALL(v)      	v.begin(),v.end()
#define ALLR(v)     	v.rbegin(),v.rend()
#define pii         	3.14159265358979323
#define inf     		LLONG_MAX
#define ones(x)     	__builtin_popcount(x)
#define fill(a,b)   	memset(a,b,sizeof(a))
#define mod     		1000000007

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

void solve()
{
	ll n;
	
	cin>>n;
	
	ll ans= 0;
	
	while(n>=500)
	{
		ans+=1000;
		n-=500;
	}
	
	while(n>=5)
	{ans+=5;
	n-=5;
	}
	cout<<ans;
}
 
signed main()
{
 
    fast;
 
    ll t;
    
    t=1;
    
    //cin>>t;
    
    while(t--)
    {
        solve();
    }
 
    return 0;
}


Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int m = sc.nextInt();
		int ans = 0;
		Map<Integer,Long> h = new LinkedHashMap<Integer,Long>();
		List<Boolean> maxVertex = new ArrayList<Boolean>();
		for(int i = 0; i < n; i++) {
			h.put(i, sc.nextLong());
			maxVertex.add(true);
		}
		for(int i = 0; i < m; i++) {
			int a = sc.nextInt()-1;
			int b = sc.nextInt()-1;
			if(h.get(a) < h.get(b)) {
				maxVertex.set(a,false);
			}
			else if(h.get(a)>h.get(b)) {
				maxVertex.set(b,false);
			}
			else {
				maxVertex.set(a,false);
				maxVertex.set(b,false);
			}
		}
		for(boolean i:maxVertex) {
			if(i == true) {
				ans++;
			}
		}
		System.out.println(ans);
	}
}

Measured memory_bytes: 76852
import sys
from collections import deque
import copy
import math
def get_read_func(fileobject):
    if fileobject == None :
        return raw_input
    else:
        return fileobject.readline

def main():
    if len(sys.argv) > 1:
        f = open(sys.argv[1])
    else:
        f = None
    read_func = get_read_func(f);
    input_raw = read_func().strip().split()
    [N] = [long(input_raw[0])]
    H = []
    input_raw = read_func().strip().split()
    for i in range(N):
        H.append(long(input_raw[i]))

    dp = [sys.maxint for i in range(N + 1)]
    dp[0] = 0
    for i in range(N):
        if i + 1 < N:
            dp[i + 1] = min(dp[i + 1], dp[i] + abs(H[i] - H[i + 1]))
        if i + 2 < N:
            dp[i + 2] = min(dp[i + 2], dp[i] + abs(H[i] - H[i + 2]))

    print dp[N - 1]


if __name__ == '__main__':
    main()

Measured memory_bytes: 20744
import java.util.Scanner;
 
public class Main {
 
    static Scanner sc = new Scanner(System.in);
 
    public static void main(String[] args) {
        while (true) {
            int N = sc.nextInt();
            if (N == 0) break;
            int[] v = new int[N];
            int sum = 0;
            for (int i = 0; i < N; ++i) {
                v[i] = sc.nextInt();
                sum += v[i];
            }
            int ans = sum;
            for (int i = 1; i < (1 << N); ++i) {
                int a = 0;
                for (int j = 0; j < N; ++j) {
                    if ((i & (1 << j)) != 0) {
                        a += v[j];
                    }
                }
                ans = Math.min(ans, Math.abs(a - (sum - a)));
            }
            System.out.println(ans);
        }
    }
}

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

const double PI = acos(-1);
const double EPS = 1e-15;
using ll = long long;
using ull = unsigned long long;
const int inf = 2e9;
const ll INF = 2e18;
const ll MOD = 1e9+7;
const ll MOD1 = 998244353;
typedef pair<ll,ll> P;

#define rep(i,a,b) for (int i = (a); i < (b); i++)
#define rrep(i,a,b) for (int i = (a); i >= (b); i--)
#define REP(i,n) rep(i,0,n)
#define RREP(i,n) rrep(i,n,0)
#define sz(s) (s).size()
#define pb push_back
#define fi first
#define se second
//#define mp make_pair

struct H {
  ll vote;
  string name;
  H(){vote = 0; name = "";}
  H(ll t, string c) {
    vote = t;
    name = c;
  }
  bool operator<(H e) const {
    if (vote == e.vote) return name > e.name;
    else return vote < e.vote;
  }
};

ll n,m,k,l;
vector<H> a;
vector<H> other, me;
set<string> st;

bool ok(ll K) {
  if (k < K) return 0;
  if (k - K >= sz(other)) return 1;
  H line = other[k - K];
  ll cnt = 0;
  REP(i,K) {
    ll vote = me[i].vote;
    string name = me[i].name;
    if (vote > line.vote) continue;
    else if (vote == line.vote) {
      if (name < line.name) continue;
      else cnt++;
    } else {
      cnt += line.vote - vote;
      if (name > line.name) cnt++;
    }
  }
//  cout << endl;
//  cout << "*" << line.vote << " " << line.name << endl;
//  cout << K << " " << cnt << " " << (cnt <= l? "ok":"no") <<endl;
  return cnt <= l;
}

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

  while (cin >> n >> m >> k >> l, n) {
  other.clear();
  me.clear();
  st.clear();
  a.clear();

  REP(i,n) {
    string s;
    ll v;
    cin >> s >> v;
    a.pb(H(v,s));
  }
  sort(a.rbegin(),a.rend());
//
//  REP(i,n) {
//    cout << a[i].vote << " " << a[i].name << endl;
//  }

  REP(i,m) {
    string s;
    cin >> s;
    st.insert(s);
  }

  REP(i,n) {
    if (st.count(a[i].name)) {
      me.pb(a[i]);
    } else {
      other.pb(a[i]);
    }
  }

  other.pb({0,"zzz"});

  ll left = 0, r = m;
  while (left < r) {
    ll mid = (left + r + 1) / 2;
    if (ok(mid)) {
      left = mid;
    } else {
      r = mid - 1;
    }
  }
  cout << left << endl;
  }
  return 0;
}



Measured memory_bytes: 21104
n = gets.chomp.to_i
t, a  = gets.chomp.split(" ").map(&:to_f)
h = gets.chomp.split(" ").map(&:to_f)

d = 1000
ans = 0
n.times do |i|
  x = h[i]
  t_ = t - x * 0.006
  d_ = (a - t_).abs
  if d_ < d
    d = d_
    ans = i
  end
end
puts ans + 1

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

using namespace std;

//------------------------------- Libraries --------------------------------//

//------------------------------- Type Names -------------------------------//

using i64 = int_fast64_t;

using seika = string;
//akari : 1D, yukari : 2D, maki : 3D vector
template <class kizuna>
using akari = vector<kizuna>;
template <class yuzuki>
using yukari = akari<akari<yuzuki>>;
template <class tsurumaki>
using maki = akari<yukari<tsurumaki>>;
//akane : ascending order, aoi : decending order
template <class kotonoha>
using akane = priority_queue<kotonoha, akari<kotonoha>, greater<kotonoha>>;
template <class kotonoha>
using aoi = priority_queue<kotonoha>;

//------------------------------- Dubug Functions ---------------------------//
inline void print()
{
    cout << endl;
}
template <typename First, typename... Rest>
void print(const First &first, const Rest &... rest)
{
    cout << first << ' ';
    print(rest...);
}
//------------------------------- Solver ------------------------------------//

void solve()
{
    int n, k, mask = 0;
    cin >> n >> k;
    while (k--)
    {
        int x;
        cin >> x;
        mask |= 1 << x;
    }
    for (int s = 0; s < 1 << n; s++)
    {
        if ((s | mask) != s)
        {
            continue;
        }
        cout << s << ':';
        for (int i = 0; i < n; i++)
        {
            if (s >> i & 1)
            {
                cout << ' ' << i;
            }
        }
        cout << '\n';
    }
}

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



Measured memory_bytes: 3096
#include<iostream>
#include<vector>
#include<algorithm>
#include<iomanip>
#include<string>

using namespace std;


int main() {

	int N,K;

	cin >> N >> K;

	double sum = 0;

	for (int i=1; i < N+1; i++) {

		double front = 1.0 / (double)N;
		int j = i;

		while (j < K) {
			
			j *= 2;

			front /= 2.0;
		}

		sum += front;
	}

	cout << fixed << setprecision(15) << sum << endl;

	return 0;
}

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

using ll = long long;
#define rep(i, n) for (long long i = 0; i < (n); ++i)
#define repr(i, a, b) for (auto i = (a); i < (b); ++i)
#define itr(x) for (auto&& v : (x))
#define updatemax(t, v) ((t) = std::max((t), (v)))
#define updatemin(t, v) ((t) = std::min((t), (v)))

#include <boost/operators.hpp>

class modint : private boost::operators<modint>, private boost::equivalent<modint> {
  modint(const long long x, const bool y)
      : x(x) {}

 public:
  static long long M;
  long long x;
  modint(const long long x = 0)
      : x((x % M + M) % M) {}
  modint operator-() const { return modint(x ? M - x : 0, true); }
  modint& operator+=(const modint& b) { return ((x += b.x) >= M ? x -= M : 0), *this; }
  modint& operator++() { return (++x >= M ? x -= M : 0), *this; }
  modint& operator-=(const modint& b) { return ((x -= b.x) < 0 ? x += M : 0), *this; }
  modint& operator--() { return (--x < 0 ? x += M : 0), *this; }
  modint& operator*=(const modint& b) { return x = x * b.x % M, *this; }
  modint& operator/=(const modint& b) { return *this *= b.pow(-1); }
  modint pow(long long b) const {
    long long r = 1, a = x;
    b = (b % (M - 1) + (M - 1)) % (M - 1);
    while (b) {
      if (b & 1) r = r * a % M;
      b = b >> 1;
      a = a * a % M;
    }
    return modint(r, true);
  }
  friend bool operator<(const modint& a, const modint& b) { return a.x < b.x; }
  friend std::istream& operator>>(std::istream& s, modint& a) { return s >> a.x, a = a.x, s; }
  friend std::ostream& operator<<(std::ostream& s, const modint& a) { return s << a.x; }
};
long long modint::M = 1e9 + 7;

modint a[200100];
int main() {
  ll n;
  cin >> n;
  rep(i, n) cin >> a[i];
  modint sum(0), sum2(0);
  rep(i, n) sum += a[i];
  rep(i, n) sum2 += a[i].pow(2);
  cout << (sum.pow(2) - sum2) / 2 << endl;
}


Measured memory_bytes: 5196
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
#define rep(i,m,n) for(int i=m;i<n;i++)
ll mod=1e9+7;

int ctoi(char c){
  if(c=='1') return 1;
  if(c=='2') return 2;
  if(c=='3') return 3;
  if(c=='4') return 4;
  if(c=='5') return 5;
  if(c=='6') return 6;
  if(c=='7') return 7;
  if(c=='8') return 8;
  if(c=='9') return 9;
  if(c=='0') return 0;
}

int main(){
  string s;
  cin>>s;
  int k;
  cin>>k;
  int n=s.size();
  int ans=0;
  if(k==1){
    ans=(n-1)*9+ctoi(s.at(0));
  }
  
  if(k==2){
    rep(i,2,n){
      ans+=81*(i-1);
    }
    ans+=(ctoi(s.at(0))-1)*9*(n-1);
    bool cur=false;
    rep(i,1,n){
      if(!cur) ans+=ctoi(s.at(i));
      else ans+=9;
      if(ctoi(s.at(i))!=0) cur=true;
    }
  }
  
  if(k==3){
    rep(i,3,n){
      ans+=729*(i-1)*(i-2)/2;
    }
    ans+=(ctoi(s.at(0))-1)*81*(n-1)*(n-2)/2;
    int now=0;
    rep(i,1,n){
      if(s.at(i)!='0'){
        now=i;
        break;
      }
    }
    if(now!=0){
      rep(i,2,n-now){
        ans+=81*(i-1);
      }
      ans+=(ctoi(s.at(now))-1)*9*(n-now-1);
      bool cur=false;
      rep(i,1,n-now){
        if(!cur) ans+=ctoi(s.at(i+now));
        else ans+=9;
        if(ctoi(s.at(i+now))!=0) cur=true;
      }
    }
  }
  
  cout<<ans<<endl;
}

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

int main(){
  int n,m; cin>>n>>m;
  vector<vector<int>> job(100001);
  priority_queue<int> pq;
  for(int i=0;i<n;i++){
    int a,b; cin>>a>>b;
    job[a].push_back(b);
  }
  long long ans=0;
  for(int i=1;i<=m;i++){
    for(int j=0;j<job[i].size();j++){
      pq.push(job[i][j]);
    }
    if(!pq.empty()){
      ans+=pq.top(); pq.pop();
    }
  }
  cout<<ans<<endl;
}

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

int main()
{
    long long N;
    scanf("%lld", &N);
    long long K;
    scanf("%lld", &K);
    std::vector<long long> p(N);
    for (int i = 0; i < N; i++)
    {
        scanf("%lld", &p[i]);
    }

    // exp = (p+1)/2
    // sum(exp[j:j+K]) = sum(p[j:j+K])/2 + K/2

    ll sum = 0;
    for (int i = 0; i < K; i++)
    {
        sum += p[i];
    }

    ll mx = sum;
    for (int j = 0; j + K < N; j++)
    {
        sum += (p[j + K] - p[j]);
        if (sum > mx)
        {
            mx = sum;
        }
    }

    printf("%.6lf\n", ((double)mx+K)/2);

    return 0;
}


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

int ma(string s, int a){
    vector<int> dic;
    for(int i=0; i<a; i++){
        if(i >= s.size()){
            dic.push_back(0);
        }
        else{
            dic.push_back(s[i] - '0');
        }
    }

    sort(dic.begin(),dic.end(),greater<int>());

    int ans = 0;

    for(int i=0; i<a; i++){
        int kake = 1;
        int cnt = a-i;
        while(cnt > 1){
            cnt--;
            kake *= 10;
        }

        ans += dic[i]*kake;
    }

    return ans;
}

int mi(string s, int a){
    vector<int> dic;
    for(int i=0; i<a; i++){
        if(i >= s.size()){
            dic.push_back(0);
        }
        else{
            dic.push_back(s[i] - '0');
        }
    }

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

    int ans = 0;

    for(int i=0; i<a; i++){
        int kake = 1;
        int cnt = a-i;
        while(cnt > 1){
            cnt--;
            kake *= 10;
        }

        ans += dic[i]*kake;
    }
    
    return ans;

}

int main(){
    while(1){
        int a;
        string s;
        cin>>s>>a;
        if(s[0] == '0' && a == 0) break;
        set<string> lis;
        map<string,int> idx;
        string pre = s;
        idx[pre] = 0;
        lis.insert(s);
        int cnt = 1;
        int ans;
        
        while(1){
            int high = ma(pre,a);
            int low = mi(pre,a);

            string in = to_string((high-low));

            if(lis.count(in)){
                pre = in;
                break;
            }
            lis.insert(in);
            pre = in;
            idx[pre] = cnt;
            cnt++;
            
        }

        cout<<idx[pre]<<" "<<pre<<" "<<(cnt - idx[pre])<<endl;
    }

    return 0;
    
}


Measured memory_bytes: 3232
String = str(input())

# setで重複を無くし，ビット演算でカウントする
# ビット演算，2進数で奇数を表した場合、最後の1桁は必ず1
## print(char.count(String) & 1)
result = {}
for char in String:
    try:
        result[char] += 1
    except KeyError:
        result[char] = 1

result = list(map(lambda x: x % 2, list(result.values())))
if result == [0] * len(result):
    print('Yes')
else:
    print('No')




Measured memory_bytes: 2940
#include<stdio.h>
#define MAX 2000000

int H,A[MAX+1];

void maxHeapify(int i){
  int tmp,l,r,largest;
  l=2*i;
  r=2*i+1;
  if(l<=H && A[l]>A[i]){
    largest=l;
  }
  else {
    largest = i;
     }
  if(r<=H&& A[r]>A[largest]){
    largest=r;
  }
  if(largest !=i){
    tmp = A[i];
    A[i] = A[largest];
    A[largest] = tmp;
    maxHeapify(largest);
  }
}

int main(){
  int i;
  scanf("%d",&H);
  for(i=1;i<=H;i++){
    scanf("%d",&A[i]);
  }
  for(i=H/2;i>=1;i--){
    maxHeapify(i);
  }
    for(i=1;i<=H;i++){
    printf(" %d",A[i]);
    }
    printf("\n");
  return 0;
}

Measured memory_bytes: 2552
#include <iostream>
#define int long long
using namespace std;

int n;
int a[100000];

signed main() {
	int i;
	
	cin >> n;
	for (i = 0; i < n; i++) cin >> a[i];
	
	int p = 1;
	int ans = 0;
	for (i = 0; i < n; i++) {
		ans += (a[i] - 1) / p;
		if (a[i] == p || p == 1) p++;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define Accepted 0
using namespace std;
const long long mod=1e9+7,maxn=1e6,p=5000;
long long jc[1111111],injc[1111111],n,a[222222],b[222222],x,y,mxx,mxy,s,t,num[4444][4444],ans;
bool used[4444][4444];
long long dx[]={1,0},dy[]={0,1};
queue<pair<long long,long long> > q;
long long binpow(long long a,long long t)
{
	long long res=1,p=a;
	for (long long i=t;i;i>>=1)
	{
		if (i&1) res=res*p%mod;
		p=p*p%mod;
	}
	return res;
}
void Init()
{
	jc[0]=1;
	for (long long i=1;i<=maxn;i++) jc[i]=jc[i-1]*i%mod;
	injc[maxn]=binpow(jc[maxn],mod-2);
	for (long long i=maxn-1;i>=0;i--) injc[i]=injc[i+1]*(i+1)%mod;
}
long long C(long long n,long long k)
{
	if (n<k) return 0;
	return (jc[n]*injc[k]%mod)*injc[n-k]%mod;
}
bool In(long long x,long long y)
{
	return (x>=0 && x<=2*mxx && y>=0 && y<=2*mxy);
}
int main()
{
	Init();
	scanf("%lld",&n);
	for (long long i=1;i<=n;i++) scanf("%lld%lld",&a[i],&b[i]);
	for (long long i=1;i<=n;i++)
	{
		mxx=max(mxx,a[i]);
		mxy=max(mxy,b[i]);
	}
	for (long long i=1;i<=n;i++)
	{
		num[-a[i]+mxx][-b[i]+mxy]++;
	}
	q.push(make_pair(0,0));
	used[0][0]=1;
	while(!q.empty())
	{
		x=q.front().first;y=q.front().second;q.pop();
		for (long long i=0;i<2;i++)
		{
			long long xx=x+dx[i],yy=y+dy[i];
			if (!In(xx,yy)) continue;
			num[xx][yy]=(num[xx][yy]+num[x][y])%mod;
			if (!used[xx][yy])
			{
				used[xx][yy]=1;
				q.push(make_pair(xx,yy)); 
			}
		}
	}
	for (long long i=1;i<=n;i++)
	{
		ans=(ans+num[a[i]+mxx][b[i]+mxy])%mod;
	}
	for (long long i=1;i<=n;i++)
	{
		ans=(ans-C(a[i]*2+b[i]*2,2*a[i]))%mod;
	}
	ans=ans*((mod+1)/2)%mod;
	printf("%lld\n",(ans+mod)%mod);
	return Accepted;
}

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

#define     ll     long long int

int main( )
{
    int w, a, b;
    cin >> w >> a >> b;
    if (a + w < b) {
        cout << (b - (a + w)) << '\n';
    }
    else if (b + w < a) {
        cout << (a - (b + w)) << '\n';
    }
    else {
        cout << "0\n";
    }
    return 0;
}


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

using namespace std;

#define INF (1ll << 62)
#define pb push_back
#define ii pair<int,int>
#define OK (cerr <<"OK"<< endl)
#define debug(x) cerr << #x " = " << (x) << endl
#define ff first
#define ss second
#define int long long
#define tt tuple<int, int, int>
#define endl '\n'

signed main () {
  
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);

  int n;

  cin >> n;

  cout << (n + 1) / 2 << endl;

}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
	int a,b,c;
	cin>>a>>b>>c;
	if((a==b&&a!=c)||(a==c&&a!=b)||(b==c&&a!=b)){
		cout<<"Yes"<<endl;
	}else{
		cout<<"No"<<endl;
	}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, from, to) for (int i = from; i < (to); ++i)
#define mp(x,y) make_pair(x,y)
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()
#define pb push_back
using ll = long long;
using vin=vector<int>;
using vll=vector<ll>;
using vst=vector<string>;
using P = pair<int, int>;
const int inf=1e9+7;
const ll INF=9e18;
template <typename T> bool chmin(T &a, const T& b){if(a > b){a = b;return true;}return false;}
template <typename T> bool chmax(T &a, const T& b){if(a < b){a = b;return true;}return false;}
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
template<class T> inline void YES(T condition){ if(condition) cout << "YES" << endl; else cout << "NO" << endl; }
const int dx[4] = { 1, 0, -1, 0 };
const int dy[4] = { 0, 1, 0, -1 };

int main(){cout<<fixed<<setprecision(20);
		   int n,x;
           cin>>n>>x;
           vin a(n);
           rep(i,0,n)cin>>a[i];
           sort(all(a));
           int ans=0;
           rep(i,0,n){
             if(i!=n-1){
            if(a[i]<=x){
             x-=a[i];
              ans++;
            }
             else break;
             }
             else{
              if(a[i]==x)ans++; 
             }
           }
           cout<<ans<<endl;
}

Measured memory_bytes: 3552
#include<stdio.h>

int main(){
	int i,tmp,j;
	int ht[10];
	for(i=0;i<=9;i++){
		scanf("%d",&ht[i]);
	}
	for(j=1;j<10;j++){
		for(i=9;i>=j;i--){
			if(ht[i-1]<=ht[i]){
				tmp=ht[i-1];
				ht[i-1]=ht[i];
				ht[i]=tmp;
			}
		}
	}
	for(i=0;i<3;i++){
		printf("%d\n",ht[i]);
	}
	return 0;
}

Measured memory_bytes: 600
def B():
    a = [list(map(int, input().split())) for i in range(3)]
    n = int(input())
    for b in (int(input()) for _ in range(n)):
        for i in range(3):
            for j in range(3):
                if a[i][j] == b:
                    a[i][j] = 1
    if ((a[0][0] == a[1][1] == a[2][2] == 1) or (a[0][2] == a[1][1] == a[2][0] == 1)):
        print('Yes')
        return
    for i in range(3):
        if all(a[i][j] == 1 for j in range(3)) or all(a[j][i] == 1 for j in range(3)):
            print('Yes')
            return
    print('No')
B()

Measured memory_bytes: 3064
n=int(input(""))
if(n>=400 and n<=599):
        print("8")
elif(n>=600 and n<=799):
        print("7")
       
elif(n>=800 and n<=999):
        print("6")
       
elif(n>=1000 and n<=1199):
        print("5")
        
elif(n>=1200 and n<=1399):
        print("4")
       
elif(n>=1400 and n<=1599):
        print("3")
       
elif(n>=1600 and n<=1799):
        print("2")
        
elif(n>=1800 and n<=1999):
        print("1")
       

Measured memory_bytes: 9148
#include<iostream>
#include<cmath>
#include<iomanip>
#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long a,c;
    string b;
    cin>>a>>b;
    c=0;
    c=(b[0]-'0')*100+(b[2]-'0')*10+b[3]-'0';
    cout<<a*c/100<<endl;
/*
 *  long long a;
    string s;
    cin>>a>>s;
    s.erase(1,1);
    long long b=stoll(s);
    cout<<a*b/100;
*/
}


Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i=0; i<(int)(n); i++)
#define all(x) x.begin(), x.end()
#define mod 1000000007
typedef long long ll;

int main() {
    int n;
    cin >> n;
    map<string, int> mapa;
    rep(i, n){
        string str;
        cin >> str;
        mapa[str]++;
    }
    int greatest = 0;
    for(auto m : mapa){
        greatest = max(greatest, m.second);
    }
    for(auto m : mapa){
        if(m.second == greatest){
            cout << m.first << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 25216
import java.util.*;

public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		// 整数の入力
		String S = sc.next();
      	int n = S.length();
        String flag = "Yes";
      for(int i=0;i<n;i++){
        char d = S.charAt(i);
        String x = String.valueOf(d);
        if((x.equals("L") && i%2 == 0)|| (x.equals("R") && i%2 == 1)){
         flag = "No";
        }
      }
        System.out.println(flag);
      
	}
}

Measured memory_bytes: 23764
#include <stdio.h>

int main(){
    int N=0;
    int a,b,c,i;
    int max=0;
    scanf("%d",&N);
    
    for(i=0;i<N;i++){
        scanf("%d %d %d",&a,&b,&c);
        if(a>b&&a>c){
            max=a;
            if(max*max==b*b+c*c){
                printf("%s\n","YES");
            }else{
                printf("%s\n","NO");
            }
        }else if(b>a&&b>c){
            max=b;
            if(max*max==a*a+c*c){
                printf("%s\n","YES");
            }else{
                printf("%s\n","NO");
            }
        }else{
            max=c;
            if(max*max==b*b+a*a){
                printf("%s\n","YES");
            }else{
                printf("%s\n","NO");
            }
        }
    }
    return 0;
}

Measured memory_bytes: 576
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <cstdio>
#include <cmath>
#include <tuple>


using namespace std;

// vector<vector<int>> mat(N, vector<int>(M, 0));

int main(int argc, const char *argv[])
{
    //ABC141 A
    string str;
    cin>>str;

    int check = 1;

    int size = str.size();
    for (int i = 0; i < size; i++)
    {
        if(i%2 == 0)
        {
            if(str[i] == 'L')
            {
                check = 0;
            }
        }
        else
        {
            if(str[i] == 'R')
            {
                check = 0;
            }
        }
        
    }

    if(check == 1)
    {
        cout<<"Yes";
    }
    else
    {
        cout<<"No";
    }
    
    
    return 0;
}


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

ll n, a[51];
int main(){
  cin >> n;
  ll mini = INT_MAX, maxi = INT_MIN;
  int argmini, argmaxi;
  for(int i=1;i<=n;i++){
    cin >> a[i];
    if (mini > a[i]) {mini = a[i]; argmini = i;}
    if (maxi < a[i]) {maxi = a[i]; argmaxi = i;}
  }
  if (0 <= mini){
    cout << n-1 << endl;
    for(int i=1;i<n;i++) cout << i << " " << i+1 << endl;
  }else if (maxi <= 0){
    cout << n-1 << endl;
    for(int i=n;i>1;i--) cout << i << " " << i-1 << endl;    
  }else{
    if (abs(mini) <= maxi){
      cout << 2*n-1 << endl;
      for(int i=1;i<=n;i++) cout << argmaxi << " " << i << endl;
      for(int i=1;i<n;i++) cout << i << " " << i+1 << endl;
    }else{
      cout << 2*n-1 << endl;
      for(int i=1;i<=n;i++) cout << argmini << " " << i << endl;
      for(int i=n;i>1;i--) cout << i << " " << i-1 << endl;
    }
  }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
typedef long long LL;
typedef pair<int, int> pii;
 
#define fst first
#define snd second
#define pb(a) push_back(a)
#define mp(a, b) make_pair(a, b)
#define REP(i, a, b)  for(int i = (a), i##end = (b); i < i##end; ++i)
#define DREP(i, a, b) for(int i=(a-1), i##end = (b); i >=i##end; --i)
 
template <typename T> bool chkmax(T& a, T b) { return a < b ? a = b, 1 : 0; }
template <typename T> bool chkmin(T& a, T b) { return a > b ? a = b, 1 : 0; }
 
const int N = 100000;
const int oo = 0x3f3f3f3f;
 
template<typename T> T read() {
    T n(0), f(1);
    char ch = getchar();
    for(;!isdigit(ch); ch = getchar()) if(ch == '-') f = -1;
    for(; isdigit(ch); ch = getchar()) n = n * 10 + ch - 48; 
    return n * f;
}

int l, r, ans;
char s[N + 5];

int main() {
#ifdef Wearry
    freopen("data.txt", "r", stdin);
    freopen("ans.txt", "w", stdout);
#endif 

    scanf("%s", s);
    l = 0, r = strlen(s) - 1;

    while(l <= r) {
        if(s[l] == s[r]) ++ l, -- r;
        else if(s[l] != 'x' && s[r] != 'x') return !puts("-1");
        else {
            ++ ans;
            if(s[l] == 'x') ++ l;
            if(s[r] == 'x') -- r;
        }
    }
    printf("%d\n", ans);

    return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <string>
#include <vector>
#include <math.h>
#include <queue>
#include <deque>
#include <map>
const int MOD = 1e9+7;
typedef long long ll;
using namespace std;

ll n, m;
vector<pair<int, int> > ab(100000);
vector<ll> ans(100000);
ll par[100001];
ll ran[100001];
ll siz[100001];

void init(int n){
	for (int i = 0; i <= n; i++){
		par[i] = i;
		ran[i] = 0;
		siz[i] = 1;
	}
}
int find(int x){
	if (par[x] == x){
		return x;
	}else{
		par[x] = find(par[x]);
		return par[x];
	}
}
void unite(int x, int y){
	x = find(x);
	y = find(y);
	if (x == y) return;

	if (ran[x] < ran[y]){
		par[x] = y;
		siz[y] += siz[x];
	}else{
		par[y] = x;
		siz[x] += siz[y];
		if (ran[x] == ran[y]) ran[x]++;
	}
}
bool same(int x, int y){
	return find(x) == find(y);
}
int size(int x){
	return siz[find(x)];
}

int main(){
	cin >> n >> m;
	for (int i = 0; i < m; i++){
		cin >> ab[i].first >> ab[i].second;
	}
	init(n);
	ans[m] = n*(n-1)/2;
	for (int i = m-1; i > 0; i--){
		ll tmp1_size = size(ab[i].first), tmp2_size = size(ab[i].second);
		if (!same(ab[i].first, ab[i].second)){
			ans[i] = ans[i+1] - tmp1_size*tmp2_size;
		}else{
			ans[i] = ans[i+1];
		}
		unite(ab[i].first, ab[i].second);
	}
	for (int i = 1; i <= m; i++){
		cout << ans[i] << endl;
	}
 	return 0;
 }

Measured memory_bytes: 5248
#include <bits/stdc++.h>
#define r(i,n) for(int i=0;i<n;i++)
using namespace std;
#define int long long
typedef pair<int,int>P;
#define F first
#define S second



struct RSQ{
  int n=(1<<20),data[(1<<21)];
  RSQ(){
    memset(data,0,sizeof(data));
  }

  // 0 index
  void add(int i,int v){
    i++;
    while(i<=n){
      data[i]+=v;
      i+=i&-i;
    }
  }
  int sum(int i){
    int res=0;
    while(i>0){
      res+=data[i];
      i-=i&-i;
    }
    return res;
  }

  //[a,b) 0indexed
  int sum(int x,int y){
    return sum(y)-sum(x);
  }

  int K_number(int k){
    int l = 0,r = (1<<21)+1;
    while( l < r ) {
      int mid = (l+r) / 2;
      if( sum( 0 , mid+1 ) >= k ) r = mid;
      else l = mid+1;
    }
    //cout<<l<<' '<<r<<endl;
    return l;
  }

};

int a[200009];
int b[200009];
int c[200009];
int cnt;

map<int,int>M_nz;
map<int,int>M_zn;

signed main(){

  RSQ seg,SUM;

  priority_queue<int>L;
  priority_queue<int,vector<int>,greater<int> >R;

  int n,off;
  cin>>n;

  vector<int>num;

  r(i,n){
    cin>>a[i];
    if(a[i]==1){
      cin>>b[i]>>c[i];
      num.push_back(b[i]);
    }
  }

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

  r(i,num.size()){
    M_nz[num[i]]=cnt;
    M_zn[cnt]=num[i];
    cnt++;
  }

  int N=num.size();

  int pp=0;

  r(i,n){
    if(a[i]==1){
      off+=c[i];
      int x=b[i];

      seg.add(M_nz[x],x);
      SUM.add(M_nz[x],1);
      pp++;
    }

    else{
      int idx=M_zn[SUM.K_number((pp+1)/2)];
      //cout<<idx<<endl;
      int s1 = seg.sum(M_nz[idx]+1,N);
      int s2 = seg.sum(0,M_nz[idx]);
      s1=s1-SUM.sum(M_nz[idx]+1,N)*idx;
      s2=idx*SUM.sum(0,M_nz[idx])-s2;

      //cout<<s1<<' '<<s2<<endl;

      cout<<idx<<' '<<s1+s2+off<<endl;
    }
  }

}

Measured memory_bytes: 53364
import java.util.Scanner;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        long a = sc.nextLong();
        long b = sc.nextLong();
        long c = sc.nextLong();
        sc.close();
        if(a < c) {
            c -= a;
            a = 0;
            if(b < c) {
                b = 0;
            } else {
                b -= c;
            }
        } else {
            a -= c;
        }
        System.out.println(a + " " + b);
    }
}


Measured memory_bytes: 38852
#include <bits/stdc++.h>
#define fi first
#define se second
#define pii pair<int,int>
#define mp make_pair
#define pb push_back
#define space putchar(' ')
#define enter putchar('\n')
#define eps 1e-10
#define MAXN 200005
//#define ivorysi
using namespace std;
typedef long long int64;
typedef unsigned int u32;
typedef double db;
template<class T>
void read(T &res) {
    res = 0;T f = 1;char c = getchar();
    while(c < '0' || c > '9') {
	if(c == '-') f = -1;
	c = getchar();
    }
    while(c >= '0' && c <= '9') {
	res = res * 10 +c - '0';
	c = getchar();
    }
    res *= f;
}
template<class T>
void out(T x) {
    if(x < 0) {x = -x;putchar('-');}
    if(x >= 10) {
	out(x / 10);
    }
    putchar('0' + x % 10);
}
int N;
int a[MAXN];
void Solve() {
    read(N);
    for(int i = 1 ; i <= N ; ++i) read(a[i]);
    if(N & 1) {
	for(int i = N ; i >= 1 ; i -= 2) {out(a[i]);space;}
	for(int i = i = 2 ; i <= N ; i += 2) {out(a[i]);space;}
	enter;
    }
    else {
	for(int i = N ; i >= 1 ; i -= 2) {out(a[i]);space;}
	for(int i = 1 ; i <= N ; i += 2) {out(a[i]);space;}
	enter;
    }

}
int main() {
#ifdef ivorysi
    freopen("f1.in","r",stdin);
#endif
    Solve();
}


Measured memory_bytes: 2944
import java.util.Scanner;

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

        String s = scan.nextLine();
        String sub = scan.nextLine();

        int min = 0;

        for (int i = 0; i <= s.length()-sub.length(); i++){
            String sSub = s.substring(i,i+sub.length());
            int count = 0;
            for (int j = 0; j < sub.length(); j++){
                if (sSub.charAt(j) != sub.charAt(j)){
                    count++;
                }
            }
            if (i == 0)
                min = count;
            else if (count < min)
                min = count;
        }

        System.out.println(min);
    }
}


Measured memory_bytes: 36752
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  
  int N = 5;
  vector<int> vec(N);
  for (int i = 0; i < N; i++) {
    cin >> vec.at(i);
  }
  
  for (int i = 0; i < N; i++) {
    if(vec.at(i) == 0){
      cout << i+1 << endl;
    }
  }

}

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

int findSumOfDigits(int n) {
  int sum = 0;
  while (n > 0) {
    sum += n % 10;
    n /= 10;
  }
  return sum;
}

int main(void) {
  int N;
  cin >> N;
  int sum = findSumOfDigits(N);

  if (N % sum == 0) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
#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 n;
  cin >> n;
  vector<string> w(n);
  rep(i, n) cin >> w[i];
  
  bool ok = true;
  rep(i, n) rep(j, n) {
    if (i == j) continue;
    if (w[i] == w[j]) ok = false;
  }
  rep(i, n-1) if (w[i][w[i].size()-1] != w[i+1][0]) ok = false;
  if (ok) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 3540
#include <bits/stdc++.h>
// statics
using namespace std;
using int64 = long long;
using PAIR = pair<int64, int64>;
constexpr int INF = 1 << 30;
constexpr int64 LINF = 1LL << 60;
constexpr int MOD = 1e9 + 7;
constexpr int MAX_N = 3e5 + 1;

// init/input
#define int int64
#define INIT ios::sync_with_stdio(false);cin.tie(0);
#define VAR(type, ...) type __VA_ARGS__;MACRO_VAR_Scan(__VA_ARGS__);
template<typename T> void MACRO_VAR_Scan(T &t) {cin>>t;}
template<typename First, typename...Rest> void MACRO_VAR_Scan(First &first, Rest&...rest) {cin>>first;MACRO_VAR_Scan(rest...);}
#define VEC(type, c, n) vector<type> c(n);for(auto &&i:c)cin>>i;

// out
#define OUT(dist) cout<<(dist);
#define FOUT(n, dist) cout<<fixed<<setprecision(n)<<(dist);
#define SP cout<<" ";
#define BR cout<<endl;
#define zero(n) cout<<setfill('0')<<right<<setw(n)
#define debug(x) cerr<<#x<<":"<< (x);BR;

// utility
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define EACH(i, a) for(auto &&i:(a))
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define RFOR(i, a, b) for(int i=(b)-1;i>=(a);--i)
#define REP(i, n) for(int i=0;i<(n);++i)
#define RREP(i, n) for(int i=(n)-1;i>=0;--i)
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; }
int gcd(int a,int b){return b?gcd(b,a%b):a;}

signed main() {
  INIT;
  VAR(int,n);
  VEC(int,a,n);
  int ans = 0;

  REP(i,n-2){
    vector<PAIR> b(3);
    REP(j,3){
      b[j] = make_pair(a[i+j], j);
    }
    sort(ALL(b));
    if (b[1].second==1) ++ans;

    EACH(bi,b){
      debug(bi.first);
      debug(bi.second);
    }
  }
  OUT(ans)BR;
  
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
signed main(){
  int n,m;
  cin>>n>>m;
  vector<vector<int> >G(n);
  for(int i=0;i<m;i++){
    int a,b;
    cin>>a>>b;
    a--;b--;
    G[a].push_back(b);
    G[b].push_back(a);
  }
  int dp[2][n];
  memset(dp,-1,sizeof(dp));
  typedef pair<int,int> P;
  queue<P> q;
  dp[0][0]=0;
  q.push(P(0,0));
  while(!q.empty()){
    P p=q.front();q.pop();
    int v=p.first,x=p.second;
    for(int u:G[v]){
      if(~dp[(x+1)%2][u]) continue;
      dp[(x+1)%2][u]=x+1;
      q.push(P(u,x+1));
    }
  }
  //for(int i=0;i<n;i++) cout<<i<<":"<<dp[0][i]<<" "<<dp[1][i]<<endl;
  int e=0,o=0;
  for(int i=0;i<n;i++){
    if(dp[0][i]<0||e<0) e=-1;
    else e=max(e,dp[0][i]);
    if(dp[1][i]<0||o<0) o=-1;
    else o=max(o,dp[1][i]);
  }
  //cout<<e<<" "<<o<<endl;
  if(e<0&&o<0) cout<<-1<<endl;
  else if(e<0) cout<<o<<endl;
  else if(o<0) cout<<e<<endl;
  else cout<<min(e,o)<<endl;
  return 0;
}



Measured memory_bytes: 12408
#include<iostream>
#include<stdio.h>
#include<algorithm>
#include<vector>
#include<cstring>
#include<set>
#include<queue>
#include<map>
#include<math.h>

#define ll long long
#define dd double
#define scl(n)        scanf("%lld",&n)
#define scd(n)        scanf("%lf",&n)
#define scc(n)        scanf("%c",&n)
#define scs(n)        scanf("%s",&n)
#define ptl(n)        printf("%lld",n)
#define ptd(n)        printf("%f",n)
#define ptc(n)        printf("%c",n)
#define pts(n)        printf("%s",n)
#define nline         printf("\n")
#define pb            push_back
#define FOR(i,a,b)    for(ll i=a;i<=b;i++)
#define FORr(i,a,b)   for(ll i=a;i<=b;i--)
#define pi            2*acos(0.0)
#define pii           pair<ll,ll>
#define uu            first
#define vv            second
#define m       1000004
using namespace std;
vector<ll>prime,mark(m,0);
void sieve()
{
    prime.pb(2);
    for(ll i=4;i<m;i+=2)
        mark[i]=1;
    for(ll j=3;j<m;j+=2)
    {
        if(!mark[j])
        {
            prime.pb(j);
            for(ll k=j*j;k<m;k+=2*j)
                mark[k]=1;
        }
    }
}
ll a[1000006]={0};
int main()
{
   // sieve();
    ll n,high=-2,i,x;
   // vector<ll>pr;
    scl(n);
    ll g=0;
    FOR(i,1,n)
    {
        scl(x);
        a[x]++;
        if(x>high)
            high=x;
        g=__gcd(g,x);
    }
    if(g!=1)
    {
       printf("not coprime");
       return 0;
    }
    for(ll d=2;d<=high;d++)
    {
        ll cnt=0;
        for(i=d;i<=high;i+=d)
        {
           cnt+=a[i];
        }
        if(cnt>1)
        {
            printf("setwise coprime");
            return 0;
        }
    }
    printf("pairwise coprime");
//    for(i=0;prime[i]<=sqrt(high);i++)
//    {
//        cnt=0;
//        FOR(j,1,n)
//        {
//            if(a[j]%prime[i]==0)
//                cnt++;
//        }
//        if(cnt>1)
//        {
//            goto jump;
//        }
//    }
//    FOR(i,1,n)
//    {
//        if(a[i]>sqrt(high)&&mark[a[i]]==0)
//        {
//            pr.pb(a[i]);
//        }
//    }
//    for(ll i:pr)
//    {
//        cnt=0;
//        FOR(j,1,n)
//        {
//            if(a[j]%i==0)
//                cnt++;
//        }
//        if(cnt>1)
//            goto jump;
//    }
//    printf("pairwise coprime");
//    return 0;
//jump:
//    ll result=__gcd(a[1],a[2]);
//    FOR(i,3,n)
//    {
//        result=__gcd(result,a[i]);
//    }
//    if(result==1)
//        printf("setwise coprime");
//    else
//        printf("not coprime");
    return 0;
}


Measured memory_bytes: 18852
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Diagnostics;


class TEST{
	static void Main(){
		Sol mySol =new Sol();
		mySol.Solve();
	}
}

class Sol{
	public void Solve(){
		
		int ans = N;
		
		switch(K%2){
			
			case 0:
			// there exists the center vertex when diam%2 == 0
			
			for(int i=0;i<N;i++){
				
				int[] depth = new int[N];
				int[] parent = new int[N];
				int root = i;
				depth[root] = 0;
				parent[root] = -1;
				
				var Q = new Queue<int>();
				Q.Enqueue(root);
				while(Q.Count>0){
					var now = Q.Dequeue();
					foreach(var nxt in E[now]){
						if(nxt != parent[now]){
							parent[nxt] = now;
							depth[nxt] = depth[now] + 1;
							Q.Enqueue(nxt);
						}
					}
				}
				int mustRemove = depth.Count(e => e > K/2);
				ans = Math.Min(ans,mustRemove);
			}
			break;
			
			
			
			case 1:
			// there exists the center edge when diam%2 == 1
			
			for(int i=0;i<N;i++){
				
				int[] depth = new int[N];
				int[] parent = new int[N];
				int root = i;
				foreach(var adj in E[root]){
					if(adj < root)continue;
					
					depth[root] = 0;
					parent[root] = adj;
					depth[adj] = 0;
					parent[adj] = root;
					
					var Q = new Queue<int>();
					Q.Enqueue(root);
					Q.Enqueue(adj);
					
					while(Q.Count>0){
						var now = Q.Dequeue();
						foreach(var nxt in E[now]){
							if(nxt != parent[now]){
								parent[nxt] = now;
								depth[nxt] = depth[now] + 1;
								Q.Enqueue(nxt);
							}
						}
					}
//Console.WriteLine(String.Join(" ",depth));					
					int mustRemove = depth.Count(e => e > K/2);
					ans = Math.Min(ans,mustRemove);
				}
			}
			break;
			
		}
		
		Console.WriteLine(ans);
	}
	
	int N,K;
	List<int>[] E;
	public Sol(){
		var d = ria();
		N = d[0];
		K = d[1];
		E = new List<int>[N];
		for(int i=0;i<N;i++){
			E[i] = new List<int>();
		}
		for(int i=0;i<N-1;i++){
			d = ria();
			E[d[0]-1].Add(d[1]-1);
			E[d[1]-1].Add(d[0]-1);
		}
		
	}

	static String rs(){return Console.ReadLine();}
	static int ri(){return int.Parse(Console.ReadLine());}
	static long rl(){return long.Parse(Console.ReadLine());}
	static double rd(){return double.Parse(Console.ReadLine());}
	static String[] rsa(char sep=' '){return Console.ReadLine().Split(sep);}
	static int[] ria(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>int.Parse(e));}
	static long[] rla(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>long.Parse(e));}
	static double[] rda(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>double.Parse(e));}
}


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

using namespace std;

int a[100][100];

bool isSqr(int x){
    for (int i = 0; i <= 150; i++){
        if (x == i * i){
            return 1;
        }
    }
    return 0;
}

int main()
{
    int n, d;
    cin >> n >> d;
    for (int i = 0; i < n; i++){
        for (int j = 0; j < d; j++){
            cin >> a[i][j];
        }
    }
    int cnt = 0;
    for (int i = 0; i < n; i++){
        for (int j = i + 1; j < n; j++){
            int ans = 0;
            for (int k = 0; k < d; k++){
                ans += (a[i][k] - a[j][k]) * (a[i][k] - a[j][k]);
            }
            if (isSqr(ans)){
                cnt++;
            }
        }
    }
    cout << cnt;
    return 0;
}


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

#define dump(x) cout << (x) << '\n'
#define Int int64_t
#define fi first
#define se second
#define all(x) (x).begin(), (x).end()

Int INF = 1e18;
int inf = 1e9;
Int mod = 1e9+7;

typedef struct {
    bool L, R;
} p_t;

string to_str(Int x) {
    if (x == 0) {
        return "0";
    }
    string s = "";
    while (x > 0) {
        char a = '0' + (x % 10);
        s = a + s;
        x /= 10;
    }
    return s;
}

int main() {
    Int n, m;
    cin >> n >> m;
    vector<Int> s(m);
    vector<char> c(m);
    for (Int i = 0; i < m; i++) {
        cin >> s[i] >> c[i];
    }
    for (Int i = 0; i <= 999; i++) {
        bool check = true;
        string t = to_str(i);
        //cout << t << " " << t.size() << endl;
        if ((Int)t.length() != n) continue;
        for (Int j = 0; j < m; j++) {
            if (t[s[j] - 1] != c[j]) {
                check = false;
            }
        }
        if (check) {
            dump(i);
            return 0;
        }
    }
    dump(-1);
    return 0;
}


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

const int MOD = 1000000007;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define copy(from, to) copy(from.begin(), from.end(), back_inserter(to))
#define _sort(a) sort(a.begin(), a.end())
#define _sortd(a) sort(a.rbegin(), a.rend())
#define reverse(s) reverse(s.begin(), s.end())
#define p(s) cout << (s) << endl

typedef long long ll;
using namespace std;

template<class T>
void load(vector<T> &v, int n) {
  for (int i = 0; i < n; ++i) {
    T t;
    cin >> t;
    v.push_back(t);
  }
}

template<class T>
T max(vector<T> &v) {
  return *max_element(v.begin(), v.end());
}

template<class T>
T min(vector<T> &v) {
  return *min_element(v.begin(), v.end());
}

void py(bool isUpper = false) {
  if (isUpper) {
    p("YES");
  } else {
    p("Yes");
  }
}

void pn(bool isUpper = false) {
  if (isUpper) {
    p("NO");
  } else {
    p("No");
  }
}

int main() {
  string s;
  cin >> s;

  bool first = true, second = true;
  for (int i = 0; i < s.length(); ++i) {
    if (i % 2 == 0) {
      if (s[i] == 'L') {
        first = false;
      }
    } else {
      if (s[i] == 'R') {
        second = false;
      }
    }
  }

  if (!first || !second) {
    p("No");
  } else {
    p("Yes");
  }
}

Measured memory_bytes: 256
import java.util.*;
public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		long x = sc.nextLong();
		long[] a = new long[n];
		long s = 0;
		for(int i=0; i<n; i++){
			a[i] = sc.nextLong();
			s += a[i];
		}
		a[0] = Math.min(a[0], x);
		for(int i=1; i<n; i++){
			a[i] = Math.min(a[i], x-a[i-1]);
			s -= a[i];
		}
		System.out.println(s-a[0]);
	}
}

Measured memory_bytes: 51260
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main () {
  ll N, X, M;
  cin >> N >> X >> M;
  vector<ll>cycle;
  ll fl = X;
  cycle.push_back(X);
  fl = (fl * fl) % M;
  vector<bool>ex((int)M, false);
  ex[(int)X] = true;
  while (!ex[(int)fl]) {
    ex[(int)fl] = true;
    cycle.push_back(fl);
    fl = (fl * fl) % M;
  }
  int st = 0;
  while (cycle[st] != fl) st ++;
  ll si  = (ll)cycle.size() - (ll)st;
  vector<ll>sum((int)si);
  sum[0] = cycle[st];
  for (int i = 1; i < (int)si; i ++) {
    sum[i] = sum[i - 1] + cycle[i + st];
  }
  ll ans = 0;
  for (int i = 0; i < (int)min((ll)st, N); i ++) {
    ans += cycle[i];
  }
  N -= st;
  if (N <= 0) {
    cout << ans << endl;
    return 0;
  }
  ans += ((N - 1) / si) * sum[(int)(si) - 1];
  ans += sum[(int)((N - 1) % si)];
  cout << ans << endl;
}


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

typedef long long ll;
#define rep(i,n) for( ll (i)=0; (i)<(n); ++(i) )
#define rpv(d) for(auto& v:d)
#define co(n) cout << (n) << endl;
#define cn(n) cin >> n;
#define all(x) (x).begin(), (x).end()

int main(){
  int n;cn(n)
  string s;cn(s);
  rpv(s){
    cout << static_cast<char>( (v+n-'A')%26 + 'A' );
  }
  cout << endl;
}

Measured memory_bytes: 256