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

typedef pair<int,int> pii;
typedef vector<int> vec;
typedef unordered_map<int,int> hash;
#define long long long
#define pb push_back
#define all(a) (a).begin(), (a).end()
#define sz(x) (int)x.size()
#define F first
#define S second
#define pb push_back
#define mp make_pair
#define fill(a,v) memset(a,v,sizeof(a))
#define FOR(i, a, b) for(int i = a; i < b; i++)
#define INF 0x3f3f3f3f//infinity for integers
#define JJ ios_base::sync_with_stdio(0); cin.tie(0)//input fast
#define MOD 1000000007


int main()
{
	JJ;
	int x;cin>>x;
	if(x>=30){
		cout<<"Yes"<<endl;
	}
	else
		cout<<"No"<<endl;
	


	return 0;
}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
#include <vector>
#include <string>
using namespace std;
#define FL(i,a,b) for(int i = a;i<b;i++)
typedef vector<int> vi;
typedef long long int lli;
typedef long int li;
const int inf = numeric_limits<int>::max();



int main(){
    int n;
    scanf("%d",&n);
    int m = n%10;
    if(m == 2 || m == 4 || m == 5 || m == 7 || m == 9){
        printf("%s","hon");
    } 
    else if(m == 0 || m == 1 || m == 6 || m == 8){
        printf("%s","pon");
    }
    else{
        printf("%s","bon");
    }
}



Measured memory_bytes: 3828
#include <bits/stdc++.h>
 
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define rep(i, n)  for(int i=0;i<(n);++i)
#define REPr(i, n) for(int i=(n)-1;i>=0; --i)
#define FORq(i, m, n) for(int i = (m);i <= (n);++i)
#define FORqr(i, m, n) for(int i = (n);i >=(m);--i)
#define PB push_back
#define MP make_pair
#define DEBUG printf("%s\n","debug")
#define fst first
#define snd second
#define SIN(x, S) (S.count(x) != 0)
#define M0(x) memset(x,0,sizeof(x))
#define FILL(x, y) memset(x,y,sizeof(x))
#define MM(x) memset(x,-1,sizeof(x))
#define ALL(x) (x).begin(),(x).end()
using namespace std;
typedef pair<int, int> PII;
typedef pair<long long, long long> PLL;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<long long> VL;
typedef long long ll;
typedef long long integer;
///////////////////////////////////////////////
/* (๑╹◡╹) */
ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; }
ll MOD = 1000000007;
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;
}
/* (๑╹◡╹)(๑╹◡╹)(๑╹◡╹)(๑╹◡╹)(๑╹◡╹)(๑╹◡╹) */
///////////////////////////////////////////////
const int MAX = 510000;
 
long long fac[MAX], finv[MAX], inv[MAX];
 



int main() {
	int N,A,B; cin >> N >> A >> B;
	int ans = min(B,A*N);
	cout << ans << endl;
}



Measured memory_bytes: 256
#ABC152.B
a,b = map(int,input().split())
a1 = []
b1 = []
if a <= b:
    for i in range(b):
        a1.append(a)
    a1 = [str(m) for m in a1]
    print(''.join(a1))
elif b < a:
    for i in range(a):
        b1.append(b)
    b1 = [str(m) for m in b1]
    print(''.join(b1))

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
 
using namespace std;
using namespace __gnu_pbds;
 
using ll = long long;
using ldb = long double;
using pa = pair < ll, ll >;
using vec = vector < ll >;
 
template < typename T > using index_set = tree < T, null_type, less < T >, rb_tree_tag, tree_order_statistics_node_update >;
template < typename T > using MinPriorityQueue = priority_queue < T, vector < T >, greater < T > >;

#define pb push_back
#define po pop_back
#define mp make_pair
#define mt make_tuple
#define F  first
#define S  second
#define f(i,x,n) for(ll i=x;i<n;i++) 
#define unique_sort(x) sort(all(x)), x.resize(distance(x.begin(), unique(all(x))))
#define all(c) c.begin(),c.end()
#define str string
#define edl "\n"
#define add insert
#define cot continue
#define fast() ios_base::sync_with_stdio(false);cin.tie(NULL)


const int MOD = 1e9 + 7, INF = INT_MAX, N = 1e5 + 10;
const double PI = acos(-1);
const ll LINF = LLONG_MAX;

int main() 
{

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

    ll a,b,c,n;
    str s;
    cin>>a>>s;
    if(a>=3200)
    {
      cout<<s;
    }
    else
      cout<<"red";



  

    cerr << "Time taken: " << int((clock() * 1000.) / CLOCKS_PER_SEC) << "ms\n";
    return 0;
}


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

int main() {
  int n;
  cin >> n;
  vector<vector<int>> a(n, vector<int>(2));
  
  for(int i=0; i<n; i++) {
    cin >> a[i][1] >> a[i][0];
  }
  
  sort(a.begin(), a.end());
  
  int now = 0;
  for(int i=0; i<n; i++) {
    if (now + a[i][1] > a[i][0]) {
      cout << "No";
      return 0;
    }
    now += a[i][1];
  }
  cout << "Yes";
  return 0;
}

Measured memory_bytes: 11136
#include<iostream>
#include<bits/stdc++.h>
#include<string>
using namespace std;
int main()
{
  int n ;
  double  t , a , df ;
  cin >> n >> t >> a  ;
  
  vector<double> h(n) ;
  for(int i=0;i<n;i++) 
    cin >> h[i] ;
  

   int ind = 0;
   df = abs((t - h[0]*0.006)-a) ;
   
  for(int i=0;i<n;i++){
      if(df>abs((t - h[i]*0.006)-a)){
        df = abs((t - h[i]*0.006)-a) ;
        ind = i ;
      }
  }

  cout << ind+1 << endl ;
  
  return 0 ;
}

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

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n; cin>>n;
  int min=INT_MAX;
  int ans=0;
  rep(i,n){
    int p; cin>>p;
    if(p<=min){
      ans++;
      min=p;
    }
  }
  cout<<ans<<endl;
}
 

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define LL long long
using namespace std;
const int mod=1e9+7;
int fastpow(int x,int a){
	int ret=1;
	while(a){
		if(a&1) ret=(LL)ret*x%mod;
		x=(LL)x*x%mod;a>>=1;
	}
	return ret;
}

