akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <algorithm>
#include <utility>
#include <string>
#include <vector>
#include <set>
#include <stack>
#include <queue>
#include <map>
#include <math.h>
#include <string.h>
#include <iomanip>
#include <numeric>
#include <cstdlib>
#include <cstdint>
#include <cmath>
#include <functional>
#include <limits>
#include <cassert>
#include <bitset>

using namespace std;

/* template */

using ll = long long;

void debug_out() { std::cout << std::endl; }
 
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cout << H << " ";
  debug_out(T...);
}

#ifdef LOCAL
#define debug(...) cout << "debug: "; debug_out(__VA_ARGS__)
#else
#define debug(...) 
#endif

#define rep(i, a, n) for (int i = (int)(a); i < (int)(n); i++)
#define rrep(i, a, n) for (int i = ((int)(n-1)); i >= (int)(a); i--)
#define Rep(i, a, n) for (long long i = (long long)(a); i< (long long)(n); i++)
#define RRep(i, a, n) for (long long i = ((long long)(n-1ll)); i>=(long long)(a); i--)
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()

template <typename T>
std::ostream& operator<<(std::ostream& os, std::vector<T> vec) {
  for (std::size_t i = 0; i < vec.size(); i++)os << vec[i] << (i + 1 == vec.size() ? "" : " ");
  return os;
}

struct Edge{
    int to;
    ll weight;
    Edge(int t, ll w) : to(t), weight(w){ }
};

struct edge{
    int from;
    int to;
    ll weight;
    edge(int f,int t,ll w) : from(f), to(t), weight(w){ }
};


using Graph = vector<vector<Edge>>;
using graph = vector<vector<int>>;
using edges = vector<edge>;

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

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

template <class T>
T lcm(T a, T b){
    return (a*b)/gcd(a,b);
}

ll ctoi(char c) {
	switch (c) {
	case '0': return 0; case '1': return 1; case '2': return 2;
	case '3': return 3; case '4': return 4; case '5': return 5;
	case '6': return 6; case '7': return 7; case '8': return 8;
	case '9': return 9;  default: return 0;
	}
}

constexpr ll LNF = 1LL<<50;

constexpr int INF = 1e9+7;

const long double PI=3.14159265358979323846;


vector<int> dx = {1,0,-1,1,-1,0};
vector<int> dy = {1,1,1,0,0,-1};

/* template */

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    ll n; cin >> n;
    ll m = n/1000;
    m *= 1000;
    m += 1000;
    ll ans = (m-n)%1000;
    cout << ans << endl;
}

Measured memory_bytes: 3652
#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(){
  ll H;
  cin >> H;
  
  ll ans = 0;
  
  rep(i,100){
    if ( H == 1 ) {
      ans =1;
      break;
    }
    if ( pow(2,i)<= H && pow(2,i+1) > H ){
      ans = pow(2,i+1)-1;
      break;
    }
  }
  
  cout << ans << endl;
    
}
  


Measured memory_bytes: 384
import std.algorithm;
import std.array;
import std.container;
import std.conv;
import std.math;
import std.numeric;
import std.range;
import std.stdio;
import std.string;
import std.typecons;

void scan(T...)(ref T a) {
    string[] ss = readln.split;
    foreach (i, t; T) a[i] = ss[i].to!t;
}
T read(T)() { return readln.chomp.to!T; }
T[] reads(T)() { return readln.split.to!(T[]); }
alias readint = read!int;
alias readints = reads!int;

T lcm(T)(T a, T b) {
    return a * (b / gcd(a, b));
}

long calc(long a, long b, long c, long d) {
    // 区間 [1, n] で x で割り切れる数の個数
    long f(long n, long x) {
        return n / x;
    }

    // 区間 [1, n] で x or y で割り切れる数の個数
    long g(long n, long x, long y) {
        return f(n, x) + f(n, y) - f(n, lcm(x, y));
    }

    // 区間 [1, n] で x or y で割り切れない数の個数
    long h(long n, long x, long y) {
        return n - g(n, x, y);
    }

    return h(b, c, d) - h(a - 1, c, d);
}

void main() {
    long a, b, c, d; scan(a, b, c, d);
    writeln(calc(a, b, c, d));
}


Measured memory_bytes: 256
import java.util.Scanner;

class Main {
	public static void main(String[] args) {
		int a = 0, b = 0;
		
		Scanner scan = new Scanner(System.in);
		
		while( scan.hasNextInt() ) {
			a = scan.nextInt();
			b = scan.nextInt();
			
			int c = a + b;
			int i;
			
			for(i = 1; ; i++) {
				if(c < 10) {
					break;
				}
				c = c / 10;
				
			}
			
			System.out.println(i);
		}
		
	}
}

Measured memory_bytes: 20404
/*    ####################  */
/*   # I_LOVE_THUY_LINH #  */
/*  ####################  */
#include <bits/stdc++.h>
#define ll long long
#define db double
#define ld long double
#define ii pair<int,int>
#define pb push_back
#define eb emplace_back
#define vi vector<int>
#define vii vector<ii>
#define matrix vector<vector<ll>>
#define fir first
#define sec second
#define all(s) s.begin(),s.end()
#define rall(s) s.rbegin(),s.rend()
#define uni(a) (a).erase(unique(all(a)),(a).end())
#define sz(a) int((a).size())
#define ms(s,val) memset(s,val,sizeof(s))
#define bitcount(n) __builtin_popcountll(n)
#define getbit(s,k) ((s >> k)&1)
#define turnbit(s,k) (s | (1<<k))
#define offbit(s,k) (s & ~(1<<k))
#define flipbit(s,k) (s ^ (1<<k))
#define prec(n) fixed<<setprecision(n)
#define sqr(x) (ll)(x)*(ll)(x)
#define lcm(a,b) ((ll)a/__gcd((ll)a,(ll)b)*(ll)(b))
#define gcd(a,b) __gcd(a,b)
using namespace std;
const int INF = int(1e9);
int X, Y, A, B, C;
ll sum = 0;


int main(){
    ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    cin >> X >> Y >> A >> B >> C;
    vi a(A), b(B), c(C);
    for (int &x: a) cin >> x;
    for (int &x: b) cin >> x;
    for (int &x: c) cin >> x;

    sort(rall(a));
    sort(rall(b));

    priority_queue<int,vector<int>, greater<int> > pq;
    for (int i = 0; i < X; i++){
        sum += (ll)a[i];
        pq.push(a[i]);
    } 
    for (int i = 0; i < Y; i++){
        sum += (ll)b[i];
        pq.push(b[i]);
    }

    for (int x: c){
        int minpq = pq.top();
        if (x > minpq){
            sum += (x - minpq);
            pq.pop();
            pq.push(x);
        }
    }
    cout << sum;
    return 0;
}

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

using namespace std;
#define int long long
int32_t main()
{
    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    int n;
    cin>>n;
    int a[n];
    for(int i=0;i<n;++i)
    {
        cin>>a[i];
        if(a[i]==0)
        {
            cout<<0;
            return 0;
        }
    }
    int pr=1;
    for(int i=0;i<n;++i)
    {
        if((1e18/a[i]+1)<pr)
        {
            cout<<(-1);
            return 0;
        }
        else
        {
            pr*=a[i];
        }
    }
    if(pr<=(int) 1e18)
    {
        cout<<pr;
    }
    else
    {
        cout<<(-1);
    }
    return 0;
}


Measured memory_bytes: 4396
#include <iostream>
#include <iomanip>
#include <algorithm>
using namespace std;
#include <cstdio>
#include <tuple>
#include <string>
#include <vector> 
#include <set>
#include <string.h>
#include <map>
#include <cmath>
#include <deque>
using ll = long long;
using Graph = vector<vector<int>>;
#include <queue>
#include <stack>
#include <cmath>
#include <bitset>
#define rep(i,n) for (int i = 0; i < (n); ++i)


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

vector<bool> seen;
bool check = false;
ll H_MAX;
void dfs(int now,Graph& G,vector<ll> H){
    seen[now] = true;
    for(auto next:G[now]){
        if(seen[next]) continue;//訪問済みならスルー
        if(H_MAX < H[next]){
            H_MAX = H[next];
        }else if(H_MAX == H[next]){//それまでの最大と同じものを発見
            check = true;
        }
        //次のノードへ
        dfs(next,G,H);

    }

}


int main() {

    int N,M;
    cin >> N >> M;

    Graph G(N);

    vector<ll> H(N);
    rep(i,N) cin >> H[i];

    vector<ll> m(N,0);//隣接頂点の最大値格納用
    
    rep(i,M){
        int a,b;
        cin >> a >> b;
        a = a-1;
        b = b-1;

        // G[a].push_back(b);
        // G[b].push_back(a);
        //隣接頂点内での最大値を格納
        m[a] = max(m[a],H[b]);
        m[b] = max(m[b],H[a]);
    }

    //いい展望台
    //非連結である
    //または連結成分内でもっとも標高が高い
    //全てのノードについて探索

    //未訪問設定
    seen.resize(N);
    seen.assign(N,false);
    int ans = 0;
    rep(i,N){
        ans += H[i] >  m[i];

    }

    cout << ans << endl;

    //要素が０個
    //そうでなければ連結成分内でHが最大
    //連結成分ごとに探索
    // map<int,int> mp;
    // int index;
    // rep(i,N){
    //     index =  i;
    //     H_MAX = H[i];
    //     if(G[i].size() == 0){
    //         mp[i]++;
    //         continue;
    //     }
    //     //一本の道を使っていけるとこを探索
    //     for(auto next:G[i]){
    //         if(H_MAX < H[next]) {H_MAX = H[next];index = next;}
    //     }
    //     if(index == i) mp[i]++;//未更新ならピーク
    // }

    // rep(i,mp.size()){
    //     if(mp[i] != 0) ans++;
    // }

    // cout << ans << endl;


    return 0;
}

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

int maxSquare(string map[]) {
  int n = map[0].length();
  int size[n][n];

  int max = 0;
  for(int i = 0; i < n; i++) {
    if(map[i][0] == '*') size[i][0] = 0;
    else                 size[i][0] = 1;
    if(size[i][0] > max) max = size[i][0];

    if(map[0][i] == '*') size[0][i] = 0;
    else                 size[0][i] = 1;
    if(size[0][i] > max) max = size[0][i];
  }

  for(int i = 1; i < n; i++) {
    for(int j = 1; j < n; j++) {
      if(map[i][j] == '*') {
	size[i][j] = 0;
      } else {
	if(size[i-1][j-1] <= size[i-1][j] && size[i-1][j-1] <= size[i][j-1])
	  size[i][j] = size[i-1][j-1] + 1;
	if(size[i-1][j] <= size[i][j-1] && size[i-1][j] <= size[i-1][j-1])
	  size[i][j] = size[i-1][j] + 1;
	if(size[i][j-1] <= size[i-1][j-1] && size[i][j-1] <= size[i-1][j])
	  size[i][j] = size[i][j-1] + 1;

	if(size[i][j] > max) max = size[i][j];
      }
    }
  }
  return max;
}

int main() {
  int n;

  while(1) {
    cin >> n;
    if(n == 0) break;
    string map[n];
    getchar();
    for(int i = 0; i < n; i++) {
      getline(cin, map[i]);
    }

    cout << maxSquare(map) << endl;
  }
  return 0;
}

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

int main(){
	int n, k;
	cin >> n >> k;
	vector<int> a(n);
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}

	vector<int> b(n + 1, 0);

	while(k--){

		for(int i = 0; i <= n; ++i){
			b[i] = 0;
		}
	
		for(int i = 0; i < n; ++i){
			int x = a[i];
			int right = min(i + x, n - 1);
			int left = max(i - x, 0);
			b[left] += 1;
			b[right + 1] -= 1;
		}
		bool changed = false;
		for(int i = 0; i < n; ++i){
			changed |= (a[i] != b[i]);
			a[i] = b[i];
			b[i + 1] += b[i];
		}
		if(!changed)break;
	}
	for(int i = 0; i < n; ++i)cout<<a[i]<<" ";
	cout<<endl;	
	return 0;
}


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

#define ll long long 


ll n, a[100009],b[100009],c[100009];

ll dp[100009][4];

ll solve(int idx, int prev) {
	
	if(idx == n)
		return 0;

	if(dp[idx][prev] != -1)
		return dp[idx][prev];

	ll ans = INT_MIN;

	if(prev == 0) {
		ans = max(ans, b[idx] + solve(idx + 1, 1));
		ans = max(ans, c[idx] + solve(idx + 1, 2));
	} else if(prev == 1) {
		ans = max(ans, a[idx] + solve(idx + 1, 0));
		ans = max(ans, c[idx] + solve(idx + 1, 2));
	} else if(prev == 2) {
		ans = max(ans, b[idx] + solve(idx + 1, 1));
		ans = max(ans, a[idx] + solve(idx + 1, 0));
	} else {
		ans = max(ans, c[idx] + solve(idx + 1, 2));
		ans = max(ans, b[idx] + solve(idx + 1, 1));
		ans = max(ans, a[idx] + solve(idx + 1, 0));
	}

	return dp[idx][prev] = ans;
}


int main() {

// #ifndef ONLINE_JUDGE
// 	freopen("input.txt", "r", stdin);
// 	freopen("output.txt", "w", stdout);
// #endif	

	// a => 0, b => 1, c => 2

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

	cin>>n;

	for(int i = 0; i < n; i++) {
        cin>>a[i]>>b[i]>>c[i];
    }

	ll ans = solve(0, 3);

	cout<<ans<<endl;
	
}

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