struct Combin{
	#define N 200005
	int fac[N],rv[N],facrv[N];
	Combin(){
		fac[0]=rv[1]=facrv[0]=1;
		for(int i=2;i<N;i++) rv[i]=((-(LL)(mod/i)*rv[mod%i]%mod)+mod)%mod;
		for(int i=1;i<N;i++) fac[i]=(LL)fac[i-1]*i%mod;
		for(int i=1;i<N;i++) facrv[i]=(LL)facrv[i-1]*rv[i]%mod;
	}
	int C(int r1,int n1){
		if(r1>n1) return 0;
		return fac[n1]*(LL)facrv[r1]%mod*facrv[n1-r1]%mod;
	}
	#undef N
}C;
#define N 100005
int p[N],n,cnt,in[N],len[N],vis[N];
int ans=1;
void tp(int x){
	if(len[p[x]]!=0) ans=0;
	len[p[x]]=len[x]+1;
	len[x]=-1;
	in[p[x]]--;
	if(in[p[x]]==0) tp(p[x]);
}
int sz[N];
void solve(int id){
	vis[id]=1;
	if(p[id]==id&&len[id]==0){sz[1]++;return;}
	deque<int> v;
	bool iscir=true;
	v.push_back(len[id]);
	for(int i=p[id];i!=id;i=p[i])
		vis[i]=1,v.push_back(len[i]);
	for(int i:v) if(i!=0) iscir=false;
	if(iscir){
		sz[v.size()]++;
	}else{
		while(v.back()==0) v.push_front(0),v.pop_back();
		while(!v.empty()){
			int val=v.back();v.pop_back();
			while(!v.empty() && v.back()==0) v.pop_back(),val--;
			if(val==1) continue;
			else if(val<1) ans=ans*2%mod;
			else ans=0;
		}
	}
}
int f(int j){//j = 2k
	//how many ways to matchs
	//if there k matchs in 2k points
	//ans = C(2,2k)*C(2,2k-2)...*C(2,4)*C(2,2)/(k!)
	//	=C(2k-2,2k)*C(2k-4,2k-2)...C(0,2)/(k!)
	//  =(2k)!/((2!)^k)/(k!)
	return C.fac[j]*1LL*C.facrv[j/2]%mod*fastpow(C.facrv[2],j/2)%mod;
}
int main(){
	scanf("%d",&n);
	for(int i=1;i<=n;i++) scanf("%d",&p[i]),in[p[i]]++;
	for(int i=1;i<=n;i++)
		if(in[i]==0&&len[i]==0)
			tp(i);
	if(ans==0) return puts("0"),0;
	for(int i=1;i<=n;i++)
		if(vis[i]==0&&len[i]>=0)
			solve(i);
	for(int i=1;i<=n;i++){
		int ansnow=0;
		if(i==1||i%2==0){
			for(int j=0;j<=sz[i];j+=2)
				ansnow = (ansnow + C.C(j,sz[i]) *1LL* f(j)%mod *fastpow(i,j/2)%mod * fastpow(1,sz[i]-j) )%mod;
		}else{
			for(int j=0;j<=sz[i];j+=2)
				ansnow = (ansnow + C.C(j,sz[i]) *1LL* f(j)%mod *fastpow(i,j/2)%mod * fastpow(2,sz[i]-j) )%mod;
		}
		ans = ans*1LL*ansnow%mod;
	}
	cout<<ans<<endl;
	return 0;
} 


Measured memory_bytes: 4480
#include <stdio.h>

int H,A[500001];

void maxHeapify(int i){
  int l,r,largest,tmp;;
  l=i*2;
  r=i*2+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: 3636
#include <bits/stdc++.h>
using namespace std;
typedef signed long long ll;

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------


int N;
string A[202];

int C[202];

void dfs(int cur,int c) {
	if(C[cur]!=-1) {
		if(C[cur]!=c) {
			cout<<-1<<endl;
			exit(0);
		}
		return;
	}
	C[cur]=c;
	int i;
	FOR(i,N) if(A[cur][i]) dfs(i,c^1);
}



void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>N;
	FOR(y,N) {
		cin>>A[y];
		FORR(c,A[y]) c-='0';
	}
	
	MINUS(C);
	dfs(0,0);
	
	int ma=0;
	FOR(i,N) {
		MINUS(C);
		C[i]=1;
		queue<int> Q;
		int r=0;
		Q.push(i);
		while(Q.size()) {
			x=Q.front();
			Q.pop();
			r=max(r,C[x]);
			FOR(y,N) if(A[x][y]&&C[y]==-1) {
				C[y]=C[x]+1;
				Q.push(y);
			}
		}
		
		ma=max(ma,r);
	}
	cout<<ma<<endl;
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	cout.tie(0); solve(); return 0;
}


Measured memory_bytes: 384
import java.util.Scanner;

public class Main {

	public static void main(String args[]) {

		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int[] W = new int[N];
		int[] accumsum = new int[N];
		int sum = 0;
		for(int i=0;i<N;i++) {
			W[i] = sc.nextInt();
			sum += W[i];
			accumsum[i] = sum;
		}

		int ans = Integer.MAX_VALUE;
		for(int i=0;i<N;i++) {
			int diff = Math.abs(accumsum[i] - (sum - accumsum[i]));
			if(ans > diff) ans = diff;
		}
		System.out.println(ans);
	}
}


Measured memory_bytes: 21844
#include <iostream>
#include <fstream>
#include <vector>
#include <set>
#include <map>
#include <bitset>
#include <algorithm>
#include <iomanip>
#include <cmath>
#include <ctime>
#include <functional>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <deque>
#include <stack>
#include <complex>
#include <cassert>
#include <random>
#include <cstring>
#include <numeric>
#define ll long long
#define ld long double
#define null NULL
#define all(a) a.begin(), a.end()
#define forn(i, n) for (int i = 0; i < n; ++i)
#define sz(a) (int)a.size()
#define lson l , m , rt << 1
#define rson m + 1 , r , rt << 1 | 1
template<class T> int gmax(T &a, T b) { if (b > a) { a = b; return 1; } return 0; }
template<class T> int gmin(T &a, T b) { if (b < a) { a = b; return 1; } return 0; }
using namespace std;

const int MAXN = 1e5 + 5;
int a[MAXN];
int main() {
    int n;
    while(~scanf("%d", &n)) {
        map<int, int> mp;
        for (int i = 0; i < n; ++i) {
            scanf("%d", &a[i]);
            mp[a[i]] ++;
        }

        if(mp.size() == 2) {
            int tmp[10]; int cnt = 0;
            bool flag = true;
            flag &= (n % 3 == 0);
            for (auto it : mp) {
                tmp[cnt ++] = it.first;
                if(cnt == 1) {
                    flag &= it.first == 0;
                    flag &= it.second == n / 3;
                } else {
                    flag &= it.second == n / 3 * 2;
                }
                if(!flag) break;
            }
            if(flag) printf("Yes\n");
            else printf("No\n");

        } else if(mp.size() == 3) {
            int tmp[10]; int cnt = 0;
            bool flag = true;
            flag &= (n % 3 == 0);
            for (auto it : mp) {
                tmp[cnt ++] = it.first;
                flag &= it.second == n / 3;
                if(!flag) break;
            }
            flag &= (tmp[0] ^ tmp[1]) == tmp[2];
            if(flag) printf("Yes\n");
            else printf("No\n");
        } else if(mp.size() == 1) {
            if(mp.find(0) == mp.end()) printf("No\n");
            else printf("Yes\n");
        } else {
            printf("No\n");
        }

        
    }
    return 0;
}

Measured memory_bytes: 4224
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;

#define ff              first
#define ss              second
#define int             long long
#define pb              push_back
#define mp              make_pair
#define pii             pair<int,int>
#define vi              vector<int>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define mod             1000000007
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define mk(arr,n,type)  type *arr=new type[n];
#define w(x)            int x; cin>>x; while(x--)
#define FIO             ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
mt19937                 rng(chrono::steady_clock::now().time_since_epoch().count());

typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;

int32_t main()
{
	FIO;
	int n; cin>>n;
	mk(arr,n,int);
	
	for(int i = 0; i<n; i++)
		cin>>arr[i];
		
	mk(dp,n,int);
	
	dp[0] = 0;
	dp[1] = abs(arr[1] - arr[0]);
	
	for(int i = 2; i<n; i++)
	{
			dp[i] = min(abs(arr[i] - arr[i-1]) + dp[i-1], abs(arr[i] - arr[i-2]) + dp[i-2]);
	}
	
	cout << dp[n-1] <<"\n";
	
	return 0;
}

Measured memory_bytes: 5148
import java.util.*;

public class Main {

  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int x = sc.nextInt();
    int[] l = new int[n + 1];
    int total = 0;
    int count = 0;

    for(int i = 1;i < n + 1;i++) {
      l[0] = 0;
      total += sc.nextInt();
      l[i] = total;
    }

    for(int i = 0;i < n + 1;i++) {
      if(l[i] > x) break;
      count++;
    }
    System.out.println(count);


  }

}


Measured memory_bytes: 21844
// Transformation.cc
// 文字列 str に対して、与えられた命令の列を実行するプログラムを
// 作成してください。命令は以下の操作のいずれかです：
//
// ・print a b: strの a 文字目から b 文字目までを出力する。
// ・reverse a b: strの a 文字目から b 文字目までを逆順にする。
// ・replace a b p: strの a 文字目から b 文字目までを p に置き換える。
//
// ここでは、文字列 strの最初の文字を 0 文字目とします。
//
// 【入力】
// 1 行目に文字列 str が与えられます。strは英小文字のみ含みます。
// 2 行目に命令の数 qが与えられます。
// 続く q行に各命令が上記の形式で与えられます。
// 【出力】
// 各 print 命令ごとに文字列を１行に出力してください。
// 【制約】
// ・1≤strの長さ≤1000
// ・1≤q≤100
// ・0≤a≤b<strの長さ
// ・replace 命令では b−a+1=pの長さ
// 【例】
// 入力１：
// abcde
// 3
// replace 1 3 xyz
// reverse 0 2
// print 1 4
// 出力１：
// xaze
// 入力２：
// xyz
// 3
// print 0 2
// replace 0 2 abc
// print 0 2
// 出力２：
// xyz
// abc
#include<iostream>
#include<string>
using namespace std;

void print( string str, int a, int b) {
  for ( int i = a; i <= b; i++) {
    cout << str[i];
  }
  cout << endl;
}

string reverse( string str, int a, int b) {
  char swap_c;

  for ( int i = a, j = b; i < j; i++, j--) {
    swap_c = str[i]; str[i] = str[j]; str[j] = swap_c;
  }

  return str;
}

string replace( string str1, string str2, int a, int b) {
  str1.erase( a, b-a+1);
  str1.insert( a, str2);

  return str1;
}

int main( void) {
  string str;
  int op_num;
  string op;
  int a, b;
  string rep_str;

  cin >> str;
  cin >> op_num;

  for ( int i = 0; i < op_num; i++) {
    cin >> op >> a >> b;
    if ( op == "print") print( str, a, b);
    else if ( op == "reverse") str = reverse( str, a, b);
    else if ( op == "replace") {
      cin >> rep_str;
      str = replace( str, rep_str, a, b);
    }
  }

  return 0;
}



Measured memory_bytes: 3208
void main(){
  import std.stdio, std.string, std.conv, std.algorithm;
  import std.exception, std.typecons, std.container;

  int h, w; rd(h, w);
  auto c=new char[][](h, w);
  foreach(i; 0..h) c[i]=readln.chomp.to!(char[]);

  alias pair=Tuple!(int, int);
  int[pair] map;
  foreach(i; 0..h)foreach(j; 0..w) map[pair(i, j)]=map.length.to!(int);
  auto n=h*w;
  alias E=Tuple!(int, "to", int, "cost");
  auto g=new E[][](n);
  auto dir=[[1, 0], [-1, 0], [0, 1], [0, -1]];
  foreach(i; 0..h)foreach(j; 0..w){
    if(c[i][j]=='#') continue;
    foreach(dd; dir){
      auto ai=i+dd[0], aj=j+dd[1];
      if(ai<0 || ai>=h || aj<0 || aj>=w) continue;
      if(c[ai][aj]=='.'){
        g[map[pair(i, j)]]~=E(map[pair(ai, aj)], 1);
        g[map[pair(ai, aj)]]~=E(map[pair(i, j)], 1);
      }
    }
  }
  auto d=new int[](n);
  const int inf=1e9.to!(int);
  fill(d, inf);
  alias P=Tuple!(int, "v", int, "dist");
  auto Q=new RedBlackTree!(P, "a.dist<b.dist", true);
  d[map[pair(0, 0)]]=0; Q.insert(P(map[pair(0, 0)], 0));
  while(Q.length>0){
    auto cur=Q.front; Q.removeFront;
    foreach(e; g[cur.v]){
      if(d[e.to]<=d[cur.v]+e.cost) continue;
      d[e.to]=d[cur.v]+e.cost;
      Q.insert(P(e.to, d[e.to]));
    }
  }
  if(d[map[pair(h-1, w-1)]]==inf){writeln(-1); return;}

  int bk=0;
  foreach(i; 0..h) bk+=count(c[i], '#');
  auto res=n-bk-(d[map[pair(h-1, w-1)]]+1);
  enforce(res>=0);
  writeln(res);
}
void rd(T...)(ref T x){
  import std.stdio, std.string, std.conv;
  auto l=readln.split;
  assert(l.length==x.length);
  foreach(i, ref e; x){
    e=l[i].to!(typeof(e));
  }
}

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

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

const int N = 110;
int a[N], sum[N];

int main() {
    int n = read();
    for (int i = 1; i <= n; i++) a[i] = read();
    for (int i = 1; i <= n; i++) {
        sum[i] = sum[i - 1] + a[i];
    }
    int ans = 1e9;
    for (int T = 1; T < n; T++) {
        int sum0 = 0;
        for (int i = 1; i <= n; i++) {
            if (i <= T) sum0 += a[i];
            else break; 
        }
        ans = min(ans, abs(sum[n] - sum0 - sum0));
    //    printf("%d\n", ans);
    }
    printf("%d\n", ans);
    return 0;
}

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

using namespace std;

int N, K, h[100000];
int dp[100000];