int main() {
  int n;
  cin >> n;
  vector<int>data(9,0);
  for(int i = 0;i < n;i++){
    int a;
    cin >> a;
    if(a < 400){
      data[0]++;
    }
    else if(a < 800){
      data[1]++;
    }
    else if(a < 1200){
      data[2]++;
    }
    else if(a < 1600){
      data[3]++;
    }
    else if(a < 2000){
      data[4]++;
    }
    else if(a < 2400){
      data[5]++;
    }
    else if(a < 2800){
      data[6]++;
    }
    else if(a < 3200){
      data[7]++;
    }
    else{
      data[8]++;
    }
  }
  int min = 0,max = 0;
  for(int i = 0;i < 8;i++){
    if(data[i] != 0){
      min++;
      max++;
    }
  }
  if(min == 0 && data[8]!= 0) min = 1;
  max +=data[8];
  cout << min << " " << max << endl;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#ifdef _DEBUG
#include "dump.hpp"
#else
#define dump(...)
#endif

//#define int long long
#define rep(i, a, b) for (int i = (a); i < (b); i++)
#define rrep(i, a, b) for (int i = (b)-1; i >= (a); i--)
#define all(c) begin(c), end(c)
const int INF =
    sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = 1e9 + 7;
template <class T>
bool chmax(T &a, const T &b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
template <class T>
bool chmin(T &a, const T &b) {
    if (b < a) {
        a = b;
        return true;
    }
    return false;
}

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

    int N;
    cin >> N;
    vector<int> a(N);
    rep(i, 0, N) {
        cin >> a[i];
        a[i]--;
    }

    int x = 0;
    rep(i, 0, N) {
        if (a[x] == 1) {
            cout << i + 1 << endl;
            return 0;
        }
        x = a[x];
    }
    cout << -1 << endl;

    return 0;
}

Measured memory_bytes: 640
/*
AizuOnline A1106
Title
*/
#include <stdio.h>
// Select Below
//#include <stdlib.h>
//#include <string.h>
#include <float.h>
#include <math.h>
//#include <limits.h>
//Global data section
int a,b,c;
//
int gcd(int x, int y){
	return y == 0 ? x: gcd(y, x%y);
}

main()
{
  int d,d2;
  int p,q,r,s,gcdpq,gcdrs;

  while(EOF!=scanf("%d %d %d",&a,&b,&c) && (a||b||c))
    {
      if(c ==0)
	{
	  if(a > 1 || (a ==1 && b >= 0))
	    printf("%d %d 1 0\n",a,b);
	  else
	    printf("1 0 %d %d\n",a,b);
	  continue;
	}
      d= b*b-4*a*c;
      if(d < 0)             // Imaginal
	{
	  printf("Impossible\n");
	}
      else if (d == 0)      // KANZEN HEIHOU
	{
	  p=sqrt(a);q=sqrt(c);
	  if(p*p==a && q*q == c)
	    {
	      if(b>0)
		printf("%d %d %d %d\n",p,q,p,q);
	      else
		printf("%d %d %d %d\n",p,-q,p,-q);
	    }
	  else
	    {
	      printf("Impossible\n");
	    }
	}
      else
	{
	  d2 = sqrt((double)(d));
	  if(d2*d2 == d)
	    {
	      p=r=2*a;
	      q=-b+d2;
	      s=-b-d2;
	      
	      gcdpq= gcd(p,q);
	      if(gcdpq < 0)gcdpq= -gcdpq;
	      p /= gcdpq;
	      q /= gcdpq;
	      gcdrs= gcd(r,s);
	      if(gcdrs < 0)gcdrs= -gcdrs;
	      r /= gcdrs;
	      s /= gcdrs;
	      if(p > r ||((p == r)&& -q >= -s))
		printf("%d %d %d %d\n",p,-q,r,-s);
	      else
		printf("%d %d %d %d\n",r,-s,p,-q);
	    }
	  else
	    {
	      printf("Impossible\n");
	    }
	}
    }
return(0);
}

Measured memory_bytes: 612
#include <bits/stdc++.h>
#define int long long int
using namespace std;
template<typename T,typename U> using P=pair<T,U>;
template<typename T> using V=vector<T>;
template<typename T>bool chmax(T&a,T b){if(a<b){a=b;return true;}return false;}
template<typename T>bool chmin(T&a,T b){if(a>b){a=b;return true;}return false;}

template<typename T> vector<T> make_v(size_t a) { return vector<T>(a); }
template<typename T,typename... Ts> auto make_v(size_t a,Ts... ts) { return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...)); }

template<typename T> void fill_all(T& arr, const T& v) { arr = v; }
template<typename T, typename U> void fill_all(T& arr, const U& v) { for (auto& i : arr) fill_all(i, v); }

template<typename T>auto&operator<<(ostream&s,const vector<T>&v){s<<"[";bool a=1;for(auto e:v){s<<(a?"":" ")<<e;a=0;}s<<"]";return s;}
template<typename T,typename U>auto&operator<<(ostream&s,const pair<T,U>&p){s<<"("<<p.first<<","<<p.second<<")";return s;}
template<typename T>auto&operator<<(ostream&s,const set<T>&st){s<<"{";bool a=1;for(auto e:st){s<<(a?"":" ")<<e;a=0;}s<<"}";return s;}
template<typename T,typename U>auto&operator<<(ostream&s,const map<T,U>&m){s<<"{";bool a=1;for(auto e:m){s<<(a?"":" ")<<e.first<<":"<<e.second;a=0;}s<<"}";return s;}
#define DUMP(x) cout<<#x<<" = "<<(x)<<endl

struct edge { int to, cost; };

const int INF = 1LL<<60;
const int MOD = 1e9+7;


int n, Q;
string s;
vector<char> t, d;

int check(int m) {
   if (m == -1 || m == n) {
      return m;
   }
   for (int i = 0; i < Q; ++i) {
      if (s[m] == t[i]) {
         if (d[i] == 'L') {
            --m;
         } else {
            ++m;
         }
      }
      if (m == -1 || m == n) {
         return m;
      }
   }
   return 0;
}

int binary_search_max(int MIN, int MAX)
{
   int l = MIN, r = MAX+1;
   while (r - l > 1) {
      int m = (l + r) / 2;
      if (check(m) == -1) {
         l = m;
      } else {
         r = m;
      }
   }
   return l;
}
int binary_search_min(int MIN, int MAX)
{
   int l = MIN-1, r = MAX;
   while (r - l > 1) {
      int m = (l + r) / 2;
      if (check(m) == n) {
         r = m;
      } else {
         l = m;
      }
   }
   return r;
}

signed main()
{
   cin >> n >> Q;
   cin >> s;
   t.resize(Q); d.resize(Q);
   for (int i = 0; i < Q; ++i) {
      cin >> t[i] >> d[i];
   }

   int l = binary_search_max(-1, n),
       r = binary_search_min(-1, n);
   int ans = r - l - 1;
   cout << ans << endl;


   return 0;
}


Measured memory_bytes: 900
#include <iostream>
#include <set>
using namespace std;
int main()
{
	long long n, buffer,ans;
	multiset<long long> data;
	multiset<long long>::iterator p1,p2;
	cin >> n;
	for (int i = 0; i < n; i++)
	{
		cin >> buffer;
		data.insert(buffer);
	}
	p1 = data.begin();
	for (int i = 0; i <(int)(n/2)-1;i++) ++p1;
	p2 = p1;
	++p2;
	ans = *p2 - *p1;
	cout << ans;
}

Measured memory_bytes: 4992
#input of int(split by space)
def get_i()
  return gets.chomp.split(" ").map(&:to_i)
end
#input of float(split by space)
def get_f()
  return gets.chomp.split(" ").map(&:to_f)
end
#input of string(split by space)
def get()
  return gets.chomp.split(" ")
end
#input of string(split per one character)
def get_nsp()
  return gets.chomp.split("")
end
#yes or no decision
def yn_judge(bool,y="Yes",n="No")
  return bool ? y : n 
end
#create of array
def array(size1,init=nil,size2=-1)
  if size2==-1
      return Array.new(size1){init}
  else
      return Array.new(size2){Array.new(size1){init}}
  end
end

def max(a,b)
    return a>b ? a : b
end

def min(a,b)
    return a>b ? b : a
end

INF=Float::INFINITY

N=gets.to_i
MOD=10**9+7
s1=get_nsp
s2=get_nsp
i=0
prev=-1
ans=3
while i<N
  if s1[i]!=s2[i]
    times=2
    times+=1 if prev==2
    prev=2
    ans*=times
    i+=2
  else
      times=1
      times+=1 if prev==1
      prev=1
      ans*=times
      i+=1
  end 
  ans%=MOD
end
puts ans

Measured memory_bytes: 14284
#include<deque>
#include<queue>
#include<vector>
#include<algorithm>
#include<iostream>
#include<set>
#include<cmath>
#include<tuple>
#include<string>
#include<chrono>
#include<functional>
#include<iterator>
#include<random>
#include<unordered_set>
#include<array>
#include<map>
#include<iomanip>
#include<assert.h>
#include<bitset>
#include<stack>
#include<memory>
using namespace std;
using namespace std::chrono;
typedef long long int llint;
typedef double lldo;
#define mp make_pair
#define mt make_tuple
#define pub push_back
#define puf push_front
#define pob pop_back
#define pof pop_front
#define fir first
#define sec second
#define res resize
#define ins insert
#define era erase

/*
cout<<fixed<<setprecision(20);
cin.tie(0);
ios::sync_with_stdio(false);
*/
const llint mod=1000000007;
const llint big=2.19e15+1;
const long double pai=3.141592653589793238462643383279502884197;
const long double eps=1e-15;
template <class T,class U>bool mineq(T& a,U b){if(a>b){a=b;return true;}return false;}
template <class T,class U>bool maxeq(T& a,U b){if(a<b){a=b;return true;}return false;}
llint gcd(llint a,llint b){if(a%b==0){return b;}else return gcd(b,a%b);}
llint lcm(llint a,llint b){if(a==0){return b;}return a/gcd(a,b)*b;}
template<class T> void SO(T& ve){sort(ve.begin(),ve.end());}
template<class T> void REV(T& ve){reverse(ve.begin(),ve.end());}
template<class T>llint LBI(vector<T>&ar,T in){return lower_bound(ar.begin(),ar.end(),in)-ar.begin();}
template<class T>llint UBI(vector<T>&ar,T in){return upper_bound(ar.begin(),ar.end(),in)-ar.begin();}

int main(void) {
	int n,h,w;cin>>n>>h>>w;
	cout<<(n+1-h)*(n+1-w)<<endl;
}

Measured memory_bytes: 256
from collections import deque

S = deque(input().strip())
q = int(input())

rev = False
for _ in range(q):
    query = input().split()
    if query[0] == '1':
        rev = not rev
    else:
        if (query[1] == '1') ^ rev:
            S.appendleft(query[2])
        else:
            S.append(query[2])
S = S if not rev else reversed(S)
print(*S, sep='')