int main(){
	cin >> N >> K;
	for(int i = 0; i < N; ++i) cin >> h[i];

	for(int i = 0; i < N; ++i) dp[i] = INT_MAX;
	dp[0] = 0;

	for(int i = 1; i < N; ++i){
		for(int j = i - K; j < i; ++j){
			if(j >= 0){
				dp[i] = min(dp[i], dp[j]+abs(h[j]-h[i]));
			}
		}
	}

	cout << dp[N-1] << endl;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define fi first
#define se second
#define pb push_back
#define rep(i, s, n) for (int i = s; i < n; i++)
#define rrep(i, s, n) for (int i = (n)-1; i >= (s); i--)
#define all(a) a.begin(),a.end()
typedef pair<int,int>pint;
typedef vector<int>vint;
typedef vector<pint>vpint;
const long long MOD = 1000000007, INF = 1e18;
template<class T>inline bool chmax(T& a,T b){if(a<b){a=b;return true;}return false;}
template<class T>inline bool chmin(T& a,T b){if(a>b){a=b;return true;}return false;}
string get_str(string s) {
	s+=',';
	string ret="";
	for(int i=0; i<s.size(); i++) {
		if(s[i]==',') ret+="=%ld, ";
		else ret+=s[i];
	}
	return ret;
}
#define dump(...) printf(get_str(#__VA_ARGS__).c_str(),__VA_ARGS__);cout<<endl
 
#define endl '\n'
#define IOS()                     \
	ios_base::sync_with_stdio(0); \
	cin.tie(0)
 
//******************************************************************************
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,typename V>
typename enable_if<is_class<T>::value==0>::type
fill_v(T &t,const V &v){t=v;}
 
template<typename T,typename V>
typename enable_if<is_class<T>::value!=0>::type
fill_v(T &t,const V &v){
	for(auto &e:t) fill_v(e,v);
}
 
 
#define P2 pair<int,pair<int,int>>
signed main()
{
	//IOS();
	int H,W;
	cin>>H>>W;
	auto s = make_v<char>(H,W);
	auto dist = make_v<int>(H,W);
	fill_v(dist,INF);
	queue<P2>que;
	for(int i = 0;i < H;i++){
		for(int j = 0;j < W;j++){
			cin>>s[i][j];
			if(s[i][j]=='#'){
				que.push({0,{i,j}});
				dist[i][j]=0;
			}
		}
	}

	int dy[]={1,0,-1,0};
	int dx[]={0,-1,0,1};
	while(!que.empty()){
		int i = que.front().se.fi;
		int j = que.front().se.se;
		int cost = que.front().fi;
		que.pop();
		if(dist[i][j]!=cost)continue;
		rep(k,0,4){
			int ni = i + dy[k];
			int nj = j + dx[k];
			if(ni<0||H<=ni||nj<0||W<=nj)continue;
			if(dist[ni][nj]<=cost+1)continue;
			dist[ni][nj]=cost+1;
			que.push({cost+1,{ni,nj}});
		}
	}
	int ans = 0;
	for(int i = 0;i < H;i++){
		for(int j = 0;j < W;j++){
			//cout<<dist[i][j]<<endl;
			chmax(ans,dist[i][j]);
		}
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 33332
#include<iostream>
typedef long long ll;
using namespace std;

ll luc(int n){
    ll L[87];
    L[0] = 2;
    L[1] = 1;
    int i=2;
    while(i<=n){
        L[i]=L[i-1]+L[i-2];
        i++;
    }
    return L[n];
}

int main(){
    int N;
    cin >> N;
    ll ans = luc(N);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
A,B,C = map(int,input().split())

def check(A,B,C):
    cnt = 0
    for i in range(1,B+1):
        if (A*i)%B==C:
            cnt =1
    if cnt==0:
        print("NO")
    else:
        print("YES")

check(A,B,C)

Measured memory_bytes: 3060
# include "bits/stdc++.h"
using namespace std;
using LL = long long;
using ULL = unsigned long long;
const double PI = acos(-1);
template<class T>constexpr T INF() { return ::std::numeric_limits<T>::max(); }
template<class T>constexpr T HINF() { return INF<T>() / 2; }
template <typename T_char>T_char TL(T_char cX) { return tolower(cX); };
template <typename T_char>T_char TU(T_char cX) { return toupper(cX); };
typedef pair<LL, LL> pii;
const int vy[] = { -1, -1, -1, 0, 1, 1, 1, 0 }, vx[] = { -1, 0, 1, 1, 1, 0, -1, -1 };
const int dx[4] = { 0,1,0,-1 }, dy[4] = { 1,0,-1,0 };
int popcnt(unsigned long long n) { int cnt = 0; for (int i = 0; i < 64; i++)if ((n >> i) & 1)cnt++; return cnt; }
int d_sum(LL n) { int ret = 0; while (n > 0) { ret += n % 10; n /= 10; }return ret; }
int d_cnt(LL n) { int ret = 0; while (n > 0) { ret++; n /= 10; }return ret; }
LL gcd(LL a, LL b) { if (b == 0)return a; return gcd(b, a%b); };
LL lcm(LL a, LL b) { LL g = gcd(a, b); return a / g*b; };
# define ALL(qpqpq)           (qpqpq).begin(),(qpqpq).end()
# define UNIQUE(wpwpw)        sort(ALL((wpwpw)));(wpwpw).erase(unique(ALL((wpwpw))),(wpwpw).end())
# define LOWER(epepe)         transform(ALL((epepe)),(epepe).begin(),TL<char>)
# define UPPER(rprpr)         transform(ALL((rprpr)),(rprpr).begin(),TU<char>)
# define FOR(i,tptpt,ypypy)   for(LL i=(tptpt);i<(ypypy);i++)
# define REP(i,upupu)         FOR(i,0,upupu)
# define INIT                 std::ios::sync_with_stdio(false);std::cin.tie(0)

int n,h,w;

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

Measured memory_bytes: 892
#include <iostream>
#include <sstream>
#include <queue>
#include <map>
#include <set>
#include <vector>
#include <numeric>
#include <algorithm>
#include <string>
#include <complex>
 
#include <cassert>
#include <cstdlib>
#include <cmath>
#include <cstdio>
#include <cstring>
 
#define REP(i,e) for(int i=0;i<(int)(e);i++)
#define FOR(i,b,e) for(int i=(int)(b);i<(int)(e);i++)
#define ALL(c) (c).begin(), (c).end()
#define EACH(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();++it)
#define RALL(c) (c).rbegin(), (c).rend()
#define ALLA(a,n) ((a)+0), ((a)+n)
 
using namespace std;
 
typedef long long ll;
typedef vector<int> vint;
typedef vector<long long> vll;
typedef vector<string> vstring;
typedef vector<double> vdouble;
 
template<class T>void pp(T v,int n){ REP(i,n)cout<<v[i]<< ' ' ; cout << endl; }
template<class T>void pp(T v){ EACH(it,v) cout << *it << ' ' ; cout << endl;  }
template<class T>T& ls(T& a,T b){ if(b<a) a=b; return a; }
template<class T>T& gs(T& a,T b){ if(b>a) a=b; return a; }
inline ll to_i(const string& s){ll n;sscanf(s.c_str(),"%lld",&n);return n;}
inline string to_s(ll n){char buf[32];sprintf(buf,"%lld",n);return string(buf);}

ll calc(const vint &v, int a, int b, int c) {
  deque<int> qu(ALL(v));
  vint u;
  REP(i,a) if (qu.size()) {
    u.push_back(qu.front());
    qu.pop_front();
  }
  REP(i,b) if (qu.size()) {
    u.push_back(qu.back());
    qu.pop_back();
  }
  sort(RALL(u));
  REP(i,c) if (u.size() && u.back() < 0) u.pop_back();
  return accumulate(ALL(u), 0LL);
}

int main() {
  int n, k;
  while (cin >> n >> k && n) {
    vint v(n);
    REP(i,n) cin >> v[i];
    ll result = 0;
    REP(a,k+1) REP(b,k+1) {
      int c = k - a - b;
      if (c < 0) continue;
      gs(result, calc(v, a, b, c));
    }

    cout << result << endl;
  }
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<algorithm>
using namespace std;
const int N=100005;
int n;
int a[N],b[N];
long long suma,sumb;
long long sum[N];
int c[N<<1],cnt;
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
	{
		scanf("%d%d",&a[i],&b[i]);
		c[++cnt]=a[i],c[++cnt]=b[i];
		suma+=a[i],sumb+=b[i];
	}
	sort(c+1,c+cnt+1);
	for(int i=1;i<=n;i++)
		sum[i]=sum[i-1]+c[i];
	long long ans=min(suma,sumb);
	for(int i=1;i<=n;i++)
	{
		long long x=a[i],y=b[i];
		if(x>y) swap(x,y);
		if(lower_bound(c+1,c+cnt+1,x)-c<=n-2)
  		{
   			if(lower_bound(c+1,c+cnt+1,y)-c<=n-1) ans=min(ans,sum[n]);
   			else ans=min(ans,y+sum[n-1]);
  		}
  		else ans=min(ans,x+y+sum[n-2]);
	}
	printf("%lld",ans);
	return 0;
}

Measured memory_bytes: 2560
#include<iostream>
using namespace std;
#include<string>
#include<utility>
#include<algorithm>
#include<vector>
#include<math.h>
#include<bits/stdc++.h>
#include<stdio.h>
 
int main(){
    int M_1,D_1,M_2,D_2;
    cin >> M_1 >> D_1 >> M_2 >> D_2;
    if(M_1==M_2){
        cout << 0;
    }
    else{
        cout << 1;
    }
}

Measured memory_bytes: 256
fun main(args:Array<String>){
    val input = readLine()!!.split(" ")
    val x1 = input[0].toInt()
    val y1 = input[1].toInt()
    val x2 = input[2].toInt()
    val y2 = input[3].toInt()

    println("${x2-(y2-y1)} ${y2+(x2-x1)} ${x1-(y2-y1)} ${y1+(x2-x1)}")
}

Measured memory_bytes: 37924
#include<stdio.h>

int main(void)
{
  int a, b, i;
  
  scanf("%d %d", &a, &b);
  if(a > b){
    for(i=0; i<a; i++){
      printf("%d", b);
    }
  }else{
    for(i=0; i<b; i++){
      printf("%d", a);
    }
  }
  
  return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <sstream>
#include <algorithm>
#include <functional>
#include <iterator>
#include <bitset>
#include <string>
#include <list>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>

typedef   signed long long int slli;
typedef unsigned long long int ulli;
const slli MAX_SLLI = 0x7FFFFFFFFFFFFFFF;
const slli MIN_SLLI = 0x8000000000000000;
const ulli MAX_ULLI = 0xFFFFFFFFFFFFFFFF;
const ulli MIN_ULLI = 0x0000000000000000;

#define N_TIMES(i, n)     for (ulli i = 0;     i <  n; ++i)
#define N_TIMES_REV(i, n) for (slli i = n - 1; i >= 0; --i)

#ifdef __DEBUG__
template<typename T>
std::ostream& operator<<(std::ostream &os, const std::list<T> &list)
{
  const std::string delim = ", ";
  typename std::list<T>::const_iterator itr = list.begin();
  while (itr != list.end()) {
    os << *itr;
    ++itr;
    if(itr != list.end()) os << delim;
  }
  return os;
}

template<typename T>
std::ostream& operator<<(std::ostream &os, const std::vector<T> &v)
{
  const std::string delim = ", ";
  for (unsigned n = 0; n < v.size(); ++n) {
    os << v[n];
    if((n + 1) < v.size()) os << delim;
  }
  return os;
}
#endif /* __DEBUG__ */

const ulli MOD = 1e+9 + 7;

std::vector<ulli> fact_cache;

void init_fact_cache(ulli S)
{
  fact_cache = std::vector<ulli>(S + 1);
  
  fact_cache[0] = 1;
  
  for (ulli i = 1; i <= S; ++i) {
    fact_cache[i] = (i * fact_cache[i - 1]) % MOD;
  }
}

int main()
{
  ulli N, M;
  std::cin >> N >> M;
  
  init_fact_cache(std::max(N, M) + 10);
  
  ulli S = 0;
  
  if (N == M) {
    S = (fact_cache[N] * fact_cache[N]) % MOD;
    S = (S * 2) % MOD;
  } else if (N == M + 1) {
    S = (fact_cache[N] * fact_cache[M]) % MOD;
  } else if (M == N + 1) {
    S = (fact_cache[N] * fact_cache[M]) % MOD;
  } else {
    S = 0;
  }
  
  std::cout << S << std::endl;
  
  return 0;
}

Measured memory_bytes: 1024
/* imports all std modules {{{*/
import
  std.algorithm,
  std.array,
  std.ascii,
  std.base64,
  std.bigint,
  std.bitmanip,
  std.compiler,
  std.complex,
  std.concurrency,
  std.container,
  std.conv,
  std.csv,
  std.datetime,
  std.demangle,
  std.encoding,
  std.exception,
  std.file,
  std.format,
  std.functional,
  std.getopt,
  std.json,
  std.math,
  std.mathspecial,
  std.meta,
  std.mmfile,
  std.net.curl,
  std.net.isemail,
  std.numeric,
  std.parallelism,
  std.path,
  std.process,
  std.random,
  std.range,
  std.regex,
  std.signals,
  std.socket,
  std.stdint,
  std.stdio,
  std.string,
  std.system,
  std.traits,
  std.typecons,
  std.uni,
  std.uri,
  std.utf,
  std.uuid,
  std.variant,
  std.zip,
  std.zlib;
/*}}}*/

/+---test
2 16
---+/
/+---test
0 3
---+/
/+---test
998244353 99824435
---+/

void main(string[] args) {
  int A, B;
  readf(" %d %d ", &A, &B);

  const K = (A+B)/2;
  if (abs(A-K) != abs(B-K)) {
    "IMPOSSIBLE".writeln;
  } else {
    K.writeln;
  }
}


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

#define lli long long
#define FOR(i,a,b) for (lli i=(a);i<(b);i++)
#define REP(i,n) for (lli i=0;i<(n);i++)
#define rep(i,n) for (lli i=0;i<(n);i++)

#define INF LONG_MAX/3
#define PB push_back
#define pb push_back
#define all(a) (a).begin(),(a),end()
#define pll pair<lli,lli>

int main(){
  lli N,K,X,Y;

  cin>>N>>K>>X>>Y;

  cout<<min(K,N)*X+max(N-K,(long long)0)*Y<<endl;

  
  return 0;
}


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

class State
{
public:
  int index, op, cost;
  string s;
  State(int _index, int _op, int _cost, string _s)
    :index(_index), op(_op), cost(_cost), s(_s) {}
};

int main()
{
  string s;
  queue<State> que;
  map<string, int> memo;
  que.push(State(0, -1, 0, "01234567"));
  while (!que.empty()) {
    const State st = que.front();
    que.pop();
    
    if (memo.find(st.s) != memo.end())
      continue;
    
    memo[st.s] = st.cost;
    if (st.index != 3 && st.index != 7 && st.op != 2) {
      s = st.s;
      swap(s[st.index], s[st.index+1]);
      if (memo.find(s) == memo.end())
	que.push(State(st.index+1, 0, st.cost+1, s));
    }
    
    if (st.index != 0 && st.index != 4 && st.op != 0) {
      s = st.s;
      swap(s[st.index], s[st.index-1]);
      if (memo.find(s) == memo.end())
	que.push(State(st.index-1, 2, st.cost+1, s));
    }
    
    if (st.index < 4 && st.op != 1) {
      s = st.s;
      swap(s[st.index], s[st.index+4]);
      if (memo.find(s) == memo.end())
	que.push(State(st.index+4, 3, st.cost+1, s));
    }

    if (st.index > 3 && st.op != 3) {
      s = st.s;
      swap(s[st.index], s[st.index-4]);
      if (memo.find(s) == memo.end())
	que.push(State(st.index-4, 1, st.cost+1, s));
      }
  }
  
  size_t p;
  while (getline(cin, s)) {
    while ((p = s.find_first_of(" \r\n")) != string::npos) {
      s.erase(s.begin()+p);
    }
    cout << memo.find(s)->second << endl;
  }
  return 0;
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
#include <iterator>
#include <iostream>
#include <numeric>
#include <math.h>
#define ll long long
#define ull long
#define mpa make_pair
#define pb push_back
#define ff first
#define pii pair<ll,ll>
#define dd long long
#define trace(x) cerr << #x << " : " << x << endl
#define ss second
#define boost ios_base::sync_with_stdio(0)
#define forp(i,a,b) for(ll i=a;i<=b;i++)
#define rep(i,n)    for(ll i=0;i<n;++i)
#define ren(i,n)    for(ll i=n-1;i>=0;i--)
#define forn(i,a,b) for(ll i=a;i>=b;i--)
#define all(c) (c).begin(),(c).end()
#define tr(c,i) for(typeof((c).begin()) i = (c).begin(); i != (c).end();
#define sc(x) scanf("%lld",&x)
#define clr(x,val) memset(x,val,sizeof(x))
#define pr(x) printf("%lld\n",x) 
#define gc getchar
#define pdd pair<dd,dd>
#define prec(x) cout<<fixed<<setprecision(x)
#define fre freopen("input.txt","r",stdin),freopen("output.txt","w",stdout)
#define ar array 
using namespace std;
 ar<ll,2> dice[200005];
int main(){
  ll n;
  cin>>n;
  for(ll i=1;i<=n;i++)cin>>dice[i][0]>>dice[i][1];
  
  ll ans=0;
  for(ll i=1;i<=n-2;i++){
  	  if(dice[i][0]==dice[i][1] && dice[i+1][0]==dice[i+1][1] && dice[i+2][0]==dice[i+2][1])ans++;
  }
  if(ans)cout<<"Yes";
  else cout<<"No";
    
    
    
    
    
	
   
}
  

Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define REP(i,m,n) for(int i=(int)(m); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define RREP(i,m,n) for(int i=(int)(m); i>=(int)(n); i--)
#define rrep(i,n) RREP(i,n-1,0)
#define REPL(i,m,n) for(ll i=(ll)(m); i<(ll)(n); i++)
#define repl(i,n) REPL(i,0,n)
#define all(v) v.begin(), v.end()
const int inf = 1e9+7;
const ll longinf = 1LL<<60;
const ll mod = 1e9+7;
void find_divisor(ll N, vector<ll>& divisor) {
  for(int i=1; i<=sqrt(N); i++) {
    if(N % i == 0)
      divisor.push_back(i);
  }
  int n = divisor.size();
  for(int i=n-1; i>=0; i--) {
    if(N != (ll)pow(divisor[i], 2))
      divisor.push_back(N / divisor[i]);
  }
}
int main() {
  ll N;
  cin >> N;
  vector<ll> divisor1, divisor2;
  find_divisor(N, divisor1);
  find_divisor(N-1, divisor2);
  set<ll> se, ans;
  ans.insert(N);
  for(auto d: divisor1) se.insert(d);
  for(auto d: divisor2) if(d != 1) ans.insert(d);
  for(auto d: divisor1) {
    ll n = N;
    if(d == 1) continue;
    while(n % d == 0) n /= d;
    if(n % d == 1) ans.insert(d);
  }
  cout << ans.size() << endl;
  return 0;
}


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

template<class Type> inline bool chmax(Type& a, Type b) { if (a < b) { a = b; return 1; } return 0; }
template<class Type> inline bool chmin(Type& a, Type b) { if (a > b) { a = b; return 1; } return 0; }

template<class Type>
Type modpow(Type a, Type n, Type mod)
{
	Type res = 1;
	while (0 < n)
	{
		if (n & 1)
		{
			res = res * a % mod;
		}
		a = a * a % mod;
		n >>= 1;
	}
	return res;
}

template<class Type>
Type gcd(Type x, Type y)
{
	Type r;
	if (x < y)
	{
		swap(x, y);
	}

	while (0 < y)
	{
		r = x % y;
		x = y;
		y = r;
	}
	return x;
}

template<class Type>
Type lcm(Type x, Type y)
{
	return x * y / gcd(x, y);
}

template<class Type>
bool isPrime(Type x)
{
	if (x == 2) return true;
	if (x < 2 || x % 2 == 0) return false;

	for (Type i = 3; i <= sqrt(x); i += 2)
	{
		if (x % i == 0) return false;
	}
	return true;
}

template<class Type>
vector<bool> eratos(Type n)
{
	vector<bool> isPrime(n + 1, true);
	isPrime[0] = isPrime[1] = false;
	for (Type i = 2; i <= n; i++)
	{
		if (isPrime[i])
		{
			Type j = i + i;
			while (j <= n)
			{
				isPrime[j] = false;
				j = j + i;
			}
		}
	}
	return isPrime;
}

bool binarySearchJudge(vector<int> a, int index, int key)
{
	if (key <= a[index]) return true;
	else return false;
}

int binarySearch(vector<int> a, int key)
{
	int ng = -1;
	int ok = a.size();
	while (1 < abs(ng - ok))
	{
		int mid = (ng + ok) / 2;
		if (binarySearchJudge(a, mid, key)) ok = mid;
		else ng = mid;
	}
	return a[ok] == key;
}

int main()
{
	char c;
	cin >> c;
	cout << (char)(c + 1) << endl;
}

Measured memory_bytes: 256
A,B,C,D = map(int,input().split())
from fractions import gcd
CD = C*D//gcd(C,D)
A_count = A - 1 - (A-1)//C - (A-1)//D + (A-1)//CD
B_count = B - B//C - B//D + B//CD
print(B_count-A_count)

Measured memory_bytes: 63980
package main

import (
	"fmt"
	"math"
)

func main() {
	var x, y, m, n, d int
	fmt.Scanf("%d %d", &x, &y)
	m = int(math.Max(float64(x), float64(y)))
	n = int(math.Min(float64(x), float64(y)))

	for ; n != 0; {
		d = m % n //あまり
		m = n //m <- n
		n = d // n <- あまり
	}
	fmt.Printf("%d\n", m)
}



Measured memory_bytes: 1160
#include <iostream>//cout<<right で右揃え
#include <iomanip>//cout<<setw(数字) で空白による桁揃え
#include <string>
#include <vector>
#include <queue>
#include <algorithm>
#include <cstdlib>//abs()で整数絶対値
#include <cmath>//abs()かfabs()で少数絶対値
#include <functional>//sort第三引数greater<型名>()で降順

using namespace std;
using ll = long long int;

int main(){
    int A,B,C,D;cin>>A>>B>>C>>D;
    while(1){
        C -= B;
        if(C<=0){
            cout << "Yes" << endl;
            break;
        }else{
            A -= D;
            if(A<=0){
                cout << "No" << endl;
                break;
            }
        }
    }
}

Measured memory_bytes: 3632
INF = float('inf')
n, ma, mb = map(int, input().split())
cmax = n * 10
t = [[INF] * (cmax + 1) for _ in range(cmax + 1)]
for _ in range(n):
  a, b, c = map(int, input().split())
  for aa in range(cmax, 0, -1):
    for bb in range(cmax, 0, -1):
      if t[aa][bb] == INF:
        continue
      t[aa + a][bb + b] = min(t[aa + a][bb + b], t[aa][bb] + c)
  t[a][b] = min(t[a][b], c)
result = INF
for a in range(1, cmax):
  for b in range(1, cmax):
    if a * mb == b * ma:
      result = min(result, t[a][b])
if result == INF:
  result = -1
print(result)


Measured memory_bytes: 4848
#pragma target("avx")
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef unordered_map<ll, ll> U_MAP;
typedef priority_queue<ll> pq;
typedef priority_queue<ll, vector<ll>, greater<ll>> rpq;
constexpr ll INF = 1e9, MOD = 1e9 + 7, ohara = 1e6 + 10;
constexpr ll LINF = 1e18;

#define rep(i, n) for (ll(i) = 0; (i) < (int)(n); (i)++)
#define rrep(i, a, b) for (ll i = (a); i < (b); i++)
#define rrrep(i, a, b) for (ll i = (a); i >= (b); i--)
#define all(v) (v).begin(), (v).end()
#define Size(n) (n).size()
#define Cout(x) cout << (x) << endl
#define doublecout(a) cout << fixed << setprecision(15) << a << endl;
#define fi first
#define se second
#define m_p make_pair
#define p_b push_back
string to_string(string s) { return '"' + s + '"'; }
string to_string(const char* s) { return to_string((string)s); }
string to_string(bool b) { return (b ? "true" : "false"); }
template <typename A, typename B>
string to_string(pair<A, B> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}
template <typename A>
string to_string(A v) {
  bool first = true;
  string res = "{";
  for (const auto& x : v) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(x);
  }
  res += "}";
  return res;
}
void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)

//------ Believe yourself as a genius!!!!!! ------

int dy[] = {1, 0, -1, 0};
int dx[] = {0, 1, 0, -1};
// int dy[]={-1,0,1,-1,1,-1,0,1};int dx[]={-1,-1,-1,0,0,1,1,1};
string alph("abcdefghijklmnopqrstuvwxyz"), s;
ll n, cnt, ans, a[ohara], b, c, d, tmp, m, h, w, x, y, sum, k, q;
U_MAP mp;

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

  cin >> n;
  rep(i, n) {
    cin >> a[i];
    ans += a[i];
    mp[a[i]]++;
  }
  cin >> q;
  while (q--) {
    cin >> b >> c;
    ans -= mp[b] * b;
    mp[c] += mp[b];
    ans += mp[b] * c;
    mp[b] = 0;
    Cout(ans);
  }
  return 0;
}

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

using namespace std;
int main() {
  string s, t;
  cin >> s >> t;

  int hit;
  for (int i = 0; i < 3; i++) {
    if (s[i] == t[i]) hit++;
  }
  cout << hit << endl;

  return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int main()
{
  int n,m,l,i,j,k;
  double sum;
  scanf("%d %d %d",&n,&m,&l);
  int a[n][m],b[m][l];
  double out[n][l];
  for(i=0;i<n;i++)
    for(j=0;j<m;j++)
      scanf("%d",&a[i][j]);

  for(i=0;i<m;i++)
    for(j=0;j<l;j++)
      scanf("%d",&b[i][j]);

  sum=0;

  for(i=0;i<n;i++){
    for(j=0;j<l;j++){
        for(k=0;k<m;k++)  sum+=(double)a[i][k]*b[k][j];

        out[i][j]=sum;
        sum=0;
    }
  }
  for(i=0;i<n;i++){
    for(j=0;j<l;j++) {
      printf("%.0lf",out[i][j]);
      if(j<l-1) printf(" ");
    }
    printf("\n");
  }

  return 0;

}

Measured memory_bytes: 792
import std.stdio, std.string, std.conv, std.algorithm;

void main(){

  int n, m, q; rd(n, m, q);
  auto cul=new int[][](n+1, n+1);
  foreach(_; 0..m){
    int l, r; rd(l, r);
    cul[l][r]++;
  }
  for(int i=1; i<=n; i++){
    foreach(j; 0..n) cul[i][j+1]+=cul[i][j];
  }
  while(q--){
    int l, r; rd(l, r);
    int num=0;
    for(int i=l; i<=r; i++){
      num+=cul[i][r]-cul[i][i-1];
    }
    writeln(num);
  }

}

void rd(T...)(ref T x){
  import std.stdio, std.string, std.conv;
  auto l=readln.split;
  assert(l.length==x.length);
  foreach(i, ref e; x) e=l[i].to!(typeof(e));
}


Measured memory_bytes: 9340
n,k=map(int,input().split())
S=input()
One,Zero=[],[]
cnt1,cnt0=0,0
for s in S:
    if s=='1':
        cnt1+=1
        if cnt0:
            Zero.append(cnt0)
            cnt0=0
    else:
        cnt0+=1
        if cnt1:
            One.append(cnt1)
            cnt1=0
if cnt1:
    One.append(cnt1)
if cnt0:
    Zero.append(cnt0)
if S[0]=='0':
    One=[0]+One
if S[-1]=='0':
    One=One+[0]
l=len(Zero)
if k>=l:
    ans=n
else:
    ans=sum(One[:k+1]+Zero[:k])
    prev=ans
    for i in range(l-k):
        tmp=prev-One[i]+One[i+k+1]-Zero[i]+Zero[i+k]
        ans=max(ans,tmp)
        prev=tmp
print(ans)

Measured memory_bytes: 46576
#include<stdio.h>
#define N 200000000

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

        maxHeapify(largest);
      }
}

int main(){
  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: 3692
N,M,C = list(map(int, input().split(' ')))
B= list(map(int, input().split(' ')))
i=0
for j in range(N):
    ab=0
    A= list(map(int, input().split(' ')))
    for a, b in zip(A,B):
        ab+=a*b
    if ab+C>0:
        i+=1
print(i)

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


int main(){
  string S, T;
  cin >> S >> T;
  int len = S.size();
  for(int ii=0; ii<len; ii++){
    if(S.substr(ii, len-ii) + S.substr(0, ii) == T){
      cout << "Yes" << endl;
      return 0;
    }
  }
  cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <cassert>
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <map>

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR (i, 0, n)
#define _ << " _ " <<
#define TRACE(x) cerr << #x << " = " << x << endl
#define debug(...) fprintf(stderr, __VA_ARGS__)
//#define debug
//#define TRACE(x)

using namespace std;

typedef long long llint;

const int MAXN = 100010;

int n, a[MAXN], b[MAXN], sol;
map<int, int> pos;

int main(void) {
  scanf("%d",&n);
  REP(i, n) {
    scanf("%d",&a[i]);
    pos[a[i]] = i;
    b[i] = a[i];
  }
  sort(b, b + n);

  REP(i, n)
    if (pos[b[i]] % 2 != i % 2) 
      ++sol;

  printf("%d\n",sol/2);
  
  return 0;
}


Measured memory_bytes: 5760
//  0019.cpp

#include <cstdio>
#include <cmath>

using namespace std;


int main(){
    long long int n,a=1;
    
    scanf("%lld",&n);
    
    for(int i=1;i<=n;i++)
        a *= i;
    
    printf("%lld\n",a);
    
    
    return 0;
}

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

using namespace std;
long long euclid(long long n,long long m){
	if(n%m==0){
		return m;
	}

	return euclid(m,n%m);
}

int main() {
    long long a, b, c, d;
	long long cnt=0,cnt2=0;
    cin >> a >> b >> c >> d;
	long long g = euclid(c,d);
	long long l = (c*d)/g;
	cnt = b;
	cnt -=b/c;
	cnt -=b/d;
	cnt += b/l;
	
	a --;
	cnt2 = a;  
	cnt2 -=a/c;
	cnt2 -=a/d;
	cnt2 += a/l;

	cout << cnt-cnt2<< endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, s, e) for (int i = (int)(s); i <= (int)(e); i++)
#define printYesNo(is_ok) puts(is_ok ? "Yes" : "No");
#define SORT(v) sort(v.begin(), v.end());
#define RSORT(v) sort(v.rbegin(), v.rend());
#define REVERSE(v) reverse(v.begin(), v.end());

template <typename T>
void printlnVector(T v)
{
  rep(i, v.size())
  {
    cout << v[i] << endl;
  }
}

template <typename T>
void printVector(T v)
{
  rep(i, v.size())
  {
    cout << v[i] << " ";
  }
  cout << endl;
}

int H, W;
bool is_ok(vector<string> field)
{
  stack<pair<int, int>> pos_stack;
  pos_stack.push(make_pair(0, 0));
  int dirx[] = {1, 0};
  int diry[] = {0, 1};
  field[0][0] = 'o';
  while (pos_stack.size())
  {
    pair<int, int> pos = pos_stack.top();
    pos_stack.pop();
    int pos_x = pos.first;
    int pos_y = pos.second;

    rep(i, 2)
    {
      int next_x = pos_x + dirx[i];
      int next_y = pos_y + diry[i];

      if (0 <= next_x && next_x < H + 1 && 0 <= next_y && next_y < W + 1 && field[next_x][next_y] == '#')
      {
        field[next_x][next_y] = 'o';
        pos_stack.push(make_pair(next_x, next_y));
        break;
      }
    }
  }

  rep(i, H) rep(j, W)
  {
    if (field[i][j] == '#')
      return false;
  }
  return true;
}

int main()
{
  cin >> H >> W;
  vector<string> A(H);
  rep(i, H)
  {
    cin >> A[i];
  }
  A.push_back(string(W, '.'));
  if (is_ok(A))
    cout << "Possible" << endl;
  else
    cout << "Impossible" << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
struct Fast {Fast() {std::cin.tie(0); ios::sync_with_stdio(false);}} fast;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using pii = pair<int, int>;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define MOD 1000000007


int main() {
  int N, X;
  cin >> N >> X;
  vi L(N);
  rep(i, N) cin >> L[i];
  vi D(N + 1, 0);
  int counter = 1;
  rep(i, N) {
    D[i + 1] = D[i] + L[i];
    if (D[i + 1] <= X) counter ++;
    else break;
  }

  cout << counter << endl;
}



Measured memory_bytes: 256
//   _/                _/                 _/_/_/   _/
//_/_/_/_/   _/_/   _/_/_/_/   _/_/    _/       _/_/
// _/     _/    _/   _/     _/    _/  _/_/_/     _/
//_/     _/    _/   _/     _/    _/  _/    _/   _/
// _/_/   _/_/       _/_/   _/_/      _/_/     _/
#include<iostream>
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<set>
#include<map>
#include<queue>
#include<vector>
using namespace std;
typedef long long ll;
const int MOD=1e9+7;
const double pi=3.14159265358979323846;
const int inf=1e9;
const ll INF=1e18;
typedef pair<int,int> P;
int main() {
  cin.tie(0),cout.tie(0);
  ios::sync_with_stdio(false);
  ll n,p[200005]={},ans=0,M=1e9;
  cin >> n;
  for(int i=0; i<n; i++) {
    cin >> p[i];
    M=min(M,p[i]);
    if(p[i]<=M) {
      ans++;
    }
  }
  cout << ans << endl;
}


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

using namespace std;
typedef unsigned long long ull;
int n,m,k,ans;
char _map[11][11],temp[11][11],kk[11][11];
void copy(){for(int i=1; i<=n; i++) for(int j=1; j<=m; j++) temp[i][j] = kk[i][j];}
void p(){for(int i=1; i<=n; i++) for(int j=1; j<=m; j++) kk[i][j] = _map[i][j];}
void turnp(int y){for(int i=1; i<=m; i++) kk[y][i]='r';}
void turntemp(int x){for(int i=1; i<=n; i++) temp[i][x]='r';}
int main(){
    ios_base::sync_with_stdio(0);cin.tie(nullptr);
    cin>>n>>m>>k;
    for(int i=1; i<=n; i++) for(int j=1; j<=m;j ++) cin>>_map[i][j];
    for(int i=0; i<=(1<<n)-1; i++){
        p();
        for(int check=0; check<n; check++) if(i&(1<<check)) turnp(check+1);
        for(int j=0; j<=(1<<m)-1; j++){
            copy();
            int cnt = 0;
            for(int check=0; check<m; check++) if(j&(1<<check)) turntemp(check+1);
            for(int i=1; i<=n; i++) for(int j=1; j<=m; j++) if(temp[i][j] == '#') cnt++;
            if(cnt == k) ans++;
        }
    }
    cout<<ans<<'\n';
}

Measured memory_bytes: 3580