Measured memory_bytes: 12272
#include <stdio.h>
int main(){
    long int n,k,cnt=0;
    scanf("%ld%ld",&n,&k);
    if(!k){
        printf("%ld\n",n*n);
        return 0;
    }
    for(long int i=k;++i-n-1;)cnt+=n/i*(i-k)+((n%i>=k)?n%i-k+1:0);
    printf("%ld\n",cnt);
    return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
int main()
{
    string s,t;
    int countt=0;
    cin>>s>>t;
    for(int i=0;i<3;i++)
    {
        if(s[i]==t[i])
            countt++;
    }
    cout<<countt<<endl;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<math.h>
  int main(){
  int check(double);
  int n;
  double number[10000];
  int i;
  int count=0;

  scanf("%d",&n);

  for(i=0;i<n;i++){
    scanf("%lf",&number[i]);
    if(check(number[i]) == 1) count++;
  }
  printf("%d\n",count);
  return 0;
}

int check(double x){
  double i = 3.0;
  double y = sqrt(x);
  if(x == 2) return 1;
  if((int)x % 2 == 0) return 0;
  while(i <= y){
    if((int)x % (int)i == 0) return 0;
    i += 2;
  }
  return 1;
}



Measured memory_bytes: 2084
#include<stdio.h>
#include<algorithm>
#include<string>
#include<iostream>
using  namespace std;
const int maxn=1000100;
int a[maxn],b[maxn];
int main()
{
    int n;
    scanf("%d",&n);
    for(int i=1; i<=n; i++)
    {
        scanf("%d",&a[i]);
    }
    if(n&1)
    {
        int mid=(n+1)/2;
        int sum=1;
        b[mid]=a[1];
        int ans=2;
        while(ans<=n)
        {
            b[mid+sum]=a[ans];
            ans++;
            b[mid-sum]=a[ans];
            sum++;
            ans++;
        }
    }
    else
    {
        int mid=(n)/2+1;
        int sum=1;
        b[mid]=a[1];
        int ans=2;
        while(ans<=n)
        {
            b[mid-sum]=a[ans];
            ans++;
            b[mid+sum]=a[ans];
            sum++;
            ans++;
        }
    }
    for(int i=1;i<=n;i++)
    {
        printf("%d",b[i]);
        if(i!=n)
            printf(" ");
        else

            printf("\n");
    }

}


Measured memory_bytes: 7040
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
 
class SegmentTree {
private:
    int n;
    vector<ll> node;
    ll INF = (1ll << 31) - 1;
public:
    SegmentTree(int N) {
        n = 1;
        while (n < N) n *= 2;
        node.resize(2 * n - 1, INF);
    }
 
    void update(int i, ll x) {
        i += (n - 1);
        node[i] = x;
        while (i > 0) {
            i = (i - 1) / 2;
            node[i] = min(node[2 * i + 1], node[2 * i + 2]);
        }
    }
 
    ll query(int a, int b, int k, int l, int r) {
        if (r <= a || b <= l) return INF;
        if (a <= l && r <= b) return node[k];
        ll vl = query(a, b, 2 * k + 1, l, (l + r) / 2);
        ll vr = query(a, b, 2 * k + 2, (l + r) / 2, r);
        return min(vl, vr);
    }
 
};
 
 
int main() {
    int n, q;
    cin >> n >> q;
    ll com, x, y;
    SegmentTree st(n);
    int N = 1;
    while (N < n) N *= 2;
    for (int i = 0; i < q; i++) {
        cin >> com >> x >> y;
        if (com == 0) {
            st.update(x, y);
        } else {
            cout << st.query(x, y + 1, 0, 0, N) << "\n";
        }
    }
    return 0;
}


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

ll GCD(int x, int y){
   ll u = max(x, y), v = min(x, y);
   if (v == 1 or u % v == 0) return v;
   else return GCD(u % v, v);
}

int main(){
    ll x, y; cin >> x >> y;
    cout << GCD(x, y) << endl;;
}


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

int n;
int x[1000],y[1000];
int main()
{
	scanf("%d",&n);
	int par = -1;
	for(int i = 0;i < n;++i) {
		scanf("%d%d",&x[i],&y[i]);
		int par2 = (x[i]+y[i])&1;
		if(i == 0) {
			par = par2;
		} else if(par != par2) {
			printf("-1\n");
			return 0;
		}
	}
	if(par == 1) {
		printf("31\n");
		for(int i = 0;i < 31;++i) printf("%d ", 1<<i);
		printf("\n");
	} else {
		printf("32\n1 ");
		for(int i = 0;i < 31;++i) printf("%d ", 1<<i);
		printf("\n");
	}
	for(int i = 0;i < n;++i) {
		if(par == 0) {
			putchar('R');
			--x[i];
		}
		for(int j = 0;j < 30;++j) {
			assert((x[i]^y[i])&1);
			if((x[i]&1)==1) {
				if((y[i]^x[i])&2) {
					putchar('R');
					--x[i];
				} else {
					putchar('L');
					++x[i];
				}
			} else {
				if((y[i]^x[i])&2) {
					putchar('U');
					--y[i];
				} else {
					putchar('D');
					++y[i];
				}
			}
			x[i] >>= 1;
			y[i] >>= 1;
		}
		if(x[i] == -1) {
			putchar('L');
		} else if(x[i] == 1) {
			putchar('R');
		} else if(y[i] == -1) {
			putchar('D');
		} else if(y[i] == 1) {
			putchar('U');
		}
		printf("\n");
	}
}


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

int main(int argc, char const *argv[]) {
    int a, b, c;
    cin >> a >> b >> c;

    if ((a == b && a != c) || (b == c && b != a) || (c == a && c != b)) {
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    return 0;
}


Measured memory_bytes: 3588
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#include <iterator>
#include <cmath>
#include <set>
#include <deque> 
#include <string>


using namespace std;

int n;
int l[110];
int s[110];
int x;

int main()
{
	scanf("%d%d", &n, &x);
	
	s[0] = 0;
	for (int i = 0 ; i < n ; i++)
	{
		scanf("%d", &(l[i]));		
		s[i + 1] = s[i] + l[i];
	}
	
	int p = 0;
	while (p <= n && s[p] <= x)	
		p++;
			
	printf("%d\n", p);
	
	
	return 0;
}



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

// number of odd numbers is even
// number of even numbers doesn't matter

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

      int N, odd = 0;
      cin >> N;
      int arr[N];
      for(int i=0; i<N; i++) {
            cin >> arr[i];
            if(arr[i]%2 != 0) odd++;
      }

      if(odd%2 == 0) cout << "YES" << endl;
      else cout << "NO" << endl;
}

Measured memory_bytes: 3452
#pragma GCC optimize(2)
#include <bits/stdc++.h>
#define DEBUG fprintf(stderr, "Passing [%s] line %d\n", __FUNCTION__, __LINE__)
#define File(x) freopen(x".in","r",stdin); freopen(x".out","w",stdout)

using namespace std;

typedef long long LL;
typedef pair <int, int> PII;
typedef pair <int, PII> PIII;

inline int gi()
{
	int f = 1, x = 0; char c = getchar();
	while (c < '0' || c > '9') {if (c == '-') f = -1; c = getchar();}
	while (c >= '0' && c <= '9') x = x * 10 + c - '0', c = getchar();
	return f * x;
}

inline LL gl()
{
	LL f = 1, x = 0; char c = getchar();
	while (c < '0' || c > '9') {if (c == '-') f = -1; c = getchar();}
	while (c >= '0' && c <= '9') x = x * 10 + c - '0', c = getchar();
	return f * x;
}

const int INF = 0x3f3f3f3f, N = 200003;

int main()
{
	//File("");
	LL n, m, k;
	cin >> n >> m >> k;
	if (k < n + m) {puts("No"); return 0;}
	if (1ll * 4 * n * m < (k - n - m) * (k - n - m)) puts("Yes");
	else puts("No");
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define REP(i, j, n) for (int i = j; i < (n); ++i)
using namespace std;
typedef long long ll;
typedef vector<int> vi;
#define MOD 1000000007

ll modpow(ll a,ll b,ll mod){
	if(b==0)return 1;
	if(b%2)return modpow(a,b-1,mod)*a%mod;
	ll z=modpow(a,b/2,mod);
	return z*z%mod;
}


int main()
{
    vector<ll> c(60,0);
    ll n;
    ll a;
    cin >> n;
    rep(i, n)
    {
        cin >> a;
        bitset<60> bit(a);
        rep(j, 60){
            if(bit.test(j))c[j]++;
            }
    }
    ll ans = 0;
    rep(i, 60)
    {
        ll l = modpow(2, i,MOD);
        ans += (( (n - c[i]) * c[i]) % MOD) *l;
        ans%=MOD;
    }
    cout << ans% MOD << endl;
}


Measured memory_bytes: 256
//#include <tourist>
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> p;
const int INF = 1e9;
const ll LINF = ll(1e18) + 1;
const int MOD = 1000000007;
const int dx[4] = {0, 1, 0, -1}, dy[4] = {-1, 0, 1, 0};
const int Dx[8] = {0, 1, 1, 1, 0, -1, -1, -1}, Dy[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl
#define rep(i, n) for (int i = 0; i < n; i++)
#define ALL(v) v.begin(), v.end()
#define debug(v)          \
    cout << #v << ":";    \
    for (auto x : v)      \
    {                     \
        cout << x << ' '; \
    }                     \
    cout << endl;
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;
}
//cout<<fixed<<setprecision(15);有効数字15桁
//-std=c++14
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
int n, m;
vector<int> a;
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> n;
    cout << (n+1)/2 << "\n";
}


Measured memory_bytes: 256
from sys import stdin
input=stdin.readline().rstrip().split()

sx=int(input[0])
sy=int(input[1])
tx=int(input[2])
ty=int(input[3])

first=tx-sx
second=ty-sy

output=first*"R"+second*"U"+first*"L"+second*"D"+"D"+(first+1)*"R"+(second+1)*"U"+"L"+"U"+(first+1)*"L"+(second+1)*"D"+"R"
"""
output=None
output+=first*"R"
output+=second*"U"

output+=first*"L"
output+=second*"D"

output+="D"
output+=(first+1)*"R"
output+=(second+1)*"U"
output+="L"

output+="U"
output+=(first+1)*"L"
output+=(second+1)*"D"
output+="R"
"""
print(output)

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

int main () {
  int n,k;
  cin >> n >> k;
  int s,p,r;
  cin >> s >> p >> r;
  //s p r
  vector<string> list(k,"");
  string st;
  cin >> st;
  for(int i=0;i<n;i++) {
    list.at(i%k)=list.at(i%k)+st.at(i);
  }
  long long ans=0;
  for(int i=0;i<k;i++) {
    int temp='a';
    for(int j=0;j<list.at(i).size();j++) {
      if(list.at(i).at(j)!=temp) {
        int point=0;
        if(list.at(i).at(j)=='s') {
          point=s;
        }
        if(list.at(i).at(j)=='p') {
          point=p;
        }
        if(list.at(i).at(j)=='r') {
          point=r;
        }
        ans+=point;
        temp=list.at(i).at(j);
      }
      else {
        temp='a';
      }
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 5120
#include <cstdio>
#include <vector>
#include <cmath>

using namespace std;

const int INF = 1e9 + 5;

vector <int> h;
int n;
vector <int> dp;

int solve(int idx){

    if(dp[idx] != INF)
        return dp[idx];
        
    int a = 0;

    if((idx + 1) < n){
        a = solve(idx+1) + abs(h[idx]-h[idx+1]);
    } 

    int b = INF;

    if((idx + 2) < n){
        b = solve(idx+2) + abs(h[idx]-h[idx+2]);
    }


    return dp[idx] = min(a,b);
}

int main(){

    scanf("%d",&n);
    vector <int> heights(n);
    dp.assign(n,INF);
    
    for(int i=0;i<n;i++){
        scanf("%d",&heights[i]);
    }

    h = heights;

    printf("%d\n",solve(0));

    return 0;
}

Measured memory_bytes: 6144
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <sstream>
#include <unordered_map>
#include <vector>


#define INF 4000000000000000000LL
#define MOD 1000000007
#define ALL(x) std::begin(x), std::end(x)


int main(int argc, char** argv)
{
  std::cin.tie(0);
  std::ios_base::sync_with_stdio(0);

  std::cout << std::fixed << std::setprecision(6);
  std::cerr << std::fixed << std::setprecision(6);

  int H, W, K, C = 0;

  std::cin >> H >> W >> K;

  std::vector<std::string> a(H);

  for (auto& s : a)
    std::cin >> s;

  for (int i = 0; i < 1 << H; i ++) {
    std::set<int> v;

    for (int k = 0, b = 1; k < H; k ++, b <<= 1)
      if (i & b)
        v.insert(k);
    
    for (int j = 0; j < 1 << W; j ++) {
      std::set<int> h;

      for (int k = 0, b = 1; k < W; k ++, b <<= 1)
        if (j & b)
          h.insert(k);

      int c = 0;

      for (int k = 0; k < H; k ++)
        if (v.count(k) == 0) {
          for (int l = 0; l < W; l ++)
            if (h.count(l) == 0)
              if (a[k][l] == '#')
                c ++;
        }

      if (c == K)
        C ++;
    }
  }

  std::cout << C << std::endl;

  return 0;
}


Measured memory_bytes: 3648
#include<stdio.h>

int main(void)
{
	int a, b, c, s, temp, f1;

	scanf("%d",&s);
	for(f1 = 0; f1 < s; f1++)
	{
		scanf("%d %d %d",&a, &b, &c);
		if(a < b){
			temp = a;
			a = b;
			b = temp;
		}
		if(a < c){
			temp = a;
			a = c;
			c = temp;
		}
		if(a * a == b * b + c * c)
			printf("YES\n");
		else
			printf("NO\n");
	}
	return 0;
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
using namespace std;
#ifdef LOCAL_DEBUG
  #include "LOCAL_DEBUG.hpp"
#endif
#define int long long

//int match[10] = {6,2,5,5,4,5,6,3,7,6};
string match = "6255456376";

signed main(){

  int n,m; cin >> n >> m;
  vector<char> a(m);
  for(int i = 0; i < m; i++) cin >> a[i];
  // sort(a.rbegin(),a.rend(),[&](char x,char y){
  //   int a = x - '0';
  //   int b = y - '0';
  //   return match[a] < match[b];
  // });

  vector<string> dp(n+10,"INF");
  dp[0] = "";
  auto f = [&](string s,string t){
    if(s == "INF") return t;
    else if(s.size() < t.size()) return t;
    else if(s.size() > t.size()) return s;
    else {
      for(int i = 0; i < s.size(); i++){
        if((int)(s[i] - '0') > (int)(t[i] - '0')){
          return s;
        }
        if((int)(s[i] - '0') < (int)(t[i] - '0')){
          return t;
        }
      }
    }
    return s;
  };
  for(int i = 0; i <= n; i++){
    for(int j = 0; j < m; j++){
      if(dp[i] == "INF") continue;
      char c = match[(int)(a[j] - '0')];
      int p = (int)(c - '0');
      dp[i + p] = f(dp[i + p],dp[i] + a[j]);
      // if(i-p == 0 && dp[i-p] == "") dp[i] = a[j];
      // if(i-p > 0 && dp[i-p] != "") dp[i] = f(dp[i],dp[i-p] + a[j]);
    }
  }
  cout << dp[n] << endl;

  return 0;
}


Measured memory_bytes: 43136
#include <iostream>
#include <map>
#include <vector>
#include <cmath>
#include <iomanip>
#include <string>
#include <queue>
#include <algorithm>
#include <cctype>
#define shosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef pair<int,P> pip;
typedef vector<pip> vip;
const int inf=1<<30;
const double pi=acos(-1);
const double eps=1e-8;

struct point{
	double x,y;
	point operator+(point Gep){
		return point{x+Gep.x,y+Gep.y};
	}
	point operator-(point Gep){
		return point{x-Gep.x,y-Gep.y};
	}
	point operator*(double Gex){
		return point{x*Gex,y*Gex};
	}
	point operator/(double Gex){
		if(!Gex) return point{0,0}; 
		return point{x/Gex,y/Gex};
	}
	bool operator==(point Gep){
		return fabs(x-Gep.x)<eps&&fabs(y-Gep.y)<eps;
	}
};

class Geom{
	private:
	vector<point> Ge;
	vector<pair<point,point> > Geseg,Geline;
	public:
	void line_push(point Gex,point Gey){
		Geline.push_back(make_pair(Gex,Gey));
	}
	void seg_push(point Gex,point Gey){
		Geseg.push_back(make_pair(Gex,Gey));
	}
	void point_push(point Gex){
		Ge.push_back(Gex);
	}
	point DIP(pair<point,point> Gex,pdd Gey){
		double Gea=Gey.first,Geb=Gey.second;
		point Ge1=Gex.first,Ge2=Gex.second;
		return (Ge1*Geb+Ge2*Gea)/(Gea+Geb);
	}
	point POI(pair<point,point>Gex,pair<point,point> Gey){
		pair<point,point> Ge1(PRO(Gex,Gey.first),PRO(Gex,Gey.second));
		pdd Ger(EXTLEN(Gey.first,Ge1.first),EXTLEN(Gey.second,Ge1.second));
		return DIP(Ge1,Ger);
	}
	double IP(point Gex,point Gey){
		return Gex.x*Gey.x+Gex.y*Gey.y;
	}
	double CP(point Gex,point Gey){
		return Gex.x*Gey.y-Gey.x*Gex.y;
	}
	double LEN(point Gex){
		return sqrt(Gex.x*Gex.x+Gex.y*Gex.y);
	}
	double EXTLEN(point Gex,point Gey){
		return LEN(Gex-Gey);
	}
	point PRO(pair<point,point> Gea,point Gex){
		point Ge1=Gex-Gea.second,Ge2=Gea.first-Gea.second;
		return Ge2*(IP(Ge1,Ge2)/(LEN(Ge2)*LEN(Ge2)))+Gea.second;
	}
	point REF(pair<point,point> Gea,point Gex){
		point Ge1=PRO(Gea,Gex);
		return Ge1*2-Gex;
	}
	int JUD(point Gea,point Geb,point Gex){
		if(Gea==Geb||Gex==Geb) return 0;
		point Ge1=Gea-Gex,Ge2=Geb-Gex;
		double Getmp=CP(Ge1,Ge2);
		if(Getmp>0) return 1;
		if(Getmp<0) return 2;
		if(IP(Ge1,Ge2)<0) return 3;
		if(LEN(Ge1)<LEN(Ge2)) return 4;
		return 5;
	}
	pair<point,point> line_open(int Gex){
		return Geline[Gex];
	}
	point point_open(int Gex){
		return Ge[Gex];
	}
	pair<point,point> seg_open(int Gex){
		return Geseg[Gex];
	}
};

int q;
double x,xx,y,yy,xxx,yyy;

int main(){
	cout<<shosu(10);
	cin>>x>>y>>xx>>yy>>q;
	for(int i=0;i<q;i++){
		cin>>xxx>>yyy;
		Geom geo;
		geo.point_push(point{x,y});
		geo.point_push(point{xx,yy});
		int ans=geo.JUD(geo.point_open(1),point{xxx,yyy},geo.point_open(0));
		if(ans==1) cout<<"COUNTER_CLOCKWISE"<<endl;
		else if(ans==2) cout<<"CLOCKWISE"<<endl;
		else if(ans==3) cout<<"ONLINE_BACK"<<endl;
		else if(ans==4) cout<<"ONLINE_FRONT"<<endl;
		else cout<<"ON_SEGMENT"<<endl;
	}
}

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

int main()
{
    int X;
    cin >> X;
    int v = 0;
    for(int i=1; i<=360; i++){
        v += X;
        v %= 360;
        if(v==0){
            cout << i << endl;
            return 0;
        }
    }
    return 0;
}

Measured memory_bytes: 3636
#include <algorithm>
#include <array>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <vector>
using namespace std;
#define int long long

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

    string s;
    cin >> s;

    set<char> ss;
    for (auto &&i : s) {
        ss.insert(i);
    }

    cout << (ss.size() == 2 ? "Yes" : "No") << endl;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
	int n,p;
	while(cin>>n>>p,n||p){
		int a[51]={0},ans=0,now=0;
		while(true){
			int cnt=0;
			for(int i=0;i<n;i++)if(a[i]!=0)cnt++;
			if(cnt==1&&p==0)break;
			
			if(p!=0){
			a[now]++;
			p--;
			}
			else {
			p+=a[now];
			a[now]=0;
			}
		if(now==n-1)now=0;
		else now++;
		//for(int x=0;x<n;x++)cout<<a[x]<<" ";cout<<endl;
		}
	for(int i=0;i<n;i++)if(a[i]!=0)cout<<i<<endl;
	for(int i=0;i<51;i++)a[i]=0;
	}
	return 0;
}

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

using namespace std;

const int N = 1e2+7;

int n;
string s[10] = { "SUN", "MON", "TUE", "WED", "THU", "FRI",  "SAT" };

int main()
{
    string ss;
    cin >> ss;
    for (int i = 0; i < 7; ++i) {
        if (ss == s[i]) {
            cout << 7-i << endl;
            return 0;
        }
    }
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define REP(i, a, b) for(int i = a, i##_len = (b); i < i##_len; ++i)

int main()
{
    string S;
    cin >> S;
    cout << S.substr(0, 4) << " " << S.substr(4,8) << endl;;
    return 0;
}

Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"io"
	"os"
	"sort"
	"strconv"
)

var sc *bufio.Scanner

const BufferSize = 1024

func nextInt() int {
	if !sc.Scan() {
		panic(nil)
	}
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

var production bool

func debugf(format string, v ...interface{}) {
	if !production {
		fmt.Printf(format, v...)
	}
}

func max(x, y int) int {
	if x > y {
		return x
	}
	return y
}

func abs(x int) int {
	if x < 0 {
		return -x
	}
	return x
}

type bc struct {
	x int
	y int
}

type bcs []bc

func (b bcs) Len() int { return len(b) }
func (b bcs) Less(i, j int) bool {
	if b[i].x != b[j].x {
		return b[i].x < b[j].x
	} else {
		return b[i].y < b[j].y
	}
}
func (b bcs) Swap(i, j int) { b[i], b[j] = b[j], b[i] }

func answer(reader io.Reader, writer io.Writer) {
	sc = bufio.NewScanner(reader)
	buf := make([]byte, BufferSize)
	sc.Buffer(buf, 1e+6)
	sc.Split(bufio.ScanWords)
	n := nextInt()
	x := make([]bc, n)
	d := map[int]map[int]int{}

	for i := 0; i < n; i++ {
		x[i].x = nextInt()
		x[i].y = nextInt()
	}
	sort.Sort(bcs(x))

	for i := 0; i < n-1; i++ {
		for j := i + 1; j < n; j++ {
			if i == j {
				continue
			}
			dx := x[j].x - x[i].x
			dy := x[j].y - x[i].y
			if d[dx] == nil {
				d[dx] = map[int]int{}
			}
			d[dx][dy]++
			debugf("dx:%d, dy:%d, count:%d\n", dx, dy, d[dx][dy])
		}
	}

	debugf("%v\n", d)
	m := 0
	for i := range d {
		for j := range d[i] {
			m = max(m, d[i][j])
		}
	}

	_, _ = fmt.Fprintf(writer, "%d", n-m)
}

func main() {
	production = true
	answer(os.Stdin, os.Stdout)
}


Measured memory_bytes: 1152
// abydbc639iixt3v6powmr2xrjj11dhey
#include<iostream>
#include<vector>
#include<cstring>
#include<unordered_map>
#include<math.h>
#include<map>
#include<algorithm>
#include<iomanip>
#define vi vector<int>
#define ll long long
using namespace std;

long long int mod(string n, long long int k){
    long long int res = 0; 
    for (long long int i = 0; i < n.length(); i++) 
         res = (res*10 + (int)n[i] - '0') %k;
    return res;
}
string longDivision(string number, long long int divisor) 
{
    // As result can be very large store it in string 
    string ans; 
    
    // Find prefix of number that is larger 
    // than divisor. 
    long long int idx = 0; 
    long long int temp = number[idx] - '0'; 
    while (temp < divisor) 
       temp = temp * 10 + (number[++idx] - '0'); 
    
    // Repeatedly divide divisor with temp. After  
    // every division, update temp to include one  
    // more digit. 
    while (number.size() > idx) 
    { 
        // Store result in answer i.e. temp / divisor 
        ans += (temp / divisor) + '0'; 
          
        // Take next digit of number 
        temp = (temp % divisor) * 10 + number[++idx] - '0'; 
    } 
      
    // If divisor is greater than number 
    if (ans.length() == 0) 
        return "0"; 
      
    // else return ans 
    return ans; 
}


ll n;
vector<ll> a;
vector<ll> prefix;
ll sum(ll l, ll r){
    if(l==0) return prefix[r];
    return prefix[r]-prefix[l-1];
}
ll dp[402][402];
ll f(ll l, ll r){
    // if(l==r-1) return a[l]+a[r];
    if(l==r) return 0;
    // if(l>r) {cout<<"h";return 1e12;}
    if(dp[l][r]!=-1) return dp[l][r];
    ll Min = f(l,l) + f(l+1,r) + sum(l,r);
    for(ll m=l+1;m<r;m++){
        Min=min(Min,f(l,m)+f(m+1,r)+sum(l,r));
    }
    dp[l][r]=Min;
    return Min;
}

int main(){
    memset(dp, -1, sizeof(dp));
    cin>>n;
    for(ll i=0;i<n;i++){
        ll x;
        cin>>x;
        a.push_back(x);
        // Min=min(Min, x);
    }
    ll s=0;
    for(ll i=0;i<n;i++){
        s+=a[i];
        prefix.push_back(s);
    }
    cout<<f(0,n-1)<<endl;
    return 0;

}
//1 2 4 5 3
//
// 1 1 2 3 4
/*
    11
    10
    01

->
    101 
    011
    010
    001

a1:
    111
    110
    111
    100 ->X=1

    010
    100
    101
    110



*/


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

using namespace std;

template<class C>
class seg_tree {
	vector<C> tree;
	C(*key)(C, C);
	const C def;
	int p = 1;
public:
	seg_tree(vector<C> v, C func(C, C), C a) : def(a), key(func) {
		int n = (int)v.size();
		while (p < n) {
			p <<= 1;
		}
		tree.resize(2 * p, def);
		for (int i = 0; i < n; ++i) {
			tree[i + p] = v[i];
		}
		for (int i = p - 1; i > 0; --i) {
			tree[i] = key(tree[i << 1], tree[(i << 1) + 1]);
		}
	}
	seg_tree(int n, C func(C, C), C a) : def(a), key(func) {
		while (p < n) {
			p <<= 1;
		}
		tree.resize(2 * p, def);
	}
	C get(int l, int r) {
		C ans = def;
		for (l += p, r += p; l <= r; l >>= 1, r >>= 1) {
			if (l & 1) {
				ans = key(ans, tree[l++]);
			}
			if ((r & 1) == 0) {
				ans = key(ans, tree[r--]);
			}
		}
		return ans;
	}
	int get_right(int i, C x) {
		if (get(i, p - 1) < x) {
			return -1;
		}
		int v = i + p;
		while (tree[v] < x) {
			if (v & 1) {
				++v;
			}
			v >>= 1;
		}
		while (v < p) {
			v <<= 1;
			if (tree[v] < x) {
				++v;
			}
		}
		return v - p;
	}
	int get_left(int i, C x) {
		if (get(0, i) < x) {
			return -1;
		}
		int v = i + p;
		while (tree[v] < x) {
			if ((v & 1) == 0) {
				--v;
			}
			v >>= 1;
		}
		while (v < p) {
			v <<= 1;
			if (tree[v + 1] >= x) {
				++v;
			}
		}
		return v - p;
	}
};

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

	int n;
	cin >> n;
	vector<int> p(n);
	for (int i = 0; i < n; ++i) {
		cin >> p[i];
	}
	seg_tree<int> tree(p, [](int a, int b) { return max(a, b); }, 0);
	long long ans = 0;
	for (int i = 0; i < n; ++i) {
		int l1 = tree.get_left(i, p[i] + 1), l2;
		if (l1 <= 0) {
			l2 = -1;
		}
		else {
			l2 = tree.get_left(l1 - 1, p[i] + 1);
		}
		int r1 = tree.get_right(i, p[i] + 1), r2;
		if (r1 == -1) {
			r2 = r1 = n;
		}
		else {
			r2 = tree.get_right(r1 + 1, p[i] + 1);
			if (r2 == -1) {
				r2 = n;
			}
		}
		ans += 1ll * p[i] * (1ll * (r2 - r1) * (i - l1) + 1ll * (l1 - l2) * (r1 - i));
	}
	cout << ans;

	return 0;
}

Measured memory_bytes: 2048
def solve(N):
    allcount=0
    if N<105:
        return allcount
    for i in range(105,N+1,2):
        count=0
        for j in range(1,i+1):
            if i%j==0:
                count += 1
        if count==8:
            allcount += 1
    return allcount


N=int(input())
print(solve(N))

Measured memory_bytes: 3060
#include <stdio.h>

int main(){
int x,y;
while(1){
   scanf("%d %d",&x,&y); 
   if(x==0 && y==0)
      break;
   if(x<=y){
      printf("%d %d\n",x,y);
   }else{
      printf("%d %d\n",y,x);
   }
}
return 0;
}

Measured memory_bytes: 600
local n = io.read("*n")
local t, r = {}, {}
for i = 1, n do
  t[i] = io.read("*n")
  r[i] = 0
end
local abs, min = math.abs, math.min
r[2] = abs(t[2] - t[1])
for i = 3, n do
  r[i] = min(r[i - 1] + abs(t[i] - t[i - 1]), r[i - 2] + abs(t[i] - t[i - 2]))
end
print(r[n])


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

using namespace std;

#define REP(i, N) for (int i = 0; i < (int)N; i++)
#define RREP(i, N) for (int i =(int)N-1; i >= 0; i--)
#define FOR(i, a, b) for (int i = a; i < (int)b; i++)
#define ALL(x) (x).begin(), (x).end()
#define INF (1 << 30)
#define LLINF (1LL << 62)
#define DEBUG(...) debug(__LINE__, ":" __VA_ARGS__)

typedef long long ll;
typedef pair<int, int> Pii;
typedef pair<ll, ll> Pll;
typedef pair<int,string> Pis;

int main(){
  int a,b,c;
  cin>>a>>b>>c;
  if(a==b&&b==c){
    //cout<<"Yes"<<endl;
    cout<<"No"<<endl;
    return 0;
  }
  if(a!=b&&b!=c&&a!=c){
    cout<<"No"<<endl;
    return 0;
  }
  cout<<"Yes"<<endl;
}


Measured memory_bytes: 256
N = int(input())
T = list(map(int, input().split()))
M = int(input())
PX = []
for i in range(M):
    PX.append(list(map(int, input().split())))

for i in PX:
    temp = T[:]
    temp[i[0]-1] = i[1]
    print(sum(temp))


Measured memory_bytes: 3064